From 5ff277349cb1b1cda27cf1b3b4d946e160643906 Mon Sep 17 00:00:00 2001 From: can1357 Date: Wed, 15 Jul 2026 15:16:29 +0200 Subject: [PATCH] refactor(coding-agent): consolidated tool surface onto xd:// devices and hub - Added the `xd://` virtual device protocol (`internal-urls/xd-protocol.ts`, `tools/xdev.ts`): tools declaring `loadMode: "discoverable"` are unmounted from the request tools array and driven via `read xd://` (list/docs+schema) and `write xd://` (execute), gated by the `tools.xdev` setting (default on) and inlined into the system prompt. - Merged the `irc`, `job`, and `launch` tools into a single `hub` tool (`tools/hub/`, `async/job-manager.ts`): messaging keeps `send`/`inbox`/`list`, job control maps to `wait`/`cancel`/`jobs`, process supervision keeps `start`/`logs`/`stop`/`restart`/`describe` with `ps`, and the unified `wait` races background jobs against peer messages; SDK `IrcTool`/`JobTool`/`LaunchTool` are replaced by `HubTool`. - Removed the hidden `resolve` tool in favor of the `xd://resolve`/`xd://reject`/`xd://propose` resolution devices, auto-including `write` whenever a deferrable tool or plan mode is present. - Removed the BM25 tool-discovery system: the `search_tool_bm25` tool, the `tool-discovery` module, the `tools.discoveryMode`/`mcp.discoveryMode`/`mcp.discoveryDefaultServers`/`tools.essentialOverride` settings, per-tool MCP selection, and the `mcp_tool_selection` message type. - Unified tool presentation on `ToolLoadMode` (`essential`|`discoverable`), replacing the custom-tool `xdev?: boolean` opt-out; custom, extension, MCP, RPC host, image-generation, and TTS tools now default to `discoverable`, and added a `satisfies` predicate to `SoftToolRequirement`. - Removed the standalone `ssh` command tool and `ssh/ssh-executor` (the `ssh://` read/write/search protocol stays), and made `--tools` address hidden built-ins. - Updated collab-web to render `xd://` dispatches and `hub` op families, dropped the `search_tool_bm25`/`ssh`/`report-finding` renderers, refreshed tool docs and prompts, and migrated the affected tests and changelogs. --- README.md | 8 +- docs/advisor-watchdog.md | 6 +- docs/compaction.md | 2 +- docs/custom-tools.md | 2 +- docs/resolve-tool-runtime.md | 156 +-- docs/session.md | 16 +- docs/settings.md | 3 - docs/task-agent-discovery.md | 2 +- docs/tools/ast-edit.md | 18 +- docs/tools/bash.md | 2 +- docs/tools/edit.md | 2 +- docs/tools/hub.md | 126 ++ docs/tools/irc.md | 100 -- docs/tools/job.md | 141 --- docs/tools/launch.md | 122 -- docs/tools/resolve.md | 90 -- docs/tools/search_tool_bm25.md | 118 -- docs/tools/ssh.md | 127 -- docs/tools/task.md | 18 +- packages/agent/CHANGELOG.md | 27 + packages/agent/src/agent-loop.ts | 5 +- .../src/compaction/branch-summarization.ts | 1 - packages/agent/src/compaction/entries.ts | 7 - packages/agent/src/types.ts | 22 +- .../agent/test/soft-tool-requirement.test.ts | 58 + packages/coding-agent/CHANGELOG.md | 24 +- packages/coding-agent/DEVELOPMENT.md | 4 +- packages/coding-agent/examples/sdk/README.md | 21 +- packages/coding-agent/package.json | 12 +- .../coding-agent/src/async/job-manager.ts | 4 +- packages/coding-agent/src/cli/args.ts | 4 +- .../src/cli/gallery-fixtures/agentic.ts | 54 +- .../src/cli/gallery-fixtures/misc.ts | 75 +- .../src/cli/gallery-fixtures/search.ts | 80 +- .../src/cli/gallery-fixtures/shell.ts | 11 +- .../src/cli/gallery-fixtures/types.ts | 2 +- .../src/config/settings-schema.ts | 72 +- packages/coding-agent/src/config/settings.ts | 38 - .../src/extensibility/custom-tools/types.ts | 3 + .../src/extensibility/custom-tools/wrapper.ts | 4 +- .../src/extensibility/extensions/types.ts | 3 + .../src/extensibility/extensions/wrapper.ts | 10 +- .../coding-agent/src/internal-urls/index.ts | 3 +- .../coding-agent/src/internal-urls/router.ts | 35 +- .../coding-agent/src/internal-urls/types.ts | 12 +- .../src/internal-urls/xd-protocol.ts | 46 + .../coding-agent/src/modes/acp/acp-agent.ts | 163 ++- .../components/chat-transcript-builder.ts | 14 +- .../src/modes/components/read-tool-group.ts | 21 +- .../src/modes/components/tool-execution.ts | 18 +- .../modes/controllers/command-controller.ts | 5 +- .../src/modes/controllers/event-controller.ts | 53 +- .../controllers/extension-ui-controller.ts | 4 +- .../controllers/mcp-command-controller.ts | 2 +- .../modes/controllers/selector-controller.ts | 3 +- .../controllers/ssh-command-controller.ts | 5 +- .../src/modes/controllers/tool-args-reveal.ts | 2 + .../src/modes/interactive-mode.ts | 99 +- .../coding-agent/src/modes/rpc/host-tools.ts | 4 +- .../coding-agent/src/modes/rpc/rpc-client.ts | 1 + .../coding-agent/src/modes/rpc/rpc-mode.ts | 2 +- .../coding-agent/src/modes/rpc/rpc-types.ts | 4 +- .../coding-agent/src/modes/runtime-init.ts | 2 +- .../src/modes/utils/tools-markdown.ts | 22 +- .../modes/utils/transcript-render-helpers.ts | 2 +- .../src/modes/utils/ui-helpers.ts | 20 +- .../src/plan-mode/approved-plan.ts | 10 +- .../src/prompts/goals/goal-todo-context.md | 8 - .../src/prompts/system/irc-incoming.md | 2 +- .../src/prompts/system/orchestrate-notice.md | 2 +- .../src/prompts/system/plan-mode-active.md | 14 +- .../plan-mode-tool-decision-reminder.md | 2 +- .../prompts/system/resolve-device-reminder.md | 3 + .../prompts/system/subagent-system-prompt.md | 8 +- .../src/prompts/system/system-prompt.md | 19 +- .../coding-agent/src/prompts/tools/bash.md | 13 +- .../coding-agent/src/prompts/tools/hub.md | 32 + .../coding-agent/src/prompts/tools/irc.md | 11 - .../coding-agent/src/prompts/tools/job.md | 11 - .../coding-agent/src/prompts/tools/launch.md | 25 - .../coding-agent/src/prompts/tools/resolve.md | 4 - .../src/prompts/tools/search-tool-bm25.md | 32 - .../coding-agent/src/prompts/tools/ssh.md | 23 - .../src/prompts/tools/task-summary.md | 2 +- .../src/registry/agent-registry.ts | 4 +- packages/coding-agent/src/sdk.ts | 309 +---- .../coding-agent/src/session/agent-session.ts | 742 +++--------- .../src/session/session-context.ts | 15 - .../src/session/session-entries.ts | 8 - .../src/session/session-manager.ts | 14 - .../src/session/tool-choice-queue.ts | 16 +- .../src/slash-commands/builtin-registry.ts | 11 +- .../src/slash-commands/helpers/ssh.ts | 5 +- packages/coding-agent/src/ssh/ssh-executor.ts | 178 --- packages/coding-agent/src/system-prompt.ts | 29 +- packages/coding-agent/src/task/executor.ts | 95 +- packages/coding-agent/src/task/index.ts | 35 +- .../coding-agent/src/task/persisted-revive.ts | 2 +- packages/coding-agent/src/task/render.ts | 59 +- .../coding-agent/src/tool-discovery/mode.ts | 24 - .../src/tool-discovery/tool-index.ts | 271 ----- packages/coding-agent/src/tools/bash.ts | 2 +- .../coding-agent/src/tools/builtin-names.ts | 16 +- packages/coding-agent/src/tools/grep.ts | 26 +- packages/coding-agent/src/tools/hub/index.ts | 576 +++++++++ packages/coding-agent/src/tools/hub/jobs.ts | 614 ++++++++++ packages/coding-agent/src/tools/hub/launch.ts | 561 +++++++++ .../coding-agent/src/tools/hub/messaging.ts | 722 +++++++++++ packages/coding-agent/src/tools/hub/types.ts | 115 ++ packages/coding-agent/src/tools/index.ts | 212 +--- packages/coding-agent/src/tools/irc.ts | 852 ------------- packages/coding-agent/src/tools/job.ts | 752 ------------ packages/coding-agent/src/tools/launch.ts | 643 ---------- packages/coding-agent/src/tools/read.ts | 21 +- packages/coding-agent/src/tools/renderers.ts | 26 +- .../src/tools/report-tool-issue.ts | 361 +++--- packages/coding-agent/src/tools/resolve.ts | 322 +++-- packages/coding-agent/src/tools/review.ts | 176 +-- .../src/tools/search-tool-bm25.ts | 351 ------ packages/coding-agent/src/tools/ssh.ts | 404 ------- packages/coding-agent/src/tools/write.ts | 123 +- packages/coding-agent/src/tools/xdev.ts | 362 ++++++ packages/coding-agent/src/vibe/runtime.ts | 4 +- packages/coding-agent/test/acp-agent.test.ts | 66 +- .../coding-agent/test/acp-builtins.test.ts | 2 - .../test/acp-lazy-startup.test.ts | 1 - .../test/agent-session-mcp-discovery.test.ts | 1072 ----------------- ...gent-session-plan-mode-convergence.test.ts | 48 +- .../agent-session-resolve-reminder.test.ts | 30 +- .../test/agent-session-ssh-refresh.test.ts | 240 ---- ...agent-session-tool-call-loop-guard.test.ts | 2 +- .../agent-session-tool-rebuild-skip.test.ts | 76 +- .../test/async-yield-queue.test.ts | 8 +- .../test/discovery/builtin-defaults.test.ts | 6 +- .../coding-agent/test/gallery-cli.test.ts | 6 +- .../test/goals/goal-mode-integration.test.ts | 66 - ...interactive-mode-default-plan-mode.test.ts | 19 +- .../test/issue-4348-repro.test.ts | 2 - .../test/job-poll-displacement.test.ts | 30 +- .../test/job-renderer-preview.test.ts | 62 +- .../test/job-tool-agent-roster.test.ts | 56 +- .../utils/render-initial-messages.test.ts | 2 - .../coding-agent/test/read-tool-group.test.ts | 30 +- .../sdk-generate-image-tool-gating.test.ts | 18 + .../test/sdk-mcp-auto-discovery.test.ts | 242 ---- .../test/sdk-mcp-discovery.test.ts | 514 -------- .../test/sdk-tool-activation.test.ts | 30 +- .../test/settings-manager.test.ts | 11 - .../test/ssh/ssh-executor.test.ts | 95 -- .../test/task/subagent-lsp.test.ts | 4 +- .../test/tool-discovery/initial-tools.test.ts | 192 --- .../test/tool-discovery/persistence.test.ts | 46 - .../test/tool-discovery/subagent.test.ts | 48 - .../test/tool-discovery/tool-index.test.ts | 311 ----- packages/coding-agent/test/tools.test.ts | 20 +- .../coding-agent/test/tools/ast-edit.test.ts | 4 +- .../coding-agent/test/tools/ast-grep.test.ts | 89 +- .../test/tools/bash-interceptor.test.ts | 8 +- .../test/tools/grep-path-lists.test.ts | 2 +- .../coding-agent/test/tools/hub-wait.test.ts | 112 ++ .../coding-agent/test/tools/index.test.ts | 101 +- .../test/tools/irc-renderer.test.ts | 54 +- .../test/tools/irc-roster-activity.test.ts | 4 +- packages/coding-agent/test/tools/irc.test.ts | 185 +-- .../test/tools/launch-renderer.test.ts | 22 +- .../provider-schema-compatibility.test.ts | 6 +- .../test/tools/report-tool-issue.test.ts | 58 +- .../coding-agent/test/tools/resolve.test.ts | 200 +-- .../coding-agent/test/tools/review.test.ts | 301 +---- .../test/tools/root-path-alias.test.ts | 2 +- .../test/tools/schema-validation.test.ts | 6 +- .../test/tools/search-tool-bm25.test.ts | 264 ---- .../test/tools/search-url-paths.test.ts | 9 +- .../test/tools/ssh-commit-stability.test.ts | 61 - .../test/tools/ssh-description.test.ts | 135 --- .../test/tools/ssh-render.test.ts | 106 -- .../write-streaming-preview-expand.test.ts | 2 + .../test/write-xdev-dispatch.test.ts | 108 ++ packages/collab-web/CHANGELOG.md | 9 + .../collab-web/src/tool-render/ToolView.tsx | 28 +- .../collab-web/src/tool-render/registry.ts | 15 +- .../collab-web/src/tool-render/tools/hub.tsx | 84 ++ .../src/tool-render/tools/report-finding.tsx | 54 - .../src/tool-render/tools/search-bm25.tsx | 118 -- .../collab-web/src/tool-render/tools/ssh.tsx | 104 -- packages/collab-web/test/tool-view.test.tsx | 31 + scripts/tool-prompt-usage.ts | 1 - 187 files changed, 5722 insertions(+), 11337 deletions(-) create mode 100644 docs/tools/hub.md delete mode 100644 docs/tools/irc.md delete mode 100644 docs/tools/job.md delete mode 100644 docs/tools/launch.md delete mode 100644 docs/tools/resolve.md delete mode 100644 docs/tools/search_tool_bm25.md delete mode 100644 docs/tools/ssh.md create mode 100644 packages/coding-agent/src/internal-urls/xd-protocol.ts create mode 100644 packages/coding-agent/src/prompts/system/resolve-device-reminder.md create mode 100644 packages/coding-agent/src/prompts/tools/hub.md delete mode 100644 packages/coding-agent/src/prompts/tools/irc.md delete mode 100644 packages/coding-agent/src/prompts/tools/job.md delete mode 100644 packages/coding-agent/src/prompts/tools/launch.md delete mode 100644 packages/coding-agent/src/prompts/tools/resolve.md delete mode 100644 packages/coding-agent/src/prompts/tools/search-tool-bm25.md delete mode 100644 packages/coding-agent/src/prompts/tools/ssh.md delete mode 100644 packages/coding-agent/src/ssh/ssh-executor.ts delete mode 100644 packages/coding-agent/src/tool-discovery/mode.ts delete mode 100644 packages/coding-agent/src/tool-discovery/tool-index.ts create mode 100644 packages/coding-agent/src/tools/hub/index.ts create mode 100644 packages/coding-agent/src/tools/hub/jobs.ts create mode 100644 packages/coding-agent/src/tools/hub/launch.ts create mode 100644 packages/coding-agent/src/tools/hub/messaging.ts create mode 100644 packages/coding-agent/src/tools/hub/types.ts delete mode 100644 packages/coding-agent/src/tools/irc.ts delete mode 100644 packages/coding-agent/src/tools/job.ts delete mode 100644 packages/coding-agent/src/tools/launch.ts delete mode 100644 packages/coding-agent/src/tools/search-tool-bm25.ts delete mode 100644 packages/coding-agent/src/tools/ssh.ts create mode 100644 packages/coding-agent/src/tools/xdev.ts delete mode 100644 packages/coding-agent/test/agent-session-mcp-discovery.test.ts delete mode 100644 packages/coding-agent/test/agent-session-ssh-refresh.test.ts delete mode 100644 packages/coding-agent/test/sdk-mcp-auto-discovery.test.ts delete mode 100644 packages/coding-agent/test/sdk-mcp-discovery.test.ts delete mode 100644 packages/coding-agent/test/ssh/ssh-executor.test.ts delete mode 100644 packages/coding-agent/test/tool-discovery/initial-tools.test.ts delete mode 100644 packages/coding-agent/test/tool-discovery/persistence.test.ts delete mode 100644 packages/coding-agent/test/tool-discovery/subagent.test.ts delete mode 100644 packages/coding-agent/test/tool-discovery/tool-index.test.ts create mode 100644 packages/coding-agent/test/tools/hub-wait.test.ts delete mode 100644 packages/coding-agent/test/tools/search-tool-bm25.test.ts delete mode 100644 packages/coding-agent/test/tools/ssh-commit-stability.test.ts delete mode 100644 packages/coding-agent/test/tools/ssh-description.test.ts delete mode 100644 packages/coding-agent/test/tools/ssh-render.test.ts create mode 100644 packages/coding-agent/test/write-xdev-dispatch.test.ts create mode 100644 packages/collab-web/src/tool-render/tools/hub.tsx delete mode 100644 packages/collab-web/src/tool-render/tools/report-finding.tsx delete mode 100644 packages/collab-web/src/tool-render/tools/search-bm25.tsx delete mode 100644 packages/collab-web/src/tool-render/tools/ssh.tsx create mode 100644 packages/collab-web/test/tool-view.test.tsx diff --git a/README.md b/README.md index a9d03c0f5..db1309caa 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ Stealth's on by default, so pages see a normal user instead of a headless bot. T ## Whatever the task needs, _it's already in the box_. -32 tools live in the same namespace as `read` and `bash`. Pin the active set with `--tools read,edit,bash,…` and the rest stay hidden but indexed — `search_tool_bm25` pulls them back in mid-session when `tools.discoveryMode` says so. +32 tools live in the same namespace as `read` and `bash`. Pin the active set with `--tools read,edit,bash,…`; rarely used discoverable tools stay behind `xd://` devices. `read xd://` lists them, and `write xd://` runs one when `tools.xdev` is enabled. **Files & search** @@ -245,9 +245,8 @@ Stealth's on by default, so pages see a normal user instead of a headless bot. T **Coordination** - `task` — fan out subagents in parallel, optionally workspace-isolated. -- `irc` — short prose between live agents in this process. +- `hub` — message live agents, wait on or cancel background jobs, and supervise long-running processes. - `todo` — ordered mutations over the session todo list with phase tracking. -- `job` — wait on or cancel background jobs. - `ask` — structured follow-up questions for interactive runs. **Outside the box** @@ -270,9 +269,8 @@ Stealth's on by default, so pages see a normal user instead of a headless bot. T **Misc** - `resolve` — apply or discard a queued preview action. -- `search_tool_bm25` — BM25 over the hidden tool index; activates top matches mid-session. -Setting-gated, off by default: `github`, `inspect_image`, `tts`, `checkpoint`, `rewind`, `search_tool_bm25`, `retain`, `recall`, `reflect`. Flip them on once, scoped per project. +Setting-gated, off by default: `github`, `inspect_image`, `tts`, `checkpoint`, `rewind`, `retain`, `recall`, `reflect`. Flip them on once, scoped per project. [Full reference →](https://omp.sh/docs/tools) diff --git a/docs/advisor-watchdog.md b/docs/advisor-watchdog.md index a4881fa5c..65870bf11 100644 --- a/docs/advisor-watchdog.md +++ b/docs/advisor-watchdog.md @@ -80,7 +80,7 @@ Every advisor has the `advise` tool for surfacing notes into the primary transcr - `grep` - `glob` -A `WATCHDOG.yml` roster entry may broaden this with `tools: [...]`, selecting any subset of the built-in pool the session actually built (a factory that returned `null`, e.g. `lsp` with no matching servers, is absent). Grantable tools include mutating ones: `edit`, `write`, `bash`, `eval`, `browser`, `debug`, `ast_edit`, `task`, `job`, and the memory tools. Tool names outside [`BUILTIN_TOOL_NAMES`](../packages/coding-agent/src/tools/builtin-names.ts) are dropped with a warning. +A `WATCHDOG.yml` roster entry may broaden this with `tools: [...]`, selecting any subset of the built-in pool the session actually built (a factory that returned `null`, e.g. `lsp` with no matching servers, is absent). Grantable tools include mutating ones: `edit`, `write`, `bash`, `eval`, `browser`, `debug`, `ast_edit`, `task`, `hub`, and the memory tools. Tool names outside [`BUILTIN_TOOL_NAMES`](../packages/coding-agent/src/tools/builtin-names.ts) are dropped with a warning. Advisor grants are not routed through the primary agent's approval wrapper. The advisor pool is built from the built-in tool factories against its own `-advisor` `ToolSession` and then filtered by `WATCHDOG.yml`; it is not the primary `toolRegistry` wrapped with `ExtensionToolWrapper`. Granting write- or exec-tier tools therefore lets the advisor invoke those tools directly, subject to the tool's own runtime guards but not to `tools.approvalMode` / `tools.approval.` prompts. Keep mutating grants narrow and trusted. @@ -233,7 +233,7 @@ Fields: - `instructions` (top level): shared prompt prepended to every advisor's system prompt alongside `WATCHDOG.md`. Concatenated across all discovered `WATCHDOG.yml` files. - `advisors[].name`: human label; slugified for the session id and the `/__advisor.jsonl` filename. Duplicate slugs across files are resolved by the same specificity rule as `WATCHDOG.md` discovery (project leaf > project ancestor > user). - `advisors[].model`: optional model selector with optional `:level` thinking suffix (e.g. `x-ai/grok-code-fast:high`). Omitted → the advisor uses `modelRoles.advisor`. -- `advisors[].tools`: optional list of built-in tool names to grant. Omitted or empty → the default `read`/`grep`/`glob` subset. Any name in [`BUILTIN_TOOL_NAMES`](../packages/coding-agent/src/tools/builtin-names.ts) is accepted, including mutating tools (`edit`, `write`, `bash`, `eval`, `browser`, `debug`, `ast_edit`, `task`, `job`, and the memory tools). Legacy aliases (`search`→`grep`, `find`→`glob`) are normalized. Unknown names are dropped with a warning. See [Tools and isolation](#tools-and-isolation) for the safety implications of granting mutating tools. +- `advisors[].tools`: optional list of built-in tool names to grant. Omitted or empty → the default `read`/`grep`/`glob` subset. Any name in [`BUILTIN_TOOL_NAMES`](../packages/coding-agent/src/tools/builtin-names.ts) is accepted, including mutating tools (`edit`, `write`, `bash`, `eval`, `browser`, `debug`, `ast_edit`, `task`, `hub`, and the memory tools). Legacy aliases (`search`→`grep`, `find`→`glob`) are normalized. Unknown names are dropped with a warning. See [Tools and isolation](#tools-and-isolation) for the safety implications of granting mutating tools. - `advisors[].instructions`: this advisor's specialization, appended after the shared baseline. Both instruction fields expand `@path` imports like `WATCHDOG.md`. ### Discovery locations @@ -277,4 +277,4 @@ Why a file: The file follows session switches: on `/new`, resume/switch, and branch the recorder reopens at the new session's path on the next advisor turn; before a `/drop` deletes the old artifacts dir the recorder feed is detached and drained so a queued write cannot recreate the deleted file. The on-disk log is append-only and independent of the in-memory context — re-primes and compaction never truncate it. -The advisor is never a peer. The `advisor`-kind registry ref is excluded from every agent-facing surface — the `irc` peer roster and broadcast targets, the subagent peer prompt, and the `history://` index/lookup/completions — and cannot be messaged (`irc send` and collab chat refuse it) or revived/killed from the Agent Hub or collab. It is not addressable as a peer, regardless of what tools it has been granted. +The advisor is never a peer. The `advisor`-kind registry ref is excluded from every agent-facing surface — the `hub` peer roster and broadcast targets, the subagent peer prompt, and the `history://` index/lookup/completions — and cannot be messaged (`hub` send and collab chat refuse it) or revived/killed from the Agent Hub or collab. It is not addressable as a peer, regardless of what tools it has been granted. diff --git a/docs/compaction.md b/docs/compaction.md index 186d53054..3d9790691 100644 --- a/docs/compaction.md +++ b/docs/compaction.md @@ -164,7 +164,7 @@ If pruning changes entries, session storage is rewritten and agent message state ### Useless-result elision -Tools can flag a finished result as contextually useless — a search with zero matches, a `job` poll that timed out with everything still running, an empty `irc` inbox drain. The flag originates on the tool result (`AgentToolResult.useless`, set via `ToolResultBuilder.useless()` or directly on the returned object), is copied by the agent loop onto the persisted `ToolResultMessage` (never together with `isError` — errors always win), and is consumed in three places: +Tools can flag a finished result as contextually useless — a search with zero matches, a `hub` wait that timed out with everything still running, an empty `hub` inbox drain. The flag originates on the tool result (`AgentToolResult.useless`, set via `ToolResultBuilder.useless()` or directly on the returned object), is copied by the agent loop onto the persisted `ToolResultMessage` (never together with `isError` — errors always win), and is consumed in three places: - **Per-turn stale-result pass** (`pruneSupersededToolResults`, gated by `compaction.dropUseless`, default on): flagged results are blanked to the exact placeholder `[Uneventful result elided]` (`USELESS_NOTICE`) with the same cache-aware timing as superseded reads — only when the suffix after the candidate is small (≤ ~8k tokens) or the session has idled past the provider prompt-cache lifetime. Results smaller than the notice itself are never blanked (no savings), and protected tools are exempt. - **Threshold prune** (`pruneToolOutputs`): flagged results bypass the protect-recent window, same as superseded reads, and receive `USELESS_NOTICE` instead of the token-count placeholder. diff --git a/docs/custom-tools.md b/docs/custom-tools.md index 9f74137fd..9c6d63e0c 100644 --- a/docs/custom-tools.md +++ b/docs/custom-tools.md @@ -129,7 +129,7 @@ From `types.ts` and `loader.ts`: - `typebox`: zod-backed compatibility shim for legacy TypeBox-style schemas - `zod`: injected `zod/v4` module (canonical for new schemas) - `pi`: injected `@oh-my-pi/pi-coding-agent` exports -- `pushPendingAction(action)`: register a preview action for hidden `resolve` tool (`docs/resolve-tool-runtime.md`) +- `pushPendingAction(action)`: register a preview action finalized via plain-text writes to `/xdev/resolve` or `/xdev/reject` (`docs/resolve-tool-runtime.md`) Loader starts with a no-op UI context and requires host code to call `setUIContext(...)` when real UI is ready. ## Execution contract and typing diff --git a/docs/resolve-tool-runtime.md b/docs/resolve-tool-runtime.md index 6aadf6168..97001b01e 100644 --- a/docs/resolve-tool-runtime.md +++ b/docs/resolve-tool-runtime.md @@ -1,145 +1,53 @@ -# Resolve tool runtime internals +# Resolution devices runtime -This document explains how preview/apply workflows are modeled in coding-agent and how built-in or custom tools can participate via the pending-invoker registry and `pushPendingAction`. (Pending previews live in a separate non-forcing registry inside `ToolChoiceQueue`; only genuine hard forces use the consuming directive queue.) +Pending previews and plan approval no longer use a `resolve` tool. They finalize through three plain-text writes handled by `packages/coding-agent/src/tools/resolve.ts`: -## Scope and key files +- `/xdev/resolve` — apply the pending staged preview; body = reason text +- `/xdev/reject` — discard the pending staged preview; body = reason text +- `/xdev/propose` — submit the plan for approval while plan mode is active; body = the plan slug/title (`` for `local://-plan.md`) -- [`src/tools/resolve.ts`](../packages/coding-agent/src/tools/resolve.ts) -- [`src/tools/ast-edit.ts`](../packages/coding-agent/src/tools/ast-edit.ts) -- [`src/extensibility/custom-tools/types.ts`](../packages/coding-agent/src/extensibility/custom-tools/types.ts) -- [`src/extensibility/custom-tools/loader.ts`](../packages/coding-agent/src/extensibility/custom-tools/loader.ts) -- [`src/sdk.ts`](../packages/coding-agent/src/sdk.ts) +## Preview flows -## What `resolve` does +Preview producers call `queueResolveHandler(...)` with `apply(reason)` and optional `reject(reason)` callbacks. That registers a non-forcing pending invoker in `ToolChoiceQueue`. -`resolve` is a hidden tool that finalizes a pending preview action. +While a preview is pending, `AgentSession.nextToolChoiceDirective()` returns a soft requirement: -- `action: "apply"` executes the queued action's `apply(reason, extra)` callback and returns that result with resolve metadata. -- `action: "discard"` invokes `reject(reason, extra)` if provided; otherwise returns `Discarded: