Skip to content

feat(cli): session-wide format default (top-level --format / CBM_CLI_FORMAT) — follow-up from #2102 #2298

Open

Description

@Lowpower

Context

Follow-up to #2102 / #2140.

Help-only discoverability ((c)) is done: top-level cli --help now points at tool-level --format json, and keeps payload JSON vs outer --json (MCP envelope) distinct.

In #2102, @DeusData noted that a session-wide flag or environment default needs a separate decision about supported tools and precedence, and that the help-only step did not approve that API extension. This issue is that decision request — discussion only; no PR until you say the shape is OK.

Proposal

Keep today’s defaults unchanged (including non-TTY: still no auto-switch to JSON).

  • (a) Top-level flag: cli [--format tree|json] <tool> ... as a default for tools that already accept format; an explicit per-tool --format still wins.
  • (b) Env var: CBM_CLI_FORMAT=tree|json for bridges that spawn the binary without full control over argv on every call.

I’d lean (a) + (b) if both are acceptable; either alone is also fine if you prefer a smaller surface.

Open questions for maintainers

  1. Supported tools — apply only where format already exists today (search_graph / trace_path / detect_changes and any peers), or also refuse/warn when --format / CBM_CLI_FORMAT is set for a tool that has no format arg?
  2. Precedence — suggestion:
    per-tool --format > top-level --format > CBM_CLI_FORMAT > built-in default (tree)
  3. Invalid values — hard error vs ignore-and-default for unknown format / env values?
  4. Docs — top-level CLI_USAGE + README CLI section only, or also each tool’s --help?

Non-goals

  • Do not flip non-TTY stdout to JSON automatically.
  • Do not change the meaning of outer --json (full MCP envelope).

Happy to implement once you pick a direction (or say neither). Happy to adjust the precedence / tool set to match your preference.

Activity

  1. DeusData commented on Oct 19, 2026

    @DeusData
    Owner

    Thank you for keeping the session-wide format proposal separate from the help-only change. Supported tools, precedence, invalid values, and documentation remain explicit direction questions; I have no new API approval to give yet.

  2. Lowpower commented on Oct 20, 2026

    @Lowpower
    ContributorAuthor

    Thanks for the clarification — proposing concrete defaults so you can approve/reject by point. Still discussion-only; no PR until you say the shape is OK.

    Surface: both (a) top-level cli [--format tree|json] <tool> ... and (b) CBM_CLI_FORMAT=tree|json, unless you prefer only one.

    1. Supported tools — apply only where a tool already accepts format today (search_graph / trace_path / detect_changes and any peers). If top-level --format / CBM_CLI_FORMAT is set for a tool without format, ignore those defaults (no warn/error); the tool keeps its current behavior.
    2. Precedence — per-tool --format > top-level --format > CBM_CLI_FORMAT > built-in default (tree).
    3. Invalid values — hard error for unknown values of either top-level --format or CBM_CLI_FORMAT (same spirit as rejecting bad per-tool --format), with a short message listing tree|json.
    4. Docs — top-level CLI_USAGE + README CLI section only (point at the new defaults and the precedence). No change to each tool’s --help beyond what already documents per-tool --format.

    Non-goals (unchanged): no non-TTY auto-JSON; outer --json stays the MCP envelope.

    If this shape looks right, I’m happy to open a focused PR. Happy to drop (a) or (b), or switch invalid values to ignore-and-default, if you prefer smaller surface.

  3. removed
    parsing/qualityGraph extraction bugs, false positives, missing edges
    on Oct 25, 2026
  4. DeusData commented on Oct 25, 2026

    @DeusData
    Owner

    Thank you for spelling out the defaults, precedence, and invalid-value behavior. Those concrete choices still need a maintainer decision before you open a PR. Sorry for the delay; I’ll follow up soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestux/behaviorDisplay bugs, docs, adoption UX

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions