@bradygaster/squad-cli 0.7.0 → 0.8.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.
- package/README.md +77 -77
- package/dist/cli/commands/copilot.d.ts +13 -0
- package/dist/cli/commands/copilot.d.ts.map +1 -0
- package/dist/cli/commands/copilot.js +86 -0
- package/dist/cli/commands/copilot.js.map +1 -0
- package/dist/cli/commands/export.d.ts +9 -0
- package/dist/cli/commands/export.d.ts.map +1 -0
- package/dist/cli/commands/export.js +89 -0
- package/dist/cli/commands/export.js.map +1 -0
- package/dist/cli/commands/import.d.ts +9 -0
- package/dist/cli/commands/import.d.ts.map +1 -0
- package/dist/cli/commands/import.js +116 -0
- package/dist/cli/commands/import.js.map +1 -0
- package/dist/cli/commands/plugin.d.ts +14 -0
- package/dist/cli/commands/plugin.d.ts.map +1 -0
- package/dist/cli/commands/plugin.js +134 -0
- package/dist/cli/commands/plugin.js.map +1 -0
- package/dist/cli/commands/watch.d.ts +8 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/commands/watch.js +178 -0
- package/dist/cli/commands/watch.js.map +1 -0
- package/dist/cli/copilot-install.d.ts +73 -0
- package/dist/cli/copilot-install.d.ts.map +1 -0
- package/dist/cli/copilot-install.js +117 -0
- package/dist/cli/copilot-install.js.map +1 -0
- package/dist/cli/core/detect-squad-dir.d.ts +13 -0
- package/dist/cli/core/detect-squad-dir.d.ts.map +1 -0
- package/dist/cli/core/detect-squad-dir.js +21 -0
- package/dist/cli/core/detect-squad-dir.js.map +1 -0
- package/dist/cli/core/email-scrub.d.ts +10 -0
- package/dist/cli/core/email-scrub.d.ts.map +1 -0
- package/dist/cli/core/email-scrub.js +103 -0
- package/dist/cli/core/email-scrub.js.map +1 -0
- package/dist/cli/core/errors.d.ts +17 -0
- package/dist/cli/core/errors.d.ts.map +1 -0
- package/dist/cli/core/errors.js +22 -0
- package/dist/cli/core/errors.js.map +1 -0
- package/dist/cli/core/gh-cli.d.ts +41 -0
- package/dist/cli/core/gh-cli.d.ts.map +1 -0
- package/dist/cli/core/gh-cli.js +67 -0
- package/dist/cli/core/gh-cli.js.map +1 -0
- package/dist/cli/core/history-split.d.ts +9 -0
- package/dist/cli/core/history-split.d.ts.map +1 -0
- package/dist/cli/core/history-split.js +65 -0
- package/dist/cli/core/history-split.js.map +1 -0
- package/dist/cli/core/init.d.ts +9 -0
- package/dist/cli/core/init.d.ts.map +1 -0
- package/dist/cli/core/init.js +296 -0
- package/dist/cli/core/init.js.map +1 -0
- package/dist/cli/core/migrate-directory.d.ts +11 -0
- package/dist/cli/core/migrate-directory.d.ts.map +1 -0
- package/dist/cli/core/migrate-directory.js +71 -0
- package/dist/cli/core/migrate-directory.js.map +1 -0
- package/dist/cli/core/migrations.d.ts +11 -0
- package/dist/cli/core/migrations.d.ts.map +1 -0
- package/dist/cli/core/migrations.js +78 -0
- package/dist/cli/core/migrations.js.map +1 -0
- package/dist/cli/core/output.d.ts +34 -0
- package/dist/cli/core/output.d.ts.map +1 -0
- package/dist/cli/core/output.js +47 -0
- package/dist/cli/core/output.js.map +1 -0
- package/dist/cli/core/project-type.d.ts +9 -0
- package/dist/cli/core/project-type.d.ts.map +1 -0
- package/dist/cli/core/project-type.js +29 -0
- package/dist/cli/core/project-type.js.map +1 -0
- package/dist/cli/core/team-md.d.ts +28 -0
- package/dist/cli/core/team-md.d.ts.map +1 -0
- package/dist/cli/core/team-md.js +91 -0
- package/dist/cli/core/team-md.js.map +1 -0
- package/dist/cli/core/templates.d.ts +30 -0
- package/dist/cli/core/templates.d.ts.map +1 -0
- package/dist/cli/core/templates.js +247 -0
- package/dist/cli/core/templates.js.map +1 -0
- package/dist/cli/core/upgrade.d.ts +20 -0
- package/dist/cli/core/upgrade.d.ts.map +1 -0
- package/dist/cli/core/upgrade.js +399 -0
- package/dist/cli/core/upgrade.js.map +1 -0
- package/dist/cli/core/version.d.ts +18 -0
- package/dist/cli/core/version.d.ts.map +1 -0
- package/dist/cli/core/version.js +61 -0
- package/dist/cli/core/version.js.map +1 -0
- package/dist/cli/core/workflows.d.ts +10 -0
- package/dist/cli/core/workflows.d.ts.map +1 -0
- package/dist/cli/core/workflows.js +155 -0
- package/dist/cli/core/workflows.js.map +1 -0
- package/dist/cli/index.d.ts +26 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +26 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/shell/autocomplete.d.ts +12 -0
- package/dist/cli/shell/autocomplete.d.ts.map +1 -0
- package/dist/cli/shell/autocomplete.js +39 -0
- package/dist/cli/shell/autocomplete.js.map +1 -0
- package/dist/cli/shell/commands.d.ts +19 -0
- package/dist/cli/shell/commands.d.ts.map +1 -0
- package/dist/cli/shell/commands.js +87 -0
- package/dist/cli/shell/commands.js.map +1 -0
- package/dist/cli/shell/components/AgentPanel.d.ts +8 -0
- package/dist/cli/shell/components/AgentPanel.d.ts.map +1 -0
- package/dist/cli/shell/components/AgentPanel.js +17 -0
- package/dist/cli/shell/components/AgentPanel.js.map +1 -0
- package/dist/cli/shell/components/InputPrompt.d.ts +9 -0
- package/dist/cli/shell/components/InputPrompt.d.ts.map +1 -0
- package/dist/cli/shell/components/InputPrompt.js +50 -0
- package/dist/cli/shell/components/InputPrompt.js.map +1 -0
- package/dist/cli/shell/components/MessageStream.d.ts +13 -0
- package/dist/cli/shell/components/MessageStream.d.ts.map +1 -0
- package/dist/cli/shell/components/MessageStream.js +7 -0
- package/dist/cli/shell/components/MessageStream.js.map +1 -0
- package/dist/cli/shell/components/index.d.ts +4 -0
- package/dist/cli/shell/components/index.d.ts.map +1 -0
- package/dist/cli/shell/components/index.js +4 -0
- package/dist/cli/shell/components/index.js.map +1 -0
- package/dist/cli/shell/coordinator.d.ts +32 -0
- package/dist/cli/shell/coordinator.d.ts.map +1 -0
- package/dist/cli/shell/coordinator.js +113 -0
- package/dist/cli/shell/coordinator.js.map +1 -0
- package/dist/cli/shell/index.d.ts +28 -0
- package/dist/cli/shell/index.d.ts.map +1 -0
- package/dist/cli/shell/index.js +66 -0
- package/dist/cli/shell/index.js.map +1 -0
- package/dist/cli/shell/lifecycle.d.ts +52 -0
- package/dist/cli/shell/lifecycle.d.ts.map +1 -0
- package/dist/cli/shell/lifecycle.js +168 -0
- package/dist/cli/shell/lifecycle.js.map +1 -0
- package/dist/cli/shell/memory.d.ts +36 -0
- package/dist/cli/shell/memory.d.ts.map +1 -0
- package/dist/cli/shell/memory.js +53 -0
- package/dist/cli/shell/memory.js.map +1 -0
- package/dist/cli/shell/render.d.ts +22 -0
- package/dist/cli/shell/render.d.ts.map +1 -0
- package/dist/cli/shell/render.js +44 -0
- package/dist/cli/shell/render.js.map +1 -0
- package/dist/cli/shell/router.d.ts +17 -0
- package/dist/cli/shell/router.d.ts.map +1 -0
- package/dist/cli/shell/router.js +55 -0
- package/dist/cli/shell/router.js.map +1 -0
- package/dist/cli/shell/sessions.d.ts +15 -0
- package/dist/cli/shell/sessions.d.ts.map +1 -0
- package/dist/cli/shell/sessions.js +37 -0
- package/dist/cli/shell/sessions.js.map +1 -0
- package/dist/cli/shell/spawn.d.ts +47 -0
- package/dist/cli/shell/spawn.d.ts.map +1 -0
- package/dist/cli/shell/spawn.js +77 -0
- package/dist/cli/shell/spawn.js.map +1 -0
- package/dist/cli/shell/stream-bridge.d.ts +60 -0
- package/dist/cli/shell/stream-bridge.d.ts.map +1 -0
- package/dist/cli/shell/stream-bridge.js +98 -0
- package/dist/cli/shell/stream-bridge.js.map +1 -0
- package/dist/cli/shell/terminal.d.ts +30 -0
- package/dist/cli/shell/terminal.d.ts.map +1 -0
- package/dist/cli/shell/terminal.js +34 -0
- package/dist/cli/shell/terminal.js.map +1 -0
- package/dist/cli/shell/types.d.ts +21 -0
- package/dist/cli/shell/types.d.ts.map +1 -0
- package/dist/cli/shell/types.js +5 -0
- package/dist/cli/shell/types.js.map +1 -0
- package/dist/cli/upgrade.d.ts +141 -0
- package/dist/cli/upgrade.d.ts.map +1 -0
- package/dist/cli/upgrade.js +226 -0
- package/dist/cli/upgrade.js.map +1 -0
- package/dist/cli-entry.d.ts +10 -0
- package/dist/cli-entry.d.ts.map +1 -0
- package/dist/cli-entry.js +213 -0
- package/dist/cli-entry.js.map +1 -0
- package/dist/cli.js +2 -2
- package/package.json +45 -34
- package/templates/casting-history.json +4 -0
- package/templates/casting-policy.json +35 -0
- package/templates/casting-registry.json +3 -0
- package/templates/ceremonies.md +41 -0
- package/templates/charter.md +53 -0
- package/templates/constraint-tracking.md +38 -0
- package/templates/copilot-instructions.md +46 -0
- package/templates/history.md +10 -0
- package/templates/identity/now.md +9 -0
- package/templates/identity/wisdom.md +15 -0
- package/templates/mcp-config.md +90 -0
- package/templates/multi-agent-format.md +28 -0
- package/templates/orchestration-log.md +27 -0
- package/templates/plugin-marketplace.md +49 -0
- package/templates/raw-agent-output.md +37 -0
- package/templates/roster.md +60 -0
- package/templates/routing.md +54 -0
- package/templates/run-output.md +50 -0
- package/templates/scribe-charter.md +119 -0
- package/templates/skill.md +24 -0
- package/templates/skills/squad-conventions/SKILL.md +69 -0
- package/templates/squad.agent.md +1146 -0
- package/templates/workflows/squad-ci.yml +24 -0
- package/templates/workflows/squad-docs.yml +50 -0
- package/templates/workflows/squad-heartbeat.yml +315 -0
- package/templates/workflows/squad-insider-release.yml +61 -0
- package/templates/workflows/squad-issue-assign.yml +161 -0
- package/templates/workflows/squad-label-enforce.yml +181 -0
- package/templates/workflows/squad-main-guard.yml +129 -0
- package/templates/workflows/squad-preview.yml +55 -0
- package/templates/workflows/squad-promote.yml +121 -0
- package/templates/workflows/squad-release.yml +77 -0
- package/templates/workflows/squad-triage.yml +260 -0
- package/templates/workflows/sync-squad-labels.yml +169 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template system types and manifest for Squad initialization.
|
|
3
|
+
* @module cli/core/templates
|
|
4
|
+
*/
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { dirname, join } from 'node:path';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
8
|
+
/**
|
|
9
|
+
* Template manifest — all files that init copies.
|
|
10
|
+
*
|
|
11
|
+
* Categorization:
|
|
12
|
+
* - Squad-owned (overwriteOnUpgrade: true): squad.agent.md, workflows, template files, casting data
|
|
13
|
+
* - User-owned (overwriteOnUpgrade: false): team.md, routing.md, decisions.md, ceremonies.md, agent history/identity
|
|
14
|
+
*/
|
|
15
|
+
export const TEMPLATE_MANIFEST = [
|
|
16
|
+
// Core coordinator
|
|
17
|
+
{
|
|
18
|
+
source: 'squad.agent.md',
|
|
19
|
+
destination: '../.github/agents/squad.agent.md',
|
|
20
|
+
overwriteOnUpgrade: true,
|
|
21
|
+
description: 'Squad coordinator agent prompt',
|
|
22
|
+
},
|
|
23
|
+
// Casting system (squad-owned, overwrite on upgrade)
|
|
24
|
+
{
|
|
25
|
+
source: 'casting-history.json',
|
|
26
|
+
destination: 'casting-history.json',
|
|
27
|
+
overwriteOnUpgrade: true,
|
|
28
|
+
description: 'Casting history tracking',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
source: 'casting-policy.json',
|
|
32
|
+
destination: 'casting-policy.json',
|
|
33
|
+
overwriteOnUpgrade: true,
|
|
34
|
+
description: 'Casting policy configuration',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
source: 'casting-registry.json',
|
|
38
|
+
destination: 'casting-registry.json',
|
|
39
|
+
overwriteOnUpgrade: true,
|
|
40
|
+
description: 'Universe-based character registry',
|
|
41
|
+
},
|
|
42
|
+
// Template files (squad-owned, overwrite on upgrade)
|
|
43
|
+
{
|
|
44
|
+
source: 'charter.md',
|
|
45
|
+
destination: 'charter.md',
|
|
46
|
+
overwriteOnUpgrade: true,
|
|
47
|
+
description: 'Agent charter template',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
source: 'constraint-tracking.md',
|
|
51
|
+
destination: 'constraint-tracking.md',
|
|
52
|
+
overwriteOnUpgrade: true,
|
|
53
|
+
description: 'Constraint tracking template',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
source: 'copilot-instructions.md',
|
|
57
|
+
destination: 'copilot-instructions.md',
|
|
58
|
+
overwriteOnUpgrade: true,
|
|
59
|
+
description: 'Copilot instructions template',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
source: 'history.md',
|
|
63
|
+
destination: 'history.md',
|
|
64
|
+
overwriteOnUpgrade: true,
|
|
65
|
+
description: 'Agent history template',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
source: 'mcp-config.md',
|
|
69
|
+
destination: 'mcp-config.md',
|
|
70
|
+
overwriteOnUpgrade: true,
|
|
71
|
+
description: 'MCP configuration template',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
source: 'multi-agent-format.md',
|
|
75
|
+
destination: 'multi-agent-format.md',
|
|
76
|
+
overwriteOnUpgrade: true,
|
|
77
|
+
description: 'Multi-agent format specification',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
source: 'orchestration-log.md',
|
|
81
|
+
destination: 'orchestration-log.md',
|
|
82
|
+
overwriteOnUpgrade: true,
|
|
83
|
+
description: 'Orchestration log template',
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
source: 'plugin-marketplace.md',
|
|
87
|
+
destination: 'plugin-marketplace.md',
|
|
88
|
+
overwriteOnUpgrade: true,
|
|
89
|
+
description: 'Plugin marketplace template',
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
source: 'raw-agent-output.md',
|
|
93
|
+
destination: 'raw-agent-output.md',
|
|
94
|
+
overwriteOnUpgrade: true,
|
|
95
|
+
description: 'Raw agent output template',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
source: 'roster.md',
|
|
99
|
+
destination: 'roster.md',
|
|
100
|
+
overwriteOnUpgrade: true,
|
|
101
|
+
description: 'Team roster template',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
source: 'run-output.md',
|
|
105
|
+
destination: 'run-output.md',
|
|
106
|
+
overwriteOnUpgrade: true,
|
|
107
|
+
description: 'Run output template',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
source: 'scribe-charter.md',
|
|
111
|
+
destination: 'scribe-charter.md',
|
|
112
|
+
overwriteOnUpgrade: true,
|
|
113
|
+
description: 'Scribe charter template',
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
source: 'skill.md',
|
|
117
|
+
destination: 'skill.md',
|
|
118
|
+
overwriteOnUpgrade: true,
|
|
119
|
+
description: 'Skill definition template',
|
|
120
|
+
},
|
|
121
|
+
// User-owned files (never overwrite)
|
|
122
|
+
{
|
|
123
|
+
source: 'ceremonies.md',
|
|
124
|
+
destination: 'ceremonies.md',
|
|
125
|
+
overwriteOnUpgrade: false,
|
|
126
|
+
description: 'Team ceremonies configuration',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
source: 'routing.md',
|
|
130
|
+
destination: 'routing.md',
|
|
131
|
+
overwriteOnUpgrade: false,
|
|
132
|
+
description: 'Agent routing rules',
|
|
133
|
+
},
|
|
134
|
+
// Identity subdirectory (user-owned)
|
|
135
|
+
{
|
|
136
|
+
source: 'identity/now.md',
|
|
137
|
+
destination: 'identity/now.md',
|
|
138
|
+
overwriteOnUpgrade: false,
|
|
139
|
+
description: 'Agent current focus',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
source: 'identity/wisdom.md',
|
|
143
|
+
destination: 'identity/wisdom.md',
|
|
144
|
+
overwriteOnUpgrade: false,
|
|
145
|
+
description: 'Agent accumulated wisdom',
|
|
146
|
+
},
|
|
147
|
+
// Skills subdirectory (squad-owned)
|
|
148
|
+
{
|
|
149
|
+
source: 'skills/squad-conventions/SKILL.md',
|
|
150
|
+
destination: 'skills/squad-conventions/SKILL.md',
|
|
151
|
+
overwriteOnUpgrade: true,
|
|
152
|
+
description: 'Squad conventions skill definition',
|
|
153
|
+
},
|
|
154
|
+
// Workflows (squad-owned, overwrite on upgrade)
|
|
155
|
+
{
|
|
156
|
+
source: 'workflows/squad-ci.yml',
|
|
157
|
+
destination: '../.github/workflows/squad-ci.yml',
|
|
158
|
+
overwriteOnUpgrade: true,
|
|
159
|
+
description: 'Squad CI workflow',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
source: 'workflows/squad-docs.yml',
|
|
163
|
+
destination: '../.github/workflows/squad-docs.yml',
|
|
164
|
+
overwriteOnUpgrade: true,
|
|
165
|
+
description: 'Squad docs workflow',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
source: 'workflows/squad-heartbeat.yml',
|
|
169
|
+
destination: '../.github/workflows/squad-heartbeat.yml',
|
|
170
|
+
overwriteOnUpgrade: true,
|
|
171
|
+
description: 'Squad heartbeat workflow',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
source: 'workflows/squad-insider-release.yml',
|
|
175
|
+
destination: '../.github/workflows/squad-insider-release.yml',
|
|
176
|
+
overwriteOnUpgrade: true,
|
|
177
|
+
description: 'Squad insider release workflow',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
source: 'workflows/squad-issue-assign.yml',
|
|
181
|
+
destination: '../.github/workflows/squad-issue-assign.yml',
|
|
182
|
+
overwriteOnUpgrade: true,
|
|
183
|
+
description: 'Squad issue auto-assignment workflow',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
source: 'workflows/squad-label-enforce.yml',
|
|
187
|
+
destination: '../.github/workflows/squad-label-enforce.yml',
|
|
188
|
+
overwriteOnUpgrade: true,
|
|
189
|
+
description: 'Squad label enforcement workflow',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
source: 'workflows/squad-main-guard.yml',
|
|
193
|
+
destination: '../.github/workflows/squad-main-guard.yml',
|
|
194
|
+
overwriteOnUpgrade: true,
|
|
195
|
+
description: 'Squad main branch protection workflow',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
source: 'workflows/squad-preview.yml',
|
|
199
|
+
destination: '../.github/workflows/squad-preview.yml',
|
|
200
|
+
overwriteOnUpgrade: true,
|
|
201
|
+
description: 'Squad preview workflow',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
source: 'workflows/squad-promote.yml',
|
|
205
|
+
destination: '../.github/workflows/squad-promote.yml',
|
|
206
|
+
overwriteOnUpgrade: true,
|
|
207
|
+
description: 'Squad promotion workflow',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
source: 'workflows/squad-release.yml',
|
|
211
|
+
destination: '../.github/workflows/squad-release.yml',
|
|
212
|
+
overwriteOnUpgrade: true,
|
|
213
|
+
description: 'Squad release workflow',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
source: 'workflows/squad-triage.yml',
|
|
217
|
+
destination: '../.github/workflows/squad-triage.yml',
|
|
218
|
+
overwriteOnUpgrade: true,
|
|
219
|
+
description: 'Squad issue triage workflow',
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
source: 'workflows/sync-squad-labels.yml',
|
|
223
|
+
destination: '../.github/workflows/sync-squad-labels.yml',
|
|
224
|
+
overwriteOnUpgrade: true,
|
|
225
|
+
description: 'Squad label sync workflow',
|
|
226
|
+
},
|
|
227
|
+
];
|
|
228
|
+
/**
|
|
229
|
+
* Get the templates directory path.
|
|
230
|
+
* Walks up from the current file to find templates/ — works both
|
|
231
|
+
* from compiled dist/cli/core/templates.js and from a bundled cli.js at the root.
|
|
232
|
+
*/
|
|
233
|
+
export function getTemplatesDir() {
|
|
234
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
235
|
+
let dir = dirname(currentFile);
|
|
236
|
+
for (let i = 0; i < 6; i++) {
|
|
237
|
+
const candidate = join(dir, 'templates');
|
|
238
|
+
if (existsSync(candidate))
|
|
239
|
+
return candidate;
|
|
240
|
+
const parent = dirname(dir);
|
|
241
|
+
if (parent === dir)
|
|
242
|
+
break;
|
|
243
|
+
dir = parent;
|
|
244
|
+
}
|
|
245
|
+
throw new Error('Templates directory not found — installation may be corrupted');
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../../src/cli/core/templates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAcrC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAmB;IAC/C,mBAAmB;IACnB;QACE,MAAM,EAAE,gBAAgB;QACxB,WAAW,EAAE,kCAAkC;QAC/C,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,gCAAgC;KAC9C;IAED,qDAAqD;IACrD;QACE,MAAM,EAAE,sBAAsB;QAC9B,WAAW,EAAE,sBAAsB;QACnC,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,0BAA0B;KACxC;IACD;QACE,MAAM,EAAE,qBAAqB;QAC7B,WAAW,EAAE,qBAAqB;QAClC,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,8BAA8B;KAC5C;IACD;QACE,MAAM,EAAE,uBAAuB;QAC/B,WAAW,EAAE,uBAAuB;QACpC,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,mCAAmC;KACjD;IAED,qDAAqD;IACrD;QACE,MAAM,EAAE,YAAY;QACpB,WAAW,EAAE,YAAY;QACzB,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,wBAAwB;KACtC;IACD;QACE,MAAM,EAAE,wBAAwB;QAChC,WAAW,EAAE,wBAAwB;QACrC,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,8BAA8B;KAC5C;IACD;QACE,MAAM,EAAE,yBAAyB;QACjC,WAAW,EAAE,yBAAyB;Q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AI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Squad upgrade command — overwrites squad-owned files, runs migrations
|
|
3
|
+
* Zero-dep implementation using Node.js stdlib only
|
|
4
|
+
* @module cli/core/upgrade
|
|
5
|
+
*/
|
|
6
|
+
export interface UpgradeOptions {
|
|
7
|
+
migrateDirectory?: boolean;
|
|
8
|
+
self?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface UpdateInfo {
|
|
11
|
+
fromVersion: string;
|
|
12
|
+
toVersion: string;
|
|
13
|
+
filesUpdated: string[];
|
|
14
|
+
migrationsRun: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Run the upgrade command
|
|
18
|
+
*/
|
|
19
|
+
export declare function runUpgrade(dest: string, options?: UpgradeOptions): Promise<UpdateInfo>;
|
|
20
|
+
//# sourceMappingURL=upgrade.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../../src/cli/core/upgrade.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgBH,MAAM,WAAW,cAAc;IAC7B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB;AAiRD;;GAEG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAoJhG"}
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Squad upgrade command — overwrites squad-owned files, runs migrations
|
|
3
|
+
* Zero-dep implementation using Node.js stdlib only
|
|
4
|
+
* @module cli/core/upgrade
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { dirname } from 'node:path';
|
|
10
|
+
import { success, warn, info, dim } from './output.js';
|
|
11
|
+
import { fatal } from './errors.js';
|
|
12
|
+
import { detectSquadDir } from './detect-squad-dir.js';
|
|
13
|
+
import { TEMPLATE_MANIFEST, getTemplatesDir } from './templates.js';
|
|
14
|
+
import { runMigrations } from './migrations.js';
|
|
15
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
16
|
+
const currentDir = dirname(currentFile);
|
|
17
|
+
/**
|
|
18
|
+
* Read version from squad.agent.md HTML comment
|
|
19
|
+
*/
|
|
20
|
+
function readInstalledVersion(agentPath) {
|
|
21
|
+
try {
|
|
22
|
+
if (!fs.existsSync(agentPath))
|
|
23
|
+
return '0.0.0';
|
|
24
|
+
const content = fs.readFileSync(agentPath, 'utf8');
|
|
25
|
+
// Try HTML comment first (new format)
|
|
26
|
+
const commentMatch = content.match(/<!-- version: ([0-9.]+(?:-[a-z]+(?:\.\d+)?)?) -->/);
|
|
27
|
+
if (commentMatch)
|
|
28
|
+
return commentMatch[1];
|
|
29
|
+
// Fallback to frontmatter (old format)
|
|
30
|
+
const frontmatterMatch = content.match(/^version:\s*"([^"]+)"/m);
|
|
31
|
+
return frontmatterMatch ? frontmatterMatch[1] : '0.0.0';
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return '0.0.0';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Compare semver strings: -1 (a<b), 0 (a==b), 1 (a>b)
|
|
39
|
+
*/
|
|
40
|
+
function compareSemver(a, b) {
|
|
41
|
+
const stripPre = (v) => v.split('-')[0];
|
|
42
|
+
const pa = stripPre(a).split('.').map(Number);
|
|
43
|
+
const pb = stripPre(b).split('.').map(Number);
|
|
44
|
+
for (let i = 0; i < 3; i++) {
|
|
45
|
+
if ((pa[i] || 0) < (pb[i] || 0))
|
|
46
|
+
return -1;
|
|
47
|
+
if ((pa[i] || 0) > (pb[i] || 0))
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
// Base versions equal — pre-release is less than release
|
|
51
|
+
const aPre = a.includes('-');
|
|
52
|
+
const bPre = b.includes('-');
|
|
53
|
+
if (aPre && !bPre)
|
|
54
|
+
return -1;
|
|
55
|
+
if (!aPre && bPre)
|
|
56
|
+
return 1;
|
|
57
|
+
if (aPre && bPre)
|
|
58
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Stamp version into squad.agent.md after copying
|
|
63
|
+
*/
|
|
64
|
+
function stampVersion(filePath, version) {
|
|
65
|
+
let content = fs.readFileSync(filePath, 'utf8');
|
|
66
|
+
// Replace version in HTML comment
|
|
67
|
+
content = content.replace(/<!-- version: [^>]+ -->/m, `<!-- version: ${version} -->`);
|
|
68
|
+
// Replace version in Identity section's Version line
|
|
69
|
+
content = content.replace(/- \*\*Version:\*\* [0-9.]+(?:-[a-z]+(?:\.\d+)?)?/m, `- **Version:** ${version}`);
|
|
70
|
+
// Replace {version} placeholder
|
|
71
|
+
content = content.replace(/`Squad v\{version\}`/g, `\`Squad v${version}\``);
|
|
72
|
+
fs.writeFileSync(filePath, content);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Detect project type by checking marker files
|
|
76
|
+
*/
|
|
77
|
+
function detectProjectType(dir) {
|
|
78
|
+
if (fs.existsSync(path.join(dir, 'package.json')))
|
|
79
|
+
return 'npm';
|
|
80
|
+
if (fs.existsSync(path.join(dir, 'go.mod')))
|
|
81
|
+
return 'go';
|
|
82
|
+
if (fs.existsSync(path.join(dir, 'requirements.txt')) ||
|
|
83
|
+
fs.existsSync(path.join(dir, 'pyproject.toml')))
|
|
84
|
+
return 'python';
|
|
85
|
+
if (fs.existsSync(path.join(dir, 'pom.xml')) ||
|
|
86
|
+
fs.existsSync(path.join(dir, 'build.gradle')) ||
|
|
87
|
+
fs.existsSync(path.join(dir, 'build.gradle.kts')))
|
|
88
|
+
return 'java';
|
|
89
|
+
try {
|
|
90
|
+
const entries = fs.readdirSync(dir);
|
|
91
|
+
if (entries.some(e => e.endsWith('.csproj') || e.endsWith('.sln') ||
|
|
92
|
+
e.endsWith('.slnx') || e.endsWith('.fsproj') ||
|
|
93
|
+
e.endsWith('.vbproj')))
|
|
94
|
+
return 'dotnet';
|
|
95
|
+
}
|
|
96
|
+
catch { }
|
|
97
|
+
return 'unknown';
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Project-type-sensitive workflows that need stubs for non-npm projects
|
|
101
|
+
*/
|
|
102
|
+
const PROJECT_TYPE_SENSITIVE_WORKFLOWS = new Set([
|
|
103
|
+
'squad-ci.yml',
|
|
104
|
+
'squad-release.yml',
|
|
105
|
+
'squad-preview.yml',
|
|
106
|
+
'squad-insider-release.yml',
|
|
107
|
+
'squad-docs.yml',
|
|
108
|
+
]);
|
|
109
|
+
/**
|
|
110
|
+
* Generate stub workflow for non-npm projects
|
|
111
|
+
*/
|
|
112
|
+
function generateProjectWorkflowStub(workflowFile, projectType) {
|
|
113
|
+
const typeLabel = projectType === 'unknown'
|
|
114
|
+
? 'Project type was not detected'
|
|
115
|
+
: projectType + ' project';
|
|
116
|
+
const todoBuildCmd = projectType === 'unknown'
|
|
117
|
+
? '# TODO: Project type was not detected — add your build/test commands here'
|
|
118
|
+
: '# TODO: Add your ' + projectType + ' build/test commands here';
|
|
119
|
+
const buildHints = [
|
|
120
|
+
' # Go: go test ./...',
|
|
121
|
+
' # Python: pip install -r requirements.txt && pytest',
|
|
122
|
+
' # .NET: dotnet test',
|
|
123
|
+
' # Java (Maven): mvn test',
|
|
124
|
+
' # Java (Gradle): ./gradlew test',
|
|
125
|
+
].join('\n');
|
|
126
|
+
if (workflowFile === 'squad-ci.yml') {
|
|
127
|
+
return 'name: Squad CI\n' +
|
|
128
|
+
'# ' + typeLabel + ' — configure build/test commands below\n\n' +
|
|
129
|
+
'on:\n' +
|
|
130
|
+
' pull_request:\n' +
|
|
131
|
+
' branches: [dev, preview, main, insider]\n' +
|
|
132
|
+
' types: [opened, synchronize, reopened]\n' +
|
|
133
|
+
' push:\n' +
|
|
134
|
+
' branches: [dev, insider]\n\n' +
|
|
135
|
+
'permissions:\n' +
|
|
136
|
+
' contents: read\n\n' +
|
|
137
|
+
'jobs:\n' +
|
|
138
|
+
' test:\n' +
|
|
139
|
+
' runs-on: ubuntu-latest\n' +
|
|
140
|
+
' steps:\n' +
|
|
141
|
+
' - uses: actions/checkout@v4\n\n' +
|
|
142
|
+
' - name: Build and test\n' +
|
|
143
|
+
' run: |\n' +
|
|
144
|
+
' ' + todoBuildCmd + '\n' +
|
|
145
|
+
buildHints + '\n' +
|
|
146
|
+
' echo "No build commands configured — update squad-ci.yml"\n';
|
|
147
|
+
}
|
|
148
|
+
if (workflowFile === 'squad-release.yml') {
|
|
149
|
+
return 'name: Squad Release\n' +
|
|
150
|
+
'# ' + typeLabel + ' — configure build, test, and release commands below\n\n' +
|
|
151
|
+
'on:\n' +
|
|
152
|
+
' push:\n' +
|
|
153
|
+
' branches: [main]\n\n' +
|
|
154
|
+
'permissions:\n' +
|
|
155
|
+
' contents: write\n\n' +
|
|
156
|
+
'jobs:\n' +
|
|
157
|
+
' release:\n' +
|
|
158
|
+
' runs-on: ubuntu-latest\n' +
|
|
159
|
+
' steps:\n' +
|
|
160
|
+
' - uses: actions/checkout@v4\n' +
|
|
161
|
+
' with:\n' +
|
|
162
|
+
' fetch-depth: 0\n\n' +
|
|
163
|
+
' - name: Build and test\n' +
|
|
164
|
+
' run: |\n' +
|
|
165
|
+
' ' + todoBuildCmd + '\n' +
|
|
166
|
+
buildHints + '\n' +
|
|
167
|
+
' echo "No build commands configured — update squad-release.yml"\n\n' +
|
|
168
|
+
' - name: Create release\n' +
|
|
169
|
+
' env:\n' +
|
|
170
|
+
' GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n' +
|
|
171
|
+
' run: |\n' +
|
|
172
|
+
' # TODO: Add your release commands here (e.g., git tag, gh release create)\n' +
|
|
173
|
+
' echo "No release commands configured — update squad-release.yml"\n';
|
|
174
|
+
}
|
|
175
|
+
if (workflowFile === 'squad-preview.yml') {
|
|
176
|
+
return 'name: Squad Preview Validation\n' +
|
|
177
|
+
'# ' + typeLabel + ' — configure build, test, and validation commands below\n\n' +
|
|
178
|
+
'on:\n' +
|
|
179
|
+
' push:\n' +
|
|
180
|
+
' branches: [preview]\n\n' +
|
|
181
|
+
'permissions:\n' +
|
|
182
|
+
' contents: read\n\n' +
|
|
183
|
+
'jobs:\n' +
|
|
184
|
+
' validate:\n' +
|
|
185
|
+
' runs-on: ubuntu-latest\n' +
|
|
186
|
+
' steps:\n' +
|
|
187
|
+
' - uses: actions/checkout@v4\n\n' +
|
|
188
|
+
' - name: Build and test\n' +
|
|
189
|
+
' run: |\n' +
|
|
190
|
+
' ' + todoBuildCmd + '\n' +
|
|
191
|
+
buildHints + '\n' +
|
|
192
|
+
' echo "No build commands configured — update squad-preview.yml"\n\n' +
|
|
193
|
+
' - name: Validate\n' +
|
|
194
|
+
' run: |\n' +
|
|
195
|
+
' # TODO: Add pre-release validation commands here\n' +
|
|
196
|
+
' echo "No validation commands configured — update squad-preview.yml"\n';
|
|
197
|
+
}
|
|
198
|
+
if (workflowFile === 'squad-insider-release.yml') {
|
|
199
|
+
return 'name: Squad Insider Release\n' +
|
|
200
|
+
'# ' + typeLabel + ' — configure build, test, and insider release commands below\n\n' +
|
|
201
|
+
'on:\n' +
|
|
202
|
+
' push:\n' +
|
|
203
|
+
' branches: [insider]\n\n' +
|
|
204
|
+
'permissions:\n' +
|
|
205
|
+
' contents: write\n\n' +
|
|
206
|
+
'jobs:\n' +
|
|
207
|
+
' release:\n' +
|
|
208
|
+
' runs-on: ubuntu-latest\n' +
|
|
209
|
+
' steps:\n' +
|
|
210
|
+
' - uses: actions/checkout@v4\n' +
|
|
211
|
+
' with:\n' +
|
|
212
|
+
' fetch-depth: 0\n\n' +
|
|
213
|
+
' - name: Build and test\n' +
|
|
214
|
+
' run: |\n' +
|
|
215
|
+
' ' + todoBuildCmd + '\n' +
|
|
216
|
+
buildHints + '\n' +
|
|
217
|
+
' echo "No build commands configured — update squad-insider-release.yml"\n\n' +
|
|
218
|
+
' - name: Create insider release\n' +
|
|
219
|
+
' env:\n' +
|
|
220
|
+
' GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n' +
|
|
221
|
+
' run: |\n' +
|
|
222
|
+
' # TODO: Add your insider/pre-release commands here\n' +
|
|
223
|
+
' echo "No release commands configured — update squad-insider-release.yml"\n';
|
|
224
|
+
}
|
|
225
|
+
if (workflowFile === 'squad-docs.yml') {
|
|
226
|
+
return 'name: Squad Docs — Build & Deploy\n' +
|
|
227
|
+
'# ' + typeLabel + ' — configure documentation build commands below\n\n' +
|
|
228
|
+
'on:\n' +
|
|
229
|
+
' workflow_dispatch:\n' +
|
|
230
|
+
' push:\n' +
|
|
231
|
+
' branches: [preview]\n' +
|
|
232
|
+
' paths:\n' +
|
|
233
|
+
" - 'docs/**'\n" +
|
|
234
|
+
" - '.github/workflows/squad-docs.yml'\n\n" +
|
|
235
|
+
'permissions:\n' +
|
|
236
|
+
' contents: read\n' +
|
|
237
|
+
' pages: write\n' +
|
|
238
|
+
' id-token: write\n\n' +
|
|
239
|
+
'jobs:\n' +
|
|
240
|
+
' build:\n' +
|
|
241
|
+
' runs-on: ubuntu-latest\n' +
|
|
242
|
+
' steps:\n' +
|
|
243
|
+
' - uses: actions/checkout@v4\n\n' +
|
|
244
|
+
' - name: Build docs\n' +
|
|
245
|
+
' run: |\n' +
|
|
246
|
+
' # TODO: Add your documentation build commands here\n' +
|
|
247
|
+
' # This workflow is optional — remove or customize it for your project\n' +
|
|
248
|
+
' echo "No docs build commands configured — update or remove squad-docs.yml"\n';
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Write workflow file: verbatim copy for npm, stub for others
|
|
254
|
+
*/
|
|
255
|
+
function writeWorkflowFile(file, srcPath, destPath, projectType) {
|
|
256
|
+
if (projectType !== 'npm' && PROJECT_TYPE_SENSITIVE_WORKFLOWS.has(file)) {
|
|
257
|
+
const stub = generateProjectWorkflowStub(file, projectType);
|
|
258
|
+
if (stub) {
|
|
259
|
+
fs.writeFileSync(destPath, stub);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
fs.copyFileSync(srcPath, destPath);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Get CLI version from package.json
|
|
267
|
+
*/
|
|
268
|
+
function getCLIVersion() {
|
|
269
|
+
try {
|
|
270
|
+
// From src/cli/core/upgrade.ts, go up to package root
|
|
271
|
+
const pkgPath = path.join(currentDir, '..', '..', '..', 'package.json');
|
|
272
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
273
|
+
return pkg.version || '0.0.0';
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
return '0.0.0';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Run the upgrade command
|
|
281
|
+
*/
|
|
282
|
+
export async function runUpgrade(dest, options = {}) {
|
|
283
|
+
const cliVersion = getCLIVersion();
|
|
284
|
+
const filesUpdated = [];
|
|
285
|
+
// Detect squad directory
|
|
286
|
+
const squadDirInfo = detectSquadDir(dest);
|
|
287
|
+
if (squadDirInfo.isLegacy) {
|
|
288
|
+
warn('DEPRECATION: .ai-team/ is deprecated and will be removed in v1.0.0');
|
|
289
|
+
warn("Run 'squad upgrade --migrate-directory' to migrate to .squad/");
|
|
290
|
+
console.log();
|
|
291
|
+
}
|
|
292
|
+
// Verify squad exists
|
|
293
|
+
if (!fs.existsSync(squadDirInfo.path)) {
|
|
294
|
+
fatal('No squad found — run init first.');
|
|
295
|
+
}
|
|
296
|
+
const agentDest = path.join(dest, '.github', 'agents', 'squad.agent.md');
|
|
297
|
+
const oldVersion = readInstalledVersion(agentDest);
|
|
298
|
+
// Check if already current
|
|
299
|
+
const isAlreadyCurrent = oldVersion && oldVersion !== '0.0.0' && compareSemver(oldVersion, cliVersion) === 0;
|
|
300
|
+
const projectType = detectProjectType(dest);
|
|
301
|
+
if (isAlreadyCurrent) {
|
|
302
|
+
info(`Already up to date (v${cliVersion})`);
|
|
303
|
+
// Still run missing migrations
|
|
304
|
+
const migrationsApplied = await runMigrations(squadDirInfo.path, oldVersion, cliVersion);
|
|
305
|
+
// Refresh squad-owned files even when version matches
|
|
306
|
+
const templatesDir = getTemplatesDir();
|
|
307
|
+
const workflowsSrc = path.join(templatesDir, 'workflows');
|
|
308
|
+
const workflowsDest = path.join(dest, '.github', 'workflows');
|
|
309
|
+
if (fs.existsSync(workflowsSrc)) {
|
|
310
|
+
const wfFiles = fs.readdirSync(workflowsSrc).filter(f => f.endsWith('.yml'));
|
|
311
|
+
fs.mkdirSync(workflowsDest, { recursive: true });
|
|
312
|
+
for (const file of wfFiles) {
|
|
313
|
+
writeWorkflowFile(file, path.join(workflowsSrc, file), path.join(workflowsDest, file), projectType);
|
|
314
|
+
}
|
|
315
|
+
success(`upgraded squad workflows (${wfFiles.length} files)`);
|
|
316
|
+
filesUpdated.push(`workflows (${wfFiles.length} files)`);
|
|
317
|
+
}
|
|
318
|
+
// Refresh squad.agent.md
|
|
319
|
+
const agentSrc = path.join(templatesDir, 'squad.agent.md');
|
|
320
|
+
if (fs.existsSync(agentSrc)) {
|
|
321
|
+
fs.mkdirSync(path.dirname(agentDest), { recursive: true });
|
|
322
|
+
fs.copyFileSync(agentSrc, agentDest);
|
|
323
|
+
stampVersion(agentDest, cliVersion);
|
|
324
|
+
success('upgraded squad.agent.md');
|
|
325
|
+
filesUpdated.push('squad.agent.md');
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
fromVersion: oldVersion,
|
|
329
|
+
toVersion: cliVersion,
|
|
330
|
+
filesUpdated,
|
|
331
|
+
migrationsRun: migrationsApplied,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
// Upgrade squad.agent.md
|
|
335
|
+
const templatesDir = getTemplatesDir();
|
|
336
|
+
const agentSrc = path.join(templatesDir, 'squad.agent.md');
|
|
337
|
+
if (!fs.existsSync(agentSrc)) {
|
|
338
|
+
fatal('squad.agent.md not found in templates — installation may be corrupted');
|
|
339
|
+
}
|
|
340
|
+
fs.mkdirSync(path.dirname(agentDest), { recursive: true });
|
|
341
|
+
fs.copyFileSync(agentSrc, agentDest);
|
|
342
|
+
stampVersion(agentDest, cliVersion);
|
|
343
|
+
const fromLabel = oldVersion === '0.0.0' || !oldVersion ? 'unknown' : oldVersion;
|
|
344
|
+
success(`upgraded coordinator from ${fromLabel} to ${cliVersion}`);
|
|
345
|
+
filesUpdated.push('squad.agent.md');
|
|
346
|
+
// Upgrade squad-owned files from template manifest
|
|
347
|
+
const filesToUpgrade = TEMPLATE_MANIFEST.filter(f => f.overwriteOnUpgrade);
|
|
348
|
+
for (const file of filesToUpgrade) {
|
|
349
|
+
const srcPath = path.join(templatesDir, file.source);
|
|
350
|
+
const destPath = path.join(squadDirInfo.path, file.destination);
|
|
351
|
+
if (!fs.existsSync(srcPath))
|
|
352
|
+
continue;
|
|
353
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
354
|
+
fs.copyFileSync(srcPath, destPath);
|
|
355
|
+
filesUpdated.push(file.destination);
|
|
356
|
+
}
|
|
357
|
+
if (filesToUpgrade.length > 0) {
|
|
358
|
+
success(`upgraded ${filesToUpgrade.length} squad-owned files`);
|
|
359
|
+
}
|
|
360
|
+
// Upgrade workflows
|
|
361
|
+
const workflowsSrc = path.join(templatesDir, 'workflows');
|
|
362
|
+
const workflowsDest = path.join(dest, '.github', 'workflows');
|
|
363
|
+
if (fs.existsSync(workflowsSrc)) {
|
|
364
|
+
const wfFiles = fs.readdirSync(workflowsSrc).filter(f => f.endsWith('.yml'));
|
|
365
|
+
fs.mkdirSync(workflowsDest, { recursive: true });
|
|
366
|
+
for (const file of wfFiles) {
|
|
367
|
+
writeWorkflowFile(file, path.join(workflowsSrc, file), path.join(workflowsDest, file), projectType);
|
|
368
|
+
}
|
|
369
|
+
success(`upgraded squad workflows (${wfFiles.length} files)`);
|
|
370
|
+
filesUpdated.push(`workflows (${wfFiles.length} files)`);
|
|
371
|
+
}
|
|
372
|
+
// Run migrations
|
|
373
|
+
const migrationsApplied = await runMigrations(squadDirInfo.path, oldVersion, cliVersion);
|
|
374
|
+
// Update copilot-instructions.md if @copilot is enabled
|
|
375
|
+
const copilotInstructionsSrc = path.join(templatesDir, 'copilot-instructions.md');
|
|
376
|
+
const copilotInstructionsDest = path.join(dest, '.github', 'copilot-instructions.md');
|
|
377
|
+
const teamMdPath = path.join(squadDirInfo.path, 'team.md');
|
|
378
|
+
if (fs.existsSync(teamMdPath)) {
|
|
379
|
+
const teamContent = fs.readFileSync(teamMdPath, 'utf8');
|
|
380
|
+
const copilotEnabled = teamContent.includes('🤖 Coding Agent');
|
|
381
|
+
if (copilotEnabled && fs.existsSync(copilotInstructionsSrc)) {
|
|
382
|
+
fs.mkdirSync(path.dirname(copilotInstructionsDest), { recursive: true });
|
|
383
|
+
fs.copyFileSync(copilotInstructionsSrc, copilotInstructionsDest);
|
|
384
|
+
success('upgraded .github/copilot-instructions.md');
|
|
385
|
+
filesUpdated.push('copilot-instructions.md');
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
console.log();
|
|
389
|
+
info(`Upgrade complete: v${fromLabel} → v${cliVersion}`);
|
|
390
|
+
dim('Never touches user state: team.md, decisions/, agents/*/history.md');
|
|
391
|
+
console.log();
|
|
392
|
+
return {
|
|
393
|
+
fromVersion: fromLabel,
|
|
394
|
+
toVersion: cliVersion,
|
|
395
|
+
filesUpdated,
|
|
396
|
+
migrationsRun: migrationsApplied,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
//# sourceMappingURL=upgrade.js.map
|