Skip to content

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

Merged
josephfarina merged 6 commits into
mainfrom
josephfarina/global-pnp-runtime
Nov 16, 2026
Merged

josephfarina merged 6 commits into
mainfrom
josephfarina/global-pnp-runtime

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

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 astryx command 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 to yarn add a CLI the project already has, reads no Core, and astryx doctor fails with "@astryxdesign/core could not be resolved". Commands the CLI prints in such a project, including the CLI: line of the agent docs that init writes, use yarn 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

  1. Why does it fail? A Plug'n'Play project keeps no node_modules. Only the runtime Yarn writes at the project root (.pnp.cjs, with .pnp.loader.mjs for ES modules) can resolve its packages, and Yarn preloads it into every command it runs. A copy started directly, such as the global astryx, 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.
  2. Why does it harm the task? The answer comes from another release than the project's (docs, templates, agent text), and the printed advice and doctor steer people to change a project that is fine.
  3. Why does that matter? Plug'n'Play is Yarn 4's default, and the global mode record lists it among the supported install layouts.

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 one yarn astryx runs.

Expected behavior and authority

  • spec:AST-081 FR2 and FR9: in a project that installs @astryxdesign/cli, that CLI answers, and every copy hands the run to it.
  • spec:AST-081 FR5: printed commands use the project's run prefix when the project's own CLI answers.
  • spec:AST-081 platform 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.cjs in 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, beside findPnpPackage; both now share one pnpApi lookup.
  • foundation/env/package-manager.mjs: cliBinResolves is 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 renamed global-local.rows-40-59 to hold G59, with its name updated in the record, docs/contributing/cli-conventions.md, and the test-duration records.

Evidence

  • Reproduction before the change, in a Yarn 4.18 Plug'n'Play app on Astryx 0.7.10 with the CLI from current main installed for the computer:
    • astryx --version printed the global release and astryx: 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 Button warned could not resolve the generated default theme, and astryx doctor reported @astryxdesign/core could not be resolved from this project and exited 1.
    • init wrote CLI: 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 astryx takes 1.1 s.
  • Result after the change: astryx --version prints 0.7.10 and astryx: answered by this project's CLI 0.7.10, handed over from CLI <global> in 0.64 s (yarn astryx --version takes 0.59 s); doctor resolves Core 0.7.10; init writes CLI: run every command as `yarn astryx <cmd>` .
  • Agents: four coding agents (Claude Code, Codex, Gemini CLI, Copilot CLI) each added the same page to that app twice, once with the agent docs the current CLI writes and once with the docs this change writes. Before: 72 of their Astryx commands were yarn dlx downloads, and the 8 runs took 1,366 s in total. After: none were, 74 ran as yarn astryx, and the 8 runs took 909 s. Every build passed in both.
  • Representative unchanged path: npm and pnpm projects, projects with only Core, and folders outside a project. Rows G1 to G58 of the global and project table and the hand-off end-to-end tests pass unchanged. Outside a Plug'n'Play project the only added work is one file check per folder above the working folder.
  • Regression test: G59 starts the global copy in a stand-in Plug'n'Play project and fails before this change, because the global copy answers itself; it also checks the printed command. G28 (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, and cliBinResolves.

Scope

Components: CLI (global-mode hand-off, printed-command picker)

  • 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 FR9 sentence, the G59 row, and the platform note describe present behavior.
  • R2 research: none in the record.
  • R3 evidence: the G59 row names its test.
  • 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 foundation/release (including pnp-runtime.test.mjs and handoff.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, and test/global-mode-docs.test.mjs: 24 files, 572 passed, 3 skipped.
  • tsc --project tsconfig.strict.json after sync-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.
  • Real Yarn 4.18 Plug'n'Play apps: one on Astryx 0.7.10, and one on the current canary with this change laid over the published files.

…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.
@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:13am 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:19 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 efc0794

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

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:73 compares the raw runtime path with the JSON-quoted path that withPnpRuntime writes 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 astryx hands each Plug'n'Play run to the project's CLI, and printed commands start with yarn 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: doctor could 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: cliBinResolves looked only for node_modules/.bin, and the dlx prefix for Yarn 2+ is yarn 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.
  • pnpDependsOn and findPnpPackage share one runtime lookup. Verified: paths.mjs:693-745.
  • cliBinResolves is 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.mjs failures 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: clear
  • docs/contributing/cli-conventions.md: clear
  • docs/specs/AST-081-global-mode/spec.md: note (unchanged G28 now overlaps G59)
  • packages/cli/foundation/env/package-manager.mjs: clear
  • packages/cli/foundation/env/package-manager.test.mjs: clear
  • packages/cli/foundation/fs/paths.mjs: clear
  • packages/cli/foundation/fs/paths.test.mjs: clear
  • packages/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: clear
  • packages/cli/test/global-local.rows-40-59.test.mjs: clear
  • packages/cli/test/global-local.test.mjs: clear
  • scripts/vitest-node-durations.json: clear
  • scripts/vitest-node-durations.min-node.json: clear

Automated review (maintainer link)

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 5baec2f

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 4.97 MB packed (+3.4 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

…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.
@josephfarina josephfarina changed the title fix(cli): in a Yarn Plug'n'Play project, every copy reaches the project's own CLI 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 Nov 16, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

Thanks for the review. Fixed in c1854ff:

  1. Interrupt grace. The copy that starts the run again with the runtime now passes an interrupt straight on. The run started again passes it on to the project's CLI after the one grace. A hand-off also passes on at most one interrupt per grace, because a terminal's Ctrl-C reaches a restarted run twice: once from the terminal and once from the copy that restarted it. G58 now has a Plug'n'Play case. With the starting copy alone, the CLI gets the interrupt once, after 5 to 9 seconds. With the whole group, it gets it once, in under 5 seconds. Without the fix, the alone case takes 10.2 s and the test fails.
  2. Loop guard. preloads() reads the runtime in the Node options both as Yarn writes it and quoted, as withPnpRuntime writes a path with white space. New unit tests cover a POSIX path with a space and a quoted Windows path, whose backslashes quoting doubles.
  3. Title. It now names a copy started outside the project's runtime.

Non-blocking:

  • The runtime search now keeps the project search's limits. It ends at a repository's root, and it reads the home folder only when it starts there. A unit test covers both.
  • A runtime that throws at preload: Yarn preloads the runtime the same way, so yarn astryx with that runtime fails the same way, with the runtime's own error. I left this as is, so the two ways of starting the CLI match.

Local: 24 files, 575 passed (all of G1–G59, the hand-off end-to-end tests, foundation/release, env, paths, doc-loads), plus tsc strict, check-cli-structure, ESLint, and Prettier.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec c1854ff

@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 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"; delete interruptWaiting and keep interruptAtOnce, 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 dlx download and now use yarn astryx: verified (cliBinResolves fallback, 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_OPTIONS as 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).
  • pnpDependsOn sits beside findPnpPackage and both share one runtime-API lookup: verified (paths.mjs:693-746).
  • cliBinResolves is 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 astryx hands each run to the project's own CLI by starting again with the runtime, and printed commands start with yarn 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: clear
  • docs/contributing/cli-conventions.md: clear
  • docs/specs/AST-081-global-mode/spec.md: clear (owner-approved); G28 note
  • packages/cli/foundation/env/package-manager.mjs: clear
  • packages/cli/foundation/env/package-manager.test.mjs: clear
  • packages/cli/foundation/fs/paths.mjs: clear
  • packages/cli/foundation/fs/paths.test.mjs: clear
  • packages/cli/foundation/release/handoff.mjs: blocking finding (interrupt guard)
  • packages/cli/foundation/release/pnp-runtime.mjs: clear
  • packages/cli/foundation/release/pnp-runtime.test.mjs: clear
  • packages/cli/foundation/release/project.mjs: clear
  • packages/cli/test-utils/pnp-fixtures.mjs: clear
  • packages/cli/test/global-local.rows-40-59.test.mjs: clear
  • packages/cli/test/global-local.test.mjs: clear
  • scripts/vitest-node-durations.json: clear
  • scripts/vitest-node-durations.min-node.json: clear

Automated review (maintainer link)

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

Copy link
Copy Markdown
Contributor Author

Fixed in the new head:

  • Interrupts. The one-interrupt-per-grace guard is gone, so a second interrupt sent to the starting copy within the grace is passed on again, as FR9 says. The restart's parent still passes an interrupt straight on. G58, including its Plug'n'Play cases, and G59 pass.
  • G28. It now names the case its test covers: a Plug'n'Play project whose runtime does not start. The copy that started the run answers after the run starts again once, and the hint gives Yarn's command. G59 keeps only the hand-off through a runtime that starts. The starts: false fixture option that G59 used for that branch is removed.

@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 44639f6

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

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 doctor failed on Core: the author's measurement.
  • Printed commands there used a yarn dlx download and now use yarn astryx: verified (cliBinResolves falls back to pnpDependsOn; 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_OPTIONS as 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-63 and :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).
  • pnpDependsOn sits beside findPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-746).
  • cliBinResolves is 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, pnpDependsOn and cliBinResolves: 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 astryx hands each run to the project's own CLI by starting again with the runtime, and printed commands start with yarn 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: clear
  • docs/contributing/cli-conventions.md: clear
  • docs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)
  • packages/cli/foundation/env/package-manager.mjs: clear
  • packages/cli/foundation/env/package-manager.test.mjs: clear
  • packages/cli/foundation/fs/paths.mjs: clear
  • packages/cli/foundation/fs/paths.test.mjs: clear
  • packages/cli/foundation/release/handoff.mjs: clear; non-blocking note (interrupt count)
  • packages/cli/foundation/release/pnp-runtime.mjs: clear
  • packages/cli/foundation/release/pnp-runtime.test.mjs: clear
  • packages/cli/foundation/release/project.mjs: clear
  • packages/cli/test-utils/pnp-fixtures.mjs: clear
  • packages/cli/test/global-local.rows-16-39.test.mjs: clear
  • packages/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: clear
  • scripts/vitest-node-durations.json: clear
  • scripts/vitest-node-durations.min-node.json: clear

Automated review (maintainer link)

Comment on lines +541 to +544
if (interruptAtOnce) {
forward('SIGINT');
return;
}

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

@josephfarina

Copy link
Copy Markdown
Contributor Author

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 node_modules project. A test that cannot fail without the change proves nothing, so I left the merge and that test out. The head is unchanged at 44639f6.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec dab6c16

@astracat-bot

astracat-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

In reply to @josephfarina

I'll run a full review to re-check this with your note.

@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 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 a type: module workspace), the restarted run gets --experimental-loader and prints Node's three-line ExperimentalWarning before it hands off, and the project's CLI prints it again, so the computer's astryx prints that warning twice where yarn astryx prints 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=ExperimentalWarning as a Node argument, not in NODE_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 add of the CLI: verified (G59 fails at the base with the computer's release answering; the same fixture prints that hint at the base). That doctor failed on Core: the author's measurement.
  • Printed commands there used a yarn dlx download and now use yarn astryx: verified (cliBinResolves falls back to pnpDependsOn; G59's printed-command assertion; the same fixture prints yarn 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_OPTIONS as 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-63 and :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).
  • pnpDependsOn sits beside findPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-747).
  • cliBinResolves is 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, pnpDependsOn and cliBinResolves: 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 astryx hands each run to the project's own CLI by starting again with the runtime, and printed commands start with yarn 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: clear
  • docs/contributing/cli-conventions.md: clear
  • docs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)
  • packages/cli/foundation/env/package-manager.mjs: clear
  • packages/cli/foundation/env/package-manager.test.mjs: clear
  • packages/cli/foundation/fs/paths.mjs: clear
  • packages/cli/foundation/fs/paths.test.mjs: clear
  • packages/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: clear
  • packages/cli/foundation/release/project.mjs: clear
  • packages/cli/test-utils/pnp-fixtures.mjs: clear
  • packages/cli/test/global-local.rows-16-39.test.mjs: clear
  • packages/cli/test/global-local.rows-40-59.test.mjs: G59's fixture has no .pnp.loader.mjs, so it misses the blocking finding
  • packages/cli/test/global-local.test.mjs: clear
  • scripts/vitest-node-durations.json: clear
  • scripts/vitest-node-durations.min-node.json: clear

Automated review (maintainer link)

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

Copy link
Copy Markdown
Contributor Author

Fixed in the new head. The run started again with the runtime now gets --disable-warning=ExperimentalWarning as a Node argument of its own (handOff's nodeArgs), not through NODE_OPTIONS, so the project's CLI still prints Node's loader warning once, as under Yarn. G59's fixture now has a .pnp.loader.mjs and checks all of standard error: the hand-off line and one warning. Without the argument there are two warnings, and G59 fails.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec e296865

@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: 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 add of the CLI: verified (G59 fails at the base with the computer's release answering, and the same fixture prints that hint there). That component warned about the theme and doctor failed on Core: the author's measurement, not reproduced.
  • Printed commands there used a yarn dlx download and now use yarn astryx: verified for the picker (cliBinResolves falls back to pnpDependsOn; G59 asserts yarn astryx; the base prints yarn dlx @astryxdesign/[email protected]). The line init writes: 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_OPTIONS as 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-63 and :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).
  • pnpDependsOn sits beside findPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-747).
  • cliBinResolves is 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, pnpDependsOn and cliBinResolves: 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=ExperimentalWarning as 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:212 and :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 astryx hands each run to the project's own CLI by starting again with the runtime, and printed commands start with yarn 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: clear
  • docs/contributing/cli-conventions.md: clear
  • docs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)
  • packages/cli/foundation/env/package-manager.mjs: clear
  • packages/cli/foundation/env/package-manager.test.mjs: clear
  • packages/cli/foundation/fs/paths.mjs: clear
  • packages/cli/foundation/fs/paths.test.mjs: clear
  • packages/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: clear
  • packages/cli/foundation/release/pnp-runtime.test.mjs: clear
  • packages/cli/foundation/release/project.mjs: clear
  • packages/cli/test-utils/pnp-fixtures.mjs: clear
  • packages/cli/test/global-local.rows-16-39.test.mjs: clear
  • packages/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: clear
  • scripts/vitest-node-durations.json: clear
  • scripts/vitest-node-durations.min-node.json: clear

Automated review (maintainer link)

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 5baec2f

@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: 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 add of the CLI: verified (G59 fails at the base with the computer's release answering, and the same fixture prints that hint there). That component warned about the theme and doctor failed on Core: the author's measurement, not reproduced.
  • Printed commands there used a yarn dlx download and now use yarn astryx: verified for the picker (cliBinResolves falls back to pnpDependsOn; G59 asserts yarn astryx; the base prints yarn dlx @astryxdesign/[email protected]). The line init writes: 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_OPTIONS as 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-63 and :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).
  • pnpDependsOn sits beside findPnpPackage, and both share one runtime-API lookup: verified (paths.mjs:693-747).
  • cliBinResolves is 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, pnpDependsOn and cliBinResolves: 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=ExperimentalWarning as 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:212 and :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 astryx hands each run to the project's own CLI by starting again with the runtime, and printed commands start with yarn 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: clear
  • docs/contributing/cli-conventions.md: clear
  • docs/specs/AST-081-global-mode/spec.md: clear (owner-approved at this head)
  • packages/cli/foundation/env/package-manager.mjs: clear
  • packages/cli/foundation/env/package-manager.test.mjs: clear
  • packages/cli/foundation/fs/paths.mjs: clear
  • packages/cli/foundation/fs/paths.test.mjs: clear
  • packages/cli/foundation/release/handoff.mjs: clear; non-blocking note (interrupt count)
  • packages/cli/foundation/release/pnp-runtime.mjs: clear
  • packages/cli/foundation/release/pnp-runtime.test.mjs: clear
  • packages/cli/foundation/release/project.mjs: clear
  • packages/cli/test-utils/pnp-fixtures.mjs: clear
  • packages/cli/test/global-local.rows-16-39.test.mjs: clear
  • packages/cli/test/global-local.rows-40-59.test.mjs: clear
  • packages/cli/test/global-local.test.mjs: clear
  • scripts/vitest-node-durations.json: clear
  • scripts/vitest-node-durations.min-node.json: clear

Automated review (maintainer link)

@josephfarina
josephfarina merged commit fb7e4af into main Nov 16, 2026
132 of 138 checks passed
@github-actions
github-actions Bot deleted the josephfarina/global-pnp-runtime branch November 17, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 5baec2fd 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