Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

docs(agents): require restoring shared pnpm shims before worktree removal

vastsad2cd523e99dc
diff --git a/AGENTS.md b/AGENTS.md
index b06c4e48f..d8393a19a 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,6 +1,6 @@
# AGENTS.md
-Policy-Sync: 2026-09-26.1
+Policy-Sync: 2026-11-17.1
Mandatory rules for AI coding agents working in PI-Desktop.
@@ -250,6 +250,26 @@ isolated to the request worktree or its scratch directory. Install or rebuild
dependencies only when the host environment is missing or incompatible, and
record that reason. Clean CI and release runners may install from lockfiles.
+### Shared install teardown
+
+A worktree that shares the primary checkout's `node_modules` also shares
+its pnpm bin shims. Shims written from inside the worktree record absolute
+worktree paths, so removing the worktree silently breaks `tsc`, `electron`,
+`vitest`, `electron-builder`, and every other package script in the primary
+checkout.
+
+Before removing a worktree, confirm no shim still references one:
+
+```bash
+grep -h "worktrees/" node_modules/.bin/* apps/*/node_modules/.bin/* \
+ packages/*/node_modules/.bin/* | grep -v "^# cmd-shim-target="
+```
+
+The command must print nothing. If it does, rewrite the offending shims
+back to the primary checkout path, then verify `tsc --version` and
+`electron --version` actually run. Never delete the worktree first and
+leave the shared shims dangling.
+
### Before candidate validation
Refresh the task against the latest remote `main`.
diff --git a/CLAUDE.md b/CLAUDE.md
index f4d13738e..8af386214 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1,6 +1,6 @@
# CLAUDE.md
-Policy-Sync: 2026-09-26.1
+Policy-Sync: 2026-11-17.1
Instructions for Claude Code CLI and Claude Cowork on PI-Desktop.
@@ -105,6 +105,24 @@ ports, logs, and artifacts isolated. Install or rebuild only for missing or
incompatible host dependencies, and record the reason; clean CI/release
runners may install from lockfiles.
+### Shared install teardown
+
+A worktree that shares the primary checkout's `node_modules` also shares its
+pnpm bin shims. Shims written from inside the worktree record absolute
+worktree paths, so removing the worktree breaks `tsc`, `electron`, `vitest`,
+and `electron-builder` in the primary checkout.
+
+Before `git worktree remove`, verify no shim still references a worktree:
+
+```bash
+grep -h "worktrees/" node_modules/.bin/* apps/*/node_modules/.bin/* \
+ packages/*/node_modules/.bin/* | grep -v "^# cmd-shim-target="
+```
+
+It must print nothing. Rewrite offenders back to the primary checkout path
+and confirm `tsc --version` / `electron --version` run. Never delete the
+worktree first and leave dangling shims behind.
+
### Architecture (frozen)
```text