Skip to content

fix(targets): stop installs clobbering user prompts and piling up backups - #1919

Merged
tmchow merged 3 commits into
EveryInc:mainfrom
Quinnod345:fix/symlink-containment-backup-sync-validation-1916
Oct 28, 2026
Merged

tmchow merged 3 commits into
EveryInc:mainfrom
Quinnod345:fix/symlink-containment-backup-sync-validation-1916

Conversation

@Quinnod345

@Quinnod345 Quinnod345 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Reinstalling or syncing to Codex, Pi, or OpenCode no longer damages user files. Before this change, a prompt or Pi extension that the user had symlinked into the install directory had its target file overwritten with plugin content. A same-named file the user wrote by hand was also overwritten and then recorded as plugin-owned. On OpenCode, every reinstall left a new opencode.json.bak.<timestamp> and a <command>.md.bak.<timestamp> for each command, even when nothing had changed.

Fixes #1916

What changed for users

Situation Before After
Codex or Pi prompt, or Pi extension, is a symlink to the user's own file Plugin content written through the link Link and target left alone, and the name is left out of the install manifest
Same-named file exists that the install manifest does not list Overwritten, then claimed as owned Kept, with a warning
A managed prompt or extension is dropped from the bundle, and the user has replaced it with a symlink Symlink deleted Symlink kept
Identical OpenCode reinstall New config and command backups every run No backups and no writes
OpenCode config or command content actually changes Backed up, then written Same. A config backup that fails still stops the install before anything is modified (#1914)

Prompts and extensions now follow the same ownership rule that agents and skills already followed. In codex.ts and pi.ts, prompt, extension, and agent writes all go through one helper, cleanupCurrentManagedFile.

Also:

  • --permissions help text now says from-commands, which is the value the parser accepts.
  • git clone gets -- before the source and destination arguments.

Behavior to accept

A prompt or extension file that exists but is not listed in the install manifest is now treated as the user's and is never updated. One example is a manifest deleted by hand. Agents and skills already behave this way, and Pi installs have written manifests since #609.

Not changed from #1916

The issue also proposed an ownership gate on legacy Pi prompt cleanup. That gate is left out:

  • Legacy files predate manifests, so a manifest-based gate would stop the legacy sweep from running at all.
  • moveLegacyArtifactToBackup already skips symlinks.
  • A regular file that happens to share a historical CE command name is moved to legacy-backup/. It is never deleted.

Validation

Security Disclosure

This changes converter and writer output and how files are handled during install. Installs no longer follow a symlink at a leaf file when writing prompts or extensions. Cleanup no longer deletes user symlinks in the prompt and extension directories. No new shell execution. With the git clone change, a source value that starts with - can no longer be read as a git option. No secrets or dependency changes.

Agent Disclosure

Co-authored-by: Trevin Chow [email protected]

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T15:44:44.065577Z
We couldn’t complete this review. Comment @codex review to try again.
b8f9801 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…-1916

Resolves the conflict with EveryInc#1914 in src/targets/opencode.ts: config is
backed up (and a failed backup still throws) only when the merged config
differs from the file on disk, and command files are backed up and
rewritten only when their content changed.
…ssion tests

Prompt, extension, and agent writes in codex.ts and pi.ts now go through
one cleanupCurrentManagedFile helper instead of three near-identical ones.
Adds tests for symlinked and unmanaged prompts/extensions (Pi, Codex), a
symlink left in place of a dropped managed prompt, and an identical
OpenCode reinstall leaving no backups. Each fails on main.
@tmchow tmchow changed the title fix(targets): guard Codex/Pi against symlink traversal, prevent backup spam, and verify sync outputRoot (#1916) fix(targets): stop installs clobbering user prompts and piling up backups Oct 28, 2026
@tmchow

tmchow commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Thanks for this, Quinn. The symlink fix is a real one, and I wanted to get it in, so I pushed a couple of commits to your branch instead of going another review round.

What I changed:

  • Merged main (1be2078). It conflicted with fix(opencode): preserve user files and skill ownership on reinstall #1914 in src/targets/opencode.ts. I kept fix(opencode): preserve user files and skill ownership on reinstall #1914's rule that a failed config backup stops the install before anything is touched, and combined it with your change so opencode.json and command files are only backed up and rewritten when their content actually changed.
  • One helper instead of three (810db75). In codex.ts and pi.ts, prompts, Pi extensions, and agents all go through a single cleanupCurrentManagedFile now, rather than near-copies of the same check.
  • Six writer regression tests: symlinked and unmanaged prompts for Pi and Codex, a symlinked Pi extension, a symlink left where a dropped prompt used to be, and an identical OpenCode reinstall. All six fail on main and pass here. Full suite is 4723 passing.
  • Rewrote the title and description to match the diff. The original body described a storeRootEscapesManagedRoot check on .agents/skills and an --output directory/permission check, and neither is in the code.

I kept your from-commands help text fix and the -- on git clone.

One thing from #1916 I left out on purpose: the ownership gate on legacy Pi prompt cleanup. Legacy files predate install manifests, so a manifest gate would stop that sweep from running at all, and moveLegacyArtifactToBackup already skips symlinks. A regular file with an old CE command name gets moved to legacy-backup/, not deleted.

@tmchow
tmchow merged commit 125f80b into EveryInc:main Oct 28, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 28, 2026
@Quinnod345

Copy link
Copy Markdown
Contributor Author

Awesome, thanks for merging this and consolidating the helper + adding the 6 writer regression tests, @tmchow! Good call on leaving the legacy Pi prompt sweep ungated too since moveLegacyArtifactToBackup already skips symlinks.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Prompts/extensions bypass symlink & ownership guards (codex/pi) and OpenCode install accumulates .bak.<ts> files

2 participants