Skip to content

fix(scripts): run worktree setup without POSIX shell - #6268

Closed
RioPlay wants to merge 4 commits into
pingdotgg:mainfrom
RioPlay:fix/windows-worktree-setup
Closed

RioPlay wants to merge 4 commits into
pingdotgg:mainfrom
RioPlay:fix/windows-worktree-setup

Conversation

@RioPlay

@RioPlay RioPlay commented Aug 12, 2026 •

Copy link
Copy Markdown

Problem

Worktree setup from t3.json is typed into a terminal via ProjectSetupScriptRunner. The command used ln -sf, &&, and `` expansion, which fails under Windows PowerShell/cmd — so new worktrees on Windows never get deps, env files, or a warm web cache.

Fix

Replace the shell one-liner with node scripts/setup-worktree.ts that:

  1. Runs vp i with the worktree as cwd
  2. Links project-root .env files into the worktree (copy if symlink is denied)
  3. Warms the web dep cache

Does not delete a worktree .env when the project root has no source yet. Parent dirs are created as needed.

Test plan

  • vp test run scripts/setup-worktree.test.ts (link / copy / skip-missing / same-path)
  • Create a worktree on Windows and confirm setup terminal runs without ln errors
  • Confirm .env appears in the worktree (link or copy) when present on the project root

Model: Grok 4.5 · Harness: Grok Build


Note

Medium Risk
Touches worktree bootstrap and .env linking/copying with filesystem staging/rollback; a bug could leave worktrees without deps or with wrong env files, especially on Windows.

Overview
Replaces the POSIX-only worktree setup command in t3.json (vp i && ln -sf ...) with node scripts/setup-worktree.ts, so setup works under PowerShell/cmd on Windows.

The new script installs deps, links .env and infra/relay/.env from the project root into the worktree (falling back to copy when symlinks are denied), then warms the web dep cache. Linking uses staging + backup/rename so a failed mid-flight write does not wipe a local worktree .env, and missing sources are skipped instead of deleting the destination.

Adds unit coverage for path resolution, link/copy, same-path/junction skips, missing sources, and non-file sources.

Reviewed by Cursor Bugbot for commit 6091865. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Replace inline shell worktree setup with a Node script in scripts/setup-worktree.ts

  • Replaces the inline shell command in t3.json with node scripts/setup-worktree.ts, removing the dependency on a POSIX shell.
  • The new script resolves projectRoot and worktree from environment variables, installs dependencies via vp i, links or copies configured .env files, and warms the web dep cache.
  • Env file linking uses an atomic staging/rename flow: symlink when possible, copy as fallback, and never deletes an existing worktree env when the source is missing.
  • Behavioral Change: env file handling now skips when source and destination resolve to the same path (symlink/junction-aware), replacing the previous unconditional symlink creation.

Macroscope summarized 6091865.

RioPlay and others added 2 commits August 11, 2026 21:54
t3.json worktree setup used ln -sf and shell variable expansion, which
fails under Windows PowerShell when creating worktrees.

Replace it with a small Node script that installs deps, links or copies
.env files, and warms the web dep cache.
Pin cwd for installs, only replace env files when the project root has a source, create parent dirs, and cover link/copy/skip paths so Windows setup does not wipe local .env files.
@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 885c5f53-10a5-4957-b9ae-1284223bad44

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Aug 12, 2026
Comment thread scripts/setup-worktree.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 6091865

This PR replaces POSIX shell commands with a cross-platform Node.js script for developer worktree setup. The change only affects development tooling (not production runtime), includes comprehensive tests, and maintains equivalent functionality while adding Windows compatibility.

You can customize Macroscope's approvability policy. Learn more.

Review: rmSync before symlink/copy could delete a locally edited worktree .env if the replacement then failed. Stage to a temp path and only rename over the destination after the operation succeeds; restore from backup on swap failure.
Comment thread scripts/setup-worktree.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1cb172a. Configure here.

Comment thread scripts/setup-worktree.test.ts Outdated
Review: resolve alone missed worktree junctions/symlinks to the project root, and a directory source could symlink-succeed on POSIX. Use realpath for identity, skip non-files without touching the destination, and cover both cases in tests.

@CDVolvik CDVolvik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows verification (PowerShell 5.1 + Node 22.14, Developer Mode on).

The old t3.json command is broken here exactly as described:

ln : The term 'ln' is not recognized as the name of a cmdlet, function,
script file, or operable program.

scripts/setup-worktree.test.ts: 6/6. The link path works on this box — symlinkSync(..., "file") succeeded and lstat reports a symlink (so the copy fallback is unexercised here). spawnSync("node", ["-e", "..."], { shell: true }) does pass the args through cmd.exe on this Node, so the vp i / node …/warm-dep-cache.ts spawn shape is fine.

I did not run the full setup (vp i + cache warm) in a real worktree. The unchecked items in the test plan are still the missing piece.

One small gap: the junction/same-path test returns if symlinkSync(..., "junction") throws, so CI on a box without that permission never sees skipped-same-path. The missing-source and not-a-file cases still pin the "don't delete the worktree .env" rule.

@juliusmarminge

Copy link
Copy Markdown
Member

Superseded by #13589, which landed the same cross-OS worktree setup approach (node scripts/setup-worktree.ts + a single t3.json Setup Worktree action). Closing this PR as superseded — feel free to reopen if there's still unique work here that didn't land.

@juliusmarminge

Copy link
Copy Markdown
Member

Superseded by #13589

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants