@bradygaster/squad-sdk 0.7.0 → 0.8.2-1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (443) hide show
  1. package/README.md +3 -3
  2. package/dist/adapter/client.d.ts +246 -0
  3. package/dist/adapter/client.d.ts.map +1 -0
  4. package/dist/adapter/client.js +699 -0
  5. package/dist/adapter/client.js.map +1 -0
  6. package/dist/adapter/errors.d.ts +260 -0
  7. package/dist/adapter/errors.d.ts.map +1 -0
  8. package/dist/adapter/errors.js +362 -0
  9. package/dist/adapter/errors.js.map +1 -0
  10. package/dist/adapter/types.d.ts +817 -0
  11. package/dist/adapter/types.d.ts.map +1 -0
  12. package/dist/adapter/types.js +11 -0
  13. package/dist/adapter/types.js.map +1 -0
  14. package/dist/agents/charter-compiler.d.ts +106 -0
  15. package/dist/agents/charter-compiler.d.ts.map +1 -0
  16. package/dist/agents/charter-compiler.js +165 -0
  17. package/dist/agents/charter-compiler.js.map +1 -0
  18. package/dist/agents/history-shadow.d.ts +80 -0
  19. package/dist/agents/history-shadow.d.ts.map +1 -0
  20. package/dist/agents/history-shadow.js +239 -0
  21. package/dist/agents/history-shadow.js.map +1 -0
  22. package/dist/agents/index.d.ts +71 -0
  23. package/dist/agents/index.d.ts.map +1 -0
  24. package/dist/agents/index.js +183 -0
  25. package/dist/agents/index.js.map +1 -0
  26. package/dist/agents/lifecycle.d.ts +138 -0
  27. package/dist/agents/lifecycle.d.ts.map +1 -0
  28. package/dist/agents/lifecycle.js +284 -0
  29. package/dist/agents/lifecycle.js.map +1 -0
  30. package/dist/agents/model-selector.d.ts +80 -0
  31. package/dist/agents/model-selector.d.ts.map +1 -0
  32. package/dist/agents/model-selector.js +171 -0
  33. package/dist/agents/model-selector.js.map +1 -0
  34. package/dist/agents/onboarding.d.ts +65 -0
  35. package/dist/agents/onboarding.d.ts.map +1 -0
  36. package/dist/agents/onboarding.js +373 -0
  37. package/dist/agents/onboarding.js.map +1 -0
  38. package/dist/build/bundle.d.ts +32 -0
  39. package/dist/build/bundle.d.ts.map +1 -0
  40. package/dist/build/bundle.js +97 -0
  41. package/dist/build/bundle.js.map +1 -0
  42. package/dist/build/ci-pipeline.d.ts +51 -0
  43. package/dist/build/ci-pipeline.d.ts.map +1 -0
  44. package/dist/build/ci-pipeline.js +180 -0
  45. package/dist/build/ci-pipeline.js.map +1 -0
  46. package/dist/build/github-dist.d.ts +37 -0
  47. package/dist/build/github-dist.d.ts.map +1 -0
  48. package/dist/build/github-dist.js +117 -0
  49. package/dist/build/github-dist.js.map +1 -0
  50. package/dist/build/index.d.ts +11 -0
  51. package/dist/build/index.d.ts.map +1 -0
  52. package/dist/build/index.js +11 -0
  53. package/dist/build/index.js.map +1 -0
  54. package/dist/build/install-migration.d.ts +28 -0
  55. package/dist/build/install-migration.d.ts.map +1 -0
  56. package/dist/build/install-migration.js +103 -0
  57. package/dist/build/install-migration.js.map +1 -0
  58. package/dist/build/npm-package.d.ts +54 -0
  59. package/dist/build/npm-package.d.ts.map +1 -0
  60. package/dist/build/npm-package.js +128 -0
  61. package/dist/build/npm-package.js.map +1 -0
  62. package/dist/build/release.d.ts +108 -0
  63. package/dist/build/release.d.ts.map +1 -0
  64. package/dist/build/release.js +295 -0
  65. package/dist/build/release.js.map +1 -0
  66. package/dist/build/versioning.d.ts +38 -0
  67. package/dist/build/versioning.d.ts.map +1 -0
  68. package/dist/build/versioning.js +113 -0
  69. package/dist/build/versioning.js.map +1 -0
  70. package/dist/builders/index.d.ts +156 -0
  71. package/dist/builders/index.d.ts.map +1 -0
  72. package/dist/builders/index.js +404 -0
  73. package/dist/builders/index.js.map +1 -0
  74. package/dist/builders/types.d.ts +187 -0
  75. package/dist/builders/types.d.ts.map +1 -0
  76. package/dist/builders/types.js +12 -0
  77. package/dist/builders/types.js.map +1 -0
  78. package/dist/casting/casting-engine.d.ts +60 -0
  79. package/dist/casting/casting-engine.d.ts.map +1 -0
  80. package/dist/casting/casting-engine.js +223 -0
  81. package/dist/casting/casting-engine.js.map +1 -0
  82. package/dist/casting/casting-history.d.ts +54 -0
  83. package/dist/casting/casting-history.d.ts.map +1 -0
  84. package/dist/casting/casting-history.js +63 -0
  85. package/dist/casting/casting-history.js.map +1 -0
  86. package/dist/casting/index.d.ts +46 -0
  87. package/dist/casting/index.d.ts.map +1 -0
  88. package/dist/casting/index.js +45 -0
  89. package/dist/casting/index.js.map +1 -0
  90. package/dist/client/event-bus.d.ts +29 -0
  91. package/dist/client/event-bus.d.ts.map +1 -0
  92. package/dist/client/event-bus.js +52 -0
  93. package/dist/client/event-bus.js.map +1 -0
  94. package/dist/client/index.d.ts +103 -0
  95. package/dist/client/index.d.ts.map +1 -0
  96. package/dist/client/index.js +182 -0
  97. package/dist/client/index.js.map +1 -0
  98. package/dist/client/session-pool.d.ts +66 -0
  99. package/dist/client/session-pool.d.ts.map +1 -0
  100. package/dist/client/session-pool.js +145 -0
  101. package/dist/client/session-pool.js.map +1 -0
  102. package/dist/config/agent-doc.d.ts +43 -0
  103. package/dist/config/agent-doc.d.ts.map +1 -0
  104. package/dist/config/agent-doc.js +158 -0
  105. package/dist/config/agent-doc.js.map +1 -0
  106. package/dist/config/agent-source.d.ts +95 -0
  107. package/dist/config/agent-source.d.ts.map +1 -0
  108. package/dist/config/agent-source.js +274 -0
  109. package/dist/config/agent-source.js.map +1 -0
  110. package/dist/config/doc-sync.d.ts +66 -0
  111. package/dist/config/doc-sync.d.ts.map +1 -0
  112. package/dist/config/doc-sync.js +270 -0
  113. package/dist/config/doc-sync.js.map +1 -0
  114. package/dist/config/feature-audit.d.ts +49 -0
  115. package/dist/config/feature-audit.d.ts.map +1 -0
  116. package/dist/config/feature-audit.js +148 -0
  117. package/dist/config/feature-audit.js.map +1 -0
  118. package/dist/config/index.d.ts +15 -0
  119. package/dist/config/index.d.ts.map +1 -0
  120. package/dist/config/index.js +15 -0
  121. package/dist/config/index.js.map +1 -0
  122. package/dist/config/init.d.ts +86 -0
  123. package/dist/config/init.d.ts.map +1 -0
  124. package/dist/config/init.js +807 -0
  125. package/dist/config/init.js.map +1 -0
  126. package/dist/config/legacy-fallback.d.ts +83 -0
  127. package/dist/config/legacy-fallback.d.ts.map +1 -0
  128. package/dist/config/legacy-fallback.js +212 -0
  129. package/dist/config/legacy-fallback.js.map +1 -0
  130. package/dist/config/markdown-migration.d.ts +157 -0
  131. package/dist/config/markdown-migration.d.ts.map +1 -0
  132. package/dist/config/markdown-migration.js +434 -0
  133. package/dist/config/markdown-migration.js.map +1 -0
  134. package/dist/config/migration.d.ts +123 -0
  135. package/dist/config/migration.d.ts.map +1 -0
  136. package/dist/config/migration.js +273 -0
  137. package/dist/config/migration.js.map +1 -0
  138. package/dist/config/migrations/index.d.ts +36 -0
  139. package/dist/config/migrations/index.d.ts.map +1 -0
  140. package/dist/config/migrations/index.js +216 -0
  141. package/dist/config/migrations/index.js.map +1 -0
  142. package/dist/config/models.d.ts +134 -0
  143. package/dist/config/models.d.ts.map +1 -0
  144. package/dist/config/models.js +354 -0
  145. package/dist/config/models.js.map +1 -0
  146. package/dist/config/routing.d.ts +118 -0
  147. package/dist/config/routing.d.ts.map +1 -0
  148. package/dist/config/routing.js +247 -0
  149. package/dist/config/routing.js.map +1 -0
  150. package/dist/config/schema.d.ts +72 -0
  151. package/dist/config/schema.d.ts.map +1 -0
  152. package/dist/config/schema.js +63 -0
  153. package/dist/config/schema.js.map +1 -0
  154. package/dist/coordinator/coordinator.d.ts +82 -0
  155. package/dist/coordinator/coordinator.d.ts.map +1 -0
  156. package/dist/coordinator/coordinator.js +192 -0
  157. package/dist/coordinator/coordinator.js.map +1 -0
  158. package/dist/coordinator/direct-response.d.ts +83 -0
  159. package/dist/coordinator/direct-response.d.ts.map +1 -0
  160. package/dist/coordinator/direct-response.js +187 -0
  161. package/dist/coordinator/direct-response.js.map +1 -0
  162. package/dist/coordinator/fan-out.d.ts +83 -0
  163. package/dist/coordinator/fan-out.d.ts.map +1 -0
  164. package/dist/coordinator/fan-out.js +161 -0
  165. package/dist/coordinator/fan-out.js.map +1 -0
  166. package/dist/coordinator/index.d.ts +62 -0
  167. package/dist/coordinator/index.d.ts.map +1 -0
  168. package/dist/coordinator/index.js +177 -0
  169. package/dist/coordinator/index.js.map +1 -0
  170. package/dist/coordinator/response-tiers.d.ts +49 -0
  171. package/dist/coordinator/response-tiers.d.ts.map +1 -0
  172. package/dist/coordinator/response-tiers.js +149 -0
  173. package/dist/coordinator/response-tiers.js.map +1 -0
  174. package/dist/hooks/index.d.ts +103 -0
  175. package/dist/hooks/index.d.ts.map +1 -0
  176. package/dist/hooks/index.js +279 -0
  177. package/dist/hooks/index.js.map +1 -0
  178. package/dist/index.d.ts +37 -1
  179. package/dist/index.d.ts.map +1 -1
  180. package/dist/index.js +37 -3
  181. package/dist/index.js.map +1 -1
  182. package/dist/marketplace/backend.d.ts +35 -0
  183. package/dist/marketplace/backend.d.ts.map +1 -0
  184. package/dist/marketplace/backend.js +99 -0
  185. package/dist/marketplace/backend.js.map +1 -0
  186. package/dist/marketplace/browser.d.ts +33 -0
  187. package/dist/marketplace/browser.d.ts.map +1 -0
  188. package/dist/marketplace/browser.js +97 -0
  189. package/dist/marketplace/browser.js.map +1 -0
  190. package/dist/marketplace/extension-adapter.d.ts +51 -0
  191. package/dist/marketplace/extension-adapter.d.ts.map +1 -0
  192. package/dist/marketplace/extension-adapter.js +81 -0
  193. package/dist/marketplace/extension-adapter.js.map +1 -0
  194. package/dist/marketplace/index.d.ts +51 -0
  195. package/dist/marketplace/index.d.ts.map +1 -0
  196. package/dist/marketplace/index.js +108 -0
  197. package/dist/marketplace/index.js.map +1 -0
  198. package/dist/marketplace/packaging.d.ts +25 -0
  199. package/dist/marketplace/packaging.d.ts.map +1 -0
  200. package/dist/marketplace/packaging.js +117 -0
  201. package/dist/marketplace/packaging.js.map +1 -0
  202. package/dist/marketplace/schema.d.ts +50 -0
  203. package/dist/marketplace/schema.d.ts.map +1 -0
  204. package/dist/marketplace/schema.js +120 -0
  205. package/dist/marketplace/schema.js.map +1 -0
  206. package/dist/marketplace/security.d.ts +26 -0
  207. package/dist/marketplace/security.d.ts.map +1 -0
  208. package/dist/marketplace/security.js +199 -0
  209. package/dist/marketplace/security.js.map +1 -0
  210. package/dist/multi-squad.d.ts +89 -0
  211. package/dist/multi-squad.d.ts.map +1 -0
  212. package/dist/multi-squad.js +233 -0
  213. package/dist/multi-squad.js.map +1 -0
  214. package/dist/parsers.d.ts +15 -0
  215. package/dist/parsers.d.ts.map +1 -0
  216. package/dist/parsers.js +15 -0
  217. package/dist/parsers.js.map +1 -0
  218. package/dist/ralph/index.d.ts +58 -0
  219. package/dist/ralph/index.d.ts.map +1 -0
  220. package/dist/ralph/index.js +128 -0
  221. package/dist/ralph/index.js.map +1 -0
  222. package/dist/ralph/triage.d.ts +48 -0
  223. package/dist/ralph/triage.d.ts.map +1 -0
  224. package/dist/ralph/triage.js +310 -0
  225. package/dist/ralph/triage.js.map +1 -0
  226. package/dist/remote/bridge.d.ts +79 -0
  227. package/dist/remote/bridge.d.ts.map +1 -0
  228. package/dist/remote/bridge.js +583 -0
  229. package/dist/remote/bridge.js.map +1 -0
  230. package/dist/remote/index.d.ts +7 -0
  231. package/dist/remote/index.d.ts.map +1 -0
  232. package/dist/remote/index.js +6 -0
  233. package/dist/remote/index.js.map +1 -0
  234. package/dist/remote/protocol.d.ts +130 -0
  235. package/dist/remote/protocol.d.ts.map +1 -0
  236. package/dist/remote/protocol.js +25 -0
  237. package/dist/remote/protocol.js.map +1 -0
  238. package/dist/remote/types.d.ts +34 -0
  239. package/dist/remote/types.d.ts.map +1 -0
  240. package/dist/remote/types.js +5 -0
  241. package/dist/remote/types.js.map +1 -0
  242. package/dist/resolution.d.ts +119 -0
  243. package/dist/resolution.d.ts.map +1 -0
  244. package/dist/resolution.js +259 -0
  245. package/dist/resolution.js.map +1 -0
  246. package/dist/runtime/benchmarks.d.ts +121 -0
  247. package/dist/runtime/benchmarks.d.ts.map +1 -0
  248. package/dist/runtime/benchmarks.js +251 -0
  249. package/dist/runtime/benchmarks.js.map +1 -0
  250. package/dist/runtime/config.d.ts +314 -0
  251. package/dist/runtime/config.d.ts.map +1 -0
  252. package/dist/runtime/config.js +467 -0
  253. package/dist/runtime/config.js.map +1 -0
  254. package/dist/runtime/constants.d.ts +37 -0
  255. package/dist/runtime/constants.d.ts.map +1 -0
  256. package/dist/runtime/constants.js +60 -0
  257. package/dist/runtime/constants.js.map +1 -0
  258. package/dist/runtime/cost-tracker.d.ts +73 -0
  259. package/dist/runtime/cost-tracker.d.ts.map +1 -0
  260. package/dist/runtime/cost-tracker.js +157 -0
  261. package/dist/runtime/cost-tracker.js.map +1 -0
  262. package/dist/runtime/event-bus-ws-bridge.d.ts +35 -0
  263. package/dist/runtime/event-bus-ws-bridge.d.ts.map +1 -0
  264. package/dist/runtime/event-bus-ws-bridge.js +55 -0
  265. package/dist/runtime/event-bus-ws-bridge.js.map +1 -0
  266. package/dist/runtime/event-bus.d.ts +190 -0
  267. package/dist/runtime/event-bus.d.ts.map +1 -0
  268. package/dist/runtime/event-bus.js +218 -0
  269. package/dist/runtime/event-bus.js.map +1 -0
  270. package/dist/runtime/event-payloads.d.ts +108 -0
  271. package/dist/runtime/event-payloads.d.ts.map +1 -0
  272. package/dist/runtime/event-payloads.js +28 -0
  273. package/dist/runtime/event-payloads.js.map +1 -0
  274. package/dist/runtime/health.d.ts +66 -0
  275. package/dist/runtime/health.d.ts.map +1 -0
  276. package/dist/runtime/health.js +112 -0
  277. package/dist/runtime/health.js.map +1 -0
  278. package/dist/runtime/i18n.d.ts +54 -0
  279. package/dist/runtime/i18n.d.ts.map +1 -0
  280. package/dist/runtime/i18n.js +126 -0
  281. package/dist/runtime/i18n.js.map +1 -0
  282. package/dist/runtime/offline.d.ts +64 -0
  283. package/dist/runtime/offline.d.ts.map +1 -0
  284. package/dist/runtime/offline.js +108 -0
  285. package/dist/runtime/offline.js.map +1 -0
  286. package/dist/runtime/otel-api.d.ts +38 -0
  287. package/dist/runtime/otel-api.d.ts.map +1 -0
  288. package/dist/runtime/otel-api.js +94 -0
  289. package/dist/runtime/otel-api.js.map +1 -0
  290. package/dist/runtime/otel-bridge.d.ts +52 -0
  291. package/dist/runtime/otel-bridge.d.ts.map +1 -0
  292. package/dist/runtime/otel-bridge.js +132 -0
  293. package/dist/runtime/otel-bridge.js.map +1 -0
  294. package/dist/runtime/otel-init.d.ts +84 -0
  295. package/dist/runtime/otel-init.d.ts.map +1 -0
  296. package/dist/runtime/otel-init.js +86 -0
  297. package/dist/runtime/otel-init.js.map +1 -0
  298. package/dist/runtime/otel-metrics.d.ts +42 -0
  299. package/dist/runtime/otel-metrics.d.ts.map +1 -0
  300. package/dist/runtime/otel-metrics.js +196 -0
  301. package/dist/runtime/otel-metrics.js.map +1 -0
  302. package/dist/runtime/otel.d.ts +55 -0
  303. package/dist/runtime/otel.d.ts.map +1 -0
  304. package/dist/runtime/otel.js +165 -0
  305. package/dist/runtime/otel.js.map +1 -0
  306. package/dist/runtime/squad-observer.d.ts +75 -0
  307. package/dist/runtime/squad-observer.d.ts.map +1 -0
  308. package/dist/runtime/squad-observer.js +190 -0
  309. package/dist/runtime/squad-observer.js.map +1 -0
  310. package/dist/runtime/streaming.d.ts +106 -0
  311. package/dist/runtime/streaming.d.ts.map +1 -0
  312. package/dist/runtime/streaming.js +192 -0
  313. package/dist/runtime/streaming.js.map +1 -0
  314. package/dist/runtime/telemetry.d.ts +82 -0
  315. package/dist/runtime/telemetry.d.ts.map +1 -0
  316. package/dist/runtime/telemetry.js +120 -0
  317. package/dist/runtime/telemetry.js.map +1 -0
  318. package/dist/sharing/agent-repo.d.ts +33 -0
  319. package/dist/sharing/agent-repo.d.ts.map +1 -0
  320. package/dist/sharing/agent-repo.js +79 -0
  321. package/dist/sharing/agent-repo.js.map +1 -0
  322. package/dist/sharing/cache.d.ts +36 -0
  323. package/dist/sharing/cache.d.ts.map +1 -0
  324. package/dist/sharing/cache.js +85 -0
  325. package/dist/sharing/cache.js.map +1 -0
  326. package/dist/sharing/conflicts.d.ts +32 -0
  327. package/dist/sharing/conflicts.d.ts.map +1 -0
  328. package/dist/sharing/conflicts.js +123 -0
  329. package/dist/sharing/conflicts.js.map +1 -0
  330. package/dist/sharing/consult.d.ts +226 -0
  331. package/dist/sharing/consult.d.ts.map +1 -0
  332. package/dist/sharing/consult.js +818 -0
  333. package/dist/sharing/consult.js.map +1 -0
  334. package/dist/sharing/export.d.ts +50 -0
  335. package/dist/sharing/export.d.ts.map +1 -0
  336. package/dist/sharing/export.js +156 -0
  337. package/dist/sharing/export.js.map +1 -0
  338. package/dist/sharing/history-split.d.ts +34 -0
  339. package/dist/sharing/history-split.d.ts.map +1 -0
  340. package/dist/sharing/history-split.js +101 -0
  341. package/dist/sharing/history-split.js.map +1 -0
  342. package/dist/sharing/import.d.ts +37 -0
  343. package/dist/sharing/import.d.ts.map +1 -0
  344. package/dist/sharing/import.js +138 -0
  345. package/dist/sharing/import.js.map +1 -0
  346. package/dist/sharing/index.d.ts +12 -0
  347. package/dist/sharing/index.d.ts.map +1 -0
  348. package/dist/sharing/index.js +12 -0
  349. package/dist/sharing/index.js.map +1 -0
  350. package/dist/sharing/versioning.d.ts +32 -0
  351. package/dist/sharing/versioning.d.ts.map +1 -0
  352. package/dist/sharing/versioning.js +64 -0
  353. package/dist/sharing/versioning.js.map +1 -0
  354. package/dist/skills/index.d.ts +49 -0
  355. package/dist/skills/index.d.ts.map +1 -0
  356. package/dist/skills/index.js +85 -0
  357. package/dist/skills/index.js.map +1 -0
  358. package/dist/skills/skill-loader.d.ts +56 -0
  359. package/dist/skills/skill-loader.d.ts.map +1 -0
  360. package/dist/skills/skill-loader.js +106 -0
  361. package/dist/skills/skill-loader.js.map +1 -0
  362. package/dist/skills/skill-source.d.ts +63 -0
  363. package/dist/skills/skill-source.d.ts.map +1 -0
  364. package/dist/skills/skill-source.js +199 -0
  365. package/dist/skills/skill-source.js.map +1 -0
  366. package/dist/streams/filter.d.ts +33 -0
  367. package/dist/streams/filter.d.ts.map +1 -0
  368. package/dist/streams/filter.js +29 -0
  369. package/dist/streams/filter.js.map +1 -0
  370. package/dist/streams/index.d.ts +9 -0
  371. package/dist/streams/index.d.ts.map +1 -0
  372. package/dist/streams/index.js +9 -0
  373. package/dist/streams/index.js.map +1 -0
  374. package/dist/streams/resolver.d.ts +40 -0
  375. package/dist/streams/resolver.d.ts.map +1 -0
  376. package/dist/streams/resolver.js +162 -0
  377. package/dist/streams/resolver.js.map +1 -0
  378. package/dist/streams/types.d.ts +44 -0
  379. package/dist/streams/types.d.ts.map +1 -0
  380. package/dist/streams/types.js +10 -0
  381. package/dist/streams/types.js.map +1 -0
  382. package/dist/tools/index.d.ts +95 -0
  383. package/dist/tools/index.d.ts.map +1 -0
  384. package/dist/tools/index.js +475 -0
  385. package/dist/tools/index.js.map +1 -0
  386. package/dist/types.d.ts +66 -0
  387. package/dist/types.d.ts.map +1 -0
  388. package/dist/types.js +8 -0
  389. package/dist/types.js.map +1 -0
  390. package/dist/upstream/index.d.ts +8 -0
  391. package/dist/upstream/index.d.ts.map +1 -0
  392. package/dist/upstream/index.js +7 -0
  393. package/dist/upstream/index.js.map +1 -0
  394. package/dist/upstream/resolver.d.ts +37 -0
  395. package/dist/upstream/resolver.d.ts.map +1 -0
  396. package/dist/upstream/resolver.js +234 -0
  397. package/dist/upstream/resolver.js.map +1 -0
  398. package/dist/upstream/types.d.ts +55 -0
  399. package/dist/upstream/types.d.ts.map +1 -0
  400. package/dist/upstream/types.js +11 -0
  401. package/dist/upstream/types.js.map +1 -0
  402. package/dist/utils/normalize-eol.d.ts +6 -0
  403. package/dist/utils/normalize-eol.d.ts.map +1 -0
  404. package/dist/utils/normalize-eol.js +8 -0
  405. package/dist/utils/normalize-eol.js.map +1 -0
  406. package/dist/utils/safe-timestamp.d.ts +6 -0
  407. package/dist/utils/safe-timestamp.d.ts.map +1 -0
  408. package/dist/utils/safe-timestamp.js +8 -0
  409. package/dist/utils/safe-timestamp.js.map +1 -0
  410. package/package.json +151 -6
  411. package/templates/casting-history.json +4 -0
  412. package/templates/casting-policy.json +35 -0
  413. package/templates/casting-registry.json +3 -0
  414. package/templates/ceremonies.md +41 -0
  415. package/templates/charter.md +53 -0
  416. package/templates/constraint-tracking.md +38 -0
  417. package/templates/copilot-instructions.md +46 -0
  418. package/templates/history.md +10 -0
  419. package/templates/identity/now.md +9 -0
  420. package/templates/identity/wisdom.md +15 -0
  421. package/templates/mcp-config.md +98 -0
  422. package/templates/multi-agent-format.md +28 -0
  423. package/templates/orchestration-log.md +27 -0
  424. package/templates/plugin-marketplace.md +49 -0
  425. package/templates/raw-agent-output.md +37 -0
  426. package/templates/roster.md +60 -0
  427. package/templates/routing.md +54 -0
  428. package/templates/run-output.md +50 -0
  429. package/templates/scribe-charter.md +119 -0
  430. package/templates/skill.md +24 -0
  431. package/templates/skills/project-conventions/SKILL.md +56 -0
  432. package/templates/squad.agent.md +1146 -0
  433. package/templates/workflows/squad-ci.yml +24 -0
  434. package/templates/workflows/squad-docs.yml +50 -0
  435. package/templates/workflows/squad-heartbeat.yml +316 -0
  436. package/templates/workflows/squad-insider-release.yml +61 -0
  437. package/templates/workflows/squad-issue-assign.yml +161 -0
  438. package/templates/workflows/squad-label-enforce.yml +181 -0
  439. package/templates/workflows/squad-preview.yml +55 -0
  440. package/templates/workflows/squad-promote.yml +120 -0
  441. package/templates/workflows/squad-release.yml +77 -0
  442. package/templates/workflows/squad-triage.yml +260 -0
  443. package/templates/workflows/sync-squad-labels.yml +169 -0
@@ -0,0 +1,807 @@
1
+ /**
2
+ * Squad Initialization Module (M2-6, PRD #98)
3
+ *
4
+ * Creates new Squad projects with typed configuration.
5
+ * Generates squad.config.ts or squad.config.json with agent definitions.
6
+ * Scaffolds directory structure, templates, workflows, and agent files.
7
+ *
8
+ * @module config/init
9
+ */
10
+ import { mkdir, writeFile, appendFile, unlink } from 'fs/promises';
11
+ import { join, dirname } from 'path';
12
+ import { fileURLToPath } from 'url';
13
+ import { existsSync, cpSync, statSync, mkdirSync, readFileSync, readdirSync } from 'fs';
14
+ import { MODELS } from '../runtime/constants.js';
15
+ // ============================================================================
16
+ // Template Resolution
17
+ // ============================================================================
18
+ /**
19
+ * Get the SDK templates directory path.
20
+ */
21
+ export function getSDKTemplatesDir() {
22
+ // Use fileURLToPath for cross-platform compatibility (handles Windows drive letters, URL encoding)
23
+ const currentDir = dirname(fileURLToPath(import.meta.url));
24
+ // Try relative to this file (in dist/)
25
+ const distPath = join(currentDir, '../../templates');
26
+ if (existsSync(distPath)) {
27
+ return distPath;
28
+ }
29
+ // Try relative to package root (for dev)
30
+ const pkgPath = join(currentDir, '../../../templates');
31
+ if (existsSync(pkgPath)) {
32
+ return pkgPath;
33
+ }
34
+ return null;
35
+ }
36
+ /**
37
+ * Copy a directory recursively.
38
+ */
39
+ function copyRecursiveSync(src, dest) {
40
+ if (!existsSync(dest)) {
41
+ mkdirSync(dest, { recursive: true });
42
+ }
43
+ for (const entry of statSync(src).isDirectory() ? readdirSync(src) : []) {
44
+ const srcPath = join(src, entry);
45
+ const destPath = join(dest, entry);
46
+ if (statSync(srcPath).isDirectory()) {
47
+ copyRecursiveSync(srcPath, destPath);
48
+ }
49
+ else {
50
+ cpSync(srcPath, destPath);
51
+ }
52
+ }
53
+ }
54
+ // ============================================================================
55
+ // Default Agent Templates
56
+ // ============================================================================
57
+ /**
58
+ * Default agent templates for common roles.
59
+ */
60
+ const AGENT_TEMPLATES = {
61
+ 'lead': {
62
+ displayName: 'Lead',
63
+ description: 'Technical lead responsible for architecture, delegation, and project coordination.'
64
+ },
65
+ 'developer': {
66
+ displayName: 'Developer',
67
+ description: 'Software developer focused on feature implementation and code quality.'
68
+ },
69
+ 'tester': {
70
+ displayName: 'Tester',
71
+ description: 'Quality assurance specialist responsible for test coverage and validation.'
72
+ },
73
+ 'scribe': {
74
+ displayName: 'Scribe',
75
+ description: 'Documentation specialist maintaining history, decisions, and technical records.'
76
+ },
77
+ 'ralph': {
78
+ displayName: 'Ralph',
79
+ description: 'Persistent memory agent that maintains context across sessions.'
80
+ }
81
+ };
82
+ // ============================================================================
83
+ // Configuration Templates
84
+ // ============================================================================
85
+ /**
86
+ * Format a readonly string array as a single-quoted TypeScript array literal.
87
+ */
88
+ function formatModelArray(chain) {
89
+ return `[${chain.map(m => `'${m}'`).join(', ')}]`;
90
+ }
91
+ /**
92
+ * Generate TypeScript config file content.
93
+ */
94
+ function generateTypeScriptConfig(options) {
95
+ const { projectName, projectDescription, agents } = options;
96
+ return `import type { SquadConfig } from '@bradygaster/squad';
97
+
98
+ /**
99
+ * Squad Configuration for ${projectName}
100
+ * ${projectDescription ? `\n * ${projectDescription}` : ''}
101
+ */
102
+ const config: SquadConfig = {
103
+ version: '1.0.0',
104
+
105
+ models: {
106
+ defaultModel: '${MODELS.DEFAULT}',
107
+ defaultTier: 'standard',
108
+ fallbackChains: {
109
+ premium: ${formatModelArray(MODELS.FALLBACK_CHAINS.premium)},
110
+ standard: ${formatModelArray(MODELS.FALLBACK_CHAINS.standard)},
111
+ fast: ${formatModelArray(MODELS.FALLBACK_CHAINS.fast)}
112
+ },
113
+ preferSameProvider: true,
114
+ respectTierCeiling: true,
115
+ nuclearFallback: {
116
+ enabled: false,
117
+ model: '${MODELS.NUCLEAR_FALLBACK}',
118
+ maxRetriesBeforeNuclear: ${MODELS.NUCLEAR_MAX_RETRIES}
119
+ }
120
+ },
121
+
122
+ routing: {
123
+ rules: [
124
+ {
125
+ workType: 'feature-dev',
126
+ agents: ['@${agents[0]?.name || 'coordinator'}'],
127
+ confidence: 'high'
128
+ },
129
+ {
130
+ workType: 'bug-fix',
131
+ agents: ['@${agents.find(a => a.role === 'developer')?.name || agents[0]?.name || 'coordinator'}'],
132
+ confidence: 'high'
133
+ },
134
+ {
135
+ workType: 'testing',
136
+ agents: ['@${agents.find(a => a.role === 'tester')?.name || agents[0]?.name || 'coordinator'}'],
137
+ confidence: 'high'
138
+ },
139
+ {
140
+ workType: 'documentation',
141
+ agents: ['@${agents.find(a => a.role === 'scribe')?.name || agents[0]?.name || 'coordinator'}'],
142
+ confidence: 'high'
143
+ }
144
+ ],
145
+ governance: {
146
+ eagerByDefault: true,
147
+ scribeAutoRuns: false,
148
+ allowRecursiveSpawn: false
149
+ }
150
+ },
151
+
152
+ casting: {
153
+ allowlistUniverses: [
154
+ 'The Usual Suspects',
155
+ 'Breaking Bad',
156
+ 'The Wire',
157
+ 'Firefly'
158
+ ],
159
+ overflowStrategy: 'generic',
160
+ universeCapacity: {}
161
+ },
162
+
163
+ platforms: {
164
+ vscode: {
165
+ disableModelSelection: false,
166
+ scribeMode: 'sync'
167
+ }
168
+ }
169
+ };
170
+
171
+ export default config;
172
+ `;
173
+ }
174
+ /**
175
+ * Generate JSON config file content.
176
+ */
177
+ function generateJsonConfig(options) {
178
+ const { agents } = options;
179
+ const config = {
180
+ version: '1.0.0',
181
+ models: {
182
+ defaultModel: MODELS.DEFAULT,
183
+ defaultTier: 'standard',
184
+ fallbackChains: {
185
+ premium: [...MODELS.FALLBACK_CHAINS.premium],
186
+ standard: [...MODELS.FALLBACK_CHAINS.standard],
187
+ fast: [...MODELS.FALLBACK_CHAINS.fast]
188
+ },
189
+ preferSameProvider: true,
190
+ respectTierCeiling: true,
191
+ nuclearFallback: {
192
+ enabled: false,
193
+ model: MODELS.NUCLEAR_FALLBACK,
194
+ maxRetriesBeforeNuclear: MODELS.NUCLEAR_MAX_RETRIES
195
+ }
196
+ },
197
+ routing: {
198
+ rules: [
199
+ {
200
+ workType: 'feature-dev',
201
+ agents: [`@${agents[0]?.name || 'coordinator'}`],
202
+ confidence: 'high'
203
+ },
204
+ {
205
+ workType: 'bug-fix',
206
+ agents: [`@${agents.find(a => a.role === 'developer')?.name || agents[0]?.name || 'coordinator'}`],
207
+ confidence: 'high'
208
+ },
209
+ {
210
+ workType: 'testing',
211
+ agents: [`@${agents.find(a => a.role === 'tester')?.name || agents[0]?.name || 'coordinator'}`],
212
+ confidence: 'high'
213
+ },
214
+ {
215
+ workType: 'documentation',
216
+ agents: [`@${agents.find(a => a.role === 'scribe')?.name || agents[0]?.name || 'coordinator'}`],
217
+ confidence: 'high'
218
+ }
219
+ ],
220
+ governance: {
221
+ eagerByDefault: true,
222
+ scribeAutoRuns: false,
223
+ allowRecursiveSpawn: false
224
+ }
225
+ },
226
+ casting: {
227
+ allowlistUniverses: [
228
+ 'The Usual Suspects',
229
+ 'Breaking Bad',
230
+ 'The Wire',
231
+ 'Firefly'
232
+ ],
233
+ overflowStrategy: 'generic',
234
+ universeCapacity: {}
235
+ },
236
+ platforms: {
237
+ vscode: {
238
+ disableModelSelection: false,
239
+ scribeMode: 'sync'
240
+ }
241
+ }
242
+ };
243
+ return JSON.stringify(config, null, 2);
244
+ }
245
+ /**
246
+ * Generate SDK builder config file content (new defineSquad() format).
247
+ */
248
+ function generateSDKBuilderConfig(options) {
249
+ const { projectName, projectDescription, agents } = options;
250
+ // Generate imports
251
+ let code = `import {\n defineSquad,\n defineTeam,\n defineAgent,\n} from '@bradygaster/squad-sdk';\n\n`;
252
+ code += `/**\n * Squad Configuration — ${projectName}\n`;
253
+ if (projectDescription) {
254
+ code += ` *\n * ${projectDescription}\n`;
255
+ }
256
+ code += ` */\n`;
257
+ // Generate agent definitions
258
+ for (const agent of agents) {
259
+ const displayName = agent.displayName || titleCase(agent.name);
260
+ code += `const ${agent.name} = defineAgent({\n`;
261
+ code += ` name: '${agent.name}',\n`;
262
+ code += ` role: '${agent.role}',\n`;
263
+ code += ` description: '${displayName}',\n`;
264
+ code += ` status: 'active',\n`;
265
+ code += `});\n\n`;
266
+ }
267
+ // Generate squad config
268
+ code += `export default defineSquad({\n`;
269
+ code += ` version: '1.0.0',\n\n`;
270
+ code += ` team: defineTeam({\n`;
271
+ code += ` name: '${projectName}',\n`;
272
+ if (projectDescription) {
273
+ code += ` description: '${projectDescription.replace(/'/g, "\\'")}',\n`;
274
+ }
275
+ code += ` members: [${agents.map(a => `'${a.name}'`).join(', ')}],\n`;
276
+ code += ` }),\n\n`;
277
+ code += ` agents: [${agents.map(a => a.name).join(', ')}],\n`;
278
+ code += `});\n`;
279
+ return code;
280
+ }
281
+ // ============================================================================
282
+ // Agent Template Generation
283
+ // ============================================================================
284
+ /**
285
+ * Generate charter.md content for an agent.
286
+ */
287
+ function generateCharter(agent, projectName, projectDescription) {
288
+ const template = AGENT_TEMPLATES[agent.role];
289
+ const displayName = agent.displayName || template?.displayName || titleCase(agent.name);
290
+ const description = template?.description || 'Team member focused on their assigned responsibilities.';
291
+ return `# ${displayName} — ${titleCase(agent.role)}
292
+
293
+ ${description}
294
+
295
+ ## Project Context
296
+
297
+ **Project:** ${projectName}
298
+ ${projectDescription ? `**Description:** ${projectDescription}\n` : ''}
299
+
300
+ ## Responsibilities
301
+
302
+ - Collaborate with team members on assigned work
303
+ - Maintain code quality and project standards
304
+ - Document decisions and progress in history
305
+
306
+ ## Work Style
307
+
308
+ - Read project context and team decisions before starting work
309
+ - Communicate clearly with team members
310
+ - Follow established patterns and conventions
311
+ `;
312
+ }
313
+ /**
314
+ * Generate initial history.md content for an agent.
315
+ */
316
+ function generateInitialHistory(agent, projectName, projectDescription, userName) {
317
+ const displayName = agent.displayName || AGENT_TEMPLATES[agent.role]?.displayName || titleCase(agent.name);
318
+ const now = new Date().toISOString().split('T')[0];
319
+ return `# Project Context
320
+
321
+ ${userName ? `- **Owner:** ${userName}\n` : ''}- **Project:** ${projectName}
322
+ ${projectDescription ? `- **Description:** ${projectDescription}\n` : ''}- **Created:** ${now}
323
+
324
+ ## Core Context
325
+
326
+ Agent ${displayName} initialized and ready for work.
327
+
328
+ ## Recent Updates
329
+
330
+ 📌 Team initialized on ${now}
331
+
332
+ ## Learnings
333
+
334
+ Initial setup complete.
335
+ `;
336
+ }
337
+ /**
338
+ * Convert kebab-case or snake_case to Title Case.
339
+ */
340
+ function titleCase(str) {
341
+ return str
342
+ .split(/[-_]/)
343
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
344
+ .join(' ');
345
+ }
346
+ // ============================================================================
347
+ // Initialization Functions
348
+ // ============================================================================
349
+ /**
350
+ * Stamp version into squad.agent.md content.
351
+ */
352
+ function stampVersionInContent(content, version) {
353
+ return content.replace(/<!-- version: [^>]* -->/, `<!-- version: ${version} -->`);
354
+ }
355
+ /**
356
+ * Initialize a new Squad project.
357
+ *
358
+ * Creates:
359
+ * - .squad/ directory structure (agents, casting, decisions, skills, identity, etc.)
360
+ * - squad.config.ts or squad.config.json
361
+ * - Agent directories with charter.md and history.md
362
+ * - .gitattributes for merge drivers
363
+ * - .gitignore entries for logs
364
+ * - .github/agents/squad.agent.md
365
+ * - .github/workflows/ (optional)
366
+ * - .squad/templates/ (optional)
367
+ * - .copilot/mcp-config.json (optional)
368
+ * - Identity files (now.md, wisdom.md)
369
+ * - ceremonies.md
370
+ *
371
+ * @param options - Initialization options
372
+ * @returns Result with created file paths
373
+ */
374
+ /**
375
+ * Workflow files that are part of the Squad framework and should always be installed.
376
+ * Other workflows in templates/workflows/ are generic CI/CD scaffolding and are opt-in.
377
+ */
378
+ const FRAMEWORK_WORKFLOWS = [
379
+ 'squad-heartbeat.yml',
380
+ 'squad-issue-assign.yml',
381
+ 'squad-triage.yml',
382
+ 'sync-squad-labels.yml',
383
+ ];
384
+ export async function initSquad(options) {
385
+ const { teamRoot, projectName, projectDescription, agents, configFormat = 'typescript', userName, skipExisting = true, includeWorkflows = true, includeTemplates = true, includeMcpConfig = true, projectType = 'unknown', version = '0.0.0', } = options;
386
+ const createdFiles = [];
387
+ const skippedFiles = [];
388
+ const agentDirs = [];
389
+ // Validate inputs
390
+ if (!teamRoot) {
391
+ throw new Error('teamRoot is required');
392
+ }
393
+ if (!projectName) {
394
+ throw new Error('projectName is required');
395
+ }
396
+ if (!agents || agents.length === 0) {
397
+ throw new Error('At least one agent is required');
398
+ }
399
+ // Get templates directory
400
+ const templatesDir = getSDKTemplatesDir();
401
+ // Helper to convert absolute path to relative
402
+ const toRelativePath = (absolutePath) => {
403
+ // Use path separator-agnostic approach
404
+ if (absolutePath.startsWith(teamRoot)) {
405
+ const relative = absolutePath.slice(teamRoot.length);
406
+ // Remove leading separator if present
407
+ return relative.startsWith('/') || relative.startsWith('\\')
408
+ ? relative.slice(1)
409
+ : relative;
410
+ }
411
+ return absolutePath;
412
+ };
413
+ // Helper to write file (respects skipExisting)
414
+ const writeIfNotExists = async (filePath, content) => {
415
+ if (existsSync(filePath) && skipExisting) {
416
+ skippedFiles.push(toRelativePath(filePath));
417
+ return false;
418
+ }
419
+ await mkdir(dirname(filePath), { recursive: true });
420
+ await writeFile(filePath, content, 'utf-8');
421
+ createdFiles.push(toRelativePath(filePath));
422
+ return true;
423
+ };
424
+ // Helper to copy file (respects skipExisting)
425
+ const copyIfNotExists = async (src, dest) => {
426
+ if (existsSync(dest) && skipExisting) {
427
+ skippedFiles.push(toRelativePath(dest));
428
+ return false;
429
+ }
430
+ await mkdir(dirname(dest), { recursive: true });
431
+ cpSync(src, dest);
432
+ createdFiles.push(toRelativePath(dest));
433
+ return true;
434
+ };
435
+ // -------------------------------------------------------------------------
436
+ // Create .squad/ directory structure
437
+ // -------------------------------------------------------------------------
438
+ const squadDir = join(teamRoot, '.squad');
439
+ const directories = [
440
+ join(squadDir, 'agents'),
441
+ join(squadDir, 'casting'),
442
+ join(squadDir, 'decisions'),
443
+ join(squadDir, 'decisions', 'inbox'),
444
+ join(squadDir, 'skills'),
445
+ join(squadDir, 'plugins'),
446
+ join(squadDir, 'identity'),
447
+ join(squadDir, 'orchestration-log'),
448
+ join(squadDir, 'log'),
449
+ ];
450
+ for (const dir of directories) {
451
+ if (!existsSync(dir)) {
452
+ await mkdir(dir, { recursive: true });
453
+ }
454
+ }
455
+ // -------------------------------------------------------------------------
456
+ // Create .squad/config.json for squad settings
457
+ // -------------------------------------------------------------------------
458
+ const squadConfigPath = join(squadDir, 'config.json');
459
+ if (!existsSync(squadConfigPath)) {
460
+ const squadConfig = {
461
+ version: 1,
462
+ teamRoot: teamRoot,
463
+ };
464
+ // Only include extractionDisabled if explicitly set
465
+ if (options.extractionDisabled) {
466
+ squadConfig.extractionDisabled = true;
467
+ }
468
+ await writeFile(squadConfigPath, JSON.stringify(squadConfig, null, 2), 'utf-8');
469
+ createdFiles.push(toRelativePath(squadConfigPath));
470
+ }
471
+ // -------------------------------------------------------------------------
472
+ // Create configuration file
473
+ // -------------------------------------------------------------------------
474
+ // When configFormat is 'markdown', skip config file generation entirely
475
+ let configPath;
476
+ if (configFormat !== 'markdown') {
477
+ const configFileName = configFormat === 'sdk' ? 'squad.config.ts' :
478
+ configFormat === 'typescript' ? 'squad.config.ts' : 'squad.config.json';
479
+ configPath = join(teamRoot, configFileName);
480
+ const configContent = configFormat === 'sdk' ? generateSDKBuilderConfig(options) :
481
+ configFormat === 'typescript' ? generateTypeScriptConfig(options) :
482
+ generateJsonConfig(options);
483
+ await writeIfNotExists(configPath, configContent);
484
+ }
485
+ else {
486
+ // No config file for markdown-only mode
487
+ configPath = '';
488
+ }
489
+ // -------------------------------------------------------------------------
490
+ // Create agent directories and files
491
+ // -------------------------------------------------------------------------
492
+ const agentsDir = join(squadDir, 'agents');
493
+ for (const agent of agents) {
494
+ const agentDir = join(agentsDir, agent.name);
495
+ await mkdir(agentDir, { recursive: true });
496
+ agentDirs.push(agentDir);
497
+ // Create charter.md
498
+ const charterPath = join(agentDir, 'charter.md');
499
+ const charterContent = generateCharter(agent, projectName, projectDescription);
500
+ await writeIfNotExists(charterPath, charterContent);
501
+ // Create history.md
502
+ const historyPath = join(agentDir, 'history.md');
503
+ const historyContent = generateInitialHistory(agent, projectName, projectDescription, userName);
504
+ await writeIfNotExists(historyPath, historyContent);
505
+ }
506
+ // -------------------------------------------------------------------------
507
+ // Create identity files (now.md, wisdom.md)
508
+ // -------------------------------------------------------------------------
509
+ const identityDir = join(squadDir, 'identity');
510
+ const nowMdPath = join(identityDir, 'now.md');
511
+ const wisdomMdPath = join(identityDir, 'wisdom.md');
512
+ const nowContent = `---
513
+ updated_at: ${new Date().toISOString()}
514
+ focus_area: Initial setup
515
+ active_issues: []
516
+ ---
517
+
518
+ # What We're Focused On
519
+
520
+ Getting started. Updated by coordinator at session start.
521
+ `;
522
+ const wisdomContent = `---
523
+ last_updated: ${new Date().toISOString()}
524
+ ---
525
+
526
+ # Team Wisdom
527
+
528
+ Reusable patterns and heuristics learned through work. NOT transcripts — each entry is a distilled, actionable insight.
529
+
530
+ ## Patterns
531
+
532
+ <!-- Append entries below. Format: **Pattern:** description. **Context:** when it applies. -->
533
+ `;
534
+ await writeIfNotExists(nowMdPath, nowContent);
535
+ await writeIfNotExists(wisdomMdPath, wisdomContent);
536
+ // -------------------------------------------------------------------------
537
+ // Create ceremonies.md
538
+ // -------------------------------------------------------------------------
539
+ const ceremoniesDest = join(squadDir, 'ceremonies.md');
540
+ if (templatesDir && existsSync(join(templatesDir, 'ceremonies.md'))) {
541
+ await copyIfNotExists(join(templatesDir, 'ceremonies.md'), ceremoniesDest);
542
+ }
543
+ // -------------------------------------------------------------------------
544
+ // Create decisions.md (canonical location at squad root)
545
+ // -------------------------------------------------------------------------
546
+ const decisionsPath = join(squadDir, 'decisions.md');
547
+ const decisionsContent = `# Squad Decisions
548
+
549
+ ## Active Decisions
550
+
551
+ No decisions recorded yet.
552
+
553
+ ## Governance
554
+
555
+ - All meaningful changes require team consensus
556
+ - Document architectural decisions here
557
+ - Keep history focused on work, decisions focused on direction
558
+ `;
559
+ await writeIfNotExists(decisionsPath, decisionsContent);
560
+ // -------------------------------------------------------------------------
561
+ // Create team.md (required by shell lifecycle)
562
+ // -------------------------------------------------------------------------
563
+ const teamPath = join(squadDir, 'team.md');
564
+ const teamContent = `# Squad Team
565
+
566
+ > ${projectDescription || projectName}
567
+
568
+ ## Coordinator
569
+
570
+ | Name | Role | Notes |
571
+ |------|------|-------|
572
+ | Squad | Coordinator | Routes work, enforces handoffs and reviewer gates. |
573
+
574
+ ## Members
575
+
576
+ | Name | Role | Charter | Status |
577
+ |------|------|---------|--------|
578
+
579
+ ## Project Context
580
+
581
+ - **Project:** ${projectName}
582
+ ${projectDescription ? `- **Description:** ${projectDescription}\n` : ''}- **Created:** ${new Date().toISOString().split('T')[0]}
583
+ `;
584
+ await writeIfNotExists(teamPath, teamContent);
585
+ // -------------------------------------------------------------------------
586
+ // Create routing.md
587
+ // -------------------------------------------------------------------------
588
+ const routingPath = join(squadDir, 'routing.md');
589
+ if (templatesDir && existsSync(join(templatesDir, 'routing.md'))) {
590
+ await copyIfNotExists(join(templatesDir, 'routing.md'), routingPath);
591
+ }
592
+ else {
593
+ const routingContent = `# Squad Routing
594
+
595
+ ## Work Type Rules
596
+
597
+ | Work Type | Primary Agent | Fallback |
598
+ |-----------|---------------|----------|
599
+
600
+ ## Governance
601
+
602
+ - Route based on work type and agent expertise
603
+ - Update this file as team capabilities evolve
604
+ `;
605
+ await writeIfNotExists(routingPath, routingContent);
606
+ }
607
+ // -------------------------------------------------------------------------
608
+ // Copy starter skills
609
+ // -------------------------------------------------------------------------
610
+ const skillsDir = join(squadDir, 'skills');
611
+ if (templatesDir && existsSync(join(templatesDir, 'skills'))) {
612
+ const skillsSrc = join(templatesDir, 'skills');
613
+ const existingSkills = existsSync(skillsDir) ? readdirSync(skillsDir) : [];
614
+ if (existingSkills.length === 0) {
615
+ cpSync(skillsSrc, skillsDir, { recursive: true });
616
+ createdFiles.push('.squad/skills');
617
+ }
618
+ }
619
+ // -------------------------------------------------------------------------
620
+ // Create .gitattributes for merge drivers
621
+ // -------------------------------------------------------------------------
622
+ const gitattributesPath = join(teamRoot, '.gitattributes');
623
+ const unionRules = [
624
+ '.squad/decisions.md merge=union',
625
+ '.squad/agents/*/history.md merge=union',
626
+ '.squad/log/** merge=union',
627
+ '.squad/orchestration-log/** merge=union',
628
+ ];
629
+ let existingAttrs = '';
630
+ if (existsSync(gitattributesPath)) {
631
+ existingAttrs = readFileSync(gitattributesPath, 'utf-8');
632
+ }
633
+ const missingRules = unionRules.filter(rule => !existingAttrs.includes(rule));
634
+ if (missingRules.length > 0) {
635
+ const block = (existingAttrs && !existingAttrs.endsWith('\n') ? '\n' : '')
636
+ + '# Squad: union merge for append-only team state files\n'
637
+ + missingRules.join('\n') + '\n';
638
+ await appendFile(gitattributesPath, block);
639
+ createdFiles.push(toRelativePath(gitattributesPath));
640
+ }
641
+ // -------------------------------------------------------------------------
642
+ // Create .gitignore entries for runtime state (logs, inbox, sessions)
643
+ // These paths are written during normal squad operation but should not be
644
+ // committed to version control (they are runtime state).
645
+ // -------------------------------------------------------------------------
646
+ const gitignorePath = join(teamRoot, '.gitignore');
647
+ const ignoreEntries = [
648
+ '.squad/orchestration-log/',
649
+ '.squad/log/',
650
+ '.squad/decisions/inbox/',
651
+ '.squad/sessions/',
652
+ ];
653
+ let existingIgnore = '';
654
+ if (existsSync(gitignorePath)) {
655
+ existingIgnore = readFileSync(gitignorePath, 'utf-8');
656
+ }
657
+ const missingIgnore = ignoreEntries.filter(entry => !existingIgnore.includes(entry));
658
+ if (missingIgnore.length > 0) {
659
+ const block = (existingIgnore && !existingIgnore.endsWith('\n') ? '\n' : '')
660
+ + '# Squad: ignore runtime state (logs, inbox, sessions)\n'
661
+ + missingIgnore.join('\n') + '\n';
662
+ await appendFile(gitignorePath, block);
663
+ createdFiles.push(toRelativePath(gitignorePath));
664
+ }
665
+ // -------------------------------------------------------------------------
666
+ // Create .github/agents/squad.agent.md
667
+ // -------------------------------------------------------------------------
668
+ const agentFile = join(teamRoot, '.github', 'agents', 'squad.agent.md');
669
+ if (!existsSync(agentFile) || !skipExisting) {
670
+ if (templatesDir && existsSync(join(templatesDir, 'squad.agent.md'))) {
671
+ let agentContent = readFileSync(join(templatesDir, 'squad.agent.md'), 'utf-8');
672
+ agentContent = stampVersionInContent(agentContent, version);
673
+ await mkdir(dirname(agentFile), { recursive: true });
674
+ await writeFile(agentFile, agentContent, 'utf-8');
675
+ createdFiles.push(toRelativePath(agentFile));
676
+ }
677
+ }
678
+ else {
679
+ skippedFiles.push(toRelativePath(agentFile));
680
+ }
681
+ // -------------------------------------------------------------------------
682
+ // Copy .squad/templates/ (optional)
683
+ // -------------------------------------------------------------------------
684
+ if (includeTemplates && templatesDir) {
685
+ const templatesDest = join(teamRoot, '.squad', 'templates');
686
+ if (!existsSync(templatesDest)) {
687
+ cpSync(templatesDir, templatesDest, { recursive: true });
688
+ createdFiles.push(toRelativePath(templatesDest));
689
+ }
690
+ else {
691
+ skippedFiles.push(toRelativePath(templatesDest));
692
+ }
693
+ }
694
+ // -------------------------------------------------------------------------
695
+ // Copy workflows (optional)
696
+ // -------------------------------------------------------------------------
697
+ if (includeWorkflows && templatesDir && existsSync(join(templatesDir, 'workflows'))) {
698
+ const workflowsSrc = join(templatesDir, 'workflows');
699
+ const workflowsDest = join(teamRoot, '.github', 'workflows');
700
+ if (statSync(workflowsSrc).isDirectory()) {
701
+ const allWorkflowFiles = readdirSync(workflowsSrc).filter(f => f.endsWith('.yml'));
702
+ const workflowFiles = allWorkflowFiles.filter(f => FRAMEWORK_WORKFLOWS.includes(f));
703
+ await mkdir(workflowsDest, { recursive: true });
704
+ for (const file of workflowFiles) {
705
+ const destFile = join(workflowsDest, file);
706
+ if (!existsSync(destFile) || !skipExisting) {
707
+ cpSync(join(workflowsSrc, file), destFile);
708
+ createdFiles.push(toRelativePath(destFile));
709
+ }
710
+ else {
711
+ skippedFiles.push(toRelativePath(destFile));
712
+ }
713
+ }
714
+ }
715
+ }
716
+ // -------------------------------------------------------------------------
717
+ // Create sample MCP config (optional)
718
+ // -------------------------------------------------------------------------
719
+ if (includeMcpConfig) {
720
+ const mcpConfigPath = join(teamRoot, '.copilot', 'mcp-config.json');
721
+ if (!existsSync(mcpConfigPath)) {
722
+ const mcpSample = {
723
+ mcpServers: {
724
+ "EXAMPLE-trello": {
725
+ command: "npx",
726
+ args: ["-y", "@trello/mcp-server"],
727
+ env: {
728
+ TRELLO_API_KEY: "${TRELLO_API_KEY}",
729
+ TRELLO_TOKEN: "${TRELLO_TOKEN}"
730
+ }
731
+ }
732
+ }
733
+ };
734
+ await mkdir(dirname(mcpConfigPath), { recursive: true });
735
+ await writeFile(mcpConfigPath, JSON.stringify(mcpSample, null, 2) + '\n', 'utf-8');
736
+ createdFiles.push(toRelativePath(mcpConfigPath));
737
+ }
738
+ else {
739
+ skippedFiles.push(toRelativePath(mcpConfigPath));
740
+ }
741
+ }
742
+ // -------------------------------------------------------------------------
743
+ // Generate .squad/workstreams.json (when streams provided)
744
+ // -------------------------------------------------------------------------
745
+ if (options.streams && options.streams.length > 0) {
746
+ const workstreamsConfig = {
747
+ workstreams: options.streams,
748
+ defaultWorkflow: 'branch-per-issue',
749
+ };
750
+ const workstreamsPath = join(squadDir, 'workstreams.json');
751
+ await writeIfNotExists(workstreamsPath, JSON.stringify(workstreamsConfig, null, 2) + '\n');
752
+ }
753
+ // -------------------------------------------------------------------------
754
+ // Add .squad-workstream to .gitignore
755
+ // -------------------------------------------------------------------------
756
+ {
757
+ const workstreamIgnoreEntry = '.squad-workstream';
758
+ let currentIgnore = '';
759
+ if (existsSync(gitignorePath)) {
760
+ currentIgnore = readFileSync(gitignorePath, 'utf-8');
761
+ }
762
+ if (!currentIgnore.includes(workstreamIgnoreEntry)) {
763
+ const block = (currentIgnore && !currentIgnore.endsWith('\n') ? '\n' : '')
764
+ + '# Squad: workstream activation file (local to this machine)\n'
765
+ + workstreamIgnoreEntry + '\n';
766
+ await appendFile(gitignorePath, block);
767
+ createdFiles.push(toRelativePath(gitignorePath));
768
+ }
769
+ }
770
+ // -------------------------------------------------------------------------
771
+ // Create .first-run marker
772
+ // -------------------------------------------------------------------------
773
+ const firstRunMarker = join(squadDir, '.first-run');
774
+ if (!existsSync(firstRunMarker)) {
775
+ await writeFile(firstRunMarker, new Date().toISOString() + '\n', 'utf-8');
776
+ createdFiles.push(toRelativePath(firstRunMarker));
777
+ }
778
+ // -------------------------------------------------------------------------
779
+ // Store init prompt for REPL auto-casting
780
+ // -------------------------------------------------------------------------
781
+ if (options.prompt) {
782
+ const promptFile = join(squadDir, '.init-prompt');
783
+ await writeFile(promptFile, options.prompt, 'utf-8');
784
+ createdFiles.push(toRelativePath(promptFile));
785
+ }
786
+ return {
787
+ createdFiles,
788
+ skippedFiles,
789
+ configPath,
790
+ agentDirs,
791
+ agentFile,
792
+ squadDir,
793
+ };
794
+ }
795
+ /**
796
+ * Clean up orphan .init-prompt file.
797
+ * Called by CLI on Ctrl+C abort to remove partial state.
798
+ *
799
+ * @param squadDir - Path to the .squad directory
800
+ */
801
+ export async function cleanupOrphanInitPrompt(squadDir) {
802
+ const promptFile = join(squadDir, '.init-prompt');
803
+ if (existsSync(promptFile)) {
804
+ await unlink(promptFile);
805
+ }
806
+ }
807
+ //# sourceMappingURL=init.js.map