@cleocode/cleo 2026.4.161 → 2026.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (857) hide show
  1. package/dist/backfill/audit-columns.d.ts +105 -0
  2. package/dist/backfill/audit-columns.d.ts.map +1 -0
  3. package/dist/backfill/audit-columns.js +258 -0
  4. package/dist/backfill/audit-columns.js.map +1 -0
  5. package/dist/cli/commands/adapter.d.ts +28 -0
  6. package/dist/cli/commands/adapter.d.ts.map +1 -0
  7. package/dist/cli/commands/adapter.js +119 -0
  8. package/dist/cli/commands/adapter.js.map +1 -0
  9. package/dist/cli/commands/add-batch.d.ts +33 -0
  10. package/dist/cli/commands/add-batch.d.ts.map +1 -0
  11. package/dist/cli/commands/add-batch.js +148 -0
  12. package/dist/cli/commands/add-batch.js.map +1 -0
  13. package/dist/cli/commands/add.d.ts +162 -0
  14. package/dist/cli/commands/add.d.ts.map +1 -0
  15. package/dist/cli/commands/add.js +279 -0
  16. package/dist/cli/commands/add.js.map +1 -0
  17. package/dist/cli/commands/admin.d.ts +24 -0
  18. package/dist/cli/commands/admin.d.ts.map +1 -0
  19. package/dist/cli/commands/admin.js +283 -0
  20. package/dist/cli/commands/admin.js.map +1 -0
  21. package/dist/cli/commands/adr.d.ts +33 -0
  22. package/dist/cli/commands/adr.d.ts.map +1 -0
  23. package/dist/cli/commands/adr.js +147 -0
  24. package/dist/cli/commands/adr.js.map +1 -0
  25. package/dist/cli/commands/agent-profile-status.d.ts +98 -0
  26. package/dist/cli/commands/agent-profile-status.d.ts.map +1 -0
  27. package/dist/cli/commands/agent-profile-status.js +71 -0
  28. package/dist/cli/commands/agent-profile-status.js.map +1 -0
  29. package/dist/cli/commands/agent.d.ts +47 -0
  30. package/dist/cli/commands/agent.d.ts.map +1 -0
  31. package/dist/cli/commands/agent.js +2976 -0
  32. package/dist/cli/commands/agent.js.map +1 -0
  33. package/dist/cli/commands/analyze.d.ts +21 -0
  34. package/dist/cli/commands/analyze.d.ts.map +1 -0
  35. package/dist/cli/commands/analyze.js +32 -0
  36. package/dist/cli/commands/analyze.js.map +1 -0
  37. package/dist/cli/commands/archive-stats.d.ts +66 -0
  38. package/dist/cli/commands/archive-stats.d.ts.map +1 -0
  39. package/dist/cli/commands/archive-stats.js +93 -0
  40. package/dist/cli/commands/archive-stats.js.map +1 -0
  41. package/dist/cli/commands/archive.d.ts +42 -0
  42. package/dist/cli/commands/archive.d.ts.map +1 -0
  43. package/dist/cli/commands/archive.js +59 -0
  44. package/dist/cli/commands/archive.js.map +1 -0
  45. package/dist/cli/commands/audit.d.ts +22 -0
  46. package/dist/cli/commands/audit.d.ts.map +1 -0
  47. package/dist/cli/commands/audit.js +137 -0
  48. package/dist/cli/commands/audit.js.map +1 -0
  49. package/dist/cli/commands/backfill.d.ts +56 -0
  50. package/dist/cli/commands/backfill.d.ts.map +1 -0
  51. package/dist/cli/commands/backfill.js +161 -0
  52. package/dist/cli/commands/backfill.js.map +1 -0
  53. package/dist/cli/commands/backup-inspect.d.ts +33 -0
  54. package/dist/cli/commands/backup-inspect.d.ts.map +1 -0
  55. package/dist/cli/commands/backup-inspect.js +430 -0
  56. package/dist/cli/commands/backup-inspect.js.map +1 -0
  57. package/dist/cli/commands/backup.d.ts +23 -0
  58. package/dist/cli/commands/backup.d.ts.map +1 -0
  59. package/dist/cli/commands/backup.js +564 -0
  60. package/dist/cli/commands/backup.js.map +1 -0
  61. package/dist/cli/commands/blockers.d.ts +20 -0
  62. package/dist/cli/commands/blockers.d.ts.map +1 -0
  63. package/dist/cli/commands/blockers.js +31 -0
  64. package/dist/cli/commands/blockers.js.map +1 -0
  65. package/dist/cli/commands/brain.d.ts +37 -0
  66. package/dist/cli/commands/brain.d.ts.map +1 -0
  67. package/dist/cli/commands/brain.js +445 -0
  68. package/dist/cli/commands/brain.js.map +1 -0
  69. package/dist/cli/commands/briefing.d.ts +52 -0
  70. package/dist/cli/commands/briefing.d.ts.map +1 -0
  71. package/dist/cli/commands/briefing.js +69 -0
  72. package/dist/cli/commands/briefing.js.map +1 -0
  73. package/dist/cli/commands/bug.d.ts +61 -0
  74. package/dist/cli/commands/bug.d.ts.map +1 -0
  75. package/dist/cli/commands/bug.js +198 -0
  76. package/dist/cli/commands/bug.js.map +1 -0
  77. package/dist/cli/commands/cancel.d.ts +26 -0
  78. package/dist/cli/commands/cancel.d.ts.map +1 -0
  79. package/dist/cli/commands/cancel.js +40 -0
  80. package/dist/cli/commands/cancel.js.map +1 -0
  81. package/dist/cli/commands/cant.d.ts +13 -0
  82. package/dist/cli/commands/cant.d.ts.map +1 -0
  83. package/dist/cli/commands/cant.js +245 -0
  84. package/dist/cli/commands/cant.js.map +1 -0
  85. package/dist/cli/commands/chain.d.ts +24 -0
  86. package/dist/cli/commands/chain.d.ts.map +1 -0
  87. package/dist/cli/commands/chain.js +116 -0
  88. package/dist/cli/commands/chain.js.map +1 -0
  89. package/dist/cli/commands/check.d.ts +18 -0
  90. package/dist/cli/commands/check.d.ts.map +1 -0
  91. package/dist/cli/commands/check.js +280 -0
  92. package/dist/cli/commands/check.js.map +1 -0
  93. package/dist/cli/commands/checkpoint.d.ts +27 -0
  94. package/dist/cli/commands/checkpoint.d.ts.map +1 -0
  95. package/dist/cli/commands/checkpoint.js +105 -0
  96. package/dist/cli/commands/checkpoint.js.map +1 -0
  97. package/dist/cli/commands/claim.d.ts +35 -0
  98. package/dist/cli/commands/claim.d.ts.map +1 -0
  99. package/dist/cli/commands/claim.js +35 -0
  100. package/dist/cli/commands/claim.js.map +1 -0
  101. package/dist/cli/commands/code.d.ts +22 -0
  102. package/dist/cli/commands/code.d.ts.map +1 -0
  103. package/dist/cli/commands/code.js +161 -0
  104. package/dist/cli/commands/code.js.map +1 -0
  105. package/dist/cli/commands/complete.d.ts +49 -0
  106. package/dist/cli/commands/complete.d.ts.map +1 -0
  107. package/dist/cli/commands/complete.js +83 -0
  108. package/dist/cli/commands/complete.js.map +1 -0
  109. package/dist/cli/commands/complexity.d.ts +13 -0
  110. package/dist/cli/commands/complexity.d.ts.map +1 -0
  111. package/dist/cli/commands/complexity.js +32 -0
  112. package/dist/cli/commands/complexity.js.map +1 -0
  113. package/dist/cli/commands/compliance.d.ts +27 -0
  114. package/dist/cli/commands/compliance.d.ts.map +1 -0
  115. package/dist/cli/commands/compliance.js +233 -0
  116. package/dist/cli/commands/compliance.js.map +1 -0
  117. package/dist/cli/commands/conduit.d.ts +28 -0
  118. package/dist/cli/commands/conduit.d.ts.map +1 -0
  119. package/dist/cli/commands/conduit.js +279 -0
  120. package/dist/cli/commands/conduit.js.map +1 -0
  121. package/dist/cli/commands/config.d.ts +25 -0
  122. package/dist/cli/commands/config.d.ts.map +1 -0
  123. package/dist/cli/commands/config.js +132 -0
  124. package/dist/cli/commands/config.js.map +1 -0
  125. package/dist/cli/commands/consensus.d.ts +21 -0
  126. package/dist/cli/commands/consensus.d.ts.map +1 -0
  127. package/dist/cli/commands/consensus.js +100 -0
  128. package/dist/cli/commands/consensus.js.map +1 -0
  129. package/dist/cli/commands/context.d.ts +19 -0
  130. package/dist/cli/commands/context.d.ts.map +1 -0
  131. package/dist/cli/commands/context.js +111 -0
  132. package/dist/cli/commands/context.js.map +1 -0
  133. package/dist/cli/commands/contribution.d.ts +21 -0
  134. package/dist/cli/commands/contribution.d.ts.map +1 -0
  135. package/dist/cli/commands/contribution.js +90 -0
  136. package/dist/cli/commands/contribution.js.map +1 -0
  137. package/dist/cli/commands/current.d.ts +18 -0
  138. package/dist/cli/commands/current.d.ts.map +1 -0
  139. package/dist/cli/commands/current.js +28 -0
  140. package/dist/cli/commands/current.js.map +1 -0
  141. package/dist/cli/commands/daemon.d.ts +36 -0
  142. package/dist/cli/commands/daemon.d.ts.map +1 -0
  143. package/dist/cli/commands/daemon.js +223 -0
  144. package/dist/cli/commands/daemon.js.map +1 -0
  145. package/dist/cli/commands/dash.d.ts +23 -0
  146. package/dist/cli/commands/dash.d.ts.map +1 -0
  147. package/dist/cli/commands/dash.js +38 -0
  148. package/dist/cli/commands/dash.js.map +1 -0
  149. package/dist/cli/commands/decomposition.d.ts +13 -0
  150. package/dist/cli/commands/decomposition.d.ts.map +1 -0
  151. package/dist/cli/commands/decomposition.js +92 -0
  152. package/dist/cli/commands/decomposition.js.map +1 -0
  153. package/dist/cli/commands/delete.d.ts +29 -0
  154. package/dist/cli/commands/delete.d.ts.map +1 -0
  155. package/dist/cli/commands/delete.js +55 -0
  156. package/dist/cli/commands/delete.js.map +1 -0
  157. package/dist/cli/commands/deps.d.ts +45 -0
  158. package/dist/cli/commands/deps.d.ts.map +1 -0
  159. package/dist/cli/commands/deps.js +170 -0
  160. package/dist/cli/commands/deps.js.map +1 -0
  161. package/dist/cli/commands/detect-drift.d.ts +23 -0
  162. package/dist/cli/commands/detect-drift.d.ts.map +1 -0
  163. package/dist/cli/commands/detect-drift.js +440 -0
  164. package/dist/cli/commands/detect-drift.js.map +1 -0
  165. package/dist/cli/commands/detect.d.ts +3 -0
  166. package/dist/cli/commands/detect.d.ts.map +1 -0
  167. package/dist/cli/commands/detect.js +14 -0
  168. package/dist/cli/commands/detect.js.map +1 -0
  169. package/dist/cli/commands/diagnostics.d.ts +19 -0
  170. package/dist/cli/commands/diagnostics.d.ts.map +1 -0
  171. package/dist/cli/commands/diagnostics.js +109 -0
  172. package/dist/cli/commands/diagnostics.js.map +1 -0
  173. package/dist/cli/commands/docs.d.ts +25 -0
  174. package/dist/cli/commands/docs.d.ts.map +1 -0
  175. package/dist/cli/commands/docs.js +798 -0
  176. package/dist/cli/commands/docs.js.map +1 -0
  177. package/dist/cli/commands/doctor-projects.d.ts +101 -0
  178. package/dist/cli/commands/doctor-projects.d.ts.map +1 -0
  179. package/dist/cli/commands/doctor-projects.js +188 -0
  180. package/dist/cli/commands/doctor-projects.js.map +1 -0
  181. package/dist/cli/commands/doctor.d.ts +66 -0
  182. package/dist/cli/commands/doctor.d.ts.map +1 -0
  183. package/dist/cli/commands/doctor.js +178 -0
  184. package/dist/cli/commands/doctor.js.map +1 -0
  185. package/dist/cli/commands/dynamic.d.ts +15 -0
  186. package/dist/cli/commands/dynamic.d.ts.map +1 -0
  187. package/dist/cli/commands/dynamic.js +21 -0
  188. package/dist/cli/commands/dynamic.js.map +1 -0
  189. package/dist/cli/commands/exists.d.ts +13 -0
  190. package/dist/cli/commands/exists.d.ts.map +1 -0
  191. package/dist/cli/commands/exists.js +40 -0
  192. package/dist/cli/commands/exists.js.map +1 -0
  193. package/dist/cli/commands/export-tasks.d.ts +46 -0
  194. package/dist/cli/commands/export-tasks.d.ts.map +1 -0
  195. package/dist/cli/commands/export-tasks.js +81 -0
  196. package/dist/cli/commands/export-tasks.js.map +1 -0
  197. package/dist/cli/commands/export.d.ts +35 -0
  198. package/dist/cli/commands/export.d.ts.map +1 -0
  199. package/dist/cli/commands/export.js +68 -0
  200. package/dist/cli/commands/export.js.map +1 -0
  201. package/dist/cli/commands/find.d.ts +54 -0
  202. package/dist/cli/commands/find.d.ts.map +1 -0
  203. package/dist/cli/commands/find.js +92 -0
  204. package/dist/cli/commands/find.js.map +1 -0
  205. package/dist/cli/commands/gc.d.ts +25 -0
  206. package/dist/cli/commands/gc.d.ts.map +1 -0
  207. package/dist/cli/commands/gc.js +165 -0
  208. package/dist/cli/commands/gc.js.map +1 -0
  209. package/dist/cli/commands/generate-changelog.d.ts +30 -0
  210. package/dist/cli/commands/generate-changelog.d.ts.map +1 -0
  211. package/dist/cli/commands/generate-changelog.js +270 -0
  212. package/dist/cli/commands/generate-changelog.js.map +1 -0
  213. package/dist/cli/commands/grade.d.ts +13 -0
  214. package/dist/cli/commands/grade.d.ts.map +1 -0
  215. package/dist/cli/commands/grade.js +27 -0
  216. package/dist/cli/commands/grade.js.map +1 -0
  217. package/dist/cli/commands/history.d.ts +13 -0
  218. package/dist/cli/commands/history.d.ts.map +1 -0
  219. package/dist/cli/commands/history.js +65 -0
  220. package/dist/cli/commands/history.js.map +1 -0
  221. package/dist/cli/commands/import-tasks.d.ts +60 -0
  222. package/dist/cli/commands/import-tasks.d.ts.map +1 -0
  223. package/dist/cli/commands/import-tasks.js +83 -0
  224. package/dist/cli/commands/import-tasks.js.map +1 -0
  225. package/dist/cli/commands/import.d.ts +42 -0
  226. package/dist/cli/commands/import.d.ts.map +1 -0
  227. package/dist/cli/commands/import.js +64 -0
  228. package/dist/cli/commands/import.js.map +1 -0
  229. package/dist/cli/commands/init.d.ts +65 -0
  230. package/dist/cli/commands/init.d.ts.map +1 -0
  231. package/dist/cli/commands/init.js +122 -0
  232. package/dist/cli/commands/init.js.map +1 -0
  233. package/dist/cli/commands/inject.d.ts +41 -0
  234. package/dist/cli/commands/inject.d.ts.map +1 -0
  235. package/dist/cli/commands/inject.js +56 -0
  236. package/dist/cli/commands/inject.js.map +1 -0
  237. package/dist/cli/commands/install-global.d.ts +48 -0
  238. package/dist/cli/commands/install-global.d.ts.map +1 -0
  239. package/dist/cli/commands/install-global.js +104 -0
  240. package/dist/cli/commands/install-global.js.map +1 -0
  241. package/dist/cli/commands/intelligence.d.ts +21 -0
  242. package/dist/cli/commands/intelligence.d.ts.map +1 -0
  243. package/dist/cli/commands/intelligence.js +145 -0
  244. package/dist/cli/commands/intelligence.js.map +1 -0
  245. package/dist/cli/commands/issue.d.ts +23 -0
  246. package/dist/cli/commands/issue.d.ts.map +1 -0
  247. package/dist/cli/commands/issue.js +152 -0
  248. package/dist/cli/commands/issue.js.map +1 -0
  249. package/dist/cli/commands/labels.d.ts +21 -0
  250. package/dist/cli/commands/labels.d.ts.map +1 -0
  251. package/dist/cli/commands/labels.js +65 -0
  252. package/dist/cli/commands/labels.js.map +1 -0
  253. package/dist/cli/commands/lifecycle.d.ts +25 -0
  254. package/dist/cli/commands/lifecycle.d.ts.map +1 -0
  255. package/dist/cli/commands/lifecycle.js +221 -0
  256. package/dist/cli/commands/lifecycle.js.map +1 -0
  257. package/dist/cli/commands/list.d.ts +28 -0
  258. package/dist/cli/commands/list.d.ts.map +1 -0
  259. package/dist/cli/commands/list.js +81 -0
  260. package/dist/cli/commands/list.js.map +1 -0
  261. package/dist/cli/commands/log.d.ts +36 -0
  262. package/dist/cli/commands/log.d.ts.map +1 -0
  263. package/dist/cli/commands/log.js +50 -0
  264. package/dist/cli/commands/log.js.map +1 -0
  265. package/dist/cli/commands/manifest.d.ts +15 -0
  266. package/dist/cli/commands/manifest.d.ts.map +1 -0
  267. package/dist/cli/commands/manifest.js +334 -0
  268. package/dist/cli/commands/manifest.js.map +1 -0
  269. package/dist/cli/commands/map.d.ts +25 -0
  270. package/dist/cli/commands/map.d.ts.map +1 -0
  271. package/dist/cli/commands/map.js +37 -0
  272. package/dist/cli/commands/map.js.map +1 -0
  273. package/dist/cli/commands/memory.d.ts +48 -0
  274. package/dist/cli/commands/memory.d.ts.map +1 -0
  275. package/dist/cli/commands/memory.js +2439 -0
  276. package/dist/cli/commands/memory.js.map +1 -0
  277. package/dist/cli/commands/migrate-claude-mem.d.ts +23 -0
  278. package/dist/cli/commands/migrate-claude-mem.d.ts.map +1 -0
  279. package/dist/cli/commands/migrate-claude-mem.js +181 -0
  280. package/dist/cli/commands/migrate-claude-mem.js.map +1 -0
  281. package/dist/cli/commands/next.d.ts +27 -0
  282. package/dist/cli/commands/next.d.ts.map +1 -0
  283. package/dist/cli/commands/next.js +40 -0
  284. package/dist/cli/commands/next.js.map +1 -0
  285. package/dist/cli/commands/nexus.d.ts +15 -0
  286. package/dist/cli/commands/nexus.d.ts.map +1 -0
  287. package/dist/cli/commands/nexus.js +3377 -0
  288. package/dist/cli/commands/nexus.js.map +1 -0
  289. package/dist/cli/commands/ops.d.ts +23 -0
  290. package/dist/cli/commands/ops.d.ts.map +1 -0
  291. package/dist/cli/commands/ops.js +35 -0
  292. package/dist/cli/commands/ops.js.map +1 -0
  293. package/dist/cli/commands/orchestrate.d.ts +48 -0
  294. package/dist/cli/commands/orchestrate.d.ts.map +1 -0
  295. package/dist/cli/commands/orchestrate.js +774 -0
  296. package/dist/cli/commands/orchestrate.js.map +1 -0
  297. package/dist/cli/commands/otel.d.ts +30 -0
  298. package/dist/cli/commands/otel.d.ts.map +1 -0
  299. package/dist/cli/commands/otel.js +193 -0
  300. package/dist/cli/commands/otel.js.map +1 -0
  301. package/dist/cli/commands/phase.d.ts +29 -0
  302. package/dist/cli/commands/phase.d.ts.map +1 -0
  303. package/dist/cli/commands/phase.js +189 -0
  304. package/dist/cli/commands/phase.js.map +1 -0
  305. package/dist/cli/commands/pivot.d.ts +34 -0
  306. package/dist/cli/commands/pivot.d.ts.map +1 -0
  307. package/dist/cli/commands/pivot.js +50 -0
  308. package/dist/cli/commands/pivot.js.map +1 -0
  309. package/dist/cli/commands/plan.d.ts +17 -0
  310. package/dist/cli/commands/plan.d.ts.map +1 -0
  311. package/dist/cli/commands/plan.js +27 -0
  312. package/dist/cli/commands/plan.js.map +1 -0
  313. package/dist/cli/commands/playbook.d.ts +26 -0
  314. package/dist/cli/commands/playbook.d.ts.map +1 -0
  315. package/dist/cli/commands/playbook.js +220 -0
  316. package/dist/cli/commands/playbook.js.map +1 -0
  317. package/dist/cli/commands/promote.d.ts +19 -0
  318. package/dist/cli/commands/promote.d.ts.map +1 -0
  319. package/dist/cli/commands/promote.js +27 -0
  320. package/dist/cli/commands/promote.js.map +1 -0
  321. package/dist/cli/commands/provider.d.ts +23 -0
  322. package/dist/cli/commands/provider.d.ts.map +1 -0
  323. package/dist/cli/commands/provider.js +168 -0
  324. package/dist/cli/commands/provider.js.map +1 -0
  325. package/dist/cli/commands/reason.d.ts +18 -0
  326. package/dist/cli/commands/reason.d.ts.map +1 -0
  327. package/dist/cli/commands/reason.js +102 -0
  328. package/dist/cli/commands/reason.js.map +1 -0
  329. package/dist/cli/commands/reconcile.d.ts +35 -0
  330. package/dist/cli/commands/reconcile.d.ts.map +1 -0
  331. package/dist/cli/commands/reconcile.js +102 -0
  332. package/dist/cli/commands/reconcile.js.map +1 -0
  333. package/dist/cli/commands/refresh-memory.d.ts +16 -0
  334. package/dist/cli/commands/refresh-memory.d.ts.map +1 -0
  335. package/dist/cli/commands/refresh-memory.js +34 -0
  336. package/dist/cli/commands/refresh-memory.js.map +1 -0
  337. package/dist/cli/commands/relates.d.ts +19 -0
  338. package/dist/cli/commands/relates.d.ts.map +1 -0
  339. package/dist/cli/commands/relates.js +129 -0
  340. package/dist/cli/commands/relates.js.map +1 -0
  341. package/dist/cli/commands/release.d.ts +27 -0
  342. package/dist/cli/commands/release.d.ts.map +1 -0
  343. package/dist/cli/commands/release.js +300 -0
  344. package/dist/cli/commands/release.js.map +1 -0
  345. package/dist/cli/commands/remote.d.ts +49 -0
  346. package/dist/cli/commands/remote.d.ts.map +1 -0
  347. package/dist/cli/commands/remote.js +265 -0
  348. package/dist/cli/commands/remote.js.map +1 -0
  349. package/dist/cli/commands/reorder.d.ts +31 -0
  350. package/dist/cli/commands/reorder.d.ts.map +1 -0
  351. package/dist/cli/commands/reorder.js +57 -0
  352. package/dist/cli/commands/reorder.js.map +1 -0
  353. package/dist/cli/commands/reparent.d.ts +27 -0
  354. package/dist/cli/commands/reparent.d.ts.map +1 -0
  355. package/dist/cli/commands/reparent.js +36 -0
  356. package/dist/cli/commands/reparent.js.map +1 -0
  357. package/dist/cli/commands/req.d.ts +37 -0
  358. package/dist/cli/commands/req.d.ts.map +1 -0
  359. package/dist/cli/commands/req.js +121 -0
  360. package/dist/cli/commands/req.js.map +1 -0
  361. package/dist/cli/commands/research.d.ts +25 -0
  362. package/dist/cli/commands/research.d.ts.map +1 -0
  363. package/dist/cli/commands/research.js +327 -0
  364. package/dist/cli/commands/research.js.map +1 -0
  365. package/dist/cli/commands/restore.d.ts +64 -0
  366. package/dist/cli/commands/restore.d.ts.map +1 -0
  367. package/dist/cli/commands/restore.js +539 -0
  368. package/dist/cli/commands/restore.js.map +1 -0
  369. package/dist/cli/commands/revert.d.ts +79 -0
  370. package/dist/cli/commands/revert.d.ts.map +1 -0
  371. package/dist/cli/commands/revert.js +300 -0
  372. package/dist/cli/commands/revert.js.map +1 -0
  373. package/dist/cli/commands/roadmap.d.ts +29 -0
  374. package/dist/cli/commands/roadmap.d.ts.map +1 -0
  375. package/dist/cli/commands/roadmap.js +43 -0
  376. package/dist/cli/commands/roadmap.js.map +1 -0
  377. package/dist/cli/commands/safestop.d.ts +41 -0
  378. package/dist/cli/commands/safestop.d.ts.map +1 -0
  379. package/dist/cli/commands/safestop.js +62 -0
  380. package/dist/cli/commands/safestop.js.map +1 -0
  381. package/dist/cli/commands/schema.d.ts +44 -0
  382. package/dist/cli/commands/schema.d.ts.map +1 -0
  383. package/dist/cli/commands/schema.js +177 -0
  384. package/dist/cli/commands/schema.js.map +1 -0
  385. package/dist/cli/commands/self-update.d.ts +81 -0
  386. package/dist/cli/commands/self-update.d.ts.map +1 -0
  387. package/dist/cli/commands/self-update.js +483 -0
  388. package/dist/cli/commands/self-update.js.map +1 -0
  389. package/dist/cli/commands/sentient.d.ts +44 -0
  390. package/dist/cli/commands/sentient.d.ts.map +1 -0
  391. package/dist/cli/commands/sentient.js +687 -0
  392. package/dist/cli/commands/sentient.js.map +1 -0
  393. package/dist/cli/commands/sequence.d.ts +15 -0
  394. package/dist/cli/commands/sequence.d.ts.map +1 -0
  395. package/dist/cli/commands/sequence.js +68 -0
  396. package/dist/cli/commands/sequence.js.map +1 -0
  397. package/dist/cli/commands/session.d.ts +32 -0
  398. package/dist/cli/commands/session.d.ts.map +1 -0
  399. package/dist/cli/commands/session.js +583 -0
  400. package/dist/cli/commands/session.js.map +1 -0
  401. package/dist/cli/commands/show.d.ts +21 -0
  402. package/dist/cli/commands/show.d.ts.map +1 -0
  403. package/dist/cli/commands/show.js +37 -0
  404. package/dist/cli/commands/show.js.map +1 -0
  405. package/dist/cli/commands/skills.d.ts +31 -0
  406. package/dist/cli/commands/skills.d.ts.map +1 -0
  407. package/dist/cli/commands/skills.js +303 -0
  408. package/dist/cli/commands/skills.js.map +1 -0
  409. package/dist/cli/commands/snapshot.d.ts +17 -0
  410. package/dist/cli/commands/snapshot.d.ts.map +1 -0
  411. package/dist/cli/commands/snapshot.js +95 -0
  412. package/dist/cli/commands/snapshot.js.map +1 -0
  413. package/dist/cli/commands/start.d.ts +21 -0
  414. package/dist/cli/commands/start.d.ts.map +1 -0
  415. package/dist/cli/commands/start.js +32 -0
  416. package/dist/cli/commands/start.js.map +1 -0
  417. package/dist/cli/commands/stats.d.ts +30 -0
  418. package/dist/cli/commands/stats.d.ts.map +1 -0
  419. package/dist/cli/commands/stats.js +71 -0
  420. package/dist/cli/commands/stats.js.map +1 -0
  421. package/dist/cli/commands/sticky.d.ts +23 -0
  422. package/dist/cli/commands/sticky.d.ts.map +1 -0
  423. package/dist/cli/commands/sticky.js +315 -0
  424. package/dist/cli/commands/sticky.js.map +1 -0
  425. package/dist/cli/commands/stop.d.ts +15 -0
  426. package/dist/cli/commands/stop.d.ts.map +1 -0
  427. package/dist/cli/commands/stop.js +25 -0
  428. package/dist/cli/commands/stop.js.map +1 -0
  429. package/dist/cli/commands/sync.d.ts +25 -0
  430. package/dist/cli/commands/sync.d.ts.map +1 -0
  431. package/dist/cli/commands/sync.js +125 -0
  432. package/dist/cli/commands/sync.js.map +1 -0
  433. package/dist/cli/commands/testing.d.ts +22 -0
  434. package/dist/cli/commands/testing.d.ts.map +1 -0
  435. package/dist/cli/commands/testing.js +111 -0
  436. package/dist/cli/commands/testing.js.map +1 -0
  437. package/dist/cli/commands/token.d.ts +22 -0
  438. package/dist/cli/commands/token.d.ts.map +1 -0
  439. package/dist/cli/commands/token.js +197 -0
  440. package/dist/cli/commands/token.js.map +1 -0
  441. package/dist/cli/commands/transcript.d.ts +32 -0
  442. package/dist/cli/commands/transcript.d.ts.map +1 -0
  443. package/dist/cli/commands/transcript.js +526 -0
  444. package/dist/cli/commands/transcript.js.map +1 -0
  445. package/dist/cli/commands/update.d.ts +164 -0
  446. package/dist/cli/commands/update.d.ts.map +1 -0
  447. package/dist/cli/commands/update.js +234 -0
  448. package/dist/cli/commands/update.js.map +1 -0
  449. package/dist/cli/commands/upgrade.d.ts +76 -0
  450. package/dist/cli/commands/upgrade.d.ts.map +1 -0
  451. package/dist/cli/commands/upgrade.js +154 -0
  452. package/dist/cli/commands/upgrade.js.map +1 -0
  453. package/dist/cli/commands/verify.d.ts +83 -0
  454. package/dist/cli/commands/verify.d.ts.map +1 -0
  455. package/dist/cli/commands/verify.js +108 -0
  456. package/dist/cli/commands/verify.js.map +1 -0
  457. package/dist/cli/commands/web.d.ts +27 -0
  458. package/dist/cli/commands/web.d.ts.map +1 -0
  459. package/dist/cli/commands/web.js +414 -0
  460. package/dist/cli/commands/web.js.map +1 -0
  461. package/dist/cli/field-context.d.ts +32 -0
  462. package/dist/cli/field-context.d.ts.map +1 -0
  463. package/dist/cli/field-context.js +47 -0
  464. package/dist/cli/field-context.js.map +1 -0
  465. package/dist/cli/format-context.d.ts +32 -0
  466. package/dist/cli/format-context.d.ts.map +1 -0
  467. package/dist/cli/format-context.js +50 -0
  468. package/dist/cli/format-context.js.map +1 -0
  469. package/dist/cli/help-renderer.d.ts +40 -0
  470. package/dist/cli/help-renderer.d.ts.map +1 -0
  471. package/dist/cli/help-renderer.js +325 -0
  472. package/dist/cli/help-renderer.js.map +1 -0
  473. package/dist/cli/index.d.ts +14 -0
  474. package/dist/cli/index.d.ts.map +1 -0
  475. package/dist/cli/index.js +1561 -9748
  476. package/dist/cli/index.js.map +4 -4
  477. package/dist/cli/infer-files-via-gitnexus.d.ts +12 -0
  478. package/dist/cli/infer-files-via-gitnexus.d.ts.map +1 -0
  479. package/dist/cli/infer-files-via-gitnexus.js +12 -0
  480. package/dist/cli/infer-files-via-gitnexus.js.map +1 -0
  481. package/dist/cli/lib/did-you-mean.d.ts +30 -0
  482. package/dist/cli/lib/did-you-mean.d.ts.map +1 -0
  483. package/dist/cli/lib/did-you-mean.js +63 -0
  484. package/dist/cli/lib/did-you-mean.js.map +1 -0
  485. package/dist/cli/lib/registry-args.d.ts +36 -0
  486. package/dist/cli/lib/registry-args.d.ts.map +1 -0
  487. package/dist/cli/lib/registry-args.js +37 -0
  488. package/dist/cli/lib/registry-args.js.map +1 -0
  489. package/dist/cli/lib/subcommand-guard.d.ts +45 -0
  490. package/dist/cli/lib/subcommand-guard.d.ts.map +1 -0
  491. package/dist/cli/lib/subcommand-guard.js +55 -0
  492. package/dist/cli/lib/subcommand-guard.js.map +1 -0
  493. package/dist/cli/logger-bootstrap.d.ts +6 -0
  494. package/dist/cli/logger-bootstrap.d.ts.map +1 -0
  495. package/dist/cli/logger-bootstrap.js +10 -0
  496. package/dist/cli/logger-bootstrap.js.map +1 -0
  497. package/dist/cli/middleware/output-format.d.ts +30 -0
  498. package/dist/cli/middleware/output-format.d.ts.map +1 -0
  499. package/dist/cli/middleware/output-format.js +35 -0
  500. package/dist/cli/middleware/output-format.js.map +1 -0
  501. package/dist/cli/paths.d.ts +85 -0
  502. package/dist/cli/paths.d.ts.map +1 -0
  503. package/dist/cli/paths.js +108 -0
  504. package/dist/cli/paths.js.map +1 -0
  505. package/dist/cli/progress.d.ts +89 -0
  506. package/dist/cli/progress.d.ts.map +1 -0
  507. package/dist/cli/progress.js +185 -0
  508. package/dist/cli/progress.js.map +1 -0
  509. package/dist/cli/renderers/colors.d.ts +32 -0
  510. package/dist/cli/renderers/colors.d.ts.map +1 -0
  511. package/dist/cli/renderers/colors.js +141 -0
  512. package/dist/cli/renderers/colors.js.map +1 -0
  513. package/dist/cli/renderers/error.d.ts +13 -0
  514. package/dist/cli/renderers/error.d.ts.map +1 -0
  515. package/dist/cli/renderers/error.js +42 -0
  516. package/dist/cli/renderers/error.js.map +1 -0
  517. package/dist/cli/renderers/index.d.ts +90 -0
  518. package/dist/cli/renderers/index.d.ts.map +1 -0
  519. package/dist/cli/renderers/index.js +268 -0
  520. package/dist/cli/renderers/index.js.map +1 -0
  521. package/dist/cli/renderers/lafs-validator.d.ts +91 -0
  522. package/dist/cli/renderers/lafs-validator.d.ts.map +1 -0
  523. package/dist/cli/renderers/lafs-validator.js +176 -0
  524. package/dist/cli/renderers/lafs-validator.js.map +1 -0
  525. package/dist/cli/renderers/normalizer.d.ts +21 -0
  526. package/dist/cli/renderers/normalizer.d.ts.map +1 -0
  527. package/dist/cli/renderers/normalizer.js +106 -0
  528. package/dist/cli/renderers/normalizer.js.map +1 -0
  529. package/dist/cli/renderers/system.d.ts +110 -0
  530. package/dist/cli/renderers/system.d.ts.map +1 -0
  531. package/dist/cli/renderers/system.js +662 -0
  532. package/dist/cli/renderers/system.js.map +1 -0
  533. package/dist/cli/renderers/tasks.d.ts +28 -0
  534. package/dist/cli/renderers/tasks.d.ts.map +1 -0
  535. package/dist/cli/renderers/tasks.js +306 -0
  536. package/dist/cli/renderers/tasks.js.map +1 -0
  537. package/dist/cli/tree-context.d.ts +53 -0
  538. package/dist/cli/tree-context.d.ts.map +1 -0
  539. package/dist/cli/tree-context.js +43 -0
  540. package/dist/cli/tree-context.js.map +1 -0
  541. package/dist/dispatch/adapters/cli.d.ts +67 -0
  542. package/dist/dispatch/adapters/cli.d.ts.map +1 -0
  543. package/dist/dispatch/adapters/cli.js +331 -0
  544. package/dist/dispatch/adapters/cli.js.map +1 -0
  545. package/dist/dispatch/adapters/typed.d.ts +362 -0
  546. package/dist/dispatch/adapters/typed.d.ts.map +1 -0
  547. package/dist/dispatch/adapters/typed.js +278 -0
  548. package/dist/dispatch/adapters/typed.js.map +1 -0
  549. package/dist/dispatch/context/session-context.d.ts +108 -0
  550. package/dist/dispatch/context/session-context.d.ts.map +1 -0
  551. package/dist/dispatch/context/session-context.js +111 -0
  552. package/dist/dispatch/context/session-context.js.map +1 -0
  553. package/dist/dispatch/dispatcher.d.ts +37 -0
  554. package/dist/dispatch/dispatcher.d.ts.map +1 -0
  555. package/dist/dispatch/dispatcher.js +172 -0
  556. package/dist/dispatch/dispatcher.js.map +1 -0
  557. package/dist/dispatch/domains/_base.d.ts +104 -0
  558. package/dist/dispatch/domains/_base.d.ts.map +1 -0
  559. package/dist/dispatch/domains/_base.js +147 -0
  560. package/dist/dispatch/domains/_base.js.map +1 -0
  561. package/dist/dispatch/domains/_meta.d.ts +23 -0
  562. package/dist/dispatch/domains/_meta.d.ts.map +1 -0
  563. package/dist/dispatch/domains/_meta.js +25 -0
  564. package/dist/dispatch/domains/_meta.js.map +1 -0
  565. package/dist/dispatch/domains/_routing.d.ts +8 -0
  566. package/dist/dispatch/domains/_routing.d.ts.map +1 -0
  567. package/dist/dispatch/domains/_routing.js +20 -0
  568. package/dist/dispatch/domains/_routing.js.map +1 -0
  569. package/dist/dispatch/domains/admin/smoke-provider.d.ts +54 -0
  570. package/dist/dispatch/domains/admin/smoke-provider.d.ts.map +1 -0
  571. package/dist/dispatch/domains/admin/smoke-provider.js +309 -0
  572. package/dist/dispatch/domains/admin/smoke-provider.js.map +1 -0
  573. package/dist/dispatch/domains/admin.d.ts +51 -0
  574. package/dist/dispatch/domains/admin.d.ts.map +1 -0
  575. package/dist/dispatch/domains/admin.js +1163 -0
  576. package/dist/dispatch/domains/admin.js.map +1 -0
  577. package/dist/dispatch/domains/check/canon.d.ts +65 -0
  578. package/dist/dispatch/domains/check/canon.d.ts.map +1 -0
  579. package/dist/dispatch/domains/check/canon.js +193 -0
  580. package/dist/dispatch/domains/check/canon.js.map +1 -0
  581. package/dist/dispatch/domains/check.d.ts +37 -0
  582. package/dist/dispatch/domains/check.d.ts.map +1 -0
  583. package/dist/dispatch/domains/check.js +562 -0
  584. package/dist/dispatch/domains/check.js.map +1 -0
  585. package/dist/dispatch/domains/conduit.d.ts +61 -0
  586. package/dist/dispatch/domains/conduit.d.ts.map +1 -0
  587. package/dist/dispatch/domains/conduit.js +609 -0
  588. package/dist/dispatch/domains/conduit.js.map +1 -0
  589. package/dist/dispatch/domains/diagnostics.d.ts +25 -0
  590. package/dist/dispatch/domains/diagnostics.d.ts.map +1 -0
  591. package/dist/dispatch/domains/diagnostics.js +82 -0
  592. package/dist/dispatch/domains/diagnostics.js.map +1 -0
  593. package/dist/dispatch/domains/docs.d.ts +63 -0
  594. package/dist/dispatch/domains/docs.d.ts.map +1 -0
  595. package/dist/dispatch/domains/docs.js +539 -0
  596. package/dist/dispatch/domains/docs.js.map +1 -0
  597. package/dist/dispatch/domains/index.d.ts +33 -0
  598. package/dist/dispatch/domains/index.d.ts.map +1 -0
  599. package/dist/dispatch/domains/index.js +58 -0
  600. package/dist/dispatch/domains/index.js.map +1 -0
  601. package/dist/dispatch/domains/intelligence.d.ts +26 -0
  602. package/dist/dispatch/domains/intelligence.d.ts.map +1 -0
  603. package/dist/dispatch/domains/intelligence.js +154 -0
  604. package/dist/dispatch/domains/intelligence.js.map +1 -0
  605. package/dist/dispatch/domains/ivtr.d.ts +182 -0
  606. package/dist/dispatch/domains/ivtr.d.ts.map +1 -0
  607. package/dist/dispatch/domains/ivtr.js +430 -0
  608. package/dist/dispatch/domains/ivtr.js.map +1 -0
  609. package/dist/dispatch/domains/memory.d.ts +22 -0
  610. package/dist/dispatch/domains/memory.d.ts.map +1 -0
  611. package/dist/dispatch/domains/memory.js +1281 -0
  612. package/dist/dispatch/domains/memory.js.map +1 -0
  613. package/dist/dispatch/domains/nexus.d.ts +78 -0
  614. package/dist/dispatch/domains/nexus.d.ts.map +1 -0
  615. package/dist/dispatch/domains/nexus.js +938 -0
  616. package/dist/dispatch/domains/nexus.js.map +1 -0
  617. package/dist/dispatch/domains/orchestrate.d.ts +307 -0
  618. package/dist/dispatch/domains/orchestrate.d.ts.map +1 -0
  619. package/dist/dispatch/domains/orchestrate.js +986 -0
  620. package/dist/dispatch/domains/orchestrate.js.map +1 -0
  621. package/dist/dispatch/domains/pipeline.d.ts +276 -0
  622. package/dist/dispatch/domains/pipeline.d.ts.map +1 -0
  623. package/dist/dispatch/domains/pipeline.js +689 -0
  624. package/dist/dispatch/domains/pipeline.js.map +1 -0
  625. package/dist/dispatch/domains/playbook.d.ts +131 -0
  626. package/dist/dispatch/domains/playbook.d.ts.map +1 -0
  627. package/dist/dispatch/domains/playbook.js +633 -0
  628. package/dist/dispatch/domains/playbook.js.map +1 -0
  629. package/dist/dispatch/domains/release.d.ts +97 -0
  630. package/dist/dispatch/domains/release.d.ts.map +1 -0
  631. package/dist/dispatch/domains/release.js +177 -0
  632. package/dist/dispatch/domains/release.js.map +1 -0
  633. package/dist/dispatch/domains/sentient.d.ts +60 -0
  634. package/dist/dispatch/domains/sentient.d.ts.map +1 -0
  635. package/dist/dispatch/domains/sentient.js +270 -0
  636. package/dist/dispatch/domains/sentient.js.map +1 -0
  637. package/dist/dispatch/domains/session.d.ts +49 -0
  638. package/dist/dispatch/domains/session.d.ts.map +1 -0
  639. package/dist/dispatch/domains/session.js +459 -0
  640. package/dist/dispatch/domains/session.js.map +1 -0
  641. package/dist/dispatch/domains/sticky.d.ts +82 -0
  642. package/dist/dispatch/domains/sticky.d.ts.map +1 -0
  643. package/dist/dispatch/domains/sticky.js +287 -0
  644. package/dist/dispatch/domains/sticky.js.map +1 -0
  645. package/dist/dispatch/domains/tasks.d.ts +58 -0
  646. package/dist/dispatch/domains/tasks.d.ts.map +1 -0
  647. package/dist/dispatch/domains/tasks.js +497 -0
  648. package/dist/dispatch/domains/tasks.js.map +1 -0
  649. package/dist/dispatch/domains/tools.d.ts +37 -0
  650. package/dist/dispatch/domains/tools.d.ts.map +1 -0
  651. package/dist/dispatch/domains/tools.js +481 -0
  652. package/dist/dispatch/domains/tools.js.map +1 -0
  653. package/dist/dispatch/engines/_error.d.ts +114 -0
  654. package/dist/dispatch/engines/_error.d.ts.map +1 -0
  655. package/dist/dispatch/engines/_error.js +290 -0
  656. package/dist/dispatch/engines/_error.js.map +1 -0
  657. package/dist/dispatch/engines/admin-engine.d.ts +386 -0
  658. package/dist/dispatch/engines/admin-engine.d.ts.map +1 -0
  659. package/dist/dispatch/engines/admin-engine.js +270 -0
  660. package/dist/dispatch/engines/admin-engine.js.map +1 -0
  661. package/dist/dispatch/engines/code-engine.d.ts +14 -0
  662. package/dist/dispatch/engines/code-engine.d.ts.map +1 -0
  663. package/dist/dispatch/engines/code-engine.js +14 -0
  664. package/dist/dispatch/engines/code-engine.js.map +1 -0
  665. package/dist/dispatch/engines/codebase-map-engine.d.ts +31 -0
  666. package/dist/dispatch/engines/codebase-map-engine.d.ts.map +1 -0
  667. package/dist/dispatch/engines/codebase-map-engine.js +43 -0
  668. package/dist/dispatch/engines/codebase-map-engine.js.map +1 -0
  669. package/dist/dispatch/engines/config-engine.d.ts +14 -0
  670. package/dist/dispatch/engines/config-engine.d.ts.map +1 -0
  671. package/dist/dispatch/engines/config-engine.js +14 -0
  672. package/dist/dispatch/engines/config-engine.js.map +1 -0
  673. package/dist/dispatch/engines/diagnostics-engine.d.ts +13 -0
  674. package/dist/dispatch/engines/diagnostics-engine.d.ts.map +1 -0
  675. package/dist/dispatch/engines/diagnostics-engine.js +12 -0
  676. package/dist/dispatch/engines/diagnostics-engine.js.map +1 -0
  677. package/dist/dispatch/engines/hooks-engine.d.ts +13 -0
  678. package/dist/dispatch/engines/hooks-engine.d.ts.map +1 -0
  679. package/dist/dispatch/engines/hooks-engine.js +12 -0
  680. package/dist/dispatch/engines/hooks-engine.js.map +1 -0
  681. package/dist/dispatch/engines/init-engine.d.ts +14 -0
  682. package/dist/dispatch/engines/init-engine.d.ts.map +1 -0
  683. package/dist/dispatch/engines/init-engine.js +14 -0
  684. package/dist/dispatch/engines/init-engine.js.map +1 -0
  685. package/dist/dispatch/engines/lifecycle-engine.d.ts +13 -0
  686. package/dist/dispatch/engines/lifecycle-engine.d.ts.map +1 -0
  687. package/dist/dispatch/engines/lifecycle-engine.js +12 -0
  688. package/dist/dispatch/engines/lifecycle-engine.js.map +1 -0
  689. package/dist/dispatch/engines/memory-engine.d.ts +10 -0
  690. package/dist/dispatch/engines/memory-engine.d.ts.map +1 -0
  691. package/dist/dispatch/engines/memory-engine.js +10 -0
  692. package/dist/dispatch/engines/memory-engine.js.map +1 -0
  693. package/dist/dispatch/engines/nexus-engine.d.ts +603 -0
  694. package/dist/dispatch/engines/nexus-engine.d.ts.map +1 -0
  695. package/dist/dispatch/engines/nexus-engine.js +1438 -0
  696. package/dist/dispatch/engines/nexus-engine.js.map +1 -0
  697. package/dist/dispatch/engines/orchestrate-engine.d.ts +252 -0
  698. package/dist/dispatch/engines/orchestrate-engine.d.ts.map +1 -0
  699. package/dist/dispatch/engines/orchestrate-engine.js +1526 -0
  700. package/dist/dispatch/engines/orchestrate-engine.js.map +1 -0
  701. package/dist/dispatch/engines/pipeline-engine.d.ts +13 -0
  702. package/dist/dispatch/engines/pipeline-engine.d.ts.map +1 -0
  703. package/dist/dispatch/engines/pipeline-engine.js +12 -0
  704. package/dist/dispatch/engines/pipeline-engine.js.map +1 -0
  705. package/dist/dispatch/engines/release-engine.d.ts +13 -0
  706. package/dist/dispatch/engines/release-engine.d.ts.map +1 -0
  707. package/dist/dispatch/engines/release-engine.js +13 -0
  708. package/dist/dispatch/engines/release-engine.js.map +1 -0
  709. package/dist/dispatch/engines/session-engine.d.ts +15 -0
  710. package/dist/dispatch/engines/session-engine.d.ts.map +1 -0
  711. package/dist/dispatch/engines/session-engine.js +12 -0
  712. package/dist/dispatch/engines/session-engine.js.map +1 -0
  713. package/dist/dispatch/engines/sticky-engine.d.ts +13 -0
  714. package/dist/dispatch/engines/sticky-engine.d.ts.map +1 -0
  715. package/dist/dispatch/engines/sticky-engine.js +12 -0
  716. package/dist/dispatch/engines/sticky-engine.js.map +1 -0
  717. package/dist/dispatch/engines/system-engine.d.ts +543 -0
  718. package/dist/dispatch/engines/system-engine.d.ts.map +1 -0
  719. package/dist/dispatch/engines/system-engine.js +1278 -0
  720. package/dist/dispatch/engines/system-engine.js.map +1 -0
  721. package/dist/dispatch/engines/task-engine.d.ts +1161 -0
  722. package/dist/dispatch/engines/task-engine.d.ts.map +1 -0
  723. package/dist/dispatch/engines/task-engine.js +1599 -0
  724. package/dist/dispatch/engines/task-engine.js.map +1 -0
  725. package/dist/dispatch/engines/template-parser.d.ts +85 -0
  726. package/dist/dispatch/engines/template-parser.d.ts.map +1 -0
  727. package/dist/dispatch/engines/template-parser.js +114 -0
  728. package/dist/dispatch/engines/template-parser.js.map +1 -0
  729. package/dist/dispatch/engines/tools-engine.d.ts +13 -0
  730. package/dist/dispatch/engines/tools-engine.d.ts.map +1 -0
  731. package/dist/dispatch/engines/tools-engine.js +12 -0
  732. package/dist/dispatch/engines/tools-engine.js.map +1 -0
  733. package/dist/dispatch/engines/validate-engine.d.ts +13 -0
  734. package/dist/dispatch/engines/validate-engine.d.ts.map +1 -0
  735. package/dist/dispatch/engines/validate-engine.js +13 -0
  736. package/dist/dispatch/engines/validate-engine.js.map +1 -0
  737. package/dist/dispatch/index.d.ts +20 -0
  738. package/dist/dispatch/index.d.ts.map +1 -0
  739. package/dist/dispatch/index.js +19 -0
  740. package/dist/dispatch/index.js.map +1 -0
  741. package/dist/dispatch/lib/background-jobs.d.ts +162 -0
  742. package/dist/dispatch/lib/background-jobs.d.ts.map +1 -0
  743. package/dist/dispatch/lib/background-jobs.js +360 -0
  744. package/dist/dispatch/lib/background-jobs.js.map +1 -0
  745. package/dist/dispatch/lib/budget.d.ts +36 -0
  746. package/dist/dispatch/lib/budget.d.ts.map +1 -0
  747. package/dist/dispatch/lib/budget.js +109 -0
  748. package/dist/dispatch/lib/budget.js.map +1 -0
  749. package/dist/dispatch/lib/capability-matrix.d.ts +11 -0
  750. package/dist/dispatch/lib/capability-matrix.d.ts.map +1 -0
  751. package/dist/dispatch/lib/capability-matrix.js +10 -0
  752. package/dist/dispatch/lib/capability-matrix.js.map +1 -0
  753. package/dist/dispatch/lib/config-loader.d.ts +42 -0
  754. package/dist/dispatch/lib/config-loader.d.ts.map +1 -0
  755. package/dist/dispatch/lib/config-loader.js +218 -0
  756. package/dist/dispatch/lib/config-loader.js.map +1 -0
  757. package/dist/dispatch/lib/config.d.ts +11 -0
  758. package/dist/dispatch/lib/config.d.ts.map +1 -0
  759. package/dist/dispatch/lib/config.js +10 -0
  760. package/dist/dispatch/lib/config.js.map +1 -0
  761. package/dist/dispatch/lib/defaults.d.ts +115 -0
  762. package/dist/dispatch/lib/defaults.d.ts.map +1 -0
  763. package/dist/dispatch/lib/defaults.js +61 -0
  764. package/dist/dispatch/lib/defaults.js.map +1 -0
  765. package/dist/dispatch/lib/engine.d.ts +17 -0
  766. package/dist/dispatch/lib/engine.d.ts.map +1 -0
  767. package/dist/dispatch/lib/engine.js +36 -0
  768. package/dist/dispatch/lib/engine.js.map +1 -0
  769. package/dist/dispatch/lib/exit-codes.d.ts +35 -0
  770. package/dist/dispatch/lib/exit-codes.d.ts.map +1 -0
  771. package/dist/dispatch/lib/exit-codes.js +60 -0
  772. package/dist/dispatch/lib/exit-codes.js.map +1 -0
  773. package/dist/dispatch/lib/gateway-meta.d.ts +37 -0
  774. package/dist/dispatch/lib/gateway-meta.d.ts.map +1 -0
  775. package/dist/dispatch/lib/gateway-meta.js +50 -0
  776. package/dist/dispatch/lib/gateway-meta.js.map +1 -0
  777. package/dist/dispatch/lib/job-manager-accessor.d.ts +9 -0
  778. package/dist/dispatch/lib/job-manager-accessor.d.ts.map +1 -0
  779. package/dist/dispatch/lib/job-manager-accessor.js +13 -0
  780. package/dist/dispatch/lib/job-manager-accessor.js.map +1 -0
  781. package/dist/dispatch/lib/meta.d.ts +26 -0
  782. package/dist/dispatch/lib/meta.d.ts.map +1 -0
  783. package/dist/dispatch/lib/meta.js +37 -0
  784. package/dist/dispatch/lib/meta.js.map +1 -0
  785. package/dist/dispatch/lib/param-utils.d.ts +11 -0
  786. package/dist/dispatch/lib/param-utils.d.ts.map +1 -0
  787. package/dist/dispatch/lib/param-utils.js +10 -0
  788. package/dist/dispatch/lib/param-utils.js.map +1 -0
  789. package/dist/dispatch/lib/projections.d.ts +56 -0
  790. package/dist/dispatch/lib/projections.d.ts.map +1 -0
  791. package/dist/dispatch/lib/projections.js +65 -0
  792. package/dist/dispatch/lib/projections.js.map +1 -0
  793. package/dist/dispatch/lib/proto-envelope.d.ts +56 -0
  794. package/dist/dispatch/lib/proto-envelope.d.ts.map +1 -0
  795. package/dist/dispatch/lib/proto-envelope.js +17 -0
  796. package/dist/dispatch/lib/proto-envelope.js.map +1 -0
  797. package/dist/dispatch/lib/schema-utils.d.ts +39 -0
  798. package/dist/dispatch/lib/schema-utils.d.ts.map +1 -0
  799. package/dist/dispatch/lib/schema-utils.js +88 -0
  800. package/dist/dispatch/lib/schema-utils.js.map +1 -0
  801. package/dist/dispatch/lib/security.d.ts +11 -0
  802. package/dist/dispatch/lib/security.d.ts.map +1 -0
  803. package/dist/dispatch/lib/security.js +10 -0
  804. package/dist/dispatch/lib/security.js.map +1 -0
  805. package/dist/dispatch/middleware/audit.d.ts +23 -0
  806. package/dist/dispatch/middleware/audit.d.ts.map +1 -0
  807. package/dist/dispatch/middleware/audit.js +169 -0
  808. package/dist/dispatch/middleware/audit.js.map +1 -0
  809. package/dist/dispatch/middleware/field-filter.d.ts +25 -0
  810. package/dist/dispatch/middleware/field-filter.d.ts.map +1 -0
  811. package/dist/dispatch/middleware/field-filter.js +70 -0
  812. package/dist/dispatch/middleware/field-filter.js.map +1 -0
  813. package/dist/dispatch/middleware/pipeline.d.ts +33 -0
  814. package/dist/dispatch/middleware/pipeline.d.ts.map +1 -0
  815. package/dist/dispatch/middleware/pipeline.js +60 -0
  816. package/dist/dispatch/middleware/pipeline.js.map +1 -0
  817. package/dist/dispatch/middleware/projection.d.ts +35 -0
  818. package/dist/dispatch/middleware/projection.d.ts.map +1 -0
  819. package/dist/dispatch/middleware/projection.js +146 -0
  820. package/dist/dispatch/middleware/projection.js.map +1 -0
  821. package/dist/dispatch/middleware/protocol-enforcement.d.ts +30 -0
  822. package/dist/dispatch/middleware/protocol-enforcement.d.ts.map +1 -0
  823. package/dist/dispatch/middleware/protocol-enforcement.js +56 -0
  824. package/dist/dispatch/middleware/protocol-enforcement.js.map +1 -0
  825. package/dist/dispatch/middleware/rate-limiter.d.ts +72 -0
  826. package/dist/dispatch/middleware/rate-limiter.d.ts.map +1 -0
  827. package/dist/dispatch/middleware/rate-limiter.js +127 -0
  828. package/dist/dispatch/middleware/rate-limiter.js.map +1 -0
  829. package/dist/dispatch/middleware/sanitizer.d.ts +24 -0
  830. package/dist/dispatch/middleware/sanitizer.d.ts.map +1 -0
  831. package/dist/dispatch/middleware/sanitizer.js +56 -0
  832. package/dist/dispatch/middleware/sanitizer.js.map +1 -0
  833. package/dist/dispatch/middleware/session-resolver.d.ts +26 -0
  834. package/dist/dispatch/middleware/session-resolver.d.ts.map +1 -0
  835. package/dist/dispatch/middleware/session-resolver.js +65 -0
  836. package/dist/dispatch/middleware/session-resolver.js.map +1 -0
  837. package/dist/dispatch/middleware/telemetry.d.ts +21 -0
  838. package/dist/dispatch/middleware/telemetry.d.ts.map +1 -0
  839. package/dist/dispatch/middleware/telemetry.js +50 -0
  840. package/dist/dispatch/middleware/telemetry.js.map +1 -0
  841. package/dist/dispatch/middleware/verification-gates.d.ts +22 -0
  842. package/dist/dispatch/middleware/verification-gates.d.ts.map +1 -0
  843. package/dist/dispatch/middleware/verification-gates.js +59 -0
  844. package/dist/dispatch/middleware/verification-gates.js.map +1 -0
  845. package/dist/dispatch/registry.d.ts +91 -0
  846. package/dist/dispatch/registry.d.ts.map +1 -0
  847. package/dist/dispatch/registry.js +6430 -0
  848. package/dist/dispatch/registry.js.map +1 -0
  849. package/dist/dispatch/types.d.ts +150 -0
  850. package/dist/dispatch/types.d.ts.map +1 -0
  851. package/dist/dispatch/types.js +38 -0
  852. package/dist/dispatch/types.js.map +1 -0
  853. package/dist/migrations/2026-04-25-t991-parent-link-repair.d.ts +88 -0
  854. package/dist/migrations/2026-04-25-t991-parent-link-repair.d.ts.map +1 -0
  855. package/dist/migrations/2026-04-25-t991-parent-link-repair.js +76 -0
  856. package/dist/migrations/2026-04-25-t991-parent-link-repair.js.map +1 -0
  857. package/package.json +9 -9
@@ -0,0 +1,1278 @@
1
+ /**
2
+ * System Engine
3
+ *
4
+ * Thin wrapper layer that delegates to core modules.
5
+ * All business logic lives in src/core/.
6
+ *
7
+ * Read-only queries: dash, stats, labels, archive-stats, log, context, sequence,
8
+ * metrics, health, diagnostics, help, roadmap, compliance
9
+ * Mutate operations: inject.generate, backup, restore, migrate, cleanup, audit,
10
+ * sync, safestop, uncancel
11
+ *
12
+ * @task T4631
13
+ * @task T4783
14
+ */
15
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
16
+ import { basename, join } from 'node:path';
17
+ import { analyzeArchive, auditData, cleanupSystem, systemCreateBackup as createBackup, ensureCleoOsHub, generateInjection, getAccessor, getArchiveStats, getCleoCantWorkflowsDir, getCleoConfigDir, getCleoGlobalAgentsDir, getCleoGlobalJustfilePath, getCleoGlobalRecipesDir, getCleoHome, getCleoPiExtensionsDir, getDashboard, getLabels, getMigrationStatus, getProjectStats, getRoadmap, getRuntimeDiagnostics, getSystemDiagnostics, getSystemHealth, getSystemMetrics, listSystemBackups, repairSequence, restoreBackup, safestop, uncancelTask, } from '@cleocode/core/internal';
18
+ import { CLEO_DIR_NAME, COMPLIANCE_JSONL, METRICS_SUBDIR, TASKS_DB_FILENAME, } from '../../cli/paths.js';
19
+ import { cleoErrorToEngineError, engineError } from './_error.js';
20
+ // ===== Help topics (static data, stays in engine) =====
21
+ const HELP_TOPICS = {
22
+ session: {
23
+ topic: 'session',
24
+ content: [
25
+ 'Session Management',
26
+ '',
27
+ ' cleosession list - List all sessions',
28
+ ' cleosession start --scope epic:T001 - Start session',
29
+ ' cleosession end --note "Progress" - End session',
30
+ ' cleosession resume <id> - Resume session',
31
+ ].join('\n'),
32
+ relatedCommands: ['cleo session list', 'cleo session start', 'cleo session end'],
33
+ },
34
+ tasks: {
35
+ topic: 'tasks',
36
+ content: [
37
+ 'Task Operations',
38
+ '',
39
+ ' cleoadd "Title" --desc "Description" - Create task',
40
+ ' cleoupdate T1234 --status active - Update task',
41
+ ' cleocomplete T1234 - Complete task',
42
+ ' cleofind "query" - Search tasks',
43
+ ' cleoshow T1234 - Show task details',
44
+ ].join('\n'),
45
+ relatedCommands: ['cleo add', 'cleo update', 'cleo complete', 'cleo find', 'cleo show'],
46
+ },
47
+ focus: {
48
+ topic: 'focus',
49
+ content: [
50
+ 'Task Work Management',
51
+ '',
52
+ ' cleostart T1234 - Start working on task',
53
+ ' cleocurrent - Show current task',
54
+ ' cleostop - Stop working on current task',
55
+ ].join('\n'),
56
+ relatedCommands: ['cleo start', 'cleo current', 'cleo stop'],
57
+ },
58
+ labels: {
59
+ topic: 'labels',
60
+ content: [
61
+ 'Label Operations',
62
+ '',
63
+ ' cleolabels - List all labels',
64
+ ' cleolabels show <name> - Show tasks with label',
65
+ ].join('\n'),
66
+ relatedCommands: ['cleo labels'],
67
+ },
68
+ compliance: {
69
+ topic: 'compliance',
70
+ content: [
71
+ 'Compliance Monitoring',
72
+ '',
73
+ ' cleocompliance summary - Compliance overview',
74
+ ' cleocompliance violations - List violations',
75
+ ' cleocompliance trend - Compliance trend',
76
+ ].join('\n'),
77
+ relatedCommands: ['cleo compliance summary', 'cleo compliance violations'],
78
+ },
79
+ };
80
+ // ===== Dashboard =====
81
+ /**
82
+ * Project dashboard: task counts by status, active session info,
83
+ * current focus, recent completions.
84
+ *
85
+ * @remarks
86
+ * This is the primary overview endpoint for the CLEO CLI `dash` command.
87
+ * It aggregates task counts, current session/focus state, high-priority tasks,
88
+ * blocked tasks, and recent completions into a single response.
89
+ *
90
+ * @param projectRoot - Absolute path to the project root
91
+ * @param params - Optional parameters to control blocked tasks display limit
92
+ * @returns EngineResult with comprehensive dashboard data
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const result = await systemDash('/project', { blockedTasksLimit: 5 });
97
+ * ```
98
+ */
99
+ export async function systemDash(projectRoot, params) {
100
+ try {
101
+ const accessor = await getAccessor(projectRoot);
102
+ const result = await getDashboard({ cwd: projectRoot, blockedTasksLimit: params?.blockedTasksLimit }, accessor);
103
+ // Add missing fields that core doesn't produce
104
+ const data = result;
105
+ const summary = data.summary;
106
+ return {
107
+ success: true,
108
+ data: {
109
+ project: data.project,
110
+ currentPhase: data.currentPhase,
111
+ summary: {
112
+ pending: summary.pending,
113
+ active: summary.active,
114
+ blocked: summary.blocked,
115
+ done: summary.done,
116
+ cancelled: summary.cancelled ?? 0,
117
+ total: summary.total,
118
+ archived: summary.archived ?? 0,
119
+ grandTotal: summary.grandTotal ?? summary.total,
120
+ },
121
+ taskWork: (data.focus ?? data.taskWork),
122
+ activeSession: data.activeSession ?? null,
123
+ highPriority: data.highPriority,
124
+ blockedTasks: data.blockedTasks,
125
+ recentCompletions: (data.recentCompletions ?? []),
126
+ topLabels: data.topLabels,
127
+ },
128
+ };
129
+ }
130
+ catch (err) {
131
+ return cleoErrorToEngineError(err, 'E_NOT_INITIALIZED', 'System not initialized');
132
+ }
133
+ }
134
+ // ===== Stats =====
135
+ /**
136
+ * Detailed statistics: tasks by status/priority/type/phase,
137
+ * completion rate, average cycle time.
138
+ */
139
+ export async function systemStats(projectRoot, params) {
140
+ try {
141
+ const accessor = await getAccessor(projectRoot);
142
+ const result = await getProjectStats({ period: String(params?.period ?? 30), cwd: projectRoot }, accessor);
143
+ // Core stats lacks byPriority, byType, byPhase, cycleTimes — fill from accessor
144
+ const queryResult = await accessor.queryTasks({});
145
+ const tasks = queryResult?.tasks ?? [];
146
+ // Distribution breakdowns: active tasks only (exclude cancelled — not actionable work)
147
+ const activeTasks = tasks.filter((t) => t.status !== 'cancelled');
148
+ const byPriority = {};
149
+ for (const t of activeTasks) {
150
+ byPriority[t.priority] = (byPriority[t.priority] ?? 0) + 1;
151
+ }
152
+ const byType = {};
153
+ for (const t of activeTasks) {
154
+ const type = t.type || 'task';
155
+ byType[type] = (byType[type] ?? 0) + 1;
156
+ }
157
+ // byPhase tracks RCASD-IVTR+C pipeline stages (pipelineStage), not project phases (phase).
158
+ // t.phase is a legacy project-phase field (e.g. "Phase 1"); t.pipelineStage is RCASD.
159
+ const byPhase = {};
160
+ for (const t of activeTasks) {
161
+ const phase = t.pipelineStage || 'unassigned';
162
+ byPhase[phase] = (byPhase[phase] ?? 0) + 1;
163
+ }
164
+ // Cycle times
165
+ const completedTasks = tasks.filter((t) => t.status === 'done' && t.completedAt && t.createdAt);
166
+ let totalCycleDays = 0;
167
+ let samples = 0;
168
+ for (const t of completedTasks) {
169
+ const created = new Date(t.createdAt).getTime();
170
+ const completed = new Date(t.completedAt).getTime();
171
+ if (completed > created) {
172
+ totalCycleDays += (completed - created) / 86400000;
173
+ samples++;
174
+ }
175
+ }
176
+ const averageDays = samples > 0 ? Math.round((totalCycleDays / samples) * 100) / 100 : null;
177
+ const coreData = result;
178
+ const currentState = coreData.currentState;
179
+ const completionMetrics = coreData.completionMetrics;
180
+ const activityMetrics = coreData.activityMetrics;
181
+ const allTime = coreData.allTime;
182
+ return {
183
+ success: true,
184
+ data: {
185
+ currentState: {
186
+ pending: currentState.pending,
187
+ active: currentState.active,
188
+ done: currentState.done,
189
+ blocked: currentState.blocked,
190
+ cancelled: tasks.filter((t) => t.status === 'cancelled').length,
191
+ totalActive: currentState.totalActive,
192
+ archived: currentState.archived ?? 0,
193
+ grandTotal: currentState.grandTotal ?? currentState.totalActive,
194
+ },
195
+ byPriority,
196
+ byType,
197
+ byPhase,
198
+ completionMetrics: completionMetrics,
199
+ activityMetrics: activityMetrics,
200
+ allTime: allTime,
201
+ cycleTimes: { averageDays, samples },
202
+ },
203
+ };
204
+ }
205
+ catch (err) {
206
+ return cleoErrorToEngineError(err, 'E_NOT_INITIALIZED', 'Failed to get stats');
207
+ }
208
+ }
209
+ // ===== Labels =====
210
+ /**
211
+ * List all unique labels across tasks with counts and task IDs per label.
212
+ */
213
+ export async function systemLabels(projectRoot) {
214
+ try {
215
+ const accessor = await getAccessor(projectRoot);
216
+ const result = await getLabels(projectRoot, accessor);
217
+ return { success: true, data: result };
218
+ }
219
+ catch (err) {
220
+ return cleoErrorToEngineError(err, 'E_NOT_INITIALIZED', 'Failed to get labels');
221
+ }
222
+ }
223
+ // ===== Archive Stats =====
224
+ /**
225
+ * Archive metrics: total archived, by reason, average cycle time, archive rate.
226
+ * When a report type is specified, delegates to analyzeArchive for detailed analytics.
227
+ */
228
+ export async function systemArchiveStats(projectRoot, params) {
229
+ try {
230
+ const accessor = await getAccessor(projectRoot);
231
+ // If a non-default report type is requested, use the full analytics engine
232
+ if (params?.report && params.report !== 'summary') {
233
+ const result = await analyzeArchive({
234
+ report: params.report,
235
+ since: params.since,
236
+ until: params.until,
237
+ cwd: projectRoot,
238
+ }, accessor);
239
+ return { success: true, data: result };
240
+ }
241
+ const result = await getArchiveStats({ period: params?.period, cwd: projectRoot }, accessor);
242
+ return { success: true, data: result };
243
+ }
244
+ catch (err) {
245
+ return cleoErrorToEngineError(err, 'E_NOT_INITIALIZED', 'Failed to get archive stats');
246
+ }
247
+ }
248
+ // ===== Log =====
249
+ /**
250
+ * Query audit log with optional filters.
251
+ * Reads from SQLite audit_log table.
252
+ *
253
+ * @task T4837
254
+ */
255
+ export async function systemLog(projectRoot, filters) {
256
+ try {
257
+ // Canonical path: SQLite audit_log table.
258
+ const entries = await queryAuditLogSqlite(projectRoot, filters);
259
+ return { success: true, data: entries };
260
+ }
261
+ catch (err) {
262
+ return cleoErrorToEngineError(err, 'E_FILE_ERROR', 'Failed to read audit log');
263
+ }
264
+ }
265
+ /**
266
+ * Query audit_log from SQLite.
267
+ * Includes dispatch-level fields (domain, requestId, durationMs, success,
268
+ * source, gateway, errorMessage) when present (T4844).
269
+ *
270
+ * @task T4837
271
+ * @task T4844
272
+ */
273
+ async function queryAuditLogSqlite(projectRoot, filters) {
274
+ try {
275
+ const { join } = await import('node:path');
276
+ const { existsSync } = await import('node:fs');
277
+ const dbPath = join(projectRoot, CLEO_DIR_NAME, TASKS_DB_FILENAME);
278
+ if (!existsSync(dbPath)) {
279
+ const offset = filters?.offset ?? 0;
280
+ const limit = filters?.limit ?? 20;
281
+ return {
282
+ entries: [],
283
+ pagination: { total: 0, offset, limit, hasMore: false },
284
+ };
285
+ }
286
+ const { getDb } = await import('@cleocode/core/internal');
287
+ const { auditLog } = await import('@cleocode/core/internal');
288
+ const { sql } = await import('drizzle-orm');
289
+ const db = await getDb(projectRoot);
290
+ // Check if audit_log table exists and has data
291
+ try {
292
+ // Build dynamic WHERE conditions
293
+ const conditions = [];
294
+ if (filters?.operation) {
295
+ // Match against both legacy 'action' column and new 'operation' column
296
+ conditions.push(sql `(${auditLog.action} = ${filters.operation} OR ${auditLog.operation} = ${filters.operation})`);
297
+ }
298
+ if (filters?.taskId) {
299
+ conditions.push(sql `${auditLog.taskId} = ${filters.taskId}`);
300
+ }
301
+ if (filters?.since) {
302
+ conditions.push(sql `${auditLog.timestamp} >= ${filters.since}`);
303
+ }
304
+ if (filters?.until) {
305
+ conditions.push(sql `${auditLog.timestamp} <= ${filters.until}`);
306
+ }
307
+ const whereClause = conditions.length > 0 ? sql.join(conditions, sql ` AND `) : sql `1=1`;
308
+ // Count total matching entries
309
+ const countResult = await db.all(sql `SELECT count(*) as cnt FROM ${auditLog} WHERE ${whereClause}`);
310
+ const total = countResult[0]?.cnt ?? 0;
311
+ if (total === 0) {
312
+ return {
313
+ entries: [],
314
+ pagination: {
315
+ total: 0,
316
+ offset: filters?.offset ?? 0,
317
+ limit: filters?.limit ?? 20,
318
+ hasMore: false,
319
+ },
320
+ };
321
+ }
322
+ const offset = filters?.offset ?? 0;
323
+ const limit = filters?.limit ?? 20;
324
+ // Fetch paginated results (includes dispatch-level columns)
325
+ const rows = await db.all(sql `SELECT * FROM ${auditLog}
326
+ WHERE ${whereClause}
327
+ ORDER BY ${auditLog.timestamp} DESC
328
+ LIMIT ${limit} OFFSET ${offset}`);
329
+ const entries = rows.map((row) => ({
330
+ operation: row.operation ?? row.action,
331
+ taskId: row.task_id,
332
+ timestamp: row.timestamp,
333
+ actor: row.actor,
334
+ details: row.details_json ? JSON.parse(row.details_json) : {},
335
+ before: row.before_json ? JSON.parse(row.before_json) : undefined,
336
+ after: row.after_json ? JSON.parse(row.after_json) : undefined,
337
+ // Dispatch-level fields (may be null for legacy task-only entries)
338
+ ...(row.domain != null && {
339
+ domain: row.domain,
340
+ sessionId: row.session_id,
341
+ requestId: row.request_id,
342
+ durationMs: row.duration_ms,
343
+ success: row.success === 1,
344
+ source: row.source,
345
+ gateway: row.gateway,
346
+ error: row.error_message,
347
+ }),
348
+ }));
349
+ return {
350
+ entries,
351
+ pagination: { total, offset, limit, hasMore: offset + limit < total },
352
+ };
353
+ }
354
+ catch {
355
+ const offset = filters?.offset ?? 0;
356
+ const limit = filters?.limit ?? 20;
357
+ return {
358
+ entries: [],
359
+ pagination: { total: 0, offset, limit, hasMore: false },
360
+ };
361
+ }
362
+ }
363
+ catch {
364
+ const offset = filters?.offset ?? 0;
365
+ const limit = filters?.limit ?? 20;
366
+ return {
367
+ entries: [],
368
+ pagination: { total: 0, offset, limit, hasMore: false },
369
+ };
370
+ }
371
+ }
372
+ // ===== Context =====
373
+ /**
374
+ * Context window tracking: estimate token usage from current session/state.
375
+ */
376
+ export function systemContext(projectRoot, params) {
377
+ try {
378
+ const cleoDir = join(projectRoot, CLEO_DIR_NAME);
379
+ // Resolve state file
380
+ let stateFile;
381
+ if (params?.session) {
382
+ const sessionFile = join(cleoDir, 'context-states', `context-state-${params.session}.json`);
383
+ stateFile = existsSync(sessionFile) ? sessionFile : join(cleoDir, '.context-state.json');
384
+ }
385
+ else {
386
+ const currentSessionPath = join(cleoDir, '.current-session');
387
+ if (existsSync(currentSessionPath)) {
388
+ const currentSession = readFileSync(currentSessionPath, 'utf-8').trim();
389
+ if (currentSession) {
390
+ const sessionFile = join(cleoDir, 'context-states', `context-state-${currentSession}.json`);
391
+ stateFile = existsSync(sessionFile) ? sessionFile : join(cleoDir, '.context-state.json');
392
+ }
393
+ else {
394
+ stateFile = join(cleoDir, '.context-state.json');
395
+ }
396
+ }
397
+ else {
398
+ stateFile = join(cleoDir, '.context-state.json');
399
+ }
400
+ }
401
+ // Collect session files
402
+ const sessions = [];
403
+ const statesDir = join(cleoDir, 'context-states');
404
+ if (existsSync(statesDir)) {
405
+ for (const file of readdirSync(statesDir)) {
406
+ if (file.startsWith('context-state-') && file.endsWith('.json')) {
407
+ try {
408
+ const state = JSON.parse(readFileSync(join(statesDir, file), 'utf-8'));
409
+ sessions.push({
410
+ file: basename(file),
411
+ sessionId: state.sessionId ?? null,
412
+ percentage: state.contextWindow?.percentage ?? 0,
413
+ status: state.status ?? 'unknown',
414
+ timestamp: state.timestamp,
415
+ });
416
+ }
417
+ catch {
418
+ // skip invalid files
419
+ }
420
+ }
421
+ }
422
+ }
423
+ const singletonFile = join(cleoDir, '.context-state.json');
424
+ if (existsSync(singletonFile)) {
425
+ try {
426
+ const state = JSON.parse(readFileSync(singletonFile, 'utf-8'));
427
+ sessions.push({
428
+ file: '.context-state.json',
429
+ sessionId: state.sessionId ?? 'global',
430
+ percentage: state.contextWindow?.percentage ?? 0,
431
+ status: state.status ?? 'unknown',
432
+ timestamp: state.timestamp,
433
+ });
434
+ }
435
+ catch {
436
+ // skip
437
+ }
438
+ }
439
+ if (!existsSync(stateFile)) {
440
+ return {
441
+ success: true,
442
+ data: {
443
+ available: false,
444
+ status: 'unavailable',
445
+ percentage: 0,
446
+ currentTokens: 0,
447
+ maxTokens: 0,
448
+ timestamp: null,
449
+ stale: true,
450
+ sessions,
451
+ },
452
+ };
453
+ }
454
+ try {
455
+ const state = JSON.parse(readFileSync(stateFile, 'utf-8'));
456
+ const timestamp = state.timestamp;
457
+ const staleMs = state.staleAfterMs ?? 5000;
458
+ const percentage = state.contextWindow?.percentage ?? 0;
459
+ const current = state.contextWindow?.currentTokens ?? 0;
460
+ const max = state.contextWindow?.maxTokens ?? 0;
461
+ let status = state.status ?? 'unknown';
462
+ const fileTime = new Date(timestamp).getTime();
463
+ if (Date.now() - fileTime > staleMs) {
464
+ status = 'stale';
465
+ }
466
+ return {
467
+ success: true,
468
+ data: {
469
+ available: true,
470
+ status,
471
+ percentage,
472
+ currentTokens: current,
473
+ maxTokens: max,
474
+ timestamp,
475
+ stale: status === 'stale',
476
+ sessions,
477
+ },
478
+ };
479
+ }
480
+ catch {
481
+ return {
482
+ success: true,
483
+ data: {
484
+ available: false,
485
+ status: 'error',
486
+ percentage: 0,
487
+ currentTokens: 0,
488
+ maxTokens: 0,
489
+ timestamp: null,
490
+ stale: true,
491
+ sessions,
492
+ },
493
+ };
494
+ }
495
+ }
496
+ catch (err) {
497
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'System operation failed');
498
+ }
499
+ }
500
+ // ===== Sequence =====
501
+ /**
502
+ * Read task ID sequence state from canonical SQLite metadata.
503
+ * Supports 'show' and 'check' actions.
504
+ * @task T4815
505
+ */
506
+ export async function systemSequence(projectRoot, params) {
507
+ const { showSequence, checkSequence } = await import('@cleocode/core/internal');
508
+ try {
509
+ const action = params?.action ?? 'show';
510
+ if (action === 'check') {
511
+ const check = await checkSequence(projectRoot);
512
+ return { success: true, data: check };
513
+ }
514
+ const seq = await showSequence(projectRoot);
515
+ return {
516
+ success: true,
517
+ data: {
518
+ counter: Number(seq.counter ?? 0),
519
+ lastId: String(seq.lastId ?? ''),
520
+ checksum: String(seq.checksum ?? ''),
521
+ nextId: String(seq.nextId ?? ''),
522
+ },
523
+ };
524
+ }
525
+ catch (err) {
526
+ return cleoErrorToEngineError(err, 'E_NOT_FOUND', 'Sequence not found');
527
+ }
528
+ }
529
+ // ===== Inject Generate (MVI) =====
530
+ /**
531
+ * Generate Minimum Viable Injection (MVI).
532
+ */
533
+ export async function systemInjectGenerate(projectRoot) {
534
+ try {
535
+ const root = projectRoot || process.cwd();
536
+ const accessor = await getAccessor(root);
537
+ const result = await generateInjection(root, accessor);
538
+ return { success: true, data: result };
539
+ }
540
+ catch (err) {
541
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to generate injection');
542
+ }
543
+ }
544
+ // ===== Metrics =====
545
+ /**
546
+ * System metrics: token usage, compliance summary, session counts.
547
+ * @task T4631
548
+ */
549
+ export async function systemMetrics(projectRoot, params) {
550
+ try {
551
+ const accessor = await getAccessor(projectRoot);
552
+ const result = await getSystemMetrics(projectRoot, params, accessor);
553
+ return { success: true, data: result };
554
+ }
555
+ catch (err) {
556
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to get metrics');
557
+ }
558
+ }
559
+ // ===== Health =====
560
+ /**
561
+ * System health check: verify core data files exist and are valid.
562
+ * @task T4631
563
+ */
564
+ export async function systemHealth(projectRoot, params) {
565
+ try {
566
+ const result = await getSystemHealth(projectRoot, params);
567
+ return { success: true, data: result };
568
+ }
569
+ catch (err) {
570
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to get health');
571
+ }
572
+ }
573
+ // ===== Diagnostics =====
574
+ /**
575
+ * System diagnostics: extended health checks with fix suggestions.
576
+ * @task T4631
577
+ */
578
+ export async function systemDiagnostics(projectRoot, params) {
579
+ try {
580
+ const result = await getSystemDiagnostics(projectRoot, params);
581
+ return { success: true, data: result };
582
+ }
583
+ catch (err) {
584
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to get diagnostics');
585
+ }
586
+ }
587
+ // ===== Help =====
588
+ /**
589
+ * Return help text for the system.
590
+ * @task T4631
591
+ */
592
+ export function systemHelp(_projectRoot, params) {
593
+ const topic = params?.topic;
594
+ if (topic) {
595
+ const topicHelp = HELP_TOPICS[topic];
596
+ if (topicHelp) {
597
+ return { success: true, data: topicHelp };
598
+ }
599
+ return engineError('E_NOT_FOUND', `Unknown help topic: ${topic}. Available topics: ${Object.keys(HELP_TOPICS).join(', ')}`);
600
+ }
601
+ return {
602
+ success: true,
603
+ data: {
604
+ content: [
605
+ 'CLEO Task Management System',
606
+ '',
607
+ 'Essential Commands:',
608
+ ' cleofind "query" - Fuzzy search tasks',
609
+ ' cleoshow T1234 - Full task details',
610
+ ' cleoadd "Task" - Create task',
611
+ ' cleodone <id> - Complete task',
612
+ ' cleostart <id> - Start working on task',
613
+ ' cleodash - Project overview',
614
+ ' cleosession list - List sessions',
615
+ '',
616
+ 'Help Topics: session, tasks, focus, labels, compliance',
617
+ ].join('\n'),
618
+ relatedCommands: ['cleo find', 'cleo show', 'cleo add', 'cleo done', 'cleo dash'],
619
+ },
620
+ };
621
+ }
622
+ // ===== Roadmap =====
623
+ /**
624
+ * Generate roadmap from pending epics and optional CHANGELOG history.
625
+ * @task T4631
626
+ */
627
+ export async function systemRoadmap(projectRoot, params) {
628
+ try {
629
+ const accessor = await getAccessor(projectRoot);
630
+ const result = await getRoadmap({
631
+ includeHistory: params?.includeHistory,
632
+ upcomingOnly: params?.upcomingOnly,
633
+ cwd: projectRoot,
634
+ }, accessor);
635
+ return { success: true, data: result };
636
+ }
637
+ catch (err) {
638
+ return cleoErrorToEngineError(err, 'E_NOT_INITIALIZED', 'System not initialized');
639
+ }
640
+ }
641
+ // ===== Compliance =====
642
+ /**
643
+ * System compliance report from COMPLIANCE.jsonl.
644
+ * @task T4631
645
+ */
646
+ export function systemCompliance(projectRoot, params) {
647
+ try {
648
+ if (params?.subcommand === 'trend') {
649
+ const compliancePath = join(projectRoot, CLEO_DIR_NAME, METRICS_SUBDIR, COMPLIANCE_JSONL);
650
+ let entries = [];
651
+ if (existsSync(compliancePath)) {
652
+ const content = readFileSync(compliancePath, 'utf-8').trim();
653
+ if (content) {
654
+ entries = content
655
+ .split('\n')
656
+ .filter((l) => l.trim())
657
+ .map((l) => JSON.parse(l));
658
+ }
659
+ }
660
+ if (params.epic) {
661
+ entries = entries.filter((e) => {
662
+ const ctx = (e._context ?? {});
663
+ return ctx.epic_id === params.epic || ctx.task_id === params.epic;
664
+ });
665
+ }
666
+ if (params.days) {
667
+ const cutoff = new Date(Date.now() - params.days * 86400000).toISOString();
668
+ entries = entries.filter((e) => e.timestamp >= cutoff);
669
+ }
670
+ const totalEntries = entries.length;
671
+ const compliance = entries.map((e) => (e.compliance ?? {}));
672
+ const avgPassRate = totalEntries > 0
673
+ ? Math.round((compliance.reduce((sum, c) => sum + (c.compliance_pass_rate ?? 0), 0) /
674
+ totalEntries) *
675
+ 1000) / 1000
676
+ : 0;
677
+ const avgAdherence = totalEntries > 0
678
+ ? Math.round((compliance.reduce((sum, c) => sum + (c.rule_adherence_score ?? 0), 0) /
679
+ totalEntries) *
680
+ 1000) / 1000
681
+ : 0;
682
+ const totalViolations = compliance.reduce((sum, c) => sum + (c.violation_count ?? 0), 0);
683
+ const byDate = {};
684
+ for (const e of entries) {
685
+ const date = e.timestamp.split('T')[0];
686
+ if (!byDate[date])
687
+ byDate[date] = [];
688
+ byDate[date].push(e);
689
+ }
690
+ const dataPoints = Object.entries(byDate)
691
+ .sort(([a], [b]) => a.localeCompare(b))
692
+ .map(([date, dayEntries]) => {
693
+ const dayCompliance = dayEntries.map((de) => (de.compliance ?? {}));
694
+ return {
695
+ date,
696
+ entries: dayEntries.length,
697
+ avgPassRate: dayCompliance.reduce((s, c) => s + (c.compliance_pass_rate ?? 0), 0) /
698
+ dayEntries.length,
699
+ violations: dayCompliance.reduce((s, c) => s + (c.violation_count ?? 0), 0),
700
+ };
701
+ });
702
+ let trend;
703
+ if (dataPoints.length >= 2) {
704
+ const first = dataPoints[0].avgPassRate;
705
+ const last = dataPoints[dataPoints.length - 1].avgPassRate;
706
+ trend = last > first ? 'improving' : last < first ? 'declining' : 'stable';
707
+ }
708
+ else {
709
+ trend = 'insufficient_data';
710
+ }
711
+ return {
712
+ success: true,
713
+ data: {
714
+ totalEntries,
715
+ averagePassRate: avgPassRate,
716
+ averageAdherence: avgAdherence,
717
+ totalViolations,
718
+ trend,
719
+ dataPoints,
720
+ },
721
+ };
722
+ }
723
+ // Default: summary (possibly filtered by epic/days)
724
+ const compliancePath = join(projectRoot, '.cleo', 'metrics', 'COMPLIANCE.jsonl');
725
+ let entries = [];
726
+ if (existsSync(compliancePath)) {
727
+ const content = readFileSync(compliancePath, 'utf-8').trim();
728
+ if (content) {
729
+ entries = content
730
+ .split('\n')
731
+ .filter((l) => l.trim())
732
+ .map((l) => JSON.parse(l));
733
+ }
734
+ }
735
+ if (params?.epic) {
736
+ entries = entries.filter((e) => {
737
+ const ctx = (e._context ?? {});
738
+ return ctx.epic_id === params.epic || ctx.task_id === params.epic;
739
+ });
740
+ }
741
+ if (params?.days) {
742
+ const cutoff = new Date(Date.now() - params.days * 86400000).toISOString();
743
+ entries = entries.filter((e) => e.timestamp >= cutoff);
744
+ }
745
+ const totalEntries = entries.length;
746
+ const compliance = entries.map((e) => (e.compliance ?? {}));
747
+ const avgPassRate = totalEntries > 0
748
+ ? Math.round((compliance.reduce((sum, c) => sum + (c.compliance_pass_rate ?? 0), 0) /
749
+ totalEntries) *
750
+ 1000) / 1000
751
+ : 0;
752
+ const avgAdherence = totalEntries > 0
753
+ ? Math.round((compliance.reduce((sum, c) => sum + (c.rule_adherence_score ?? 0), 0) /
754
+ totalEntries) *
755
+ 1000) / 1000
756
+ : 0;
757
+ const totalViolations = compliance.reduce((sum, c) => sum + (c.violation_count ?? 0), 0);
758
+ return {
759
+ success: true,
760
+ data: {
761
+ totalEntries,
762
+ averagePassRate: avgPassRate,
763
+ averageAdherence: avgAdherence,
764
+ totalViolations,
765
+ },
766
+ };
767
+ }
768
+ catch (err) {
769
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to get roadmap');
770
+ }
771
+ }
772
+ // ===== Backup =====
773
+ /**
774
+ * Create a backup of CLEO data files.
775
+ *
776
+ * Async because `createBackup` (T5158) now opens tasks.db + brain.db via
777
+ * their drizzle accessors before snapshotting so both databases are
778
+ * captured even when the current CLI command path hasn't already opened
779
+ * them (e.g. `cleo backup add` in a fresh process).
780
+ *
781
+ * @task T4631
782
+ * @task T5158
783
+ */
784
+ export async function systemBackup(projectRoot, params) {
785
+ try {
786
+ const result = await createBackup(projectRoot, params);
787
+ return { success: true, data: result };
788
+ }
789
+ catch (err) {
790
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to create backup');
791
+ }
792
+ }
793
+ /**
794
+ * List available system backups (read-only).
795
+ * @task T4783
796
+ */
797
+ export function systemListBackups(projectRoot) {
798
+ try {
799
+ const result = listSystemBackups(projectRoot);
800
+ return { success: true, data: result };
801
+ }
802
+ catch (err) {
803
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to list backups');
804
+ }
805
+ }
806
+ // ===== Restore =====
807
+ /**
808
+ * Restore from a backup.
809
+ * @task T4631
810
+ */
811
+ export function systemRestore(projectRoot, params) {
812
+ try {
813
+ const result = restoreBackup(projectRoot, params);
814
+ return { success: true, data: result };
815
+ }
816
+ catch (err) {
817
+ return cleoErrorToEngineError(err, 'E_RESTORE_FAILED', 'Failed to restore');
818
+ }
819
+ }
820
+ /**
821
+ * Restore an individual file from backup.
822
+ * @task T5329
823
+ */
824
+ export async function backupRestore(projectRoot, fileName, options) {
825
+ try {
826
+ const { getBackupDir, getTaskPath, getConfigPath } = await import('@cleocode/core/internal');
827
+ const { restoreFromBackup, listBackups } = await import('@cleocode/core/internal');
828
+ const backupDir = getBackupDir(projectRoot);
829
+ const targetPathMap = {
830
+ 'tasks.db': getTaskPath,
831
+ 'config.json': getConfigPath,
832
+ };
833
+ const pathGetter = targetPathMap[fileName];
834
+ if (!pathGetter) {
835
+ return engineError('E_INVALID_INPUT', `Unknown file: ${fileName}. Valid files: tasks.db, config.json`);
836
+ }
837
+ const targetPath = pathGetter();
838
+ const backups = await listBackups(fileName, backupDir);
839
+ if (backups.length === 0) {
840
+ return engineError('E_NOT_FOUND', `No backups found for ${fileName}`);
841
+ }
842
+ if (options?.dryRun) {
843
+ return {
844
+ success: true,
845
+ data: {
846
+ restored: false,
847
+ file: fileName,
848
+ from: backups[0],
849
+ targetPath,
850
+ dryRun: true,
851
+ },
852
+ };
853
+ }
854
+ const restoredFrom = await restoreFromBackup(fileName, backupDir, targetPath);
855
+ return {
856
+ success: true,
857
+ data: {
858
+ restored: true,
859
+ file: fileName,
860
+ from: restoredFrom,
861
+ targetPath,
862
+ },
863
+ };
864
+ }
865
+ catch (err) {
866
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Backup restore failed');
867
+ }
868
+ }
869
+ // ===== Migrate =====
870
+ /**
871
+ * Check/run schema migrations.
872
+ * @task T4631
873
+ */
874
+ export async function systemMigrate(projectRoot, params) {
875
+ try {
876
+ const result = await getMigrationStatus(projectRoot, params);
877
+ return { success: true, data: result };
878
+ }
879
+ catch (err) {
880
+ return cleoErrorToEngineError(err, 'E_MIGRATE_FAILED', 'Failed to migrate');
881
+ }
882
+ }
883
+ // ===== Cleanup =====
884
+ /**
885
+ * Cleanup stale data (sessions, backups, logs).
886
+ * @task T4631
887
+ */
888
+ export async function systemCleanup(projectRoot, params) {
889
+ try {
890
+ const result = await cleanupSystem(projectRoot, params);
891
+ return { success: true, data: result };
892
+ }
893
+ catch (err) {
894
+ return cleoErrorToEngineError(err, 'E_CLEANUP_FAILED', 'Failed to cleanup');
895
+ }
896
+ }
897
+ // ===== Audit =====
898
+ /**
899
+ * Audit data integrity.
900
+ * @task T4631
901
+ */
902
+ export async function systemAudit(projectRoot, params) {
903
+ try {
904
+ const result = await auditData(projectRoot, params);
905
+ return { success: true, data: result };
906
+ }
907
+ catch (err) {
908
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Failed to audit');
909
+ }
910
+ }
911
+ /**
912
+ * Sync check (no external sync targets in native mode).
913
+ * @task T4631
914
+ */
915
+ export function systemSync(_projectRoot, params) {
916
+ return {
917
+ success: true,
918
+ data: {
919
+ direction: params?.direction ?? 'up',
920
+ synced: 0,
921
+ conflicts: 0,
922
+ message: 'Sync is a no-op in native mode (no external sync targets configured)',
923
+ },
924
+ };
925
+ }
926
+ // ===== Safestop =====
927
+ /**
928
+ * Safe stop: signal clean shutdown for agents.
929
+ * @task T4631
930
+ */
931
+ export async function systemSafestop(projectRoot, params) {
932
+ try {
933
+ const result = await safestop(projectRoot, params);
934
+ return { success: true, data: result };
935
+ }
936
+ catch (err) {
937
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Sync failed');
938
+ }
939
+ }
940
+ // ===== Uncancel =====
941
+ /**
942
+ * Uncancel a cancelled task (restore to pending).
943
+ * @task T4631
944
+ */
945
+ export async function systemUncancel(projectRoot, params) {
946
+ try {
947
+ const result = await uncancelTask(projectRoot, params);
948
+ return { success: true, data: result };
949
+ }
950
+ catch (err) {
951
+ return cleoErrorToEngineError(err, 'E_UNCANCEL_FAILED', 'Failed to uncancel');
952
+ }
953
+ }
954
+ // ===== Doctor Report =====
955
+ /**
956
+ * Run comprehensive doctor diagnostics.
957
+ * @task T4795
958
+ */
959
+ export async function systemDoctor(projectRoot) {
960
+ const { coreDoctorReport } = await import('@cleocode/core/internal');
961
+ try {
962
+ const result = await coreDoctorReport(projectRoot);
963
+ return { success: true, data: result };
964
+ }
965
+ catch (err) {
966
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Doctor check failed');
967
+ }
968
+ }
969
+ // ===== Doctor Fix =====
970
+ /**
971
+ * Run auto-fix for failed doctor checks.
972
+ * @task T4795
973
+ */
974
+ export async function systemFix(projectRoot) {
975
+ const { runDoctorFixes } = await import('@cleocode/core/internal');
976
+ try {
977
+ const result = await runDoctorFixes(projectRoot);
978
+ return { success: true, data: result };
979
+ }
980
+ catch (err) {
981
+ return cleoErrorToEngineError(err, 'E_GENERAL', 'Doctor fix failed');
982
+ }
983
+ }
984
+ /**
985
+ * Runtime/channel diagnostics for CLI installation mode checks.
986
+ * @task T4815
987
+ */
988
+ export async function systemRuntime(_projectRoot, params) {
989
+ try {
990
+ const data = await getRuntimeDiagnostics({ detailed: params?.detailed ?? false });
991
+ return { success: true, data };
992
+ }
993
+ catch (err) {
994
+ return cleoErrorToEngineError(err, 'E_RUNTIME_ERROR', 'Runtime check failed');
995
+ }
996
+ }
997
+ /**
998
+ * Report all resolved CleoOS paths (project + global hub).
999
+ *
1000
+ * Backs the `cleo admin paths` CLI command. Read-only: reports current state
1001
+ * without mutating the filesystem. Use `systemScaffoldHub()` to create
1002
+ * missing hub directories and seed the starter justfile.
1003
+ *
1004
+ * @task Phase 1 — XDG Foundation + Justfile Hub Skeleton
1005
+ */
1006
+ export async function systemPaths(projectRoot) {
1007
+ try {
1008
+ const cleoHome = getCleoHome();
1009
+ const configDir = getCleoConfigDir();
1010
+ const globalRecipes = getCleoGlobalRecipesDir();
1011
+ const globalJustfile = getCleoGlobalJustfilePath();
1012
+ const piExtensions = getCleoPiExtensionsDir();
1013
+ const cantWorkflows = getCleoCantWorkflowsDir();
1014
+ const globalAgents = getCleoGlobalAgentsDir();
1015
+ return {
1016
+ success: true,
1017
+ data: {
1018
+ projectCleoDir: join(projectRoot, CLEO_DIR_NAME),
1019
+ cleoHome,
1020
+ configDir,
1021
+ hub: {
1022
+ globalRecipes,
1023
+ globalJustfile,
1024
+ piExtensions,
1025
+ cantWorkflows,
1026
+ globalAgents,
1027
+ },
1028
+ scaffolded: {
1029
+ globalRecipes: existsSync(globalRecipes),
1030
+ globalJustfile: existsSync(globalJustfile),
1031
+ piExtensions: existsSync(piExtensions),
1032
+ cantWorkflows: existsSync(cantWorkflows),
1033
+ globalAgents: existsSync(globalAgents),
1034
+ },
1035
+ },
1036
+ };
1037
+ }
1038
+ catch (err) {
1039
+ return cleoErrorToEngineError(err, 'E_PATHS_RESOLVE_FAILED', 'Failed to resolve paths');
1040
+ }
1041
+ }
1042
+ /**
1043
+ * Create the CleoOS Hub directories and seed the starter justfile if absent.
1044
+ *
1045
+ * Idempotent: safe to call repeatedly. Never overwrites existing user-edited
1046
+ * justfile or README content. Backs the `cleo admin scaffold-hub` CLI
1047
+ * command and is invoked automatically by `cleo init` (Phase 5).
1048
+ *
1049
+ * @task Phase 1 — XDG Foundation + Justfile Hub Skeleton
1050
+ */
1051
+ export async function systemScaffoldHub() {
1052
+ try {
1053
+ const result = await ensureCleoOsHub();
1054
+ return { success: true, data: result };
1055
+ }
1056
+ catch (err) {
1057
+ return cleoErrorToEngineError(err, 'E_SCAFFOLD_HUB_FAILED', 'Failed to scaffold hub');
1058
+ }
1059
+ }
1060
+ /**
1061
+ * Repair task ID sequence using canonical core implementation.
1062
+ * @task T4815
1063
+ */
1064
+ export async function systemSequenceRepair(projectRoot) {
1065
+ try {
1066
+ const repair = await repairSequence(projectRoot);
1067
+ return {
1068
+ success: true,
1069
+ data: {
1070
+ repaired: repair.repaired,
1071
+ message: repair.message,
1072
+ counter: repair.counter,
1073
+ oldCounter: repair.oldCounter,
1074
+ newCounter: repair.newCounter,
1075
+ },
1076
+ };
1077
+ }
1078
+ catch (err) {
1079
+ return cleoErrorToEngineError(err, 'E_SEQUENCE_REPAIR_FAILED', 'Failed to repair sequence');
1080
+ }
1081
+ }
1082
+ /**
1083
+ * Smoke-test definitions: one lightweight read-only query per domain.
1084
+ * Each probe exercises the full dispatch pipeline (middleware, handler, engine, core).
1085
+ *
1086
+ * T511: includes an `adapter` probe so adapter health is covered by smoke tests,
1087
+ * consistent with its inclusion in the doctor report via `checkAdapterHealth()`.
1088
+ */
1089
+ const SMOKE_PROBES = [
1090
+ { domain: 'admin', operation: 'version' },
1091
+ { domain: 'tasks', operation: 'find', params: { query: '__smoke_probe__', limit: 1 } },
1092
+ { domain: 'session', operation: 'status' },
1093
+ { domain: 'memory', operation: 'find', params: { query: '__smoke_probe__' } },
1094
+ { domain: 'pipeline', operation: 'list' },
1095
+ { domain: 'check', operation: 'schema' },
1096
+ { domain: 'tools', operation: 'list', params: { limit: 1 } },
1097
+ { domain: 'sticky', operation: 'list', params: { limit: 1 } },
1098
+ { domain: 'nexus', operation: 'status' },
1099
+ { domain: 'orchestrate', operation: 'status' },
1100
+ { domain: 'adapter', operation: 'list' },
1101
+ ];
1102
+ /**
1103
+ * Run operational smoke tests across all domains.
1104
+ *
1105
+ * Dispatches one read-only query per domain through the full CLI dispatch
1106
+ * pipeline and reports pass/fail with timing. Catches crashes (TypeError,
1107
+ * ReferenceError, etc.) not just structured error responses.
1108
+ *
1109
+ * @task T130
1110
+ */
1111
+ export async function systemSmoke() {
1112
+ const { dispatchRaw } = await import('../adapters/cli.js');
1113
+ const totalStart = Date.now();
1114
+ const probes = [];
1115
+ for (const probe of SMOKE_PROBES) {
1116
+ const start = Date.now();
1117
+ try {
1118
+ const response = await dispatchRaw('query', probe.domain, probe.operation, probe.params);
1119
+ const elapsed = Date.now() - start;
1120
+ if (response.success) {
1121
+ probes.push({
1122
+ domain: probe.domain,
1123
+ operation: probe.operation,
1124
+ status: 'pass',
1125
+ timeMs: elapsed,
1126
+ });
1127
+ }
1128
+ else {
1129
+ // Structured error responses that are domain-specific (like "no session") are still valid
1130
+ // operational results — the dispatch pipeline worked. Only treat E_INTERNAL / E_NO_HANDLER as failures.
1131
+ const code = response.error?.code ?? '';
1132
+ const isCrash = code === 'E_INTERNAL' || code === 'E_NO_HANDLER';
1133
+ probes.push({
1134
+ domain: probe.domain,
1135
+ operation: probe.operation,
1136
+ status: isCrash ? 'fail' : 'pass',
1137
+ timeMs: elapsed,
1138
+ ...(isCrash ? { error: response.error?.message } : {}),
1139
+ });
1140
+ }
1141
+ }
1142
+ catch (err) {
1143
+ const elapsed = Date.now() - start;
1144
+ probes.push({
1145
+ domain: probe.domain,
1146
+ operation: probe.operation,
1147
+ status: 'fail',
1148
+ timeMs: elapsed,
1149
+ error: err instanceof Error ? `${err.constructor.name}: ${err.message}` : String(err),
1150
+ });
1151
+ }
1152
+ }
1153
+ // --- DB connectivity and migration state checks ---
1154
+ const dbChecks = [];
1155
+ // tasks.db connectivity + integrity
1156
+ {
1157
+ const start = Date.now();
1158
+ try {
1159
+ const { getDb, getNativeDb } = await import('@cleocode/core/internal');
1160
+ const projectRoot = (await import('@cleocode/core/internal')).getProjectRoot();
1161
+ await getDb(projectRoot);
1162
+ const nativeDb = getNativeDb();
1163
+ if (nativeDb) {
1164
+ const result = nativeDb.prepare('PRAGMA integrity_check').get();
1165
+ const ok = result?.integrity_check === 'ok';
1166
+ dbChecks.push({
1167
+ domain: 'db',
1168
+ operation: 'tasks.db',
1169
+ status: ok ? 'pass' : 'fail',
1170
+ timeMs: Date.now() - start,
1171
+ ...(!ok ? { error: 'SQLite integrity check failed' } : {}),
1172
+ });
1173
+ }
1174
+ else {
1175
+ dbChecks.push({
1176
+ domain: 'db',
1177
+ operation: 'tasks.db',
1178
+ status: 'fail',
1179
+ timeMs: Date.now() - start,
1180
+ error: 'Native DB handle unavailable',
1181
+ });
1182
+ }
1183
+ }
1184
+ catch (err) {
1185
+ dbChecks.push({
1186
+ domain: 'db',
1187
+ operation: 'tasks.db',
1188
+ status: 'fail',
1189
+ timeMs: Date.now() - start,
1190
+ error: err instanceof Error ? err.message : String(err),
1191
+ });
1192
+ }
1193
+ }
1194
+ // brain.db connectivity
1195
+ {
1196
+ const start = Date.now();
1197
+ try {
1198
+ const { getBrainDb } = await import('@cleocode/core/internal');
1199
+ const projectRoot = (await import('@cleocode/core/internal')).getProjectRoot();
1200
+ const brainDb = await getBrainDb(projectRoot);
1201
+ if (brainDb) {
1202
+ dbChecks.push({
1203
+ domain: 'db',
1204
+ operation: 'brain.db',
1205
+ status: 'pass',
1206
+ timeMs: Date.now() - start,
1207
+ });
1208
+ }
1209
+ else {
1210
+ dbChecks.push({
1211
+ domain: 'db',
1212
+ operation: 'brain.db',
1213
+ status: 'fail',
1214
+ timeMs: Date.now() - start,
1215
+ error: 'brain.db not initialized',
1216
+ });
1217
+ }
1218
+ }
1219
+ catch (err) {
1220
+ dbChecks.push({
1221
+ domain: 'db',
1222
+ operation: 'brain.db',
1223
+ status: 'fail',
1224
+ timeMs: Date.now() - start,
1225
+ error: err instanceof Error ? err.message : String(err),
1226
+ });
1227
+ }
1228
+ }
1229
+ // Migration state validation (detect stale journals)
1230
+ {
1231
+ const start = Date.now();
1232
+ try {
1233
+ const migrationStatus = await getMigrationStatus((await import('@cleocode/core/internal')).getProjectRoot());
1234
+ const hasPending = migrationStatus.migrations.some((m) => !m.applied);
1235
+ dbChecks.push({
1236
+ domain: 'db',
1237
+ operation: 'migrations',
1238
+ status: hasPending ? 'fail' : 'pass',
1239
+ timeMs: Date.now() - start,
1240
+ ...(hasPending
1241
+ ? {
1242
+ error: `Unapplied migrations detected (${migrationStatus.from} → ${migrationStatus.to}). Run: cleo upgrade`,
1243
+ }
1244
+ : {}),
1245
+ });
1246
+ }
1247
+ catch (err) {
1248
+ dbChecks.push({
1249
+ domain: 'db',
1250
+ operation: 'migrations',
1251
+ status: 'fail',
1252
+ timeMs: Date.now() - start,
1253
+ error: err instanceof Error ? err.message : String(err),
1254
+ });
1255
+ }
1256
+ }
1257
+ const allProbes = [...probes, ...dbChecks];
1258
+ const totalMs = Date.now() - totalStart;
1259
+ const passed = allProbes.filter((p) => p.status === 'pass').length;
1260
+ const failed = allProbes.filter((p) => p.status === 'fail').length;
1261
+ const skipped = allProbes.filter((p) => p.status === 'skip').length;
1262
+ if (failed === 0) {
1263
+ return {
1264
+ success: true,
1265
+ data: { probes, dbChecks, passed, failed, skipped, totalMs },
1266
+ };
1267
+ }
1268
+ return {
1269
+ success: false,
1270
+ error: {
1271
+ code: 'E_SMOKE_FAILURES',
1272
+ message: `${failed} probe(s) failed smoke test`,
1273
+ exitCode: 1,
1274
+ details: { probes, dbChecks, passed, failed, skipped, totalMs },
1275
+ },
1276
+ };
1277
+ }
1278
+ //# sourceMappingURL=system-engine.js.map