Skip to content

Conversation

@jzw
Copy link

@jzw jzw commented Jan 23, 2026

Summary

  • Adds a backupFile() utility that creates timestamped backups before overwriting
  • Backs up config.toml before writing (Codex target)
  • Backs up opencode.json before writing (OpenCode target)
  • Backup files use the pattern: config.toml.bak.2026-01-23T21-16-40-065Z

Context

When running bunx @every-env/compound-plugin install compound-engineering --to codex, the CLI overwrites ~/.codex/config.toml without warning, which can destroy user customizations.

Test plan

  • Added test for Codex config backup
  • Added test for OpenCode config backup
  • All existing tests pass

🤖 Generated with Claude Code

@jzw
Copy link
Author

jzw commented Jan 24, 2026

@kieranklaassen this bit me. I figured it may be good to save others the same frustration.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b67848fc27

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 5 to 9
if (!(await pathExists(filePath))) return null

const timestamp = new Date().toISOString().replace(/[:.]/g, "-")
const backupPath = `${filePath}.bak.${timestamp}`
await fs.copyFile(filePath, backupPath)

Choose a reason for hiding this comment

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

P2 Badge Allow overwrite when backup copy lacks perms

The new backupFile always runs fs.copyFile when a config exists. copyFile needs read access to the source file and write access to the parent directory; if a config is writable but not readable (or the directory is not writable for new files), the backup throws and the install/convert aborts even though overwriting the config would have succeeded before. This introduces a regression for restrictive-permission setups (e.g., write-only config files or read-only directories), where the CLI now fails before writing the new config.

Useful? React with 👍 / 👎.

Copy link
Author

@jzw jzw Jan 24, 2026

Choose a reason for hiding this comment

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

If the directory isn't writable, the script already fails when writing prompts/skills before reaching the config backup. The only edge case this blocks is write-only config files, which is feels exceedingly rare. Made it best-effort anyway, backup failures are now silently ignored.

Before writing config.toml (Codex) or opencode.json (OpenCode), the CLI
attempts to create a timestamped backup of any existing config file.
This prevents accidental data loss when users have customized configs.

Backup is best-effort - if it fails (e.g., unusual permissions), the
install continues without blocking.

Backup files are named: config.toml.bak.2026-01-23T21-16-40-065Z
@kieranklaassen
Copy link
Collaborator

OHH TYTY!

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.

2 participants