Skip to content

fix(hook): preserve existing Copilot instructions#1513

Open
season179 wants to merge 1 commit intortk-ai:developfrom
season179:fix/copilot-instructions-preserve
Open

fix(hook): preserve existing Copilot instructions#1513
season179 wants to merge 1 commit intortk-ai:developfrom
season179:fix/copilot-instructions-preserve

Conversation

@season179
Copy link
Copy Markdown

Summary

  • Preserve existing .github/copilot-instructions.md content when installing Copilot support.
  • Add an RTK instruction block with <!-- rtk-instructions v2 --> markers so future installs update idempotently.
  • Migrate legacy unmarked RTK Copilot instructions without duplicating the RTK section.

Fixes #1512

Root Cause

run_copilot() used write_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 the
whole file with RTK instructions.

Test plan

  • rtk cargo +1.92.0 test patch_copilot_instructions
  • rtk cargo fmt --all -- --check
  • rtk git diff --check
  • Manual temp-project check: running init --copilot twice preserved existing Copilot rules and produced one RTK marker block

Notes

Full rtk cargo +1.92.0 test was attempted and reached the suite, but failed in unrelated existing areas: curl truncation expectations, tracking DB creation in this sandbox, and a global uninstall test
touching /Users/season/.config/opencode/plugins/rtk.ts. The new Copilot tests passed.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 25, 2026

CLA assistant check
All committers have signed the CLA.

@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier labels Apr 25, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟡 Risk medium

Summary

This PR fixes the Copilot instructions installation to preserve existing user-authored content in .github/copilot-instructions.md instead of overwriting it. It introduces HTML comment markers (<!-- rtk-instructions v2 -->) for idempotent upserts and includes migration logic to strip legacy unmarked RTK instruction blocks.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1512


Analyzed automatically by wshm · This is an automated analysis, not a human review.

@kiljacken
Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants