Split out from #1867 (secondary finding there: search_graph / trace_path / detect_changes emit the compact tree by default when stdout is not a TTY), per the maintainer's invitation to give it its own discussion.
Current state (verified on v0.10.8) — better than my original report assumed
- Tools that accept a
format argument (notably search_graph / trace_path / detect_changes) already support --format json, and <tool> --help documents it (e.g. search_graph --help: "Response encoding. tree (default) … json: the SAME tree model as structured JSON")
- The README CLI section documents both layers: tool-level
--format json (payload JSON) vs outer --json (full MCP envelope)
- The tree default is deliberate, and I understand why: the primary non-TTY consumers of this CLI are AI agents and bridges, and the compact tree is token-optimized for exactly that audience
So this is not a bug report — it is a small UX/discoverability suggestion.
Remaining friction
--format json is per-tool-call only. A script or bridge invoking several tools must pass it on every single invocation; there is no way to set it once for a session.
- The top-level
cli --help doesn't mention it. You have to run <tool> --help for each tool to discover the flag. The README covers it, but --help is where habitual CLI users look first.
Suggestion — pick whichever direction you prefer; happy to submit a PR
- (a) Top-level flag:
cli [--format tree|json] <tool> ... acting as a default for tools that accept format; an explicit per-tool --format still wins.
- (b) Env var:
CBM_CLI_FORMAT=tree|json, useful for bridges that spawn the binary from generated glue code without full control over argv on every call.
- (c) Docs-only: add one line to the top-level
cli usage string pointing at tool-level --format json.
I'd lean towards (a) + (b): both are fully backward compatible, and they deliberately do not flip the default on non-TTY stdout — auto-switching would silently change the output that model-facing bridges and agents see, which I assume is the audience the tree default was designed for.
I can implement this myself if you agree on a direction. From reading the source, the change looks localized:
run_cli() in src/main.c — merge a top-level/env-provided format into args_json before tool dispatch (per-tool explicit value still takes precedence)
tests/test_cli.c — precedence tests (top-level vs per-tool vs unset)
CLI_USAGE string + README CLI section
- Per CONTRIBUTING (pre-commit hooks,
scripts/lint.sh, DCO Signed-off-by trailer)
Split out of #1867 per @DeusData's request
Split out from #1867 (secondary finding there:
search_graph/trace_path/detect_changesemit the compact tree by default when stdout is not a TTY), per the maintainer's invitation to give it its own discussion.Current state (verified on v0.10.8) — better than my original report assumed
formatargument (notablysearch_graph/trace_path/detect_changes) already support--format json, and<tool> --helpdocuments it (e.g.search_graph --help: "Response encoding. tree (default) … json: the SAME tree model as structured JSON")--format json(payload JSON) vs outer--json(full MCP envelope)So this is not a bug report — it is a small UX/discoverability suggestion.
Remaining friction
--format jsonis per-tool-call only. A script or bridge invoking several tools must pass it on every single invocation; there is no way to set it once for a session.cli --helpdoesn't mention it. You have to run<tool> --helpfor each tool to discover the flag. The README covers it, but--helpis where habitual CLI users look first.Suggestion — pick whichever direction you prefer; happy to submit a PR
cli [--format tree|json] <tool> ...acting as a default for tools that acceptformat; an explicit per-tool--formatstill wins.CBM_CLI_FORMAT=tree|json, useful for bridges that spawn the binary from generated glue code without full control over argv on every call.cliusage string pointing at tool-level--format json.I'd lean towards (a) + (b): both are fully backward compatible, and they deliberately do not flip the default on non-TTY stdout — auto-switching would silently change the output that model-facing bridges and agents see, which I assume is the audience the tree default was designed for.
I can implement this myself if you agree on a direction. From reading the source, the change looks localized:
run_cli()insrc/main.c— merge a top-level/env-providedformatintoargs_jsonbefore tool dispatch (per-tool explicit value still takes precedence)tests/test_cli.c— precedence tests (top-level vs per-tool vs unset)CLI_USAGEstring + README CLI sectionscripts/lint.sh, DCOSigned-off-bytrailer)