Skip to content

Prime CLI v1#766

Open
xeophon wants to merge 21 commits into
mainfrom
codex/compact-command-registry
Open

Prime CLI v1#766
xeophon wants to merge 21 commits into
mainfrom
codex/compact-command-registry

Conversation

@xeophon

@xeophon xeophon commented Jun 29, 2026

Copy link
Copy Markdown
Member

Summary

Prime CLI v1 — rewrite the command surface around a declarative command registry and strict Pydantic leaf configs, with a clean Prime ↔ Verifiers ownership boundary. Supersedes #760 (this branch includes those commits).

What changed

Command architecture

  • A data-driven command_registry + longest-path dispatcher replaces the Typer / leaves/ routing. Default-command groups, implicit routing, and Typer contexts are gone.
  • Every Prime-owned leaf now has a strict Pydantic *Config model and a run(config) entrypoint; the router parses Prime-owned handlers via prime-pydantic-config.
  • Explicit command paths replace the implicit ones: prime eval run, prime eval submit, prime train run, prime lab view, prime env install owner/environment@version.
  • The registry is compact (~400 lines smaller): module and config_attr are derived from the path via a 3-entry module-alias map (eval→evals, secret→secrets, train→rl) plus one module_override for the prime train usage exception. Each entry keeps only path, summary, section, run_attr, positionals, and optional verifiers / pre_exec.
  • Per-leaf config schemas are inlined into their command modules (previously *_configs.py), consumed via Command.config_attr.
  • Rich group-level help panels are restored in command_router.py.

Prime ↔ Verifiers boundary

  • Prime owns the platform control plane: account contexts, Hub CRUD and publishing, public/private acquisition, downloads, wheel caching and install, hosted evaluation and training, Lab, compute, and account workflows.
  • Verifiers owns the local runtime and is exec'd with native argv (no rewriting): eval run, env init / validate / serve, and gepa run. Each such command declares verifiers=<name>; the router execs verifiers.v1.cli.* (eval/init/serve/validate) and verifiers.scripts.gepa directly through the selected workspace interpreter.
  • env init keeps a Prime-side pre_exec preflight hook (lab hygiene) that runs before the Verifiers exec, replacing the old subprocess-run-then-hygiene sequence.
  • Verifiers becomes the single source of truth for its artifact format: eval-artifact loading and result conversion delegate to verifiers.read_upload_data / convert_results_for_upload. Prime keeps only the hosted-eval upload (the add-on) and an invalid-line warning. The eval manifest contract and the eval-run sidecar are removed.

Deprecated alias

  • prime rl is hidden and deprecated. Using it prints [DEPRECATED] The 'rl' command is deprecated. Use 'prime train' instead. and dispatches to prime train.

Platform

  • requires-python = ">=3.11,<3.14" (drops Python 3.10); CI and release Docker matrices are aligned.
  • verifiers>=0.1.15.dev371; the Verifiers git pin is removed from uv.sources.
  • New docs/verifiers-v1-cli.md documents the Prime vs Verifiers ownership split and native artifacts.

Companion change

Verifiers CLI lifecycle surface: PrimeIntellect-ai/verifiers#1857

Verification

  • ruff check / ruff format --check clean across packages/prime.
  • Full suite against the Verifiers PR head (0.1.15.dev409): 1050 passed, 2 skipped.
  • test_command_router.py green, including the command-contract test that imports every command module and resolves run_attr / config_attr / verifiers, and the no-typer-in-source test.

xeophon added 19 commits June 23, 2026 11:34
Removes the `prime_cli/leaves/` layer: command callbacks now live in
`prime_cli/commands/` with their Pydantic config schemas beside them in
`*_configs.py`, consumed by the router via `Command.config_attr`.

`command_registry.py` shrinks ~400 lines: `module` is derived from
`path[0]` via a 3-entry alias map (`eval->evals`, `secret->secrets`,
`train->rl`) plus a single `module_override` for the `train usage`
exception, and `config_attr` is derived from the path. The 135 entries
keep only `path`, `summary`, `section`, `run_attr`, `raw`,
`positionals`.

Rich group-level help panels are restored in `command_router.py` (the
per-command pydantic_config panels were already present).

Tests updated for Click 8.2.1 console-width pinning and
whitespace-normalized assertions.
xeophon and others added 2 commits June 29, 2026 11:19
Remove the 25 separate *_configs.py files by merging each module's
config schemas directly into the corresponding commands/<name>.py.
Configs are placed at the top of each module (above command functions)
so builtin-name shadowing (e.g. def list) does not break pydantic
annotation evaluation; from __future__ import annotations is added
where the merged config classes are referenced before definition.

Update test imports that referenced the removed *_configs modules to
import the config classes from their command modules instead.

Net -309 lines (per-file boilerplate removed). Full suite green
(1055 passed, 2 skipped).

Amp-Thread-ID: https://ampcode.com/threads/T-019f0942-a19e-752c-be0a-0288e6e7f22f
Co-authored-by: Amp <amp@ampcode.com>
Q1 - eliminate the raw run_leaf(leaf_args) forwarding pattern:
  * Command now declares verifiers (a Verifiers CLI module name)
    instead of raw=True + a thin run_attr forwarder.
  * The router execs verifiers.v1.cli.* directly for those commands, so
    gepa.py, run_eval_cmd, and env serve/validate disappear.
  * env init keeps Prime-side work as a pre_exec hook
    (init_preflight) that runs lab-hygiene fixes before the Verifiers
    exec, replacing the old subprocess-run-then-hygiene sequence.

Q2 - stop reimplementing Verifiers' own artifact format in Prime:
  * _load_eval_directory -> verifiers.read_upload_data().as_dict()
    (Prime keeps only the invalid-line warning, an add-on).
  * _has_eval_files/_validate_eval_path/_discover_eval_outputs
    -> has_eval_artifacts/resolve_eval_artifact_dir/
    discover_eval_artifact_dirs.
  * convert_eval_results -> delegates to
    verifiers.convert_results_for_upload (byte-identical logic).
  Verifiers is now the single source of truth for its artifact format; Prime
  only owns the hosted-eval upload (the add-on).

Tests updated to mock prime_cli.command_router.exec_verifiers_process
and the new registry shape. Net -206 lines. Suite green (1050 passed,
2 skipped) against verifiers 0.1.15.dev409.

Amp-Thread-ID: https://ampcode.com/threads/T-019f0942-a19e-752c-be0a-0288e6e7f22f
Co-authored-by: Amp <amp@ampcode.com>
@xeophon xeophon changed the title Compact the Prime CLI command registry and finish leaves→commands Prime Jun 29, 2026
@xeophon xeophon changed the title Prime Prime CLI v1 Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant