Skip to content

fix(worktree): new-feature.sh still uses npm install, so provisioning dirties the lockfile (#816 gap) #826

Closed

Description

@admarble

Context

#816 fixed worktree provisioning so it "cannot dirty the lockfile", switching the TypeScript worktree-manager path to the package manager's frozen install (npm ci / pnpm install --frozen-lockfile). The rationale is worth restating because it is not cosmetic — a single unstaged package-lock.json cascades into three unrelated-looking failures:

scripts/new-feature.sh was not covered by that fix and still uses npm install --silent at three sites.

Evidence

Observed 2026-07-26 while provisioning the worktree for #804 with ./scripts/new-feature.sh 804. Immediately after provisioning, before any edit:

$ git diff --stat package-lock.json
 package-lock.json | 12 ------------
 1 file changed, 12 deletions(-)

$ git diff package-lock.json | head
-      "libc": [
-        "glibc"
-      ],
...
-      "libc": [
-        "musl"

This is the exact signature #816 documents: the local npm stripping libc fields a newer npm wrote via dependabot. It had to be reverted by hand before committing, and would otherwise have ridden along in PR #825.

Affected sites

templates/scripts/new-feature.sh (note: scripts/new-feature.sh is a symlink to it — edit the template, not the link):

  • :203 — cache-enabled path, package-lock changed
  • :210 — cache-enabled path, cache initialization
  • :219 — default path

Proposal

Use the frozen install at all three sites, matching #816's substitution. The enclosing if [ ! -d "node_modules" ] guard means this always runs against an absent node_modules, which is exactly npm ci's precondition, so the swap is safe.

Worth considering whether the script should route through the same package-manager abstraction the TypeScript path uses rather than hardcoding npm, since the script already hardcodes npm elsewhere — but a like-for-like npm ci swap is the minimal fix and can land first.

Acceptance Criteria

  • AC-1: All three npm install --silent sites in templates/scripts/new-feature.sh use a frozen install that cannot rewrite package-lock.json.
  • AC-2: Provisioning a fresh worktree on a repo whose committed lockfile disagrees with the local npm leaves git status --porcelain empty — verified by running the script, not by inspection.
  • AC-3: The SEQUANT_NPM_CACHE=true path still works: cache hit copies node_modules, cache miss installs and updates the hash file.
  • AC-4: Failure mode is not silently worse than before — if the frozen install fails because the lockfile is genuinely out of sync with package.json, the script surfaces that rather than leaving a half-provisioned worktree.

Non-Goals

  • Migrating the script to the TypeScript worktree-manager path.
  • Generalizing the script beyond npm (pnpm/yarn support) — separate concern.

References

Activity

  1. added a commit that references this issue on Jul 27, 2026
  2. added 2 commits that reference this issue on Jul 29, 2026
  3. added a commit that references this issue on Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions