agentplane 0.3.14 → 0.3.16

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 (425) hide show
  1. package/assets/policy/incidents.md +7 -0
  2. package/bin/agentplane.js +1 -1
  3. package/bin/framework-dev-contract.js +1 -0
  4. package/dist/.build-manifest.json +508 -323
  5. package/dist/backends/task-backend/load.d.ts.map +1 -1
  6. package/dist/backends/task-backend/load.js +32 -19
  7. package/dist/backends/task-backend/local-backend-doc.d.ts.map +1 -1
  8. package/dist/backends/task-backend/local-backend-doc.js +1 -1
  9. package/dist/backends/task-backend/redmine/backend-runtime.d.ts +147 -0
  10. package/dist/backends/task-backend/redmine/backend-runtime.d.ts.map +1 -0
  11. package/dist/backends/task-backend/redmine/backend-runtime.js +258 -0
  12. package/dist/backends/task-backend/redmine/backend-sync/context.d.ts +44 -0
  13. package/dist/backends/task-backend/redmine/backend-sync/context.d.ts.map +1 -0
  14. package/dist/backends/task-backend/redmine/backend-sync/context.js +8 -0
  15. package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts +6 -0
  16. package/dist/backends/task-backend/redmine/backend-sync/ids.d.ts.map +1 -0
  17. package/dist/backends/task-backend/redmine/backend-sync/ids.js +21 -0
  18. package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts +4 -0
  19. package/dist/backends/task-backend/redmine/backend-sync/migration.d.ts.map +1 -0
  20. package/dist/backends/task-backend/redmine/backend-sync/migration.js +87 -0
  21. package/dist/backends/task-backend/redmine/backend-sync/status.d.ts +10 -0
  22. package/dist/backends/task-backend/redmine/backend-sync/status.d.ts.map +1 -0
  23. package/dist/backends/task-backend/redmine/backend-sync/status.js +78 -0
  24. package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts +12 -0
  25. package/dist/backends/task-backend/redmine/backend-sync/sync.d.ts.map +1 -0
  26. package/dist/backends/task-backend/redmine/backend-sync/sync.js +82 -0
  27. package/dist/backends/task-backend/redmine/backend-sync/write.d.ts +5 -0
  28. package/dist/backends/task-backend/redmine/backend-sync/write.d.ts.map +1 -0
  29. package/dist/backends/task-backend/redmine/backend-sync/write.js +100 -0
  30. package/dist/backends/task-backend/redmine/backend-sync.d.ts +6 -66
  31. package/dist/backends/task-backend/redmine/backend-sync.d.ts.map +1 -1
  32. package/dist/backends/task-backend/redmine/backend-sync.js +5 -367
  33. package/dist/backends/task-backend/redmine-backend.d.ts +2 -33
  34. package/dist/backends/task-backend/redmine-backend.d.ts.map +1 -1
  35. package/dist/backends/task-backend/redmine-backend.js +26 -241
  36. package/dist/backends/task-backend/shared/errors.d.ts +12 -0
  37. package/dist/backends/task-backend/shared/errors.d.ts.map +1 -1
  38. package/dist/backends/task-backend/shared/errors.js +12 -0
  39. package/dist/cli/archive.d.ts.map +1 -1
  40. package/dist/cli/archive.js +3 -5
  41. package/dist/cli/error-map.d.ts +7 -1
  42. package/dist/cli/error-map.d.ts.map +1 -1
  43. package/dist/cli/error-map.js +231 -19
  44. package/dist/cli/exit-codes.d.ts +14 -2
  45. package/dist/cli/exit-codes.d.ts.map +1 -1
  46. package/dist/cli/exit-codes.js +24 -11
  47. package/dist/cli/output.d.ts +3 -0
  48. package/dist/cli/output.d.ts.map +1 -1
  49. package/dist/cli/output.js +25 -14
  50. package/dist/cli/prompts.d.ts.map +1 -1
  51. package/dist/cli/prompts.js +44 -0
  52. package/dist/cli/run-cli/command-catalog/core.d.ts.map +1 -1
  53. package/dist/cli/run-cli/command-catalog/core.js +34 -76
  54. package/dist/cli/run-cli/command-catalog/lifecycle.d.ts.map +1 -1
  55. package/dist/cli/run-cli/command-catalog/lifecycle.js +23 -26
  56. package/dist/cli/run-cli/command-catalog/project.d.ts.map +1 -1
  57. package/dist/cli/run-cli/command-catalog/project.js +39 -54
  58. package/dist/cli/run-cli/command-catalog/shared.d.ts +15 -3
  59. package/dist/cli/run-cli/command-catalog/shared.d.ts.map +1 -1
  60. package/dist/cli/run-cli/command-catalog/shared.js +19 -6
  61. package/dist/cli/run-cli/command-catalog/task.d.ts.map +1 -1
  62. package/dist/cli/run-cli/command-catalog/task.js +63 -57
  63. package/dist/cli/run-cli/command-loaders.d.ts +174 -0
  64. package/dist/cli/run-cli/command-loaders.d.ts.map +1 -0
  65. package/dist/cli/run-cli/command-loaders.js +128 -0
  66. package/dist/cli/run-cli/commands/init/model.d.ts +42 -0
  67. package/dist/cli/run-cli/commands/init/model.d.ts.map +1 -0
  68. package/dist/cli/run-cli/commands/init/orchestrate.d.ts +9 -0
  69. package/dist/cli/run-cli/commands/init/orchestrate.d.ts.map +1 -0
  70. package/dist/cli/run-cli/commands/init/orchestrate.js +321 -0
  71. package/dist/cli/run-cli/commands/init/parsers.d.ts +5 -0
  72. package/dist/cli/run-cli/commands/init/parsers.d.ts.map +1 -0
  73. package/dist/cli/run-cli/commands/init/parsers.js +36 -0
  74. package/dist/cli/run-cli/commands/init/presets.d.ts +15 -0
  75. package/dist/cli/run-cli/commands/init/presets.d.ts.map +1 -0
  76. package/dist/cli/run-cli/commands/init/presets.js +63 -0
  77. package/dist/cli/run-cli/commands/init/spec.d.ts +5 -0
  78. package/dist/cli/run-cli/commands/init/spec.d.ts.map +1 -0
  79. package/dist/cli/run-cli/commands/init/spec.js +212 -0
  80. package/dist/cli/run-cli/commands/init/write-config.d.ts +1 -0
  81. package/dist/cli/run-cli/commands/init/write-config.d.ts.map +1 -1
  82. package/dist/cli/run-cli/commands/init/write-config.js +1 -0
  83. package/dist/cli/run-cli/commands/init/write-gitignore.js +1 -1
  84. package/dist/cli/run-cli/commands/init.d.ts +1 -28
  85. package/dist/cli/run-cli/commands/init.d.ts.map +1 -1
  86. package/dist/cli/run-cli/commands/init.js +1 -596
  87. package/dist/cli/run-cli/update-warning.d.ts +1 -0
  88. package/dist/cli/run-cli/update-warning.d.ts.map +1 -1
  89. package/dist/cli/run-cli/update-warning.js +10 -2
  90. package/dist/cli/run-cli.d.ts.map +1 -1
  91. package/dist/cli/run-cli.js +1 -2
  92. package/dist/cli/spec/errors.d.ts +13 -1
  93. package/dist/cli/spec/errors.d.ts.map +1 -1
  94. package/dist/cli/spec/errors.js +14 -4
  95. package/dist/commands/backend.d.ts.map +1 -1
  96. package/dist/commands/backend.js +66 -118
  97. package/dist/commands/block.spec.js +1 -1
  98. package/dist/commands/branch/work-start.js +1 -1
  99. package/dist/commands/commit.spec.js +1 -1
  100. package/dist/commands/doctor/branch-pr.js +1 -1
  101. package/dist/commands/doctor/fixes.js +1 -1
  102. package/dist/commands/doctor/runtime.d.ts.map +1 -1
  103. package/dist/commands/doctor/runtime.js +2 -2
  104. package/dist/commands/doctor/workspace.js +1 -1
  105. package/dist/commands/finish.spec.js +1 -1
  106. package/dist/commands/guard/commit.command.js +1 -1
  107. package/dist/commands/guard/impl/clean.d.ts +6 -0
  108. package/dist/commands/guard/impl/clean.d.ts.map +1 -0
  109. package/dist/commands/guard/impl/clean.js +29 -0
  110. package/dist/commands/guard/impl/close-dirt.d.ts +6 -0
  111. package/dist/commands/guard/impl/close-dirt.d.ts.map +1 -0
  112. package/dist/commands/guard/impl/close-dirt.js +56 -0
  113. package/dist/commands/guard/impl/commands.d.ts +4 -36
  114. package/dist/commands/guard/impl/commands.d.ts.map +1 -1
  115. package/dist/commands/guard/impl/commands.js +4 -549
  116. package/dist/commands/guard/impl/comment-commit.js +1 -1
  117. package/dist/commands/guard/impl/commit-diagnostics.d.ts +4 -0
  118. package/dist/commands/guard/impl/commit-diagnostics.d.ts.map +1 -0
  119. package/dist/commands/guard/impl/commit-diagnostics.js +150 -0
  120. package/dist/commands/guard/impl/commit.d.ts +25 -0
  121. package/dist/commands/guard/impl/commit.d.ts.map +1 -0
  122. package/dist/commands/guard/impl/commit.js +366 -0
  123. package/dist/commands/guard/impl/guard-commit.d.ts +3 -0
  124. package/dist/commands/guard/impl/guard-commit.d.ts.map +1 -0
  125. package/dist/commands/guard/impl/guard-commit.js +21 -0
  126. package/dist/commands/guard/impl/policy.d.ts +1 -0
  127. package/dist/commands/guard/impl/policy.d.ts.map +1 -1
  128. package/dist/commands/guard/impl/policy.js +9 -2
  129. package/dist/commands/guard/impl/suggest.d.ts +6 -0
  130. package/dist/commands/guard/impl/suggest.d.ts.map +1 -0
  131. package/dist/commands/guard/impl/suggest.js +33 -0
  132. package/dist/commands/hooks/index.d.ts +3 -0
  133. package/dist/commands/hooks/index.d.ts.map +1 -1
  134. package/dist/commands/hooks/index.js +27 -10
  135. package/dist/commands/pr/integrate/cmd.js +1 -1
  136. package/dist/commands/pr/integrate/internal/prepare.js +1 -1
  137. package/dist/commands/pr/internal/auto-commit.d.ts.map +1 -1
  138. package/dist/commands/pr/internal/auto-commit.js +2 -5
  139. package/dist/commands/pr/internal/gh-api.d.ts.map +1 -1
  140. package/dist/commands/pr/internal/gh-api.js +15 -8
  141. package/dist/commands/pr/internal/sync-branch.d.ts +0 -1
  142. package/dist/commands/pr/internal/sync-branch.d.ts.map +1 -1
  143. package/dist/commands/pr/internal/sync-branch.js +2 -5
  144. package/dist/commands/pr/internal/sync.d.ts.map +1 -1
  145. package/dist/commands/pr/internal/sync.js +30 -0
  146. package/dist/commands/pr/open.d.ts.map +1 -1
  147. package/dist/commands/pr/open.js +98 -8
  148. package/dist/commands/recipes/impl/resolver.js +1 -1
  149. package/dist/commands/recipes/impl/version.js +1 -1
  150. package/dist/commands/release/apply.command.js +1 -1
  151. package/dist/commands/release/apply.mutation.d.ts +1 -0
  152. package/dist/commands/release/apply.mutation.d.ts.map +1 -1
  153. package/dist/commands/release/apply.mutation.js +5 -1
  154. package/dist/commands/release/apply.pipeline/finalize.d.ts +21 -0
  155. package/dist/commands/release/apply.pipeline/finalize.d.ts.map +1 -0
  156. package/dist/commands/release/apply.pipeline/finalize.js +80 -0
  157. package/dist/commands/release/apply.pipeline/mutation.d.ts +18 -0
  158. package/dist/commands/release/apply.pipeline/mutation.d.ts.map +1 -0
  159. package/dist/commands/release/apply.pipeline/mutation.js +78 -0
  160. package/dist/commands/release/apply.pipeline/preflight.d.ts +25 -0
  161. package/dist/commands/release/apply.pipeline/preflight.d.ts.map +1 -0
  162. package/dist/commands/release/apply.pipeline/preflight.js +69 -0
  163. package/dist/commands/release/apply.pipeline/shared.d.ts +2 -0
  164. package/dist/commands/release/apply.pipeline/shared.d.ts.map +1 -0
  165. package/dist/commands/release/apply.pipeline/shared.js +5 -0
  166. package/dist/commands/release/apply.pipeline/state.d.ts +25 -0
  167. package/dist/commands/release/apply.pipeline/state.d.ts.map +1 -0
  168. package/dist/commands/release/apply.pipeline/state.js +129 -0
  169. package/dist/commands/release/apply.pipeline.d.ts +1 -1
  170. package/dist/commands/release/apply.pipeline.d.ts.map +1 -1
  171. package/dist/commands/release/apply.pipeline.js +4 -347
  172. package/dist/commands/release/apply.preflight.d.ts +9 -6
  173. package/dist/commands/release/apply.preflight.d.ts.map +1 -1
  174. package/dist/commands/release/apply.preflight.js +71 -51
  175. package/dist/commands/runtime.command.d.ts +2 -2
  176. package/dist/commands/runtime.command.d.ts.map +1 -1
  177. package/dist/commands/runtime.command.js +2 -2
  178. package/dist/commands/scenario/impl/commands.d.ts.map +1 -1
  179. package/dist/commands/scenario/impl/commands.js +52 -39
  180. package/dist/commands/scenario/impl/report.d.ts.map +1 -1
  181. package/dist/commands/scenario/impl/report.js +4 -7
  182. package/dist/commands/shared/allow-prefix-policy.d.ts.map +1 -0
  183. package/dist/{shared → commands/shared}/allow-prefix-policy.js +1 -1
  184. package/dist/commands/shared/comment-format.d.ts.map +1 -0
  185. package/dist/commands/shared/diagnostics.d.ts.map +1 -0
  186. package/dist/commands/shared/git-context.d.ts +1 -27
  187. package/dist/commands/shared/git-context.d.ts.map +1 -1
  188. package/dist/commands/shared/git-context.js +1 -156
  189. package/dist/commands/shared/git-diff.d.ts +1 -10
  190. package/dist/commands/shared/git-diff.d.ts.map +1 -1
  191. package/dist/commands/shared/git-diff.js +1 -49
  192. package/dist/commands/shared/git-ops.d.ts +1 -14
  193. package/dist/commands/shared/git-ops.d.ts.map +1 -1
  194. package/dist/commands/shared/git-ops.js +20 -150
  195. package/dist/commands/shared/git-worktree.d.ts +1 -9
  196. package/dist/commands/shared/git-worktree.d.ts.map +1 -1
  197. package/dist/commands/shared/git-worktree.js +1 -68
  198. package/dist/commands/shared/git.d.ts +1 -3
  199. package/dist/commands/shared/git.d.ts.map +1 -1
  200. package/dist/commands/shared/git.js +1 -14
  201. package/dist/commands/shared/policy-deny.d.ts +1 -1
  202. package/dist/commands/shared/reconcile-check.js +1 -1
  203. package/dist/commands/shared/task-backend.d.ts.map +1 -1
  204. package/dist/commands/shared/task-backend.js +24 -2
  205. package/dist/commands/shared/task-store/intents.d.ts.map +1 -1
  206. package/dist/commands/shared/task-store/intents.js +1 -1
  207. package/dist/commands/start.spec.js +1 -1
  208. package/dist/commands/task/close-tail-state.d.ts +7 -0
  209. package/dist/commands/task/close-tail-state.d.ts.map +1 -0
  210. package/dist/commands/task/close-tail-state.js +18 -0
  211. package/dist/commands/task/derive.js +1 -1
  212. package/dist/commands/task/finish-close.d.ts +22 -0
  213. package/dist/commands/task/finish-close.d.ts.map +1 -0
  214. package/dist/commands/task/finish-close.js +119 -0
  215. package/dist/commands/task/finish-command.d.ts +3 -0
  216. package/dist/commands/task/finish-command.d.ts.map +1 -0
  217. package/dist/commands/task/finish-command.js +56 -0
  218. package/dist/commands/task/finish-execute.d.ts +8 -0
  219. package/dist/commands/task/finish-execute.d.ts.map +1 -0
  220. package/dist/commands/task/finish-execute.js +272 -0
  221. package/dist/commands/task/finish-findings.d.ts +20 -0
  222. package/dist/commands/task/finish-findings.d.ts.map +1 -0
  223. package/dist/commands/task/finish-findings.js +27 -0
  224. package/dist/commands/task/finish-plan.d.ts +7 -0
  225. package/dist/commands/task/finish-plan.d.ts.map +1 -0
  226. package/dist/commands/task/finish-plan.js +157 -0
  227. package/dist/commands/task/finish-types.d.ts +69 -0
  228. package/dist/commands/task/finish-types.d.ts.map +1 -0
  229. package/dist/commands/task/finish.d.ts +1 -42
  230. package/dist/commands/task/finish.d.ts.map +1 -1
  231. package/dist/commands/task/finish.js +1 -527
  232. package/dist/commands/task/hosted-close-pr.command.d.ts.map +1 -1
  233. package/dist/commands/task/hosted-close-pr.command.js +29 -4
  234. package/dist/commands/task/hosted-close.command.d.ts.map +1 -1
  235. package/dist/commands/task/hosted-close.command.js +23 -2
  236. package/dist/commands/task/hosted-merge-sync/builders.d.ts +35 -0
  237. package/dist/commands/task/hosted-merge-sync/builders.d.ts.map +1 -0
  238. package/dist/commands/task/hosted-merge-sync/builders.js +148 -0
  239. package/dist/commands/task/hosted-merge-sync/github.d.ts +10 -0
  240. package/dist/commands/task/hosted-merge-sync/github.d.ts.map +1 -0
  241. package/dist/commands/task/hosted-merge-sync/github.js +113 -0
  242. package/dist/commands/task/hosted-merge-sync/local-branch.d.ts +12 -0
  243. package/dist/commands/task/hosted-merge-sync/local-branch.d.ts.map +1 -0
  244. package/dist/commands/task/hosted-merge-sync/local-branch.js +143 -0
  245. package/dist/commands/task/hosted-merge-sync/model.d.ts +47 -0
  246. package/dist/commands/task/hosted-merge-sync/model.d.ts.map +1 -0
  247. package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts +12 -0
  248. package/dist/commands/task/hosted-merge-sync/pr-meta.d.ts.map +1 -0
  249. package/dist/commands/task/hosted-merge-sync/pr-meta.js +26 -0
  250. package/dist/commands/task/hosted-merge-sync.d.ts +5 -63
  251. package/dist/commands/task/hosted-merge-sync.d.ts.map +1 -1
  252. package/dist/commands/task/hosted-merge-sync.js +10 -444
  253. package/dist/commands/task/new.js +1 -1
  254. package/dist/commands/task/set-status.command.js +1 -1
  255. package/dist/commands/task/shared/direct-work-lock.d.ts.map +1 -0
  256. package/dist/commands/task/shared/git-log.d.ts.map +1 -0
  257. package/dist/commands/task/shared/transitions.d.ts +1 -1
  258. package/dist/commands/task/shared/transitions.d.ts.map +1 -1
  259. package/dist/commands/task/shared/transitions.js +4 -6
  260. package/dist/commands/upgrade/apply.js +1 -1
  261. package/dist/commands/workflow-playbook.command.d.ts.map +1 -1
  262. package/dist/commands/workflow-playbook.command.js +8 -7
  263. package/dist/harness/hooks-lifecycle.d.ts.map +1 -1
  264. package/dist/harness/hooks-lifecycle.js +11 -7
  265. package/dist/meta/release.d.ts.map +1 -1
  266. package/dist/meta/release.js +8 -4
  267. package/dist/policy/engine.d.ts +1 -1
  268. package/dist/policy/evaluate.d.ts +1 -1
  269. package/dist/policy/{types.d.ts → model.d.ts} +1 -1
  270. package/dist/policy/{types.d.ts.map → model.d.ts.map} +1 -1
  271. package/dist/policy/result.d.ts +1 -1
  272. package/dist/policy/rules/allowlist.d.ts +1 -1
  273. package/dist/policy/rules/branch-pr-base.d.ts +1 -1
  274. package/dist/policy/rules/clean-tree.d.ts +1 -1
  275. package/dist/policy/rules/commit-subject.d.ts +1 -1
  276. package/dist/policy/rules/protected-paths.d.ts +1 -1
  277. package/dist/runner/adapters/base.d.ts +42 -0
  278. package/dist/runner/adapters/base.d.ts.map +1 -0
  279. package/dist/runner/adapters/base.js +107 -0
  280. package/dist/runner/adapters/codex-preparation.d.ts +7 -0
  281. package/dist/runner/adapters/codex-preparation.d.ts.map +1 -0
  282. package/dist/runner/adapters/codex-preparation.js +86 -0
  283. package/dist/runner/adapters/codex.d.ts.map +1 -1
  284. package/dist/runner/adapters/codex.js +30 -175
  285. package/dist/runner/adapters/custom-preparation.d.ts +9 -0
  286. package/dist/runner/adapters/custom-preparation.d.ts.map +1 -0
  287. package/dist/runner/adapters/custom-preparation.js +191 -0
  288. package/dist/runner/adapters/custom.d.ts.map +1 -1
  289. package/dist/runner/adapters/custom.js +26 -279
  290. package/dist/runner/process-supervision/run.d.ts +30 -0
  291. package/dist/runner/process-supervision/run.d.ts.map +1 -0
  292. package/dist/runner/process-supervision/run.js +349 -0
  293. package/dist/runner/process-supervision/signals.d.ts +16 -0
  294. package/dist/runner/process-supervision/signals.d.ts.map +1 -0
  295. package/dist/runner/process-supervision/signals.js +85 -0
  296. package/dist/runner/process-supervision/state.d.ts +10 -0
  297. package/dist/runner/process-supervision/state.d.ts.map +1 -0
  298. package/dist/runner/process-supervision/state.js +42 -0
  299. package/dist/runner/process-supervision/streams.d.ts +6 -0
  300. package/dist/runner/process-supervision/streams.d.ts.map +1 -0
  301. package/dist/runner/process-supervision/streams.js +23 -0
  302. package/dist/runner/process-supervision.d.ts +5 -47
  303. package/dist/runner/process-supervision.d.ts.map +1 -1
  304. package/dist/runner/process-supervision.js +3 -490
  305. package/dist/runner/usecases/scenario-materialize-task.js +1 -1
  306. package/dist/runtime/approvals/index.d.ts +1 -1
  307. package/dist/runtime/approvals/{types.d.ts → model.d.ts} +1 -1
  308. package/dist/runtime/approvals/{types.d.ts.map → model.d.ts.map} +1 -1
  309. package/dist/runtime/approvals/runtime.d.ts +1 -1
  310. package/dist/runtime/behavior/index.d.ts +1 -1
  311. package/dist/runtime/behavior/{types.d.ts → model.d.ts} +1 -1
  312. package/dist/runtime/behavior/{types.d.ts.map → model.d.ts.map} +1 -1
  313. package/dist/runtime/behavior/resolve.d.ts +1 -1
  314. package/dist/runtime/capabilities/backend.d.ts +1 -1
  315. package/dist/runtime/capabilities/index.d.ts +1 -1
  316. package/dist/runtime/capabilities/{types.d.ts → model.d.ts} +1 -1
  317. package/dist/runtime/capabilities/{types.d.ts.map → model.d.ts.map} +1 -1
  318. package/dist/runtime/capabilities/model.js +1 -0
  319. package/dist/runtime/capabilities/recipe.d.ts +1 -1
  320. package/dist/runtime/capabilities/registry.d.ts +1 -1
  321. package/dist/runtime/capabilities/runner.d.ts +1 -1
  322. package/dist/runtime/execution-context.d.ts.map +1 -1
  323. package/dist/runtime/execution-context.js +16 -0
  324. package/dist/runtime/execution-profile/index.d.ts +1 -1
  325. package/dist/runtime/execution-profile/{types.d.ts → model.d.ts} +1 -1
  326. package/dist/runtime/execution-profile/{types.d.ts.map → model.d.ts.map} +1 -1
  327. package/dist/runtime/execution-profile/model.js +1 -0
  328. package/dist/runtime/execution-profile/resolve.d.ts +1 -1
  329. package/dist/runtime/explain/index.d.ts +1 -1
  330. package/dist/runtime/explain/{types.d.ts → model.d.ts} +1 -1
  331. package/dist/runtime/explain/{types.d.ts.map → model.d.ts.map} +1 -1
  332. package/dist/runtime/explain/model.js +1 -0
  333. package/dist/runtime/explain/resolve.d.ts +1 -1
  334. package/dist/runtime/protocol/index.d.ts +1 -1
  335. package/dist/runtime/protocol/index.js +1 -1
  336. package/dist/runtime/protocol/{types.d.ts → model.d.ts} +1 -1
  337. package/dist/runtime/protocol/{types.d.ts.map → model.d.ts.map} +1 -1
  338. package/dist/runtime/protocol/resolve.d.ts +1 -1
  339. package/dist/runtime/protocol/resolve.js +1 -1
  340. package/dist/runtime/shared/repo-cli-version.d.ts.map +1 -0
  341. package/dist/{shared → runtime/shared}/repo-cli-version.js +1 -1
  342. package/dist/runtime/shared/runtime-artifacts.d.ts.map +1 -0
  343. package/dist/{shared → runtime/shared}/runtime-source.d.ts +1 -1
  344. package/dist/runtime/shared/runtime-source.d.ts.map +1 -0
  345. package/dist/{shared → runtime/shared}/runtime-source.js +1 -1
  346. package/dist/runtime/shared/version-compare.d.ts.map +1 -0
  347. package/dist/runtime/task-intake/resolve.js +1 -1
  348. package/dist/shared/errors.d.ts +52 -2
  349. package/dist/shared/errors.d.ts.map +1 -1
  350. package/dist/shared/errors.js +66 -4
  351. package/dist/shared/trace-events.d.ts +13 -0
  352. package/dist/shared/trace-events.d.ts.map +1 -0
  353. package/dist/shared/trace-events.js +17 -0
  354. package/dist/{shared/task-doc-conflicts.d.ts → task-doc/conflicts.d.ts} +1 -1
  355. package/dist/task-doc/conflicts.d.ts.map +1 -0
  356. package/dist/{shared/task-doc-conflicts.js → task-doc/conflicts.js} +1 -1
  357. package/dist/{shared/task-doc-state.d.ts → task-doc/state.d.ts} +1 -1
  358. package/dist/task-doc/state.d.ts.map +1 -0
  359. package/package.json +8 -8
  360. package/dist/cli/run-cli/error-guidance.d.ts +0 -9
  361. package/dist/cli/run-cli/error-guidance.d.ts.map +0 -1
  362. package/dist/cli/run-cli/error-guidance.js +0 -210
  363. package/dist/cli/run-cli.test-helpers.d.ts +0 -2
  364. package/dist/cli/run-cli.test-helpers.d.ts.map +0 -1
  365. package/dist/cli/run-cli.test-helpers.js +0 -1
  366. package/dist/commands/recipes.test-helpers.d.ts +0 -202
  367. package/dist/commands/recipes.test-helpers.d.ts.map +0 -1
  368. package/dist/commands/recipes.test-helpers.js +0 -483
  369. package/dist/commands/release.test-helpers.d.ts +0 -38
  370. package/dist/commands/release.test-helpers.d.ts.map +0 -1
  371. package/dist/commands/release.test-helpers.js +0 -55
  372. package/dist/commands/task.test-helpers.d.ts +0 -13
  373. package/dist/commands/task.test-helpers.d.ts.map +0 -1
  374. package/dist/commands/task.test-helpers.js +0 -65
  375. package/dist/runner/test-helpers.d.ts +0 -30
  376. package/dist/runner/test-helpers.d.ts.map +0 -1
  377. package/dist/runner/test-helpers.js +0 -97
  378. package/dist/shared/agent-emoji.d.ts +0 -5
  379. package/dist/shared/agent-emoji.d.ts.map +0 -1
  380. package/dist/shared/agent-emoji.js +0 -51
  381. package/dist/shared/allow-prefix-policy.d.ts.map +0 -1
  382. package/dist/shared/comment-format.d.ts.map +0 -1
  383. package/dist/shared/diagnostics.d.ts.map +0 -1
  384. package/dist/shared/direct-work-lock.d.ts.map +0 -1
  385. package/dist/shared/git-log.d.ts.map +0 -1
  386. package/dist/shared/repo-cli-version.d.ts.map +0 -1
  387. package/dist/shared/runtime-artifacts.d.ts.map +0 -1
  388. package/dist/shared/runtime-source.d.ts.map +0 -1
  389. package/dist/shared/task-doc-conflicts.d.ts.map +0 -1
  390. package/dist/shared/task-doc-state.d.ts.map +0 -1
  391. package/dist/shared/version-compare.d.ts.map +0 -1
  392. package/dist/testing/cli-harness/recipe-archives.d.ts +0 -28
  393. package/dist/testing/cli-harness/recipe-archives.d.ts.map +0 -1
  394. package/dist/testing/cli-harness/recipe-archives.js +0 -374
  395. package/dist/testing/cli-harness/stdio.d.ts +0 -26
  396. package/dist/testing/cli-harness/stdio.d.ts.map +0 -1
  397. package/dist/testing/cli-harness/stdio.js +0 -84
  398. package/dist/testing/cli-harness.d.ts +0 -25
  399. package/dist/testing/cli-harness.d.ts.map +0 -1
  400. package/dist/testing/cli-harness.js +0 -313
  401. package/dist/testing/index.d.ts +0 -2
  402. package/dist/testing/index.d.ts.map +0 -1
  403. package/dist/testing/index.js +0 -1
  404. /package/dist/{policy/types.js → cli/run-cli/commands/init/model.js} +0 -0
  405. /package/dist/{shared → commands/shared}/allow-prefix-policy.d.ts +0 -0
  406. /package/dist/{shared → commands/shared}/comment-format.d.ts +0 -0
  407. /package/dist/{shared → commands/shared}/comment-format.js +0 -0
  408. /package/dist/{shared → commands/shared}/diagnostics.d.ts +0 -0
  409. /package/dist/{shared → commands/shared}/diagnostics.js +0 -0
  410. /package/dist/{runtime/approvals/types.js → commands/task/finish-types.js} +0 -0
  411. /package/dist/{runtime/behavior/types.js → commands/task/hosted-merge-sync/model.js} +0 -0
  412. /package/dist/{shared → commands/task/shared}/direct-work-lock.d.ts +0 -0
  413. /package/dist/{shared → commands/task/shared}/direct-work-lock.js +0 -0
  414. /package/dist/{shared → commands/task/shared}/git-log.d.ts +0 -0
  415. /package/dist/{shared → commands/task/shared}/git-log.js +0 -0
  416. /package/dist/{runtime/capabilities/types.js → policy/model.js} +0 -0
  417. /package/dist/runtime/{execution-profile/types.js → approvals/model.js} +0 -0
  418. /package/dist/runtime/{explain/types.js → behavior/model.js} +0 -0
  419. /package/dist/runtime/protocol/{types.js → model.js} +0 -0
  420. /package/dist/{shared → runtime/shared}/repo-cli-version.d.ts +0 -0
  421. /package/dist/{shared → runtime/shared}/runtime-artifacts.d.ts +0 -0
  422. /package/dist/{shared → runtime/shared}/runtime-artifacts.js +0 -0
  423. /package/dist/{shared → runtime/shared}/version-compare.d.ts +0 -0
  424. /package/dist/{shared → runtime/shared}/version-compare.js +0 -0
  425. /package/dist/{shared/task-doc-state.js → task-doc/state.js} +0 -0
@@ -0,0 +1,87 @@
1
+ import { taskDocToSectionMap } from "@agentplaneorg/core";
2
+ import { BackendError, redmineConfigMissingEnvMessage, redmineIssueIdMissingMessage, sleep, toStringSafe, } from "../../shared.js";
3
+ import { buildRedmineCanonicalStateWithOptions, parseRedmineCanonicalState } from "../state.js";
4
+ import { revisionNumber } from "./context.js";
5
+ export async function migrateRedmineCanonicalState(context) {
6
+ if (!context.customFields.canonical_state) {
7
+ throw new BackendError(redmineConfigMissingEnvMessage("AGENTPLANE_REDMINE_CUSTOM_FIELDS_CANONICAL_STATE"), "E_BACKEND");
8
+ }
9
+ const tasks = await context.listTasksRemote();
10
+ const result = {
11
+ scanned: tasks.length,
12
+ migrated: [],
13
+ skippedStructured: [],
14
+ skippedNoDoc: [],
15
+ failed: [],
16
+ };
17
+ for (const [index, task] of tasks.entries()) {
18
+ const taskId = toStringSafe(task.id).trim();
19
+ if (!taskId)
20
+ continue;
21
+ const issue = context.issueCache.get(taskId);
22
+ if (!issue) {
23
+ result.failed.push({
24
+ taskId,
25
+ reason: "Redmine issue payload was not cached during remote list refresh",
26
+ });
27
+ continue;
28
+ }
29
+ const currentState = parseRedmineCanonicalState(context.customFieldValue(issue, context.customFields.canonical_state));
30
+ if (currentState) {
31
+ result.skippedStructured.push(taskId);
32
+ continue;
33
+ }
34
+ const sections = task.sections && Object.keys(task.sections).length > 0
35
+ ? task.sections
36
+ : task.doc
37
+ ? taskDocToSectionMap(task.doc)
38
+ : undefined;
39
+ if (!sections || Object.keys(sections).length === 0) {
40
+ result.skippedNoDoc.push(taskId);
41
+ continue;
42
+ }
43
+ const issueIdText = toStringSafe(issue.id);
44
+ if (!issueIdText) {
45
+ result.failed.push({ taskId, reason: redmineIssueIdMissingMessage() });
46
+ continue;
47
+ }
48
+ const nextRevision = Math.max(revisionNumber(task.revision), 0, 1);
49
+ const nextCanonicalState = buildRedmineCanonicalStateWithOptions({
50
+ ...task,
51
+ sections,
52
+ revision: nextRevision,
53
+ }, { base: currentState, revision: nextRevision });
54
+ if (!nextCanonicalState) {
55
+ result.skippedNoDoc.push(taskId);
56
+ continue;
57
+ }
58
+ const customFields = [];
59
+ context.appendCustomField(customFields, "canonical_state", nextCanonicalState);
60
+ try {
61
+ await context.requestJson("PUT", `issues/${issueIdText}.json`, {
62
+ issue: { custom_fields: customFields },
63
+ });
64
+ context.setIssueCustomFieldValue(issue, context.customFields.canonical_state, nextCanonicalState);
65
+ context.issueCache.set(taskId, issue);
66
+ await context.cacheTask({
67
+ ...task,
68
+ sections,
69
+ revision: nextRevision,
70
+ dirty: false,
71
+ }, false);
72
+ result.migrated.push(taskId);
73
+ }
74
+ catch (err) {
75
+ result.failed.push({
76
+ taskId,
77
+ reason: err instanceof Error ? err.message : "Unknown Redmine canonical_state migration failure",
78
+ });
79
+ }
80
+ if (context.batchPauseMs > 0 &&
81
+ context.batchSize > 0 &&
82
+ (index + 1) % context.batchSize === 0) {
83
+ await sleep(context.batchPauseMs);
84
+ }
85
+ }
86
+ return result;
87
+ }
@@ -0,0 +1,10 @@
1
+ import type { RedmineSyncContext } from "./context.js";
2
+ export declare function inferRedmineStatusIdForTaskStatus(context: RedmineSyncContext, statusRaw: unknown): Promise<number | null>;
3
+ export declare function loadRedmineInferredStatusByTaskStatus(context: RedmineSyncContext): Promise<Map<string, number>>;
4
+ export declare function selectRedmineInferredStatus(statuses: {
5
+ id: number;
6
+ name: string;
7
+ isClosed: boolean;
8
+ isDefault: boolean;
9
+ }[], target: "TODO" | "DOING" | "DONE"): number | null;
10
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../../src/backends/task-backend/redmine/backend-sync/status.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CASxB;AAED,wBAAsB,qCAAqC,CACzD,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAuC9B;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,EAAE,EAC/E,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAChC,MAAM,GAAG,IAAI,CA6Bf"}
@@ -0,0 +1,78 @@
1
+ import { toStringSafe } from "../../shared.js";
2
+ export async function inferRedmineStatusIdForTaskStatus(context, statusRaw) {
3
+ const status = toStringSafe(statusRaw).trim().toUpperCase();
4
+ if (!status)
5
+ return null;
6
+ const explicit = context.statusMap?.[status];
7
+ if (typeof explicit === "number" && Number.isFinite(explicit))
8
+ return explicit;
9
+ const inferred = await loadRedmineInferredStatusByTaskStatus(context);
10
+ return inferred.get(status) ?? null;
11
+ }
12
+ export async function loadRedmineInferredStatusByTaskStatus(context) {
13
+ if (context.inferredStatusByTaskStatus)
14
+ return context.inferredStatusByTaskStatus;
15
+ const map = new Map();
16
+ context.setInferredStatusByTaskStatus(map);
17
+ try {
18
+ const payload = await context.requestJson("GET", "issue_statuses.json");
19
+ const statuses = Array.isArray(payload.issue_statuses) ? payload.issue_statuses : [];
20
+ const parsed = [];
21
+ for (const item of statuses) {
22
+ if (!item || typeof item !== "object" || Array.isArray(item))
23
+ continue;
24
+ const status = item;
25
+ const id = typeof status.id === "number" ? status.id : null;
26
+ if (!id || !Number.isFinite(id))
27
+ continue;
28
+ parsed.push({
29
+ id,
30
+ name: toStringSafe(status.name).trim().toLowerCase(),
31
+ isClosed: status.is_closed === true,
32
+ isDefault: status.is_default === true,
33
+ });
34
+ }
35
+ const done = selectRedmineInferredStatus(parsed, "DONE");
36
+ const doing = selectRedmineInferredStatus(parsed, "DOING");
37
+ const todo = selectRedmineInferredStatus(parsed, "TODO");
38
+ if (done !== null)
39
+ map.set("DONE", done);
40
+ if (doing !== null)
41
+ map.set("DOING", doing);
42
+ if (todo !== null)
43
+ map.set("TODO", todo);
44
+ }
45
+ catch {
46
+ // Best effort: keep previous behavior when status discovery is unavailable.
47
+ }
48
+ return map;
49
+ }
50
+ export function selectRedmineInferredStatus(statuses, target) {
51
+ if (statuses.length === 0)
52
+ return null;
53
+ if (target === "DOING") {
54
+ const byId = statuses.find((item) => item.id === 2);
55
+ if (byId)
56
+ return byId.id;
57
+ const byName = statuses.find((item) => item.name.includes("progress") || item.name.includes("doing"));
58
+ return byName?.id ?? null;
59
+ }
60
+ if (target === "DONE") {
61
+ const closed = statuses.find((item) => item.isClosed);
62
+ if (closed)
63
+ return closed.id;
64
+ const byId = statuses.find((item) => item.id === 5 || item.id === 3 || item.id === 6);
65
+ if (byId)
66
+ return byId.id;
67
+ const byName = statuses.find((item) => item.name.includes("done") ||
68
+ item.name.includes("closed") ||
69
+ item.name.includes("resolved") ||
70
+ item.name.includes("complete"));
71
+ return byName?.id ?? null;
72
+ }
73
+ const byDefault = statuses.find((item) => item.isDefault);
74
+ if (byDefault)
75
+ return byDefault.id;
76
+ const byId = statuses.find((item) => item.id === 1);
77
+ return byId?.id ?? statuses[0]?.id ?? null;
78
+ }
@@ -0,0 +1,12 @@
1
+ import { type TaskData } from "../../shared.js";
2
+ import type { RedmineSyncContext } from "./context.js";
3
+ export declare function syncRedmine(context: RedmineSyncContext, opts: {
4
+ direction: "push" | "pull";
5
+ conflict: "diff" | "prefer-local" | "prefer-remote" | "fail";
6
+ quiet: boolean;
7
+ confirm: boolean;
8
+ }): Promise<void>;
9
+ export declare function syncPushRedmine(context: RedmineSyncContext, quiet: boolean, confirm: boolean): Promise<void>;
10
+ export declare function syncPullRedmine(context: RedmineSyncContext, conflict: "diff" | "prefer-local" | "prefer-remote" | "fail", quiet: boolean): Promise<void>;
11
+ export declare function handleRedmineConflict(context: RedmineSyncContext, taskId: string, localTask: TaskData, remoteTask: TaskData, conflict: "diff" | "prefer-local" | "prefer-remote" | "fail"): Promise<void>;
12
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../../../../src/backends/task-backend/redmine/backend-sync/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEvD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE;IACJ,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,eAAe,GAAG,MAAM,CAAC;IAC7D,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB,GACA,OAAO,CAAC,IAAI,CAAC,CAUf;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAkBf;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,eAAe,GAAG,MAAM,EAC5D,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,kBAAkB,EAC3B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,QAAQ,EACnB,UAAU,EAAE,QAAQ,EACpB,QAAQ,EAAE,MAAM,GAAG,cAAc,GAAG,eAAe,GAAG,MAAM,GAC3D,OAAO,CAAC,IAAI,CAAC,CAcf"}
@@ -0,0 +1,82 @@
1
+ import { BackendError, toStringSafe } from "../../shared.js";
2
+ export async function syncRedmine(context, opts) {
3
+ if (opts.direction === "push") {
4
+ await syncPushRedmine(context, opts.quiet, opts.confirm);
5
+ return;
6
+ }
7
+ if (opts.direction === "pull") {
8
+ await syncPullRedmine(context, opts.conflict, opts.quiet);
9
+ return;
10
+ }
11
+ throw new BackendError("Invalid sync direction (expected push|pull)", "E_BACKEND");
12
+ }
13
+ export async function syncPushRedmine(context, quiet, confirm) {
14
+ if (!context.cache) {
15
+ throw new BackendError("Redmine cache is disabled; sync push is unavailable", "E_BACKEND");
16
+ }
17
+ const tasks = await context.cache.listTasks();
18
+ const dirty = tasks.filter((task) => task.dirty);
19
+ if (dirty.length === 0) {
20
+ if (!quiet)
21
+ process.stdout.write("ℹ️ no local task changes to push\n");
22
+ return;
23
+ }
24
+ if (!confirm) {
25
+ for (const task of dirty) {
26
+ process.stdout.write(`- pending push: ${task.id}\n`);
27
+ }
28
+ throw new BackendError("Refusing to push without --yes (preview above)", "E_BACKEND");
29
+ }
30
+ await context.writeTasks(dirty);
31
+ if (!quiet)
32
+ process.stdout.write(`✅ pushed ${dirty.length} task(s) (dirty)\n`);
33
+ }
34
+ export async function syncPullRedmine(context, conflict, quiet) {
35
+ if (!context.cache) {
36
+ throw new BackendError("Redmine cache is disabled; sync pull is unavailable", "E_BACKEND");
37
+ }
38
+ const remoteTasks = await context.listTasksRemote();
39
+ const remoteById = new Map();
40
+ for (const task of remoteTasks) {
41
+ const taskId = toStringSafe(task.id);
42
+ if (taskId)
43
+ remoteById.set(taskId, task);
44
+ }
45
+ const localTasks = await context.cache.listTasks();
46
+ const localById = new Map();
47
+ for (const task of localTasks) {
48
+ const taskId = toStringSafe(task.id);
49
+ if (taskId)
50
+ localById.set(taskId, task);
51
+ }
52
+ for (const [taskId, remoteTask] of remoteById.entries()) {
53
+ const localTask = localById.get(taskId);
54
+ if (localTask?.dirty) {
55
+ if (context.tasksDiffer(localTask, remoteTask)) {
56
+ await handleRedmineConflict(context, taskId, localTask, remoteTask, conflict);
57
+ continue;
58
+ }
59
+ localTask.dirty = false;
60
+ await context.cacheTask(localTask, false);
61
+ continue;
62
+ }
63
+ await context.cacheTask(remoteTask, false);
64
+ }
65
+ if (!quiet)
66
+ process.stdout.write(`✅ pulled ${remoteById.size} task(s) (remote)\n`);
67
+ }
68
+ export async function handleRedmineConflict(context, taskId, localTask, remoteTask, conflict) {
69
+ if (conflict === "prefer-local") {
70
+ await context.writeTask(localTask);
71
+ return;
72
+ }
73
+ if (conflict === "prefer-remote") {
74
+ await context.cacheTask(remoteTask, false);
75
+ return;
76
+ }
77
+ if (conflict === "diff") {
78
+ process.stdout.write(`${context.diffTasks(localTask, remoteTask)}\n`);
79
+ throw new BackendError(`Conflict detected for ${taskId}`, "E_BACKEND");
80
+ }
81
+ throw new BackendError(`Conflict detected for ${taskId}`, "E_BACKEND");
82
+ }
@@ -0,0 +1,5 @@
1
+ import { type TaskData, type TaskWriteOptions } from "../../shared.js";
2
+ import { type RedmineSyncContext } from "./context.js";
3
+ export declare function writeRedmineTask(context: RedmineSyncContext, task: TaskData, opts?: TaskWriteOptions): Promise<void>;
4
+ export declare function writeRedmineTasks(context: RedmineSyncContext, tasks: TaskData[], opts?: TaskWriteOptions): Promise<void>;
5
+ //# sourceMappingURL=write.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../../../src/backends/task-backend/redmine/backend-sync/write.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAoC,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGzF,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,QAAQ,EACd,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CA4Ff;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,QAAQ,EAAE,EACjB,IAAI,CAAC,EAAE,gBAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CAWf"}
@@ -0,0 +1,100 @@
1
+ import { taskDocToSectionMap } from "@agentplaneorg/core";
2
+ import { missingTaskIdMessage, RedmineUnavailable, sleep, toStringSafe, validateTaskId, } from "../../shared.js";
3
+ import { parseRedmineCanonicalState } from "../state.js";
4
+ import { issueFromPayload, revisionNumber } from "./context.js";
5
+ import { inferRedmineStatusIdForTaskStatus } from "./status.js";
6
+ export async function writeRedmineTask(context, task, opts) {
7
+ const taskId = toStringSafe(task.id).trim();
8
+ if (!taskId)
9
+ throw new Error(missingTaskIdMessage());
10
+ validateTaskId(taskId);
11
+ try {
12
+ context.ensureDocMetadata(task);
13
+ let issue = await context.findIssueByTaskId(taskId);
14
+ let issueId = issue?.id;
15
+ let issueIdText = issueId ? toStringSafe(issueId) : "";
16
+ let existingIssue = issue ?? null;
17
+ if (issueIdText && !existingIssue) {
18
+ const payload = await context.requestJson("GET", `issues/${issueIdText}.json`);
19
+ existingIssue = issueFromPayload(payload);
20
+ }
21
+ const currentState = existingIssue && context.customFields.canonical_state
22
+ ? parseRedmineCanonicalState(context.customFieldValue(existingIssue, context.customFields.canonical_state))
23
+ : null;
24
+ context.assertExpectedRevisionSupported(taskId, opts);
25
+ context.assertExpectedRevision(taskId, opts?.expectedRevision, currentState?.revision ?? 0);
26
+ const nextRevision = issueIdText
27
+ ? Math.max(revisionNumber(task.revision), revisionNumber(currentState?.revision), 0) + 1
28
+ : Math.max(revisionNumber(task.revision), revisionNumber(currentState?.revision), 1);
29
+ const taskForWrite = {
30
+ ...task,
31
+ revision: nextRevision,
32
+ sections: task.sections && Object.keys(task.sections).length > 0
33
+ ? task.sections
34
+ : task.doc
35
+ ? taskDocToSectionMap(task.doc)
36
+ : undefined,
37
+ };
38
+ const payload = context.taskToIssuePayload(taskForWrite, existingIssue ?? undefined);
39
+ if (payload.status_id === undefined) {
40
+ const inferredStatusId = await inferRedmineStatusIdForTaskStatus(context, taskForWrite.status);
41
+ if (inferredStatusId !== null)
42
+ payload.status_id = inferredStatusId;
43
+ }
44
+ if (issueIdText) {
45
+ await context.requestJson("PUT", `issues/${issueIdText}.json`, { issue: payload });
46
+ }
47
+ else {
48
+ const createPayload = { ...payload, project_id: context.projectId };
49
+ const created = await context.requestJson("POST", "issues.json", { issue: createPayload });
50
+ const createdIssue = issueFromPayload(created);
51
+ issueId = createdIssue?.id;
52
+ issueIdText = issueId ? toStringSafe(issueId) : "";
53
+ if (issueIdText) {
54
+ const updatePayload = { ...payload };
55
+ delete updatePayload.project_id;
56
+ await context.requestJson("PUT", `issues/${issueIdText}.json`, { issue: updatePayload });
57
+ const refreshed = await context.requestJson("GET", `issues/${issueIdText}.json`);
58
+ existingIssue = issueFromPayload(refreshed);
59
+ }
60
+ }
61
+ if (issueIdText) {
62
+ const existingComments = existingIssue && context.customFields.comments
63
+ ? context.normalizeComments(context.maybeParseJson(context.customFieldValue(existingIssue, context.customFields.comments)))
64
+ : [];
65
+ const desiredComments = context.normalizeComments(taskForWrite.comments);
66
+ await context.appendCommentNotes(issueIdText, existingComments, desiredComments);
67
+ }
68
+ taskForWrite.dirty = false;
69
+ await context.cacheTask(taskForWrite, false);
70
+ context.issueCache.clear();
71
+ }
72
+ catch (err) {
73
+ if (!(err instanceof RedmineUnavailable))
74
+ throw err;
75
+ if (!context.cache)
76
+ throw err;
77
+ context.assertExpectedRevisionSupported(taskId, opts);
78
+ const taskForCache = {
79
+ ...task,
80
+ revision: Math.max(revisionNumber(task.revision), 1),
81
+ sections: task.sections && Object.keys(task.sections).length > 0
82
+ ? task.sections
83
+ : task.doc
84
+ ? taskDocToSectionMap(task.doc)
85
+ : undefined,
86
+ dirty: true,
87
+ };
88
+ await context.cache.writeTask(taskForCache, opts);
89
+ }
90
+ }
91
+ export async function writeRedmineTasks(context, tasks, opts) {
92
+ for (const [index, task] of tasks.entries()) {
93
+ await context.writeTask(task, opts);
94
+ if (context.batchPauseMs > 0 &&
95
+ context.batchSize > 0 &&
96
+ (index + 1) % context.batchSize === 0) {
97
+ await sleep(context.batchPauseMs);
98
+ }
99
+ }
100
+ }
@@ -1,67 +1,7 @@
1
- import { type TaskCanonicalStateMigrationResult, type TaskData, type TaskDocMeta, type TaskWriteOptions } from "../shared.js";
2
- import { type TaskComment } from "./comments.js";
3
- type RedmineCachePort = {
4
- listTasks: () => Promise<TaskData[]>;
5
- writeTask: (task: TaskData, opts?: TaskWriteOptions) => Promise<void>;
6
- };
7
- export type RedmineSyncContext = {
8
- cache: RedmineCachePort | null;
9
- customFields: Record<string, unknown>;
10
- ownerAgent: string;
11
- projectId: string;
12
- batchSize: number;
13
- batchPauseMs: number;
14
- statusMap: Record<string, unknown>;
15
- issueCache: Map<string, Record<string, unknown>>;
16
- inferredStatusByTaskStatus: Map<string, number> | null;
17
- setInferredStatusByTaskStatus: (next: Map<string, number> | null) => void;
18
- listTasksRemote: () => Promise<TaskData[]>;
19
- writeTask: (task: TaskData, opts?: TaskWriteOptions) => Promise<void>;
20
- writeTasks: (tasks: TaskData[], opts?: TaskWriteOptions) => Promise<void>;
21
- findIssueByTaskId: (taskId: string) => Promise<Record<string, unknown> | null>;
22
- issueToTask: (issue: Record<string, unknown>, taskIdOverride?: string) => TaskData | null;
23
- taskToIssuePayload: (task: TaskData, existingIssue?: Record<string, unknown>) => Record<string, unknown>;
24
- appendCustomField: (fields: Record<string, unknown>[], key: string, value: unknown) => void;
25
- customFieldValue: (issue: Record<string, unknown>, fieldId: unknown) => string | null;
26
- maybeParseJson: (value: unknown) => unknown;
27
- normalizeComments: (value: unknown) => TaskComment[];
28
- appendCommentNotes: (issueId: string, existingComments: TaskComment[], desiredComments: TaskComment[]) => Promise<void>;
29
- cacheTask: (task: TaskData, dirty: boolean) => Promise<void>;
30
- assertExpectedRevisionSupported: (taskId: string, opts?: TaskWriteOptions) => void;
31
- assertExpectedRevision: (taskId: string, expectedRevision: number | undefined, currentRevision: number) => void;
32
- ensureDocMetadata: (task: TaskDocMeta) => void;
33
- diffTasks: (localTask: TaskData, remoteTask: TaskData) => string;
34
- tasksDiffer: (localTask: TaskData, remoteTask: TaskData) => boolean;
35
- taskIdFieldId: () => unknown;
36
- setIssueCustomFieldValue: (issue: Record<string, unknown>, fieldId: unknown, value: unknown) => void;
37
- requestJson: (method: string, reqPath: string, payload?: Record<string, unknown>, params?: Record<string, unknown>, opts?: {
38
- attempts?: number;
39
- backoff?: number;
40
- }) => Promise<Record<string, unknown>>;
41
- };
42
- export declare function generateRedmineTaskId(context: RedmineSyncContext, opts: {
43
- length: number;
44
- attempts: number;
45
- }): Promise<string>;
46
- export declare function migrateRedmineCanonicalState(context: RedmineSyncContext): Promise<TaskCanonicalStateMigrationResult>;
47
- export declare function writeRedmineTask(context: RedmineSyncContext, task: TaskData, opts?: TaskWriteOptions): Promise<void>;
48
- export declare function writeRedmineTasks(context: RedmineSyncContext, tasks: TaskData[], opts?: TaskWriteOptions): Promise<void>;
49
- export declare function syncRedmine(context: RedmineSyncContext, opts: {
50
- direction: "push" | "pull";
51
- conflict: "diff" | "prefer-local" | "prefer-remote" | "fail";
52
- quiet: boolean;
53
- confirm: boolean;
54
- }): Promise<void>;
55
- export declare function syncPushRedmine(context: RedmineSyncContext, quiet: boolean, confirm: boolean): Promise<void>;
56
- export declare function syncPullRedmine(context: RedmineSyncContext, conflict: "diff" | "prefer-local" | "prefer-remote" | "fail", quiet: boolean): Promise<void>;
57
- export declare function handleRedmineConflict(context: RedmineSyncContext, taskId: string, localTask: TaskData, remoteTask: TaskData, conflict: "diff" | "prefer-local" | "prefer-remote" | "fail"): Promise<void>;
58
- export declare function inferRedmineStatusIdForTaskStatus(context: RedmineSyncContext, statusRaw: unknown): Promise<number | null>;
59
- export declare function loadRedmineInferredStatusByTaskStatus(context: RedmineSyncContext): Promise<Map<string, number>>;
60
- export declare function selectRedmineInferredStatus(statuses: {
61
- id: number;
62
- name: string;
63
- isClosed: boolean;
64
- isDefault: boolean;
65
- }[], target: "TODO" | "DOING" | "DONE"): number | null;
66
- export {};
1
+ export type { RedmineSyncContext } from "./backend-sync/context.js";
2
+ export { generateRedmineTaskId } from "./backend-sync/ids.js";
3
+ export { migrateRedmineCanonicalState } from "./backend-sync/migration.js";
4
+ export { inferRedmineStatusIdForTaskStatus, loadRedmineInferredStatusByTaskStatus, selectRedmineInferredStatus, } from "./backend-sync/status.js";
5
+ export { handleRedmineConflict, syncPullRedmine, syncPushRedmine, syncRedmine, } from "./backend-sync/sync.js";
6
+ export { writeRedmineTask, writeRedmineTasks } from "./backend-sync/write.js";
67
7
  //# sourceMappingURL=backend-sync.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"backend-sync.d.ts","sourceRoot":"","sources":["../../../../src/backends/task-backend/redmine/backend-sync.ts"],"names":[],"mappings":"AAEA,OAAO,EAUL,KAAK,iCAAiC,EACtC,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,KAAK,gBAAgB,GAAG;IACtB,SAAS,EAAE,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrC,SAAS,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,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