Add man pages for bm CLI commands
Motivation
Man pages are the original machine-readable documentation — structured, parseable, and now the ideal format for AI agents to understand CLI tools. With agents increasingly using CLIs directly (see Karpathy's take), shipping proper man pages makes bm a first-class citizen in agent workflows.
The bm CLI has enough subcommands and complex flag combinations (especially search-notes with --hybrid, --min-similarity, --metadata-filters, --project, etc.) that --help output alone isn't sufficient. Man pages provide the EXAMPLES section that both humans and agents need.
References:
- Unix man pages: AI-friendly documentation since 1971
- Unix.com: man pages, LLMs, and why this old site still lives
Proposal
1. Ship man pages with bm
Start with the most complex commands:
bm-search-notes(1)— hybrid search, metadata filters, similarity thresholds, project scopingbm-build-context(1)— depth, memory URLs, graph traversalbm-project(1)— add, list, remove, reindexbm(1)— overview with SEE ALSO to subcommands
Each man page should follow the standard structure:
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES ← this is the key section for agents
EXIT STATUS
SEE ALSO
The EXAMPLES section is critical — real-world queries that agents can adapt:
EXAMPLES
Search by semantic similarity:
bm tool search-notes "machine learning" --hybrid
Filter by metadata:
bm tool search-notes --metadata '{"status": "active"}' --project claw
Cross-project search:
bm tool search-notes "API design" --project specs
Lower similarity threshold for broader results:
bm tool search-notes "coffee" --min-similarity 0.3 --page-size 20
2. Implementation options
- click-man: Auto-generate man pages from Click/Typer CLI definitions. Gets us 80% there.
- Hand-written mdoc/roff: Better EXAMPLES sections, but more maintenance.
- Hybrid: Auto-generate structure, hand-write EXAMPLES.
Install location: man bm-search-notes should work after uv tool install basic-memory.
3. MCP prompts as structured docs
The same man-page content could be served via MCP prompts capability — giving agents structured reference docs (SYNOPSIS + EXAMPLES) before they call a tool. This is the programmatic equivalent of man for MCP-connected agents.
Second slice: #1389 bundles the 23 section-3 pages in the package (src/basic_memory/man/man3/), serves them as MCP resources (memory://man index, memory://man/<page> with any spelling of a page reference), and adds bm man <topic> / bm man list. bm man install unchanged. Next: registry generator for SYNOPSIS/PARAMETERS, bm man install --project, groff for section 3.
Third slice: #1393 makes the MCP SYNOPSIS block on every section-3 page a generated section — just man-regen renders it from the live tool registry, pages flip to generated: registry, and a test holds the shipped blocks byte-equal to the rendering (a tool change without a regenerate fails CI). Also adds basic-memory-diagnostics(3), so the section-3 corpus now matches the tool registry one-to-one. Remaining from the roadmap: PARAMETERS from schema descriptions, section-1 pages from Typer help, bm man install --project.
Hey Paul — nice work landing the SYNOPSIS generator in #1393! The three-round Codex review cycle that hardened the frontmatter flip and escape handling is a good example of the kind of incremental cleanup that compounds.
I'd like to take the next slice: PARAMETERS generation from schema descriptions. The data source is already there — every tool schema exposes description on each property (I checked: all registered tools have descriptions on all params except the no-param basic_memory_diagnostics).
Specifically what I'm thinking:
-
render_parameters()inbasic_memory.man— renders a## PARAMETERSsection from the tool's JSON schemaproperties, producing the same- **name** — descriptionbullet format the hand-written pages use. Required params first, then optional, in schema order (mirroring SYNOPSIS). Type info and defaults woven into the description naturally. -
extract_parameters()/replace_parameters()— regex helpers matching the## PARAMETERSblock, parallel to the existingextract_mcp_synopsis()/replace_mcp_synopsis()pair. -
Update
scripts/update_man_pages.pyto also regenerate PARAMETERS alongside SYNOPSIS. -
Extend the drift test in
tests/test_man_pages.pyto hold shipped PARAMETERS byte-equal to the rendering (same pattern as SYNOPSIS). -
Preserve hand-curated content — the 6 pages that already have PARAMETERS sections (write-note, search-notes, build-context, edit-note, read-note, recent-activity) have field knowledge that goes beyond the schema descriptions (gotcha cross-refs, behavioral notes). The generator should produce the mechanical description; curated additions can either be preserved as-is or folded into tool docstrings upstream so the generator captures them.
The tricky design question: should the generator wholesale replace PARAMETERS (like it does SYNOPSIS), or should there be a merge strategy that preserves hand-written additions? SYNOPSIS is one-to-one with the schema so byte equality makes sense; PARAMETERS currently carry field knowledge (e.g. write-note's notes about overwrite behavior, search-notes' min_similarity threshold guidance) that isn't in the schema. Two approaches:
- Option A: Generator owns PARAMETERS entirely. Curated content migrates to tool docstrings so it flows through the schema.
- Option B: Generator produces a baseline; hand-written pages can extend individual bullets with curated notes that survive regeneration (trickier regex, more maintenance).
I lean toward Option A — it's the same principle that made SYNOPSIS reliable. Happy to hear your preference before starting.
This builds on my earlier contributions (PR #1380 tool reference, #1386 search_notes example fix). Let me know if this slice is available and if you have any preferences on the approach!
Just checking in — let me know if this slice is open or if you'd rather handle it differently. Happy to adjust scope.
Thanks for checking in — yes, this slice is open, and Option A is the direction we want.
Please have the registry generator own the complete ## PARAMETERS section. Parameter-specific details should live in the MCP schema descriptions so they reach both clients and the generated manual; broader explanations, examples, and gotchas should remain in their existing curated sections.
A few scope notes:
- generate every schema property, required first and then optional in schema order;
- render required/default information deterministically rather than trying to merge or interpret existing prose;
- replace the complete PARAMETERS block on regeneration;
- extend the live-registry drift test so every generated page is checked against its actual tool schema;
- use clear scenario-focused tests rather than a parameterized formatting matrix.
Please keep the PR to PARAMETERS generation and any schema-description improvements required to preserve genuinely parameter-specific information. Thanks for taking this on.
Got it, thanks — Option A it is. I'll keep the PR to registry-owned PARAMETERS (required first, then optional, schema order; deterministic required/default rendering; full-block replacement on regen) plus the drift-test extension and scenario-focused tests, with only the schema-description changes needed so nothing parameter-specific from the curated pages gets lost. PR coming shortly.
Opened https://github.com/basicmachines-co/basic-memory/pull/1478 implementing Option A.
Thanks for merging #1478 — good to see PARAMETERS land clean.
I'd like to take the next slice on the roadmap: section-1 pages generated from the Typer help.
Current state: the eight bundled section-1 pages (apropos, cat, find, grep, head, ls, tail, tree) are all generated: hand, and their SYNOPSIS and OPTIONS blocks are mechanical restatements of the POSIX verb definitions in cli/commands/posix.py. They already drift — grep(1)'s SYNOPSIS lists --json, --plain, --project, --local, --cloud, but OPTIONS only documents -F and the pagination flags. That's exactly the class of drift the section-3 work removed.
Proposed scope, mirroring the SYNOPSIS/PARAMETERS split:
render_cli_synopsis()/render_options()inbasic_memory.man, rendering from the Typer command tree (typer.main.get_command(app), walking to the named subcommand) rather than the MCP registry — arguments first, then options in declaration order, with defaults rendered deterministically the same wayrender_parametersdoes.extract_options()/replace_options()regex helpers alongside the existingextract_parameters()/replace_parameters()pair, and a section-1 branch inregenerate_page().scripts/update_man_pages.pyregenerates section-1 alongside section-3, sojust man-regenstays the one entry point.- Drift test extension in
tests/test_man_pages.py: every section-1 page whose command this build registers is byte-equal to the live rendering, plus the ownership-declaration check. Scenario-focused tests, same as last time. - Help text improvements in
posix.pyonly where a flag currently has nohelp=and the generated page would otherwise render an empty bullet.
Out of scope: the groff sources (bm.1, basic-memory.1) stay hand-owned — the COMMANDS overview there isn't one-to-one with anything, and groff generation is its own roadmap item.
One design question before I start. Section-3 declares generated: registry because the MCP tool registry is the source. Section-1's source is the Typer tree, which is a different surface — do you want a distinct token (generated: cli) so generated: names the actual owner, or is one registry value across both simpler to reason about? test_registry_pages_declare_registry_ownership gets the corresponding branch either way. I'd lean toward cli, but it's your frontmatter vocabulary.
The other judgement call: generated OPTIONS will be the complete flag list, so pages like grep(1) grow from two bullets to the full set. I read that as the point — but if you'd rather keep OPTIONS curated and only generate SYNOPSIS on section 1, say so and I'll cut it to that.
PR within a week either way. Happy to start on the cli token and adjust if you prefer otherwise.
Thanks—this fits the existing approach. Please extend the current just man-regen pipeline, using the Typer command tree as the source for section-1 SYNOPSIS and OPTIONS, just as the MCP tool schemas drive section 3.
Use generated: cli, and generate the complete public options list, including shared flags. Keep DESCRIPTION, EXAMPLES, and other curated sections hand-owned. Reuse the existing section-replacement machinery where practical, while preserving CLI-specific syntax such as flag aliases and paired boolean options.
Drift tests and targeted improvements to missing help= text sound right. Agreed on leaving the groff sources out of scope.
The CLI: blocks on section-3 pages are owned by neither generator, and no test holds them to the Typer tree.
search-notes(3) advertises bm tool search-notes ... [--search-type TYPE], but the resolved Click command has no --search-type — it exposes --permalink/--title/--vector/--hybrid. The page is already stale.
Nothing catches this by design: replace_mcp_synopsis deliberately leaves the CLI block alone (test_replace_mcp_synopsis_touches_only_the_mcp_block asserts it), and the section-1 generator only walks pages named after a bm verb — bm tool <verb> is not one. 12 of 22 section-3 pages carry such a block.
Which way do you want it?
(a) section-3 generator also owns CLI:, rendered from the Typer tree and drift-tested beside the MCP SYNOPSIS; or
(b) CLI: leaves section 3 for a bm tool section-1 page, section 3 stays MCP-only.
The drift test lands in a different place for each, so this needs deciding first.
Done. bm.1 and the section-1 pages ship in the package, with SYNOPSIS/OPTIONS generated from Typer (#1524). The stale bm tool search-notes CLI block raised above went away with the 1.0 tool surface (#1881); search-notes(3) no longer exists.