@evalops/maestro 0.10.50 → 0.10.51

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/dist/agent/agent-outcome.d.ts +54 -0
  2. package/dist/agent/agent-outcome.d.ts.map +1 -0
  3. package/dist/agent/agent-outcome.js +142 -0
  4. package/dist/agent/agent-outcome.js.map +1 -0
  5. package/dist/agent/agent-resume.d.ts.map +1 -1
  6. package/dist/agent/agent-resume.js +3 -3
  7. package/dist/agent/agent-resume.js.map +1 -1
  8. package/dist/agent/agent-run-summary.d.ts +37 -0
  9. package/dist/agent/agent-run-summary.d.ts.map +1 -0
  10. package/dist/agent/agent-run-summary.js +15 -0
  11. package/dist/agent/agent-run-summary.js.map +1 -0
  12. package/dist/agent/agent-work-board.d.ts +82 -0
  13. package/dist/agent/agent-work-board.d.ts.map +1 -0
  14. package/dist/agent/agent-work-board.js +312 -0
  15. package/dist/agent/agent-work-board.js.map +1 -0
  16. package/dist/agent/auto-compaction.d.ts +7 -2
  17. package/dist/agent/auto-compaction.d.ts.map +1 -1
  18. package/dist/agent/auto-compaction.js +23 -10
  19. package/dist/agent/auto-compaction.js.map +1 -1
  20. package/dist/agent/mission-artifacts.d.ts +62 -0
  21. package/dist/agent/mission-artifacts.d.ts.map +1 -0
  22. package/dist/agent/mission-artifacts.js +438 -0
  23. package/dist/agent/mission-artifacts.js.map +1 -0
  24. package/dist/agent/mission-manifest.d.ts +139 -3
  25. package/dist/agent/mission-manifest.d.ts.map +1 -1
  26. package/dist/agent/mission-manifest.js +549 -3
  27. package/dist/agent/mission-manifest.js.map +1 -1
  28. package/dist/agent/mission-store.d.ts +80 -0
  29. package/dist/agent/mission-store.d.ts.map +1 -0
  30. package/dist/agent/mission-store.js +603 -0
  31. package/dist/agent/mission-store.js.map +1 -0
  32. package/dist/agent/modes.d.ts +2 -2
  33. package/dist/agent/modes.d.ts.map +1 -1
  34. package/dist/agent/modes.js +10 -3
  35. package/dist/agent/modes.js.map +1 -1
  36. package/dist/agent/providers/codex-app-server.d.ts.map +1 -1
  37. package/dist/agent/providers/codex-app-server.js +1 -3
  38. package/dist/agent/providers/codex-app-server.js.map +1 -1
  39. package/dist/agent/providers/google-gemini-cli.js +203 -107
  40. package/dist/agent/providers/google.js +100 -41
  41. package/dist/agent/providers/scripted.d.ts.map +1 -1
  42. package/dist/agent/providers/scripted.js +1 -3
  43. package/dist/agent/providers/scripted.js.map +1 -1
  44. package/dist/agent/providers/validation.d.ts.map +1 -1
  45. package/dist/agent/providers/validation.js +1 -3
  46. package/dist/agent/providers/validation.js.map +1 -1
  47. package/dist/agent/providers/vertex.js +203 -107
  48. package/dist/agent/snapshot-store.d.ts +32 -0
  49. package/dist/agent/snapshot-store.d.ts.map +1 -0
  50. package/dist/agent/snapshot-store.js +195 -0
  51. package/dist/agent/snapshot-store.js.map +1 -0
  52. package/dist/agent/specialist-profiles.d.ts +36 -0
  53. package/dist/agent/specialist-profiles.d.ts.map +1 -0
  54. package/dist/agent/specialist-profiles.js +159 -0
  55. package/dist/agent/specialist-profiles.js.map +1 -0
  56. package/dist/agent/subagent-specs.d.ts +4 -1
  57. package/dist/agent/subagent-specs.d.ts.map +1 -1
  58. package/dist/agent/subagent-specs.js +81 -8
  59. package/dist/agent/subagent-specs.js.map +1 -1
  60. package/dist/agent/swarm/coverage-gate.d.ts +37 -0
  61. package/dist/agent/swarm/coverage-gate.d.ts.map +1 -0
  62. package/dist/agent/swarm/coverage-gate.js +48 -0
  63. package/dist/agent/swarm/coverage-gate.js.map +1 -0
  64. package/dist/agent/swarm/executor.d.ts +1 -0
  65. package/dist/agent/swarm/executor.d.ts.map +1 -1
  66. package/dist/agent/swarm/executor.js +151 -15
  67. package/dist/agent/swarm/executor.js.map +1 -1
  68. package/dist/agent/swarm/orchestrator-prompt.d.ts +25 -0
  69. package/dist/agent/swarm/orchestrator-prompt.d.ts.map +1 -0
  70. package/dist/agent/swarm/orchestrator-prompt.js +48 -0
  71. package/dist/agent/swarm/orchestrator-prompt.js.map +1 -0
  72. package/dist/agent/swarm/plan-parser.d.ts.map +1 -1
  73. package/dist/agent/swarm/plan-parser.js +27 -2
  74. package/dist/agent/swarm/plan-parser.js.map +1 -1
  75. package/dist/agent/swarm/types.d.ts +17 -0
  76. package/dist/agent/swarm/types.d.ts.map +1 -1
  77. package/dist/agent/swarm/types.js.map +1 -1
  78. package/dist/agent/swarm/validation-directive.d.ts +21 -0
  79. package/dist/agent/swarm/validation-directive.d.ts.map +1 -0
  80. package/dist/agent/swarm/validation-directive.js +25 -0
  81. package/dist/agent/swarm/validation-directive.js.map +1 -0
  82. package/dist/agent/transport/tool-execution-bridge.d.ts.map +1 -1
  83. package/dist/agent/transport/tool-execution-bridge.js +4 -1
  84. package/dist/agent/transport/tool-execution-bridge.js.map +1 -1
  85. package/dist/api/enterprise-routes.d.ts.map +1 -1
  86. package/dist/api/enterprise-routes.js +87 -10
  87. package/dist/api/enterprise-routes.js.map +1 -1
  88. package/dist/api/org-settings-merge.d.ts +12 -0
  89. package/dist/api/org-settings-merge.d.ts.map +1 -0
  90. package/dist/api/org-settings-merge.js +38 -0
  91. package/dist/api/org-settings-merge.js.map +1 -0
  92. package/dist/api/user-settings-merge.d.ts +16 -0
  93. package/dist/api/user-settings-merge.d.ts.map +1 -0
  94. package/dist/api/user-settings-merge.js +37 -0
  95. package/dist/api/user-settings-merge.js.map +1 -0
  96. package/dist/app-server/daemon-lifecycle-api.d.ts.map +1 -1
  97. package/dist/app-server/daemon-lifecycle-api.js +1 -3
  98. package/dist/app-server/daemon-lifecycle-api.js.map +1 -1
  99. package/dist/app-server/external-agent-import-api.d.ts.map +1 -1
  100. package/dist/app-server/external-agent-import-api.js +1 -3
  101. package/dist/app-server/external-agent-import-api.js.map +1 -1
  102. package/dist/app-server/network-governance-api.d.ts.map +1 -1
  103. package/dist/app-server/network-governance-api.js +1 -3
  104. package/dist/app-server/network-governance-api.js.map +1 -1
  105. package/dist/app-server/plugin-bundle-api.d.ts.map +1 -1
  106. package/dist/app-server/plugin-bundle-api.js +1 -3
  107. package/dist/app-server/plugin-bundle-api.js.map +1 -1
  108. package/dist/app-server/policy-control-api.d.ts.map +1 -1
  109. package/dist/app-server/policy-control-api.js +1 -3
  110. package/dist/app-server/policy-control-api.js.map +1 -1
  111. package/dist/app-server/protocol-modes-api.d.ts.map +1 -1
  112. package/dist/app-server/protocol-modes-api.js +1 -3
  113. package/dist/app-server/protocol-modes-api.js.map +1 -1
  114. package/dist/cli/args.d.ts +2 -0
  115. package/dist/cli/args.d.ts.map +1 -1
  116. package/dist/cli/args.js +15 -0
  117. package/dist/cli/args.js.map +1 -1
  118. package/dist/cli/commands/a2a.d.ts.map +1 -1
  119. package/dist/cli/commands/a2a.js +1 -3
  120. package/dist/cli/commands/a2a.js.map +1 -1
  121. package/dist/cli/commands/agents.d.ts +4 -0
  122. package/dist/cli/commands/agents.d.ts.map +1 -1
  123. package/dist/cli/commands/agents.js +149 -0
  124. package/dist/cli/commands/agents.js.map +1 -1
  125. package/dist/cli/commands/mission.d.ts +4 -0
  126. package/dist/cli/commands/mission.d.ts.map +1 -0
  127. package/dist/cli/commands/mission.js +196 -0
  128. package/dist/cli/commands/mission.js.map +1 -0
  129. package/dist/cli/commands/value.d.ts +10 -0
  130. package/dist/cli/commands/value.d.ts.map +1 -0
  131. package/dist/cli/commands/value.js +33 -0
  132. package/dist/cli/commands/value.js.map +1 -0
  133. package/dist/cli/headless-protocol.d.ts.map +1 -1
  134. package/dist/cli/headless-protocol.js +1 -3
  135. package/dist/cli/headless-protocol.js.map +1 -1
  136. package/dist/cli/help.d.ts.map +1 -1
  137. package/dist/cli/help.js +10 -0
  138. package/dist/cli/help.js.map +1 -1
  139. package/dist/cli/system-prompt.d.ts.map +1 -1
  140. package/dist/cli/system-prompt.js +38 -7
  141. package/dist/cli/system-prompt.js.map +1 -1
  142. package/dist/cli-runtime.js +7756 -2800
  143. package/dist/cli-tui/client-tools/client-tool-controller.d.ts.map +1 -1
  144. package/dist/cli-tui/client-tools/client-tool-controller.js +1 -3
  145. package/dist/cli-tui/client-tools/client-tool-controller.js.map +1 -1
  146. package/dist/cli-tui/commands/undo-handlers.d.ts.map +1 -1
  147. package/dist/cli-tui/commands/undo-handlers.js +7 -2
  148. package/dist/cli-tui/commands/undo-handlers.js.map +1 -1
  149. package/dist/cli-tui/tui-renderer/skills-controller.d.ts +3 -0
  150. package/dist/cli-tui/tui-renderer/skills-controller.d.ts.map +1 -1
  151. package/dist/cli-tui/tui-renderer/skills-controller.js +77 -33
  152. package/dist/cli-tui/tui-renderer/skills-controller.js.map +1 -1
  153. package/dist/codex/app-server-client.d.ts.map +1 -1
  154. package/dist/codex/app-server-client.js +1 -3
  155. package/dist/codex/app-server-client.js.map +1 -1
  156. package/dist/codex/compatibility.d.ts.map +1 -1
  157. package/dist/codex/compatibility.js +1 -3
  158. package/dist/codex/compatibility.js.map +1 -1
  159. package/dist/codex/subagent-dispatch-table.d.ts +8 -0
  160. package/dist/codex/subagent-dispatch-table.d.ts.map +1 -1
  161. package/dist/codex/subagent-dispatch-table.js +23 -0
  162. package/dist/codex/subagent-dispatch-table.js.map +1 -1
  163. package/dist/context/manifest.d.ts.map +1 -1
  164. package/dist/context/manifest.js +1 -3
  165. package/dist/context/manifest.js.map +1 -1
  166. package/dist/conversation/render-model.d.ts +0 -36
  167. package/dist/conversation/render-model.d.ts.map +1 -1
  168. package/dist/conversation/render-model.js +1 -3
  169. package/dist/conversation/render-model.js.map +1 -1
  170. package/dist/customer-value/ambient-learning.d.ts +75 -0
  171. package/dist/customer-value/ambient-learning.d.ts.map +1 -0
  172. package/dist/customer-value/ambient-learning.js +472 -0
  173. package/dist/customer-value/ambient-learning.js.map +1 -0
  174. package/dist/customer-value/internal-helpers.d.ts +13 -0
  175. package/dist/customer-value/internal-helpers.d.ts.map +1 -0
  176. package/dist/customer-value/internal-helpers.js +70 -0
  177. package/dist/customer-value/internal-helpers.js.map +1 -0
  178. package/dist/customer-value/report.d.ts +282 -0
  179. package/dist/customer-value/report.d.ts.map +1 -0
  180. package/dist/customer-value/report.js +2085 -0
  181. package/dist/customer-value/report.js.map +1 -0
  182. package/dist/db/schema.d.ts +5 -1
  183. package/dist/db/schema.d.ts.map +1 -1
  184. package/dist/db/schema.js.map +1 -1
  185. package/dist/evalops/agent-bootstrap.d.ts.map +1 -1
  186. package/dist/evalops/agent-bootstrap.js +1 -3
  187. package/dist/evalops/agent-bootstrap.js.map +1 -1
  188. package/dist/evalops/agent-mcp-metadata.d.ts.map +1 -1
  189. package/dist/evalops/agent-mcp-metadata.js +1 -3
  190. package/dist/evalops/agent-mcp-metadata.js.map +1 -1
  191. package/dist/index.d.ts +1 -0
  192. package/dist/index.d.ts.map +1 -1
  193. package/dist/index.js +1 -0
  194. package/dist/index.js.map +1 -1
  195. package/dist/installers/maestro-review-workflow.d.ts +38 -0
  196. package/dist/installers/maestro-review-workflow.d.ts.map +1 -0
  197. package/dist/installers/maestro-review-workflow.js +163 -0
  198. package/dist/installers/maestro-review-workflow.js.map +1 -0
  199. package/dist/load-env.d.ts.map +1 -1
  200. package/dist/load-env.js +2 -1
  201. package/dist/load-env.js.map +1 -1
  202. package/dist/main.d.ts.map +1 -1
  203. package/dist/main.js +92 -3
  204. package/dist/main.js.map +1 -1
  205. package/dist/mcp/config.d.ts.map +1 -1
  206. package/dist/mcp/config.js +1 -3
  207. package/dist/mcp/config.js.map +1 -1
  208. package/dist/mcp/elicitation.d.ts.map +1 -1
  209. package/dist/mcp/elicitation.js +1 -3
  210. package/dist/mcp/elicitation.js.map +1 -1
  211. package/dist/mcp/official-registry.d.ts.map +1 -1
  212. package/dist/mcp/official-registry.js +1 -3
  213. package/dist/mcp/official-registry.js.map +1 -1
  214. package/dist/mcp/workspace-trust.d.ts.map +1 -1
  215. package/dist/mcp/workspace-trust.js +1 -3
  216. package/dist/mcp/workspace-trust.js.map +1 -1
  217. package/dist/memory/service-client.d.ts.map +1 -1
  218. package/dist/memory/service-client.js +1 -3
  219. package/dist/memory/service-client.js.map +1 -1
  220. package/dist/models/config-loader.d.ts.map +1 -1
  221. package/dist/models/config-loader.js +1 -3
  222. package/dist/models/config-loader.js.map +1 -1
  223. package/dist/node_modules/@evalops/contracts/dist/index.d.ts +1 -0
  224. package/dist/node_modules/@evalops/contracts/dist/index.d.ts.map +1 -1
  225. package/dist/node_modules/@evalops/contracts/dist/index.js +1 -0
  226. package/dist/node_modules/@evalops/contracts/dist/index.js.map +1 -1
  227. package/dist/node_modules/@evalops/contracts/dist/maestro-settings.d.ts +61 -0
  228. package/dist/node_modules/@evalops/contracts/dist/maestro-settings.d.ts.map +1 -0
  229. package/dist/node_modules/@evalops/contracts/dist/maestro-settings.js +183 -0
  230. package/dist/node_modules/@evalops/contracts/dist/maestro-settings.js.map +1 -0
  231. package/dist/node_modules/@evalops/contracts/package.json +1 -1
  232. package/dist/node_modules/@evalops/tui/package.json +1 -1
  233. package/dist/oauth/connectors.d.ts.map +1 -1
  234. package/dist/oauth/connectors.js +1 -3
  235. package/dist/oauth/connectors.js.map +1 -1
  236. package/dist/oauth/evalops.d.ts.map +1 -1
  237. package/dist/oauth/evalops.js +1 -3
  238. package/dist/oauth/evalops.js.map +1 -1
  239. package/dist/platform/a2a-client.d.ts.map +1 -1
  240. package/dist/platform/a2a-client.js +1 -3
  241. package/dist/platform/a2a-client.js.map +1 -1
  242. package/dist/platform/a2a-cockpit.d.ts +1 -0
  243. package/dist/platform/a2a-cockpit.d.ts.map +1 -1
  244. package/dist/platform/a2a-cockpit.js +42 -11
  245. package/dist/platform/a2a-cockpit.js.map +1 -1
  246. package/dist/platform/a2a-completion-audit.d.ts +1 -1
  247. package/dist/platform/a2a-completion-audit.d.ts.map +1 -1
  248. package/dist/platform/a2a-completion-audit.js +7 -11
  249. package/dist/platform/a2a-completion-audit.js.map +1 -1
  250. package/dist/platform/a2a-maestro-peer.js +16 -0
  251. package/dist/platform/a2a-maestro-peer.js.map +1 -1
  252. package/dist/platform/a2a-peer-pairing.d.ts.map +1 -1
  253. package/dist/platform/a2a-peer-pairing.js +1 -3
  254. package/dist/platform/a2a-peer-pairing.js.map +1 -1
  255. package/dist/platform/a2a-peer-registry.d.ts.map +1 -1
  256. package/dist/platform/a2a-peer-registry.js +1 -3
  257. package/dist/platform/a2a-peer-registry.js.map +1 -1
  258. package/dist/platform/a2a-task-ledger.d.ts +20 -0
  259. package/dist/platform/a2a-task-ledger.d.ts.map +1 -1
  260. package/dist/platform/a2a-task-ledger.js +207 -11
  261. package/dist/platform/a2a-task-ledger.js.map +1 -1
  262. package/dist/platform/a2a-work-graph.d.ts.map +1 -1
  263. package/dist/platform/a2a-work-graph.js +1 -3
  264. package/dist/platform/a2a-work-graph.js.map +1 -1
  265. package/dist/platform/operating-layer.d.ts.map +1 -1
  266. package/dist/platform/operating-layer.js +14 -8
  267. package/dist/platform/operating-layer.js.map +1 -1
  268. package/dist/platform/tool-execution-client.d.ts.map +1 -1
  269. package/dist/platform/tool-execution-client.js +19 -2
  270. package/dist/platform/tool-execution-client.js.map +1 -1
  271. package/dist/providers/auth.d.ts.map +1 -1
  272. package/dist/providers/auth.js +1 -3
  273. package/dist/providers/auth.js.map +1 -1
  274. package/dist/runtime/env.d.ts +9 -1
  275. package/dist/runtime/env.d.ts.map +1 -1
  276. package/dist/runtime/env.js +63 -1
  277. package/dist/runtime/env.js.map +1 -1
  278. package/dist/safety/policy.d.ts.map +1 -1
  279. package/dist/safety/policy.js +1 -4
  280. package/dist/safety/policy.js.map +1 -1
  281. package/dist/sandbox/docker-sandbox.d.ts.map +1 -1
  282. package/dist/sandbox/docker-sandbox.js +6 -1
  283. package/dist/sandbox/docker-sandbox.js.map +1 -1
  284. package/dist/server/handlers/hosted-runner-drain.d.ts.map +1 -1
  285. package/dist/server/handlers/hosted-runner-drain.js +1 -3
  286. package/dist/server/handlers/hosted-runner-drain.js.map +1 -1
  287. package/dist/server/handlers/platform-a2a-push.d.ts.map +1 -1
  288. package/dist/server/handlers/platform-a2a-push.js +53 -2
  289. package/dist/server/handlers/platform-a2a-push.js.map +1 -1
  290. package/dist/server/handlers/runtime-app-server-ws.d.ts.map +1 -1
  291. package/dist/server/handlers/runtime-app-server-ws.js +1 -3
  292. package/dist/server/handlers/runtime-app-server-ws.js.map +1 -1
  293. package/dist/server/headless-runtime-service.d.ts +16 -0
  294. package/dist/server/headless-runtime-service.d.ts.map +1 -1
  295. package/dist/server/headless-runtime-service.js +232 -206
  296. package/dist/server/headless-runtime-service.js.map +1 -1
  297. package/dist/server/hosted-agent-runtime-progress.d.ts.map +1 -1
  298. package/dist/server/hosted-agent-runtime-progress.js +12 -3
  299. package/dist/server/hosted-agent-runtime-progress.js.map +1 -1
  300. package/dist/server/pending-request-payload.d.ts.map +1 -1
  301. package/dist/server/pending-request-payload.js +1 -3
  302. package/dist/server/pending-request-payload.js.map +1 -1
  303. package/dist/server/route-auth.d.ts.map +1 -1
  304. package/dist/server/route-auth.js +2 -0
  305. package/dist/server/route-auth.js.map +1 -1
  306. package/dist/server/session-serialization.d.ts.map +1 -1
  307. package/dist/server/session-serialization.js +1 -3
  308. package/dist/server/session-serialization.js.map +1 -1
  309. package/dist/services/compliance/normalize.d.ts.map +1 -1
  310. package/dist/services/compliance/normalize.js +1 -3
  311. package/dist/services/compliance/normalize.js.map +1 -1
  312. package/dist/services/intelligent-router/normalize.d.ts.map +1 -1
  313. package/dist/services/intelligent-router/normalize.js +1 -3
  314. package/dist/services/intelligent-router/normalize.js.map +1 -1
  315. package/dist/services/revenue-attribution/normalize.d.ts.map +1 -1
  316. package/dist/services/revenue-attribution/normalize.js +1 -3
  317. package/dist/services/revenue-attribution/normalize.js.map +1 -1
  318. package/dist/services/traces/normalize.d.ts.map +1 -1
  319. package/dist/services/traces/normalize.js +1 -3
  320. package/dist/services/traces/normalize.js.map +1 -1
  321. package/dist/services/workspace-config/normalize.d.ts.map +1 -1
  322. package/dist/services/workspace-config/normalize.js +1 -3
  323. package/dist/services/workspace-config/normalize.js.map +1 -1
  324. package/dist/skills/composer.d.ts.map +1 -1
  325. package/dist/skills/composer.js +13 -1
  326. package/dist/skills/composer.js.map +1 -1
  327. package/dist/skills/index.d.ts +1 -0
  328. package/dist/skills/index.d.ts.map +1 -1
  329. package/dist/skills/index.js +1 -0
  330. package/dist/skills/index.js.map +1 -1
  331. package/dist/skills/learned-guidelines.d.ts +33 -0
  332. package/dist/skills/learned-guidelines.d.ts.map +1 -0
  333. package/dist/skills/learned-guidelines.js +291 -0
  334. package/dist/skills/learned-guidelines.js.map +1 -0
  335. package/dist/skills/linter.d.ts.map +1 -1
  336. package/dist/skills/linter.js +1 -3
  337. package/dist/skills/linter.js.map +1 -1
  338. package/dist/skills/runtime-activation.d.ts +1 -0
  339. package/dist/skills/runtime-activation.d.ts.map +1 -1
  340. package/dist/skills/runtime-activation.js +2 -3
  341. package/dist/skills/runtime-activation.js.map +1 -1
  342. package/dist/skills/tool.d.ts.map +1 -1
  343. package/dist/skills/tool.js +26 -21
  344. package/dist/skills/tool.js.map +1 -1
  345. package/dist/skills/trust-cache.d.ts +7 -0
  346. package/dist/skills/trust-cache.d.ts.map +1 -1
  347. package/dist/skills/trust-cache.js +16 -0
  348. package/dist/skills/trust-cache.js.map +1 -1
  349. package/dist/telemetry/agent-workforce-native-event.d.ts.map +1 -1
  350. package/dist/telemetry/agent-workforce-native-event.js +1 -3
  351. package/dist/telemetry/agent-workforce-native-event.js.map +1 -1
  352. package/dist/telemetry/maestro-event-bus.d.ts.map +1 -1
  353. package/dist/telemetry/maestro-event-bus.js +42 -81
  354. package/dist/telemetry/maestro-event-bus.js.map +1 -1
  355. package/dist/telemetry/maestro-platform-replay-fixture.d.ts.map +1 -1
  356. package/dist/telemetry/maestro-platform-replay-fixture.js +1 -3
  357. package/dist/telemetry/maestro-platform-replay-fixture.js.map +1 -1
  358. package/dist/telemetry.d.ts.map +1 -1
  359. package/dist/telemetry.js +54 -43
  360. package/dist/telemetry.js.map +1 -1
  361. package/dist/theme/theme-loader.d.ts.map +1 -1
  362. package/dist/theme/theme-loader.js +1 -3
  363. package/dist/theme/theme-loader.js.map +1 -1
  364. package/dist/tools/apply-patch.d.ts.map +1 -1
  365. package/dist/tools/apply-patch.js +76 -8
  366. package/dist/tools/apply-patch.js.map +1 -1
  367. package/dist/tools/diff-preview.d.ts.map +1 -1
  368. package/dist/tools/diff-preview.js +10 -1
  369. package/dist/tools/diff-preview.js.map +1 -1
  370. package/dist/tools/edit.d.ts.map +1 -1
  371. package/dist/tools/edit.js +17 -0
  372. package/dist/tools/edit.js.map +1 -1
  373. package/dist/tools/write.d.ts.map +1 -1
  374. package/dist/tools/write.js +9 -0
  375. package/dist/tools/write.js.map +1 -1
  376. package/dist/undo/tracker.d.ts +5 -0
  377. package/dist/undo/tracker.d.ts.map +1 -1
  378. package/dist/undo/tracker.js +13 -0
  379. package/dist/undo/tracker.js.map +1 -1
  380. package/dist/utils/fs.d.ts +1 -1
  381. package/dist/utils/fs.d.ts.map +1 -1
  382. package/dist/utils/fs.js +29 -2
  383. package/dist/utils/fs.js.map +1 -1
  384. package/dist/utils/git-stash.d.ts.map +1 -1
  385. package/dist/utils/git-stash.js +15 -8
  386. package/dist/utils/git-stash.js.map +1 -1
  387. package/dist/utils/json.d.ts +11 -0
  388. package/dist/utils/json.d.ts.map +1 -1
  389. package/dist/utils/json.js +9 -0
  390. package/dist/utils/json.js.map +1 -1
  391. package/dist/utils/shell-env.d.ts.map +1 -1
  392. package/dist/utils/shell-env.js +2 -0
  393. package/dist/utils/shell-env.js.map +1 -1
  394. package/dist/utils/url-extractor-git.d.ts +26 -0
  395. package/dist/utils/url-extractor-git.d.ts.map +1 -0
  396. package/dist/utils/url-extractor-git.js +259 -0
  397. package/dist/utils/url-extractor-git.js.map +1 -0
  398. package/dist/utils/url-extractor.d.ts.map +1 -1
  399. package/dist/utils/url-extractor.js +23 -251
  400. package/dist/utils/url-extractor.js.map +1 -1
  401. package/dist/version.json +2 -2
  402. package/package.json +310 -306
  403. package/skills/incident-triage/SKILL.md +19 -1
  404. package/skills/install-code-review/SKILL.md +69 -0
  405. package/skills/security-review/SKILL.md +68 -0
  406. package/skills/security-review/reference/rubric.md +85 -0
@@ -17,4 +17,8 @@ export interface AgentsInitResult {
17
17
  export declare function discoverAgentRuleSources(projectRoot: string, targetPath?: string, includeTarget?: boolean): AgentRuleSource[];
18
18
  export declare function buildAgentsInitPrompt(targetPath: string, sources?: AgentRuleSource[]): string;
19
19
  export declare function handleAgentsInit(inputPath?: string, options?: AgentsInitOptions): AgentsInitResult;
20
+ export declare function handleAgentsProfileCommand(args: readonly string[], options?: {
21
+ json?: boolean;
22
+ force?: boolean;
23
+ }): void;
20
24
  //# sourceMappingURL=agents.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/agents.ts"],"names":[],"mappings":"AA+FA,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACnB;AAMD,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,eAAe,EAAE,CAAC;CAC3B;AA2FD,wBAAgB,wBAAwB,CACvC,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,aAAa,UAAQ,GACnB,eAAe,EAAE,CAgDnB;AAsFD,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,eAAe,EAIvB,GACC,MAAM,CAER;AAED,wBAAgB,gBAAgB,CAC/B,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,GAAE,iBAAsB,GAC7B,gBAAgB,CAkClB"}
1
+ {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/agents.ts"],"names":[],"mappings":"AAsGA,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACnB;AAMD,MAAM,WAAW,iBAAiB;IACjC,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,eAAe,EAAE,CAAC;CAC3B;AA2FD,wBAAgB,wBAAwB,CACvC,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,aAAa,UAAQ,GACnB,eAAe,EAAE,CAgDnB;AAsFD,wBAAgB,qBAAqB,CACpC,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,eAAe,EAIvB,GACC,MAAM,CAER;AAED,wBAAgB,gBAAgB,CAC/B,SAAS,CAAC,EAAE,MAAM,EAClB,OAAO,GAAE,iBAAsB,GAC7B,gBAAgB,CAkClB;AAED,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAC/C,IAAI,CAoFN"}
@@ -1,6 +1,7 @@
1
1
  import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, } from "node:fs";
2
2
  import { basename, dirname, isAbsolute, join, relative, resolve, } from "node:path";
3
3
  import * as Diff from "diff";
4
+ import { createSpecialistProfile, deleteSpecialistProfile, listSpecialistProfiles, resolveSpecialistProfile, } from "../../agent/specialist-profiles.js";
4
5
  import { writeTextFileAtomic } from "../../utils/fs.js";
5
6
  import { truncateUtf8 } from "../system-prompt.js";
6
7
  const TEMPLATE = `# Repository Guidelines
@@ -277,4 +278,152 @@ export function handleAgentsInit(inputPath, options = {}) {
277
278
  sources: ruleSources,
278
279
  };
279
280
  }
281
+ export function handleAgentsProfileCommand(args, options = {}) {
282
+ const json = options.json === true || args.includes("--json");
283
+ const force = options.force === true || args.includes("--force");
284
+ const filteredArgs = args.filter((arg) => arg !== "--json" && arg !== "--force");
285
+ const action = filteredArgs[0] ?? "list";
286
+ switch (action) {
287
+ case "list": {
288
+ const profiles = listSpecialistProfiles();
289
+ if (json) {
290
+ console.log(JSON.stringify(profiles, null, 2));
291
+ return;
292
+ }
293
+ if (profiles.length === 0) {
294
+ console.log("No specialist profiles found.");
295
+ return;
296
+ }
297
+ for (const profile of profiles) {
298
+ console.log(`${profile.name} (${profile.scope})${profile.description ? ` - ${profile.description}` : ""}`);
299
+ }
300
+ return;
301
+ }
302
+ case "show": {
303
+ const name = filteredArgs[1];
304
+ if (!name)
305
+ throw new Error("agents profile show requires a name");
306
+ const profile = resolveSpecialistProfile(name);
307
+ if (!profile)
308
+ throw new Error(`specialist profile not found: ${name}`);
309
+ if (json) {
310
+ console.log(JSON.stringify(profile, null, 2));
311
+ return;
312
+ }
313
+ console.log(`# ${profile.name}`);
314
+ if (profile.description)
315
+ console.log(`\n${profile.description}`);
316
+ console.log(`\nScope: ${profile.scope}`);
317
+ console.log(`Path: ${profile.path}`);
318
+ console.log(`\n${profile.prompt}`);
319
+ return;
320
+ }
321
+ case "create": {
322
+ const name = filteredArgs[1];
323
+ if (!name)
324
+ throw new Error("agents profile create requires a name");
325
+ const parsed = parseProfileCreateArgs(filteredArgs.slice(2));
326
+ const profile = createSpecialistProfile({
327
+ name,
328
+ description: parsed.description,
329
+ prompt: parsed.prompt,
330
+ tools: parsed.tools,
331
+ model: parsed.model,
332
+ scope: parsed.scope,
333
+ overwrite: force,
334
+ });
335
+ if (json) {
336
+ console.log(JSON.stringify(profile, null, 2));
337
+ return;
338
+ }
339
+ console.log(`Created specialist profile ${profile.name} at ${profile.path}.`);
340
+ return;
341
+ }
342
+ case "delete": {
343
+ const name = filteredArgs[1];
344
+ if (!name)
345
+ throw new Error("agents profile delete requires a name");
346
+ const { scope } = parseProfileDeleteArgs(filteredArgs.slice(2));
347
+ const deleted = deleteSpecialistProfile({ name, scope });
348
+ if (json) {
349
+ console.log(JSON.stringify({ name, scope, deleted }, null, 2));
350
+ return;
351
+ }
352
+ console.log(deleted
353
+ ? `Deleted specialist profile ${name} (${scope}).`
354
+ : `No specialist profile ${name} found in ${scope} scope.`);
355
+ return;
356
+ }
357
+ default:
358
+ throw new Error(`Unknown agents profile action: ${action}. Use list, show, create, or delete.`);
359
+ }
360
+ }
361
+ function parseProfileCreateArgs(args) {
362
+ let description;
363
+ let tools;
364
+ let model;
365
+ let scope;
366
+ const promptParts = [];
367
+ for (let index = 0; index < args.length; index++) {
368
+ const arg = args[index];
369
+ const next = args[index + 1];
370
+ if (arg === "--description" && next) {
371
+ description = next;
372
+ index++;
373
+ }
374
+ else if (arg === "--tools" && next) {
375
+ tools = next
376
+ .split(",")
377
+ .map((tool) => tool.trim())
378
+ .filter(Boolean);
379
+ index++;
380
+ }
381
+ else if (arg === "--model" && next) {
382
+ model = next;
383
+ index++;
384
+ }
385
+ else if (arg === "--scope" && next) {
386
+ scope = parseProfileScope(next);
387
+ if (!scope)
388
+ throw new Error(`invalid profile scope: ${next}`);
389
+ index++;
390
+ }
391
+ else if (arg) {
392
+ promptParts.push(arg);
393
+ }
394
+ }
395
+ const prompt = promptParts.join(" ").trim();
396
+ if (!prompt) {
397
+ throw new Error("agents profile create requires prompt text");
398
+ }
399
+ return { description, prompt, tools, model, scope };
400
+ }
401
+ function parseProfileDeleteArgs(args) {
402
+ let scope = "project";
403
+ for (let index = 0; index < args.length; index++) {
404
+ const arg = args[index];
405
+ const next = args[index + 1];
406
+ if (arg === "--scope" && next) {
407
+ const parsed = parseProfileScope(next);
408
+ if (!parsed)
409
+ throw new Error(`invalid profile scope: ${next}`);
410
+ scope = parsed;
411
+ index++;
412
+ }
413
+ else if (arg?.startsWith("--scope=")) {
414
+ const value = arg.slice("--scope=".length);
415
+ const parsed = parseProfileScope(value);
416
+ if (!parsed)
417
+ throw new Error(`invalid profile scope: ${value}`);
418
+ scope = parsed;
419
+ }
420
+ else if (arg) {
421
+ throw new Error(`unexpected agents profile delete argument: ${arg}`);
422
+ }
423
+ }
424
+ return { scope };
425
+ }
426
+ function parseProfileScope(value) {
427
+ return value === "project" || value === "user" ? value : undefined;
428
+ }
280
429
  //# sourceMappingURL=agents.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/cli/commands/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,QAAQ,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EACN,QAAQ,EACR,OAAO,EACP,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,GACP,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BhB,CAAC;AAEF,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;qGA2B2E,CAAC;AAEtG,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACrC,MAAM;IACN,KAAK;IACL,MAAM;IACN,cAAc;IACd,MAAM;IACN,OA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EAAE,MAAM;gBACZ,MAAM,EAAE,SAAS;gBACjB,IAAI;gBACJ,OAAO,EAAE,WAAW;aACpB,CAAC;QACH,CAAC;QACD,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAChE,OAAO;YACN,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,SAAS;YACjB,IAAI;YACJ,OAAO,EAAE,WAAW;SACpB,CAAC;IACH,CAAC;IACD,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1C,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IAChE,OAAO;QACN,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,WAAW;KACpB,CAAC;AACH,CAAC","sourcesContent":["import {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\tstatSync,\n} from \"node:fs\";\nimport type { Dirent } from \"node:fs\";\nimport {\n\tbasename,\n\tdirname,\n\tisAbsolute,\n\tjoin,\n\trelative,\n\tresolve,\n} from \"node:path\";\nimport * as Diff from \"diff\";\nimport { writeTextFileAtomic } from \"../../utils/fs.js\";\nimport { truncateUtf8 } from \"../system-prompt.js\";\n\nconst TEMPLATE = `# Repository Guidelines\n\nUse this as the contributor quickstart for **{{PROJECT_NAME}}**.\n\n## Project Structure\n- Map the main source, test, docs, scripts, and config paths.\n- Call out generated, vendored, or build-output directories agents should not edit.\n\n## Commands\n- Install: \\`npm install\\` (or the repo's package manager).\n- Develop: \\`npm run dev\\`; Build: \\`npm run build\\`.\n- Quality: \\`npm run lint\\`, \\`npm run format\\`, and \\`npm test\\`.\n\n## Style\n- Follow the checked-in formatter and linter; keep naming consistent with nearby code.\n- Prefer small, focused changes and comments only for non-obvious behavior.\n\n## Testing\n- Add or update tests beside changed behavior.\n- Cover success, error, and boundary cases with deterministic fixtures.\n\n## Pull Requests\n- Use imperative commit subjects and keep PRs scoped.\n- Include behavior changes, linked issues, validation steps, and screenshots for UI changes.\n\n## Security\n- Do not commit secrets; document new environment variables and migrations.\n`;\n\nconst GENERATION_PROMPT = `Generate a file named AGENTS.md that serves as a contributor guide for this repository.\n\nYour goal is to produce a clear, concise, and well-structured document with descriptive headings and actionable explanations for each section. Follow the outline below, but adapt as needed—add sections if relevant, and omit those that do not apply to this project.\n\nDocument Requirements:\n- Title the document \"Repository Guidelines\".\n- Use Markdown headings (#, ##, etc.) for structure.\n- Keep the document concise; about 20 lines and 150-250 words is optimal.\n- Keep explanations short, direct, and specific to this repository.\n- Provide examples where helpful (commands, directory paths, naming patterns).\n- Maintain a professional, instructional tone.\n\nRecommended Sections:\n- Project Structure & Module Organization: Outline where source code, tests, docs, configs, and assets live.\n- Build, Test, and Development Commands: List key commands for installing, building, testing, and running locally with short explanations.\n- Coding Style & Naming Conventions: Indentation rules, style preferences, naming patterns, formatting/linting tools.\n- Testing Guidelines: Frameworks, coverage expectations, naming conventions, and how to run tests.\n- Commit & Pull Request Guidelines: Commit message conventions, PR requirements (descriptions, linked issues, screenshots), and pre-review checks.\n- (Optional) Security & Configuration Tips, Architecture Overview, or Agent-Specific Instructions if applicable.\n\nInstructions:\n- Use the available tools to inspect this repository as needed (e.g., list directories, read configs, inspect scripts) before writing.\n- If existing AI tool rule files are supplied below, preserve their intent in the generated AGENTS.md instead of ignoring or mechanically concatenating them.\n- If an existing AGENTS.md or AGENT.md is supplied below, update its guidance instead of discarding hand-written project specifics.\n- Add a short HTML comment near the top noting which AI rule sources contributed.\n- Overwrite the entire contents of AGENTS.md at the target path.\n- Keep output scoped to the single Markdown file; do not create extra files.\n- Write the final document directly to the AGENTS.md file and return a brief confirmation when done.`;\n\nconst MAX_IMPORTED_RULE_BYTES = 12_000;\nconst RULE_WALK_IGNORE_DIRS = new Set([\n\t\".git\",\n\t\".hg\",\n\t\".svn\",\n\t\"node_modules\",\n\t\"dist\",\n\t\"build\",\n\t\"coverage\",\n\t\".next\",\n\t\".turbo\",\n\t\".cache\",\n\t\"tmp\",\n]);\n\nexport interface AgentRuleSource {\n\tpath: string;\n\trelativePath: string;\n\tlabel: string;\n\tcontent: string;\n\ttruncated: boolean;\n}\n\nfunction buildAgentsTemplate(projectName: string): string {\n\treturn TEMPLATE.replace(/{{PROJECT_NAME}}/g, projectName);\n}\n\nexport interface AgentsInitOptions {\n\tforce?: boolean;\n}\n\nexport interface AgentsInitResult {\n\tpath: string;\n\taction: \"created\" | \"updated\" | \"preview\";\n\tdiff?: string;\n\tsources: AgentRuleSource[];\n}\n\nfunction resolveTargetPath(targetPath?: string): string {\n\tif (!targetPath) {\n\t\treturn join(process.cwd(), \"AGENTS.md\");\n\t}\n\tconst resolved = resolve(targetPath);\n\tif (resolved.toLowerCase().endsWith(\".md\")) {\n\t\treturn resolved;\n\t}\n\treturn join(resolved, \"AGENTS.md\");\n}\n\nfunction isMarkdownRuleFile(fileName: string): boolean {\n\tconst lower = fileName.toLowerCase();\n\treturn lower.endsWith(\".md\") || lower.endsWith(\".mdc\");\n}\n\nfunction isPathInside(root: string, candidate: string): boolean {\n\tconst relativePath = relative(root, candidate);\n\treturn (\n\t\trelativePath === \"\" ||\n\t\t(!relativePath.startsWith(\"..\") && !isAbsolute(relativePath))\n\t);\n}\n\nfunction readRuleSource(\n\tprojectRoot: string,\n\tfilePath: string,\n\tlabel: string,\n): AgentRuleSource | null {\n\ttry {\n\t\tconst resolvedPath = resolve(filePath);\n\t\tconst linkStat = lstatSync(resolvedPath);\n\t\tif (!linkStat.isFile()) {\n\t\t\treturn null;\n\t\t}\n\t\tconst rootRealPath = realpathSync(projectRoot);\n\t\tconst fileRealPath = realpathSync(resolvedPath);\n\t\tif (!isPathInside(rootRealPath, fileRealPath)) {\n\t\t\treturn null;\n\t\t}\n\t\tconst stat = statSync(resolvedPath);\n\t\tif (!stat.isFile()) {\n\t\t\treturn null;\n\t\t}\n\t\tconst raw = readFileSync(resolvedPath);\n\t\tconst truncated = raw.byteLength > MAX_IMPORTED_RULE_BYTES;\n\t\tconst content = truncated\n\t\t\t? truncateUtf8(raw, MAX_IMPORTED_RULE_BYTES).content\n\t\t\t: raw.toString(\"utf-8\");\n\t\treturn {\n\t\t\tpath: resolvedPath,\n\t\t\trelativePath:\n\t\t\t\trelative(projectRoot, resolvedPath) || basename(resolvedPath),\n\t\t\tlabel,\n\t\t\tcontent,\n\t\t\ttruncated,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction walkRuleFiles(\n\tdir: string,\n\tpredicate: (fileName: string) => boolean,\n): string[] {\n\tlet entries: Dirent[];\n\ttry {\n\t\tentries = readdirSync(dir, { withFileTypes: true });\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst files: string[] = [];\n\tfor (const entry of entries) {\n\t\tconst entryPath = join(dir, entry.name);\n\t\tif (entry.isDirectory()) {\n\t\t\tif (!RULE_WALK_IGNORE_DIRS.has(entry.name)) {\n\t\t\t\tfiles.push(...walkRuleFiles(entryPath, predicate));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.isFile() && predicate(entry.name)) {\n\t\t\tfiles.push(entryPath);\n\t\t}\n\t}\n\treturn files.sort((a, b) => a.localeCompare(b));\n}\n\nexport function discoverAgentRuleSources(\n\tprojectRoot: string,\n\ttargetPath?: string,\n\tincludeTarget = false,\n): AgentRuleSource[] {\n\tconst root = resolve(projectRoot);\n\tconst target = targetPath ? resolve(targetPath) : null;\n\tconst sources = new Map<string, AgentRuleSource>();\n\n\tconst addSource = (filePath: string, label: string): void => {\n\t\tconst resolvedPath = resolve(filePath);\n\t\tconst source = readRuleSource(root, resolvedPath, label);\n\t\tif (!source) {\n\t\t\treturn;\n\t\t}\n\t\tsources.set(resolvedPath, source);\n\t};\n\n\tif (target && includeTarget && existsSync(target)) {\n\t\taddSource(target, \"Existing AGENTS.md\");\n\t}\n\tfor (const candidate of [\"AGENTS.md\", \"AGENT.md\"]) {\n\t\tconst candidatePath = join(root, candidate);\n\t\tif (!target || resolve(candidatePath) !== target) {\n\t\t\taddSource(candidatePath, \"Existing Maestro agent instructions\");\n\t\t}\n\t}\n\n\tfor (const cursorRule of walkRuleFiles(\n\t\tjoin(root, \".cursor\", \"rules\"),\n\t\t(name) => isMarkdownRuleFile(name),\n\t)) {\n\t\taddSource(cursorRule, \"Cursor rule\");\n\t}\n\taddSource(join(root, \".cursorrules\"), \"Cursor rules\");\n\tfor (const claudeRule of walkRuleFiles(\n\t\troot,\n\t\t(name) => name === \"CLAUDE.md\",\n\t)) {\n\t\taddSource(claudeRule, \"Claude instructions\");\n\t}\n\taddSource(join(root, \".windsurfrules\"), \"Windsurf rules\");\n\taddSource(join(root, \".clinerules\"), \"Cline rules\");\n\taddSource(join(root, \".goosehints\"), \"Goose hints\");\n\taddSource(\n\t\tjoin(root, \".github\", \"copilot-instructions.md\"),\n\t\t\"Copilot instructions\",\n\t);\n\n\treturn Array.from(sources.values()).sort((a, b) =>\n\t\ta.relativePath.localeCompare(b.relativePath),\n\t);\n}\n\nfunction formatRuleSourceSummary(sources: AgentRuleSource[]): string {\n\tif (sources.length === 0) {\n\t\treturn \"\";\n\t}\n\tconst sourcePaths = sources.map((source) =>\n\t\tformatRulePathForHtmlComment(source.relativePath),\n\t);\n\treturn [\n\t\t\"## Imported AI Tooling Rules\",\n\t\t`<!-- Imported by maestro /init from: ${sourcePaths.join(\", \")} -->`,\n\t\t\"\",\n\t\t\"Review and fold these existing AI-tool instructions into the sections above:\",\n\t\t\"\",\n\t\t...sources.map((source) => {\n\t\t\tconst truncatedNote = source.truncated ? \" (truncated)\" : \"\";\n\t\t\treturn `- ${formatRulePathForMarkdown(source.relativePath)}: ${source.label}${truncatedNote}`;\n\t\t}),\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\nfunction formatRulePathForMarkdown(relativePath: string): string {\n\treturn JSON.stringify(relativePath);\n}\n\nfunction formatRulePathForHtmlComment(relativePath: string): string {\n\treturn JSON.stringify(relativePath).replace(/-{2,}/g, (dashes) =>\n\t\tdashes.split(\"\").join(\" \"),\n\t);\n}\n\nfunction buildAgentsInitContent(\n\tprojectName: string,\n\truleSources: AgentRuleSource[],\n): string {\n\treturn `${buildAgentsTemplate(projectName).trimEnd()}\\n\\n${formatRuleSourceSummary(ruleSources)}`;\n}\n\nfunction buildAgentsInitDiff(\n\ttargetPath: string,\n\toldContent: string,\n\tnewContent: string,\n): string {\n\treturn Diff.createTwoFilesPatch(\n\t\ttargetPath,\n\t\ttargetPath,\n\t\toldContent,\n\t\tnewContent,\n\t\t\"current\",\n\t\t\"proposed\",\n\t);\n}\n\nfunction markdownFenceFor(content: string): string {\n\tconst longestBacktickRun = Math.max(\n\t\t0,\n\t\t...(content.match(/`+/g) ?? []).map((run) => run.length),\n\t);\n\treturn \"`\".repeat(Math.max(3, longestBacktickRun + 1));\n}\n\nfunction formatRuleSourcesForPrompt(sources: AgentRuleSource[]): string {\n\tif (sources.length === 0) {\n\t\treturn \"\";\n\t}\n\tconst blocks = sources.map((source) => {\n\t\tconst fence = markdownFenceFor(source.content);\n\t\treturn [\n\t\t\t`### ${formatRulePathForMarkdown(source.relativePath)} (${source.label})`,\n\t\t\tsource.truncated\n\t\t\t\t? `The content below was truncated to ${MAX_IMPORTED_RULE_BYTES} bytes.`\n\t\t\t\t: \"\",\n\t\t\t`${fence}md`,\n\t\t\tsource.content.trimEnd(),\n\t\t\tfence,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\"\\n\");\n\t});\n\treturn [\"\", \"Existing AI tool rule files to merge:\", \"\", ...blocks].join(\n\t\t\"\\n\\n\",\n\t);\n}\n\nexport function buildAgentsInitPrompt(\n\ttargetPath: string,\n\tsources: AgentRuleSource[] = discoverAgentRuleSources(\n\t\tdirname(targetPath),\n\t\ttargetPath,\n\t\texistsSync(targetPath),\n\t),\n): string {\n\treturn `${GENERATION_PROMPT}\\n\\nTarget path: ${targetPath}${formatRuleSourcesForPrompt(sources)}`;\n}\n\nexport function handleAgentsInit(\n\tinputPath?: string,\n\toptions: AgentsInitOptions = {},\n): AgentsInitResult {\n\tconst target = resolveTargetPath(inputPath);\n\tconst directory = dirname(target);\n\tconst projectName = basename(directory);\n\tconst exists = existsSync(target);\n\tconst ruleSources = discoverAgentRuleSources(directory, target, exists);\n\tconst nextContent = buildAgentsInitContent(projectName, ruleSources);\n\tif (exists) {\n\t\tconst previousContent = readFileSync(target, \"utf-8\");\n\t\tconst diff = buildAgentsInitDiff(target, previousContent, nextContent);\n\t\tif (!options.force) {\n\t\t\treturn {\n\t\t\t\tpath: target,\n\t\t\t\taction: \"preview\",\n\t\t\t\tdiff,\n\t\t\t\tsources: ruleSources,\n\t\t\t};\n\t\t}\n\t\tmkdirSync(directory, { recursive: true });\n\t\twriteTextFileAtomic(target, nextContent, { encoding: \"utf-8\" });\n\t\treturn {\n\t\t\tpath: target,\n\t\t\taction: \"updated\",\n\t\t\tdiff,\n\t\t\tsources: ruleSources,\n\t\t};\n\t}\n\tmkdirSync(directory, { recursive: true });\n\twriteTextFileAtomic(target, nextContent, { encoding: \"utf-8\" });\n\treturn {\n\t\tpath: target,\n\t\taction: \"created\",\n\t\tsources: ruleSources,\n\t};\n}\n"]}
1
+ {"version":3,"file":"agents.js","sourceRoot":"","sources":["../../../src/cli/commands/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,UAAU,EACV,SAAS,EACT,SAAS,EACT,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,QAAQ,GACR,MAAM,SAAS,CAAC;AAEjB,OAAO,EACN,QAAQ,EACR,OAAO,EACP,UAAU,EACV,IAAI,EACJ,QAAQ,EACR,OAAO,GACP,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,E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AAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACpE,CAAC","sourcesContent":["import {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\treaddirSync,\n\trealpathSync,\n\tstatSync,\n} from \"node:fs\";\nimport type { Dirent } from \"node:fs\";\nimport {\n\tbasename,\n\tdirname,\n\tisAbsolute,\n\tjoin,\n\trelative,\n\tresolve,\n} from \"node:path\";\nimport * as Diff from \"diff\";\nimport {\n\ttype SpecialistProfileScope,\n\tcreateSpecialistProfile,\n\tdeleteSpecialistProfile,\n\tlistSpecialistProfiles,\n\tresolveSpecialistProfile,\n} from \"../../agent/specialist-profiles.js\";\nimport { writeTextFileAtomic } from \"../../utils/fs.js\";\nimport { truncateUtf8 } from \"../system-prompt.js\";\n\nconst TEMPLATE = `# Repository Guidelines\n\nUse this as the contributor quickstart for **{{PROJECT_NAME}}**.\n\n## Project Structure\n- Map the main source, test, docs, scripts, and config paths.\n- Call out generated, vendored, or build-output directories agents should not edit.\n\n## Commands\n- Install: \\`npm install\\` (or the repo's package manager).\n- Develop: \\`npm run dev\\`; Build: \\`npm run build\\`.\n- Quality: \\`npm run lint\\`, \\`npm run format\\`, and \\`npm test\\`.\n\n## Style\n- Follow the checked-in formatter and linter; keep naming consistent with nearby code.\n- Prefer small, focused changes and comments only for non-obvious behavior.\n\n## Testing\n- Add or update tests beside changed behavior.\n- Cover success, error, and boundary cases with deterministic fixtures.\n\n## Pull Requests\n- Use imperative commit subjects and keep PRs scoped.\n- Include behavior changes, linked issues, validation steps, and screenshots for UI changes.\n\n## Security\n- Do not commit secrets; document new environment variables and migrations.\n`;\n\nconst GENERATION_PROMPT = `Generate a file named AGENTS.md that serves as a contributor guide for this repository.\n\nYour goal is to produce a clear, concise, and well-structured document with descriptive headings and actionable explanations for each section. Follow the outline below, but adapt as needed—add sections if relevant, and omit those that do not apply to this project.\n\nDocument Requirements:\n- Title the document \"Repository Guidelines\".\n- Use Markdown headings (#, ##, etc.) for structure.\n- Keep the document concise; about 20 lines and 150-250 words is optimal.\n- Keep explanations short, direct, and specific to this repository.\n- Provide examples where helpful (commands, directory paths, naming patterns).\n- Maintain a professional, instructional tone.\n\nRecommended Sections:\n- Project Structure & Module Organization: Outline where source code, tests, docs, configs, and assets live.\n- Build, Test, and Development Commands: List key commands for installing, building, testing, and running locally with short explanations.\n- Coding Style & Naming Conventions: Indentation rules, style preferences, naming patterns, formatting/linting tools.\n- Testing Guidelines: Frameworks, coverage expectations, naming conventions, and how to run tests.\n- Commit & Pull Request Guidelines: Commit message conventions, PR requirements (descriptions, linked issues, screenshots), and pre-review checks.\n- (Optional) Security & Configuration Tips, Architecture Overview, or Agent-Specific Instructions if applicable.\n\nInstructions:\n- Use the available tools to inspect this repository as needed (e.g., list directories, read configs, inspect scripts) before writing.\n- If existing AI tool rule files are supplied below, preserve their intent in the generated AGENTS.md instead of ignoring or mechanically concatenating them.\n- If an existing AGENTS.md or AGENT.md is supplied below, update its guidance instead of discarding hand-written project specifics.\n- Add a short HTML comment near the top noting which AI rule sources contributed.\n- Overwrite the entire contents of AGENTS.md at the target path.\n- Keep output scoped to the single Markdown file; do not create extra files.\n- Write the final document directly to the AGENTS.md file and return a brief confirmation when done.`;\n\nconst MAX_IMPORTED_RULE_BYTES = 12_000;\nconst RULE_WALK_IGNORE_DIRS = new Set([\n\t\".git\",\n\t\".hg\",\n\t\".svn\",\n\t\"node_modules\",\n\t\"dist\",\n\t\"build\",\n\t\"coverage\",\n\t\".next\",\n\t\".turbo\",\n\t\".cache\",\n\t\"tmp\",\n]);\n\nexport interface AgentRuleSource {\n\tpath: string;\n\trelativePath: string;\n\tlabel: string;\n\tcontent: string;\n\ttruncated: boolean;\n}\n\nfunction buildAgentsTemplate(projectName: string): string {\n\treturn TEMPLATE.replace(/{{PROJECT_NAME}}/g, projectName);\n}\n\nexport interface AgentsInitOptions {\n\tforce?: boolean;\n}\n\nexport interface AgentsInitResult {\n\tpath: string;\n\taction: \"created\" | \"updated\" | \"preview\";\n\tdiff?: string;\n\tsources: AgentRuleSource[];\n}\n\nfunction resolveTargetPath(targetPath?: string): string {\n\tif (!targetPath) {\n\t\treturn join(process.cwd(), \"AGENTS.md\");\n\t}\n\tconst resolved = resolve(targetPath);\n\tif (resolved.toLowerCase().endsWith(\".md\")) {\n\t\treturn resolved;\n\t}\n\treturn join(resolved, \"AGENTS.md\");\n}\n\nfunction isMarkdownRuleFile(fileName: string): boolean {\n\tconst lower = fileName.toLowerCase();\n\treturn lower.endsWith(\".md\") || lower.endsWith(\".mdc\");\n}\n\nfunction isPathInside(root: string, candidate: string): boolean {\n\tconst relativePath = relative(root, candidate);\n\treturn (\n\t\trelativePath === \"\" ||\n\t\t(!relativePath.startsWith(\"..\") && !isAbsolute(relativePath))\n\t);\n}\n\nfunction readRuleSource(\n\tprojectRoot: string,\n\tfilePath: string,\n\tlabel: string,\n): AgentRuleSource | null {\n\ttry {\n\t\tconst resolvedPath = resolve(filePath);\n\t\tconst linkStat = lstatSync(resolvedPath);\n\t\tif (!linkStat.isFile()) {\n\t\t\treturn null;\n\t\t}\n\t\tconst rootRealPath = realpathSync(projectRoot);\n\t\tconst fileRealPath = realpathSync(resolvedPath);\n\t\tif (!isPathInside(rootRealPath, fileRealPath)) {\n\t\t\treturn null;\n\t\t}\n\t\tconst stat = statSync(resolvedPath);\n\t\tif (!stat.isFile()) {\n\t\t\treturn null;\n\t\t}\n\t\tconst raw = readFileSync(resolvedPath);\n\t\tconst truncated = raw.byteLength > MAX_IMPORTED_RULE_BYTES;\n\t\tconst content = truncated\n\t\t\t? truncateUtf8(raw, MAX_IMPORTED_RULE_BYTES).content\n\t\t\t: raw.toString(\"utf-8\");\n\t\treturn {\n\t\t\tpath: resolvedPath,\n\t\t\trelativePath:\n\t\t\t\trelative(projectRoot, resolvedPath) || basename(resolvedPath),\n\t\t\tlabel,\n\t\t\tcontent,\n\t\t\ttruncated,\n\t\t};\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction walkRuleFiles(\n\tdir: string,\n\tpredicate: (fileName: string) => boolean,\n): string[] {\n\tlet entries: Dirent[];\n\ttry {\n\t\tentries = readdirSync(dir, { withFileTypes: true });\n\t} catch {\n\t\treturn [];\n\t}\n\n\tconst files: string[] = [];\n\tfor (const entry of entries) {\n\t\tconst entryPath = join(dir, entry.name);\n\t\tif (entry.isDirectory()) {\n\t\t\tif (!RULE_WALK_IGNORE_DIRS.has(entry.name)) {\n\t\t\t\tfiles.push(...walkRuleFiles(entryPath, predicate));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (entry.isFile() && predicate(entry.name)) {\n\t\t\tfiles.push(entryPath);\n\t\t}\n\t}\n\treturn files.sort((a, b) => a.localeCompare(b));\n}\n\nexport function discoverAgentRuleSources(\n\tprojectRoot: string,\n\ttargetPath?: string,\n\tincludeTarget = false,\n): AgentRuleSource[] {\n\tconst root = resolve(projectRoot);\n\tconst target = targetPath ? resolve(targetPath) : null;\n\tconst sources = new Map<string, AgentRuleSource>();\n\n\tconst addSource = (filePath: string, label: string): void => {\n\t\tconst resolvedPath = resolve(filePath);\n\t\tconst source = readRuleSource(root, resolvedPath, label);\n\t\tif (!source) {\n\t\t\treturn;\n\t\t}\n\t\tsources.set(resolvedPath, source);\n\t};\n\n\tif (target && includeTarget && existsSync(target)) {\n\t\taddSource(target, \"Existing AGENTS.md\");\n\t}\n\tfor (const candidate of [\"AGENTS.md\", \"AGENT.md\"]) {\n\t\tconst candidatePath = join(root, candidate);\n\t\tif (!target || resolve(candidatePath) !== target) {\n\t\t\taddSource(candidatePath, \"Existing Maestro agent instructions\");\n\t\t}\n\t}\n\n\tfor (const cursorRule of walkRuleFiles(\n\t\tjoin(root, \".cursor\", \"rules\"),\n\t\t(name) => isMarkdownRuleFile(name),\n\t)) {\n\t\taddSource(cursorRule, \"Cursor rule\");\n\t}\n\taddSource(join(root, \".cursorrules\"), \"Cursor rules\");\n\tfor (const claudeRule of walkRuleFiles(\n\t\troot,\n\t\t(name) => name === \"CLAUDE.md\",\n\t)) {\n\t\taddSource(claudeRule, \"Claude instructions\");\n\t}\n\taddSource(join(root, \".windsurfrules\"), \"Windsurf rules\");\n\taddSource(join(root, \".clinerules\"), \"Cline rules\");\n\taddSource(join(root, \".goosehints\"), \"Goose hints\");\n\taddSource(\n\t\tjoin(root, \".github\", \"copilot-instructions.md\"),\n\t\t\"Copilot instructions\",\n\t);\n\n\treturn Array.from(sources.values()).sort((a, b) =>\n\t\ta.relativePath.localeCompare(b.relativePath),\n\t);\n}\n\nfunction formatRuleSourceSummary(sources: AgentRuleSource[]): string {\n\tif (sources.length === 0) {\n\t\treturn \"\";\n\t}\n\tconst sourcePaths = sources.map((source) =>\n\t\tformatRulePathForHtmlComment(source.relativePath),\n\t);\n\treturn [\n\t\t\"## Imported AI Tooling Rules\",\n\t\t`<!-- Imported by maestro /init from: ${sourcePaths.join(\", \")} -->`,\n\t\t\"\",\n\t\t\"Review and fold these existing AI-tool instructions into the sections above:\",\n\t\t\"\",\n\t\t...sources.map((source) => {\n\t\t\tconst truncatedNote = source.truncated ? \" (truncated)\" : \"\";\n\t\t\treturn `- ${formatRulePathForMarkdown(source.relativePath)}: ${source.label}${truncatedNote}`;\n\t\t}),\n\t\t\"\",\n\t].join(\"\\n\");\n}\n\nfunction formatRulePathForMarkdown(relativePath: string): string {\n\treturn JSON.stringify(relativePath);\n}\n\nfunction formatRulePathForHtmlComment(relativePath: string): string {\n\treturn JSON.stringify(relativePath).replace(/-{2,}/g, (dashes) =>\n\t\tdashes.split(\"\").join(\" \"),\n\t);\n}\n\nfunction buildAgentsInitContent(\n\tprojectName: string,\n\truleSources: AgentRuleSource[],\n): string {\n\treturn `${buildAgentsTemplate(projectName).trimEnd()}\\n\\n${formatRuleSourceSummary(ruleSources)}`;\n}\n\nfunction buildAgentsInitDiff(\n\ttargetPath: string,\n\toldContent: string,\n\tnewContent: string,\n): string {\n\treturn Diff.createTwoFilesPatch(\n\t\ttargetPath,\n\t\ttargetPath,\n\t\toldContent,\n\t\tnewContent,\n\t\t\"current\",\n\t\t\"proposed\",\n\t);\n}\n\nfunction markdownFenceFor(content: string): string {\n\tconst longestBacktickRun = Math.max(\n\t\t0,\n\t\t...(content.match(/`+/g) ?? []).map((run) => run.length),\n\t);\n\treturn \"`\".repeat(Math.max(3, longestBacktickRun + 1));\n}\n\nfunction formatRuleSourcesForPrompt(sources: AgentRuleSource[]): string {\n\tif (sources.length === 0) {\n\t\treturn \"\";\n\t}\n\tconst blocks = sources.map((source) => {\n\t\tconst fence = markdownFenceFor(source.content);\n\t\treturn [\n\t\t\t`### ${formatRulePathForMarkdown(source.relativePath)} (${source.label})`,\n\t\t\tsource.truncated\n\t\t\t\t? `The content below was truncated to ${MAX_IMPORTED_RULE_BYTES} bytes.`\n\t\t\t\t: \"\",\n\t\t\t`${fence}md`,\n\t\t\tsource.content.trimEnd(),\n\t\t\tfence,\n\t\t]\n\t\t\t.filter(Boolean)\n\t\t\t.join(\"\\n\");\n\t});\n\treturn [\"\", \"Existing AI tool rule files to merge:\", \"\", ...blocks].join(\n\t\t\"\\n\\n\",\n\t);\n}\n\nexport function buildAgentsInitPrompt(\n\ttargetPath: string,\n\tsources: AgentRuleSource[] = discoverAgentRuleSources(\n\t\tdirname(targetPath),\n\t\ttargetPath,\n\t\texistsSync(targetPath),\n\t),\n): string {\n\treturn `${GENERATION_PROMPT}\\n\\nTarget path: ${targetPath}${formatRuleSourcesForPrompt(sources)}`;\n}\n\nexport function handleAgentsInit(\n\tinputPath?: string,\n\toptions: AgentsInitOptions = {},\n): AgentsInitResult {\n\tconst target = resolveTargetPath(inputPath);\n\tconst directory = dirname(target);\n\tconst projectName = basename(directory);\n\tconst exists = existsSync(target);\n\tconst ruleSources = discoverAgentRuleSources(directory, target, exists);\n\tconst nextContent = buildAgentsInitContent(projectName, ruleSources);\n\tif (exists) {\n\t\tconst previousContent = readFileSync(target, \"utf-8\");\n\t\tconst diff = buildAgentsInitDiff(target, previousContent, nextContent);\n\t\tif (!options.force) {\n\t\t\treturn {\n\t\t\t\tpath: target,\n\t\t\t\taction: \"preview\",\n\t\t\t\tdiff,\n\t\t\t\tsources: ruleSources,\n\t\t\t};\n\t\t}\n\t\tmkdirSync(directory, { recursive: true });\n\t\twriteTextFileAtomic(target, nextContent, { encoding: \"utf-8\" });\n\t\treturn {\n\t\t\tpath: target,\n\t\t\taction: \"updated\",\n\t\t\tdiff,\n\t\t\tsources: ruleSources,\n\t\t};\n\t}\n\tmkdirSync(directory, { recursive: true });\n\twriteTextFileAtomic(target, nextContent, { encoding: \"utf-8\" });\n\treturn {\n\t\tpath: target,\n\t\taction: \"created\",\n\t\tsources: ruleSources,\n\t};\n}\n\nexport function handleAgentsProfileCommand(\n\targs: readonly string[],\n\toptions: { json?: boolean; force?: boolean } = {},\n): void {\n\tconst json = options.json === true || args.includes(\"--json\");\n\tconst force = options.force === true || args.includes(\"--force\");\n\tconst filteredArgs = args.filter(\n\t\t(arg) => arg !== \"--json\" && arg !== \"--force\",\n\t);\n\tconst action = filteredArgs[0] ?? \"list\";\n\tswitch (action) {\n\t\tcase \"list\": {\n\t\t\tconst profiles = listSpecialistProfiles();\n\t\t\tif (json) {\n\t\t\t\tconsole.log(JSON.stringify(profiles, null, 2));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (profiles.length === 0) {\n\t\t\t\tconsole.log(\"No specialist profiles found.\");\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const profile of profiles) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`${profile.name} (${profile.scope})${profile.description ? ` - ${profile.description}` : \"\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tcase \"show\": {\n\t\t\tconst name = filteredArgs[1];\n\t\t\tif (!name) throw new Error(\"agents profile show requires a name\");\n\t\t\tconst profile = resolveSpecialistProfile(name);\n\t\t\tif (!profile) throw new Error(`specialist profile not found: ${name}`);\n\t\t\tif (json) {\n\t\t\t\tconsole.log(JSON.stringify(profile, null, 2));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconsole.log(`# ${profile.name}`);\n\t\t\tif (profile.description) console.log(`\\n${profile.description}`);\n\t\t\tconsole.log(`\\nScope: ${profile.scope}`);\n\t\t\tconsole.log(`Path: ${profile.path}`);\n\t\t\tconsole.log(`\\n${profile.prompt}`);\n\t\t\treturn;\n\t\t}\n\t\tcase \"create\": {\n\t\t\tconst name = filteredArgs[1];\n\t\t\tif (!name) throw new Error(\"agents profile create requires a name\");\n\t\t\tconst parsed = parseProfileCreateArgs(filteredArgs.slice(2));\n\t\t\tconst profile = createSpecialistProfile({\n\t\t\t\tname,\n\t\t\t\tdescription: parsed.description,\n\t\t\t\tprompt: parsed.prompt,\n\t\t\t\ttools: parsed.tools,\n\t\t\t\tmodel: parsed.model,\n\t\t\t\tscope: parsed.scope,\n\t\t\t\toverwrite: force,\n\t\t\t});\n\t\t\tif (json) {\n\t\t\t\tconsole.log(JSON.stringify(profile, null, 2));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconsole.log(\n\t\t\t\t`Created specialist profile ${profile.name} at ${profile.path}.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tcase \"delete\": {\n\t\t\tconst name = filteredArgs[1];\n\t\t\tif (!name) throw new Error(\"agents profile delete requires a name\");\n\t\t\tconst { scope } = parseProfileDeleteArgs(filteredArgs.slice(2));\n\t\t\tconst deleted = deleteSpecialistProfile({ name, scope });\n\t\t\tif (json) {\n\t\t\t\tconsole.log(JSON.stringify({ name, scope, deleted }, null, 2));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconsole.log(\n\t\t\t\tdeleted\n\t\t\t\t\t? `Deleted specialist profile ${name} (${scope}).`\n\t\t\t\t\t: `No specialist profile ${name} found in ${scope} scope.`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown agents profile action: ${action}. Use list, show, create, or delete.`,\n\t\t\t);\n\t}\n}\n\nfunction parseProfileCreateArgs(args: readonly string[]): {\n\tdescription?: string;\n\tprompt: string;\n\ttools?: string[];\n\tmodel?: string;\n\tscope?: SpecialistProfileScope;\n} {\n\tlet description: string | undefined;\n\tlet tools: string[] | undefined;\n\tlet model: string | undefined;\n\tlet scope: SpecialistProfileScope | undefined;\n\tconst promptParts: string[] = [];\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst arg = args[index];\n\t\tconst next = args[index + 1];\n\t\tif (arg === \"--description\" && next) {\n\t\t\tdescription = next;\n\t\t\tindex++;\n\t\t} else if (arg === \"--tools\" && next) {\n\t\t\ttools = next\n\t\t\t\t.split(\",\")\n\t\t\t\t.map((tool) => tool.trim())\n\t\t\t\t.filter(Boolean);\n\t\t\tindex++;\n\t\t} else if (arg === \"--model\" && next) {\n\t\t\tmodel = next;\n\t\t\tindex++;\n\t\t} else if (arg === \"--scope\" && next) {\n\t\t\tscope = parseProfileScope(next);\n\t\t\tif (!scope) throw new Error(`invalid profile scope: ${next}`);\n\t\t\tindex++;\n\t\t} else if (arg) {\n\t\t\tpromptParts.push(arg);\n\t\t}\n\t}\n\tconst prompt = promptParts.join(\" \").trim();\n\tif (!prompt) {\n\t\tthrow new Error(\"agents profile create requires prompt text\");\n\t}\n\treturn { description, prompt, tools, model, scope };\n}\n\nfunction parseProfileDeleteArgs(args: readonly string[]): {\n\tscope: SpecialistProfileScope;\n} {\n\tlet scope: SpecialistProfileScope = \"project\";\n\tfor (let index = 0; index < args.length; index++) {\n\t\tconst arg = args[index];\n\t\tconst next = args[index + 1];\n\t\tif (arg === \"--scope\" && next) {\n\t\t\tconst parsed = parseProfileScope(next);\n\t\t\tif (!parsed) throw new Error(`invalid profile scope: ${next}`);\n\t\t\tscope = parsed;\n\t\t\tindex++;\n\t\t} else if (arg?.startsWith(\"--scope=\")) {\n\t\t\tconst value = arg.slice(\"--scope=\".length);\n\t\t\tconst parsed = parseProfileScope(value);\n\t\t\tif (!parsed) throw new Error(`invalid profile scope: ${value}`);\n\t\t\tscope = parsed;\n\t\t} else if (arg) {\n\t\t\tthrow new Error(`unexpected agents profile delete argument: ${arg}`);\n\t\t}\n\t}\n\treturn { scope };\n}\n\nfunction parseProfileScope(\n\tvalue: string | undefined,\n): SpecialistProfileScope | undefined {\n\treturn value === \"project\" || value === \"user\" ? value : undefined;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ export declare function handleMissionCommand(subcommand: string | undefined, args: readonly string[], options?: {
2
+ json?: boolean;
3
+ }): Promise<void>;
4
+ //# sourceMappingURL=mission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/mission.ts"],"names":[],"mappings":"AAqBA,wBAAsB,oBAAoB,CACzC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,GAC9B,OAAO,CAAC,IAAI,CAAC,CAsBf"}
@@ -0,0 +1,196 @@
1
+ import { existsSync, readdirSync } from "node:fs";
2
+ import chalk from "chalk";
3
+ import { getMissionArtifactLayout, initializeMissionArtifacts, summarizeMissionSnapshot, validateMissionArtifactContent, } from "../../agent/mission-artifacts.js";
4
+ import { MISSION_MANIFEST_VERSION, } from "../../agent/mission-manifest.js";
5
+ import { MissionStore, getMissionStatePath, listMissionStoreSnapshots, } from "../../agent/mission-store.js";
6
+ import { readJsonFile, readTextFile, writeJsonFile } from "../../utils/fs.js";
7
+ export async function handleMissionCommand(subcommand, args, options = {}) {
8
+ switch (subcommand ?? "status") {
9
+ case "init":
10
+ handleMissionInit(args, options);
11
+ return;
12
+ case "status":
13
+ handleMissionStatus(args, options);
14
+ return;
15
+ case "record":
16
+ handleMissionRecord(args, options);
17
+ return;
18
+ case "set-state":
19
+ handleMissionSetState(args, options);
20
+ return;
21
+ case "validate":
22
+ handleMissionValidate(args, options);
23
+ return;
24
+ default:
25
+ throw new Error(`Unknown mission subcommand: ${subcommand}. Use init, status, record, set-state, or validate.`);
26
+ }
27
+ }
28
+ function handleMissionInit(args, options) {
29
+ const missionId = args[0];
30
+ if (!missionId) {
31
+ throw new Error("mission init requires a mission id");
32
+ }
33
+ const title = args.slice(1).join(" ").trim() || missionId;
34
+ const layout = getMissionArtifactLayout(missionId);
35
+ const statePath = getMissionStatePath(missionId);
36
+ if (!existsSync(statePath) &&
37
+ existsSync(layout.missionDir) &&
38
+ readdirSync(layout.missionDir).length > 0) {
39
+ throw new Error(`mission state missing for existing mission: ${missionId}. Restore state.json instead of re-running init.`);
40
+ }
41
+ const stateExists = existsSync(statePath);
42
+ const snapshot = stateExists
43
+ ? MissionStore.load(missionId).getSnapshot()
44
+ : MissionStore.create({ missionId, title }).save();
45
+ if (snapshot.sourceMissionId &&
46
+ snapshot.sourceMissionId !== missionId.trim() &&
47
+ snapshot.missionId !== missionId.trim()) {
48
+ throw new Error(`missionId "${missionId.trim()}" collides with existing mission "${snapshot.sourceMissionId}"`);
49
+ }
50
+ const shouldSeedFeaturesArtifact = stateExists &&
51
+ shouldSeedFeaturesArtifactFromState(layout.featuresJson, snapshot);
52
+ const initializedLayout = initializeMissionArtifacts({ missionId, title });
53
+ if (shouldSeedFeaturesArtifact) {
54
+ writeJsonFile(initializedLayout.featuresJson, {
55
+ version: MISSION_MANIFEST_VERSION,
56
+ missionId: snapshot.missionId,
57
+ milestones: [],
58
+ features: snapshot.features,
59
+ createdAt: snapshot.createdAt,
60
+ updatedAt: snapshot.updatedAt,
61
+ });
62
+ }
63
+ if (options.json) {
64
+ console.log(JSON.stringify({ layout: initializedLayout, snapshot }, null, 2));
65
+ return;
66
+ }
67
+ console.log(chalk.bold("Mission initialized"));
68
+ console.log(`id: ${snapshot.missionId}`);
69
+ console.log(`dir: ${initializedLayout.missionDir}`);
70
+ }
71
+ function shouldSeedFeaturesArtifactFromState(featuresPath, snapshot) {
72
+ if (!existsSync(featuresPath))
73
+ return true;
74
+ if (snapshot.features.length === 0)
75
+ return false;
76
+ const manifest = readJsonFile(featuresPath, {
77
+ fallback: null,
78
+ rotateOnParseFail: true,
79
+ });
80
+ return !manifest?.features?.length;
81
+ }
82
+ function handleMissionStatus(args, options) {
83
+ const missionId = args[0];
84
+ if (missionId) {
85
+ const snapshot = MissionStore.load(missionId).getSnapshot();
86
+ if (options.json) {
87
+ console.log(JSON.stringify(snapshot, null, 2));
88
+ return;
89
+ }
90
+ console.log(summarizeMissionSnapshot(snapshot));
91
+ return;
92
+ }
93
+ const snapshots = listMissionStoreSnapshots();
94
+ if (options.json) {
95
+ console.log(JSON.stringify(snapshots, null, 2));
96
+ return;
97
+ }
98
+ if (snapshots.length === 0) {
99
+ console.log(chalk.dim("No missions found."));
100
+ return;
101
+ }
102
+ for (const snapshot of snapshots) {
103
+ console.log(summarizeMissionSnapshot(snapshot));
104
+ console.log("");
105
+ }
106
+ }
107
+ function handleMissionRecord(args, options) {
108
+ const missionId = args[0];
109
+ if (!missionId) {
110
+ throw new Error("mission record requires a mission id");
111
+ }
112
+ const message = args.slice(1).join(" ").trim();
113
+ if (!message) {
114
+ throw new Error("mission record requires a message");
115
+ }
116
+ const snapshot = MissionStore.load(missionId).appendProgress({
117
+ type: "note",
118
+ message,
119
+ });
120
+ if (options.json) {
121
+ console.log(JSON.stringify(snapshot, null, 2));
122
+ return;
123
+ }
124
+ console.log(`Recorded mission note for ${snapshot.missionId}.`);
125
+ }
126
+ function handleMissionSetState(args, options) {
127
+ const missionId = args[0];
128
+ const state = args[1];
129
+ if (!missionId || !state) {
130
+ throw new Error("mission set-state requires <mission-id> <state>");
131
+ }
132
+ if (!isMissionState(state)) {
133
+ throw new Error(`invalid mission state: ${state}`);
134
+ }
135
+ const message = args.slice(2).join(" ").trim() || undefined;
136
+ const snapshot = MissionStore.load(missionId).setState(state, message);
137
+ if (options.json) {
138
+ console.log(JSON.stringify(snapshot, null, 2));
139
+ return;
140
+ }
141
+ console.log(`Mission ${snapshot.missionId} is now ${snapshot.state}.`);
142
+ }
143
+ function handleMissionValidate(args, options) {
144
+ const missionId = args[0];
145
+ if (!missionId) {
146
+ throw new Error("mission validate requires a mission id");
147
+ }
148
+ const layout = getMissionArtifactLayout(missionId);
149
+ const requiredFiles = [
150
+ layout.featuresJson,
151
+ layout.validationStateJson,
152
+ layout.servicesYaml,
153
+ layout.stateJson,
154
+ ];
155
+ const results = requiredFiles.map((path) => {
156
+ try {
157
+ return {
158
+ path,
159
+ ...validateMissionArtifactContent(path, readTextFile(path)),
160
+ };
161
+ }
162
+ catch {
163
+ return {
164
+ path,
165
+ ok: false,
166
+ message: "Missing required mission artifact",
167
+ };
168
+ }
169
+ });
170
+ const failed = results.filter((result) => !result.ok);
171
+ if (failed.length > 0) {
172
+ process.exitCode = 1;
173
+ }
174
+ if (options.json) {
175
+ console.log(JSON.stringify(results, null, 2));
176
+ return;
177
+ }
178
+ if (failed.length === 0) {
179
+ console.log(`Mission ${missionId} artifacts are valid.`);
180
+ return;
181
+ }
182
+ for (const result of failed) {
183
+ console.log(chalk.red(`${result.path}: ${"message" in result ? result.message : "invalid"}`));
184
+ }
185
+ }
186
+ function isMissionState(value) {
187
+ return [
188
+ "awaiting-input",
189
+ "ready",
190
+ "running",
191
+ "blocked",
192
+ "completed",
193
+ "failed",
194
+ ].includes(value);
195
+ }
196
+ //# sourceMappingURL=mission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mission.js","sourceRoot":"","sources":["../../../src/cli/commands/mission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACN,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,8BAA8B,GAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,wBAAwB,GAExB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAEN,YAAY,EAE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AK,CAAC,GAAG,CACR,GAAG,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAAE,CACrE,CACD,CAAC;IACH,CAAC;AACF,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACpC,OAAO;QACN,gBAAgB;QAChB,OAAO;QACP,SAAS;QACT,SAAS;QACT,WAAW;QACX,QAAQ;KACR,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC","sourcesContent":["import { existsSync, readdirSync } from \"node:fs\";\nimport chalk from \"chalk\";\nimport {\n\tgetMissionArtifactLayout,\n\tinitializeMissionArtifacts,\n\tsummarizeMissionSnapshot,\n\tvalidateMissionArtifactContent,\n} from \"../../agent/mission-artifacts.js\";\nimport {\n\tMISSION_MANIFEST_VERSION,\n\ttype MissionManifest,\n} from \"../../agent/mission-manifest.js\";\nimport {\n\ttype MissionState,\n\tMissionStore,\n\ttype MissionStoreSnapshot,\n\tgetMissionStatePath,\n\tlistMissionStoreSnapshots,\n} from \"../../agent/mission-store.js\";\nimport { readJsonFile, readTextFile, writeJsonFile } from \"../../utils/fs.js\";\n\nexport async function handleMissionCommand(\n\tsubcommand: string | undefined,\n\targs: readonly string[],\n\toptions: { json?: boolean } = {},\n): Promise<void> {\n\tswitch (subcommand ?? \"status\") {\n\t\tcase \"init\":\n\t\t\thandleMissionInit(args, options);\n\t\t\treturn;\n\t\tcase \"status\":\n\t\t\thandleMissionStatus(args, options);\n\t\t\treturn;\n\t\tcase \"record\":\n\t\t\thandleMissionRecord(args, options);\n\t\t\treturn;\n\t\tcase \"set-state\":\n\t\t\thandleMissionSetState(args, options);\n\t\t\treturn;\n\t\tcase \"validate\":\n\t\t\thandleMissionValidate(args, options);\n\t\t\treturn;\n\t\tdefault:\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown mission subcommand: ${subcommand}. Use init, status, record, set-state, or validate.`,\n\t\t\t);\n\t}\n}\n\nfunction handleMissionInit(\n\targs: readonly string[],\n\toptions: { json?: boolean },\n): void {\n\tconst missionId = args[0];\n\tif (!missionId) {\n\t\tthrow new Error(\"mission init requires a mission id\");\n\t}\n\tconst title = args.slice(1).join(\" \").trim() || missionId;\n\tconst layout = getMissionArtifactLayout(missionId);\n\tconst statePath = getMissionStatePath(missionId);\n\tif (\n\t\t!existsSync(statePath) &&\n\t\texistsSync(layout.missionDir) &&\n\t\treaddirSync(layout.missionDir).length > 0\n\t) {\n\t\tthrow new Error(\n\t\t\t`mission state missing for existing mission: ${missionId}. Restore state.json instead of re-running init.`,\n\t\t);\n\t}\n\tconst stateExists = existsSync(statePath);\n\tconst snapshot = stateExists\n\t\t? MissionStore.load(missionId).getSnapshot()\n\t\t: MissionStore.create({ missionId, title }).save();\n\tif (\n\t\tsnapshot.sourceMissionId &&\n\t\tsnapshot.sourceMissionId !== missionId.trim() &&\n\t\tsnapshot.missionId !== missionId.trim()\n\t) {\n\t\tthrow new Error(\n\t\t\t`missionId \"${missionId.trim()}\" collides with existing mission \"${snapshot.sourceMissionId}\"`,\n\t\t);\n\t}\n\tconst shouldSeedFeaturesArtifact =\n\t\tstateExists &&\n\t\tshouldSeedFeaturesArtifactFromState(layout.featuresJson, snapshot);\n\tconst initializedLayout = initializeMissionArtifacts({ missionId, title });\n\tif (shouldSeedFeaturesArtifact) {\n\t\twriteJsonFile(initializedLayout.featuresJson, {\n\t\t\tversion: MISSION_MANIFEST_VERSION,\n\t\t\tmissionId: snapshot.missionId,\n\t\t\tmilestones: [],\n\t\t\tfeatures: snapshot.features,\n\t\t\tcreatedAt: snapshot.createdAt,\n\t\t\tupdatedAt: snapshot.updatedAt,\n\t\t});\n\t}\n\tif (options.json) {\n\t\tconsole.log(\n\t\t\tJSON.stringify({ layout: initializedLayout, snapshot }, null, 2),\n\t\t);\n\t\treturn;\n\t}\n\tconsole.log(chalk.bold(\"Mission initialized\"));\n\tconsole.log(`id: ${snapshot.missionId}`);\n\tconsole.log(`dir: ${initializedLayout.missionDir}`);\n}\n\nfunction shouldSeedFeaturesArtifactFromState(\n\tfeaturesPath: string,\n\tsnapshot: MissionStoreSnapshot,\n): boolean {\n\tif (!existsSync(featuresPath)) return true;\n\tif (snapshot.features.length === 0) return false;\n\tconst manifest = readJsonFile<MissionManifest | null>(featuresPath, {\n\t\tfallback: null,\n\t\trotateOnParseFail: true,\n\t});\n\treturn !manifest?.features?.length;\n}\n\nfunction handleMissionStatus(\n\targs: readonly string[],\n\toptions: { json?: boolean },\n): void {\n\tconst missionId = args[0];\n\tif (missionId) {\n\t\tconst snapshot = MissionStore.load(missionId).getSnapshot();\n\t\tif (options.json) {\n\t\t\tconsole.log(JSON.stringify(snapshot, null, 2));\n\t\t\treturn;\n\t\t}\n\t\tconsole.log(summarizeMissionSnapshot(snapshot));\n\t\treturn;\n\t}\n\tconst snapshots = listMissionStoreSnapshots();\n\tif (options.json) {\n\t\tconsole.log(JSON.stringify(snapshots, null, 2));\n\t\treturn;\n\t}\n\tif (snapshots.length === 0) {\n\t\tconsole.log(chalk.dim(\"No missions found.\"));\n\t\treturn;\n\t}\n\tfor (const snapshot of snapshots) {\n\t\tconsole.log(summarizeMissionSnapshot(snapshot));\n\t\tconsole.log(\"\");\n\t}\n}\n\nfunction handleMissionRecord(\n\targs: readonly string[],\n\toptions: { json?: boolean },\n): void {\n\tconst missionId = args[0];\n\tif (!missionId) {\n\t\tthrow new Error(\"mission record requires a mission id\");\n\t}\n\tconst message = args.slice(1).join(\" \").trim();\n\tif (!message) {\n\t\tthrow new Error(\"mission record requires a message\");\n\t}\n\tconst snapshot = MissionStore.load(missionId).appendProgress({\n\t\ttype: \"note\",\n\t\tmessage,\n\t});\n\tif (options.json) {\n\t\tconsole.log(JSON.stringify(snapshot, null, 2));\n\t\treturn;\n\t}\n\tconsole.log(`Recorded mission note for ${snapshot.missionId}.`);\n}\n\nfunction handleMissionSetState(\n\targs: readonly string[],\n\toptions: { json?: boolean },\n): void {\n\tconst missionId = args[0];\n\tconst state = args[1] as MissionState | undefined;\n\tif (!missionId || !state) {\n\t\tthrow new Error(\"mission set-state requires <mission-id> <state>\");\n\t}\n\tif (!isMissionState(state)) {\n\t\tthrow new Error(`invalid mission state: ${state}`);\n\t}\n\tconst message = args.slice(2).join(\" \").trim() || undefined;\n\tconst snapshot = MissionStore.load(missionId).setState(state, message);\n\tif (options.json) {\n\t\tconsole.log(JSON.stringify(snapshot, null, 2));\n\t\treturn;\n\t}\n\tconsole.log(`Mission ${snapshot.missionId} is now ${snapshot.state}.`);\n}\n\nfunction handleMissionValidate(\n\targs: readonly string[],\n\toptions: { json?: boolean },\n): void {\n\tconst missionId = args[0];\n\tif (!missionId) {\n\t\tthrow new Error(\"mission validate requires a mission id\");\n\t}\n\tconst layout = getMissionArtifactLayout(missionId);\n\tconst requiredFiles = [\n\t\tlayout.featuresJson,\n\t\tlayout.validationStateJson,\n\t\tlayout.servicesYaml,\n\t\tlayout.stateJson,\n\t];\n\tconst results = requiredFiles.map((path) => {\n\t\ttry {\n\t\t\treturn {\n\t\t\t\tpath,\n\t\t\t\t...validateMissionArtifactContent(path, readTextFile(path)),\n\t\t\t};\n\t\t} catch {\n\t\t\treturn {\n\t\t\t\tpath,\n\t\t\t\tok: false as const,\n\t\t\t\tmessage: \"Missing required mission artifact\",\n\t\t\t};\n\t\t}\n\t});\n\tconst failed = results.filter((result) => !result.ok);\n\tif (failed.length > 0) {\n\t\tprocess.exitCode = 1;\n\t}\n\tif (options.json) {\n\t\tconsole.log(JSON.stringify(results, null, 2));\n\t\treturn;\n\t}\n\tif (failed.length === 0) {\n\t\tconsole.log(`Mission ${missionId} artifacts are valid.`);\n\t\treturn;\n\t}\n\tfor (const result of failed) {\n\t\tconsole.log(\n\t\t\tchalk.red(\n\t\t\t\t`${result.path}: ${\"message\" in result ? result.message : \"invalid\"}`,\n\t\t\t),\n\t\t);\n\t}\n}\n\nfunction isMissionState(value: string): value is MissionState {\n\treturn [\n\t\t\"awaiting-input\",\n\t\t\"ready\",\n\t\t\"running\",\n\t\t\"blocked\",\n\t\t\"completed\",\n\t\t\"failed\",\n\t].includes(value);\n}\n"]}
@@ -0,0 +1,10 @@
1
+ interface ValueOptions {
2
+ format?: string;
3
+ outputDir?: string;
4
+ sessionDir?: string;
5
+ telemetryPath?: string;
6
+ writeArtifacts?: boolean;
7
+ }
8
+ export declare function handleValueCommand(period?: string, options?: ValueOptions): Promise<void>;
9
+ export {};
10
+ //# sourceMappingURL=value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/value.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,wBAAsB,kBAAkB,CACvC,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,GAAE,YAAiB,GACxB,OAAO,CAAC,IAAI,CAAC,CAiCf"}
@@ -0,0 +1,33 @@
1
+ import { buildCustomerValueReport, formatCustomerValueMarkdown, formatCustomerValueReport, writeCustomerValueArtifacts, } from "../../customer-value/report.js";
2
+ export async function handleValueCommand(period, options = {}) {
3
+ const report = await buildCustomerValueReport({
4
+ period,
5
+ sessionDir: options.sessionDir,
6
+ telemetryPath: options.telemetryPath,
7
+ });
8
+ const artifacts = options.writeArtifacts
9
+ ? await writeCustomerValueArtifacts(report, {
10
+ outputDir: options.outputDir,
11
+ })
12
+ : undefined;
13
+ if (options.format === "json") {
14
+ console.log(JSON.stringify(artifacts ? { report, artifacts } : report, null, 2));
15
+ return;
16
+ }
17
+ if (options.format === "md" || options.format === "markdown") {
18
+ console.log(formatCustomerValueMarkdown(report));
19
+ if (artifacts) {
20
+ console.log(`\nSaved value artifact manifest: ${artifacts.manifestPath}`);
21
+ }
22
+ return;
23
+ }
24
+ console.log(formatCustomerValueReport(report));
25
+ if (artifacts) {
26
+ console.log("");
27
+ console.log(`Saved value artifacts: ${artifacts.outputDir}`);
28
+ console.log(`Manifest: ${artifacts.manifestPath}`);
29
+ console.log(`Report JSON: ${artifacts.reportJsonPath}`);
30
+ console.log(`Report Markdown: ${artifacts.reportMarkdownPath}`);
31
+ }
32
+ }
33
+ //# sourceMappingURL=value.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.js","sourceRoot":"","sources":["../../../src/cli/commands/value.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,2BAA2B,GAC3B,MAAM,gCAAgC,CAAC;AAUxC,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACvC,MAAe,EACf,UAAwB,EAAE;IAE1B,MAAM,MAAM,GAAG,MAAM,wBAAwB,CAAC;QAC7C,MAAM;QACN,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,aAAa,EAAE,OAAO,CAAC,aAAa;KACpC,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,OAAO,CAAC,cAAc;QACvC,CAAC,CAAC,MAAM,2BAA2B,CAAC,MAAM,EAAE;YAC1C,SAAS,EAAE,OAAO,CAAC,SAAS;SAC5B,CAAC;QACH,CAAC,CAAC,SAAS,CAAC;IAEb,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CACV,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACnE,CAAC;QACF,OAAO;IACR,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC,CAAC;QACjD,IAAI,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,oCAAoC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO;IACR,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,IAAI,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,0BAA0B,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7D,OAAO,CAAC,GAAG,CAAC,aAAa,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,gBAAgB,SAAS,CAAC,cAAc,EAAE,CAAC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,oBAAoB,SAAS,CAAC,kBAAkB,EAAE,CAAC,CAAC;IACjE,CAAC;AACF,CAAC","sourcesContent":["import {\n\tbuildCustomerValueReport,\n\tformatCustomerValueMarkdown,\n\tformatCustomerValueReport,\n\twriteCustomerValueArtifacts,\n} from \"../../customer-value/report.js\";\n\ninterface ValueOptions {\n\tformat?: string;\n\toutputDir?: string;\n\tsessionDir?: string;\n\ttelemetryPath?: string;\n\twriteArtifacts?: boolean;\n}\n\nexport async function handleValueCommand(\n\tperiod?: string,\n\toptions: ValueOptions = {},\n): Promise<void> {\n\tconst report = await buildCustomerValueReport({\n\t\tperiod,\n\t\tsessionDir: options.sessionDir,\n\t\ttelemetryPath: options.telemetryPath,\n\t});\n\tconst artifacts = options.writeArtifacts\n\t\t? await writeCustomerValueArtifacts(report, {\n\t\t\t\toutputDir: options.outputDir,\n\t\t\t})\n\t\t: undefined;\n\n\tif (options.format === \"json\") {\n\t\tconsole.log(\n\t\t\tJSON.stringify(artifacts ? { report, artifacts } : report, null, 2),\n\t\t);\n\t\treturn;\n\t}\n\tif (options.format === \"md\" || options.format === \"markdown\") {\n\t\tconsole.log(formatCustomerValueMarkdown(report));\n\t\tif (artifacts) {\n\t\t\tconsole.log(`\\nSaved value artifact manifest: ${artifacts.manifestPath}`);\n\t\t}\n\t\treturn;\n\t}\n\tconsole.log(formatCustomerValueReport(report));\n\tif (artifacts) {\n\t\tconsole.log(\"\");\n\t\tconsole.log(`Saved value artifacts: ${artifacts.outputDir}`);\n\t\tconsole.log(`Manifest: ${artifacts.manifestPath}`);\n\t\tconsole.log(`Report JSON: ${artifacts.reportJsonPath}`);\n\t\tconsole.log(`Report Markdown: ${artifacts.reportMarkdownPath}`);\n\t}\n}\n"]}