feat: add robot subcommand surface for capabilities schemas examples (f3.1 f3.2 f3.3 task 1.3.4) #36
Notifications
Due Date
No due date set.
Blocks
#30 feat: populate ExampleDoc.output for robot examples endpoint (F3.3)
terraphim/agent-tasks
#31 feat: case-insensitive flags and --flag=value separators (F2.3)
terraphim/agent-tasks
#32 feat: live index_status in robot capabilities response (F3.1)
terraphim/agent-tasks
Reference: terraphim/agent-tasks#36
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
Specification
terraphim-agent-session-search-spec.mdsections F3.1 Capabilities Endpoint, F3.2 Schema Documentation, and F3.3 Examples Endpoint mandate three CLI surfaces:The implementation tasks (terraphim-agent-session-search-tasks.md, Task 1.3.4) mark these subcommands
[x]complete, but a clap-level grep oncrates/terraphim_agent/src/main.rsforRobot|Schemas|Capabilities|ExamplesasSubcommandvariants returns zero hits. TheSelfDocumentationRust API methods do exist (pub fn capabilities(),pub fn all_schemas(),pub fn examples()atcrates/terraphim_agent/src/robot/docs.rs:25,:65,:70) but they are unreachable from the CLI -- and the entirepub mod docsis wrapped in#[allow(dead_code)](robot/mod.rs:9).Existing related issues -- #11 (Route REPL output through machine-readable formatter, Task 1.4.1+1.4.3), #30 (populate ExampleDoc.output for examples endpoint), and #32 (live index_status in capabilities response) -- handle the output formatter and response data, but none add the actual
robotsubcommand surface that exposes those structures over the binary CLI. This is the missing wiring layer between the existing Rust API and the documented user-facing contract.Without this, AI agents cannot self-discover terraphim-agent's command surface, schemas, or runnable examples, blocking the entire MCP-style
robot capabilities/robot schemasintegration story that motivates Phase 1.Acceptance Criteria
Command::Robot { sub: RobotSub }variant to the existingCommandenum incrates/terraphim_agent/src/main.rs:699.RobotSubenum with three variants:Capabilities-- no args; emits the result ofSelfDocumentation::capabilities_data().Schemas { command: Option<String> }-- single command name selects one schema, no arg returnsall_schemas().Examples { command: Option<String> }-- same shape asSchemasbut returnsExampleDoc[].RobotFormatter(robot/output.rs), honouring the global--formatflag (lines 689-690), so--format json|jsonl|minimal|tableall work.--robotmode (line 686-687) output is the standardRobotResponse<T>envelope fromrobot/schema.rs, includingmeta.command,meta.elapsed_ms, and the newmeta.exit_codeslot.terraphim-agent robot capabilities --format json | jq .features.session_searchreturns a boolean.terraphim-agent robot schemas searchreturns the search command'sCommandDocJSON.terraphim-agent robot examples searchreturns at least one runnableExampleDoc.schemas/examplesexits withExitCode::ErrorNotFound(4) and includes aRobotErrorlisting valid commands.#[allow(dead_code)]onpub mod docsinrobot/mod.rs:9.crates/terraphim_agent/tests/robot_subcommand.rsexercising each subcommand viaassert_cmdwith both--format jsonand default output.cargo test -p terraphim_agentpasses.cargo clippy -p terraphim_agent -- -D warningspasses.Proposed Approach
RobotSubnext to existingCommandenum (around line 698) usingclap::Subcommandderive, identical pattern toRolesSub/ConfigSub.Command::Robot { sub }in the existing dispatch and call into a thinhandle_robot(sub, &cli) -> Result<ExitCode>function in a newcrates/terraphim_agent/src/robot/cli.rsmodule.handle_robotinstantiatesSelfDocumentation::new()(already a stateless builder), dispatches tocapabilities_data()/all_schemas()/examples(), wraps the result inRobotResponse, and serialises throughRobotFormatter::format(&response, cli.format).replfeature gate incrates/terraphim_agent/src/repl/so/robot capabilitiesworks inside the REPL too -- but this is a stretch goal and can be deferred to a follow-up if it pushes the diff above 500 LOC.Affected crates:
terraphim_agentonly.Affected files:
crates/terraphim_agent/src/main.rs(addRobotSub, dispatch arm)crates/terraphim_agent/src/robot/mod.rs(drop dead-code attr; export new submodule)crates/terraphim_agent/src/robot/cli.rs(handle_robot)crates/terraphim_agent/tests/robot_subcommand.rsDependencies
Soft-pairs with #30 (ExampleDoc.output) and #32 (live index_status) -- both populate response data; this issue exposes the response surface. Can land independently because the response types already exist with empty/static defaults.
Pairs naturally with #35 (ExitCode wiring) for the
meta.exit_codefield but does not strictly block on it.Verification
Scope
Single PR, ~350-450 LOC. New
cli.rsmodule is a thin dispatcher (~120 LOC), enum additions are mechanical, tests carry the rest. No external crate or workspace dependency changes.