Repository navigation
fix(cli): in a Yarn Plug'n'Play project, a copy started outside the project's runtime hands the run to the project's own CLI - #11972
Conversation
…ct's own CLI A Plug'n'Play project keeps no node_modules: only the runtime Yarn writes at the project root knows where its packages are. A copy of the CLI started without that runtime, such as the one installed for the computer, saw no project CLI and no Core there, answered with its own release, told the user to add a CLI the project already has, and doctor reported Core missing. Such a copy now starts again with the project's runtime preloaded through NODE_OPTIONS, as Yarn starts a command, and that run hands off to the project's own CLI as in any other project. Printed commands in a Plug'n'Play project start with `yarn astryx` when the workspace depends on the CLI, instead of downloading the CLI with `yarn dlx` for each command.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec efc0794 |
There was a problem hiding this comment.
Changes requested. The Plug'n'Play restart does what it says, and its AST-081 change is approved, but three small fixes are needed first.
- In a Plug'n'Play project, a SIGINT sent only to the starting copy now reaches the project's CLI after about 10 s instead of the 5 s that AST-081 FR9 and G58 require: the restart (
handoff.mjs:204) and the hand-off each wait out the grace period, so pass the interrupt straight on from the restart's parent and add a Plug'n'Play case to G58 or G59. - The loop guard at
pnp-runtime.mjs:73compares the raw runtime path with the JSON-quoted path thatwithPnpRuntimewrites for paths with spaces; on Windows, where that quoting doubles every backslash, a runtime that does not start makes the run start again over and over, one nested Node process per level, so compare against the same quoted text and add a Windows-path unit test. - The title says every copy reaches the project's own CLI, but by the PR's own platform note a programmatic host's run does not start again, and G59 tests only the global copy, so retitle it to name copies started outside the project's runtime, as the changeset already does.
Two non-blocking notes: the runtime search ignores the repository and home-folder limits that the record's project search uses, and a runtime that throws at preload ends the run with exit 1.
Claims and files checked
Review mode: full; reason: no-earlier-review
Claims:
- Changeset: the computer's
astryxhands each Plug'n'Play run to the project's CLI, and printed commands start withyarn astryx. Verified: G59 passes on this branch and fails on the base. - Title: every copy reaches the project's own CLI. False: hosted runs, and runs already under another Plug'n'Play runtime, do not start again (
handoff.mjs:200,pnp-runtime.mjs:71). - Before: the global copy answered itself and suggested
yarn add. Verified: the G28 test, and G59 run against the base. - Before:
doctorcould not resolve Core. Consistent with the code (no Core is visible outside the runtime); not reproduced. - Before: printed commands used
yarn dlx @astryxdesign/cli@<version>. Verified:cliBinResolveslooked only fornode_modules/.bin, and the dlx prefix for Yarn 2+ isyarn dlx. - The run starts again with the runtime preloaded through
NODE_OPTIONS. Verified:pnp-runtime.mjs:93-107,handoff.mjs:200-211. - The restarted run reads packages through the runtime API, and the project's CLI inherits the runtime. Verified:
findPnpPackage; the spawn inherits the environment. - Node options that already preload the runtime prevent a loop. Verified on POSIX (G59). False on Windows paths with spaces (
pnp-runtime.mjs:73). - A programmatic host's run does not start again. Verified:
handoff.mjs:200. pnpDependsOnandfindPnpPackageshare one runtime lookup. Verified:paths.mjs:693-745.cliBinResolvesis true under Plug'n'Play when the folder's workspace depends on the CLI. Verified: unit tests,package-manager.mjs:482.- The rows-file rename is applied in the record, the contributing guide and the duration files. Verified: the old name no longer appears.
- Outside Plug'n'Play, the only added work is one file check per folder. Verified:
pnp-runtime.mjs:43-55,:72-75. - G59 fails before the change, checks the printed command, and covers a runtime that does not start. Verified: G59 run against the base, and the test body.
- Rows G1 to G58 and the hand-off end-to-end tests pass unchanged. Verified: 23 of the 24 listed files pass; the 3
cache.test.mjsfailures also happen on the base in the review sandbox. - Timings and the four-agent comparison. Not reproduced (the author's measurements in a real Yarn app).
- No new public API, default or interaction model. Verified: the exports map and command docs are unchanged, and the CI API analysis lists no rows.
Files:
.changeset/global-pnp-runtime.md: cleardocs/contributing/cli-conventions.md: cleardocs/specs/AST-081-global-mode/spec.md: note (unchanged G28 now overlaps G59)packages/cli/foundation/env/package-manager.mjs: clearpackages/cli/foundation/env/package-manager.test.mjs: clearpackages/cli/foundation/fs/paths.mjs: clearpackages/cli/foundation/fs/paths.test.mjs: clearpackages/cli/foundation/release/handoff.mjs: blocking (interrupt grace doubled on the restart path)packages/cli/foundation/release/pnp-runtime.mjs: blocking (Windows loop guard); note (runtime search limits)packages/cli/foundation/release/pnp-runtime.test.mjs: clear (no Windows-path case)packages/cli/test-utils/pnp-fixtures.mjs: clearpackages/cli/test/global-local.rows-40-59.test.mjs: clearpackages/cli/test/global-local.test.mjs: clearscripts/vitest-node-durations.json: clearscripts/vitest-node-durations.min-node.json: clear
PR Analysis Report🔎 Preview ·
|
…tops on a quoted runtime - The copy that starts a run again with the project's runtime passes an interrupt straight on; the run started again passes it on to the project's CLI after the one grace, so an interrupt sent to the starting copy alone arrives after 5 seconds, not 10. A hand-off passes on at most one interrupt per grace, so a terminal's Ctrl-C that reaches a restarted run twice is still passed on once. G58 covers a Plug'n'Play project. - The loop guard reads the runtime in the Node options both as Yarn writes it and as the restart quotes it; quoting doubles a Windows path's backslashes, so the raw path alone missed it. - The runtime search keeps the project search's limits: it ends at a repository's root and reads the home folder only when it starts there.
|
Thanks for the review. Fixed in c1854ff:
Non-blocking:
Local: 24 files, 575 passed (all of G1–G59, the hand-off end-to-end tests, |
|
/approve-spec c1854ff |
There was a problem hiding this comment.
Changes requested. The three earlier blockers are fixed: an interrupt on the restarted path now arrives after one 5-second grace, the loop guard reads quoted Windows paths, and the title is accurate.
handOff's new one-interrupt-per-grace guard (packages/cli/foundation/release/handoff.mjs:549-552) drops a second SIGINT sent to the starting copy while the first is still waiting out its grace, in every layout (two interrupts 2 s apart now reach the project's CLI once, at 5 s, instead of at 5 s and 7 s), against AST-081 FR9's "A SIGINT that reaches only the starting copy is forwarded if the handed-off CLI is still running 5 seconds later"; deleteinterruptWaitingand keepinterruptAtOnce, since G58 (its Plug'n'Play cases included) and G59 still pass without the guard.
This guard follows the earlier review's suggestion of a single pending timer, which was wrong: a group Ctrl-C already reaches a CLI that stops in time only once without it. Non-blocking: row G28 still describes the case G59's runtime-that-does-not-start branch covers; consider narrowing it or folding it into G59.
Claims and files checked
Review mode: incremental; reason: none
Claims:
- Before the change, the computer's copy in a Plug'n'Play project answered with its own release and suggested installing the CLI: verified (G59 fails at the base with the computer's release answering; G28's test shows the hint).
- Printed commands there used a
yarn dlxdownload and now useyarn astryx: verified (cliBinResolvesfallback, G59's printed-command assertion, unit tests). - The computer's copy now hands the run to the project's own CLI: verified (G59).
- The restart preloads the runtime through
NODE_OPTIONSas Yarn does, quoting paths with white space: verified (pnp-runtime.mjs:127-139, unit tests). - The restarted run loads nothing of the project's before the hand-off, keeping FR2's order: verified (the restart runs before the release choice; it reads only package metadata).
- The runtime lookup needs a runtime within the project search's limits, a package.json under it that declares Astryx, and no CLI or Core visible without it: verified (
pnp-runtime.mjs:46-63,:103-116, unit tests). - The loop guard reads the runtime as Yarn writes it and quoted: verified (
pnp-runtime.mjs:83-88, unit tests). - A run that already preloads the runtime, and a programmatic host's run, never start again: verified (
handoff.mjs:200,pnp-runtime.mjs:104-106, G59). - The restarting copy passes an interrupt straight on, so it reaches the project's CLI once after one 5-second grace, and G58 covers Plug'n'Play: verified (G58).
- A hand-off passes on at most one interrupt per grace: verified as implemented; it contradicts FR9 (blocking finding above).
pnpDependsOnsits besidefindPnpPackageand both share one runtime-API lookup: verified (paths.mjs:693-746).cliBinResolvesis true under Plug'n'Play when the folder's workspace depends on the CLI: verified (unit tests).- AST-081 gains the FR9 sentence, row G59 and the narrower platform note, and the rows file's new name is used in the record, the contributing guide and the duration records: verified (no old name remains).
- npm and pnpm projects, Core-only projects and folders outside a project are unchanged: false for interrupt forwarding (blocking finding above); rows G1 to G58 pass.
- Outside Plug'n'Play the only added work is one file check per folder: accurate in substance (one runtime check per folder, with the project search's repository-marker checks ending the walk).
- G59 fails before the change, checks the printed command, and checks that a runtime that does not start leaves one answer: verified (red-first run).
- The real Yarn 4.18 transcripts, timings and coding-agent runs: the author's measurements, not reproduced here; G59 shows the same behavior with a stand-in runtime.
- The test totals (24 files): verified apart from three cache tests that fail the same way at the base in this sandbox.
- Changeset: the computer's
astryxhands each run to the project's own CLI by starting again with the runtime, and printed commands start withyarn astryx: verified (G59). - Title: a copy started outside the project's runtime hands the run to the project's own CLI: verified.
Files:
.changeset/global-pnp-runtime.md: cleardocs/contributing/cli-conventions.md: cleardocs/specs/AST-081-global-mode/spec.md: clear (owner-approved); G28 notepackages/cli/foundation/env/package-manager.mjs: clearpackages/cli/foundation/env/package-manager.test.mjs: clearpackages/cli/foundation/fs/paths.mjs: clearpackages/cli/foundation/fs/paths.test.mjs: clearpackages/cli/foundation/release/handoff.mjs: blocking finding (interrupt guard)packages/cli/foundation/release/pnp-runtime.mjs: clearpackages/cli/foundation/release/pnp-runtime.test.mjs: clearpackages/cli/foundation/release/project.mjs: clearpackages/cli/test-utils/pnp-fixtures.mjs: clearpackages/cli/test/global-local.rows-40-59.test.mjs: clearpackages/cli/test/global-local.test.mjs: clearscripts/vitest-node-durations.json: clearscripts/vitest-node-durations.min-node.json: clear
…untime that does not start - Drop the one-interrupt-per-grace guard: it held back a second interrupt sent to the starting copy within the grace, in every layout. The copy that starts a Plug'n'Play run again still passes an interrupt straight on. - G28 now names the case its test covers, a Plug'n'Play runtime that does not start; G59 keeps the hand-off through a runtime that does.
|
Fixed in the new head:
|
|
/approve-spec 44639f6 |
There was a problem hiding this comment.
Changes requested. The interrupt guard is gone, and the restart, the printed commands, the AST-081 change and the tests all check out; only one sentence in the description needs correcting.
- The description's "Regression test" bullet says G59 also checks that a runtime that does not start leaves one answer from the starting copy, but this head moved that case to G28 (
packages/cli/test/global-local.rows-16-39.test.mjs), so update that sentence to name G28.
Non-blocking: in a Plug'n'Play project, a terminal Ctrl-C reaches a project CLI that is still running after 5 seconds three times instead of twice, because the restarted run arms a grace timer both for the group's interrupt and for the copy that forwards it (see the inline note).
Claims and files checked
Review mode: full; reason: spec-record
Claims:
- Before the change, the computer's copy in a Plug'n'Play project answered with its own release and suggested installing the CLI: verified (G59 fails at the base with the computer's release answering; G28 shows the hint). That
doctorfailed on Core: the author's measurement. - Printed commands there used a
yarn dlxdownload and now useyarn astryx: verified (cliBinResolvesfalls back topnpDependsOn; G59's printed-command assertion; a unit test that fails at the base). - The computer's copy now hands the run to the project's own CLI: verified (G59).
- The restart preloads the runtime through
NODE_OPTIONSas Yarn does, quoting a path with white space: verified (pnp-runtime.mjs:127-139, unit tests). - The restarted run reads the project's packages through the runtime, and the project's CLI inherits it: verified (
findPnpPackage; the hand-off passes this run's environment). - The restarted run loads nothing of the project's before the hand-off: verified (the restart runs before the release choice, which reads only package metadata).
- The runtime lookup stays within the project search's limits and needs a package.json under it that declares Astryx, with no CLI or Core visible without it: verified (
pnp-runtime.mjs:46-63and:103-116, unit tests). - The loop guard reads the runtime as Yarn writes it and quoted: verified (
pnp-runtime.mjs:83-88, unit tests). - A run that already preloads the runtime, and a programmatic host's run, never start again: verified (
handoff.mjs:200,pnp-runtime.mjs:104-106, G28). - The restarting copy passes an interrupt straight on, so it reaches the project's CLI once after one 5-second grace, and G58 covers Plug'n'Play: verified (G58; its Plug'n'Play case fails at the base).
pnpDependsOnsits besidefindPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-746).cliBinResolvesis true under Plug'n'Play when the folder's workspace depends on the CLI: verified (unit tests).- AST-081 gains the FR9 sentence, row G59, G28 narrowed to the case its test covers, and the narrower platform note, and the rows file's new name is used everywhere: verified (no old name remains).
- npm and pnpm projects, Core-only projects and folders outside a project are unchanged, and rows G1 to G58 and the hand-off end-to-end tests pass: verified.
- Outside Plug'n'Play the only added work is one file check per folder: accurate in substance (one runtime check per folder, plus the repository-marker checks that end the walk at the repository root).
- G59 fails before the change and checks the printed command: verified (red-first run). That G59 also checks a runtime that does not start: false at this head (blocking finding above; G28 covers it).
- Unit tests cover the runtime lookup, the environment,
pnpDependsOnandcliBinResolves: verified. - The real Yarn 4.18 transcripts, timings and coding-agent runs: the author's measurements, not reproduced; G59 shows the same behavior with a stand-in runtime.
- The test totals (24 files, 572 passed, 3 skipped): consistent; three unrelated cache tests that need readable process titles fail the same way at the base.
- The latest comment: the one-interrupt-per-grace guard is gone, and G28 names the runtime that does not start: verified.
- Changeset: the computer's
astryxhands each run to the project's own CLI by starting again with the runtime, and printed commands start withyarn astryx: verified (G59). - Title: a copy started outside the project's runtime hands the run to the project's own CLI: verified.
Files:
.changeset/global-pnp-runtime.md: cleardocs/contributing/cli-conventions.md: cleardocs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)packages/cli/foundation/env/package-manager.mjs: clearpackages/cli/foundation/env/package-manager.test.mjs: clearpackages/cli/foundation/fs/paths.mjs: clearpackages/cli/foundation/fs/paths.test.mjs: clearpackages/cli/foundation/release/handoff.mjs: clear; non-blocking note (interrupt count)packages/cli/foundation/release/pnp-runtime.mjs: clearpackages/cli/foundation/release/pnp-runtime.test.mjs: clearpackages/cli/foundation/release/project.mjs: clearpackages/cli/test-utils/pnp-fixtures.mjs: clearpackages/cli/test/global-local.rows-16-39.test.mjs: clearpackages/cli/test/global-local.rows-40-59.test.mjs: clear (the description misstates what G59 covers; blocking finding above)packages/cli/test/global-local.test.mjs: clearscripts/vitest-node-durations.json: clearscripts/vitest-node-durations.min-node.json: clear
| if (interruptAtOnce) { | ||
| forward('SIGINT'); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Non-blocking: on a terminal Ctrl-C, this process and the restarted run both get the group's SIGINT, and this branch forwards it again at once. The restarted run then arms two grace timers, so a project CLI that is still running after 5 s receives SIGINT three times (at about 0 s, 5 s and 5 s) instead of twice, as in a node_modules project. FR9 and G58 fix the count only for a CLI that stops within the grace, so this does not contradict them. For parity, the grace could merge SIGINTs that arrive a few milliseconds apart.
|
The description is fixed. The "Regression test" bullet now names G28 for a runtime that does not start, and G59 for the hand-off and the printed command. On the non-blocking interrupt count: I tried the suggested merge of interrupts that arrive a few milliseconds apart, with a G58 case for a CLI still running after the grace in a Plug'n'Play project. Without the merge, that CLI got the interrupt twice, not three times: the group's copy, then one forward after 5 s, as in a |
|
/approve-spec dab6c16 |
|
I'll run a full review to re-check this with your note. |
There was a problem hiding this comment.
Changes requested. The description fix checks out, and the restart, the printed commands, the AST-081 change and the tests hold. One problem in the restart itself remains, which earlier reviews missed.
- Miss: in a Plug'n'Play project that has
.pnp.loader.mjs(Yarn writes it by default for atype: moduleworkspace), the restarted run gets--experimental-loaderand prints Node's three-lineExperimentalWarningbefore it hands off, and the project's CLI prints it again, so the computer'sastryxprints that warning twice whereyarn astryxprints it once, against AST-081 FR1's same output through every door; keep the restarted run's own warning out (for example, start it with--disable-warning=ExperimentalWarningas a Node argument, not inNODE_OPTIONS, so the project's CLI is unaffected) and add the loader to G59's fixture with a check of the whole standard error.
Non-blocking: in a Plug'n'Play project, a terminal Ctrl-C can reach a project CLI that is still running after 5 seconds three times instead of twice (see the inline note).
Claims and files checked
Review mode: incremental; reason: none
Claims:
- Before the change, the computer's copy in a Plug'n'Play project answered with its own release and asked for a
yarn addof the CLI: verified (G59 fails at the base with the computer's release answering; the same fixture prints that hint at the base). Thatdoctorfailed on Core: the author's measurement. - Printed commands there used a
yarn dlxdownload and now useyarn astryx: verified (cliBinResolvesfalls back topnpDependsOn; G59's printed-command assertion; the same fixture printsyarn dlx @astryxdesign/[email protected]at the base). - The computer's copy now hands the run to the project's own CLI: verified (G59).
- The restart preloads the runtime through
NODE_OPTIONSas Yarn does, quoting a path with white space: verified for the flags and quoting (pnp-runtime.mjs:127-139, unit tests, Yarn's published plugin); it appends after existing options where Yarn prepends. - The restarted run reads the project's packages through the runtime, and the project's CLI inherits it: verified (
findPnpPackage; the hand-off passes this run's environment). - The restarted run loads nothing of the project's before the hand-off: verified (the restart runs before the release choice, which reads only package metadata).
- The runtime lookup stays within the project search's limits and needs a package.json under it that declares Astryx, with no CLI or Core visible without it: verified (
pnp-runtime.mjs:46-63and:103-116, unit tests). - The loop guard reads the runtime as Yarn writes it and quoted: verified (
pnp-runtime.mjs:83-88, unit tests). - A run that already preloads the runtime, and a programmatic host's run, never start again: verified (
handoff.mjs:200,pnp-runtime.mjs:104-106, G28). - The restarting copy passes an interrupt straight on, so an interrupt sent to it alone reaches the project's CLI after one 5-second grace, and G58 covers Plug'n'Play: verified (G58 passes, and its Plug'n'Play case fails at the base; a probe measured 5.01 s).
pnpDependsOnsits besidefindPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-747).cliBinResolvesis true under Plug'n'Play when the folder's workspace depends on the CLI: verified (unit test fails at the base, passes at the head).- AST-081 gains the FR9 sentence, row G59, G28 narrowed to the case its test covers, and the narrower platform note, and the rows file's new name is used everywhere: verified (no old name remains).
- npm and pnpm projects, Core-only projects and folders outside a project are unchanged, and rows G1 to G58 and the hand-off end-to-end tests pass: verified.
- Outside Plug'n'Play the only added work is one file check per folder: accurate in substance (one runtime check per folder, plus the repository-marker checks that end the walk at the repository root).
- G59 fails before the change and checks the printed command: verified (red-first run). G28 covers a runtime that does not start, and the starting copy answers: verified (G28 passes with an empty runtime and ends with one answer).
- Unit tests cover the runtime lookup, the environment,
pnpDependsOnandcliBinResolves: verified. - The real Yarn 4.18 transcripts, timings and coding-agent runs: the author's measurements, not reproduced; G59 shows the same behavior with a stand-in runtime.
- The test totals (24 files, 572 passed, 3 skipped): not reproduced in full; the 9 most relevant files pass here.
- The latest comment's count of two interrupts for a CLI still running after the grace: a CLI that stays running gets three on this head (non-blocking note).
- Changeset: the computer's
astryxhands each run to the project's own CLI by starting again with the runtime, and printed commands start withyarn astryx: verified (G59); it does not mention the doubled loader warning above. - Title: a copy started outside the project's runtime hands the run to the project's own CLI: verified.
Files:
.changeset/global-pnp-runtime.md: cleardocs/contributing/cli-conventions.md: cleardocs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)packages/cli/foundation/env/package-manager.mjs: clearpackages/cli/foundation/env/package-manager.test.mjs: clearpackages/cli/foundation/fs/paths.mjs: clearpackages/cli/foundation/fs/paths.test.mjs: clearpackages/cli/foundation/release/handoff.mjs: blocking finding above (the restart's loader warning); non-blocking note (interrupt count)packages/cli/foundation/release/pnp-runtime.mjs: part of the blocking finding (the loader the restart preloads)packages/cli/foundation/release/pnp-runtime.test.mjs: clearpackages/cli/foundation/release/project.mjs: clearpackages/cli/test-utils/pnp-fixtures.mjs: clearpackages/cli/test/global-local.rows-16-39.test.mjs: clearpackages/cli/test/global-local.rows-40-59.test.mjs: G59's fixture has no.pnp.loader.mjs, so it misses the blocking findingpackages/cli/test/global-local.test.mjs: clearscripts/vitest-node-durations.json: clearscripts/vitest-node-durations.min-node.json: clear
…ts own Preloading a project's .pnp.loader.mjs makes Node print its three-line ExperimentalWarning once per process. The run started again with the runtime printed it, and the project's CLI it hands off to printed it again, so the computer's astryx warned twice where yarn astryx warns once. The run started again now gets --disable-warning=ExperimentalWarning as a Node argument of its own, which the project's CLI does not inherit. G59's fixture has the loader, and checks all of standard error.
|
Fixed in the new head. The run started again with the runtime now gets |
|
/approve-spec e296865 |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet. The restarted run now keeps its own loader warning out, so in a Plug'n'Play app with .pnp.loader.mjs the computer's astryx prints the same standard error as yarn astryx, and G59 checks it; the restart, the printed commands, the AST-081 change and the tests hold.
Non-blocking: in a Plug'n'Play project, a terminal Ctrl-C can reach a project CLI that is still running after 5 seconds three times instead of twice (see the earlier inline note).
Claims and files checked
Review mode: incremental; reason: none
Claims:
- Before the change, the computer's copy in a Plug'n'Play project answered with its own release and asked for a
yarn addof the CLI: verified (G59 fails at the base with the computer's release answering, and the same fixture prints that hint there). Thatcomponentwarned about the theme anddoctorfailed on Core: the author's measurement, not reproduced. - Printed commands there used a
yarn dlxdownload and now useyarn astryx: verified for the picker (cliBinResolvesfalls back topnpDependsOn; G59 assertsyarn astryx; the base printsyarn dlx @astryxdesign/[email protected]). The lineinitwrites: the author's measurement, not run here. - The computer's copy now hands the run to the project's own CLI, as in other layouts: verified (G59).
- The restart preloads the runtime through
NODE_OPTIONSas Yarn does, quoting a path with white space: verified for the flags and quoting (pnp-runtime.mjs:127-139, unit tests); it appends after existing options where Yarn prepends. - The restarted run reads the project's packages through the runtime, and the project's CLI inherits it: verified (
findPnpPackage; the hand-off passes the run's environment; G59). - The restarted run loads nothing of the project's before the hand-off: verified (the restart runs before the release choice, which reads only package metadata).
- The runtime lookup stays within the project search's limits and needs a package.json under it that declares Astryx, with no CLI or Core visible without it: verified (
pnp-runtime.mjs:46-63and:103-116, unit tests). - The loop guard reads the runtime as Yarn writes it and quoted: verified (
pnp-runtime.mjs:83-88, unit tests). - A run that already preloads the runtime, and a programmatic host's run, never start again: verified (
handoff.mjs:200,pnp-runtime.mjs:104-106, G28). - The restarting copy passes an interrupt straight on, so an interrupt sent to it alone reaches the project's CLI after one 5-second grace, and G58 covers Plug'n'Play: verified (G58 passes; its Plug'n'Play case fails at the base).
pnpDependsOnsits besidefindPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-747).cliBinResolvesis true under Plug'n'Play when the folder's workspace depends on the CLI: verified (unit test fails at the base, passes at the head).- AST-081 gains the FR9 sentence, row G59, G28 narrowed to the case its test covers, and the narrower platform note, and the rows file's new name is used everywhere: verified (no old name remains).
- npm and pnpm projects, Core-only projects and folders outside a project are unchanged, and rows G1 to G58 and the hand-off end-to-end tests pass: verified (all three rows files and the hand-off end-to-end tests pass at the head).
- Outside Plug'n'Play the only added work is one file check per folder: accurate in substance (one runtime check per folder, plus the repository-marker checks that end the walk at the repository root).
- G59 fails before the change and checks the printed command; G28 covers a runtime that does not start, and the starting copy answers: verified (red-first run; G28 passes).
- Unit tests cover the runtime lookup, the environment,
pnpDependsOnandcliBinResolves: verified. - The real Yarn 4.18 transcripts, timings and coding-agent runs: the author's measurements, not reproduced; G59 shows the same behavior with a stand-in runtime.
- The test totals (24 files, 572 passed, 3 skipped): not reproduced in full; the 9 most relevant files pass here.
- Latest comment: the restarted run gets
--disable-warning=ExperimentalWarningas its own Node argument, so the project's CLI prints the loader warning once as under Yarn, and G59 has the loader and checks all of standard error, failing without the argument: verified (handoff.mjs:212and:531; G59 fails with that line removed and passes with it). - Earlier comment: a CLI still running after the grace gets the interrupt twice: holds for a CLI that stops on the first forwarded signal; one that keeps running gets it three times (non-blocking note).
- Changeset: the computer's
astryxhands each run to the project's own CLI by starting again with the runtime, and printed commands start withyarn astryx: verified (G59 and the fixture's output at the head). - Title: a copy started outside the project's runtime hands the run to the project's own CLI: verified.
Files:
.changeset/global-pnp-runtime.md: cleardocs/contributing/cli-conventions.md: cleardocs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)packages/cli/foundation/env/package-manager.mjs: clearpackages/cli/foundation/env/package-manager.test.mjs: clearpackages/cli/foundation/fs/paths.mjs: clearpackages/cli/foundation/fs/paths.test.mjs: clearpackages/cli/foundation/release/handoff.mjs: clear; the earlier loader-warning finding is fixed; non-blocking note (interrupt count)packages/cli/foundation/release/pnp-runtime.mjs: clearpackages/cli/foundation/release/pnp-runtime.test.mjs: clearpackages/cli/foundation/release/project.mjs: clearpackages/cli/test-utils/pnp-fixtures.mjs: clearpackages/cli/test/global-local.rows-16-39.test.mjs: clearpackages/cli/test/global-local.rows-40-59.test.mjs: clear (G59 now has the loader and checks all of standard error)packages/cli/test/global-local.test.mjs: clearscripts/vitest-node-durations.json: clearscripts/vitest-node-durations.min-node.json: clear
|
/approve-spec 5baec2f |
There was a problem hiding this comment.
Approved pending CI: CI has not run its tests on this head yet, because its jobs found CI full; re-run all jobs. The Plug'n'Play restart, the yarn astryx printed commands, the AST-081 change and the tests hold at this head: G59, G58 and G28 pass, and G59, G58 and the cliBinResolves Plug'n'Play test fail without the change.
Non-blocking: in a Plug'n'Play project, a terminal Ctrl-C can reach a project CLI that is still running after 5 seconds three times instead of twice (see the earlier inline note).
Claims and files checked
Review mode: incremental; reason: none
Claims:
- Before the change, the computer's copy in a Plug'n'Play project answered with its own release and asked for a
yarn addof the CLI: verified (G59 fails at the base with the computer's release answering, and the same fixture prints that hint there). Thatcomponentwarned about the theme anddoctorfailed on Core: the author's measurement, not reproduced. - Printed commands there used a
yarn dlxdownload and now useyarn astryx: verified for the picker (cliBinResolvesfalls back topnpDependsOn; G59 assertsyarn astryx; the base printsyarn dlx @astryxdesign/[email protected]). The lineinitwrites: the author's measurement, not run here. - The computer's copy now hands the run to the project's own CLI, as in other layouts: verified (G59).
- The restart preloads the runtime through
NODE_OPTIONSas Yarn does, quoting a path with white space: verified for the flags and quoting (pnp-runtime.mjs:127-139, unit tests); it appends after existing options where Yarn prepends. - The restarted run reads the project's packages through the runtime, and the project's CLI inherits it: verified (
findPnpPackage; the hand-off passes the run's environment; G59). - The restarted run loads nothing of the project's before the hand-off: verified (the restart runs before the release choice, which reads only package metadata).
- The runtime lookup stays within the project search's limits and needs a package.json under it that declares Astryx, with no CLI or Core visible without it: verified (
pnp-runtime.mjs:46-63and:103-116, unit tests). - The loop guard reads the runtime as Yarn writes it and quoted: verified (
pnp-runtime.mjs:83-88, unit tests). - A run that already preloads the runtime, and a programmatic host's run, never start again: verified (
handoff.mjs:200,pnp-runtime.mjs:104-106, G28). - The restarting copy passes an interrupt straight on, so an interrupt sent to it alone reaches the project's CLI after one 5-second grace, and G58 covers Plug'n'Play: verified (G58 passes; it fails at the base).
pnpDependsOnsits besidefindPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-747).cliBinResolvesis true under Plug'n'Play when the folder's workspace depends on the CLI: verified (unit test fails at the base, passes at the head).- AST-081 gains the FR9 sentence, row G59, G28 narrowed to the case its test covers, and the narrower platform note, and the rows file's new name is used everywhere: verified (no old name remains).
- npm and pnpm projects, Core-only projects and folders outside a project are unchanged, and rows G1 to G58 and the hand-off end-to-end tests pass: verified (all three rows files and the hand-off end-to-end tests pass at the head).
- Outside Plug'n'Play the only added work is one file check per folder: accurate in substance (one runtime check per folder, plus the repository-marker checks that end the walk at the repository root).
- G59 fails before the change and checks the printed command; G28 covers a runtime that does not start, and the starting copy answers: verified (red-first run; G28 passes).
- Unit tests cover the runtime lookup, the environment,
pnpDependsOnandcliBinResolves: verified. - The real Yarn 4.18 transcripts, timings and coding-agent runs: the author's measurements, not reproduced; G59 shows the same behavior with a stand-in runtime.
- The test totals (24 files, 572 passed, 3 skipped): not reproduced in full; the 9 most relevant files pass here.
- Latest code comment: the restarted run gets
--disable-warning=ExperimentalWarningas its own Node argument, so the project's CLI prints the loader warning once as under Yarn, and G59 checks all of standard error, failing without the argument: verified (handoff.mjs:212and:531; G59 fails with that line removed and passes with it). - Earlier comment: a CLI still running after the grace gets the interrupt twice: holds for a CLI that stops on the first forwarded signal; one that keeps running gets it three times (non-blocking note).
- Changeset: the computer's
astryxhands each run to the project's own CLI by starting again with the runtime, and printed commands start withyarn astryx: verified (G59 and the fixture's output at the head). - Title: a copy started outside the project's runtime hands the run to the project's own CLI: verified.
Files:
.changeset/global-pnp-runtime.md: cleardocs/contributing/cli-conventions.md: cleardocs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)packages/cli/foundation/env/package-manager.mjs: clearpackages/cli/foundation/env/package-manager.test.mjs: clearpackages/cli/foundation/fs/paths.mjs: clearpackages/cli/foundation/fs/paths.test.mjs: clearpackages/cli/foundation/release/handoff.mjs: clear; non-blocking note (interrupt count)packages/cli/foundation/release/pnp-runtime.mjs: clearpackages/cli/foundation/release/pnp-runtime.test.mjs: clearpackages/cli/foundation/release/project.mjs: clearpackages/cli/test-utils/pnp-fixtures.mjs: clearpackages/cli/test/global-local.rows-16-39.test.mjs: clearpackages/cli/test/global-local.rows-40-59.test.mjs: clearpackages/cli/test/global-local.test.mjs: clearscripts/vitest-node-durations.json: clearscripts/vitest-node-durations.min-node.json: clear
User impact
People and agents who use Astryx in a Yarn Plug'n'Play project (the install layout Yarn 4 uses unless a project opts out) with the
astryxcommand installed for the computer get the wrong release. The global copy cannot see the project's packages, so it answers with its own release, tells them toyarn adda CLI the project already has, reads no Core, andastryx doctorfails with "@astryxdesign/core could not be resolved". Commands the CLI prints in such a project, including theCLI:line of the agent docs thatinitwrites, useyarn dlx @astryxdesign/cli@<version>, which downloads and links the CLI again for every command.After this change the global copy hands the run to the project's own CLI there, as it does in npm, pnpm, and Bun projects, and printed commands start with
yarn astryx.Problem and solution fit
node_modules. Only the runtime Yarn writes at the project root (.pnp.cjs, with.pnp.loader.mjsfor ES modules) can resolve its packages, and Yarn preloads it into every command it runs. A copy started directly, such as the globalastryx, runs without it, so its lookups find no CLI and no Core, and the release choice treats the folder as a project with no CLI of its own.doctorsteer people to change a project that is fine.The fix starts such a copy again with the project's runtime preloaded through
NODE_OPTIONS, as Yarn starts a command. The run started again reads the project's packages through the runtime's API, which the CLI already does in a Plug'n'Play process, and the existing hand-off runs the project's own CLI, which inherits the runtime. The printed-command picker treats a CLI that the folder's workspace depends on as oneyarn astryxruns.Expected behavior and authority
spec:AST-081FR2 and FR9: in a project that installs@astryxdesign/cli, that CLI answers, and every copy hands the run to it.spec:AST-081FR5: printed commands use the project's run prefix when the project's own CLI answers.spec:AST-081platform support lists Yarn Plug'n'Play in the supported floor. Its "unsupported behavior" note said that a copy could not see the project's CLI without running the project's loader, and that the release equal to the project's Core would answer instead; the code answered with the starting copy. The note now names only the remaining limit: a programmatic host's run does not start again.Preloading the runtime keeps FR2's order. FR2 forbids loading the project's
astryx.config, its integrations, or its Core before the hand-off. The runtime is none of these: it is the module resolver Yarn runs every command with, and the run started again loads nothing of the project's before it hands off.Smallest restoration
foundation/release/pnp-runtime.mjs(new): which runtime a run needs (a.pnp.cjsin the folder or a folder above it, within the project search's limits, a package.json under it that declares Astryx, and no Astryx CLI or Core visible without it), and the environment that preloads it, built as Yarn builds it. The loop guard reads the runtime in the Node options both as Yarn writes it and quoted, as the restart writes a path with white space.foundation/release/handoff.mjs: before the choice, a copy that needs the runtime starts again with it, through the existing hand-off spawn. A run whose Node options already preload that runtime never starts again, so a runtime that does not start cannot loop. A programmatic host's run does not start again. The copy that starts again passes an interrupt straight on, so an interrupt sent to it alone still reaches the project's CLI after one 5-second grace (G58 covers a Plug'n'Play project).foundation/fs/paths.mjs:pnpDependsOn, besidefindPnpPackage; both now share onepnpApilookup.foundation/env/package-manager.mjs:cliBinResolvesis true under Plug'n'Play when the folder's workspace depends on the CLI.spec:AST-081: an FR9 sentence on starting again with the runtime, the G59 row, G28 narrowed to a runtime that does not start (the case its test covers), and the platform note. The rows file is renamedglobal-local.rows-40-59to hold G59, with its name updated in the record,docs/contributing/cli-conventions.md, and the test-duration records.Evidence
astryx --versionprinted the global release andastryx: this project has no Astryx CLI installed; answered by CLI <global> while its Core is 0.7.10. To match, run: yarn add @astryxdesign/[email protected].astryx component Buttonwarnedcould not resolve the generated default theme, andastryx doctorreported@astryxdesign/core could not be resolved from this projectand exited 1.initwroteCLI: run every command as `yarn dlx @astryxdesign/cli@<version> <cmd>`. Each such call took 2.8 s warm and printed about 12 lines of Yarn progress;yarn astryxtakes 1.1 s.astryx --versionprints0.7.10andastryx: answered by this project's CLI 0.7.10, handed over from CLI <global>in 0.64 s (yarn astryx --versiontakes 0.59 s);doctorresolves Core 0.7.10;initwritesCLI: run every command as `yarn astryx <cmd>`.yarn dlxdownloads, and the 8 runs took 1,366 s in total. After: none were, 74 ran asyarn astryx, and the 8 runs took 909 s. Every build passed in both.test/global-local.rows-16-39.test.mjs) covers a runtime that does not start: the run starts again once, and the starting copy answers. G58 covers interrupts in a Plug'n'Play project. Unit tests cover the runtime lookup, the environment,pnpDependsOn, andcliBinResolves.Scope
Components: CLI (global-mode hand-off, printed-command picker)
Writing rubric results
Testing
vitest run --project nodeoverfoundation/release(includingpnp-runtime.test.mjsandhandoff.e2e.test.mjs),foundation/env,foundation/fs/paths.test.mjs,foundation/doc-compiler/doc-loads.test.mjs,test/global-local.test.mjs,test/global-local.rows-16-39.test.mjs,test/global-local.rows-40-59.test.mjs,test/global-mode-notes.test.mjs, andtest/global-mode-docs.test.mjs: 24 files, 572 passed, 3 skipped.tsc --project tsconfig.strict.jsonaftersync-api-types,scripts/check-cli-structure.mjs,scripts/check-knowledge.mjs, ESLint on the changed files, Prettier on the changed Markdown, and the copyright check.