@cleocode/cleo 2026.4.10 → 2026.4.11

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 (693) hide show
  1. package/dist/cli/commander-shim.d.ts +112 -0
  2. package/dist/cli/commander-shim.d.ts.map +1 -0
  3. package/dist/cli/commander-shim.js +233 -0
  4. package/dist/cli/commander-shim.js.map +1 -0
  5. package/dist/cli/commands/add.d.ts +12 -0
  6. package/dist/cli/commands/add.d.ts.map +1 -0
  7. package/dist/cli/commands/add.js +98 -0
  8. package/dist/cli/commands/add.js.map +1 -0
  9. package/dist/cli/commands/admin.d.ts +12 -0
  10. package/dist/cli/commands/admin.d.ts.map +1 -0
  11. package/dist/cli/commands/admin.js +59 -0
  12. package/dist/cli/commands/admin.js.map +1 -0
  13. package/dist/cli/commands/adr.d.ts +27 -0
  14. package/dist/cli/commands/adr.d.ts.map +1 -0
  15. package/dist/cli/commands/adr.js +79 -0
  16. package/dist/cli/commands/adr.js.map +1 -0
  17. package/dist/cli/commands/agent-profile-status.d.ts +98 -0
  18. package/dist/cli/commands/agent-profile-status.d.ts.map +1 -0
  19. package/dist/cli/commands/agent-profile-status.js +71 -0
  20. package/dist/cli/commands/agent-profile-status.js.map +1 -0
  21. package/dist/cli/commands/agent.d.ts +38 -0
  22. package/dist/cli/commands/agent.d.ts.map +1 -0
  23. package/dist/cli/commands/agent.js +1125 -0
  24. package/dist/cli/commands/agent.js.map +1 -0
  25. package/dist/cli/commands/agents.d.ts +17 -0
  26. package/dist/cli/commands/agents.d.ts.map +1 -0
  27. package/dist/cli/commands/agents.js +20 -0
  28. package/dist/cli/commands/agents.js.map +1 -0
  29. package/dist/cli/commands/analyze.d.ts +12 -0
  30. package/dist/cli/commands/analyze.d.ts.map +1 -0
  31. package/dist/cli/commands/analyze.js +20 -0
  32. package/dist/cli/commands/analyze.js.map +1 -0
  33. package/dist/cli/commands/archive-stats.d.ts +18 -0
  34. package/dist/cli/commands/archive-stats.d.ts.map +1 -0
  35. package/dist/cli/commands/archive-stats.js +49 -0
  36. package/dist/cli/commands/archive-stats.js.map +1 -0
  37. package/dist/cli/commands/archive.d.ts +12 -0
  38. package/dist/cli/commands/archive.d.ts.map +1 -0
  39. package/dist/cli/commands/archive.js +32 -0
  40. package/dist/cli/commands/archive.js.map +1 -0
  41. package/dist/cli/commands/backfill.d.ts +38 -0
  42. package/dist/cli/commands/backfill.d.ts.map +1 -0
  43. package/dist/cli/commands/backfill.js +147 -0
  44. package/dist/cli/commands/backfill.js.map +1 -0
  45. package/dist/cli/commands/backup.d.ts +8 -0
  46. package/dist/cli/commands/backup.d.ts.map +1 -0
  47. package/dist/cli/commands/backup.js +35 -0
  48. package/dist/cli/commands/backup.js.map +1 -0
  49. package/dist/cli/commands/blockers.d.ts +7 -0
  50. package/dist/cli/commands/blockers.d.ts.map +1 -0
  51. package/dist/cli/commands/blockers.js +16 -0
  52. package/dist/cli/commands/blockers.js.map +1 -0
  53. package/dist/cli/commands/brain.d.ts +29 -0
  54. package/dist/cli/commands/brain.d.ts.map +1 -0
  55. package/dist/cli/commands/brain.js +107 -0
  56. package/dist/cli/commands/brain.js.map +1 -0
  57. package/dist/cli/commands/briefing.d.ts +22 -0
  58. package/dist/cli/commands/briefing.d.ts.map +1 -0
  59. package/dist/cli/commands/briefing.js +45 -0
  60. package/dist/cli/commands/briefing.js.map +1 -0
  61. package/dist/cli/commands/bug.d.ts +12 -0
  62. package/dist/cli/commands/bug.d.ts.map +1 -0
  63. package/dist/cli/commands/bug.js +81 -0
  64. package/dist/cli/commands/bug.js.map +1 -0
  65. package/dist/cli/commands/cant.d.ts +32 -0
  66. package/dist/cli/commands/cant.d.ts.map +1 -0
  67. package/dist/cli/commands/cant.js +281 -0
  68. package/dist/cli/commands/cant.js.map +1 -0
  69. package/dist/cli/commands/check.d.ts +22 -0
  70. package/dist/cli/commands/check.d.ts.map +1 -0
  71. package/dist/cli/commands/check.js +164 -0
  72. package/dist/cli/commands/check.js.map +1 -0
  73. package/dist/cli/commands/checkpoint.d.ts +15 -0
  74. package/dist/cli/commands/checkpoint.d.ts.map +1 -0
  75. package/dist/cli/commands/checkpoint.js +91 -0
  76. package/dist/cli/commands/checkpoint.js.map +1 -0
  77. package/dist/cli/commands/code.d.ts +11 -0
  78. package/dist/cli/commands/code.d.ts.map +1 -0
  79. package/dist/cli/commands/code.js +114 -0
  80. package/dist/cli/commands/code.js.map +1 -0
  81. package/dist/cli/commands/commands.d.ts +13 -0
  82. package/dist/cli/commands/commands.d.ts.map +1 -0
  83. package/dist/cli/commands/commands.js +29 -0
  84. package/dist/cli/commands/commands.js.map +1 -0
  85. package/dist/cli/commands/complete.d.ts +12 -0
  86. package/dist/cli/commands/complete.d.ts.map +1 -0
  87. package/dist/cli/commands/complete.js +43 -0
  88. package/dist/cli/commands/complete.js.map +1 -0
  89. package/dist/cli/commands/compliance.d.ts +8 -0
  90. package/dist/cli/commands/compliance.d.ts.map +1 -0
  91. package/dist/cli/commands/compliance.js +85 -0
  92. package/dist/cli/commands/compliance.js.map +1 -0
  93. package/dist/cli/commands/config.d.ts +10 -0
  94. package/dist/cli/commands/config.d.ts.map +1 -0
  95. package/dist/cli/commands/config.js +69 -0
  96. package/dist/cli/commands/config.js.map +1 -0
  97. package/dist/cli/commands/consensus.d.ts +13 -0
  98. package/dist/cli/commands/consensus.d.ts.map +1 -0
  99. package/dist/cli/commands/consensus.js +45 -0
  100. package/dist/cli/commands/consensus.js.map +1 -0
  101. package/dist/cli/commands/context.d.ts +8 -0
  102. package/dist/cli/commands/context.d.ts.map +1 -0
  103. package/dist/cli/commands/context.js +40 -0
  104. package/dist/cli/commands/context.js.map +1 -0
  105. package/dist/cli/commands/contribution.d.ts +13 -0
  106. package/dist/cli/commands/contribution.d.ts.map +1 -0
  107. package/dist/cli/commands/contribution.js +41 -0
  108. package/dist/cli/commands/contribution.js.map +1 -0
  109. package/dist/cli/commands/current.d.ts +13 -0
  110. package/dist/cli/commands/current.d.ts.map +1 -0
  111. package/dist/cli/commands/current.js +20 -0
  112. package/dist/cli/commands/current.js.map +1 -0
  113. package/dist/cli/commands/dash.d.ts +12 -0
  114. package/dist/cli/commands/dash.d.ts.map +1 -0
  115. package/dist/cli/commands/dash.js +24 -0
  116. package/dist/cli/commands/dash.js.map +1 -0
  117. package/dist/cli/commands/decomposition.d.ts +13 -0
  118. package/dist/cli/commands/decomposition.d.ts.map +1 -0
  119. package/dist/cli/commands/decomposition.js +45 -0
  120. package/dist/cli/commands/decomposition.js.map +1 -0
  121. package/dist/cli/commands/delete.d.ts +12 -0
  122. package/dist/cli/commands/delete.d.ts.map +1 -0
  123. package/dist/cli/commands/delete.js +37 -0
  124. package/dist/cli/commands/delete.js.map +1 -0
  125. package/dist/cli/commands/deps.d.ts +24 -0
  126. package/dist/cli/commands/deps.d.ts.map +1 -0
  127. package/dist/cli/commands/deps.js +98 -0
  128. package/dist/cli/commands/deps.js.map +1 -0
  129. package/dist/cli/commands/detect-drift.d.ts +15 -0
  130. package/dist/cli/commands/detect-drift.d.ts.map +1 -0
  131. package/dist/cli/commands/detect-drift.js +424 -0
  132. package/dist/cli/commands/detect-drift.js.map +1 -0
  133. package/dist/cli/commands/detect.d.ts +10 -0
  134. package/dist/cli/commands/detect.d.ts.map +1 -0
  135. package/dist/cli/commands/detect.js +24 -0
  136. package/dist/cli/commands/detect.js.map +1 -0
  137. package/dist/cli/commands/docs.d.ts +13 -0
  138. package/dist/cli/commands/docs.d.ts.map +1 -0
  139. package/dist/cli/commands/docs.js +169 -0
  140. package/dist/cli/commands/docs.js.map +1 -0
  141. package/dist/cli/commands/doctor.d.ts +15 -0
  142. package/dist/cli/commands/doctor.d.ts.map +1 -0
  143. package/dist/cli/commands/doctor.js +133 -0
  144. package/dist/cli/commands/doctor.js.map +1 -0
  145. package/dist/cli/commands/dynamic.d.ts +24 -0
  146. package/dist/cli/commands/dynamic.d.ts.map +1 -0
  147. package/dist/cli/commands/dynamic.js +27 -0
  148. package/dist/cli/commands/dynamic.js.map +1 -0
  149. package/dist/cli/commands/env.d.ts +12 -0
  150. package/dist/cli/commands/env.d.ts.map +1 -0
  151. package/dist/cli/commands/env.js +44 -0
  152. package/dist/cli/commands/env.js.map +1 -0
  153. package/dist/cli/commands/exists.d.ts +22 -0
  154. package/dist/cli/commands/exists.d.ts.map +1 -0
  155. package/dist/cli/commands/exists.js +51 -0
  156. package/dist/cli/commands/exists.js.map +1 -0
  157. package/dist/cli/commands/export-tasks.d.ts +10 -0
  158. package/dist/cli/commands/export-tasks.d.ts.map +1 -0
  159. package/dist/cli/commands/export-tasks.js +47 -0
  160. package/dist/cli/commands/export-tasks.js.map +1 -0
  161. package/dist/cli/commands/export.d.ts +9 -0
  162. package/dist/cli/commands/export.d.ts.map +1 -0
  163. package/dist/cli/commands/export.js +46 -0
  164. package/dist/cli/commands/export.js.map +1 -0
  165. package/dist/cli/commands/find.d.ts +14 -0
  166. package/dist/cli/commands/find.d.ts.map +1 -0
  167. package/dist/cli/commands/find.js +70 -0
  168. package/dist/cli/commands/find.js.map +1 -0
  169. package/dist/cli/commands/generate-changelog.d.ts +14 -0
  170. package/dist/cli/commands/generate-changelog.d.ts.map +1 -0
  171. package/dist/cli/commands/generate-changelog.js +252 -0
  172. package/dist/cli/commands/generate-changelog.js.map +1 -0
  173. package/dist/cli/commands/grade.d.ts +13 -0
  174. package/dist/cli/commands/grade.d.ts.map +1 -0
  175. package/dist/cli/commands/grade.js +26 -0
  176. package/dist/cli/commands/grade.js.map +1 -0
  177. package/dist/cli/commands/history.d.ts +9 -0
  178. package/dist/cli/commands/history.d.ts.map +1 -0
  179. package/dist/cli/commands/history.js +30 -0
  180. package/dist/cli/commands/history.js.map +1 -0
  181. package/dist/cli/commands/implementation.d.ts +13 -0
  182. package/dist/cli/commands/implementation.d.ts.map +1 -0
  183. package/dist/cli/commands/implementation.js +41 -0
  184. package/dist/cli/commands/implementation.js.map +1 -0
  185. package/dist/cli/commands/import-tasks.d.ts +10 -0
  186. package/dist/cli/commands/import-tasks.d.ts.map +1 -0
  187. package/dist/cli/commands/import-tasks.js +38 -0
  188. package/dist/cli/commands/import-tasks.js.map +1 -0
  189. package/dist/cli/commands/import.d.ts +9 -0
  190. package/dist/cli/commands/import.d.ts.map +1 -0
  191. package/dist/cli/commands/import.js +28 -0
  192. package/dist/cli/commands/import.js.map +1 -0
  193. package/dist/cli/commands/init.d.ts +34 -0
  194. package/dist/cli/commands/init.d.ts.map +1 -0
  195. package/dist/cli/commands/init.js +96 -0
  196. package/dist/cli/commands/init.js.map +1 -0
  197. package/dist/cli/commands/inject.d.ts +8 -0
  198. package/dist/cli/commands/inject.d.ts.map +1 -0
  199. package/dist/cli/commands/inject.js +28 -0
  200. package/dist/cli/commands/inject.js.map +1 -0
  201. package/dist/cli/commands/issue.d.ts +17 -0
  202. package/dist/cli/commands/issue.d.ts.map +1 -0
  203. package/dist/cli/commands/issue.js +107 -0
  204. package/dist/cli/commands/issue.js.map +1 -0
  205. package/dist/cli/commands/labels.d.ts +13 -0
  206. package/dist/cli/commands/labels.d.ts.map +1 -0
  207. package/dist/cli/commands/labels.js +44 -0
  208. package/dist/cli/commands/labels.js.map +1 -0
  209. package/dist/cli/commands/lifecycle.d.ts +8 -0
  210. package/dist/cli/commands/lifecycle.d.ts.map +1 -0
  211. package/dist/cli/commands/lifecycle.js +84 -0
  212. package/dist/cli/commands/lifecycle.js.map +1 -0
  213. package/dist/cli/commands/list.d.ts +14 -0
  214. package/dist/cli/commands/list.d.ts.map +1 -0
  215. package/dist/cli/commands/list.js +71 -0
  216. package/dist/cli/commands/list.js.map +1 -0
  217. package/dist/cli/commands/log.d.ts +12 -0
  218. package/dist/cli/commands/log.d.ts.map +1 -0
  219. package/dist/cli/commands/log.js +30 -0
  220. package/dist/cli/commands/log.js.map +1 -0
  221. package/dist/cli/commands/map.d.ts +10 -0
  222. package/dist/cli/commands/map.d.ts.map +1 -0
  223. package/dist/cli/commands/map.js +23 -0
  224. package/dist/cli/commands/map.js.map +1 -0
  225. package/dist/cli/commands/memory-brain.d.ts +14 -0
  226. package/dist/cli/commands/memory-brain.d.ts.map +1 -0
  227. package/dist/cli/commands/memory-brain.js +157 -0
  228. package/dist/cli/commands/memory-brain.js.map +1 -0
  229. package/dist/cli/commands/migrate-claude-mem.d.ts +18 -0
  230. package/dist/cli/commands/migrate-claude-mem.d.ts.map +1 -0
  231. package/dist/cli/commands/migrate-claude-mem.js +60 -0
  232. package/dist/cli/commands/migrate-claude-mem.js.map +1 -0
  233. package/dist/cli/commands/next.d.ts +9 -0
  234. package/dist/cli/commands/next.d.ts.map +1 -0
  235. package/dist/cli/commands/next.js +20 -0
  236. package/dist/cli/commands/next.js.map +1 -0
  237. package/dist/cli/commands/nexus.d.ts +16 -0
  238. package/dist/cli/commands/nexus.d.ts.map +1 -0
  239. package/dist/cli/commands/nexus.js +155 -0
  240. package/dist/cli/commands/nexus.js.map +1 -0
  241. package/dist/cli/commands/observe.d.ts +9 -0
  242. package/dist/cli/commands/observe.d.ts.map +1 -0
  243. package/dist/cli/commands/observe.js +39 -0
  244. package/dist/cli/commands/observe.js.map +1 -0
  245. package/dist/cli/commands/ops.d.ts +10 -0
  246. package/dist/cli/commands/ops.d.ts.map +1 -0
  247. package/dist/cli/commands/ops.js +19 -0
  248. package/dist/cli/commands/ops.js.map +1 -0
  249. package/dist/cli/commands/orchestrate.d.ts +8 -0
  250. package/dist/cli/commands/orchestrate.d.ts.map +1 -0
  251. package/dist/cli/commands/orchestrate.js +58 -0
  252. package/dist/cli/commands/orchestrate.js.map +1 -0
  253. package/dist/cli/commands/otel.d.ts +12 -0
  254. package/dist/cli/commands/otel.d.ts.map +1 -0
  255. package/dist/cli/commands/otel.js +128 -0
  256. package/dist/cli/commands/otel.js.map +1 -0
  257. package/dist/cli/commands/phase.d.ts +12 -0
  258. package/dist/cli/commands/phase.d.ts.map +1 -0
  259. package/dist/cli/commands/phase.js +91 -0
  260. package/dist/cli/commands/phase.js.map +1 -0
  261. package/dist/cli/commands/phases.d.ts +12 -0
  262. package/dist/cli/commands/phases.d.ts.map +1 -0
  263. package/dist/cli/commands/phases.js +37 -0
  264. package/dist/cli/commands/phases.js.map +1 -0
  265. package/dist/cli/commands/plan.d.ts +8 -0
  266. package/dist/cli/commands/plan.d.ts.map +1 -0
  267. package/dist/cli/commands/plan.js +15 -0
  268. package/dist/cli/commands/plan.js.map +1 -0
  269. package/dist/cli/commands/promote.d.ts +7 -0
  270. package/dist/cli/commands/promote.d.ts.map +1 -0
  271. package/dist/cli/commands/promote.js +15 -0
  272. package/dist/cli/commands/promote.js.map +1 -0
  273. package/dist/cli/commands/reason.d.ts +35 -0
  274. package/dist/cli/commands/reason.d.ts.map +1 -0
  275. package/dist/cli/commands/reason.js +104 -0
  276. package/dist/cli/commands/reason.js.map +1 -0
  277. package/dist/cli/commands/refresh-memory.d.ts +9 -0
  278. package/dist/cli/commands/refresh-memory.d.ts.map +1 -0
  279. package/dist/cli/commands/refresh-memory.js +24 -0
  280. package/dist/cli/commands/refresh-memory.js.map +1 -0
  281. package/dist/cli/commands/relates.d.ts +12 -0
  282. package/dist/cli/commands/relates.d.ts.map +1 -0
  283. package/dist/cli/commands/relates.js +53 -0
  284. package/dist/cli/commands/relates.js.map +1 -0
  285. package/dist/cli/commands/release.d.ts +8 -0
  286. package/dist/cli/commands/release.d.ts.map +1 -0
  287. package/dist/cli/commands/release.js +72 -0
  288. package/dist/cli/commands/release.js.map +1 -0
  289. package/dist/cli/commands/remote.d.ts +12 -0
  290. package/dist/cli/commands/remote.d.ts.map +1 -0
  291. package/dist/cli/commands/remote.js +207 -0
  292. package/dist/cli/commands/remote.js.map +1 -0
  293. package/dist/cli/commands/reorder.d.ts +7 -0
  294. package/dist/cli/commands/reorder.d.ts.map +1 -0
  295. package/dist/cli/commands/reorder.js +20 -0
  296. package/dist/cli/commands/reorder.js.map +1 -0
  297. package/dist/cli/commands/reparent.d.ts +10 -0
  298. package/dist/cli/commands/reparent.d.ts.map +1 -0
  299. package/dist/cli/commands/reparent.js +19 -0
  300. package/dist/cli/commands/reparent.js.map +1 -0
  301. package/dist/cli/commands/research.d.ts +8 -0
  302. package/dist/cli/commands/research.d.ts.map +1 -0
  303. package/dist/cli/commands/research.js +129 -0
  304. package/dist/cli/commands/research.js.map +1 -0
  305. package/dist/cli/commands/restore.d.ts +11 -0
  306. package/dist/cli/commands/restore.d.ts.map +1 -0
  307. package/dist/cli/commands/restore.js +224 -0
  308. package/dist/cli/commands/restore.js.map +1 -0
  309. package/dist/cli/commands/roadmap.d.ts +8 -0
  310. package/dist/cli/commands/roadmap.d.ts.map +1 -0
  311. package/dist/cli/commands/roadmap.js +21 -0
  312. package/dist/cli/commands/roadmap.js.map +1 -0
  313. package/dist/cli/commands/safestop.d.ts +14 -0
  314. package/dist/cli/commands/safestop.d.ts.map +1 -0
  315. package/dist/cli/commands/safestop.js +32 -0
  316. package/dist/cli/commands/safestop.js.map +1 -0
  317. package/dist/cli/commands/self-update.d.ts +15 -0
  318. package/dist/cli/commands/self-update.d.ts.map +1 -0
  319. package/dist/cli/commands/self-update.js +329 -0
  320. package/dist/cli/commands/self-update.js.map +1 -0
  321. package/dist/cli/commands/sequence.d.ts +8 -0
  322. package/dist/cli/commands/sequence.d.ts.map +1 -0
  323. package/dist/cli/commands/sequence.js +30 -0
  324. package/dist/cli/commands/sequence.js.map +1 -0
  325. package/dist/cli/commands/session.d.ts +12 -0
  326. package/dist/cli/commands/session.d.ts.map +1 -0
  327. package/dist/cli/commands/session.js +175 -0
  328. package/dist/cli/commands/session.js.map +1 -0
  329. package/dist/cli/commands/show.d.ts +13 -0
  330. package/dist/cli/commands/show.d.ts.map +1 -0
  331. package/dist/cli/commands/show.js +20 -0
  332. package/dist/cli/commands/show.js.map +1 -0
  333. package/dist/cli/commands/skills.d.ts +13 -0
  334. package/dist/cli/commands/skills.d.ts.map +1 -0
  335. package/dist/cli/commands/skills.js +131 -0
  336. package/dist/cli/commands/skills.js.map +1 -0
  337. package/dist/cli/commands/snapshot.d.ts +9 -0
  338. package/dist/cli/commands/snapshot.d.ts.map +1 -0
  339. package/dist/cli/commands/snapshot.js +50 -0
  340. package/dist/cli/commands/snapshot.js.map +1 -0
  341. package/dist/cli/commands/specification.d.ts +13 -0
  342. package/dist/cli/commands/specification.d.ts.map +1 -0
  343. package/dist/cli/commands/specification.js +45 -0
  344. package/dist/cli/commands/specification.js.map +1 -0
  345. package/dist/cli/commands/start.d.ts +13 -0
  346. package/dist/cli/commands/start.d.ts.map +1 -0
  347. package/dist/cli/commands/start.js +20 -0
  348. package/dist/cli/commands/start.js.map +1 -0
  349. package/dist/cli/commands/stats.d.ts +12 -0
  350. package/dist/cli/commands/stats.d.ts.map +1 -0
  351. package/dist/cli/commands/stats.js +35 -0
  352. package/dist/cli/commands/stats.js.map +1 -0
  353. package/dist/cli/commands/sticky.d.ts +16 -0
  354. package/dist/cli/commands/sticky.d.ts.map +1 -0
  355. package/dist/cli/commands/sticky.js +211 -0
  356. package/dist/cli/commands/sticky.js.map +1 -0
  357. package/dist/cli/commands/stop.d.ts +13 -0
  358. package/dist/cli/commands/stop.d.ts.map +1 -0
  359. package/dist/cli/commands/stop.js +20 -0
  360. package/dist/cli/commands/stop.js.map +1 -0
  361. package/dist/cli/commands/testing.d.ts +13 -0
  362. package/dist/cli/commands/testing.d.ts.map +1 -0
  363. package/dist/cli/commands/testing.js +64 -0
  364. package/dist/cli/commands/testing.js.map +1 -0
  365. package/dist/cli/commands/token.d.ts +10 -0
  366. package/dist/cli/commands/token.d.ts.map +1 -0
  367. package/dist/cli/commands/token.js +135 -0
  368. package/dist/cli/commands/token.js.map +1 -0
  369. package/dist/cli/commands/update.d.ts +12 -0
  370. package/dist/cli/commands/update.d.ts.map +1 -0
  371. package/dist/cli/commands/update.js +83 -0
  372. package/dist/cli/commands/update.js.map +1 -0
  373. package/dist/cli/commands/upgrade.d.ts +18 -0
  374. package/dist/cli/commands/upgrade.d.ts.map +1 -0
  375. package/dist/cli/commands/upgrade.js +103 -0
  376. package/dist/cli/commands/upgrade.js.map +1 -0
  377. package/dist/cli/commands/validate.d.ts +12 -0
  378. package/dist/cli/commands/validate.d.ts.map +1 -0
  379. package/dist/cli/commands/validate.js +23 -0
  380. package/dist/cli/commands/validate.js.map +1 -0
  381. package/dist/cli/commands/verify.d.ts +8 -0
  382. package/dist/cli/commands/verify.d.ts.map +1 -0
  383. package/dist/cli/commands/verify.js +28 -0
  384. package/dist/cli/commands/verify.js.map +1 -0
  385. package/dist/cli/commands/web.d.ts +13 -0
  386. package/dist/cli/commands/web.d.ts.map +1 -0
  387. package/dist/cli/commands/web.js +277 -0
  388. package/dist/cli/commands/web.js.map +1 -0
  389. package/dist/cli/field-context.d.ts +32 -0
  390. package/dist/cli/field-context.d.ts.map +1 -0
  391. package/dist/cli/field-context.js +47 -0
  392. package/dist/cli/field-context.js.map +1 -0
  393. package/dist/cli/format-context.d.ts +32 -0
  394. package/dist/cli/format-context.d.ts.map +1 -0
  395. package/dist/cli/format-context.js +50 -0
  396. package/dist/cli/format-context.js.map +1 -0
  397. package/dist/cli/index.d.ts +9 -0
  398. package/dist/cli/index.d.ts.map +1 -0
  399. package/dist/cli/index.js +3767 -3387
  400. package/dist/cli/index.js.map +4 -4
  401. package/dist/cli/logger-bootstrap.d.ts +6 -0
  402. package/dist/cli/logger-bootstrap.d.ts.map +1 -0
  403. package/dist/cli/logger-bootstrap.js +10 -0
  404. package/dist/cli/logger-bootstrap.js.map +1 -0
  405. package/dist/cli/middleware/output-format.d.ts +30 -0
  406. package/dist/cli/middleware/output-format.d.ts.map +1 -0
  407. package/dist/cli/middleware/output-format.js +35 -0
  408. package/dist/cli/middleware/output-format.js.map +1 -0
  409. package/dist/cli/progress.d.ts +84 -0
  410. package/dist/cli/progress.d.ts.map +1 -0
  411. package/dist/cli/progress.js +169 -0
  412. package/dist/cli/progress.js.map +1 -0
  413. package/dist/cli/renderers/colors.d.ts +32 -0
  414. package/dist/cli/renderers/colors.d.ts.map +1 -0
  415. package/dist/cli/renderers/colors.js +141 -0
  416. package/dist/cli/renderers/colors.js.map +1 -0
  417. package/dist/cli/renderers/error.d.ts +13 -0
  418. package/dist/cli/renderers/error.d.ts.map +1 -0
  419. package/dist/cli/renderers/error.js +42 -0
  420. package/dist/cli/renderers/error.js.map +1 -0
  421. package/dist/cli/renderers/index.d.ts +59 -0
  422. package/dist/cli/renderers/index.d.ts.map +1 -0
  423. package/dist/cli/renderers/index.js +208 -0
  424. package/dist/cli/renderers/index.js.map +1 -0
  425. package/dist/cli/renderers/lafs-validator.d.ts +97 -0
  426. package/dist/cli/renderers/lafs-validator.d.ts.map +1 -0
  427. package/dist/cli/renderers/lafs-validator.js +229 -0
  428. package/dist/cli/renderers/lafs-validator.js.map +1 -0
  429. package/dist/cli/renderers/normalizer.d.ts +21 -0
  430. package/dist/cli/renderers/normalizer.d.ts.map +1 -0
  431. package/dist/cli/renderers/normalizer.js +106 -0
  432. package/dist/cli/renderers/normalizer.js.map +1 -0
  433. package/dist/cli/renderers/system.d.ts +25 -0
  434. package/dist/cli/renderers/system.d.ts.map +1 -0
  435. package/dist/cli/renderers/system.js +416 -0
  436. package/dist/cli/renderers/system.js.map +1 -0
  437. package/dist/cli/renderers/tasks.d.ts +28 -0
  438. package/dist/cli/renderers/tasks.d.ts.map +1 -0
  439. package/dist/cli/renderers/tasks.js +306 -0
  440. package/dist/cli/renderers/tasks.js.map +1 -0
  441. package/dist/dispatch/adapters/cli.d.ts +67 -0
  442. package/dist/dispatch/adapters/cli.d.ts.map +1 -0
  443. package/dist/dispatch/adapters/cli.js +262 -0
  444. package/dist/dispatch/adapters/cli.js.map +1 -0
  445. package/dist/dispatch/context/session-context.d.ts +54 -0
  446. package/dist/dispatch/context/session-context.d.ts.map +1 -0
  447. package/dist/dispatch/context/session-context.js +61 -0
  448. package/dist/dispatch/context/session-context.js.map +1 -0
  449. package/dist/dispatch/dispatcher.d.ts +23 -0
  450. package/dist/dispatch/dispatcher.d.ts.map +1 -0
  451. package/dist/dispatch/dispatcher.js +84 -0
  452. package/dist/dispatch/dispatcher.js.map +1 -0
  453. package/dist/dispatch/domains/_base.d.ts +59 -0
  454. package/dist/dispatch/domains/_base.d.ts.map +1 -0
  455. package/dist/dispatch/domains/_base.js +77 -0
  456. package/dist/dispatch/domains/_base.js.map +1 -0
  457. package/dist/dispatch/domains/_meta.d.ts +23 -0
  458. package/dist/dispatch/domains/_meta.d.ts.map +1 -0
  459. package/dist/dispatch/domains/_meta.js +25 -0
  460. package/dist/dispatch/domains/_meta.js.map +1 -0
  461. package/dist/dispatch/domains/_routing.d.ts +8 -0
  462. package/dist/dispatch/domains/_routing.d.ts.map +1 -0
  463. package/dist/dispatch/domains/_routing.js +20 -0
  464. package/dist/dispatch/domains/_routing.js.map +1 -0
  465. package/dist/dispatch/domains/admin.d.ts +25 -0
  466. package/dist/dispatch/domains/admin.d.ts.map +1 -0
  467. package/dist/dispatch/domains/admin.js +719 -0
  468. package/dist/dispatch/domains/admin.js.map +1 -0
  469. package/dist/dispatch/domains/check.d.ts +22 -0
  470. package/dist/dispatch/domains/check.d.ts.map +1 -0
  471. package/dist/dispatch/domains/check.js +360 -0
  472. package/dist/dispatch/domains/check.js.map +1 -0
  473. package/dist/dispatch/domains/conduit.d.ts +38 -0
  474. package/dist/dispatch/domains/conduit.d.ts.map +1 -0
  475. package/dist/dispatch/domains/conduit.js +247 -0
  476. package/dist/dispatch/domains/conduit.js.map +1 -0
  477. package/dist/dispatch/domains/index.d.ts +27 -0
  478. package/dist/dispatch/domains/index.d.ts.map +1 -0
  479. package/dist/dispatch/domains/index.js +40 -0
  480. package/dist/dispatch/domains/index.js.map +1 -0
  481. package/dist/dispatch/domains/memory.d.ts +22 -0
  482. package/dist/dispatch/domains/memory.d.ts.map +1 -0
  483. package/dist/dispatch/domains/memory.js +303 -0
  484. package/dist/dispatch/domains/memory.js.map +1 -0
  485. package/dist/dispatch/domains/nexus.d.ts +22 -0
  486. package/dist/dispatch/domains/nexus.d.ts.map +1 -0
  487. package/dist/dispatch/domains/nexus.js +286 -0
  488. package/dist/dispatch/domains/nexus.js.map +1 -0
  489. package/dist/dispatch/domains/orchestrate.d.ts +19 -0
  490. package/dist/dispatch/domains/orchestrate.d.ts.map +1 -0
  491. package/dist/dispatch/domains/orchestrate.js +259 -0
  492. package/dist/dispatch/domains/orchestrate.js.map +1 -0
  493. package/dist/dispatch/domains/pipeline.d.ts +35 -0
  494. package/dist/dispatch/domains/pipeline.d.ts.map +1 -0
  495. package/dist/dispatch/domains/pipeline.js +593 -0
  496. package/dist/dispatch/domains/pipeline.js.map +1 -0
  497. package/dist/dispatch/domains/session.d.ts +22 -0
  498. package/dist/dispatch/domains/session.d.ts.map +1 -0
  499. package/dist/dispatch/domains/session.js +257 -0
  500. package/dist/dispatch/domains/session.js.map +1 -0
  501. package/dist/dispatch/domains/sticky.d.ts +20 -0
  502. package/dist/dispatch/domains/sticky.d.ts.map +1 -0
  503. package/dist/dispatch/domains/sticky.js +164 -0
  504. package/dist/dispatch/domains/sticky.js.map +1 -0
  505. package/dist/dispatch/domains/tasks.d.ts +25 -0
  506. package/dist/dispatch/domains/tasks.d.ts.map +1 -0
  507. package/dist/dispatch/domains/tasks.js +361 -0
  508. package/dist/dispatch/domains/tasks.js.map +1 -0
  509. package/dist/dispatch/domains/tools.d.ts +37 -0
  510. package/dist/dispatch/domains/tools.d.ts.map +1 -0
  511. package/dist/dispatch/domains/tools.js +481 -0
  512. package/dist/dispatch/domains/tools.js.map +1 -0
  513. package/dist/dispatch/engines/_error.d.ts +85 -0
  514. package/dist/dispatch/engines/_error.d.ts.map +1 -0
  515. package/dist/dispatch/engines/_error.js +244 -0
  516. package/dist/dispatch/engines/_error.js.map +1 -0
  517. package/dist/dispatch/engines/code-engine.d.ts +18 -0
  518. package/dist/dispatch/engines/code-engine.d.ts.map +1 -0
  519. package/dist/dispatch/engines/code-engine.js +71 -0
  520. package/dist/dispatch/engines/code-engine.js.map +1 -0
  521. package/dist/dispatch/engines/codebase-map-engine.d.ts +31 -0
  522. package/dist/dispatch/engines/codebase-map-engine.d.ts.map +1 -0
  523. package/dist/dispatch/engines/codebase-map-engine.js +43 -0
  524. package/dist/dispatch/engines/codebase-map-engine.js.map +1 -0
  525. package/dist/dispatch/engines/config-engine.d.ts +32 -0
  526. package/dist/dispatch/engines/config-engine.d.ts.map +1 -0
  527. package/dist/dispatch/engines/config-engine.js +70 -0
  528. package/dist/dispatch/engines/config-engine.js.map +1 -0
  529. package/dist/dispatch/engines/hooks-engine.d.ts +96 -0
  530. package/dist/dispatch/engines/hooks-engine.d.ts.map +1 -0
  531. package/dist/dispatch/engines/hooks-engine.js +144 -0
  532. package/dist/dispatch/engines/hooks-engine.js.map +1 -0
  533. package/dist/dispatch/engines/init-engine.d.ts +56 -0
  534. package/dist/dispatch/engines/init-engine.d.ts.map +1 -0
  535. package/dist/dispatch/engines/init-engine.js +78 -0
  536. package/dist/dispatch/engines/init-engine.js.map +1 -0
  537. package/dist/dispatch/engines/lifecycle-engine.d.ts +66 -0
  538. package/dist/dispatch/engines/lifecycle-engine.d.ts.map +1 -0
  539. package/dist/dispatch/engines/lifecycle-engine.js +224 -0
  540. package/dist/dispatch/engines/lifecycle-engine.js.map +1 -0
  541. package/dist/dispatch/engines/memory-engine.d.ts +10 -0
  542. package/dist/dispatch/engines/memory-engine.d.ts.map +1 -0
  543. package/dist/dispatch/engines/memory-engine.js +10 -0
  544. package/dist/dispatch/engines/memory-engine.js.map +1 -0
  545. package/dist/dispatch/engines/nexus-engine.d.ts +167 -0
  546. package/dist/dispatch/engines/nexus-engine.d.ts.map +1 -0
  547. package/dist/dispatch/engines/nexus-engine.js +356 -0
  548. package/dist/dispatch/engines/nexus-engine.js.map +1 -0
  549. package/dist/dispatch/engines/orchestrate-engine.d.ts +133 -0
  550. package/dist/dispatch/engines/orchestrate-engine.d.ts.map +1 -0
  551. package/dist/dispatch/engines/orchestrate-engine.js +769 -0
  552. package/dist/dispatch/engines/orchestrate-engine.js.map +1 -0
  553. package/dist/dispatch/engines/pipeline-engine.d.ts +51 -0
  554. package/dist/dispatch/engines/pipeline-engine.d.ts.map +1 -0
  555. package/dist/dispatch/engines/pipeline-engine.js +191 -0
  556. package/dist/dispatch/engines/pipeline-engine.js.map +1 -0
  557. package/dist/dispatch/engines/release-engine.d.ts +94 -0
  558. package/dist/dispatch/engines/release-engine.d.ts.map +1 -0
  559. package/dist/dispatch/engines/release-engine.js +763 -0
  560. package/dist/dispatch/engines/release-engine.js.map +1 -0
  561. package/dist/dispatch/engines/session-engine.d.ts +383 -0
  562. package/dist/dispatch/engines/session-engine.d.ts.map +1 -0
  563. package/dist/dispatch/engines/session-engine.js +960 -0
  564. package/dist/dispatch/engines/session-engine.js.map +1 -0
  565. package/dist/dispatch/engines/sticky-engine.d.ts +100 -0
  566. package/dist/dispatch/engines/sticky-engine.d.ts.map +1 -0
  567. package/dist/dispatch/engines/sticky-engine.js +181 -0
  568. package/dist/dispatch/engines/sticky-engine.js.map +1 -0
  569. package/dist/dispatch/engines/system-engine.d.ts +539 -0
  570. package/dist/dispatch/engines/system-engine.d.ts.map +1 -0
  571. package/dist/dispatch/engines/system-engine.js +1266 -0
  572. package/dist/dispatch/engines/system-engine.js.map +1 -0
  573. package/dist/dispatch/engines/task-engine.d.ts +1055 -0
  574. package/dist/dispatch/engines/task-engine.d.ts.map +1 -0
  575. package/dist/dispatch/engines/task-engine.js +1387 -0
  576. package/dist/dispatch/engines/task-engine.js.map +1 -0
  577. package/dist/dispatch/engines/template-parser.d.ts +85 -0
  578. package/dist/dispatch/engines/template-parser.d.ts.map +1 -0
  579. package/dist/dispatch/engines/template-parser.js +108 -0
  580. package/dist/dispatch/engines/template-parser.js.map +1 -0
  581. package/dist/dispatch/engines/tools-engine.d.ts +270 -0
  582. package/dist/dispatch/engines/tools-engine.d.ts.map +1 -0
  583. package/dist/dispatch/engines/tools-engine.js +636 -0
  584. package/dist/dispatch/engines/tools-engine.js.map +1 -0
  585. package/dist/dispatch/engines/validate-engine.d.ts +218 -0
  586. package/dist/dispatch/engines/validate-engine.d.ts.map +1 -0
  587. package/dist/dispatch/engines/validate-engine.js +737 -0
  588. package/dist/dispatch/engines/validate-engine.js.map +1 -0
  589. package/dist/dispatch/index.d.ts +20 -0
  590. package/dist/dispatch/index.d.ts.map +1 -0
  591. package/dist/dispatch/index.js +19 -0
  592. package/dist/dispatch/index.js.map +1 -0
  593. package/dist/dispatch/lib/background-jobs.d.ts +86 -0
  594. package/dist/dispatch/lib/background-jobs.d.ts.map +1 -0
  595. package/dist/dispatch/lib/background-jobs.js +183 -0
  596. package/dist/dispatch/lib/background-jobs.js.map +1 -0
  597. package/dist/dispatch/lib/budget.d.ts +35 -0
  598. package/dist/dispatch/lib/budget.d.ts.map +1 -0
  599. package/dist/dispatch/lib/budget.js +102 -0
  600. package/dist/dispatch/lib/budget.js.map +1 -0
  601. package/dist/dispatch/lib/capability-matrix.d.ts +11 -0
  602. package/dist/dispatch/lib/capability-matrix.d.ts.map +1 -0
  603. package/dist/dispatch/lib/capability-matrix.js +10 -0
  604. package/dist/dispatch/lib/capability-matrix.js.map +1 -0
  605. package/dist/dispatch/lib/config-loader.d.ts +42 -0
  606. package/dist/dispatch/lib/config-loader.d.ts.map +1 -0
  607. package/dist/dispatch/lib/config-loader.js +217 -0
  608. package/dist/dispatch/lib/config-loader.js.map +1 -0
  609. package/dist/dispatch/lib/config.d.ts +11 -0
  610. package/dist/dispatch/lib/config.d.ts.map +1 -0
  611. package/dist/dispatch/lib/config.js +10 -0
  612. package/dist/dispatch/lib/config.js.map +1 -0
  613. package/dist/dispatch/lib/defaults.d.ts +117 -0
  614. package/dist/dispatch/lib/defaults.d.ts.map +1 -0
  615. package/dist/dispatch/lib/defaults.js +58 -0
  616. package/dist/dispatch/lib/defaults.js.map +1 -0
  617. package/dist/dispatch/lib/engine.d.ts +26 -0
  618. package/dist/dispatch/lib/engine.d.ts.map +1 -0
  619. package/dist/dispatch/lib/engine.js +46 -0
  620. package/dist/dispatch/lib/engine.js.map +1 -0
  621. package/dist/dispatch/lib/gateway-meta.d.ts +37 -0
  622. package/dist/dispatch/lib/gateway-meta.d.ts.map +1 -0
  623. package/dist/dispatch/lib/gateway-meta.js +50 -0
  624. package/dist/dispatch/lib/gateway-meta.js.map +1 -0
  625. package/dist/dispatch/lib/job-manager-accessor.d.ts +9 -0
  626. package/dist/dispatch/lib/job-manager-accessor.d.ts.map +1 -0
  627. package/dist/dispatch/lib/job-manager-accessor.js +13 -0
  628. package/dist/dispatch/lib/job-manager-accessor.js.map +1 -0
  629. package/dist/dispatch/lib/meta.d.ts +26 -0
  630. package/dist/dispatch/lib/meta.d.ts.map +1 -0
  631. package/dist/dispatch/lib/meta.js +37 -0
  632. package/dist/dispatch/lib/meta.js.map +1 -0
  633. package/dist/dispatch/lib/param-utils.d.ts +11 -0
  634. package/dist/dispatch/lib/param-utils.d.ts.map +1 -0
  635. package/dist/dispatch/lib/param-utils.js +10 -0
  636. package/dist/dispatch/lib/param-utils.js.map +1 -0
  637. package/dist/dispatch/lib/projections.d.ts +56 -0
  638. package/dist/dispatch/lib/projections.d.ts.map +1 -0
  639. package/dist/dispatch/lib/projections.js +65 -0
  640. package/dist/dispatch/lib/projections.js.map +1 -0
  641. package/dist/dispatch/lib/schema-utils.d.ts +39 -0
  642. package/dist/dispatch/lib/schema-utils.d.ts.map +1 -0
  643. package/dist/dispatch/lib/schema-utils.js +88 -0
  644. package/dist/dispatch/lib/schema-utils.js.map +1 -0
  645. package/dist/dispatch/lib/security.d.ts +11 -0
  646. package/dist/dispatch/lib/security.d.ts.map +1 -0
  647. package/dist/dispatch/lib/security.js +10 -0
  648. package/dist/dispatch/lib/security.js.map +1 -0
  649. package/dist/dispatch/middleware/audit.d.ts +23 -0
  650. package/dist/dispatch/middleware/audit.d.ts.map +1 -0
  651. package/dist/dispatch/middleware/audit.js +169 -0
  652. package/dist/dispatch/middleware/audit.js.map +1 -0
  653. package/dist/dispatch/middleware/field-filter.d.ts +24 -0
  654. package/dist/dispatch/middleware/field-filter.d.ts.map +1 -0
  655. package/dist/dispatch/middleware/field-filter.js +65 -0
  656. package/dist/dispatch/middleware/field-filter.js.map +1 -0
  657. package/dist/dispatch/middleware/pipeline.d.ts +33 -0
  658. package/dist/dispatch/middleware/pipeline.d.ts.map +1 -0
  659. package/dist/dispatch/middleware/pipeline.js +60 -0
  660. package/dist/dispatch/middleware/pipeline.js.map +1 -0
  661. package/dist/dispatch/middleware/projection.d.ts +35 -0
  662. package/dist/dispatch/middleware/projection.d.ts.map +1 -0
  663. package/dist/dispatch/middleware/projection.js +146 -0
  664. package/dist/dispatch/middleware/projection.js.map +1 -0
  665. package/dist/dispatch/middleware/protocol-enforcement.d.ts +27 -0
  666. package/dist/dispatch/middleware/protocol-enforcement.d.ts.map +1 -0
  667. package/dist/dispatch/middleware/protocol-enforcement.js +45 -0
  668. package/dist/dispatch/middleware/protocol-enforcement.js.map +1 -0
  669. package/dist/dispatch/middleware/rate-limiter.d.ts +72 -0
  670. package/dist/dispatch/middleware/rate-limiter.d.ts.map +1 -0
  671. package/dist/dispatch/middleware/rate-limiter.js +127 -0
  672. package/dist/dispatch/middleware/rate-limiter.js.map +1 -0
  673. package/dist/dispatch/middleware/sanitizer.d.ts +24 -0
  674. package/dist/dispatch/middleware/sanitizer.d.ts.map +1 -0
  675. package/dist/dispatch/middleware/sanitizer.js +56 -0
  676. package/dist/dispatch/middleware/sanitizer.js.map +1 -0
  677. package/dist/dispatch/middleware/session-resolver.d.ts +26 -0
  678. package/dist/dispatch/middleware/session-resolver.d.ts.map +1 -0
  679. package/dist/dispatch/middleware/session-resolver.js +65 -0
  680. package/dist/dispatch/middleware/session-resolver.js.map +1 -0
  681. package/dist/dispatch/middleware/verification-gates.d.ts +22 -0
  682. package/dist/dispatch/middleware/verification-gates.d.ts.map +1 -0
  683. package/dist/dispatch/middleware/verification-gates.js +59 -0
  684. package/dist/dispatch/middleware/verification-gates.js.map +1 -0
  685. package/dist/dispatch/registry.d.ts +91 -0
  686. package/dist/dispatch/registry.d.ts.map +1 -0
  687. package/dist/dispatch/registry.js +3133 -0
  688. package/dist/dispatch/registry.js.map +1 -0
  689. package/dist/dispatch/types.d.ts +202 -0
  690. package/dist/dispatch/types.d.ts.map +1 -0
  691. package/dist/dispatch/types.js +26 -0
  692. package/dist/dispatch/types.js.map +1 -0
  693. package/package.json +7 -7
@@ -0,0 +1,1387 @@
1
+ /**
2
+ * Task Engine
3
+ *
4
+ * Native TypeScript implementation of core task CRUD operations.
5
+ * Uses StoreProvider (via getStore()) for task/session data access,
6
+ * falling back to direct JSON for config and specialized operations.
7
+ *
8
+ * CRUD operations (show, list, find, exists, create, update, complete, delete, archive)
9
+ * delegate to src/core/tasks/*.
10
+ *
11
+ * Non-CRUD operations delegate to src/core/tasks/task-ops.ts.
12
+ *
13
+ * @task T4657
14
+ * @task T4790
15
+ * @epic T4654
16
+ */
17
+ // validation-rules.js still used by other engines; core modules handle their own validation
18
+ // Core module imports for accessor-based operations
19
+ import { addTask as coreAddTask, archiveTasks as coreArchiveTasks, completeTask as coreCompleteTask, deleteTask as coreDeleteTask, findTasks as coreFindTasks, listTasks as coreListTasks, showTask as coreShowTask, coreTaskAnalyze, coreTaskBatchValidate, coreTaskBlockers, coreTaskCancel, coreTaskComplexityEstimate, coreTaskDepends, coreTaskDeps, coreTaskDepsCycles, coreTaskDepsOverview, coreTaskExport, coreTaskHistory, coreTaskImport, coreTaskLint, coreTaskNext, coreTaskPromote, coreTaskRelates, coreTaskRelatesAdd, coreTaskReopen, coreTaskReorder, coreTaskReparent, coreTaskRestore, coreTaskStats, coreTaskTree, coreTaskUnarchive, updateTask as coreUpdateTask, getAccessor, predictImpact, toCompact, } from '@cleocode/core/internal';
20
+ import { engineError } from './_error.js';
21
+ const TASK_COMPLETE_EXIT_TO_ENGINE_CODE = {
22
+ 4: 'E_NOT_FOUND',
23
+ 5: 'E_DEPENDENCY_ERROR',
24
+ 6: 'E_VALIDATION_FAILED',
25
+ 16: 'E_HAS_CHILDREN',
26
+ 17: 'E_TASK_COMPLETED',
27
+ 40: 'E_VERIFICATION_INIT_FAILED',
28
+ 44: 'E_MAX_ROUNDS_EXCEEDED',
29
+ 45: 'E_GATE_DEPENDENCY',
30
+ 80: 'E_LIFECYCLE_GATE_FAILED',
31
+ };
32
+ /**
33
+ * Convert a core Task to a TaskRecord for backward compatibility.
34
+ * TaskRecord has string-typed status/priority; Task has union types.
35
+ *
36
+ * @task T4657
37
+ * @epic T4654
38
+ */
39
+ function taskToRecord(task) {
40
+ // Task union-typed fields (status, priority, origin, etc.) widen to string in TaskRecord.
41
+ // Some fields have structural mismatches (blockedBy: string vs string[], etc.)
42
+ // so we explicitly map each field rather than relying on spread.
43
+ return {
44
+ id: task.id,
45
+ title: task.title,
46
+ description: task.description ?? '',
47
+ status: task.status,
48
+ priority: task.priority,
49
+ type: task.type,
50
+ phase: task.phase,
51
+ createdAt: task.createdAt,
52
+ updatedAt: task.updatedAt ?? null,
53
+ completedAt: task.completedAt ?? null,
54
+ cancelledAt: task.cancelledAt ?? null,
55
+ parentId: task.parentId,
56
+ position: task.position,
57
+ positionVersion: task.positionVersion,
58
+ depends: task.depends,
59
+ relates: task.relates,
60
+ files: task.files,
61
+ acceptance: task.acceptance,
62
+ notes: task.notes,
63
+ labels: task.labels,
64
+ size: task.size ?? null,
65
+ epicLifecycle: task.epicLifecycle ?? null,
66
+ noAutoComplete: task.noAutoComplete ?? null,
67
+ verification: task.verification ? { ...task.verification } : null,
68
+ origin: task.origin ?? null,
69
+ cancellationReason: task.cancellationReason,
70
+ blockedBy: task.blockedBy ? [task.blockedBy] : undefined,
71
+ pipelineStage: task.pipelineStage ?? null,
72
+ };
73
+ }
74
+ /**
75
+ * Convert an array of core Tasks to TaskRecords.
76
+ *
77
+ * @task T4657
78
+ * @epic T4654
79
+ */
80
+ function tasksToRecords(tasks) {
81
+ return tasks.map(taskToRecord);
82
+ }
83
+ // loadTaskFile and saveTaskFile removed — all operations now use DataAccessor.
84
+ // Config reads (hierarchy limits, phase meta) still use readJsonFile directly
85
+ // since they are NOT domain data (they don't go through the accessor).
86
+ // Priority normalization moved to core/tasks/add.ts (normalizePriority)
87
+ // ===== Query Operations =====
88
+ /**
89
+ * Get a single task by ID.
90
+ *
91
+ * @remarks
92
+ * Fetches the full task record from the data accessor and converts it
93
+ * to the backward-compatible TaskRecord format.
94
+ *
95
+ * @param projectRoot - Absolute path to the project root
96
+ * @param taskId - Task identifier (e.g. "T001")
97
+ * @returns EngineResult containing the task record
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const result = await taskShow('/project', 'T42');
102
+ * if (result.success) console.log(result.data.task.title);
103
+ * ```
104
+ *
105
+ * @task T4657
106
+ * @epic T4654
107
+ */
108
+ export async function taskShow(projectRoot, taskId) {
109
+ try {
110
+ const accessor = await getAccessor(projectRoot);
111
+ const detail = await coreShowTask(taskId, projectRoot, accessor);
112
+ return { success: true, data: { task: taskToRecord(detail) } };
113
+ }
114
+ catch (err) {
115
+ const code = err?.code;
116
+ if (code === 4 /* NOT_FOUND */) {
117
+ return engineError('E_NOT_FOUND', err.message || `Task '${taskId}' not found`);
118
+ }
119
+ if (code === 2 /* INVALID_INPUT */) {
120
+ return engineError('E_INVALID_INPUT', err.message || 'Invalid input');
121
+ }
122
+ return engineError('E_NOT_INITIALIZED', err.message || 'Task database not initialized');
123
+ }
124
+ }
125
+ /**
126
+ * List tasks with optional filters.
127
+ *
128
+ * @remarks
129
+ * Supports filtering by parent, status, priority, type, phase, and label.
130
+ * When `compact` is true, returns lightweight CompactTask records.
131
+ * Results are paginated via `limit` and `offset` parameters.
132
+ *
133
+ * @param projectRoot - Absolute path to the project root
134
+ * @param params - Optional filter, pagination, and format parameters
135
+ * @returns EngineResult with task array, total count, and filtered count
136
+ *
137
+ * @example
138
+ * ```typescript
139
+ * const result = await taskList('/project', { status: 'active', limit: 10 });
140
+ * ```
141
+ *
142
+ * @task T4657
143
+ * @epic T4654
144
+ */
145
+ export async function taskList(projectRoot, params) {
146
+ try {
147
+ const accessor = await getAccessor(projectRoot);
148
+ const result = await coreListTasks({
149
+ parentId: params?.parent ?? undefined,
150
+ status: params?.status,
151
+ priority: params?.priority,
152
+ type: params?.type,
153
+ phase: params?.phase,
154
+ label: params?.label,
155
+ children: params?.children,
156
+ limit: params?.limit,
157
+ offset: params?.offset,
158
+ }, projectRoot, accessor);
159
+ const tasks = params?.compact
160
+ ? result.tasks.map((t) => toCompact(t))
161
+ : tasksToRecords(result.tasks);
162
+ if (params?.compact) {
163
+ return {
164
+ success: true,
165
+ data: { tasks, total: result.total, filtered: result.filtered },
166
+ page: result.page,
167
+ };
168
+ }
169
+ return {
170
+ success: true,
171
+ data: { tasks, total: result.total, filtered: result.filtered },
172
+ page: result.page,
173
+ };
174
+ }
175
+ catch (err) {
176
+ const code = err?.code;
177
+ if (code === 4)
178
+ return engineError('E_NOT_FOUND', err.message || 'Task not found');
179
+ if (code === 2)
180
+ return engineError('E_INVALID_INPUT', err.message || 'Invalid input');
181
+ return engineError('E_NOT_INITIALIZED', err.message || 'Task database not initialized');
182
+ }
183
+ }
184
+ /**
185
+ * Fuzzy search tasks by title/description/ID.
186
+ *
187
+ * @remarks
188
+ * Returns minimal task records to keep context consumption low.
189
+ * Supports exact matching, status filtering, and archive inclusion.
190
+ *
191
+ * @param projectRoot - Absolute path to the project root
192
+ * @param query - Search string to match against title, description, or ID
193
+ * @param limit - Maximum number of results (defaults to 20)
194
+ * @param options - Additional search options
195
+ * @returns EngineResult with matching tasks and total count
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * const result = await taskFind('/project', 'authentication', 10);
200
+ * ```
201
+ *
202
+ * @task T4657
203
+ * @epic T4654
204
+ */
205
+ export async function taskFind(projectRoot, query, limit, options) {
206
+ try {
207
+ const accessor = await getAccessor(projectRoot);
208
+ const findResult = await coreFindTasks({
209
+ query,
210
+ id: options?.id,
211
+ exact: options?.exact,
212
+ status: options?.status,
213
+ includeArchive: options?.includeArchive,
214
+ limit: limit ?? 20,
215
+ offset: options?.offset,
216
+ }, projectRoot, accessor);
217
+ const results = findResult.results.map((r) => ({
218
+ id: r.id,
219
+ title: r.title,
220
+ status: r.status,
221
+ priority: r.priority,
222
+ parentId: r.parentId,
223
+ }));
224
+ return { success: true, data: { results, total: results.length } };
225
+ }
226
+ catch (err) {
227
+ const code = err?.code;
228
+ if (code === 4)
229
+ return engineError('E_NOT_FOUND', err.message || 'Task not found');
230
+ if (code === 2)
231
+ return engineError('E_INVALID_INPUT', err.message || 'Invalid input');
232
+ return engineError('E_NOT_INITIALIZED', err.message || 'Task database not initialized');
233
+ }
234
+ }
235
+ /**
236
+ * Check if a task exists.
237
+ *
238
+ * @remarks
239
+ * Returns `{ exists: true }` if the task is found, `{ exists: false }` otherwise.
240
+ * Never fails -- catches all errors and returns false.
241
+ *
242
+ * @param projectRoot - Absolute path to the project root
243
+ * @param taskId - Task identifier to check
244
+ * @returns EngineResult with exists flag and the queried taskId
245
+ *
246
+ * @example
247
+ * ```typescript
248
+ * const result = await taskExists('/project', 'T42');
249
+ * if (result.success && result.data.exists) { console.log('exists'); }
250
+ * ```
251
+ *
252
+ *
253
+ @task
254
+ T4657
255
+ * @epic T4654
256
+ */
257
+ export async function taskExists(projectRoot, taskId) {
258
+ try {
259
+ const accessor = await getAccessor(projectRoot);
260
+ const exists = await accessor.taskExists(taskId);
261
+ return { success: true, data: { exists, taskId } };
262
+ }
263
+ catch {
264
+ return { success: true, data: { exists: false, taskId } };
265
+ }
266
+ }
267
+ // ===== Mutate Operations =====
268
+ /**
269
+ * Create a new task.
270
+ *
271
+ * @remarks
272
+ * Validates hierarchy depth, sibling limits, parent type, and circular
273
+ * references before creating the task. Supports dry-run mode for preview.
274
+ *
275
+ * @param projectRoot - Absolute path to the project root
276
+ * @param params - Task creation parameters
277
+ * @returns EngineResult with the created task record and duplicate flag
278
+ *
279
+ * @example
280
+ * ```typescript
281
+ * const result = await taskCreate('/project', {
282
+ * title: 'Implement auth',
283
+ * description: 'Add JWT-based authentication',
284
+ * priority: 'high',
285
+ * });
286
+ * ```
287
+ */
288
+ export async function taskCreate(projectRoot, params) {
289
+ try {
290
+ const accessor = await getAccessor(projectRoot);
291
+ const result = await coreAddTask({
292
+ title: params.title,
293
+ description: params.description,
294
+ parentId: params.parent || null,
295
+ depends: params.depends,
296
+ priority: params.priority || 'medium',
297
+ labels: params.labels,
298
+ type: params.type || undefined,
299
+ phase: params.phase,
300
+ size: params.size,
301
+ acceptance: params.acceptance,
302
+ notes: params.notes,
303
+ files: params.files,
304
+ dryRun: params.dryRun,
305
+ }, projectRoot, accessor);
306
+ return {
307
+ success: true,
308
+ data: {
309
+ task: taskToRecord(result.task),
310
+ duplicate: result.duplicate ?? false,
311
+ dryRun: params.dryRun,
312
+ },
313
+ };
314
+ }
315
+ catch (err) {
316
+ const cleoErr = err;
317
+ // Map CleoError exit codes to engine error codes (see src/types/exit-codes.ts)
318
+ if (cleoErr.code === 10 /* PARENT_NOT_FOUND */) {
319
+ return engineError('E_PARENT_NOT_FOUND', cleoErr.message ?? 'Parent task not found');
320
+ }
321
+ if (cleoErr.code === 11 /* DEPTH_EXCEEDED */) {
322
+ return engineError('E_DEPTH_EXCEEDED', cleoErr.message ?? 'Max hierarchy depth exceeded');
323
+ }
324
+ if (cleoErr.code === 12 /* SIBLING_LIMIT */) {
325
+ return engineError('E_SIBLING_LIMIT', cleoErr.message ?? 'Max siblings exceeded');
326
+ }
327
+ if (cleoErr.code === 13 /* INVALID_PARENT_TYPE */) {
328
+ return engineError('E_INVALID_PARENT', cleoErr.message ?? 'Invalid parent type');
329
+ }
330
+ if (cleoErr.code === 14 /* CIRCULAR_REFERENCE */) {
331
+ return engineError('E_CIRCULAR_REFERENCE', cleoErr.message ?? 'Circular reference detected');
332
+ }
333
+ if (cleoErr.code === 6 /* VALIDATION_ERROR */ || cleoErr.code === 2 /* INVALID_INPUT */) {
334
+ return engineError('E_VALIDATION_FAILED', cleoErr.message ?? 'Validation failed');
335
+ }
336
+ if (cleoErr.code === 4 /* NOT_FOUND */) {
337
+ return engineError('E_NOT_FOUND', cleoErr.message ?? 'Task not found');
338
+ }
339
+ return engineError('E_NOT_INITIALIZED', cleoErr.message ?? 'Task database not initialized');
340
+ }
341
+ }
342
+ /**
343
+ * Update a task's fields.
344
+ *
345
+ * @remarks
346
+ * Supports atomic label and dependency operations via addLabels/removeLabels
347
+ * and addDepends/removeDepends. Returns the updated task and a list of
348
+ * changed fields.
349
+ *
350
+ * @param projectRoot - Absolute path to the project root
351
+ * @param taskId - Task identifier to update
352
+ * @param updates - Fields to update (only provided fields are changed)
353
+ * @returns EngineResult with the updated task record and list of changes
354
+ *
355
+ * @example
356
+ * ```typescript
357
+ * const result = await taskUpdate('/project', 'T42', { status: 'active' });
358
+ * ```
359
+ */
360
+ export async function taskUpdate(projectRoot, taskId, updates) {
361
+ try {
362
+ const accessor = await getAccessor(projectRoot);
363
+ const result = await coreUpdateTask({
364
+ taskId,
365
+ title: updates.title,
366
+ description: updates.description,
367
+ status: updates.status,
368
+ priority: updates.priority,
369
+ notes: updates.notes,
370
+ labels: updates.labels,
371
+ addLabels: updates.addLabels,
372
+ removeLabels: updates.removeLabels,
373
+ depends: updates.depends,
374
+ addDepends: updates.addDepends,
375
+ removeDepends: updates.removeDepends,
376
+ acceptance: updates.acceptance,
377
+ parentId: updates.parent,
378
+ type: updates.type,
379
+ size: updates.size,
380
+ }, projectRoot, accessor);
381
+ return { success: true, data: { task: taskToRecord(result.task), changes: result.changes } };
382
+ }
383
+ catch (err) {
384
+ const cleoErr = err;
385
+ if (cleoErr.code === 4 /* NOT_FOUND */) {
386
+ return engineError('E_NOT_FOUND', cleoErr.message ?? `Task '${taskId}' not found`);
387
+ }
388
+ if (cleoErr.code === 6 /* VALIDATION_ERROR */ || cleoErr.code === 2 /* INVALID_INPUT */) {
389
+ return engineError('E_VALIDATION_FAILED', cleoErr.message ?? 'Validation failed');
390
+ }
391
+ if (cleoErr.code === 102 /* NO_CHANGE */) {
392
+ return engineError('E_NO_CHANGE', cleoErr.message ?? 'No changes specified');
393
+ }
394
+ return engineError('E_NOT_INITIALIZED', cleoErr.message ?? 'Task database not initialized');
395
+ }
396
+ }
397
+ /**
398
+ * Complete a task (set status to done).
399
+ *
400
+ * @remarks
401
+ * May trigger auto-completion of parent tasks and unblocking of dependent
402
+ * tasks. Maps core exit codes to engine error codes for structured error reporting.
403
+ *
404
+ * @param projectRoot - Absolute path to the project root
405
+ * @param taskId - Task identifier to complete
406
+ * @param notes - Optional completion notes
407
+ * @returns EngineResult with the completed task, auto-completed parents, and unblocked tasks
408
+ *
409
+ * @example
410
+ * ```typescript
411
+ * const result = await taskComplete('/project', 'T42', 'All tests passing');
412
+ * ```
413
+ */
414
+ export async function taskComplete(projectRoot, taskId, notes) {
415
+ try {
416
+ const accessor = await getAccessor(projectRoot);
417
+ const result = await coreCompleteTask({ taskId, notes }, projectRoot, accessor);
418
+ return {
419
+ success: true,
420
+ data: {
421
+ task: result.task,
422
+ ...(result.autoCompleted && { autoCompleted: result.autoCompleted }),
423
+ ...(result.unblockedTasks && { unblockedTasks: result.unblockedTasks }),
424
+ },
425
+ };
426
+ }
427
+ catch (err) {
428
+ const cleoErr = err;
429
+ const message = cleoErr.message ?? 'Failed to complete task';
430
+ if (typeof cleoErr.code === 'number') {
431
+ const mappedCode = TASK_COMPLETE_EXIT_TO_ENGINE_CODE[cleoErr.code];
432
+ if (mappedCode) {
433
+ return engineError(mappedCode, message);
434
+ }
435
+ }
436
+ return engineError('E_INTERNAL', message);
437
+ }
438
+ }
439
+ /**
440
+ * Delete a task.
441
+ *
442
+ * @remarks
443
+ * When `force` is true, cascade-deletes child tasks. Otherwise, returns
444
+ * E_HAS_CHILDREN if the task has children.
445
+ *
446
+ * @param projectRoot - Absolute path to the project root
447
+ * @param taskId - Task identifier to delete
448
+ * @param force - When true, enables cascade deletion of children
449
+ * @returns EngineResult with the deleted task and optional cascade info
450
+ *
451
+ * @example
452
+ * ```typescript
453
+ * const result = await taskDelete('/project', 'T42', true);
454
+ * ```
455
+ */
456
+ export async function taskDelete(projectRoot, taskId, force) {
457
+ try {
458
+ const accessor = await getAccessor(projectRoot);
459
+ const result = await coreDeleteTask({
460
+ taskId,
461
+ force: force ?? false,
462
+ cascade: force ?? false,
463
+ }, projectRoot, accessor);
464
+ return {
465
+ success: true,
466
+ data: {
467
+ deletedTask: taskToRecord(result.deletedTask),
468
+ deleted: true,
469
+ cascadeDeleted: result.cascadeDeleted,
470
+ },
471
+ };
472
+ }
473
+ catch (err) {
474
+ const cleoErr = err;
475
+ if (cleoErr.code === 4 /* NOT_FOUND */) {
476
+ return engineError('E_NOT_FOUND', cleoErr.message ?? `Task '${taskId}' not found`);
477
+ }
478
+ if (cleoErr.code === 16 /* HAS_CHILDREN */) {
479
+ return engineError('E_HAS_CHILDREN', cleoErr.message ?? `Task '${taskId}' has children`);
480
+ }
481
+ return engineError('E_NOT_INITIALIZED', cleoErr.message ?? 'Task database not initialized');
482
+ }
483
+ }
484
+ /**
485
+ * Archive completed tasks.
486
+ * Moves done/cancelled tasks from active task data to archive.
487
+ *
488
+ * @remarks
489
+ * Archives a specific task by ID, or all tasks completed before a given date.
490
+ * Archived tasks are no longer returned by default queries.
491
+ *
492
+ * @param projectRoot - Absolute path to the project root
493
+ * @param taskId - Optional specific task ID to archive
494
+ * @param before - Optional ISO date string; archives tasks completed before this date
495
+ * @returns EngineResult with count and list of archived task IDs
496
+ *
497
+ * @example
498
+ * ```typescript
499
+ * const result = await taskArchive('/project', undefined, '2026-01-01');
500
+ * ```
501
+ */
502
+ export async function taskArchive(projectRoot, taskId, before) {
503
+ try {
504
+ const accessor = await getAccessor(projectRoot);
505
+ const result = await coreArchiveTasks({
506
+ taskIds: taskId ? [taskId] : undefined,
507
+ before,
508
+ }, projectRoot, accessor);
509
+ return {
510
+ success: true,
511
+ data: {
512
+ archivedCount: result.archived.length,
513
+ archivedTasks: result.archived.map((id) => ({ id })),
514
+ },
515
+ };
516
+ }
517
+ catch (err) {
518
+ const cleoErr = err;
519
+ if (cleoErr.code === 4 /* NOT_FOUND */) {
520
+ return engineError('E_NOT_FOUND', cleoErr.message ?? 'Task not found');
521
+ }
522
+ return engineError('E_NOT_INITIALIZED', cleoErr.message ?? 'Task database not initialized');
523
+ }
524
+ }
525
+ // ===== Non-CRUD Operations (delegated to core/tasks/task-ops.ts) =====
526
+ /**
527
+ * Suggest next task to work on based on priority, phase alignment, age, and dependency readiness.
528
+ *
529
+ * @remarks
530
+ * Scores all pending tasks and returns ranked suggestions. When `explain`
531
+ * is true, includes per-task scoring reasons in the response.
532
+ *
533
+ * @param projectRoot - Absolute path to the project root
534
+ * @param params - Optional count limit and explain flag
535
+ * @returns EngineResult with scored suggestions and total candidate count
536
+ *
537
+ * @example
538
+ * ```typescript
539
+ * const result = await taskNext('/project', { count: 3, explain: true });
540
+ * ```
541
+ *
542
+ * @task T4657
543
+ * @task T4790
544
+ * @epic T4654
545
+ */
546
+ export async function taskNext(projectRoot, params) {
547
+ try {
548
+ const result = await coreTaskNext(projectRoot, params);
549
+ return { success: true, data: result };
550
+ }
551
+ catch {
552
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
553
+ }
554
+ }
555
+ /**
556
+ * Show blocked tasks and analyze blocking chains.
557
+ *
558
+ * @remarks
559
+ * Identifies all blocked tasks, traces their blocking chains, and highlights
560
+ * critical blockers (tasks that block the most other tasks).
561
+ *
562
+ * @param projectRoot - Absolute path to the project root
563
+ * @param params - Optional analysis and limit parameters
564
+ * @returns EngineResult with blocked tasks, critical blockers, and summary
565
+ *
566
+ * @example
567
+ * ```typescript
568
+ * const result = await taskBlockers('/project', { analyze: true });
569
+ * ```
570
+ *
571
+ * @task T4657
572
+ * @task T4790
573
+ * @epic T4654
574
+ */
575
+ export async function taskBlockers(projectRoot, params) {
576
+ try {
577
+ const result = await coreTaskBlockers(projectRoot, params);
578
+ return { success: true, data: result };
579
+ }
580
+ catch {
581
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
582
+ }
583
+ }
584
+ /**
585
+ * Build hierarchy tree.
586
+ *
587
+ * @remarks
588
+ * Returns a tree structure of tasks rooted at the given task ID, or
589
+ * the full project tree when no task ID is specified.
590
+ *
591
+ * @param projectRoot - Absolute path to the project root
592
+ * @param taskId - Optional root task ID for subtree
593
+ * @returns EngineResult with the hierarchical tree data
594
+ *
595
+ * @example
596
+ * ```typescript
597
+ * const result = await taskTree('/project', 'T1');
598
+ * ```
599
+ *
600
+ * @task T4657
601
+ * @task T4790
602
+ * @epic T4654
603
+ */
604
+ export async function taskTree(projectRoot, taskId) {
605
+ try {
606
+ const result = await coreTaskTree(projectRoot, taskId);
607
+ return { success: true, data: result };
608
+ }
609
+ catch (err) {
610
+ const message = err instanceof Error ? err.message : String(err);
611
+ if (message.includes('not found')) {
612
+ return engineError('E_NOT_FOUND', message);
613
+ }
614
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
615
+ }
616
+ }
617
+ /**
618
+ * Show dependencies for a task - both what it depends on and what depends on it.
619
+ *
620
+ * @remarks
621
+ * Returns bidirectional dependency information including unresolved deps
622
+ * and a ready flag indicating whether all dependencies are satisfied.
623
+ *
624
+ * @param projectRoot - Absolute path to the project root
625
+ * @param taskId - Task identifier to inspect
626
+ * @returns EngineResult with dependency information in both directions
627
+ *
628
+ * @example
629
+ * ```typescript
630
+ * const result = await taskDeps('/project', 'T42');
631
+ * ```
632
+ *
633
+ * @task T4657
634
+ * @task T4790
635
+ * @epic T4654
636
+ */
637
+ export async function taskDeps(projectRoot, taskId) {
638
+ try {
639
+ const result = await coreTaskDeps(projectRoot, taskId);
640
+ return { success: true, data: result };
641
+ }
642
+ catch (err) {
643
+ const message = err instanceof Error ? err.message : String(err);
644
+ if (message.includes('not found')) {
645
+ return engineError('E_NOT_FOUND', message);
646
+ }
647
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
648
+ }
649
+ }
650
+ /**
651
+ * Show task relations (existing relates entries).
652
+ *
653
+ * @remarks
654
+ * Lists all `relates` entries for a given task, including the relationship
655
+ * type and optional reason.
656
+ *
657
+ * @param projectRoot - Absolute path to the project root
658
+ * @param taskId - Task identifier to inspect
659
+ * @returns EngineResult with relations array and count
660
+ *
661
+ * @example
662
+ * ```typescript
663
+ * const result = await taskRelates('/project', 'T42');
664
+ * ```
665
+ *
666
+ * @task T4657
667
+ * @task T4790
668
+ * @epic T4654
669
+ */
670
+ export async function taskRelates(projectRoot, taskId) {
671
+ try {
672
+ const result = await coreTaskRelates(projectRoot, taskId);
673
+ return { success: true, data: result };
674
+ }
675
+ catch (err) {
676
+ const message = err instanceof Error ? err.message : String(err);
677
+ if (message.includes('not found')) {
678
+ return engineError('E_NOT_FOUND', message);
679
+ }
680
+ return engineError('E_GENERAL', `Failed to read task relations: ${message}`);
681
+ }
682
+ }
683
+ /**
684
+ * Add a relation between two tasks.
685
+ *
686
+ * @remarks
687
+ * Valid relation types: related, blocks, duplicates, absorbs, fixes, extends, supersedes.
688
+ *
689
+ * @param projectRoot - Absolute path to the project root
690
+ * @param taskId - Source task identifier
691
+ * @param relatedId - Target task identifier
692
+ * @param type - Relation type (e.g. "blocks", "related")
693
+ * @param reason - Optional explanation for the relation
694
+ * @returns EngineResult confirming the relation was added
695
+ *
696
+ * @example
697
+ * ```typescript
698
+ * const result = await taskRelatesAdd('/project', 'T42', 'T43', 'blocks', 'Needs auth first');
699
+ * ```
700
+ *
701
+ * @task T4790
702
+ */
703
+ export async function taskRelatesAdd(projectRoot, taskId, relatedId, type, reason) {
704
+ try {
705
+ const result = await coreTaskRelatesAdd(projectRoot, taskId, relatedId, type, reason);
706
+ return { success: true, data: result };
707
+ }
708
+ catch (err) {
709
+ const message = err instanceof Error ? err.message : String(err);
710
+ if (message.includes('not found')) {
711
+ return engineError('E_NOT_FOUND', message);
712
+ }
713
+ if (message.includes('Invalid relation type')) {
714
+ return engineError('E_VALIDATION', message, {
715
+ fix: 'Use a valid relation type: related, blocks, duplicates, absorbs, fixes, extends, supersedes',
716
+ });
717
+ }
718
+ return engineError('E_GENERAL', `Failed to update task relations: ${message}`);
719
+ }
720
+ }
721
+ /**
722
+ * Analyze a task for description quality, missing fields, and dependency health.
723
+ *
724
+ * @remarks
725
+ * When no task ID is provided, analyzes all tasks to identify bottlenecks,
726
+ * leverage opportunities, and overall project health metrics.
727
+ *
728
+ * @param projectRoot - Absolute path to the project root
729
+ * @param taskId - Optional specific task to analyze
730
+ * @param params - Optional analysis parameters
731
+ * @returns EngineResult with recommended task, bottlenecks, tiers, and metrics
732
+ *
733
+ * @example
734
+ * ```typescript
735
+ * const result = await taskAnalyze('/project');
736
+ * ```
737
+ *
738
+ * @task T4657
739
+ * @task T4790
740
+ * @epic T4654
741
+ */
742
+ export async function taskAnalyze(projectRoot, taskId, params) {
743
+ try {
744
+ const result = await coreTaskAnalyze(projectRoot, taskId, params);
745
+ return { success: true, data: result };
746
+ }
747
+ catch (err) {
748
+ const message = err instanceof Error ? err.message : String(err);
749
+ if (message.includes('not found')) {
750
+ return engineError('E_NOT_FOUND', message);
751
+ }
752
+ return engineError('E_GENERAL', `Task analysis failed: ${message}`);
753
+ }
754
+ }
755
+ /**
756
+ * Predict downstream impact of a free-text change description.
757
+ *
758
+ * Delegates to {@link predictImpact} from the intelligence module.
759
+ * Uses keyword matching against task titles/descriptions, then traces
760
+ * the reverse dependency graph for transitive effects.
761
+ *
762
+ * @remarks
763
+ * The impact report includes directly affected tasks, transitively
764
+ * affected tasks (through the dependency graph), and a severity assessment.
765
+ *
766
+ * @param projectRoot - Project root directory
767
+ * @param change - Free-text description of the proposed change
768
+ * @param matchLimit - Maximum seed tasks to match (default: 5)
769
+ * @returns Impact prediction report
770
+ *
771
+ * @example
772
+ * ```typescript
773
+ * const result = await taskImpact('/project', 'Refactor authentication module');
774
+ * ```
775
+ *
776
+ * @task T043
777
+ */
778
+ export async function taskImpact(projectRoot, change, matchLimit) {
779
+ try {
780
+ const result = await predictImpact(change, projectRoot, undefined, matchLimit);
781
+ return { success: true, data: result };
782
+ }
783
+ catch (err) {
784
+ const message = err instanceof Error ? err.message : String(err);
785
+ return engineError('E_GENERAL', `Impact prediction failed: ${message}`);
786
+ }
787
+ }
788
+ /**
789
+ * Restore a cancelled task back to pending.
790
+ *
791
+ * @remarks
792
+ * When cascade is true, also restores cancelled children.
793
+ *
794
+ * @param projectRoot - Absolute path to the project root
795
+ * @param taskId - Task identifier to restore
796
+ * @param params - Optional cascade and notes options
797
+ * @returns EngineResult with restored task IDs and count
798
+ *
799
+ * @example
800
+ * ```typescript
801
+ * const result = await taskRestore('/project', 'T42', { cascade: true });
802
+ * ```
803
+ *
804
+ * @task T4790
805
+ */
806
+ export async function taskRestore(projectRoot, taskId, params) {
807
+ try {
808
+ const result = await coreTaskRestore(projectRoot, taskId, params);
809
+ return { success: true, data: result };
810
+ }
811
+ catch (err) {
812
+ const message = err instanceof Error ? err.message : String(err);
813
+ if (message.includes('not found')) {
814
+ return engineError('E_NOT_FOUND', message);
815
+ }
816
+ if (message.includes('not cancelled')) {
817
+ return engineError('E_INVALID_INPUT', message);
818
+ }
819
+ return engineError('E_NOT_INITIALIZED', 'Failed to restore task');
820
+ }
821
+ }
822
+ /**
823
+ * Move an archived task back to active task data with status 'done' (or specified status).
824
+ *
825
+ * @remarks
826
+ * By default restores with status 'done'. Use `preserveStatus` to keep
827
+ * the original status, or `status` to set a specific status.
828
+ *
829
+ * @param projectRoot - Absolute path to the project root
830
+ * @param taskId - Archived task identifier to restore
831
+ * @param params - Optional status override parameters
832
+ * @returns EngineResult with the unarchived task info
833
+ *
834
+ * @example
835
+ * ```typescript
836
+ * const result = await taskUnarchive('/project', 'T42', { status: 'pending' });
837
+ * ```
838
+ *
839
+ * @task T4790
840
+ */
841
+ export async function taskUnarchive(projectRoot, taskId, params) {
842
+ try {
843
+ const result = await coreTaskUnarchive(projectRoot, taskId, params);
844
+ return { success: true, data: result };
845
+ }
846
+ catch (err) {
847
+ const message = err instanceof Error ? err.message : String(err);
848
+ if (message.includes('not found')) {
849
+ return engineError('E_NOT_FOUND', message);
850
+ }
851
+ if (message.includes('already exists')) {
852
+ return engineError('E_ID_COLLISION', message);
853
+ }
854
+ return engineError('E_NOT_INITIALIZED', 'Failed to unarchive task');
855
+ }
856
+ }
857
+ /**
858
+ * Change task position within its sibling group.
859
+ *
860
+ * @remarks
861
+ * Reorders a task to the specified zero-based position among its siblings.
862
+ *
863
+ * @param projectRoot - Absolute path to the project root
864
+ * @param taskId - Task identifier to reorder
865
+ * @param position - Target zero-based position
866
+ * @returns EngineResult with new position and total siblings
867
+ *
868
+ * @example
869
+ * ```typescript
870
+ * const result = await taskReorder('/project', 'T42', 0); // move to first
871
+ * ```
872
+ *
873
+ * @task T4790
874
+ */
875
+ export async function taskReorder(projectRoot, taskId, position) {
876
+ try {
877
+ const result = await coreTaskReorder(projectRoot, taskId, position);
878
+ return { success: true, data: result };
879
+ }
880
+ catch (err) {
881
+ const message = err instanceof Error ? err.message : String(err);
882
+ if (message.includes('not found')) {
883
+ return engineError('E_NOT_FOUND', message);
884
+ }
885
+ return engineError('E_NOT_INITIALIZED', 'Failed to reorder task');
886
+ }
887
+ }
888
+ /**
889
+ * Move task under a different parent.
890
+ *
891
+ * @remarks
892
+ * Pass null as `newParentId` to promote the task to a root-level task.
893
+ * Validates hierarchy depth and circular reference constraints.
894
+ *
895
+ * @param projectRoot - Absolute path to the project root
896
+ * @param taskId - Task identifier to move
897
+ * @param newParentId - New parent task ID, or null for root
898
+ * @returns EngineResult with old and new parent information
899
+ *
900
+ * @example
901
+ * ```typescript
902
+ * const result = await taskReparent('/project', 'T42', 'T1');
903
+ * ```
904
+ *
905
+ * @task T4790
906
+ */
907
+ export async function taskReparent(projectRoot, taskId, newParentId) {
908
+ try {
909
+ const result = await coreTaskReparent(projectRoot, taskId, newParentId);
910
+ return { success: true, data: result };
911
+ }
912
+ catch (err) {
913
+ const message = err instanceof Error ? err.message : String(err);
914
+ if (message.includes('not found')) {
915
+ const code = message.includes('Parent') ? 'E_PARENT_NOT_FOUND' : 'E_NOT_FOUND';
916
+ return engineError(code, message);
917
+ }
918
+ if (message.includes('subtask')) {
919
+ return engineError('E_INVALID_PARENT_TYPE', message);
920
+ }
921
+ if (message.includes('circular')) {
922
+ return engineError('E_CIRCULAR_REFERENCE', message);
923
+ }
924
+ if (message.includes('depth')) {
925
+ return engineError('E_DEPTH_EXCEEDED', message);
926
+ }
927
+ if (message.includes('siblings')) {
928
+ return engineError('E_SIBLING_LIMIT', message);
929
+ }
930
+ return engineError('E_NOT_INITIALIZED', 'Failed to reparent task');
931
+ }
932
+ }
933
+ /**
934
+ * Promote a subtask to task or task to root (remove parent).
935
+ *
936
+ * @remarks
937
+ * Removes the parent reference and may change the task type from subtask to task.
938
+ *
939
+ * @param projectRoot - Absolute path to the project root
940
+ * @param taskId - Task identifier to promote
941
+ * @returns EngineResult with promotion details
942
+ *
943
+ * @example
944
+ * ```typescript
945
+ * const result = await taskPromote('/project', 'T42');
946
+ * ```
947
+ *
948
+ * @task T4790
949
+ */
950
+ export async function taskPromote(projectRoot, taskId) {
951
+ try {
952
+ const result = await coreTaskPromote(projectRoot, taskId);
953
+ return { success: true, data: result };
954
+ }
955
+ catch (err) {
956
+ const message = err instanceof Error ? err.message : String(err);
957
+ if (message.includes('not found')) {
958
+ return engineError('E_NOT_FOUND', message);
959
+ }
960
+ return engineError('E_NOT_INITIALIZED', 'Failed to promote task');
961
+ }
962
+ }
963
+ /**
964
+ * Reopen a completed task (set status back to pending).
965
+ *
966
+ * @remarks
967
+ * Only works on tasks with status 'done'. Optionally sets a different
968
+ * target status and records a reason for reopening.
969
+ *
970
+ * @param projectRoot - Absolute path to the project root
971
+ * @param taskId - Task identifier to reopen
972
+ * @param params - Optional target status and reason
973
+ * @returns EngineResult with reopen details including previous and new status
974
+ *
975
+ * @example
976
+ * ```typescript
977
+ * const result = await taskReopen('/project', 'T42', { reason: 'Tests regressed' });
978
+ * ```
979
+ *
980
+ * @task T4790
981
+ */
982
+ export async function taskReopen(projectRoot, taskId, params) {
983
+ try {
984
+ const result = await coreTaskReopen(projectRoot, taskId, params);
985
+ return { success: true, data: result };
986
+ }
987
+ catch (err) {
988
+ const message = err instanceof Error ? err.message : String(err);
989
+ if (message.includes('not found')) {
990
+ return engineError('E_NOT_FOUND', message);
991
+ }
992
+ if (message.includes('not completed')) {
993
+ return engineError('E_INVALID_INPUT', message);
994
+ }
995
+ if (message.includes('Invalid target')) {
996
+ return engineError('E_INVALID_INPUT', message);
997
+ }
998
+ return engineError('E_NOT_INITIALIZED', 'Failed to reopen task');
999
+ }
1000
+ }
1001
+ /**
1002
+ * Cancel a task (soft terminal state -- reversible via restore).
1003
+ *
1004
+ * @remarks
1005
+ * Sets the task status to cancelled with an optional reason. The task can
1006
+ * be restored later via {@link taskRestore}.
1007
+ *
1008
+ * @param projectRoot - Absolute path to the project root
1009
+ * @param taskId - Task identifier to cancel
1010
+ * @param reason - Optional cancellation reason
1011
+ * @returns EngineResult with cancellation details
1012
+ *
1013
+ * @example
1014
+ * ```typescript
1015
+ * const result = await taskCancel('/project', 'T42', 'No longer needed');
1016
+ * ```
1017
+ *
1018
+ * @task T4529
1019
+ */
1020
+ export async function taskCancel(projectRoot, taskId, reason) {
1021
+ try {
1022
+ const result = await coreTaskCancel(projectRoot, taskId, { reason });
1023
+ return { success: true, data: result };
1024
+ }
1025
+ catch (err) {
1026
+ const message = err instanceof Error ? err.message : String(err);
1027
+ if (message.includes('not found'))
1028
+ return engineError('E_NOT_FOUND', message);
1029
+ if (message.includes('already cancelled') || message.includes('completed'))
1030
+ return engineError('E_INVALID_INPUT', message);
1031
+ return engineError('E_INTERNAL', message);
1032
+ }
1033
+ }
1034
+ /**
1035
+ * Deterministic complexity scoring from task metadata.
1036
+ *
1037
+ * @remarks
1038
+ * Produces a size estimate (small/medium/large) based on dependency depth,
1039
+ * subtask count, file count, and other structural factors.
1040
+ *
1041
+ * @param projectRoot - Absolute path to the project root
1042
+ * @param params - Parameters including the task ID to estimate
1043
+ * @returns EngineResult with size, score, factors, and structural metrics
1044
+ *
1045
+ * @example
1046
+ * ```typescript
1047
+ * const result = await taskComplexityEstimate('/project', { taskId: 'T42' });
1048
+ * ```
1049
+ *
1050
+ * @task T4657
1051
+ * @task T4790
1052
+ * @epic T4654
1053
+ */
1054
+ export async function taskComplexityEstimate(projectRoot, params) {
1055
+ try {
1056
+ const result = await coreTaskComplexityEstimate(projectRoot, params);
1057
+ return { success: true, data: result };
1058
+ }
1059
+ catch (err) {
1060
+ const message = err instanceof Error ? err.message : String(err);
1061
+ if (message.includes('not found')) {
1062
+ return engineError('E_NOT_FOUND', message);
1063
+ }
1064
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1065
+ }
1066
+ }
1067
+ /**
1068
+ * List dependencies for a task in a given direction.
1069
+ * @task T4657
1070
+ * @task T4790
1071
+ * @epic T4654
1072
+ */
1073
+ export async function taskDepends(projectRoot, taskId, direction = 'both', tree) {
1074
+ try {
1075
+ const result = await coreTaskDepends(projectRoot, taskId, direction, tree ? { tree } : undefined);
1076
+ return { success: true, data: result };
1077
+ }
1078
+ catch (err) {
1079
+ const message = err instanceof Error ? err.message : String(err);
1080
+ if (message.includes('not found')) {
1081
+ return engineError('E_NOT_FOUND', message);
1082
+ }
1083
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1084
+ }
1085
+ }
1086
+ /**
1087
+ * Overview of all dependencies across the project.
1088
+ * @task T5157
1089
+ */
1090
+ export async function taskDepsOverview(projectRoot) {
1091
+ try {
1092
+ const result = await coreTaskDepsOverview(projectRoot);
1093
+ return { success: true, data: result };
1094
+ }
1095
+ catch (err) {
1096
+ const message = err instanceof Error ? err.message : String(err);
1097
+ return engineError('E_NOT_INITIALIZED', message);
1098
+ }
1099
+ }
1100
+ /**
1101
+ * Detect circular dependencies across the project.
1102
+ * @task T5157
1103
+ */
1104
+ export async function taskDepsCycles(projectRoot) {
1105
+ try {
1106
+ const result = await coreTaskDepsCycles(projectRoot);
1107
+ return { success: true, data: result };
1108
+ }
1109
+ catch (err) {
1110
+ const message = err instanceof Error ? err.message : String(err);
1111
+ return engineError('E_NOT_INITIALIZED', message);
1112
+ }
1113
+ }
1114
+ /**
1115
+ * Compute task statistics, optionally scoped to an epic.
1116
+ * @task T4657
1117
+ * @task T4790
1118
+ * @epic T4654
1119
+ */
1120
+ export async function taskStats(projectRoot, epicId) {
1121
+ try {
1122
+ const result = await coreTaskStats(projectRoot, epicId);
1123
+ return { success: true, data: result };
1124
+ }
1125
+ catch {
1126
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1127
+ }
1128
+ }
1129
+ /**
1130
+ * Export tasks as JSON or CSV.
1131
+ * @task T4657
1132
+ * @task T4790
1133
+ * @epic T4654
1134
+ */
1135
+ export async function taskExport(projectRoot, params) {
1136
+ try {
1137
+ const result = await coreTaskExport(projectRoot, params);
1138
+ return { success: true, data: result };
1139
+ }
1140
+ catch {
1141
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1142
+ }
1143
+ }
1144
+ /**
1145
+ * Get task history from the log file.
1146
+ * @task T4657
1147
+ * @task T4790
1148
+ * @epic T4654
1149
+ */
1150
+ export async function taskHistory(projectRoot, taskId, limit) {
1151
+ try {
1152
+ const result = await coreTaskHistory(projectRoot, taskId, limit);
1153
+ return { success: true, data: result };
1154
+ }
1155
+ catch {
1156
+ return engineError('E_NOT_INITIALIZED', 'Failed to read task history');
1157
+ }
1158
+ }
1159
+ /**
1160
+ * Lint tasks for common issues.
1161
+ * @task T4657
1162
+ * @task T4790
1163
+ * @epic T4654
1164
+ */
1165
+ export async function taskLint(projectRoot, taskId) {
1166
+ try {
1167
+ const result = await coreTaskLint(projectRoot, taskId);
1168
+ return { success: true, data: result };
1169
+ }
1170
+ catch (err) {
1171
+ const message = err instanceof Error ? err.message : String(err);
1172
+ if (message.includes('not found')) {
1173
+ return engineError('E_NOT_FOUND', message);
1174
+ }
1175
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1176
+ }
1177
+ }
1178
+ /**
1179
+ * Validate multiple tasks at once.
1180
+ * @task T4657
1181
+ * @task T4790
1182
+ * @epic T4654
1183
+ */
1184
+ export async function taskBatchValidate(projectRoot, taskIds, checkMode = 'full') {
1185
+ try {
1186
+ const result = await coreTaskBatchValidate(projectRoot, taskIds, checkMode);
1187
+ return { success: true, data: result };
1188
+ }
1189
+ catch {
1190
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1191
+ }
1192
+ }
1193
+ /**
1194
+ * Import tasks from a JSON source string or export package.
1195
+ * @task T4790
1196
+ */
1197
+ export async function taskImport(projectRoot, source, overwrite) {
1198
+ try {
1199
+ const result = await coreTaskImport(projectRoot, source, overwrite);
1200
+ return { success: true, data: result };
1201
+ }
1202
+ catch (err) {
1203
+ const message = err instanceof Error ? err.message : String(err);
1204
+ if (message.includes('Invalid JSON')) {
1205
+ return engineError('E_INVALID_INPUT', message);
1206
+ }
1207
+ return engineError('E_NOT_INITIALIZED', 'Failed to import tasks');
1208
+ }
1209
+ }
1210
+ /**
1211
+ * Compute a ranked plan: in-progress epics, ready tasks, blockers, bugs.
1212
+ * @task T4815
1213
+ */
1214
+ export async function taskPlan(projectRoot) {
1215
+ const { coreTaskPlan } = await import('@cleocode/core/internal');
1216
+ try {
1217
+ const result = await coreTaskPlan(projectRoot);
1218
+ return { success: true, data: result };
1219
+ }
1220
+ catch {
1221
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1222
+ }
1223
+ }
1224
+ /**
1225
+ * Find related tasks using semantic search or keyword matching.
1226
+ * @task T5672
1227
+ */
1228
+ export async function taskRelatesFind(projectRoot, taskId, params) {
1229
+ try {
1230
+ const { suggestRelated, discoverRelated } = await import('@cleocode/core/internal');
1231
+ const accessor = await getAccessor(projectRoot);
1232
+ const mode = params?.mode ?? 'suggest';
1233
+ let result;
1234
+ if (mode === 'discover') {
1235
+ result = await discoverRelated(taskId, undefined, accessor);
1236
+ }
1237
+ else {
1238
+ const threshold = params?.threshold ?? 50;
1239
+ result = await suggestRelated(taskId, { threshold }, accessor);
1240
+ }
1241
+ return { success: true, data: result };
1242
+ }
1243
+ catch (err) {
1244
+ const message = err instanceof Error ? err.message : String(err);
1245
+ if (message.includes('not found')) {
1246
+ return engineError('E_NOT_FOUND', message);
1247
+ }
1248
+ return engineError('E_INTERNAL', message);
1249
+ }
1250
+ }
1251
+ /**
1252
+ * List all labels used in tasks.
1253
+ * @task T5672
1254
+ */
1255
+ export async function taskLabelList(projectRoot) {
1256
+ try {
1257
+ const { listLabels } = await import('@cleocode/core/internal');
1258
+ const accessor = await getAccessor(projectRoot);
1259
+ const labels = await listLabels(projectRoot, accessor);
1260
+ return { success: true, data: { labels, count: labels.length } };
1261
+ }
1262
+ catch {
1263
+ return engineError('E_NOT_INITIALIZED', 'Task database not initialized');
1264
+ }
1265
+ }
1266
+ /**
1267
+ * Show tasks associated with a label.
1268
+ * @task T5672
1269
+ */
1270
+ export async function taskLabelShow(projectRoot, label) {
1271
+ try {
1272
+ const { showLabelTasks } = await import('@cleocode/core/internal');
1273
+ const accessor = await getAccessor(projectRoot);
1274
+ const result = await showLabelTasks(label, projectRoot, accessor);
1275
+ return { success: true, data: result };
1276
+ }
1277
+ catch (err) {
1278
+ const message = err instanceof Error ? err.message : String(err);
1279
+ return engineError('E_INTERNAL', message);
1280
+ }
1281
+ }
1282
+ // ---------------------------------------------------------------------------
1283
+ // Sync sub-domain (provider-agnostic task reconciliation)
1284
+ // ---------------------------------------------------------------------------
1285
+ /**
1286
+ * Reconcile external tasks with CLEO as SSoT.
1287
+ */
1288
+ export async function taskSyncReconcile(projectRoot, params) {
1289
+ try {
1290
+ const { reconcile } = await import('@cleocode/core/internal');
1291
+ const accessor = await getAccessor(projectRoot);
1292
+ const result = await reconcile(params.externalTasks, {
1293
+ providerId: params.providerId,
1294
+ cwd: projectRoot,
1295
+ dryRun: params.dryRun,
1296
+ conflictPolicy: params.conflictPolicy,
1297
+ defaultPhase: params.defaultPhase,
1298
+ defaultLabels: params.defaultLabels,
1299
+ }, accessor);
1300
+ return { success: true, data: result };
1301
+ }
1302
+ catch (err) {
1303
+ const message = err instanceof Error ? err.message : String(err);
1304
+ return engineError('E_INTERNAL', message);
1305
+ }
1306
+ }
1307
+ /**
1308
+ * List external task links by provider or task ID.
1309
+ */
1310
+ export async function taskSyncLinks(projectRoot, params) {
1311
+ try {
1312
+ const { getLinksByProvider, getLinksByTaskId } = await import('@cleocode/core/internal');
1313
+ if (params?.taskId) {
1314
+ const links = await getLinksByTaskId(params.taskId, projectRoot);
1315
+ return { success: true, data: { links, count: links.length } };
1316
+ }
1317
+ if (params?.providerId) {
1318
+ const links = await getLinksByProvider(params.providerId, projectRoot);
1319
+ return { success: true, data: { links, count: links.length } };
1320
+ }
1321
+ return engineError('E_INVALID_INPUT', 'Either providerId or taskId is required');
1322
+ }
1323
+ catch (err) {
1324
+ const message = err instanceof Error ? err.message : String(err);
1325
+ return engineError('E_INTERNAL', message);
1326
+ }
1327
+ }
1328
+ /**
1329
+ * Remove all external task links for a provider.
1330
+ */
1331
+ export async function taskSyncLinksRemove(projectRoot, providerId) {
1332
+ try {
1333
+ const { removeLinksByProvider } = await import('@cleocode/core/internal');
1334
+ const removed = await removeLinksByProvider(providerId, projectRoot);
1335
+ return { success: true, data: { providerId, removed } };
1336
+ }
1337
+ catch (err) {
1338
+ const message = err instanceof Error ? err.message : String(err);
1339
+ return engineError('E_INTERNAL', message);
1340
+ }
1341
+ }
1342
+ /**
1343
+ * Atomically claim a task for an agent.
1344
+ *
1345
+ * Fails if the task is already claimed by a different agent.
1346
+ * No-op if the task is already claimed by the same agent (idempotent).
1347
+ */
1348
+ export async function taskClaim(projectRoot, taskId, agentId) {
1349
+ try {
1350
+ if (!taskId)
1351
+ return engineError('E_INVALID_INPUT', 'taskId is required');
1352
+ if (!agentId)
1353
+ return engineError('E_INVALID_INPUT', 'agentId is required');
1354
+ const acc = await getAccessor(projectRoot);
1355
+ await acc.claimTask(taskId, agentId);
1356
+ return { success: true, data: { taskId, agentId } };
1357
+ }
1358
+ catch (err) {
1359
+ const message = err instanceof Error ? err.message : String(err);
1360
+ if (message.includes('not found'))
1361
+ return engineError('E_NOT_FOUND', message);
1362
+ if (message.includes('already claimed'))
1363
+ return engineError('E_CONFLICT', message);
1364
+ return engineError('E_INTERNAL', message);
1365
+ }
1366
+ }
1367
+ /**
1368
+ * Release an agent's claim on a task, setting assignee to null.
1369
+ *
1370
+ * No-op if the task is not currently claimed.
1371
+ */
1372
+ export async function taskUnclaim(projectRoot, taskId) {
1373
+ try {
1374
+ if (!taskId)
1375
+ return engineError('E_INVALID_INPUT', 'taskId is required');
1376
+ const acc = await getAccessor(projectRoot);
1377
+ await acc.unclaimTask(taskId);
1378
+ return { success: true, data: { taskId } };
1379
+ }
1380
+ catch (err) {
1381
+ const message = err instanceof Error ? err.message : String(err);
1382
+ if (message.includes('not found'))
1383
+ return engineError('E_NOT_FOUND', message);
1384
+ return engineError('E_INTERNAL', message);
1385
+ }
1386
+ }
1387
+ //# sourceMappingURL=task-engine.js.map