fix(hook): preserve existing Copilot instructions#1513
fix(hook): preserve existing Copilot instructions#1513season179 wants to merge 1 commit intortk-ai:developfrom
Conversation
📊 Automated PR Analysis
SummaryThis PR fixes the Copilot instructions installation to preserve existing user-authored content in Review Checklist
Linked issues: #1512 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Drive by comment, but I think the more idiomatic way to manage this would be to create a .github/instructions/rtk.instruction.md. Avoids messing with the users existing instructions, and reduces the risk of clobbering the RTK instructions if the user runs /init to regenerate their copilot-instructions. |
Summary
.github/copilot-instructions.mdcontent when installing Copilot support.<!-- rtk-instructions v2 -->markers so future installs update idempotently.Fixes #1512
Root Cause
run_copilot()usedwrite_if_changed()for.github/copilot-instructions.md. When the file already existed with user-authored Copilot rules, any content mismatch caused RTK to atomically replace thewhole file with RTK instructions.
Test plan
rtk cargo +1.92.0 test patch_copilot_instructionsrtk cargo fmt --all -- --checkrtk git diff --checkinit --copilottwice preserved existing Copilot rules and produced one RTK marker blockNotes
Full
rtk cargo +1.92.0 testwas attempted and reached the suite, but failed in unrelated existing areas: curl truncation expectations, tracking DB creation in this sandbox, and a global uninstall testtouching
/Users/season/.config/opencode/plugins/rtk.ts. The new Copilot tests passed.