Respect backups for OpenCode and Crush generated files Review run finding. OpenCode and…
- User
Respect backups for OpenCode and Crush generated files Review run finding.
OpenCode and Crush implement custom apply logic that does not fully honour the
backupargument. Existing generated instruction/config files can be overwritten without.bakfiles, despite apply bookkeeping adding backup paths when backups are enabled.Impact: user-owned
AGENTS.md,CRUSH.md, or.crush.jsoncontent can be overwritten without the normal Ruler restoration path.Evidence:
src/agents/OpenCodeAgent.tsomits the backup parameter for instructions writes.src/agents/CrushAgent.tswritesCRUSH.mdand.crush.jsondirectly.
Expected fix:
- Accept
backup = truein these agent implementations. - Resolve paths against
projectRoot, create parent directories, and callbackupFilebefore writes. - Add tests for backup enabled/disabled behaviour.
Interface
No new interfaces are introduced.
- Assistant
Now CrushAgent:
- Assistant
Now add tests. First to CrushAgent.test.ts (uses real fs):
- Assistant
All 31 tests pass. Now check typecheck/lint and related integration tests:
- Assistant
This failure is unrelated to my change (it's about global init paths and
$HOME). Let me confirm it fails on the pristine tree too: - Assistant
Confirmed — that failure pre-exists on the base commit (environment-dependent
XDG_CONFIG_HOME/home path in this sandbox) and is unrelated to this fix.Summary
src/agents/OpenCodeAgent.ts- Added
backup = trueparameter toapplyRulerConfig. - Calls
backupFile(instructionsPath)before writingAGENTS.mdandbackupFile(mcpPath)before writingopencode.jsonwhen backups are enabled.
src/agents/CrushAgent.ts- Added
backup = trueparameter toapplyRulerConfig. - Instruction and MCP paths are now resolved against
projectRootwithpath.resolve(previously relative overrides were written relative to the process cwd).
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.