Skip to content

fix(cli): return the build playbook as data, and render the text from it - #6566

Merged
josephfarina merged 2 commits into
mainfrom
cli-spec/templates-layout/build-playbook-data
Sep 24, 2026
Merged

josephfarina merged 2 commits into
mainfrom
cli-spec/templates-layout/build-playbook-data

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

User impact

Any agent or script that asks build for its playbook through the machine surfaces. astryx build in a terminal prints a four-step workflow, the on-system rules and follow-up commands; astryx --json build and build() from @astryxdesign/cli/api returned only:

{"apiVersion": 1, "type": "build.help", "data": {"playbook": true}}

So the caller the CLI is designed for got a boolean, and anything that wanted the guidance had to copy the prose by hand and keep it in sync. After the change the envelope carries the playbook, and the terminal output is rendered from those same values.

Problem and solution fit

  1. Why does it occur? The playbook lived in printPlaybook() in the command file, as hard-coded prose with the caller's package-manager invocation interpolated. The API leaf returned a marker for the renderer to expand.
  2. Why does it harm the task? The text output was richer than the envelope, so --json and the programmatic API could not answer the one question build with no query exists to answer.
  3. Why does that matter? The package-manager prefix is the reason the prose went renderer-side, and it is solvable the way build.kit already solves it for hint.commands: carry bare subcommands in the data and let the renderer prefix them.

The API now returns {playbook: true, title, steps, rules, related}. Each step has a title, its commands ({command, purpose?}, bare subcommands) and an optional returns. The command renders those values; nothing in the text is absent from the envelope.

Expected behavior and authority

docs/architecture/cli-surface.md (authority: current):

  • System model, Render: "In --json mode, jsonOut writes a single envelope. Otherwise the formatters render the same values as text."
  • INV4: "Human output is a projection of the JSON, produced only by the formatters."

docs/specs/AST-017/spec.md (authority: current), DEC-4: every field in a stable response keeps "its canonical type, contract tests, applicable text output, and complete consumer documentation aligned in the same change." The new fields have a typedef, tests, the text projection, the FunctionDoc returns entry and the README response-type row.

Compatibility (AST-017 FR5/FR13): additive. type and data.playbook: true are unchanged; old consumers keep working.

Smallest restoration

  • api/build/help/help.mjs returns the playbook content; api/build/build.type.mjs types it.
  • clients/cli/commands/build.mjs renders that data instead of its own copy.
  • Docs: the FunctionDoc returns entry, and the one-line build.help description in foundation/response/response-types.doc.mjs with the regenerated README row. The old description ("a marker the renderer expands") would be false after this change.

The content moved as written with three edits a structured shape forced or that would otherwise put a false statement into a new public field: the commands embedded in rule and tip prose (docs tokens, search <query>) became related entries so they can be rendered with the caller's invocation; the tip's first sentence repeated step 1 and was dropped; step 1 promised a "Compose:" suggestion the kit no longer prints, and now says "a recommended start", which is what the kit shows.

Evidence

  • Reproduction before the change: astryx --json build printed {"playbook": true} as its entire data, while astryx build printed the full playbook.
  • Result after the change: astryx --json build carries the title, three steps (five commands), three rules and two related lookups; astryx build prints the same steps, commands, rules and lookups, each command prefixed with the project's own invocation.
  • Representative unchanged path: astryx build "<idea>" (the kit) is untouched; its tests pass unchanged.
  • Regression test or other mutation-sensitive proof: clients/cli/commands/build.playbook.test.mjs checks that the text prints exactly the envelope's commands (same count, same order), every step title, returns, rule and purpose, and that every command names a registered CLI command; api/build/build.test.mjs checks the data shape. Reverting the whole fix fails all three; reverting only the renderer fails the projection test; reverting only the data fails all three.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label. (The new response fields are the restoration itself: the envelope must carry what the text shows.)
  • Public text and artifacts contain no internal Meta context.

Testing

pnpm exec vitest run packages/cli/clients/cli/commands/build.playbook.test.mjs packages/cli/api/build/build.test.mjs
pnpm -F @astryxdesign/cli readme
pnpm -F @astryxdesign/cli sync:api-types
pnpm -F @astryxdesign/cli exec tsc --project tsconfig.api-dts.json
pnpm check:cli-structure
pnpm -F @astryxdesign/cli readme:check
pnpm -F @astryxdesign/cli typecheck:json-api
ASTRYX_STRICT_LINT=1 pnpm exec eslint packages/cli/api/build/build.doc.mjs packages/cli/api/build/build.test.mjs packages/cli/api/build/build.type.mjs packages/cli/api/build/help/help.mjs packages/cli/clients/cli/commands/build.mjs packages/cli/clients/cli/commands/build.playbook.test.mjs packages/cli/foundation/response/response-types.doc.mjs
pnpm check:repo
pnpm exec vitest run packages/cli

`build` with no query printed a whole playbook in the terminal while `--json`
and `build()` returned only `{playbook: true}`, so the text was not a
projection of the envelope. The steps, rules and related lookups now live in
the `build.help` data, with bare commands the renderer prefixes.
@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 24, 2026 6:01pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 24, 2026
@astracat-bot

astracat-bot Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Sep 24, 2026, 6:22 PM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build playbook is now returned as data, and the terminal output is rendered from it — this looks ready to approve.

  • build.help keeps playbook: true and its type, and additively carries the title, steps with bare-subcommand commands, rules, and related lookups, so --json and programmatic callers get the same guidance the terminal shows.
  • The new fields land with their typedef, shape and text-projection tests (including exact command count/order and registered-command checks), FunctionDoc entry, and updated response-type/README documentation, as the stable-response contract requires.
  • Compatibility is preserved for existing consumers, the composition-kit path is unchanged, and the one wording correction ("a recommended start" instead of a "Compose:" suggestion) matches what the kit actually prints.

[Automated review]

The playbook renderer padded its command lines into a comment column by
hand. AST-042 FR3 and cli-surface INV23 keep layout in the formatter kit,
so each step's commands are now records (command, purpose) whose field
names match the JSON keys, the rules are a list, and the test reads the
records instead of the padded lines.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build playbook is now returned as data, rendered with the shared formatter kit — this looks ready to approve.

  • build.help keeps playbook: true and its type, and additively carries the title, steps with bare-subcommand commands, rules, and related lookups, so --json and programmatic callers get the same guidance the terminal shows.
  • The terminal rendering now uses shared records, list, and section blocks with field names matching the JSON keys, instead of a hand-padded comment column, which is what the shared-output-vocabulary rule requires.
  • The new fields land with their typedef, shape and text-projection tests (including exact command count/order, registered-command, and no-hand-drawn-column checks), FunctionDoc entry, and updated response-type/README documentation, as the stable-response contract requires.
  • Compatibility is preserved for existing consumers, the composition-kit path is unchanged, and the one wording correction ("a recommended start" instead of a "Compose:" suggestion) matches what the kit actually prints.

[Automated review]

github-actions Bot added a commit that referenced this pull request Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Preview availability: Storybook is not ready on the exact-head Vercel preview. Sandbox was not published for this CI run.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

19 of 420 shot(s) changed. View the report

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Slider Default probe light 15,617
Slider Default probe dark 15,615
Chat With Attachments probe light 12,964
Chat With Attachments probe dark 12,114
InputGroup With Typeahead probe light 11,012
InputGroup With Typeahead probe dark 9,189
ComplexSelector Tree list with search probe light 6,245
TextArea Vertical Form Alignment probe light 5,634
ComplexSelector Tree list with search probe dark 5,602
TextArea Vertical Form Alignment probe dark 5,047
ComplexSelector Fruit ripeness selector neutral light 4,007
ComplexSelector Fruit ripeness selector neutral dark 3,825
ToggleButton Group Single probe dark 1,538
ToggleButton Group Single probe light 1,538
MediaTheme On Dark neutral dark 838
Banner Collapsible Content (Expanded) probe dark 92
Banner Collapsible Content (Expanded) probe light 90
AlertDialog Delete neutral light 71
TableRowStatus Default neutral light 23
Slider — Default — probe light
BeforeAfterDiff
Before visual regression frame After visual regression frame Pixel difference frame
Slider — Default — probe dark
BeforeAfterDiff
Before visual regression frame After visual regression frame Pixel difference frame
Chat — With Attachments — probe light
BeforeAfterDiff
Before visual regression frame After visual regression frame Pixel difference frame

Generated by PR Enrichment workflow | View full report

@josephfarina
josephfarina marked this pull request as ready for review September 24, 2026 21:06
@josephfarina
josephfarina merged commit a860a50 into main Sep 24, 2026
39 checks passed
@github-actions
github-actions Bot deleted the cli-spec/templates-layout/build-playbook-data branch September 25, 2026 06:23

This branch was successfully deployed

1 active deployment
Preview — 6e99e840 Deployed Sep 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant