Repository navigation
fix(opencode): bridge factory default commands into CommandV2 for TUI launcher - #79
Conversation
… launcher The TUI command launcher reads GET /api/command, which is served by the V2 command store, but the factory init/review commands, configured commands, and MCP/skill commands only existed in the legacy Command service. The two stores were never synchronized, so the launcher was missing the default commands. Bridge the legacy command state into CommandV2 via a scoped transform that owns only the entries it writes itself, leaving entries contributed by other V2 producers (config and plugin command providers) untouched. Keep MCP template resolution lazy: only MCP command templates are lazy promises, and reading one resolves the remote prompt. The bridge copies concrete templates as-is and leaves lazy templates unresolved in the V2 store, so command initialization no longer executes MCP prompts and one slow, unavailable, or failing prompt cannot fail the whole command service. Templates are still materialized on demand when the command is executed. Add regression coverage for the factory defaults, configured command bridging (including the model -> ModelV2 reference mapping), and MCP template laziness against a real in-process MCP server. Co-authored-by: arena-agent <[email protected]>
…mand store The previous bridge targeted a CommandV2 compiled into the legacy app graph, but the V2 API serves /api/command from the location layer of the LocationServiceMap, so bridged entries were written to an instance the TUI never reads. Resolve the location layer for the instance's directory through the ambient LocationServiceMap (soft lookup, so runtimes without a location map are unaffected) and register the bridge transform on that CommandV2. The location ref must be built exactly as the V2 location middleware builds it, including the explicit undefined workspaceID, because the location map keys entries by structural equality where a missing key differs from a key set to undefined. Add an e2e regression test proving MCP prompt commands reach /api/command after legacy command init, and reframe the session command execution tests around the path the TUI actually takes (command list discovery -> SessionPrompt.command -> lazy MCP prompt resolution). Co-authored-by: arena-agent <[email protected]>
|
Addressed the review — execution path is now proven, and in the process I found (and fixed) a deeper problem: the first bridge version was writing to a 1. MCP execution path — provenTwo integration tests in
2. Staleness / sync semanticsThe bridge transform is registered inside the per-directory 3. Self-discovered: the bridge was targeting a dead store (fixed)While writing an e2e probe I found that with the original wiring,
The fix (
New coverage:
Also worth noting: in Verification: scoped |
… endpoint
Extend the e2e command-bridge test beyond discovery: create a session
and execute the bridged MCP command via POST /session/:id/command (the
path the TUI launcher takes), with a fake OpenAI-compatible provider so
the run completes. Asserts the MCP GetPrompt fires exactly once more
than discovery already triggered, and that the session's user message
contains the MCP prompt response rather than the empty template stored
in the V2 view.
The delta-based GetPrompt accounting is deliberate: the pre-existing v1
list response serializes the lazy MCP template getter as {} (evaluating
it), which is unrelated to this PR and out of scope.
Also trims the over-narrated bridge comments.
Co-authored-by: arena-agent <[email protected]>
|
Good catch on the execution gap — the e2e now proves it. What the test does, step by step (real server, in-process MCP server counting
So the architecture is precisely the one you'd sign off: One finding worth knowing about (pre-existing, out of scope, why the test uses delta-based counting): the v1 Also addressed the comment-nit: the bridge block in Verification: e2e 2/2 (stable across 3 runs), bridge unit 4/4, the two session execution tests 2/2, scoped |
Issue for this PR
Closes #78
Type of change
What does this PR do?
The TUI command launcher reads
GET /api/command, which is served by the V2 command store, but the factoryinit/reviewcommands, configured commands, and MCP/skill commands only existed in the legacyCommandservice. The two stores were separate, so the launcher was missing the default commands.This bridges the legacy command state into
CommandV2from theCommandlayer:CommandV2transform, registered when command state initializes, upserts each legacy command (name, template, description, agent, model, subtask). The transform owns only the entries it writes itself: each run removes the entries it bridged previously that are no longer present and upserts the current set. Entries contributed by other V2 producers (config and plugin command providers) are left untouched.modelstring (provider/model) is split withModelV2.parseinto the V2 model reference{ id, providerID }.Command.nodenow depends onCommandV2.node.How did you verify your code works?
test/command/bridge.test.tscovers: factory defaults in the V2 store (template content, review subtask), configured command bridging including the model mapping (id,providerID, and that no variant is invented), MCP prompt metadata bridged without executing the prompt (asserted against a real in-process MCP server that countsGetPromptrequests), and command initialization succeeding when an MCP prompt fails. The two MCP tests were verified to fail against the eager-resolving implementation, so they guard the laziness regression.test/command,test/mcp,test/config,test/skill,test/acp,test/session, andtest/server(v2 location) suites locally, plus the corecommandand config-plugin command tests: no new failures (twotest/sessionfailures are pre-existing on the base commit in this environment).oxlintandprettierclean on the changed files.Screenshots / recordings
Not applicable — no UI change beyond the launcher listing the commands it was missing.
Checklist