Repository navigation
fix(#847): new-feature.sh resolves frozen install from detected package manager - #859
Merged
admarble merged 5 commits intoJul 30, 2026
Conversation
…ge manager templates/scripts/new-feature.sh hardcoded `npm ci --silent` in frozen_install() and named package-lock.json in its failure message, while the TypeScript provisioning path (#816) already resolved the frozen install from PM_CONFIG[pm].ciInstall. On pnpm/yarn/bun projects the shell path ran npm ci against a non-npm lockfile and aborted pointing the user at a file their project does not use. - Add detect_package_manager() mirroring stacks.ts LOCKFILE_PRIORITY (bun.lockb/bun.lock > yarn.lock > pnpm-lock.yaml > package-lock.json, npm fallback) plus pm_ci_install/pm_lockfile/pm_recovery tables matching PM_CONFIG.ciInstall (AC-1). - frozen_install() runs the resolved command; its failure message names the resolved lockfile and a PM-appropriate recovery command (AC-3). - Hash the resolved lockfile in the SEQUANT_NPM_CACHE branch instead of a hardcoded package-lock.json, and gate install on package.json. - Add integration test driving the real script with stubbed package managers on PATH (command capture) + a PM_CONFIG drift guard (AC-2). Closes #847 Entire-Checkpoint: 0c0766fcc61a
The drift guard matched the whole script, but each ciInstall string also appears in the file's explanatory comment, so mutating the actual pm_ci_install() case table (pnpm -> "npm ci") left the test green — the prose satisfied the substring match. Scope the assertion to the pm_ci_install() function body so a wrong command in the table fails it, per the delimited-region rule in CLAUDE.md § Testing. Mutation-verified: pnpm table entry -> "npm ci" now fails the drift guard (and the three pnpm behavior tests); restored to green. Entire-Checkpoint: fd1915a1cadd
3 tasks
…re-sh-hardcodes-npm-ci-while-the-ts-path- # Conflicts: # CHANGELOG.md
…ions it hid QA on #859 found the SEQUANT_NPM_CACHE branch and the `bun` arm were modified but untested, and that the PM-aware rewrite dropped npm's `--silent`. Writing the missing tests surfaced four further npm-shaped assumptions in the same file, each now fixed and gated: - `cp -r` → `cp -R` on the cache-hit copy. BSD `cp -r` DEREFERENCES symlinks, so a pnpm node_modules was expanded into real copies and any dangling link (optional dep, foreign-platform `.bin` entry) exited non-zero — `set -e` then left a half-provisioned worktree. Only reachable for pnpm/yarn/bun since this PR made the branch work for them at all. - CACHE_DIR is anchored to MAIN_REPO_DIR. Execution is inside the new worktree by that point, so `../worktrees/.npm-cache` resolved to `worktrees/feature/worktrees/.npm-cache`. - `pm_recovery bun` defers to `pm_lockfile` instead of naming `bun.lockb`: a bun.lock project was told to commit a file it does not have, which is the wrong-file misdirection AC-3 exists to eliminate. - The next-steps hint uses the detected PM's run prefix (`pm_run`, mirroring PM_CONFIG.run) instead of a hardcoded `npm run dev`. - `npm ci --silent` is restored via `pm_quiet_flag` at the call site, so the ciInstall drift guard still matches PM_CONFIG verbatim. - HASH_FILE renamed `.package-lock-hash` → `.lockfile-hash`. Tests: 7 → 15. New coverage for the cache branch (hash of the resolved lockfile, cache-hit reuse with symlink preservation, non-npm project not aborting in the hasher), the bun arm, the quiet flag, the next-steps hint, and a second drift guard over pm_run. Mutation verification recorded in the PR body.
…missing Two QA-round-3 gaps: 1. .lockfile-hash was one shared file in ../worktrees/.npm-cache, which every sibling repo under the same parent shares — two projects alternated overwriting it, so both missed the cache every run. Now keyed as .lockfile-hash-$(basename MAIN_REPO_DIR). Thrash-only bug (a hit copies the project's own node_modules), but it defeated the cache entirely for multi-project setups. 2. A manifest-only project (package.json, no lockfile) falls back to npm and 'npm ci' fails because it REQUIRES a lockfile — the error said "The committed package-lock.json is out of sync", describing a file that doesn't exist. frozen_install now branches on the resolved lockfile's existence: missing → 'No <lockfile> found', present → the out-of-sync wording. Recovery command unchanged (it generates the lockfile either way). Mutation results recorded in the PR body.
admarble
deleted the
feature/847-new-feature-sh-hardcodes-npm-ci-while-the-ts-path-
branch
July 30, 2026 03:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
templates/scripts/new-feature.shhardcodednpm ci --silentinfrozen_install()and namedpackage-lock.jsonin its failure message, while the TypeScript provisioning path (#816) already resolved the frozen install fromPM_CONFIG[pm].ciInstall. On a pnpm/yarn/bun project the shell path rannpm ciagainst a non-npm lockfile and aborted with "package-lock.json out of sync" — pointing the user at a file their project doesn't use.detect_package_manager()mirroringsrc/lib/stacks.tsLOCKFILE_PRIORITY(bun.lockb/bun.lock→yarn.lock→pnpm-lock.yaml→package-lock.json, npm fallback), pluspm_ci_install/pm_lockfile/pm_recoverytables matchingPM_CONFIG.ciInstall.frozen_install()runs the resolved command and its failure message names the resolved lockfile + a PM-appropriate recovery command.SEQUANT_NPM_CACHEbranch hashes the resolved lockfile instead of a hardcodedpackage-lock.json, and the install step is gated onpackage.jsonexisting so non-JS projects skip it.Pre-PR AC Verification
new-feature.shdetect_package_manager()+pm_ci_install(); tests: pnpm→pnpm install --frozen-lockfile, yarn→yarn install --immutable, npm→npm cifrozen_install()failure block usespm_lockfile/pm_recovery; test asserts stderr namespnpm-lock.yaml+pnpm install --lockfile-only, neverpackage-lock.jsonTest plan
npx vitest run __tests__/new-feature-frozen-install.integration.test.ts— 7 passednpm run build— passes (no TS changes)npm run lint— passesbash -n templates/scripts/new-feature.sh— syntax OKMutation verification (gate tests ship with a recorded result, per CLAUDE.md § Testing)
&& [ -f "package.json" ]install gategate: no package.json skips installpm_lockfilepnpm →package-lock.jsonAC-3pm_ci_installpnpm →npm ciThe drift guard was initially a whole-file substring match, which the mutation exposed as tautological — each
ciInstallstring also appears in the file's explanatory comment, so the pnpm-table mutation left it green. Rescoped to thepm_ci_install()function body (second commit); re-running the same mutation now fails it. All restored to green.Closes #847
🤖 Generated with Claude Code
QA follow-up pass (commit
9133875d)QA found the
SEQUANT_NPM_CACHEbranch and thebunarm were modified but untested, and that resolving fromPM_CONFIG.ciInstallsilently dropped npm's--silent. Writing the missing tests surfaced four more npm-shaped assumptions in the same file — all fixed here, each gated by a mutation-verified test.cp -r→cp -Ron the cache-hit copycp -rdereferences symlinks. A pnpmnode_modulesis a farm of relative links into.pnpm/, so the copy was expanded into full real copies, and any dangling link (optional dep, foreign-platform.binentry) exited non-zero —set -ethen left a half-provisioned worktree. Only reachable for pnpm/yarn/bun because this PR made the branch work for them.-Rpreserves links on BSD and GNU alike, and is more faithful for npm's own.bin/entries.CACHE_DIRanchored toMAIN_REPO_DIR../worktrees/.npm-cacheresolved toworktrees/feature/worktrees/.npm-cache— one level below where the worktrees live.pm_recovery bundefers topm_lockfilebun.lockproject was told togit commit bun.lockb, a file it does not have — the same wrong-file misdirection AC-3 exists to eliminate.pm_runnpm run devon a package-manager-aware script.pm_runmirrorsPM_CONFIG.run(yarn takes norun).npm ci --silentrestored viapm_quiet_flagciInstalldrift guard still matchesPM_CONFIGverbatim. Only npm gets a flag — yarn has no equivalent and pnpm/bun's are untested here.HASH_FILE→.lockfile-hashTests: 7 → 15. New coverage for the cache branch (resolved-lockfile hash, cache-hit reuse with symlink preservation, non-npm project not aborting in the hasher), the
bunarm, the quiet flag, the next-steps hint, and a second drift guard overpm_run.Mutation verification (round 2)
pm_quiet_flagnpm--silent→ emptypm_recoverybun → hardcodedbun.lockbpm_runpnpm →npm runpm_rundrift guardcp -R→cp -rCACHE_DIR→ cwd-relativepm_ci_installbun →npm ciciInstalldrift guardAll restored to green (15/15).
origin/mainmerged and theCHANGELOG.mdconflict resolved in2eb9751a.Two items were deliberately not folded in, as separate follow-ups: the TS-side
|| "npm"fallback (worktree-manager.ts:541and:1223— two sites, not the one the spec named), andyarn install --immutablebeing Yarn 2+ syntax that Yarn 1 ignores (a pre-existingstacks.ts:103defect that must be fixed in both paths at once, never one alone).Round 3 — QA-gap fixes (
8cd3717b)Two residual gaps from the round-2 second look:
.lockfile-hashwas one shared file in../worktrees/.npm-cache, which every sibling repo under the same parent shares — two projects alternated overwriting it, missing the cache every run (thrash-only: a hit copies the project's ownnode_modules, so it could never produce a wrong copy).lockfile-hash-$(basename "$MAIN_REPO_DIR")package.json, no lockfile) falls back to npm;npm cifails because it requires a lockfile, and the error said "The committed package-lock.json is out of sync" — describing a file that doesn't existfrozen_installbranches on the resolved lockfile's existence: missing →No <lockfile> found — <cmd> requires a committed lockfile; present → the out-of-sync wording. Recovery command unchanged (it generates the lockfile either way)Tests: 15 → 17 (manifest-only error wording; stale shared-name hash file is not read as a cache hit).
Mutation verification (round 3)
HASH_FILE→ shared.lockfile-hashRestored to green (17/17) between and after mutations.