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
I’ll trace the agent apply paths and existing backup test patterns, then add failing coverage before the implementation change.
- Assistant
rgisn’t installed in this checkout, so I’m usingfind/grepfor the same inspection. The worktree is clean but checked out at a detached HEAD; I’ll keep the fix local unless repository metadata indicates a safe feature-branch workflow. - Assistant
The engine already forwards the backup flag correctly. The defect is isolated to these two adapters: OpenCode’s internal MCP path is normally engine-managed, while Crush owns both files itself. I’m covering each adapter directly, including relative custom paths so path resolution and directory creation are verified alongside backup behavior.
- Assistant
The new tests fail at compile time because both concrete methods currently expose only four parameters—confirming the missing backup contract. I’m now adding the defaulted fifth argument and applying the same resolve/create/backup sequence used by the repository’s other adapters.
- Assistant
The targeted adapter tests now pass. I’ve also added OpenCode to the existing real-filesystem backup-forwarding suite, so its default and disabled modes verify actual
.bakcreation rather than only checking a mocked helper call. Next I’m formatting and running the repository’s full CI command set. - Assistant
The full suite reached 1,039 passing tests, with two failures unrelated to these changes: one hard-codes
/rootwhile this runner reports/workspaceas its home, and one expects a permissions error while tests run as root. I’m rerunning those cases individually to distinguish environmental assumptions from regressions, then I’ll complete the remaining build check. - Assistant
The CLI-level backup matrix is now in place for both agents and both flag modes, covering their instruction and config outputs. That verification is still running; formatting has completed and I’m waiting on the focused CLI test, lint, and build chain.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.