@bradygaster/squad-sdk 0.9.3-insider.1 → 0.9.4

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 (53) hide show
  1. package/dist/config/init.d.ts +5 -0
  2. package/dist/config/init.d.ts.map +1 -1
  3. package/dist/config/init.js +59 -26
  4. package/dist/config/init.js.map +1 -1
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/platform/azure-devops.d.ts.map +1 -1
  10. package/dist/platform/azure-devops.js +7 -5
  11. package/dist/platform/azure-devops.js.map +1 -1
  12. package/dist/platform/comms-teams.d.ts +80 -1
  13. package/dist/platform/comms-teams.d.ts.map +1 -1
  14. package/dist/platform/comms-teams.js +306 -84
  15. package/dist/platform/comms-teams.js.map +1 -1
  16. package/dist/platform/comms.d.ts +1 -1
  17. package/dist/platform/comms.d.ts.map +1 -1
  18. package/dist/platform/comms.js +13 -5
  19. package/dist/platform/comms.js.map +1 -1
  20. package/dist/platform/types.d.ts +9 -10
  21. package/dist/platform/types.d.ts.map +1 -1
  22. package/dist/resolution.d.ts +44 -0
  23. package/dist/resolution.d.ts.map +1 -1
  24. package/dist/resolution.js +69 -18
  25. package/dist/resolution.js.map +1 -1
  26. package/dist/roles/catalog-engineering.d.ts +17 -0
  27. package/dist/roles/catalog-engineering.d.ts.map +1 -1
  28. package/dist/roles/catalog-engineering.js +45 -0
  29. package/dist/roles/catalog-engineering.js.map +1 -1
  30. package/dist/roles/catalog.d.ts +1 -1
  31. package/dist/roles/catalog.d.ts.map +1 -1
  32. package/dist/runtime/scheduler.d.ts +6 -0
  33. package/dist/runtime/scheduler.d.ts.map +1 -1
  34. package/dist/runtime/scheduler.js +25 -2
  35. package/dist/runtime/scheduler.js.map +1 -1
  36. package/dist/state-backend.d.ts +5 -0
  37. package/dist/state-backend.d.ts.map +1 -1
  38. package/dist/state-backend.js +66 -39
  39. package/dist/state-backend.js.map +1 -1
  40. package/package.json +1 -1
  41. package/templates/casting-reference.md +104 -104
  42. package/templates/ceremonies.md +28 -28
  43. package/templates/mcp-config.md +0 -2
  44. package/templates/orchestration-log.md +27 -27
  45. package/templates/scribe-charter.md +1 -1
  46. package/templates/skills/external-comms/SKILL.md +329 -329
  47. package/templates/skills/gh-auth-isolation/SKILL.md +183 -183
  48. package/templates/skills/humanizer/SKILL.md +105 -105
  49. package/templates/skills/pr-review-response/SKILL.md +268 -0
  50. package/templates/skills/pr-screenshots/SKILL.md +149 -149
  51. package/templates/skills/versioning-policy/SKILL.md +119 -0
  52. package/templates/squad.agent.md.template +13 -6
  53. package/templates/workflows/squad-heartbeat.yml +167 -167
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: "versioning-policy"
3
+ description: "Semver versioning rules for Squad SDK and CLI — prevents prerelease version incidents"
4
+ domain: "release, versioning, npm, CI"
5
+ confidence: "medium"
6
+ source: "earned (PR #640 workspace resolution incident, PR #116 prerelease leak, CI gate implementation)"
7
+ ---
8
+
9
+ ## Context
10
+
11
+ Squad is a monorepo with two publishable npm packages (`@bradygaster/squad-sdk` and `@bradygaster/squad-cli`) managed via npm workspaces. Version mismatches and prerelease leaks have caused production incidents — most notably PR #640, where a `-build.N` prerelease version silently broke workspace dependency resolution.
12
+
13
+ This skill codifies the versioning rules every agent must follow.
14
+
15
+ ## 1. Version Format
16
+
17
+ All packages use **strict semver**: `MAJOR.MINOR.PATCH`
18
+
19
+ - ✅ `0.9.1`, `1.0.0`, `0.10.0`
20
+ - ❌ `0.9.1-build.4`, `0.9.1-preview.1`, `0.8.6.1-preview`
21
+
22
+ No prerelease suffixes on `dev` or `main` branches — ever.
23
+
24
+ ## 2. Prerelease Versions Are Ephemeral
25
+
26
+ The `scripts/bump-build.mjs` script creates `-build.N` versions (e.g., `0.9.1-build.4`) for **local development testing only**.
27
+
28
+ Rules:
29
+ - `-build.N` versions are created automatically during local `npm run build`
30
+ - They are **never committed** to `dev` or `main`
31
+ - The script skips itself in CI (`CI=true` or `SKIP_BUILD_BUMP=1`)
32
+ - If you see a `-build.N` version in a PR diff, it is a bug — reject the PR
33
+
34
+ ## 3. SDK and CLI Version Sync
35
+
36
+ Both `@bradygaster/squad-sdk` and `@bradygaster/squad-cli` **MUST have the same version** at all times. The root `package.json` version must also match.
37
+
38
+ `bump-build.mjs` enforces this by updating all three `package.json` files in lockstep (root + `packages/squad-sdk` + `packages/squad-cli`).
39
+
40
+ If versions diverge, workspace resolution silently breaks (see §4).
41
+
42
+ ## 4. npm Workspace Semver Footgun
43
+
44
+ The CLI depends on the SDK via a workspace dependency with a semver range:
45
+
46
+ ```json
47
+ "@bradygaster/squad-sdk": ">=0.9.0"
48
+ ```
49
+
50
+ **Critical:** Per the semver specification, `>=0.9.0` does **NOT** match `0.9.1-build.4`.
51
+
52
+ Semver prerelease versions (anything with a `-` suffix) are only matched by ranges that explicitly reference the same `MAJOR.MINOR.PATCH` base with a prerelease comparator. A bare `>=0.9.0` range skips all prerelease versions.
53
+
54
+ **What happens:** When the local SDK has version `0.9.1-build.4`, npm's workspace resolution fails to match the `>=0.9.0` range. npm then **silently installs a stale published version** from the npm registry instead of using the local workspace link. The build succeeds but runs against old SDK code.
55
+
56
+ This is the root cause of the **PR #640 incident**, where workspace packages appeared linked but were actually running against stale registry versions.
57
+
58
+ ## 5. Who Bumps Versions
59
+
60
+ **Surgeon (Release Manager) owns all version bumps.**
61
+
62
+ | Agent | May modify `version` in package.json? |
63
+ |-------|---------------------------------------|
64
+ | Surgeon | ✅ Yes — sole owner of version bumps |
65
+ | Any other agent | ❌ No — unless explicitly fixing a prerelease leak |
66
+
67
+ If you discover a prerelease version committed to `dev` or `main`, you may fix it (revert to the clean release version) without Surgeon's approval. This is a safety escape hatch, not a license to manage versions.
68
+
69
+ ## 6. Version Bump Lifecycle
70
+
71
+ ```
72
+ ┌─────────────────────────────────────────────────────────┐
73
+ │ Development phase │
74
+ │ Versions stay at current release: 0.9.1 │
75
+ │ bump-build.mjs creates -build.N locally (not committed)│
76
+ ├─────────────────────────────────────────────────────────┤
77
+ │ Pre-release testing │
78
+ │ bump-build.mjs → 0.9.1-build.1, -build.2, ... │
79
+ │ Local only. Never committed. Never pushed. │
80
+ ├─────────────────────────────────────────────────────────┤
81
+ │ Release │
82
+ │ Surgeon bumps to next version (e.g., 0.9.2 or 0.10.0) │
83
+ │ Tags, publishes to npm registry │
84
+ ├─────────────────────────────────────────────────────────┤
85
+ │ Post-release │
86
+ │ Versions stay at the new release version (e.g., 0.9.2) │
87
+ │ Development continues on clean version │
88
+ └─────────────────────────────────────────────────────────┘
89
+ ```
90
+
91
+ ## 7. CI Enforcement
92
+
93
+ The **`prerelease-version-guard`** CI gate blocks any PR to `dev` or `main` that contains prerelease version strings in `package.json` files.
94
+
95
+ - The gate scans all three `package.json` files for `-` in the version field
96
+ - PRs with prerelease versions **cannot merge** until the version is cleaned
97
+ - The `skip-version-check` label bypasses the gate — use **only** for the bump-build script's own PR (if applicable), and only with Surgeon's approval
98
+
99
+ ## 8. Incident Reference — PR #640
100
+
101
+ **PR #640** is the cautionary tale for this entire policy.
102
+
103
+ **What happened:** Prerelease versions (`0.9.1-build.4`) were committed to a branch. The workspace dependency `>=0.9.0` failed to match the prerelease version per semver spec. npm silently installed a stale published SDK from the registry instead of linking the local workspace copy. Four PRs (#637–#640) attempted iterative patches before the root cause was identified.
104
+
105
+ **Root cause:** No versioning policy existed. Agents didn't know that prerelease versions break workspace resolution, or that only Surgeon should modify versions.
106
+
107
+ **Resolution:** This skill, the `prerelease-version-guard` CI gate, and the team decision to centralize version ownership under Surgeon.
108
+
109
+ ## Quick Reference
110
+
111
+ | Rule | Summary |
112
+ |------|---------|
113
+ | Format | `MAJOR.MINOR.PATCH` — no prerelease on dev/main |
114
+ | Prerelease | `-build.N` is local-only, never committed |
115
+ | Sync | SDK + CLI + root must have identical versions |
116
+ | Ownership | Surgeon bumps versions; others don't touch them |
117
+ | CI gate | `prerelease-version-guard` blocks prerelease PRs |
118
+ | Escape hatch | Any agent may revert a prerelease leak to clean version |
119
+ | Footgun | `>=0.9.0` does NOT match `0.9.1-build.4` per semver |
@@ -19,6 +19,7 @@ You are **Squad (Coordinator)** — the orchestrator for this project's AI team.
19
19
  - You may NOT generate domain artifacts (code, designs, analyses) — spawn an agent
20
20
  - You may NOT bypass reviewer approval on rejected work
21
21
  - You may NOT invent facts or assumptions — ask the user or spawn an agent who knows
22
+ - You may NOT do work yourself — ALWAYS delegate to a team member, even for small tasks. The only exception is Direct Mode (status checks, factual questions, and simple answers from context — see Response Mode Selection).
22
23
 
23
24
  Check: Does `.squad/team.md` exist? (fall back to `.ai-team/team.md` for repos migrating from older installs)
24
25
  - **No** → Init Mode
@@ -104,7 +105,7 @@ The `union` merge driver keeps all lines from both sides, which is correct for a
104
105
 
105
106
  **If you wrote code, generated artifacts, or produced domain work without dispatching to an agent, you violated this rule. The coordinator ROUTES — it does not BUILD. No exceptions.**
106
107
 
107
- **On every session start:** Run `git config user.name` to identify the current user, and **resolve the team root** (see Worktree Awareness). Store the team root — all `.squad/` paths must be resolved relative to it. Pass the team root into every spawn prompt as `TEAM_ROOT` and the current user's name into every agent spawn prompt and Scribe log so the team always knows who requested the work. Check `.squad/identity/now.md` if it exists — it tells you what the team was last focused on. Update it if the focus has shifted.
108
+ **On every session start:** Run `git config user.name` to identify the current user, and **resolve the team root** (see Worktree Awareness). Store the team root — all `.squad/` paths must be resolved relative to it. Pass the team root and the current datetime (from `<current_datetime>` in your system context) into every spawn prompt as `TEAM_ROOT` and `CURRENT_DATETIME` respectively. Pass the current user's name into every agent spawn prompt and Scribe log so the team always knows who requested the work. Check `.squad/identity/now.md` if it exists — it tells you what the team was last focused on. Update it if the focus has shifted.
108
109
 
109
110
  **⚡ Context caching:** After the first message in a session, `team.md`, `routing.md`, and `registry.json` are already in your context. Do NOT re-read them on subsequent messages — you already have the roster, routing rules, and cast names. Only re-read if the user explicitly modifies the team (adds/removes members, changes routing).
110
111
 
@@ -330,6 +331,7 @@ description: "{emoji} {Name}: {brief task summary}"
330
331
  prompt: |
331
332
  You are {Name}, the {Role} on this project.
332
333
  TEAM ROOT: {team_root}
334
+ CURRENT_DATETIME: {current_datetime}
333
335
  WORKTREE_PATH: {worktree_path}
334
336
  WORKTREE_MODE: {true|false}
335
337
  **Requested by:** {current user name}
@@ -348,7 +350,7 @@ prompt: |
348
350
  ⚠️ RESPONSE ORDER: After ALL tool calls, write a plain text summary as FINAL output.
349
351
  ```
350
352
 
351
- For read-only queries, use the explore agent: `agent_type: "explore"` with `"You are {Name}, the {Role}. {question} TEAM ROOT: {team_root}"`
353
+ For read-only queries, use the explore agent: `agent_type: "explore"` with `"You are {Name}, the {Role}. CURRENT_DATETIME: {current_datetime} — {question} TEAM ROOT: {team_root}"`
352
354
 
353
355
  ### Per-Agent Model Selection
354
356
 
@@ -499,7 +501,7 @@ The `sql` tool is **CLI-only**. It does not exist on VS Code, JetBrains, or GitH
499
501
 
500
502
  MCP (Model Context Protocol) servers extend Squad with tools for external services — Trello, Aspire dashboards, Azure, Notion, and more. The user configures MCP servers in their environment; Squad discovers and uses them.
501
503
 
502
- > **Full patterns:** Read `.squad/skills/mcp-tool-discovery/SKILL.md` for discovery patterns, domain-specific usage, graceful degradation. Read `.squad/templates/mcp-config.md` for config file locations, sample configs, and authentication notes.
504
+ > **Config details:** Read `.squad/templates/mcp-config.md` for config file locations, sample configs, and authentication notes.
503
505
 
504
506
  #### Detection
505
507
 
@@ -623,15 +625,17 @@ Squad and all spawned agents may be running inside a **git worktree** rather tha
623
625
 
624
626
  **How the Coordinator resolves the team root (on every session start):**
625
627
 
626
- 1. Run `git rev-parse --show-toplevel` to get the current worktree root.
627
- 2. Check if `.squad/` exists at that root (fall back to `.ai-team/` for repos that haven't migrated yet).
628
+ 1. **Check CWD first** does `.squad/` exist in the current working directory?
629
+ - **Yes** Team root = CWD. This handles monorepos where `.squad/` lives in a subfolder.
630
+ 2. If not, run `git rev-parse --show-toplevel` to get the current worktree root.
631
+ 3. Check if `.squad/` exists at that root (fall back to `.ai-team/` for repos that haven't migrated yet).
628
632
  - **Yes** → use **worktree-local** strategy. Team root = current worktree root.
629
633
  - **No** → use **main-checkout** strategy. Discover the main working tree:
630
634
  ```
631
635
  git worktree list --porcelain
632
636
  ```
633
637
  The first `worktree` line is the main working tree. Team root = that path.
634
- 3. The user may override the strategy at any time (e.g., *"use main checkout for team state"* or *"keep team state in this worktree"*).
638
+ 4. The user may override the strategy at any time (e.g., *"use main checkout for team state"* or *"keep team state in this worktree"*).
635
639
 
636
640
  **Passing the team root to agents:**
637
641
  - The Coordinator includes `TEAM_ROOT: {resolved_path}` in every spawn prompt.
@@ -769,6 +773,7 @@ prompt: |
769
773
  {paste contents of .squad/agents/{name}/charter.md here}
770
774
 
771
775
  TEAM ROOT: {team_root}
776
+ CURRENT_DATETIME: {current_datetime}
772
777
  All `.squad/` paths are relative to this root.
773
778
 
774
779
  PERSONAL_AGENT: {true|false} # Whether this is a personal agent
@@ -815,6 +820,7 @@ prompt: |
815
820
  Do the work. Respond as {Name}.
816
821
 
817
822
  ⚠️ OUTPUT: Report outcomes in human terms. Never expose tool internals or SQL.
823
+ ⚠️ DATES: When writing dates in any file (decisions, history, logs), use ONLY the CURRENT_DATETIME value above. Never infer or guess the date.
818
824
 
819
825
  AFTER work:
820
826
  1. APPEND to .squad/agents/{name}/history.md under "## Learnings":
@@ -871,6 +877,7 @@ description: "📋 Scribe: Log session & merge decisions"
871
877
  prompt: |
872
878
  You are the Scribe. Read .squad/agents/scribe/charter.md.
873
879
  TEAM ROOT: {team_root}
880
+ CURRENT_DATETIME: {current_datetime}
874
881
 
875
882
  SPAWN MANIFEST: {spawn_manifest}
876
883
 
@@ -1,167 +1,167 @@
1
- name: Squad Heartbeat (Ralph)
2
- # ⚠️ SYNC: This workflow is maintained in 4 locations. Changes must be applied to all:
3
- # - templates/workflows/squad-heartbeat.yml (source template)
4
- # - packages/squad-cli/templates/workflows/squad-heartbeat.yml (CLI package)
5
- # - .squad/templates/workflows/squad-heartbeat.yml (installed template)
6
- # - .github/workflows/squad-heartbeat.yml (active workflow)
7
- # Run 'squad upgrade' to sync installed copies from source templates.
8
-
9
- on:
10
- # React to completed work or new squad work
11
- issues:
12
- types: [closed, labeled]
13
- pull_request:
14
- types: [closed]
15
-
16
- # Manual trigger
17
- workflow_dispatch:
18
-
19
- permissions:
20
- issues: write
21
- contents: read
22
- pull-requests: read
23
-
24
- jobs:
25
- heartbeat:
26
- runs-on: ubuntu-latest
27
- steps:
28
- - uses: actions/checkout@v4
29
-
30
- - name: Check triage script
31
- id: check-script
32
- run: |
33
- if [ -f ".squad/templates/ralph-triage.js" ]; then
34
- echo "has_script=true" >> $GITHUB_OUTPUT
35
- else
36
- echo "has_script=false" >> $GITHUB_OUTPUT
37
- echo "⚠️ ralph-triage.js not found — run 'squad upgrade' to install"
38
- fi
39
-
40
- - name: Ralph — Smart triage
41
- if: steps.check-script.outputs.has_script == 'true'
42
- env:
43
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44
- run: |
45
- node .squad/templates/ralph-triage.js \
46
- --squad-dir .squad \
47
- --output triage-results.json
48
-
49
- - name: Ralph — Apply triage decisions
50
- if: steps.check-script.outputs.has_script == 'true' && hashFiles('triage-results.json') != ''
51
- uses: actions/github-script@v7
52
- with:
53
- script: |
54
- const fs = require('fs');
55
- const path = 'triage-results.json';
56
- if (!fs.existsSync(path)) {
57
- core.info('No triage results — board is clear');
58
- return;
59
- }
60
-
61
- const results = JSON.parse(fs.readFileSync(path, 'utf8'));
62
- if (results.length === 0) {
63
- core.info('📋 Board is clear — Ralph found no untriaged issues');
64
- return;
65
- }
66
-
67
- for (const decision of results) {
68
- try {
69
- await github.rest.issues.addLabels({
70
- owner: context.repo.owner,
71
- repo: context.repo.repo,
72
- issue_number: decision.issueNumber,
73
- labels: [decision.label]
74
- });
75
-
76
- await github.rest.issues.createComment({
77
- owner: context.repo.owner,
78
- repo: context.repo.repo,
79
- issue_number: decision.issueNumber,
80
- body: [
81
- '### 🔄 Ralph — Auto-Triage',
82
- '',
83
- `**Assigned to:** ${decision.assignTo}`,
84
- `**Reason:** ${decision.reason}`,
85
- `**Source:** ${decision.source}`,
86
- '',
87
- '> Ralph auto-triaged this issue using routing rules.',
88
- '> To reassign, swap the `squad:*` label.'
89
- ].join('\n')
90
- });
91
-
92
- core.info(`Triaged #${decision.issueNumber} → ${decision.assignTo} (${decision.source})`);
93
- } catch (e) {
94
- core.warning(`Failed to triage #${decision.issueNumber}: ${e.message}`);
95
- }
96
- }
97
-
98
- core.info(`🔄 Ralph triaged ${results.length} issue(s)`);
99
-
100
- # Copilot auto-assign step (uses PAT if available)
101
- - name: Ralph — Assign @copilot issues
102
- if: success()
103
- uses: actions/github-script@v7
104
- with:
105
- github-token: ${{ secrets.COPILOT_ASSIGN_TOKEN || secrets.GITHUB_TOKEN }}
106
- script: |
107
- const fs = require('fs');
108
-
109
- let teamFile = '.squad/team.md';
110
- if (!fs.existsSync(teamFile)) {
111
- teamFile = '.ai-team/team.md';
112
- }
113
- if (!fs.existsSync(teamFile)) return;
114
-
115
- const content = fs.readFileSync(teamFile, 'utf8');
116
-
117
- // Check if @copilot is on the team with auto-assign
118
- const hasCopilot = content.includes('🤖 Coding Agent') || content.includes('@copilot');
119
- const autoAssign = content.includes('<!-- copilot-auto-assign: true -->');
120
- if (!hasCopilot || !autoAssign) return;
121
-
122
- // Find issues labeled squad:copilot with no assignee
123
- try {
124
- const { data: copilotIssues } = await github.rest.issues.listForRepo({
125
- owner: context.repo.owner,
126
- repo: context.repo.repo,
127
- labels: 'squad:copilot',
128
- state: 'open',
129
- per_page: 5
130
- });
131
-
132
- const unassigned = copilotIssues.filter(i =>
133
- !i.assignees || i.assignees.length === 0
134
- );
135
-
136
- if (unassigned.length === 0) {
137
- core.info('No unassigned squad:copilot issues');
138
- return;
139
- }
140
-
141
- // Get repo default branch
142
- const { data: repoData } = await github.rest.repos.get({
143
- owner: context.repo.owner,
144
- repo: context.repo.repo
145
- });
146
-
147
- for (const issue of unassigned) {
148
- try {
149
- await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/assignees', {
150
- owner: context.repo.owner,
151
- repo: context.repo.repo,
152
- issue_number: issue.number,
153
- assignees: ['copilot-swe-agent[bot]'],
154
- agent_assignment: {
155
- target_repo: `${context.repo.owner}/${context.repo.repo}`,
156
- base_branch: repoData.default_branch,
157
- custom_instructions: `Read .squad/team.md (or .ai-team/team.md) for team context and .squad/routing.md (or .ai-team/routing.md) for routing rules.`
158
- }
159
- });
160
- core.info(`Assigned copilot-swe-agent[bot] to #${issue.number}`);
161
- } catch (e) {
162
- core.warning(`Failed to assign @copilot to #${issue.number}: ${e.message}`);
163
- }
164
- }
165
- } catch (e) {
166
- core.info(`No squad:copilot label found or error: ${e.message}`);
167
- }
1
+ name: Squad Heartbeat (Ralph)
2
+ # ⚠️ SYNC: This workflow is maintained in 4 locations. Changes must be applied to all:
3
+ # - templates/workflows/squad-heartbeat.yml (source template)
4
+ # - packages/squad-cli/templates/workflows/squad-heartbeat.yml (CLI package)
5
+ # - .squad/templates/workflows/squad-heartbeat.yml (installed template)
6
+ # - .github/workflows/squad-heartbeat.yml (active workflow)
7
+ # Run 'squad upgrade' to sync installed copies from source templates.
8
+
9
+ on:
10
+ # React to completed work or new squad work
11
+ issues:
12
+ types: [closed, labeled]
13
+ pull_request:
14
+ types: [closed]
15
+
16
+ # Manual trigger
17
+ workflow_dispatch:
18
+
19
+ permissions:
20
+ issues: write
21
+ contents: read
22
+ pull-requests: read
23
+
24
+ jobs:
25
+ heartbeat:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ - name: Check triage script
31
+ id: check-script
32
+ run: |
33
+ if [ -f ".squad/templates/ralph-triage.js" ]; then
34
+ echo "has_script=true" >> $GITHUB_OUTPUT
35
+ else
36
+ echo "has_script=false" >> $GITHUB_OUTPUT
37
+ echo "⚠️ ralph-triage.js not found — run 'squad upgrade' to install"
38
+ fi
39
+
40
+ - name: Ralph — Smart triage
41
+ if: steps.check-script.outputs.has_script == 'true'
42
+ env:
43
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44
+ run: |
45
+ node .squad/templates/ralph-triage.js \
46
+ --squad-dir .squad \
47
+ --output triage-results.json
48
+
49
+ - name: Ralph — Apply triage decisions
50
+ if: steps.check-script.outputs.has_script == 'true' && hashFiles('triage-results.json') != ''
51
+ uses: actions/github-script@v7
52
+ with:
53
+ script: |
54
+ const fs = require('fs');
55
+ const path = 'triage-results.json';
56
+ if (!fs.existsSync(path)) {
57
+ core.info('No triage results — board is clear');
58
+ return;
59
+ }
60
+
61
+ const results = JSON.parse(fs.readFileSync(path, 'utf8'));
62
+ if (results.length === 0) {
63
+ core.info('📋 Board is clear — Ralph found no untriaged issues');
64
+ return;
65
+ }
66
+
67
+ for (const decision of results) {
68
+ try {
69
+ await github.rest.issues.addLabels({
70
+ owner: context.repo.owner,
71
+ repo: context.repo.repo,
72
+ issue_number: decision.issueNumber,
73
+ labels: [decision.label]
74
+ });
75
+
76
+ await github.rest.issues.createComment({
77
+ owner: context.repo.owner,
78
+ repo: context.repo.repo,
79
+ issue_number: decision.issueNumber,
80
+ body: [
81
+ '### 🔄 Ralph — Auto-Triage',
82
+ '',
83
+ `**Assigned to:** ${decision.assignTo}`,
84
+ `**Reason:** ${decision.reason}`,
85
+ `**Source:** ${decision.source}`,
86
+ '',
87
+ '> Ralph auto-triaged this issue using routing rules.',
88
+ '> To reassign, swap the `squad:*` label.'
89
+ ].join('\n')
90
+ });
91
+
92
+ core.info(`Triaged #${decision.issueNumber} → ${decision.assignTo} (${decision.source})`);
93
+ } catch (e) {
94
+ core.warning(`Failed to triage #${decision.issueNumber}: ${e.message}`);
95
+ }
96
+ }
97
+
98
+ core.info(`🔄 Ralph triaged ${results.length} issue(s)`);
99
+
100
+ # Copilot auto-assign step (uses PAT if available)
101
+ - name: Ralph — Assign @copilot issues
102
+ if: success()
103
+ uses: actions/github-script@v7
104
+ with:
105
+ github-token: ${{ secrets.COPILOT_ASSIGN_TOKEN || secrets.GITHUB_TOKEN }}
106
+ script: |
107
+ const fs = require('fs');
108
+
109
+ let teamFile = '.squad/team.md';
110
+ if (!fs.existsSync(teamFile)) {
111
+ teamFile = '.ai-team/team.md';
112
+ }
113
+ if (!fs.existsSync(teamFile)) return;
114
+
115
+ const content = fs.readFileSync(teamFile, 'utf8');
116
+
117
+ // Check if @copilot is on the team with auto-assign
118
+ const hasCopilot = content.includes('🤖 Coding Agent') || content.includes('@copilot');
119
+ const autoAssign = content.includes('<!-- copilot-auto-assign: true -->');
120
+ if (!hasCopilot || !autoAssign) return;
121
+
122
+ // Find issues labeled squad:copilot with no assignee
123
+ try {
124
+ const { data: copilotIssues } = await github.rest.issues.listForRepo({
125
+ owner: context.repo.owner,
126
+ repo: context.repo.repo,
127
+ labels: 'squad:copilot',
128
+ state: 'open',
129
+ per_page: 5
130
+ });
131
+
132
+ const unassigned = copilotIssues.filter(i =>
133
+ !i.assignees || i.assignees.length === 0
134
+ );
135
+
136
+ if (unassigned.length === 0) {
137
+ core.info('No unassigned squad:copilot issues');
138
+ return;
139
+ }
140
+
141
+ // Get repo default branch
142
+ const { data: repoData } = await github.rest.repos.get({
143
+ owner: context.repo.owner,
144
+ repo: context.repo.repo
145
+ });
146
+
147
+ for (const issue of unassigned) {
148
+ try {
149
+ await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/assignees', {
150
+ owner: context.repo.owner,
151
+ repo: context.repo.repo,
152
+ issue_number: issue.number,
153
+ assignees: ['copilot-swe-agent[bot]'],
154
+ agent_assignment: {
155
+ target_repo: `${context.repo.owner}/${context.repo.repo}`,
156
+ base_branch: repoData.default_branch,
157
+ custom_instructions: `Read .squad/team.md (or .ai-team/team.md) for team context and .squad/routing.md (or .ai-team/routing.md) for routing rules.`
158
+ }
159
+ });
160
+ core.info(`Assigned copilot-swe-agent[bot] to #${issue.number}`);
161
+ } catch (e) {
162
+ core.warning(`Failed to assign @copilot to #${issue.number}: ${e.message}`);
163
+ }
164
+ }
165
+ } catch (e) {
166
+ core.info(`No squad:copilot label found or error: ${e.message}`);
167
+ }