xcoder-dna 0.0.0-stage → 1.3.0

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 (390) hide show
  1. package/LICENSE +66 -0
  2. package/README.md +87 -2
  3. package/dist/agents/ai-chat-debate.d.ts +36 -0
  4. package/dist/agents/ai-chat-debate.js +300 -0
  5. package/dist/agents/ai-chat-report-writer.d.ts +7 -0
  6. package/dist/agents/ai-chat-report-writer.js +100 -0
  7. package/dist/agents/duplicate-detector.d.ts +41 -0
  8. package/dist/agents/duplicate-detector.js +65 -0
  9. package/dist/agents/genesis-agent.d.ts +61 -0
  10. package/dist/agents/genesis-agent.js +340 -0
  11. package/dist/agents/samurai-agent.d.ts +53 -0
  12. package/dist/agents/samurai-agent.js +279 -0
  13. package/dist/agents/sub-agent.d.ts +56 -0
  14. package/dist/agents/sub-agent.js +353 -0
  15. package/dist/backlog/backlog-requirement-validator.d.ts +10 -0
  16. package/dist/backlog/backlog-requirement-validator.js +60 -0
  17. package/dist/backlog/backlog-store.d.ts +29 -0
  18. package/dist/backlog/backlog-store.js +148 -0
  19. package/dist/backlog/po-agent.d.ts +16 -0
  20. package/dist/backlog/po-agent.js +121 -0
  21. package/dist/backlog/types.d.ts +25 -0
  22. package/dist/backlog/types.js +4 -0
  23. package/dist/bench/run.d.ts +11 -0
  24. package/dist/bench/run.js +185 -0
  25. package/dist/bench/types.d.ts +50 -0
  26. package/dist/bench/types.js +1 -0
  27. package/dist/cli/swarm.d.ts +10 -0
  28. package/dist/cli/swarm.js +100 -0
  29. package/dist/cli/task.d.ts +14 -0
  30. package/dist/cli/task.js +121 -0
  31. package/dist/cli/wbc-arg.d.ts +6 -0
  32. package/dist/cli/wbc-arg.js +40 -0
  33. package/dist/cli/wbc.d.ts +45 -0
  34. package/dist/cli/wbc.js +98 -0
  35. package/dist/commands/license.d.ts +9 -0
  36. package/dist/commands/license.js +140 -0
  37. package/dist/commands/release.d.ts +44 -0
  38. package/dist/commands/release.js +180 -0
  39. package/dist/commands/test.d.ts +50 -0
  40. package/dist/commands/test.js +385 -0
  41. package/dist/config/loadConfig.d.ts +82 -0
  42. package/dist/config/loadConfig.js +240 -0
  43. package/dist/config/secure-mode.d.ts +29 -0
  44. package/dist/config/secure-mode.js +63 -0
  45. package/dist/config/user-config.d.ts +39 -0
  46. package/dist/config/user-config.js +202 -0
  47. package/dist/engine/reasoning-engine.d.ts +21 -0
  48. package/dist/engine/reasoning-engine.js +59 -0
  49. package/dist/events/bus.d.ts +22 -0
  50. package/dist/events/bus.js +18 -0
  51. package/dist/index.d.ts +79 -0
  52. package/dist/index.js +77 -0
  53. package/dist/indexing/ignoreRules.d.ts +1 -0
  54. package/dist/indexing/ignoreRules.js +53 -0
  55. package/dist/instance-swarm/instance-swarm-orchestrator.d.ts +57 -0
  56. package/dist/instance-swarm/instance-swarm-orchestrator.js +204 -0
  57. package/dist/instance-swarm/protocol-name-resolver.d.ts +23 -0
  58. package/dist/instance-swarm/protocol-name-resolver.js +64 -0
  59. package/dist/license/gate.d.ts +31 -0
  60. package/dist/license/gate.js +188 -0
  61. package/dist/license/http-client.d.ts +43 -0
  62. package/dist/license/http-client.js +195 -0
  63. package/dist/license/manager.d.ts +39 -0
  64. package/dist/license/manager.js +175 -0
  65. package/dist/license/receipt.d.ts +27 -0
  66. package/dist/license/receipt.js +108 -0
  67. package/dist/license/state-codec.d.ts +72 -0
  68. package/dist/license/state-codec.js +218 -0
  69. package/dist/license/state-paths.d.ts +17 -0
  70. package/dist/license/state-paths.js +64 -0
  71. package/dist/license/store.d.ts +44 -0
  72. package/dist/license/store.js +223 -0
  73. package/dist/license/trust-anchor.d.ts +24 -0
  74. package/dist/license/trust-anchor.js +74 -0
  75. package/dist/license/types.d.ts +34 -0
  76. package/dist/license/types.js +19 -0
  77. package/dist/llm/budget.d.ts +23 -0
  78. package/dist/llm/budget.js +58 -0
  79. package/dist/llm/client.d.ts +53 -0
  80. package/dist/llm/client.js +122 -0
  81. package/dist/llm/factory.d.ts +14 -0
  82. package/dist/llm/factory.js +32 -0
  83. package/dist/orchestrator/defect-logger.d.ts +31 -0
  84. package/dist/orchestrator/defect-logger.js +101 -0
  85. package/dist/orchestrator/defect-manager.d.ts +118 -0
  86. package/dist/orchestrator/defect-manager.js +338 -0
  87. package/dist/orchestrator/defect-migration.d.ts +14 -0
  88. package/dist/orchestrator/defect-migration.js +174 -0
  89. package/dist/orchestrator/defect-store.d.ts +48 -0
  90. package/dist/orchestrator/defect-store.js +76 -0
  91. package/dist/orchestrator/healing.d.ts +14 -0
  92. package/dist/orchestrator/healing.js +11 -0
  93. package/dist/orchestrator/interactive-steering.d.ts +64 -0
  94. package/dist/orchestrator/interactive-steering.js +107 -0
  95. package/dist/orchestrator/interrupt-handler.d.ts +30 -0
  96. package/dist/orchestrator/interrupt-handler.js +70 -0
  97. package/dist/orchestrator/lesson-manager.d.ts +25 -0
  98. package/dist/orchestrator/lesson-manager.js +122 -0
  99. package/dist/orchestrator/progress-summary.d.ts +15 -0
  100. package/dist/orchestrator/progress-summary.js +106 -0
  101. package/dist/orchestrator/reasoning-score.d.ts +49 -0
  102. package/dist/orchestrator/reasoning-score.js +117 -0
  103. package/dist/orchestrator/swarm.d.ts +36 -0
  104. package/dist/orchestrator/swarm.js +77 -0
  105. package/dist/orchestrator/task-factory.d.ts +15 -0
  106. package/dist/orchestrator/task-factory.js +176 -0
  107. package/dist/orchestrator/validation-gate.d.ts +23 -0
  108. package/dist/orchestrator/validation-gate.js +155 -0
  109. package/dist/protocol/react-contract.d.ts +136 -0
  110. package/dist/protocol/react-contract.js +698 -0
  111. package/dist/protocol/wks-protocol-manager.d.ts +22 -0
  112. package/dist/protocol/wks-protocol-manager.js +72 -0
  113. package/dist/sdlc-runtime/conversation-runner.d.ts +8 -0
  114. package/dist/sdlc-runtime/conversation-runner.js +64 -0
  115. package/dist/sdlc-runtime/dag-utils.d.ts +15 -0
  116. package/dist/sdlc-runtime/dag-utils.js +67 -0
  117. package/dist/sdlc-runtime/defect-integration.d.ts +7 -0
  118. package/dist/sdlc-runtime/defect-integration.js +99 -0
  119. package/dist/sdlc-runtime/execution-loop.d.ts +38 -0
  120. package/dist/sdlc-runtime/execution-loop.js +274 -0
  121. package/dist/sdlc-runtime/lesson-recorder.d.ts +9 -0
  122. package/dist/sdlc-runtime/lesson-recorder.js +27 -0
  123. package/dist/sdlc-runtime/plan-initializer.d.ts +47 -0
  124. package/dist/sdlc-runtime/plan-initializer.js +135 -0
  125. package/dist/sdlc-runtime/progress-persister.d.ts +10 -0
  126. package/dist/sdlc-runtime/progress-persister.js +34 -0
  127. package/dist/sdlc-runtime/protocol-loader.d.ts +10 -0
  128. package/dist/sdlc-runtime/protocol-loader.js +21 -0
  129. package/dist/sdlc-runtime/reporting.d.ts +24 -0
  130. package/dist/sdlc-runtime/reporting.js +68 -0
  131. package/dist/sdlc-runtime/sdlc-orchestrator.d.ts +59 -0
  132. package/dist/sdlc-runtime/sdlc-orchestrator.js +170 -0
  133. package/dist/sdlc-runtime/sdlc-skill.d.ts +44 -0
  134. package/dist/sdlc-runtime/sdlc-skill.js +148 -0
  135. package/dist/sdlc-runtime/steering-handler.d.ts +14 -0
  136. package/dist/sdlc-runtime/steering-handler.js +51 -0
  137. package/dist/sdlc-runtime/trace-recorder.d.ts +10 -0
  138. package/dist/sdlc-runtime/trace-recorder.js +7 -0
  139. package/dist/security/index.d.ts +16 -0
  140. package/dist/security/index.js +12 -0
  141. package/dist/security/input-screen.d.ts +30 -0
  142. package/dist/security/input-screen.js +75 -0
  143. package/dist/security/tool-call-guard.d.ts +16 -0
  144. package/dist/security/tool-call-guard.js +163 -0
  145. package/dist/security/untrusted-content.d.ts +34 -0
  146. package/dist/security/untrusted-content.js +63 -0
  147. package/dist/skills/advanced-dfir/SKILL.md +85 -0
  148. package/dist/skills/advanced-pentest-lab/SKILL.md +88 -0
  149. package/dist/skills/analyst/SKILL.md +55 -0
  150. package/dist/skills/architect/SKILL.md +54 -0
  151. package/dist/skills/aws/SKILL.md +92 -0
  152. package/dist/skills/azure/SKILL.md +90 -0
  153. package/dist/skills/bylaw-context.d.ts +45 -0
  154. package/dist/skills/bylaw-context.js +61 -0
  155. package/dist/skills/bylaw-review.d.ts +20 -0
  156. package/dist/skills/bylaw-review.js +101 -0
  157. package/dist/skills/conversation/SKILL.md +29 -0
  158. package/dist/skills/design-patterns/SKILL.md +190 -0
  159. package/dist/skills/devops/SKILL.md +55 -0
  160. package/dist/skills/directives.d.ts +20 -0
  161. package/dist/skills/directives.js +313 -0
  162. package/dist/skills/docker/SKILL.md +76 -0
  163. package/dist/skills/docker-expert/SKILL.md +56 -0
  164. package/dist/skills/enterprise-systems-analyst/SKILL.md +83 -0
  165. package/dist/skills/enterprise-systems-analyst/references/crm.md +41 -0
  166. package/dist/skills/enterprise-systems-analyst/references/erp.md +40 -0
  167. package/dist/skills/enterprise-systems-analyst/references/financial-systems.md +35 -0
  168. package/dist/skills/enterprise-systems-analyst/references/hcm.md +38 -0
  169. package/dist/skills/enterprise-systems-analyst/references/mrp.md +37 -0
  170. package/dist/skills/enterprise-systems-analyst/references/scm.md +32 -0
  171. package/dist/skills/ethical-hacking-methodology/SKILL.md +119 -0
  172. package/dist/skills/externalSkillLoader.d.ts +25 -0
  173. package/dist/skills/externalSkillLoader.js +65 -0
  174. package/dist/skills/externalSkillRegistry.d.ts +33 -0
  175. package/dist/skills/externalSkillRegistry.js +94 -0
  176. package/dist/skills/filesystem-management/SKILL.md +61 -0
  177. package/dist/skills/first-run-seed.d.ts +26 -0
  178. package/dist/skills/first-run-seed.js +75 -0
  179. package/dist/skills/git-vcs/SKILL.md +84 -0
  180. package/dist/skills/kafka/SKILL.md +89 -0
  181. package/dist/skills/kubernetes/SKILL.md +93 -0
  182. package/dist/skills/kubernetes-expert/SKILL.md +54 -0
  183. package/dist/skills/openshift/SKILL.md +93 -0
  184. package/dist/skills/pentester/SKILL.md +59 -0
  185. package/dist/skills/performance-tester/SKILL.md +57 -0
  186. package/dist/skills/playwright-ui-tester/SKILL.md +67 -0
  187. package/dist/skills/programmer/SKILL.md +58 -0
  188. package/dist/skills/project-scaffolding/SKILL.md +133 -0
  189. package/dist/skills/qa-engineer/SKILL.md +91 -0
  190. package/dist/skills/rca/SKILL.md +58 -0
  191. package/dist/skills/redhat/SKILL.md +92 -0
  192. package/dist/skills/rosa/SKILL.md +80 -0
  193. package/dist/skills/scrum-framework/SKILL.md +74 -0
  194. package/dist/skills/scrum-framework/references/artifacts_and_quality.md +79 -0
  195. package/dist/skills/scrum-framework/references/roles_and_events.md +105 -0
  196. package/dist/skills/scrum-master-agent/SKILL.md +74 -0
  197. package/dist/skills/scrum-master-agent/references/behaviors.md +56 -0
  198. package/dist/skills/sdlc-skill.d.ts +1 -0
  199. package/dist/skills/sdlc-skill.js +4 -0
  200. package/dist/skills/secops/SKILL.md +52 -0
  201. package/dist/skills/secure-architect.bylaws.d.ts +68 -0
  202. package/dist/skills/secure-architect.bylaws.js +525 -0
  203. package/dist/skills/seed-skills.d.ts +48 -0
  204. package/dist/skills/seed-skills.js +213 -0
  205. package/dist/skills/skill-authoring/SKILL.md +123 -0
  206. package/dist/skills/skill-header.d.ts +51 -0
  207. package/dist/skills/skill-header.js +163 -0
  208. package/dist/skills/skill-path-guard.d.ts +41 -0
  209. package/dist/skills/skill-path-guard.js +95 -0
  210. package/dist/skills/skillRouter.d.ts +51 -0
  211. package/dist/skills/skillRouter.js +90 -0
  212. package/dist/skills/skills-root.d.ts +64 -0
  213. package/dist/skills/skills-root.js +168 -0
  214. package/dist/skills/software-architect/SKILL.md +77 -0
  215. package/dist/skills/software-engineer/SKILL.md +74 -0
  216. package/dist/skills/solid-principles/SKILL.md +94 -0
  217. package/dist/skills/task-planning/SKILL.md +115 -0
  218. package/dist/skills/tester/SKILL.md +54 -0
  219. package/dist/skills/ubuntu/SKILL.md +87 -0
  220. package/dist/skills/ui-ux-design/SKILL.md +114 -0
  221. package/dist/skills/workspace-context/SKILL.md +103 -0
  222. package/dist/sprint/controller.d.ts +37 -0
  223. package/dist/sprint/controller.js +220 -0
  224. package/dist/sprint/dag-builder.d.ts +14 -0
  225. package/dist/sprint/dag-builder.js +105 -0
  226. package/dist/sprint/reporter.d.ts +11 -0
  227. package/dist/sprint/reporter.js +97 -0
  228. package/dist/sprint/state-store.d.ts +10 -0
  229. package/dist/sprint/state-store.js +71 -0
  230. package/dist/sprint/types.d.ts +24 -0
  231. package/dist/sprint/types.js +4 -0
  232. package/dist/store/file-version-store.d.ts +24 -0
  233. package/dist/store/file-version-store.js +73 -0
  234. package/dist/store/task-store.d.ts +90 -0
  235. package/dist/store/task-store.js +166 -0
  236. package/dist/task-ingest/architect-detailer.d.ts +43 -0
  237. package/dist/task-ingest/architect-detailer.js +141 -0
  238. package/dist/task-ingest/detail-schema.d.ts +9 -0
  239. package/dist/task-ingest/detail-schema.js +195 -0
  240. package/dist/task-ingest/detailed-run.d.ts +36 -0
  241. package/dist/task-ingest/detailed-run.js +108 -0
  242. package/dist/task-ingest/extract-id.d.ts +9 -0
  243. package/dist/task-ingest/extract-id.js +24 -0
  244. package/dist/task-ingest/index.d.ts +23 -0
  245. package/dist/task-ingest/index.js +14 -0
  246. package/dist/task-ingest/ingest.d.ts +45 -0
  247. package/dist/task-ingest/ingest.js +163 -0
  248. package/dist/task-ingest/list-ingested.d.ts +13 -0
  249. package/dist/task-ingest/list-ingested.js +30 -0
  250. package/dist/task-ingest/pending-filter.d.ts +30 -0
  251. package/dist/task-ingest/pending-filter.js +59 -0
  252. package/dist/task-ingest/scanner.d.ts +56 -0
  253. package/dist/task-ingest/scanner.js +216 -0
  254. package/dist/task-ingest/source-reader.d.ts +25 -0
  255. package/dist/task-ingest/source-reader.js +93 -0
  256. package/dist/task-ingest/spec-builder.d.ts +34 -0
  257. package/dist/task-ingest/spec-builder.js +89 -0
  258. package/dist/task-ingest/wbs-extract.d.ts +50 -0
  259. package/dist/task-ingest/wbs-extract.js +226 -0
  260. package/dist/task-ingest/wbs-parser.d.ts +36 -0
  261. package/dist/task-ingest/wbs-parser.js +170 -0
  262. package/dist/tools/apiTestTool.d.ts +37 -0
  263. package/dist/tools/apiTestTool.js +128 -0
  264. package/dist/tools/ast-tools.d.ts +183 -0
  265. package/dist/tools/ast-tools.js +853 -0
  266. package/dist/tools/browse-tool.d.ts +105 -0
  267. package/dist/tools/browse-tool.js +394 -0
  268. package/dist/tools/credential.d.ts +17 -0
  269. package/dist/tools/credential.js +32 -0
  270. package/dist/tools/dependency-graph.d.ts +23 -0
  271. package/dist/tools/dependency-graph.js +164 -0
  272. package/dist/tools/edit-tool.d.ts +34 -0
  273. package/dist/tools/edit-tool.js +95 -0
  274. package/dist/tools/file-header-manager.d.ts +27 -0
  275. package/dist/tools/file-header-manager.js +153 -0
  276. package/dist/tools/fs-tools.d.ts +154 -0
  277. package/dist/tools/fs-tools.js +337 -0
  278. package/dist/tools/git-tools.d.ts +79 -0
  279. package/dist/tools/git-tools.js +348 -0
  280. package/dist/tools/github-tool.d.ts +48 -0
  281. package/dist/tools/github-tool.js +147 -0
  282. package/dist/tools/globTool.d.ts +20 -0
  283. package/dist/tools/globTool.js +34 -0
  284. package/dist/tools/grepTool.d.ts +19 -0
  285. package/dist/tools/grepTool.js +44 -0
  286. package/dist/tools/index-freshness.d.ts +58 -0
  287. package/dist/tools/index-freshness.js +190 -0
  288. package/dist/tools/index-glob.d.ts +48 -0
  289. package/dist/tools/index-glob.js +175 -0
  290. package/dist/tools/load-skill-tool.d.ts +15 -0
  291. package/dist/tools/load-skill-tool.js +114 -0
  292. package/dist/tools/patch-tools.d.ts +58 -0
  293. package/dist/tools/patch-tools.js +153 -0
  294. package/dist/tools/playwright-tool.d.ts +66 -0
  295. package/dist/tools/playwright-tool.js +121 -0
  296. package/dist/tools/project-detect.d.ts +20 -0
  297. package/dist/tools/project-detect.js +87 -0
  298. package/dist/tools/prompt-guidance.d.ts +22 -0
  299. package/dist/tools/prompt-guidance.js +23 -0
  300. package/dist/tools/scheduleTool.d.ts +19 -0
  301. package/dist/tools/scheduleTool.js +181 -0
  302. package/dist/tools/search-tools.d.ts +27 -0
  303. package/dist/tools/search-tools.js +78 -0
  304. package/dist/tools/sed-tool.d.ts +66 -0
  305. package/dist/tools/sed-tool.js +402 -0
  306. package/dist/tools/shell-result.d.ts +11 -0
  307. package/dist/tools/shell-result.js +1 -0
  308. package/dist/tools/shell-tool.d.ts +45 -0
  309. package/dist/tools/shell-tool.js +141 -0
  310. package/dist/tools/siteCrawlerTool.d.ts +32 -0
  311. package/dist/tools/siteCrawlerTool.js +205 -0
  312. package/dist/tools/tool-registry.d.ts +67 -0
  313. package/dist/tools/tool-registry.js +596 -0
  314. package/dist/tools/validate-tool.d.ts +23 -0
  315. package/dist/tools/validate-tool.js +201 -0
  316. package/dist/tools/workspace-index.d.ts +46 -0
  317. package/dist/tools/workspace-index.js +173 -0
  318. package/dist/types.d.ts +222 -0
  319. package/dist/types.js +7 -0
  320. package/dist/updater/index.d.ts +14 -0
  321. package/dist/updater/index.js +120 -0
  322. package/dist/util/banner.d.ts +25 -0
  323. package/dist/util/banner.js +140 -0
  324. package/dist/util/command-suggester.d.ts +6 -0
  325. package/dist/util/command-suggester.js +25 -0
  326. package/dist/util/confirm-interrupt.d.ts +10 -0
  327. package/dist/util/confirm-interrupt.js +31 -0
  328. package/dist/util/continue-trigger.d.ts +11 -0
  329. package/dist/util/continue-trigger.js +20 -0
  330. package/dist/util/env-info.d.ts +18 -0
  331. package/dist/util/env-info.js +37 -0
  332. package/dist/util/file-access-log.d.ts +35 -0
  333. package/dist/util/file-access-log.js +140 -0
  334. package/dist/util/footer-manager.d.ts +124 -0
  335. package/dist/util/footer-manager.js +195 -0
  336. package/dist/util/footer-renderer.d.ts +67 -0
  337. package/dist/util/footer-renderer.js +319 -0
  338. package/dist/util/footer-state.d.ts +34 -0
  339. package/dist/util/footer-state.js +18 -0
  340. package/dist/util/footer-text.d.ts +51 -0
  341. package/dist/util/footer-text.js +74 -0
  342. package/dist/util/ids.d.ts +1 -0
  343. package/dist/util/ids.js +4 -0
  344. package/dist/util/levenshtein.d.ts +6 -0
  345. package/dist/util/levenshtein.js +34 -0
  346. package/dist/util/logger.d.ts +10 -0
  347. package/dist/util/logger.js +41 -0
  348. package/dist/util/logs.d.ts +26 -0
  349. package/dist/util/logs.js +88 -0
  350. package/dist/util/output-handler.d.ts +89 -0
  351. package/dist/util/output-handler.js +193 -0
  352. package/dist/util/output-interceptor.d.ts +18 -0
  353. package/dist/util/output-interceptor.js +49 -0
  354. package/dist/util/output-paths.d.ts +43 -0
  355. package/dist/util/output-paths.js +121 -0
  356. package/dist/util/package-json.d.ts +6 -0
  357. package/dist/util/package-json.js +36 -0
  358. package/dist/util/process-kill.d.ts +27 -0
  359. package/dist/util/process-kill.js +148 -0
  360. package/dist/util/protocol-error-logger.d.ts +33 -0
  361. package/dist/util/protocol-error-logger.js +73 -0
  362. package/dist/util/redact.d.ts +25 -0
  363. package/dist/util/redact.js +103 -0
  364. package/dist/util/scroll-region-guard.d.ts +33 -0
  365. package/dist/util/scroll-region-guard.js +63 -0
  366. package/dist/util/spinner.d.ts +15 -0
  367. package/dist/util/spinner.js +49 -0
  368. package/dist/util/terminal-output.d.ts +34 -0
  369. package/dist/util/terminal-output.js +1 -0
  370. package/dist/util/terminal-silent.d.ts +6 -0
  371. package/dist/util/terminal-silent.js +20 -0
  372. package/dist/util/terminal.d.ts +56 -0
  373. package/dist/util/terminal.js +124 -0
  374. package/dist/util/text-sanitize.d.ts +8 -0
  375. package/dist/util/text-sanitize.js +45 -0
  376. package/dist/util/thinking-spinner.d.ts +27 -0
  377. package/dist/util/thinking-spinner.js +189 -0
  378. package/dist/util/tool-error-logger.d.ts +33 -0
  379. package/dist/util/tool-error-logger.js +77 -0
  380. package/dist/util/tty.d.ts +13 -0
  381. package/dist/util/tty.js +16 -0
  382. package/dist/util/xcoder-paths.d.ts +56 -0
  383. package/dist/util/xcoder-paths.js +63 -0
  384. package/dist/version.d.ts +2 -0
  385. package/dist/version.js +4 -0
  386. package/dist/worker-agent/to-subtask-node.d.ts +35 -0
  387. package/dist/worker-agent/to-subtask-node.js +41 -0
  388. package/dist/worker-agent/worker-orchestrator.d.ts +104 -0
  389. package/dist/worker-agent/worker-orchestrator.js +201 -0
  390. package/package.json +39 -4
@@ -0,0 +1,18 @@
1
+ // xcoder:version 1 | xcoder:task task-4f2baf | xcoder:updated 2026-08-05T05:48:22.242Z | xcoder:subtask code-st-11b531
2
+ import { EventEmitter } from "node:events";
3
+ /**
4
+ * A single EventEmitter every RAO-producing part of the system emits to —
5
+ * `agents/sub-agent.ts`, `orchestrator/swarm.ts`, `orchestrator/
6
+ * sdlc-orchestrator.ts`. Two things consume it today: `util/terminal.ts`
7
+ * (indirectly — those modules still call `term.*` directly for the CLI's
8
+ * colored output) and `xcoder observe --json`, which prints every event as
9
+ * a JSON line. Adding another
10
+ * consumer (a plain JSON event log, a metrics exporter) means subscribing
11
+ * here, not threading a new parameter through every function that produces
12
+ * an event.
13
+ */
14
+ export const xcoderEvents = new EventEmitter();
15
+ xcoderEvents.setMaxListeners(200);
16
+ export function emitXcoderEvent(ev) {
17
+ xcoderEvents.emit("event", { ...ev, ts: new Date().toISOString() });
18
+ }
@@ -0,0 +1,79 @@
1
+ export { runDebate } from "./agents/ai-chat-debate.js";
2
+ export { writeReport } from "./agents/ai-chat-report-writer.js";
3
+ export { DuplicateActionDetector } from "./agents/duplicate-detector.js";
4
+ export { GenesisReActOrchestrator, type OrchestratorState } from "./agents/genesis-agent.js";
5
+ export { SamuraiAgent } from "./agents/samurai-agent.js";
6
+ export { SubAgent } from "./agents/sub-agent.js";
7
+ export { addBacklogItem, updateBacklogItem, listBacklogItems, getBacklogItem } from "./backlog/backlog-store.js";
8
+ export { runPoPick } from "./backlog/po-agent.js";
9
+ export { runBenchmark, compareReports } from "./bench/run.js";
10
+ export { registerSwarmCommand } from "./cli/swarm.js";
11
+ export { registerTaskCommand } from "./cli/task.js";
12
+ export { extractWbcArg } from "./cli/wbc-arg.js";
13
+ export { capturedWbc, runCapturedWbc, setWbcSourcePath } from "./cli/wbc.js";
14
+ export { registerLicenseCommand } from "./commands/license.js";
15
+ export { runRelease } from "./commands/release.js";
16
+ export { registerTestCommand } from "./commands/test.js";
17
+ export { type AgentRole } from "./config/loadConfig.js";
18
+ export { applyUserConfig, extractConfigArg, formatUserConfig, parseConfigArg, readUserConfig, saveUserConfig, userConfigPath } from "./config/user-config.js";
19
+ export { getOrchestratorEngine } from "./engine/reasoning-engine.js";
20
+ export { xcoderEvents, type XcoderEvent, emitXcoderEvent } from "./events/bus.js";
21
+ export { InstanceSwarmOrchestrator } from "./instance-swarm/instance-swarm-orchestrator.js";
22
+ export { LICENSE_REQUIRED_EXIT_CODE, isLicensedFeature, maybeRefreshLicense, requireLicense, createDefaultLicenseManager } from "./license/gate.js";
23
+ export { requestScope } from "./llm/budget.js";
24
+ export { LlmClient, type LlmMessage } from "./llm/client.js";
25
+ export { createLlmClient } from "./llm/factory.js";
26
+ export { logDefectEvent } from "./orchestrator/defect-logger.js";
27
+ export { scanForDefects, classifyDefectRouting, buildFixDefectNode, resolveDefect, recordFixAttempt } from "./orchestrator/defect-manager.js";
28
+ export { migrateLegacyDefects } from "./orchestrator/defect-migration.js";
29
+ export { loadDefectsIndex, upsertDefect } from "./orchestrator/defect-store.js";
30
+ export { decideHealing } from "./orchestrator/healing.js";
31
+ export { InteractiveSteeringManager, type SteeringInjection } from "./orchestrator/interactive-steering.js";
32
+ export { type InterruptAction, computeInterruptAction } from "./orchestrator/interrupt-handler.js";
33
+ export { resolveLessonFlag, loadLessons, checkLessonFileSize, recordLesson } from "./orchestrator/lesson-manager.js";
34
+ export { buildProgressSummaryMarkdown } from "./orchestrator/progress-summary.js";
35
+ export { computeReasoningScore, efficiencyHint } from "./orchestrator/reasoning-score.js";
36
+ export { dispatchSwarm } from "./orchestrator/swarm.js";
37
+ export { deliverableFor, acceptanceCriteriaFor, buildInitialPlan, isConversation, buildTaskSpec } from "./orchestrator/task-factory.js";
38
+ export { validateSubtask, type ValidationOutcome } from "./orchestrator/validation-gate.js";
39
+ export { type WksProtocolMap, parseWksProtocol } from "./protocol/wks-protocol-manager.js";
40
+ export { SdlcOrchestrator } from "./sdlc-runtime/sdlc-orchestrator.js";
41
+ export { classifyIntake, INTAKE_RULES, STAGE_ROLE } from "./sdlc-runtime/sdlc-skill.js";
42
+ export { BYLAW_SECTION_HEADER } from "./skills/bylaw-context.js";
43
+ export { reviewDeliverable } from "./skills/bylaw-review.js";
44
+ export { BA_REQUIREMENTS_DIRECTIVE, ROLE_DIRECTIVES } from "./skills/directives.js";
45
+ export { maybeSeedSkillsHome } from "./skills/first-run-seed.js";
46
+ export { inferLayers, renderBylaws, type BylawFinding, type BylawLayer, type ReviewResult } from "./skills/secure-architect.bylaws.js";
47
+ export { sprintStart, sprintStatus, sprintRetro, sprintAbort } from "./sprint/controller.js";
48
+ export { saveTaskRun, loadTaskRun, reconcileOrphanedTasks, saveProgressSummary, listTaskRuns, findResumableTasks, detectResumableTask, isResumableRun, saveTaskRunSync, RESUMABLE_STATUSES } from "./store/task-store.js";
49
+ export { parseStepSpec, runBrowse, type BrowseResult } from "./tools/browse-tool.js";
50
+ export { redact } from "./tools/credential.js";
51
+ export { ensureFreshIndex } from "./tools/index-freshness.js";
52
+ export { type ToolManifestEntry } from "./tools/tool-registry.js";
53
+ export { getOrBuildIndex, buildIndex, type WorkspaceIndex } from "./tools/workspace-index.js";
54
+ export { type SubtaskNode, type TokenUsage, type Role, type SdlcStage, type TaskRun, type TaskSpec, type SubtaskResult, type LessonEntry, type SubtaskStatus, type TaskInputs } from "./types.js";
55
+ export { maybePrintBanner } from "./util/banner.js";
56
+ export { suggestCommands } from "./util/command-suggester.js";
57
+ export { confirmInterrupt } from "./util/confirm-interrupt.js";
58
+ export { isContinueTrigger } from "./util/continue-trigger.js";
59
+ export { logFileAccess, logIndexRefresh } from "./util/file-access-log.js";
60
+ export { FooterManager } from "./util/footer-manager.js";
61
+ export { titleField, sanitizeTitle, versionLabel, FOOTER_TITLE_MAX } from "./util/footer-text.js";
62
+ export { shortId } from "./util/ids.js";
63
+ export { log } from "./util/logger.js";
64
+ export { appendSys, appendScore, taskLogDir } from "./util/logs.js";
65
+ export { getOutputHandler } from "./util/output-handler.js";
66
+ export { getOutputPaths } from "./util/output-paths.js";
67
+ export { killProcessTree, killTrackedPids } from "./util/process-kill.js";
68
+ export { enableProtocolErrorLogging } from "./util/protocol-error-logger.js";
69
+ export { redactSecrets } from "./util/redact.js";
70
+ export { setSpinnerStyle, getSpinnerStyle, createSpinner, type SpinnerHandle, AVAILABLE_SPINNER_STYLES } from "./util/spinner.js";
71
+ export { taskIntro, taskOutro, orchestratorNote, printCrash, printInterruptSummary } from "./util/terminal.js";
72
+ export { sanitizeForTerminal } from "./util/text-sanitize.js";
73
+ export { enableToolErrorLogging } from "./util/tool-error-logger.js";
74
+ export { isInteractiveStdout } from "./util/tty.js";
75
+ export { createXcoderPaths } from "./util/xcoder-paths.js";
76
+ export { XCODER_VERSION } from "./version.js";
77
+ export { WorkerOrchestrator, type WorkerRunReport, type WorkerSubtask, type WorkerRunRequest, type WorkerSubtaskReport } from "./worker-agent/worker-orchestrator.js";
78
+ export { inlineIntoDependents, dagSnapshot, recomputeReady } from "./sdlc-runtime/dag-utils.js";
79
+ export { getStageRole, classifyDesignRole, isInternalRole, SDLC_STAGES, STAGE_ROLE as SDLC_STAGE_ROLE, INTERNAL_ROLES, CONVERSATION_RULE } from "./sdlc-runtime/sdlc-skill.js";
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ // Public barrel — the only import path other packages may use.
2
+ export { runDebate } from "./agents/ai-chat-debate.js";
3
+ export { writeReport } from "./agents/ai-chat-report-writer.js";
4
+ export { DuplicateActionDetector } from "./agents/duplicate-detector.js";
5
+ export { GenesisReActOrchestrator } from "./agents/genesis-agent.js";
6
+ export { SamuraiAgent } from "./agents/samurai-agent.js";
7
+ export { SubAgent } from "./agents/sub-agent.js";
8
+ export { addBacklogItem, updateBacklogItem, listBacklogItems, getBacklogItem } from "./backlog/backlog-store.js";
9
+ export { runPoPick } from "./backlog/po-agent.js";
10
+ export { runBenchmark, compareReports } from "./bench/run.js";
11
+ export { registerSwarmCommand } from "./cli/swarm.js";
12
+ export { registerTaskCommand } from "./cli/task.js";
13
+ export { extractWbcArg } from "./cli/wbc-arg.js";
14
+ export { capturedWbc, runCapturedWbc, setWbcSourcePath } from "./cli/wbc.js";
15
+ export { registerLicenseCommand } from "./commands/license.js";
16
+ export { runRelease } from "./commands/release.js";
17
+ export { registerTestCommand } from "./commands/test.js";
18
+ export { applyUserConfig, extractConfigArg, formatUserConfig, parseConfigArg, readUserConfig, saveUserConfig, userConfigPath } from "./config/user-config.js";
19
+ export { getOrchestratorEngine } from "./engine/reasoning-engine.js";
20
+ export { xcoderEvents, emitXcoderEvent } from "./events/bus.js";
21
+ export { InstanceSwarmOrchestrator } from "./instance-swarm/instance-swarm-orchestrator.js";
22
+ export { LICENSE_REQUIRED_EXIT_CODE, isLicensedFeature, maybeRefreshLicense, requireLicense, createDefaultLicenseManager } from "./license/gate.js";
23
+ export { requestScope } from "./llm/budget.js";
24
+ export { LlmClient } from "./llm/client.js";
25
+ export { createLlmClient } from "./llm/factory.js";
26
+ export { logDefectEvent } from "./orchestrator/defect-logger.js";
27
+ export { scanForDefects, classifyDefectRouting, buildFixDefectNode, resolveDefect, recordFixAttempt } from "./orchestrator/defect-manager.js";
28
+ export { migrateLegacyDefects } from "./orchestrator/defect-migration.js";
29
+ export { loadDefectsIndex, upsertDefect } from "./orchestrator/defect-store.js";
30
+ export { decideHealing } from "./orchestrator/healing.js";
31
+ export { InteractiveSteeringManager } from "./orchestrator/interactive-steering.js";
32
+ export { computeInterruptAction } from "./orchestrator/interrupt-handler.js";
33
+ export { resolveLessonFlag, loadLessons, checkLessonFileSize, recordLesson } from "./orchestrator/lesson-manager.js";
34
+ export { buildProgressSummaryMarkdown } from "./orchestrator/progress-summary.js";
35
+ export { computeReasoningScore, efficiencyHint } from "./orchestrator/reasoning-score.js";
36
+ export { dispatchSwarm } from "./orchestrator/swarm.js";
37
+ export { deliverableFor, acceptanceCriteriaFor, buildInitialPlan, isConversation, buildTaskSpec } from "./orchestrator/task-factory.js";
38
+ export { validateSubtask } from "./orchestrator/validation-gate.js";
39
+ export { parseWksProtocol } from "./protocol/wks-protocol-manager.js";
40
+ export { SdlcOrchestrator } from "./sdlc-runtime/sdlc-orchestrator.js";
41
+ export { classifyIntake, INTAKE_RULES, STAGE_ROLE } from "./sdlc-runtime/sdlc-skill.js";
42
+ export { BYLAW_SECTION_HEADER } from "./skills/bylaw-context.js";
43
+ export { reviewDeliverable } from "./skills/bylaw-review.js";
44
+ export { BA_REQUIREMENTS_DIRECTIVE, ROLE_DIRECTIVES } from "./skills/directives.js";
45
+ export { maybeSeedSkillsHome } from "./skills/first-run-seed.js";
46
+ export { inferLayers, renderBylaws } from "./skills/secure-architect.bylaws.js";
47
+ export { sprintStart, sprintStatus, sprintRetro, sprintAbort } from "./sprint/controller.js";
48
+ export { saveTaskRun, loadTaskRun, reconcileOrphanedTasks, saveProgressSummary, listTaskRuns, findResumableTasks, detectResumableTask, isResumableRun, saveTaskRunSync, RESUMABLE_STATUSES } from "./store/task-store.js";
49
+ export { parseStepSpec, runBrowse } from "./tools/browse-tool.js";
50
+ export { redact } from "./tools/credential.js";
51
+ export { ensureFreshIndex } from "./tools/index-freshness.js";
52
+ export { getOrBuildIndex, buildIndex } from "./tools/workspace-index.js";
53
+ export { maybePrintBanner } from "./util/banner.js";
54
+ export { suggestCommands } from "./util/command-suggester.js";
55
+ export { confirmInterrupt } from "./util/confirm-interrupt.js";
56
+ export { isContinueTrigger } from "./util/continue-trigger.js";
57
+ export { logFileAccess, logIndexRefresh } from "./util/file-access-log.js";
58
+ export { FooterManager } from "./util/footer-manager.js";
59
+ export { titleField, sanitizeTitle, versionLabel, FOOTER_TITLE_MAX } from "./util/footer-text.js";
60
+ export { shortId } from "./util/ids.js";
61
+ export { log } from "./util/logger.js";
62
+ export { appendSys, appendScore, taskLogDir } from "./util/logs.js";
63
+ export { getOutputHandler } from "./util/output-handler.js";
64
+ export { getOutputPaths } from "./util/output-paths.js";
65
+ export { killProcessTree, killTrackedPids } from "./util/process-kill.js";
66
+ export { enableProtocolErrorLogging } from "./util/protocol-error-logger.js";
67
+ export { redactSecrets } from "./util/redact.js";
68
+ export { setSpinnerStyle, getSpinnerStyle, createSpinner, AVAILABLE_SPINNER_STYLES } from "./util/spinner.js";
69
+ export { taskIntro, taskOutro, orchestratorNote, printCrash, printInterruptSummary } from "./util/terminal.js";
70
+ export { sanitizeForTerminal } from "./util/text-sanitize.js";
71
+ export { enableToolErrorLogging } from "./util/tool-error-logger.js";
72
+ export { isInteractiveStdout } from "./util/tty.js";
73
+ export { createXcoderPaths } from "./util/xcoder-paths.js";
74
+ export { XCODER_VERSION } from "./version.js";
75
+ export { WorkerOrchestrator } from "./worker-agent/worker-orchestrator.js";
76
+ export { inlineIntoDependents, dagSnapshot, recomputeReady } from "./sdlc-runtime/dag-utils.js";
77
+ export { getStageRole, classifyDesignRole, isInternalRole, SDLC_STAGES, STAGE_ROLE as SDLC_STAGE_ROLE, INTERNAL_ROLES, CONVERSATION_RULE } from "./sdlc-runtime/sdlc-skill.js";
@@ -0,0 +1 @@
1
+ export declare function loadIgnoreRules(cwd?: string): string[];
@@ -0,0 +1,53 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ const IGNORE_FILES = [".agent/.agentignore", ".gitignore", ".dockerignore"];
4
+ const ALWAYS_IGNORE = ["**/node_modules/**", ".git/**", "dist/**", ".agent/index/**", ".log/**"];
5
+ /**
6
+ * Converts a single ignore-line pattern into a glob-compatible pattern.
7
+ *
8
+ * - Trailing slash means directory only -> prefix with double-star-slash and
9
+ * append double-star so it matches at any depth.
10
+ * - Bare directory name (no path separators, no dots, no glob chars) -> prefix
11
+ * with double-star-slash and append slash-double-star so it matches the
12
+ * directory and everything inside at any depth.
13
+ * - Patterns already starting with double-star-slash are left as-is.
14
+ * - Everything else is treated as a literal file/glob pattern.
15
+ */
16
+ function normalizePattern(line) {
17
+ const trimmed = line.trim();
18
+ if (!trimmed || trimmed.startsWith("#"))
19
+ return trimmed;
20
+ // Already a recursive glob -- use as-is
21
+ if (trimmed.startsWith("**/"))
22
+ return trimmed;
23
+ // Directory-only pattern: "node_modules/" -> "**/node_modules/**"
24
+ if (trimmed.endsWith("/"))
25
+ return `**/${trimmed}**`;
26
+ // Bare directory name (no path separators, no dots, no glob chars):
27
+ // e.g. "dist" -> "**/dist/**", but "Thumbs.db" stays as-is (has a dot)
28
+ if (!trimmed.includes("/") &&
29
+ !trimmed.includes("\\") &&
30
+ !trimmed.includes(".") &&
31
+ !trimmed.includes("*") &&
32
+ !trimmed.includes("?")) {
33
+ return `**/${trimmed}/**`;
34
+ }
35
+ return trimmed;
36
+ }
37
+ export function loadIgnoreRules(cwd = process.cwd()) {
38
+ const rules = new Set(ALWAYS_IGNORE);
39
+ for (const rel of IGNORE_FILES) {
40
+ const p = path.join(cwd, rel);
41
+ if (!fs.existsSync(p))
42
+ continue;
43
+ const lines = fs
44
+ .readFileSync(p, "utf-8")
45
+ .split("\n")
46
+ .map((l) => l.trim())
47
+ .filter((l) => l && !l.startsWith("#"));
48
+ for (const line of lines) {
49
+ rules.add(normalizePattern(line));
50
+ }
51
+ }
52
+ return [...rules];
53
+ }
@@ -0,0 +1,57 @@
1
+ import type { TokenUsage } from "../types.js";
2
+ import type { SwarmDispatchResult } from "../orchestrator/swarm.js";
3
+ import { LlmClient } from "../llm/client.js";
4
+ export interface InstanceSwarmResult {
5
+ instanceId: string;
6
+ status: "completed" | "failed" | "timeout";
7
+ results: SwarmDispatchResult[];
8
+ errors: string[];
9
+ totalTokenUsage: TokenUsage;
10
+ outputDir: string;
11
+ }
12
+ export interface InstanceSwarmOrchestratorHooks {
13
+ /** Called when a worker starts processing its goal */
14
+ onWorkerStart?: (workerIndex: number, workerId: string) => void;
15
+ /** Called when a worker completes with a result */
16
+ onWorkerFinish?: (workerIndex: number, workerId: string, crashed: boolean, summary: string) => void;
17
+ /** Called when a worker fails with an error */
18
+ onWorkerError?: (workerIndex: number, workerId: string, error: string) => void;
19
+ /** Called when the swarm run completes */
20
+ onSwarmComplete?: (result: InstanceSwarmResult) => void;
21
+ }
22
+ export interface InstanceSwarmOrchestratorOptions {
23
+ workspaceRoot: string;
24
+ llm: LlmClient;
25
+ /** Worker (instance_agent role) client — defaults to `llm`. */
26
+ agentClient?: LlmClient;
27
+ concurrency?: number;
28
+ maxIterations?: number;
29
+ outputDir?: string;
30
+ instanceId?: string;
31
+ hooks?: InstanceSwarmOrchestratorHooks;
32
+ }
33
+ /**
34
+ * Instance Samurai Swarm Orchestrator.
35
+ *
36
+ * Creates and dispatches one or more SubAgents with a given goal and
37
+ * protocol section injected into their system prompts. Multiple instances
38
+ * run concurrently with full isolation — the orchestrator never throws,
39
+ * it returns a structured result.
40
+ */
41
+ export declare class InstanceSwarmOrchestrator {
42
+ private opts;
43
+ constructor(opts: InstanceSwarmOrchestratorOptions);
44
+ /**
45
+ * Dispatches SubAgents (one or a bounded pool) against the goal, with
46
+ * protocol section from wks_protocol.md injected. Returns a structured
47
+ * InstanceSwarmResult — NEVER throws.
48
+ */
49
+ run(goal: string, protocolName: string): Promise<InstanceSwarmResult>;
50
+ /**
51
+ * Builds a synthetic SubtaskNode suitable for SubAgent consumption.
52
+ * This avoids coupling to the Master Orchestrator's DAG lifecycle —
53
+ * we create self-contained nodes with the goal and protocol overrides
54
+ * already baked in.
55
+ */
56
+ private buildSyntheticNode;
57
+ }
@@ -0,0 +1,204 @@
1
+ import { SubAgent } from "../agents/sub-agent.js";
2
+ import { parseWksProtocol } from "../protocol/wks-protocol-manager.js";
3
+ import { resolveRole, resolveSectionKey } from "./protocol-name-resolver.js";
4
+ import { shortId } from "../util/ids.js";
5
+ import { getOutputPaths } from "../util/output-paths.js";
6
+ import path from "node:path";
7
+ import { promises as fs } from "node:fs";
8
+ // (end of options interface)
9
+ /**
10
+ * Instance Samurai Swarm Orchestrator.
11
+ *
12
+ * Creates and dispatches one or more SubAgents with a given goal and
13
+ * protocol section injected into their system prompts. Multiple instances
14
+ * run concurrently with full isolation — the orchestrator never throws,
15
+ * it returns a structured result.
16
+ */
17
+ export class InstanceSwarmOrchestrator {
18
+ opts;
19
+ constructor(opts) {
20
+ const now = new Date().toISOString().replace(/[:.]/g, "-");
21
+ const instanceId = opts.instanceId ?? `swarm-${shortId("is")}`;
22
+ const outputDir = opts.outputDir ??
23
+ getOutputPaths({ cwd: opts.workspaceRoot }).instanceSwarmDir(`${instanceId}-${now}`);
24
+ this.opts = {
25
+ workspaceRoot: opts.workspaceRoot,
26
+ llm: opts.llm,
27
+ agentClient: opts.agentClient,
28
+ concurrency: opts.concurrency ?? 1,
29
+ maxIterations: opts.maxIterations ?? 200,
30
+ outputDir,
31
+ instanceId,
32
+ hooks: opts.hooks ?? {},
33
+ };
34
+ }
35
+ /**
36
+ * Dispatches SubAgents (one or a bounded pool) against the goal, with
37
+ * protocol section from wks_protocol.md injected. Returns a structured
38
+ * InstanceSwarmResult — NEVER throws.
39
+ */
40
+ async run(goal, protocolName) {
41
+ const { instanceId, outputDir, workspaceRoot, llm, agentClient, concurrency, maxIterations } = this.opts;
42
+ const errors = [];
43
+ const results = [];
44
+ const totalTokenUsage = { inputTokens: 0, outputTokens: 0 };
45
+ // Ensure output directory exists
46
+ try {
47
+ await fs.mkdir(outputDir, { recursive: true });
48
+ }
49
+ catch (e) {
50
+ errors.push(`failed to create output directory ${outputDir}: ${e.message}`);
51
+ }
52
+ // Load protocol map
53
+ let protocolMap = {};
54
+ try {
55
+ const filePath = path.join(this.opts.workspaceRoot, "wks_protocol.md");
56
+ const content = await fs.readFile(filePath, "utf-8");
57
+ protocolMap = parseWksProtocol(content);
58
+ }
59
+ catch {
60
+ // File missing or unreadable — proceed without protocol overrides
61
+ }
62
+ // Resolve protocol name to role + section key
63
+ const role = resolveRole(protocolName);
64
+ const sectionKey = resolveSectionKey(protocolName);
65
+ // Build protocol overrides for the resolved role
66
+ let protocolOverrides;
67
+ if (sectionKey && protocolMap[sectionKey] !== undefined) {
68
+ protocolOverrides = { [role]: protocolMap[sectionKey] };
69
+ }
70
+ // Resolve the section content for logging/debugging
71
+ const sectionBody = sectionKey ? protocolMap[sectionKey] : undefined;
72
+ const hasProtocolSection = sectionBody !== undefined && sectionBody !== "";
73
+ // Build synthetic subtask nodes — one per concurrent worker.
74
+ // Each worker gets the same goal and protocol overrides, and they
75
+ // operate independently (no shared state).
76
+ const taskId = `swarm-${instanceId}`;
77
+ const maxConcurrency = Math.max(1, concurrency);
78
+ const nodes = Array.from({ length: maxConcurrency }, (_, i) => this.buildSyntheticNode({
79
+ taskId,
80
+ workerIndex: i,
81
+ goal,
82
+ role,
83
+ hasProtocolSection,
84
+ sectionBody,
85
+ }));
86
+ // Run workers concurrently with bounded pool (same pattern as dispatchSwarm)
87
+ const queue = [...nodes];
88
+ const { hooks } = this.opts;
89
+ async function worker() {
90
+ while (queue.length) {
91
+ const node = queue.shift();
92
+ if (!node)
93
+ return;
94
+ // Extract worker index from synthetic node id (format: taskId/index)
95
+ const workerIndex = parseInt(node.id.split("/").pop() ?? "0", 10);
96
+ hooks.onWorkerStart?.(workerIndex, node.id);
97
+ const agent = new SubAgent({
98
+ taskId: node.id.split("/")[0],
99
+ workspaceRoot,
100
+ llm: agentClient ?? llm,
101
+ maxIterations,
102
+ protocolOverrides,
103
+ });
104
+ let result;
105
+ try {
106
+ result = await agent.run(node);
107
+ }
108
+ catch (e) {
109
+ const message = e.stack ?? String(e);
110
+ errors.push(`worker for ${node.id} crashed: ${message}`);
111
+ hooks.onWorkerError?.(workerIndex, node.id, message);
112
+ result = {
113
+ summary: `Sub Agent crashed unexpectedly: ${e.message}`,
114
+ deliverable: null,
115
+ filesTouched: [],
116
+ raoTrace: [],
117
+ tokenUsage: { inputTokens: 0, outputTokens: 0 },
118
+ iterations: 0,
119
+ crashed: true,
120
+ };
121
+ }
122
+ hooks.onWorkerFinish?.(workerIndex, node.id, result.crashed ?? false, result.summary);
123
+ results.push({ subtaskId: node.id, result });
124
+ totalTokenUsage.inputTokens += result.tokenUsage.inputTokens;
125
+ totalTokenUsage.outputTokens += result.tokenUsage.outputTokens;
126
+ }
127
+ }
128
+ try {
129
+ const workerCount = Math.min(maxConcurrency, nodes.length);
130
+ const workerPromises = [];
131
+ for (let i = 0; i < workerCount; i++) {
132
+ workerPromises.push(worker());
133
+ }
134
+ await Promise.all(workerPromises);
135
+ }
136
+ catch (e) {
137
+ errors.push(`orchestrator worker pool failed: ${e.message}`);
138
+ }
139
+ const allCrashed = results.length > 0 && results.every((r) => r.result.crashed);
140
+ const anyTimeout = results.some((r) => !r.result.crashed &&
141
+ !r.result.stuckLoop &&
142
+ r.result.iterations >= maxIterations);
143
+ let status = "completed";
144
+ if (allCrashed && results.length > 0) {
145
+ status = "failed";
146
+ }
147
+ else if (anyTimeout) {
148
+ status = "timeout";
149
+ }
150
+ else if (errors.length > 0 && results.length === 0) {
151
+ status = "failed";
152
+ }
153
+ const finalResult = {
154
+ instanceId,
155
+ status,
156
+ results,
157
+ errors,
158
+ totalTokenUsage,
159
+ outputDir,
160
+ };
161
+ hooks.onSwarmComplete?.(finalResult);
162
+ return finalResult;
163
+ }
164
+ /**
165
+ * Builds a synthetic SubtaskNode suitable for SubAgent consumption.
166
+ * This avoids coupling to the Master Orchestrator's DAG lifecycle —
167
+ * we create self-contained nodes with the goal and protocol overrides
168
+ * already baked in.
169
+ */
170
+ buildSyntheticNode(params) {
171
+ const nodeId = `${params.taskId}/${params.workerIndex}`;
172
+ const protocolNote = params.hasProtocolSection
173
+ ? `\nThe wks_protocol.md section for role "${params.role}" has been injected into your system prompt.`
174
+ : "";
175
+ return {
176
+ id: nodeId,
177
+ stage: "code", // Default stage — the orchestrator runs isolated from the WBS DAG
178
+ role: params.role,
179
+ engine: "react-v1",
180
+ dependsOn: [],
181
+ goal: `${params.goal}${protocolNote}`,
182
+ upstreamContext: {},
183
+ deliverableSpec: "Working implementation matching the goal, with files_touched listing every file written.",
184
+ acceptanceCriteria: [
185
+ {
186
+ id: "AC1",
187
+ type: "schema",
188
+ description: "Every file referenced in the goal was actually written (files_touched is non-empty).",
189
+ },
190
+ {
191
+ id: "AC2",
192
+ type: "command",
193
+ description: "The project's own build/typecheck command exits 0.",
194
+ },
195
+ ],
196
+ status: "ready",
197
+ healing: {
198
+ attempts: 0,
199
+ maxAttempts: 2,
200
+ log: [],
201
+ },
202
+ };
203
+ }
204
+ }
@@ -0,0 +1,23 @@
1
+ import type { Role } from "../types.js";
2
+ import type { WksProtocolKey } from "../protocol/wks-protocol-manager.js";
3
+ /**
4
+ * Maps user-visible protocol names (e.g. 'coder', 'secops', 'ui ux') to
5
+ * canonical Role values already defined in the Role union type.
6
+ *
7
+ * This avoids adding new Role values (which would require new directives
8
+ * and break the closed Role union) while still giving users the protocol
9
+ * sections they expect from wks_protocol.md.
10
+ */
11
+ export declare const ALIAS_MAP: Record<string, Role>;
12
+ /**
13
+ * Returns the canonical Role for a given protocol name. Falls back to the
14
+ * protocol name itself if it's a recognised WksProtocolKey but not a Role
15
+ * (i.e. 'master-orchestrator'). Returns 'conversation' as ultimate fallback.
16
+ */
17
+ export declare function resolveRole(protocolName: string): Role;
18
+ /**
19
+ * Returns the WksProtocolKey to look up in the parsed wks_protocol.md.
20
+ * Returns undefined if no mapping exists — in which case the SubAgent runs
21
+ * without a protocol section override.
22
+ */
23
+ export declare function resolveSectionKey(protocolName: string): WksProtocolKey | undefined;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Maps user-visible protocol names (e.g. 'coder', 'secops', 'ui ux') to
3
+ * canonical Role values already defined in the Role union type.
4
+ *
5
+ * This avoids adding new Role values (which would require new directives
6
+ * and break the closed Role union) while still giving users the protocol
7
+ * sections they expect from wks_protocol.md.
8
+ */
9
+ export const ALIAS_MAP = {
10
+ coder: "programmer",
11
+ secops: "defect-manager",
12
+ "ui ux": "ui-api-tester",
13
+ "ui/ux": "ui-api-tester",
14
+ };
15
+ /**
16
+ * Returns the canonical Role for a given protocol name. Falls back to the
17
+ * protocol name itself if it's a recognised WksProtocolKey but not a Role
18
+ * (i.e. 'master-orchestrator'). Returns 'conversation' as ultimate fallback.
19
+ */
20
+ export function resolveRole(protocolName) {
21
+ const normalised = protocolName.toLowerCase().trim();
22
+ // 1. Explicit alias?
23
+ if (ALIAS_MAP[normalised])
24
+ return ALIAS_MAP[normalised];
25
+ // 2. Already a known Role?
26
+ const KNOWN_ROLES = new Set([
27
+ "requirements-analyst",
28
+ "architect",
29
+ "programmer",
30
+ "refactorer",
31
+ "tester",
32
+ "ui-api-tester",
33
+ "technical-writer",
34
+ "devops",
35
+ "conversation",
36
+ "business-analyst",
37
+ "defect-manager",
38
+ ]);
39
+ if (KNOWN_ROLES.has(normalised))
40
+ return normalised;
41
+ // 3. Ultimate fallback.
42
+ return "conversation";
43
+ }
44
+ /**
45
+ * Returns the WksProtocolKey to look up in the parsed wks_protocol.md.
46
+ * Returns undefined if no mapping exists — in which case the SubAgent runs
47
+ * without a protocol section override.
48
+ */
49
+ export function resolveSectionKey(protocolName) {
50
+ const normalised = protocolName.toLowerCase().trim();
51
+ // 1. Explicit alias mapping
52
+ if (ALIAS_MAP[normalised])
53
+ return ALIAS_MAP[normalised];
54
+ // 2. Direct Role match
55
+ const role = resolveRole(normalised);
56
+ if (role !== "conversation")
57
+ return role;
58
+ // 3. If the original string matches a known wks protocol key pattern but isn't a Role,
59
+ // return it directly (e.g. 'master-orchestrator').
60
+ if (normalised === "master-orchestrator")
61
+ return "master-orchestrator";
62
+ // 4. Not a recognised key — no override
63
+ return undefined;
64
+ }
@@ -0,0 +1,31 @@
1
+ import { type LicenseStore } from "./store.js";
2
+ import { type LicenseApi } from "./http-client.js";
3
+ import { type LicenseManager } from "./manager.js";
4
+ import { type TrustAnchor } from "./trust-anchor.js";
5
+ import { type LicenseGateResult } from "./types.js";
6
+ /** Exit code for "this command needs an active license". */
7
+ export declare const LICENSE_REQUIRED_EXIT_CODE = 4;
8
+ export declare function isLicensedFeature(commandPath: string): boolean;
9
+ /**
10
+ * The hint a denial prints. Per-tree, so a v1 user is told v1's own binary
11
+ * name rather than another tree's command.
12
+ */
13
+ export declare const ACTIVATE_COMMAND = "xcoder license activate";
14
+ /**
15
+ * Decide whether a licensed feature may run.
16
+ *
17
+ * Never throws, never touches the network. Returns the verified claims on
18
+ * success so the caller does not have to re-read the store.
19
+ */
20
+ export declare function requireLicense(opts?: {
21
+ now?: () => number;
22
+ store?: LicenseStore;
23
+ anchor?: TrustAnchor;
24
+ }): LicenseGateResult;
25
+ /**
26
+ * Opportunity-refresh after a successful gate. Best-effort by contract: any
27
+ * failure is swallowed so an offline machine still runs the command.
28
+ */
29
+ export declare function maybeRefreshLicense(mgr: LicenseManager, now?: () => number): Promise<void>;
30
+ /** Build a manager with production wiring (used by licensed call sites). */
31
+ export declare function createDefaultLicenseManager(api?: LicenseApi, store?: LicenseStore): LicenseManager;