Repository navigation
cli: the real CLI as one tarball that runs with nothing installed - #6507
josephfarina wants to merge 8 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
No new or modified components detected. Bundle Size SummaryNo component packages changed. Accessibility AuditStatus: No accessibility violations detected. Visual Regression25 of 420 shot(s) changed. View the report A change here is a question, not a failure: check whether the after is the
and 5 more. Generated by PR Enrichment workflow | View full report |
component, hook, search and theme targets only need a Core that matches the CLI's release. When the project has none, they now read the one installed beside the CLI (a global install of both, or the standalone runtime) instead of failing with ERR_CORE_NOT_FOUND. The project's own Core still wins. doctor, swizzle and theme build keep the project-only lookup: they describe or write to the project, so a Core it never installed must not read as installed there. A doctor test pins that.
scripts/build-cli-standalone.mjs lays @astryxdesign/cli, its production dependencies and the matching @astryxdesign/core out as an installed node_modules tree and packs it as one npm tarball (astryxdesign-cli-standalone-<version>.tgz). Extract it and run node package/bin/astryx.mjs: no package manager, registry or install step. Versions come from pnpm-lock.yaml through pnpm deploy, and the tree carries a manifest listing every package it bundles. It is a plain tree, not a JS bundle: the CLI loads command modules, parsers and integration configs at runtime, which bundling breaks. The smoke test extracts the tarball twice into empty directories with a scrubbed environment and checks that 14 read-only commands print exactly what the workspace CLI prints, that a project's own Core wins, that doctor still reports Core missing from the project, and that nothing is written. A new workflow runs both on PRs that touch the CLI, Core or the lockfile and keeps the tarball as an artifact. Nothing is published.
The api resolves Core through the catalog lookup, but the text renderer looked it up again project-only. With no Core in the project and one beside the CLI, --json listed components and text mode crashed. The renderer now uses the same catalog lookup, and the smoke test runs the text form of each list command next to its --json form.
npm pack died on the ~9,500-file bundled tree in CI with "Exit handler never called" while it worked locally. The build now writes the tarball itself: ustar entries under package/, sorted, with a fixed timestamp and owner, gzipped with zlib. The same tree always packs to the same bytes, and npm still installs the result.
The runtime's CLI and Core used to come from pnpm deploy's copy of the workspace packages. Now they are the tarballs pnpm pack produces, the same ones pnpm publish uploads, extracted unchanged. pnpm deploy only supplies their locked third-party dependencies. The packed tarballs stay beside the runtime and the manifest records their integrity, so anyone can check that the runtime holds the published packages. Packing runs each package's prepack, so the workflow no longer builds Core as a separate step.
The runtime is the published CLI, so testing it against a list of commands compared with the workspace CLI was the wrong frame. The test now checks that the runtime holds the packed CLI and Core byte for byte, then runs cli-smoke-test.mjs and cli-json-smoke-test.mjs against it, extracted into an empty directory with a scrubbed environment. Both suites take ASTRYX_SMOKE_BIN and ASTRYX_SMOKE_CWD for that, and default to the workspace CLI and repo root as before. It also runs the commands that write files (init, template, theme template, theme build) in an empty project, and keeps the runtime's own contract: a project's Core wins, doctor sees only the project, it runs from anywhere, and nothing writes into it.
9539cd5 to
55ad98b
Compare
There was a problem hiding this comment.
Thanks for building this — the empty-directory use case is clear, the runtime now contains the packages exactly as published, and keeping a project's own Core first while doctor, swizzle, and theme build stay project-only are the right boundaries to preserve.
Approval is waiting on a maintainer decision first. As you note, "None governs how the CLI ships or how it finds Core", so a maintainer needs to provide or identify the governing spec for this addition before it can be approved. That spec needs to settle:
- The standalone runtime itself: tarball layout and name, the bundled manifest, and its unpublished status.
- The catalog Core fallback: which commands (including
Project.componentsconsumers such as gap-report) may answer from a Core beside the CLI, that a project's own Core wins, and which commands stay project-only. - Whether a Core beside the CLI must match the CLI version, and what should happen when it does not.
Two independent items also need attention, and would still be needed after that decision:
- The fallback is automatic behaviour in the shipped CLI (for example, a global install of both packages), so please document it — fallback, project precedence, and the project-only boundary — in the relevant command docs or linked consumer documentation. Deferring consumer docs to standalone publishing does not cover the fallback releasing with the CLI patch.
- The new
CLI Standaloneworkflow was still running, not yet green, on this revision during review, so parity currently rests on the local report. Please point to a green run for this revision.
Text-mode component --list and the earlier packing failure are fixed in this revision — thank you for those.
[Automated review]
The fallback ships with the CLI itself (a global install of the CLI and Core gets it too), so it can't be a hidden behavior. The API reference docs for component, hook, search, build and theme targets now say that a Core installed beside the CLI answers when the project has none, and their ERR_CORE_NOT_FOUND entries say when it still happens. Swizzle's docs say only the project's own Core counts. The changeset also stops claiming theme build is project-only: it compiles with whatever Core the CLI resolves, as it always has.
cli-smoke-test.mjs and cli-json-smoke-test.mjs take --bin and --cwd instead of two ASTRYX_ environment variables. Same behavior, and no new Astryx-named variables. Defaults are unchanged.
There was a problem hiding this comment.
Thanks for building this — the empty-directory use case is clear, the runtime now contains the packages exactly as published, and keeping a project's own Core first while doctor and swizzle stay project-only are the right boundaries to preserve. The fallback documentation, the text-mode listing fix, the deterministic packing, and switching the smoke suites to --bin/--cwd flags all address the earlier feedback.
Approval is waiting on a maintainer decision first. As you note, "None governs how the CLI ships or how it finds Core", so a maintainer needs to provide or identify the governing spec for this addition before it can be approved. That spec needs to settle:
- The standalone runtime itself: tarball layout and name, the bundled manifest, and its unpublished status.
- The catalog Core fallback: which commands (including
Project.componentsconsumers such as gap-report) may answer from a Core beside the CLI, that a project's own Core wins, and which commands stay project-only. - Whether a Core beside the CLI must match the CLI version, and what should happen when it does not.
One independent item also needs attention, and would still be needed after that decision:
- The new
CLI Standaloneworkflow was still running, not yet green, on this revision during review, so parity currently rests on the local report. Please point to a green run for this revision.
[Automated review]
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
Fixes: - build-theme targets: replace character-drawn formatTargetsTable with records() inline layout (INV23); show className field - docs list: add package field to text projection - upgrade --list: render from JSON result via records() instead of API logger (was printing undefined, showing PR numbers, missing version) Deferred (open PRs would conflict): - template: id, isReady fields (#6265) - component: themeData, findRelatedBlocks, --blocks fields (#6507) - component --props: type union in formatProps code block Guard test (text-json-parity.test.mjs): - manifest-driven: fails on a new JSON-capable command with no case - checks text->JSON (record keys, text blocks, list items) - checks JSON->text (leaf fields by label or per-key value presence) - per-command allowlist with stale-entry check
|
Closing: running the CLI with nothing installed is now covered by global install mode (#7649) and |









User need
Tools that scaffold a small app and hand it to an agent want the CLI answering in seconds. Today it only runs after an install, and in a cold or sandboxed environment that install (or the big workspace you reach the CLI through) takes a minute or two before the first
astryx componentprints anything. That eats most of the time budget for a quick app, so people hand-roll their own CLI tarballs. Those drift from our releases and usually carry only part of the CLI.Problem and solution fit
scripts/build-cli-standalone.mjspacks@astryxdesign/cliand@astryxdesign/corewithpnpm pack, which runs their prepack and rewrites their manifests exactly likepnpm publishdoes. It extracts those two tarballs unchanged into an installednode_moduleslayout and adds the third-party dependenciespnpm-lock.yamlpins for them. Nothing in the CLI or Core is rebuilt, bundled or edited. Extract the result anywhere and runnode package/bin/astryx.mjs. No package manager, no registry.component,hook,search,build,theme targets) fall back to the Core installed beside the CLI when the project has none. Without that they fail withERR_CORE_NOT_FOUNDin an empty directory. A project's own Core still wins.cli-smoke-test.mjsandcli-json-smoke-test.mjstake--binand--cwd, so the CLI's own suites can run against a packaged CLI. Their defaults don't change. ACLI Standaloneworkflow builds the runtime and runs them against it.Current specification
None governs how the CLI ships or how it finds Core.
spec:AST-042(current) says every command is a thin layer over one@astryxdesign/cli/apifunction. This PR adds no command, subcommand or option, and the runtime runs those same commands straight from the published package. The fallback lives in the API functions. The text renderer forcomponent --listre-resolves Core on its own (one of the handler gaps AST-042 lists under FR1), so it now uses the same lookup as its API function. Closing that gap is separate. A maintainer still needs to settle the distribution contract, so this stays a draft.Public delta and caller burden
astryxdesign-cli-standalone-<version>.tgzholdsbin/astryx.mjs, thenode_modulestree andastryx-standalone.json(versions, the integrity of the packed CLI and Core, source commit, lockfile hash, and every bundled package with its license). The packedastryxdesign-cli-<version>.tgzandastryxdesign-core-<version>.tgzsit beside it. Itspackage.jsonisprivate. Publishing it to npm is a follow-up.component,hook,search,buildandtheme targetsused to fail withERR_CORE_NOT_FOUND. Now they answer from a Core installed beside the CLI when there is one (this runtime, or a global install of both), with the same output that Core gives inside a project.doctorandswizzlestill only count the project's Core. The npm packages don't change.Nothing new for callers to decide.
Design and alternatives
pnpm deploy, which copies them out of the workspace.pnpm packoutput is what npm actually receives (manifest rewritten, publish scripts stripped), so the runtime uses that now, and the test checks it byte for byte..bindirs are dropped, so the tree has no symlinks.npm packdied on a tree this size in CI with "Exit handler never called".Evidence
On 0.6.3, rebased on main.
29edbaea). TheCLI Standalonejob passed, and the 43 checks on it came back 31 success, 12 skipped, 0 failing.cli-smoke-test.mjs760/760,cli-json-smoke-test.mjs12/12). The workspace CLI gets the same 760 and 12.--binand--cwdflags above. They only pick which CLI the suite runs and where.init --features agents,template <block> <dir>,theme templateandtheme buildall do.doctorstill failscore-installedin a project without Core. A second extraction at another depth answers the same. Nothing writes into the runtime. The manifest matches all 125 packages in the tree.I broke it on purpose three ways and each one got caught. Editing one file in the runtime's CLI fails the byte for byte check. Deleting one of the CLI's dependencies from the runtime fails both suites at the first command. Removing the fallback fails the byte for byte check and
cli-smoke-test.mjs, which finds no components in an empty directory.Scope
gpt-tokenizerpeer went out in cli: drop the unused gpt-tokenizer peer #6508.Testing
node scripts/build-cli-standalone.mjsnode .github/scripts/cli-standalone-smoke-test.mjs .astryx-standalone/astryxdesign-cli-standalone-0.6.3.tgzpnpm -F @astryxdesign/cli exec tsc --project tsconfig.api-dts.jsonpnpm check:repoand strict eslint on the touched files (0 errors)npx vitest run packages/cli scripts(5,840 passed)