Repository navigation
fix(cli): generate manifest examples and response types from the docs - #6585
Conversation
The manifest's examples and response types came from hand-written maps that had drifted from the CommandDocs and FunctionDocs, and `upgrade` was missing `upgrade.registry`. Both now come from the docs each command is built from.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approval recommended: the manifest is now generated from the docs each command is built from, as the CLI surface record requires.
- Examples come from each command's CommandDoc and response types from the FunctionDoc it wraps, replacing the hand-kept maps that had drifted for most commands.
upgrade.registry— already emitted byupgrade --registry --json— is now listed in the manifest, the response-types doc, and the README table, so agents can expect it.- The only remaining hand-kept list covers the two envelopes no API function returns (
manifestandtheme.build.batch), and a test fails if a FunctionDoc ever declares either. - New tests load every CommandDoc and FunctionDoc from disk and require exact equality, check the runtime
upgrade.registryenvelope, and fail against the previous implementation. Command behavior, manifest shape, and text output are unchanged.
[Automated review]
| * Example invocations per fully-qualified command. Optional, agent-facing. | ||
| * @type {Record<string, string[]>} | ||
| */ | ||
| const EXAMPLES = { |
There was a problem hiding this comment.
make sure to actually run before and after before merging this and comparing output
# Conflicts: # packages/cli/README.md # packages/cli/clients/cli/lib/manifest.mjs # packages/cli/foundation/response/response-types.doc.mjs
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression15 of 420 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
# Conflicts: # packages/cli/clients/cli/lib/manifest.mjs
There was a problem hiding this comment.
Thanks for restoring the manifest as a generated surface — deriving examples from each CommandDoc and response types from the wrapped FunctionDoc, and listing upgrade.registry, matches the CLI surface record and was verified at this revision (doc-equality tests, generated-table check, and a direct manifest run all pass).
One fix is needed before approval: the README paragraph beginning “The manifest is derived from Commander metadata” still says response types come from a small declarative RESPONSE_TYPES map in src/lib/manifest.mjs. That map and path no longer exist after this change, so the paragraph now points readers at the old hand-kept source. Please update it to describe the new derivation (examples from the CommandDoc, response types from the FunctionDoc returns plus the CLI-built envelopes, JSON support from the allowlist).
No command behavior or manifest shape change is being requested.
[Automated review]
There was a problem hiding this comment.
Thanks for restoring the manifest as a generated surface — deriving examples from each CommandDoc and response types from the wrapped FunctionDoc, and listing upgrade.registry, matches the CLI surface record and was verified at this revision (doc-equality tests and a direct manifest run both pass).
One fix is needed before approval: the README paragraph beginning “The manifest is derived from Commander metadata” still says response types come from a small declarative RESPONSE_TYPES map in src/lib/manifest.mjs. That map and path no longer exist after this change, so the paragraph now points readers at the old hand-kept source. Please update it to describe the new derivation (examples from the CommandDoc, response types from the FunctionDoc returns plus the CLI-built envelopes, JSON support from the allowlist).
No command behavior or manifest shape change is being requested.
[Automated review]
The merge with main took main's README to regenerate the tables and dropped this PR's paragraph, which still described the removed RESPONSE_TYPES map.
There was a problem hiding this comment.
Approval recommended: the manifest is now generated from the docs each command is built from, as the CLI surface record requires.
- Examples come from each command's CommandDoc and response types from the FunctionDoc it wraps, replacing the hand-kept maps that had drifted for most commands.
upgrade.registry— already emitted byupgrade --registry --json— is now listed in the manifest, the response-types doc, and the README table, so agents can expect it.- The README paragraph describing how the manifest is built now matches the new derivation, and the generated README tables check in sync.
- The only remaining hand-kept list covers the two envelopes no API function returns (
manifestandtheme.build.batch), and a test fails if a FunctionDoc ever declares either. - New tests load every CommandDoc and FunctionDoc from disk and require exact equality, check the runtime
upgrade.registryenvelope, and pass at this revision alongside the docs-drift check. Command behavior, manifest shape, and text output are unchanged.
[Automated review]
# Conflicts: # packages/cli/README.md # packages/cli/clients/cli/lib/manifest.mjs
# Conflicts: # packages/cli/clients/cli/lib/manifest.mjs
There was a problem hiding this comment.
Approval recommended: the manifest is now generated from the docs each command is built from, as the CLI surface record requires.
- Examples come from each command's CommandDoc and response types from the FunctionDoc it wraps, replacing the hand-kept maps that had drifted for most commands.
- The registry envelope — already emitted by the registry mode — is now listed in the manifest, the response-types doc, and the README table, so agents can expect it.
- The README paragraph describing how the manifest is built now matches the new derivation, and the generated README tables check in sync.
- The only remaining hand-kept list covers the two envelopes no API function returns, and a test fails if a FunctionDoc ever declares either.
- New tests load every CommandDoc and FunctionDoc from disk and require exact equality, check the runtime registry envelope, and pass at this revision alongside the docs-drift check. Command behavior, manifest shape, and text output are unchanged.
[Automated review]
# Conflicts: # packages/cli/README.md # packages/cli/clients/cli/lib/manifest.mjs # packages/cli/foundation/response/response-types.doc.mjs
`theme add` with no slug, or with --list, answers with themeListAvailable()'s theme.list instead of calling themeAdd(), so the wrapped FunctionDoc cannot declare it. Deriving response types from that FunctionDoc alone dropped it: the manifest listed only theme.add, while the released 0.6.4 manifest lists both. It is now a CLI-layer envelope like theme.build.batch. New test: a bare `theme add --json` emits theme.list and the manifest lists it; it fails without the entry.
There was a problem hiding this comment.
Approval recommended: the manifest is now generated from the docs each command is built from, as the CLI surface record requires.
- Examples come from each command's CommandDoc and response types from the FunctionDoc it wraps, replacing the hand-kept maps that had drifted for most commands.
- The only remaining pinned list covers the envelopes no wrapped API function returns — the manifest itself, the theme-build batch, and the list answer from
theme addwith no slug — and a test fails if a FunctionDoc ever declares one of them. - A direct before-and-after run at this revision shows the same commands and the same response-type sets, with examples corrected and only ordering changes for two response-type lists; no other manifest field changed.
- The README paragraph describing how the manifest is built now matches the new derivation, and the generated tables check in sync.
- New tests load every CommandDoc and FunctionDoc from disk and require exact equality, check the runtime registry and theme-add list envelopes, and pass at this revision alongside the docs-drift check. Command behavior, manifest shape, and text output are unchanged.
[Automated review]
User impact
astryx manifest --json(and the manifest embedded in bareastryx --json) is how an agent learns the CLI without scraping--help. Two of its per-command facts were written by hand inclients/cli/lib/manifest.mjsand had drifted from the docs every command is built from:EXAMPLESmap disagreed with the CommandDocexamplesfor 25 of the 34 documented commands.componentshowedastryx componentandastryx component XDSButtonwhere its CommandDoc showsastryx component --list;blog,layout,theme,integration,theme palette, anddoctor integrationshowed none at all.RESPONSE_TYPESmap left outupgrade.registry.astryx --json upgrade --registryemits it (andupgrade()'s FunctionDoc lists it), but the manifest, the response-types doc, and the README response-type table did not, so an agent reading the manifest could not expect it:This folds in the
upgrade.registryregistration: once response types are derived, the manifest lists it by construction, and the response-types doc must name it in the same change, so the two cannot ship as separate branches without editing the same lines.Problem and solution fit
Expected behavior and authority
docs/architecture/cli-surface.md(current):docs/specs/AST-017/spec.md(current), DEC-4:and FR14: "Commands and options MUST appear in generated help and the machine-readable manifest."
Smallest restoration
defineCommandrecords the CommandDoc and FunctionDoc a command is built from (commandDocsOf(cmd)).buildManifesttakes each entry'sexamplesfrom the CommandDoc (examples[].cli) and itsresponseTypesfrom the FunctionDoc'sreturns. The one remaining hand-kept list,CLI_LAYER_RESPONSE_TYPES, holds the two envelopes no API function returns:manifest(it wraps no API function) andtheme.build.batch(built by thetheme buildcommand around severalthemeBuild()receipts). A test fails as soon as a FunctionDoc declares either, so the list only shrinks.manifestis registered by hand inindex.mjs, so its CommandDoc is read directly.responseTypesindex is built from the described command tree.upgrade.registrygets its response-types entry, which regenerates one README table row. The README's paragraph on how the manifest is built, and the file headers that described the old maps, now say where each fact comes from.Unchanged: command names, descriptions, arguments, options,
jsonflags, the manifest's shape and types, and every other command's set of response types. Two lists now follow their FunctionDoc's order (docs:docs.detailbeforedocs.index;theme add:theme.addbeforetheme.list), and the flat index's keys follow the command tree; neither order is part of the contract.Compatibility:
responseTypesgains one entry andexamplesvalues change; no field is added or removed (AST-017 FR5, contract-restoring).Evidence
blogfirst,upgrade.registrymissing, and the FunctionDoc order fordocs).astryx manifest --json | jq -c '.data.responseTypes.upgrade'prints["upgrade.list","upgrade.registry","upgrade.status","upgrade.run"], and every manifestexampleslist equals its CommandDoc's.test/drift/docs-drift.test.mjs) still checks that the response-types doc equals the manifest's set;astryx manifesttext output is unchanged.clients/cli/lib/manifest.test.mjsloads every CommandDoc undercommands/and every FunctionDoc underapi/from disk and requires the manifest's examples and response types to equal them, requires every FunctionDoc return to be listed, runsupgrade --registry --jsonand checks its type is listed, and pins the CLI-layer list. Restoring the basemanifest.mjsfails 4 of these tests.Scope
Testing
All pass; the CLI suite is 4303 passed, 5 skipped (base 4298 + 5 new).
Before and after
Ran
astryx manifest --jsonon main at d88274b and on this branch (that commit plus this change), then compared every command:examplesandresponseTypeschanged.responseTypes:upgradegainsupgrade.registry, the typeastryx --json upgrade --registryalready emits.docsandtheme addlist the same types, now in FunctionDoc order. The top-levelresponseTypesset is unchanged.examples: 26 commands now show exactly their CommandDoc examples, including 8 that showed none before (for exampleblog,theme,doctor integration).Full comparison
Refreshed on main 9143f03
Main merged in again. #6867 added
component.batchto the old hand-kept response-type map. Under this PR, the manifest takes response types from each FunctionDoc'sreturns, and the component FunctionDoc on main already declarescomponent.batch, so the manifest still lists it and no hand-kept entry is needed. The README tables are regenerated, adding this PR'supgrade.registryrow, and the hand-written manifest paragraph is kept. On main 9143f03 plus this head: the full CLI node suite (353 files, 5,576 tests, including the manifest drift tests),check:cli-structure,check:changesets,readme:check, both typechecks,cli-api-types-verify, eslint and prettier pass.Refreshed on main 5bb03cf
#6615 removed the
layoutentries from the old hand-kept maps inmanifest.mjs, and this PR replaces those maps, so they conflicted. The resolution keeps this PR's derivation, which has no layout entries, because the layout docs are gone.component.batchand itsastryx component Button Badge Textexample still come from the component docs on main. Regenerating the README changed nothing. On main 5bb03cf plus this head: the full CLI node suite (346 files, 5,513 tests, including the manifest drift tests) and every gate listed above pass.Refreshed on main ebd939b, and one regression fixed
Main merged in again: #6737 and the
layoutrestore (#6887). #6737 addedROOT_RESPONSE_TYPES(help and version), whichtest/drift/docs-drift.mjsimports. That export stays here as a second hand-kept list, and the response-types enum header now names both lists.upgrade.registryappears once, with #6737's wording.Regression found and fixed. A diff of
astryx manifest --jsonagainst main showed that deriving response types from the wrapped FunctionDoc droppedtheme.listfromtheme add. A baretheme add(or--list) answers withthemeListAvailable()'stheme.listinstead of callingthemeAdd(), and the published 0.6.4 manifest lists both. It is now a CLI-layer envelope, liketheme.build.batch. New test: a baretheme add --jsonemitstheme.listand the manifest lists it. Removing the entry fails it and the derivation test.Against the published 0.6.4 manifest, no command loses a response type. Added since then:
component.batch,discover.item,integration verify'sintegration.pack-check, andupgrade.registry.On main ebd939b plus this head: the full CLI node suite (342 files, 5,321 tests) and every gate listed above pass.