@sudocode-ai/local-server 0.1.6 → 0.1.8

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 (361) hide show
  1. package/README.md +6 -0
  2. package/dist/errors/agent-errors.d.ts +43 -0
  3. package/dist/errors/agent-errors.d.ts.map +1 -0
  4. package/dist/errors/agent-errors.js +69 -0
  5. package/dist/errors/agent-errors.js.map +1 -0
  6. package/dist/execution/adapters/claude-adapter.d.ts +63 -0
  7. package/dist/execution/adapters/claude-adapter.d.ts.map +1 -0
  8. package/dist/execution/adapters/claude-adapter.js +82 -0
  9. package/dist/execution/adapters/claude-adapter.js.map +1 -0
  10. package/dist/execution/adapters/codex-adapter.d.ts +67 -0
  11. package/dist/execution/adapters/codex-adapter.d.ts.map +1 -0
  12. package/dist/execution/adapters/codex-adapter.js +183 -0
  13. package/dist/execution/adapters/codex-adapter.js.map +1 -0
  14. package/dist/execution/adapters/codex-config-builder.d.ts +30 -0
  15. package/dist/execution/adapters/codex-config-builder.d.ts.map +1 -0
  16. package/dist/execution/adapters/codex-config-builder.js +110 -0
  17. package/dist/execution/adapters/codex-config-builder.js.map +1 -0
  18. package/dist/execution/adapters/copilot-adapter.d.ts +94 -0
  19. package/dist/execution/adapters/copilot-adapter.d.ts.map +1 -0
  20. package/dist/execution/adapters/copilot-adapter.js +163 -0
  21. package/dist/execution/adapters/copilot-adapter.js.map +1 -0
  22. package/dist/execution/adapters/copilot-config-builder.d.ts +48 -0
  23. package/dist/execution/adapters/copilot-config-builder.d.ts.map +1 -0
  24. package/dist/execution/adapters/copilot-config-builder.js +125 -0
  25. package/dist/execution/adapters/copilot-config-builder.js.map +1 -0
  26. package/dist/execution/adapters/cursor-adapter.d.ts +66 -0
  27. package/dist/execution/adapters/cursor-adapter.d.ts.map +1 -0
  28. package/dist/execution/adapters/cursor-adapter.js +121 -0
  29. package/dist/execution/adapters/cursor-adapter.js.map +1 -0
  30. package/dist/execution/adapters/cursor-config-builder.d.ts +29 -0
  31. package/dist/execution/adapters/cursor-config-builder.d.ts.map +1 -0
  32. package/dist/execution/adapters/cursor-config-builder.js +49 -0
  33. package/dist/execution/adapters/cursor-config-builder.js.map +1 -0
  34. package/dist/execution/adapters/shared/config-presets.d.ts +102 -0
  35. package/dist/execution/adapters/shared/config-presets.d.ts.map +1 -0
  36. package/dist/execution/adapters/shared/config-presets.js +205 -0
  37. package/dist/execution/adapters/shared/config-presets.js.map +1 -0
  38. package/dist/execution/adapters/shared/config-utils.d.ts +95 -0
  39. package/dist/execution/adapters/shared/config-utils.d.ts.map +1 -0
  40. package/dist/execution/adapters/shared/config-utils.js +163 -0
  41. package/dist/execution/adapters/shared/config-utils.js.map +1 -0
  42. package/dist/execution/adapters/shared/index.d.ts +8 -0
  43. package/dist/execution/adapters/shared/index.d.ts.map +1 -0
  44. package/dist/execution/adapters/shared/index.js +8 -0
  45. package/dist/execution/adapters/shared/index.js.map +1 -0
  46. package/dist/execution/executors/agent-executor-wrapper.d.ts +153 -0
  47. package/dist/execution/executors/agent-executor-wrapper.d.ts.map +1 -0
  48. package/dist/execution/executors/agent-executor-wrapper.js +652 -0
  49. package/dist/execution/executors/agent-executor-wrapper.js.map +1 -0
  50. package/dist/execution/executors/executor-factory.d.ts +95 -0
  51. package/dist/execution/executors/executor-factory.d.ts.map +1 -0
  52. package/dist/execution/executors/executor-factory.js +120 -0
  53. package/dist/execution/executors/executor-factory.js.map +1 -0
  54. package/dist/execution/output/ag-ui-adapter.d.ts +0 -2
  55. package/dist/execution/output/ag-ui-adapter.d.ts.map +1 -1
  56. package/dist/execution/output/ag-ui-adapter.js +0 -2
  57. package/dist/execution/output/ag-ui-adapter.js.map +1 -1
  58. package/dist/execution/output/index.d.ts +0 -3
  59. package/dist/execution/output/index.d.ts.map +1 -1
  60. package/dist/execution/output/index.js +0 -2
  61. package/dist/execution/output/index.js.map +1 -1
  62. package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts +108 -0
  63. package/dist/execution/output/normalized-to-ag-ui-adapter.d.ts.map +1 -0
  64. package/dist/execution/output/normalized-to-ag-ui-adapter.js +321 -0
  65. package/dist/execution/output/normalized-to-ag-ui-adapter.js.map +1 -0
  66. package/dist/execution/process/builders/claude.d.ts +25 -58
  67. package/dist/execution/process/builders/claude.d.ts.map +1 -1
  68. package/dist/execution/process/builders/claude.js +153 -19
  69. package/dist/execution/process/builders/claude.js.map +1 -1
  70. package/dist/execution/transport/ipc-transport-manager.d.ts +74 -0
  71. package/dist/execution/transport/ipc-transport-manager.d.ts.map +1 -0
  72. package/dist/execution/transport/ipc-transport-manager.js +104 -0
  73. package/dist/execution/transport/ipc-transport-manager.js.map +1 -0
  74. package/dist/execution/transport/transport-manager.d.ts.map +1 -1
  75. package/dist/execution/transport/transport-manager.js +3 -0
  76. package/dist/execution/transport/transport-manager.js.map +1 -1
  77. package/dist/execution/worktree/conflict-detector.d.ts +85 -0
  78. package/dist/execution/worktree/conflict-detector.d.ts.map +1 -0
  79. package/dist/execution/worktree/conflict-detector.js +129 -0
  80. package/dist/execution/worktree/conflict-detector.js.map +1 -0
  81. package/dist/execution/worktree/git-cli.d.ts +9 -0
  82. package/dist/execution/worktree/git-cli.d.ts.map +1 -1
  83. package/dist/execution/worktree/git-cli.js +10 -0
  84. package/dist/execution/worktree/git-cli.js.map +1 -1
  85. package/dist/execution/worktree/git-sync-cli.d.ts +187 -0
  86. package/dist/execution/worktree/git-sync-cli.d.ts.map +1 -0
  87. package/dist/execution/worktree/git-sync-cli.js +350 -0
  88. package/dist/execution/worktree/git-sync-cli.js.map +1 -0
  89. package/dist/execution/worktree/manager.d.ts +18 -0
  90. package/dist/execution/worktree/manager.d.ts.map +1 -1
  91. package/dist/execution/worktree/manager.js +9 -3
  92. package/dist/execution/worktree/manager.js.map +1 -1
  93. package/dist/index.d.ts +1 -3
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +175 -195
  96. package/dist/index.js.map +1 -1
  97. package/dist/middleware/project-context.d.ts +37 -0
  98. package/dist/middleware/project-context.d.ts.map +1 -0
  99. package/dist/middleware/project-context.js +91 -0
  100. package/dist/middleware/project-context.js.map +1 -0
  101. package/dist/public/assets/index-Bb_W5bUr.css +1 -0
  102. package/dist/public/assets/index-CFKL113G.js +710 -0
  103. package/dist/public/assets/index-CFKL113G.js.map +1 -0
  104. package/dist/public/assets/{react-vendor-ByUx1V_q.js → react-vendor-DiL5hC7l.js} +2 -2
  105. package/dist/public/assets/{react-vendor-ByUx1V_q.js.map → react-vendor-DiL5hC7l.js.map} +1 -1
  106. package/dist/public/assets/ui-vendor-B4WMPEfa.js +54 -0
  107. package/dist/public/assets/ui-vendor-B4WMPEfa.js.map +1 -0
  108. package/dist/public/index.html +4 -4
  109. package/dist/routes/agents.d.ts +3 -0
  110. package/dist/routes/agents.d.ts.map +1 -0
  111. package/dist/routes/agents.js +62 -0
  112. package/dist/routes/agents.js.map +1 -0
  113. package/dist/routes/config.d.ts +3 -0
  114. package/dist/routes/config.d.ts.map +1 -0
  115. package/dist/routes/config.js +25 -0
  116. package/dist/routes/config.js.map +1 -0
  117. package/dist/routes/editors.d.ts +15 -0
  118. package/dist/routes/editors.d.ts.map +1 -0
  119. package/dist/routes/editors.js +98 -0
  120. package/dist/routes/editors.js.map +1 -0
  121. package/dist/routes/executions-stream.d.ts +8 -5
  122. package/dist/routes/executions-stream.d.ts.map +1 -1
  123. package/dist/routes/executions-stream.js +10 -6
  124. package/dist/routes/executions-stream.js.map +1 -1
  125. package/dist/routes/executions.d.ts +6 -10
  126. package/dist/routes/executions.d.ts.map +1 -1
  127. package/dist/routes/executions.js +506 -54
  128. package/dist/routes/executions.js.map +1 -1
  129. package/dist/routes/feedback.d.ts +3 -2
  130. package/dist/routes/feedback.d.ts.map +1 -1
  131. package/dist/routes/feedback.js +32 -22
  132. package/dist/routes/feedback.js.map +1 -1
  133. package/dist/routes/files.d.ts +18 -0
  134. package/dist/routes/files.d.ts.map +1 -0
  135. package/dist/routes/files.js +89 -0
  136. package/dist/routes/files.js.map +1 -0
  137. package/dist/routes/issues.d.ts +3 -2
  138. package/dist/routes/issues.d.ts.map +1 -1
  139. package/dist/routes/issues.js +19 -18
  140. package/dist/routes/issues.js.map +1 -1
  141. package/dist/routes/projects.d.ts +11 -0
  142. package/dist/routes/projects.d.ts.map +1 -0
  143. package/dist/routes/projects.js +447 -0
  144. package/dist/routes/projects.js.map +1 -0
  145. package/dist/routes/relationships.d.ts +3 -2
  146. package/dist/routes/relationships.d.ts.map +1 -1
  147. package/dist/routes/relationships.js +12 -10
  148. package/dist/routes/relationships.js.map +1 -1
  149. package/dist/routes/repo-info.d.ts +3 -0
  150. package/dist/routes/repo-info.d.ts.map +1 -0
  151. package/dist/routes/repo-info.js +126 -0
  152. package/dist/routes/repo-info.js.map +1 -0
  153. package/dist/routes/specs.d.ts +3 -2
  154. package/dist/routes/specs.d.ts.map +1 -1
  155. package/dist/routes/specs.js +19 -18
  156. package/dist/routes/specs.js.map +1 -1
  157. package/dist/services/agent-registry.d.ts +140 -0
  158. package/dist/services/agent-registry.d.ts.map +1 -0
  159. package/dist/services/agent-registry.js +272 -0
  160. package/dist/services/agent-registry.js.map +1 -0
  161. package/dist/services/db.d.ts.map +1 -1
  162. package/dist/services/db.js +19 -14
  163. package/dist/services/db.js.map +1 -1
  164. package/dist/services/editor-service.d.ts +57 -0
  165. package/dist/services/editor-service.d.ts.map +1 -0
  166. package/dist/services/editor-service.js +204 -0
  167. package/dist/services/editor-service.js.map +1 -0
  168. package/dist/services/execution-changes-service.d.ts +92 -0
  169. package/dist/services/execution-changes-service.d.ts.map +1 -0
  170. package/dist/services/execution-changes-service.js +546 -0
  171. package/dist/services/execution-changes-service.js.map +1 -0
  172. package/dist/services/execution-lifecycle.d.ts +1 -0
  173. package/dist/services/execution-lifecycle.d.ts.map +1 -1
  174. package/dist/services/execution-lifecycle.js +37 -7
  175. package/dist/services/execution-lifecycle.js.map +1 -1
  176. package/dist/services/execution-logs-store.d.ts +75 -0
  177. package/dist/services/execution-logs-store.d.ts.map +1 -1
  178. package/dist/services/execution-logs-store.js +142 -2
  179. package/dist/services/execution-logs-store.js.map +1 -1
  180. package/dist/services/execution-service.d.ts +50 -58
  181. package/dist/services/execution-service.d.ts.map +1 -1
  182. package/dist/services/execution-service.js +433 -448
  183. package/dist/services/execution-service.js.map +1 -1
  184. package/dist/services/execution-worker-pool.d.ts +116 -0
  185. package/dist/services/execution-worker-pool.d.ts.map +1 -0
  186. package/dist/services/execution-worker-pool.js +326 -0
  187. package/dist/services/execution-worker-pool.js.map +1 -0
  188. package/dist/services/executions.d.ts +3 -0
  189. package/dist/services/executions.d.ts.map +1 -1
  190. package/dist/services/executions.js +11 -2
  191. package/dist/services/executions.js.map +1 -1
  192. package/dist/services/export.d.ts +8 -2
  193. package/dist/services/export.d.ts.map +1 -1
  194. package/dist/services/export.js +29 -23
  195. package/dist/services/export.js.map +1 -1
  196. package/dist/services/feedback.d.ts +16 -0
  197. package/dist/services/feedback.d.ts.map +1 -1
  198. package/dist/services/feedback.js +25 -1
  199. package/dist/services/feedback.js.map +1 -1
  200. package/dist/services/file-search/git-ls-files-strategy.d.ts +72 -0
  201. package/dist/services/file-search/git-ls-files-strategy.d.ts.map +1 -0
  202. package/dist/services/file-search/git-ls-files-strategy.js +176 -0
  203. package/dist/services/file-search/git-ls-files-strategy.js.map +1 -0
  204. package/dist/services/file-search/index.d.ts +9 -0
  205. package/dist/services/file-search/index.d.ts.map +1 -0
  206. package/dist/services/file-search/index.js +10 -0
  207. package/dist/services/file-search/index.js.map +1 -0
  208. package/dist/services/file-search/registry.d.ts +97 -0
  209. package/dist/services/file-search/registry.d.ts.map +1 -0
  210. package/dist/services/file-search/registry.js +140 -0
  211. package/dist/services/file-search/registry.js.map +1 -0
  212. package/dist/services/file-search/strategy.d.ts +58 -0
  213. package/dist/services/file-search/strategy.d.ts.map +1 -0
  214. package/dist/services/file-search/strategy.js +8 -0
  215. package/dist/services/file-search/strategy.js.map +1 -0
  216. package/dist/services/project-context.d.ts +69 -0
  217. package/dist/services/project-context.d.ts.map +1 -0
  218. package/dist/services/project-context.js +113 -0
  219. package/dist/services/project-context.js.map +1 -0
  220. package/dist/services/project-manager.d.ts +95 -0
  221. package/dist/services/project-manager.d.ts.map +1 -0
  222. package/dist/services/project-manager.js +388 -0
  223. package/dist/services/project-manager.js.map +1 -0
  224. package/dist/services/project-registry.d.ts +98 -0
  225. package/dist/services/project-registry.d.ts.map +1 -0
  226. package/dist/services/project-registry.js +289 -0
  227. package/dist/services/project-registry.js.map +1 -0
  228. package/dist/services/prompt-resolver.d.ts +97 -0
  229. package/dist/services/prompt-resolver.d.ts.map +1 -0
  230. package/dist/services/prompt-resolver.js +377 -0
  231. package/dist/services/prompt-resolver.js.map +1 -0
  232. package/dist/services/repo-info.d.ts +29 -0
  233. package/dist/services/repo-info.d.ts.map +1 -0
  234. package/dist/services/repo-info.js +99 -0
  235. package/dist/services/repo-info.js.map +1 -0
  236. package/dist/services/watcher.d.ts +3 -4
  237. package/dist/services/watcher.d.ts.map +1 -1
  238. package/dist/services/watcher.js +18 -35
  239. package/dist/services/watcher.js.map +1 -1
  240. package/dist/services/websocket.d.ts +51 -15
  241. package/dist/services/websocket.d.ts.map +1 -1
  242. package/dist/services/websocket.js +169 -40
  243. package/dist/services/websocket.js.map +1 -1
  244. package/dist/services/worktree-sync-service.d.ts +228 -0
  245. package/dist/services/worktree-sync-service.d.ts.map +1 -0
  246. package/dist/services/worktree-sync-service.js +563 -0
  247. package/dist/services/worktree-sync-service.js.map +1 -0
  248. package/dist/types/editor.d.ts +49 -0
  249. package/dist/types/editor.d.ts.map +1 -0
  250. package/dist/types/editor.js +50 -0
  251. package/dist/types/editor.js.map +1 -0
  252. package/dist/types/project.d.ts +58 -0
  253. package/dist/types/project.d.ts.map +1 -0
  254. package/dist/types/project.js +10 -0
  255. package/dist/types/project.js.map +1 -0
  256. package/dist/utils/executable-check.d.ts +36 -0
  257. package/dist/utils/executable-check.d.ts.map +1 -0
  258. package/dist/utils/executable-check.js +79 -0
  259. package/dist/utils/executable-check.js.map +1 -0
  260. package/dist/workers/execution-worker.d.ts +18 -0
  261. package/dist/workers/execution-worker.d.ts.map +1 -0
  262. package/dist/workers/execution-worker.js +340 -0
  263. package/dist/workers/execution-worker.js.map +1 -0
  264. package/dist/workers/worker-ipc.d.ts +84 -0
  265. package/dist/workers/worker-ipc.d.ts.map +1 -0
  266. package/dist/workers/worker-ipc.js +29 -0
  267. package/dist/workers/worker-ipc.js.map +1 -0
  268. package/package.json +6 -4
  269. package/dist/execution/engine/engine.d.ts +0 -103
  270. package/dist/execution/engine/engine.d.ts.map +0 -1
  271. package/dist/execution/engine/engine.js +0 -10
  272. package/dist/execution/engine/engine.js.map +0 -1
  273. package/dist/execution/engine/simple-engine.d.ts +0 -190
  274. package/dist/execution/engine/simple-engine.d.ts.map +0 -1
  275. package/dist/execution/engine/simple-engine.js +0 -611
  276. package/dist/execution/engine/simple-engine.js.map +0 -1
  277. package/dist/execution/engine/types.d.ts +0 -116
  278. package/dist/execution/engine/types.d.ts.map +0 -1
  279. package/dist/execution/engine/types.js +0 -10
  280. package/dist/execution/engine/types.js.map +0 -1
  281. package/dist/execution/output/ag-ui-integration.d.ts +0 -96
  282. package/dist/execution/output/ag-ui-integration.d.ts.map +0 -1
  283. package/dist/execution/output/ag-ui-integration.js +0 -96
  284. package/dist/execution/output/ag-ui-integration.js.map +0 -1
  285. package/dist/execution/output/claude-code-output-processor.d.ts +0 -321
  286. package/dist/execution/output/claude-code-output-processor.d.ts.map +0 -1
  287. package/dist/execution/output/claude-code-output-processor.js +0 -769
  288. package/dist/execution/output/claude-code-output-processor.js.map +0 -1
  289. package/dist/execution/process/index.d.ts +0 -15
  290. package/dist/execution/process/index.d.ts.map +0 -1
  291. package/dist/execution/process/index.js +0 -15
  292. package/dist/execution/process/index.js.map +0 -1
  293. package/dist/execution/process/manager.d.ts +0 -133
  294. package/dist/execution/process/manager.d.ts.map +0 -1
  295. package/dist/execution/process/manager.js +0 -10
  296. package/dist/execution/process/manager.js.map +0 -1
  297. package/dist/execution/process/simple-manager.d.ts +0 -102
  298. package/dist/execution/process/simple-manager.d.ts.map +0 -1
  299. package/dist/execution/process/simple-manager.js +0 -336
  300. package/dist/execution/process/simple-manager.js.map +0 -1
  301. package/dist/execution/process/types.d.ts +0 -105
  302. package/dist/execution/process/types.d.ts.map +0 -1
  303. package/dist/execution/process/types.js +0 -10
  304. package/dist/execution/process/types.js.map +0 -1
  305. package/dist/execution/process/utils.d.ts +0 -53
  306. package/dist/execution/process/utils.d.ts.map +0 -1
  307. package/dist/execution/process/utils.js +0 -97
  308. package/dist/execution/process/utils.js.map +0 -1
  309. package/dist/execution/resilience/circuit-breaker.d.ts +0 -170
  310. package/dist/execution/resilience/circuit-breaker.d.ts.map +0 -1
  311. package/dist/execution/resilience/circuit-breaker.js +0 -291
  312. package/dist/execution/resilience/circuit-breaker.js.map +0 -1
  313. package/dist/execution/resilience/executor.d.ts +0 -109
  314. package/dist/execution/resilience/executor.d.ts.map +0 -1
  315. package/dist/execution/resilience/executor.js +0 -10
  316. package/dist/execution/resilience/executor.js.map +0 -1
  317. package/dist/execution/resilience/index.d.ts +0 -14
  318. package/dist/execution/resilience/index.d.ts.map +0 -1
  319. package/dist/execution/resilience/index.js +0 -15
  320. package/dist/execution/resilience/index.js.map +0 -1
  321. package/dist/execution/resilience/resilient-executor.d.ts +0 -86
  322. package/dist/execution/resilience/resilient-executor.d.ts.map +0 -1
  323. package/dist/execution/resilience/resilient-executor.js +0 -261
  324. package/dist/execution/resilience/resilient-executor.js.map +0 -1
  325. package/dist/execution/resilience/retry.d.ts +0 -161
  326. package/dist/execution/resilience/retry.d.ts.map +0 -1
  327. package/dist/execution/resilience/retry.js +0 -234
  328. package/dist/execution/resilience/retry.js.map +0 -1
  329. package/dist/execution/resilience/types.d.ts +0 -226
  330. package/dist/execution/resilience/types.d.ts.map +0 -1
  331. package/dist/execution/resilience/types.js +0 -30
  332. package/dist/execution/resilience/types.js.map +0 -1
  333. package/dist/execution/workflow/index.d.ts +0 -13
  334. package/dist/execution/workflow/index.d.ts.map +0 -1
  335. package/dist/execution/workflow/index.js +0 -13
  336. package/dist/execution/workflow/index.js.map +0 -1
  337. package/dist/execution/workflow/linear-orchestrator.d.ts +0 -216
  338. package/dist/execution/workflow/linear-orchestrator.d.ts.map +0 -1
  339. package/dist/execution/workflow/linear-orchestrator.js +0 -683
  340. package/dist/execution/workflow/linear-orchestrator.js.map +0 -1
  341. package/dist/execution/workflow/memory-storage.d.ts +0 -54
  342. package/dist/execution/workflow/memory-storage.d.ts.map +0 -1
  343. package/dist/execution/workflow/memory-storage.js +0 -68
  344. package/dist/execution/workflow/memory-storage.js.map +0 -1
  345. package/dist/execution/workflow/orchestrator.d.ts +0 -158
  346. package/dist/execution/workflow/orchestrator.d.ts.map +0 -1
  347. package/dist/execution/workflow/orchestrator.js +0 -9
  348. package/dist/execution/workflow/orchestrator.js.map +0 -1
  349. package/dist/execution/workflow/types.d.ts +0 -172
  350. package/dist/execution/workflow/types.d.ts.map +0 -1
  351. package/dist/execution/workflow/types.js +0 -9
  352. package/dist/execution/workflow/types.js.map +0 -1
  353. package/dist/execution/workflow/utils.d.ts +0 -89
  354. package/dist/execution/workflow/utils.d.ts.map +0 -1
  355. package/dist/execution/workflow/utils.js +0 -152
  356. package/dist/execution/workflow/utils.js.map +0 -1
  357. package/dist/public/assets/index-BvlblDHK.js +0 -570
  358. package/dist/public/assets/index-BvlblDHK.js.map +0 -1
  359. package/dist/public/assets/index-BwuKdLgN.css +0 -1
  360. package/dist/public/assets/ui-vendor-CotR6bx9.js +0 -54
  361. package/dist/public/assets/ui-vendor-CotR6bx9.js.map +0 -1
@@ -0,0 +1,377 @@
1
+ /**
2
+ * Prompt resolver service
3
+ *
4
+ * Resolves entity references and file mentions in agent prompts:
5
+ * - Injects [[s-xxxxx]] or @s-xxxxx spec references with markdown content
6
+ * - Injects [[i-xxxxx]] or @i-xxxxx issue references with markdown content
7
+ * - Tracks @file mentions but leaves them for agent to handle
8
+ */
9
+ import { getSpecById } from "./specs.js";
10
+ import { getIssueById } from "./issues.js";
11
+ /**
12
+ * PromptResolver service
13
+ *
14
+ * Extracts and resolves entity references in agent prompts
15
+ */
16
+ export class PromptResolver {
17
+ db;
18
+ constructor(db) {
19
+ this.db = db;
20
+ }
21
+ /**
22
+ * Resolve all references in a prompt
23
+ *
24
+ * @param prompt - The raw prompt with [[entity-id]], @entity-id, and @file references
25
+ * @param alreadyExpandedIds - Optional set of entity IDs that were already expanded in parent executions
26
+ * @param implicitIssueId - Optional issue ID to automatically include even if not mentioned in prompt (for issue-based executions)
27
+ * @returns Resolution result with resolved prompt, references, and errors
28
+ */
29
+ async resolve(prompt, alreadyExpandedIds = new Set(), implicitIssueId) {
30
+ const references = [];
31
+ const errors = [];
32
+ const expandedEntityIds = [];
33
+ // Extract all references (order matters - extract entity IDs first)
34
+ const specRefs = this.extractSpecReferences(prompt);
35
+ const issueRefs = this.extractIssueReferences(prompt);
36
+ // Extract entity IDs for filtering file mentions
37
+ const entityIds = new Set([
38
+ ...specRefs.map((r) => r.id),
39
+ ...issueRefs.map((r) => r.id),
40
+ ]);
41
+ const fileRefs = this.extractFileMentions(prompt, entityIds);
42
+ // Track all references
43
+ references.push(...fileRefs);
44
+ // Resolve and inject specs (replace inline)
45
+ let resolvedPrompt = prompt;
46
+ for (const ref of specRefs) {
47
+ // Skip if already expanded in parent execution
48
+ if (alreadyExpandedIds.has(ref.id)) {
49
+ ref.found = true;
50
+ references.push(ref);
51
+ continue;
52
+ }
53
+ const spec = getSpecById(this.db, ref.id);
54
+ if (spec) {
55
+ ref.found = true;
56
+ resolvedPrompt = this.replaceReference(resolvedPrompt, ref.id, this.formatSpec(spec));
57
+ expandedEntityIds.push(ref.id);
58
+ }
59
+ else {
60
+ ref.found = false;
61
+ ref.error = `Spec ${ref.id} not found`;
62
+ errors.push(ref.error);
63
+ }
64
+ references.push(ref);
65
+ }
66
+ // Resolve issues (keep reference, append content at end)
67
+ const issueAppendixes = [];
68
+ for (const ref of issueRefs) {
69
+ // Skip if already expanded in parent execution
70
+ if (alreadyExpandedIds.has(ref.id)) {
71
+ ref.found = true;
72
+ references.push(ref);
73
+ continue;
74
+ }
75
+ const issue = getIssueById(this.db, ref.id);
76
+ if (issue) {
77
+ ref.found = true;
78
+ // Don't replace the reference - append content at end instead
79
+ issueAppendixes.push(`\n\nIssue ${ref.id}:\n${this.formatIssue(issue)}`);
80
+ expandedEntityIds.push(ref.id);
81
+ }
82
+ else {
83
+ ref.found = false;
84
+ ref.error = `Issue ${ref.id} not found`;
85
+ errors.push(ref.error);
86
+ }
87
+ references.push(ref);
88
+ }
89
+ // If an implicit issue ID is provided (for issue-based executions),
90
+ // automatically include it even if not mentioned in the prompt
91
+ if (implicitIssueId && !alreadyExpandedIds.has(implicitIssueId)) {
92
+ // Check if it's already in the issueRefs (explicitly mentioned)
93
+ const alreadyMentioned = issueRefs.some((ref) => ref.id === implicitIssueId);
94
+ if (!alreadyMentioned) {
95
+ const issue = getIssueById(this.db, implicitIssueId);
96
+ if (issue) {
97
+ // Add implicit issue reference
98
+ references.push({
99
+ type: "issue",
100
+ id: implicitIssueId,
101
+ found: true,
102
+ });
103
+ // Append content at the end
104
+ issueAppendixes.push(`\n\nIssue ${implicitIssueId}:\n${this.formatIssue(issue)}`);
105
+ expandedEntityIds.push(implicitIssueId);
106
+ }
107
+ else {
108
+ const error = `Implicit issue ${implicitIssueId} not found`;
109
+ errors.push(error);
110
+ references.push({
111
+ type: "issue",
112
+ id: implicitIssueId,
113
+ found: false,
114
+ error,
115
+ });
116
+ }
117
+ }
118
+ }
119
+ // Append all issue contents at the end
120
+ if (issueAppendixes.length > 0) {
121
+ resolvedPrompt += issueAppendixes.join("");
122
+ }
123
+ return {
124
+ resolvedPrompt,
125
+ references,
126
+ errors,
127
+ expandedEntityIds,
128
+ };
129
+ }
130
+ /**
131
+ * Extract spec references from prompt
132
+ * Supports two patterns:
133
+ * - [[s-xxxxx]] (bracket syntax)
134
+ * - @s-xxxxx (@ mention syntax)
135
+ */
136
+ extractSpecReferences(prompt) {
137
+ const refs = [];
138
+ // Extract bracket syntax: [[s-xxxxx]]
139
+ const bracketPattern = /\[\[(s-[a-z0-9]+)\]\]/gi;
140
+ const bracketMatches = prompt.matchAll(bracketPattern);
141
+ for (const match of bracketMatches) {
142
+ const id = match[1].toLowerCase();
143
+ if (!refs.some((r) => r.id === id)) {
144
+ refs.push({
145
+ type: "spec",
146
+ id,
147
+ found: false,
148
+ });
149
+ }
150
+ }
151
+ // Extract @ mention syntax: @s-xxxxx
152
+ const mentionPattern = /@(s-[a-z0-9]+)(?=\s|$|[^\w-])/gi;
153
+ const mentionMatches = prompt.matchAll(mentionPattern);
154
+ for (const match of mentionMatches) {
155
+ const id = match[1].toLowerCase();
156
+ if (!refs.some((r) => r.id === id)) {
157
+ refs.push({
158
+ type: "spec",
159
+ id,
160
+ found: false,
161
+ });
162
+ }
163
+ }
164
+ return refs;
165
+ }
166
+ /**
167
+ * Extract issue references from prompt
168
+ * Supports two patterns:
169
+ * - [[i-xxxxx]] (bracket syntax)
170
+ * - @i-xxxxx (@ mention syntax)
171
+ */
172
+ extractIssueReferences(prompt) {
173
+ const refs = [];
174
+ // Extract bracket syntax: [[i-xxxxx]]
175
+ const bracketPattern = /\[\[(i-[a-z0-9]+)\]\]/gi;
176
+ const bracketMatches = prompt.matchAll(bracketPattern);
177
+ for (const match of bracketMatches) {
178
+ const id = match[1].toLowerCase();
179
+ if (!refs.some((r) => r.id === id)) {
180
+ refs.push({
181
+ type: "issue",
182
+ id,
183
+ found: false,
184
+ });
185
+ }
186
+ }
187
+ // Extract @ mention syntax: @i-xxxxx
188
+ const mentionPattern = /@(i-[a-z0-9]+)(?=\s|$|[^\w-])/gi;
189
+ const mentionMatches = prompt.matchAll(mentionPattern);
190
+ for (const match of mentionMatches) {
191
+ const id = match[1].toLowerCase();
192
+ if (!refs.some((r) => r.id === id)) {
193
+ refs.push({
194
+ type: "issue",
195
+ id,
196
+ found: false,
197
+ });
198
+ }
199
+ }
200
+ return refs;
201
+ }
202
+ /**
203
+ * Extract file mentions from prompt
204
+ * Pattern: @filepath (but not @s-xxxxx or @i-xxxxx)
205
+ *
206
+ * Note: File mentions are tracked but not resolved (agent handles them)
207
+ */
208
+ extractFileMentions(prompt, entityIds) {
209
+ const pattern = /@([^\s@]+)/g;
210
+ const matches = prompt.matchAll(pattern);
211
+ const refs = [];
212
+ for (const match of matches) {
213
+ let path = match[1];
214
+ // Remove trailing punctuation (period, comma, etc.)
215
+ path = path.replace(/[.,;:!?]+$/, "");
216
+ // Skip if it's a spec or issue ID (already handled)
217
+ if (entityIds.has(path.toLowerCase())) {
218
+ continue;
219
+ }
220
+ // Avoid duplicates
221
+ if (!refs.some((r) => r.id === path)) {
222
+ refs.push({
223
+ type: "file",
224
+ id: path,
225
+ found: true, // Files are not resolved here, just tracked
226
+ });
227
+ }
228
+ }
229
+ return refs;
230
+ }
231
+ /**
232
+ * Replace a reference with formatted content
233
+ * Handles both [[id]] and @id syntaxes
234
+ */
235
+ replaceReference(prompt, id, content) {
236
+ // Replace bracket syntax: [[id]]
237
+ const bracketPattern = new RegExp(`\\[\\[${id}\\]\\]`, "gi");
238
+ prompt = prompt.replace(bracketPattern, content);
239
+ // Replace @ mention syntax: @id
240
+ const mentionPattern = new RegExp(`@${id}(?=\\s|$|[^\\w-])`, "gi");
241
+ prompt = prompt.replace(mentionPattern, content);
242
+ return prompt;
243
+ }
244
+ /**
245
+ * Format spec - returns all information shown in CLI show command
246
+ */
247
+ formatSpec(spec) {
248
+ const parts = [];
249
+ // Header
250
+ parts.push(`**${spec.id}: ${spec.title}**`);
251
+ parts.push("");
252
+ // Metadata
253
+ parts.push(`**Priority:** ${spec.priority}`);
254
+ if (spec.file_path) {
255
+ parts.push(`**File:** ${spec.file_path}`);
256
+ }
257
+ if (spec.parent_id) {
258
+ parts.push(`**Parent:** ${spec.parent_id}`);
259
+ }
260
+ parts.push(`**Created:** ${spec.created_at}`);
261
+ parts.push(`**Updated:** ${spec.updated_at}`);
262
+ // Tags
263
+ const tags = this.getTags(spec.id, "spec");
264
+ if (tags.length > 0) {
265
+ parts.push(`**Tags:** ${tags.join(", ")}`);
266
+ }
267
+ // Relationships
268
+ const outgoing = this.getOutgoingRelationships(spec.id, "spec");
269
+ if (outgoing.length > 0) {
270
+ parts.push("");
271
+ parts.push("**Outgoing Relationships:**");
272
+ for (const rel of outgoing) {
273
+ parts.push(`- ${rel.relationship_type} → ${rel.to_id} (${rel.to_type})`);
274
+ }
275
+ }
276
+ const incoming = this.getIncomingRelationships(spec.id, "spec");
277
+ if (incoming.length > 0) {
278
+ parts.push("");
279
+ parts.push("**Incoming Relationships:**");
280
+ for (const rel of incoming) {
281
+ parts.push(`- ${rel.from_id} (${rel.from_type}) → ${rel.relationship_type}`);
282
+ }
283
+ }
284
+ // Content
285
+ if (spec.content) {
286
+ parts.push("");
287
+ parts.push("**Content:**");
288
+ parts.push(spec.content);
289
+ }
290
+ return parts.join("\n");
291
+ }
292
+ /**
293
+ * Format issue - returns all information shown in CLI show command
294
+ */
295
+ formatIssue(issue) {
296
+ const parts = [];
297
+ // Header
298
+ parts.push(`**${issue.id}: ${issue.title}**`);
299
+ parts.push("");
300
+ // Metadata
301
+ parts.push(`**Status:** ${issue.status}`);
302
+ parts.push(`**Priority:** ${issue.priority}`);
303
+ if (issue.assignee) {
304
+ parts.push(`**Assignee:** ${issue.assignee}`);
305
+ }
306
+ if (issue.parent_id) {
307
+ parts.push(`**Parent:** ${issue.parent_id}`);
308
+ }
309
+ parts.push(`**Created:** ${issue.created_at}`);
310
+ parts.push(`**Updated:** ${issue.updated_at}`);
311
+ if (issue.closed_at) {
312
+ parts.push(`**Closed:** ${issue.closed_at}`);
313
+ }
314
+ // Tags
315
+ const tags = this.getTags(issue.id, "issue");
316
+ if (tags.length > 0) {
317
+ parts.push(`**Tags:** ${tags.join(", ")}`);
318
+ }
319
+ // Relationships
320
+ const outgoing = this.getOutgoingRelationships(issue.id, "issue");
321
+ if (outgoing.length > 0) {
322
+ parts.push("");
323
+ parts.push("**Outgoing Relationships:**");
324
+ for (const rel of outgoing) {
325
+ parts.push(`- ${rel.relationship_type} → ${rel.to_id} (${rel.to_type})`);
326
+ }
327
+ }
328
+ const incoming = this.getIncomingRelationships(issue.id, "issue");
329
+ if (incoming.length > 0) {
330
+ parts.push("");
331
+ parts.push("**Incoming Relationships:**");
332
+ for (const rel of incoming) {
333
+ parts.push(`- ${rel.from_id} (${rel.from_type}) → ${rel.relationship_type}`);
334
+ }
335
+ }
336
+ // Content
337
+ if (issue.content) {
338
+ parts.push("");
339
+ parts.push("**Content:**");
340
+ parts.push(issue.content);
341
+ }
342
+ return parts.join("\n");
343
+ }
344
+ /**
345
+ * Get tags for an entity
346
+ */
347
+ getTags(entityId, entityType) {
348
+ const query = this.db.prepare(`
349
+ SELECT tag FROM tags WHERE entity_id = ? AND entity_type = ?
350
+ `);
351
+ const rows = query.all(entityId, entityType);
352
+ return rows.map((r) => r.tag);
353
+ }
354
+ /**
355
+ * Get outgoing relationships for an entity
356
+ */
357
+ getOutgoingRelationships(entityId, entityType) {
358
+ const query = this.db.prepare(`
359
+ SELECT relationship_type, to_id, to_type
360
+ FROM relationships
361
+ WHERE from_id = ? AND from_type = ?
362
+ `);
363
+ return query.all(entityId, entityType);
364
+ }
365
+ /**
366
+ * Get incoming relationships for an entity
367
+ */
368
+ getIncomingRelationships(entityId, entityType) {
369
+ const query = this.db.prepare(`
370
+ SELECT relationship_type, from_id, from_type
371
+ FROM relationships
372
+ WHERE to_id = ? AND to_type = ?
373
+ `);
374
+ return query.all(entityId, entityType);
375
+ }
376
+ }
377
+ //# sourceMappingURL=prompt-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-resolver.js","sourceRoot":"","sources":["../../src/services/prompt-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM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,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAChC,CAAC;IAED;;OAEG;IACK,wBAAwB,CAC9B,QAAgB,EAChB,UAA4B;QAM5B,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;KAI7B,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAInC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,wBAAwB,CAC9B,QAAgB,EAChB,UAA4B;QAM5B,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC;;;;KAI7B,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAInC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Repository info service - provides git repository information
3
+ */
4
+ export interface RepositoryInfo {
5
+ name: string;
6
+ branch: string;
7
+ path: string;
8
+ }
9
+ export interface BranchInfo {
10
+ current: string;
11
+ branches: string[];
12
+ }
13
+ /**
14
+ * Get repository information for a given repository path
15
+ *
16
+ * @param repoPath - Absolute path to the repository root
17
+ * @returns Repository information including name, branch, and path
18
+ * @throws Error if the path is not a valid git repository
19
+ */
20
+ export declare function getRepositoryInfo(repoPath: string): Promise<RepositoryInfo>;
21
+ /**
22
+ * Get branch information for a given repository path
23
+ *
24
+ * @param repoPath - Absolute path to the repository root
25
+ * @returns Current branch and list of all local branches
26
+ * @throws Error if the path is not a valid git repository
27
+ */
28
+ export declare function getRepositoryBranches(repoPath: string): Promise<BranchInfo>;
29
+ //# sourceMappingURL=repo-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-info.d.ts","sourceRoot":"","sources":["../../src/services/repo-info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,CAAC,CAgDzB;AAED;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,CAAC,CA8CrB"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Repository info service - provides git repository information
3
+ */
4
+ import * as path from "path";
5
+ import { GitCli } from "../execution/worktree/git-cli.js";
6
+ /**
7
+ * Get repository information for a given repository path
8
+ *
9
+ * @param repoPath - Absolute path to the repository root
10
+ * @returns Repository information including name, branch, and path
11
+ * @throws Error if the path is not a valid git repository
12
+ */
13
+ export async function getRepositoryInfo(repoPath) {
14
+ const gitCli = new GitCli();
15
+ // Check if repoPath is a valid git repository
16
+ const isValidRepo = await gitCli.isValidRepo(repoPath);
17
+ if (!isValidRepo) {
18
+ throw new Error("Not a git repository");
19
+ }
20
+ // Get repository name from git remote URL
21
+ let repoName = path.basename(repoPath); // Fallback to directory name
22
+ try {
23
+ const remoteOutput = gitCli["execGit"]("git remote get-url origin", repoPath);
24
+ const remoteUrl = remoteOutput.trim();
25
+ // Extract repo name from various URL formats:
26
+ // - https://github.com/user/repo.git
27
+ // - git@github.com:user/repo.git
28
+ // - https://github.com/user/repo
29
+ const match = remoteUrl.match(/\/([^\/]+?)(\.git)?$/);
30
+ if (match && match[1]) {
31
+ repoName = match[1];
32
+ }
33
+ }
34
+ catch (error) {
35
+ // No remote or error getting remote - use directory name as fallback
36
+ console.log("No git remote found, using directory name as fallback");
37
+ }
38
+ // Get current branch
39
+ let branch = "(detached)";
40
+ try {
41
+ const output = gitCli["execGit"]("git rev-parse --abbrev-ref HEAD", repoPath);
42
+ branch = output.trim();
43
+ }
44
+ catch (error) {
45
+ console.error("Failed to get current branch:", error);
46
+ }
47
+ return {
48
+ name: repoName,
49
+ branch,
50
+ path: repoPath,
51
+ };
52
+ }
53
+ /**
54
+ * Get branch information for a given repository path
55
+ *
56
+ * @param repoPath - Absolute path to the repository root
57
+ * @returns Current branch and list of all local branches
58
+ * @throws Error if the path is not a valid git repository
59
+ */
60
+ export async function getRepositoryBranches(repoPath) {
61
+ const gitCli = new GitCli();
62
+ // Check if repoPath is a valid git repository
63
+ const isValidRepo = await gitCli.isValidRepo(repoPath);
64
+ if (!isValidRepo) {
65
+ throw new Error("Not a git repository");
66
+ }
67
+ // Get current branch
68
+ let currentBranch = "(detached)";
69
+ try {
70
+ const output = gitCli["execGit"]("git rev-parse --abbrev-ref HEAD", repoPath);
71
+ currentBranch = output.trim();
72
+ }
73
+ catch (error) {
74
+ console.error("Failed to get current branch:", error);
75
+ }
76
+ // Get all local branches
77
+ const branches = [];
78
+ try {
79
+ const output = gitCli["execGit"]("git branch --format='%(refname:short)'", repoPath);
80
+ const branchList = output
81
+ .trim()
82
+ .split("\n")
83
+ .map((b) => b.trim())
84
+ .filter((b) => b.length > 0);
85
+ branches.push(...branchList);
86
+ }
87
+ catch (error) {
88
+ console.error("Failed to get branches:", error);
89
+ // Fallback to just current branch if we can't list branches
90
+ if (currentBranch !== "(detached)") {
91
+ branches.push(currentBranch);
92
+ }
93
+ }
94
+ return {
95
+ current: currentBranch,
96
+ branches,
97
+ };
98
+ }
99
+ //# sourceMappingURL=repo-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-info.js","sourceRoot":"","sources":["../../src/services/repo-info.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAa1D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,QAAgB;IAEhB,MAAM,MAAM,GAAG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a,KAAK,YAAY,EAAE,CAAC;YACnC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE,aAAa;QACtB,QAAQ;KACT,CAAC;AACJ,CAAC"}
@@ -13,10 +13,6 @@ export interface ServerWatcherOptions {
13
13
  * Base directory to watch (e.g., .sudocode)
14
14
  */
15
15
  baseDir: string;
16
- /**
17
- * Debounce delay in milliseconds (default: 2000)
18
- */
19
- debounceDelay?: number;
20
16
  /**
21
17
  * Enable reverse sync (JSONL → Markdown) when JSONL files change (default: false)
22
18
  */
@@ -27,9 +23,12 @@ export interface ServerWatcherOptions {
27
23
  */
28
24
  onFileChange?: (info: {
29
25
  filePath: string;
26
+ baseDir: string;
30
27
  event: "add" | "change" | "unlink";
31
28
  entityType?: "spec" | "issue";
32
29
  entityId?: string;
30
+ entity?: any;
31
+ timestamp: Date;
33
32
  }) => void;
34
33
  }
35
34
  export interface ServerWatcherControl {
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.d.ts","sourceRoot":"","sources":["../../src/services/watcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,kCAAkC,CAAC;AAE1C,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,EAAE,EAAE,QAAQ,CAAC,QAAQ,CAAC;IACtB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;QACnC,UAAU,CAAC,EAAE,MAAM,GAAG,OA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AO,EAAE,oBAAoB,GAC5B,oBAAoB,CAuDtB"}
@@ -8,52 +8,35 @@ import { startWatcher as startCliWatcher, } from "@sudocode-ai/cli/dist/watcher.
8
8
  * This wraps the CLI watcher with server-specific logging and callbacks
9
9
  */
10
10
  export function startServerWatcher(options) {
11
- const { db, baseDir, debounceDelay = 2000, syncJSONLToMarkdown = false, onFileChange, } = options;
11
+ const { db, baseDir, syncJSONLToMarkdown = false, onFileChange, } = options;
12
12
  console.log(`[watcher] Starting file watcher for ${baseDir}`);
13
- console.log(`[watcher] Debounce delay: ${debounceDelay}ms`);
14
13
  if (syncJSONLToMarkdown) {
15
14
  console.log(`[watcher] Reverse sync (JSONL → Markdown) enabled`);
16
15
  }
17
- // Start the CLI watcher with server-specific callbacks
18
- // TODO: Migrate away from parsing messages and start a watcher directly instead of using the CLI watcher.
16
+ // Start the CLI watcher with typed callbacks
19
17
  const control = startCliWatcher({
20
18
  db,
21
19
  baseDir,
22
- debounceDelay,
23
20
  syncJSONLToMarkdown,
24
- onLog: (message) => {
25
- console.log(message);
26
- // Extract entity info from log messages if available
27
- // Log format: "[watch] <event> <path>" or "[watch] Synced <type> <id> (<action>)"
21
+ // NEW PATH: Use typed callback (preferred)
22
+ onEntitySync: (event) => {
23
+ console.log(`[watcher] Entity synced: ${event.entityType} ${event.entityId} (${event.action})`);
28
24
  if (onFileChange) {
29
- // TODO: Use something more robust than regex parsing here.
30
- // Match markdown sync log: "[watch] Synced issue ISSUE-001 (updated)"
31
- const syncMatch = message.match(/\[watch\] Synced (spec|issue) ([A-Z]+-\d+) \((created|updated)\)/);
32
- if (syncMatch) {
33
- const [, entityType, entityId] = syncMatch;
34
- onFileChange({
35
- filePath: "", // Path not available in sync message
36
- event: "change",
37
- entityType: entityType,
38
- entityId,
39
- });
40
- return; // Early return to avoid double-processing
41
- }
42
- // Match JSONL file change: "[watch] change issues.jsonl" or "[watch] change specs.jsonl"
43
- const jsonlChangeMatch = message.match(/\[watch\] change (issues|specs)\.jsonl/);
44
- if (jsonlChangeMatch) {
45
- const [, entityType] = jsonlChangeMatch;
46
- // For JSONL changes, we don't know which specific entity changed
47
- // so we broadcast a generic update that will trigger a refetch
48
- onFileChange({
49
- filePath: `${entityType}.jsonl`,
50
- event: "change",
51
- entityType: (entityType === "issues" ? "issue" : "spec"),
52
- entityId: "*", // Wildcard to indicate "any entity of this type"
53
- });
54
- }
25
+ onFileChange({
26
+ filePath: event.filePath,
27
+ baseDir: event.baseDir,
28
+ event: "change",
29
+ entityType: event.entityType,
30
+ entityId: event.entityId,
31
+ entity: event.entity, // Pass through entity data
32
+ timestamp: event.timestamp,
33
+ });
55
34
  }
56
35
  },
36
+ // Keep onLog for debugging
37
+ onLog: (message) => {
38
+ console.log(message);
39
+ },
57
40
  onError: (error) => {
58
41
  console.error(`[watcher] Error: ${error.message}`);
59
42
  },
@@ -1 +1 @@
1
- {"version":3,"file":"watcher.js","sourceRoot":"","sources":["../../src/services/watcher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,YAAY,IAAI,eAAe,GAEhC,MAAM,kCAAkC,CAAC;AA0C1C;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAA6B;IAE7B,MAAM,EACJ,EAAE,EACF,OAAO,EACP,aAAa,GAAG,IAAI,EACpB,mBAAmB,GAAG,KAAK,EAC3B,YAAY,GACb,GAAG,OAAO,CAAC;IAEZ,OAAO,CAAC,GAAG,CAAC,uCAAuC,OAAO,EAAE,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,CAAC,6BAA6B,aAAa,IAAI,CAAC,CAAC;IAC5D,IAAI,mBAAmB,EAAE,CAAC;QACxB,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;IAED,uDAAuD;IACvD,0GAA0G;IAC1G,MAAM,OAAO,GAAG,eAAe,CAAC;QAC9B,EAAE;QACF,OAAO;QACP,aAAa;QACb,mBAAmB;QACnB,KAAK,EAAE,CAAC,OAAO,EAA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