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 run the relevant tests:
- Assistant
All pass. Now typecheck, lint, and the broader suite:
- Assistant
The test-file parsing errors are pre-existing (tests aren't in the eslint tsconfig project). Fix the prettier issue:
- Assistant
Let me verify whether these two failures are pre-existing on HEAD:
- Assistant
Done. Both agents now honour the
backupargument thatapply-enginepasses (src/core/apply-engine.ts:498-504) but they previously ignored.Changes:
-
src/agents/OpenCodeAgent.ts— addedbackup = trueparameter; callsbackupFile()on the instructions path before overwritingAGENTS.md, and on the MCP path before overwritingopencode.json(the direct-write path used when the agent is invoked with MCP JSON, e.g. custom configs/tests — the engine-managed path viapropagateMcpToOpenCodealready backed up). -
src/agents/CrushAgent.ts— added parameter; paths are now resolved against via (previously relative overrides resolved against cwd, unlike every other agent); switched writes to so parent directories are created; calls before writing both and .
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.