sudocode 1.0.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (447) hide show
  1. package/README.md +222 -0
  2. package/build.js +75 -0
  3. package/node_modules/@sudocode-ai/cli/README.md +330 -0
  4. package/node_modules/@sudocode-ai/cli/dist/cli/feedback-commands.d.ts +53 -0
  5. package/node_modules/@sudocode-ai/cli/dist/cli/feedback-commands.d.ts.map +1 -0
  6. package/node_modules/@sudocode-ai/cli/dist/cli/feedback-commands.js +274 -0
  7. package/node_modules/@sudocode-ai/cli/dist/cli/feedback-commands.js.map +1 -0
  8. package/node_modules/@sudocode-ai/cli/dist/cli/init-commands.d.ts +22 -0
  9. package/node_modules/@sudocode-ai/cli/dist/cli/init-commands.d.ts.map +1 -0
  10. package/node_modules/@sudocode-ai/cli/dist/cli/init-commands.js +148 -0
  11. package/node_modules/@sudocode-ai/cli/dist/cli/init-commands.js.map +1 -0
  12. package/node_modules/@sudocode-ai/cli/dist/cli/issue-commands.d.ts +45 -0
  13. package/node_modules/@sudocode-ai/cli/dist/cli/issue-commands.d.ts.map +1 -0
  14. package/node_modules/@sudocode-ai/cli/dist/cli/issue-commands.js +310 -0
  15. package/node_modules/@sudocode-ai/cli/dist/cli/issue-commands.js.map +1 -0
  16. package/node_modules/@sudocode-ai/cli/dist/cli/query-commands.d.ts +18 -0
  17. package/node_modules/@sudocode-ai/cli/dist/cli/query-commands.d.ts.map +1 -0
  18. package/node_modules/@sudocode-ai/cli/dist/cli/query-commands.js +61 -0
  19. package/node_modules/@sudocode-ai/cli/dist/cli/query-commands.js.map +1 -0
  20. package/node_modules/@sudocode-ai/cli/dist/cli/reference-commands.d.ts +22 -0
  21. package/node_modules/@sudocode-ai/cli/dist/cli/reference-commands.d.ts.map +1 -0
  22. package/node_modules/@sudocode-ai/cli/dist/cli/reference-commands.js +136 -0
  23. package/node_modules/@sudocode-ai/cli/dist/cli/reference-commands.js.map +1 -0
  24. package/node_modules/@sudocode-ai/cli/dist/cli/relationship-commands.d.ts +14 -0
  25. package/node_modules/@sudocode-ai/cli/dist/cli/relationship-commands.d.ts.map +1 -0
  26. package/node_modules/@sudocode-ai/cli/dist/cli/relationship-commands.js +76 -0
  27. package/node_modules/@sudocode-ai/cli/dist/cli/relationship-commands.js.map +1 -0
  28. package/node_modules/@sudocode-ai/cli/dist/cli/server-commands.d.ts +17 -0
  29. package/node_modules/@sudocode-ai/cli/dist/cli/server-commands.d.ts.map +1 -0
  30. package/node_modules/@sudocode-ai/cli/dist/cli/server-commands.js +99 -0
  31. package/node_modules/@sudocode-ai/cli/dist/cli/server-commands.js.map +1 -0
  32. package/node_modules/@sudocode-ai/cli/dist/cli/spec-commands.d.ts +38 -0
  33. package/node_modules/@sudocode-ai/cli/dist/cli/spec-commands.d.ts.map +1 -0
  34. package/node_modules/@sudocode-ai/cli/dist/cli/spec-commands.js +321 -0
  35. package/node_modules/@sudocode-ai/cli/dist/cli/spec-commands.js.map +1 -0
  36. package/node_modules/@sudocode-ai/cli/dist/cli/status-commands.d.ts +17 -0
  37. package/node_modules/@sudocode-ai/cli/dist/cli/status-commands.d.ts.map +1 -0
  38. package/node_modules/@sudocode-ai/cli/dist/cli/status-commands.js +131 -0
  39. package/node_modules/@sudocode-ai/cli/dist/cli/status-commands.js.map +1 -0
  40. package/node_modules/@sudocode-ai/cli/dist/cli/sync-commands.d.ts +24 -0
  41. package/node_modules/@sudocode-ai/cli/dist/cli/sync-commands.d.ts.map +1 -0
  42. package/node_modules/@sudocode-ai/cli/dist/cli/sync-commands.js +416 -0
  43. package/node_modules/@sudocode-ai/cli/dist/cli/sync-commands.js.map +1 -0
  44. package/node_modules/@sudocode-ai/cli/dist/cli/update-commands.d.ts +12 -0
  45. package/node_modules/@sudocode-ai/cli/dist/cli/update-commands.d.ts.map +1 -0
  46. package/node_modules/@sudocode-ai/cli/dist/cli/update-commands.js +78 -0
  47. package/node_modules/@sudocode-ai/cli/dist/cli/update-commands.js.map +1 -0
  48. package/node_modules/@sudocode-ai/cli/dist/cli.d.ts +6 -0
  49. package/node_modules/@sudocode-ai/cli/dist/cli.d.ts.map +1 -0
  50. package/node_modules/@sudocode-ai/cli/dist/cli.js +426 -0
  51. package/node_modules/@sudocode-ai/cli/dist/cli.js.map +1 -0
  52. package/node_modules/@sudocode-ai/cli/dist/db.d.ts +21 -0
  53. package/node_modules/@sudocode-ai/cli/dist/db.d.ts.map +1 -0
  54. package/node_modules/@sudocode-ai/cli/dist/db.js +54 -0
  55. package/node_modules/@sudocode-ai/cli/dist/db.js.map +1 -0
  56. package/node_modules/@sudocode-ai/cli/dist/export.d.ts +79 -0
  57. package/node_modules/@sudocode-ai/cli/dist/export.d.ts.map +1 -0
  58. package/node_modules/@sudocode-ai/cli/dist/export.js +195 -0
  59. package/node_modules/@sudocode-ai/cli/dist/export.js.map +1 -0
  60. package/node_modules/@sudocode-ai/cli/dist/filename-generator.d.ts +30 -0
  61. package/node_modules/@sudocode-ai/cli/dist/filename-generator.d.ts.map +1 -0
  62. package/node_modules/@sudocode-ai/cli/dist/filename-generator.js +93 -0
  63. package/node_modules/@sudocode-ai/cli/dist/filename-generator.js.map +1 -0
  64. package/node_modules/@sudocode-ai/cli/dist/id-generator.d.ts +26 -0
  65. package/node_modules/@sudocode-ai/cli/dist/id-generator.d.ts.map +1 -0
  66. package/node_modules/@sudocode-ai/cli/dist/id-generator.js +123 -0
  67. package/node_modules/@sudocode-ai/cli/dist/id-generator.js.map +1 -0
  68. package/node_modules/@sudocode-ai/cli/dist/import.d.ts +118 -0
  69. package/node_modules/@sudocode-ai/cli/dist/import.d.ts.map +1 -0
  70. package/node_modules/@sudocode-ai/cli/dist/import.js +608 -0
  71. package/node_modules/@sudocode-ai/cli/dist/import.js.map +1 -0
  72. package/node_modules/@sudocode-ai/cli/dist/index.d.ts +13 -0
  73. package/node_modules/@sudocode-ai/cli/dist/index.d.ts.map +1 -0
  74. package/node_modules/@sudocode-ai/cli/dist/index.js +13 -0
  75. package/node_modules/@sudocode-ai/cli/dist/index.js.map +1 -0
  76. package/node_modules/@sudocode-ai/cli/dist/jsonl.d.ts +69 -0
  77. package/node_modules/@sudocode-ai/cli/dist/jsonl.d.ts.map +1 -0
  78. package/node_modules/@sudocode-ai/cli/dist/jsonl.js +333 -0
  79. package/node_modules/@sudocode-ai/cli/dist/jsonl.js.map +1 -0
  80. package/node_modules/@sudocode-ai/cli/dist/markdown.d.ts +146 -0
  81. package/node_modules/@sudocode-ai/cli/dist/markdown.d.ts.map +1 -0
  82. package/node_modules/@sudocode-ai/cli/dist/markdown.js +357 -0
  83. package/node_modules/@sudocode-ai/cli/dist/markdown.js.map +1 -0
  84. package/node_modules/@sudocode-ai/cli/dist/migrations.d.ts +23 -0
  85. package/node_modules/@sudocode-ai/cli/dist/migrations.d.ts.map +1 -0
  86. package/node_modules/@sudocode-ai/cli/dist/migrations.js +57 -0
  87. package/node_modules/@sudocode-ai/cli/dist/migrations.js.map +1 -0
  88. package/node_modules/@sudocode-ai/cli/dist/operations/events.d.ts +53 -0
  89. package/node_modules/@sudocode-ai/cli/dist/operations/events.d.ts.map +1 -0
  90. package/node_modules/@sudocode-ai/cli/dist/operations/events.js +108 -0
  91. package/node_modules/@sudocode-ai/cli/dist/operations/events.js.map +1 -0
  92. package/node_modules/@sudocode-ai/cli/dist/operations/feedback-anchors.d.ts +92 -0
  93. package/node_modules/@sudocode-ai/cli/dist/operations/feedback-anchors.d.ts.map +1 -0
  94. package/node_modules/@sudocode-ai/cli/dist/operations/feedback-anchors.js +444 -0
  95. package/node_modules/@sudocode-ai/cli/dist/operations/feedback-anchors.js.map +1 -0
  96. package/node_modules/@sudocode-ai/cli/dist/operations/feedback.d.ts +76 -0
  97. package/node_modules/@sudocode-ai/cli/dist/operations/feedback.d.ts.map +1 -0
  98. package/node_modules/@sudocode-ai/cli/dist/operations/feedback.js +234 -0
  99. package/node_modules/@sudocode-ai/cli/dist/operations/feedback.js.map +1 -0
  100. package/node_modules/@sudocode-ai/cli/dist/operations/index.d.ts +10 -0
  101. package/node_modules/@sudocode-ai/cli/dist/operations/index.d.ts.map +1 -0
  102. package/node_modules/@sudocode-ai/cli/dist/operations/index.js +10 -0
  103. package/node_modules/@sudocode-ai/cli/dist/operations/index.js.map +1 -0
  104. package/node_modules/@sudocode-ai/cli/dist/operations/issues.d.ts +82 -0
  105. package/node_modules/@sudocode-ai/cli/dist/operations/issues.d.ts.map +1 -0
  106. package/node_modules/@sudocode-ai/cli/dist/operations/issues.js +411 -0
  107. package/node_modules/@sudocode-ai/cli/dist/operations/issues.js.map +1 -0
  108. package/node_modules/@sudocode-ai/cli/dist/operations/references.d.ts +34 -0
  109. package/node_modules/@sudocode-ai/cli/dist/operations/references.d.ts.map +1 -0
  110. package/node_modules/@sudocode-ai/cli/dist/operations/references.js +117 -0
  111. package/node_modules/@sudocode-ai/cli/dist/operations/references.js.map +1 -0
  112. package/node_modules/@sudocode-ai/cli/dist/operations/relationships.d.ts +57 -0
  113. package/node_modules/@sudocode-ai/cli/dist/operations/relationships.d.ts.map +1 -0
  114. package/node_modules/@sudocode-ai/cli/dist/operations/relationships.js +236 -0
  115. package/node_modules/@sudocode-ai/cli/dist/operations/relationships.js.map +1 -0
  116. package/node_modules/@sudocode-ai/cli/dist/operations/specs.d.ts +64 -0
  117. package/node_modules/@sudocode-ai/cli/dist/operations/specs.d.ts.map +1 -0
  118. package/node_modules/@sudocode-ai/cli/dist/operations/specs.js +290 -0
  119. package/node_modules/@sudocode-ai/cli/dist/operations/specs.js.map +1 -0
  120. package/node_modules/@sudocode-ai/cli/dist/operations/tags.d.ts +42 -0
  121. package/node_modules/@sudocode-ai/cli/dist/operations/tags.d.ts.map +1 -0
  122. package/node_modules/@sudocode-ai/cli/dist/operations/tags.js +127 -0
  123. package/node_modules/@sudocode-ai/cli/dist/operations/tags.js.map +1 -0
  124. package/node_modules/@sudocode-ai/cli/dist/operations/transactions.d.ts +41 -0
  125. package/node_modules/@sudocode-ai/cli/dist/operations/transactions.d.ts.map +1 -0
  126. package/node_modules/@sudocode-ai/cli/dist/operations/transactions.js +111 -0
  127. package/node_modules/@sudocode-ai/cli/dist/operations/transactions.js.map +1 -0
  128. package/node_modules/@sudocode-ai/cli/dist/sync.d.ts +47 -0
  129. package/node_modules/@sudocode-ai/cli/dist/sync.d.ts.map +1 -0
  130. package/node_modules/@sudocode-ai/cli/dist/sync.js +442 -0
  131. package/node_modules/@sudocode-ai/cli/dist/sync.js.map +1 -0
  132. package/node_modules/@sudocode-ai/cli/dist/test-schema.d.ts +5 -0
  133. package/node_modules/@sudocode-ai/cli/dist/test-schema.d.ts.map +1 -0
  134. package/node_modules/@sudocode-ai/cli/dist/test-schema.js +46 -0
  135. package/node_modules/@sudocode-ai/cli/dist/test-schema.js.map +1 -0
  136. package/node_modules/@sudocode-ai/cli/dist/types.d.ts +7 -0
  137. package/node_modules/@sudocode-ai/cli/dist/types.d.ts.map +1 -0
  138. package/node_modules/@sudocode-ai/cli/dist/types.js +7 -0
  139. package/node_modules/@sudocode-ai/cli/dist/types.js.map +1 -0
  140. package/node_modules/@sudocode-ai/cli/dist/update-checker.d.ts +24 -0
  141. package/node_modules/@sudocode-ai/cli/dist/update-checker.d.ts.map +1 -0
  142. package/node_modules/@sudocode-ai/cli/dist/update-checker.js +151 -0
  143. package/node_modules/@sudocode-ai/cli/dist/update-checker.js.map +1 -0
  144. package/node_modules/@sudocode-ai/cli/dist/version.d.ts +12 -0
  145. package/node_modules/@sudocode-ai/cli/dist/version.d.ts.map +1 -0
  146. package/node_modules/@sudocode-ai/cli/dist/version.js +23 -0
  147. package/node_modules/@sudocode-ai/cli/dist/version.js.map +1 -0
  148. package/node_modules/@sudocode-ai/cli/dist/watcher.d.ts +63 -0
  149. package/node_modules/@sudocode-ai/cli/dist/watcher.d.ts.map +1 -0
  150. package/node_modules/@sudocode-ai/cli/dist/watcher.js +438 -0
  151. package/node_modules/@sudocode-ai/cli/dist/watcher.js.map +1 -0
  152. package/node_modules/@sudocode-ai/cli/package.json +65 -0
  153. package/node_modules/@sudocode-ai/local-server/README.md +19 -0
  154. package/node_modules/@sudocode-ai/local-server/dist/cli.d.ts +7 -0
  155. package/node_modules/@sudocode-ai/local-server/dist/cli.d.ts.map +1 -0
  156. package/node_modules/@sudocode-ai/local-server/dist/cli.js +7 -0
  157. package/node_modules/@sudocode-ai/local-server/dist/cli.js.map +1 -0
  158. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/engine.d.ts +103 -0
  159. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/engine.d.ts.map +1 -0
  160. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/engine.js +10 -0
  161. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/engine.js.map +1 -0
  162. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/simple-engine.d.ts +190 -0
  163. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/simple-engine.d.ts.map +1 -0
  164. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/simple-engine.js +611 -0
  165. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/simple-engine.js.map +1 -0
  166. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/types.d.ts +116 -0
  167. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/types.d.ts.map +1 -0
  168. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/types.js +10 -0
  169. package/node_modules/@sudocode-ai/local-server/dist/execution/engine/types.js.map +1 -0
  170. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-adapter.d.ts +176 -0
  171. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-adapter.d.ts.map +1 -0
  172. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-adapter.js +438 -0
  173. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-adapter.js.map +1 -0
  174. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-integration.d.ts +96 -0
  175. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-integration.d.ts.map +1 -0
  176. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-integration.js +96 -0
  177. package/node_modules/@sudocode-ai/local-server/dist/execution/output/ag-ui-integration.js.map +1 -0
  178. package/node_modules/@sudocode-ai/local-server/dist/execution/output/claude-code-output-processor.d.ts +321 -0
  179. package/node_modules/@sudocode-ai/local-server/dist/execution/output/claude-code-output-processor.d.ts.map +1 -0
  180. package/node_modules/@sudocode-ai/local-server/dist/execution/output/claude-code-output-processor.js +769 -0
  181. package/node_modules/@sudocode-ai/local-server/dist/execution/output/claude-code-output-processor.js.map +1 -0
  182. package/node_modules/@sudocode-ai/local-server/dist/execution/output/index.d.ts +18 -0
  183. package/node_modules/@sudocode-ai/local-server/dist/execution/output/index.d.ts.map +1 -0
  184. package/node_modules/@sudocode-ai/local-server/dist/execution/output/index.js +15 -0
  185. package/node_modules/@sudocode-ai/local-server/dist/execution/output/index.js.map +1 -0
  186. package/node_modules/@sudocode-ai/local-server/dist/execution/output/types.d.ts +421 -0
  187. package/node_modules/@sudocode-ai/local-server/dist/execution/output/types.d.ts.map +1 -0
  188. package/node_modules/@sudocode-ai/local-server/dist/execution/output/types.js +22 -0
  189. package/node_modules/@sudocode-ai/local-server/dist/execution/output/types.js.map +1 -0
  190. package/node_modules/@sudocode-ai/local-server/dist/execution/process/builders/claude.d.ts +86 -0
  191. package/node_modules/@sudocode-ai/local-server/dist/execution/process/builders/claude.d.ts.map +1 -0
  192. package/node_modules/@sudocode-ai/local-server/dist/execution/process/builders/claude.js +59 -0
  193. package/node_modules/@sudocode-ai/local-server/dist/execution/process/builders/claude.js.map +1 -0
  194. package/node_modules/@sudocode-ai/local-server/dist/execution/process/index.d.ts +15 -0
  195. package/node_modules/@sudocode-ai/local-server/dist/execution/process/index.d.ts.map +1 -0
  196. package/node_modules/@sudocode-ai/local-server/dist/execution/process/index.js +15 -0
  197. package/node_modules/@sudocode-ai/local-server/dist/execution/process/index.js.map +1 -0
  198. package/node_modules/@sudocode-ai/local-server/dist/execution/process/manager.d.ts +133 -0
  199. package/node_modules/@sudocode-ai/local-server/dist/execution/process/manager.d.ts.map +1 -0
  200. package/node_modules/@sudocode-ai/local-server/dist/execution/process/manager.js +10 -0
  201. package/node_modules/@sudocode-ai/local-server/dist/execution/process/manager.js.map +1 -0
  202. package/node_modules/@sudocode-ai/local-server/dist/execution/process/simple-manager.d.ts +102 -0
  203. package/node_modules/@sudocode-ai/local-server/dist/execution/process/simple-manager.d.ts.map +1 -0
  204. package/node_modules/@sudocode-ai/local-server/dist/execution/process/simple-manager.js +336 -0
  205. package/node_modules/@sudocode-ai/local-server/dist/execution/process/simple-manager.js.map +1 -0
  206. package/node_modules/@sudocode-ai/local-server/dist/execution/process/types.d.ts +105 -0
  207. package/node_modules/@sudocode-ai/local-server/dist/execution/process/types.d.ts.map +1 -0
  208. package/node_modules/@sudocode-ai/local-server/dist/execution/process/types.js +10 -0
  209. package/node_modules/@sudocode-ai/local-server/dist/execution/process/types.js.map +1 -0
  210. package/node_modules/@sudocode-ai/local-server/dist/execution/process/utils.d.ts +53 -0
  211. package/node_modules/@sudocode-ai/local-server/dist/execution/process/utils.d.ts.map +1 -0
  212. package/node_modules/@sudocode-ai/local-server/dist/execution/process/utils.js +97 -0
  213. package/node_modules/@sudocode-ai/local-server/dist/execution/process/utils.js.map +1 -0
  214. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/circuit-breaker.d.ts +170 -0
  215. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/circuit-breaker.d.ts.map +1 -0
  216. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/circuit-breaker.js +291 -0
  217. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/circuit-breaker.js.map +1 -0
  218. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/executor.d.ts +109 -0
  219. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/executor.d.ts.map +1 -0
  220. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/executor.js +10 -0
  221. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/executor.js.map +1 -0
  222. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/index.d.ts +14 -0
  223. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/index.d.ts.map +1 -0
  224. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/index.js +15 -0
  225. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/index.js.map +1 -0
  226. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/resilient-executor.d.ts +86 -0
  227. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/resilient-executor.d.ts.map +1 -0
  228. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/resilient-executor.js +261 -0
  229. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/resilient-executor.js.map +1 -0
  230. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/retry.d.ts +161 -0
  231. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/retry.d.ts.map +1 -0
  232. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/retry.js +234 -0
  233. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/retry.js.map +1 -0
  234. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/types.d.ts +226 -0
  235. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/types.d.ts.map +1 -0
  236. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/types.js +30 -0
  237. package/node_modules/@sudocode-ai/local-server/dist/execution/resilience/types.js.map +1 -0
  238. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/event-buffer.d.ts +119 -0
  239. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/event-buffer.d.ts.map +1 -0
  240. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/event-buffer.js +208 -0
  241. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/event-buffer.js.map +1 -0
  242. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/index.d.ts +10 -0
  243. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/index.d.ts.map +1 -0
  244. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/index.js +10 -0
  245. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/index.js.map +1 -0
  246. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/sse-transport.d.ts +146 -0
  247. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/sse-transport.d.ts.map +1 -0
  248. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/sse-transport.js +282 -0
  249. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/sse-transport.js.map +1 -0
  250. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/transport-manager.d.ts +176 -0
  251. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/transport-manager.d.ts.map +1 -0
  252. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/transport-manager.js +231 -0
  253. package/node_modules/@sudocode-ai/local-server/dist/execution/transport/transport-manager.js.map +1 -0
  254. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/index.d.ts +13 -0
  255. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/index.d.ts.map +1 -0
  256. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/index.js +13 -0
  257. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/index.js.map +1 -0
  258. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/linear-orchestrator.d.ts +216 -0
  259. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/linear-orchestrator.d.ts.map +1 -0
  260. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/linear-orchestrator.js +683 -0
  261. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/linear-orchestrator.js.map +1 -0
  262. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/memory-storage.d.ts +54 -0
  263. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/memory-storage.d.ts.map +1 -0
  264. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/memory-storage.js +68 -0
  265. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/memory-storage.js.map +1 -0
  266. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/orchestrator.d.ts +158 -0
  267. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/orchestrator.d.ts.map +1 -0
  268. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/orchestrator.js +9 -0
  269. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/orchestrator.js.map +1 -0
  270. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/types.d.ts +172 -0
  271. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/types.d.ts.map +1 -0
  272. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/types.js +9 -0
  273. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/types.js.map +1 -0
  274. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/utils.d.ts +89 -0
  275. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/utils.d.ts.map +1 -0
  276. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/utils.js +152 -0
  277. package/node_modules/@sudocode-ai/local-server/dist/execution/workflow/utils.js.map +1 -0
  278. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/config.d.ts +74 -0
  279. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/config.d.ts.map +1 -0
  280. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/config.js +280 -0
  281. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/config.js.map +1 -0
  282. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/git-cli.d.ts +151 -0
  283. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/git-cli.d.ts.map +1 -0
  284. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/git-cli.js +189 -0
  285. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/git-cli.js.map +1 -0
  286. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/index.d.ts +16 -0
  287. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/index.d.ts.map +1 -0
  288. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/index.js +15 -0
  289. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/index.js.map +1 -0
  290. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/manager.d.ts +184 -0
  291. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/manager.d.ts.map +1 -0
  292. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/manager.js +452 -0
  293. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/manager.js.map +1 -0
  294. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/types.d.ts +90 -0
  295. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/types.d.ts.map +1 -0
  296. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/types.js +42 -0
  297. package/node_modules/@sudocode-ai/local-server/dist/execution/worktree/types.js.map +1 -0
  298. package/node_modules/@sudocode-ai/local-server/dist/index.d.ts +8 -0
  299. package/node_modules/@sudocode-ai/local-server/dist/index.d.ts.map +1 -0
  300. package/node_modules/@sudocode-ai/local-server/dist/index.js +356 -0
  301. package/node_modules/@sudocode-ai/local-server/dist/index.js.map +1 -0
  302. package/node_modules/@sudocode-ai/local-server/dist/public/assets/index-C4SmlXoo.js +568 -0
  303. package/node_modules/@sudocode-ai/local-server/dist/public/assets/index-C4SmlXoo.js.map +1 -0
  304. package/node_modules/@sudocode-ai/local-server/dist/public/assets/index-DE59j7ti.css +1 -0
  305. package/node_modules/@sudocode-ai/local-server/dist/public/assets/react-vendor-LX0UoTxg.js +60 -0
  306. package/node_modules/@sudocode-ai/local-server/dist/public/assets/react-vendor-LX0UoTxg.js.map +1 -0
  307. package/node_modules/@sudocode-ai/local-server/dist/public/assets/ui-vendor-_cxVHaqZ.js +54 -0
  308. package/node_modules/@sudocode-ai/local-server/dist/public/assets/ui-vendor-_cxVHaqZ.js.map +1 -0
  309. package/node_modules/@sudocode-ai/local-server/dist/public/favicon.ico +0 -0
  310. package/node_modules/@sudocode-ai/local-server/dist/public/index.html +16 -0
  311. package/node_modules/@sudocode-ai/local-server/dist/public/logo.png +0 -0
  312. package/node_modules/@sudocode-ai/local-server/dist/routes/executions-stream.d.ts +24 -0
  313. package/node_modules/@sudocode-ai/local-server/dist/routes/executions-stream.d.ts.map +1 -0
  314. package/node_modules/@sudocode-ai/local-server/dist/routes/executions-stream.js +55 -0
  315. package/node_modules/@sudocode-ai/local-server/dist/routes/executions-stream.js.map +1 -0
  316. package/node_modules/@sudocode-ai/local-server/dist/routes/executions.d.ts +19 -0
  317. package/node_modules/@sudocode-ai/local-server/dist/routes/executions.d.ts.map +1 -0
  318. package/node_modules/@sudocode-ai/local-server/dist/routes/executions.js +267 -0
  319. package/node_modules/@sudocode-ai/local-server/dist/routes/executions.js.map +1 -0
  320. package/node_modules/@sudocode-ai/local-server/dist/routes/feedback.d.ts +7 -0
  321. package/node_modules/@sudocode-ai/local-server/dist/routes/feedback.d.ts.map +1 -0
  322. package/node_modules/@sudocode-ai/local-server/dist/routes/feedback.js +329 -0
  323. package/node_modules/@sudocode-ai/local-server/dist/routes/feedback.js.map +1 -0
  324. package/node_modules/@sudocode-ai/local-server/dist/routes/issues.d.ts +7 -0
  325. package/node_modules/@sudocode-ai/local-server/dist/routes/issues.d.ts.map +1 -0
  326. package/node_modules/@sudocode-ai/local-server/dist/routes/issues.js +280 -0
  327. package/node_modules/@sudocode-ai/local-server/dist/routes/issues.js.map +1 -0
  328. package/node_modules/@sudocode-ai/local-server/dist/routes/relationships.d.ts +7 -0
  329. package/node_modules/@sudocode-ai/local-server/dist/routes/relationships.d.ts.map +1 -0
  330. package/node_modules/@sudocode-ai/local-server/dist/routes/relationships.js +308 -0
  331. package/node_modules/@sudocode-ai/local-server/dist/routes/relationships.js.map +1 -0
  332. package/node_modules/@sudocode-ai/local-server/dist/routes/specs.d.ts +7 -0
  333. package/node_modules/@sudocode-ai/local-server/dist/routes/specs.d.ts.map +1 -0
  334. package/node_modules/@sudocode-ai/local-server/dist/routes/specs.js +270 -0
  335. package/node_modules/@sudocode-ai/local-server/dist/routes/specs.js.map +1 -0
  336. package/node_modules/@sudocode-ai/local-server/dist/services/db.d.ts +33 -0
  337. package/node_modules/@sudocode-ai/local-server/dist/services/db.d.ts.map +1 -0
  338. package/node_modules/@sudocode-ai/local-server/dist/services/db.js +85 -0
  339. package/node_modules/@sudocode-ai/local-server/dist/services/db.js.map +1 -0
  340. package/node_modules/@sudocode-ai/local-server/dist/services/execution-lifecycle.d.ts +108 -0
  341. package/node_modules/@sudocode-ai/local-server/dist/services/execution-lifecycle.d.ts.map +1 -0
  342. package/node_modules/@sudocode-ai/local-server/dist/services/execution-lifecycle.js +286 -0
  343. package/node_modules/@sudocode-ai/local-server/dist/services/execution-lifecycle.js.map +1 -0
  344. package/node_modules/@sudocode-ai/local-server/dist/services/execution-service.d.ts +185 -0
  345. package/node_modules/@sudocode-ai/local-server/dist/services/execution-service.d.ts.map +1 -0
  346. package/node_modules/@sudocode-ai/local-server/dist/services/execution-service.js +676 -0
  347. package/node_modules/@sudocode-ai/local-server/dist/services/execution-service.js.map +1 -0
  348. package/node_modules/@sudocode-ai/local-server/dist/services/executions.d.ts +59 -0
  349. package/node_modules/@sudocode-ai/local-server/dist/services/executions.d.ts.map +1 -0
  350. package/node_modules/@sudocode-ai/local-server/dist/services/executions.js +164 -0
  351. package/node_modules/@sudocode-ai/local-server/dist/services/executions.js.map +1 -0
  352. package/node_modules/@sudocode-ai/local-server/dist/services/export.d.ts +24 -0
  353. package/node_modules/@sudocode-ai/local-server/dist/services/export.d.ts.map +1 -0
  354. package/node_modules/@sudocode-ai/local-server/dist/services/export.js +106 -0
  355. package/node_modules/@sudocode-ai/local-server/dist/services/export.js.map +1 -0
  356. package/node_modules/@sudocode-ai/local-server/dist/services/feedback.d.ts +40 -0
  357. package/node_modules/@sudocode-ai/local-server/dist/services/feedback.d.ts.map +1 -0
  358. package/node_modules/@sudocode-ai/local-server/dist/services/feedback.js +54 -0
  359. package/node_modules/@sudocode-ai/local-server/dist/services/feedback.js.map +1 -0
  360. package/node_modules/@sudocode-ai/local-server/dist/services/issues.d.ts +27 -0
  361. package/node_modules/@sudocode-ai/local-server/dist/services/issues.d.ts.map +1 -0
  362. package/node_modules/@sudocode-ai/local-server/dist/services/issues.js +35 -0
  363. package/node_modules/@sudocode-ai/local-server/dist/services/issues.js.map +1 -0
  364. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-template-engine.d.ts +108 -0
  365. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-template-engine.d.ts.map +1 -0
  366. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-template-engine.js +212 -0
  367. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-template-engine.js.map +1 -0
  368. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-templates.d.ts +97 -0
  369. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-templates.d.ts.map +1 -0
  370. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-templates.js +236 -0
  371. package/node_modules/@sudocode-ai/local-server/dist/services/prompt-templates.js.map +1 -0
  372. package/node_modules/@sudocode-ai/local-server/dist/services/relationships.d.ts +35 -0
  373. package/node_modules/@sudocode-ai/local-server/dist/services/relationships.d.ts.map +1 -0
  374. package/node_modules/@sudocode-ai/local-server/dist/services/relationships.js +42 -0
  375. package/node_modules/@sudocode-ai/local-server/dist/services/relationships.js.map +1 -0
  376. package/node_modules/@sudocode-ai/local-server/dist/services/specs.d.ts +27 -0
  377. package/node_modules/@sudocode-ai/local-server/dist/services/specs.d.ts.map +1 -0
  378. package/node_modules/@sudocode-ai/local-server/dist/services/specs.js +35 -0
  379. package/node_modules/@sudocode-ai/local-server/dist/services/specs.js.map +1 -0
  380. package/node_modules/@sudocode-ai/local-server/dist/services/watcher.d.ts +50 -0
  381. package/node_modules/@sudocode-ai/local-server/dist/services/watcher.d.ts.map +1 -0
  382. package/node_modules/@sudocode-ai/local-server/dist/services/watcher.js +69 -0
  383. package/node_modules/@sudocode-ai/local-server/dist/services/watcher.js.map +1 -0
  384. package/node_modules/@sudocode-ai/local-server/dist/services/websocket.d.ts +127 -0
  385. package/node_modules/@sudocode-ai/local-server/dist/services/websocket.d.ts.map +1 -0
  386. package/node_modules/@sudocode-ai/local-server/dist/services/websocket.js +389 -0
  387. package/node_modules/@sudocode-ai/local-server/dist/services/websocket.js.map +1 -0
  388. package/node_modules/@sudocode-ai/local-server/dist/utils/sudocode-dir.d.ts +6 -0
  389. package/node_modules/@sudocode-ai/local-server/dist/utils/sudocode-dir.d.ts.map +1 -0
  390. package/node_modules/@sudocode-ai/local-server/dist/utils/sudocode-dir.js +9 -0
  391. package/node_modules/@sudocode-ai/local-server/dist/utils/sudocode-dir.js.map +1 -0
  392. package/node_modules/@sudocode-ai/local-server/package.json +72 -0
  393. package/node_modules/@sudocode-ai/mcp/LICENSE +21 -0
  394. package/node_modules/@sudocode-ai/mcp/README.md +226 -0
  395. package/node_modules/@sudocode-ai/mcp/dist/client.d.ts +33 -0
  396. package/node_modules/@sudocode-ai/mcp/dist/client.d.ts.map +1 -0
  397. package/node_modules/@sudocode-ai/mcp/dist/client.js +159 -0
  398. package/node_modules/@sudocode-ai/mcp/dist/client.js.map +1 -0
  399. package/node_modules/@sudocode-ai/mcp/dist/index.d.ts +6 -0
  400. package/node_modules/@sudocode-ai/mcp/dist/index.d.ts.map +1 -0
  401. package/node_modules/@sudocode-ai/mcp/dist/index.js +64 -0
  402. package/node_modules/@sudocode-ai/mcp/dist/index.js.map +1 -0
  403. package/node_modules/@sudocode-ai/mcp/dist/server.d.ts +26 -0
  404. package/node_modules/@sudocode-ai/mcp/dist/server.d.ts.map +1 -0
  405. package/node_modules/@sudocode-ai/mcp/dist/server.js +575 -0
  406. package/node_modules/@sudocode-ai/mcp/dist/server.js.map +1 -0
  407. package/node_modules/@sudocode-ai/mcp/dist/tools/analytics.d.ts +41 -0
  408. package/node_modules/@sudocode-ai/mcp/dist/tools/analytics.d.ts.map +1 -0
  409. package/node_modules/@sudocode-ai/mcp/dist/tools/analytics.js +21 -0
  410. package/node_modules/@sudocode-ai/mcp/dist/tools/analytics.js.map +1 -0
  411. package/node_modules/@sudocode-ai/mcp/dist/tools/feedback.d.ts +19 -0
  412. package/node_modules/@sudocode-ai/mcp/dist/tools/feedback.d.ts.map +1 -0
  413. package/node_modules/@sudocode-ai/mcp/dist/tools/feedback.js +24 -0
  414. package/node_modules/@sudocode-ai/mcp/dist/tools/feedback.js.map +1 -0
  415. package/node_modules/@sudocode-ai/mcp/dist/tools/init.d.ts +17 -0
  416. package/node_modules/@sudocode-ai/mcp/dist/tools/init.d.ts.map +1 -0
  417. package/node_modules/@sudocode-ai/mcp/dist/tools/init.js +15 -0
  418. package/node_modules/@sudocode-ai/mcp/dist/tools/init.js.map +1 -0
  419. package/node_modules/@sudocode-ai/mcp/dist/tools/issues.d.ts +44 -0
  420. package/node_modules/@sudocode-ai/mcp/dist/tools/issues.d.ts.map +1 -0
  421. package/node_modules/@sudocode-ai/mcp/dist/tools/issues.js +106 -0
  422. package/node_modules/@sudocode-ai/mcp/dist/tools/issues.js.map +1 -0
  423. package/node_modules/@sudocode-ai/mcp/dist/tools/references.d.ts +21 -0
  424. package/node_modules/@sudocode-ai/mcp/dist/tools/references.d.ts.map +1 -0
  425. package/node_modules/@sudocode-ai/mcp/dist/tools/references.js +49 -0
  426. package/node_modules/@sudocode-ai/mcp/dist/tools/references.js.map +1 -0
  427. package/node_modules/@sudocode-ai/mcp/dist/tools/relationships.d.ts +15 -0
  428. package/node_modules/@sudocode-ai/mcp/dist/tools/relationships.d.ts.map +1 -0
  429. package/node_modules/@sudocode-ai/mcp/dist/tools/relationships.js +18 -0
  430. package/node_modules/@sudocode-ai/mcp/dist/tools/relationships.js.map +1 -0
  431. package/node_modules/@sudocode-ai/mcp/dist/tools/specs.d.ts +35 -0
  432. package/node_modules/@sudocode-ai/mcp/dist/tools/specs.d.ts.map +1 -0
  433. package/node_modules/@sudocode-ai/mcp/dist/tools/specs.js +85 -0
  434. package/node_modules/@sudocode-ai/mcp/dist/tools/specs.js.map +1 -0
  435. package/node_modules/@sudocode-ai/mcp/dist/types.d.ts +35 -0
  436. package/node_modules/@sudocode-ai/mcp/dist/types.d.ts.map +1 -0
  437. package/node_modules/@sudocode-ai/mcp/dist/types.js +21 -0
  438. package/node_modules/@sudocode-ai/mcp/dist/types.js.map +1 -0
  439. package/node_modules/@sudocode-ai/mcp/package.json +67 -0
  440. package/node_modules/@sudocode-ai/types/README.md +7 -0
  441. package/node_modules/@sudocode-ai/types/dist/schema.d.ts +45 -0
  442. package/node_modules/@sudocode-ai/types/dist/schema.d.ts.map +1 -0
  443. package/node_modules/@sudocode-ai/types/dist/schema.js +338 -0
  444. package/node_modules/@sudocode-ai/types/dist/schema.js.map +1 -0
  445. package/node_modules/@sudocode-ai/types/package.json +46 -0
  446. package/package.json +51 -12
  447. package/index.js +0 -5
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Database service for sudocode server
3
+ * Uses shared schema from @sudocode-ai/types
4
+ */
5
+ import Database from "better-sqlite3";
6
+ import * as path from "path";
7
+ import * as fs from "fs";
8
+ import { EXECUTIONS_TABLE, EXECUTIONS_INDEXES, PROMPT_TEMPLATES_TABLE, PROMPT_TEMPLATES_INDEXES, EXECUTION_LOGS_TABLE, EXECUTION_LOGS_INDEXES, } from "@sudocode-ai/types/schema";
9
+ import { initializeDefaultTemplates } from "./prompt-templates.js";
10
+ /**
11
+ * Initialize database with CLI schema + server extensions
12
+ */
13
+ export function initDatabase(config) {
14
+ const { path: dbPath, readOnly = false } = config;
15
+ // Ensure directory exists
16
+ const dir = path.dirname(dbPath);
17
+ if (!fs.existsSync(dir)) {
18
+ fs.mkdirSync(dir, { recursive: true });
19
+ }
20
+ // Open database
21
+ const db = new Database(dbPath, {
22
+ readonly: readOnly,
23
+ fileMustExist: false,
24
+ });
25
+ // Don't modify schema if read-only
26
+ if (readOnly) {
27
+ return db;
28
+ }
29
+ // Configure database
30
+ db.pragma("journal_mode = WAL");
31
+ db.pragma("foreign_keys = ON");
32
+ db.pragma("synchronous = NORMAL");
33
+ db.pragma("temp_store = MEMORY");
34
+ // Create server-specific tables
35
+ db.exec(EXECUTIONS_TABLE);
36
+ db.exec(PROMPT_TEMPLATES_TABLE);
37
+ db.exec(EXECUTION_LOGS_TABLE);
38
+ // Create indexes
39
+ db.exec(EXECUTIONS_INDEXES);
40
+ db.exec(PROMPT_TEMPLATES_INDEXES);
41
+ db.exec(EXECUTION_LOGS_INDEXES);
42
+ // Initialize default prompt templates
43
+ initializeDefaultTemplates(db);
44
+ return db;
45
+ }
46
+ /**
47
+ * Check if database has CLI tables
48
+ */
49
+ export function hasCliTables(db) {
50
+ const result = db
51
+ .prepare(`
52
+ SELECT COUNT(*) as count
53
+ FROM sqlite_master
54
+ WHERE type='table'
55
+ AND name IN ('specs', 'issues', 'relationships', 'tags')
56
+ `)
57
+ .get();
58
+ return result.count === 4;
59
+ }
60
+ /**
61
+ * Get database info
62
+ */
63
+ export function getDatabaseInfo(db) {
64
+ const tables = db
65
+ .prepare(`
66
+ SELECT name
67
+ FROM sqlite_master
68
+ WHERE type='table'
69
+ ORDER BY name
70
+ `)
71
+ .all();
72
+ const version = db.prepare("PRAGMA user_version").get();
73
+ return {
74
+ tables: tables.map((t) => t.name),
75
+ version: version.user_version,
76
+ hasCliTables: hasCliTables(db),
77
+ };
78
+ }
79
+ /**
80
+ * Close database connection
81
+ */
82
+ export function closeDatabase(db) {
83
+ db.close();
84
+ }
85
+ //# sourceMappingURL=db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/services/db.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC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5B,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAClC,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAEhC,sCAAsC;IACtC,0BAA0B,CAAC,EAAE,CAAC,CAAC;IAE/B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,EAAqB;IAChD,MAAM,MAAM,GAAG,EAAE;SACd,OAAO,CACN;;;;;GAKH,CACE;SACA,GAAG,EAAuB,CAAC;IAE9B,OAAO,MAAM,CAAC,KAAK,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,EAAqB;IACnD,MAAM,MAAM,GAAG,EAAE;SACd,OAAO,CACN;;;;;GAKH,CACE;SACA,GAAG,EAAwB,CAAC;IAE/B,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,GAAG,EAEpD,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACjC,OAAO,EAAE,OAAO,CAAC,YAAY;QAC7B,YAAY,EAAE,YAAY,CAAC,EAAE,CAAC;KAC/B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,EAAqB;IACjD,EAAE,CAAC,KAAK,EAAE,CAAC;AACb,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Execution Lifecycle Service
3
+ *
4
+ * Centralized service for managing execution lifecycle with worktree integration.
5
+ * Coordinates between WorktreeManager and execution database services.
6
+ *
7
+ * @module services/execution-lifecycle
8
+ */
9
+ import type Database from "better-sqlite3";
10
+ import type { AgentType, Execution } from "@sudocode-ai/types";
11
+ import { type IWorktreeManager } from "../execution/worktree/manager.js";
12
+ /**
13
+ * Parameters for creating an execution with worktree
14
+ */
15
+ export interface CreateExecutionWithWorktreeParams {
16
+ issueId: string;
17
+ issueTitle: string;
18
+ agentType: AgentType;
19
+ targetBranch: string;
20
+ repoPath: string;
21
+ mode?: string;
22
+ prompt?: string;
23
+ config?: string;
24
+ }
25
+ /**
26
+ * Result of creating an execution with worktree
27
+ */
28
+ export interface CreateExecutionWithWorktreeResult {
29
+ execution: Execution;
30
+ worktreePath: string;
31
+ branchName: string;
32
+ }
33
+ /**
34
+ * ExecutionLifecycleService
35
+ *
36
+ * Manages the full lifecycle of executions with worktree support:
37
+ * - Creating executions with isolated worktrees
38
+ * - Cleaning up executions and associated worktrees
39
+ * - Handling orphaned worktrees
40
+ */
41
+ export declare class ExecutionLifecycleService {
42
+ private worktreeManager;
43
+ private db;
44
+ private repoPath;
45
+ /**
46
+ * Create a new ExecutionLifecycleService
47
+ *
48
+ * @param db - Database instance
49
+ * @param repoPath - Path to the git repository
50
+ * @param worktreeManager - Optional worktree manager (defaults to new instance)
51
+ */
52
+ constructor(db: Database.Database, repoPath: string, worktreeManager?: IWorktreeManager);
53
+ /**
54
+ * Create an execution with an isolated worktree
55
+ *
56
+ * Creates a worktree first, then creates the execution record.
57
+ * If worktree creation fails, no execution is created.
58
+ * If execution creation fails, the worktree is cleaned up.
59
+ *
60
+ * @param params - Execution creation parameters
61
+ * @returns Execution with worktree information
62
+ * @throws Error if creation fails
63
+ */
64
+ createExecutionWithWorktree(params: CreateExecutionWithWorktreeParams): Promise<CreateExecutionWithWorktreeResult>;
65
+ /**
66
+ * Check if an execution should be cleaned up based on its config
67
+ *
68
+ * @param executionId - ID of execution to check
69
+ * @returns true if should cleanup, false otherwise
70
+ */
71
+ shouldCleanupExecution(executionId: string): boolean;
72
+ /**
73
+ * Clean up an execution and its associated worktree
74
+ *
75
+ * Removes the worktree from filesystem and git metadata.
76
+ * Branch deletion is controlled by autoDeleteBranches config.
77
+ * Respects the cleanupMode configuration from execution config.
78
+ *
79
+ * IMPORTANT: The worktree_path is NEVER cleared from the database.
80
+ * This allows follow-up executions to find and reuse the same worktree path.
81
+ * The filesystem worktree is deleted, but the path remains in the DB as a historical record.
82
+ *
83
+ * @param executionId - ID of execution to cleanup
84
+ * @throws Error if cleanup fails
85
+ */
86
+ cleanupExecution(executionId: string): Promise<void>;
87
+ /**
88
+ * Clean up orphaned worktrees
89
+ *
90
+ * Finds worktrees that are registered in git but don't have
91
+ * corresponding execution records, or vice versa.
92
+ * Also cleans up worktrees for finished executions (completed/failed/stopped).
93
+ */
94
+ cleanupOrphanedWorktrees(): Promise<void>;
95
+ }
96
+ /**
97
+ * Sanitize a string to be safe for use in git branch names
98
+ *
99
+ * - Converts to lowercase
100
+ * - Replaces spaces and slashes with hyphens
101
+ * - Removes special characters
102
+ * - Limits length to 50 characters
103
+ *
104
+ * @param str - String to sanitize
105
+ * @returns Sanitized string safe for branch names
106
+ */
107
+ export declare function sanitizeForBranchName(str: string): string;
108
+ //# sourceMappingURL=execution-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-lifecycle.d.ts","sourceRoot":"","sources":["../../src/services/execution-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,kCAAkC,CAAC;AAK1C;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,eAAe,CAAmB;IAC1C,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;;;OAMG;gBAED,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,CAAC,EAAE,gBAAgB;IAcpC;;;;;;;;;;OAUG;IACG,2BAA2B,CAC/B,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,iCAAiC,CAAC;IAyG7C;;;;;OAKG;IACH,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO;IA0BpD;;;;;;;;;;;;;OAaG;IACG,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkC1D;;;;;;OAMG;IACG,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;CAwEhD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAezD"}
@@ -0,0 +1,286 @@
1
+ /**
2
+ * Execution Lifecycle Service
3
+ *
4
+ * Centralized service for managing execution lifecycle with worktree integration.
5
+ * Coordinates between WorktreeManager and execution database services.
6
+ *
7
+ * @module services/execution-lifecycle
8
+ */
9
+ import path from "path";
10
+ import { WorktreeManager, } from "../execution/worktree/manager.js";
11
+ import { getWorktreeConfig } from "../execution/worktree/config.js";
12
+ import { createExecution, getExecution } from "./executions.js";
13
+ import { randomUUID } from "crypto";
14
+ /**
15
+ * ExecutionLifecycleService
16
+ *
17
+ * Manages the full lifecycle of executions with worktree support:
18
+ * - Creating executions with isolated worktrees
19
+ * - Cleaning up executions and associated worktrees
20
+ * - Handling orphaned worktrees
21
+ */
22
+ export class ExecutionLifecycleService {
23
+ worktreeManager;
24
+ db;
25
+ repoPath;
26
+ /**
27
+ * Create a new ExecutionLifecycleService
28
+ *
29
+ * @param db - Database instance
30
+ * @param repoPath - Path to the git repository
31
+ * @param worktreeManager - Optional worktree manager (defaults to new instance)
32
+ */
33
+ constructor(db, repoPath, worktreeManager) {
34
+ this.db = db;
35
+ this.repoPath = repoPath;
36
+ // Load config and create worktree manager if not provided
37
+ if (worktreeManager) {
38
+ this.worktreeManager = worktreeManager;
39
+ }
40
+ else {
41
+ const config = getWorktreeConfig(repoPath);
42
+ this.worktreeManager = new WorktreeManager(config);
43
+ }
44
+ }
45
+ /**
46
+ * Create an execution with an isolated worktree
47
+ *
48
+ * Creates a worktree first, then creates the execution record.
49
+ * If worktree creation fails, no execution is created.
50
+ * If execution creation fails, the worktree is cleaned up.
51
+ *
52
+ * @param params - Execution creation parameters
53
+ * @returns Execution with worktree information
54
+ * @throws Error if creation fails
55
+ */
56
+ async createExecutionWithWorktree(params) {
57
+ const { issueId, issueTitle, agentType, targetBranch, repoPath } = params;
58
+ // Validation 1: Check for existing active execution for this issue
59
+ const existingExecution = this.db
60
+ .prepare(`SELECT id FROM executions
61
+ WHERE issue_id = ?
62
+ AND status = 'running'
63
+ AND worktree_path IS NOT NULL`)
64
+ .get(issueId);
65
+ if (existingExecution) {
66
+ throw new Error(`Active execution already exists for issue ${issueId}: ${existingExecution.id}`);
67
+ }
68
+ // Validation 2: Validate git repository
69
+ const isValidRepo = await this.worktreeManager.isValidRepo(repoPath);
70
+ if (!isValidRepo) {
71
+ throw new Error(`Not a git repository: ${repoPath}`);
72
+ }
73
+ // Validation 3: Validate target branch exists
74
+ const branches = await this.worktreeManager.listBranches(repoPath);
75
+ if (!branches.includes(targetBranch)) {
76
+ throw new Error(`Target branch does not exist: ${targetBranch}`);
77
+ }
78
+ const config = this.worktreeManager.getConfig();
79
+ // Generate execution ID
80
+ const executionId = randomUUID();
81
+ // Determine branch name based on autoCreateBranches setting
82
+ let branchName;
83
+ if (config.autoCreateBranches) {
84
+ // Generate branch name: {branchPrefix}/{execution-id}/{sanitized-issue-title}
85
+ const sanitizedTitle = sanitizeForBranchName(issueTitle);
86
+ branchName = `${config.branchPrefix}/${executionId.substring(0, 8)}/${sanitizedTitle}`;
87
+ }
88
+ else {
89
+ // Use target branch directly when not auto-creating branches
90
+ branchName = targetBranch;
91
+ }
92
+ // Generate worktree path: {repoPath}/{worktreeStoragePath}/{execution-id}
93
+ const worktreePath = path.join(repoPath, config.worktreeStoragePath, executionId);
94
+ let worktreeCreated = false;
95
+ try {
96
+ // Step 1: Create worktree
97
+ await this.worktreeManager.createWorktree({
98
+ repoPath,
99
+ branchName,
100
+ worktreePath,
101
+ baseBranch: targetBranch,
102
+ createBranch: config.autoCreateBranches,
103
+ });
104
+ worktreeCreated = true;
105
+ // Step 2: Create execution record in database
106
+ const execution = createExecution(this.db, {
107
+ id: executionId,
108
+ issue_id: issueId,
109
+ agent_type: agentType,
110
+ mode: params.mode,
111
+ prompt: params.prompt,
112
+ config: params.config,
113
+ target_branch: targetBranch,
114
+ branch_name: branchName,
115
+ worktree_path: worktreePath,
116
+ });
117
+ return {
118
+ execution,
119
+ worktreePath,
120
+ branchName,
121
+ };
122
+ }
123
+ catch (error) {
124
+ // If worktree was created but execution creation failed, cleanup worktree
125
+ if (worktreeCreated) {
126
+ try {
127
+ await this.worktreeManager.cleanupWorktree(worktreePath, repoPath);
128
+ }
129
+ catch (cleanupError) {
130
+ // Log cleanup error but throw original error
131
+ console.error(`Failed to cleanup worktree after execution creation failure:`, cleanupError);
132
+ }
133
+ }
134
+ // Re-throw the original error
135
+ throw error;
136
+ }
137
+ }
138
+ /**
139
+ * Check if an execution should be cleaned up based on its config
140
+ *
141
+ * @param executionId - ID of execution to check
142
+ * @returns true if should cleanup, false otherwise
143
+ */
144
+ shouldCleanupExecution(executionId) {
145
+ const execution = getExecution(this.db, executionId);
146
+ if (!execution) {
147
+ return false;
148
+ }
149
+ // Check if cleanupMode is set to 'manual'
150
+ if (execution.config) {
151
+ try {
152
+ const config = JSON.parse(execution.config);
153
+ if (config.cleanupMode === "manual" || config.cleanupMode === "never") {
154
+ return false;
155
+ }
156
+ }
157
+ catch (error) {
158
+ console.error(`Failed to parse execution config for ${executionId}:`, error);
159
+ // Default to cleanup on parse error
160
+ }
161
+ }
162
+ return true;
163
+ }
164
+ /**
165
+ * Clean up an execution and its associated worktree
166
+ *
167
+ * Removes the worktree from filesystem and git metadata.
168
+ * Branch deletion is controlled by autoDeleteBranches config.
169
+ * Respects the cleanupMode configuration from execution config.
170
+ *
171
+ * IMPORTANT: The worktree_path is NEVER cleared from the database.
172
+ * This allows follow-up executions to find and reuse the same worktree path.
173
+ * The filesystem worktree is deleted, but the path remains in the DB as a historical record.
174
+ *
175
+ * @param executionId - ID of execution to cleanup
176
+ * @throws Error if cleanup fails
177
+ */
178
+ async cleanupExecution(executionId) {
179
+ // Check if we should cleanup based on config
180
+ if (!this.shouldCleanupExecution(executionId)) {
181
+ return;
182
+ }
183
+ // Get execution from database
184
+ const execution = getExecution(this.db, executionId);
185
+ if (!execution) {
186
+ // Execution doesn't exist, nothing to cleanup
187
+ return;
188
+ }
189
+ // If execution has a worktree path, clean up the filesystem worktree
190
+ // but KEEP the worktree_path in the database for follow-up executions
191
+ if (execution.worktree_path) {
192
+ try {
193
+ await this.worktreeManager.cleanupWorktree(execution.worktree_path, this.repoPath);
194
+ // NOTE: We do NOT set worktree_path to null in the database
195
+ // Follow-up executions need this path to recreate the worktree
196
+ }
197
+ catch (error) {
198
+ // Log error but don't fail - cleanup is best-effort
199
+ console.error(`Failed to cleanup worktree for execution ${executionId}:`, error);
200
+ }
201
+ }
202
+ }
203
+ /**
204
+ * Clean up orphaned worktrees
205
+ *
206
+ * Finds worktrees that are registered in git but don't have
207
+ * corresponding execution records, or vice versa.
208
+ * Also cleans up worktrees for finished executions (completed/failed/stopped).
209
+ */
210
+ async cleanupOrphanedWorktrees() {
211
+ const repoPath = this.repoPath;
212
+ const config = this.worktreeManager.getConfig();
213
+ try {
214
+ // List all worktrees from git
215
+ const worktrees = await this.worktreeManager.listWorktrees(repoPath);
216
+ // Filter to worktrees in our storage path
217
+ const managedWorktrees = worktrees.filter((w) => w.path.includes(config.worktreeStoragePath));
218
+ // For each managed worktree, check if it has a corresponding execution
219
+ for (const worktree of managedWorktrees) {
220
+ const worktreePath = worktree.path;
221
+ // Try to extract execution ID from path
222
+ const executionId = path.basename(worktreePath);
223
+ // Check if execution exists in database
224
+ const execution = getExecution(this.db, executionId);
225
+ if (!execution) {
226
+ // Orphaned worktree - cleanup
227
+ console.log(`Cleaning up orphaned worktree: ${worktreePath} (no execution found)`);
228
+ try {
229
+ await this.worktreeManager.cleanupWorktree(worktreePath, repoPath);
230
+ }
231
+ catch (error) {
232
+ console.error(`Failed to cleanup orphaned worktree ${worktreePath}:`, error);
233
+ }
234
+ }
235
+ else if (execution.status === "completed" ||
236
+ execution.status === "failed" ||
237
+ execution.status === "stopped") {
238
+ // Execution is finished but worktree still exists
239
+ // Check if we should cleanup based on execution config
240
+ if (!this.shouldCleanupExecution(executionId)) {
241
+ console.log(`Skipping cleanup for finished execution ${executionId} (manual cleanup mode)`);
242
+ continue;
243
+ }
244
+ console.log(`Cleaning up worktree for finished execution ${executionId} (status: ${execution.status})`);
245
+ try {
246
+ await this.worktreeManager.cleanupWorktree(worktreePath, repoPath);
247
+ // NOTE: We do NOT set worktree_path to null in the database
248
+ // Follow-up executions need this path to recreate the worktree
249
+ }
250
+ catch (error) {
251
+ console.error(`Failed to cleanup worktree for finished execution ${executionId}:`, error);
252
+ }
253
+ }
254
+ }
255
+ }
256
+ catch (error) {
257
+ console.error(`Failed to cleanup orphaned worktrees in ${repoPath}:`, error);
258
+ }
259
+ }
260
+ }
261
+ /**
262
+ * Sanitize a string to be safe for use in git branch names
263
+ *
264
+ * - Converts to lowercase
265
+ * - Replaces spaces and slashes with hyphens
266
+ * - Removes special characters
267
+ * - Limits length to 50 characters
268
+ *
269
+ * @param str - String to sanitize
270
+ * @returns Sanitized string safe for branch names
271
+ */
272
+ export function sanitizeForBranchName(str) {
273
+ return (str
274
+ .toLowerCase()
275
+ // Replace spaces and slashes with hyphens
276
+ .replace(/[\s/]+/g, "-")
277
+ // Remove special characters (keep alphanumeric, hyphens, underscores)
278
+ .replace(/[^a-z0-9\-_]/g, "")
279
+ // Remove consecutive hyphens
280
+ .replace(/-+/g, "-")
281
+ // Remove leading/trailing hyphens
282
+ .replace(/^-+|-+$/g, "")
283
+ // Limit length
284
+ .substring(0, 50));
285
+ }
286
+ //# sourceMappingURL=execution-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-lifecycle.js","sourceRoot":"","sources":["../../src/services/execution-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EACL,eAAe,GAEhB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAyBpC;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAyB;IAC5B,eAAe,CAAmB;IAClC,EAAE,CAAoB;IACtB,QAAQ,CAAS;IAEzB;;;;;;OAMG;IACH,YACE,EAAqB,EACrB,QAAgB,EAChB,eAAkC;QAElC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,0DAA0D;QAC1D,IAAI,eAAe,EAAE,CAAC;YACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACzC,CAAC;aAAM,CAAC;YACN,MAAM,MAAM,GAAG,iBAAiB,CAAC,QAAQ,CAAC,CAAC;YAC3C,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;QACrD,CAAC;IACH,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E,GAAG,CAAC;QACpB,kCAAkC;SACjC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;QACxB,eAAe;SACd,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CACpB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Execution Service
3
+ *
4
+ * High-level service for managing issue-to-execution transformations.
5
+ * Coordinates between template rendering, worktree management, and workflow execution.
6
+ *
7
+ * @module services/execution-service
8
+ */
9
+ import type Database from "better-sqlite3";
10
+ import type { Execution } from "@sudocode-ai/types";
11
+ import { ExecutionLifecycleService } from "./execution-lifecycle.js";
12
+ import type { TransportManager } from "../execution/transport/transport-manager.js";
13
+ /**
14
+ * Configuration for creating an execution
15
+ */
16
+ export interface ExecutionConfig {
17
+ mode?: "worktree" | "local";
18
+ model?: string;
19
+ timeout?: number;
20
+ baseBranch?: string;
21
+ branchName?: string;
22
+ checkpointInterval?: number;
23
+ continueOnStepFailure?: boolean;
24
+ captureFileChanges?: boolean;
25
+ captureToolCalls?: boolean;
26
+ }
27
+ /**
28
+ * Template variable context for rendering
29
+ */
30
+ export interface TemplateContext {
31
+ issueId: string;
32
+ title: string;
33
+ description: string;
34
+ relatedSpecs?: Array<{
35
+ id: string;
36
+ title: string;
37
+ }>;
38
+ feedback?: Array<{
39
+ issueId: string;
40
+ content: string;
41
+ }>;
42
+ }
43
+ /**
44
+ * Result from prepareExecution - preview before starting
45
+ */
46
+ export interface ExecutionPrepareResult {
47
+ renderedPrompt: string;
48
+ issue: {
49
+ id: string;
50
+ title: string;
51
+ content: string;
52
+ };
53
+ relatedSpecs: Array<{
54
+ id: string;
55
+ title: string;
56
+ }>;
57
+ defaultConfig: ExecutionConfig;
58
+ warnings?: string[];
59
+ errors?: string[];
60
+ }
61
+ /**
62
+ * ExecutionService
63
+ *
64
+ * Manages the full lifecycle of issue-based executions:
65
+ * - Preparing execution with template rendering
66
+ * - Creating and starting executions with worktree isolation
67
+ * - Creating follow-up executions that reuse worktrees
68
+ * - Canceling and cleaning up executions
69
+ */
70
+ export declare class ExecutionService {
71
+ private db;
72
+ private templateEngine;
73
+ private lifecycleService;
74
+ private repoPath;
75
+ private transportManager?;
76
+ private activeOrchestrators;
77
+ /**
78
+ * Create a new ExecutionService
79
+ *
80
+ * @param db - Database instance
81
+ * @param repoPath - Path to the git repository
82
+ * @param lifecycleService - Optional execution lifecycle service (creates one if not provided)
83
+ * @param transportManager - Optional transport manager for SSE streaming
84
+ */
85
+ constructor(db: Database.Database, repoPath: string, lifecycleService?: ExecutionLifecycleService, transportManager?: TransportManager);
86
+ /**
87
+ * Prepare execution - load issue, render template, return preview
88
+ *
89
+ * This method loads the issue and related context, renders the template,
90
+ * and returns a preview for the user to review before starting execution.
91
+ *
92
+ * @param issueId - ID of issue to prepare execution for
93
+ * @param options - Optional template and config overrides
94
+ * @returns Execution prepare result with rendered prompt and context
95
+ */
96
+ prepareExecution(issueId: string, options?: {
97
+ templateId?: string;
98
+ config?: Partial<ExecutionConfig>;
99
+ }): Promise<ExecutionPrepareResult>;
100
+ /**
101
+ * Create and start execution
102
+ *
103
+ * Creates an execution record, sets up worktree (if needed), and starts
104
+ * workflow execution. Returns the execution record immediately while
105
+ * workflow runs in the background.
106
+ *
107
+ * @param issueId - ID of issue to execute
108
+ * @param config - Execution configuration
109
+ * @param prompt - Rendered prompt to execute
110
+ * @returns Created execution record
111
+ */
112
+ createExecution(issueId: string, config: ExecutionConfig, prompt: string): Promise<Execution>;
113
+ /**
114
+ * Create follow-up execution - reuse worktree from previous execution
115
+ *
116
+ * Creates a new execution that reuses the worktree from a previous execution,
117
+ * appending feedback or additional context to the prompt.
118
+ *
119
+ * @param executionId - ID of previous execution to follow up on
120
+ * @param feedback - Additional feedback/context to append to prompt
121
+ * @returns Created follow-up execution record
122
+ */
123
+ createFollowUp(executionId: string, feedback: string): Promise<Execution>;
124
+ /**
125
+ * Cancel a running execution
126
+ *
127
+ * Stops the workflow execution and marks the execution as cancelled.
128
+ * Optionally cleans up the worktree based on config.
129
+ *
130
+ * @param executionId - ID of execution to cancel
131
+ */
132
+ cancelExecution(executionId: string): Promise<void>;
133
+ /**
134
+ * Clean up execution resources
135
+ *
136
+ * Removes the worktree and associated files. This is called automatically
137
+ * on workflow completion, or can be called manually.
138
+ *
139
+ * @param executionId - ID of execution to clean up
140
+ */
141
+ cleanupExecution(executionId: string): Promise<void>;
142
+ /**
143
+ * Check if worktree exists in filesystem for an execution
144
+ *
145
+ * @param executionId - ID of execution to check
146
+ * @returns true if worktree exists, false otherwise
147
+ */
148
+ worktreeExists(executionId: string): Promise<boolean>;
149
+ /**
150
+ * Delete worktree for an execution
151
+ *
152
+ * Manually deletes the worktree for a specific execution, regardless of
153
+ * cleanupMode configuration. This allows users to manually cleanup worktrees
154
+ * when they're configured for manual cleanup.
155
+ *
156
+ * @param executionId - ID of execution whose worktree to delete
157
+ * @throws Error if execution not found, has no worktree, or worktree doesn't exist
158
+ */
159
+ deleteWorktree(executionId: string): Promise<void>;
160
+ /**
161
+ * Shutdown execution service - cancel all active executions
162
+ *
163
+ * This is called during server shutdown to gracefully terminate
164
+ * all running executions before the server exits.
165
+ */
166
+ shutdown(): Promise<void>;
167
+ /**
168
+ * List all executions for an issue
169
+ *
170
+ * Returns all executions associated with a specific issue,
171
+ * ordered by creation time (most recent first).
172
+ *
173
+ * @param issueId - ID of issue to list executions for
174
+ * @returns Array of executions for the issue
175
+ */
176
+ listExecutions(issueId: string): Execution[];
177
+ /**
178
+ * Get a single execution by ID
179
+ *
180
+ * @param executionId - ID of execution to retrieve
181
+ * @returns Execution or null if not found
182
+ */
183
+ getExecution(executionId: string): Execution | null;
184
+ }
185
+ //# sourceMappingURL=execution-service.d.ts.map