@neural-node-labs/xcoder-dna 0.0.0-stage → 1.5.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 (406) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +132 -2
  3. package/dist/agents/agent-catalog.d.ts +87 -0
  4. package/dist/agents/agent-catalog.js +159 -0
  5. package/dist/agents/agent-registry.d.ts +76 -0
  6. package/dist/agents/agent-registry.js +189 -0
  7. package/dist/agents/ai-chat-debate.d.ts +36 -0
  8. package/dist/agents/ai-chat-debate.js +300 -0
  9. package/dist/agents/ai-chat-report-writer.d.ts +7 -0
  10. package/dist/agents/ai-chat-report-writer.js +100 -0
  11. package/dist/agents/duplicate-detector.d.ts +41 -0
  12. package/dist/agents/duplicate-detector.js +65 -0
  13. package/dist/agents/genesis-agent.d.ts +61 -0
  14. package/dist/agents/genesis-agent.js +340 -0
  15. package/dist/agents/samurai-agent.d.ts +53 -0
  16. package/dist/agents/samurai-agent.js +279 -0
  17. package/dist/agents/sub-agent.d.ts +56 -0
  18. package/dist/agents/sub-agent.js +353 -0
  19. package/dist/backlog/backlog-requirement-validator.d.ts +10 -0
  20. package/dist/backlog/backlog-requirement-validator.js +60 -0
  21. package/dist/backlog/backlog-store.d.ts +29 -0
  22. package/dist/backlog/backlog-store.js +148 -0
  23. package/dist/backlog/po-agent.d.ts +16 -0
  24. package/dist/backlog/po-agent.js +121 -0
  25. package/dist/backlog/types.d.ts +25 -0
  26. package/dist/backlog/types.js +4 -0
  27. package/dist/bench/run.d.ts +11 -0
  28. package/dist/bench/run.js +185 -0
  29. package/dist/bench/types.d.ts +50 -0
  30. package/dist/bench/types.js +1 -0
  31. package/dist/cli/delegate.d.ts +90 -0
  32. package/dist/cli/delegate.js +220 -0
  33. package/dist/cli/swarm.d.ts +10 -0
  34. package/dist/cli/swarm.js +100 -0
  35. package/dist/cli/task.d.ts +14 -0
  36. package/dist/cli/task.js +121 -0
  37. package/dist/cli/wbc-arg.d.ts +6 -0
  38. package/dist/cli/wbc-arg.js +40 -0
  39. package/dist/cli/wbc.d.ts +45 -0
  40. package/dist/cli/wbc.js +98 -0
  41. package/dist/commands/license.d.ts +9 -0
  42. package/dist/commands/license.js +140 -0
  43. package/dist/commands/release.d.ts +44 -0
  44. package/dist/commands/release.js +180 -0
  45. package/dist/commands/test.d.ts +50 -0
  46. package/dist/commands/test.js +385 -0
  47. package/dist/config/env-guard.d.ts +35 -0
  48. package/dist/config/env-guard.js +100 -0
  49. package/dist/config/env-snapshot.d.ts +18 -0
  50. package/dist/config/env-snapshot.js +30 -0
  51. package/dist/config/loadConfig.d.ts +82 -0
  52. package/dist/config/loadConfig.js +249 -0
  53. package/dist/config/secure-mode.d.ts +29 -0
  54. package/dist/config/secure-mode.js +63 -0
  55. package/dist/config/user-config.d.ts +39 -0
  56. package/dist/config/user-config.js +202 -0
  57. package/dist/engine/reasoning-engine.d.ts +21 -0
  58. package/dist/engine/reasoning-engine.js +59 -0
  59. package/dist/events/bus.d.ts +22 -0
  60. package/dist/events/bus.js +18 -0
  61. package/dist/index.d.ts +87 -0
  62. package/dist/index.js +88 -0
  63. package/dist/indexing/ignoreRules.d.ts +1 -0
  64. package/dist/indexing/ignoreRules.js +53 -0
  65. package/dist/instance-swarm/instance-swarm-orchestrator.d.ts +57 -0
  66. package/dist/instance-swarm/instance-swarm-orchestrator.js +204 -0
  67. package/dist/instance-swarm/protocol-name-resolver.d.ts +23 -0
  68. package/dist/instance-swarm/protocol-name-resolver.js +64 -0
  69. package/dist/license/gate.d.ts +31 -0
  70. package/dist/license/gate.js +188 -0
  71. package/dist/license/http-client.d.ts +43 -0
  72. package/dist/license/http-client.js +195 -0
  73. package/dist/license/manager.d.ts +39 -0
  74. package/dist/license/manager.js +175 -0
  75. package/dist/license/receipt.d.ts +27 -0
  76. package/dist/license/receipt.js +108 -0
  77. package/dist/license/state-codec.d.ts +72 -0
  78. package/dist/license/state-codec.js +218 -0
  79. package/dist/license/state-paths.d.ts +17 -0
  80. package/dist/license/state-paths.js +64 -0
  81. package/dist/license/store.d.ts +44 -0
  82. package/dist/license/store.js +223 -0
  83. package/dist/license/trust-anchor.d.ts +24 -0
  84. package/dist/license/trust-anchor.js +74 -0
  85. package/dist/license/types.d.ts +34 -0
  86. package/dist/license/types.js +19 -0
  87. package/dist/llm/budget.d.ts +23 -0
  88. package/dist/llm/budget.js +58 -0
  89. package/dist/llm/client.d.ts +53 -0
  90. package/dist/llm/client.js +122 -0
  91. package/dist/llm/factory.d.ts +14 -0
  92. package/dist/llm/factory.js +32 -0
  93. package/dist/orchestrator/defect-logger.d.ts +31 -0
  94. package/dist/orchestrator/defect-logger.js +101 -0
  95. package/dist/orchestrator/defect-manager.d.ts +118 -0
  96. package/dist/orchestrator/defect-manager.js +338 -0
  97. package/dist/orchestrator/defect-migration.d.ts +14 -0
  98. package/dist/orchestrator/defect-migration.js +174 -0
  99. package/dist/orchestrator/defect-store.d.ts +48 -0
  100. package/dist/orchestrator/defect-store.js +76 -0
  101. package/dist/orchestrator/healing.d.ts +14 -0
  102. package/dist/orchestrator/healing.js +11 -0
  103. package/dist/orchestrator/interactive-steering.d.ts +64 -0
  104. package/dist/orchestrator/interactive-steering.js +107 -0
  105. package/dist/orchestrator/interrupt-handler.d.ts +30 -0
  106. package/dist/orchestrator/interrupt-handler.js +70 -0
  107. package/dist/orchestrator/lesson-manager.d.ts +25 -0
  108. package/dist/orchestrator/lesson-manager.js +122 -0
  109. package/dist/orchestrator/progress-summary.d.ts +15 -0
  110. package/dist/orchestrator/progress-summary.js +106 -0
  111. package/dist/orchestrator/reasoning-score.d.ts +49 -0
  112. package/dist/orchestrator/reasoning-score.js +117 -0
  113. package/dist/orchestrator/swarm.d.ts +36 -0
  114. package/dist/orchestrator/swarm.js +77 -0
  115. package/dist/orchestrator/task-factory.d.ts +15 -0
  116. package/dist/orchestrator/task-factory.js +176 -0
  117. package/dist/orchestrator/validation-gate.d.ts +23 -0
  118. package/dist/orchestrator/validation-gate.js +155 -0
  119. package/dist/protocol/react-contract.d.ts +136 -0
  120. package/dist/protocol/react-contract.js +698 -0
  121. package/dist/protocol/wks-protocol-manager.d.ts +22 -0
  122. package/dist/protocol/wks-protocol-manager.js +72 -0
  123. package/dist/sdlc-runtime/conversation-runner.d.ts +8 -0
  124. package/dist/sdlc-runtime/conversation-runner.js +64 -0
  125. package/dist/sdlc-runtime/dag-utils.d.ts +15 -0
  126. package/dist/sdlc-runtime/dag-utils.js +67 -0
  127. package/dist/sdlc-runtime/defect-integration.d.ts +7 -0
  128. package/dist/sdlc-runtime/defect-integration.js +99 -0
  129. package/dist/sdlc-runtime/execution-loop.d.ts +38 -0
  130. package/dist/sdlc-runtime/execution-loop.js +274 -0
  131. package/dist/sdlc-runtime/lesson-recorder.d.ts +9 -0
  132. package/dist/sdlc-runtime/lesson-recorder.js +27 -0
  133. package/dist/sdlc-runtime/plan-initializer.d.ts +47 -0
  134. package/dist/sdlc-runtime/plan-initializer.js +135 -0
  135. package/dist/sdlc-runtime/progress-persister.d.ts +10 -0
  136. package/dist/sdlc-runtime/progress-persister.js +34 -0
  137. package/dist/sdlc-runtime/protocol-loader.d.ts +10 -0
  138. package/dist/sdlc-runtime/protocol-loader.js +21 -0
  139. package/dist/sdlc-runtime/reporting.d.ts +24 -0
  140. package/dist/sdlc-runtime/reporting.js +68 -0
  141. package/dist/sdlc-runtime/run-task.d.ts +81 -0
  142. package/dist/sdlc-runtime/run-task.js +210 -0
  143. package/dist/sdlc-runtime/sdlc-orchestrator.d.ts +59 -0
  144. package/dist/sdlc-runtime/sdlc-orchestrator.js +170 -0
  145. package/dist/sdlc-runtime/sdlc-skill.d.ts +44 -0
  146. package/dist/sdlc-runtime/sdlc-skill.js +148 -0
  147. package/dist/sdlc-runtime/steering-handler.d.ts +14 -0
  148. package/dist/sdlc-runtime/steering-handler.js +51 -0
  149. package/dist/sdlc-runtime/trace-recorder.d.ts +10 -0
  150. package/dist/sdlc-runtime/trace-recorder.js +7 -0
  151. package/dist/security/index.d.ts +16 -0
  152. package/dist/security/index.js +12 -0
  153. package/dist/security/input-screen.d.ts +30 -0
  154. package/dist/security/input-screen.js +75 -0
  155. package/dist/security/tool-call-guard.d.ts +16 -0
  156. package/dist/security/tool-call-guard.js +174 -0
  157. package/dist/security/untrusted-content.d.ts +34 -0
  158. package/dist/security/untrusted-content.js +63 -0
  159. package/dist/skills/advanced-dfir/SKILL.md +85 -0
  160. package/dist/skills/advanced-pentest-lab/SKILL.md +88 -0
  161. package/dist/skills/analyst/SKILL.md +55 -0
  162. package/dist/skills/architect/SKILL.md +54 -0
  163. package/dist/skills/aws/SKILL.md +92 -0
  164. package/dist/skills/azure/SKILL.md +90 -0
  165. package/dist/skills/bylaw-context.d.ts +45 -0
  166. package/dist/skills/bylaw-context.js +61 -0
  167. package/dist/skills/bylaw-review.d.ts +20 -0
  168. package/dist/skills/bylaw-review.js +101 -0
  169. package/dist/skills/conversation/SKILL.md +29 -0
  170. package/dist/skills/design-patterns/SKILL.md +190 -0
  171. package/dist/skills/devops/SKILL.md +55 -0
  172. package/dist/skills/directives.d.ts +20 -0
  173. package/dist/skills/directives.js +313 -0
  174. package/dist/skills/docker/SKILL.md +76 -0
  175. package/dist/skills/docker-expert/SKILL.md +56 -0
  176. package/dist/skills/enterprise-systems-analyst/SKILL.md +83 -0
  177. package/dist/skills/enterprise-systems-analyst/references/crm.md +41 -0
  178. package/dist/skills/enterprise-systems-analyst/references/erp.md +40 -0
  179. package/dist/skills/enterprise-systems-analyst/references/financial-systems.md +35 -0
  180. package/dist/skills/enterprise-systems-analyst/references/hcm.md +38 -0
  181. package/dist/skills/enterprise-systems-analyst/references/mrp.md +37 -0
  182. package/dist/skills/enterprise-systems-analyst/references/scm.md +32 -0
  183. package/dist/skills/ethical-hacking-methodology/SKILL.md +119 -0
  184. package/dist/skills/externalSkillLoader.d.ts +25 -0
  185. package/dist/skills/externalSkillLoader.js +65 -0
  186. package/dist/skills/externalSkillRegistry.d.ts +33 -0
  187. package/dist/skills/externalSkillRegistry.js +94 -0
  188. package/dist/skills/filesystem-management/SKILL.md +61 -0
  189. package/dist/skills/first-run-seed.d.ts +26 -0
  190. package/dist/skills/first-run-seed.js +75 -0
  191. package/dist/skills/git-vcs/SKILL.md +84 -0
  192. package/dist/skills/kafka/SKILL.md +89 -0
  193. package/dist/skills/kubernetes/SKILL.md +93 -0
  194. package/dist/skills/kubernetes-expert/SKILL.md +54 -0
  195. package/dist/skills/openshift/SKILL.md +93 -0
  196. package/dist/skills/pentester/SKILL.md +59 -0
  197. package/dist/skills/performance-tester/SKILL.md +57 -0
  198. package/dist/skills/playwright-ui-tester/SKILL.md +67 -0
  199. package/dist/skills/programmer/SKILL.md +58 -0
  200. package/dist/skills/project-scaffolding/SKILL.md +133 -0
  201. package/dist/skills/qa-engineer/SKILL.md +91 -0
  202. package/dist/skills/rca/SKILL.md +58 -0
  203. package/dist/skills/redhat/SKILL.md +92 -0
  204. package/dist/skills/rosa/SKILL.md +80 -0
  205. package/dist/skills/scrum-framework/SKILL.md +74 -0
  206. package/dist/skills/scrum-framework/references/artifacts_and_quality.md +79 -0
  207. package/dist/skills/scrum-framework/references/roles_and_events.md +105 -0
  208. package/dist/skills/scrum-master-agent/SKILL.md +74 -0
  209. package/dist/skills/scrum-master-agent/references/behaviors.md +56 -0
  210. package/dist/skills/sdlc-skill.d.ts +1 -0
  211. package/dist/skills/sdlc-skill.js +4 -0
  212. package/dist/skills/secops/SKILL.md +52 -0
  213. package/dist/skills/secure-architect.bylaws.d.ts +68 -0
  214. package/dist/skills/secure-architect.bylaws.js +525 -0
  215. package/dist/skills/seed-skills.d.ts +48 -0
  216. package/dist/skills/seed-skills.js +213 -0
  217. package/dist/skills/skill-authoring/SKILL.md +123 -0
  218. package/dist/skills/skill-header.d.ts +51 -0
  219. package/dist/skills/skill-header.js +163 -0
  220. package/dist/skills/skill-path-guard.d.ts +41 -0
  221. package/dist/skills/skill-path-guard.js +95 -0
  222. package/dist/skills/skillRouter.d.ts +51 -0
  223. package/dist/skills/skillRouter.js +90 -0
  224. package/dist/skills/skills-root.d.ts +64 -0
  225. package/dist/skills/skills-root.js +168 -0
  226. package/dist/skills/software-architect/SKILL.md +77 -0
  227. package/dist/skills/software-engineer/SKILL.md +74 -0
  228. package/dist/skills/solid-principles/SKILL.md +94 -0
  229. package/dist/skills/task-planning/SKILL.md +115 -0
  230. package/dist/skills/tester/SKILL.md +54 -0
  231. package/dist/skills/ubuntu/SKILL.md +87 -0
  232. package/dist/skills/ui-ux-design/SKILL.md +114 -0
  233. package/dist/skills/workspace-context/SKILL.md +103 -0
  234. package/dist/sprint/controller.d.ts +37 -0
  235. package/dist/sprint/controller.js +220 -0
  236. package/dist/sprint/dag-builder.d.ts +14 -0
  237. package/dist/sprint/dag-builder.js +105 -0
  238. package/dist/sprint/reporter.d.ts +11 -0
  239. package/dist/sprint/reporter.js +97 -0
  240. package/dist/sprint/state-store.d.ts +10 -0
  241. package/dist/sprint/state-store.js +71 -0
  242. package/dist/sprint/types.d.ts +24 -0
  243. package/dist/sprint/types.js +4 -0
  244. package/dist/store/file-version-store.d.ts +24 -0
  245. package/dist/store/file-version-store.js +73 -0
  246. package/dist/store/task-store.d.ts +90 -0
  247. package/dist/store/task-store.js +166 -0
  248. package/dist/task-ingest/architect-detailer.d.ts +43 -0
  249. package/dist/task-ingest/architect-detailer.js +141 -0
  250. package/dist/task-ingest/detail-schema.d.ts +9 -0
  251. package/dist/task-ingest/detail-schema.js +195 -0
  252. package/dist/task-ingest/detailed-run.d.ts +36 -0
  253. package/dist/task-ingest/detailed-run.js +108 -0
  254. package/dist/task-ingest/extract-id.d.ts +9 -0
  255. package/dist/task-ingest/extract-id.js +24 -0
  256. package/dist/task-ingest/index.d.ts +23 -0
  257. package/dist/task-ingest/index.js +14 -0
  258. package/dist/task-ingest/ingest.d.ts +45 -0
  259. package/dist/task-ingest/ingest.js +163 -0
  260. package/dist/task-ingest/list-ingested.d.ts +13 -0
  261. package/dist/task-ingest/list-ingested.js +30 -0
  262. package/dist/task-ingest/pending-filter.d.ts +30 -0
  263. package/dist/task-ingest/pending-filter.js +59 -0
  264. package/dist/task-ingest/scanner.d.ts +56 -0
  265. package/dist/task-ingest/scanner.js +216 -0
  266. package/dist/task-ingest/source-reader.d.ts +25 -0
  267. package/dist/task-ingest/source-reader.js +93 -0
  268. package/dist/task-ingest/spec-builder.d.ts +34 -0
  269. package/dist/task-ingest/spec-builder.js +89 -0
  270. package/dist/task-ingest/wbs-extract.d.ts +50 -0
  271. package/dist/task-ingest/wbs-extract.js +226 -0
  272. package/dist/task-ingest/wbs-parser.d.ts +36 -0
  273. package/dist/task-ingest/wbs-parser.js +170 -0
  274. package/dist/tools/apiTestTool.d.ts +37 -0
  275. package/dist/tools/apiTestTool.js +128 -0
  276. package/dist/tools/ast-tools.d.ts +183 -0
  277. package/dist/tools/ast-tools.js +853 -0
  278. package/dist/tools/browse-tool.d.ts +105 -0
  279. package/dist/tools/browse-tool.js +394 -0
  280. package/dist/tools/credential.d.ts +17 -0
  281. package/dist/tools/credential.js +32 -0
  282. package/dist/tools/dependency-graph.d.ts +23 -0
  283. package/dist/tools/dependency-graph.js +164 -0
  284. package/dist/tools/edit-tool.d.ts +34 -0
  285. package/dist/tools/edit-tool.js +95 -0
  286. package/dist/tools/file-header-manager.d.ts +27 -0
  287. package/dist/tools/file-header-manager.js +153 -0
  288. package/dist/tools/fs-tools.d.ts +154 -0
  289. package/dist/tools/fs-tools.js +337 -0
  290. package/dist/tools/git-tools.d.ts +79 -0
  291. package/dist/tools/git-tools.js +348 -0
  292. package/dist/tools/github-tool.d.ts +48 -0
  293. package/dist/tools/github-tool.js +147 -0
  294. package/dist/tools/globTool.d.ts +20 -0
  295. package/dist/tools/globTool.js +34 -0
  296. package/dist/tools/grepTool.d.ts +19 -0
  297. package/dist/tools/grepTool.js +44 -0
  298. package/dist/tools/index-freshness.d.ts +58 -0
  299. package/dist/tools/index-freshness.js +196 -0
  300. package/dist/tools/index-glob.d.ts +48 -0
  301. package/dist/tools/index-glob.js +175 -0
  302. package/dist/tools/load-skill-tool.d.ts +15 -0
  303. package/dist/tools/load-skill-tool.js +114 -0
  304. package/dist/tools/patch-tools.d.ts +58 -0
  305. package/dist/tools/patch-tools.js +153 -0
  306. package/dist/tools/playwright-tool.d.ts +66 -0
  307. package/dist/tools/playwright-tool.js +121 -0
  308. package/dist/tools/project-detect.d.ts +20 -0
  309. package/dist/tools/project-detect.js +87 -0
  310. package/dist/tools/prompt-guidance.d.ts +22 -0
  311. package/dist/tools/prompt-guidance.js +23 -0
  312. package/dist/tools/schedule-audit.d.ts +50 -0
  313. package/dist/tools/schedule-audit.js +124 -0
  314. package/dist/tools/schedule-validation.d.ts +67 -0
  315. package/dist/tools/schedule-validation.js +210 -0
  316. package/dist/tools/scheduleTool.d.ts +62 -0
  317. package/dist/tools/scheduleTool.js +313 -0
  318. package/dist/tools/search-tools.d.ts +27 -0
  319. package/dist/tools/search-tools.js +78 -0
  320. package/dist/tools/sed-tool.d.ts +66 -0
  321. package/dist/tools/sed-tool.js +402 -0
  322. package/dist/tools/shell-result.d.ts +11 -0
  323. package/dist/tools/shell-result.js +1 -0
  324. package/dist/tools/shell-tool.d.ts +45 -0
  325. package/dist/tools/shell-tool.js +141 -0
  326. package/dist/tools/siteCrawlerTool.d.ts +32 -0
  327. package/dist/tools/siteCrawlerTool.js +205 -0
  328. package/dist/tools/tool-registry.d.ts +67 -0
  329. package/dist/tools/tool-registry.js +606 -0
  330. package/dist/tools/validate-tool.d.ts +23 -0
  331. package/dist/tools/validate-tool.js +201 -0
  332. package/dist/tools/workspace-index.d.ts +46 -0
  333. package/dist/tools/workspace-index.js +173 -0
  334. package/dist/types.d.ts +222 -0
  335. package/dist/types.js +7 -0
  336. package/dist/updater/index.d.ts +14 -0
  337. package/dist/updater/index.js +120 -0
  338. package/dist/util/banner.d.ts +25 -0
  339. package/dist/util/banner.js +140 -0
  340. package/dist/util/command-suggester.d.ts +6 -0
  341. package/dist/util/command-suggester.js +25 -0
  342. package/dist/util/confirm-interrupt.d.ts +10 -0
  343. package/dist/util/confirm-interrupt.js +31 -0
  344. package/dist/util/continue-trigger.d.ts +11 -0
  345. package/dist/util/continue-trigger.js +20 -0
  346. package/dist/util/env-info.d.ts +18 -0
  347. package/dist/util/env-info.js +37 -0
  348. package/dist/util/file-access-log.d.ts +35 -0
  349. package/dist/util/file-access-log.js +140 -0
  350. package/dist/util/footer-manager.d.ts +124 -0
  351. package/dist/util/footer-manager.js +195 -0
  352. package/dist/util/footer-renderer.d.ts +67 -0
  353. package/dist/util/footer-renderer.js +319 -0
  354. package/dist/util/footer-state.d.ts +34 -0
  355. package/dist/util/footer-state.js +18 -0
  356. package/dist/util/footer-text.d.ts +51 -0
  357. package/dist/util/footer-text.js +74 -0
  358. package/dist/util/ids.d.ts +1 -0
  359. package/dist/util/ids.js +4 -0
  360. package/dist/util/levenshtein.d.ts +6 -0
  361. package/dist/util/levenshtein.js +34 -0
  362. package/dist/util/logger.d.ts +10 -0
  363. package/dist/util/logger.js +41 -0
  364. package/dist/util/logs.d.ts +80 -0
  365. package/dist/util/logs.js +135 -0
  366. package/dist/util/output-handler.d.ts +89 -0
  367. package/dist/util/output-handler.js +193 -0
  368. package/dist/util/output-interceptor.d.ts +18 -0
  369. package/dist/util/output-interceptor.js +49 -0
  370. package/dist/util/output-paths.d.ts +43 -0
  371. package/dist/util/output-paths.js +121 -0
  372. package/dist/util/package-json.d.ts +6 -0
  373. package/dist/util/package-json.js +36 -0
  374. package/dist/util/process-kill.d.ts +27 -0
  375. package/dist/util/process-kill.js +148 -0
  376. package/dist/util/protocol-error-logger.d.ts +33 -0
  377. package/dist/util/protocol-error-logger.js +73 -0
  378. package/dist/util/redact.d.ts +25 -0
  379. package/dist/util/redact.js +119 -0
  380. package/dist/util/scroll-region-guard.d.ts +33 -0
  381. package/dist/util/scroll-region-guard.js +63 -0
  382. package/dist/util/spinner.d.ts +15 -0
  383. package/dist/util/spinner.js +49 -0
  384. package/dist/util/terminal-output.d.ts +34 -0
  385. package/dist/util/terminal-output.js +1 -0
  386. package/dist/util/terminal-silent.d.ts +6 -0
  387. package/dist/util/terminal-silent.js +20 -0
  388. package/dist/util/terminal.d.ts +56 -0
  389. package/dist/util/terminal.js +124 -0
  390. package/dist/util/text-sanitize.d.ts +8 -0
  391. package/dist/util/text-sanitize.js +45 -0
  392. package/dist/util/thinking-spinner.d.ts +27 -0
  393. package/dist/util/thinking-spinner.js +189 -0
  394. package/dist/util/tool-error-logger.d.ts +33 -0
  395. package/dist/util/tool-error-logger.js +77 -0
  396. package/dist/util/tty.d.ts +13 -0
  397. package/dist/util/tty.js +16 -0
  398. package/dist/util/xcoder-paths.d.ts +56 -0
  399. package/dist/util/xcoder-paths.js +63 -0
  400. package/dist/version.d.ts +2 -0
  401. package/dist/version.js +5 -0
  402. package/dist/worker-agent/to-subtask-node.d.ts +35 -0
  403. package/dist/worker-agent/to-subtask-node.js +41 -0
  404. package/dist/worker-agent/worker-orchestrator.d.ts +104 -0
  405. package/dist/worker-agent/worker-orchestrator.js +201 -0
  406. package/package.json +43 -3
@@ -0,0 +1,220 @@
1
+ // xcoder:version 6 | xcoder:task task-691585 | xcoder:updated 2026-11-05T05:46:07.113Z | xcoder:subtask code-st-b5251b
2
+ // Cross-CLI delegation seam.
3
+ //
4
+ // `xcoder jarvis <args...>` runs the real `jarvis` binary in a child process
5
+ // and forwards every argument verbatim. This module owns that seam and nothing
6
+ // else: it does not know what jarvis does, and it never interprets a child flag.
7
+ //
8
+ // Why a subprocess and not an import: boundary rule 1 (`scripts/check-boundaries.mjs`)
9
+ // forbids one agent importing another, and the `xcoder` bin lives in
10
+ // `@xcoder/sdlc-agent`. The only legal shared home for this code is this library.
11
+ //
12
+ // Why argv is pre-extracted instead of parsed by commander: commander eagerly
13
+ // consumes root options (`--config`, `--workspace`) it sees after a subcommand,
14
+ // which would silently swallow a child flag. The workspace already solves this
15
+ // class of problem the same way for `--config` and `--wbc` (see `wbc-arg.ts`),
16
+ // so delegation follows that precedent rather than adding a new parsing mode.
17
+ import { spawn } from "node:child_process";
18
+ import { existsSync } from "node:fs";
19
+ import path from "node:path";
20
+ /** The closed allowlist of agent CLIs that may be reached through `xcoder`. */
21
+ export const DELEGABLE_TARGETS = ["jarvis", "litebro", "bugfinder"];
22
+ /** Shell convention for "command not found", identical on every platform. */
23
+ export const EXIT_ENOENT = 127;
24
+ /**
25
+ * Interrupted. POSIX would be 128+SIGINT (130); Windows has no signal-number
26
+ * convention, so one deterministic, testable constant is used everywhere.
27
+ */
28
+ export const EXIT_INTERRUPTED = 130;
29
+ /** The jarvis spec, shared by the `xcoder` CLI and the aggregator's DISPATCH. */
30
+ export const JARVIS_SPEC = {
31
+ target: "jarvis",
32
+ bin: "jarvis",
33
+ fallbackModule: path.join("packages", "jarvis-agent", "dist", "program.js"),
34
+ summary: "Jarvis — ReAct agent with scoped memory and an enforced tool allowlist",
35
+ };
36
+ const SPECS = {
37
+ jarvis: JARVIS_SPEC,
38
+ litebro: {
39
+ target: "litebro",
40
+ bin: "litebro",
41
+ fallbackModule: path.join("packages", "litebro", "dist", "cli.js"),
42
+ summary: "Litebro — tool-less planner/broker",
43
+ },
44
+ bugfinder: {
45
+ target: "bugfinder",
46
+ bin: "bugfinder",
47
+ fallbackModule: path.join("packages", "qa-agent", "dist", "qa-cli.js"),
48
+ summary: "Bugfinder — the QA agent",
49
+ },
50
+ };
51
+ export function isDelegableTarget(name) {
52
+ return DELEGABLE_TARGETS.includes(name);
53
+ }
54
+ /** The spec for an allowlisted target, or `undefined` for anything else. */
55
+ export function delegateSpec(target) {
56
+ return isDelegableTarget(target) ? SPECS[target] : undefined;
57
+ }
58
+ /**
59
+ * Resolve what to execute.
60
+ *
61
+ * The workspace build is tried first so a developer running from a checkout gets
62
+ * the code they just built; PATH is the declared fallback once published. The
63
+ * choice is returned so callers can log it (Spoofing control, design T4).
64
+ */
65
+ export function resolveDelegateCommand(spec, cwd) {
66
+ const local = path.resolve(cwd, spec.fallbackModule);
67
+ if (existsSync(local))
68
+ return { command: process.execPath, argv: [local] };
69
+ return { command: spec.bin, argv: [] };
70
+ }
71
+ function validTargetsMessage() {
72
+ return `valid targets: ${DELEGABLE_TARGETS.join(", ")}`;
73
+ }
74
+ /**
75
+ * Run the child with `argv` verbatim and return the code the parent must exit with.
76
+ *
77
+ * Never builds a command string, never parses, normalises, reorders or drops an
78
+ * argument, and never throws for an expected condition (spawn failure → 1).
79
+ */
80
+ export async function runDelegated(spec, argv, deps = {}) {
81
+ const stderr = deps.stderr ?? process.stderr;
82
+ if (!isDelegableTarget(spec.target)) {
83
+ stderr.write(`xcoder: '${spec.target}' is not a delegable target — ${validTargetsMessage()}\n`);
84
+ return 1;
85
+ }
86
+ const cwd = deps.cwd ?? process.cwd();
87
+ const resolve = deps.resolveBin ?? ((s, c) => resolveDelegateCommand(s, c));
88
+ const launch = resolve(spec, cwd);
89
+ if (launch === null) {
90
+ stderr.write(`xcoder: cannot find '${spec.bin}' — install it or build the workspace (${spec.fallbackModule}). ${validTargetsMessage()}\n`);
91
+ return EXIT_ENOENT;
92
+ }
93
+ if (deps.env?.XCODER_DELEGATE_VERBOSE ?? process.env.XCODER_DELEGATE_VERBOSE) {
94
+ // Counts and identifiers only: never the arguments themselves (no task text,
95
+ // no PII), never the environment.
96
+ stderr.write(`xcoder: delegating to ${spec.target} via ${launch.command} (${argv.length} argument${argv.length === 1 ? "" : "s"})\n`);
97
+ }
98
+ const spawnFn = deps.spawn ?? spawn;
99
+ const env = deps.env ?? process.env;
100
+ return new Promise((resolvePromise) => {
101
+ let child;
102
+ try {
103
+ child = spawnFn(launch.command, [...launch.argv, ...argv], {
104
+ cwd,
105
+ env,
106
+ stdio: "inherit",
107
+ shell: false,
108
+ });
109
+ }
110
+ catch (err) {
111
+ // Fail closed: a delegation that never started is not a success.
112
+ stderr.write(`xcoder: failed to start '${spec.bin}': ${err.message}\n`);
113
+ resolvePromise(1);
114
+ return;
115
+ }
116
+ const forward = (signal) => {
117
+ try {
118
+ child.kill(signal);
119
+ }
120
+ catch {
121
+ // The child is already gone; the exit handler owns the outcome.
122
+ }
123
+ };
124
+ const onSigint = () => forward("SIGINT");
125
+ const onSigterm = () => forward("SIGTERM");
126
+ process.on("SIGINT", onSigint);
127
+ process.on("SIGTERM", onSigterm);
128
+ const settle = (code) => {
129
+ process.off("SIGINT", onSigint);
130
+ process.off("SIGTERM", onSigterm);
131
+ resolvePromise(code);
132
+ };
133
+ child.once("error", (err) => {
134
+ if (err.code === "ENOENT") {
135
+ stderr.write(`xcoder: cannot find '${spec.bin}' — ${validTargetsMessage()}\n`);
136
+ settle(EXIT_ENOENT);
137
+ return;
138
+ }
139
+ stderr.write(`xcoder: '${spec.bin}' failed to start: ${err.message}\n`);
140
+ settle(1);
141
+ });
142
+ child.once("exit", (code, _signal) => {
143
+ if (code !== null) {
144
+ // The child's own exit code is the parent's, unchanged (0/1/2 all pass through).
145
+ settle(code);
146
+ return;
147
+ }
148
+ settle(EXIT_INTERRUPTED);
149
+ });
150
+ });
151
+ }
152
+ /**
153
+ * Register `<target> [args...]` on `parent` with pure passthrough semantics.
154
+ *
155
+ * Registering makes the target discoverable in `xcoder --help`. Argument
156
+ * handling belongs to `extractDelegatedArg`, because commander would otherwise
157
+ * consume root options that the child legitimately accepts.
158
+ */
159
+ export function registerDelegatedCommand(parent, spec) {
160
+ parent
161
+ .command(`${spec.target} [args...]`)
162
+ .description(`${spec.summary}. Every argument is forwarded verbatim.`)
163
+ .helpOption(false)
164
+ .allowUnknownOption(true)
165
+ .allowExcessArguments(true)
166
+ .action(async (_args, _opts, cmd) => {
167
+ const code = await runDelegated(spec, cmd.args);
168
+ process.exitCode = code;
169
+ });
170
+ }
171
+ /**
172
+ * Root options that take a value, so their value is never mistaken for a target.
173
+ *
174
+ * Closed on purpose: a wildcard here would let any argument become a command,
175
+ * and dropping an entry here would make `xcoder -task jarvis` run the `jarvis`
176
+ * binary instead of a task called "jarvis". Options with an *optional* value
177
+ * (`--resume`, `--debug-tools`) are listed too: their value can look exactly
178
+ * like a target, so the conservative reading is "do not delegate".
179
+ */
180
+ const ROOT_OPTIONS_WITH_VALUE = new Set([
181
+ "--config",
182
+ "-w",
183
+ "--workspace",
184
+ "--wbc",
185
+ "--wbs",
186
+ "-task",
187
+ "--task",
188
+ "--design",
189
+ "--code",
190
+ "--defect",
191
+ "--budget",
192
+ "--max-healing",
193
+ "-c",
194
+ "--concurrency",
195
+ "--model",
196
+ "--spinner",
197
+ "--resume",
198
+ "--debug-tools",
199
+ ]);
200
+ /**
201
+ * Detect a delegation from raw argv, before commander sees anything.
202
+ *
203
+ * Returns `undefined` for every ordinary invocation, so existing commands are
204
+ * parsed exactly as before. When a target is found, everything after it is
205
+ * returned untouched — the parent never validates a child flag.
206
+ */
207
+ export function extractDelegatedArg(argv) {
208
+ for (let i = 2; i < argv.length; i++) {
209
+ const token = argv[i];
210
+ if (ROOT_OPTIONS_WITH_VALUE.has(token)) {
211
+ i++; // skip this option's value
212
+ continue;
213
+ }
214
+ if (token.startsWith("-"))
215
+ continue;
216
+ const spec = delegateSpec(token);
217
+ return spec ? { spec, args: argv.slice(i + 1), index: i } : undefined;
218
+ }
219
+ return undefined;
220
+ }
@@ -0,0 +1,10 @@
1
+ import { Command } from "commander";
2
+ /**
3
+ * Register the `xcoder swarm` subcommand.
4
+ *
5
+ * Runs an instance swarm: multiple SubAgents dispatched concurrently
6
+ * against a goal, with a protocol section injected from wks_protocol.md.
7
+ * Includes a master spinner for the overall run, per-worker lifecycle
8
+ * callbacks, and a color-coded summary printed on completion.
9
+ */
10
+ export declare function registerSwarmCommand(parent: Command): void;
@@ -0,0 +1,100 @@
1
+ import path from "node:path";
2
+ import { createLlmClient } from "../llm/factory.js";
3
+ import { InstanceSwarmOrchestrator, } from "../instance-swarm/instance-swarm-orchestrator.js";
4
+ import { getOrBuildIndex } from "../tools/workspace-index.js";
5
+ import { log } from "../util/logger.js";
6
+ import { createSpinner } from "../util/spinner.js";
7
+ import { printSwarmSummary } from "../util/terminal.js";
8
+ /**
9
+ * Register the `xcoder swarm` subcommand.
10
+ *
11
+ * Runs an instance swarm: multiple SubAgents dispatched concurrently
12
+ * against a goal, with a protocol section injected from wks_protocol.md.
13
+ * Includes a master spinner for the overall run, per-worker lifecycle
14
+ * callbacks, and a color-coded summary printed on completion.
15
+ */
16
+ export function registerSwarmCommand(parent) {
17
+ parent
18
+ .command("swarm <goal...>")
19
+ .description("Run an instance swarm: multiple SubAgents dispatched concurrently against a goal, with a protocol section injected.")
20
+ .option("--protocol <name>", "protocol name (coder, tester, architect, ui-ux, secops, devops)")
21
+ .option("-m, --model <name>", "override the LLM model (default: env XCODER_MODEL or deepseek-chat)")
22
+ .option("-w, --workspace <dir>", "workspace root", process.cwd())
23
+ .option("--concurrency <n>", "number of concurrent SubAgents", "1")
24
+ .option("--max-iterations <n>", "max iterations per SubAgent", "200")
25
+ .action(async (goalParts, opts) => {
26
+ const root = path.resolve(opts.workspace);
27
+ const goal = goalParts.join(" ");
28
+ if (!opts.protocol) {
29
+ log.fail("--protocol is required (coder, tester, architect, ui-ux, secops, devops)");
30
+ process.exitCode = 1;
31
+ return;
32
+ }
33
+ await getOrBuildIndex(root);
34
+ let llm;
35
+ try {
36
+ llm = createLlmClient("instance_agent", { model: opts.model });
37
+ }
38
+ catch (e) {
39
+ log.fail(e.message);
40
+ process.exitCode = 1;
41
+ return;
42
+ }
43
+ const concurrency = parseInt(opts.concurrency, 10);
44
+ const maxIterations = parseInt(opts.maxIterations, 10);
45
+ log.dim(`swarm goal: ${goal}`);
46
+ log.dim(`protocol: ${opts.protocol} concurrency: ${concurrency}`);
47
+ // ── Master spinner: keeps the CLI alive while workers run ──
48
+ const spinner = createSpinner(`Dispatching swarm (${concurrency} worker${concurrency > 1 ? "s" : ""})…`);
49
+ const orchestrator = new InstanceSwarmOrchestrator({
50
+ workspaceRoot: root,
51
+ llm,
52
+ concurrency,
53
+ maxIterations,
54
+ hooks: {
55
+ onWorkerStart: (_wi, workerId) => {
56
+ spinner.stop(`Worker started: ${workerId}`);
57
+ // Re-start the spinner for the next wait
58
+ spinner.stop(`Dispatching swarm (${concurrency} worker${concurrency > 1 ? "s" : ""})…`);
59
+ },
60
+ onWorkerFinish: (_wi, workerId, crashed, summary) => {
61
+ const preview = summary.length > 80 ? summary.slice(0, 77) + "..." : summary;
62
+ const icon = crashed ? "✗" : "✓";
63
+ const color = crashed
64
+ ? log.fail.bind(log)
65
+ : log.ok.bind(log);
66
+ // Temporarily stop the spinner to print the worker result,
67
+ // then we'll print a final summary at the end.
68
+ spinner.stop(`${icon} ${workerId}: ${preview}`);
69
+ },
70
+ onWorkerError: (_wi, workerId, error) => {
71
+ log.fail(`Worker ${workerId} error: ${error}`);
72
+ },
73
+ },
74
+ });
75
+ let swarmResult;
76
+ try {
77
+ swarmResult = await orchestrator.run(goal, opts.protocol);
78
+ }
79
+ catch (e) {
80
+ spinner.fail(`swarm orchestration failed: ${e.message}`);
81
+ process.exitCode = 1;
82
+ return;
83
+ }
84
+ spinner.stop("Swarm complete.");
85
+ // ── Color-coded summary ──
86
+ printSwarmSummary({
87
+ instanceId: swarmResult.instanceId,
88
+ status: swarmResult.status,
89
+ errors: swarmResult.errors,
90
+ workerCount: swarmResult.results.length,
91
+ crashedCount: swarmResult.results.filter((r) => r.result.crashed).length,
92
+ totalInputTokens: swarmResult.totalTokenUsage.inputTokens,
93
+ totalOutputTokens: swarmResult.totalTokenUsage.outputTokens,
94
+ outputDir: swarmResult.outputDir,
95
+ });
96
+ if (swarmResult.status === "failed") {
97
+ process.exitCode = 1;
98
+ }
99
+ });
100
+ }
@@ -0,0 +1,14 @@
1
+ import type { Command } from "commander";
2
+ /**
3
+ * Register the `xcoder task` subcommand tree:
4
+ *
5
+ * xcoder task add --from <path> [--force]
6
+ * xcoder task list
7
+ * xcoder task scan [--dir <path>] [--dry-run] [--json] [--force]
8
+ *
9
+ * `add` and `scan` record intent and exit 0 without running anything or
10
+ * spending a single token. For both, exit 1 is a hard failure; 2 and 3 stay
11
+ * reserved for escalated and halted *runs*, which ingestion never produces.
12
+ * Skips and unchanged files are a successful scan, not a failure.
13
+ */
14
+ export declare function registerTaskCommand(parent: Command): void;
@@ -0,0 +1,121 @@
1
+ // xcoder:version 5 | xcoder:task task-cee5a1 | xcoder:updated 2026-10-23T12:58:17.067Z | xcoder:subtask code-st-f13216
2
+ // `xcoder task` — ingest scannable task runs from markdown/WBS sources.
3
+ //
4
+ // Registered the same way as `swarm` and `test`: one exported
5
+ // `register...Command(parent)` so `sdlc-cli.ts` stays a thin composition root.
6
+ // All real work lives in `src/task-ingest/` — these actions only translate
7
+ // results into exit codes and sanitized terminal output.
8
+ import path from "node:path";
9
+ import { ingestTask, listIngestedTasks, scanMarkdownTasks } from "../task-ingest/index.js";
10
+ import { sanitizeForTerminal } from "../util/text-sanitize.js";
11
+ import { log } from "../util/logger.js";
12
+ function workspaceRoot(parent) {
13
+ return path.resolve(parent.opts().workspace ?? process.cwd());
14
+ }
15
+ /**
16
+ * Register the `xcoder task` subcommand tree:
17
+ *
18
+ * xcoder task add --from <path> [--force]
19
+ * xcoder task list
20
+ * xcoder task scan [--dir <path>] [--dry-run] [--json] [--force]
21
+ *
22
+ * `add` and `scan` record intent and exit 0 without running anything or
23
+ * spending a single token. For both, exit 1 is a hard failure; 2 and 3 stay
24
+ * reserved for escalated and halted *runs*, which ingestion never produces.
25
+ * Skips and unchanged files are a successful scan, not a failure.
26
+ */
27
+ export function registerTaskCommand(parent) {
28
+ const taskCmd = parent
29
+ .command("task")
30
+ .description("Manage task runs that are scannable by status/incomplete/resume.");
31
+ taskCmd
32
+ .command("add")
33
+ .description("Create a scannable task run from a markdown/WBS source file. Records intent only — it does not run the task.")
34
+ .requiredOption("--from <path>", "workspace-relative path to the source file")
35
+ .option("--force", "replace a task that already has completed or in-flight subtasks", false)
36
+ .action(async (opts) => {
37
+ const root = workspaceRoot(parent);
38
+ const result = await ingestTask({
39
+ workspaceRoot: root,
40
+ from: opts.from,
41
+ force: opts.force === true,
42
+ });
43
+ if (!result.ok) {
44
+ log.fail(`${result.code}: ${sanitizeForTerminal(result.message, 300)}`);
45
+ process.exitCode = 1;
46
+ return;
47
+ }
48
+ const verb = result.created ? "created" : "unchanged";
49
+ const source = sanitizeForTerminal(result.sourcePath, 80);
50
+ const count = `${result.nodeCount} subtask${result.nodeCount === 1 ? "" : "s"}, first: ${result.firstStage}`;
51
+ log.ok(`${verb} ${result.taskId} from ${source} (${count})`);
52
+ log.raw(`next: ${result.nextCommand}`);
53
+ });
54
+ taskCmd
55
+ .command("list")
56
+ .description("List task runs and the source file each was ingested from.")
57
+ .action(async () => {
58
+ const root = workspaceRoot(parent);
59
+ const tasks = await listIngestedTasks(root);
60
+ if (!tasks.length) {
61
+ log.ok(`no task runs found in ${root}`);
62
+ return;
63
+ }
64
+ const header = `${"TASK ID".padEnd(16)} ${"STATUS".padEnd(12)} ${"N".padEnd(4)} ${"SOURCE".padEnd(32)} GOAL`;
65
+ log.raw(header);
66
+ log.raw("-".repeat(header.length));
67
+ for (const t of tasks) {
68
+ const source = t.sourcePath ?? "(free-text)";
69
+ log.raw(`${t.taskId.padEnd(16)} ${t.status.padEnd(12)} ${String(t.nodeCount).padEnd(4)} ${sanitizeForTerminal(source, 32).padEnd(32)} ${sanitizeForTerminal(t.goal, 48)}`);
70
+ }
71
+ });
72
+ taskCmd
73
+ .command("scan")
74
+ .description("Discover .md task files in a directory and ingest each one. Skips progress summaries and non-task files.")
75
+ .option("--dir <path>", "directory to scan (defaults to the task store directory)")
76
+ .option("--dry-run", "report what would be ingested without writing anything", false)
77
+ .option("--force", "replace tasks that already have completed or in-flight subtasks", false)
78
+ .option("--json", "machine output: the scan report only, no prose", false)
79
+ .action(async (opts) => {
80
+ const root = workspaceRoot(parent);
81
+ const result = await scanMarkdownTasks({
82
+ workspaceRoot: root,
83
+ dir: opts.dir,
84
+ dryRun: opts.dryRun === true,
85
+ force: opts.force === true,
86
+ });
87
+ if (opts.json === true) {
88
+ log.raw(JSON.stringify(result, null, 2));
89
+ }
90
+ else {
91
+ const mode = opts.dryRun === true ? " (dry run)" : "";
92
+ log.raw(`scanned ${sanitizeForTerminal(result.dir, 120)}${mode} — ${result.scanned} markdown file(s)`);
93
+ for (const o of result.created) {
94
+ log.ok(`would create/created ${o.taskId ?? "?"} from ${sanitizeForTerminal(o.sourcePath, 100)}`);
95
+ }
96
+ for (const o of result.unchanged) {
97
+ log.dim(`unchanged ${o.taskId ?? "?"} from ${sanitizeForTerminal(o.sourcePath, 100)}`);
98
+ }
99
+ for (const o of result.skipped) {
100
+ log.dim(`skipped ${sanitizeForTerminal(o.sourcePath, 100)} (${o.reason ?? "skipped"})`);
101
+ }
102
+ for (const o of result.failed) {
103
+ log.fail(`failed ${sanitizeForTerminal(o.sourcePath, 100)} ${o.code ?? "error"}: ${sanitizeForTerminal(o.message ?? "", 200)}`);
104
+ }
105
+ if (result.dirError) {
106
+ log.fail(`${result.dirError.code}: ${sanitizeForTerminal(result.dirError.message, 300)}`);
107
+ }
108
+ }
109
+ // Exit 1 only for a hard failure: the directory itself was unusable, or
110
+ // every candidate that looked like a task failed. Skips and unchanged
111
+ // files are a successful scan. 2 and 3 stay reserved for escalated and
112
+ // halted *runs*.
113
+ if (result.dirError) {
114
+ process.exitCode = 1;
115
+ return;
116
+ }
117
+ if (result.failed.length > 0 && result.created.length === 0 && result.unchanged.length === 0) {
118
+ process.exitCode = 1;
119
+ }
120
+ });
121
+ }
@@ -0,0 +1,6 @@
1
+ export interface WbcArg {
2
+ value?: string;
3
+ argv: string[];
4
+ error?: string;
5
+ }
6
+ export declare function extractWbcArg(argv: string[]): WbcArg;
@@ -0,0 +1,40 @@
1
+ // xcoder:version 1 | xcoder:task task-7a4850 | xcoder:updated 2026-10-25T16:26:45.781Z | xcoder:subtask code-st-892a22
2
+ // C1 — pure argv pre-extractor for the root-level `--wbc <file>` flag.
3
+ //
4
+ // `xcoder --wbc foo.md` has NO subcommand, so commander would reject it with
5
+ // `commander.unknownCommand` (exit 127). The workspace already solves this class
6
+ // of problem for `--config` by rewriting `process.argv` before
7
+ // `program.parseAsync()` (see `extractConfigArg` in config/user-config.ts); this
8
+ // follows that precedent exactly rather than adding a root positional argument,
9
+ // which would change how every argument-less invocation is parsed.
10
+ //
11
+ // Never touches the filesystem, never throws. Path validation and workspace
12
+ // confinement are C3's job (via C9), so there is exactly one confinement
13
+ // implementation.
14
+ const FLAGS = ["--wbc", "--wbs"];
15
+ export function extractWbcArg(argv) {
16
+ const rest = argv.slice(0, 2);
17
+ let value;
18
+ let error;
19
+ for (let i = 2; i < argv.length; i++) {
20
+ const arg = argv[i];
21
+ const inline = FLAGS.find((f) => arg.startsWith(`${f}=`));
22
+ if (inline) {
23
+ value = arg.slice(inline.length + 1);
24
+ continue;
25
+ }
26
+ if (FLAGS.includes(arg)) {
27
+ const next = argv[i + 1];
28
+ if (next === undefined || next.startsWith("--")) {
29
+ return { argv, error: "--wbc requires a path to a WBS file" };
30
+ }
31
+ value = next;
32
+ i++;
33
+ continue;
34
+ }
35
+ rest.push(arg);
36
+ }
37
+ if (error)
38
+ return { argv, error };
39
+ return { argv: rest, value };
40
+ }
@@ -0,0 +1,45 @@
1
+ import type { Command } from "commander";
2
+ export interface WbcCliOptions {
3
+ wbc: string;
4
+ /** --dry-run: print the plan, write nothing. */
5
+ dryRun?: boolean;
6
+ /** --force: replace a record that already has progress. */
7
+ force?: boolean;
8
+ /** --no-architect: deterministic, zero-token content. */
9
+ noArchitect?: boolean;
10
+ /** --max-items <n>, clamped to MAX_ITEMS (200). */
11
+ maxItems?: number;
12
+ /** Default 3, clamped 1..8. */
13
+ concurrency?: number;
14
+ /** Passed through to createLlmClient. */
15
+ model?: string;
16
+ }
17
+ export declare function setWbcSourcePath(value: string | undefined): void;
18
+ /** The path captured from argv, or undefined when `--wbc` was not given. */
19
+ export declare function capturedWbc(): string | undefined;
20
+ /**
21
+ * Root-level flags for the feature. Declared here so the help text and the
22
+ * option list live in one file; the composition root applies them.
23
+ */
24
+ export declare const WBC_OPTIONS: ReadonlyArray<readonly [string, string]>;
25
+ /** Applies the feature's root flags to `program`. */
26
+ export declare function registerWbcFlag(program: Command): void;
27
+ /**
28
+ * Runs the extraction and translates the result into an exit code and
29
+ * sanitised terminal output. Every attacker-influenced string goes through
30
+ * `sanitizeForTerminal` (C14) on the way to the terminal only.
31
+ */
32
+ export declare function runWbcCli(opts: WbcCliOptions, workspaceRoot: string): Promise<void>;
33
+ /**
34
+ * Root-action branch: runs the extraction when `--wbc` was captured and
35
+ * reports whether it handled the invocation (so the caller can return early).
36
+ */
37
+ export declare function runCapturedWbc(opts: {
38
+ workspace: string;
39
+ dryRun?: boolean;
40
+ force?: boolean;
41
+ architect?: boolean;
42
+ maxItems?: unknown;
43
+ concurrency?: unknown;
44
+ model?: string;
45
+ }): Promise<boolean>;
@@ -0,0 +1,98 @@
1
+ // xcoder:version 3 | xcoder:task task-7a4850 | xcoder:updated 2026-10-25T16:40:07.741Z | xcoder:subtask code-st-892a22
2
+ // C2 — the root-command surface for `xcoder --wbc <file>`.
3
+ //
4
+ // `--wbc` is declared on the ROOT command (the same block that owns
5
+ // `--workspace`, `--concurrency` and `--model`), so it shows up in
6
+ // `xcoder --help` and reuses those globals rather than declaring a second set
7
+ // of conflicting flags. `--wbc` itself is lifted out of argv by
8
+ // `extractWbcArg()` before `program.parseAsync()` (C1); the captured path is
9
+ // handed in through `setWbcSourcePath()` and consumed inside the root action.
10
+ import { extractWbsTasks } from "../task-ingest/wbs-extract.js";
11
+ import { sanitizeForTerminal } from "../util/text-sanitize.js";
12
+ import { log } from "../util/logger.js";
13
+ /** Set by the composition root after `extractWbcArg()` captures the value. */
14
+ let capturedWbcPath;
15
+ export function setWbcSourcePath(value) {
16
+ capturedWbcPath = value;
17
+ }
18
+ /** The path captured from argv, or undefined when `--wbc` was not given. */
19
+ export function capturedWbc() {
20
+ return capturedWbcPath;
21
+ }
22
+ /**
23
+ * Root-level flags for the feature. Declared here so the help text and the
24
+ * option list live in one file; the composition root applies them.
25
+ */
26
+ export const WBC_OPTIONS = [
27
+ ["--wbc <path>", "with a WBS file: extract every pending item into its own scannable task run"],
28
+ ["--dry-run", "with --wbc: print the extraction plan and write nothing"],
29
+ ["--force", "with --wbc: replace task records that already have progress"],
30
+ ["--max-items <n>", "with --wbc: extract at most <n> pending items (default 50, max 200)"],
31
+ ["--no-architect", "with --wbc: use deterministic task content, spending zero tokens"],
32
+ ];
33
+ /** Applies the feature's root flags to `program`. */
34
+ export function registerWbcFlag(program) {
35
+ for (const [flags, description] of WBC_OPTIONS)
36
+ program.option(flags, description);
37
+ }
38
+ /** Commander leaves option values as strings; NaN is passed through so the
39
+ * orchestrator reports `bad-options` rather than silently defaulting. */
40
+ function numeric(value) {
41
+ if (value === undefined)
42
+ return undefined;
43
+ return Number(value);
44
+ }
45
+ /**
46
+ * Runs the extraction and translates the result into an exit code and
47
+ * sanitised terminal output. Every attacker-influenced string goes through
48
+ * `sanitizeForTerminal` (C14) on the way to the terminal only.
49
+ */
50
+ export async function runWbcCli(opts, workspaceRoot) {
51
+ const result = await extractWbsTasks({
52
+ workspaceRoot,
53
+ from: opts.wbc,
54
+ dryRun: opts.dryRun === true,
55
+ force: opts.force === true,
56
+ detailer: opts.noArchitect === true ? null : undefined,
57
+ maxItems: opts.maxItems,
58
+ concurrency: opts.concurrency,
59
+ });
60
+ if (!result.ok) {
61
+ const where = result.line === undefined ? "" : ` (line ${result.line})`;
62
+ log.fail(`${result.code}${where}: ${sanitizeForTerminal(result.message, 300)}`);
63
+ process.exitCode = 1;
64
+ return;
65
+ }
66
+ if (result.tasks.length === 0) {
67
+ log.ok(`no pending items — nothing to extract from ${sanitizeForTerminal(result.sourcePath, 100)}`);
68
+ return;
69
+ }
70
+ for (const task of result.tasks) {
71
+ const verb = task.created ? (result.dryRun ? "would create" : "created") : "unchanged";
72
+ log.raw(`${verb} ${task.taskId} ${sanitizeForTerminal(result.sourcePath, 60)}:${task.line} ` +
73
+ `${sanitizeForTerminal(task.stages.join(">"), 60)} resume: ${task.nextCommand}`);
74
+ }
75
+ const c = result.counts;
76
+ const prefix = result.dryRun ? "dry run — would extract" : "extracted";
77
+ log.dim(`${prefix} ${result.tasks.length} task(s) from ${sanitizeForTerminal(result.sourcePath, 100)} — ` +
78
+ `${c.created} created, ${c.unchanged} unchanged, ${c.checked} checked skipped, ${c.superseded} superseded`);
79
+ }
80
+ /**
81
+ * Root-action branch: runs the extraction when `--wbc` was captured and
82
+ * reports whether it handled the invocation (so the caller can return early).
83
+ */
84
+ export async function runCapturedWbc(opts) {
85
+ const from = capturedWbc();
86
+ if (from === undefined)
87
+ return false;
88
+ await runWbcCli({
89
+ wbc: from,
90
+ dryRun: opts.dryRun === true,
91
+ force: opts.force === true,
92
+ noArchitect: opts.architect === false,
93
+ maxItems: numeric(opts.maxItems),
94
+ concurrency: numeric(opts.concurrency),
95
+ model: opts.model,
96
+ }, opts.workspace);
97
+ return true;
98
+ }
@@ -0,0 +1,9 @@
1
+ import type { Command } from "commander";
2
+ import { type LicenseApi } from "../license/http-client.js";
3
+ import { type LicenseManager } from "../license/manager.js";
4
+ /** Test seam: the registrar accepts injected dependencies. */
5
+ export interface LicenseCommandDeps {
6
+ manager?: LicenseManager;
7
+ api?: LicenseApi;
8
+ }
9
+ export declare function registerLicenseCommand(program: Command, deps?: LicenseCommandDeps): void;