squads-cli 0.2.0 → 0.2.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 (223) hide show
  1. package/README.md +521 -288
  2. package/dist/auth-YW3UPFSB.js +23 -0
  3. package/dist/auth-YW3UPFSB.js.map +1 -0
  4. package/dist/autonomy-PSVZVX7A.js +105 -0
  5. package/dist/autonomy-PSVZVX7A.js.map +1 -0
  6. package/dist/chunk-67RO2HKR.js +174 -0
  7. package/dist/chunk-67RO2HKR.js.map +1 -0
  8. package/dist/chunk-7OCVIDC7.js +12 -0
  9. package/dist/chunk-7OCVIDC7.js.map +1 -0
  10. package/dist/chunk-BODLDQY7.js +452 -0
  11. package/dist/chunk-BODLDQY7.js.map +1 -0
  12. package/dist/chunk-EHQJHRIW.js +103 -0
  13. package/dist/chunk-EHQJHRIW.js.map +1 -0
  14. package/dist/chunk-FFFCFZ6A.js +121 -0
  15. package/dist/chunk-FFFCFZ6A.js.map +1 -0
  16. package/dist/chunk-FIWT2NMM.js +165 -0
  17. package/dist/chunk-FIWT2NMM.js.map +1 -0
  18. package/dist/chunk-HF4WR7RA.js +154 -0
  19. package/dist/chunk-HF4WR7RA.js.map +1 -0
  20. package/dist/chunk-J6QF4ZQX.js +230 -0
  21. package/dist/chunk-J6QF4ZQX.js.map +1 -0
  22. package/dist/chunk-LOA3KWYJ.js +294 -0
  23. package/dist/chunk-LOA3KWYJ.js.map +1 -0
  24. package/dist/chunk-M5FXNY6Y.js +384 -0
  25. package/dist/chunk-M5FXNY6Y.js.map +1 -0
  26. package/dist/chunk-QHNUMM4V.js +87 -0
  27. package/dist/chunk-QHNUMM4V.js.map +1 -0
  28. package/dist/chunk-QJ7C7CMB.js +223 -0
  29. package/dist/chunk-QJ7C7CMB.js.map +1 -0
  30. package/dist/chunk-RM6BWILN.js +74 -0
  31. package/dist/chunk-RM6BWILN.js.map +1 -0
  32. package/dist/chunk-TYFTF53O.js +613 -0
  33. package/dist/chunk-TYFTF53O.js.map +1 -0
  34. package/dist/chunk-TZXD6WFN.js +420 -0
  35. package/dist/chunk-TZXD6WFN.js.map +1 -0
  36. package/dist/chunk-WVOIY5GW.js +621 -0
  37. package/dist/chunk-WVOIY5GW.js.map +1 -0
  38. package/dist/chunk-Z2UKDBNL.js +162 -0
  39. package/dist/chunk-Z2UKDBNL.js.map +1 -0
  40. package/dist/chunk-ZTQ7ISUR.js +338 -0
  41. package/dist/chunk-ZTQ7ISUR.js.map +1 -0
  42. package/dist/cli.js +2483 -5902
  43. package/dist/cli.js.map +1 -1
  44. package/dist/context-GWPF4SEY.js +291 -0
  45. package/dist/context-GWPF4SEY.js.map +1 -0
  46. package/dist/context-feed-AJGVAR6H.js +394 -0
  47. package/dist/context-feed-AJGVAR6H.js.map +1 -0
  48. package/dist/cost-XBCDJ7XC.js +275 -0
  49. package/dist/cost-XBCDJ7XC.js.map +1 -0
  50. package/dist/create-BLFGG6PF.js +286 -0
  51. package/dist/create-BLFGG6PF.js.map +1 -0
  52. package/dist/dashboard-LGT2B2BL.js +951 -0
  53. package/dist/dashboard-LGT2B2BL.js.map +1 -0
  54. package/dist/dashboard-RMK2BOD2.js +794 -0
  55. package/dist/dashboard-RMK2BOD2.js.map +1 -0
  56. package/dist/doctor-XPUIIBHJ.js +374 -0
  57. package/dist/doctor-XPUIIBHJ.js.map +1 -0
  58. package/dist/env-config-SQEI3Y7Y.js +21 -0
  59. package/dist/env-config-SQEI3Y7Y.js.map +1 -0
  60. package/dist/exec-OUXM7JBF.js +223 -0
  61. package/dist/exec-OUXM7JBF.js.map +1 -0
  62. package/dist/feedback-KNAOG5QK.js +229 -0
  63. package/dist/feedback-KNAOG5QK.js.map +1 -0
  64. package/dist/github-UQTM5KMS.js +23 -0
  65. package/dist/github-UQTM5KMS.js.map +1 -0
  66. package/dist/goal-BVHV5573.js +168 -0
  67. package/dist/goal-BVHV5573.js.map +1 -0
  68. package/dist/health-4UXN44PF.js +218 -0
  69. package/dist/health-4UXN44PF.js.map +1 -0
  70. package/dist/history-ILH3SWHB.js +232 -0
  71. package/dist/history-ILH3SWHB.js.map +1 -0
  72. package/dist/index.d.ts +736 -8
  73. package/dist/index.js +1312 -6
  74. package/dist/index.js.map +1 -1
  75. package/dist/init-XQZ7BOGT.js +812 -0
  76. package/dist/init-XQZ7BOGT.js.map +1 -0
  77. package/dist/kpi-RQIU7WGK.js +413 -0
  78. package/dist/kpi-RQIU7WGK.js.map +1 -0
  79. package/dist/learn-OIFUVZAS.js +269 -0
  80. package/dist/learn-OIFUVZAS.js.map +1 -0
  81. package/dist/login-DXZANWZY.js +155 -0
  82. package/dist/login-DXZANWZY.js.map +1 -0
  83. package/dist/memory-T3ACCS7E.js +560 -0
  84. package/dist/memory-T3ACCS7E.js.map +1 -0
  85. package/dist/memory-VNF2VFRB.js +23 -0
  86. package/dist/memory-VNF2VFRB.js.map +1 -0
  87. package/dist/progress-DAUZMT3N.js +202 -0
  88. package/dist/progress-DAUZMT3N.js.map +1 -0
  89. package/dist/providers-3P5D2XL5.js +65 -0
  90. package/dist/providers-3P5D2XL5.js.map +1 -0
  91. package/dist/results-UECWGLTB.js +224 -0
  92. package/dist/results-UECWGLTB.js.map +1 -0
  93. package/dist/run-I6KAXU6U.js +4049 -0
  94. package/dist/run-I6KAXU6U.js.map +1 -0
  95. package/dist/session-HBU6KZOD.js +64 -0
  96. package/dist/session-HBU6KZOD.js.map +1 -0
  97. package/dist/sessions-CK25VGPL.js +333 -0
  98. package/dist/sessions-CK25VGPL.js.map +1 -0
  99. package/dist/squad-parser-DCG65BJS.js +35 -0
  100. package/dist/squad-parser-DCG65BJS.js.map +1 -0
  101. package/dist/stats-G6NAU5BD.js +334 -0
  102. package/dist/stats-G6NAU5BD.js.map +1 -0
  103. package/dist/status-AQNLDZVN.js +352 -0
  104. package/dist/status-AQNLDZVN.js.map +1 -0
  105. package/dist/sync-ZI3MHA4G.js +836 -0
  106. package/dist/sync-ZI3MHA4G.js.map +1 -0
  107. package/dist/templates/core/AGENTS.md.template +51 -0
  108. package/dist/templates/core/BUSINESS_BRIEF.md.template +29 -0
  109. package/dist/templates/core/CLAUDE.md.template +48 -0
  110. package/dist/templates/core/provider.yaml.template +5 -0
  111. package/dist/templates/first-squad/SQUAD.md.template +23 -0
  112. package/dist/templates/first-squad/lead.md.template +44 -0
  113. package/dist/templates/memory/getting-started/state.md.template +19 -0
  114. package/dist/templates/seed/BUSINESS_BRIEF.md.template +27 -0
  115. package/dist/templates/seed/CLAUDE.md.template +119 -0
  116. package/dist/templates/seed/README.md.template +42 -0
  117. package/dist/templates/seed/config/SYSTEM.md +52 -0
  118. package/dist/templates/seed/config/provider.yaml +4 -0
  119. package/dist/templates/seed/hooks/settings.json.template +31 -0
  120. package/dist/templates/seed/memory/company/directives.md +37 -0
  121. package/dist/templates/seed/memory/company/manager/state.md +16 -0
  122. package/dist/templates/seed/memory/engineering/issue-solver/state.md +12 -0
  123. package/dist/templates/seed/memory/intelligence/intel-lead/state.md +9 -0
  124. package/dist/templates/seed/memory/marketing/content-drafter/state.md +12 -0
  125. package/dist/templates/seed/memory/operations/ops-lead/state.md +12 -0
  126. package/dist/templates/seed/memory/product/lead/state.md +14 -0
  127. package/dist/templates/seed/memory/research/lead/state.md +14 -0
  128. package/dist/templates/seed/skills/gh/SKILL.md +57 -0
  129. package/dist/templates/seed/skills/squads-cli/SKILL.md +84 -0
  130. package/dist/templates/seed/squads/company/SQUAD.md +51 -0
  131. package/dist/templates/seed/squads/company/company-critic.md +49 -0
  132. package/dist/templates/seed/squads/company/company-eval.md +49 -0
  133. package/dist/templates/seed/squads/company/event-dispatcher.md +43 -0
  134. package/dist/templates/seed/squads/company/goal-tracker.md +43 -0
  135. package/dist/templates/seed/squads/company/manager.md +54 -0
  136. package/dist/templates/seed/squads/engineering/SQUAD.md +48 -0
  137. package/dist/templates/seed/squads/engineering/code-reviewer.md +57 -0
  138. package/dist/templates/seed/squads/engineering/issue-solver.md +58 -0
  139. package/dist/templates/seed/squads/engineering/test-writer.md +50 -0
  140. package/dist/templates/seed/squads/intelligence/SQUAD.md +38 -0
  141. package/dist/templates/seed/squads/intelligence/intel-critic.md +36 -0
  142. package/dist/templates/seed/squads/intelligence/intel-eval.md +31 -0
  143. package/dist/templates/seed/squads/intelligence/intel-lead.md +71 -0
  144. package/dist/templates/seed/squads/marketing/SQUAD.md +47 -0
  145. package/dist/templates/seed/squads/marketing/content-drafter.md +71 -0
  146. package/dist/templates/seed/squads/marketing/growth-analyst.md +49 -0
  147. package/dist/templates/seed/squads/marketing/social-poster.md +44 -0
  148. package/dist/templates/seed/squads/operations/SQUAD.md +45 -0
  149. package/dist/templates/seed/squads/operations/finance-tracker.md +47 -0
  150. package/dist/templates/seed/squads/operations/goal-tracker.md +48 -0
  151. package/dist/templates/seed/squads/operations/ops-lead.md +58 -0
  152. package/dist/templates/seed/squads/product/SQUAD.md +41 -0
  153. package/dist/templates/seed/squads/product/lead.md +56 -0
  154. package/dist/templates/seed/squads/product/scanner.md +50 -0
  155. package/dist/templates/seed/squads/product/worker.md +55 -0
  156. package/dist/templates/seed/squads/research/SQUAD.md +38 -0
  157. package/dist/templates/seed/squads/research/analyst.md +50 -0
  158. package/dist/templates/seed/squads/research/lead.md +52 -0
  159. package/dist/templates/seed/squads/research/synthesizer.md +59 -0
  160. package/dist/templates/skills/squads-learn/SKILL.md +86 -0
  161. package/dist/templates/skills/squads-workflow/instruction.md +70 -0
  162. package/dist/terminal-FBQFQTKZ.js +55 -0
  163. package/dist/terminal-FBQFQTKZ.js.map +1 -0
  164. package/dist/update-D7CGIZ3M.js +18 -0
  165. package/dist/update-D7CGIZ3M.js.map +1 -0
  166. package/dist/update-STU276HR.js +83 -0
  167. package/dist/update-STU276HR.js.map +1 -0
  168. package/package.json +31 -13
  169. package/templates/core/AGENTS.md.template +51 -0
  170. package/templates/core/BUSINESS_BRIEF.md.template +29 -0
  171. package/templates/core/CLAUDE.md.template +48 -0
  172. package/templates/core/provider.yaml.template +5 -0
  173. package/templates/first-squad/SQUAD.md.template +23 -0
  174. package/templates/first-squad/lead.md.template +44 -0
  175. package/templates/memory/getting-started/state.md.template +19 -0
  176. package/templates/seed/BUSINESS_BRIEF.md.template +27 -0
  177. package/templates/seed/CLAUDE.md.template +119 -0
  178. package/templates/seed/README.md.template +42 -0
  179. package/templates/seed/config/SYSTEM.md +52 -0
  180. package/templates/seed/config/provider.yaml +4 -0
  181. package/templates/seed/hooks/settings.json.template +31 -0
  182. package/templates/seed/memory/company/directives.md +37 -0
  183. package/templates/seed/memory/company/manager/state.md +16 -0
  184. package/templates/seed/memory/engineering/issue-solver/state.md +12 -0
  185. package/templates/seed/memory/intelligence/intel-lead/state.md +9 -0
  186. package/templates/seed/memory/marketing/content-drafter/state.md +12 -0
  187. package/templates/seed/memory/operations/ops-lead/state.md +12 -0
  188. package/templates/seed/memory/product/lead/state.md +14 -0
  189. package/templates/seed/memory/research/lead/state.md +14 -0
  190. package/templates/seed/skills/gh/SKILL.md +57 -0
  191. package/templates/seed/skills/squads-cli/SKILL.md +84 -0
  192. package/templates/seed/squads/company/SQUAD.md +51 -0
  193. package/templates/seed/squads/company/company-critic.md +49 -0
  194. package/templates/seed/squads/company/company-eval.md +49 -0
  195. package/templates/seed/squads/company/event-dispatcher.md +43 -0
  196. package/templates/seed/squads/company/goal-tracker.md +43 -0
  197. package/templates/seed/squads/company/manager.md +54 -0
  198. package/templates/seed/squads/engineering/SQUAD.md +48 -0
  199. package/templates/seed/squads/engineering/code-reviewer.md +57 -0
  200. package/templates/seed/squads/engineering/issue-solver.md +58 -0
  201. package/templates/seed/squads/engineering/test-writer.md +50 -0
  202. package/templates/seed/squads/intelligence/SQUAD.md +38 -0
  203. package/templates/seed/squads/intelligence/intel-critic.md +36 -0
  204. package/templates/seed/squads/intelligence/intel-eval.md +31 -0
  205. package/templates/seed/squads/intelligence/intel-lead.md +71 -0
  206. package/templates/seed/squads/marketing/SQUAD.md +47 -0
  207. package/templates/seed/squads/marketing/content-drafter.md +71 -0
  208. package/templates/seed/squads/marketing/growth-analyst.md +49 -0
  209. package/templates/seed/squads/marketing/social-poster.md +44 -0
  210. package/templates/seed/squads/operations/SQUAD.md +45 -0
  211. package/templates/seed/squads/operations/finance-tracker.md +47 -0
  212. package/templates/seed/squads/operations/goal-tracker.md +48 -0
  213. package/templates/seed/squads/operations/ops-lead.md +58 -0
  214. package/templates/seed/squads/product/SQUAD.md +41 -0
  215. package/templates/seed/squads/product/lead.md +56 -0
  216. package/templates/seed/squads/product/scanner.md +50 -0
  217. package/templates/seed/squads/product/worker.md +55 -0
  218. package/templates/seed/squads/research/SQUAD.md +38 -0
  219. package/templates/seed/squads/research/analyst.md +50 -0
  220. package/templates/seed/squads/research/lead.md +52 -0
  221. package/templates/seed/squads/research/synthesizer.md +59 -0
  222. package/templates/skills/squads-learn/SKILL.md +86 -0
  223. package/templates/skills/squads-workflow/instruction.md +70 -0
@@ -0,0 +1,613 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/lib/squad-parser.ts
4
+ import { readFileSync as readFileSync2, existsSync as existsSync2, readdirSync, writeFileSync as writeFileSync2 } from "fs";
5
+ import { join as join2, basename, dirname as dirname2 } from "path";
6
+ import matter from "gray-matter";
7
+
8
+ // src/lib/mcp-config.ts
9
+ import { existsSync, mkdirSync, writeFileSync, readFileSync } from "fs";
10
+ import { join, dirname } from "path";
11
+ var SERVER_REGISTRY = {};
12
+ function getHome() {
13
+ return process.env.HOME || process.env.USERPROFILE || "";
14
+ }
15
+ function getContextsDir() {
16
+ return join(getHome(), ".claude", "contexts");
17
+ }
18
+ function getMcpConfigsDir() {
19
+ return join(getHome(), ".claude", "mcp-configs");
20
+ }
21
+ function generateMcpConfig(mcpServers) {
22
+ const config = { mcpServers: {} };
23
+ for (const server of mcpServers) {
24
+ const def = SERVER_REGISTRY[server];
25
+ if (def) {
26
+ config.mcpServers[server] = def;
27
+ }
28
+ }
29
+ return config;
30
+ }
31
+ function writeMcpConfig(config, path) {
32
+ const dir = dirname(path);
33
+ if (!existsSync(dir)) {
34
+ mkdirSync(dir, { recursive: true });
35
+ }
36
+ writeFileSync(path, JSON.stringify(config, null, 2));
37
+ }
38
+ function readMcpConfig(path) {
39
+ if (!existsSync(path)) return null;
40
+ try {
41
+ const content = readFileSync(path, "utf-8");
42
+ return JSON.parse(content);
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+ function resolveMcpConfig(squadName, mcpServers, forceRegenerate = false) {
48
+ const home = getHome();
49
+ const userOverride = join(getMcpConfigsDir(), `${squadName}.json`);
50
+ if (existsSync(userOverride)) {
51
+ const config = readMcpConfig(userOverride);
52
+ return {
53
+ path: userOverride,
54
+ source: "user-override",
55
+ servers: config ? Object.keys(config.mcpServers) : void 0
56
+ };
57
+ }
58
+ if (mcpServers && mcpServers.length > 0) {
59
+ const generatedPath = join(getContextsDir(), `${squadName}.mcp.json`);
60
+ const shouldGenerate = forceRegenerate || !existsSync(generatedPath);
61
+ if (shouldGenerate) {
62
+ const config2 = generateMcpConfig(mcpServers);
63
+ writeMcpConfig(config2, generatedPath);
64
+ return {
65
+ path: generatedPath,
66
+ source: "generated",
67
+ servers: Object.keys(config2.mcpServers),
68
+ generated: true
69
+ };
70
+ }
71
+ const config = readMcpConfig(generatedPath);
72
+ return {
73
+ path: generatedPath,
74
+ source: "generated",
75
+ servers: config ? Object.keys(config.mcpServers) : mcpServers,
76
+ generated: false
77
+ };
78
+ }
79
+ return {
80
+ path: join(home, ".claude.json"),
81
+ source: "fallback"
82
+ };
83
+ }
84
+ function resolveMcpConfigPath(squadName, mcpServers) {
85
+ return resolveMcpConfig(squadName, mcpServers).path;
86
+ }
87
+
88
+ // src/lib/squad-parser.ts
89
+ function findSquadsDir() {
90
+ let dir = process.cwd();
91
+ for (let i = 0; i < 5; i++) {
92
+ const squadsPath = join2(dir, ".agents", "squads");
93
+ if (existsSync2(squadsPath)) {
94
+ return squadsPath;
95
+ }
96
+ const parent = join2(dir, "..");
97
+ if (parent === dir) break;
98
+ dir = parent;
99
+ }
100
+ return null;
101
+ }
102
+ function findProjectRoot() {
103
+ const squadsDir = findSquadsDir();
104
+ if (!squadsDir) return null;
105
+ return join2(squadsDir, "..", "..");
106
+ }
107
+ function hasLocalInfraConfig() {
108
+ const projectRoot = findProjectRoot();
109
+ if (!projectRoot) return false;
110
+ const envPath = join2(projectRoot, ".env");
111
+ if (!existsSync2(envPath)) return false;
112
+ const content = readFileSync2(envPath, "utf-8");
113
+ const infraKeys = ["LANGFUSE_", "SQUADS_BRIDGE", "SQUADS_POSTGRES", "SQUADS_REDIS"];
114
+ return infraKeys.some((key) => content.includes(key));
115
+ }
116
+ function listSquads(squadsDir) {
117
+ const squads = [];
118
+ const entries = readdirSync(squadsDir, { withFileTypes: true });
119
+ for (const entry of entries) {
120
+ if (entry.isDirectory() && !entry.name.startsWith("_")) {
121
+ const squadFile = join2(squadsDir, entry.name, "SQUAD.md");
122
+ if (existsSync2(squadFile)) {
123
+ squads.push(entry.name);
124
+ }
125
+ }
126
+ }
127
+ return squads;
128
+ }
129
+ function findSimilarSquads(input, squads) {
130
+ const lower = input.toLowerCase();
131
+ function levenshtein(a, b) {
132
+ const m = a.length, n = b.length;
133
+ const dp = Array.from(
134
+ { length: m + 1 },
135
+ (_, i) => Array.from({ length: n + 1 }, (_2, j) => i === 0 ? j : j === 0 ? i : 0)
136
+ );
137
+ for (let i = 1; i <= m; i++) {
138
+ for (let j = 1; j <= n; j++) {
139
+ dp[i][j] = a[i - 1] === b[j - 1] ? dp[i - 1][j - 1] : 1 + Math.min(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]);
140
+ }
141
+ }
142
+ return dp[m][n];
143
+ }
144
+ const threshold = Math.max(2, Math.floor(input.length / 3));
145
+ return squads.map((s) => ({ name: s, dist: levenshtein(lower, s.toLowerCase()) })).filter(({ name, dist }) => dist <= threshold || name.toLowerCase().includes(lower) || lower.includes(name.toLowerCase())).sort((a, b) => a.dist - b.dist).slice(0, 3).map(({ name }) => name);
146
+ }
147
+ function listAgents(squadsDir, squadName) {
148
+ const agents = [];
149
+ const dirs = squadName ? [squadName] : readdirSync(squadsDir, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith("_")).map((e) => e.name);
150
+ for (const dir of dirs) {
151
+ const squadPath = join2(squadsDir, dir);
152
+ if (!existsSync2(squadPath)) continue;
153
+ const files = readdirSync(squadPath);
154
+ for (const file of files) {
155
+ if (file.endsWith(".md") && file !== "SQUAD.md") {
156
+ const agentName = file.replace(".md", "");
157
+ agents.push({
158
+ name: agentName,
159
+ role: `Agent in ${dir}`,
160
+ trigger: "manual",
161
+ filePath: join2(squadPath, file)
162
+ });
163
+ }
164
+ }
165
+ }
166
+ return agents;
167
+ }
168
+ function parseSquadFile(filePath) {
169
+ const rawContent = readFileSync2(filePath, "utf-8");
170
+ const { data: frontmatter, content: bodyContent } = matter(rawContent);
171
+ const fm = frontmatter;
172
+ const lines = bodyContent.split("\n");
173
+ const dirName = basename(dirname2(filePath));
174
+ const squad = {
175
+ // Display name can be different from dir (e.g., "Engineering Squad")
176
+ name: fm.name || dirName,
177
+ // Directory name for file path resolution
178
+ dir: dirName,
179
+ mission: fm.mission || "",
180
+ agents: [],
181
+ pipelines: [],
182
+ triggers: { scheduled: [], event: [], manual: [] },
183
+ routines: [],
184
+ dependencies: [],
185
+ outputPath: "",
186
+ goals: [],
187
+ // Apply frontmatter fields
188
+ effort: fm.effort,
189
+ context: fm.context,
190
+ repo: fm.repo,
191
+ stack: fm.stack,
192
+ providers: fm.providers,
193
+ // Preserve raw frontmatter for KPIs and other custom fields
194
+ frontmatter,
195
+ // Phase ordering: which squads must complete before this one
196
+ depends_on: Array.isArray(fm.depends_on) ? fm.depends_on : void 0
197
+ };
198
+ let currentSection = "";
199
+ let inTable = false;
200
+ let tableHeaders = [];
201
+ for (const line of lines) {
202
+ if (line.startsWith("# Squad:")) {
203
+ squad.name = line.replace("# Squad:", "").trim().toLowerCase();
204
+ continue;
205
+ }
206
+ if (line.startsWith("## ")) {
207
+ currentSection = line.replace("## ", "").trim().toLowerCase();
208
+ inTable = false;
209
+ continue;
210
+ }
211
+ if (currentSection === "mission" && line.trim() && !line.startsWith("#")) {
212
+ if (!squad.mission) {
213
+ squad.mission = line.trim();
214
+ }
215
+ }
216
+ const effortMatch = line.match(/^effort:\s*(high|medium|low)/i);
217
+ if (effortMatch && !squad.effort) {
218
+ squad.effort = effortMatch[1].toLowerCase();
219
+ }
220
+ if (currentSection.includes("agent") || currentSection.includes("orchestrator") || currentSection.includes("evaluator") || currentSection.includes("builder") || currentSection.includes("priority")) {
221
+ if (line.includes("|") && line.includes("Agent")) {
222
+ inTable = true;
223
+ tableHeaders = line.split("|").map((h) => h.trim().toLowerCase());
224
+ continue;
225
+ }
226
+ if (inTable && line.includes("|") && !line.includes("---")) {
227
+ const cells = line.split("|").map((c) => c.trim().replace(/`/g, "").replace(/\*\*/g, ""));
228
+ const agentIdx = tableHeaders.findIndex((h) => h === "agent");
229
+ const roleIdx = tableHeaders.findIndex((h) => h === "role");
230
+ const triggerIdx = tableHeaders.findIndex((h) => h === "trigger");
231
+ const statusIdx = tableHeaders.findIndex((h) => h === "status");
232
+ const effortIdx = tableHeaders.findIndex((h) => h === "effort");
233
+ if (agentIdx >= 0 && cells[agentIdx]) {
234
+ const effortValue = effortIdx >= 0 ? cells[effortIdx]?.toLowerCase() : void 0;
235
+ const effort = ["high", "medium", "low"].includes(effortValue || "") ? effortValue : void 0;
236
+ squad.agents.push({
237
+ name: cells[agentIdx],
238
+ role: roleIdx >= 0 ? cells[roleIdx] : "",
239
+ trigger: triggerIdx >= 0 ? cells[triggerIdx] : "manual",
240
+ status: statusIdx >= 0 ? cells[statusIdx] : "active",
241
+ effort
242
+ });
243
+ }
244
+ }
245
+ }
246
+ if (line.includes("\u2192") && line.includes("`")) {
247
+ const pipelineMatch = line.match(/`([^`]+)`\s*→\s*`([^`]+)`/g);
248
+ if (pipelineMatch) {
249
+ const agentNames = line.match(/`([^`]+)`/g)?.map((m) => m.replace(/`/g, "")) || [];
250
+ if (agentNames.length >= 2) {
251
+ squad.pipelines.push({
252
+ name: "default",
253
+ agents: agentNames
254
+ });
255
+ }
256
+ }
257
+ }
258
+ if (line.toLowerCase().includes("pipeline:")) {
259
+ const pipelineContent = line.split(":")[1];
260
+ if (pipelineContent && pipelineContent.includes("\u2192")) {
261
+ const agentNames = pipelineContent.match(/`([^`]+)`/g)?.map((m) => m.replace(/`/g, "")) || [];
262
+ if (agentNames.length >= 2) {
263
+ squad.pipelines.push({
264
+ name: "default",
265
+ agents: agentNames
266
+ });
267
+ }
268
+ }
269
+ }
270
+ if (line.toLowerCase().includes("primary") && line.includes("`")) {
271
+ const match = line.match(/`([^`]+)`/);
272
+ if (match) {
273
+ squad.outputPath = match[1].replace(/\/$/, "");
274
+ }
275
+ }
276
+ if (currentSection === "goals") {
277
+ const goalMatch = line.match(/^-\s*\[([ x])\]\s*(.+)$/);
278
+ if (goalMatch) {
279
+ const completed = goalMatch[1] === "x";
280
+ let description = goalMatch[2].trim();
281
+ let progress;
282
+ const progressMatch = description.match(/\(progress:\s*([^)]+)\)/i);
283
+ if (progressMatch) {
284
+ progress = progressMatch[1];
285
+ description = description.replace(progressMatch[0], "").trim();
286
+ }
287
+ squad.goals.push({
288
+ description,
289
+ completed,
290
+ progress
291
+ });
292
+ }
293
+ }
294
+ }
295
+ return squad;
296
+ }
297
+ function loadSquad(squadName) {
298
+ const squadsDir = findSquadsDir();
299
+ if (!squadsDir) return null;
300
+ const squadFile = join2(squadsDir, squadName, "SQUAD.md");
301
+ if (!existsSync2(squadFile)) return null;
302
+ return parseSquadFile(squadFile);
303
+ }
304
+ function loadAgentDefinition(agentPath) {
305
+ if (!existsSync2(agentPath)) return "";
306
+ return readFileSync2(agentPath, "utf-8");
307
+ }
308
+ function parseAgentProvider(agentPath) {
309
+ if (!existsSync2(agentPath)) return void 0;
310
+ const content = readFileSync2(agentPath, "utf-8");
311
+ try {
312
+ const { data: frontmatter } = matter(content);
313
+ if (frontmatter?.provider && typeof frontmatter.provider === "string") {
314
+ return frontmatter.provider.toLowerCase();
315
+ }
316
+ } catch {
317
+ }
318
+ const providerHeaderMatch = content.match(/##\s*Provider\s*\n+([a-zA-Z0-9_-]+)/i);
319
+ if (providerHeaderMatch) {
320
+ return providerHeaderMatch[1].toLowerCase();
321
+ }
322
+ return void 0;
323
+ }
324
+ function addGoalToSquad(squadName, goal) {
325
+ const squadsDir = findSquadsDir();
326
+ if (!squadsDir) return false;
327
+ const squadFile = join2(squadsDir, squadName, "SQUAD.md");
328
+ if (!existsSync2(squadFile)) return false;
329
+ let content = readFileSync2(squadFile, "utf-8");
330
+ if (!content.includes("## Goals")) {
331
+ const insertPoint = content.indexOf("## Dependencies");
332
+ if (insertPoint > 0) {
333
+ content = content.slice(0, insertPoint) + `## Goals
334
+
335
+ - [ ] ${goal}
336
+
337
+ ` + content.slice(insertPoint);
338
+ } else {
339
+ content += `
340
+ ## Goals
341
+
342
+ - [ ] ${goal}
343
+ `;
344
+ }
345
+ } else {
346
+ const goalsIdx = content.indexOf("## Goals");
347
+ const nextSectionIdx = content.indexOf("\n## ", goalsIdx + 1);
348
+ const endIdx = nextSectionIdx > 0 ? nextSectionIdx : content.length;
349
+ const goalsSection = content.slice(goalsIdx, endIdx);
350
+ const lastGoalMatch = goalsSection.match(/^-\s*\[[ x]\].+$/gm);
351
+ if (lastGoalMatch) {
352
+ const lastGoal = lastGoalMatch[lastGoalMatch.length - 1];
353
+ const lastGoalIdx = content.lastIndexOf(lastGoal, endIdx);
354
+ const insertPos = lastGoalIdx + lastGoal.length;
355
+ content = content.slice(0, insertPos) + `
356
+ - [ ] ${goal}` + content.slice(insertPos);
357
+ } else {
358
+ const headerEnd = goalsIdx + "## Goals".length;
359
+ content = content.slice(0, headerEnd) + `
360
+
361
+ - [ ] ${goal}` + content.slice(headerEnd);
362
+ }
363
+ }
364
+ writeFileSync2(squadFile, content);
365
+ return true;
366
+ }
367
+ function updateGoalInSquad(squadName, goalIndex, updates) {
368
+ const squadsDir = findSquadsDir();
369
+ if (!squadsDir) return false;
370
+ const squadFile = join2(squadsDir, squadName, "SQUAD.md");
371
+ if (!existsSync2(squadFile)) return false;
372
+ const content = readFileSync2(squadFile, "utf-8");
373
+ const lines = content.split("\n");
374
+ let currentSection = "";
375
+ let goalCount = 0;
376
+ for (let i = 0; i < lines.length; i++) {
377
+ const line = lines[i];
378
+ if (line.startsWith("## ")) {
379
+ currentSection = line.replace("## ", "").trim().toLowerCase();
380
+ continue;
381
+ }
382
+ if (currentSection === "goals") {
383
+ const goalMatch = line.match(/^-\s*\[([ x])\]\s*(.+)$/);
384
+ if (goalMatch) {
385
+ if (goalCount === goalIndex) {
386
+ let newLine = "- [" + (updates.completed ? "x" : " ") + "] " + goalMatch[2];
387
+ if (updates.progress !== void 0) {
388
+ newLine = newLine.replace(/\s*\(progress:\s*[^)]+\)/i, "");
389
+ if (updates.progress) {
390
+ newLine += ` (progress: ${updates.progress})`;
391
+ }
392
+ }
393
+ lines[i] = newLine;
394
+ writeFileSync2(squadFile, lines.join("\n"));
395
+ return true;
396
+ }
397
+ goalCount++;
398
+ }
399
+ }
400
+ }
401
+ return false;
402
+ }
403
+ function findProjectSkillsDir() {
404
+ const projectRoot = findProjectRoot();
405
+ if (!projectRoot) return null;
406
+ const skillsDir = join2(projectRoot, ".claude", "skills");
407
+ return existsSync2(skillsDir) ? skillsDir : null;
408
+ }
409
+ function findGlobalSkillsDir() {
410
+ const home = process.env.HOME || process.env.USERPROFILE || "";
411
+ if (!home) return null;
412
+ const skillsDir = join2(home, ".claude", "skills");
413
+ return existsSync2(skillsDir) ? skillsDir : null;
414
+ }
415
+ function findSquadLocalSkillsDir(squadDir) {
416
+ const squadsDir = findSquadsDir();
417
+ if (!squadsDir) return null;
418
+ const skillsDir = join2(squadsDir, squadDir, "skills");
419
+ return existsSync2(skillsDir) ? skillsDir : null;
420
+ }
421
+ function listSkillsInDir(skillsDir) {
422
+ if (!existsSync2(skillsDir)) return [];
423
+ try {
424
+ const entries = readdirSync(skillsDir, { withFileTypes: true });
425
+ const skills = [];
426
+ for (const entry of entries) {
427
+ if (entry.isDirectory()) {
428
+ const skillMdPath = join2(skillsDir, entry.name, "SKILL.md");
429
+ if (existsSync2(skillMdPath)) {
430
+ skills.push(entry.name);
431
+ }
432
+ } else if (entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md") {
433
+ skills.push(entry.name.replace(".md", ""));
434
+ }
435
+ }
436
+ return skills;
437
+ } catch {
438
+ return [];
439
+ }
440
+ }
441
+ function findMemoryDir() {
442
+ const projectRoot = findProjectRoot();
443
+ if (!projectRoot) return null;
444
+ const memoryDir = join2(projectRoot, ".agents", "memory");
445
+ return existsSync2(memoryDir) ? memoryDir : null;
446
+ }
447
+ function resolveSkill(skillName, squadDir) {
448
+ if (squadDir) {
449
+ const squadSkillsDir = findSquadLocalSkillsDir(squadDir);
450
+ if (squadSkillsDir) {
451
+ const dirPath = join2(squadSkillsDir, skillName);
452
+ if (existsSync2(dirPath) && existsSync2(join2(dirPath, "SKILL.md"))) {
453
+ return { name: skillName, path: dirPath, source: "squad-local" };
454
+ }
455
+ const filePath = join2(squadSkillsDir, `${skillName}.md`);
456
+ if (existsSync2(filePath)) {
457
+ return { name: skillName, path: filePath, source: "squad-local" };
458
+ }
459
+ }
460
+ }
461
+ const projectSkillsDir = findProjectSkillsDir();
462
+ if (projectSkillsDir) {
463
+ const dirPath = join2(projectSkillsDir, skillName);
464
+ if (existsSync2(dirPath) && existsSync2(join2(dirPath, "SKILL.md"))) {
465
+ return { name: skillName, path: dirPath, source: "project" };
466
+ }
467
+ const filePath = join2(projectSkillsDir, `${skillName}.md`);
468
+ if (existsSync2(filePath)) {
469
+ return { name: skillName, path: filePath, source: "project" };
470
+ }
471
+ }
472
+ const globalSkillsDir = findGlobalSkillsDir();
473
+ if (globalSkillsDir) {
474
+ const dirPath = join2(globalSkillsDir, skillName);
475
+ if (existsSync2(dirPath) && existsSync2(join2(dirPath, "SKILL.md"))) {
476
+ return { name: skillName, path: dirPath, source: "global" };
477
+ }
478
+ const filePath = join2(globalSkillsDir, `${skillName}.md`);
479
+ if (existsSync2(filePath)) {
480
+ return { name: skillName, path: filePath, source: "global" };
481
+ }
482
+ }
483
+ return null;
484
+ }
485
+ function getSquadLocalSkills(squadDir) {
486
+ const squadSkillsDir = findSquadLocalSkillsDir(squadDir);
487
+ if (!squadSkillsDir) return [];
488
+ const skillNames = listSkillsInDir(squadSkillsDir);
489
+ const skills = [];
490
+ for (const name of skillNames) {
491
+ const resolved = resolveSkill(name, squadDir);
492
+ if (resolved && resolved.source === "squad-local") {
493
+ skills.push(resolved);
494
+ }
495
+ }
496
+ return skills;
497
+ }
498
+ function resolveMemoryPaths(patterns) {
499
+ const memoryDir = findMemoryDir();
500
+ if (!memoryDir) return [];
501
+ const resolved = [];
502
+ for (const pattern of patterns) {
503
+ if (pattern.endsWith("/*")) {
504
+ const subdir = pattern.slice(0, -2);
505
+ const subdirPath = join2(memoryDir, subdir);
506
+ if (existsSync2(subdirPath)) {
507
+ try {
508
+ const files = readdirSync(subdirPath);
509
+ for (const file of files) {
510
+ if (file.endsWith(".md")) {
511
+ resolved.push(join2(subdirPath, file));
512
+ }
513
+ }
514
+ } catch {
515
+ }
516
+ }
517
+ } else {
518
+ const fullPath = join2(memoryDir, pattern);
519
+ if (existsSync2(fullPath)) {
520
+ resolved.push(fullPath);
521
+ }
522
+ }
523
+ }
524
+ return resolved;
525
+ }
526
+ function findSquadLocalMcpConfig(squadDir) {
527
+ const squadsDir = findSquadsDir();
528
+ if (!squadsDir) return null;
529
+ const mcpConfigPath = join2(squadsDir, squadDir, "mcp.json");
530
+ return existsSync2(mcpConfigPath) ? mcpConfigPath : null;
531
+ }
532
+ function resolveExecutionContext(squad, forceRegenerate = false) {
533
+ const ctx = squad.context || {};
534
+ const squadLocalMcpConfig = findSquadLocalMcpConfig(squad.dir);
535
+ let mcpConfigPath;
536
+ let mcpSource;
537
+ let mcpServers = [];
538
+ if (squadLocalMcpConfig) {
539
+ mcpConfigPath = squadLocalMcpConfig;
540
+ mcpSource = "squad-local";
541
+ try {
542
+ const content = readFileSync2(squadLocalMcpConfig, "utf-8");
543
+ const config = JSON.parse(content);
544
+ mcpServers = Object.keys(config.mcpServers || {});
545
+ } catch {
546
+ }
547
+ } else {
548
+ const mcpResolution = resolveMcpConfig(
549
+ squad.name,
550
+ ctx.mcp,
551
+ forceRegenerate
552
+ );
553
+ mcpConfigPath = mcpResolution.path;
554
+ mcpSource = mcpResolution.source;
555
+ mcpServers = mcpResolution.servers || [];
556
+ }
557
+ const resolvedSkills = [];
558
+ const skillPaths = [];
559
+ const squadLocalSkills = getSquadLocalSkills(squad.dir);
560
+ for (const skill of squadLocalSkills) {
561
+ resolvedSkills.push(skill);
562
+ skillPaths.push(skill.path);
563
+ }
564
+ if (ctx.skills) {
565
+ for (const skillName of ctx.skills) {
566
+ if (resolvedSkills.some((s) => s.name === skillName)) {
567
+ continue;
568
+ }
569
+ const resolved = resolveSkill(skillName, squad.dir);
570
+ if (resolved) {
571
+ resolvedSkills.push(resolved);
572
+ skillPaths.push(resolved.path);
573
+ }
574
+ }
575
+ }
576
+ const memoryPaths = ctx.memory?.load ? resolveMemoryPaths(ctx.memory.load) : [];
577
+ return {
578
+ // Copy all SquadContext fields
579
+ ...ctx,
580
+ // Add squad name
581
+ squadName: squad.name,
582
+ // Add resolved paths
583
+ resolved: {
584
+ mcpConfigPath,
585
+ mcpSource,
586
+ mcpServers,
587
+ skillPaths,
588
+ // Backward compatible
589
+ skills: resolvedSkills,
590
+ // New detailed skill info
591
+ memoryPaths
592
+ }
593
+ };
594
+ }
595
+
596
+ export {
597
+ resolveMcpConfigPath,
598
+ findSquadsDir,
599
+ findProjectRoot,
600
+ hasLocalInfraConfig,
601
+ listSquads,
602
+ findSimilarSquads,
603
+ listAgents,
604
+ parseSquadFile,
605
+ loadSquad,
606
+ loadAgentDefinition,
607
+ parseAgentProvider,
608
+ addGoalToSquad,
609
+ updateGoalInSquad,
610
+ getSquadLocalSkills,
611
+ resolveExecutionContext
612
+ };
613
+ //# sourceMappingURL=chunk-TYFTF53O.js.map