docs(v2): generate the CLI reference from stash manifest --json#45
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Jul 5, 2026
db331b9 to
f29a71a
Compare
coderdan
added a commit
to cipherstash/stack
that referenced
this pull request
Jul 8, 2026
…-3431)
Phase 1 of docs/plans/cli-help-and-manifest.md: a single source of truth for
command metadata so help/docs can't drift from the real command set.
- src/cli/registry.ts: Flag/CommandDescriptor/CommandGroup types + the full
command surface (groups, summaries, flags; long/examples for key commands),
populated from the existing HELP surface and per-command flag parsing.
- src/cli/manifest.ts: buildManifest(version) → { name, version, groups[] },
the exact contract the docs generator (cipherstash/docs#45) targets. version
comes from the CLI's package.json.
- `stash manifest --json` emits the structured surface; `stash manifest` prints
a grouped human-readable list. Pure metadata — no native binary required.
Additive and non-breaking; the top-level HELP string is untouched. Rendering
help from the registry (phases 2–4) is the documented follow-on.
Tests: unit coverage for buildManifest shape/version/hidden-exclusion; e2e for
`manifest --json`, `manifest`, and `--help` listing the command.
coderdan
added a commit
to cipherstash/stack
that referenced
this pull request
Jul 8, 2026
…-3431)
Phase 1 of docs/plans/cli-help-and-manifest.md: a single source of truth for
command metadata so help/docs can't drift from the real command set.
- src/cli/registry.ts: Flag/CommandDescriptor/CommandGroup types + the full
command surface (groups, summaries, flags; long/examples for key commands),
populated from the existing HELP surface and per-command flag parsing.
- src/cli/manifest.ts: buildManifest(version) → { name, version, groups[] },
the exact contract the docs generator (cipherstash/docs#45) targets. version
comes from the CLI's package.json.
- `stash manifest --json` emits the structured surface; `stash manifest` prints
a grouped human-readable list. Pure metadata — no native binary required.
Additive and non-breaking; the top-level HELP string is untouched. Rendering
help from the registry (phases 2–4) is the documented follow-on.
Tests: unit coverage for buildManifest shape/version/hidden-exclusion; e2e for
`manifest --json`, `manifest`, and `--help` listing the command.
stash manifest --json
PROTOTYPE for review. Generates /reference/cli from the shipped `stash` CLI so the reference can't drift from the actual command surface, and stamps every page with the CLI version it was generated from. - scripts/generate-cli-docs.ts — parses `stash --help` (captured to a fixture) into a manifest, then renders one page per top-level command (grouped Setup/Auth/Database/Schema/Encrypt/Deployment) with a "Generated from stash v0.16.0" banner, a verifiedAgainst.cli facet, and [cli] / [cli, eql] components per the content-model tagging rule. - `bun run generate-docs:cli` (package.json). - scripts/fixtures/stash-help-0.16.0.txt — captured input. - content/docs/reference/cli/* — generated output (10 command pages + index). Bootstrap note: `stash` 0.16.0 is a hand-rolled TS CLI with no machine-readable output and no per-command --help, so we parse the single top-level --help. Target: add `stash manifest --json` to the CLI, then swap loadManifest() to read it and delete the parser — the page format stays identical. Today's --help is thin (no args, no per-command examples, auth/encrypt subcommands undetailed); those gaps are exactly what the JSON manifest fills. Surfaces the drift too: 0.16.0 uses `db install` (not `eql install`) and has ~15 commands the hand-written pages never documented. Claude-Session: https://claude.ai/code/session_01CqDNqLSEEkCi7xAJFq7HJA
…build - Resolve the latest published version via `npm view stash version` and run that exact version live, so a new `stash` release refreshes the docs the next time the script runs (offline: falls back to the cached fixture). Removes the pinned CLI_VERSION constant. - Wire `generate-docs:cli` into `prebuild`, next to the EQL/TypeDoc generators, so every production build regenerates the CLI reference from the latest CLI. - Rename the fixture to a version-agnostic cache (scripts/fixtures/stash-help.txt). Claude-Session: https://claude.ai/code/session_01CqDNqLSEEkCi7xAJFq7HJA
…amples Adds a supplement hook to the CLI generator: an optional scripts/cli-supplements/<command>.md is merged after the generated reference (synopsis + flags), so the rich per-command narrative and curated examples the thin `stash --help` can't provide can be authored now, without waiting on the CLI. Supplements live outside content/ so they're never treated as pages or wiped by the clean step. Demonstrated on `auth` (device-code flow + keyset binding, grounded in the CLI source). Content-model direction: per-command reference detail (examples, flag help) should migrate into the CLI itself (long-help + examples, GitHub-CLI/cobra style) and be generated from there; cross-command conceptual narrative (the profile / workspace model) belongs in a linked CLI concept page. The supplement hook is the interim bridge and the seam for both. Claude-Session: https://claude.ai/code/session_01CqDNqLSEEkCi7xAJFq7HJA
stash CLI 0.17 ships the `manifest` command (structured, versioned command surface), so swap the generator off `--help` scraping onto `stash manifest --json` and delete the text parser — the realization of this PR's stated target. - loadManifest() now runs `npx stash@<version> manifest --json` and projects it onto the renderer's model; nav groups + order come straight from the CLI. - Per-command flags carry their `default` and `env` (folded into the flag description); examples come from the manifest. Pipes in flag values (`--eql-version <2|3>`) are escaped so the GFM table renders. - Fixture swapped from stash-help.txt to stash-manifest.json. - Regenerated against 0.17.0: new `eql` group (eql install/upgrade/status), new `doctor` + `manifest` pages, `db` no longer lists install/upgrade. types:check passes; generator lints clean (bar pre-existing noNonNullAssertion style warnings shared with the original).
f6797a7 to
6a7ac7b
Compare
The `auth regions --json` flag description is "Emit machine-readable
[{ slug, label }] ...". MDX parsed `{ slug, label }` as a JS expression,
so prerendering /reference/cli/auth threw `ReferenceError: slug is not
defined` and failed the build. (The earlier `<tt>` failure masked this;
it surfaced once #52 landed via rebase.)
Escape `{`/`}` (and stray `<`) in manifest-derived prose — flag
descriptions and summaries. Flag names/values stay in code spans, which
are literal, so they're untouched. Verified: `next build` prerenders all
355 pages, including /reference/cli/auth.
There was a problem hiding this comment.
Pull request overview
This PR adds a generator that produces the v2 /reference/cli docs directly from the shipped stash CLI’s structured stash manifest --json output, aiming to prevent the CLI reference from drifting from the actual command surface.
Changes:
- Add
scripts/generate-cli-docs.tsto fetch the latest publishedstashversion, readmanifest --json, and render MDX pages +meta.jsonfor/content/docs/reference/cli. - Wire the generator into
prebuildand add agenerate-docs:clipackage script. - Add a cached fixture (
scripts/fixtures/stash-manifest.json) and a supplements mechanism (scripts/cli-supplements/<command>.md) to merge hand-authored prose after generated content.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/generate-cli-docs.ts | New CLI-doc generator consuming stash manifest --json, rendering reference pages + meta. |
| scripts/fixtures/stash-manifest.json | Cached manifest fixture for offline/failed CLI execution scenarios. |
| scripts/cli-supplements/auth.md | Hand-authored supplemental prose merged into the generated auth page. |
| package.json | Adds generate-docs:cli and runs it during prebuild. |
| content/docs/reference/cli/index.mdx | Generated CLI reference index page listing commands by manifest group. |
| content/docs/reference/cli/meta.json | Generated nav/meta describing CLI pages grouped by manifest order. |
| content/docs/reference/cli/auth.mdx | Generated auth group page + merged supplement content. |
| content/docs/reference/cli/db.mdx | Generated db group page from manifest. |
| content/docs/reference/cli/doctor.mdx | Generated doctor command page from manifest. |
| content/docs/reference/cli/encrypt.mdx | Generated encrypt group page from manifest. |
| content/docs/reference/cli/env.mdx | Generated env command page from manifest. |
| content/docs/reference/cli/eql.mdx | Generated eql group page from manifest. |
| content/docs/reference/cli/impl.mdx | Generated impl command page from manifest. |
| content/docs/reference/cli/init.mdx | Generated init command page from manifest. |
| content/docs/reference/cli/manifest.mdx | Generated manifest command page from manifest. |
| content/docs/reference/cli/plan.mdx | Generated plan command page from manifest. |
| content/docs/reference/cli/schema.mdx | Generated schema group page from manifest. |
| content/docs/reference/cli/status.mdx | Generated status command page from manifest. |
| content/docs/reference/cli/wizard.mdx | Generated wizard command page from manifest. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Vercel preview feedback on /reference/cli/auth: - Remove the "--supabase / --drizzle flags only tag the referrer" paragraph. - Convert the "Good to know" blockquote into a proper <Callout title=...>. Edited the auth supplement (the page is generated from it) and recast the em-dashes in the touched prose. Verified: next build prerenders all 355 pages.
- loadRawManifest: validate the JSON delimiters before slicing, throwing a clear error (which falls back to the fixture) instead of feeding garbage to JSON.parse. - Reconcile CLI_VERSION to the loaded manifest's version after loading, so pages are stamped with the version of the data actually used — including the fixture-fallback path, where npm-latest and the cached manifest can differ.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generates
/reference/clifrom the shippedstashCLI so the reference can't drift from the real command surface.Update (stash CLI 0.17): the CLI now ships
stash manifest --json— the structured, versioned command surface it builds from its own command registry. This PR now consumes that directly, which was the stated target. The--helptext parser is deleted.Pipeline
scripts/generate-cli-docs.ts(bun run generate-docs:cli, wired intoprebuild):loadManifest()runsnpx stash@<version> manifest --jsonand projects it onto the renderer's model. Nav groups and their order come straight from the CLI (no hardcoded group map). Offline → cachedscripts/fixtures/stash-manifest.json.npm view stash version, runs that version'smanifest --json, stamps every page (verifiedAgainst.cli+ banner). A newstashrelease refreshes the docs on the next build.flagscarrydefaultandenv(folded into the flag description), and curatedexamplescome straight from the CLI. Pipes in flag values (--eql-version <2|3>) are escaped so the GFM table renders.[cli]/[cli, eql]by the content-model rule.Generated against 0.17.0
eql.mdx(eql install/eql upgrade/eql status), anddb.mdxno longer listsinstall/upgrade(they moved to theeqlgroup in the CLI).doctorandmanifestpages;envunder Experimental.cli: "0.17.0".Hybrid content (rich prose)
The per-command supplement hook (
scripts/cli-supplements/<command>.md, merged after the generated skeleton) is retained and still demonstrated onauth(device-code flow + keyset binding). The manifest also now carrieslong(multi-paragraph help) for some commands (init,auth login,manifest) — rendering that into the pages is a natural follow-up, deferred here to keep the page format stable.Validation
bun run types:checkpasses (fumadocs-mdx + next typegen + tsc).noNonNullAssertionstyle warnings shared with the original. (The branch's other Biome errors are pre-existing SVG-a11y issues fixed later onv2; they clear on rebase.)Open for review
db→eqlCLI commands and move the CLI reference into /reference/cli #41's hand-moved CLI pages (these supersede them).--database-url"…for this run only — never written to disk"), emitted verbatim from the CLI registry. If we want those out of the docs (per the em-dash preference), the clean fix is in the CLI's registry text upstream, not a generator-side rewrite — flagging for a call.