Skip to content

4/n astryx init foolproof: scope CLI invocation (no bare npx astryx footgun) - #4151

Merged
josephfarina merged 1 commit into
mainfrom
navi/vibe/cli-scoped-invocation
Jul 22, 2026
Merged

josephfarina merged 1 commit into
mainfrom
navi/vibe/cli-scoped-invocation

Conversation

@josephfarina

Copy link
Copy Markdown
Contributor

Problem

Bare npx astryx resolves to an unrelated package on the npm registry (https://www.npmjs.com/package/astryx, an empty 0.0.0 squat) whenever our CLI isn't installed. Our docs, runtime hints, and the injected AGENTS.md/CLAUDE.md index all told users (and agents) to run npx astryx …, so a first-run / one-off invocation silently fetched a look-alike package. The postinstall banner also printed a stale npx xds init.

Fix

A single install-aware source of truth in package-manager.mjs — getCliInvocation / formatCliCommand / getDlxPrefix / isCliOneOff:

  • installed / global / dev → <pm> astryx <cmd> (e.g. pnpm exec astryx …) — unchanged
  • one-off (detected via npx/pnpm dlx/yarn dlx/bunx cache in process.argv[1]) → <dlx> @astryxdesign/cli <cmd>, which always resolves to us

Routed through every runtime hint the CLI prints — search, component, hook, docs, build, template, swizzle, discover, theme, init, upgrade, doctor, update-check, the manifest pointer, and the postinstall banner — plus the injected agent-docs index. Structured --json fields (search command, upgrade suggestedCommand) keep the canonical bare astryx <cmd> form; only human output is rewritten.

Docs: bootstrap commands use the scoped package (npx @astryxdesign/cli …); reference commands use bare astryx <cmd> (fails cleanly if uninstalled — never a look-alike fetch). Also fixes the stale npx xds init banner and the core <Theme> runtime warning.

Testing

  • New unit tests for the helper (isCliOneOff, getDlxPrefix, getCliInvocation, formatCliCommand) + updated agent-docs/init tests.
  • Verified with two ad-hoc chaos suites (not committed): a logic fuzzer (18,619 assertions, 0 failures across every PM × invocation-path shape) and a live-CLI e2e scan (605 checks, 0 failures) confirming no npx astryx/bunx astryx or xds leaks in one-off output.
  • Targeted suite green on the merged result (package-manager, init next-steps, agent-docs, upgrade ordering, doctor, search, json-contract, component-format, update-check).

Stacked on #4147 (base retargets to main once that merges).

Made with Cursor

@vercel

vercel Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 22, 2026 1:36am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 22, 2026
@josephfarina josephfarina changed the title fix(cli): scope CLI invocation so bare npx astryx never hits the squatter 4/n astryx init foolproof: scope CLI invocation (no bare npx astryx footgun) Jul 22, 2026
@josephfarina
josephfarina force-pushed the navi/vibe/cli-scoped-invocation branch from 5b609ac to 948bca7 Compare July 22, 2026 01:18
@josephfarina
josephfarina changed the base branch from navi/vibe/install-init-foolproof to main July 22, 2026 01:18
@josephfarina
josephfarina enabled auto-merge (squash) July 22, 2026 01:27
…uatter

Bare `npx astryx` resolves to an unrelated package on the npm registry when the
CLI isn't installed. Route every command the CLI prints through a single
install-aware source of truth (getCliInvocation / formatCliCommand /
getDlxPrefix / isCliOneOff in package-manager.mjs):

- installed / global / dev runs  -> `<pm> astryx <cmd>` (unchanged)
- one-off runs (npx / pnpm dlx / yarn dlx / bunx cache) -> `<dlx> @astryxdesign/cli <cmd>`

Applied to search, component, hook, docs, build, template, swizzle, discover,
theme, init, upgrade, doctor, update-check, the manifest pointer, the postinstall
banner, and the injected AGENTS.md/CLAUDE.md index. Structured `--json` fields
keep the canonical bare `astryx <cmd>` form; only human output is rewritten.
Docs use the scoped package for bootstrap and bare `astryx` for references
(fails cleanly, never a look-alike fetch). Also fixes the stale `npx xds init`
postinstall banner and the core <Theme> runtime warning.

Stacked on #4147.

Co-authored-by: Cursor <[email protected]>
@josephfarina
josephfarina force-pushed the navi/vibe/cli-scoped-invocation branch from 948bca7 to cb5e651 Compare July 22, 2026 01:34
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Jul 22, 2026
@josephfarina
josephfarina merged commit 04cd8f7 into main Jul 22, 2026
19 checks passed
github-actions Bot added a commit that referenced this pull request Jul 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

CheckboxInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 449 -
Complexity N/A Very High (45) -
DropdownMenu · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 952 -
Complexity N/A Very High (95) -
Field · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 504 -
Complexity N/A High (30) -
NumberInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 496 -
Complexity N/A Very High (76) -
Selector · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1269 -
Complexity N/A Very High (101) -
SideNav · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1839 -
Complexity N/A Very High (179) -
Switch · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 388 -
Complexity N/A Very High (43) -
TextArea · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 346 -
Complexity N/A Very High (45) -
TextInput · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 349 -
Complexity N/A Very High (48) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@github-actions
github-actions Bot deleted the navi/vibe/cli-scoped-invocation branch July 22, 2026 06:56
josephfarina added a commit that referenced this pull request Jul 22, 2026
…4207)

* feat(core): docs.mjs redirects to the Astryx CLI instead of printing docs

core's bundled docs.mjs was a self-sufficient off-ramp: agents (and humans) got
component docs from it and never reached the CLI or ran `astryx init` — which is
what installs the full component guide + design rules + tokens into
AGENTS.md/CLAUDE.md. It was also a shallower view than the CLI (e.g. Button: 82
lines here vs 269 via `astryx component Button` — no Import, no Variants, terser).

Redirect docs.mjs to the CLI so everyone converges on the current, richer source
and gets init:
- any invocation now prints how to install + run the CLI, using the scoped
  `npx @astryxdesign/cli` form (never the bare `npx astryx` footgun — see #4151).
- README "Component Docs" section updated to point at the CLI.

Validated in the fresh-install harness (Opus 4.8 + Sonnet 5): agents converge on
the CLI + init; docs.mjs is no longer a dead-end off-ramp.

* test(core): update docs-script tests for CLI redirect behavior

docs.mjs now redirects to the Astryx CLI instead of printing a component
catalog / per-component docs, so assert the redirect banner + exit 0
regardless of args rather than the old catalog output.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — cb5e651f Deployed Jul 22, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant