Skip to content

fix(cli): preserve user .github/copilot-instructions.md on upgrade (#2186) - #2221

Merged
tamirdresher merged 1 commit into
github:devfrom
tamirdresher:fix/2186-preserve-copilot-instructions-on-upgrade
Oct 14, 2026
Merged

tamirdresher merged 1 commit into
github:devfrom
tamirdresher:fix/2186-preserve-copilot-instructions-on-upgrade

Conversation

@tamirdresher

Copy link
Copy Markdown
Collaborator

Summary

  • Wrap the Squad .github/copilot-instructions.md template in / markers.
  • Add mergeCopilotInstructionsContent,
    emoveCopilotInstructionsBlock, and syncCopilotInstructionsFile in managed-file.ts and wire them into squad upgrade, squad init, and squad copilot.
  • Preserve 100% of user-authored .github/copilot-instructions.md content while appending or updating only the Squad-managed block.
  • Add unit and regression tests for fresh creation, preserving existing user instructions without markers, and idempotent marker-based upgrades.

Closes #2186

Copilot AI balanced review requested due to automatic review settings October 14, 2026 14:17
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🟠 Impact Analysis — PR #2221

Risk tier: 🟠 HIGH

📊 Summary

Metric Count
Files changed 11
Files added 1
Files modified 10
Files deleted 0
Modules touched 5

🎯 Risk Factors

  • 11 files changed (6-20 → MEDIUM)
  • 5 modules touched (5-8 → HIGH)

📦 Modules Affected

root (2 files)
  • .changeset/preserve-copilot-instructions-on-upgrade.md
  • templates/copilot-instructions.md
squad-cli (5 files)
  • packages/squad-cli/src/cli/commands/copilot.ts
  • packages/squad-cli/src/cli/core/init.ts
  • packages/squad-cli/src/cli/core/managed-file.ts
  • packages/squad-cli/src/cli/core/upgrade.ts
  • packages/squad-cli/templates/copilot-instructions.md
squad-sdk (1 file)
  • packages/squad-sdk/templates/copilot-instructions.md
templates (1 file)
  • .squad-templates/copilot-instructions.md
tests (2 files)
  • test/cli/upgrade-portability.test.ts
  • test/cli/upgrade.test.ts

This report is generated automatically for every PR. See #733 for details.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 0e33392

PR Scope: 📦🔧 Mixed (product + infrastructure)

⚠️ 3 item(s) to address before review

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.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🏗️ Architectural Review

Authoritative evidence: base-controlled pull_request_target reporter.

⚠️ Architectural review: 1 warning(s).

Severity Category Finding Files
🟡 warning bootstrap-area 3 file(s) in the bootstrap area (packages/squad-cli/src/cli/core/) were modified. These files must maintain zero external dependencies. Review carefully. packages/squad-cli/src/cli/core/init.ts, packages/squad-cli/src/cli/core/managed-file.ts, packages/squad-cli/src/cli/core/upgrade.ts

Automated architectural review — informational only.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Malformed or ambiguous markers can still delete user content, and the template mirrors and release changeset are incomplete.

5 open findings
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

Comment on lines +73 to +74
const startIdx = text.indexOf(COPILOT_INSTRUCTIONS_START);
const endIdx = startIdx !== -1 ? text.indexOf(COPILOT_INSTRUCTIONS_END, startIdx) : -1;
Comment on lines +94 to +96
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
@tamirdresher
tamirdresher force-pushed the fix/2186-preserve-copilot-instructions-on-upgrade branch from 5d836f1 to 0e33392 Compare October 14, 2026 14:49
@tamirdresher
tamirdresher merged commit 4fc9867 into github:dev Oct 14, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Squad upgrade over wrote my copilot-instructions.md. Removed all of my instructions and replaced it with squad instructions

2 participants