Skip to content

refactor(devtools): make command metadata single-source #617

Closed as not planned

Description

@Sinity

Problem

The devtools command surface has two parallel metadata systems:

  • devtools.__main__ dispatches through COMMAND_SPECS from devtools/command_catalog.py.
  • Each command module defines its own local argparse.ArgumentParser for options/help.

Evidence from current master:

  • devtools/command_catalog.py declares command names, categories, descriptions, modules, examples, and featured status for docs and discovery.
  • devtools.__main__ implements custom top-level argparse dispatch, command listing, JSON inventory, and --json forwarding.
  • 45 devtools/*.py modules construct their own argparse.ArgumentParser.
  • Generated docs and devtools --list-commands --json are catalog-derived, while command help and option parsing are parser-derived.
  • The product CLI already uses Click, but devtools reimplements grouping/listing/help routing separately.

Impact

Every devtools command has at least two sources of truth: catalog metadata and local parser metadata. That adds boilerplate to every new command and makes drift easy: descriptions, examples, JSON support, and option-level documentation can disagree across docs, inventory, and actual command help.

This also limits verifiability. devtools --list-commands --json cannot expose option-level metadata without inspecting or duplicating each local parser.

Acceptance criteria

  • Pick one source of truth for devtools command metadata.
  • Either migrate devtools to a Click/Typer-style command tree, or define a small first-party command-spec DSL that generates argparse parsers, docs, and JSON inventory from one declaration.
  • Preserve existing command names and common invocations.
  • Make generated docs/devtools.md and devtools --list-commands --json derive from the same metadata as command help.
  • Add a regression check that every registered command has synchronized docs/help/inventory metadata.
  • Run focused devtools command tests and devtools verify --quick.

Ref #578
Ref #610

Activity

  1. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Additional compactness note: the desired direction is specifically to keep CommandSpec as the docs/control-plane registry, but use Click as the executor for the top-level devtools command group.

    Current evidence:

    • devtools/__main__.py hand-rolls top-level dispatch with argparse, an unknown-command check, and --json argv splicing.
    • devtools/command_catalog.py separately maintains command metadata and imports entrypoints by module string.
    • Individual devtools modules mostly still own their own argparse parsers.

    A good first PR does not need to convert every subcommand to Click. It can build a generated Click group over COMMAND_SPECS, preserve current subcommand argv forwarding, and remove top-level custom dispatch/error/listing behavior. Later PRs can migrate subcommands opportunistically.

    Ref #578

  2. Sinity commented on May 1, 2026

    @Sinity
    OwnerAuthor

    Superseded by #625. I consolidated this finding into the composite issue so the work can be handled as one coherent slice instead of as a tiny standalone ticket. The original evidence remains available in this issue history.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions