@compilr-dev/cli 0.4.0 → 0.5.1

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 (634) hide show
  1. package/README.md +254 -68
  2. package/dist/.tsbuildinfo.app +1 -0
  3. package/dist/.tsbuildinfo.data +1 -0
  4. package/dist/.tsbuildinfo.domain +1 -0
  5. package/dist/.tsbuildinfo.foundation +1 -0
  6. package/dist/agent.d.ts +134 -4
  7. package/dist/agent.js +345 -166
  8. package/dist/anchors/index.d.ts +9 -0
  9. package/dist/anchors/index.js +9 -0
  10. package/dist/anchors/project-anchors.d.ts +79 -0
  11. package/dist/anchors/project-anchors.js +202 -0
  12. package/dist/auth/api-client.d.ts +124 -0
  13. package/dist/auth/api-client.js +261 -0
  14. package/dist/auth/index.d.ts +172 -0
  15. package/dist/auth/index.js +545 -0
  16. package/dist/auth/storage.d.ts +52 -0
  17. package/dist/auth/storage.js +118 -0
  18. package/dist/changelog/index.d.ts +16 -0
  19. package/dist/changelog/index.js +24 -0
  20. package/dist/changelog/releases.d.ts +17 -0
  21. package/dist/changelog/releases.js +63 -0
  22. package/dist/commands/index.d.ts +2 -1
  23. package/dist/commands-v2/handlers/auth.d.ts +10 -0
  24. package/dist/commands-v2/handlers/auth.js +118 -0
  25. package/dist/commands-v2/handlers/background.d.ts +14 -0
  26. package/dist/commands-v2/handlers/background.js +276 -0
  27. package/dist/commands-v2/handlers/context.d.ts +13 -0
  28. package/dist/commands-v2/handlers/context.js +533 -0
  29. package/dist/commands-v2/handlers/core.d.ts +14 -0
  30. package/dist/commands-v2/handlers/core.js +290 -0
  31. package/dist/commands-v2/handlers/debug.d.ts +11 -0
  32. package/dist/commands-v2/handlers/debug.js +177 -0
  33. package/dist/commands-v2/handlers/delegations.d.ts +8 -0
  34. package/dist/commands-v2/handlers/delegations.js +29 -0
  35. package/dist/commands-v2/handlers/files.d.ts +8 -0
  36. package/dist/commands-v2/handlers/files.js +162 -0
  37. package/dist/commands-v2/handlers/filter.d.ts +9 -0
  38. package/dist/commands-v2/handlers/filter.js +130 -0
  39. package/dist/commands-v2/handlers/games.d.ts +7 -0
  40. package/dist/commands-v2/handlers/games.js +57 -0
  41. package/dist/commands-v2/handlers/index.d.ts +25 -0
  42. package/dist/commands-v2/handlers/index.js +63 -0
  43. package/dist/commands-v2/handlers/mcp.d.ts +8 -0
  44. package/dist/commands-v2/handlers/mcp.js +39 -0
  45. package/dist/commands-v2/handlers/notifications.d.ts +9 -0
  46. package/dist/commands-v2/handlers/notifications.js +34 -0
  47. package/dist/commands-v2/handlers/project.d.ts +22 -0
  48. package/dist/commands-v2/handlers/project.js +1035 -0
  49. package/dist/commands-v2/handlers/reset.d.ts +11 -0
  50. package/dist/commands-v2/handlers/reset.js +118 -0
  51. package/dist/commands-v2/handlers/session.d.ts +161 -0
  52. package/dist/commands-v2/handlers/session.js +805 -0
  53. package/dist/commands-v2/handlers/settings.d.ts +17 -0
  54. package/dist/commands-v2/handlers/settings.js +417 -0
  55. package/dist/commands-v2/handlers/tasks.d.ts +5 -0
  56. package/dist/commands-v2/handlers/tasks.js +36 -0
  57. package/dist/commands-v2/handlers/team.d.ts +9 -0
  58. package/dist/commands-v2/handlers/team.js +549 -0
  59. package/dist/commands-v2/handlers/terminals.d.ts +9 -0
  60. package/dist/commands-v2/handlers/terminals.js +34 -0
  61. package/dist/commands-v2/index.d.ts +14 -0
  62. package/dist/commands-v2/index.js +18 -0
  63. package/dist/commands-v2/registry.d.ts +52 -0
  64. package/dist/commands-v2/registry.js +114 -0
  65. package/dist/commands-v2/types.d.ts +153 -0
  66. package/dist/commands-v2/types.js +7 -0
  67. package/dist/commands.js +123 -7
  68. package/dist/compilr-diff-companion.vsix +0 -0
  69. package/dist/db/index.js +98 -4
  70. package/dist/db/repositories/document-repository.d.ts +2 -0
  71. package/dist/db/repositories/document-repository.js +5 -1
  72. package/dist/db/repositories/index.d.ts +2 -0
  73. package/dist/db/repositories/index.js +1 -0
  74. package/dist/db/repositories/plan-repository.d.ts +101 -0
  75. package/dist/db/repositories/plan-repository.js +275 -0
  76. package/dist/db/repositories/project-repository.d.ts +6 -0
  77. package/dist/db/repositories/project-repository.js +41 -0
  78. package/dist/db/repositories/work-item-repository.d.ts +15 -0
  79. package/dist/db/repositories/work-item-repository.js +69 -4
  80. package/dist/db/schema.d.ts +40 -3
  81. package/dist/db/schema.js +66 -3
  82. package/dist/episodes/index.d.ts +20 -0
  83. package/dist/episodes/index.js +27 -0
  84. package/dist/episodes/recorder.d.ts +51 -0
  85. package/dist/episodes/recorder.js +195 -0
  86. package/dist/episodes/significant-work.d.ts +21 -0
  87. package/dist/episodes/significant-work.js +56 -0
  88. package/dist/episodes/store.d.ts +38 -0
  89. package/dist/episodes/store.js +199 -0
  90. package/dist/episodes/types.d.ts +35 -0
  91. package/dist/episodes/types.js +6 -0
  92. package/dist/episodes/work-at-risk.d.ts +12 -0
  93. package/dist/episodes/work-at-risk.js +38 -0
  94. package/dist/episodes/work-summary-anchor.d.ts +23 -0
  95. package/dist/episodes/work-summary-anchor.js +73 -0
  96. package/dist/games/coins.d.ts +66 -0
  97. package/dist/games/coins.js +165 -0
  98. package/dist/games/game-base.d.ts +84 -0
  99. package/dist/games/game-base.js +204 -0
  100. package/dist/games/index.d.ts +16 -0
  101. package/dist/games/index.js +49 -0
  102. package/dist/games/scores.d.ts +69 -0
  103. package/dist/games/scores.js +191 -0
  104. package/dist/games/tetris/board.d.ts +59 -0
  105. package/dist/games/tetris/board.js +170 -0
  106. package/dist/games/tetris/index.d.ts +109 -0
  107. package/dist/games/tetris/index.js +610 -0
  108. package/dist/games/tetris/pieces.d.ts +44 -0
  109. package/dist/games/tetris/pieces.js +271 -0
  110. package/dist/games/tetris/renderer.d.ts +26 -0
  111. package/dist/games/tetris/renderer.js +77 -0
  112. package/dist/guide/guide-content.d.ts +23 -0
  113. package/dist/guide/guide-content.js +196 -0
  114. package/dist/guide/index.d.ts +8 -0
  115. package/dist/guide/index.js +7 -0
  116. package/dist/guide/shared-content.d.ts +37 -0
  117. package/dist/guide/shared-content.js +1272 -0
  118. package/dist/guide/tutorial-helpers.d.ts +57 -0
  119. package/dist/guide/tutorial-helpers.js +147 -0
  120. package/dist/handlers/ask-user-handlers.d.ts +32 -0
  121. package/dist/handlers/ask-user-handlers.js +104 -0
  122. package/dist/handlers/delegation-handlers.d.ts +34 -0
  123. package/dist/handlers/delegation-handlers.js +291 -0
  124. package/dist/handlers/permission-handler.d.ts +30 -0
  125. package/dist/handlers/permission-handler.js +205 -0
  126. package/dist/index.d.ts +11 -1
  127. package/dist/index.js +615 -179
  128. package/dist/input-handlers/index.d.ts +7 -0
  129. package/dist/input-handlers/index.js +7 -0
  130. package/dist/input-handlers/memory-handler.d.ts +26 -0
  131. package/dist/input-handlers/memory-handler.js +69 -0
  132. package/dist/models/index.d.ts +10 -0
  133. package/dist/models/index.js +12 -0
  134. package/dist/models/model-registry.d.ts +38 -0
  135. package/dist/models/model-registry.js +69 -0
  136. package/dist/models/model-tiers.d.ts +28 -0
  137. package/dist/models/model-tiers.js +71 -0
  138. package/dist/models/model-validation.d.ts +25 -0
  139. package/dist/models/model-validation.js +291 -0
  140. package/dist/models/ollama-models.d.ts +73 -0
  141. package/dist/models/ollama-models.js +178 -0
  142. package/dist/models/provider-types.d.ts +6 -0
  143. package/dist/models/provider-types.js +1 -0
  144. package/dist/models/providers.d.ts +35 -0
  145. package/dist/models/providers.js +58 -0
  146. package/dist/models/types.d.ts +4 -0
  147. package/dist/models/types.js +4 -0
  148. package/dist/multi-agent/activity.d.ts +21 -0
  149. package/dist/multi-agent/activity.js +34 -0
  150. package/dist/multi-agent/agent-selection.d.ts +55 -0
  151. package/dist/multi-agent/agent-selection.js +90 -0
  152. package/dist/multi-agent/artifacts.d.ts +197 -0
  153. package/dist/multi-agent/artifacts.js +379 -0
  154. package/dist/multi-agent/checkpointer.d.ts +138 -0
  155. package/dist/multi-agent/checkpointer.js +471 -0
  156. package/dist/multi-agent/collision-utils.d.ts +16 -0
  157. package/dist/multi-agent/collision-utils.js +28 -0
  158. package/dist/multi-agent/context-resolver.d.ts +97 -0
  159. package/dist/multi-agent/context-resolver.js +316 -0
  160. package/dist/multi-agent/custom-agents.d.ts +83 -0
  161. package/dist/multi-agent/custom-agents.js +227 -0
  162. package/dist/multi-agent/delegation-tracker.d.ts +157 -0
  163. package/dist/multi-agent/delegation-tracker.js +243 -0
  164. package/dist/multi-agent/file-lock-hook.d.ts +29 -0
  165. package/dist/multi-agent/file-lock-hook.js +97 -0
  166. package/dist/multi-agent/file-locks.d.ts +58 -0
  167. package/dist/multi-agent/file-locks.js +194 -0
  168. package/dist/multi-agent/index.d.ts +24 -0
  169. package/dist/multi-agent/index.js +30 -0
  170. package/dist/multi-agent/mention-parser.d.ts +64 -0
  171. package/dist/multi-agent/mention-parser.js +146 -0
  172. package/dist/multi-agent/notification-manager.d.ts +84 -0
  173. package/dist/multi-agent/notification-manager.js +224 -0
  174. package/dist/multi-agent/pending-requests.d.ts +122 -0
  175. package/dist/multi-agent/pending-requests.js +155 -0
  176. package/dist/multi-agent/session-registry.d.ts +139 -0
  177. package/dist/multi-agent/session-registry.js +514 -0
  178. package/dist/multi-agent/shared-context.d.ts +293 -0
  179. package/dist/multi-agent/shared-context.js +671 -0
  180. package/dist/multi-agent/skill-requirements.d.ts +66 -0
  181. package/dist/multi-agent/skill-requirements.js +178 -0
  182. package/dist/multi-agent/task-assignment.d.ts +69 -0
  183. package/dist/multi-agent/task-assignment.js +123 -0
  184. package/dist/multi-agent/task-suggestion.d.ts +31 -0
  185. package/dist/multi-agent/task-suggestion.js +72 -0
  186. package/dist/multi-agent/team-agent.d.ts +201 -0
  187. package/dist/multi-agent/team-agent.js +488 -0
  188. package/dist/multi-agent/team.d.ts +286 -0
  189. package/dist/multi-agent/team.js +610 -0
  190. package/dist/multi-agent/tool-config.d.ts +110 -0
  191. package/dist/multi-agent/tool-config.js +661 -0
  192. package/dist/multi-agent/types.d.ts +211 -0
  193. package/dist/multi-agent/types.js +617 -0
  194. package/dist/prompts/plan-mode-prompt.d.ts +11 -0
  195. package/dist/prompts/plan-mode-prompt.js +95 -0
  196. package/dist/repl-helpers.d.ts +63 -0
  197. package/dist/repl-helpers.js +319 -0
  198. package/dist/repl-v2.d.ts +554 -0
  199. package/dist/repl-v2.js +3286 -0
  200. package/dist/session/index.d.ts +6 -0
  201. package/dist/session/index.js +6 -0
  202. package/dist/session/project-session-manager.d.ts +158 -0
  203. package/dist/session/project-session-manager.js +650 -0
  204. package/dist/settings/index.d.ts +156 -13
  205. package/dist/settings/index.js +377 -24
  206. package/dist/settings/mcp-config.d.ts +76 -0
  207. package/dist/settings/mcp-config.js +143 -0
  208. package/dist/settings/paths.d.ts +114 -0
  209. package/dist/settings/paths.js +270 -0
  210. package/dist/shared-handlers.d.ts +62 -0
  211. package/dist/shared-handlers.js +48 -0
  212. package/dist/system-prompt/builder.d.ts +5 -0
  213. package/dist/system-prompt/builder.js +4 -0
  214. package/dist/system-prompt/index.d.ts +18 -0
  215. package/dist/system-prompt/index.js +18 -0
  216. package/dist/system-prompt/modules.d.ts +5 -0
  217. package/dist/system-prompt/modules.js +4 -0
  218. package/dist/tabbed-menu.js +2 -1
  219. package/dist/templates/compilr-md-import.d.ts +16 -0
  220. package/dist/templates/compilr-md-import.js +241 -0
  221. package/dist/templates/compilr-md.js +10 -58
  222. package/dist/templates/config-json.d.ts +1 -25
  223. package/dist/templates/index.d.ts +2 -0
  224. package/dist/templates/index.js +35 -75
  225. package/dist/themes/colors.js +3 -1
  226. package/dist/themes/registry.d.ts +5 -36
  227. package/dist/themes/registry.js +11 -95
  228. package/dist/themes/types.d.ts +3 -38
  229. package/dist/themes/types.js +2 -2
  230. package/dist/tool-names.d.ts +108 -0
  231. package/dist/tool-names.js +227 -0
  232. package/dist/tools/anchor-tools.d.ts +31 -0
  233. package/dist/tools/anchor-tools.js +255 -0
  234. package/dist/tools/artifact-tools.d.ts +42 -0
  235. package/dist/tools/artifact-tools.js +328 -0
  236. package/dist/tools/ask-user-simple.d.ts +1 -1
  237. package/dist/tools/ask-user-simple.js +2 -1
  238. package/dist/tools/ask-user.d.ts +1 -1
  239. package/dist/tools/ask-user.js +2 -1
  240. package/dist/tools/backlog-wrappers.d.ts +56 -0
  241. package/dist/tools/backlog-wrappers.js +353 -0
  242. package/dist/tools/backlog.d.ts +2 -2
  243. package/dist/tools/backlog.js +2 -2
  244. package/dist/tools/db-tools.d.ts +12 -0
  245. package/dist/tools/db-tools.js +14 -0
  246. package/dist/tools/delegate-background.d.ts +27 -0
  247. package/dist/tools/delegate-background.js +115 -0
  248. package/dist/tools/delegate.d.ts +22 -0
  249. package/dist/tools/delegate.js +97 -0
  250. package/dist/tools/delegation-status.d.ts +16 -0
  251. package/dist/tools/delegation-status.js +128 -0
  252. package/dist/tools/document-db.d.ts +43 -0
  253. package/dist/tools/document-db.js +220 -0
  254. package/dist/tools/guide-tool.d.ts +12 -0
  255. package/dist/tools/guide-tool.js +59 -0
  256. package/dist/tools/handoff.d.ts +25 -0
  257. package/dist/tools/handoff.js +99 -0
  258. package/dist/tools/meta-tools.d.ts +26 -0
  259. package/dist/tools/meta-tools.js +47 -0
  260. package/dist/tools/plan-tools.d.ts +54 -0
  261. package/dist/tools/plan-tools.js +338 -0
  262. package/dist/tools/platform-adapter.d.ts +29 -0
  263. package/dist/tools/platform-adapter.js +394 -0
  264. package/dist/tools/project-db.d.ts +34 -0
  265. package/dist/tools/project-db.js +39 -0
  266. package/dist/tools/recall-work-tool.d.ts +18 -0
  267. package/dist/tools/recall-work-tool.js +82 -0
  268. package/dist/tools/workitem-db.d.ts +135 -0
  269. package/dist/tools/workitem-db.js +730 -0
  270. package/dist/tools.d.ts +67 -2
  271. package/dist/tools.js +238 -38
  272. package/dist/ui/ask-user-overlay.d.ts +2 -2
  273. package/dist/ui/ask-user-overlay.js +443 -535
  274. package/dist/ui/ask-user-simple-overlay.d.ts +2 -2
  275. package/dist/ui/ask-user-simple-overlay.js +182 -209
  276. package/dist/ui/autocomplete-controller.d.ts +42 -0
  277. package/dist/ui/autocomplete-controller.js +384 -0
  278. package/dist/ui/base/index.d.ts +26 -0
  279. package/dist/ui/base/index.js +33 -0
  280. package/dist/ui/base/inline-overlay-utils.d.ts +217 -0
  281. package/dist/ui/base/inline-overlay-utils.js +320 -0
  282. package/dist/ui/base/inline-overlay.d.ts +159 -0
  283. package/dist/ui/base/inline-overlay.js +257 -0
  284. package/dist/ui/base/key-utils.d.ts +15 -0
  285. package/dist/ui/base/key-utils.js +30 -0
  286. package/dist/ui/base/overlay-base-v2.d.ts +203 -0
  287. package/dist/ui/base/overlay-base-v2.js +260 -0
  288. package/dist/ui/base/overlay-base.d.ts +156 -0
  289. package/dist/ui/base/overlay-base.js +238 -0
  290. package/dist/ui/base/overlay-lifecycle.d.ts +65 -0
  291. package/dist/ui/base/overlay-lifecycle.js +159 -0
  292. package/dist/ui/base/overlay-types.d.ts +185 -0
  293. package/dist/ui/base/overlay-types.js +7 -0
  294. package/dist/ui/base/render-utils.d.ts +27 -0
  295. package/dist/ui/base/render-utils.js +36 -0
  296. package/dist/ui/base/screen-stack.d.ts +148 -0
  297. package/dist/ui/base/screen-stack.js +184 -0
  298. package/dist/ui/base/tabbed-list-overlay-v2.d.ts +118 -0
  299. package/dist/ui/base/tabbed-list-overlay-v2.js +335 -0
  300. package/dist/ui/base/tabbed-list-overlay.d.ts +153 -0
  301. package/dist/ui/base/tabbed-list-overlay.js +369 -0
  302. package/dist/ui/constants/labels.d.ts +14 -0
  303. package/dist/ui/constants/labels.js +51 -0
  304. package/dist/ui/conversation-store.d.ts +55 -0
  305. package/dist/ui/conversation-store.js +107 -0
  306. package/dist/ui/conversation.d.ts +75 -4
  307. package/dist/ui/conversation.js +376 -165
  308. package/dist/ui/diff.d.ts +7 -1
  309. package/dist/ui/diff.js +85 -48
  310. package/dist/ui/ephemeral.d.ts +1 -1
  311. package/dist/ui/ephemeral.js +4 -10
  312. package/dist/ui/features/index.d.ts +34 -0
  313. package/dist/ui/features/index.js +34 -0
  314. package/dist/ui/features/input-feature.d.ts +85 -0
  315. package/dist/ui/features/input-feature.js +238 -0
  316. package/dist/ui/features/list-feature.d.ts +155 -0
  317. package/dist/ui/features/list-feature.js +244 -0
  318. package/dist/ui/features/pagination-feature.d.ts +154 -0
  319. package/dist/ui/features/pagination-feature.js +238 -0
  320. package/dist/ui/features/search-feature.d.ts +148 -0
  321. package/dist/ui/features/search-feature.js +185 -0
  322. package/dist/ui/features/tab-feature.d.ts +194 -0
  323. package/dist/ui/features/tab-feature.js +307 -0
  324. package/dist/ui/file-autocomplete.d.ts +24 -0
  325. package/dist/ui/file-autocomplete.js +56 -0
  326. package/dist/ui/footer-renderer.d.ts +69 -0
  327. package/dist/ui/footer-renderer.js +431 -0
  328. package/dist/ui/footer.d.ts +181 -7
  329. package/dist/ui/footer.js +523 -74
  330. package/dist/ui/guardrail-overlay.d.ts +29 -0
  331. package/dist/ui/guardrail-overlay.js +145 -0
  332. package/dist/ui/index.d.ts +1 -1
  333. package/dist/ui/index.js +1 -3
  334. package/dist/ui/input-controller.d.ts +51 -0
  335. package/dist/ui/input-controller.js +176 -0
  336. package/dist/ui/input-prompt.d.ts +135 -33
  337. package/dist/ui/input-prompt.js +728 -337
  338. package/dist/ui/iteration-limit-overlay.d.ts +2 -2
  339. package/dist/ui/iteration-limit-overlay.js +92 -128
  340. package/dist/ui/keyboard-handler.d.ts +57 -0
  341. package/dist/ui/keyboard-handler.js +557 -0
  342. package/dist/ui/keys-overlay.d.ts +1 -0
  343. package/dist/ui/keys-overlay.js +203 -141
  344. package/dist/ui/line-utils.d.ts +88 -0
  345. package/dist/ui/line-utils.js +150 -0
  346. package/dist/ui/live-region-facade.d.ts +42 -0
  347. package/dist/ui/live-region-facade.js +205 -0
  348. package/dist/ui/live-region.d.ts +157 -0
  349. package/dist/ui/live-region.js +379 -0
  350. package/dist/ui/mascot/expressions.d.ts +32 -0
  351. package/dist/ui/mascot/expressions.js +213 -0
  352. package/dist/ui/mascot/index.d.ts +8 -0
  353. package/dist/ui/mascot/index.js +8 -0
  354. package/dist/ui/mascot/renderer.d.ts +19 -0
  355. package/dist/ui/mascot/renderer.js +132 -0
  356. package/dist/ui/overlay/data/tutorial-content.d.ts +9 -0
  357. package/dist/ui/overlay/data/tutorial-content.js +9 -0
  358. package/dist/ui/overlay/data/tutorial-registry.d.ts +12 -0
  359. package/dist/ui/overlay/data/tutorial-registry.js +116 -0
  360. package/dist/ui/overlay/data/tutorial-types.d.ts +35 -0
  361. package/dist/ui/overlay/data/tutorial-types.js +6 -0
  362. package/dist/ui/overlay/data/tutorials/basics/first-conversation.d.ts +7 -0
  363. package/dist/ui/overlay/data/tutorials/basics/first-conversation.js +220 -0
  364. package/dist/ui/overlay/data/tutorials/basics/first-project.d.ts +7 -0
  365. package/dist/ui/overlay/data/tutorials/basics/first-project.js +284 -0
  366. package/dist/ui/overlay/data/tutorials/basics/navigation.d.ts +8 -0
  367. package/dist/ui/overlay/data/tutorials/basics/navigation.js +22 -0
  368. package/dist/ui/overlay/data/tutorials/basics/welcome.d.ts +7 -0
  369. package/dist/ui/overlay/data/tutorials/basics/welcome.js +174 -0
  370. package/dist/ui/overlay/data/tutorials/config/context-management.d.ts +7 -0
  371. package/dist/ui/overlay/data/tutorials/config/context-management.js +158 -0
  372. package/dist/ui/overlay/data/tutorials/config/mcp-servers.d.ts +8 -0
  373. package/dist/ui/overlay/data/tutorials/config/mcp-servers.js +155 -0
  374. package/dist/ui/overlay/data/tutorials/config/model-selection.d.ts +7 -0
  375. package/dist/ui/overlay/data/tutorials/config/model-selection.js +162 -0
  376. package/dist/ui/overlay/data/tutorials/config/permissions-safety.d.ts +7 -0
  377. package/dist/ui/overlay/data/tutorials/config/permissions-safety.js +163 -0
  378. package/dist/ui/overlay/data/tutorials/config/settings-config.d.ts +7 -0
  379. package/dist/ui/overlay/data/tutorials/config/settings-config.js +166 -0
  380. package/dist/ui/overlay/data/tutorials/planning/arch.d.ts +7 -0
  381. package/dist/ui/overlay/data/tutorials/planning/arch.js +168 -0
  382. package/dist/ui/overlay/data/tutorials/planning/backlog.d.ts +7 -0
  383. package/dist/ui/overlay/data/tutorials/planning/backlog.js +103 -0
  384. package/dist/ui/overlay/data/tutorials/planning/build.d.ts +7 -0
  385. package/dist/ui/overlay/data/tutorials/planning/build.js +173 -0
  386. package/dist/ui/overlay/data/tutorials/planning/design.d.ts +7 -0
  387. package/dist/ui/overlay/data/tutorials/planning/design.js +205 -0
  388. package/dist/ui/overlay/data/tutorials/planning/docs.d.ts +7 -0
  389. package/dist/ui/overlay/data/tutorials/planning/docs.js +143 -0
  390. package/dist/ui/overlay/data/tutorials/planning/prd.d.ts +7 -0
  391. package/dist/ui/overlay/data/tutorials/planning/prd.js +173 -0
  392. package/dist/ui/overlay/data/tutorials/planning/scaffold.d.ts +7 -0
  393. package/dist/ui/overlay/data/tutorials/planning/scaffold.js +164 -0
  394. package/dist/ui/overlay/data/tutorials/planning/sketch.d.ts +7 -0
  395. package/dist/ui/overlay/data/tutorials/planning/sketch.js +58 -0
  396. package/dist/ui/overlay/data/tutorials/projects/anchors.d.ts +7 -0
  397. package/dist/ui/overlay/data/tutorials/projects/anchors.js +248 -0
  398. package/dist/ui/overlay/data/tutorials/projects/import-project.d.ts +7 -0
  399. package/dist/ui/overlay/data/tutorials/projects/import-project.js +172 -0
  400. package/dist/ui/overlay/data/tutorials/projects/managing-projects.d.ts +8 -0
  401. package/dist/ui/overlay/data/tutorials/projects/managing-projects.js +212 -0
  402. package/dist/ui/overlay/data/tutorials/projects/new-project.d.ts +7 -0
  403. package/dist/ui/overlay/data/tutorials/projects/new-project.js +251 -0
  404. package/dist/ui/overlay/data/tutorials/projects/session-management.d.ts +7 -0
  405. package/dist/ui/overlay/data/tutorials/projects/session-management.js +169 -0
  406. package/dist/ui/overlay/data/tutorials/teams/background-execution.d.ts +7 -0
  407. package/dist/ui/overlay/data/tutorials/teams/background-execution.js +171 -0
  408. package/dist/ui/overlay/data/tutorials/teams/multi-terminal.d.ts +8 -0
  409. package/dist/ui/overlay/data/tutorials/teams/multi-terminal.js +147 -0
  410. package/dist/ui/overlay/data/tutorials/teams/task-assignment.d.ts +7 -0
  411. package/dist/ui/overlay/data/tutorials/teams/task-assignment.js +204 -0
  412. package/dist/ui/overlay/data/tutorials/teams/team-overview.d.ts +7 -0
  413. package/dist/ui/overlay/data/tutorials/teams/team-overview.js +165 -0
  414. package/dist/ui/overlay/data/tutorials/teams/working-with-agents.d.ts +7 -0
  415. package/dist/ui/overlay/data/tutorials/teams/working-with-agents.js +172 -0
  416. package/dist/ui/overlay/impl/agents-overlay-v2.d.ts +45 -0
  417. package/dist/ui/overlay/impl/agents-overlay-v2.js +814 -0
  418. package/dist/ui/overlay/impl/anchors-overlay-v2.d.ts +47 -0
  419. package/dist/ui/overlay/impl/anchors-overlay-v2.js +749 -0
  420. package/dist/ui/overlay/impl/arch-type-overlay-v2.d.ts +37 -0
  421. package/dist/ui/overlay/impl/arch-type-overlay-v2.js +240 -0
  422. package/dist/ui/overlay/impl/artifact-detail-overlay-v2.d.ts +43 -0
  423. package/dist/ui/overlay/impl/artifact-detail-overlay-v2.js +232 -0
  424. package/dist/ui/overlay/impl/artifact-overlay-v2.d.ts +40 -0
  425. package/dist/ui/overlay/impl/artifact-overlay-v2.js +115 -0
  426. package/dist/ui/overlay/impl/ask-user-overlay-v2.d.ts +72 -0
  427. package/dist/ui/overlay/impl/ask-user-overlay-v2.js +581 -0
  428. package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.d.ts +46 -0
  429. package/dist/ui/overlay/impl/ask-user-simple-overlay-v2.js +204 -0
  430. package/dist/ui/overlay/impl/background-overlay-v2.d.ts +40 -0
  431. package/dist/ui/overlay/impl/background-overlay-v2.js +147 -0
  432. package/dist/ui/overlay/impl/backlog-overlay-v2.d.ts +52 -0
  433. package/dist/ui/overlay/impl/backlog-overlay-v2.js +681 -0
  434. package/dist/ui/overlay/impl/changelog-overlay-v2.d.ts +44 -0
  435. package/dist/ui/overlay/impl/changelog-overlay-v2.js +165 -0
  436. package/dist/ui/overlay/impl/commands-overlay-v2.d.ts +33 -0
  437. package/dist/ui/overlay/impl/commands-overlay-v2.js +439 -0
  438. package/dist/ui/overlay/impl/config-overlay-v2.d.ts +111 -0
  439. package/dist/ui/overlay/impl/config-overlay-v2.js +718 -0
  440. package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.d.ts +83 -0
  441. package/dist/ui/overlay/impl/custom-agent-form-overlay-v2.js +711 -0
  442. package/dist/ui/overlay/impl/dashboard-overlay-v2.d.ts +57 -0
  443. package/dist/ui/overlay/impl/dashboard-overlay-v2.js +382 -0
  444. package/dist/ui/overlay/impl/delegations-overlay-v2.d.ts +28 -0
  445. package/dist/ui/overlay/impl/delegations-overlay-v2.js +279 -0
  446. package/dist/ui/overlay/impl/docs-overlay-v2.d.ts +45 -0
  447. package/dist/ui/overlay/impl/docs-overlay-v2.js +117 -0
  448. package/dist/ui/overlay/impl/document-detail-overlay-v2.d.ts +84 -0
  449. package/dist/ui/overlay/impl/document-detail-overlay-v2.js +1112 -0
  450. package/dist/ui/overlay/impl/filter-overlay-v2.d.ts +41 -0
  451. package/dist/ui/overlay/impl/filter-overlay-v2.js +110 -0
  452. package/dist/ui/overlay/impl/games-overlay-v2.d.ts +31 -0
  453. package/dist/ui/overlay/impl/games-overlay-v2.js +135 -0
  454. package/dist/ui/overlay/impl/guardrail-overlay-v2.d.ts +43 -0
  455. package/dist/ui/overlay/impl/guardrail-overlay-v2.js +114 -0
  456. package/dist/ui/overlay/impl/help-overlay-v2.d.ts +57 -0
  457. package/dist/ui/overlay/impl/help-overlay-v2.js +287 -0
  458. package/dist/ui/overlay/impl/init-setup-overlay-v2.d.ts +25 -0
  459. package/dist/ui/overlay/impl/init-setup-overlay-v2.js +97 -0
  460. package/dist/ui/overlay/impl/iteration-limit-overlay-v2.d.ts +35 -0
  461. package/dist/ui/overlay/impl/iteration-limit-overlay-v2.js +105 -0
  462. package/dist/ui/overlay/impl/keys-overlay-v2.d.ts +41 -0
  463. package/dist/ui/overlay/impl/keys-overlay-v2.js +248 -0
  464. package/dist/ui/overlay/impl/login-overlay-v2.d.ts +49 -0
  465. package/dist/ui/overlay/impl/login-overlay-v2.js +277 -0
  466. package/dist/ui/overlay/impl/mascot-overlay-v2.d.ts +41 -0
  467. package/dist/ui/overlay/impl/mascot-overlay-v2.js +138 -0
  468. package/dist/ui/overlay/impl/mcp-overlay-v2.d.ts +63 -0
  469. package/dist/ui/overlay/impl/mcp-overlay-v2.js +907 -0
  470. package/dist/ui/overlay/impl/model-overlay-v2.d.ts +93 -0
  471. package/dist/ui/overlay/impl/model-overlay-v2.js +1143 -0
  472. package/dist/ui/overlay/impl/model-warning-overlay-v2.d.ts +46 -0
  473. package/dist/ui/overlay/impl/model-warning-overlay-v2.js +132 -0
  474. package/dist/ui/overlay/impl/new-overlay-v2.d.ts +108 -0
  475. package/dist/ui/overlay/impl/new-overlay-v2.js +1243 -0
  476. package/dist/ui/overlay/impl/notifications-overlay-v2.d.ts +20 -0
  477. package/dist/ui/overlay/impl/notifications-overlay-v2.js +116 -0
  478. package/dist/ui/overlay/impl/onboarding-wizard-overlay-v2.d.ts +76 -0
  479. package/dist/ui/overlay/impl/onboarding-wizard-overlay-v2.js +728 -0
  480. package/dist/ui/overlay/impl/pending-overlay-v2.d.ts +51 -0
  481. package/dist/ui/overlay/impl/pending-overlay-v2.js +445 -0
  482. package/dist/ui/overlay/impl/permission-overlay-v2.d.ts +36 -0
  483. package/dist/ui/overlay/impl/permission-overlay-v2.js +380 -0
  484. package/dist/ui/overlay/impl/permissions-overlay-v2.d.ts +85 -0
  485. package/dist/ui/overlay/impl/permissions-overlay-v2.js +820 -0
  486. package/dist/ui/overlay/impl/plan-approval-overlay-v2.d.ts +35 -0
  487. package/dist/ui/overlay/impl/plan-approval-overlay-v2.js +181 -0
  488. package/dist/ui/overlay/impl/project-edit-overlay-v2.d.ts +36 -0
  489. package/dist/ui/overlay/impl/project-edit-overlay-v2.js +195 -0
  490. package/dist/ui/overlay/impl/projects-overlay-v2.d.ts +37 -0
  491. package/dist/ui/overlay/impl/projects-overlay-v2.js +733 -0
  492. package/dist/ui/overlay/impl/reset-overlay-v2.d.ts +39 -0
  493. package/dist/ui/overlay/impl/reset-overlay-v2.js +107 -0
  494. package/dist/ui/overlay/impl/resume-overlay-v2.d.ts +60 -0
  495. package/dist/ui/overlay/impl/resume-overlay-v2.js +414 -0
  496. package/dist/ui/overlay/impl/session-mode-overlay-v2.d.ts +43 -0
  497. package/dist/ui/overlay/impl/session-mode-overlay-v2.js +124 -0
  498. package/dist/ui/overlay/impl/tasks-overlay-v2.d.ts +28 -0
  499. package/dist/ui/overlay/impl/tasks-overlay-v2.js +283 -0
  500. package/dist/ui/overlay/impl/team-overlay-v2.d.ts +86 -0
  501. package/dist/ui/overlay/impl/team-overlay-v2.js +692 -0
  502. package/dist/ui/overlay/impl/terminals-overlay-v2.d.ts +26 -0
  503. package/dist/ui/overlay/impl/terminals-overlay-v2.js +217 -0
  504. package/dist/ui/overlay/impl/theme-overlay-v2.d.ts +42 -0
  505. package/dist/ui/overlay/impl/theme-overlay-v2.js +135 -0
  506. package/dist/ui/overlay/impl/tools-overlay-v2.d.ts +47 -0
  507. package/dist/ui/overlay/impl/tools-overlay-v2.js +214 -0
  508. package/dist/ui/overlay/impl/tutorial-overlay-v2.d.ts +45 -0
  509. package/dist/ui/overlay/impl/tutorial-overlay-v2.js +212 -0
  510. package/dist/ui/overlay/impl/workflow-overlay-v2.d.ts +80 -0
  511. package/dist/ui/overlay/impl/workflow-overlay-v2.js +641 -0
  512. package/dist/ui/overlay/index.d.ts +52 -0
  513. package/dist/ui/overlay/index.js +54 -0
  514. package/dist/ui/overlay/key-utils.d.ts +6 -0
  515. package/dist/ui/overlay/key-utils.js +6 -0
  516. package/dist/ui/overlay/types.d.ts +140 -0
  517. package/dist/ui/overlay/types.js +22 -0
  518. package/dist/ui/overlay-manager.d.ts +43 -0
  519. package/dist/ui/overlay-manager.js +238 -0
  520. package/dist/ui/overlays.d.ts +0 -4
  521. package/dist/ui/overlays.js +4 -460
  522. package/dist/ui/permission-overlay.d.ts +1 -1
  523. package/dist/ui/permission-overlay.js +189 -300
  524. package/dist/ui/providers/types.d.ts +178 -0
  525. package/dist/ui/providers/types.js +9 -0
  526. package/dist/ui/render-modes.d.ts +36 -0
  527. package/dist/ui/render-modes.js +44 -0
  528. package/dist/ui/startup-menu.d.ts +36 -0
  529. package/dist/ui/startup-menu.js +236 -0
  530. package/dist/ui/status-bar-controller.d.ts +33 -0
  531. package/dist/ui/status-bar-controller.js +99 -0
  532. package/dist/ui/subagent-renderer.d.ts +117 -0
  533. package/dist/ui/subagent-renderer.js +318 -0
  534. package/dist/ui/terminal-autocomplete-utils.d.ts +23 -0
  535. package/dist/ui/terminal-autocomplete-utils.js +83 -0
  536. package/dist/ui/terminal-codes.d.ts +94 -0
  537. package/dist/ui/terminal-codes.js +124 -0
  538. package/dist/ui/terminal-line-builders.d.ts +17 -0
  539. package/dist/ui/terminal-line-builders.js +42 -0
  540. package/dist/ui/terminal-render-item.d.ts +16 -0
  541. package/dist/ui/terminal-render-item.js +267 -0
  542. package/dist/ui/terminal-renderer.d.ts +220 -0
  543. package/dist/ui/terminal-renderer.js +750 -0
  544. package/dist/ui/terminal-types.d.ts +179 -0
  545. package/dist/ui/terminal-types.js +34 -0
  546. package/dist/ui/terminal-ui.d.ts +331 -0
  547. package/dist/ui/terminal-ui.js +819 -0
  548. package/dist/ui/terminal.d.ts +20 -0
  549. package/dist/ui/terminal.js +72 -0
  550. package/dist/ui/todo-zone.d.ts +19 -1
  551. package/dist/ui/todo-zone.js +124 -38
  552. package/dist/ui/tool-formatters.d.ts +16 -0
  553. package/dist/ui/tool-formatters.js +1027 -0
  554. package/dist/ui/turn-metrics.d.ts +56 -0
  555. package/dist/ui/turn-metrics.js +75 -0
  556. package/dist/ui/types.d.ts +28 -0
  557. package/dist/ui/types.js +1 -0
  558. package/dist/ui/vscode-diff-ipc.d.ts +102 -0
  559. package/dist/ui/vscode-diff-ipc.js +385 -0
  560. package/dist/utils/credentials.d.ts +24 -5
  561. package/dist/utils/credentials.js +123 -9
  562. package/dist/utils/debug-log.d.ts +28 -0
  563. package/dist/utils/debug-log.js +57 -0
  564. package/dist/utils/format-tokens.d.ts +13 -0
  565. package/dist/utils/format-tokens.js +18 -0
  566. package/dist/utils/git-config.d.ts +26 -0
  567. package/dist/utils/git-config.js +54 -0
  568. package/dist/utils/message-utils.d.ts +61 -0
  569. package/dist/utils/message-utils.js +72 -0
  570. package/dist/utils/model-tiers.d.ts +8 -1
  571. package/dist/utils/model-tiers.js +39 -17
  572. package/dist/utils/open-browser.d.ts +5 -0
  573. package/dist/utils/open-browser.js +32 -0
  574. package/dist/utils/path-safety.d.ts +56 -0
  575. package/dist/utils/path-safety.js +240 -0
  576. package/dist/utils/project-detection.d.ts +58 -0
  577. package/dist/utils/project-detection.js +424 -0
  578. package/dist/utils/project-memory.js +2 -1
  579. package/dist/utils/project-status.d.ts +2 -2
  580. package/dist/utils/startup-perf.d.ts +18 -0
  581. package/dist/utils/startup-perf.js +60 -0
  582. package/dist/utils/token-tracker.d.ts +62 -0
  583. package/dist/utils/token-tracker.js +150 -0
  584. package/dist/utils/token-types.d.ts +23 -0
  585. package/dist/utils/token-types.js +18 -0
  586. package/dist/utils/types/config-types.d.ts +32 -0
  587. package/dist/utils/types/config-types.js +8 -0
  588. package/dist/utils/update-checker.d.ts +28 -0
  589. package/dist/utils/update-checker.js +106 -0
  590. package/dist/utils/version.d.ts +7 -0
  591. package/dist/utils/version.js +10 -0
  592. package/dist/utils/vscode-detect.d.ts +39 -0
  593. package/dist/utils/vscode-detect.js +137 -0
  594. package/dist/workflow/guided-mode-injector.d.ts +42 -0
  595. package/dist/workflow/guided-mode-injector.js +191 -0
  596. package/dist/workflow/index.d.ts +8 -0
  597. package/dist/workflow/index.js +8 -0
  598. package/dist/workflow/step-criteria.d.ts +62 -0
  599. package/dist/workflow/step-criteria.js +150 -0
  600. package/dist/workflow/step-tracker.d.ts +92 -0
  601. package/dist/workflow/step-tracker.js +141 -0
  602. package/package.json +32 -12
  603. package/dist/index.old.d.ts +0 -7
  604. package/dist/index.old.js +0 -1014
  605. package/dist/repl.d.ts +0 -121
  606. package/dist/repl.js +0 -1878
  607. package/dist/templates/claude-md.d.ts +0 -7
  608. package/dist/templates/claude-md.js +0 -189
  609. package/dist/test-autocomplete.d.ts +0 -7
  610. package/dist/test-autocomplete.js +0 -85
  611. package/dist/test-tabbed-menu.d.ts +0 -7
  612. package/dist/test-tabbed-menu.js +0 -25
  613. package/dist/tool-selector.d.ts +0 -71
  614. package/dist/tool-selector.js +0 -184
  615. package/dist/ui/agents-overlay.d.ts +0 -12
  616. package/dist/ui/agents-overlay.js +0 -501
  617. package/dist/ui/arch-type-overlay.d.ts +0 -20
  618. package/dist/ui/arch-type-overlay.js +0 -229
  619. package/dist/ui/backlog-overlay.d.ts +0 -17
  620. package/dist/ui/backlog-overlay.js +0 -786
  621. package/dist/ui/commands-overlay.d.ts +0 -11
  622. package/dist/ui/commands-overlay.js +0 -410
  623. package/dist/ui/config-overlay.d.ts +0 -34
  624. package/dist/ui/config-overlay.js +0 -977
  625. package/dist/ui/init-overlay.d.ts +0 -24
  626. package/dist/ui/init-overlay.js +0 -525
  627. package/dist/ui/input-prompt-v2.d.ts +0 -179
  628. package/dist/ui/input-prompt-v2.js +0 -991
  629. package/dist/ui/model-warning-overlay.d.ts +0 -30
  630. package/dist/ui/model-warning-overlay.js +0 -171
  631. package/dist/ui/tools-overlay.d.ts +0 -26
  632. package/dist/ui/tools-overlay.js +0 -278
  633. package/dist/ui/tutorial-overlay.d.ts +0 -10
  634. package/dist/ui/tutorial-overlay.js +0 -936
@@ -0,0 +1,1035 @@
1
+ /**
2
+ * Project Commands for REPL V2
3
+ *
4
+ * Commands for project management: init, backlog, workflow, anchors, design, sketch, refine
5
+ */
6
+ import { executeCommand } from '../registry.js';
7
+ import { BacklogOverlayV2, WorkflowOverlayV2, DocsOverlayV2, DocumentDetailOverlayV2, AnchorsOverlayV2, ProjectsOverlayV2, NewProjectOverlayV2, OnboardingWizardOverlayV2, KeysOverlayV2, ArchTypeOverlayV2, ModelWarningOverlayV2 } from '../../ui/overlay/index.js';
8
+ import { projectRepository, workItemRepository } from '../../db/repositories/index.js';
9
+ import { setCurrentProject, getCurrentProject } from '../../tools/project-db.js';
10
+ import { getSkillPrompt } from '../../repl-helpers.js';
11
+ import { getModelTier, modelMeetsTier } from '../../utils/model-tiers.js';
12
+ import { getCurrentProjectIdForTracking, handleProjectSwitch } from './session.js';
13
+ // =============================================================================
14
+ // Helper Functions
15
+ // =============================================================================
16
+ /**
17
+ * Sync the footer project name with the current project.
18
+ * Call after any overlay that might change the current project.
19
+ */
20
+ function syncFooterWithCurrentProject(ctx) {
21
+ const current = getCurrentProject();
22
+ ctx.ui.setProjectName(current?.displayName ?? null);
23
+ }
24
+ // =============================================================================
25
+ // New Command
26
+ // =============================================================================
27
+ export const newCommand = {
28
+ name: 'new',
29
+ description: 'Create a new project',
30
+ details: 'Interactive wizard to scaffold a new project. Asks about project name, type, tech stack, and documentation preferences. Creates project structure with COMPILR.md, backlog, and optional separate docs repo.',
31
+ examples: [{ code: '/new' }],
32
+ interactions: [
33
+ '8-step wizard (0-7)',
34
+ '↑/↓ for selection steps, type for input steps',
35
+ 'Enter to confirm, Esc to go back',
36
+ ],
37
+ async execute(_args, ctx) {
38
+ // Track project ID before overlay (for session/team switch handling)
39
+ const oldProjectId = getCurrentProjectIdForTracking();
40
+ const newProjectOverlay = new NewProjectOverlayV2();
41
+ const result = await ctx.ui.showOverlay(newProjectOverlay);
42
+ // User cancelled
43
+ if (!result?.created) {
44
+ return true;
45
+ }
46
+ // Check if this was an import or new project
47
+ const isImport = result.imported === true;
48
+ // Show success message
49
+ if (isImport) {
50
+ ctx.ui.print({ type: 'success', message: `Project imported: ${result.projectPath ?? ''}` });
51
+ }
52
+ else {
53
+ ctx.ui.print({ type: 'success', message: `Project created: ${result.projectPath ?? ''}` });
54
+ if (result.docsPath) {
55
+ ctx.ui.print({ type: 'success', message: `Docs repo created: ${result.docsPath}` });
56
+ }
57
+ }
58
+ // Register project in database if tracking is enabled
59
+ if (result.trackInDatabase && result.projectName && result.projectPath) {
60
+ try {
61
+ // Determine display name - for imports, use detected name; for new projects, prettify
62
+ const displayName = result.detectedProject?.displayName
63
+ ?? result.projectName.replace(/-/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
64
+ const project = projectRepository.create({
65
+ name: result.projectName,
66
+ display_name: displayName,
67
+ description: result.description,
68
+ path: result.projectPath,
69
+ type: 'general',
70
+ workflow_mode: result.workflowMode ?? 'flexible',
71
+ git_remote: result.gitRemote,
72
+ // For imports, include detected language and framework
73
+ language: result.detectedProject?.language ?? undefined,
74
+ framework: result.detectedProject?.framework ?? undefined,
75
+ package_manager: result.detectedProject?.packageManager ?? undefined,
76
+ });
77
+ // For imports, set lifecycle to 'active' immediately
78
+ if (isImport) {
79
+ projectRepository.update(project.id, { lifecycle_state: 'active' });
80
+ }
81
+ setCurrentProject({ id: project.id, name: project.name, displayName: project.displayName, path: project.path });
82
+ ctx.ui.setProjectName(project.displayName);
83
+ ctx.ui.print({ type: 'success', message: `Project tracked in database (${result.workflowMode ?? 'flexible'} mode)` });
84
+ ctx.ui.print({ type: 'success', message: `"${project.displayName}" is now the current project` });
85
+ // Handle project switch - saves old session/team and creates fresh team for new project
86
+ const switchResult = await handleProjectSwitch(oldProjectId, ctx.agent ?? null, ctx.team && ctx.agentFactory ? {
87
+ team: ctx.team,
88
+ agentFactory: ctx.agentFactory,
89
+ } : undefined);
90
+ if (switchResult?.switched) {
91
+ // Update the team if a new one was created
92
+ if (switchResult.newTeam && ctx.setTeam) {
93
+ ctx.setTeam(switchResult.newTeam);
94
+ // Update footer with new active agent
95
+ const active = switchResult.newTeam.getActive();
96
+ ctx.ui.setActiveTeamAgent({
97
+ id: active.id,
98
+ displayName: active.displayName,
99
+ mascot: active.mascot,
100
+ });
101
+ }
102
+ ctx.ui.print({ type: 'info', message: 'Fresh team and session started for project.' });
103
+ }
104
+ }
105
+ catch (dbError) {
106
+ ctx.ui.print({ type: 'warning', message: `Could not register in database: ${dbError.message}` });
107
+ }
108
+ }
109
+ // Show next steps
110
+ ctx.ui.print({ type: 'info', message: '' });
111
+ if (isImport) {
112
+ // Import-specific next steps
113
+ ctx.ui.print({ type: 'info', message: 'Next steps:' });
114
+ ctx.ui.print({ type: 'info', message: ' Review the generated COMPILR.md' });
115
+ ctx.ui.print({ type: 'info', message: ' Add existing work items with /backlog' });
116
+ ctx.ui.print({ type: 'info', message: ' Or ask the agent to explore the codebase' });
117
+ }
118
+ else {
119
+ // New project next steps
120
+ ctx.ui.print({ type: 'info', message: 'Next steps:' });
121
+ ctx.ui.print({ type: 'info', message: ` cd ${result.projectPath?.split('/').pop() ?? 'project'}` });
122
+ ctx.ui.print({ type: 'info', message: ' npm install' });
123
+ ctx.ui.print({ type: 'info', message: ' npm run dev' });
124
+ }
125
+ ctx.ui.print({ type: 'info', message: '' });
126
+ // Hint for agent interaction
127
+ const compilrMdPath = result.docsPath
128
+ ? `${result.docsPath}/COMPILR.md`
129
+ : `${result.projectPath ?? '.'}/COMPILR.md`;
130
+ ctx.ui.print({ type: 'info', message: `Tip: Ask the agent to read ${compilrMdPath} to get started!` });
131
+ if (!isImport) {
132
+ ctx.ui.print({ type: 'info', message: 'When ready to define requirements, type /design' });
133
+ }
134
+ return true;
135
+ },
136
+ };
137
+ // =============================================================================
138
+ // Init Command (Setup Status Placeholder)
139
+ // =============================================================================
140
+ export const initCommand = {
141
+ name: 'init',
142
+ description: 'Run the CLI setup wizard',
143
+ details: 'Opens the onboarding wizard to configure API keys, git settings, and CLI preferences. Re-runnable anytime to update settings.',
144
+ examples: [{ code: '/init' }],
145
+ interactions: [
146
+ '↑/↓ to navigate wizard steps',
147
+ 'Enter to confirm, Esc to go back',
148
+ 'Type to enter values in input steps',
149
+ ],
150
+ async execute(_args, ctx) {
151
+ // Show onboarding wizard (same as first-run experience)
152
+ // Loop if user chooses to configure keys
153
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
154
+ while (true) {
155
+ const wizard = new OnboardingWizardOverlayV2();
156
+ const result = await ctx.ui.showOverlay(wizard);
157
+ if (result?.openKeys) {
158
+ // User chose to configure keys - show keys overlay then loop back
159
+ const keysOverlay = new KeysOverlayV2();
160
+ await ctx.ui.showOverlay(keysOverlay);
161
+ continue;
162
+ }
163
+ // Done (completed or cancelled)
164
+ break;
165
+ }
166
+ return true;
167
+ },
168
+ };
169
+ // =============================================================================
170
+ // Backlog Command
171
+ // =============================================================================
172
+ export const backlogCommand = {
173
+ name: 'backlog',
174
+ description: 'View and manage project backlog',
175
+ details: 'Opens an interactive overlay to browse, filter, and manage backlog items. You can add new items, change status/priority, search, and view details.',
176
+ examples: [{ code: '/backlog' }],
177
+ interactions: [
178
+ 'Tab cycles: All → Feature → Bug → Tech-Debt → Chore → Active',
179
+ '↑/↓ to navigate, ←/→ for pages',
180
+ 'Enter for details, Space to toggle status',
181
+ '/ to search, n for new item',
182
+ 'Esc to close',
183
+ ],
184
+ async execute(_args, ctx) {
185
+ // Get team agent IDs for owner selection in detail screen
186
+ const teamAgentIds = ctx.team?.getAgentIds() ?? [];
187
+ const backlogOverlay = new BacklogOverlayV2(undefined, teamAgentIds);
188
+ const result = await ctx.ui.showOverlay(backlogOverlay);
189
+ if (result?.modified) {
190
+ ctx.ui.print({ type: 'success', message: 'Backlog updated.' });
191
+ }
192
+ return true;
193
+ },
194
+ };
195
+ // =============================================================================
196
+ // Workflow Command
197
+ // =============================================================================
198
+ export const workflowCommand = {
199
+ name: 'workflow',
200
+ description: 'View project workflow dashboard',
201
+ details: 'Displays the current project workflow status, progress through phases (init → design → backlog → scaffold → build), and recommended next actions. Helps you understand where you are in the development process.',
202
+ examples: [{ code: '/workflow' }],
203
+ interactions: [
204
+ '↑/↓ to navigate actions',
205
+ 'Enter to run selected action',
206
+ 'Esc to close',
207
+ ],
208
+ async execute(_args, ctx) {
209
+ // Track project ID before overlay (for session switch handling)
210
+ const oldProjectId = getCurrentProjectIdForTracking();
211
+ const workflowOverlay = new WorkflowOverlayV2();
212
+ const result = await ctx.ui.showOverlay(workflowOverlay);
213
+ // Handle project switch if it occurred (includes team switching)
214
+ const switchResult = await handleProjectSwitch(oldProjectId, ctx.agent ?? null, ctx.team && ctx.agentFactory ? {
215
+ team: ctx.team,
216
+ agentFactory: ctx.agentFactory,
217
+ } : undefined);
218
+ if (switchResult?.switched) {
219
+ // Update the team if a new one was created/loaded
220
+ if (switchResult.newTeam && ctx.setTeam) {
221
+ ctx.setTeam(switchResult.newTeam);
222
+ // Update footer with new active agent
223
+ const active = switchResult.newTeam.getActive();
224
+ ctx.ui.setActiveTeamAgent({
225
+ id: active.id,
226
+ displayName: active.displayName,
227
+ mascot: active.mascot,
228
+ });
229
+ }
230
+ if (switchResult.sessionRestored) {
231
+ ctx.ui.print({ type: 'info', message: `Session restored (${String(switchResult.messageCount)} messages).` });
232
+ }
233
+ else {
234
+ ctx.ui.print({ type: 'info', message: 'Started fresh session for this project.' });
235
+ }
236
+ }
237
+ // Handle workflow result - execute command if returned
238
+ if (result?.command) {
239
+ // Strip leading slash and execute the command
240
+ const cmd = result.command.replace(/^\//, '');
241
+ await executeCommand(cmd, '', ctx);
242
+ }
243
+ // Sync footer with current project (may have changed during overlay)
244
+ syncFooterWithCurrentProject(ctx);
245
+ return true;
246
+ },
247
+ };
248
+ // =============================================================================
249
+ // Anchors Command
250
+ // =============================================================================
251
+ export const anchorsCommand = {
252
+ name: 'anchors',
253
+ description: 'View and manage anchors (persistent context)',
254
+ details: 'Anchors are critical pieces of information that survive context compaction. They are always included at the top of the context window. Manage both global anchors and project-specific anchors.',
255
+ examples: [{ code: '/anchors' }],
256
+ interactions: [
257
+ '↑/↓ to navigate anchors',
258
+ '[a] Add new anchor',
259
+ '[e] or Enter to edit',
260
+ '[d] to delete',
261
+ '[r] to refresh',
262
+ 'Esc to close',
263
+ ],
264
+ async execute(_args, ctx) {
265
+ const anchorsOverlay = new AnchorsOverlayV2();
266
+ const result = await ctx.ui.showOverlay(anchorsOverlay);
267
+ if (result?.modified) {
268
+ ctx.ui.print({ type: 'success', message: 'Anchors updated.' });
269
+ }
270
+ return true;
271
+ },
272
+ };
273
+ // =============================================================================
274
+ // Design Command
275
+ // =============================================================================
276
+ export const designCommand = {
277
+ name: 'design',
278
+ description: 'Agent-driven requirements gathering',
279
+ details: 'Comprehensive requirements gathering workflow. The agent guides you through vision, features, and technical context phases, then creates a PRD and populates the backlog with 5-15 items. Best used after /new.',
280
+ examples: [{ code: '/design' }],
281
+ async execute(_args, ctx) {
282
+ // Check if a project is set
283
+ const currentProject = getCurrentProject();
284
+ if (!currentProject) {
285
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
286
+ return true;
287
+ }
288
+ // Check model tier - /design works best with large models
289
+ const currentModel = ctx.model ?? 'unknown';
290
+ if (!modelMeetsTier(currentModel, '/design')) {
291
+ const modelTier = getModelTier(currentModel);
292
+ const warningOverlay = new ModelWarningOverlayV2({
293
+ command: '/design',
294
+ currentModel,
295
+ currentTier: modelTier.tier,
296
+ suggestedModel: modelTier.suggestedUpgrade,
297
+ alternativeCommand: '/sketch',
298
+ });
299
+ const choice = await ctx.ui.showOverlay(warningOverlay);
300
+ switch (choice) {
301
+ case 'cancel':
302
+ return true;
303
+ case 'alternative':
304
+ // Run /sketch instead
305
+ await executeCommand('sketch', '', ctx);
306
+ return true;
307
+ case 'switch':
308
+ // TODO: Hot-switch model when setModel is available in ctx
309
+ ctx.ui.print({ type: 'info', message: `Continuing with ${currentModel} (model switching not yet available in V2)` });
310
+ break;
311
+ case 'continue':
312
+ // Proceed with current model
313
+ break;
314
+ }
315
+ }
316
+ // Get design skill prompt
317
+ const designPrompt = getSkillPrompt('design');
318
+ if (!designPrompt) {
319
+ ctx.ui.print({ type: 'error', message: 'Design skill not found.' });
320
+ return true;
321
+ }
322
+ // Build full message for agent with project context
323
+ const fullMessage = `I want to design my project and create the backlog.
324
+
325
+ ## PROJECT CONTEXT (IMPORTANT)
326
+ - Project Name: ${currentProject.name} (ID: ${String(currentProject.id)})
327
+ - This is a NEW project being designed from scratch
328
+ - Do NOT scan the filesystem - the current directory is NOT the project
329
+ - Do NOT use detect_project, glob, read_file, or ls tools
330
+ - Focus ONLY on gathering requirements via ask_user questions
331
+
332
+ ## DOCUMENT STORAGE (CRITICAL)
333
+ Save all documents and backlog items using the database - do NOT write files directly.
334
+ - For backlog items: \`workitem_add({ type: "feature", title: "...", description: "...", priority: "high" })\`
335
+ - For documents: \`project_document_add({ doc_type: "prd", title: "...", content: "..." })\`
336
+ - The database is the source of truth for all project documents
337
+ - Do NOT use write_file or edit tools for documentation
338
+
339
+ ${designPrompt}
340
+
341
+ Please start by using todo_write to track the design phases, then begin with Phase 1: Vision. Use the ask_user tool to gather information efficiently.`;
342
+ // Queue message for agent
343
+ ctx.queueAgentMessage({
344
+ message: fullMessage,
345
+ displayMessage: 'Start the design process for my project.',
346
+ });
347
+ return true;
348
+ },
349
+ };
350
+ // =============================================================================
351
+ // Sketch Command
352
+ // =============================================================================
353
+ export const sketchCommand = {
354
+ name: 'sketch',
355
+ description: 'Quick 6-question project outline',
356
+ details: 'Lightweight alternative to /design. Asks 6 quick questions and creates 3-8 backlog items. Good for small projects or when you want to get started quickly.',
357
+ examples: [{ code: '/sketch' }],
358
+ execute(_args, ctx) {
359
+ // Check if a project is set
360
+ const currentProject = getCurrentProject();
361
+ if (!currentProject) {
362
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
363
+ return Promise.resolve(true);
364
+ }
365
+ // Get sketch skill prompt
366
+ const sketchPrompt = getSkillPrompt('sketch');
367
+ if (!sketchPrompt) {
368
+ ctx.ui.print({ type: 'error', message: 'Sketch skill not found.' });
369
+ return Promise.resolve(true);
370
+ }
371
+ // Build full message for agent with project context
372
+ const fullMessage = `I want to quickly outline my project.
373
+
374
+ ## PROJECT CONTEXT (IMPORTANT)
375
+ - Project Name: ${currentProject.name} (ID: ${String(currentProject.id)})
376
+ - This is a NEW project being designed from scratch
377
+ - Do NOT scan the filesystem - the current directory is NOT the project
378
+ - Do NOT use detect_project, glob, read_file, or ls tools
379
+ - Focus ONLY on gathering requirements via ask_user questions
380
+
381
+ ## DOCUMENT STORAGE (CRITICAL)
382
+ Save all documents and backlog items using the database - do NOT write files directly.
383
+ - For backlog items: \`workitem_add({ type: "feature", title: "...", description: "..." })\`
384
+ - For documents: \`project_document_add({ doc_type: "prd", title: "...", content: "..." })\`
385
+ - Do NOT use write_file or edit tools for documentation
386
+
387
+ ${sketchPrompt}
388
+
389
+ Please start by asking me about the type of application I'm building using the ask_user_simple tool.`;
390
+ // Queue message for agent
391
+ ctx.queueAgentMessage({
392
+ message: fullMessage,
393
+ displayMessage: 'Quick project outline.',
394
+ });
395
+ return Promise.resolve(true);
396
+ },
397
+ };
398
+ // =============================================================================
399
+ // Refine Command
400
+ // =============================================================================
401
+ export const refineCommand = {
402
+ name: 'refine',
403
+ description: 'Iterative refinement of requirements',
404
+ details: 'Iteratively refine backlog items. Can focus on a specific item or let the agent suggest what to refine. Useful for breaking down large items or adding acceptance criteria.',
405
+ examples: [
406
+ { code: '/refine', description: 'Agent picks item to refine' },
407
+ { code: '/refine REQ-003', description: 'Refine specific item' },
408
+ ],
409
+ async execute(args, ctx) {
410
+ // Check if a project is set
411
+ const currentProject = getCurrentProject();
412
+ if (!currentProject) {
413
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
414
+ return true;
415
+ }
416
+ // Check if project has work items in database
417
+ const counts = workItemRepository.getStatusCounts(currentProject.id);
418
+ const totalItems = counts.backlog + counts.in_progress + counts.completed + counts.skipped;
419
+ if (totalItems === 0) {
420
+ ctx.ui.print({ type: 'error', message: 'No backlog items found. Run /design first to create initial requirements.' });
421
+ return true;
422
+ }
423
+ // Check if a specific item ID was provided (e.g., /refine REQ-001)
424
+ const itemId = args.trim().toUpperCase();
425
+ const isFocusedRefine = itemId && /^[A-Z]+-\d{3}$/.test(itemId);
426
+ // For full refine mode (no item ID), check model tier and warn
427
+ if (!isFocusedRefine) {
428
+ const currentModel = ctx.model ?? 'unknown';
429
+ if (!modelMeetsTier(currentModel, '/refine')) {
430
+ const modelTier = getModelTier(currentModel);
431
+ const warningOverlay = new ModelWarningOverlayV2({
432
+ command: '/refine',
433
+ currentModel,
434
+ currentTier: modelTier.tier,
435
+ suggestedModel: modelTier.suggestedUpgrade,
436
+ alternativeCommand: '/refine <ITEM-ID>',
437
+ });
438
+ const choice = await ctx.ui.showOverlay(warningOverlay);
439
+ switch (choice) {
440
+ case 'cancel':
441
+ return true;
442
+ case 'alternative':
443
+ ctx.ui.print({ type: 'info', message: 'Tip: Use /refine <ITEM-ID> for focused refinement with smaller models.' });
444
+ ctx.ui.print({ type: 'info', message: ' Example: /refine REQ-001' });
445
+ return true;
446
+ case 'switch':
447
+ // TODO: Hot-switch model when setModel is available in ctx
448
+ ctx.ui.print({ type: 'info', message: `Continuing with ${currentModel} (model switching not yet available in V2)` });
449
+ break;
450
+ case 'continue':
451
+ break;
452
+ }
453
+ }
454
+ }
455
+ // Get appropriate skill prompt
456
+ const skillName = isFocusedRefine ? 'refine-item' : 'refine';
457
+ const refinePrompt = getSkillPrompt(skillName);
458
+ if (!refinePrompt) {
459
+ ctx.ui.print({ type: 'error', message: `${skillName} skill not found.` });
460
+ return true;
461
+ }
462
+ // Build message based on mode
463
+ const userIntent = isFocusedRefine
464
+ ? `I want to refine backlog item ${itemId}.`
465
+ : 'I want to refine my project requirements.';
466
+ const agentInstructions = isFocusedRefine
467
+ ? `Please use workitem_query to find item "${itemId}", then guide me through refining it using workitem_update.`
468
+ : 'Please start by using workitem_query with limit:10 to get an overview, then ask me what I\'d like to focus on using ask_user_simple.';
469
+ const fullMessage = `${userIntent}
470
+
471
+ ## PROJECT CONTEXT (IMPORTANT)
472
+ - Project Name: ${currentProject.name} (ID: ${String(currentProject.id)})
473
+ - Do NOT scan the filesystem - the current directory is NOT the project
474
+ - Do NOT use detect_project, glob, read_file, or ls tools
475
+ - Use ONLY database tools to access project data
476
+
477
+ ## DOCUMENT STORAGE (CRITICAL)
478
+ Use database tools for all updates - do NOT write files directly.
479
+ - Use \`workitem_query\` to read items
480
+ - Use \`workitem_update\` to modify items
481
+ - Do NOT use write_file or edit tools
482
+
483
+ ${refinePrompt}
484
+
485
+ ${agentInstructions}`;
486
+ // Queue message for agent
487
+ ctx.queueAgentMessage({
488
+ message: fullMessage,
489
+ displayMessage: userIntent,
490
+ });
491
+ return true;
492
+ },
493
+ };
494
+ // =============================================================================
495
+ // Build Command
496
+ // =============================================================================
497
+ export const buildCommand = {
498
+ name: 'build',
499
+ description: 'Implement a backlog item',
500
+ details: 'Picks the highest priority backlog item (or a specific one) and guides the agent through implementing it. Includes planning, coding, testing, and committing. Auto-detects if project scaffold is needed first.',
501
+ examples: [
502
+ { code: '/build', description: 'Pick highest priority item' },
503
+ { code: '/build REQ-003', description: 'Build specific item' },
504
+ { code: '/build scaffold', description: 'Create project structure first' },
505
+ ],
506
+ async execute(args, ctx) {
507
+ const argTrimmed = args.trim();
508
+ // Handle `/build scaffold` - redirect to scaffold command
509
+ if (argTrimmed.toLowerCase() === 'scaffold') {
510
+ await executeCommand('scaffold', '', ctx);
511
+ return true;
512
+ }
513
+ // Check if a project is set
514
+ const currentProject = getCurrentProject();
515
+ if (!currentProject) {
516
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
517
+ return true;
518
+ }
519
+ // Check if project has a path set (REQUIRED for building)
520
+ if (!currentProject.path) {
521
+ ctx.ui.print({ type: 'error', message: 'Project path not set. Cannot build without a target directory.' });
522
+ ctx.ui.print({ type: 'info', message: 'Tip: Update the project path in /projects to specify where files should be created.' });
523
+ return true;
524
+ }
525
+ // Warn if cwd doesn't match project path (common source of confusion)
526
+ const buildCwd = process.cwd();
527
+ if (buildCwd !== currentProject.path) {
528
+ ctx.ui.print({ type: 'warning', message: `Working directory differs from project path!` });
529
+ ctx.ui.print({ type: 'info', message: ` cwd: ${buildCwd}` });
530
+ ctx.ui.print({ type: 'info', message: ` project: ${currentProject.path}` });
531
+ ctx.ui.print({ type: 'info', message: `Files will be created/modified in the project path, not cwd.` });
532
+ }
533
+ // Parse item ID argument (e.g., "REQ-001")
534
+ const requestedItemId = argTrimmed.toUpperCase();
535
+ const isSpecificItem = requestedItemId && /^[A-Z]+-\d{3}$/.test(requestedItemId);
536
+ // Find the item to build
537
+ let selectedItem;
538
+ if (isSpecificItem) {
539
+ // Get specific item by ID
540
+ selectedItem = workItemRepository.getByItemId(currentProject.id, requestedItemId);
541
+ if (!selectedItem) {
542
+ ctx.ui.print({ type: 'error', message: `Work item "${requestedItemId}" not found.` });
543
+ return true;
544
+ }
545
+ if (selectedItem.status !== 'backlog') {
546
+ ctx.ui.print({ type: 'warning', message: `Work item "${requestedItemId}" is already ${selectedItem.status}. Use /backlog to view status.` });
547
+ return true;
548
+ }
549
+ }
550
+ else {
551
+ // Auto-select highest priority backlog item
552
+ selectedItem = workItemRepository.getNext(currentProject.id);
553
+ if (!selectedItem) {
554
+ ctx.ui.print({ type: 'info', message: 'No backlog items found. Create items with /design or /backlog first.' });
555
+ ctx.ui.print({ type: 'info', message: 'Or run /build scaffold to create the project foundation.' });
556
+ return true;
557
+ }
558
+ }
559
+ // Check model tier for full builds (not targeted item)
560
+ if (!isSpecificItem) {
561
+ const currentModel = ctx.model ?? 'unknown';
562
+ if (!modelMeetsTier(currentModel, '/build')) {
563
+ const modelTier = getModelTier(currentModel);
564
+ const warningOverlay = new ModelWarningOverlayV2({
565
+ command: '/build',
566
+ currentModel,
567
+ currentTier: modelTier.tier,
568
+ suggestedModel: modelTier.suggestedUpgrade,
569
+ alternativeCommand: `/build ${selectedItem.itemId}`,
570
+ });
571
+ const choice = await ctx.ui.showOverlay(warningOverlay);
572
+ switch (choice) {
573
+ case 'cancel':
574
+ return true;
575
+ case 'alternative':
576
+ ctx.ui.print({ type: 'info', message: `Tip: Use /build ${selectedItem.itemId} to build a specific item with smaller models.` });
577
+ return true;
578
+ case 'switch':
579
+ ctx.ui.print({ type: 'info', message: `Continuing with ${currentModel} (model switching not yet available in V2)` });
580
+ break;
581
+ case 'continue':
582
+ break;
583
+ }
584
+ }
585
+ }
586
+ // Get build skill prompt and replace placeholders
587
+ let buildPrompt = getSkillPrompt('build');
588
+ if (!buildPrompt) {
589
+ ctx.ui.print({ type: 'error', message: 'Build skill not found.' });
590
+ return true;
591
+ }
592
+ // Replace {{projectPath}} and item placeholders with actual values
593
+ buildPrompt = buildPrompt
594
+ .replace(/\{\{projectPath\}\}/g, currentProject.path)
595
+ .replace(/\{\{item_id\}\}/g, selectedItem.itemId)
596
+ .replace(/\{\{item_title\}\}/g, selectedItem.title)
597
+ .replace(/\{\{item_type\}\}/g, selectedItem.type)
598
+ .replace(/\{\{item_priority\}\}/g, selectedItem.priority)
599
+ .replace(/\{\{item_description\}\}/g, selectedItem.description ?? 'No description provided');
600
+ // Build full message for agent with explicit project path context
601
+ const fullMessage = `I want to implement backlog item ${selectedItem.itemId}: "${selectedItem.title}".
602
+
603
+ ## PROJECT CONTEXT (CRITICAL)
604
+ - Project Name: ${currentProject.name} (ID: ${String(currentProject.id)})
605
+ - **Project Directory: ${currentProject.path}**
606
+ - ALL files MUST be created/modified in this directory
607
+
608
+ ## WORK ITEM DETAILS
609
+ - Item ID: ${selectedItem.itemId}
610
+ - Type: ${selectedItem.type}
611
+ - Priority: ${selectedItem.priority}
612
+ - Description: ${selectedItem.description ?? 'No description provided'}
613
+
614
+ ## TOOL RESTRICTIONS (CRITICAL)
615
+ - Do NOT use detect_project or find_project_root
616
+ - Do NOT scan filesystem to detect project type
617
+ - The project path above is the ONLY source of truth for where to create/modify files
618
+ - Use \`project_document_get\` to read PRD and architecture docs from the database
619
+ - Use \`workitem_query\` to read related backlog items from the database
620
+ - Use \`workitem_update\` to update the item status when done
621
+
622
+ ## FILE OPERATIONS (CRITICAL)
623
+ When creating or modifying files:
624
+ - Use absolute paths starting with: ${currentProject.path}/
625
+ - Example: write_file({ path: "${currentProject.path}/src/index.ts", ... })
626
+ - NEVER use relative paths
627
+ - IGNORE the current working directory (cwd) - it may be different from the project!
628
+ - The user may have started the CLI from a different folder
629
+
630
+ ${buildPrompt}
631
+
632
+ Please start by:
633
+ 1. Using todo_write to plan the implementation steps
634
+ 2. Reading project documents from the database (project_document_list, project_document_get)
635
+ 3. Updating the work item status to 'in_progress' using workitem_update
636
+ 4. Implementing the feature
637
+ 5. Updating the work item status to 'completed' when done`;
638
+ // Queue message for agent
639
+ ctx.queueAgentMessage({
640
+ message: fullMessage,
641
+ displayMessage: `Build ${selectedItem.itemId}: ${selectedItem.title}`,
642
+ });
643
+ return true;
644
+ },
645
+ };
646
+ // =============================================================================
647
+ // Note Command
648
+ // =============================================================================
649
+ export const noteCommand = {
650
+ name: 'note',
651
+ description: 'Create a session note capturing work done',
652
+ details: 'Creates a structured markdown note summarizing the current session including changes made, decisions, blockers, and next steps. Optionally provide a title.',
653
+ examples: [
654
+ { code: '/note', description: 'Auto-generated title' },
655
+ { code: '/note "Fixed auth bug"', description: 'Custom title' },
656
+ ],
657
+ execute(args, ctx) {
658
+ // Check if a project is set
659
+ const currentProject = getCurrentProject();
660
+ if (!currentProject) {
661
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
662
+ return Promise.resolve(true);
663
+ }
664
+ // Get session-notes skill prompt
665
+ const notePrompt = getSkillPrompt('session-notes');
666
+ if (!notePrompt) {
667
+ ctx.ui.print({ type: 'error', message: 'Session-notes skill not found.' });
668
+ return Promise.resolve(true);
669
+ }
670
+ // Check for optional title argument
671
+ const noteTitle = args.trim();
672
+ // Build title instruction based on whether title was provided
673
+ const titleInstruction = noteTitle
674
+ ? `The session title is: "${noteTitle}"`
675
+ : 'Please ask me for a title using ask_user_simple, or generate one from the session summary.';
676
+ // Build full message for agent
677
+ const fullMessage = `I want to create a session note capturing what we've done.
678
+
679
+ ## PROJECT CONTEXT
680
+ - Project Name: ${currentProject.name} (ID: ${String(currentProject.id)})
681
+
682
+ ## DOCUMENT STORAGE (CRITICAL)
683
+ Save session notes using the database - do NOT write files directly.
684
+ - Tool: \`project_document_add({ doc_type: "session-note", title: "...", content: "..." })\`
685
+ - The database is the source of truth for all project documents
686
+ - Do NOT use write_file or edit tools for documentation
687
+
688
+ ${notePrompt}
689
+
690
+ ${titleInstruction}
691
+
692
+ Review the conversation context to understand what was accomplished, then create the session note.`;
693
+ // Queue message for agent
694
+ ctx.queueAgentMessage({
695
+ message: fullMessage,
696
+ displayMessage: noteTitle
697
+ ? `Create session note: "${noteTitle}"`
698
+ : 'Create a session note for this session.',
699
+ });
700
+ return Promise.resolve(true);
701
+ },
702
+ };
703
+ // =============================================================================
704
+ // PRD Command
705
+ // =============================================================================
706
+ export const prdCommand = {
707
+ name: 'prd',
708
+ description: 'Amend or enhance the Product Requirements Document',
709
+ details: 'Update or refine the PRD created during /design. The agent reads the existing PRD and guides you through updating specific sections.',
710
+ examples: [
711
+ { code: '/prd', description: 'Interactive section selection' },
712
+ { code: '/prd vision', description: 'Update vision section' },
713
+ { code: '/prd scope', description: 'Update scope section' },
714
+ ],
715
+ execute(args, ctx) {
716
+ // Check if a project is set
717
+ const currentProject = getCurrentProject();
718
+ if (!currentProject) {
719
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
720
+ return Promise.resolve(true);
721
+ }
722
+ // Get PRD skill prompt
723
+ const prdPrompt = getSkillPrompt('prd');
724
+ if (!prdPrompt) {
725
+ ctx.ui.print({ type: 'error', message: 'PRD skill not found.' });
726
+ return Promise.resolve(true);
727
+ }
728
+ // Check for optional section argument
729
+ const section = args.trim().toLowerCase();
730
+ const validSections = ['vision', 'scope', 'technical', 'success'];
731
+ const sectionInstruction = validSections.includes(section)
732
+ ? `The user wants to update the "${section}" section specifically.`
733
+ : 'Ask the user which section they want to update using ask_user_simple.';
734
+ // Build full message for agent with project context
735
+ const fullMessage = `I want to update the Product Requirements Document.
736
+
737
+ ## DOCUMENT STORAGE (CRITICAL)
738
+ Save PRD updates using the database - do NOT write files directly.
739
+ - Project: ${currentProject.name} (ID: ${String(currentProject.id)})
740
+ - Tool: \`project_document_add({ doc_type: "prd", title: "Product Requirements Document", content: "..." })\`
741
+ - The database is the source of truth for all project documents
742
+ - Do NOT use write_file or edit tools for documentation
743
+
744
+ ${prdPrompt}
745
+
746
+ ${sectionInstruction}
747
+
748
+ Start by reading the existing PRD from the database using project_document_get({ doc_type: "prd" }). If no document exists yet, create a new one.`;
749
+ // Queue message for agent
750
+ ctx.queueAgentMessage({
751
+ message: fullMessage,
752
+ displayMessage: section
753
+ ? `Update PRD: ${section} section`
754
+ : 'Update the Product Requirements Document',
755
+ });
756
+ return Promise.resolve(true);
757
+ },
758
+ };
759
+ // =============================================================================
760
+ // Scaffold Command
761
+ // =============================================================================
762
+ export const scaffoldCommand = {
763
+ name: 'scaffold',
764
+ description: 'Create project foundation/structure',
765
+ details: 'Creates the base project structure (folders, config files, dependencies) based on tech stack from COMPILR.md. Use this before implementing features if starting from scratch. Alias for /build scaffold.',
766
+ examples: [{ code: '/scaffold' }],
767
+ async execute(_args, ctx) {
768
+ // Check if a project is set
769
+ const currentProject = getCurrentProject();
770
+ if (!currentProject) {
771
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
772
+ return true;
773
+ }
774
+ // Check if project has a path set (REQUIRED for scaffolding)
775
+ if (!currentProject.path) {
776
+ ctx.ui.print({ type: 'error', message: 'Project path not set. Cannot scaffold without a target directory.' });
777
+ ctx.ui.print({ type: 'info', message: 'Tip: Update the project path in /projects to specify where files should be created.' });
778
+ return true;
779
+ }
780
+ // Warn if cwd doesn't match project path (common source of confusion)
781
+ const cwd = process.cwd();
782
+ if (cwd !== currentProject.path) {
783
+ ctx.ui.print({ type: 'warning', message: `Working directory differs from project path!` });
784
+ ctx.ui.print({ type: 'info', message: ` cwd: ${cwd}` });
785
+ ctx.ui.print({ type: 'info', message: ` project: ${currentProject.path}` });
786
+ ctx.ui.print({ type: 'info', message: `Files will be created in the project path, not cwd.` });
787
+ }
788
+ // Check model tier - /scaffold works best with large models
789
+ const currentModel = ctx.model ?? 'unknown';
790
+ if (!modelMeetsTier(currentModel, '/scaffold')) {
791
+ const modelTier = getModelTier(currentModel);
792
+ const warningOverlay = new ModelWarningOverlayV2({
793
+ command: '/scaffold',
794
+ currentModel,
795
+ currentTier: modelTier.tier,
796
+ suggestedModel: modelTier.suggestedUpgrade,
797
+ });
798
+ const choice = await ctx.ui.showOverlay(warningOverlay);
799
+ switch (choice) {
800
+ case 'cancel':
801
+ return true;
802
+ case 'switch':
803
+ ctx.ui.print({ type: 'info', message: `Continuing with ${currentModel} (model switching not yet available in V2)` });
804
+ break;
805
+ case 'continue':
806
+ // Proceed with current model
807
+ break;
808
+ }
809
+ }
810
+ // Get scaffold skill prompt and replace path placeholder
811
+ let scaffoldPrompt = getSkillPrompt('scaffold');
812
+ if (!scaffoldPrompt) {
813
+ ctx.ui.print({ type: 'error', message: 'Scaffold skill not found.' });
814
+ return true;
815
+ }
816
+ // Replace {{projectPath}} placeholder with actual path
817
+ scaffoldPrompt = scaffoldPrompt.replace(/\{\{projectPath\}\}/g, currentProject.path);
818
+ // Build full message for agent with explicit project path context
819
+ const fullMessage = `I want to create the project scaffold/foundation.
820
+
821
+ ## PROJECT CONTEXT (CRITICAL)
822
+ - Project Name: ${currentProject.name} (ID: ${String(currentProject.id)})
823
+ - **Project Directory: ${currentProject.path}**
824
+ - ALL files MUST be created in this directory
825
+
826
+ ## TOOL RESTRICTIONS (CRITICAL)
827
+ - Do NOT use detect_project or find_project_root
828
+ - Do NOT scan filesystem to detect project type
829
+ - The project path above is the ONLY source of truth for where to create files
830
+ - Use \`project_document_get\` to read PRD and architecture docs from the database
831
+ - Use \`workitem_query\` to read backlog items from the database
832
+
833
+ ## FILE CREATION (CRITICAL)
834
+ When creating files:
835
+ - Use absolute paths starting with: ${currentProject.path}/
836
+ - Example: write_file({ path: "${currentProject.path}/package.json", ... })
837
+ - NEVER use relative paths
838
+ - IGNORE the current working directory (cwd) - it may be different from the project!
839
+ - The user may have started the CLI from a different folder
840
+
841
+ ${scaffoldPrompt}
842
+
843
+ Please start by reading the project documents from the database using project_document_list and project_document_get. Then create a plan with todo_write before generating files.`;
844
+ // Queue message for agent
845
+ ctx.queueAgentMessage({
846
+ message: fullMessage,
847
+ displayMessage: 'Create project scaffold.',
848
+ });
849
+ return true;
850
+ },
851
+ };
852
+ // =============================================================================
853
+ // Arch Command
854
+ // =============================================================================
855
+ export const archCommand = {
856
+ name: 'arch',
857
+ description: 'Create architecture documentation (ADRs, diagrams, etc.)',
858
+ details: 'Guides you through creating architecture documentation. Choose from ADRs (Architecture Decision Records), system diagrams, data models, or API designs. The agent asks questions and generates properly formatted documentation.',
859
+ examples: [
860
+ { code: '/arch', description: 'Interactive type selection' },
861
+ { code: '/arch decision', description: 'Create ADR directly' },
862
+ { code: '/arch diagram', description: 'Create system diagram' },
863
+ ],
864
+ interactions: [
865
+ '↑/↓ or 1-5 to select type',
866
+ 'Enter to confirm',
867
+ 'Esc to cancel',
868
+ ],
869
+ async execute(_args, ctx) {
870
+ // Check if a project is set (use database, not filesystem)
871
+ const currentProject = getCurrentProject();
872
+ if (!currentProject) {
873
+ ctx.ui.print({ type: 'error', message: 'No project selected. Run /new or /projects first.' });
874
+ return true;
875
+ }
876
+ // TODO: Check model tier and show warning if too small (like legacy)
877
+ // Show type selection overlay
878
+ const archOverlay = new ArchTypeOverlayV2();
879
+ const archChoice = await ctx.ui.showOverlay(archOverlay);
880
+ if (!archChoice) {
881
+ // User cancelled
882
+ return true;
883
+ }
884
+ // Get architecture skill prompt
885
+ const archPrompt = getSkillPrompt('architecture');
886
+ if (!archPrompt) {
887
+ ctx.ui.print({ type: 'error', message: 'Architecture skill not found.' });
888
+ return true;
889
+ }
890
+ // Build the document type description for display
891
+ const docTypeLabels = {
892
+ 'adr': 'Architecture Decision Record',
893
+ 'diagram': 'System Diagram',
894
+ 'data-model': 'Data Model',
895
+ 'api': 'API Design',
896
+ 'custom': 'Custom Documentation',
897
+ };
898
+ const displayType = archChoice.customTopic
899
+ ? `Custom: ${archChoice.customTopic}`
900
+ : docTypeLabels[archChoice.type];
901
+ // Replace placeholders in skill prompt
902
+ const finalPrompt = archPrompt
903
+ .replace('{{doc_type}}', archChoice.type)
904
+ .replace('{{#if custom_topic}}Custom Topic: {{custom_topic}}{{/if}}', archChoice.customTopic ? `Custom Topic: ${archChoice.customTopic}` : '');
905
+ // Build full message for agent with project context
906
+ const fullMessage = `I want to create architecture documentation.
907
+
908
+ ## DOCUMENT STORAGE (CRITICAL)
909
+ Save architecture documentation using the database - do NOT write files directly.
910
+ - Project: ${currentProject.name} (ID: ${String(currentProject.id)})
911
+ - Tool: \`project_document_add({ doc_type: "architecture", title: "...", content: "..." })\`
912
+ - The database is the source of truth for all project documents
913
+ - Do NOT use write_file or edit tools for documentation
914
+
915
+ ${finalPrompt}
916
+
917
+ Please start by using project_document_list to find any existing PRD, and workitem_query to understand the project backlog. Then use ask_user to gather the information needed for this ${archChoice.type} document.`;
918
+ // Queue message for agent
919
+ ctx.queueAgentMessage({
920
+ message: fullMessage,
921
+ displayMessage: `Create ${displayType} documentation.`,
922
+ });
923
+ return true;
924
+ },
925
+ };
926
+ // =============================================================================
927
+ // Docs Command
928
+ // =============================================================================
929
+ export const docsCommand = {
930
+ name: 'docs',
931
+ description: 'View project documents (PRD, architecture, etc.)',
932
+ details: 'Opens an overlay to browse and read documents stored in the database for the active project. Documents are created by /design, /arch, and other workflow commands.',
933
+ examples: [
934
+ { code: '/docs', description: 'List all documents' },
935
+ ],
936
+ interactions: [
937
+ '↑/↓ or j/k to navigate',
938
+ 'Enter to view document',
939
+ '↑/↓ to scroll content',
940
+ 'Esc to go back or close',
941
+ ],
942
+ async execute(_args, ctx) {
943
+ // Loop: show list → detail → back to list (until user cancels list or Ctrl+C from detail)
944
+ let showList = true;
945
+ while (showList) {
946
+ // Show document list (inline overlay)
947
+ const docsOverlay = new DocsOverlayV2();
948
+ const listResult = await ctx.ui.showOverlay(docsOverlay);
949
+ // User cancelled the list (Esc/Ctrl+C) - exit
950
+ if (!listResult?.selectedDocument || listResult.cancelled) {
951
+ showList = false;
952
+ continue;
953
+ }
954
+ // Show selected document in fullscreen detail overlay
955
+ const detailOverlay = new DocumentDetailOverlayV2(listResult.selectedDocument);
956
+ const detailResult = await ctx.ui.showOverlay(detailOverlay);
957
+ // Ctrl+C from detail - exit completely
958
+ // Esc/q from detail (goBack=true) - loop back to show list again
959
+ showList = detailResult?.goBack === true;
960
+ }
961
+ return true;
962
+ },
963
+ };
964
+ // =============================================================================
965
+ // Projects Command
966
+ // =============================================================================
967
+ export const projectsCommand = {
968
+ name: 'projects',
969
+ description: 'View and manage projects',
970
+ details: 'Opens an interactive overlay to browse, filter, and manage projects tracked in the database. You can view details, open projects, archive, restore, or delete them.',
971
+ examples: [{ code: '/projects' }],
972
+ interactions: [
973
+ 'Tab cycles: All → Active → Paused → Completed → Archived',
974
+ '↑/↓ or j/k to navigate',
975
+ 'Enter to view details and actions',
976
+ 'x to archive/restore project',
977
+ 'd to delete project',
978
+ 'a to show/hide archived',
979
+ 'Esc to close',
980
+ ],
981
+ async execute(_args, ctx) {
982
+ // Track project ID before overlay (for session switch handling)
983
+ const oldProjectId = getCurrentProjectIdForTracking();
984
+ const projectsOverlay = new ProjectsOverlayV2();
985
+ await ctx.ui.showOverlay(projectsOverlay);
986
+ // Handle project switch if it occurred (includes team switching)
987
+ const switchResult = await handleProjectSwitch(oldProjectId, ctx.agent ?? null, ctx.team && ctx.agentFactory ? {
988
+ team: ctx.team,
989
+ agentFactory: ctx.agentFactory,
990
+ } : undefined);
991
+ if (switchResult?.switched) {
992
+ const current = getCurrentProject();
993
+ // Update the team if a new one was created/loaded
994
+ if (switchResult.newTeam && ctx.setTeam) {
995
+ ctx.setTeam(switchResult.newTeam);
996
+ // Update footer with new active agent
997
+ const active = switchResult.newTeam.getActive();
998
+ ctx.ui.setActiveTeamAgent({
999
+ id: active.id,
1000
+ displayName: active.displayName,
1001
+ mascot: active.mascot,
1002
+ });
1003
+ }
1004
+ if (switchResult.sessionRestored) {
1005
+ ctx.ui.print({ type: 'success', message: `Switched to "${current?.displayName ?? 'project'}" - session restored (${String(switchResult.messageCount)} messages).` });
1006
+ }
1007
+ else {
1008
+ ctx.ui.print({ type: 'success', message: `Switched to "${current?.displayName ?? 'project'}" - fresh session.` });
1009
+ }
1010
+ }
1011
+ // Sync footer with current project (may have changed during overlay)
1012
+ syncFooterWithCurrentProject(ctx);
1013
+ return true;
1014
+ },
1015
+ };
1016
+ // =============================================================================
1017
+ // Export All Project Commands
1018
+ // =============================================================================
1019
+ export const projectCommands = [
1020
+ newCommand,
1021
+ initCommand,
1022
+ backlogCommand,
1023
+ workflowCommand,
1024
+ anchorsCommand,
1025
+ designCommand,
1026
+ sketchCommand,
1027
+ refineCommand,
1028
+ buildCommand,
1029
+ noteCommand,
1030
+ prdCommand,
1031
+ scaffoldCommand,
1032
+ archCommand,
1033
+ docsCommand,
1034
+ projectsCommand,
1035
+ ];