Skip to content

fix: link node_modules into claim worktrees so agents can run tests (#9052) - #9054

Merged
atomantic merged 3 commits into
mainfrom
claim/issue-9052
Sep 28, 2026
Merged

atomantic merged 3 commits into
mainfrom
claim/issue-9052

Conversation

@atomantic

@atomantic atomantic commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Summary

Claim worktrees now get the source checkout's node_modules linked in right after git worktree add, so an agent can run tests and npm run pregate in the worktree without a manual step or an npm install, which would empty the primary checkout's real node_modules through the symlink.

  • New script scripts/link-worktree-deps.js <source-checkout> <worktree> calls the existing linkWorktreeDependencies helper from worktreeManager.js, the one PortOS-created CoS worktrees already use. It leaves existing entries alone and never writes to the source checkout.
  • New {portosRoot} placeholder (resolved in taskPromptService.js to PATHS.installRoot). The claim prompts run the script as node "{portosRoot}/scripts/link-worktree-deps.js" "{repoPath}" "${WORKTREE}", so it also works for managed apps, whose own repo has no such script.
  • Prompt changes: the step is added to every flow that cuts its own claim worktree: claim-issue (v36), claim-issue-gitlab (v32), claim-issue-jira (v21), plan-task (v20) and plan-task-claim. The integrity snapshot was regenerated.

Test plan

  • scripts/link-worktree-deps.test.js runs the script end to end: it links the missing dirs, keeps an existing one, and exits with a usage error when an argument is missing.
  • taskPromptDefaults.test.js checks that each claim prompt links dependencies right after its worktree add.
  • taskPromptService.test.js checks that {portosRoot} is substituted.
  • npm run pregate passes.

Closes #9052

…9052)

The claim-issue prompt's Phase 2 creates a worktree with `git worktree add`
but did not link dependencies from the primary checkout, causing every
subsequent agent to manually symlink node_modules before running tests or
npm commands. This blocks test execution until the step is improvised.

Add a new script `scripts/link-worktree-deps.js` that wraps the existing
`linkWorktreeDependencies` helper from worktreeManager.js, and call it
immediately after `git worktree add` in the prompt's Phase 2. The prompt's
PROMPT_VERSIONS entry bumps from 35 to 36, and the integrity snapshot is
regenerated.

The script:
- Symlinks root, client/, and server/ node_modules when absent
- Preserves pre-existing entries (real directories or other symlinks)
- Never touches the primary checkout's real directories
- Ships with focused tests covering the three cases above

This allows claim worktrees to run `npm run pregate` and tests immediately
after creation, without manual setup.
…e app checkout (#9052)

The claim prompt referenced an unsubstituted {repoRoot} placeholder, so the
link step never ran, and it assumed the script lived in the managed app's own
repo. Claim prompts now call {portosRoot}/scripts/link-worktree-deps.js with
the app checkout ({repoPath}) as the dependency source. The GitLab, JIRA and
PLAN.md claim flows get the same step, since they cut their worktrees the
same way.
@atomantic
atomantic merged commit 7c4216c into main Sep 28, 2026
9 checks passed
@atomantic
atomantic deleted the claim/issue-9052 branch September 28, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claim-flow worktrees get no node_modules symlinks, so agents cannot run tests

1 participant