You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(worktree): npm ci runs at the worktree root even when the package lives in a subdirectory — EUSAGE on every provision #1243
In a repo whose Node package lives in a subdirectory (e.g. agent/package.json + agent/package-lock.json, with nopackage.json at the repo root), every worktree sequant run provisions prints:
! Dependency install failed (npm ci): npm error code EUSAGE
npm error The `npm ci` command can only install with an existing package-lock.json …
Phases then start with no node_modules anywhere in the worktree. Seen in 4/4 and 2/2 worktrees across two sequant run batches in admarble/varius on 2026-09-30 (sequant 2.18.0; banner Stack unknown).
Root cause
src/lib/workflow/worktree-manager.ts (~L760) runs pmConfig.ciInstall with cwd: worktreePath unconditionally for npm. pip and uv already resolve ciInstall to CI_INSTALL_SKIP when there's nothing to install (#1196 AC-2, #1217), but npm has no equivalent guard for a missing root lockfile or package.json.
Proposed
Minimum: when neither package.json nor a lockfile exists at the worktree root, resolve npm's ciInstall to CI_INSTALL_SKIP and print "Skipping dependency install — no package.json at the worktree root", the same way pip does.
Optional: a run.installDir (or detected single-subdirectory package) setting so the install runs where the package actually is.
Acceptance Criteria
AC-1: A worktree whose root has no package.json or lockfile logs a skip, not Dependency install failed, and returns true. Evidence: npx vitest run src/lib/workflow/worktree-manager.test.ts -t "no root package.json" reports ≥ 1 passed, 0 failed (mutation-verified: removing the guard reintroduces the npm ci call).
AC-2: A root with package.json + package-lock.json still runs npm ci (unchanged). Evidence: an existing or added test in the same file passes.
Non-Goals
Workspace or monorepo install orchestration beyond the optional installDir.
Key finding: the root cause is already fixed on main
The report was taken on sequant 2.18.0. #1196 (ded03e54, first in v2.19.0) added hasManifestForPackageManager() (src/lib/stacks.ts:397) and a guard in installWorktreeDeps (src/lib/workflow/worktree-manager.ts ~L732). With no root package.json, it logs Skipping dependency install — no manifest found for npm and returns true. That covers the agent/package.json layout from varius. Two tests already pin it: worktree-manager.test.ts:~195 and worktree-manager.frozen-install.test.ts:249.
What is left:
The log text differs from the issue ("no manifest found for npm" vs "no package.json at the worktree root"). The message is less helpful for the subdirectory layout.
AC-1's Evidence: filter (-t "no root package.json") matches no existing test name. It cannot pass until a test with that name exists, so the AC is checkable only after work.
Root package.json present but no lockfile still hits npm ci EUSAGE. That case is intentionally a loud failure (frozen-install.test.ts:99) and is outside this issue's AC.
AC Quality Check
AC-1 Evidence is non-vacuous (fails today, 0 tests match). The "mutation-verified" claim needs the marker in the PR body, naming the test file path first.
AC-2 Evidence is vague ("an existing or added test"). Tighten it to worktree-manager.frozen-install.test.ts > "spawns npm ci…" (L52), which already passes. It gates nothing new, so it is a regression pin only.
Non-Goals present.
Scope Assessment
Features 1, ACs 2, directories 2. ✅ SCOPE_OK. Optional item 2 (run.installDir) is deferred (see Open Questions).
Acceptance Criteria
AC-1: no root package.json or lockfile → skip logged, returns true
Verification: Unit Test Scenario: Given a tmp dir with only agent/package.json + agent/package-lock.json → When installWorktreeDeps(dir, undefined, false) → Then true, no non-git spawn, log contains no package.json at the worktree root. Assumptions: the -t filter string must appear in the new test title.
AC-2: root package.json + package-lock.json still runs npm ci
Verification: Unit Test (existing, frozen-install.test.ts:52)
Implementation Plan
worktree-manager.ts: in the skip branch, for Node package managers print Skipping dependency install — no package.json at the worktree root (keep the "no manifest found for " wording for Python PMs, or fold both into a helper). Check that the existing toContain("no manifest found") assertion at worktree-manager.test.ts ~L197 is updated in the same change.
worktree-manager.test.ts: add it("skips … no root package.json …") for the subdirectory-package layout. Assert the spawn mock is not called for a non-git command.
Mutation-verify: remove the guard, confirm that test fails, restore, and record the Mutation-verified: marker with the file path first.
Check templates/scripts/new-feature.sh for the same unconditional npm ci (it mirrors the pm_ci_install table). If it lacks a manifest guard, note it as a follow-up.
Design Review
Where does this belong?installWorktreeDeps, the single install site. The guard already lives there.
Simplest approach? Message and test only. Rejected: re-implementing the guard in stacks.ts npm ciInstall via CI_INSTALL_SKIP. The existing pre-check already precedes it, so that would duplicate it.
Reviewer challenge: "Isn't this already fixed?" Yes. The PR should say so, narrow to the message and a named test, and close the issue.
Producers/consumers: the install guard is read by ensureWorktree and the rebase re-install path (frozen-install.test.ts). new-feature.sh is a second producer of worktree installs (see step 4).
Open Questions
Close as mostly-fixed, or implement run.installDir? Recommendation: implement only the message and test now; file installDir separately if the user still wants installs inside a subdirectory. Impact if wrong: subdirectory repos still get no node_modules, just without an error.
Root package.json but no lockfile: keep the loud npm ci failure? Recommendation: yes (out of scope).
Recommended Workflow
Phases: exec → qa Quality Loop: disabled Reasoning: small, unit-test-verified change; the bug-style fix needs no testgen.
Optional run.installDir follow-up (install inside a subdirectory package) has no terminal state — ⚠️ unresolved
Python package-manager set is duplicated across two files; a new Python PM would need both updated — dropped: non-blocking polish noted in PR body
Suggestions:
isPython at src/lib/workflow/worktree-manager.ts:737 repeats the pip | poetry | uv check that is already in hasManifestForPackageManager (src/lib/stacks.ts:401). If a new Python manager is added, someone has to update both places. A shared isPythonPackageManager(pm) helper would fix this. The PR body flags the same weakness.
Activity
admarble commentedon Oct 8, 2026
Complexity: Standard (2 ACs, 2 directories)
Key finding: the root cause is already fixed on main
The report was taken on sequant 2.18.0. #1196 (
ded03e54, first in v2.19.0) addedhasManifestForPackageManager()(src/lib/stacks.ts:397) and a guard ininstallWorktreeDeps(src/lib/workflow/worktree-manager.ts~L732). With no rootpackage.json, it logsSkipping dependency install — no manifest found for npmand returnstrue. That covers theagent/package.jsonlayout from varius. Two tests already pin it:worktree-manager.test.ts:~195andworktree-manager.frozen-install.test.ts:249.What is left:
Evidence:filter (-t "no root package.json") matches no existing test name. It cannot pass until a test with that name exists, so the AC is checkable only after work.package.jsonpresent but no lockfile still hitsnpm ciEUSAGE. That case is intentionally a loud failure (frozen-install.test.ts:99) and is outside this issue's AC.AC Quality Check
worktree-manager.frozen-install.test.ts> "spawnsnpm ci…" (L52), which already passes. It gates nothing new, so it is a regression pin only.Scope Assessment
Features 1, ACs 2, directories 2. ✅ SCOPE_OK. Optional item 2 (
run.installDir) is deferred (see Open Questions).Acceptance Criteria
AC-1: no root package.json or lockfile → skip logged, returns true
Verification: Unit Test
Scenario: Given a tmp dir with only
agent/package.json+agent/package-lock.json→ WheninstallWorktreeDeps(dir, undefined, false)→ Thentrue, no non-git spawn, log containsno package.json at the worktree root.Assumptions: the
-tfilter string must appear in the new test title.AC-2: root package.json + package-lock.json still runs
npm ciVerification: Unit Test (existing, frozen-install.test.ts:52)
Implementation Plan
worktree-manager.ts: in the skip branch, for Node package managers printSkipping dependency install — no package.json at the worktree root(keep the "no manifest found for " wording for Python PMs, or fold both into a helper). Check that the existingtoContain("no manifest found")assertion atworktree-manager.test.ts~L197 is updated in the same change.worktree-manager.test.ts: addit("skips … no root package.json …")for the subdirectory-package layout. Assert the spawn mock is not called for a non-git command.Mutation-verified:marker with the file path first.templates/scripts/new-feature.shfor the same unconditionalnpm ci(it mirrors thepm_ci_installtable). If it lacks a manifest guard, note it as a follow-up.Design Review
installWorktreeDeps, the single install site. The guard already lives there.stacks.tsnpmciInstallviaCI_INSTALL_SKIP. The existing pre-check already precedes it, so that would duplicate it.npm ci/pip install -qin repos with no manifest to install from — the shell path guards, TS doesn't #1196 (pip/non-Node), fix(stacks): uv ciInstall is a bareuv pip install -q— useuv sync --frozenwith uv.lock, else requirements or skip #1217 (uv), fix(stacks): detectPackageManagerSync is JS-only — a uv/poetry repo without a declared packageManager resolves to npm and skips its install #1231 (JS-only detection). This is the 4th touch of provisioning install. It is a separate branch of the same guard, not a re-patch of the same line, so extend that guard rather than adding a parallel one.ensureWorktreeand the rebase re-install path (frozen-install.test.ts).new-feature.shis a second producer of worktree installs (see step 4).Open Questions
run.installDir? Recommendation: implement only the message and test now; fileinstallDirseparately if the user still wants installs inside a subdirectory. Impact if wrong: subdirectory repos still get nonode_modules, just without an error.package.jsonbut no lockfile: keep the loudnpm cifailure? Recommendation: yes (out of scope).Recommended Workflow
Phases: exec → qa
Quality Loop: disabled
Reasoning: small, unit-test-verified change; the
bug-style fix needs no testgen.Label Review
Current: none. Recommended:
bug. →gh issue edit 1243 --add-label bugadmarble commentedon Oct 8, 2026
QA Verdict: AC_MET_BUT_NOT_A_PLUS
AC coverage: 2/2 met
Gaps:
Suggestions:
isPythonatsrc/lib/workflow/worktree-manager.ts:737repeats thepip | poetry | uvcheck that is already inhasManifestForPackageManager(src/lib/stacks.ts:401). If a new Python manager is added, someone has to update both places. A sharedisPythonPackageManager(pm)helper would fix this. The PR body flags the same weakness.fix(#1243): name the missing root package.json when skipping the npm …