@sudocode-ai/local-server 0.1.7 → 0.1.9

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 (282) 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 +24 -57
  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 +198 -0
  86. package/dist/execution/worktree/git-sync-cli.d.ts.map +1 -0
  87. package/dist/execution/worktree/git-sync-cli.js +401 -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 +124 -229
  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-DV9Tbujb.css +1 -0
  102. package/dist/public/assets/index-DcDX9-Ad.js +740 -0
  103. package/dist/public/assets/index-DcDX9-Ad.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 +792 -37
  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 +12 -10
  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 +203 -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/routes/version.d.ts +3 -0
  158. package/dist/routes/version.d.ts.map +1 -0
  159. package/dist/routes/version.js +25 -0
  160. package/dist/routes/version.js.map +1 -0
  161. package/dist/services/agent-registry.d.ts +140 -0
  162. package/dist/services/agent-registry.d.ts.map +1 -0
  163. package/dist/services/agent-registry.js +272 -0
  164. package/dist/services/agent-registry.js.map +1 -0
  165. package/dist/services/editor-service.d.ts +57 -0
  166. package/dist/services/editor-service.d.ts.map +1 -0
  167. package/dist/services/editor-service.js +204 -0
  168. package/dist/services/editor-service.js.map +1 -0
  169. package/dist/services/execution-changes-service.d.ts +110 -0
  170. package/dist/services/execution-changes-service.d.ts.map +1 -0
  171. package/dist/services/execution-changes-service.js +700 -0
  172. package/dist/services/execution-changes-service.js.map +1 -0
  173. package/dist/services/execution-lifecycle.d.ts +1 -0
  174. package/dist/services/execution-lifecycle.d.ts.map +1 -1
  175. package/dist/services/execution-lifecycle.js +37 -7
  176. package/dist/services/execution-lifecycle.js.map +1 -1
  177. package/dist/services/execution-logs-store.d.ts +75 -0
  178. package/dist/services/execution-logs-store.d.ts.map +1 -1
  179. package/dist/services/execution-logs-store.js +142 -2
  180. package/dist/services/execution-logs-store.js.map +1 -1
  181. package/dist/services/execution-service.d.ts +82 -59
  182. package/dist/services/execution-service.d.ts.map +1 -1
  183. package/dist/services/execution-service.js +514 -469
  184. package/dist/services/execution-service.js.map +1 -1
  185. package/dist/services/execution-worker-pool.d.ts +116 -0
  186. package/dist/services/execution-worker-pool.d.ts.map +1 -0
  187. package/dist/services/execution-worker-pool.js +326 -0
  188. package/dist/services/execution-worker-pool.js.map +1 -0
  189. package/dist/services/executions.d.ts +3 -0
  190. package/dist/services/executions.d.ts.map +1 -1
  191. package/dist/services/executions.js +11 -17
  192. package/dist/services/executions.js.map +1 -1
  193. package/dist/services/export.d.ts +8 -2
  194. package/dist/services/export.d.ts.map +1 -1
  195. package/dist/services/export.js +29 -23
  196. package/dist/services/export.js.map +1 -1
  197. package/dist/services/file-search/git-ls-files-strategy.d.ts +72 -0
  198. package/dist/services/file-search/git-ls-files-strategy.d.ts.map +1 -0
  199. package/dist/services/file-search/git-ls-files-strategy.js +176 -0
  200. package/dist/services/file-search/git-ls-files-strategy.js.map +1 -0
  201. package/dist/services/file-search/index.d.ts +9 -0
  202. package/dist/services/file-search/index.d.ts.map +1 -0
  203. package/dist/services/file-search/index.js +10 -0
  204. package/dist/services/file-search/index.js.map +1 -0
  205. package/dist/services/file-search/registry.d.ts +97 -0
  206. package/dist/services/file-search/registry.d.ts.map +1 -0
  207. package/dist/services/file-search/registry.js +140 -0
  208. package/dist/services/file-search/registry.js.map +1 -0
  209. package/dist/services/file-search/strategy.d.ts +58 -0
  210. package/dist/services/file-search/strategy.d.ts.map +1 -0
  211. package/dist/services/file-search/strategy.js +8 -0
  212. package/dist/services/file-search/strategy.js.map +1 -0
  213. package/dist/services/project-context.d.ts +69 -0
  214. package/dist/services/project-context.d.ts.map +1 -0
  215. package/dist/services/project-context.js +113 -0
  216. package/dist/services/project-context.js.map +1 -0
  217. package/dist/services/project-manager.d.ts +95 -0
  218. package/dist/services/project-manager.d.ts.map +1 -0
  219. package/dist/services/project-manager.js +388 -0
  220. package/dist/services/project-manager.js.map +1 -0
  221. package/dist/services/project-registry.d.ts +98 -0
  222. package/dist/services/project-registry.d.ts.map +1 -0
  223. package/dist/services/project-registry.js +289 -0
  224. package/dist/services/project-registry.js.map +1 -0
  225. package/dist/services/prompt-resolver.d.ts +97 -0
  226. package/dist/services/prompt-resolver.d.ts.map +1 -0
  227. package/dist/services/prompt-resolver.js +377 -0
  228. package/dist/services/prompt-resolver.js.map +1 -0
  229. package/dist/services/repo-info.d.ts +12 -0
  230. package/dist/services/repo-info.d.ts.map +1 -1
  231. package/dist/services/repo-info.js +46 -0
  232. package/dist/services/repo-info.js.map +1 -1
  233. package/dist/services/version-service.d.ts +14 -0
  234. package/dist/services/version-service.d.ts.map +1 -0
  235. package/dist/services/version-service.js +57 -0
  236. package/dist/services/version-service.js.map +1 -0
  237. package/dist/services/watcher.d.ts +3 -4
  238. package/dist/services/watcher.d.ts.map +1 -1
  239. package/dist/services/watcher.js +18 -35
  240. package/dist/services/watcher.js.map +1 -1
  241. package/dist/services/websocket.d.ts +30 -16
  242. package/dist/services/websocket.d.ts.map +1 -1
  243. package/dist/services/websocket.js +102 -37
  244. package/dist/services/websocket.js.map +1 -1
  245. package/dist/services/worktree-sync-service.d.ts +326 -0
  246. package/dist/services/worktree-sync-service.d.ts.map +1 -0
  247. package/dist/services/worktree-sync-service.js +1091 -0
  248. package/dist/services/worktree-sync-service.js.map +1 -0
  249. package/dist/types/editor.d.ts +49 -0
  250. package/dist/types/editor.d.ts.map +1 -0
  251. package/dist/types/editor.js +50 -0
  252. package/dist/types/editor.js.map +1 -0
  253. package/dist/types/project.d.ts +58 -0
  254. package/dist/types/project.d.ts.map +1 -0
  255. package/dist/types/project.js +10 -0
  256. package/dist/types/project.js.map +1 -0
  257. package/dist/utils/executable-check.d.ts +36 -0
  258. package/dist/utils/executable-check.d.ts.map +1 -0
  259. package/dist/utils/executable-check.js +79 -0
  260. package/dist/utils/executable-check.js.map +1 -0
  261. package/dist/workers/execution-worker.d.ts +18 -0
  262. package/dist/workers/execution-worker.d.ts.map +1 -0
  263. package/dist/workers/execution-worker.js +340 -0
  264. package/dist/workers/execution-worker.js.map +1 -0
  265. package/dist/workers/worker-ipc.d.ts +84 -0
  266. package/dist/workers/worker-ipc.d.ts.map +1 -0
  267. package/dist/workers/worker-ipc.js +29 -0
  268. package/dist/workers/worker-ipc.js.map +1 -0
  269. package/package.json +6 -5
  270. package/dist/execution/output/ag-ui-integration.d.ts +0 -96
  271. package/dist/execution/output/ag-ui-integration.d.ts.map +0 -1
  272. package/dist/execution/output/ag-ui-integration.js +0 -96
  273. package/dist/execution/output/ag-ui-integration.js.map +0 -1
  274. package/dist/execution/output/claude-code-output-processor.d.ts +0 -321
  275. package/dist/execution/output/claude-code-output-processor.d.ts.map +0 -1
  276. package/dist/execution/output/claude-code-output-processor.js +0 -769
  277. package/dist/execution/output/claude-code-output-processor.js.map +0 -1
  278. package/dist/public/assets/index-B3SEMufD.js +0 -580
  279. package/dist/public/assets/index-B3SEMufD.js.map +0 -1
  280. package/dist/public/assets/index-D2YGL3gX.css +0 -1
  281. package/dist/public/assets/ui-vendor-CotR6bx9.js +0 -54
  282. package/dist/public/assets/ui-vendor-CotR6bx9.js.map +0 -1
@@ -0,0 +1,272 @@
1
+ /**
2
+ * Agent Registry Service
3
+ *
4
+ * Centralized service for managing agent adapters and providing agent discovery.
5
+ * Wraps the agent-execution-engine's AgentRegistry with sudocode-specific logic.
6
+ */
7
+ import { AgentRegistry } from "agent-execution-engine/agents";
8
+ import { ClaudeCodeAdapter } from "../execution/adapters/claude-adapter.js";
9
+ import { CodexAdapter } from "../execution/adapters/codex-adapter.js";
10
+ import { CursorAdapter } from "../execution/adapters/cursor-adapter.js";
11
+ import { copilotAdapter } from "../execution/adapters/copilot-adapter.js";
12
+ import { verifyExecutable, } from "../utils/executable-check.js";
13
+ /**
14
+ * Error thrown when an agent is not found in the registry
15
+ */
16
+ export class AgentNotFoundError extends Error {
17
+ constructor(agentType) {
18
+ super(`Agent '${agentType}' not found in registry`);
19
+ this.name = "AgentNotFoundError";
20
+ }
21
+ }
22
+ /**
23
+ * Error thrown when attempting to use an unimplemented agent
24
+ */
25
+ export class AgentNotImplementedError extends Error {
26
+ constructor(agentType) {
27
+ super(`Agent '${agentType}' is not yet implemented`);
28
+ this.name = "AgentNotImplementedError";
29
+ }
30
+ }
31
+ export class AgentRegistryService {
32
+ registry;
33
+ implementedAgents = new Set([
34
+ "claude-code",
35
+ "codex",
36
+ "cursor",
37
+ "copilot",
38
+ ]);
39
+ initialized = false;
40
+ /**
41
+ * Map of agent types to their default executable names
42
+ */
43
+ agentExecutables = {
44
+ "claude-code": "claude",
45
+ codex: "codex",
46
+ cursor: "cursor-agent",
47
+ copilot: "copilot",
48
+ };
49
+ /**
50
+ * Cache for verification results
51
+ * Key: agent type, Value: cached verification result with timestamp
52
+ */
53
+ verificationCache = new Map();
54
+ /**
55
+ * Cache TTL in milliseconds (default: 24 hours)
56
+ * Set to a very long duration since agent installations rarely change
57
+ */
58
+ cacheTTL = 24 * 60 * 60 * 1000; // 24 hours
59
+ constructor() {
60
+ this.registry = new AgentRegistry();
61
+ }
62
+ /**
63
+ * Initialize the registry by registering all agent adapters
64
+ * Called automatically on first use (lazy initialization)
65
+ */
66
+ initialize() {
67
+ if (this.initialized) {
68
+ return;
69
+ }
70
+ // Register fully implemented adapters
71
+ this.registry.register(new ClaudeCodeAdapter());
72
+ this.registry.register(new CodexAdapter());
73
+ this.registry.register(new CursorAdapter());
74
+ this.registry.register(copilotAdapter);
75
+ this.initialized = true;
76
+ }
77
+ /**
78
+ * Get all available agents with their metadata and implementation status
79
+ *
80
+ * @returns Array of agent information
81
+ */
82
+ getAvailableAgents() {
83
+ this.initialize();
84
+ return this.registry.getAll().map((adapter) => ({
85
+ ...adapter.metadata,
86
+ implemented: this.implementedAgents.has(adapter.metadata.name),
87
+ }));
88
+ }
89
+ /**
90
+ * Get an agent adapter by type
91
+ *
92
+ * @param agentType - The agent type to retrieve
93
+ * @returns The agent adapter
94
+ * @throws {AgentNotFoundError} If agent is not registered
95
+ */
96
+ getAdapter(agentType) {
97
+ this.initialize();
98
+ const adapter = this.registry.get(agentType);
99
+ if (!adapter) {
100
+ throw new AgentNotFoundError(agentType);
101
+ }
102
+ return adapter;
103
+ }
104
+ /**
105
+ * Check if an agent is fully implemented
106
+ *
107
+ * @param agentType - The agent type to check
108
+ * @returns True if the agent is implemented, false if it's a stub
109
+ */
110
+ isAgentImplemented(agentType) {
111
+ this.initialize();
112
+ return this.implementedAgents.has(agentType);
113
+ }
114
+ /**
115
+ * Check if an agent is registered in the registry
116
+ *
117
+ * @param agentType - The agent type to check
118
+ * @returns True if the agent is registered
119
+ */
120
+ hasAgent(agentType) {
121
+ this.initialize();
122
+ return this.registry.has(agentType);
123
+ }
124
+ /**
125
+ * Mark an agent as implemented
126
+ * Used when upgrading a stub adapter to a full implementation
127
+ *
128
+ * @param agentType - The agent type to mark as implemented
129
+ */
130
+ markAsImplemented(agentType) {
131
+ this.initialize();
132
+ if (!this.hasAgent(agentType)) {
133
+ throw new AgentNotFoundError(agentType);
134
+ }
135
+ this.implementedAgents.add(agentType);
136
+ }
137
+ /**
138
+ * Check if cached verification is still valid
139
+ *
140
+ * @param agentType - The agent type to check
141
+ * @returns Cached result if valid, undefined otherwise
142
+ */
143
+ getCachedVerification(agentType) {
144
+ const cached = this.verificationCache.get(agentType);
145
+ if (!cached) {
146
+ return undefined;
147
+ }
148
+ const age = Date.now() - cached.timestamp;
149
+ if (age > this.cacheTTL) {
150
+ // Cache expired, remove it
151
+ this.verificationCache.delete(agentType);
152
+ return undefined;
153
+ }
154
+ return cached.result;
155
+ }
156
+ /**
157
+ * Cache a verification result
158
+ *
159
+ * @param agentType - The agent type
160
+ * @param result - The verification result to cache
161
+ */
162
+ cacheVerification(agentType, result) {
163
+ this.verificationCache.set(agentType, {
164
+ result,
165
+ timestamp: Date.now(),
166
+ });
167
+ }
168
+ /**
169
+ * Clear verification cache for a specific agent or all agents
170
+ *
171
+ * @param agentType - Optional agent type to clear. If not provided, clears all cache.
172
+ */
173
+ clearVerificationCache(agentType) {
174
+ if (agentType) {
175
+ this.verificationCache.delete(agentType);
176
+ }
177
+ else {
178
+ this.verificationCache.clear();
179
+ }
180
+ }
181
+ /**
182
+ * Verify if a specific agent's executable is available on the system
183
+ * Results are cached for performance
184
+ *
185
+ * @param agentType - The agent type to verify
186
+ * @param skipCache - If true, bypass cache and perform fresh verification
187
+ * @returns Promise<VerificationResult>
188
+ */
189
+ async verifyAgent(agentType, skipCache = false) {
190
+ this.initialize();
191
+ // Check cache first unless skipCache is true
192
+ if (!skipCache) {
193
+ const cached = this.getCachedVerification(agentType);
194
+ if (cached) {
195
+ return cached;
196
+ }
197
+ }
198
+ // Check if agent is registered
199
+ if (!this.hasAgent(agentType)) {
200
+ const result = {
201
+ available: false,
202
+ error: `Agent '${agentType}' not found in registry`,
203
+ };
204
+ this.cacheVerification(agentType, result);
205
+ return result;
206
+ }
207
+ // Check if agent is implemented
208
+ if (!this.isAgentImplemented(agentType)) {
209
+ const result = {
210
+ available: false,
211
+ error: `Agent '${agentType}' is not yet implemented`,
212
+ };
213
+ this.cacheVerification(agentType, result);
214
+ return result;
215
+ }
216
+ // Get the default executable name for this agent
217
+ const executableName = this.agentExecutables[agentType];
218
+ if (!executableName) {
219
+ const result = {
220
+ available: false,
221
+ error: `No executable mapping found for agent '${agentType}'`,
222
+ };
223
+ this.cacheVerification(agentType, result);
224
+ return result;
225
+ }
226
+ // Verify the executable exists
227
+ const result = await verifyExecutable(executableName);
228
+ this.cacheVerification(agentType, result);
229
+ return result;
230
+ }
231
+ /**
232
+ * Verify all implemented agents and return their availability status
233
+ *
234
+ * @returns Promise<Map<string, VerificationResult>>
235
+ */
236
+ async verifyAllAgents() {
237
+ this.initialize();
238
+ const results = new Map();
239
+ // Get all implemented agents
240
+ const agents = this.getAvailableAgents().filter((agent) => agent.implemented);
241
+ // Verify each agent in parallel
242
+ await Promise.all(agents.map(async (agent) => {
243
+ const result = await this.verifyAgent(agent.name);
244
+ results.set(agent.name, result);
245
+ }));
246
+ return results;
247
+ }
248
+ /**
249
+ * Get all available agents with their verification status included
250
+ *
251
+ * @returns Promise<AgentInfo[]> - Array of agent information with availability status
252
+ */
253
+ async getAvailableAgentsWithVerification() {
254
+ this.initialize();
255
+ const agents = this.getAvailableAgents();
256
+ const verificationResults = await this.verifyAllAgents();
257
+ return agents.map((agent) => {
258
+ const verification = verificationResults.get(agent.name);
259
+ return {
260
+ ...agent,
261
+ available: verification?.available,
262
+ executablePath: verification?.path,
263
+ verificationError: verification?.error,
264
+ };
265
+ });
266
+ }
267
+ }
268
+ /**
269
+ * Global agent registry service instance
270
+ */
271
+ export const agentRegistryService = new AgentRegistryService();
272
+ //# sourceMappingURL=agent-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-registry.js","sourceRoot":"","sources":["../../src/services/agent-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAM9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EACL,gBAAgB,GAEjB,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,SAAiB;QAC3B,KAAK,CAAC,UAAU,SAAS,yBAAyB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;GAEG;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AAW,CAC7B,CAAC;QAEF,gCAAgC;QAChC,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;YACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAiB,CAAC,CAAC;YAC/D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAClC,CAAC,CAAC,CACH,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,kCAAkC;QACtC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACzC,MAAM,mBAAmB,GAAG,MAAM,IAAI,CAAC,eAAe,EAAE,CAAC;QAEzD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC1B,MAAM,YAAY,GAAG,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACzD,OAAO;gBACL,GAAG,KAAK;gBACR,SAAS,EAAE,YAAY,EAAE,SAAS;gBAClC,cAAc,EAAE,YAAY,EAAE,IAAI;gBAClC,iBAAiB,EAAE,YAAY,EAAE,KAAK;aACvC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * EditorService - Manages IDE opening functionality
3
+ */
4
+ import { EditorType, EditorConfig } from "../types/editor.js";
5
+ /**
6
+ * EditorService handles IDE opening operations
7
+ */
8
+ export declare class EditorService {
9
+ private repoPath;
10
+ private configCache;
11
+ private configCacheTime;
12
+ private readonly CONFIG_CACHE_TTL;
13
+ constructor(repoPath: string);
14
+ /**
15
+ * Load editor configuration from .sudocode/config.local.json
16
+ * Falls back to default (VS Code) if file doesn't exist
17
+ */
18
+ loadConfig(): Promise<EditorConfig>;
19
+ /**
20
+ * Get command name for editor type
21
+ */
22
+ getCommand(editorType: EditorType, customCommand?: string): string;
23
+ /**
24
+ * Check if editor command is available using 'which' package
25
+ */
26
+ checkAvailability(command: string): Promise<boolean>;
27
+ /**
28
+ * Spawn editor process with worktree path
29
+ *
30
+ * @param worktreePath - Absolute path to worktree directory
31
+ * @param config - Editor configuration
32
+ * @throws EditorOpenError if spawn fails
33
+ */
34
+ spawnEditor(worktreePath: string, config: EditorConfig): Promise<void>;
35
+ /**
36
+ * Open worktree in IDE using configured editor
37
+ *
38
+ * @param worktreePath - Absolute path to worktree directory
39
+ * @param editorTypeOverride - Optional editor type override for this operation
40
+ */
41
+ openWorktree(worktreePath: string, editorTypeOverride?: EditorType): Promise<void>;
42
+ /**
43
+ * Check availability of all supported editors
44
+ * Useful for settings UI to show which editors are installed
45
+ */
46
+ checkAllAvailability(): Promise<Record<EditorType, boolean>>;
47
+ /**
48
+ * Get human-readable editor name for error messages
49
+ */
50
+ private getEditorName;
51
+ /**
52
+ * Clear the config cache
53
+ * Useful for testing or when config file is updated
54
+ */
55
+ clearCache(): void;
56
+ }
57
+ //# sourceMappingURL=editor-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-service.d.ts","sourceRoot":"","sources":["../../src/services/editor-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAmB,MAAM,oBAAoB,CAAC;AAsB/E;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAiB;gBAEtC,QAAQ,EAAE,MAAM;IAI5B;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC;IAkDzC;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM;IAOlE;;OAEG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS1D;;;;;;OAMG;IACG,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAoE5E;;;;;OAKG;IACG,YAAY,CAChB,YAAY,EAAE,MAAM,EACpB,kBAAkB,CAAC,EAAE,UAAU,GAC9B,OAAO,CAAC,IAAI,CAAC;IAehB;;;OAGG;IACG,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAiBlE;;OAEG;IACH,OAAO,CAAC,aAAa;IAarB;;;OAGG;IACH,UAAU,IAAI,IAAI;CAInB"}
@@ -0,0 +1,204 @@
1
+ /**
2
+ * EditorService - Manages IDE opening functionality
3
+ */
4
+ import { spawn } from "child_process";
5
+ import * as fs from "fs/promises";
6
+ import * as path from "path";
7
+ import which from "which";
8
+ import { EditorType, EditorOpenError } from "../types/editor.js";
9
+ /**
10
+ * Command mapping for each editor type
11
+ */
12
+ const EDITOR_COMMANDS = {
13
+ [EditorType.VS_CODE]: "code",
14
+ [EditorType.CURSOR]: "cursor",
15
+ [EditorType.WINDSURF]: "windsurf",
16
+ [EditorType.INTELLIJ]: "idea",
17
+ [EditorType.ZED]: "zed",
18
+ [EditorType.XCODE]: "xed",
19
+ [EditorType.CUSTOM]: "", // Handled specially via customCommand
20
+ };
21
+ /**
22
+ * Default editor configuration
23
+ */
24
+ const DEFAULT_CONFIG = {
25
+ editorType: EditorType.VS_CODE,
26
+ };
27
+ /**
28
+ * EditorService handles IDE opening operations
29
+ */
30
+ export class EditorService {
31
+ repoPath;
32
+ configCache = null;
33
+ configCacheTime = 0;
34
+ CONFIG_CACHE_TTL = 5 * 60 * 1000; // 5 minutes
35
+ constructor(repoPath) {
36
+ this.repoPath = repoPath;
37
+ }
38
+ /**
39
+ * Load editor configuration from .sudocode/config.local.json
40
+ * Falls back to default (VS Code) if file doesn't exist
41
+ */
42
+ async loadConfig() {
43
+ // Check cache
44
+ const now = Date.now();
45
+ if (this.configCache &&
46
+ now - this.configCacheTime < this.CONFIG_CACHE_TTL) {
47
+ return this.configCache;
48
+ }
49
+ const configPath = path.join(this.repoPath, ".sudocode", "config.local.json");
50
+ try {
51
+ const content = await fs.readFile(configPath, "utf-8");
52
+ const parsed = JSON.parse(content);
53
+ if (parsed.editor && typeof parsed.editor.editorType === "string") {
54
+ const config = {
55
+ editorType: parsed.editor.editorType,
56
+ customCommand: parsed.editor.customCommand,
57
+ };
58
+ // Validate editor type
59
+ if (!Object.values(EditorType).includes(config.editorType)) {
60
+ console.warn(`Invalid editor type in config: ${config.editorType}, using default`);
61
+ return DEFAULT_CONFIG;
62
+ }
63
+ // Cache the config
64
+ this.configCache = config;
65
+ this.configCacheTime = now;
66
+ return config;
67
+ }
68
+ }
69
+ catch (error) {
70
+ // Config file doesn't exist or is invalid, use default
71
+ if (error.code !== "ENOENT") {
72
+ console.warn("Failed to load editor config:", error);
73
+ }
74
+ }
75
+ return DEFAULT_CONFIG;
76
+ }
77
+ /**
78
+ * Get command name for editor type
79
+ */
80
+ getCommand(editorType, customCommand) {
81
+ if (editorType === EditorType.CUSTOM) {
82
+ return customCommand || EDITOR_COMMANDS[EditorType.VS_CODE];
83
+ }
84
+ return EDITOR_COMMANDS[editorType];
85
+ }
86
+ /**
87
+ * Check if editor command is available using 'which' package
88
+ */
89
+ async checkAvailability(command) {
90
+ try {
91
+ await which(command);
92
+ return true;
93
+ }
94
+ catch {
95
+ return false;
96
+ }
97
+ }
98
+ /**
99
+ * Spawn editor process with worktree path
100
+ *
101
+ * @param worktreePath - Absolute path to worktree directory
102
+ * @param config - Editor configuration
103
+ * @throws EditorOpenError if spawn fails
104
+ */
105
+ async spawnEditor(worktreePath, config) {
106
+ const command = this.getCommand(config.editorType, config.customCommand);
107
+ // Check if command is available
108
+ const isAvailable = await this.checkAvailability(command);
109
+ if (!isAvailable) {
110
+ throw new EditorOpenError("EDITOR_NOT_FOUND", config.editorType, `Editor '${command}' not found in PATH`, `Please install ${this.getEditorName(config.editorType)} or configure a different editor`);
111
+ }
112
+ // Check if worktree path exists
113
+ try {
114
+ await fs.access(worktreePath);
115
+ const stats = await fs.stat(worktreePath);
116
+ if (!stats.isDirectory()) {
117
+ throw new EditorOpenError("WORKTREE_MISSING", config.editorType, `Worktree path is not a directory: ${worktreePath}`, "The worktree path must be a valid directory");
118
+ }
119
+ }
120
+ catch (error) {
121
+ if (error.code === "ENOENT") {
122
+ throw new EditorOpenError("WORKTREE_MISSING", config.editorType, `Worktree directory not found: ${worktreePath}`, "The worktree may have been deleted or the path is incorrect");
123
+ }
124
+ // If it's already an EditorOpenError, re-throw it
125
+ if (error instanceof EditorOpenError) {
126
+ throw error;
127
+ }
128
+ // For other filesystem errors, wrap them
129
+ throw new EditorOpenError("WORKTREE_MISSING", config.editorType, `Cannot access worktree directory: ${worktreePath}`, error instanceof Error ? error.message : String(error));
130
+ }
131
+ try {
132
+ // Spawn in detached mode
133
+ const child = spawn(command, [worktreePath], {
134
+ detached: true,
135
+ stdio: "ignore",
136
+ cwd: worktreePath,
137
+ });
138
+ // Unref so parent process doesn't wait for child
139
+ child.unref();
140
+ }
141
+ catch (error) {
142
+ throw new EditorOpenError("SPAWN_FAILED", config.editorType, `Failed to launch editor '${command}'`, error instanceof Error ? error.message : String(error));
143
+ }
144
+ }
145
+ /**
146
+ * Open worktree in IDE using configured editor
147
+ *
148
+ * @param worktreePath - Absolute path to worktree directory
149
+ * @param editorTypeOverride - Optional editor type override for this operation
150
+ */
151
+ async openWorktree(worktreePath, editorTypeOverride) {
152
+ // Load config
153
+ let config = await this.loadConfig();
154
+ // Apply override if provided
155
+ if (editorTypeOverride) {
156
+ config = {
157
+ ...config,
158
+ editorType: editorTypeOverride,
159
+ };
160
+ }
161
+ await this.spawnEditor(worktreePath, config);
162
+ }
163
+ /**
164
+ * Check availability of all supported editors
165
+ * Useful for settings UI to show which editors are installed
166
+ */
167
+ async checkAllAvailability() {
168
+ const results = {};
169
+ for (const editorType of Object.values(EditorType)) {
170
+ if (editorType === EditorType.CUSTOM) {
171
+ // Custom editors can't be checked without knowing the command
172
+ results[editorType] = false;
173
+ continue;
174
+ }
175
+ const command = this.getCommand(editorType);
176
+ results[editorType] = await this.checkAvailability(command);
177
+ }
178
+ return results;
179
+ }
180
+ /**
181
+ * Get human-readable editor name for error messages
182
+ */
183
+ getEditorName(editorType) {
184
+ const names = {
185
+ [EditorType.VS_CODE]: "Visual Studio Code",
186
+ [EditorType.CURSOR]: "Cursor",
187
+ [EditorType.WINDSURF]: "Windsurf",
188
+ [EditorType.INTELLIJ]: "IntelliJ IDEA",
189
+ [EditorType.ZED]: "Zed",
190
+ [EditorType.XCODE]: "Xcode",
191
+ [EditorType.CUSTOM]: "Custom Editor",
192
+ };
193
+ return names[editorType];
194
+ }
195
+ /**
196
+ * Clear the config cache
197
+ * Useful for testing or when config file is updated
198
+ */
199
+ clearCache() {
200
+ this.configCache = null;
201
+ this.configCacheTime = 0;
202
+ }
203
+ }
204
+ //# sourceMappingURL=editor-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-service.js","sourceRoot":"","sources":["../../src/services/editor-service.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAgB,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE/E;;GAEG;AACH,MAAM,eAAe,GAA+B;IAClD,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM;IAC5B,CA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C;gBACrC,8DAA8D;gBAC9D,OAAO,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;gBAC5B,SAAS;YACX,CAAC;YAED,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAC5C,OAAO,CAAC,UAAU,CAAC,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,OAAsC,CAAC;IAChD,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,UAAsB;QAC1C,MAAM,KAAK,GAA+B;YACxC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,oBAAoB;YAC1C,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,QAAQ;YAC7B,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,UAAU;YACjC,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,eAAe;YACtC,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK;YACvB,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO;YAC3B,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,eAAe;SACrC,CAAC;QACF,OAAO,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,UAAU;QACR,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;IAC3B,CAAC;CACF"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Execution Changes Service
3
+ *
4
+ * Calculates code changes (file list + diff statistics) from execution commits.
5
+ * Supports 3 scenarios:
6
+ * - Committed changes (commit-to-commit diff)
7
+ * - Uncommitted changes (working tree diff)
8
+ * - No changes
9
+ *
10
+ * @module services/execution-changes-service
11
+ */
12
+ import type Database from "better-sqlite3";
13
+ import type { ExecutionChangesResult } from "@sudocode-ai/types";
14
+ /**
15
+ * Service for calculating code changes from execution commits
16
+ */
17
+ export declare class ExecutionChangesService {
18
+ private db;
19
+ private repoPath;
20
+ constructor(db: Database.Database, repoPath: string);
21
+ /**
22
+ * Get code changes for an execution
23
+ *
24
+ * For execution chains (follow-ups), automatically calculates accumulated changes
25
+ * from the root execution to the current execution.
26
+ *
27
+ * @param executionId - Execution ID
28
+ * @returns ExecutionChangesResult with both captured and current states
29
+ */
30
+ getChanges(executionId: string): Promise<ExecutionChangesResult>;
31
+ /**
32
+ * Get root execution by traversing parent_execution_id chain
33
+ *
34
+ * For execution chains (follow-ups), this finds the original root execution.
35
+ * This allows us to calculate accumulated changes from the start of the chain.
36
+ */
37
+ private getRootExecution;
38
+ /**
39
+ * Get committed changes (commit-to-commit diff)
40
+ * Scenario A: after_commit exists and differs from before_commit
41
+ */
42
+ private getCommittedChanges;
43
+ /**
44
+ * Get uncommitted changes (working tree diff)
45
+ * Scenario B: after_commit is null or equals before_commit
46
+ */
47
+ private getUncommittedChanges;
48
+ /**
49
+ * Calculate diff statistics using git commands
50
+ *
51
+ * @param beforeCommit - Before commit SHA (null for uncommitted)
52
+ * @param afterCommit - After commit SHA (null for uncommitted)
53
+ * @param workDir - Working directory for git commands
54
+ * @returns Array of file change statistics
55
+ */
56
+ private calculateDiff;
57
+ /**
58
+ * Parse git diff --numstat output
59
+ *
60
+ * Format: "additions\tdeletions\tfilepath"
61
+ * Binary files: "-\t-\tfilepath"
62
+ */
63
+ private parseNumstat;
64
+ /**
65
+ * Parse git diff --name-status output
66
+ *
67
+ * Format: "STATUS\tfilepath"
68
+ * Renamed files: "R100\toldpath\tnewpath"
69
+ */
70
+ private parseNameStatus;
71
+ /**
72
+ * Combine numstat and name-status data into FileChangeStat array
73
+ */
74
+ private combineFileData;
75
+ /**
76
+ * Calculate summary statistics from file changes
77
+ */
78
+ private calculateSummary;
79
+ /**
80
+ * Get branch information (existence and current HEAD)
81
+ */
82
+ private getBranchInfo;
83
+ /**
84
+ * Count commits between two commit SHAs
85
+ */
86
+ private countCommitsBetween;
87
+ /**
88
+ * Count commits the branch is ahead of target branch
89
+ * Uses merge-base to find the common ancestor
90
+ */
91
+ private countCommitsAhead;
92
+ /**
93
+ * Get untracked files (respecting .gitignore)
94
+ */
95
+ private getUntrackedFiles;
96
+ /**
97
+ * Get diff content for a specific file
98
+ *
99
+ * @param executionId - Execution ID
100
+ * @param filePath - Path to the file
101
+ * @returns Object with oldContent and newContent
102
+ */
103
+ getFileDiff(executionId: string, filePath: string): Promise<{
104
+ success: boolean;
105
+ oldContent?: string;
106
+ newContent?: string;
107
+ error?: string;
108
+ }>;
109
+ }
110
+ //# sourceMappingURL=execution-changes-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execution-changes-service.d.ts","sourceRoot":"","sources":["../../src/services/execution-changes-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EACV,sBAAsB,EAIvB,MAAM,oBAAoB,CAAC;AAI5B;;GAEG;AACH,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,EAAE;IACV,OAAO,CAAC,QAAQ;gBADR,EAAE,EAAE,QAAQ,CAAC,QAAQ,EACrB,QAAQ,EAAE,MAAM;IAG1B;;;;;;;;OAQG;IACG,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAuMtE;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAkBxB;;;OAGG;YACW,mBAAmB;IA4DjC;;;OAGG;YACW,qBAAqB;IA4DnC;;;;;;;OAOG;YACW,aAAa;IAiD3B;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IA0BpB;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAsCvB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAYxB;;OAEG;IACH,OAAO,CAAC,aAAa;IAyBrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAsB3B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAiCzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAmDzB;;;;;;OAMG;IACG,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAChE,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC;CAqHH"}