@bradygaster/squad-sdk 0.8.20 → 0.8.21

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 (105) hide show
  1. package/README.md +296 -296
  2. package/dist/adapter/client.js +1 -1
  3. package/dist/adapter/client.js.map +1 -1
  4. package/dist/agents/charter-compiler.d.ts +4 -0
  5. package/dist/agents/charter-compiler.d.ts.map +1 -1
  6. package/dist/agents/charter-compiler.js +8 -0
  7. package/dist/agents/charter-compiler.js.map +1 -1
  8. package/dist/agents/history-shadow.js +30 -30
  9. package/dist/agents/index.js +1 -1
  10. package/dist/agents/index.js.map +1 -1
  11. package/dist/agents/lifecycle.js +1 -1
  12. package/dist/agents/lifecycle.js.map +1 -1
  13. package/dist/build/github-dist.js +42 -42
  14. package/dist/builders/index.d.ts +156 -0
  15. package/dist/builders/index.d.ts.map +1 -0
  16. package/dist/builders/index.js +404 -0
  17. package/dist/builders/index.js.map +1 -0
  18. package/dist/builders/types.d.ts +187 -0
  19. package/dist/builders/types.d.ts.map +1 -0
  20. package/dist/builders/types.js +12 -0
  21. package/dist/builders/types.js.map +1 -0
  22. package/dist/config/init.d.ts +5 -21
  23. package/dist/config/init.d.ts.map +1 -1
  24. package/dist/config/init.js +270 -182
  25. package/dist/config/init.js.map +1 -1
  26. package/dist/coordinator/coordinator.js +1 -1
  27. package/dist/coordinator/coordinator.js.map +1 -1
  28. package/dist/coordinator/index.js +1 -1
  29. package/dist/coordinator/index.js.map +1 -1
  30. package/dist/index.d.ts +3 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/runtime/otel-api.d.ts +38 -0
  35. package/dist/runtime/otel-api.d.ts.map +1 -0
  36. package/dist/runtime/otel-api.js +94 -0
  37. package/dist/runtime/otel-api.js.map +1 -0
  38. package/dist/runtime/otel-bridge.js +1 -1
  39. package/dist/runtime/otel-bridge.js.map +1 -1
  40. package/dist/runtime/otel.d.ts +1 -1
  41. package/dist/runtime/otel.d.ts.map +1 -1
  42. package/dist/runtime/otel.js +28 -12
  43. package/dist/runtime/otel.js.map +1 -1
  44. package/dist/runtime/squad-observer.js +1 -1
  45. package/dist/runtime/squad-observer.js.map +1 -1
  46. package/dist/sharing/consult.js +78 -78
  47. package/dist/streams/filter.d.ts +33 -0
  48. package/dist/streams/filter.d.ts.map +1 -0
  49. package/dist/streams/filter.js +29 -0
  50. package/dist/streams/filter.js.map +1 -0
  51. package/dist/streams/index.d.ts +9 -0
  52. package/dist/streams/index.d.ts.map +1 -0
  53. package/dist/streams/index.js +9 -0
  54. package/dist/streams/index.js.map +1 -0
  55. package/dist/streams/resolver.d.ts +40 -0
  56. package/dist/streams/resolver.d.ts.map +1 -0
  57. package/dist/streams/resolver.js +162 -0
  58. package/dist/streams/resolver.js.map +1 -0
  59. package/dist/streams/types.d.ts +44 -0
  60. package/dist/streams/types.d.ts.map +1 -0
  61. package/dist/streams/types.js +10 -0
  62. package/dist/streams/types.js.map +1 -0
  63. package/dist/tools/index.js +1 -1
  64. package/dist/tools/index.js.map +1 -1
  65. package/dist/types.d.ts +20 -0
  66. package/dist/types.d.ts.map +1 -1
  67. package/package.json +12 -11
  68. package/templates/casting-history.json +4 -4
  69. package/templates/casting-policy.json +35 -35
  70. package/templates/casting-registry.json +3 -3
  71. package/templates/ceremonies.md +41 -41
  72. package/templates/charter.md +53 -53
  73. package/templates/constraint-tracking.md +38 -38
  74. package/templates/copilot-instructions.md +46 -46
  75. package/templates/history.md +10 -10
  76. package/templates/identity/now.md +9 -9
  77. package/templates/identity/wisdom.md +15 -15
  78. package/templates/mcp-config.md +98 -98
  79. package/templates/multi-agent-format.md +28 -28
  80. package/templates/orchestration-log.md +27 -27
  81. package/templates/plugin-marketplace.md +49 -49
  82. package/templates/raw-agent-output.md +37 -37
  83. package/templates/roster.md +60 -60
  84. package/templates/routing.md +54 -54
  85. package/templates/run-output.md +50 -50
  86. package/templates/scribe-charter.md +119 -119
  87. package/templates/skill.md +24 -24
  88. package/templates/skills/project-conventions/SKILL.md +56 -56
  89. package/templates/squad.agent.md +1146 -1146
  90. package/templates/workflows/squad-ci.yml +24 -24
  91. package/templates/workflows/squad-docs.yml +50 -50
  92. package/templates/workflows/squad-heartbeat.yml +316 -316
  93. package/templates/workflows/squad-insider-release.yml +61 -61
  94. package/templates/workflows/squad-issue-assign.yml +161 -161
  95. package/templates/workflows/squad-label-enforce.yml +181 -181
  96. package/templates/workflows/squad-preview.yml +55 -55
  97. package/templates/workflows/squad-promote.yml +120 -120
  98. package/templates/workflows/squad-release.yml +77 -77
  99. package/templates/workflows/squad-triage.yml +260 -260
  100. package/templates/workflows/sync-squad-labels.yml +169 -169
  101. package/dist/runtime/event-bus-otel-bridge.d.ts +0 -19
  102. package/dist/runtime/event-bus-otel-bridge.d.ts.map +0 -1
  103. package/dist/runtime/event-bus-otel-bridge.js +0 -61
  104. package/dist/runtime/event-bus-otel-bridge.js.map +0 -1
  105. package/templates/workflows/squad-main-guard.yml +0 -129
@@ -1,260 +1,260 @@
1
- name: Squad Triage
2
-
3
- on:
4
- issues:
5
- types: [labeled]
6
-
7
- permissions:
8
- issues: write
9
- contents: read
10
-
11
- jobs:
12
- triage:
13
- if: github.event.label.name == 'squad'
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/checkout@v4
17
-
18
- - name: Triage issue via Lead agent
19
- uses: actions/github-script@v7
20
- with:
21
- script: |
22
- const fs = require('fs');
23
- const issue = context.payload.issue;
24
-
25
- // Read team roster — check .squad/ first, fall back to .ai-team/
26
- let teamFile = '.squad/team.md';
27
- if (!fs.existsSync(teamFile)) {
28
- teamFile = '.ai-team/team.md';
29
- }
30
- if (!fs.existsSync(teamFile)) {
31
- core.warning('No .squad/team.md or .ai-team/team.md found — cannot triage');
32
- return;
33
- }
34
-
35
- const content = fs.readFileSync(teamFile, 'utf8');
36
- const lines = content.split('\n');
37
-
38
- // Check if @copilot is on the team
39
- const hasCopilot = content.includes('🤖 Coding Agent');
40
- const copilotAutoAssign = content.includes('<!-- copilot-auto-assign: true -->');
41
-
42
- // Parse @copilot capability profile
43
- let goodFitKeywords = [];
44
- let needsReviewKeywords = [];
45
- let notSuitableKeywords = [];
46
-
47
- if (hasCopilot) {
48
- // Extract capability tiers from team.md
49
- const goodFitMatch = content.match(/🟢\s*Good fit[^:]*:\s*(.+)/i);
50
- const needsReviewMatch = content.match(/🟡\s*Needs review[^:]*:\s*(.+)/i);
51
- const notSuitableMatch = content.match(/🔴\s*Not suitable[^:]*:\s*(.+)/i);
52
-
53
- if (goodFitMatch) {
54
- goodFitKeywords = goodFitMatch[1].toLowerCase().split(',').map(s => s.trim());
55
- } else {
56
- goodFitKeywords = ['bug fix', 'test coverage', 'lint', 'format', 'dependency update', 'small feature', 'scaffolding', 'doc fix', 'documentation'];
57
- }
58
- if (needsReviewMatch) {
59
- needsReviewKeywords = needsReviewMatch[1].toLowerCase().split(',').map(s => s.trim());
60
- } else {
61
- needsReviewKeywords = ['medium feature', 'refactoring', 'api endpoint', 'migration'];
62
- }
63
- if (notSuitableMatch) {
64
- notSuitableKeywords = notSuitableMatch[1].toLowerCase().split(',').map(s => s.trim());
65
- } else {
66
- notSuitableKeywords = ['architecture', 'system design', 'security', 'auth', 'encryption', 'performance'];
67
- }
68
- }
69
-
70
- const members = [];
71
- let inMembersTable = false;
72
- for (const line of lines) {
73
- if (line.match(/^##\s+(Members|Team Roster)/i)) {
74
- inMembersTable = true;
75
- continue;
76
- }
77
- if (inMembersTable && line.startsWith('## ')) {
78
- break;
79
- }
80
- if (inMembersTable && line.startsWith('|') && !line.includes('---') && !line.includes('Name')) {
81
- const cells = line.split('|').map(c => c.trim()).filter(Boolean);
82
- if (cells.length >= 2 && cells[0] !== 'Scribe') {
83
- members.push({
84
- name: cells[0],
85
- role: cells[1]
86
- });
87
- }
88
- }
89
- }
90
-
91
- // Read routing rules — check .squad/ first, fall back to .ai-team/
92
- let routingFile = '.squad/routing.md';
93
- if (!fs.existsSync(routingFile)) {
94
- routingFile = '.ai-team/routing.md';
95
- }
96
- let routingContent = '';
97
- if (fs.existsSync(routingFile)) {
98
- routingContent = fs.readFileSync(routingFile, 'utf8');
99
- }
100
-
101
- // Find the Lead
102
- const lead = members.find(m =>
103
- m.role.toLowerCase().includes('lead') ||
104
- m.role.toLowerCase().includes('architect') ||
105
- m.role.toLowerCase().includes('coordinator')
106
- );
107
-
108
- if (!lead) {
109
- core.warning('No Lead role found in team roster — cannot triage');
110
- return;
111
- }
112
-
113
- // Build triage context
114
- const memberList = members.map(m =>
115
- `- **${m.name}** (${m.role}) → label: \`squad:${m.name.toLowerCase()}\``
116
- ).join('\n');
117
-
118
- // Determine best assignee based on issue content and routing
119
- const issueText = `${issue.title}\n${issue.body || ''}`.toLowerCase();
120
-
121
- let assignedMember = null;
122
- let triageReason = '';
123
- let copilotTier = null;
124
-
125
- // First, evaluate @copilot fit if enabled
126
- if (hasCopilot) {
127
- const isNotSuitable = notSuitableKeywords.some(kw => issueText.includes(kw));
128
- const isGoodFit = !isNotSuitable && goodFitKeywords.some(kw => issueText.includes(kw));
129
- const isNeedsReview = !isNotSuitable && !isGoodFit && needsReviewKeywords.some(kw => issueText.includes(kw));
130
-
131
- if (isGoodFit) {
132
- copilotTier = 'good-fit';
133
- assignedMember = { name: '@copilot', role: 'Coding Agent' };
134
- triageReason = '🟢 Good fit for @copilot — matches capability profile';
135
- } else if (isNeedsReview) {
136
- copilotTier = 'needs-review';
137
- assignedMember = { name: '@copilot', role: 'Coding Agent' };
138
- triageReason = '🟡 Routing to @copilot (needs review) — a squad member should review the PR';
139
- } else if (isNotSuitable) {
140
- copilotTier = 'not-suitable';
141
- // Fall through to normal routing
142
- }
143
- }
144
-
145
- // If not routed to @copilot, use keyword-based routing
146
- if (!assignedMember) {
147
- for (const member of members) {
148
- const role = member.role.toLowerCase();
149
- if ((role.includes('frontend') || role.includes('ui')) &&
150
- (issueText.includes('ui') || issueText.includes('frontend') ||
151
- issueText.includes('css') || issueText.includes('component') ||
152
- issueText.includes('button') || issueText.includes('page') ||
153
- issueText.includes('layout') || issueText.includes('design'))) {
154
- assignedMember = member;
155
- triageReason = 'Issue relates to frontend/UI work';
156
- break;
157
- }
158
- if ((role.includes('backend') || role.includes('api') || role.includes('server')) &&
159
- (issueText.includes('api') || issueText.includes('backend') ||
160
- issueText.includes('database') || issueText.includes('endpoint') ||
161
- issueText.includes('server') || issueText.includes('auth'))) {
162
- assignedMember = member;
163
- triageReason = 'Issue relates to backend/API work';
164
- break;
165
- }
166
- if ((role.includes('test') || role.includes('qa') || role.includes('quality')) &&
167
- (issueText.includes('test') || issueText.includes('bug') ||
168
- issueText.includes('fix') || issueText.includes('regression') ||
169
- issueText.includes('coverage'))) {
170
- assignedMember = member;
171
- triageReason = 'Issue relates to testing/quality work';
172
- break;
173
- }
174
- if ((role.includes('devops') || role.includes('infra') || role.includes('ops')) &&
175
- (issueText.includes('deploy') || issueText.includes('ci') ||
176
- issueText.includes('pipeline') || issueText.includes('docker') ||
177
- issueText.includes('infrastructure'))) {
178
- assignedMember = member;
179
- triageReason = 'Issue relates to DevOps/infrastructure work';
180
- break;
181
- }
182
- }
183
- }
184
-
185
- // Default to Lead if no routing match
186
- if (!assignedMember) {
187
- assignedMember = lead;
188
- triageReason = 'No specific domain match — assigned to Lead for further analysis';
189
- }
190
-
191
- const isCopilot = assignedMember.name === '@copilot';
192
- const assignLabel = isCopilot ? 'squad:copilot' : `squad:${assignedMember.name.toLowerCase()}`;
193
-
194
- // Add the member-specific label
195
- await github.rest.issues.addLabels({
196
- owner: context.repo.owner,
197
- repo: context.repo.repo,
198
- issue_number: issue.number,
199
- labels: [assignLabel]
200
- });
201
-
202
- // Apply default triage verdict
203
- await github.rest.issues.addLabels({
204
- owner: context.repo.owner,
205
- repo: context.repo.repo,
206
- issue_number: issue.number,
207
- labels: ['go:needs-research']
208
- });
209
-
210
- // Auto-assign @copilot if enabled
211
- if (isCopilot && copilotAutoAssign) {
212
- try {
213
- await github.rest.issues.addAssignees({
214
- owner: context.repo.owner,
215
- repo: context.repo.repo,
216
- issue_number: issue.number,
217
- assignees: ['copilot']
218
- });
219
- } catch (err) {
220
- core.warning(`Could not auto-assign @copilot: ${err.message}`);
221
- }
222
- }
223
-
224
- // Build copilot evaluation note
225
- let copilotNote = '';
226
- if (hasCopilot && !isCopilot) {
227
- if (copilotTier === 'not-suitable') {
228
- copilotNote = `\n\n**@copilot evaluation:** 🔴 Not suitable — issue involves work outside the coding agent's capability profile.`;
229
- } else {
230
- copilotNote = `\n\n**@copilot evaluation:** No strong capability match — routed to squad member.`;
231
- }
232
- }
233
-
234
- // Post triage comment
235
- const comment = [
236
- `### 🏗️ Squad Triage — ${lead.name} (${lead.role})`,
237
- '',
238
- `**Issue:** #${issue.number} — ${issue.title}`,
239
- `**Assigned to:** ${assignedMember.name} (${assignedMember.role})`,
240
- `**Reason:** ${triageReason}`,
241
- copilotTier === 'needs-review' ? `\n⚠️ **PR review recommended** — a squad member should review @copilot's work on this one.` : '',
242
- copilotNote,
243
- '',
244
- `---`,
245
- '',
246
- `**Team roster:**`,
247
- memberList,
248
- hasCopilot ? `- **@copilot** (Coding Agent) → label: \`squad:copilot\`` : '',
249
- '',
250
- `> To reassign, remove the current \`squad:*\` label and add the correct one.`,
251
- ].filter(Boolean).join('\n');
252
-
253
- await github.rest.issues.createComment({
254
- owner: context.repo.owner,
255
- repo: context.repo.repo,
256
- issue_number: issue.number,
257
- body: comment
258
- });
259
-
260
- core.info(`Triaged issue #${issue.number} → ${assignedMember.name} (${assignLabel})`);
1
+ name: Squad Triage
2
+
3
+ on:
4
+ issues:
5
+ types: [labeled]
6
+
7
+ permissions:
8
+ issues: write
9
+ contents: read
10
+
11
+ jobs:
12
+ triage:
13
+ if: github.event.label.name == 'squad'
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Triage issue via Lead agent
19
+ uses: actions/github-script@v7
20
+ with:
21
+ script: |
22
+ const fs = require('fs');
23
+ const issue = context.payload.issue;
24
+
25
+ // Read team roster — check .squad/ first, fall back to .ai-team/
26
+ let teamFile = '.squad/team.md';
27
+ if (!fs.existsSync(teamFile)) {
28
+ teamFile = '.ai-team/team.md';
29
+ }
30
+ if (!fs.existsSync(teamFile)) {
31
+ core.warning('No .squad/team.md or .ai-team/team.md found — cannot triage');
32
+ return;
33
+ }
34
+
35
+ const content = fs.readFileSync(teamFile, 'utf8');
36
+ const lines = content.split('\n');
37
+
38
+ // Check if @copilot is on the team
39
+ const hasCopilot = content.includes('🤖 Coding Agent');
40
+ const copilotAutoAssign = content.includes('<!-- copilot-auto-assign: true -->');
41
+
42
+ // Parse @copilot capability profile
43
+ let goodFitKeywords = [];
44
+ let needsReviewKeywords = [];
45
+ let notSuitableKeywords = [];
46
+
47
+ if (hasCopilot) {
48
+ // Extract capability tiers from team.md
49
+ const goodFitMatch = content.match(/🟢\s*Good fit[^:]*:\s*(.+)/i);
50
+ const needsReviewMatch = content.match(/🟡\s*Needs review[^:]*:\s*(.+)/i);
51
+ const notSuitableMatch = content.match(/🔴\s*Not suitable[^:]*:\s*(.+)/i);
52
+
53
+ if (goodFitMatch) {
54
+ goodFitKeywords = goodFitMatch[1].toLowerCase().split(',').map(s => s.trim());
55
+ } else {
56
+ goodFitKeywords = ['bug fix', 'test coverage', 'lint', 'format', 'dependency update', 'small feature', 'scaffolding', 'doc fix', 'documentation'];
57
+ }
58
+ if (needsReviewMatch) {
59
+ needsReviewKeywords = needsReviewMatch[1].toLowerCase().split(',').map(s => s.trim());
60
+ } else {
61
+ needsReviewKeywords = ['medium feature', 'refactoring', 'api endpoint', 'migration'];
62
+ }
63
+ if (notSuitableMatch) {
64
+ notSuitableKeywords = notSuitableMatch[1].toLowerCase().split(',').map(s => s.trim());
65
+ } else {
66
+ notSuitableKeywords = ['architecture', 'system design', 'security', 'auth', 'encryption', 'performance'];
67
+ }
68
+ }
69
+
70
+ const members = [];
71
+ let inMembersTable = false;
72
+ for (const line of lines) {
73
+ if (line.match(/^##\s+(Members|Team Roster)/i)) {
74
+ inMembersTable = true;
75
+ continue;
76
+ }
77
+ if (inMembersTable && line.startsWith('## ')) {
78
+ break;
79
+ }
80
+ if (inMembersTable && line.startsWith('|') && !line.includes('---') && !line.includes('Name')) {
81
+ const cells = line.split('|').map(c => c.trim()).filter(Boolean);
82
+ if (cells.length >= 2 && cells[0] !== 'Scribe') {
83
+ members.push({
84
+ name: cells[0],
85
+ role: cells[1]
86
+ });
87
+ }
88
+ }
89
+ }
90
+
91
+ // Read routing rules — check .squad/ first, fall back to .ai-team/
92
+ let routingFile = '.squad/routing.md';
93
+ if (!fs.existsSync(routingFile)) {
94
+ routingFile = '.ai-team/routing.md';
95
+ }
96
+ let routingContent = '';
97
+ if (fs.existsSync(routingFile)) {
98
+ routingContent = fs.readFileSync(routingFile, 'utf8');
99
+ }
100
+
101
+ // Find the Lead
102
+ const lead = members.find(m =>
103
+ m.role.toLowerCase().includes('lead') ||
104
+ m.role.toLowerCase().includes('architect') ||
105
+ m.role.toLowerCase().includes('coordinator')
106
+ );
107
+
108
+ if (!lead) {
109
+ core.warning('No Lead role found in team roster — cannot triage');
110
+ return;
111
+ }
112
+
113
+ // Build triage context
114
+ const memberList = members.map(m =>
115
+ `- **${m.name}** (${m.role}) → label: \`squad:${m.name.toLowerCase()}\``
116
+ ).join('\n');
117
+
118
+ // Determine best assignee based on issue content and routing
119
+ const issueText = `${issue.title}\n${issue.body || ''}`.toLowerCase();
120
+
121
+ let assignedMember = null;
122
+ let triageReason = '';
123
+ let copilotTier = null;
124
+
125
+ // First, evaluate @copilot fit if enabled
126
+ if (hasCopilot) {
127
+ const isNotSuitable = notSuitableKeywords.some(kw => issueText.includes(kw));
128
+ const isGoodFit = !isNotSuitable && goodFitKeywords.some(kw => issueText.includes(kw));
129
+ const isNeedsReview = !isNotSuitable && !isGoodFit && needsReviewKeywords.some(kw => issueText.includes(kw));
130
+
131
+ if (isGoodFit) {
132
+ copilotTier = 'good-fit';
133
+ assignedMember = { name: '@copilot', role: 'Coding Agent' };
134
+ triageReason = '🟢 Good fit for @copilot — matches capability profile';
135
+ } else if (isNeedsReview) {
136
+ copilotTier = 'needs-review';
137
+ assignedMember = { name: '@copilot', role: 'Coding Agent' };
138
+ triageReason = '🟡 Routing to @copilot (needs review) — a squad member should review the PR';
139
+ } else if (isNotSuitable) {
140
+ copilotTier = 'not-suitable';
141
+ // Fall through to normal routing
142
+ }
143
+ }
144
+
145
+ // If not routed to @copilot, use keyword-based routing
146
+ if (!assignedMember) {
147
+ for (const member of members) {
148
+ const role = member.role.toLowerCase();
149
+ if ((role.includes('frontend') || role.includes('ui')) &&
150
+ (issueText.includes('ui') || issueText.includes('frontend') ||
151
+ issueText.includes('css') || issueText.includes('component') ||
152
+ issueText.includes('button') || issueText.includes('page') ||
153
+ issueText.includes('layout') || issueText.includes('design'))) {
154
+ assignedMember = member;
155
+ triageReason = 'Issue relates to frontend/UI work';
156
+ break;
157
+ }
158
+ if ((role.includes('backend') || role.includes('api') || role.includes('server')) &&
159
+ (issueText.includes('api') || issueText.includes('backend') ||
160
+ issueText.includes('database') || issueText.includes('endpoint') ||
161
+ issueText.includes('server') || issueText.includes('auth'))) {
162
+ assignedMember = member;
163
+ triageReason = 'Issue relates to backend/API work';
164
+ break;
165
+ }
166
+ if ((role.includes('test') || role.includes('qa') || role.includes('quality')) &&
167
+ (issueText.includes('test') || issueText.includes('bug') ||
168
+ issueText.includes('fix') || issueText.includes('regression') ||
169
+ issueText.includes('coverage'))) {
170
+ assignedMember = member;
171
+ triageReason = 'Issue relates to testing/quality work';
172
+ break;
173
+ }
174
+ if ((role.includes('devops') || role.includes('infra') || role.includes('ops')) &&
175
+ (issueText.includes('deploy') || issueText.includes('ci') ||
176
+ issueText.includes('pipeline') || issueText.includes('docker') ||
177
+ issueText.includes('infrastructure'))) {
178
+ assignedMember = member;
179
+ triageReason = 'Issue relates to DevOps/infrastructure work';
180
+ break;
181
+ }
182
+ }
183
+ }
184
+
185
+ // Default to Lead if no routing match
186
+ if (!assignedMember) {
187
+ assignedMember = lead;
188
+ triageReason = 'No specific domain match — assigned to Lead for further analysis';
189
+ }
190
+
191
+ const isCopilot = assignedMember.name === '@copilot';
192
+ const assignLabel = isCopilot ? 'squad:copilot' : `squad:${assignedMember.name.toLowerCase()}`;
193
+
194
+ // Add the member-specific label
195
+ await github.rest.issues.addLabels({
196
+ owner: context.repo.owner,
197
+ repo: context.repo.repo,
198
+ issue_number: issue.number,
199
+ labels: [assignLabel]
200
+ });
201
+
202
+ // Apply default triage verdict
203
+ await github.rest.issues.addLabels({
204
+ owner: context.repo.owner,
205
+ repo: context.repo.repo,
206
+ issue_number: issue.number,
207
+ labels: ['go:needs-research']
208
+ });
209
+
210
+ // Auto-assign @copilot if enabled
211
+ if (isCopilot && copilotAutoAssign) {
212
+ try {
213
+ await github.rest.issues.addAssignees({
214
+ owner: context.repo.owner,
215
+ repo: context.repo.repo,
216
+ issue_number: issue.number,
217
+ assignees: ['copilot']
218
+ });
219
+ } catch (err) {
220
+ core.warning(`Could not auto-assign @copilot: ${err.message}`);
221
+ }
222
+ }
223
+
224
+ // Build copilot evaluation note
225
+ let copilotNote = '';
226
+ if (hasCopilot && !isCopilot) {
227
+ if (copilotTier === 'not-suitable') {
228
+ copilotNote = `\n\n**@copilot evaluation:** 🔴 Not suitable — issue involves work outside the coding agent's capability profile.`;
229
+ } else {
230
+ copilotNote = `\n\n**@copilot evaluation:** No strong capability match — routed to squad member.`;
231
+ }
232
+ }
233
+
234
+ // Post triage comment
235
+ const comment = [
236
+ `### 🏗️ Squad Triage — ${lead.name} (${lead.role})`,
237
+ '',
238
+ `**Issue:** #${issue.number} — ${issue.title}`,
239
+ `**Assigned to:** ${assignedMember.name} (${assignedMember.role})`,
240
+ `**Reason:** ${triageReason}`,
241
+ copilotTier === 'needs-review' ? `\n⚠️ **PR review recommended** — a squad member should review @copilot's work on this one.` : '',
242
+ copilotNote,
243
+ '',
244
+ `---`,
245
+ '',
246
+ `**Team roster:**`,
247
+ memberList,
248
+ hasCopilot ? `- **@copilot** (Coding Agent) → label: \`squad:copilot\`` : '',
249
+ '',
250
+ `> To reassign, remove the current \`squad:*\` label and add the correct one.`,
251
+ ].filter(Boolean).join('\n');
252
+
253
+ await github.rest.issues.createComment({
254
+ owner: context.repo.owner,
255
+ repo: context.repo.repo,
256
+ issue_number: issue.number,
257
+ body: comment
258
+ });
259
+
260
+ core.info(`Triaged issue #${issue.number} → ${assignedMember.name} (${assignLabel})`);