Skip to content

feat(cli): unify --format profile across commands #445

Closed

Description

@Sinity

Problem

--format is implemented inconsistently across commands. Current state:

  • polylogue list / stats / export / export-bulk and the root query — accept 8 formats: markdown, json, html, yaml, csv, obsidian, org, plaintext.
  • polylogue neighbors / tags / schema / products — accept JSON only.
  • Some commands accept --json as a separate boolean flag (legacy); others use --format json.

Users cannot apply a consistent format policy across the CLI ("give me everything as YAML"). Scripts that wrap polylogue have to special-case the JSON-only commands. This is a UX bug visible to anyone who runs the CLI in two consecutive shells.

Target

Decide and document the format profile per command class, then unify:

  1. query-shaped commands (list, stats, export, export-bulk, tags, neighbors) — all accept the full 8-format set.
  2. introspection commands (schema, products subcommands, --list-commands) — JSON + plain-text default; expand only if a specific use case demands.
  3. pipeline commands (run, reset) — output is operational, not data; restrict to the operational format set.

Replace the per-command @click.option("--format", type=...) with shared decorators in cli/click_option_groups.py. Currently --format, --json, --limit are declared 5-10 times each.

Define a canonical JSON envelope (the audit notes there's no shared error/result envelope today):

{
  "result": ...,
  "errors": [...],
  "metadata": { "command": "list", "version": "X.Y.Z", ... }
}

Acceptance criteria

  • Every query-shaped command accepts the full format set; the JSON-only commands grow to support the rest.
  • --format and --json are unified (one flag, with deprecation note for --json if removed).
  • Shared format decorator in cli/click_option_groups.py; per-command duplication removed.
  • All JSON output uses the canonical envelope.
  • tests/unit/cli/test_format_consistency.py (new) asserts the matrix: every query-shaped command × every format produces output.
  • Help text for --format is identical across commands (cite the decorator).
  • docs/cli-reference.md regenerates to show the consistent format profile.

Coordinates with

Related

Scope fence — no topology moves

This issue is behavioral, not structural. It edits polylogue/cli/** in place to unify format-flag declarations and the JSON envelope; no module moves. Verifiable by:

git diff --stat origin/master..HEAD -- polylogue/cli/
# expected: edits and additions only, no `=>` rename markers

If a fix here produces new shared modules (e.g. expanding cli/click_option_groups.py or adding cli/format_envelope.py), the additions extend docs/plans/topology-target.yaml in the same PR. Coordinates with #431 (cli/commands cohesion) only on shared-helper placement; format unification itself does not require waiting for #431.

Activity

  1. added
    type:feat
    theme:command-surface
    phase:architecture
    on Apr 26, 2026
  2. added a commit that references this issue on May 7, 2026
    dce5866
  3. Sinity commented on May 7, 2026

    @Sinity
    OwnerAuthor

    Closed-scope audit found remaining CLI format-profile drift; leaving this issue closed and tracking reconciliation in #944.

    Concrete gaps observed:

    • polylogue/cli/click_option_groups.py has the shared format option group, but polylogue/cli/commands/tags.py and polylogue/cli/commands/neighbors.py still expose JSON-only choices.
    • Query/raw/show retain command-specific format subsets rather than one obviously audited command x format matrix.
    • Existing JSON-envelope tests help, but they do not pin the full format-profile contract across the command inventory.

    #944 should make the command surface truthful and either finish the matrix or document/split intentional exceptions.

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

    area:cliphase:architecturetheme:command-surfacetype:feat

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions