Skip to content

feat(cli): add symbols/refs/cfg/callgraph/cost query commands - #440

Merged
Teakowa merged 4 commits into
mainfrom
wright-429-query-commands
Sep 29, 2026
Merged

Teakowa merged 4 commits into
mainfrom
wright-429-query-commands

Conversation

@e54-bot

@e54-bot e54-bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Implements #429: the semantic query surface previously reachable only through wright serve / wright-agent/v1 is now exposed to humans, nested under inspect per #439's top-level-surface principle ("#429 owns the inspect query surface").

  • CLI: wright inspect keeps the bounded summary; its subcommands expose the detail areas — inspect symbols [INPUT] [--only KIND], inspect refs <NAME> [INPUT], inspect cfg <RULE> [INPUT], inspect callgraph [INPUT], inspect cost [INPUT]. Each runs its agent operation (symbols, references + usage, cfg, callGraph, costEstimate) through the session's ToolService, so CLI result payloads equal the agent payloads by construction. refs reports the usage counts as the header of the reference list; cost honors the shared finding-selection options. Mixing an [INPUT] positional with a query subcommand is a usage error.
  • Naming: the issue's --kind symbol-kind filter collides with the existing --kind input-frontend flag, so the filter is spelled --only (inspect symbols --only rule), per maintainer direction on the simpler name.
  • Agent contract: references.symbol, usage.symbol, and cfg.rule accept a numeric id or the declared name (untagged Address; schema integer|string). Names resolve through the analyzer's SemanticIndex inside the driver — callers never learn the program's numbering, where symbol ids and rule indexes are different spaces. Unknown/ambiguous names return structured unknown-symbol / ambiguous-symbol / unknown-rule / ambiguous-rule errors listing candidate ids; resolution never guesses. usage additively echoes the resolved id/kind.
  • analyze: result.facts.persistentObjects carries the same facts persistentObjects serves (with resolved span paths); the text overview reports the count.
  • inspect summary: text output names the nested detail command for each area.
  • References keep the existing reference-model locations until Report reference and declaration spans at the identifier, from workshop-rs provenance #433 lands; no test asserts identifier-exact spans.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-targets --all-features </dev/null — all 31 test targets pass
  • git diff --check
  • Analyzer: name resolution finds unique symbols/rules; unknown/ambiguous produce the structured codes and candidate lists
  • Driver: name vs numeric addressing returns identical payloads; session query workflows equal the agent op payloads; analyze reports facts.persistentObjects
  • CLI black-box: all five query subcommands in text and JSON, --only filter, usage header counts, callgraph edge, exact cost counts + selection, unknown/ambiguous diagnostics, bare-inspect detail-command pointers, top-level/inspect --help coverage
  • Schema: wright-agent/v1 validates integer and string address spellings, rejects other types; UsageResult/AnalyzeResult validated against live responses
  • Real fixture: overpy-cake.ws — cakePos 16 reads / 1 write / 17 references, cfg 18 blocks, cost 3960 bytes / 29 actions / 2 rules / 1 wait

Generated with Devin

Teakowa and others added 4 commits September 30, 2026 03:20
The semantic query surface the agent contract already served is now reachable from the CLI: each new command runs its operation through the session's ToolService, so a CLI result equals the agent payload for the same input.

- ToolRequest symbol/rule fields accept a numeric id or the declared name (untagged Address); names resolve against the shared SemanticIndex in the analyzer, and unmatched/ambiguous names are structured unknown-symbol/ambiguous-symbol/unknown-rule/ambiguous-rule errors instead of guesses. Symbol ids and rule indexes stay separate spaces.
- wright refs <NAME> is the usage payload plus the references list; wright cfg <RULE> addresses rules by name. symbols gains --only <KIND> for the symbol-kind filter since --kind already selects the input frontend. cost honors the shared finding selection.
- usage echoes the resolved id/kind (additive wright-agent/v1 field); analyze gains facts.persistentObjects; inspect names the detail command per area.
- Schema, agent contract, and CLI docs updated; wright-bench call sites use the Address form.

Closes #429

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
#439 keeps the top-level command surface to distinct user intents and assigns the semantic query surface to `inspect` (#429). Move the five flat commands into inspect subcommands — inspect symbols|refs|cfg|callgraph|cost — keeping the same agent-backed payloads, the --only filter, name addressing, and finding selection.

Bare `inspect` still prints the summary, which now points to the nested detail commands; mixing an [INPUT] positional with a query subcommand is a usage error rather than a silent merge.

Refs #429, #439

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Main gained identifier spans from workshop-rs provenance (#438), so the references list now includes the declaration entry beside reads and writes (18 for cakePos). Refresh the assertion and drop the stale 'until #433 lands' notes.
@Teakowa
Teakowa enabled auto-merge (squash) September 29, 2026 20:53
@Teakowa
Teakowa merged commit b8c7433 into main Sep 29, 2026
22 checks passed
@Teakowa
Teakowa deleted the wright-429-query-commands branch September 29, 2026 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants