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
package/dist/index.d.ts CHANGED
@@ -1,17 +1,745 @@
1
- declare const version = "0.1.0";
1
+ declare const version: string;
2
2
 
3
+ type EffortLevel = 'high' | 'medium' | 'low';
4
+ interface SquadContext {
5
+ mcp?: string[];
6
+ skills?: string[];
7
+ memory?: {
8
+ load?: string[];
9
+ };
10
+ model?: {
11
+ default?: string;
12
+ expensive?: string;
13
+ cheap?: string;
14
+ };
15
+ budget?: {
16
+ daily?: number;
17
+ weekly?: number;
18
+ perExecution?: number;
19
+ };
20
+ /** Cooldown between executions in seconds */
21
+ cooldown?: number;
22
+ }
23
+ /**
24
+ * Resolved skill with path and source information.
25
+ */
26
+ interface ResolvedSkill {
27
+ /** Skill name (directory or reference name) */
28
+ name: string;
29
+ /** Absolute path to the skill directory */
30
+ path: string;
31
+ /** Where the skill was found */
32
+ source: 'squad-local' | 'project' | 'global';
33
+ }
34
+ interface SquadProviders {
35
+ /** Default provider for all agents (default: anthropic) */
36
+ default?: string;
37
+ /** Provider for vision/image tasks */
38
+ vision?: string;
39
+ /** Provider for real-time data access */
40
+ realtime?: string;
41
+ /** Provider for high-volume/cheap operations */
42
+ cheap?: string;
43
+ /** Custom provider mappings by purpose */
44
+ [key: string]: string | undefined;
45
+ }
46
+ interface SquadFrontmatter {
47
+ name?: string;
48
+ mission?: string;
49
+ repo?: string;
50
+ stack?: string;
51
+ context?: SquadContext;
52
+ effort?: EffortLevel;
53
+ /** Multi-LLM provider configuration */
54
+ providers?: SquadProviders;
55
+ /** Squad names this squad must wait for before executing (phase ordering) */
56
+ depends_on?: string[];
57
+ }
3
58
  interface Agent {
4
59
  name: string;
5
- model: string;
6
- tools: string[];
7
- trigger: 'manual' | 'scheduled' | 'event';
60
+ role: string;
61
+ trigger: string;
62
+ status?: string;
63
+ filePath?: string;
64
+ squad?: string;
65
+ effort?: EffortLevel;
66
+ /** LLM provider override (from agent file frontmatter) */
67
+ provider?: string;
68
+ /** Agent purpose (short description) */
69
+ purpose?: string;
70
+ /** Cron schedule for scheduled agents */
71
+ schedule?: string;
72
+ /** Output destinations */
73
+ outputs?: string[];
74
+ }
75
+ interface Pipeline {
76
+ name: string;
77
+ agents: string[];
78
+ }
79
+ interface Goal {
80
+ description: string;
81
+ completed: boolean;
82
+ progress?: string;
83
+ metrics?: string[];
84
+ }
85
+ /**
86
+ * Routine definition for autonomous scheduled execution.
87
+ * Defined in SQUAD.md under ### Routines yaml block.
88
+ */
89
+ interface Routine {
90
+ /** Unique name for the routine */
91
+ name: string;
92
+ /** Cron schedule (e.g., "0 8 * * *" for daily 8am) */
93
+ schedule: string;
94
+ /** Agents to run in this batch */
95
+ agents: string[];
96
+ /** Model to use (defaults to squad default or sonnet) */
97
+ model?: string;
98
+ /** Whether the routine is enabled */
99
+ enabled?: boolean;
100
+ /** Priority for execution ordering (lower = higher priority) */
101
+ priority?: number;
102
+ /** Minimum cooldown between runs (e.g., "6 hours") */
103
+ cooldown?: string;
8
104
  }
9
105
  interface Squad {
10
106
  name: string;
107
+ /** Directory name for file path resolution (e.g., "engineering") */
108
+ dir: string;
109
+ mission: string;
11
110
  agents: Agent[];
12
- mission?: string;
111
+ pipelines: Pipeline[];
112
+ triggers: {
113
+ scheduled: string[];
114
+ event: string[];
115
+ manual: string[];
116
+ };
117
+ /** Autonomous routines for scheduled batch execution */
118
+ routines: Routine[];
119
+ dependencies: string[];
120
+ outputPath: string;
121
+ goals: Goal[];
122
+ effort?: EffortLevel;
123
+ context?: SquadContext;
124
+ repo?: string;
125
+ stack?: string;
126
+ /** Multi-LLM provider configuration */
127
+ providers?: SquadProviders;
128
+ /** Domain this squad operates in */
129
+ domain?: string;
130
+ /** Permissions for this squad */
131
+ permissions?: Record<string, boolean>;
132
+ /** Raw frontmatter for accessing KPIs and other custom fields */
133
+ frontmatter?: Record<string, unknown>;
134
+ /** Squad names this squad must wait for (phase ordering) */
135
+ depends_on?: string[];
136
+ }
137
+ /**
138
+ * Resolved execution context with paths and metadata.
139
+ * Extends SquadContext with resolved paths for MCP, skills, and memory.
140
+ */
141
+ interface ExecutionContext extends SquadContext {
142
+ /** Squad name this context belongs to */
143
+ squadName: string;
144
+ /** Resolved paths and metadata */
145
+ resolved: {
146
+ /** Path to MCP config file to use */
147
+ mcpConfigPath: string;
148
+ /** Source of MCP config resolution */
149
+ mcpSource: 'user-override' | 'generated' | 'fallback' | 'squad-local';
150
+ /** List of MCP servers in the config */
151
+ mcpServers: string[];
152
+ /** Resolved skill directory paths (deprecated, use skills instead) */
153
+ skillPaths: string[];
154
+ /** Resolved skills with source information */
155
+ skills: ResolvedSkill[];
156
+ /** Resolved memory file paths */
157
+ memoryPaths: string[];
158
+ };
159
+ }
160
+ /**
161
+ * Find the .agents/squads directory by searching current directory and parents.
162
+ * Searches up to 5 parent directories.
163
+ * @returns Path to squads directory or null if not found
164
+ */
165
+ declare function findSquadsDir(): string | null;
166
+ /**
167
+ * Find the root directory of the squads project (where .agents/ lives).
168
+ * @returns Path to project root or null if not in a squads project
169
+ */
170
+ declare function findProjectRoot(): string | null;
171
+ /**
172
+ * List all squad names in the given squads directory.
173
+ * Only includes directories containing a SQUAD.md file.
174
+ * @param squadsDir - Path to the .agents/squads directory
175
+ * @returns Array of squad directory names
176
+ */
177
+ declare function listSquads(squadsDir: string): string[];
178
+ /**
179
+ * List all agents in the squads directory or a specific squad.
180
+ * Agents are markdown files (excluding SQUAD.md) in squad directories.
181
+ * @param squadsDir - Path to the .agents/squads directory
182
+ * @param squadName - Optional squad name to filter agents
183
+ * @returns Array of Agent objects with basic metadata
184
+ */
185
+ declare function listAgents(squadsDir: string, squadName?: string): Agent[];
186
+ /**
187
+ * Parse a SQUAD.md file into a Squad object.
188
+ * Extracts frontmatter metadata, agents, pipelines, goals, and routines.
189
+ * @param filePath - Path to the SQUAD.md file
190
+ * @returns Parsed Squad object with all extracted data
191
+ */
192
+ declare function parseSquadFile(filePath: string): Squad;
193
+ /**
194
+ * Load and parse a squad by name.
195
+ * Convenience function that finds the squads directory and parses the squad file.
196
+ * @param squadName - Name of the squad directory (e.g., "engineering")
197
+ * @returns Parsed Squad object or null if not found
198
+ */
199
+ declare function loadSquad(squadName: string): Squad | null;
200
+ /**
201
+ * Load raw content of an agent definition file.
202
+ * @param agentPath - Path to the agent markdown file
203
+ * @returns Raw file content or empty string if file doesn't exist
204
+ */
205
+ declare function loadAgentDefinition(agentPath: string): string;
206
+ /**
207
+ * Add a new goal to a squad's SQUAD.md file.
208
+ * Creates the Goals section if it doesn't exist.
209
+ * @param squadName - Name of the squad directory
210
+ * @param goal - Goal description text
211
+ * @returns True if goal was added successfully
212
+ */
213
+ declare function addGoalToSquad(squadName: string, goal: string): boolean;
214
+ /**
215
+ * Update an existing goal in a squad's SQUAD.md file.
216
+ * Can mark goal as completed or update progress text.
217
+ * @param squadName - Name of the squad directory
218
+ * @param goalIndex - Zero-based index of the goal to update
219
+ * @param updates - Object with optional completed and progress fields
220
+ * @returns True if goal was updated successfully
221
+ */
222
+ declare function updateGoalInSquad(squadName: string, goalIndex: number, updates: {
223
+ completed?: boolean;
224
+ progress?: string;
225
+ }): boolean;
226
+ /**
227
+ * Get all available squad-local skills for a squad.
228
+ * Scans .agents/squads/<squad>/skills/ directory.
229
+ */
230
+ declare function getSquadLocalSkills(squadDir: string): ResolvedSkill[];
231
+ /**
232
+ * Resolve execution context for a squad.
233
+ *
234
+ * Takes a Squad object and resolves all context references to actual paths:
235
+ * - MCP config path (four-tier resolution: squad-local, user-override, generated, fallback)
236
+ * - Skill directory paths (three-tier: squad-local, project, global)
237
+ * - Memory file paths
238
+ *
239
+ * @param squad - The squad to resolve context for
240
+ * @param forceRegenerate - Force MCP config regeneration
241
+ * @returns Resolved execution context with all paths
242
+ */
243
+ declare function resolveExecutionContext(squad: Squad, forceRegenerate?: boolean): ExecutionContext;
244
+
245
+ /**
246
+ * Token estimation and tracking for context compression.
247
+ *
248
+ * Uses character-based heuristics for speed (no API calls needed).
249
+ * ~4 characters per token is a reasonable approximation for English text.
250
+ */
251
+ declare const RATIOS: {
252
+ readonly english: 4;
253
+ readonly code: 3.5;
254
+ readonly json: 3;
255
+ readonly mixed: 3.75;
256
+ };
257
+ type ContentType = keyof typeof RATIOS;
258
+ /**
259
+ * Estimate token count from text content.
260
+ *
261
+ * @param text - The text to estimate tokens for
262
+ * @param type - Content type hint for better accuracy
263
+ * @returns Estimated token count
264
+ */
265
+ declare function estimateTokens(text: string, type?: ContentType): number;
266
+ /**
267
+ * Estimate tokens for a message object (handles different formats).
268
+ */
269
+ declare function estimateMessageTokens(message: {
270
+ role?: string;
271
+ content?: string | Array<{
272
+ type: string;
273
+ text?: string;
274
+ }>;
275
+ }): number;
276
+ /**
277
+ * Token usage tracker for a session.
278
+ */
279
+ interface TokenTracker {
280
+ /** Total tokens used so far */
281
+ used: number;
282
+ /** Model's context limit */
283
+ limit: number;
284
+ /** Usage as percentage (0-1) */
285
+ percentage: number;
286
+ /** Breakdown by category */
287
+ breakdown: {
288
+ system: number;
289
+ user: number;
290
+ assistant: number;
291
+ tools: number;
292
+ };
293
+ }
294
+ /**
295
+ * Create a new token tracker for a session.
296
+ *
297
+ * @param model - Model name to determine context limit
298
+ * @returns Fresh token tracker
299
+ */
300
+ declare function createTracker(model?: string): TokenTracker;
301
+ /**
302
+ * Update tracker with new content.
303
+ *
304
+ * @param tracker - Tracker to update (mutated in place)
305
+ * @param content - Content to add
306
+ * @param category - Category for breakdown tracking
307
+ */
308
+ declare function updateTracker(tracker: TokenTracker, content: string, category?: keyof TokenTracker['breakdown']): void;
309
+ /**
310
+ * Check if compression is needed based on thresholds.
311
+ */
312
+ type CompressionLevel = 'none' | 'light' | 'medium' | 'heavy';
313
+ interface ThresholdConfig {
314
+ light: number;
315
+ medium: number;
316
+ heavy: number;
317
+ }
318
+ /**
319
+ * Determine what level of compression is needed.
320
+ *
321
+ * @param tracker - Current token tracker state
322
+ * @param thresholds - Custom thresholds (optional)
323
+ * @returns Compression level needed
324
+ */
325
+ declare function getCompressionLevel(tracker: TokenTracker, thresholds?: ThresholdConfig): CompressionLevel;
326
+ /**
327
+ * Format tracker status for display.
328
+ */
329
+ declare function formatTrackerStatus(tracker: TokenTracker): string;
330
+
331
+ /**
332
+ * File deduplication for context compression.
333
+ *
334
+ * Tracks file reads across a conversation and replaces duplicate
335
+ * reads with concise references to save tokens.
336
+ *
337
+ * Based on Cline's approach: keeping only the latest version of each
338
+ * file prevents LLM confusion during edit operations.
339
+ */
340
+ /**
341
+ * Record of a file read in the conversation.
342
+ */
343
+ interface FileReadRecord {
344
+ /** File path that was read */
345
+ path: string;
346
+ /** Turn index where the read occurred */
347
+ turnIndex: number;
348
+ /** Estimated token count of the content */
349
+ tokenCount: number;
350
+ /** Hash of content for change detection */
351
+ contentHash: string;
352
+ }
353
+ /**
354
+ * Tracks file reads across a conversation for deduplication.
355
+ */
356
+ declare class FileDeduplicator {
357
+ /** Map of file path to all reads of that file */
358
+ private reads;
359
+ /** Current turn index */
360
+ private currentTurn;
361
+ /**
362
+ * Record a file read.
363
+ *
364
+ * @param path - File path that was read
365
+ * @param content - File content that was read
366
+ */
367
+ trackRead(path: string, content: string): void;
368
+ /**
369
+ * Advance to next turn.
370
+ */
371
+ nextTurn(): void;
372
+ /**
373
+ * Get current turn index.
374
+ */
375
+ getTurn(): number;
376
+ /**
377
+ * Check if a file has been read before.
378
+ *
379
+ * @param path - File path to check
380
+ * @returns Previous read record if exists
381
+ */
382
+ getPreviousRead(path: string): FileReadRecord | undefined;
383
+ /**
384
+ * Get all files that have been read multiple times.
385
+ *
386
+ * @returns Map of path to read count
387
+ */
388
+ getDuplicateReads(): Map<string, number>;
389
+ /**
390
+ * Calculate potential token savings from deduplication.
391
+ */
392
+ getPotentialSavings(): number;
393
+ /**
394
+ * Generate a deduplication reference message.
395
+ *
396
+ * @param path - File path
397
+ * @param previousTurn - Turn where file was previously read
398
+ */
399
+ static createReference(path: string, previousTurn: number): string;
400
+ /**
401
+ * Reset tracker state.
402
+ */
403
+ reset(): void;
404
+ /**
405
+ * Get statistics for debugging.
406
+ */
407
+ getStats(): {
408
+ filesTracked: number;
409
+ totalReads: number;
410
+ duplicateReads: number;
411
+ potentialSavings: number;
412
+ };
413
+ }
414
+
415
+ /**
416
+ * Token-based pruning for context compression.
417
+ *
418
+ * Based on OpenCode's approach: protect recent tool outputs (40K tokens)
419
+ * while pruning older outputs that exceed the threshold.
420
+ *
421
+ * Key insight: Recent context is critical for coherence. Older tool
422
+ * outputs can be removed entirely without summarization.
423
+ */
424
+ /**
425
+ * Configuration for token pruning.
426
+ */
427
+ interface PruneConfig {
428
+ /** Tokens to protect from pruning (recent window). Default: 40000 */
429
+ protectRecent: number;
430
+ /** Minimum tokens that must be prunable before we prune. Default: 20000 */
431
+ minimumPrunable: number;
432
+ /** Tool types that should never be pruned */
433
+ protectedTools: string[];
434
+ }
435
+ /**
436
+ * Message structure for pruning.
437
+ */
438
+ interface PrunableMessage {
439
+ role: string;
440
+ content: string | Array<MessagePart>;
441
+ /** Internal: marks message as prunable */
442
+ _prunable?: boolean;
443
+ /** Internal: token count for this message */
444
+ _tokens?: number;
445
+ }
446
+ interface MessagePart {
447
+ type: string;
448
+ text?: string;
449
+ tool_use_id?: string;
450
+ name?: string;
451
+ /** Internal: marks part as pruned */
452
+ _pruned?: boolean;
453
+ /** Internal: timestamp when pruned */
454
+ _prunedAt?: number;
455
+ }
456
+ /**
457
+ * Token pruner for conversation context.
458
+ */
459
+ declare class TokenPruner {
460
+ private config;
461
+ constructor(config?: Partial<PruneConfig>);
462
+ /**
463
+ * Prune messages to reduce token count.
464
+ *
465
+ * Strategy:
466
+ * 1. Scan messages backward from newest to oldest
467
+ * 2. Accumulate tokens for tool outputs
468
+ * 3. Mark outputs beyond protection window for pruning
469
+ * 4. Replace pruned outputs with placeholders
470
+ *
471
+ * @param messages - Messages to prune
472
+ * @returns Pruned messages (new array, originals not mutated)
473
+ */
474
+ pruneMessages(messages: PrunableMessage[]): PrunableMessage[];
475
+ /**
476
+ * Analyze which messages can be pruned.
477
+ */
478
+ private analyzePrunability;
479
+ /**
480
+ * Apply pruning to messages before the protection index.
481
+ */
482
+ private applyPruning;
483
+ /**
484
+ * Create a pruned version of a message.
485
+ */
486
+ private createPrunedMessage;
487
+ /**
488
+ * Check if a message is a tool result.
489
+ */
490
+ private isToolResult;
491
+ /**
492
+ * Check if a tool is in the protected list.
493
+ */
494
+ private isProtectedTool;
495
+ /**
496
+ * Extract tool name from a message.
497
+ */
498
+ private getToolName;
499
+ /**
500
+ * Get statistics about potential pruning.
501
+ */
502
+ getStats(messages: PrunableMessage[]): {
503
+ totalTokens: number;
504
+ prunableTokens: number;
505
+ protectedTokens: number;
506
+ savingsPercentage: number;
507
+ };
508
+ }
509
+
510
+ /**
511
+ * LLM-based summarization for heavy context compression.
512
+ *
513
+ * Based on OpenHands' Context Condenser approach:
514
+ * - Keep first N events (initial context)
515
+ * - Keep last M events (recent context)
516
+ * - Summarize the middle section via LLM
517
+ *
518
+ * This is the "last resort" compression - only used when at 95%+ context.
519
+ */
520
+ /**
521
+ * Configuration for LLM summarization.
522
+ */
523
+ interface SummaryConfig {
524
+ /** Number of messages to preserve from start. Default: 4 */
525
+ keepFirst: number;
526
+ /** Number of messages to preserve from end. Default: 20 */
527
+ keepLast: number;
528
+ /** Model to use for summarization. Default: 'claude-3-5-haiku-20241022' */
529
+ model: string;
530
+ /** Maximum tokens for summary output. Default: 2000 */
531
+ maxSummaryTokens: number;
532
+ }
533
+ /**
534
+ * Message structure for summarization.
535
+ */
536
+ interface SummarizableMessage {
537
+ role: string;
538
+ content: string | Array<{
539
+ type: string;
540
+ text?: string;
541
+ }>;
542
+ }
543
+ /**
544
+ * LLM-based conversation summarizer.
545
+ */
546
+ declare class ConversationSummarizer {
547
+ private config;
548
+ private client;
549
+ constructor(config?: Partial<SummaryConfig>);
550
+ /**
551
+ * Get or create Anthropic client.
552
+ */
553
+ private getClient;
554
+ /**
555
+ * Summarize messages to reduce token count.
556
+ *
557
+ * Strategy:
558
+ * 1. Keep first N messages (system prompt, initial context)
559
+ * 2. Keep last M messages (recent context, current task)
560
+ * 3. Summarize everything in between
561
+ *
562
+ * @param messages - Messages to summarize
563
+ * @returns Summarized messages
564
+ */
565
+ summarize(messages: SummarizableMessage[]): Promise<SummarizableMessage[]>;
566
+ /**
567
+ * Generate a summary of the middle messages.
568
+ */
569
+ private generateSummary;
570
+ /**
571
+ * Format messages for the summarization prompt.
572
+ */
573
+ private formatMessagesForSummary;
574
+ /**
575
+ * Extract text content from a message.
576
+ */
577
+ private extractContent;
578
+ /**
579
+ * Truncate very long content for summary input.
580
+ */
581
+ private truncateContent;
582
+ /**
583
+ * Estimate the cost of summarization.
584
+ *
585
+ * @param messages - Messages that would be summarized
586
+ * @returns Estimated cost in USD
587
+ */
588
+ estimateCost(messages: SummarizableMessage[]): number;
589
+ /**
590
+ * Get statistics about potential summarization.
591
+ */
592
+ getStats(messages: SummarizableMessage[]): {
593
+ totalMessages: number;
594
+ wouldKeep: number;
595
+ wouldSummarize: number;
596
+ estimatedCost: number;
597
+ };
598
+ }
599
+
600
+ /**
601
+ * Context Condenser - Main Pipeline
602
+ *
603
+ * Coordinates the three compression strategies:
604
+ * 1. Deduplication (70% threshold) - Replace duplicate file reads
605
+ * 2. Pruning (85% threshold) - Remove old tool outputs
606
+ * 3. Summarization (95% threshold) - LLM-based middle section summary
607
+ *
608
+ * Based on patterns from OpenCode, OpenHands, and Cline.
609
+ */
610
+
611
+ /**
612
+ * Configuration for the context condenser.
613
+ */
614
+ interface CondenserConfig {
615
+ /** Whether context compression is enabled */
616
+ enabled: boolean;
617
+ /** Threshold for light compression (deduplication) */
618
+ lightThreshold: number;
619
+ /** Threshold for medium compression (pruning) */
620
+ mediumThreshold: number;
621
+ /** Threshold for heavy compression (summarization) */
622
+ heavyThreshold: number;
623
+ /** Model context limit */
624
+ modelLimit: number;
625
+ /** Model name for tracking */
626
+ model: string;
627
+ /** Pruning configuration */
628
+ pruning: Partial<PruneConfig>;
629
+ /** Summarization configuration */
630
+ summarization: Partial<SummaryConfig>;
631
+ }
632
+ /**
633
+ * Message type for the condenser pipeline.
634
+ */
635
+ interface CondenserMessage extends PrunableMessage, SummarizableMessage {
636
+ role: string;
637
+ content: string | Array<{
638
+ type: string;
639
+ text?: string;
640
+ tool_use_id?: string;
641
+ name?: string;
642
+ }>;
643
+ }
644
+ /**
645
+ * Result of a condense operation.
646
+ */
647
+ interface CondenserResult {
648
+ /** Condensed messages */
649
+ messages: CondenserMessage[];
650
+ /** Compression level applied */
651
+ level: CompressionLevel;
652
+ /** Tokens before compression */
653
+ tokensBefore: number;
654
+ /** Tokens after compression */
655
+ tokensAfter: number;
656
+ /** Savings percentage */
657
+ savingsPercentage: number;
658
+ /** Duration in milliseconds */
659
+ durationMs: number;
660
+ }
661
+ /**
662
+ * Context Condenser - Main class.
663
+ */
664
+ declare class ContextCondenser {
665
+ private config;
666
+ private tracker;
667
+ private deduplicator;
668
+ private pruner;
669
+ private summarizer;
670
+ /** Metrics for tracking */
671
+ private metrics;
672
+ constructor(config?: Partial<CondenserConfig>);
673
+ /**
674
+ * Main entry point - condense messages if needed.
675
+ *
676
+ * @param messages - Current conversation messages
677
+ * @returns Condensed messages and metadata
678
+ */
679
+ condense(messages: CondenserMessage[]): Promise<CondenserResult>;
680
+ /**
681
+ * Apply light compression (deduplication).
682
+ */
683
+ private applyDeduplication;
684
+ /**
685
+ * Apply medium compression (pruning).
686
+ */
687
+ private applyPruning;
688
+ /**
689
+ * Apply heavy compression (summarization).
690
+ */
691
+ private applySummarization;
692
+ /**
693
+ * Update tracker from messages.
694
+ */
695
+ private updateTrackerFromMessages;
696
+ /**
697
+ * Create result object.
698
+ */
699
+ private createResult;
700
+ /**
701
+ * Estimate tokens for messages.
702
+ */
703
+ private estimateTokens;
704
+ /**
705
+ * Get current tracker status.
706
+ */
707
+ getStatus(): string;
708
+ /**
709
+ * Get tracker for external monitoring.
710
+ */
711
+ getTracker(): TokenTracker;
712
+ /**
713
+ * Get metrics.
714
+ */
715
+ getMetrics(): typeof this.metrics;
716
+ /**
717
+ * Check if compression is needed.
718
+ */
719
+ needsCompression(): CompressionLevel;
720
+ /**
721
+ * Reset condenser state.
722
+ */
723
+ reset(): void;
724
+ /**
725
+ * Get file deduplicator for integration with tool layer.
726
+ */
727
+ getDeduplicator(): FileDeduplicator;
13
728
  }
14
- declare function loadSquad(path: string): Promise<Squad | null>;
15
- declare function runAgent(agent: Agent, prompt: string): Promise<string>;
729
+ /**
730
+ * Create a condenser with squad-specific configuration.
731
+ */
732
+ declare function createCondenser(squadConfig?: {
733
+ condenser?: {
734
+ enabled?: boolean;
735
+ light_threshold?: number;
736
+ medium_threshold?: number;
737
+ heavy_threshold?: number;
738
+ protect_recent?: number;
739
+ };
740
+ model?: {
741
+ default?: string;
742
+ };
743
+ }): ContextCondenser;
16
744
 
17
- export { type Agent, type Squad, loadSquad, runAgent, version };
745
+ export { type Agent, type CompressionLevel, type CondenserConfig, type CondenserMessage, type CondenserResult, ContextCondenser, ConversationSummarizer, type EffortLevel, type ExecutionContext, FileDeduplicator, type Goal, type Pipeline, type ResolvedSkill, type Squad, type SquadContext, type SquadFrontmatter, type ThresholdConfig, TokenPruner, type TokenTracker, addGoalToSquad, createCondenser, createTracker, estimateMessageTokens, estimateTokens, findProjectRoot, findSquadsDir, formatTrackerStatus, getCompressionLevel, getSquadLocalSkills, listAgents, listSquads, loadAgentDefinition, loadSquad, parseSquadFile, resolveExecutionContext, updateGoalInSquad, updateTracker, version };