-
Notifications
You must be signed in to change notification settings - Fork 508
fix: backup existing config files before overwriting #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@kieranklaassen this bit me. I figured it may be good to save others the same frustration. |
There was a problem hiding this 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".
src/utils/files.ts
Outdated
| if (!(await pathExists(filePath))) return null | ||
|
|
||
| const timestamp = new Date().toISOString().replace(/[:.]/g, "-") | ||
| const backupPath = `${filePath}.bak.${timestamp}` | ||
| await fs.copyFile(filePath, backupPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 👍 / 👎.
There was a problem hiding this comment.
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
b67848f to
c151ec8
Compare
|
OHH TYTY! |
Summary
backupFile()utility that creates timestamped backups before overwritingconfig.tomlbefore writing (Codex target)opencode.jsonbefore writing (OpenCode target)config.toml.bak.2026-01-23T21-16-40-065ZContext
When running
bunx @every-env/compound-plugin install compound-engineering --to codex, the CLI overwrites~/.codex/config.tomlwithout warning, which can destroy user customizations.Test plan
🤖 Generated with Claude Code