Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 839403e59b0ca00fe50e27cf8f3cc3580936d9d6
parent 3681a992b226c9a0a3319746ed490506b45c068d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 18 Jun 2026 14:46:07 -0400

wt add: install deps with builds approved so fresh worktrees are clean

pnpm 11 gates native build scripts (esbuild, lmdb, msgpackr-extract,
sharp, unrs-resolver) behind an `allowBuilds` approval and no longer
honors the repo's legacy `onlyBuiltDependencies`. On a fresh worktree
that meant the first `pnpm install` injected a placeholder `allowBuilds:`
block into the tracked pnpm-workspace.yaml and then failed its
deps-verify-before-run check on every later `pnpm <script>` (e.g.
`pnpm dev:test`, which the Playwright webServer runs) — leaving the
worktree dirty and e2e unrunnable until manually resolved.

`wt add` now runs `pnpm install --config.dangerouslyAllowAllBuilds=true`
in the new worktree (skippable with --no-install). That builds the native
deps once and records them as built, so the tracked workspace file stays
clean and subsequent plain installs / pre-run checks pass. These are the
same build scripts the main worktree already runs. Also removes the need
for the manual `pnpm install` + `pnpm rebuild` worktree-setup steps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Diffstat:
Mscripts/worktree.mjs | 31+++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/scripts/worktree.mjs b/scripts/worktree.mjs @@ -188,14 +188,18 @@ function cmdAdd(args) { const positional = []; let from = null; let shareData = false; + let install = true; for (let i = 0; i < args.length; i++) { if (args[i] === "--from") from = args[++i]; else if (args[i] === "--share-data") shareData = true; + else if (args[i] === "--no-install") install = false; else positional.push(args[i]); } const branch = positional[0]; if (!branch) { - process.stderr.write("worktree add: usage: add <branch> [--from <ref>] [--share-data]\n"); + process.stderr.write( + "worktree add: usage: add <branch> [--from <ref>] [--share-data] [--no-install]\n", + ); return 1; } @@ -229,6 +233,29 @@ function cmdAdd(args) { process.stderr.write(`Wrote .worktree-env -> TRANSCRIPTS_DIR=${sharedTranscripts}\n`); } + // Install deps so the worktree is immediately usable. pnpm 11 gates native + // build scripts (esbuild/lmdb/msgpackr-extract/sharp/unrs-resolver) behind an + // `allowBuilds` approval and, on a fresh worktree, injects a placeholder + // `allowBuilds:` block into the tracked pnpm-workspace.yaml and then fails its + // deps-verify-before-run check on every later `pnpm <script>`. Approving all + // builds for this one install runs them and records them as built, so the + // tracked file stays clean and subsequent plain installs/pre-run checks pass. + // These are the same build scripts the main worktree already runs. + if (install) { + process.stderr.write(`\nInstalling dependencies in ${dir} …\n`); + try { + execFileSync("pnpm", ["install", "--config.dangerouslyAllowAllBuilds=true"], { + cwd: dir, + stdio: "inherit", + }); + } catch { + process.stderr.write( + "\npnpm install failed — run it yourself in the worktree " + + "(or re-run with --no-install to skip).\n", + ); + } + } + const ports = portsForOffset(offsetForIndex(indexForDir(dir))); process.stderr.write(`\nWorktree ready at ${dir}\n`); process.stderr.write( @@ -262,7 +289,7 @@ function usage() { ` ports [--shell fish|bash|posix] Print this worktree's assigned ports\n` + ` run -- <cmd...> Run a command with ports injected into env\n` + ` list List worktrees and their port blocks\n` + - ` add <branch> [--from <ref>] [--share-data] Create a pre-configured worktree\n` + + ` add <branch> [--from <ref>] [--share-data] [--no-install] Create a pre-configured worktree (installs deps unless --no-install)\n` + ` rm <name|path> [--force] Remove a worktree (--force if it has local files)\n`, ); }