Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .squad/agents/control/history.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,10 @@ There is no `claude-haiku-4.6`. The latest haiku is `claude-haiku-4.5`. Never bu

### ModelId Type
`ModelId = string` in `runtime/config.ts` — not a discriminated union. New model IDs can be added to the catalog without TypeScript changes beyond the catalog and chain arrays.

### Template Copy Rename Pattern (#613/#614)
- Template copies of `squad.agent.md` in `templates/`, `packages/squad-cli/templates/`, and `packages/squad-sdk/templates/` are now named `squad.agent.md.template` to prevent Copilot CLI 1.0.11 from discovering and merging them as `*.agent.md` files.
- The canonical source (`.squad-templates/squad.agent.md`) and the active copy (`.github/agents/squad.agent.md`) remain unchanged.
- `scripts/sync-templates.mjs` handles the rename: mirror targets get `.template` suffix, `.github/agents/` target keeps `.md`.
- All code reading templates for init/upgrade/consult (SDK `init.ts`, CLI `upgrade.ts`, CLI `templates.ts`, SDK `consult.ts`) references `squad.agent.md.template` as the source filename.
- The `TEMPLATE_MANIFEST` in `templates.ts` uses `source: 'squad.agent.md.template'` but `destination: '../.github/agents/squad.agent.md'` — source and target names differ.
2 changes: 1 addition & 1 deletion packages/squad-cli/src/cli/core/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface TemplateFile {
export const TEMPLATE_MANIFEST: TemplateFile[] = [
// Core coordinator
{
source: 'squad.agent.md',
source: 'squad.agent.md.template',
destination: '../.github/agents/squad.agent.md',
overwriteOnUpgrade: true,
description: 'Squad coordinator agent prompt',
Expand Down
8 changes: 4 additions & 4 deletions packages/squad-cli/src/cli/core/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export async function runUpgrade(dest: string, options: UpgradeOptions = {}): Pr
}

// Refresh squad.agent.md
const agentSrc = path.join(templatesDir, 'squad.agent.md');
const agentSrc = path.join(templatesDir, 'squad.agent.md.template');
if (fs.existsSync(agentSrc)) {
fs.mkdirSync(path.dirname(agentDest), { recursive: true });
fs.copyFileSync(agentSrc, agentDest);
Expand All @@ -502,10 +502,10 @@ export async function runUpgrade(dest: string, options: UpgradeOptions = {}): Pr

// Upgrade squad.agent.md
const templatesDir = getTemplatesDir();
const agentSrc = path.join(templatesDir, 'squad.agent.md');
const agentSrc = path.join(templatesDir, 'squad.agent.md.template');

if (!fs.existsSync(agentSrc)) {
fatal('squad.agent.md not found in templates — installation may be corrupted');
fatal('squad.agent.md.template not found in templates — installation may be corrupted');
}

fs.mkdirSync(path.dirname(agentDest), { recursive: true });
Expand All @@ -518,7 +518,7 @@ export async function runUpgrade(dest: string, options: UpgradeOptions = {}): Pr

// Upgrade squad-owned files from template manifest
// Exclude squad.agent.md — already copied and version-stamped above
const filesToUpgrade = TEMPLATE_MANIFEST.filter(f => f.overwriteOnUpgrade && f.source !== 'squad.agent.md');
const filesToUpgrade = TEMPLATE_MANIFEST.filter(f => f.overwriteOnUpgrade && f.source !== 'squad.agent.md.template');

for (const file of filesToUpgrade) {
const srcPath = path.join(templatesDir, file.source);
Expand Down
4 changes: 2 additions & 2 deletions packages/squad-sdk/src/config/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1032,8 +1032,8 @@ ${projectDescription ? `- **Description:** ${projectDescription}\n` : ''}- **Cre

const agentFile = join(teamRoot, '.github', 'agents', 'squad.agent.md');
if (!existsSync(agentFile) || !skipExisting) {
if (templatesDir && existsSync(join(templatesDir, 'squad.agent.md'))) {
let agentContent = readFileSync(join(templatesDir, 'squad.agent.md'), 'utf-8');
if (templatesDir && existsSync(join(templatesDir, 'squad.agent.md.template'))) {
let agentContent = readFileSync(join(templatesDir, 'squad.agent.md.template'), 'utf-8');
agentContent = stampVersionInContent(agentContent, version);
await mkdir(dirname(agentFile), { recursive: true });
await writeFile(agentFile, agentContent, 'utf-8');
Expand Down
4 changes: 2 additions & 2 deletions packages/squad-sdk/src/sharing/consult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ function getSquadAgentTemplatePath(): string | null {
const currentDir = path.dirname(fileURLToPath(import.meta.url));

// Try relative to this file (in dist/)
const distPath = path.resolve(currentDir, '../../templates/squad.agent.md');
const distPath = path.resolve(currentDir, '../../templates/squad.agent.md.template');
if (fs.existsSync(distPath)) {
return distPath;
}

// Try relative to package root
const pkgPath = path.resolve(currentDir, '../../../templates/squad.agent.md');
const pkgPath = path.resolve(currentDir, '../../../templates/squad.agent.md.template');
if (fs.existsSync(pkgPath)) {
return pkgPath;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,7 @@ The routing table determines **WHO** handles work. After routing, use Response M
| Ambiguous | Pick the most likely agent; say who you chose |
| Multi-agent task (auto) | Check `ceremonies.md` for `when: "before"` ceremonies whose condition matches; run before spawning work |

**Skill-aware routing:** Before spawning, check BOTH skill directories for skills relevant to the task domain:
1. `.copilot/skills/` — **Copilot-level skills.** Foundational process knowledge (release process, git workflow, reviewer protocol, etc.). These are the coordinator's own playbook — check first.
2. `.squad/skills/` — **Team-level skills.** Patterns and practices agents discovered during work.

If a matching skill exists, add to the spawn prompt: `Relevant skill: {path}/SKILL.md — read before starting.` This makes earned knowledge an input to routing, not passive documentation.
**Skill-aware routing:** Before spawning, check `.squad/skills/` for skills relevant to the task domain. If a matching skill exists, add to the spawn prompt: `Relevant skill: .squad/skills/{name}/SKILL.md — read before starting.` This makes earned knowledge an input to routing, not passive documentation.

### Consult Mode Detection

Expand Down Expand Up @@ -361,20 +357,20 @@ Before spawning an agent, determine which model to use. Check these layers in or

| Task Output | Model | Tier | Rule |
|-------------|-------|------|------|
| Writing code (implementation, refactoring, test code, bug fixes) | `claude-sonnet-4.6` | Standard | Quality and accuracy matter for code. Use standard tier. |
| Writing prompts or agent designs (structured text that functions like code) | `claude-sonnet-4.6` | Standard | Prompts are executable — treat like code. |
| Writing code (implementation, refactoring, test code, bug fixes) | `claude-sonnet-4.5` | Standard | Quality and accuracy matter for code. Use standard tier. |
| Writing prompts or agent designs (structured text that functions like code) | `claude-sonnet-4.5` | Standard | Prompts are executable — treat like code. |
| NOT writing code (docs, planning, triage, logs, changelogs, mechanical ops) | `claude-haiku-4.5` | Fast | Cost first. Haiku handles non-code tasks. |
| Visual/design work requiring image analysis | `claude-opus-4.5` | Premium | Vision capability required. Overrides cost rule. |

**Role-to-model mapping** (applying cost-first principle):

| Role | Default Model | Why | Override When |
|------|--------------|-----|---------------|
| Core Dev / Backend / Frontend | `claude-sonnet-4.6` | Writes code — quality first | Heavy code gen → `gpt-5.3-codex` |
| Tester / QA | `claude-sonnet-4.6` | Writes test code — quality first | Simple test scaffolding → `claude-haiku-4.5` |
| Core Dev / Backend / Frontend | `claude-sonnet-4.5` | Writes code — quality first | Heavy code gen → `gpt-5.2-codex` |
| Tester / QA | `claude-sonnet-4.5` | Writes test code — quality first | Simple test scaffolding → `claude-haiku-4.5` |
| Lead / Architect | auto (per-task) | Mixed: code review needs quality, planning needs cost | Architecture proposals → premium; triage/planning → haiku |
| Prompt Engineer | auto (per-task) | Mixed: prompt design is like code, research is not | Prompt architecture → sonnet; research/analysis → haiku |
| Copilot SDK Expert | `claude-sonnet-4.6` | Technical analysis that often touches code | Pure research → `claude-haiku-4.5` |
| Copilot SDK Expert | `claude-sonnet-4.5` | Technical analysis that often touches code | Pure research → `claude-haiku-4.5` |
| Designer / Visual | `claude-opus-4.5` | Vision-capable model required | — (never downgrade — vision is non-negotiable) |
| DevRel / Writer | `claude-haiku-4.5` | Docs and writing — not code | — |
| Scribe / Logger | `claude-haiku-4.5` | Mechanical file ops — cheapest possible | — (never bump Scribe) |
Expand All @@ -383,7 +379,7 @@ Before spawning an agent, determine which model to use. Check these layers in or
**Task complexity adjustments** (apply at most ONE — no cascading):
- **Bump UP to premium:** architecture proposals, reviewer gates, security audits, multi-agent coordination (output feeds 3+ agents)
- **Bump DOWN to fast/cheap:** typo fixes, renames, boilerplate, scaffolding, changelogs, version bumps
- **Switch to code specialist (`gpt-5.3-codex`):** large multi-file refactors, complex implementation from spec, heavy code generation (500+ lines)
- **Switch to code specialist (`gpt-5.2-codex`):** large multi-file refactors, complex implementation from spec, heavy code generation (500+ lines)
- **Switch to analytical diversity (`gemini-3-pro-preview`):** code reviews where a second perspective helps, security reviews, architecture reviews after a rejection

**Layer 4 — Default:** If nothing else matched, use `claude-haiku-4.5`. Cost wins when in doubt, unless code is being produced.
Expand All @@ -393,9 +389,9 @@ Before spawning an agent, determine which model to use. Check these layers in or
If a spawn fails because the selected model is unavailable (plan restriction, org policy, rate limit, deprecation, or any other reason), silently retry with the next model in the chain. Do NOT tell the user about fallback attempts. Maximum 3 retries before jumping to the nuclear fallback.

```
Premium: claude-opus-4.6 → claude-opus-4.5 → claude-sonnet-4.6 → claude-sonnet-4.5 → (omit model param)
Standard: claude-sonnet-4.6 → claude-sonnet-4.5 → gpt-5.4 → gpt-5.3-codex → claude-sonnet-4 → (omit model param)
Fast: claude-haiku-4.5 → gpt-5.4-mini → gpt-5.1-codex-mini → gpt-4.1 → (omit model param)
Premium: claude-opus-4.6 → claude-opus-4.6-fast → claude-opus-4.5 → claude-sonnet-4.5 → (omit model param)
Standard: claude-sonnet-4.5 → gpt-5.2-codex → claude-sonnet-4 → gpt-5.2 → (omit model param)
Fast: claude-haiku-4.5 → gpt-5.1-codex-mini → gpt-4.1 → gpt-5-mini → (omit model param)
```

`(omit model param)` = call the `task` tool WITHOUT the `model` parameter. The platform uses its built-in default. This is the nuclear fallback — it always works.
Expand All @@ -419,7 +415,7 @@ prompt: |
...
```

Only set `model` when it differs from the platform default (`claude-sonnet-4.6`). If the resolved model IS `claude-sonnet-4.6`, you MAY omit the `model` parameter — the platform uses it as default.
Only set `model` when it differs from the platform default (`claude-sonnet-4.5`). If the resolved model IS `claude-sonnet-4.5`, you MAY omit the `model` parameter — the platform uses it as default.

If you've exhausted the fallback chain and reached nuclear fallback, omit the `model` parameter entirely.

Expand All @@ -428,7 +424,7 @@ If you've exhausted the fallback chain and reached nuclear fallback, omit the `m
When spawning, include the model in your acknowledgment:

```
🔧 Fenster (claude-sonnet-4.6) — refactoring auth module
🔧 Fenster (claude-sonnet-4.5) — refactoring auth module
🎨 Redfoot (claude-opus-4.5 · vision) — designing color system
📋 Scribe (claude-haiku-4.5 · fast) — logging session
⚡ Keaton (claude-opus-4.6 · bumped for architecture) — reviewing proposal
Expand All @@ -439,9 +435,9 @@ Include tier annotation only when the model was bumped or a specialist was chose

**Valid models (current platform catalog):**

Premium: `claude-opus-4.6`, `claude-opus-4.6-1m` (Internal only), `claude-opus-4.5`
Standard: `claude-sonnet-4.6`, `claude-sonnet-4.5`, `claude-sonnet-4`, `gpt-5.4`, `gpt-5.3-codex`, `gpt-5.2-codex`, `gpt-5.2`, `gpt-5.1-codex-max`, `gpt-5.1-codex`, `gpt-5.1`, `gemini-3-pro-preview`
Fast/Cheap: `claude-haiku-4.5`, `gpt-5.4-mini`, `gpt-5.1-codex-mini`, `gpt-5-mini`, `gpt-4.1`
Premium: `claude-opus-4.6`, `claude-opus-4.6-fast`, `claude-opus-4.5`
Standard: `claude-sonnet-4.5`, `claude-sonnet-4`, `gpt-5.2-codex`, `gpt-5.2`, `gpt-5.1-codex-max`, `gpt-5.1-codex`, `gpt-5.1`, `gpt-5`, `gemini-3-pro-preview`
Fast/Cheap: `claude-haiku-4.5`, `gpt-5.1-codex-mini`, `gpt-5-mini`, `gpt-4.1`

### Client Compatibility

Expand Down Expand Up @@ -791,9 +787,7 @@ prompt: |
Read .squad/decisions.md (team decisions to respect).
If .squad/identity/wisdom.md exists, read it before starting work.
If .squad/identity/now.md exists, read it at spawn time.
Check .copilot/skills/ for copilot-level skills (process, workflow, protocol).
Check .squad/skills/ for team-level skills (patterns discovered during work).
Read any relevant SKILL.md files before working.
If .squad/skills/ has relevant SKILL.md files, read them before working.

{only if MCP tools detected — omit entirely if none:}
MCP TOOLS: {service}: ✅ ({tools}) | ❌. Fall back to CLI when unavailable.
Expand Down
5 changes: 4 additions & 1 deletion scripts/sync-templates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,15 @@ for (const relFile of sourceFiles) {
const targets = [];

// Mirror to each target directory
// Rename squad.agent.md → squad.agent.md.template in mirror targets
// so Copilot CLI 1.0.11 doesn't discover template copies as *.agent.md
for (const targetDir of MIRROR_TARGETS) {
if (!existsSync(targetDir)) {
// Skip targets whose root doesn't exist (e.g., package not checked out)
continue;
}
targets.push(join(targetDir, relFile));
const destName = relFile === AGENT_MD_FILE ? AGENT_MD_FILE + '.template' : relFile;
targets.push(join(targetDir, destName));
}

// Special case: squad.agent.md also goes to .github/agents/
Expand Down
Loading
Loading