Skip to content

fix(cli): umbrella CLI standardization slice 5 — mounts, dedupe, completion group, categorized help - #352

Merged
ywatanabe1989 merged 5 commits into
developfrom
fix/umbrella-cli-standardization
Jul 7, 2026
Merged

fix(cli): umbrella CLI standardization slice 5 — mounts, dedupe, completion group, categorized help#352
ywatanabe1989 merged 5 commits into
developfrom
fix/umbrella-cli-standardization

Conversation

@ywatanabe1989

Copy link
Copy Markdown
Collaborator

Slice 5 of the CLI-standardization plan (scitex-dev proposal 2026-0707-cli-standardization.md; slices 1-4 landed in scitex-dev as #306/#307/#308/#310). Four logical commits, verified against the real CLI from this branch (PYTHONPATH=<worktree>/src, /opt/venv-sac interpreter).

1. Fix broken mounts (writer crash, scholar missing)

  • scitex writer --help crashed (AttributeError: 'function' object has no attribute 'make_context'): the generic registry probe picked up scitex_writer._cli.main — a plain console-script function — instead of the click group. New doctrine §5b re-export shim scitex/cli/writer.py mounts scitex_writer._cli.main_group, and LazyGroup._load_lazy now skips any probed attribute that is not a click command, so this crash class is closed for every peer.
  • scitex scholar was not mounted: no probe shape matched the standalone entry point scitex_scholar._cli_main:cli. Added that probe.

Verified: scitex writer --help and scitex scholar --help both exit 0 and render the standalone groups.

2. Dedupe duplicate namespaces

notifynotification, verifyclew, eventsevent, socialiasocial. The old names are no longer registered; when scitex-dev ships click_compat (present in the repo, not yet in the released 0.21.0) they come back as hidden warn-phase deprecated aliases that forward to the canonical command (3-phase ladder, removed in v3.0); with an older scitex-dev they are simply excluded.

  • events was a dead entry: the scitex-events peer ships no CLI, so scitex events appeared in help but failed on invocation.
  • figrecipe/plt is intentionally kept: scitex-plt is a published identity-alias package (scitex_plt is figrecipe → True) and doctrine §5b's brand table documents scitex plt as a figrecipe mount. figrecipe is canonical; plt self-describes as "(alias for figrecipe)".

3. Canonical completion noun group (doctrine §1b, amended 2026-07-07)

  • Moved out of main.py into scitex/cli/completion.py (lazily mounted; main.py drops to 276 lines).
  • Bare scitex completion now shows group help — it no longer silently auto-installs.
  • completion install gains --dry-run (prints target rc file + script, writes nothing) — subsumes the old bash/zsh/fish script-dump leaves, which remain as hidden warn-phase deprecated leaves (still print the script, warn on stderr, removed in v3.0).
  • completion status unchanged.

4. Root help: categories, -V, real one-liners

  • Root help renders the doctrine §4a fixed ordered headers (Core / Data & Sync / Service / Diagnostics / Introspection / Shell; Other catch-all stays empty). Implemented inside LazyGroup.format_commands — scitex-dev's CategorizedGroup resolves real command objects, which would defeat the lazy mount and reintroduce the ~45 s cold start, hence the local implementation following the same seven-category order.
  • -V added as the short form of --version.
  • ~25 mounted groups whose one-liner degraded to the bare package name when the peer wasn't installed (dataset dataset, git git, hpc hpc, ...) now fall back to curated one-liners sourced from each package's own pyproject description.

Tests

tests/scitex/cli/{test_main,test_completion,test__lazy_subcommands}.py — 84 passed, 2 skipped (the two skips are the click_compat-gated alias-forward tests; that helper is not in the released scitex-dev yet). Existing tests/scitex/test___main__.py and tests/scitex/cli/test___init__.py still green.

Notes / follow-ups

  • src/scitex/cli/scholar/ (in-tree scholar implementation) is a pre-existing parallel implementation of the standalone scholar CLI; it keeps its own tests and is untouched here. Reconciling it with the standalone (doctrine §5b single-source rule) is a follow-up.
  • The socialia registry record should eventually get umbrella_subcommand: "social" in scitex-dev; src/scitex/cli/social.py is also a §5b-forbidden subprocess wrapper — out of scope here.
  • develop CI is currently red from a pre-existing py3.13 pytest segfault (run 28854068590), unrelated to this change.

🤖 Generated with Claude Code

- scitex writer --help crashed with AttributeError: the registry probe
  picked up scitex_writer._cli.main (a plain console-script function)
  instead of the click group. Add the doctrine 5b re-export shim
  (scitex/cli/writer.py -> scitex_writer._cli.main_group) and make the
  lazy loader skip non-click-command attributes so a probe can never
  mount an uncallable object again.
- scitex scholar was not mounted: no probe matched the standalone's
  entry point scitex_scholar._cli_main:cli. Add that probe shape.
…iases

notify->notification, verify->clew, events->event, socialia->social.
The old names are no longer registered as lazy subcommands; when
scitex-dev's click_compat helper is importable (scitex-dev > 0.21.0)
they come back as hidden warn-phase deprecated aliases that forward to
the canonical command (doctrine 3-phase ladder, removed in v3.0); with
an older scitex-dev they are simply excluded.

figrecipe/plt is intentionally NOT deduplicated: scitex-plt is a
published identity-alias package for figrecipe and doctrine 5b's brand
table documents 'scitex plt' as a figrecipe mount.

Hidden commands (the aliases) are now skipped in root help output.
Doctrine 1b (04_exceptions.md, amended 2026-07-07): a bare completion
command is banned; the completion GROUP with verb subcommands is the
canon. Changes:

- move the group out of main.py into scitex/cli/completion.py (lazily
  mounted like every other wrapper; main.py shrinks well under the
  512-line cap)
- bare 'scitex completion' now shows group help instead of silently
  auto-installing
- 'completion install' gains --dry-run: prints the target rc file and
  the completion script without touching the filesystem (subsumes the
  old bash/zsh/fish script-dump leaves)
- 'completion bash|zsh|fish' become hidden warn-phase deprecated
  leaves: still print the script, warn on stderr, removed in v3.0
- root help examples updated ('scitex completion --show' never existed)
- root help now renders the doctrine 4a fixed ordered category headers
  (Core / Data & Sync / Service / Diagnostics / Introspection / Shell;
  Other is the catch-all and stays empty) — implemented inside
  LazyGroup.format_commands so no lazy subcommand is imported for help
  (scitex-dev's CategorizedGroup resolves real command objects, which
  would defeat the lazy mount and reintroduce the ~45s cold start)
- add -V as the short form of --version (doctrine 08 universal flags)
- ~25 mounted groups whose one-liner degraded to the bare package name
  when the peer was not installed (dataset, git, hpc, newb, datetime,
  ...) now fall back to a curated one-liner sourced from each package's
  own pyproject description (_INTERNAL_HELP renamed _FALLBACK_HELP)
- writer/scholar mount smoke (--help exits 0)
- retired duplicates hidden from help; warn-phase alias help page when
  scitex-dev click_compat is importable, unknown-command otherwise
- completion noun group: verbs listed, deprecated bash/zsh/fish leaves
  hidden but still printing the script with a stderr warning,
  install --dry-run prints plan and never writes
- -V short flag; 4a category headers, order, and empty Other
- builder unit tests: alias exclusion, scholar probe shape, writer
  wrapper override, fallback one-liners
@ywatanabe1989
ywatanabe1989 merged commit 80c9883 into develop Jul 7, 2026
7 checks passed
@ywatanabe1989
ywatanabe1989 deleted the fix/umbrella-cli-standardization branch July 7, 2026 10:46
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant