Repository navigation
Description
Problem
When compound-plugin install compound-engineering --to pi runs, it unconditionally removes any directory at ~/.pi/agent/skills/<name> and replaces it with a fresh upstream copy — even if the existing path is a user-managed symlink pointing at a personal fork, local patch, or git worktree.
This breaks the common workflow of using symlinks to override upstream skills with local modifications (which is the entire basis of every downstream patch project that builds on top of compound-engineering — see "Use case" below).
Repro (verified 2026-06-30)
# Setup: user has a local fork of compound-engineering at ~/agents-skills/
mkdir -p ~/agents-skills/skills
cp -r <some-plugin>/skills/ce-session-inventory ~/agents-skills/skills/
# User creates a symlink override (the standard pattern for downstream patches)
ln -sfn ~/agents-skills/skills/ce-session-inventory ~/.pi/agent/skills/ce-session-inventory
# User runs the standard install
bunx @every-env/compound-plugin install compound-engineering --to pi
# Result: symlink is gone, replaced by upstream real dir
ls -la ~/.pi/agent/skills/ce-session-inventory
# drwxr-xr-x ... SKILL.md <- real dir, NOT a symlink
# User's local patch is silently deactivatedSource of the bug
src/targets/pi.ts:89 (in cleanupCurrentManagedSkillDir):
for (const skill of bundle.skillDirs) {
const skillName = sanitizePathName(skill.name)
const targetDir = path.join(paths.skillsDir, skillName)
await cleanupCurrentManagedSkillDir(targetDir, manifest, skillName) // <-- here
await copySkillDir(skill.sourceDir, targetDir, transformContentForPi)
}cleanupCurrentManagedSkillDir (pi.ts:395-402) does fs.rm(targetDir, { recursive: true, force: true }) for any skill name in the manifest. There is no check for "is this path a symlink to a user-managed location?".
Expected vs actual
| Expected | Actual | |
|---|---|---|
| Path doesn't exist | Create fresh dir | Create fresh dir ✓ |
| Path is a real dir from a previous compound-plugin install | Replace with new content | Replace with new content ✓ |
| Path is a real dir from somewhere else (e.g., manually authored) | Skip cleanup, leave alone | Clobbered ✗ |
| Path is a symlink to a user fork / worktree / patch | Skip cleanup, preserve symlink | Clobbered ✗ |
Use case
Symlink overrides are the established pattern for downstream patch projects that build on top of compound-engineering. Concretely, this is what agents-skills (https://github.com/EveryInc/agents-skills) does:
- 5 user symlinks at
~/.pi/agent/skills/{ce-session-inventory,ce-session-extract,ce-compound}etc. point at~/agents-skills/skills/... - This lets the user keep their patches in sync with
mainofagents-skillswhile still receiving upstream compound-engineering updates - The symlinks are re-created by a
restore-patches.shscript that runs after everycompound-plugin install
We're not the only project doing this — the pattern is fundamental to anyone who needs to customize compound-engineering for a specific deployment.
Proposed fix
Two viable approaches, both consistent with patterns already in the repo (see issue #125, #479):
Option A: Symlink detection (smallest change, recommended)
In cleanupCurrentManagedSkillDir (and the equivalent agent-file cleanup), add a check: if the target path is a symlink, skip cleanup. Treat symlinks as "user-managed, do not touch."
async function cleanupCurrentManagedSkillDir(
targetDir: string,
manifest: PiInstallManifest | null,
skillName: string,
): Promise<void> {
if (!manifest?.skills.includes(skillName)) return
// NEW: skip cleanup if target is a user-managed symlink
try {
const stat = await fs.lstat(targetDir)
if (stat.isSymbolicLink()) return
} catch (err: unknown) {
if ((err as NodeJS.ErrnoException).code !== 'ENOENT') throw err
}
await fs.rm(targetDir, { recursive: true, force: true })
}Same pattern for cleanupCurrentManagedAgentFile. ~5 lines of code, ~10 lines of test.
Tradeoff: if a user genuinely wants to revert a symlink override to upstream, they have to rm the symlink manually first. This is the correct UX — symlinks are explicit user intent.
Option B: Tracking-key manifest (consistent with #479)
Extend install-manifest.json to record "skills/agents that were installed as real dirs vs symlinks at install time." Skip cleanup only for entries the plugin knows it owns as real dirs.
Tradeoff: more invasive, requires manifest migration logic, but handles the edge case where a user creates a symlink and then later wants to convert it to upstream (one-way: symlink → upstream requires explicit user action).
I'd recommend Option A as the smaller, more intuitive fix. Happy to submit a PR if the maintainers agree.
Workaround (in place)
We run bin/restore-patches.sh after every lazypi-update to re-create the symlinks. This works but is a band-aid — it costs ~50ms per run, requires the wrapper to be installed, and creates a window where upstream CE content is briefly active before the symlinks come back. A real fix upstream would make our workaround obsolete.
Environment
@every-env/[email protected]- Pi
0.80.3(@earendil-works/pi-coding-agent) - Linux (Ubuntu 24.04), Node.js-style fs API via Bun runtime
- Incident date: 2026-06-30
Related issues in the project
- Installing to opencode overwrites
opencode.jsonfile #125 — Installing to opencode overwrites opencode.json (fixed via merge-with-priority) - fix(converters): preserve user config when writing MCP servers #479 — Preserve user config when writing MCP servers (fixed via managed-block markers + tracking keys)
Both of those followed the same pattern: when plugin-managed content collides with user content, user content wins. This issue asks for the same principle to apply to symlink overrides.
Offer
Happy to submit a PR for Option A if the maintainers agree it's a good fix. Symlink detection is ~5 LOC plus a test, no manifest changes required, and is consistent with the principle established in #125/#479.
Activity