Repository navigation
feat(design): detect a workspace's web app and its package manager (design mode v2, Phase 2a) - #911
sambitcreate wants to merge 14 commits into
Conversation
Co-Authored-By: Claude <noreply@anthropic.com>
deviceNodeEnvironment, androidSdkEnv and createNpmRunner now build PATH through prependPathEntries, which drops every empty entry, including ones inherited from the parent PATH. An empty entry means the working folder. Co-Authored-By: Claude <noreply@anthropic.com>
… lookup resolveExecutable, the login-shell lookup, the standalone-Node check and the PATH helpers move to main/services/node-toolchain.ts, generalised to node, npm, pnpm, yarn and bun, with an optional cache of validated login-shell answers for design mode. device-toolchain.ts keeps every export as a thin wrapper with the device's own settings (Node 22, npm lookup with Node's default buffer, Node lookup at 16 KiB, no cache). Two guards pin the device lookups' argv and buffer; they passed on the old code. Deviation: the plan said a one-argument lookup still fits the new type, which holds for implementations, but callers now pass the command. The guards therefore call the device lookups with the matching command; the device wrappers ignore it. No production caller calls the lookup. Co-Authored-By: Claude <noreply@anthropic.com>
app-server-core.ts holds R2-R4 of the 2a plan: the framework table, the dev-script choice (the framework's dev command first, then the first script that isn't a build, a production run, Storybook or a workspace runner) and the kind and reason of a package. Remix 3 keeps its row. Checked against remix@3.3.0 (npm latest) and the starter in @remix-run/cli: its dev script is "NODE_ENV=development node --watch --import remix/node-tsx server.ts" and server.ts listens on PORT or 44100, so the dev command is "node --watch" and the default port 44100. TanStack Start's own starter (@tanstack/create) runs "vite dev --port 3000", so 3000 stays. Co-Authored-By: Claude <noreply@anthropic.com>
R5 (decidePackageManager and its helpers), R10 (installCommand, runScriptCommand) and R1's workspace pattern helpers, all disk-free. Argument passing checked by running each manager against a script that prints its argv: npm 10.9.9 needs "--"; pnpm 12.15.0 and Yarn 4.19.0 pass a bare "--" through to the script; Yarn 1.22.22 and bun 1.3.11 forward arguments with or without it. So only npm gets "--", as the plan says. Deviation: decidePackageManager takes levelsUp and derives "enclosing" from levelsUp > 0 instead of taking both, so the two can't disagree. Co-Authored-By: Claude <noreply@anthropic.com>
app-detect.ts reads the disk with bounded, no-follow reads (readBounded:
O_NOFOLLOW | O_NONBLOCK, regular files only, cap + 1 bytes) and feeds the
pure rules: candidates at the root, in apps/, packages/, web/, frontend/,
site/ and the declared workspace patterns; install roots for members and
own-lockfile folders; the enclosing walk bounded by .git, stopAt, home
and five levels; install state. designTarget sums a detection up for 2b.
Deviations:
- The plan's edge-shape test asks that "scripts as an array" never give
no-dev-script, but R4 rule 7 (and Task 3's "a vite app with no scripts
at all is none no-dev-script") make a vite app with array scripts
exactly that. The edge test therefore uses a React package without a
framework for the array case and a vite app whose dev is null but whose
start runs vite for the null case, which keeps R4 as written.
- readBounded takes an optional { head: true } so the 512-byte yarn.lock
head can be read from a longer file through the same no-follow open.
Co-Authored-By: Claude <noreply@anthropic.com>
app-toolchain.ts implements R9: Node 22 or newer first, then the app's
own manager (npm beside the resolved Node first), with typed problems
node-missing, manager-missing, manager-conflict and unsupported-manager,
and one fixed message for each. The design resolvers share one cache of
validated login-shell answers; misses are never kept.
Deviation: the plan's field-and-lockfile conflict message names the
field's manager ("packageManager says pnpm, but the lockfile is npm's."),
but R8 recorded no field. PackageManagerInfo and the manager-conflict
problem gain an optional `field`, set only when the packageManager field
is part of the conflict.
Co-Authored-By: Claude <noreply@anthropic.com>
Spec: Phase 2a amendments S19-S24 and the status line; §4's toolchain sentence now names node-toolchain.ts. Plan index row, the design-mode and devices memory, and this plan (boxes ticked; the Remix 3 row, the per-manager "--" facts, the `field` on conflicts and readBounded's `head` option recorded). docs/devices.md still holds: Node 22, PATH, login shell, Homebrew. Co-Authored-By: Claude <noreply@anthropic.com>
…d early host commands Code review fixes for 2a: - The generated agent-device launcher runs from the person's repo and built PATH as dirname(node) + ":" + PATH, leaving an empty entry when PATH was unset or empty, or held "::". It now filters empty entries. Settles plan Q7. - run's branch for commands started before Node is resolved (xcrun simctl help) drops inherited empty entries; an unset PATH stays unset, so the shell's default search still applies. - The login-shell lookup takes an injectable execFile, so the test proves the 5 s default timeout and that maxBuffer reaches execFile only when given, without waiting. - The version-floor test now proves the Node probe clears ELECTRON_RUN_AS_NODE. Deviation: there is no agent-device-shim.test.ts; the shim's tests live in device-tools.test.ts, so the launcher cases went there. The ssh-device-script.ts remote ":$PATH" is noted in the plan's Risks as a follow-up. Co-Authored-By: Claude <noreply@anthropic.com>
- The enclosing walk counts a parent repo's lockfile only when that folder's workspaces or pnpm-workspace.yaml lists the workspace (bounded reads, matchesWorkspacePattern). An example app under a library, an unlisted folder in a pnpm repo, and a stray parent lockfile now get npm with a plain install. - Root scripts that hand off to one member are runners: yarn workspace, pnpm -C, concurrently, npm-run-all, run-p, and -w, --workspace, --prefix, --dir. A root that declares workspaces is web only when its script runs the framework's own dev command. - A framework app whose only scripts are production runs is no-dev-script, not React mocks. - clearAppToolchainCache() for 2c's Retry. - Conflict messages say how to fix, with plural wording for 3+ managers. - S20 and Risks accept a gitignored leftover lockfile as a refusal. Deviation: -w, --workspace, --prefix and --dir count as hand-offs only when the script also names npm, pnpm, yarn or bun. Bare -w would make a React library with "dev": "tsc -w" (or rollup -c -w) workspace-runner instead of React mocks; a test pins that. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Important
Two detection contracts need correction before Phase 2b consumes these results: Deno-only workspaces disappear entirely, and malformed package-manager declarations can select the wrong installer.
Reviewed changes I reviewed the complete Phase 2a diff, including app and monorepo detection, package-manager decisions, shared toolchain extraction, device PATH hardening, tests, and project records.
- App discovery and classification — Adds bounded workspace scanning, framework/script classification, monorepo membership handling, and design-target selection.
- Package managers and toolchains — Adds lockfile/conflict rules, install/run argv builders, Node 22 and manager resolution, and a validated login-shell cache.
- Device PATH hardening — Preserves the device toolchain wrappers while removing empty PATH entries from helper, launcher, Android SDK, and early host-command environments.
- Tests and project records — Adds behavioral coverage for the new modules and updates the Phase 2a plan, specification amendments, memory, test registry, and plan index.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
…geManager values - A folder with a Deno marker but no package.json is now a candidate, with reason no-package-json and Deno reported as its unsupported manager, instead of disappearing from detection. - parsePackageManagerField matches the whole value: a bare manager or manager@version with an optional prerelease and +hash. Values such as pnpm@junk, pnpm@ and yarn! are ignored, so they can no longer pick an install command. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Important
The parser hardening still accepts malformed prerelease declarations, so a typo can select the wrong installer.
Reviewed changes I reviewed the app-detection corrections added since the prior Pullfrog review.
-
Admitted Deno-only folders — Added Deno markers to candidate discovery and returns an explicit unsupported-manager result when
package.jsonis absent. -
Hardened package-manager declarations — Anchored
packageManagerparsing and added recognized-prefix malformed cases while preserving the repository's hashed declaration form.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
Important
The stricter package-manager parser drops valid Corepack hash-pinned declarations, including this repository's own value.
Reviewed changes I reviewed the exact-SemVer hardening added since the prior Pullfrog review.
- Tightened version parsing — Replaced permissive prerelease and build matching with explicit exact-version identifiers and expanded malformed-value tests.
- Preserved malformed fallback behavior — Added a package-manager decision assertion proving malformed declarations use the no-signal npm fallback.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using GPT Sol | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes I reviewed the Corepack hash-pin compatibility fix added since the prior Pullfrog review.
- Accepted SRI-style Corepack pins — Extended
packageManagerparsing to preserve exact SemVer validation while accepting Corepack hash payloads containing/,+, and terminal=padding. - Added real-pin regression coverage — Covered both representative npm, pnpm, and Yarn hash forms and the repository's checked-in
packageManagerdeclaration while retaining malformed-padding rejection.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using GPT Sol | 𝕏

Stacked on #908 (Phase 1b), which is stacked on #894 (Phase 1a). Merge in order. GitHub retargets each PR when its base merges.
Phase 2a of design mode v2 (spec
docs/superpowers/specs/2026-11-23-design-mode-live-app-design.md§8; plandocs/superpowers/plans/2026-11-24-design-mode-v2-p2a-app-detection.md; amendments S19–S24). It adds pure detection only: no IPC, no tool, no UI and no process. Nothing in the running app calls the new design modules until 2b, so there is no flag yet;AIDEN_EXPERIMENTAL_DESIGN_LIVEstarts in 2b.What changes
Devices: empty PATH entries (fix)
An empty PATH entry means "the current folder" to a shell. These spots could add one:
deviceNodeEnvironment,androidSdkEnv,createNpmRunner);A file named like a tool (
adb, say) in the working folder could then run instead of the tool. Empty entries are now dropped everywhere these paths are built.Shared Node toolchain (refactor)
main/services/node-toolchain.tsis lifted out ofdevice-toolchain.ts. It findsnode,npm,pnpm,yarnandbun:The cache keeps only paths that passed the executable check. The device wrappers keep every export and setting, including Node 22. The existing device tests pass unedited. A reviewer also diffed the old and new modules side by side over PATH, lookup and version-probe cases, with identical results apart from the PATH fix.
Web-app detection (
app-server-core.ts,app-detect.ts,app-toolchain.ts)Frameworks:
desktopapps, so a plain browser frame can't run them. Expo and React Native arereact-native.Choosing the dev script:
next start,serve -s), builds, workspace runners, and roots that hand off to a member (-w,yarn workspace,concurrently).Package managers:
packageManagerfield wins only when no lockfile disagrees. When one does, the result is a conflict, and 2b will refuse with a message saying how to fix it rather than write the wrong lockfile. Whennode_modulesholds exactly one manager's install marker, that manager breaks the tie.pnpm-workspace.yamlalone means pnpm.--before extra script arguments; this was checked against npm 10, pnpm 12, Yarn 1 and 4, and bun 1.3.Monorepos:
.gitor home. It uses the outer lockfile only when the workspace is a declared member, sonpm ciorpnpm installnever runs against a lockfile that doesn't cover it.Reads are bounded:
..or absolute paths are ignored.A FIFO named
package.jsonreturns at once.Missing tools:
app-toolchain.tsturns a missing Node (Node 22 or newer is required) or a missing package manager into a typed reason with a one-line message.clearAppToolchainCache()is ready for 2c's Retry.Review
detectWebAppagainst 45 real-shape fixture folders. Ten fixes followed, each starting from a failing test.Tests
npm run test:devices: 660/660. Existing device tests are unedited; 19 cases were added.npm run test:design-mode: 920/920, including the new detection suites.npx tsc --noEmit -p .,npm run lint,npm run test:ci-policyandnpm run cli:buildpass.environment-devices-{tab,agent,android,features,stream}.spec.ts, 6 passed and 1 skipped (the off-macOS case).Notes
ssh-device-script.ts:26exports…:$PATHon the remote, which adds an empty entry only when the remote PATH is empty.npx tsc -p main/tsconfig.jsonreports the same errors on the base commit (rootDir and import extensions). None are in files this PR touches.🤖 Generated with Claude Code