Skip to content

Rename ai-bot and prompt-assembly identifiers to tool naming (CS-12041)#5462

Merged
lukemelia merged 2 commits into
mainfrom
cs-12041-rename-ai-bot-prompt-assembly-sweep
Jul 10, 2026
Merged

Rename ai-bot and prompt-assembly identifiers to tool naming (CS-12041)#5462
lukemelia merged 2 commits into
mainfrom
cs-12041-rename-ai-bot-prompt-assembly-sweep

Conversation

@lukemelia

Copy link
Copy Markdown
Contributor

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

  • parseMarkdownSkill returns tools; enabled skills carry attributes.tools — with a fallback read of attributes.commands, because legacy Skill cards serialize their tools under the commands card field and the card-JSON push path still flows through getTools.
  • MarkdownSkillTool / markdownSkillTools, isToolResultEvent, isToolResultStatusApplied, isToolOrCodePatchResult, CHECK_CORRECTNESS_TOOL_NAME (the checkCorrectness wire string is unchanged), the correctness-check helpers, and the ai-bot lib/tests follow.
  • runtime-common's request/context exports rename (decodeToolRequest, encodeToolRequests, buildToolFunctionName[FromResolvedRef], ToolContext, ToolInvocation) with the pre-rename spellings kept as deprecated exports — realm content imports these (patterns extend Command, construct with commandContext). The ToolContextStamp keeps its registered Symbol.for('CommandContext') key so runtime identity with already-loaded content is preserved.
  • Host/base consumers move to the new names (ToolContext in the tool-service/command-runner, buildToolFunctionName in ToolField).

What stays, deliberately

commandRequestId (wire field on both event spellings), LEGACY_* wire constants and the lines reading them, the boxel?.commands frontmatter fallback (CS-12037's dual-read), and comments describing those legacy keys. Audit of packages/ai-bot/lib + runtime-common/ai shows 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-test failures 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

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>
@lukemelia
lukemelia requested a review from Copilot July 9, 2026 21:42
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Preview deployments

Host Test Results

  1 files  ±    0    1 suites  ±0   12m 34s ⏱️ - 2h 34m 31s
246 tests  - 3 189  244 ✅  - 3 176  2 💤  - 13  0 ❌ ±0 
246 runs   - 3 208  244 ✅  - 3 195  2 💤  - 13  0 ❌ ±0 

Results for commit fa2210c. ± Comparison against earlier commit 95e1973.

Realm Server Test Results

    1 files  ± 0      1 suites  ±0   12m 38s ⏱️ -36s
1 798 tests +16  1 798 ✅ +16  0 💤 ±0  0 ❌ ±0 
1 877 runs  +16  1 877 ✅ +16  0 💤 ±0  0 ❌ ±0 

Results for commit fa2210c. ± Comparison against earlier commit 95e1973.

@lukemelia
lukemelia changed the base branch from cs-12040-rename-host-services-resources-and-ui-copy-sweep-command to main July 9, 2026 21:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CommandContext to ToolContext (keeping the Symbol.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.

Comment thread packages/runtime-common/ai/prompt.ts Outdated
Comment thread packages/matrix/tests/commands.spec.ts Outdated
Comment thread packages/ai-bot/tests/prompt-construction-test.ts Outdated
Comment thread packages/ai-bot/lib/code-patch-correctness.ts
Comment thread packages/ai-bot/lib/code-patch-correctness.ts Outdated
Comment thread packages/runtime-common/ai/prompt.ts Outdated
…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>
@lukemelia
lukemelia merged commit 9bee8f1 into main Jul 10, 2026
99 of 101 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants