Skip to content

fix(presets): round-trip routing.md in preset save/apply#1429

Merged
bradygaster merged 2 commits into
devfrom
bradygaster-squad-1412-preset-routing-roundtrip
Jun 30, 2026
Merged

fix(presets): round-trip routing.md in preset save/apply#1429
bradygaster merged 2 commits into
devfrom
bradygaster-squad-1412-preset-routing-roundtrip

Conversation

@bradygaster

Copy link
Copy Markdown
Owner

Summary

Fixes #1412squad preset save/apply now round-trips custom routing configuration.

Problem

squad preset save <name> only snapshotted agent charters but dropped .squad/routing.md. When squad preset apply ran later, only skeleton routing rows were regenerated from agent roles — custom label tables, module ownership mappings, and other routing rules were lost.

Solution

  1. savePreset — after copying agents, also captures routing.md into the preset directory
  2. applyPreset — if the preset contains a saved routing.md, restores it before scaffolding runs, so writeOrMergeRouting sees the full custom content and only appends missing agent rows

Changes

  • packages/squad-sdk/src/presets/index.ts — save and restore logic for routing.md
  • test/presets.test.ts — new test verifying custom routing (label tables, module ownership) survives save→apply
  • .changeset/fix-preset-routing-roundtrip.md — patch changeset

Testing

All 37 preset tests pass including the new round-trip routing test.

savePreset now captures .squad/routing.md into the preset snapshot.
applyPreset restores the saved routing.md before scaffolding so that
custom label tables, module ownership mappings, and other routing
rules survive the save/apply cycle.

Closes #1412

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 30, 2026 19:49
@github-actions

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #1429

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 3
Files added 1
Files modified 2
Files deleted 0
Modules touched 3
Critical files 1

🎯 Risk Factors

  • 3 files changed (≤5 → LOW)
  • 3 modules touched (2-4 → MEDIUM)
  • Critical files touched: packages/squad-sdk/src/presets/index.ts

📦 Modules Affected

root (1 file)
  • .changeset/fix-preset-routing-roundtrip.md
squad-sdk (1 file)
  • packages/squad-sdk/src/presets/index.ts
tests (1 file)
  • test/presets.test.ts

⚠️ Critical Files

  • packages/squad-sdk/src/presets/index.ts

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

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 42d6d8b

PR Scope: 📦🔧 Mixed (product + infrastructure)

⚠️ 3 item(s) to address before review

Status Check Details
Single commit 2 commits — consider squashing before review
Not in draft Ready for review
Branch up to date dev is 2 commit(s) ahead — rebase recommended
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 All 4 Copilot thread(s) resolved
CI passing All checks passing

Files Changed (3 files, +143 −1)

File +/−
.changeset/fix-preset-routing-roundtrip.md +5 −0
packages/squad-sdk/src/presets/index.ts +28 −1
test/presets.test.ts +110 −0

Total: +143 −1


This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

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.

Pull request overview

This PR aims to fix preset fidelity for routing configuration by ensuring .squad/routing.md is included in preset snapshots and restored on apply, preserving custom routing sections (labels, ownership mappings, etc.) across save → apply.

Changes:

  • Update savePreset() to capture .squad/routing.md into the preset directory.
  • Update applyPreset() to restore a saved routing.md before preset scaffolding runs.
  • Add a regression test for routing round-trip and include a patch changeset for the SDK.
Show a summary per file
File Description
packages/squad-sdk/src/presets/index.ts Adds save/restore logic for routing.md during preset save/apply.
test/presets.test.ts Adds a new test verifying custom routing sections survive save→apply.
.changeset/fix-preset-routing-roundtrip.md Patch changeset documenting the routing round-trip fix.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 4
  • Review effort level: Low

Comment thread packages/squad-sdk/src/presets/index.ts
Comment thread packages/squad-sdk/src/presets/index.ts
Comment thread packages/squad-sdk/src/presets/index.ts
Comment thread test/presets.test.ts
… checks

- Add overwriteRouting option to applyPreset so callers (e.g. squad init
  --preset) can replace an existing skeleton routing.md with the preset's
  saved version without forcing agent overwrites.
- Use !== undefined instead of truthiness for readSync results so
  intentionally-empty routing.md files are faithfully round-tripped.
- Add regression test for overwriteRouting replacing existing skeleton.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bradygaster bradygaster merged commit b4a7fc0 into dev Jun 30, 2026
14 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.

[Preset] squad preset save/apply does not round-trip routing configuration

2 participants