Skip to content

fix(cli): doctor tells a fresh clone to install its dependencies for a missing Core or theme package - #12038

Merged
josephfarina merged 4 commits into
mainfrom
josephfarina/fresh-clone-doctor-fixes
Nov 16, 2026
Merged

josephfarina merged 4 commits into
mainfrom
josephfarina/fresh-clone-doctor-fixes

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Someone runs astryx doctor in a fresh clone of an Astryx app. The clone's package.json lists @astryxdesign/core and a theme package such as @astryxdesign/theme-neutral, but nothing is installed yet. A new checkout, a CI machine, and an agent sandbox all start this way. Doctor fails two checks and gives these fixes:

  • core-installed: Install the design system: `npm install @astryxdesign/core` (or yarn/pnpm/bun).
  • theme-owners: npm install @astryxdesign/theme-neutral@latest; npx @astryxdesign/cli@<answering version> theme add neutral --package @astryxdesign/cli. Its message suggests installing the theme at the answering CLI's version.

Following them changes the project. In an app that pins Core and the theme to 0.7.10, running these commands left Core at ^0.7.10 and the theme at ^0.7.16: a theme from another release beside the project's Core, although each theme names the exact Core release it works with. One npm install would have installed what the project lists.

After this change, both checks say to install the project's dependencies, with the project's package manager: core-installed fixes with Install the project's dependencies: `npm install`., and theme-owners with npm install. Its message reads Theme package "@astryxdesign/theme-neutral" is not installed, though this project lists it: install the project's dependencies with npm install. Following them keeps every version the project lists.

Problem and solution fit

  1. Why does it happen? The checks treat a package that does not resolve as one the project lacks, and name a command that adds it. In a fresh clone, the project lists the package; it is only not installed yet.
  2. Why does it harm the task? The add commands install a release the project does not list, and rewrite the version in package.json.
  3. Why does that matter? Doctor is what people and agents run to check a project, and its fixes are meant to be followed as printed.

When the project lists the package among those its install gets (dependencies, devDependencies, or optionalDependencies), the fix is now the package manager's install of the project's dependencies. A package named only as a peer keeps the add command, because some package managers do not install peers. A folder inside the project whose package.json is not the project's also keeps the current advice, because an install there would install that folder's own packages.

Expected behavior and authority

  • spec:AST-050 FR11 check 1: every added theme's owner is installed, and its module and stylesheet resolve. The check's fix should restore that state without changing which theme the record names.
  • spec:AST-081 FR2 and the G5 row (a fresh clone): with nothing installed, advice says to install the project's dependencies (the ERR_VERSIONS_UNAVAILABLE message already does). The CLI's version-alignment fix follows the same rule for a CLI the project lists.

No record changes.

Smallest restoration

  • foundation/release/project.mjs: installsPackage(dir, name) generalizes installsCliPackage.
  • foundation/release/notices.mjs: listedPackageInstall(cwd, name), the one place that decides it: the project's install command when the project cwd belongs to lists name; null outside a project, in a folder inside it whose package.json is not the project's, and when the project does not list name. cliInstallAdvice uses it for the CLI.
  • foundation/env/package-manager.mjs: installDependenciesCommand(dir), the package manager's install command. It moves here from notices.mjs, which uses it.
  • api/doctor/_adapter.mjs: dependencyInstallFor(cwd, name) returns listedPackageInstall's answer.
  • api/doctor/doctor.mjs: core-installed uses it.
  • api/doctor/theme-checks.mjs: refreshThemeCommand returns it for a listed theme package that is not installed. theme-owners names a fix that several themes share once, and separates different fixes with ; .
  • foundation/discovery/theme-imports.mjs: the resolver's message for a listed, uninstalled theme package comes from listedPackageInstall too, so it says what doctor's fix does, in a tool folder with its own package.json included. theme add shows the same message, and still suggests the add once the package is installed.

Evidence

  • Reproduction before the change: an app on Astryx 0.7.10 with node_modules removed, and the current canary installed for the computer. Doctor printed the fixes above. Running every install command it named left "@astryxdesign/core": "^0.7.10" and "@astryxdesign/theme-neutral": "^0.7.16".
  • Result after the change, with only these files replaced in that global copy: the failing checks' fixes are one command, npm install. Running it kept "0.7.10" for Core, the theme, and the CLI. Doctor then had 0 failures.
  • Agents: four coding agents asked to "run astryx doctor, fix what it reports, then make sure the build passes" in that clone all ran npm ci before doctor, in both arms. None saw or followed the old advice, and every build passed. This change helps whoever runs doctor before installing: a person, or an agent that runs doctor first.
  • Representative unchanged path: a project with Core installed passes core-installed as before, and a package named only as a peer keeps the add command. When a listed theme package is installed but stale, the fix names its refresh, as before.
  • Regression tests: core-installed in a project that lists Core (Yarn) and in one that only peer-depends on it, and theme-owners in a fresh clone that lists the theme package (pnpm). Both fail on the old code.

Scope

Components: CLI (doctor: core-installed and theme-owners; the theme import resolver's message)

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

Testing

  • vitest run --project node over api/doctor, foundation/discovery/theme-imports, foundation/release/notices.test.mjs, foundation/env/package-manager.test.mjs, test/global-local.test.mjs, api/theme/add, and the theme command tests: 14 files, 427 passed, 2 skipped.
  • Review rounds: vitest run --project node over api/doctor, foundation/discovery/theme-imports, foundation/release, test/global-local.test.mjs and api/theme/add: 18 files, 441 passed; then api/doctor, theme-imports and global-local after the ; join: 8 files, 285 passed. New tests: two listed themes give one install; one listed and one unlisted give pnpm install; and then the other theme's steps; the resolver in a tool folder with its own package.json names the add.
  • After rebasing onto main: vitest run --project node over foundation/release, foundation/discovery, foundation/fs, api/doctor, the global-local row tests, the global-mode docs and notes tests, and setup-nudge: 88 files, 1984 passed. Three timing-sensitive tests in foundation/discovery and foundation/fs failed under that load and pass when run alone; this change touches neither behavior.
  • tsc --project tsconfig.strict.json after sync-api-types, ESLint, and Prettier on the changed files.

…a missing Core or theme package

In a project that lists @astryxdesign/core and a theme package but has
not installed its dependencies, doctor's core-installed fix added Core
with no version, and its theme-owners fix added the theme package at the
latest release, then added the theme again from the CLI's copy. Following
them replaced the versions the project lists: an app pinned to 0.7.10
ended with Core ^0.7.10 and theme-neutral ^0.7.16.

When the project lists the package among those its install gets, both
fixes are now the package manager's install of the project's
dependencies, and the theme resolver's message says so. A package named
only as a peer, and a folder inside the project with its own
package.json, keep the current advice.
@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 11:11am 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, 11:31 AM UTC

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · c9a955e

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 5.12 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.

Current run: CI concluded cancelled; parts of this report may be missing.


Generated by PR Enrichment workflow | View full report

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec ee80aa4

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 2e6660f

@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 advice is the right repair, and an engineering owner has approved the core-installed change for this head, but two problems in the theme path remain.

  • With two or more listed package themes that are not installed, theme-owners joins one identical fix per theme with a space, so it prints npm install npm install (packages/cli/api/doctor/theme-checks.mjs:1433-1443), which npm runs as adding packages named npm and install; dedupe the fixes and messages before joining, and add a two-theme case to the fresh-clone test.
  • The theme resolver repeats the listed-package install decision without the nested-folder check that dependencyInstallFor applies (packages/cli/foundation/discovery/theme-imports.mjs:173-187), so in a folder with its own package.json the theme-owners message and theme add say to run the project's install while the fix still names the add, contrary to the description; put the decision in one foundation helper that cliInstallAdvice, dependencyInstallFor and the resolver all call.
Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0)
  • Claim: on the base, doctor names add commands for a missing Core and theme in a fresh clone: verified (base doctor.mjs core fix, base refreshThemeCommand).
  • Claim: core-installed now names the project's install when the project lists Core: verified (doctor.mjs:331-349, doctor.test.mjs:301-338).
  • Claim: theme-owners and the resolver message now name the project's install for a listed theme package: verified for one theme (theme-checks.mjs:119-125, theme-imports.mjs:173-187, theme-checks.test.mjs:984-1033); false for two or more themes (first finding).
  • Claim: following the fixes keeps every version the project lists: verified for one theme; false with several themes (first finding).
  • Claim: a Core named only as a peer keeps the add command: verified (project.mjs:192-203, doctor.test.mjs).
  • Claim: a folder inside the project with its own package.json keeps the current advice: true for the core-installed and theme-owners fixes; false for the theme message and theme add suggestions (second finding).
  • Claim: an installed but stale theme package keeps its refresh fix: verified (theme-checks.mjs:122).
  • Claim: installsPackage, projectListsPackage, installDependenciesCommand and dependencyInstallFor behave as described, and cliInstallAdvice is unchanged: verified.
  • Claim: theme add shows the same message and still suggests the add: verified (theme-imports.mjs:176-185).
  • Claim: no record changes: verified.
  • Claim: the new tests fail on the old code: verified (both fail on the base with these tests).
  • Claim: the real-app reproduction and the agent trial: author-reported, not reproduced (they need the public registry).
  • Changeset: doctor says to install the project's dependencies for a missing Core and theme package: verified for Core and one theme; with several themes the install repeats (first finding).
  • File .changeset/fresh-clone-doctor-fixes.md: first finding.
  • File packages/cli/api/doctor/_adapter.mjs: clear (one of the three decision sites, second finding).
  • File packages/cli/api/doctor/doctor.mjs: clear.
  • File packages/cli/api/doctor/doctor.test.mjs: clear.
  • File packages/cli/api/doctor/theme-checks.mjs: first finding.
  • File packages/cli/api/doctor/theme-checks.test.mjs: clear; a two-theme case belongs with the first fix.
  • File packages/cli/foundation/discovery/theme-imports.mjs: second finding.
  • File packages/cli/foundation/env/package-manager.mjs: clear.
  • File packages/cli/foundation/release/notices.mjs: clear (one of the three decision sites, second finding).
  • File packages/cli/foundation/release/project.mjs: clear.

Automated review (maintainer link)

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec c9a955e

@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 shared listedPackageInstall helper now keeps doctor, the theme resolver and the CLI advice in step, and two listed themes print one install, but two problems remain.

  • theme-owners still joins each theme's fix with a space (packages/cli/api/doctor/theme-checks.mjs:1437-1449), so a listed theme's bare install swallows the next theme's fix, as in npm install npm install @astryxdesign/theme-stone@latest; … for an app that lists theme-neutral but not theme-stone; join the distinct fixes with ; and add that case to the fresh-clone test.
  • The description still says foundation/release/project.mjs gains projectListsPackage, which this head removed; describe listedPackageInstall in foundation/release/notices.mjs, which cliInstallAdvice, dependencyInstallFor and the theme resolver now share.
Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0)
  • Claim (changeset): in a fresh clone doctor now says to install the project's dependencies for a missing Core and theme package: verified (doctor.mjs:331-349, theme-checks.mjs:119-125, the new tests).
  • Claim (changeset): before, the fixes added Core with no version and the theme at the latest release: verified (base core-installed fix and refreshThemeCommand; probe on the base).
  • Claim: on the base, doctor prints the two add fixes the description quotes: verified (base code; probe).
  • Claim: following them rewrote a 0.7.10 app to ^0.7.10 Core and ^0.7.16 theme: author-reported, not reproduced (needs the registry).
  • Claim: after the change both checks name the project's install, with the quoted theme message: verified (doctor.test.mjs:301-336, theme-checks.test.mjs:984-1049).
  • Claim: a package in dependencies, devDependencies or optionalDependencies gets the install, a peer-only one keeps the add: verified (project.mjs:163-167, project.mjs:199-203, the peer case in doctor.test.mjs).
  • Claim: a folder with its own package.json keeps the current advice: verified (notices.mjs:477-482, theme-imports.test.mjs:54-76).
  • Claim: the theme-app record's doctor check 1 and the global-mode record's CLI rule govern the change, and no record changes: verified (both records read; no record file in the diff).
  • Claim: the CLI's version-alignment advice follows the same rule for a listed CLI: verified (notices.mjs:520-530).
  • Claim: project.mjs generalizes installsCliPackage to installsPackage: verified; and adds projectListsPackage: false (removed at this head).
  • Claim: installDependenciesCommand moves to package-manager.mjs from notices.mjs, which uses it: verified (package-manager.mjs:331-350).
  • Claim: dependencyInstallFor gives the install when the project lists the package and the folder is the project's: verified (_adapter.mjs:733-735).
  • Claim: core-installed and refreshThemeCommand use it: verified (doctor.mjs:334-336, theme-checks.mjs:122-125).
  • Claim: the resolver's message names the install, and theme add shows it and still suggests the add: verified (theme-imports.mjs:166-183, api/theme/_adapter.mjs:926-939).
  • Claim: an installed Core passes and an installed but stale listed theme keeps its refresh: verified (doctor.mjs:329-344, theme-checks.mjs:122-123).
  • Claim: the regression tests fail on the old code: verified (all three new tests fail on the base code and pass on the head).
  • Claim: the stated test runs (427 and 1984 passed): not reproduced as stated; the five changed or nearest test files pass at this head (270 passed, 2 skipped).
  • Claim: four agents ran npm ci before doctor: author-reported, not reproduced.
  • File .changeset/fresh-clone-doctor-fixes.md: clear.
  • File packages/cli/api/doctor/_adapter.mjs: clear.
  • File packages/cli/api/doctor/doctor.mjs: clear.
  • File packages/cli/api/doctor/doctor.test.mjs: clear.
  • File packages/cli/api/doctor/theme-checks.mjs: the space join (first finding).
  • File packages/cli/api/doctor/theme-checks.test.mjs: clear; lacks the mixed case the first finding asks for.
  • File packages/cli/foundation/discovery/theme-imports.mjs: clear.
  • File packages/cli/foundation/discovery/theme-imports.test.mjs: clear.
  • File packages/cli/foundation/env/package-manager.mjs: clear.
  • File packages/cli/foundation/release/notices.mjs: clear.
  • File packages/cli/foundation/release/project.mjs: clear; the description misnames its change (second finding).

Automated review (maintainer link)

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 4a6f785

@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: some test-node shards have not finished on this head yet.

astryx doctor in a fresh clone now names the project's own install for a listed Core or theme package, and both points from the last review are fixed: distinct theme fixes are separated by ; , and the description matches the code. The new tests fail without the change and pass with it, and nothing else is needed from you.

Claims and files checked

Review mode: incremental; reason: none

  • changed rules (0): none

Claims:

  • The changeset's fresh-clone claim, that doctor now says to install the project's dependencies for a missing Core and theme package: verified (doctor.mjs:348, theme-checks.mjs:119-125, new tests).
  • The changeset's "before" claim, that the fixes added Core with no version and the theme at the latest release: verified (base doctor.mjs:340 and refreshThemeCommand).
  • The old fixes the description quotes: verified on base sources; the old message's version comes from the CLI's own dependency ranges, which the canary publish pins to its release: verified (template-needs.mjs:240-265, the release workflow).
  • The reproduction in an app on 0.7.10 that ended at ^0.7.10 and ^0.7.16, and the four-agent trial: author-reported, not reproducible here without the registry.
  • The new fixes and the new resolver message text: verified (doctor.mjs:348, theme-imports.mjs:173).
  • Listed means dependencies, devDependencies or optionalDependencies, and a peer-only package keeps the add: verified (project.mjs:163-166, project.mjs:199-203, doctor.test.mjs:316-336).
  • A folder with its own package.json keeps the current advice: verified (notices.mjs:478, theme-imports.test.mjs:66-76).
  • Each module change listed under the smallest restoration: verified (project.mjs:199, notices.mjs:477-482 and 526-528, package-manager.mjs:331-350, _adapter.mjs:733-735, doctor.mjs:334-336, theme-checks.mjs:119-125 and 1416-1449, theme-imports.mjs:166-184).
  • theme add shows the same message and still suggests the add: verified (theme-imports.mjs:175-182, api/theme/_adapter.mjs:934-938).
  • An installed but stale listed theme still gets its refresh: verified (theme-checks.mjs:122-127).
  • The regression tests fail on the old code: verified (all four new tests fail on base sources; the other 165 pass).
  • No record changes: verified (no file under docs/ changes).
  • Lint and typecheck pass: verified (both green on this head).

Files:

  • .changeset/fresh-clone-doctor-fixes.md: clear
  • packages/cli/api/doctor/_adapter.mjs: clear
  • packages/cli/api/doctor/doctor.mjs: clear
  • packages/cli/api/doctor/doctor.test.mjs: clear
  • packages/cli/api/doctor/theme-checks.mjs: clear
  • packages/cli/api/doctor/theme-checks.test.mjs: clear
  • packages/cli/foundation/discovery/theme-imports.mjs: clear
  • packages/cli/foundation/discovery/theme-imports.test.mjs: clear
  • packages/cli/foundation/env/package-manager.mjs: clear
  • packages/cli/foundation/release/notices.mjs: clear
  • packages/cli/foundation/release/project.mjs: clear

Automated review (maintainer link)

@josephfarina
josephfarina merged commit 92a19ac into main Nov 16, 2026
84 checks passed
@github-actions
github-actions Bot deleted the josephfarina/fresh-clone-doctor-fixes branch November 17, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 4a6f785d 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