@bradygaster/squad-sdk 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/README.md +296 -296
  2. package/dist/agents/history-shadow.js +30 -30
  3. package/dist/build/github-dist.js +42 -42
  4. package/dist/config/init.js +173 -173
  5. package/dist/sharing/consult.js +78 -78
  6. package/package.json +1 -1
  7. package/templates/casting/Futurama.json +9 -9
  8. package/templates/casting-history.json +4 -4
  9. package/templates/casting-policy.json +37 -37
  10. package/templates/casting-reference.md +104 -104
  11. package/templates/casting-registry.json +3 -3
  12. package/templates/ceremonies.md +41 -41
  13. package/templates/charter.md +53 -53
  14. package/templates/constraint-tracking.md +38 -38
  15. package/templates/cooperative-rate-limiting.md +229 -229
  16. package/templates/copilot-instructions.md +46 -46
  17. package/templates/history.md +10 -10
  18. package/templates/identity/now.md +9 -9
  19. package/templates/identity/wisdom.md +15 -15
  20. package/templates/issue-lifecycle.md +412 -412
  21. package/templates/keda-scaler.md +164 -164
  22. package/templates/machine-capabilities.md +74 -74
  23. package/templates/mcp-config.md +90 -90
  24. package/templates/multi-agent-format.md +28 -28
  25. package/templates/plugin-marketplace.md +49 -49
  26. package/templates/ralph-circuit-breaker.md +313 -313
  27. package/templates/raw-agent-output.md +37 -37
  28. package/templates/roster.md +60 -60
  29. package/templates/routing.md +39 -39
  30. package/templates/run-output.md +50 -50
  31. package/templates/schedule.json +19 -19
  32. package/templates/scribe-charter.md +119 -119
  33. package/templates/skill.md +24 -24
  34. package/templates/skills/agent-collaboration/SKILL.md +42 -42
  35. package/templates/skills/agent-conduct/SKILL.md +24 -24
  36. package/templates/skills/architectural-proposals/SKILL.md +151 -151
  37. package/templates/skills/ci-validation-gates/SKILL.md +84 -84
  38. package/templates/skills/cli-wiring/SKILL.md +47 -47
  39. package/templates/skills/client-compatibility/SKILL.md +89 -89
  40. package/templates/skills/cross-squad/SKILL.md +114 -114
  41. package/templates/skills/distributed-mesh/SKILL.md +287 -287
  42. package/templates/skills/distributed-mesh/mesh.json.example +30 -30
  43. package/templates/skills/distributed-mesh/sync-mesh.ps1 +111 -111
  44. package/templates/skills/distributed-mesh/sync-mesh.sh +104 -104
  45. package/templates/skills/docs-standards/SKILL.md +71 -71
  46. package/templates/skills/economy-mode/SKILL.md +114 -114
  47. package/templates/skills/external-comms/SKILL.md +329 -329
  48. package/templates/skills/gh-auth-isolation/SKILL.md +183 -183
  49. package/templates/skills/git-workflow/SKILL.md +204 -204
  50. package/templates/skills/github-multi-account/SKILL.md +95 -95
  51. package/templates/skills/history-hygiene/SKILL.md +36 -36
  52. package/templates/skills/humanizer/SKILL.md +105 -105
  53. package/templates/skills/init-mode/SKILL.md +102 -102
  54. package/templates/skills/model-selection/SKILL.md +117 -117
  55. package/templates/skills/nap/SKILL.md +24 -24
  56. package/templates/skills/personal-squad/SKILL.md +57 -57
  57. package/templates/skills/project-conventions/SKILL.md +56 -56
  58. package/templates/skills/release-process/SKILL.md +423 -423
  59. package/templates/skills/reskill/SKILL.md +92 -92
  60. package/templates/skills/reviewer-protocol/SKILL.md +79 -79
  61. package/templates/skills/secret-handling/SKILL.md +200 -200
  62. package/templates/skills/session-recovery/SKILL.md +155 -155
  63. package/templates/skills/squad-conventions/SKILL.md +69 -69
  64. package/templates/skills/test-discipline/SKILL.md +37 -37
  65. package/templates/skills/windows-compatibility/SKILL.md +74 -74
  66. package/templates/workflows/squad-ci.yml +24 -24
  67. package/templates/workflows/squad-docs.yml +54 -54
  68. package/templates/workflows/squad-heartbeat.yml +171 -171
  69. package/templates/workflows/squad-insider-release.yml +61 -61
  70. package/templates/workflows/squad-issue-assign.yml +161 -161
  71. package/templates/workflows/squad-label-enforce.yml +181 -181
  72. package/templates/workflows/squad-preview.yml +55 -55
  73. package/templates/workflows/squad-promote.yml +120 -120
  74. package/templates/workflows/squad-release.yml +77 -77
  75. package/templates/workflows/squad-triage.yml +260 -260
  76. package/templates/workflows/sync-squad-labels.yml +169 -169
@@ -1,84 +1,84 @@
1
- ---
2
- name: "ci-validation-gates"
3
- description: "Defensive CI/CD patterns: semver validation, token checks, retry logic, draft detection — earned from v0.8.22"
4
- domain: "ci-cd"
5
- confidence: "high"
6
- source: "extracted from Drucker and Trejo charters — earned knowledge from v0.8.22 release incident"
7
- ---
8
-
9
- ## Context
10
-
11
- CI workflows must be defensive. These patterns were learned from the v0.8.22 release disaster where invalid semver, wrong token types, missing retry logic, and draft releases caused a multi-hour outage. Both Drucker (CI/CD) and Trejo (Release Manager) carried this knowledge in their charters — now centralized here.
12
-
13
- ## Patterns
14
-
15
- ### Semver Validation Gate
16
- Every publish workflow MUST validate version format before `npm publish`. 4-part versions (e.g., 0.8.21.4) are NOT valid semver — npm mangles them.
17
-
18
- ```yaml
19
- - name: Validate semver
20
- run: |
21
- VERSION="${{ github.event.release.tag_name }}"
22
- VERSION="${VERSION#v}"
23
- if ! npx semver "$VERSION" > /dev/null 2>&1; then
24
- echo "❌ Invalid semver: $VERSION"
25
- echo "Only 3-part versions (X.Y.Z) or prerelease (X.Y.Z-tag.N) are valid."
26
- exit 1
27
- fi
28
- echo "✅ Valid semver: $VERSION"
29
- ```
30
-
31
- ### NPM Token Type Verification
32
- NPM_TOKEN MUST be an Automation token, not a User token with 2FA:
33
- - User tokens require OTP — CI can't provide it → EOTP error
34
- - Create Automation tokens at npmjs.com → Settings → Access Tokens → Automation
35
- - Verify before first publish in any workflow
36
-
37
- ### Retry Logic for npm Registry Propagation
38
- npm registry uses eventual consistency. After `npm publish` succeeds, the package may not be immediately queryable.
39
- - Propagation: typically 5-30s, up to 2min in rare cases
40
- - All verify steps: 5 attempts, 15-second intervals
41
- - Log each attempt: "Attempt 1/5: Checking package..."
42
- - Exit loop on success, fail after max attempts
43
-
44
- ```yaml
45
- - name: Verify package (with retry)
46
- run: |
47
- MAX_ATTEMPTS=5
48
- WAIT_SECONDS=15
49
- for attempt in $(seq 1 $MAX_ATTEMPTS); do
50
- echo "Attempt $attempt/$MAX_ATTEMPTS: Checking $PACKAGE@$VERSION..."
51
- if npm view "$PACKAGE@$VERSION" version > /dev/null 2>&1; then
52
- echo "✅ Package verified"
53
- exit 0
54
- fi
55
- [ $attempt -lt $MAX_ATTEMPTS ] && sleep $WAIT_SECONDS
56
- done
57
- echo "❌ Failed to verify after $MAX_ATTEMPTS attempts"
58
- exit 1
59
- ```
60
-
61
- ### Draft Release Detection
62
- Draft releases don't emit `release: published` event. Workflows MUST:
63
- - Trigger on `release: published` (NOT `created`)
64
- - If using workflow_dispatch: verify release is published via GitHub API before proceeding
65
-
66
- ### Build Script Protection
67
- Set `SKIP_BUILD_BUMP=1` (or `$env:SKIP_BUILD_BUMP = "1"` on Windows) before ANY release build. bump-build.mjs is for dev builds ONLY — it silently mutates versions.
68
-
69
- ## Known Failure Modes (v0.8.22 Incident)
70
-
71
- | # | What Happened | Root Cause | Prevention |
72
- |---|---------------|-----------|------------|
73
- | 1 | 4-part version published, npm mangled it | No semver validation gate | `npx semver` check before every publish |
74
- | 2 | CI failed 5+ times with EOTP | User token with 2FA | Automation token only |
75
- | 3 | Verify returned false 404 | No retry logic for propagation | 5 attempts, 15s intervals |
76
- | 4 | Workflow never triggered | Draft release doesn't emit event | Never create draft releases |
77
- | 5 | Version mutated during release | bump-build.mjs ran in release | SKIP_BUILD_BUMP=1 |
78
-
79
- ## Anti-Patterns
80
- - ❌ Publishing without semver validation gate
81
- - ❌ Single-shot verification without retry
82
- - ❌ Hard-coded secrets in workflows
83
- - ❌ Silent CI failures — every error needs actionable output with remediation
84
- - ❌ Assuming npm publish is instantly queryable
1
+ ---
2
+ name: "ci-validation-gates"
3
+ description: "Defensive CI/CD patterns: semver validation, token checks, retry logic, draft detection — earned from v0.8.22"
4
+ domain: "ci-cd"
5
+ confidence: "high"
6
+ source: "extracted from Drucker and Trejo charters — earned knowledge from v0.8.22 release incident"
7
+ ---
8
+
9
+ ## Context
10
+
11
+ CI workflows must be defensive. These patterns were learned from the v0.8.22 release disaster where invalid semver, wrong token types, missing retry logic, and draft releases caused a multi-hour outage. Both Drucker (CI/CD) and Trejo (Release Manager) carried this knowledge in their charters — now centralized here.
12
+
13
+ ## Patterns
14
+
15
+ ### Semver Validation Gate
16
+ Every publish workflow MUST validate version format before `npm publish`. 4-part versions (e.g., 0.8.21.4) are NOT valid semver — npm mangles them.
17
+
18
+ ```yaml
19
+ - name: Validate semver
20
+ run: |
21
+ VERSION="${{ github.event.release.tag_name }}"
22
+ VERSION="${VERSION#v}"
23
+ if ! npx semver "$VERSION" > /dev/null 2>&1; then
24
+ echo "❌ Invalid semver: $VERSION"
25
+ echo "Only 3-part versions (X.Y.Z) or prerelease (X.Y.Z-tag.N) are valid."
26
+ exit 1
27
+ fi
28
+ echo "✅ Valid semver: $VERSION"
29
+ ```
30
+
31
+ ### NPM Token Type Verification
32
+ NPM_TOKEN MUST be an Automation token, not a User token with 2FA:
33
+ - User tokens require OTP — CI can't provide it → EOTP error
34
+ - Create Automation tokens at npmjs.com → Settings → Access Tokens → Automation
35
+ - Verify before first publish in any workflow
36
+
37
+ ### Retry Logic for npm Registry Propagation
38
+ npm registry uses eventual consistency. After `npm publish` succeeds, the package may not be immediately queryable.
39
+ - Propagation: typically 5-30s, up to 2min in rare cases
40
+ - All verify steps: 5 attempts, 15-second intervals
41
+ - Log each attempt: "Attempt 1/5: Checking package..."
42
+ - Exit loop on success, fail after max attempts
43
+
44
+ ```yaml
45
+ - name: Verify package (with retry)
46
+ run: |
47
+ MAX_ATTEMPTS=5
48
+ WAIT_SECONDS=15
49
+ for attempt in $(seq 1 $MAX_ATTEMPTS); do
50
+ echo "Attempt $attempt/$MAX_ATTEMPTS: Checking $PACKAGE@$VERSION..."
51
+ if npm view "$PACKAGE@$VERSION" version > /dev/null 2>&1; then
52
+ echo "✅ Package verified"
53
+ exit 0
54
+ fi
55
+ [ $attempt -lt $MAX_ATTEMPTS ] && sleep $WAIT_SECONDS
56
+ done
57
+ echo "❌ Failed to verify after $MAX_ATTEMPTS attempts"
58
+ exit 1
59
+ ```
60
+
61
+ ### Draft Release Detection
62
+ Draft releases don't emit `release: published` event. Workflows MUST:
63
+ - Trigger on `release: published` (NOT `created`)
64
+ - If using workflow_dispatch: verify release is published via GitHub API before proceeding
65
+
66
+ ### Build Script Protection
67
+ Set `SKIP_BUILD_BUMP=1` (or `$env:SKIP_BUILD_BUMP = "1"` on Windows) before ANY release build. bump-build.mjs is for dev builds ONLY — it silently mutates versions.
68
+
69
+ ## Known Failure Modes (v0.8.22 Incident)
70
+
71
+ | # | What Happened | Root Cause | Prevention |
72
+ |---|---------------|-----------|------------|
73
+ | 1 | 4-part version published, npm mangled it | No semver validation gate | `npx semver` check before every publish |
74
+ | 2 | CI failed 5+ times with EOTP | User token with 2FA | Automation token only |
75
+ | 3 | Verify returned false 404 | No retry logic for propagation | 5 attempts, 15s intervals |
76
+ | 4 | Workflow never triggered | Draft release doesn't emit event | Never create draft releases |
77
+ | 5 | Version mutated during release | bump-build.mjs ran in release | SKIP_BUILD_BUMP=1 |
78
+
79
+ ## Anti-Patterns
80
+ - ❌ Publishing without semver validation gate
81
+ - ❌ Single-shot verification without retry
82
+ - ❌ Hard-coded secrets in workflows
83
+ - ❌ Silent CI failures — every error needs actionable output with remediation
84
+ - ❌ Assuming npm publish is instantly queryable
@@ -1,47 +1,47 @@
1
- # Skill: CLI Command Wiring
2
-
3
- **Bug class:** Commands implemented in `packages/squad-cli/src/cli/commands/` but never routed in `cli-entry.ts`.
4
-
5
- ## Checklist — Adding a New CLI Command
6
-
7
- 1. **Create command file** in `packages/squad-cli/src/cli/commands/<name>.ts`
8
- - Export a `run<Name>(cwd, options)` async function (or class with static methods for utility modules)
9
-
10
- 2. **Add routing block** in `packages/squad-cli/src/cli-entry.ts` inside `main()`:
11
- ```ts
12
- if (cmd === '<name>') {
13
- const { run<Name> } = await import('./cli/commands/<name>.js');
14
- // parse args, call function
15
- await run<Name>(process.cwd(), options);
16
- return;
17
- }
18
- ```
19
-
20
- 3. **Add help text** in the help section of `cli-entry.ts` (search for `Commands:`):
21
- ```ts
22
- console.log(` ${BOLD}<name>${RESET} <description>`);
23
- console.log(` Usage: <name> [flags]`);
24
- ```
25
-
26
- 4. **Verify both exist** — the recurring bug is doing step 1 but missing steps 2-3.
27
-
28
- ## Wiring Patterns by Command Type
29
-
30
- | Type | Example | How to wire |
31
- |------|---------|-------------|
32
- | Standard command | `export.ts`, `build.ts` | `run*()` function, parse flags from `args` |
33
- | Placeholder command | `loop`, `hire` | Inline in cli-entry.ts, prints pending message |
34
- | Utility/check module | `rc-tunnel.ts`, `copilot-bridge.ts` | Wire as diagnostic check (e.g., `isDevtunnelAvailable()`) |
35
- | Subcommand of another | `init-remote.ts` | Already used inside parent + standalone alias |
36
-
37
- ## Common Import Pattern
38
-
39
- ```ts
40
- import { BOLD, RESET, DIM, RED, GREEN, YELLOW } from './cli/core/output.js';
41
- ```
42
-
43
- Use dynamic `await import()` for command modules to keep startup fast (lazy loading).
44
-
45
- ## History
46
-
47
- - **#237 / PR #244:** 4 commands wired (rc, copilot-bridge, init-remote, rc-tunnel). aspire, link, loop, hire were already present.
1
+ # Skill: CLI Command Wiring
2
+
3
+ **Bug class:** Commands implemented in `packages/squad-cli/src/cli/commands/` but never routed in `cli-entry.ts`.
4
+
5
+ ## Checklist — Adding a New CLI Command
6
+
7
+ 1. **Create command file** in `packages/squad-cli/src/cli/commands/<name>.ts`
8
+ - Export a `run<Name>(cwd, options)` async function (or class with static methods for utility modules)
9
+
10
+ 2. **Add routing block** in `packages/squad-cli/src/cli-entry.ts` inside `main()`:
11
+ ```ts
12
+ if (cmd === '<name>') {
13
+ const { run<Name> } = await import('./cli/commands/<name>.js');
14
+ // parse args, call function
15
+ await run<Name>(process.cwd(), options);
16
+ return;
17
+ }
18
+ ```
19
+
20
+ 3. **Add help text** in the help section of `cli-entry.ts` (search for `Commands:`):
21
+ ```ts
22
+ console.log(` ${BOLD}<name>${RESET} <description>`);
23
+ console.log(` Usage: <name> [flags]`);
24
+ ```
25
+
26
+ 4. **Verify both exist** — the recurring bug is doing step 1 but missing steps 2-3.
27
+
28
+ ## Wiring Patterns by Command Type
29
+
30
+ | Type | Example | How to wire |
31
+ |------|---------|-------------|
32
+ | Standard command | `export.ts`, `build.ts` | `run*()` function, parse flags from `args` |
33
+ | Placeholder command | `loop`, `hire` | Inline in cli-entry.ts, prints pending message |
34
+ | Utility/check module | `rc-tunnel.ts`, `copilot-bridge.ts` | Wire as diagnostic check (e.g., `isDevtunnelAvailable()`) |
35
+ | Subcommand of another | `init-remote.ts` | Already used inside parent + standalone alias |
36
+
37
+ ## Common Import Pattern
38
+
39
+ ```ts
40
+ import { BOLD, RESET, DIM, RED, GREEN, YELLOW } from './cli/core/output.js';
41
+ ```
42
+
43
+ Use dynamic `await import()` for command modules to keep startup fast (lazy loading).
44
+
45
+ ## History
46
+
47
+ - **#237 / PR #244:** 4 commands wired (rc, copilot-bridge, init-remote, rc-tunnel). aspire, link, loop, hire were already present.
@@ -1,89 +1,89 @@
1
- ---
2
- name: "client-compatibility"
3
- description: "Platform detection and adaptive spawning for CLI vs VS Code vs other surfaces"
4
- domain: "orchestration"
5
- confidence: "high"
6
- source: "extracted"
7
- ---
8
-
9
- ## Context
10
-
11
- Squad runs on multiple Copilot surfaces (CLI, VS Code, JetBrains, GitHub.com). The coordinator must detect its platform and adapt spawning behavior accordingly. Different tools are available on different platforms, requiring conditional logic for agent spawning, SQL usage, and response timing.
12
-
13
- ## Patterns
14
-
15
- ### Platform Detection
16
-
17
- Before spawning agents, determine the platform by checking available tools:
18
-
19
- 1. **CLI mode** — `task` tool is available → full spawning control. Use `task` with `agent_type`, `mode`, `model`, `description`, `prompt` parameters. Collect results via `read_agent`.
20
-
21
- 2. **VS Code mode** — `runSubagent` or `agent` tool is available → conditional behavior. Use `runSubagent` with the task prompt. Drop `agent_type`, `mode`, and `model` parameters. Multiple subagents in one turn run concurrently (equivalent to background mode). Results return automatically — no `read_agent` needed.
22
-
23
- 3. **Fallback mode** — neither `task` nor `runSubagent`/`agent` available → work inline. Do not apologize or explain the limitation. Execute the task directly.
24
-
25
- If both `task` and `runSubagent` are available, prefer `task` (richer parameter surface).
26
-
27
- ### VS Code Spawn Adaptations
28
-
29
- When in VS Code mode, the coordinator changes behavior in these ways:
30
-
31
- - **Spawning tool:** Use `runSubagent` instead of `task`. The prompt is the only required parameter — pass the full agent prompt (charter, identity, task, hygiene, response order) exactly as you would on CLI.
32
- - **Parallelism:** Spawn ALL concurrent agents in a SINGLE turn. They run in parallel automatically. This replaces `mode: "background"` + `read_agent` polling.
33
- - **Model selection:** Accept the session model. Do NOT attempt per-spawn model selection or fallback chains — they only work on CLI. In Phase 1, all subagents use whatever model the user selected in VS Code's model picker.
34
- - **Scribe:** Cannot fire-and-forget. Batch Scribe as the LAST subagent in any parallel group. Scribe is light work (file ops only), so the blocking is tolerable.
35
- - **Launch table:** Skip it. Results arrive with the response, not separately. By the time the coordinator speaks, the work is already done.
36
- - **`read_agent`:** Skip entirely. Results return automatically when subagents complete.
37
- - **`agent_type`:** Drop it. All VS Code subagents have full tool access by default. Subagents inherit the parent's tools.
38
- - **`description`:** Drop it. The agent name is already in the prompt.
39
- - **Prompt content:** Keep ALL prompt structure — charter, identity, task, hygiene, response order blocks are surface-independent.
40
-
41
- ### Feature Degradation Table
42
-
43
- | Feature | CLI | VS Code | Degradation |
44
- |---------|-----|---------|-------------|
45
- | Parallel fan-out | `mode: "background"` + `read_agent` | Multiple subagents in one turn | None — equivalent concurrency |
46
- | Model selection | Per-spawn `model` param (4-layer hierarchy) | Session model only (Phase 1) | Accept session model, log intent |
47
- | Scribe fire-and-forget | Background, never read | Sync, must wait | Batch with last parallel group |
48
- | Launch table UX | Show table → results later | Skip table → results with response | UX only — results are correct |
49
- | SQL tool | Available | Not available | Avoid SQL in cross-platform code paths |
50
- | Response order bug | Critical workaround | Possibly necessary (unverified) | Keep the block — harmless if unnecessary |
51
-
52
- ### SQL Tool Caveat
53
-
54
- The `sql` tool is **CLI-only**. It does not exist on VS Code, JetBrains, or GitHub.com. Any coordinator logic or agent workflow that depends on SQL (todo tracking, batch processing, session state) will silently fail on non-CLI surfaces. Cross-platform code paths must not depend on SQL. Use filesystem-based state (`.squad/` files) for anything that must work everywhere.
55
-
56
- ## Examples
57
-
58
- **Example 1: CLI parallel spawn**
59
- ```typescript
60
- // Coordinator detects task tool available → CLI mode
61
- task({ agent_type: "general-purpose", mode: "background", model: "claude-sonnet-4.5", ... })
62
- task({ agent_type: "general-purpose", mode: "background", model: "claude-haiku-4.5", ... })
63
- // Later: read_agent for both
64
- ```
65
-
66
- **Example 2: VS Code parallel spawn**
67
- ```typescript
68
- // Coordinator detects runSubagent available → VS Code mode
69
- runSubagent({ prompt: "...Fenster charter + task..." })
70
- runSubagent({ prompt: "...Hockney charter + task..." })
71
- runSubagent({ prompt: "...Scribe charter + task..." }) // Last in group
72
- // Results return automatically, no read_agent
73
- ```
74
-
75
- **Example 3: Fallback mode**
76
- ```typescript
77
- // Neither task nor runSubagent available → work inline
78
- // Coordinator executes the task directly without spawning
79
- ```
80
-
81
- ## Anti-Patterns
82
-
83
- - ❌ Using SQL tool in cross-platform workflows (breaks on VS Code/JetBrains/GitHub.com)
84
- - ❌ Attempting per-spawn model selection on VS Code (Phase 1 — only session model works)
85
- - ❌ Fire-and-forget Scribe on VS Code (must batch as last subagent)
86
- - ❌ Showing launch table on VS Code (results already inline)
87
- - ❌ Apologizing or explaining platform limitations to the user
88
- - ❌ Using `task` when only `runSubagent` is available
89
- - ❌ Dropping prompt structure (charter/identity/task) on non-CLI platforms
1
+ ---
2
+ name: "client-compatibility"
3
+ description: "Platform detection and adaptive spawning for CLI vs VS Code vs other surfaces"
4
+ domain: "orchestration"
5
+ confidence: "high"
6
+ source: "extracted"
7
+ ---
8
+
9
+ ## Context
10
+
11
+ Squad runs on multiple Copilot surfaces (CLI, VS Code, JetBrains, GitHub.com). The coordinator must detect its platform and adapt spawning behavior accordingly. Different tools are available on different platforms, requiring conditional logic for agent spawning, SQL usage, and response timing.
12
+
13
+ ## Patterns
14
+
15
+ ### Platform Detection
16
+
17
+ Before spawning agents, determine the platform by checking available tools:
18
+
19
+ 1. **CLI mode** — `task` tool is available → full spawning control. Use `task` with `agent_type`, `mode`, `model`, `description`, `prompt` parameters. Collect results via `read_agent`.
20
+
21
+ 2. **VS Code mode** — `runSubagent` or `agent` tool is available → conditional behavior. Use `runSubagent` with the task prompt. Drop `agent_type`, `mode`, and `model` parameters. Multiple subagents in one turn run concurrently (equivalent to background mode). Results return automatically — no `read_agent` needed.
22
+
23
+ 3. **Fallback mode** — neither `task` nor `runSubagent`/`agent` available → work inline. Do not apologize or explain the limitation. Execute the task directly.
24
+
25
+ If both `task` and `runSubagent` are available, prefer `task` (richer parameter surface).
26
+
27
+ ### VS Code Spawn Adaptations
28
+
29
+ When in VS Code mode, the coordinator changes behavior in these ways:
30
+
31
+ - **Spawning tool:** Use `runSubagent` instead of `task`. The prompt is the only required parameter — pass the full agent prompt (charter, identity, task, hygiene, response order) exactly as you would on CLI.
32
+ - **Parallelism:** Spawn ALL concurrent agents in a SINGLE turn. They run in parallel automatically. This replaces `mode: "background"` + `read_agent` polling.
33
+ - **Model selection:** Accept the session model. Do NOT attempt per-spawn model selection or fallback chains — they only work on CLI. In Phase 1, all subagents use whatever model the user selected in VS Code's model picker.
34
+ - **Scribe:** Cannot fire-and-forget. Batch Scribe as the LAST subagent in any parallel group. Scribe is light work (file ops only), so the blocking is tolerable.
35
+ - **Launch table:** Skip it. Results arrive with the response, not separately. By the time the coordinator speaks, the work is already done.
36
+ - **`read_agent`:** Skip entirely. Results return automatically when subagents complete.
37
+ - **`agent_type`:** Drop it. All VS Code subagents have full tool access by default. Subagents inherit the parent's tools.
38
+ - **`description`:** Drop it. The agent name is already in the prompt.
39
+ - **Prompt content:** Keep ALL prompt structure — charter, identity, task, hygiene, response order blocks are surface-independent.
40
+
41
+ ### Feature Degradation Table
42
+
43
+ | Feature | CLI | VS Code | Degradation |
44
+ |---------|-----|---------|-------------|
45
+ | Parallel fan-out | `mode: "background"` + `read_agent` | Multiple subagents in one turn | None — equivalent concurrency |
46
+ | Model selection | Per-spawn `model` param (4-layer hierarchy) | Session model only (Phase 1) | Accept session model, log intent |
47
+ | Scribe fire-and-forget | Background, never read | Sync, must wait | Batch with last parallel group |
48
+ | Launch table UX | Show table → results later | Skip table → results with response | UX only — results are correct |
49
+ | SQL tool | Available | Not available | Avoid SQL in cross-platform code paths |
50
+ | Response order bug | Critical workaround | Possibly necessary (unverified) | Keep the block — harmless if unnecessary |
51
+
52
+ ### SQL Tool Caveat
53
+
54
+ The `sql` tool is **CLI-only**. It does not exist on VS Code, JetBrains, or GitHub.com. Any coordinator logic or agent workflow that depends on SQL (todo tracking, batch processing, session state) will silently fail on non-CLI surfaces. Cross-platform code paths must not depend on SQL. Use filesystem-based state (`.squad/` files) for anything that must work everywhere.
55
+
56
+ ## Examples
57
+
58
+ **Example 1: CLI parallel spawn**
59
+ ```typescript
60
+ // Coordinator detects task tool available → CLI mode
61
+ task({ agent_type: "general-purpose", mode: "background", model: "claude-sonnet-4.5", ... })
62
+ task({ agent_type: "general-purpose", mode: "background", model: "claude-haiku-4.5", ... })
63
+ // Later: read_agent for both
64
+ ```
65
+
66
+ **Example 2: VS Code parallel spawn**
67
+ ```typescript
68
+ // Coordinator detects runSubagent available → VS Code mode
69
+ runSubagent({ prompt: "...Fenster charter + task..." })
70
+ runSubagent({ prompt: "...Hockney charter + task..." })
71
+ runSubagent({ prompt: "...Scribe charter + task..." }) // Last in group
72
+ // Results return automatically, no read_agent
73
+ ```
74
+
75
+ **Example 3: Fallback mode**
76
+ ```typescript
77
+ // Neither task nor runSubagent available → work inline
78
+ // Coordinator executes the task directly without spawning
79
+ ```
80
+
81
+ ## Anti-Patterns
82
+
83
+ - ❌ Using SQL tool in cross-platform workflows (breaks on VS Code/JetBrains/GitHub.com)
84
+ - ❌ Attempting per-spawn model selection on VS Code (Phase 1 — only session model works)
85
+ - ❌ Fire-and-forget Scribe on VS Code (must batch as last subagent)
86
+ - ❌ Showing launch table on VS Code (results already inline)
87
+ - ❌ Apologizing or explaining platform limitations to the user
88
+ - ❌ Using `task` when only `runSubagent` is available
89
+ - ❌ Dropping prompt structure (charter/identity/task) on non-CLI platforms