Skip to content

fix(cli): a fresh clone that lists the CLI is told to install its dependencies - #11986

Merged
josephfarina merged 3 commits into
mainfrom
josephfarina/fresh-clone-install-advice
Nov 16, 2026
Merged

josephfarina merged 3 commits into
mainfrom
josephfarina/fresh-clone-install-advice

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Someone runs Astryx in a fresh clone (a project whose package.json lists @astryxdesign/cli but whose dependencies are not installed yet), with the astryx command installed for the computer. The once-a-day hint, doctor, and the setup reminder all say: To match, run: npm install @astryxdesign/[email protected]. Following that advice installs the dependencies, but it also replaces the exact version the project lists, "0.7.10", with the range "^0.7.10". A later install can then bring a CLI from another release than the project's Core.

After this change, the hint ends with To install the CLI this project declares, run: npm install, and doctor's fix reads To install the CLI this project declares, run: npm install. The setup reminder names the same install. Each uses the project's own package manager: pnpm install, yarn install, or bun install. The project's package.json stays as it is.

Problem and solution fit

  1. Why does it happen? The advice treats a project that lists the CLI but has not installed it the same as a project with only Core. For a project with only Core, adding the CLI at Core's version is right.
  2. Why does it harm the task? npm install <package>@<version> saves the package with npm's default range prefix, so following the advice edits the project's dependency list.
  3. Why does that matter? Astryx keeps a project's CLI and Core on one release, and a range lets them drift apart. Fresh clones are common: every new checkout, CI machine, and agent sandbox starts as one.

When the project's package.json lists the CLI among the packages its install gets (dependencies, devDependencies, or optionalDependencies), the advice is now the package manager's install of the project's dependencies, which installs the CLI the project lists. A CLI named only in peerDependencies keeps the add command, because Yarn, npm with --legacy-peer-deps, and pnpm with auto-install-peers=false install no peers. cliInstallAdvice, the one place all three read, picks the command.

Expected behavior and authority

spec:AST-081 FR2: in a project with no CLI installed, the hint names "the command [that] adds @astryxdesign/cli at the Core's version with the project's package manager", and doctor names the same command. This PR adds one detail to that rule, decided under the CLI's detail rules. When the project's package.json lists the CLI among the packages its install gets, as a fresh clone's does, the line ends To install the CLI this project declares, run: <command>, and the command installs the project's dependencies, since adding the CLI again would replace the version it lists. A CLI named only as a peer keeps the add command. The FR2 sentence and the G5 row say so.

Smallest restoration

  • foundation/release/notices.mjs: cliInstallAdvice returns the package manager's install command, with declared: true, when installsCliPackage (in project.mjs) finds the CLI in a field that an install gets. Otherwise it returns the add command, as before. For a listed CLI, the hint ends "To install the CLI this project declares, run:", because that CLI need not match the project's Core.
  • api/doctor/doctor.mjs (with _adapter.mjs): for a listed CLI, the fix starts "To install the CLI this project declares". The other wordings are unchanged.
  • assets/docs/tree/who-answers.doc.mjs: one clause for the listed case.
  • spec:AST-081: the FR2 sentence and the G5 row.

Evidence

  • Reproduction before the change: an app on Astryx 0.7.10 that lists "@astryxdesign/cli": "0.7.10", with node_modules removed and the current canary installed for the computer. The hint said To match, run: npm install @astryxdesign/[email protected], and doctor said the same. Running that command left "@astryxdesign/cli": "^0.7.10" in package.json.
  • Result after the change, with only these files replaced in that global copy: the hint ended with run: npm install, and doctor says To install the CLI this project declares, run: npm install. Running it left "0.7.10" unchanged. In both cases the project's CLI 0.7.10 then answers.
  • Representative unchanged path: a project with only Core, such as G5's own lockfile case, still gets the add command at Core's version. A folder inside a project whose package.json is not the project's still gets the run-from-the-project advice.
  • Regression test: G5 now also covers a fresh clone that lists the CLI. The hint and doctor's fix name the install, and both fail on the old code. It also covers a project that names the CLI only as a peer, which keeps the add command.

Scope

Components: CLI (global mode: the once-a-day hint, doctor, the setup reminder)

  • 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.
  • Public text and artifacts contain no internal Meta context.

Writing rubric results

  • R1 narration: none; the FR2 sentence and the G5 row describe present behavior.
  • R2 research: none in the record.
  • R3 evidence: G5's row names its test, which covers the listed-CLI case.
  • R4 rejected alternatives: none added.
  • R5 change references: none in the record.
  • R6 open questions: none touched.
  • R7 project status: none.

Testing

  • vitest run --project node over test/global-local.test.mjs, global-local.rows-16-39, global-local.rows-40-58, foundation/release, api/doctor, test/global-mode-docs.test.mjs, and test/global-mode-notes.test.mjs: 18 files, 472 passed.
  • tsc --project tsconfig.strict.json after sync-api-types, scripts/check-knowledge.mjs, scripts/check-cli-structure.mjs, ESLint, and Prettier on the changed files.

…endencies

In a project with no CLI installed, the once-a-day hint, doctor and the
setup reminder name the command that adds @astryxdesign/cli at the Core's
version. In a fresh clone whose package.json already lists the CLI, that
command replaced the exact version the project lists with a range (npm
writes ^0.7.10 for @0.7.10). There the command is now the package
manager's install of the project's dependencies, which installs the CLI
the project lists; doctor's fix says so.
@vercel

vercel Bot commented Nov 16, 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 Nov 16, 2026 6:10am UTC

Request Review

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

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 16, 2026, 6:20 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec e307698

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 2026
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · efb8a35

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.06 MB packed (+1.1 kB); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@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.

Changes requested. The fresh-clone fix is the right shape and its new assertions are red on main and green here; one state the new branch newly routes needs a condition before this can land.

  • A package that names @astryxdesign/cli only in peerDependencies takes the new "declared" branch, so the hint and doctor tell it to run the plain install, which under a package manager that does not install peer dependencies (Yarn 1 and Berry, npm with --legacy-peer-deps, pnpm with auto-install-peers=false) leaves the project with no CLI and the same warning on the next run; for this advice read the declared range from dependencies, devDependencies and optionalDependencies only, and keep the add command when the CLI is named only as a peer (packages/cli/foundation/release/notices.mjs:516 with packages/cli/foundation/release/project.mjs:171-186).

Two smaller things, neither blocking: the hint still says "To match" while the command now installs whatever version the project declares, so a project whose declared CLI is not its Core's release is told it will match when it will not, and doctor's lead for the same state says something different; and the JSDoc of noCliHint and noCliHintLine (notices.mjs:524-527, :545-547) still describes the command as the one that adds the CLI at Core's version.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims

  • Release note: in a fresh clone that lists the CLI, the hint, doctor and the setup reminder say to install the project's dependencies rather than add the CLI again — verified (foundation/release/notices.mjs:516, api/doctor/doctor.mjs:396-401, clients/cli/index.mjs:914; new G5 assertions).
  • Each of the three uses the project's own package manager — verified (the new install map is keyed by the detected manager, as the add map is).
  • The project's package.json is left as it is — verified (no changed path writes a manifest).
  • A project with only Core still gets the add command at Core's version — verified (G5's first assertion, and the yarn project row in test/global-local.rows-16-39.test.mjs:447).
  • A folder inside a project whose package.json is not the project's still gets the run-from-the-project advice — verified (that branch returns before the new one; its rows pass).
  • doctor's fix reads "To install the CLI this project declares, run: npm install." — verified (new G5 assertion).
  • Both new assertions fail on the old code — verified (base tree with this test file: the hint prints the add command, and the fix reads "To match, run: npm install @astryxdesign/[email protected].").
  • The listed test selection passes — verified with one caveat: 469 of 472 passed here, and the three failures are in foundation/release/cache.test.mjs and fail identically on the base in this environment (process-title and /proc reads), so they are not this change.
  • The record changes describe present behavior (writing rubric R1) and the repository checks pass — verified (scripts/check-knowledge.mjs exit 0; scripts/check-cli-structure.mjs exit 0; Prettier clean on the changed files; the repository's Lint workflow is green at this head).

Files

  • .changeset/fresh-clone-install-advice.md — clear (patch for the CLI, house format, accurate text).
  • docs/specs/AST-081-global-mode/spec.md — clear (FR2 sentence and G5 row only; approval lines untouched; approved for this head).
  • packages/cli/foundation/release/notices.mjs — the blocking finding above, plus the stale JSDoc note.
  • packages/cli/api/doctor/doctor.mjs — clear (lead chosen from the new flag; the other wordings unchanged).
  • packages/cli/api/doctor/_adapter.mjs — clear (passes the flag through; internal, no exported surface).
  • packages/cli/assets/docs/tree/who-answers.doc.mjs — clear (the clause matches the new behavior; the example below it is scoped to the Core-only case and stays correct).
  • packages/cli/test/global-local.test.mjs — clear (covers the hint and doctor for the declared case; red on the base).

Automated review (maintainer link)

… it installs

- A CLI named only in peerDependencies keeps the add command: Yarn, npm
  with --legacy-peer-deps and pnpm with auto-install-peers=false install no
  peers, so the plain install would leave the project without its CLI.
  installsCliPackage reads dependencies, devDependencies and
  optionalDependencies.
- For a listed CLI the hint ends "To install the CLI this project declares,
  run: <install>", as doctor's fix does: the installed CLI need not match
  the project's Core, so "To match" no longer fits.
- The JSDoc of noCliHint and noCliHintLine names both commands.
@josephfarina

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Fixed in the new head:

  • Peer-only CLI. installsCliPackage (project.mjs) reads dependencies, devDependencies, and optionalDependencies only. A CLI named only in peerDependencies keeps the add command. G5 now covers that case: the hint still says To match, run: npm install @astryxdesign/[email protected].
  • "To match". For a listed CLI, the hint now ends To install the CLI this project declares, run: npm install, the same lead as doctor's fix, because the installed CLI need not match the project's Core. The FR2 sentence quotes that ending, and the G5 row says "when they list the CLI".
  • JSDoc. noCliHint and noCliHintLine now name both commands.

Local: global-local (G1–G15), rows 16–39, foundation/release, api/doctor, global-mode docs and notes all pass, plus tsc strict, check-knowledge, and Prettier. One run had a doctor theme test time out under load; it passes on its own in 3.6 s.

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 7f06172

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 16, 2026

@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.

Approved pending CI. The fresh-clone advice now installs the CLI the project lists, the peer-only case from the last review keeps the add command, and the new G5 assertions fail on main and pass here. CI's test and typecheck jobs did not run on this head because the CI workflow found no room, so it needs a re-run before merge.

Non-blocking, if you touch these files again:

  • Miss: the comments at packages/cli/api/doctor/doctor.mjs:386-391 (and clients/cli/index.mjs:889-891, :912-913) still describe only the add command.
  • The new INSTALL map in foundation/release/notices.mjs gives the same commands as the private installAll in api/theme-edit/_context.mjs; moving that function into foundation/env/package-manager.mjs would let both share it.
Claims and files checked

Review mode: full; reason: spec-record

Claims

  • Release note: in a fresh clone whose package.json lists the CLI, the hint, doctor and the setup reminder say to install the project's dependencies rather than add the CLI again — verified (foundation/release/notices.mjs:518-521, api/doctor/doctor.mjs:396-402, clients/cli/index.mjs:914; G5 and a direct probe of all three).
  • Release note: adding the CLI again replaced the exact version with a range such as ^0.7.10 — verified as npm's behaviour with its default ^ save prefix, which the base's add command triggers; the registry run itself is not repeated here.
  • The hint now ends To install the CLI this project declares, run: npm install and doctor's fix reads the same with a full stop — verified (test/global-local.test.mjs:178-192).
  • Each uses the project's own package manager (pnpm install, yarn install, bun install) — verified (notices.mjs:398-403 keyed by the detected manager; probe with pnpm and yarn projects).
  • The project's package.json stays as it is — verified (the advice is a plain install; no changed path writes a manifest).
  • A CLI named only in peerDependencies keeps the add command — verified (foundation/release/project.mjs:198-204; test/global-local.test.mjs:194-208).
  • cliInstallAdvice is the one place all three read — verified (its only callers are noCliHint, addCliCommandFor for doctor, and the setup reminder).
  • A project with only Core still gets the add command at Core's version, and a folder inside a project whose package.json is not the project's still gets the run-from-the-project advice — verified (G5's first assertion, the G28 and tool-folder rows; the moved branch returns first at notices.mjs:513-515).
  • The new hint and doctor assertions fail on the old code — verified (the head's G5 on the base fails at :178; the base's doctor fix reads To match, run: npm install @astryxdesign/[email protected].).
  • The listed test selection passes (18 files, 472 tests) — verified with one caveat: 469 pass here and the three foundation/release/cache.test.mjs failures fail the same way on the base in this environment.
  • The strict typecheck, knowledge and CLI-structure checks, ESLint and Prettier pass — verified (knowledge and CLI-structure checks exit 0, Prettier clean, the Lint workflow green; the strict typecheck shows no error in a changed file).
  • The FR2 sentence and G5 row describe present behaviour — verified.
  • Before and after on a real 0.7.10 app — consistent with the probe of both trees; the registry run is not repeated here.

Files

  • .changeset/fresh-clone-install-advice.md — clear.
  • docs/specs/AST-081-global-mode/spec.md — clear (FR2 sentence and G5 row only; approval lines untouched; approved for this head).
  • packages/cli/foundation/release/notices.mjs — clear; non-blocking note on the INSTALL map.
  • packages/cli/foundation/release/project.mjs — clear (peer dependencies excluded; release-fact field order unchanged).
  • packages/cli/api/doctor/doctor.mjs — clear; non-blocking note on the comments above the changed lines.
  • packages/cli/api/doctor/_adapter.mjs — clear (passes the flag through; not exported from the package).
  • packages/cli/assets/docs/tree/who-answers.doc.mjs — clear (the clause matches the code; the example below stays scoped to a Core-only project).
  • packages/cli/test/global-local.test.mjs — clear (listed-CLI hint and doctor, and the peer-only case).

Automated review (maintainer link)

* The command that installs a project's dependencies, by package manager.
* @type {Record<string, string>}
*/
const INSTALL = {

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.

Non-blocking: this map gives the same commands as the private installAll in packages/cli/api/theme-edit/_context.mjs (npm install for npm and the two-lockfile case, <pm> install otherwise). Moving that function into foundation/env/package-manager.mjs, beside getRunPrefix, and calling it here and in theme-edit would leave one place for a new package manager or a change to the fallback.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec efb8a35

@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.

Approved pending CI. The fresh-clone advice installs the CLI the project lists, a peer-only CLI keeps the add command, and the new G5 assertions fail on main and pass here; this head adds only an empty commit to the tree reviewed last time. CI has not finished on this head yet, so it needs to pass before merge.

Non-blocking, if you touch these files again:

  • Miss: the comments at packages/cli/api/doctor/doctor.mjs:386-391 (and clients/cli/index.mjs:889-891, :912-913) still describe only the add command.
  • The new INSTALL map in foundation/release/notices.mjs gives the same commands as the private installAll in api/theme-edit/_context.mjs; moving that function into foundation/env/package-manager.mjs would let both share it.
Claims and files checked

Review mode: incremental; reason: none

changed rules (0): none

Claims

  • Release note: in a fresh clone whose package.json lists the CLI, the hint, doctor and the setup reminder say to install the project's dependencies rather than add the CLI again — verified (foundation/release/notices.mjs:518-521, api/doctor/doctor.mjs:396-402, clients/cli/index.mjs:914-919; G5).
  • Release note: adding the CLI again replaced the exact version with a range such as ^0.7.10 — verified as npm's behaviour with its default ^ save prefix, which the base's add command triggers; the registry run itself is not repeated here.
  • Before the change, all three named the add command at Core's version — verified (the base's cliInstallAdvice always returns it).
  • The hint now ends To install the CLI this project declares, run: npm install and doctor's fix reads the same with a full stop — verified (test/global-local.test.mjs:178-192).
  • Each uses the project's own package manager (pnpm install, yarn install, bun install) — verified (notices.mjs:398-403, keyed by the detected manager; fixture probe with pnpm and yarn projects).
  • The project's package.json stays as it is — verified (the advice is a plain install; no changed path writes a manifest).
  • A CLI named only in peerDependencies keeps the add command — verified (foundation/release/project.mjs:162-166, :198-204; test/global-local.test.mjs:194-208).
  • cliInstallAdvice is the one place all three read — verified (its only callers are noCliHint, addCliCommandFor for doctor, and the setup reminder).
  • A project with only Core still gets the add command at Core's version, and a folder inside a project whose package.json is not the project's still gets the run-from-the-project advice — verified (G5's first assertion at :133, the tool-folder tests; the moved branch returns first at notices.mjs:513-515).
  • The new hint and doctor assertions fail on the old code — verified for the hint (the head's G5 fails on the base at :178); the base's doctor fix reads the add command by its code.
  • The listed test selection passes (18 files, 472 tests) — verified with one caveat: 469 pass here, and the three foundation/release/cache.test.mjs process tests fail the same way on the base in this environment.
  • The strict typecheck, knowledge and CLI-structure checks, ESLint and Prettier pass — verified (knowledge and CLI-structure checks exit 0, Prettier and ESLint clean on the changed files, the Lint workflow green; the strict typecheck reports no error in a changed file).
  • The FR2 sentence and G5 row describe present behaviour — verified.
  • Before and after on a real 0.7.10 app — consistent with the fixture probe of both trees; the registry run is not repeated here.

Files

  • .changeset/fresh-clone-install-advice.md — clear.
  • docs/specs/AST-081-global-mode/spec.md — clear (FR2 sentence and G5 row only; approval lines untouched; approved for this head).
  • packages/cli/foundation/release/notices.mjs — clear; non-blocking note on the INSTALL map.
  • packages/cli/foundation/release/project.mjs — clear (peer dependencies excluded; release-fact field order unchanged).
  • packages/cli/api/doctor/doctor.mjs — clear; non-blocking note on the comments above the changed lines.
  • packages/cli/api/doctor/_adapter.mjs — clear (passes the flag through; not exported from the package).
  • packages/cli/assets/docs/tree/who-answers.doc.mjs — clear (the clause matches the code).
  • packages/cli/test/global-local.test.mjs — clear (listed-CLI hint and doctor, and the peer-only case).

Automated review (maintainer link)

@josephfarina
josephfarina merged commit 0f4c0aa into main Nov 16, 2026
226 of 244 checks passed
@github-actions
github-actions Bot deleted the josephfarina/fresh-clone-install-advice branch November 17, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — efb8a35b Deployed Nov 16, 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