fix: link node_modules into claim worktrees so agents can run tests (#9052) - #9054
Merged
Merged
Conversation
…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
force-pushed
the
claim/issue-9052
branch
from
September 28, 2026 08:25
6d8f516 to
e81120c
Compare
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
Claim worktrees now get the source checkout's
node_moduleslinked in right aftergit worktree add, so an agent can run tests andnpm run pregatein the worktree without a manual step or annpm install, which would empty the primary checkout's realnode_modulesthrough the symlink.scripts/link-worktree-deps.js <source-checkout> <worktree>calls the existinglinkWorktreeDependencieshelper fromworktreeManager.js, the one PortOS-created CoS worktrees already use. It leaves existing entries alone and never writes to the source checkout.{portosRoot}placeholder (resolved intaskPromptService.jstoPATHS.installRoot). The claim prompts run the script asnode "{portosRoot}/scripts/link-worktree-deps.js" "{repoPath}" "${WORKTREE}", so it also works for managed apps, whose own repo has no such script.claim-issue(v36),claim-issue-gitlab(v32),claim-issue-jira(v21),plan-task(v20) andplan-task-claim. The integrity snapshot was regenerated.Test plan
scripts/link-worktree-deps.test.jsruns 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.jschecks that each claim prompt links dependencies right after its worktree add.taskPromptService.test.jschecks that{portosRoot}is substituted.npm run pregatepasses.Closes #9052