Rename ai-bot and prompt-assembly identifiers to tool naming (CS-12041)#5462
Conversation
The shared prompt pipeline and ai-bot consume the tool-named types and helpers throughout: MarkdownSkillTool / markdownSkillTools / parseMarkdownSkill's `tools` return key, isToolResultEvent, isToolResultStatusApplied, isToolOrCodePatchResult, CHECK_CORRECTNESS_TOOL_NAME (the wire string is unchanged), and the correctness helpers. Enabled skills carry `tools` in their attributes, with a fallback read of `commands` since legacy Skill cards serialize their tools under that card field. runtime-common's tool request/context exports rename (decodeToolRequest, encodeToolRequests, buildToolFunctionName[ FromResolvedRef], ToolContext, ToolInvocation); the pre-rename spellings stay exported since realm content imports them. The ToolContext stamp keeps its registered symbol key for runtime identity with already-loaded content. Part of the command -> tool rename (CS-12041 / CS-11788). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Preview deploymentsHost Test Results 1 files ± 0 1 suites ±0 12m 34s ⏱️ - 2h 34m 31s Results for commit fa2210c. ± Comparison against earlier commit 95e1973. Realm Server Test Results 1 files ± 0 1 suites ±0 12m 38s ⏱️ -36s Results for commit fa2210c. ± Comparison against earlier commit 95e1973. |
There was a problem hiding this comment.
Pull request overview
This PR continues the command→tool identifier migration (stacked on #5458) by updating runtime-common’s prompt/tool-request pipeline plus ai-bot/host/base consumers to consistently use “tool” naming, while preserving deprecated exports and legacy wire/serialized fields for backward compatibility.
Changes:
- Renames runtime-common request/context exports and prompt-pipeline helpers to “tool” naming (with deprecated pre-rename aliases kept).
- Updates ai-bot and Matrix tests to use the new “tool” identifiers (
ToolRequest,ToolResultEvent, etc.) and updated helper names. - Moves host/base call sites and type references from
CommandContexttoToolContext(keeping theSymbol.for('CommandContext')stamp for runtime identity).
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/runtime-common/commands.ts | Introduces ToolContext/ToolInvocation and tool-named request/name helpers, with deprecated command-named aliases preserved. |
| packages/runtime-common/ai/prompt.ts | Migrates prompt construction and skill parsing from command naming to tool naming, including legacy fallbacks. |
| packages/runtime-common/ai/matrix-utils.ts | Updates message send helpers and result detection naming to tool terminology. |
| packages/runtime-common/ai/history.ts | Updates history construction typings and tool-request merging to tool-named request type. |
| packages/matrix/tests/correctness-checks.spec.ts | Updates correctness-check Playwright coverage to “tool” request/result terminology. |
| packages/matrix/tests/commands.spec.ts | Updates command-application test assertions to expect tool result events. |
| packages/host/app/tools/utils.ts | Switches utility function signatures from CommandContext to ToolContext. |
| packages/host/app/tools/patch-fields.ts | Updates tool constructor context type to ToolContext. |
| packages/host/app/tools/patch-card-instance.ts | Updates tool constructor context type to ToolContext. |
| packages/host/app/services/tool-service.ts | Updates service context stamping and tool constructor typing to ToolContext. |
| packages/host/app/routes/command-runner.ts | Updates command runner route’s context type/stamp to ToolContext. |
| packages/host/app/lib/host-base-tool.ts | Updates HostBaseTool constructor signature to accept ToolContext. |
| packages/host/app/components/operator-mode/stack.gts | Updates component argument typing from CommandContext to ToolContext. |
| packages/host/app/components/operator-mode/stack-item.gts | Updates component argument typing from CommandContext to ToolContext. |
| packages/host/app/components/operator-mode/operator-mode-overlays.gts | Updates consumed context type from CommandContext to ToolContext. |
| packages/host/app/components/operator-mode/create-listing-modal.gts | Updates dynamic command module constructor typing to use ToolContext. |
| packages/base/spec.gts | Updates example command constructors to accept ToolContext. |
| packages/base/resources/command-data.ts | Updates resource typing for command constructors to accept ToolContext. |
| packages/base/menu-items.ts | Updates menu-item parameter typing to use ToolContext. |
| packages/base/card-api.gts | Updates card context typing to use ToolContext for commandContext. |
| packages/ai-bot/tests/responding-test.ts | Updates tool-call snapshot typing from CommandRequest to ToolRequest. |
| packages/ai-bot/tests/prompt-construction-test.ts | Updates prompt regression tests and markdown-skill parsing expectations to tool naming. |
| packages/ai-bot/tests/code-patch-correctness-test.ts | Updates correctness helper tests to decode ToolRequests. |
| packages/ai-bot/tests/chat-titling-test.ts | Updates title logic tests to use tool result event naming. |
| packages/ai-bot/main.ts | Switches applied-result detection helper to tool-named export. |
| packages/ai-bot/lib/set-title.ts | Updates result-event typing and tool-request lookup to tool naming. |
| packages/ai-bot/lib/responder.ts | Switches responder gating helper to tool-named export. |
| packages/ai-bot/lib/matrix/response-publisher.ts | Updates tool-call→request conversion typing to ToolRequest. |
| packages/ai-bot/lib/code-patch-correctness.ts | Renames correctness constant to tool naming and encodes tool requests with tool-named helper. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ings getCheckCorrectnessToolRequests / buildCheckCorrectnessToolRequests match what they return; the legacy-state-key test title names the commandDefinitions key it actually exercises; "successful" typo fixed in the matrix specs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
What
Fifth slice of the command → tool rename (CS-11788), stacked on #5458. The shared prompt pipeline (
runtime-common/ai) and ai-bot move to tool naming end-to-end.Highlights
parseMarkdownSkillreturnstools; enabled skills carryattributes.tools— with a fallback read ofattributes.commands, because legacy Skill cards serialize their tools under thecommandscard field and the card-JSON push path still flows throughgetTools.MarkdownSkillTool/markdownSkillTools,isToolResultEvent,isToolResultStatusApplied,isToolOrCodePatchResult,CHECK_CORRECTNESS_TOOL_NAME(thecheckCorrectnesswire string is unchanged), the correctness-check helpers, and the ai-bot lib/tests follow.decodeToolRequest,encodeToolRequests,buildToolFunctionName[FromResolvedRef],ToolContext,ToolInvocation) with the pre-rename spellings kept as deprecated exports — realm content imports these (patterns extendCommand, construct withcommandContext). TheToolContextStampkeeps its registeredSymbol.for('CommandContext')key so runtime identity with already-loaded content is preserved.ToolContextin the tool-service/command-runner,buildToolFunctionNameinToolField).What stays, deliberately
commandRequestId(wire field on both event spellings),LEGACY_*wire constants and the lines reading them, theboxel?.commandsfrontmatter fallback (CS-12037's dual-read), and comments describing those legacy keys. Audit ofpackages/ai-bot/lib+runtime-common/aishows every remaining "command" token is one of these.Verification
runtime-common / ai-bot / host type-checks clean; per-package eslint clean; ai-bot suite 224/226 (the two
locking-testfailures are the pre-existing local Postgres-role environment issue). The prompt-construction suite exercises the renamed pipeline directly, including the mixed-history legacy-wire regression tests from CS-12039.🤖 Generated with Claude Code