@entelligentsia/forgecli 1.0.14 → 1.0.21

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 (363) hide show
  1. package/CHANGELOG.md +185 -0
  2. package/README.md +7 -1
  3. package/dist/CHANGELOG-forge-plugin.md +61 -0
  4. package/dist/bin/config.js +4 -4
  5. package/dist/bin/config.js.map +1 -1
  6. package/dist/bin/update-cli.d.ts +1 -1
  7. package/dist/bin/update-cli.js +1 -1
  8. package/dist/bin/update-cli.js.map +1 -1
  9. package/dist/extensions/forgecli/ask-user-tool.js +1 -1
  10. package/dist/extensions/forgecli/ask-user-tool.js.map +1 -1
  11. package/dist/extensions/forgecli/commands/add-pipeline.d.ts +19 -0
  12. package/dist/extensions/forgecli/commands/add-pipeline.js +143 -0
  13. package/dist/extensions/forgecli/commands/add-pipeline.js.map +1 -0
  14. package/dist/extensions/forgecli/commands/add-task.d.ts +20 -0
  15. package/dist/extensions/forgecli/commands/add-task.js +154 -0
  16. package/dist/extensions/forgecli/commands/add-task.js.map +1 -0
  17. package/dist/extensions/forgecli/commands/approve.d.ts +22 -0
  18. package/dist/extensions/forgecli/commands/approve.js +152 -0
  19. package/dist/extensions/forgecli/commands/approve.js.map +1 -0
  20. package/dist/extensions/forgecli/commands/collate.d.ts +22 -0
  21. package/dist/extensions/forgecli/commands/collate.js +134 -0
  22. package/dist/extensions/forgecli/commands/collate.js.map +1 -0
  23. package/dist/extensions/forgecli/commands/commit.d.ts +22 -0
  24. package/dist/extensions/forgecli/commands/commit.js +152 -0
  25. package/dist/extensions/forgecli/commands/commit.js.map +1 -0
  26. package/dist/extensions/forgecli/commands/config-command.d.ts +8 -0
  27. package/dist/extensions/forgecli/commands/config-command.js +67 -0
  28. package/dist/extensions/forgecli/commands/config-command.js.map +1 -0
  29. package/dist/extensions/forgecli/commands/enhance.d.ts +45 -0
  30. package/dist/extensions/forgecli/commands/enhance.js +219 -0
  31. package/dist/extensions/forgecli/commands/enhance.js.map +1 -0
  32. package/dist/extensions/forgecli/commands/implement.d.ts +22 -0
  33. package/dist/extensions/forgecli/commands/implement.js +170 -0
  34. package/dist/extensions/forgecli/commands/implement.js.map +1 -0
  35. package/dist/extensions/forgecli/commands/plan.d.ts +22 -0
  36. package/dist/extensions/forgecli/commands/plan.js +167 -0
  37. package/dist/extensions/forgecli/commands/plan.js.map +1 -0
  38. package/dist/extensions/forgecli/commands/quiz-agent.d.ts +17 -0
  39. package/dist/extensions/forgecli/commands/quiz-agent.js +98 -0
  40. package/dist/extensions/forgecli/commands/quiz-agent.js.map +1 -0
  41. package/dist/extensions/forgecli/commands/read-command.d.ts +2 -0
  42. package/dist/extensions/forgecli/commands/read-command.js +100 -0
  43. package/dist/extensions/forgecli/commands/read-command.js.map +1 -0
  44. package/dist/extensions/forgecli/commands/regenerate.d.ts +40 -0
  45. package/dist/extensions/forgecli/commands/regenerate.js +426 -0
  46. package/dist/extensions/forgecli/commands/regenerate.js.map +1 -0
  47. package/dist/extensions/forgecli/commands/remove-command.d.ts +17 -0
  48. package/dist/extensions/forgecli/commands/remove-command.js +124 -0
  49. package/dist/extensions/forgecli/commands/remove-command.js.map +1 -0
  50. package/dist/extensions/forgecli/commands/report-bug.d.ts +25 -0
  51. package/dist/extensions/forgecli/commands/report-bug.js +159 -0
  52. package/dist/extensions/forgecli/commands/report-bug.js.map +1 -0
  53. package/dist/extensions/forgecli/commands/retrospective.d.ts +20 -0
  54. package/dist/extensions/forgecli/commands/retrospective.js +126 -0
  55. package/dist/extensions/forgecli/commands/retrospective.js.map +1 -0
  56. package/dist/extensions/forgecli/commands/review-code.d.ts +35 -0
  57. package/dist/extensions/forgecli/commands/review-code.js +196 -0
  58. package/dist/extensions/forgecli/commands/review-code.js.map +1 -0
  59. package/dist/extensions/forgecli/commands/review-plan.d.ts +35 -0
  60. package/dist/extensions/forgecli/commands/review-plan.js +200 -0
  61. package/dist/extensions/forgecli/commands/review-plan.js.map +1 -0
  62. package/dist/extensions/forgecli/commands/sprint-intake.d.ts +10 -0
  63. package/dist/extensions/forgecli/commands/sprint-intake.js +91 -0
  64. package/dist/extensions/forgecli/commands/sprint-intake.js.map +1 -0
  65. package/dist/extensions/forgecli/commands/sprint-plan.d.ts +14 -0
  66. package/dist/extensions/forgecli/commands/sprint-plan.js +122 -0
  67. package/dist/extensions/forgecli/commands/sprint-plan.js.map +1 -0
  68. package/dist/extensions/forgecli/commands/status-command.d.ts +19 -0
  69. package/dist/extensions/forgecli/commands/status-command.js +140 -0
  70. package/dist/extensions/forgecli/commands/status-command.js.map +1 -0
  71. package/dist/extensions/forgecli/commands/store-query.d.ts +22 -0
  72. package/dist/extensions/forgecli/commands/store-query.js +107 -0
  73. package/dist/extensions/forgecli/commands/store-query.js.map +1 -0
  74. package/dist/extensions/forgecli/commands/store-repair.d.ts +17 -0
  75. package/dist/extensions/forgecli/commands/store-repair.js +123 -0
  76. package/dist/extensions/forgecli/commands/store-repair.js.map +1 -0
  77. package/dist/extensions/forgecli/commands/test-orchestrate.d.ts +2 -0
  78. package/dist/extensions/forgecli/commands/test-orchestrate.js +182 -0
  79. package/dist/extensions/forgecli/commands/test-orchestrate.js.map +1 -0
  80. package/dist/extensions/forgecli/commands/transcripts-command.d.ts +87 -0
  81. package/dist/extensions/forgecli/commands/transcripts-command.js +418 -0
  82. package/dist/extensions/forgecli/commands/transcripts-command.js.map +1 -0
  83. package/dist/extensions/forgecli/commands/validate.d.ts +22 -0
  84. package/dist/extensions/forgecli/commands/validate.js +152 -0
  85. package/dist/extensions/forgecli/commands/validate.js.map +1 -0
  86. package/dist/extensions/forgecli/config/config-layer.d.ts +53 -0
  87. package/dist/extensions/forgecli/config/config-layer.js +72 -0
  88. package/dist/extensions/forgecli/config/config-layer.js.map +1 -0
  89. package/dist/extensions/forgecli/config/config-writer.d.ts +16 -0
  90. package/dist/extensions/forgecli/config/config-writer.js +69 -0
  91. package/dist/extensions/forgecli/config/config-writer.js.map +1 -0
  92. package/dist/extensions/forgecli/config/model-registry.d.ts +61 -0
  93. package/dist/extensions/forgecli/config/model-registry.js +127 -0
  94. package/dist/extensions/forgecli/config/model-registry.js.map +1 -0
  95. package/dist/extensions/forgecli/config/model-resolver.d.ts +32 -0
  96. package/dist/extensions/forgecli/config/model-resolver.js +65 -0
  97. package/dist/extensions/forgecli/config/model-resolver.js.map +1 -0
  98. package/dist/extensions/forgecli/config/model-validator.d.ts +29 -0
  99. package/dist/extensions/forgecli/config/model-validator.js +107 -0
  100. package/dist/extensions/forgecli/config/model-validator.js.map +1 -0
  101. package/dist/extensions/forgecli/config-layer.d.ts +0 -16
  102. package/dist/extensions/forgecli/config-layer.js +0 -5
  103. package/dist/extensions/forgecli/config-layer.js.map +1 -1
  104. package/dist/extensions/forgecli/config-tui/component.js +1 -1
  105. package/dist/extensions/forgecli/config-tui/component.js.map +1 -1
  106. package/dist/extensions/forgecli/config-tui/handler.js +1 -1
  107. package/dist/extensions/forgecli/config-tui/handler.js.map +1 -1
  108. package/dist/extensions/forgecli/config-tui/screens/override-editor.js +1 -1
  109. package/dist/extensions/forgecli/config-tui/screens/override-editor.js.map +1 -1
  110. package/dist/extensions/forgecli/config-tui/screens/overrides-list-phases.js +1 -1
  111. package/dist/extensions/forgecli/config-tui/screens/overrides-list-phases.js.map +1 -1
  112. package/dist/extensions/forgecli/config-tui/screens/show-resolved.js +1 -1
  113. package/dist/extensions/forgecli/config-tui/screens/show-resolved.js.map +1 -1
  114. package/dist/extensions/forgecli/config-tui/state/buffer.d.ts +2 -2
  115. package/dist/extensions/forgecli/config-tui/state/model.d.ts +1 -1
  116. package/dist/extensions/forgecli/config-tui/state/reducer.js.map +1 -1
  117. package/dist/extensions/forgecli/config-tui/state/selectors.d.ts +2 -2
  118. package/dist/extensions/forgecli/config-tui/state/selectors.js +1 -1
  119. package/dist/extensions/forgecli/config-tui/state/selectors.js.map +1 -1
  120. package/dist/extensions/forgecli/context-governor-compaction.d.ts +94 -0
  121. package/dist/extensions/forgecli/context-governor-compaction.js +327 -0
  122. package/dist/extensions/forgecli/context-governor-compaction.js.map +1 -0
  123. package/dist/extensions/forgecli/context-governor.d.ts +169 -0
  124. package/dist/extensions/forgecli/context-governor.js +592 -0
  125. package/dist/extensions/forgecli/context-governor.js.map +1 -0
  126. package/dist/extensions/forgecli/dashboard/component.d.ts +17 -5
  127. package/dist/extensions/forgecli/dashboard/component.js +160 -115
  128. package/dist/extensions/forgecli/dashboard/component.js.map +1 -1
  129. package/dist/extensions/forgecli/dashboard/register.js +7 -21
  130. package/dist/extensions/forgecli/dashboard/register.js.map +1 -1
  131. package/dist/extensions/forgecli/dashboard/theme.d.ts +27 -0
  132. package/dist/extensions/forgecli/dashboard/theme.js +91 -0
  133. package/dist/extensions/forgecli/dashboard/theme.js.map +1 -0
  134. package/dist/extensions/forgecli/fix-bug.js +59 -5
  135. package/dist/extensions/forgecli/fix-bug.js.map +1 -1
  136. package/dist/extensions/forgecli/forge-artifact-tool.js +3 -2
  137. package/dist/extensions/forgecli/forge-artifact-tool.js.map +1 -1
  138. package/dist/extensions/forgecli/forge-cli-schema.json +0 -4
  139. package/dist/extensions/forgecli/forge-commands.js +1 -1
  140. package/dist/extensions/forgecli/forge-commands.js.map +1 -1
  141. package/dist/extensions/forgecli/forge-init/forge-init.d.ts +26 -0
  142. package/dist/extensions/forgecli/forge-init/forge-init.js +514 -0
  143. package/dist/extensions/forgecli/forge-init/forge-init.js.map +1 -0
  144. package/dist/extensions/forgecli/forge-init/init-context.d.ts +99 -0
  145. package/dist/extensions/forgecli/forge-init/init-context.js +178 -0
  146. package/dist/extensions/forgecli/forge-init/init-context.js.map +1 -0
  147. package/dist/extensions/forgecli/forge-init/init-progress.d.ts +39 -0
  148. package/dist/extensions/forgecli/forge-init/init-progress.js +117 -0
  149. package/dist/extensions/forgecli/forge-init/init-progress.js.map +1 -0
  150. package/dist/extensions/forgecli/forge-init/phase4-register.js +1 -1
  151. package/dist/extensions/forgecli/forge-init/phase4-register.js.map +1 -1
  152. package/dist/extensions/forgecli/forge-init/run-phases.js +2 -2
  153. package/dist/extensions/forgecli/forge-init/run-phases.js.map +1 -1
  154. package/dist/extensions/forgecli/forge-subagent.d.ts +42 -1
  155. package/dist/extensions/forgecli/forge-subagent.js +59 -18
  156. package/dist/extensions/forgecli/forge-subagent.js.map +1 -1
  157. package/dist/extensions/forgecli/forge-tools.d.ts +0 -25
  158. package/dist/extensions/forgecli/forge-tools.js +8 -37
  159. package/dist/extensions/forgecli/forge-tools.js.map +1 -1
  160. package/dist/extensions/forgecli/governor-config.d.ts +19 -0
  161. package/dist/extensions/forgecli/governor-config.js +58 -0
  162. package/dist/extensions/forgecli/governor-config.js.map +1 -0
  163. package/dist/extensions/forgecli/health-check.js +1 -1
  164. package/dist/extensions/forgecli/health-check.js.map +1 -1
  165. package/dist/extensions/forgecli/hook-dispatcher.d.ts +3 -1
  166. package/dist/extensions/forgecli/hook-dispatcher.js +39 -5
  167. package/dist/extensions/forgecli/hook-dispatcher.js.map +1 -1
  168. package/dist/extensions/forgecli/hooks/post-init-hook.js +11 -6
  169. package/dist/extensions/forgecli/hooks/post-init-hook.js.map +1 -1
  170. package/dist/extensions/forgecli/hooks/post-sprint-hook.js +11 -6
  171. package/dist/extensions/forgecli/hooks/post-sprint-hook.js.map +1 -1
  172. package/dist/extensions/forgecli/hooks/write-guard.js +1 -1
  173. package/dist/extensions/forgecli/hooks/write-guard.js.map +1 -1
  174. package/dist/extensions/forgecli/index.js +70 -36
  175. package/dist/extensions/forgecli/index.js.map +1 -1
  176. package/dist/extensions/forgecli/kickoff.d.ts +9 -0
  177. package/dist/extensions/forgecli/kickoff.js +15 -0
  178. package/dist/extensions/forgecli/kickoff.js.map +1 -1
  179. package/dist/extensions/forgecli/lib/forge-config.d.ts +1 -1
  180. package/dist/extensions/forgecli/lib/forge-config.js +1 -1
  181. package/dist/extensions/forgecli/lib/forge-config.js.map +1 -1
  182. package/dist/extensions/forgecli/lib/forge-root.d.ts +10 -0
  183. package/dist/extensions/forgecli/lib/forge-root.js +62 -0
  184. package/dist/extensions/forgecli/lib/forge-root.js.map +1 -0
  185. package/dist/extensions/forgecli/lib/halt-advisor.d.ts +19 -14
  186. package/dist/extensions/forgecli/lib/halt-advisor.js +36 -13
  187. package/dist/extensions/forgecli/lib/halt-advisor.js.map +1 -1
  188. package/dist/extensions/forgecli/lib/run-cjs.d.ts +26 -0
  189. package/dist/extensions/forgecli/lib/run-cjs.js +42 -0
  190. package/dist/extensions/forgecli/lib/run-cjs.js.map +1 -0
  191. package/dist/extensions/forgecli/orchestrator-status-bar.d.ts +3 -2
  192. package/dist/extensions/forgecli/orchestrator-status-bar.js +90 -60
  193. package/dist/extensions/forgecli/orchestrator-status-bar.js.map +1 -1
  194. package/dist/extensions/forgecli/orchestrator-tree.d.ts +4 -0
  195. package/dist/extensions/forgecli/orchestrator-tree.js +21 -3
  196. package/dist/extensions/forgecli/orchestrator-tree.js.map +1 -1
  197. package/dist/extensions/forgecli/orchestrators/calibrate.d.ts +64 -0
  198. package/dist/extensions/forgecli/orchestrators/calibrate.js +481 -0
  199. package/dist/extensions/forgecli/orchestrators/calibrate.js.map +1 -0
  200. package/dist/extensions/forgecli/orchestrators/fix-bug.d.ts +93 -0
  201. package/dist/extensions/forgecli/orchestrators/fix-bug.js +1705 -0
  202. package/dist/extensions/forgecli/orchestrators/fix-bug.js.map +1 -0
  203. package/dist/extensions/forgecli/orchestrators/halt-advisor.d.ts +59 -0
  204. package/dist/extensions/forgecli/orchestrators/halt-advisor.js +113 -0
  205. package/dist/extensions/forgecli/orchestrators/halt-advisor.js.map +1 -0
  206. package/dist/extensions/forgecli/orchestrators/materialize.d.ts +16 -0
  207. package/dist/extensions/forgecli/orchestrators/materialize.js +195 -0
  208. package/dist/extensions/forgecli/orchestrators/materialize.js.map +1 -0
  209. package/dist/extensions/forgecli/orchestrators/migrate.d.ts +22 -0
  210. package/dist/extensions/forgecli/orchestrators/migrate.js +260 -0
  211. package/dist/extensions/forgecli/orchestrators/migrate.js.map +1 -0
  212. package/dist/extensions/forgecli/orchestrators/orchestrator-preflight.d.ts +46 -0
  213. package/dist/extensions/forgecli/orchestrators/orchestrator-preflight.js +64 -0
  214. package/dist/extensions/forgecli/orchestrators/orchestrator-preflight.js.map +1 -0
  215. package/dist/extensions/forgecli/orchestrators/run-sprint.d.ts +27 -0
  216. package/dist/extensions/forgecli/orchestrators/run-sprint.js +734 -0
  217. package/dist/extensions/forgecli/orchestrators/run-sprint.js.map +1 -0
  218. package/dist/extensions/forgecli/orchestrators/run-task.d.ts +215 -0
  219. package/dist/extensions/forgecli/orchestrators/run-task.js +1491 -0
  220. package/dist/extensions/forgecli/orchestrators/run-task.js.map +1 -0
  221. package/dist/extensions/forgecli/paths/paths.d.ts +8 -0
  222. package/dist/extensions/forgecli/paths/paths.js +17 -0
  223. package/dist/extensions/forgecli/paths/paths.js.map +1 -1
  224. package/dist/extensions/forgecli/phase-vocab.d.ts +31 -0
  225. package/dist/extensions/forgecli/phase-vocab.js +82 -0
  226. package/dist/extensions/forgecli/phase-vocab.js.map +1 -0
  227. package/dist/extensions/forgecli/run-sprint.d.ts +3 -1
  228. package/dist/extensions/forgecli/run-sprint.js +1 -0
  229. package/dist/extensions/forgecli/run-sprint.js.map +1 -1
  230. package/dist/extensions/forgecli/run-task.d.ts +34 -1
  231. package/dist/extensions/forgecli/run-task.js +144 -6
  232. package/dist/extensions/forgecli/run-task.js.map +1 -1
  233. package/dist/extensions/forgecli/session-registry.d.ts +2 -2
  234. package/dist/extensions/forgecli/session-registry.js +6 -2
  235. package/dist/extensions/forgecli/session-registry.js.map +1 -1
  236. package/dist/extensions/forgecli/skill-curation/friction-emit.d.ts +99 -0
  237. package/dist/extensions/forgecli/skill-curation/friction-emit.js +245 -0
  238. package/dist/extensions/forgecli/skill-curation/friction-emit.js.map +1 -0
  239. package/dist/extensions/forgecli/skill-curation/skill-curation-flag.d.ts +21 -0
  240. package/dist/extensions/forgecli/skill-curation/skill-curation-flag.js +71 -0
  241. package/dist/extensions/forgecli/skill-curation/skill-curation-flag.js.map +1 -0
  242. package/dist/extensions/forgecli/skill-curation/skill-curator-subagent.d.ts +102 -0
  243. package/dist/extensions/forgecli/skill-curation/skill-curator-subagent.js +339 -0
  244. package/dist/extensions/forgecli/skill-curation/skill-curator-subagent.js.map +1 -0
  245. package/dist/extensions/forgecli/skill-curation/skill-retriever.d.ts +84 -0
  246. package/dist/extensions/forgecli/skill-curation/skill-retriever.js +246 -0
  247. package/dist/extensions/forgecli/skill-curation/skill-retriever.js.map +1 -0
  248. package/dist/extensions/forgecli/skill-curation/skill-usage-tracker.d.ts +91 -0
  249. package/dist/extensions/forgecli/skill-curation/skill-usage-tracker.js +224 -0
  250. package/dist/extensions/forgecli/skill-curation/skill-usage-tracker.js.map +1 -0
  251. package/dist/extensions/forgecli/store/store-error-remediation.d.ts +65 -0
  252. package/dist/extensions/forgecli/store/store-error-remediation.js +307 -0
  253. package/dist/extensions/forgecli/store/store-error-remediation.js.map +1 -0
  254. package/dist/extensions/forgecli/store/store-resolver.d.ts +56 -0
  255. package/dist/extensions/forgecli/store/store-resolver.js +263 -0
  256. package/dist/extensions/forgecli/store/store-resolver.js.map +1 -0
  257. package/dist/extensions/forgecli/store/store-validator.d.ts +16 -0
  258. package/dist/extensions/forgecli/store/store-validator.js +32 -0
  259. package/dist/extensions/forgecli/store/store-validator.js.map +1 -0
  260. package/dist/extensions/forgecli/store/transition-guard.d.ts +20 -0
  261. package/dist/extensions/forgecli/store/transition-guard.js +89 -0
  262. package/dist/extensions/forgecli/store/transition-guard.js.map +1 -0
  263. package/dist/extensions/forgecli/subagent/orchestrator-transcript.js +5 -0
  264. package/dist/extensions/forgecli/subagent/orchestrator-transcript.js.map +1 -1
  265. package/dist/extensions/forgecli/thread-switcher.d.ts +4 -1
  266. package/dist/extensions/forgecli/thread-switcher.js +36 -21
  267. package/dist/extensions/forgecli/thread-switcher.js.map +1 -1
  268. package/dist/extensions/forgecli/transcript-archive-types.d.ts +171 -0
  269. package/dist/extensions/forgecli/transcript-archive-types.js +130 -0
  270. package/dist/extensions/forgecli/transcript-archive-types.js.map +1 -0
  271. package/dist/extensions/forgecli/transcript-archive.d.ts +127 -0
  272. package/dist/extensions/forgecli/transcript-archive.js +656 -0
  273. package/dist/extensions/forgecli/transcript-archive.js.map +1 -0
  274. package/dist/extensions/forgecli/transcript-replay.d.ts +28 -0
  275. package/dist/extensions/forgecli/transcript-replay.js +153 -0
  276. package/dist/extensions/forgecli/transcript-replay.js.map +1 -0
  277. package/dist/extensions/forgecli/transcripts-tui/component.d.ts +36 -0
  278. package/dist/extensions/forgecli/transcripts-tui/component.js +112 -0
  279. package/dist/extensions/forgecli/transcripts-tui/component.js.map +1 -0
  280. package/dist/extensions/forgecli/transcripts-tui/index.d.ts +4 -0
  281. package/dist/extensions/forgecli/transcripts-tui/index.js +5 -0
  282. package/dist/extensions/forgecli/transcripts-tui/index.js.map +1 -0
  283. package/dist/extensions/forgecli/transcripts-tui/screens/browse.d.ts +21 -0
  284. package/dist/extensions/forgecli/transcripts-tui/screens/browse.js +172 -0
  285. package/dist/extensions/forgecli/transcripts-tui/screens/browse.js.map +1 -0
  286. package/dist/extensions/forgecli/transcripts-tui/screens/types.d.ts +22 -0
  287. package/dist/extensions/forgecli/transcripts-tui/screens/types.js +4 -0
  288. package/dist/extensions/forgecli/transcripts-tui/screens/types.js.map +1 -0
  289. package/dist/extensions/forgecli/transcripts-tui/state/index.d.ts +4 -0
  290. package/dist/extensions/forgecli/transcripts-tui/state/index.js +5 -0
  291. package/dist/extensions/forgecli/transcripts-tui/state/index.js.map +1 -0
  292. package/dist/extensions/forgecli/transcripts-tui/state/init.d.ts +8 -0
  293. package/dist/extensions/forgecli/transcripts-tui/state/init.js +18 -0
  294. package/dist/extensions/forgecli/transcripts-tui/state/init.js.map +1 -0
  295. package/dist/extensions/forgecli/transcripts-tui/state/model.d.ts +56 -0
  296. package/dist/extensions/forgecli/transcripts-tui/state/model.js +6 -0
  297. package/dist/extensions/forgecli/transcripts-tui/state/model.js.map +1 -0
  298. package/dist/extensions/forgecli/transcripts-tui/state/reducer.d.ts +2 -0
  299. package/dist/extensions/forgecli/transcripts-tui/state/reducer.js +51 -0
  300. package/dist/extensions/forgecli/transcripts-tui/state/reducer.js.map +1 -0
  301. package/dist/extensions/forgecli/transcripts-tui/state/selectors.d.ts +10 -0
  302. package/dist/extensions/forgecli/transcripts-tui/state/selectors.js +62 -0
  303. package/dist/extensions/forgecli/transcripts-tui/state/selectors.js.map +1 -0
  304. package/dist/extensions/forgecli/transcripts-tui/theme.d.ts +20 -0
  305. package/dist/extensions/forgecli/transcripts-tui/theme.js +47 -0
  306. package/dist/extensions/forgecli/transcripts-tui/theme.js.map +1 -0
  307. package/dist/extensions/forgecli/tui/banner.d.ts +10 -0
  308. package/dist/extensions/forgecli/tui/banner.js +36 -0
  309. package/dist/extensions/forgecli/tui/banner.js.map +1 -0
  310. package/dist/extensions/forgecli/tui/forge-header.d.ts +12 -0
  311. package/dist/extensions/forgecli/tui/forge-header.js +114 -0
  312. package/dist/extensions/forgecli/tui/forge-header.js.map +1 -0
  313. package/dist/extensions/forgecli/tui/input-router.d.ts +33 -0
  314. package/dist/extensions/forgecli/tui/input-router.js +136 -0
  315. package/dist/extensions/forgecli/tui/input-router.js.map +1 -0
  316. package/dist/extensions/forgecli/tui/orchestrator-status-bar.d.ts +26 -0
  317. package/dist/extensions/forgecli/tui/orchestrator-status-bar.js +213 -0
  318. package/dist/extensions/forgecli/tui/orchestrator-status-bar.js.map +1 -0
  319. package/dist/extensions/forgecli/tui/thread-switcher.d.ts +18 -0
  320. package/dist/extensions/forgecli/tui/thread-switcher.js +194 -0
  321. package/dist/extensions/forgecli/tui/thread-switcher.js.map +1 -0
  322. package/dist/extensions/forgecli/update/forge-update-command.d.ts +100 -0
  323. package/dist/extensions/forgecli/update/forge-update-command.js +435 -0
  324. package/dist/extensions/forgecli/update/forge-update-command.js.map +1 -0
  325. package/dist/extensions/forgecli/update/migration-engine.d.ts +117 -0
  326. package/dist/extensions/forgecli/update/migration-engine.js +563 -0
  327. package/dist/extensions/forgecli/update/migration-engine.js.map +1 -0
  328. package/dist/extensions/forgecli/update/update-check.d.ts +37 -0
  329. package/dist/extensions/forgecli/update/update-check.js +185 -0
  330. package/dist/extensions/forgecli/update/update-check.js.map +1 -0
  331. package/dist/extensions/forgecli/update/update-tools.d.ts +23 -0
  332. package/dist/extensions/forgecli/update/update-tools.js +135 -0
  333. package/dist/extensions/forgecli/update/update-tools.js.map +1 -0
  334. package/dist/extensions/forgecli/update/whats-new-widget.d.ts +26 -0
  335. package/dist/extensions/forgecli/update/whats-new-widget.js +376 -0
  336. package/dist/extensions/forgecli/update/whats-new-widget.js.map +1 -0
  337. package/dist/extensions/forgecli/update/whats-new.d.ts +120 -0
  338. package/dist/extensions/forgecli/update/whats-new.js +470 -0
  339. package/dist/extensions/forgecli/update/whats-new.js.map +1 -0
  340. package/dist/extensions/forgecli/viewport/events.d.ts +113 -0
  341. package/dist/extensions/forgecli/viewport/events.js +290 -0
  342. package/dist/extensions/forgecli/viewport/events.js.map +1 -0
  343. package/dist/extensions/forgecli/viewport/renderer.d.ts +102 -0
  344. package/dist/extensions/forgecli/viewport/renderer.js +277 -0
  345. package/dist/extensions/forgecli/viewport/renderer.js.map +1 -0
  346. package/dist/extensions/forgecli/viewport/theme.d.ts +11 -0
  347. package/dist/extensions/forgecli/viewport/theme.js +131 -0
  348. package/dist/extensions/forgecli/viewport/theme.js.map +1 -0
  349. package/dist/extensions/forgecli/wf-engine/engine.js +1 -1
  350. package/dist/extensions/forgecli/wf-engine/engine.js.map +1 -1
  351. package/dist/forge-payload/.base-pack/workflows/implement_plan.md +9 -0
  352. package/dist/forge-payload/.base-pack/workflows/plan_task.md +7 -0
  353. package/dist/forge-payload/.base-pack/workflows/review_code.md +4 -3
  354. package/dist/forge-payload/.base-pack/workflows/review_plan.md +4 -3
  355. package/dist/forge-payload/.base-pack/workflows/validate_task.md +4 -3
  356. package/dist/forge-payload/.claude-plugin/plugin.json +1 -1
  357. package/dist/forge-payload/.schemas/migrations.json +132 -27
  358. package/dist/forge-payload/meta/workflows/meta-review-implementation.md +4 -3
  359. package/dist/forge-payload/meta/workflows/meta-review-plan.md +4 -3
  360. package/dist/forge-payload/meta/workflows/meta-validate.md +4 -3
  361. package/dist/forge-payload/tools/collate.cjs +32 -0
  362. package/dist/forge-payload/tools/postflight-gate.cjs +56 -10
  363. package/package.json +5 -3
@@ -0,0 +1,307 @@
1
+ // Store-error remediation — forge-cli#24
2
+ // Moved from lib/store-error-remediation.ts to root by FORGE-S25-T22 (S-7: single-file lib/ dir).
3
+ //
4
+ // Shared remediation-hint surface for store validation errors.
5
+ // Consumed by:
6
+ // - health-check.ts (per-error row in store-integrity output)
7
+ // - hooks/write-guard.ts (block-message body for schema violations)
8
+ // - hook-dispatcher.ts (store-cli intercept block messages)
9
+ // - store-validator.ts (structured result for hook callers)
10
+ //
11
+ // Error sources:
12
+ // 1. validate.js (in-process via write-guard) — produces error strings like:
13
+ // "status: value "verified" not in [reported, triaged, in-progress, fixed]"
14
+ // "taskId: missing required field"
15
+ // "xyz: undeclared field"
16
+ // 2. store-cli.cjs validate (subprocess via store-validator.ts) — same format,
17
+ // piped through stderr.
18
+ // 3. validate-store.cjs --dry-run (subprocess via health-check.ts) — lines like:
19
+ // "ERROR FORGE-S18-T02: status: value "verified" not in [reported, triaged, ...]"
20
+ // "WARN FORGE-S18-T02: ..."
21
+ //
22
+ // This module parses those formats and returns a one-line user-facing hint
23
+ // plus an optional copy-pasteable store-cli command.
24
+ // ── Entity-type inference from entity name / ID ────────────────────────────────
25
+ /** Map entity type to the corresponding schema's status enum values. */
26
+ const STATUS_ENUMS = {
27
+ task: [
28
+ "draft",
29
+ "planned",
30
+ "plan-approved",
31
+ "implementing",
32
+ "implemented",
33
+ "review-approved",
34
+ "approved",
35
+ "committed",
36
+ "plan-revision-required",
37
+ "code-revision-required",
38
+ "blocked",
39
+ "escalated",
40
+ "abandoned",
41
+ ],
42
+ sprint: ["planning", "active", "completed", "retrospective-done", "partially-completed", "blocked", "abandoned"],
43
+ bug: ["reported", "triaged", "in-progress", "fixed"],
44
+ feature: ["proposed", "accepted", "in-progress", "delivered", "declined"],
45
+ event: [], // no status field
46
+ };
47
+ /** Known entity types that support write via store-cli. */
48
+ const ENTITY_TYPES = new Set(["task", "sprint", "bug", "feature", "event"]);
49
+ /**
50
+ * Infer the entity type from an entity name/ID string.
51
+ * Returns "task" as default if no match.
52
+ */
53
+ export function inferEntityType(entity) {
54
+ const lower = entity.toLowerCase();
55
+ // Bug patterns: BUG-015, FORGE-BUG-015, bug-031
56
+ if (/\bbug/i.test(entity))
57
+ return "bug";
58
+ // Sprint patterns: S18 (standalone), sprint-01 — but NOT inside task IDs like FORGE-S18-T02
59
+ if (/^[A-Z]+-S\d+$/i.test(entity) || /\bsprint/i.test(entity))
60
+ return "sprint";
61
+ // Feature patterns: FORGE-F01
62
+ if (/\bf\d+\b/i.test(entity) || lower.includes("feat"))
63
+ return "feature";
64
+ // Event patterns
65
+ if (lower.includes("event"))
66
+ return "event";
67
+ // Task IDs: FORGE-S18-T02, PROJECT-T01
68
+ if (/\bt\d+\b/i.test(entity))
69
+ return "task";
70
+ // Default
71
+ return "task";
72
+ }
73
+ const STATUS_REMEDIATION = {
74
+ hint: "Set status to one of the legal values for this entity type.",
75
+ command: (entityType, entityId) => `node "$FORGE_ROOT/tools/store-cli.cjs" update-status ${entityType} ${entityId} status <legal-value>`,
76
+ };
77
+ const REQUIRED_FIELD_REMEDIATION = {
78
+ hint: "Add the missing field with a valid value. Use the template command to see the canonical shape.",
79
+ command: (entityType, _entityId) => `node "$FORGE_ROOT/tools/store-cli.cjs" template ${entityType}`,
80
+ };
81
+ const UNDECLARED_FIELD_REMEDIATION = {
82
+ hint: "Remove the undeclared field, or check the schema for the correct property name.",
83
+ command: (entityType, _entityId) => `node "$FORGE_ROOT/tools/store-cli.cjs" describe ${entityType}`,
84
+ };
85
+ const TYPE_MISMATCH_REMEDIATION = {
86
+ hint: "Use the correct type for this field. Use the describe command to see the expected type.",
87
+ command: (entityType, _entityId) => `node "$FORGE_ROOT/tools/store-cli.cjs" describe ${entityType}`,
88
+ };
89
+ const PATTERN_REMEDIATION = {
90
+ hint: "The value must match the expected pattern (e.g. a date-time or ID format).",
91
+ command: (entityType, _entityId) => `node "$FORGE_ROOT/tools/store-cli.cjs" describe ${entityType}`,
92
+ };
93
+ const DATE_TIME_REMEDIATION = {
94
+ hint: "Use an ISO 8601 date-time string (e.g. 2026-05-21T12:00:00Z).",
95
+ command: (entityType, _entityId) => `node "$FORGE_ROOT/tools/store-cli.cjs" describe ${entityType}`,
96
+ };
97
+ const LENGTH_REMEDIATION = {
98
+ hint: "Adjust the value length to satisfy the schema constraint.",
99
+ command: (entityType, _entityId) => `node "$FORGE_ROOT/tools/store-cli.cjs" describe ${entityType}`,
100
+ };
101
+ /**
102
+ * Parse a single validation error line from validate.js / store-cli.
103
+ *
104
+ * Examples:
105
+ * 'status: value "verified" not in [reported, triaged, in-progress, fixed]'
106
+ * 'taskId: missing required field'
107
+ * 'xyz: undeclared field'
108
+ * 'sprintId: expected string, got number'
109
+ * 'title: value length 0 is below minLength 1'
110
+ * 'createdAt: value "today" is not a valid date-time'
111
+ * 'prefix: value "AB" does not match pattern ^[A-Z]+-[A-Z]$'
112
+ */
113
+ export function parseValidationError(line) {
114
+ // Enum violation: 'field: value "X" not in [a, b, c]'
115
+ const enumMatch = line.match(/^(\w+):\s+value\s+"([^"]+)"\s+not in \[([^\]]+)\]/);
116
+ if (enumMatch) {
117
+ return {
118
+ field: enumMatch[1],
119
+ errorKind: "enum",
120
+ observed: enumMatch[2],
121
+ enumValues: enumMatch[3].split(",").map((s) => s.trim()),
122
+ };
123
+ }
124
+ // Required field: 'field: missing required field'
125
+ if (/\bmissing required field\b/.test(line)) {
126
+ const fieldMatch = line.match(/^(\w+):/);
127
+ return { field: fieldMatch?.[1] ?? "unknown", errorKind: "required" };
128
+ }
129
+ // Undeclared field: 'xyz: undeclared field'
130
+ if (/\bundeclared field\b/.test(line)) {
131
+ const fieldMatch = line.match(/^(\w+):/);
132
+ return { field: fieldMatch?.[1] ?? "unknown", errorKind: "undeclared" };
133
+ }
134
+ // Type mismatch: 'field: expected string, got number'
135
+ const typeMatch = line.match(/^(\w+):\s+expected\s+\S+,?\s+got\s+\S+/);
136
+ if (typeMatch) {
137
+ return { field: typeMatch[1], errorKind: "type" };
138
+ }
139
+ // Date-time format: 'field: value "..." is not a valid date-time'
140
+ if (/\bis not a valid date-time\b/.test(line)) {
141
+ const fieldMatch = line.match(/^(\w+):/);
142
+ return { field: fieldMatch?.[1] ?? "unknown", errorKind: "datetime" };
143
+ }
144
+ // Pattern mismatch: 'field: value "..." does not match pattern ...'
145
+ if (/\bdoes not match pattern\b/.test(line)) {
146
+ const fieldMatch = line.match(/^(\w+):/);
147
+ return { field: fieldMatch?.[1] ?? "unknown", errorKind: "pattern" };
148
+ }
149
+ // Length violations
150
+ if (/\blength\b.*\b(exceeds|below)\b/.test(line) || /\b(exceeds|below)\b.*\blength\b/.test(line)) {
151
+ const fieldMatch = line.match(/^(\w+):/);
152
+ return { field: fieldMatch?.[1] ?? "unknown", errorKind: "length" };
153
+ }
154
+ // Generic: capture leading field name if present
155
+ const genericMatch = line.match(/^(\w+):/);
156
+ return { field: genericMatch?.[1] ?? "unknown", errorKind: "other" };
157
+ }
158
+ // ── Public API ──────────────────────────────────────────────────────────────────
159
+ /**
160
+ * Given a single validation error line (from validate.js or store-cli),
161
+ * return a user-facing remediation hint and optional copy-pasteable command.
162
+ *
163
+ * @param errorLine A single error line from validate.js / store-cli output.
164
+ * @param entityType The entity type (task, sprint, bug, feature, event).
165
+ * @param entityId The entity ID (e.g. "FORGE-S18-T02") — used for commands.
166
+ * @returns RemediationResult with hint and command.
167
+ */
168
+ export function remediateError(errorLine, entityType, entityId) {
169
+ const parsed = parseValidationError(errorLine);
170
+ switch (parsed.errorKind) {
171
+ case "enum": {
172
+ const legalValues = STATUS_ENUMS[entityType] ?? parsed.enumValues ?? [];
173
+ const isStatusField = parsed.field === "status" || parsed.field.toLowerCase().includes("status");
174
+ if (isStatusField && legalValues.length > 0) {
175
+ return {
176
+ hint: `"${parsed.observed}" is not a legal ${entityType} status. Legal values: ${legalValues.join(", ")}.`,
177
+ command: `node "$FORGE_ROOT/tools/store-cli.cjs" update-status ${entityType} ${entityId} status <${legalValues.join("|")}>`,
178
+ };
179
+ }
180
+ if (legalValues.length > 0) {
181
+ return {
182
+ hint: `Invalid value for "${parsed.field}". Allowed: ${legalValues.join(", ")}.`,
183
+ command: `node "$FORGE_ROOT/tools/store-cli.cjs" template ${entityType}`,
184
+ };
185
+ }
186
+ return {
187
+ hint: STATUS_REMEDIATION.hint,
188
+ command: STATUS_REMEDIATION.command(entityType, entityId),
189
+ };
190
+ }
191
+ case "required":
192
+ return {
193
+ hint: REQUIRED_FIELD_REMEDIATION.hint,
194
+ command: REQUIRED_FIELD_REMEDIATION.command(entityType, entityId),
195
+ };
196
+ case "undeclared":
197
+ return {
198
+ hint: UNDECLARED_FIELD_REMEDIATION.hint,
199
+ command: UNDECLARED_FIELD_REMEDIATION.command(entityType, entityId),
200
+ };
201
+ case "type":
202
+ return {
203
+ hint: TYPE_MISMATCH_REMEDIATION.hint,
204
+ command: TYPE_MISMATCH_REMEDIATION.command(entityType, entityId),
205
+ };
206
+ case "datetime":
207
+ return {
208
+ hint: DATE_TIME_REMEDIATION.hint,
209
+ command: DATE_TIME_REMEDIATION.command(entityType, entityId),
210
+ };
211
+ case "pattern":
212
+ return {
213
+ hint: PATTERN_REMEDIATION.hint,
214
+ command: PATTERN_REMEDIATION.command(entityType, entityId),
215
+ };
216
+ case "length":
217
+ return {
218
+ hint: LENGTH_REMEDIATION.hint,
219
+ command: LENGTH_REMEDIATION.command(entityType, entityId),
220
+ };
221
+ case "other":
222
+ default:
223
+ return {
224
+ hint: "Check the schema for the expected shape.",
225
+ command: `node "$FORGE_ROOT/tools/store-cli.cjs" template ${entityType}`,
226
+ };
227
+ }
228
+ }
229
+ /**
230
+ * Parse a multi-line validation output (e.g. from store-cli validate or
231
+ * validate-store --dry-run) into individual error lines and return
232
+ * remediation for each.
233
+ *
234
+ * @param output Raw multi-line output from validation tool.
235
+ * @param entityType Override entity type (inferred from output if not provided).
236
+ * @returns Array of { errorLine, remediation } objects.
237
+ */
238
+ export function remediateValidationOutput(output, entityType) {
239
+ const lines = output
240
+ .split("\n")
241
+ .map((l) => l.trim())
242
+ .filter((l) => l.length > 0);
243
+ const results = [];
244
+ for (const line of lines) {
245
+ // Strip "ERROR" / "WARN" prefix from validate-store --dry-run output
246
+ const cleaned = line.replace(/^(ERROR|WARN)\s+/, "");
247
+ if (!cleaned)
248
+ continue;
249
+ // Extract entity ID from lines like "FORGE-S18-T02: status: ..."
250
+ const entityIdMatch = cleaned.match(/^([A-Z]+-S?\d+-T?\d+|[A-Z]+-BUG-\d+|[A-Z]+-F\d+):/);
251
+ const entityId = entityIdMatch?.[1] ?? "unknown";
252
+ // If entity type not overridden, try to infer
253
+ const inferredType = entityType ?? inferEntityType(entityId);
254
+ // Skip non-error lines (hint lines from validate.js, blank lines, etc.)
255
+ if (cleaned.startsWith("(") || cleaned.startsWith("hint:") || cleaned.startsWith("#")) {
256
+ continue;
257
+ }
258
+ // Skip lines that are just an entity name without an error field
259
+ // (the real error is on the same line after the entity prefix)
260
+ const errorPart = entityIdMatch ? cleaned.slice(entityIdMatch[0].length).trim() : cleaned;
261
+ if (!errorPart || errorPart.length < 3)
262
+ continue;
263
+ results.push({
264
+ errorLine: cleaned,
265
+ remediation: remediateError(errorPart, inferredType, entityId),
266
+ });
267
+ }
268
+ return results;
269
+ }
270
+ /**
271
+ * Format a block message for a write-guard violation, appending remediation hints.
272
+ * Used by hook-dispatcher.ts for store-cli intercept blocks.
273
+ *
274
+ * @param rawReason The raw reason string from validateStoreCLIPayload or checkWriteGuard.
275
+ * @param entityType The entity type if known.
276
+ * @param entityId The entity ID if known.
277
+ * @returns Enhanced reason string with remediation hints appended.
278
+ */
279
+ export function enhanceBlockMessage(rawReason, entityType, entityId) {
280
+ // Parse the raw reason into lines and try to add remediation to each error line.
281
+ const lines = rawReason.split("\n");
282
+ const enhanced = [];
283
+ for (const line of lines) {
284
+ // Strip leading list markers and bullet points
285
+ const stripped = line.replace(/^\s*[-•]\s*/, "").trim();
286
+ // Check if this line contains a recognizable validation error pattern
287
+ const parsed = parseValidationError(stripped);
288
+ // Also match lines that contain validation error patterns not caught by parseValidationError
289
+ const hasKnownError = parsed.errorKind !== "other" ||
290
+ /\bmissing required\b|\bnot in \[|\bundeclared\b|\bexpected\b.*\bgot\b/.test(stripped);
291
+ if (hasKnownError) {
292
+ const type = entityType ?? "task";
293
+ const id = entityId ?? "unknown";
294
+ const remediation = remediateError(stripped, type, id);
295
+ enhanced.push(line);
296
+ enhanced.push(` 💡 ${remediation.hint}`);
297
+ if (remediation.command) {
298
+ enhanced.push(` → ${remediation.command}`);
299
+ }
300
+ }
301
+ else {
302
+ enhanced.push(line);
303
+ }
304
+ }
305
+ return enhanced.join("\n");
306
+ }
307
+ //# sourceMappingURL=store-error-remediation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store-error-remediation.js","sourceRoot":"","sources":["../../../../src/extensions/forgecli/store/store-error-remediation.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,kGAAkG;AAClG,EAAE;AACF,+DAA+D;AAC/D,eAAe;AACf,gEAAgE;AAChE,sEAAsE;AACtE,8DAA8D;AAC9D,8DAA8D;AAC9D,EAAE;AACF,iBAAiB;AACjB,+EAA+E;AAC/E,mFAAmF;AACnF,0CAA0C;AAC1C,iCAAiC;AACjC,iFAAiF;AACjF,6BAA6B;AAC7B,mFAAmF;AACnF,0FAA0F;AAC1F,qCAAqC;AACrC,EAAE;AACF,2EAA2E;AAC3E,qDAAqD;AAWrD,kFAAkF;AAElF,wEAAwE;AACxE,MAAM,YAAY,GAAsC;IACvD,IAAI,EAAE;QACL,OAA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AM,aAAa,GAClB,MAAM,CAAC,SAAS,KAAK,OAAO;YAC5B,uEAAuE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxF,IAAI,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,GAAG,UAAU,IAAI,MAAM,CAAC;YAClC,MAAM,EAAE,GAAG,QAAQ,IAAI,SAAS,CAAC;YACjC,MAAM,WAAW,GAAG,cAAc,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;YACvD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpB,QAAQ,CAAC,IAAI,CAAC,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;YAC1C,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;gBACzB,QAAQ,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7C,CAAC;QACF,CAAC;aAAM,CAAC;YACP,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;IACF,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { ExtensionCommandContext } from "@earendil-works/pi-coding-agent";
2
+ export declare const ENTITY_TYPES: Set<string>;
3
+ export declare const ID_PATTERNS: {
4
+ task: RegExp;
5
+ sprint: RegExp;
6
+ bug: RegExp;
7
+ feature: RegExp;
8
+ bareTask: RegExp;
9
+ idFragment: RegExp;
10
+ };
11
+ export type ResolverHit = {
12
+ dir: string;
13
+ } | {
14
+ item: any;
15
+ };
16
+ export interface ResolveOptions {
17
+ entityTypes?: Set<string>;
18
+ ctx?: ExtensionCommandContext;
19
+ statusLabel?: string;
20
+ }
21
+ export declare function isDebug(): boolean;
22
+ export declare function resolveToolDir(forgeRoot: string): string;
23
+ export declare function runStoreCli(toolDir: string, argv: string[], cwd: string): Promise<any>;
24
+ /**
25
+ * Try store-cli's native --task-suffix / --sprint-suffix flags. Returns:
26
+ * - results array on success
27
+ * - null if the flag is unsupported (older store-cli) — caller should fall back
28
+ */
29
+ export declare function suffixMatch(toolDir: string, cwd: string, kind: "task" | "sprint", suffix: string): Promise<any[] | null>;
30
+ /**
31
+ * Resolution cascade:
32
+ * 1. @path → use the path directly as artifact directory
33
+ * 2. Canonical ID → store-cli query --task/--bug/--feature/--sprint
34
+ * 3. ID suffix → --task-suffix / --sprint-suffix (one call) with loop fallback
35
+ * 4. Keyword → store-cli query --keyword (title substring)
36
+ * 5. NLP fallback → store-cli nlp "<query>"
37
+ */
38
+ export declare function resolveEntityRef(arg: string, toolDir: string, cwd: string, opts?: ResolveOptions): Promise<ResolverHit | null>;
39
+ export interface ResolveToCanonicalIdOptions {
40
+ /** Which entity types to search. Defaults to a single-element set matching `kind`. */
41
+ entityTypes?: Set<string>;
42
+ /** Command label used in error messages (e.g. "forge:run-task"). */
43
+ commandLabel?: string;
44
+ }
45
+ /**
46
+ * Resolve a raw user arg to a canonical entity ID string.
47
+ *
48
+ * 1. If the arg is already a canonical ID that resolves directly → return it.
49
+ * 2. If the arg is an unprefixed ID (e.g. "S22-T03") → suffix-match or
50
+ * prefix-normalize to the canonical form → return it.
51
+ * 3. If the arg is ambiguous → prompt the user (or hard-fail in non-interactive).
52
+ * 4. If the arg cannot be resolved → emit an actionable error and return null.
53
+ */
54
+ export declare function resolveToCanonicalId(arg: string, toolDir: string, cwd: string, kind: "task" | "sprint" | "bug" | "feature", opts: ResolveToCanonicalIdOptions & {
55
+ ctx?: ExtensionCommandContext;
56
+ }): Promise<string | null>;
@@ -0,0 +1,263 @@
1
+ // store-resolver.ts — Shared store-cli resolver for `@path` / canonical ID /
2
+ // ID-suffix / keyword / NLP cascade. Used by /forge:read, /forge:run-task,
3
+ // /forge:run-sprint, /forge:fix-bug, and (eventually) /forge:plan,
4
+ // /forge:implement ports. Co-locates the spawn helper, regex constants, and
5
+ // the multi-result picker so future ports do not drift from the canonical
6
+ // cascade.
7
+ import * as path from "node:path";
8
+ import { execFileAsync } from "../lib/exec-helpers.js";
9
+ import { isDirectory } from "../lib/shared-fs-utils.js";
10
+ export const ENTITY_TYPES = new Set(["task", "sprint", "bug", "feature"]);
11
+ export const ID_PATTERNS = {
12
+ task: /^([A-Z0-9]+-)?S\d+-T\d+$/i,
13
+ sprint: /^([A-Z0-9]+-)?S\d+$/i,
14
+ bug: /^([A-Z0-9]+-)?B\d+$/i,
15
+ feature: /^([A-Z0-9]+-)?F\d+$/i,
16
+ bareTask: /^T\d+$/i,
17
+ idFragment: /^(S|B|F|T)\d+(-T\d+)?$/i,
18
+ };
19
+ export function isDebug() {
20
+ return process.env.FORGE_DEBUG === "1";
21
+ }
22
+ export function resolveToolDir(forgeRoot) {
23
+ const nested = path.join(forgeRoot, "tools");
24
+ return isDirectory(nested) ? nested : forgeRoot;
25
+ }
26
+ export async function runStoreCli(toolDir, argv, cwd) {
27
+ const toolPath = path.join(toolDir, "store-cli.cjs");
28
+ const timeout = argv[0] === "nlp" ? 30_000 : 10_000;
29
+ const result = await execFileAsync("node", [toolPath, ...argv], {
30
+ cwd,
31
+ encoding: "utf8",
32
+ timeout,
33
+ });
34
+ try {
35
+ return JSON.parse(result.stdout);
36
+ }
37
+ catch {
38
+ throw new Error(`store-cli returned non-JSON for argv=${JSON.stringify(argv)}: ${result.stdout.slice(0, 200)}`);
39
+ }
40
+ }
41
+ function filterEntities(rs, entityTypes) {
42
+ return rs.filter((r) => entityTypes.has(r.type));
43
+ }
44
+ async function pickFromResults(items, arg, ctx, statusLabel) {
45
+ if (items.length === 1)
46
+ return { item: items[0] };
47
+ ctx.ui.setStatus(statusLabel, undefined);
48
+ const nonInteractive = process.env.FORGE_YES === "1" || process.env.FORGE_NON_INTERACTIVE === "1";
49
+ if (nonInteractive) {
50
+ ctx.ui.notify(`Multiple records match "${arg}" — refusing to pick in non-interactive mode`, "error");
51
+ return null;
52
+ }
53
+ const options = items.map((t, i) => `[${i}] ${t.id} (${t.type}): ${t.title}`);
54
+ const selection = await ctx.ui.select(`Multiple records found for "${arg}". Select one:`, options);
55
+ if (!selection)
56
+ return null;
57
+ const idx = parseInt(selection.match(/^\[(\d+)\]/)?.[1] ?? "-1", 10);
58
+ if (idx < 0 || idx >= items.length)
59
+ return null;
60
+ return { item: items[idx] };
61
+ }
62
+ /**
63
+ * Try store-cli's native --task-suffix / --sprint-suffix flags. Returns:
64
+ * - results array on success
65
+ * - null if the flag is unsupported (older store-cli) — caller should fall back
66
+ */
67
+ export async function suffixMatch(toolDir, cwd, kind, suffix) {
68
+ const flag = kind === "task" ? "--task-suffix" : "--sprint-suffix";
69
+ try {
70
+ const r = await runStoreCli(toolDir, ["query", flag, suffix], cwd);
71
+ if (r && Array.isArray(r.results) && r.path === "suffix")
72
+ return r.results;
73
+ // store-cli ran but didn't take the suffix path → treat as unsupported.
74
+ return null;
75
+ }
76
+ catch (err) {
77
+ if (isDebug())
78
+ console.error(`[forge:resolver] suffix flag failed: ${err.message}`);
79
+ return null;
80
+ }
81
+ }
82
+ /**
83
+ * Resolution cascade:
84
+ * 1. @path → use the path directly as artifact directory
85
+ * 2. Canonical ID → store-cli query --task/--bug/--feature/--sprint
86
+ * 3. ID suffix → --task-suffix / --sprint-suffix (one call) with loop fallback
87
+ * 4. Keyword → store-cli query --keyword (title substring)
88
+ * 5. NLP fallback → store-cli nlp "<query>"
89
+ */
90
+ export async function resolveEntityRef(arg, toolDir, cwd, opts = {}) {
91
+ const ctx = opts.ctx;
92
+ const statusLabel = opts.statusLabel ?? "forge:resolve";
93
+ const entityTypes = opts.entityTypes ?? ENTITY_TYPES;
94
+ const setStatus = (msg) => ctx?.ui.setStatus(statusLabel, msg);
95
+ const pick = (items) => ctx ? pickFromResults(items, arg, ctx, statusLabel) : Promise.resolve({ item: items[0] });
96
+ // ── 1. @path ──────────────────────────────────────────────────────────────
97
+ if (arg.startsWith("@")) {
98
+ const rawPath = arg.slice(1).trim();
99
+ const resolved = path.isAbsolute(rawPath) ? rawPath : path.join(cwd, rawPath);
100
+ return { dir: resolved };
101
+ }
102
+ // ── 2. Canonical structured ID ────────────────────────────────────────────
103
+ const isCanonical = /^[A-Z0-9]+-/i.test(arg) &&
104
+ (ID_PATTERNS.task.test(arg) ||
105
+ ID_PATTERNS.bug.test(arg) ||
106
+ ID_PATTERNS.feature.test(arg) ||
107
+ ID_PATTERNS.sprint.test(arg));
108
+ let structuredResult = null;
109
+ try {
110
+ if (ID_PATTERNS.task.test(arg)) {
111
+ setStatus(`Looking up task ${arg}…`);
112
+ structuredResult = await runStoreCli(toolDir, ["query", "--task", arg], cwd);
113
+ }
114
+ else if (ID_PATTERNS.bug.test(arg)) {
115
+ setStatus(`Looking up bug ${arg}…`);
116
+ structuredResult = await runStoreCli(toolDir, ["query", "--bug", arg], cwd);
117
+ }
118
+ else if (ID_PATTERNS.feature.test(arg)) {
119
+ setStatus(`Looking up feature ${arg}…`);
120
+ structuredResult = await runStoreCli(toolDir, ["query", "--feature", arg], cwd);
121
+ }
122
+ else if (ID_PATTERNS.sprint.test(arg)) {
123
+ setStatus(`Looking up sprint ${arg}…`);
124
+ structuredResult = await runStoreCli(toolDir, ["query", "--sprint", arg], cwd);
125
+ }
126
+ }
127
+ catch (err) {
128
+ if (isDebug())
129
+ console.error(`[forge:resolver] structured query failed: ${err.message}`);
130
+ }
131
+ if (structuredResult?.results?.length > 0) {
132
+ return pick(structuredResult.results);
133
+ }
134
+ if (isCanonical) {
135
+ setStatus(undefined);
136
+ ctx?.ui.notify(`No record found for canonical ID "${arg}"`, "warning");
137
+ return null;
138
+ }
139
+ // ── 3. ID suffix matching ─────────────────────────────────────────────────
140
+ const looksLikeIdFragment = ID_PATTERNS.idFragment.test(arg);
141
+ if (looksLikeIdFragment) {
142
+ setStatus(`Searching for ID suffix "${arg}"…`);
143
+ try {
144
+ const suffix = arg.toUpperCase();
145
+ // Sprint-shaped fragment (e.g. "S01"): native sprint-suffix first,
146
+ // fall back to list-and-filter.
147
+ if (ID_PATTERNS.sprint.test(arg) && !ID_PATTERNS.task.test(arg)) {
148
+ const fast = await suffixMatch(toolDir, cwd, "sprint", suffix);
149
+ if (fast && fast.length > 0)
150
+ return pick(fast);
151
+ if (fast === null) {
152
+ const r = await runStoreCli(toolDir, ["query", "--list-sprints"], cwd);
153
+ const matched = (r?.results ?? []).filter((s) => s.id?.toUpperCase().endsWith(`-${suffix}`) || s.id?.toUpperCase() === suffix);
154
+ if (matched.length > 0) {
155
+ const canonical = [];
156
+ for (const s of matched) {
157
+ try {
158
+ const rr = await runStoreCli(toolDir, ["query", "--sprint", s.id], cwd);
159
+ canonical.push(...(rr?.results ?? []));
160
+ }
161
+ catch (err) {
162
+ if (isDebug())
163
+ console.error(`[forge:resolver] sprint lookup failed for ${s.id}: ${err.message}`);
164
+ }
165
+ }
166
+ if (canonical.length > 0)
167
+ return pick(canonical);
168
+ }
169
+ }
170
+ }
171
+ // Task-shaped fragment (e.g. "T01" or "S01-T01"): native task-suffix
172
+ // first; fall back to N sprint × Tnn loop.
173
+ if (ID_PATTERNS.task.test(arg) || ID_PATTERNS.bareTask.test(arg)) {
174
+ const tPart = ID_PATTERNS.bareTask.test(arg) ? suffix : suffix.split("-")[1];
175
+ const fast = await suffixMatch(toolDir, cwd, "task", tPart);
176
+ if (fast && fast.length > 0)
177
+ return pick(fast);
178
+ if (fast === null) {
179
+ const r = await runStoreCli(toolDir, ["query", "--list-sprints"], cwd);
180
+ for (const s of r?.results ?? []) {
181
+ try {
182
+ const taskId = `${s.id}-${tPart}`;
183
+ const rr = await runStoreCli(toolDir, ["query", "--task", taskId], cwd);
184
+ if (rr?.results?.length > 0)
185
+ return pick(rr.results);
186
+ }
187
+ catch (err) {
188
+ if (isDebug())
189
+ console.error(`[forge:resolver] task lookup failed for ${s.id}-${tPart}: ${err.message}`);
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+ catch (err) {
196
+ if (isDebug())
197
+ console.error(`[forge:resolver] suffix search failed: ${err.message}`);
198
+ }
199
+ }
200
+ // ── 4. Keyword search ─────────────────────────────────────────────────────
201
+ setStatus(`Keyword search: "${arg}"…`);
202
+ let keywordResult = null;
203
+ try {
204
+ keywordResult = await runStoreCli(toolDir, ["query", "--keyword", arg], cwd);
205
+ }
206
+ catch (err) {
207
+ if (isDebug())
208
+ console.error(`[forge:resolver] keyword search failed: ${err.message}`);
209
+ }
210
+ if (keywordResult?.results?.length > 0) {
211
+ return pick(filterEntities(keywordResult.results, entityTypes));
212
+ }
213
+ // ── 5. NLP fallback ───────────────────────────────────────────────────────
214
+ setStatus(`Searching Forge store: "${arg}"…`);
215
+ const nlpResult = await runStoreCli(toolDir, ["nlp", arg], cwd);
216
+ const items = filterEntities(nlpResult.results || [], entityTypes);
217
+ if (items.length === 0) {
218
+ setStatus(undefined);
219
+ ctx?.ui.notify(`No records found matching "${arg}"`, "warning");
220
+ return null;
221
+ }
222
+ return pick(items);
223
+ }
224
+ /**
225
+ * Resolve a raw user arg to a canonical entity ID string.
226
+ *
227
+ * 1. If the arg is already a canonical ID that resolves directly → return it.
228
+ * 2. If the arg is an unprefixed ID (e.g. "S22-T03") → suffix-match or
229
+ * prefix-normalize to the canonical form → return it.
230
+ * 3. If the arg is ambiguous → prompt the user (or hard-fail in non-interactive).
231
+ * 4. If the arg cannot be resolved → emit an actionable error and return null.
232
+ */
233
+ export async function resolveToCanonicalId(arg, toolDir, cwd, kind, opts) {
234
+ const { ctx, entityTypes = new Set([kind]), commandLabel = `forge:${kind}` } = opts;
235
+ const resolved = await resolveEntityRef(arg, toolDir, cwd, {
236
+ entityTypes,
237
+ ctx,
238
+ statusLabel: `${commandLabel}: resolving`,
239
+ });
240
+ if (!resolved) {
241
+ ctx?.ui.notify(`× ${commandLabel} — could not resolve "${arg}". ` +
242
+ `No matching ${kind} found. ` +
243
+ `Try a canonical ID like <PREFIX>-S<N>-T<N> or use /forge:read for search.`, "error");
244
+ return null;
245
+ }
246
+ if ("dir" in resolved) {
247
+ // @path resolution — not a task/sprint/bug ID pattern.
248
+ ctx?.ui.notify(`× ${commandLabel} — "${arg}" resolved to a directory path, not a ${kind} ID. ` +
249
+ `Provide a canonical ${kind} ID instead.`, "error");
250
+ return null;
251
+ }
252
+ const canonicalId = resolved.item?.id;
253
+ if (!canonicalId || typeof canonicalId !== "string") {
254
+ ctx?.ui.notify(`× ${commandLabel} — resolved "${arg}" but record has no canonical ID.`, "error");
255
+ return null;
256
+ }
257
+ // If the canonical ID differs from the raw arg, notify the user.
258
+ if (canonicalId !== arg) {
259
+ ctx?.ui.notify(`ℹ ${commandLabel} — resolved "${arg}" → ${canonicalId}`, "info");
260
+ }
261
+ return canonicalId;
262
+ }
263
+ //# sourceMappingURL=store-resolver.js.map