Repository navigation
fix(cli): preserve user .github/copilot-instructions.md on upgrade (#2186) - #2221
Conversation
🟠 Impact Analysis — PR #2221Risk tier: 🟠 HIGH 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (2 files)
squad-cli (5 files)
squad-sdk (1 file)
templates (1 file)
tests (2 files)
This report is generated automatically for every PR. See #733 for details. |
🛫 PR Readiness Check
PR Scope: 📦🔧 Mixed (product + infrastructure)
|
| Status | Check | Details |
|---|---|---|
| ✅ | Single commit | 1 commit — clean history |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ❌ | Copilot threads resolved | 1 unresolved Copilot thread(s) — fix and resolve before merging |
| ❌ | CI passing | 7 check(s) still running |
Files Changed (11 files, +232 −10)
| File | +/− |
|---|---|
.changeset/preserve-copilot-instructions-on-upgrade.md |
+5 −0 |
.squad-templates/copilot-instructions.md |
+3 −0 |
packages/squad-cli/src/cli/commands/copilot.ts |
+13 −5 |
packages/squad-cli/src/cli/core/init.ts |
+3 −2 |
packages/squad-cli/src/cli/core/managed-file.ts |
+112 −1 |
packages/squad-cli/src/cli/core/upgrade.ts |
+2 −2 |
packages/squad-cli/templates/copilot-instructions.md |
+3 −0 |
packages/squad-sdk/templates/copilot-instructions.md |
+3 −0 |
templates/copilot-instructions.md |
+3 −0 |
test/cli/upgrade-portability.test.ts |
+5 −0 |
test/cli/upgrade.test.ts |
+80 −0 |
Total: +232 −10
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
🏗️ Architectural Review
Automated architectural review — informational only. |
There was a problem hiding this comment.
🟡 Changes recommended
Malformed or ambiguous markers can still delete user content, and the template mirrors and release changeset are incomplete.
5 open findings
Avoid pairing unmatched start markers with later end markers · New Require both legacy sentinels before replacing file content · New Edit canonical template instead of generated mirror · New Edit canonical template instead of generated mirror · New Declare SDK patch release for template changes · New
What changed in this PR
Adds managed markers so Squad updates its Copilot instructions without overwriting user content.
Changes:
- Adds merge, removal, and synchronization helpers.
- Integrates them with upgrade, init, and Copilot commands.
- Adds upgrade and portability regressions.
| File | Description |
|---|---|
managed-file.ts |
Implements managed-block handling. |
upgrade.ts |
Preserves instructions during upgrades. |
init.ts |
Merges instructions during initialization. |
copilot.ts |
Upserts or removes only Squad instructions. |
| CLI template | Adds managed markers. |
| SDK template | Adds managed markers. |
upgrade.test.ts |
Tests creation and preservation. |
upgrade-portability.test.ts |
Tests CRLF preservation. |
| Changeset | Documents the CLI fix. |
Review effort: Balanced
| const startIdx = text.indexOf(COPILOT_INSTRUCTIONS_START); | ||
| const endIdx = startIdx !== -1 ? text.indexOf(COPILOT_INSTRUCTIONS_END, startIdx) : -1; |
| if (headingIdx === 0) { | ||
| return `${managedBlock}\n`; | ||
| } |
| @@ -1,3 +1,4 @@ | |||
| <!-- squad:copilot-instructions:start --> | |||
| @@ -1,3 +1,4 @@ | |||
| <!-- squad:copilot-instructions:start --> | |||
| @@ -0,0 +1,5 @@ | |||
| --- | |||
| "@bradygaster/squad-cli": patch | |||
…upgrade (github#2186) Manage Squad instructions inside .github/copilot-instructions.md using <!-- squad:copilot-instructions:start --> and <!-- squad:copilot-instructions:end --> markers instead of overwriting the entire file. Closes github#2186 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5cf0811c-a02a-41a7-ab00-904b6900db7b
5d836f1 to
0e33392
Compare


Summary
emoveCopilotInstructionsBlock, and syncCopilotInstructionsFile in managed-file.ts and wire them into squad upgrade, squad init, and squad copilot.
Closes #2186