Skip to content

Commit 64e49d7

Browse files
authored
docs: add CLI reference page and remove CLI from API docs (#704) (#852)
* docs: add CLI reference page and remove CLI from API docs (#704) Remove cli/ from the generated API reference (it's a user tool, not a public Python API) and replace it with an auto-generated CLI Reference page under docs/docs/reference/cli.md. The new generate_cli_reference.py script introspects the Typer app at build time, extracting flags, types, defaults, help strings, and structured docstring sections (Prerequisites, Output, Examples, See Also). Strict mode (--strict) fails the build if any command has incomplete documentation. - Remove "cli" from PACKAGES in generate-ast.py - Remove cli from audit_coverage.py discovery and quality scope - Add generate_cli_reference.py with strict validation - Integrate into build.py (Step 4, --strict) and CI workflow - Add 21 unit tests for the generator (test_cli_reference.py) - Wire docs-autogen tests into docs-publish CI workflow - Enrich all CLI command docstrings with Prerequisites, Output, Examples, and See Also sections - Add cross-links from 5 guide pages back to CLI reference - Add 12 Mintlify redirects for old /api/cli/* URLs - Remove dead m decompose glossary entry - Add CLI docstring convention to CONTRIBUTING.md and AGENTS.md - Add clidocs/clidocs-clean poe tasks * fix(ci): scope docs-publish test step to CLI reference tests only The full tooling/docs-autogen/ test suite has 13 pre-existing failures in test_validate.py, test_escape_mdx.py, and test_anchor_collisions.py. Scope the CI step to test_cli_reference.py to avoid blocking on unrelated failures. * fix: address code review findings - Fix wrong filename in module docstring (hyphens -> underscores) - Validate before writing file (fail early with --strict) - Add missing redirects for serve/ and fix/ old API pages - Add Examples: section to CONTRIBUTING.md template and rules * fix: address remaining code review findings - Convert See Also link text from URL slugs to human-readable titles with proper capitalisation (3/3 reviewer consensus) - Remove dead discover_cli_commands() from audit_coverage.py - Switch flag formatting from double to single backticks - Filter --help param from synopsis, options tables, and strict validator - Apply _rst_to_md to root intro text - Simplify test_rst_backticks test now double backticks are gone * docs: update docs-autogen README for CLI reference pipeline - Add clidocs/clidocs-clean to quick start - Add Step 4 (generate_cli_reference.py) to pipeline overview - Add generate_cli_reference.py and test file to file structure - Remove cli/ from generated docs tree, add reference/cli.md - Remove stale Makefile shim reference - Fix make -> poe reference in validate step * docs: add prerequisites section to docs-autogen README Document the install command (matching CI) and Node.js requirement for local doc builds and previews. * fix: add friendly error when CLI extras are missing generate_cli_reference.py now catches ImportError during CLI app import and prints the required install command instead of a raw traceback. * docs: fix docs-autogen README gaps for CLI reference pipeline - Correct apidocs intro: build.py now runs 4 steps, not 2 - Document --strict distinction: clidocs is lenient, apidocs pipeline is always strict; add standalone --strict invocation example - Add CLI reference generator configuration section (--strict, --docs-root, --source-dir, --skip-cli-reference) - Document that full clean requires apidocs-clean + clidocs-clean - Add test_cli_reference.py to Development examples - Replace stale `make docs` references with `uv run poe apidocs` * docs: fix pipeline diagram and AGENTS.md traceability for CLI reference - Pipeline Overview: replace validate.py (step 3) with the actual build.py step 3 (generate-ast.py --nav-only); move validate.py to an "optional tools" section below the diagram - AGENTS.md: add test command and link to docs-autogen README so the full local testing workflow is traceable from the agent guide * docs: add node version workaround and API 404 to troubleshooting - Prerequisites: document node@22 PATH override for systems running node v25+ (mintlify dev rejects non-LTS versions) - Troubleshooting: add entries for node version error and API Reference tab 404 (generated artefacts must be built first) * docs: simplify node version requirement and troubleshooting entries
1 parent cb1a4b9 commit 64e49d7

24 files changed

Lines changed: 1170 additions & 99 deletions

.github/workflows/docs-publish.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ jobs:
8181
- name: Generate API documentation
8282
run: uv run python tooling/docs-autogen/build.py
8383

84+
# -- Run docs-autogen unit tests ------------------------------------------
85+
86+
- name: Run CLI reference tests
87+
run: uv run pytest tooling/docs-autogen/test_cli_reference.py -v --tb=short
88+
8489
# -- Validate static docs ------------------------------------------------
8590

8691
- name: Lint static docs (markdownlint)

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ pyrightconfig.json
455455
.claude/*
456456
!.claude/settings.json
457457

458-
# Generated API documentation (built by tooling/docs-autogen/)
458+
# Generated documentation (built by tooling/docs-autogen/)
459459
docs/docs/api/
460460
docs/docs/api-reference.mdx
461+
docs/docs/reference/cli.md
461462
.venv-docs-autogen/

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ mkdir -p .bob && ln -s ../.agents/skills .bob/skills
8888
- Use `...` in `@generative` function bodies
8989
- Prefer primitives over classes
9090
- **Friendly Dependency Errors**: Wraps optional backend imports in `try/except ImportError` with a helpful message (e.g., "Please pip install mellea[hf]"). See `mellea/stdlib/session.py` for examples.
91+
- **CLI command docstrings**: Typer command functions in `cli/` follow an enriched convention with `Prerequisites:` and `See Also:` sections — these feed the auto-generated CLI reference page. See [`docs/docs/guide/CONTRIBUTING.md`](docs/docs/guide/CONTRIBUTING.md) for the full pattern. Regenerate after changes: `uv run poe clidocs`. Test the generator: `uv run pytest tooling/docs-autogen/test_cli_reference.py -v`. Full pipeline docs: [`tooling/docs-autogen/README.md`](tooling/docs-autogen/README.md).
9192
- **Backend telemetry fields**: All backends must populate `mot.usage` (dict with `prompt_tokens`, `completion_tokens`, `total_tokens`), `mot.model` (str), and `mot.provider` (str) in their `post_processing()` method. `mot.streaming` (bool) and `mot.ttfb_ms` (float | None) are set automatically in `astream()` — backends do not need to set them. Metrics are automatically recorded by `TokenMetricsPlugin` and `LatencyMetricsPlugin` — don't add manual `record_token_usage_metrics()` or `record_request_duration()` calls.
9293

9394
## 6. Commits & Hooks

cli/alora/commands.py

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,25 @@ def alora_train(
3131
max_length: int = typer.Option(1024, help="Max sequence length"),
3232
grad_accum: int = typer.Option(4, help="Gradient accumulation steps"),
3333
):
34-
"""Train an aLoRA or LoRA model on your dataset.
34+
"""Train an aLoRA or LoRA adapter on a labelled dataset.
35+
36+
Fine-tunes a base causal language model using a JSONL dataset of item/label
37+
pairs. Supports both aLoRA (asymmetric LoRA) and standard LoRA adapters.
38+
39+
Prerequisites:
40+
Mellea installed with adapter extras (``uv add mellea[adapters]``).
41+
A CUDA, MPS, or CPU device available for training.
42+
43+
Output:
44+
Saves adapter weights to the path specified by ``--outfile``. The output
45+
directory contains an ``adapter_config.json`` and the trained weight
46+
files, ready for upload or local inference.
47+
48+
Examples:
49+
m alora train data.jsonl --basemodel ibm-granite/granite-3.3-2b-instruct --outfile ./adapter
50+
51+
See Also:
52+
guide: advanced/lora-and-alora-adapters
3553
3654
Args:
3755
datafile: JSONL file with item/label pairs for training.
@@ -79,7 +97,23 @@ def alora_upload(
7997
"processing if the model is invoked as an intrinsic.",
8098
),
8199
):
82-
"""Upload trained adapter to remote model registry.
100+
"""Upload a trained adapter to a remote model registry.
101+
102+
Pushes adapter weights to Hugging Face Hub, optionally packaging the adapter
103+
as an intrinsic with an ``io.yaml`` configuration file.
104+
105+
Prerequisites:
106+
Hugging Face CLI authenticated (``huggingface-cli login``).
107+
108+
Output:
109+
Creates or updates a Hugging Face Hub repository at the name specified
110+
by ``--name`` and uploads the adapter weight files.
111+
112+
Examples:
113+
m alora upload ./adapter --name acme/my-alora
114+
115+
See Also:
116+
guide: advanced/lora-and-alora-adapters
83117
84118
Args:
85119
weight_path: Path to saved adapter weights directory.
@@ -140,6 +174,24 @@ def alora_add_readme(
140174
):
141175
"""Generate and upload an INTRINSIC_README.md for a trained adapter.
142176
177+
Uses an LLM to auto-generate documentation for a trained adapter based on
178+
the training data and model configuration, then uploads it to the Hugging
179+
Face Hub repository.
180+
181+
Prerequisites:
182+
Hugging Face CLI authenticated (``huggingface-cli login``).
183+
An LLM backend available for README generation.
184+
185+
Output:
186+
Generates a README.md file, displays it for confirmation, and uploads
187+
it to the Hugging Face Hub repository specified by ``--name``.
188+
189+
Examples:
190+
m alora add-readme data.jsonl --basemodel ibm-granite/granite-3.3-2b-instruct --name acme/my-alora
191+
192+
See Also:
193+
guide: advanced/lora-and-alora-adapters
194+
143195
Args:
144196
datafile: JSONL file with item/label pairs used to train the adapter.
145197
basemodel: Base model ID or path.

cli/decompose/decompose.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,28 @@ def run(
236236
),
237237
] = False,
238238
) -> None:
239-
"""Runs the ``m decompose`` CLI workflow and writes generated outputs.
239+
"""Break a complex task into ordered, executable subtasks.
240240
241-
Reads user queries from a file or interactive input, runs the decomposition
242-
pipeline for each task job, and writes one JSON file, one rendered Python
243-
program, and any generated validation modules under a per-job output
244-
directory.
241+
Reads user queries from a file or interactive input, runs the LLM-driven
242+
decomposition pipeline for each task job, and writes one JSON file, one
243+
rendered Python script, and any generated validation modules under a per-job
244+
output directory.
245+
246+
Prerequisites:
247+
Mellea installed (``uv add mellea``). An Ollama instance running locally,
248+
or an OpenAI-compatible endpoint configured via ``--backend-endpoint``.
249+
250+
Output:
251+
Creates a directory ``<out-dir>/<out-name>/`` containing a JSON
252+
decomposition result file, a ready-to-run Python script, and any
253+
generated validation modules. One directory per task job.
254+
255+
Examples:
256+
m decompose run --out-dir ./output --input-file tasks.txt
257+
258+
See Also:
259+
guide: guide/m-decompose
260+
guide: how-to/refactor-prompts-with-cli
245261
246262
Args:
247263
out_dir: Existing directory under which per-job output directories are

cli/eval/commands.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,38 @@
44

55
import typer
66

7-
eval_app = typer.Typer(name="eval")
7+
eval_app = typer.Typer(name="eval", help="LLM-as-a-judge evaluation pipelines.")
88

99

1010
def eval_run(
1111
test_files: list[str] = typer.Argument(
1212
..., help="List of paths to json/jsonl files containing test cases"
1313
),
14-
backend: str = typer.Option("ollama", "--backend", "-b", help="Generation backend"),
15-
model: str = typer.Option(None, "--model", help="Generation model name"),
14+
backend: str = typer.Option(
15+
"ollama",
16+
"--backend",
17+
"-b",
18+
help="Inference backend for generating candidate responses (e.g. ollama, openai)",
19+
),
20+
model: str = typer.Option(
21+
None,
22+
"--model",
23+
help="Model name/id for the generation backend; uses backend default if omitted",
24+
),
1625
max_gen_tokens: int = typer.Option(
1726
256, "--max-gen-tokens", help="Max tokens to generate for responses"
1827
),
1928
judge_backend: str = typer.Option(
20-
None, "--judge-backend", "-jb", help="Judge backend"
29+
None,
30+
"--judge-backend",
31+
"-jb",
32+
help="Inference backend for the judge model; reuses --backend if omitted",
33+
),
34+
judge_model: str = typer.Option(
35+
None,
36+
"--judge-model",
37+
help="Model name/id for the judge; uses judge backend default if omitted",
2138
),
22-
judge_model: str = typer.Option(None, "--judge-model", help="Judge model name"),
2339
max_judge_tokens: int = typer.Option(
2440
256, "--max-judge-tokens", help="Max tokens for the judge model's judgement."
2541
),
@@ -29,14 +45,34 @@ def eval_run(
2945
output_format: str = typer.Option(
3046
"json", "--output-format", help="Either json or jsonl format for results"
3147
),
32-
continue_on_error: bool = typer.Option(True, "--continue-on-error"),
48+
continue_on_error: bool = typer.Option(
49+
True,
50+
"--continue-on-error",
51+
help="Skip failed test cases instead of aborting the entire run",
52+
),
3353
):
3454
"""Run LLM-as-a-judge evaluation on one or more test files.
3555
3656
Loads test cases from JSON/JSONL files, generates candidate responses using
3757
the specified generation backend, scores them with a judge model, and writes
3858
aggregated results to a file.
3959
60+
Prerequisites:
61+
Mellea installed (``uv add mellea``). At least one inference backend
62+
available (Ollama by default). A separate judge backend/model is
63+
recommended but optional (defaults to the generation backend).
64+
65+
Output:
66+
Writes evaluation results to ``<output-path>.<output-format>`` (default
67+
``eval_results.json``). The file contains per-test-case scores, judge
68+
verdicts, and aggregate statistics.
69+
70+
Examples:
71+
m eval run tests.jsonl --backend ollama --model granite3.3:2b
72+
73+
See Also:
74+
guide: evaluation-and-observability/evaluate-with-llm-as-a-judge
75+
4076
Args:
4177
test_files: Paths to JSON/JSONL files containing test cases.
4278
backend: Generation backend name.

cli/fix/commands.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,21 @@ def fix_async(
1616
False, "--dry-run", help="Report locations without modifying files"
1717
),
1818
):
19-
"""Fix async calls (aact, ainstruct, aquery) for the await_result default change.
19+
"""Fix async calls for the await_result default change.
20+
21+
Scans Python source files for ``aact``, ``ainstruct``, and ``aquery`` calls
22+
and applies an automated migration to restore blocking behaviour after the
23+
``await_result`` default changed from ``True`` to ``False``.
24+
25+
Prerequisites:
26+
Mellea installed (``uv add mellea``).
27+
28+
Output:
29+
Modifies Python source files in place (unless ``--dry-run``). Prints a
30+
summary of fixed call sites with file paths and line numbers.
31+
32+
Examples:
33+
m fix async src/ --dry-run
2034
2135
Args:
2236
path: File or directory to scan.
@@ -83,7 +97,20 @@ def fix_genslots(
8397
False, "--dry-run", help="Report locations without modifying files"
8498
),
8599
):
86-
"""Rewrite old genslot imports and class names to genstub equivalents.
100+
"""Rewrite genslot imports and class names to genstub equivalents.
101+
102+
Scans Python source files and replaces deprecated ``GenerativeSlot`` imports
103+
and class references with their ``GenerativeStub`` replacements.
104+
105+
Prerequisites:
106+
Mellea installed (``uv add mellea``).
107+
108+
Output:
109+
Modifies Python source files in place (unless ``--dry-run``). Prints a
110+
summary of rewritten references with file paths and line numbers.
111+
112+
Examples:
113+
m fix genslots src/ --dry-run
87114
88115
Args:
89116
path: File or directory to scan.

cli/m.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,15 @@ def callback() -> None:
2323
"""Mellea command-line tool for LLM-powered workflows.
2424
2525
Provides sub-commands for serving models (``m serve``), training and uploading
26-
adapters (``m alora``), decomposing tasks into subtasks (``m decompose``), and
27-
running test-based evaluation pipelines (``m eval``).
26+
adapters (``m alora``), decomposing tasks into subtasks (``m decompose``),
27+
running test-based evaluation pipelines (``m eval``), and applying automated
28+
code migrations (``m fix``).
29+
30+
Prerequisites:
31+
Mellea installed (``uv add mellea``).
32+
33+
See Also:
34+
guide: getting-started/quickstart
2835
"""
2936

3037

cli/serve/app.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,27 @@ def serve(
221221
host: str = typer.Option("0.0.0.0", help="Host to bind to"),
222222
port: int = typer.Option(8080, help="Port to bind to"),
223223
):
224-
"""Serve a FastAPI endpoint for a given script."""
224+
"""Serve a Mellea program as an OpenAI-compatible HTTP endpoint.
225+
226+
Loads a Python script containing a Mellea generative function and exposes it
227+
via a FastAPI server implementing the OpenAI chat completions API. The server
228+
accepts ``POST /v1/chat/completions`` requests.
229+
230+
Prerequisites:
231+
Mellea installed (``uv add mellea``). The target script must define at
232+
least one generative function.
233+
234+
Output:
235+
Starts a long-running HTTP server on the specified host and port.
236+
The ``/v1/chat/completions`` endpoint accepts OpenAI-format chat
237+
completion requests and returns ``ChatCompletion`` JSON responses.
238+
239+
Examples:
240+
m serve my_app.py --port 9000
241+
242+
See Also:
243+
guide: integrations/m-serve
244+
"""
225245
module = load_module_from_path(script_path)
226246
route_path = "/v1/chat/completions"
227247

docs/docs/advanced/lora-and-alora-adapters.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,5 @@ affect other sessions.
158158

159159
**See also:** [Intrinsics](./intrinsics) |
160160
[The Requirements System](../concepts/requirements-system) |
161-
[Write Custom Verifiers](../how-to/write-custom-verifiers)
161+
[Write Custom Verifiers](../how-to/write-custom-verifiers) |
162+
[CLI Reference](../reference/cli)

0 commit comments

Comments
 (0)