claude-ide-bridge 1.1.0

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 (273) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +263 -0
  3. package/dist/activityLog.d.ts +26 -0
  4. package/dist/activityLog.js +76 -0
  5. package/dist/activityLog.js.map +1 -0
  6. package/dist/bridge.d.ts +19 -0
  7. package/dist/bridge.js +277 -0
  8. package/dist/bridge.js.map +1 -0
  9. package/dist/config.d.ts +22 -0
  10. package/dist/config.js +221 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/errors.d.ts +16 -0
  13. package/dist/errors.js +20 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/extensionClient.d.ts +193 -0
  16. package/dist/extensionClient.js +698 -0
  17. package/dist/extensionClient.js.map +1 -0
  18. package/dist/fileLock.d.ts +12 -0
  19. package/dist/fileLock.js +30 -0
  20. package/dist/fileLock.js.map +1 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +38 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/lockfile.d.ts +12 -0
  25. package/dist/lockfile.js +127 -0
  26. package/dist/lockfile.js.map +1 -0
  27. package/dist/logger.d.ts +16 -0
  28. package/dist/logger.js +68 -0
  29. package/dist/logger.js.map +1 -0
  30. package/dist/probe.d.ts +22 -0
  31. package/dist/probe.js +45 -0
  32. package/dist/probe.js.map +1 -0
  33. package/dist/server.d.ts +25 -0
  34. package/dist/server.js +265 -0
  35. package/dist/server.js.map +1 -0
  36. package/dist/tools/activityLog.d.ts +39 -0
  37. package/dist/tools/activityLog.js +49 -0
  38. package/dist/tools/activityLog.js.map +1 -0
  39. package/dist/tools/aiComments.d.ts +26 -0
  40. package/dist/tools/aiComments.js +196 -0
  41. package/dist/tools/aiComments.js.map +1 -0
  42. package/dist/tools/bridgeStatus.d.ts +21 -0
  43. package/dist/tools/bridgeStatus.js +41 -0
  44. package/dist/tools/bridgeStatus.js.map +1 -0
  45. package/dist/tools/checkDocumentDirty.d.ts +28 -0
  46. package/dist/tools/checkDocumentDirty.js +61 -0
  47. package/dist/tools/checkDocumentDirty.js.map +1 -0
  48. package/dist/tools/clipboard.d.ts +50 -0
  49. package/dist/tools/clipboard.js +82 -0
  50. package/dist/tools/clipboard.js.map +1 -0
  51. package/dist/tools/closeTabs.d.ts +49 -0
  52. package/dist/tools/closeTabs.js +77 -0
  53. package/dist/tools/closeTabs.js.map +1 -0
  54. package/dist/tools/debug.d.ts +154 -0
  55. package/dist/tools/debug.js +248 -0
  56. package/dist/tools/debug.js.map +1 -0
  57. package/dist/tools/decorations.d.ts +92 -0
  58. package/dist/tools/decorations.js +150 -0
  59. package/dist/tools/decorations.js.map +1 -0
  60. package/dist/tools/diffDebugger.d.ts +62 -0
  61. package/dist/tools/diffDebugger.js +245 -0
  62. package/dist/tools/diffDebugger.js.map +1 -0
  63. package/dist/tools/editText.d.ts +80 -0
  64. package/dist/tools/editText.js +274 -0
  65. package/dist/tools/editText.js.map +1 -0
  66. package/dist/tools/fileOperations.d.ts +111 -0
  67. package/dist/tools/fileOperations.js +280 -0
  68. package/dist/tools/fileOperations.js.map +1 -0
  69. package/dist/tools/fileWatcher.d.ts +54 -0
  70. package/dist/tools/fileWatcher.js +100 -0
  71. package/dist/tools/fileWatcher.js.map +1 -0
  72. package/dist/tools/findFiles.d.ts +31 -0
  73. package/dist/tools/findFiles.js +119 -0
  74. package/dist/tools/findFiles.js.map +1 -0
  75. package/dist/tools/fixAllLintErrors.d.ts +29 -0
  76. package/dist/tools/fixAllLintErrors.js +114 -0
  77. package/dist/tools/fixAllLintErrors.js.map +1 -0
  78. package/dist/tools/flowGuardian.d.ts +61 -0
  79. package/dist/tools/flowGuardian.js +311 -0
  80. package/dist/tools/flowGuardian.js.map +1 -0
  81. package/dist/tools/formatDocument.d.ts +30 -0
  82. package/dist/tools/formatDocument.js +132 -0
  83. package/dist/tools/formatDocument.js.map +1 -0
  84. package/dist/tools/formatFile.d.ts +28 -0
  85. package/dist/tools/formatFile.js +110 -0
  86. package/dist/tools/formatFile.js.map +1 -0
  87. package/dist/tools/getBufferContent.d.ts +38 -0
  88. package/dist/tools/getBufferContent.js +100 -0
  89. package/dist/tools/getBufferContent.js.map +1 -0
  90. package/dist/tools/getCurrentSelection.d.ts +43 -0
  91. package/dist/tools/getCurrentSelection.js +75 -0
  92. package/dist/tools/getCurrentSelection.js.map +1 -0
  93. package/dist/tools/getDiagnostics.d.ts +38 -0
  94. package/dist/tools/getDiagnostics.js +204 -0
  95. package/dist/tools/getDiagnostics.js.map +1 -0
  96. package/dist/tools/getDocumentSymbols.d.ts +27 -0
  97. package/dist/tools/getDocumentSymbols.js +133 -0
  98. package/dist/tools/getDocumentSymbols.js.map +1 -0
  99. package/dist/tools/getFileTree.d.ts +36 -0
  100. package/dist/tools/getFileTree.js +111 -0
  101. package/dist/tools/getFileTree.js.map +1 -0
  102. package/dist/tools/getGitDiff.d.ts +34 -0
  103. package/dist/tools/getGitDiff.js +57 -0
  104. package/dist/tools/getGitDiff.js.map +1 -0
  105. package/dist/tools/getGitLog.d.ts +30 -0
  106. package/dist/tools/getGitLog.js +65 -0
  107. package/dist/tools/getGitLog.js.map +1 -0
  108. package/dist/tools/getGitStatus.d.ts +26 -0
  109. package/dist/tools/getGitStatus.js +95 -0
  110. package/dist/tools/getGitStatus.js.map +1 -0
  111. package/dist/tools/getOpenEditors.d.ts +21 -0
  112. package/dist/tools/getOpenEditors.js +84 -0
  113. package/dist/tools/getOpenEditors.js.map +1 -0
  114. package/dist/tools/getProjectInfo.d.ts +20 -0
  115. package/dist/tools/getProjectInfo.js +315 -0
  116. package/dist/tools/getProjectInfo.js.map +1 -0
  117. package/dist/tools/getToolCapabilities.d.ts +23 -0
  118. package/dist/tools/getToolCapabilities.js +249 -0
  119. package/dist/tools/getToolCapabilities.js.map +1 -0
  120. package/dist/tools/getWorkspaceFolders.d.ts +21 -0
  121. package/dist/tools/getWorkspaceFolders.js +47 -0
  122. package/dist/tools/getWorkspaceFolders.js.map +1 -0
  123. package/dist/tools/gitHistory.d.ts +78 -0
  124. package/dist/tools/gitHistory.js +151 -0
  125. package/dist/tools/gitHistory.js.map +1 -0
  126. package/dist/tools/gitWrite.d.ts +335 -0
  127. package/dist/tools/gitWrite.js +859 -0
  128. package/dist/tools/gitWrite.js.map +1 -0
  129. package/dist/tools/github/actions.d.ts +67 -0
  130. package/dist/tools/github/actions.js +155 -0
  131. package/dist/tools/github/actions.js.map +1 -0
  132. package/dist/tools/github/index.d.ts +4 -0
  133. package/dist/tools/github/index.js +5 -0
  134. package/dist/tools/github/index.js.map +1 -0
  135. package/dist/tools/github/issues.d.ts +140 -0
  136. package/dist/tools/github/issues.js +279 -0
  137. package/dist/tools/github/issues.js.map +1 -0
  138. package/dist/tools/github/pr.d.ts +101 -0
  139. package/dist/tools/github/pr.js +215 -0
  140. package/dist/tools/github/pr.js.map +1 -0
  141. package/dist/tools/github/review.d.ts +101 -0
  142. package/dist/tools/github/review.js +292 -0
  143. package/dist/tools/github/review.js.map +1 -0
  144. package/dist/tools/github/shared.d.ts +4 -0
  145. package/dist/tools/github/shared.js +12 -0
  146. package/dist/tools/github/shared.js.map +1 -0
  147. package/dist/tools/github.d.ts +308 -0
  148. package/dist/tools/github.js +656 -0
  149. package/dist/tools/github.js.map +1 -0
  150. package/dist/tools/hoverAtCursor.d.ts +22 -0
  151. package/dist/tools/hoverAtCursor.js +51 -0
  152. package/dist/tools/hoverAtCursor.js.map +1 -0
  153. package/dist/tools/httpClient.d.ts +83 -0
  154. package/dist/tools/httpClient.js +335 -0
  155. package/dist/tools/httpClient.js.map +1 -0
  156. package/dist/tools/index.d.ts +7 -0
  157. package/dist/tools/index.js +246 -0
  158. package/dist/tools/index.js.map +1 -0
  159. package/dist/tools/inlayHints.d.ts +38 -0
  160. package/dist/tools/inlayHints.js +56 -0
  161. package/dist/tools/inlayHints.js.map +1 -0
  162. package/dist/tools/linters/biome.d.ts +2 -0
  163. package/dist/tools/linters/biome.js +44 -0
  164. package/dist/tools/linters/biome.js.map +1 -0
  165. package/dist/tools/linters/cargo.d.ts +2 -0
  166. package/dist/tools/linters/cargo.js +45 -0
  167. package/dist/tools/linters/cargo.js.map +1 -0
  168. package/dist/tools/linters/eslint.d.ts +2 -0
  169. package/dist/tools/linters/eslint.js +59 -0
  170. package/dist/tools/linters/eslint.js.map +1 -0
  171. package/dist/tools/linters/govet.d.ts +2 -0
  172. package/dist/tools/linters/govet.js +37 -0
  173. package/dist/tools/linters/govet.js.map +1 -0
  174. package/dist/tools/linters/pyright.d.ts +2 -0
  175. package/dist/tools/linters/pyright.js +34 -0
  176. package/dist/tools/linters/pyright.js.map +1 -0
  177. package/dist/tools/linters/ruff.d.ts +2 -0
  178. package/dist/tools/linters/ruff.js +30 -0
  179. package/dist/tools/linters/ruff.js.map +1 -0
  180. package/dist/tools/linters/types.d.ts +16 -0
  181. package/dist/tools/linters/types.js +2 -0
  182. package/dist/tools/linters/types.js.map +1 -0
  183. package/dist/tools/linters/typescript.d.ts +2 -0
  184. package/dist/tools/linters/typescript.js +38 -0
  185. package/dist/tools/linters/typescript.js.map +1 -0
  186. package/dist/tools/lsp.d.ts +310 -0
  187. package/dist/tools/lsp.js +684 -0
  188. package/dist/tools/lsp.js.map +1 -0
  189. package/dist/tools/notebook.d.ts +95 -0
  190. package/dist/tools/notebook.js +144 -0
  191. package/dist/tools/notebook.js.map +1 -0
  192. package/dist/tools/openDiff.d.ts +41 -0
  193. package/dist/tools/openDiff.js +116 -0
  194. package/dist/tools/openDiff.js.map +1 -0
  195. package/dist/tools/openFile.d.ts +34 -0
  196. package/dist/tools/openFile.js +102 -0
  197. package/dist/tools/openFile.js.map +1 -0
  198. package/dist/tools/organizeImports.d.ts +29 -0
  199. package/dist/tools/organizeImports.js +64 -0
  200. package/dist/tools/organizeImports.js.map +1 -0
  201. package/dist/tools/planPersistence.d.ts +196 -0
  202. package/dist/tools/planPersistence.js +437 -0
  203. package/dist/tools/planPersistence.js.map +1 -0
  204. package/dist/tools/replaceBlock.d.ts +40 -0
  205. package/dist/tools/replaceBlock.js +105 -0
  206. package/dist/tools/replaceBlock.js.map +1 -0
  207. package/dist/tools/runCommand.d.ts +43 -0
  208. package/dist/tools/runCommand.js +141 -0
  209. package/dist/tools/runCommand.js.map +1 -0
  210. package/dist/tools/runTests.d.ts +32 -0
  211. package/dist/tools/runTests.js +160 -0
  212. package/dist/tools/runTests.js.map +1 -0
  213. package/dist/tools/saveDocument.d.ts +28 -0
  214. package/dist/tools/saveDocument.js +58 -0
  215. package/dist/tools/saveDocument.js.map +1 -0
  216. package/dist/tools/searchAndReplace.d.ts +50 -0
  217. package/dist/tools/searchAndReplace.js +203 -0
  218. package/dist/tools/searchAndReplace.js.map +1 -0
  219. package/dist/tools/searchWorkspace.d.ts +52 -0
  220. package/dist/tools/searchWorkspace.js +159 -0
  221. package/dist/tools/searchWorkspace.js.map +1 -0
  222. package/dist/tools/setActiveWorkspaceFolder.d.ts +28 -0
  223. package/dist/tools/setActiveWorkspaceFolder.js +32 -0
  224. package/dist/tools/setActiveWorkspaceFolder.js.map +1 -0
  225. package/dist/tools/tasks.d.ts +56 -0
  226. package/dist/tools/tasks.js +89 -0
  227. package/dist/tools/tasks.js.map +1 -0
  228. package/dist/tools/terminal.d.ts +241 -0
  229. package/dist/tools/terminal.js +539 -0
  230. package/dist/tools/terminal.js.map +1 -0
  231. package/dist/tools/testRunners/cargoTest.d.ts +2 -0
  232. package/dist/tools/testRunners/cargoTest.js +123 -0
  233. package/dist/tools/testRunners/cargoTest.js.map +1 -0
  234. package/dist/tools/testRunners/goTest.d.ts +2 -0
  235. package/dist/tools/testRunners/goTest.js +106 -0
  236. package/dist/tools/testRunners/goTest.js.map +1 -0
  237. package/dist/tools/testRunners/pytest.d.ts +2 -0
  238. package/dist/tools/testRunners/pytest.js +133 -0
  239. package/dist/tools/testRunners/pytest.js.map +1 -0
  240. package/dist/tools/testRunners/types.d.ts +18 -0
  241. package/dist/tools/testRunners/types.js +2 -0
  242. package/dist/tools/testRunners/types.js.map +1 -0
  243. package/dist/tools/testRunners/vitestJest.d.ts +3 -0
  244. package/dist/tools/testRunners/vitestJest.js +178 -0
  245. package/dist/tools/testRunners/vitestJest.js.map +1 -0
  246. package/dist/tools/typeHierarchy.d.ts +45 -0
  247. package/dist/tools/typeHierarchy.js +65 -0
  248. package/dist/tools/typeHierarchy.js.map +1 -0
  249. package/dist/tools/utils.d.ts +54 -0
  250. package/dist/tools/utils.js +267 -0
  251. package/dist/tools/utils.js.map +1 -0
  252. package/dist/tools/vscodeCommands.d.ts +59 -0
  253. package/dist/tools/vscodeCommands.js +108 -0
  254. package/dist/tools/vscodeCommands.js.map +1 -0
  255. package/dist/tools/watchDiagnostics.d.ts +32 -0
  256. package/dist/tools/watchDiagnostics.js +87 -0
  257. package/dist/tools/watchDiagnostics.js.map +1 -0
  258. package/dist/tools/workspaceSettings.d.ts +67 -0
  259. package/dist/tools/workspaceSettings.js +102 -0
  260. package/dist/tools/workspaceSettings.js.map +1 -0
  261. package/dist/tools/workspaceSnapshots.d.ts +174 -0
  262. package/dist/tools/workspaceSnapshots.js +474 -0
  263. package/dist/tools/workspaceSnapshots.js.map +1 -0
  264. package/dist/transport.d.ts +57 -0
  265. package/dist/transport.js +417 -0
  266. package/dist/transport.js.map +1 -0
  267. package/dist/version.d.ts +2 -0
  268. package/dist/version.js +3 -0
  269. package/dist/version.js.map +1 -0
  270. package/dist/wsUtils.d.ts +9 -0
  271. package/dist/wsUtils.js +54 -0
  272. package/dist/wsUtils.js.map +1 -0
  273. package/package.json +69 -0
@@ -0,0 +1,47 @@
1
+ import path from "node:path";
2
+ import { success } from "./utils.js";
3
+ export function createGetWorkspaceFoldersTool(workspaceFolders, extensionClient) {
4
+ return {
5
+ schema: {
6
+ name: "getWorkspaceFolders",
7
+ description: "Get all workspace folders currently open in the IDE",
8
+ annotations: { readOnlyHint: true },
9
+ inputSchema: {
10
+ $schema: "http://json-schema.org/draft-07/schema#",
11
+ type: "object",
12
+ additionalProperties: false,
13
+ },
14
+ },
15
+ async handler() {
16
+ // Use extension for real multi-root data when available
17
+ if (extensionClient?.isConnected()) {
18
+ try {
19
+ const folders = await extensionClient.getWorkspaceFolders();
20
+ if (folders && folders.length > 0) {
21
+ return success({
22
+ success: true,
23
+ folders,
24
+ rootPath: folders[0]?.path ?? null,
25
+ workspaceFile: null,
26
+ });
27
+ }
28
+ }
29
+ catch {
30
+ // Fall through to static list
31
+ }
32
+ }
33
+ return success({
34
+ success: true,
35
+ folders: workspaceFolders.map((p, i) => ({
36
+ name: path.basename(p),
37
+ uri: `file://${p}`,
38
+ path: p,
39
+ index: i,
40
+ })),
41
+ rootPath: workspaceFolders[0] ?? null,
42
+ workspaceFile: null,
43
+ });
44
+ },
45
+ };
46
+ }
47
+ //# sourceMappingURL=getWorkspaceFolders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWorkspaceFolders.js","sourceRoot":"","sources":["../../src/tools/getWorkspaceFolders.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,UAAU,6BAA6B,CAC3C,gBAA0B,EAC1B,eAAiC;IAEjC,OAAO;QACL,MAAM,EAAE;YACN,IAAI,EAAE,qBAAqB;YAC3B,WAAW,EAAE,qDAAqD;YAClE,WAAW,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE;YACnC,WAAW,EAAE;gBACX,OAAO,EAAE,yCAAyC;gBAClD,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,KAAK;aAC5B;SACF;QAED,KAAK,CAAC,OAAO;YACX,wDAAwD;YACxD,IAAI,eAAe,EAAE,WAAW,EAAE,EAAE,CAAC;gBACnC,IAAI,CAAC;oBACH,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,mBAAmB,EAAE,CAAC;oBAC5D,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAClC,OAAO,OAAO,CAAC;4BACb,OAAO,EAAE,IAAI;4BACb,OAAO;4BACP,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,IAAI;4BAClC,aAAa,EAAE,IAAI;yBACpB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,8BAA8B;gBAChC,CAAC;YACH,CAAC;YAED,OAAO,OAAO,CAAC;gBACb,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;oBACvC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;oBACtB,GAAG,EAAE,UAAU,CAAC,EAAE;oBAClB,IAAI,EAAE,CAAC;oBACP,KAAK,EAAE,CAAC;iBACT,CAAC,CAAC;gBACH,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,IAAI,IAAI;gBACrC,aAAa,EAAE,IAAI;aACpB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,78 @@
1
+ export declare function createGetCommitDetailsTool(workspace: string): {
2
+ schema: {
3
+ name: string;
4
+ description: string;
5
+ annotations: {
6
+ readOnlyHint: boolean;
7
+ };
8
+ inputSchema: {
9
+ $schema: string;
10
+ type: string;
11
+ additionalProperties: boolean;
12
+ required: string[];
13
+ properties: {
14
+ commitHash: {
15
+ type: string;
16
+ description: string;
17
+ };
18
+ includePatch: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ filePath: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ };
27
+ };
28
+ };
29
+ handler(args: Record<string, unknown>, signal?: AbortSignal): Promise<{
30
+ content: Array<{
31
+ type: string;
32
+ text: string;
33
+ }>;
34
+ }>;
35
+ };
36
+ export declare function createGetDiffBetweenRefsTool(workspace: string): {
37
+ schema: {
38
+ name: string;
39
+ description: string;
40
+ annotations: {
41
+ readOnlyHint: boolean;
42
+ };
43
+ inputSchema: {
44
+ $schema: string;
45
+ type: string;
46
+ additionalProperties: boolean;
47
+ required: string[];
48
+ properties: {
49
+ ref1: {
50
+ type: string;
51
+ description: string;
52
+ };
53
+ ref2: {
54
+ type: string;
55
+ description: string;
56
+ };
57
+ filePath: {
58
+ type: string;
59
+ description: string;
60
+ };
61
+ context: {
62
+ type: string;
63
+ description: string;
64
+ };
65
+ statOnly: {
66
+ type: string;
67
+ description: string;
68
+ };
69
+ };
70
+ };
71
+ };
72
+ handler(args: Record<string, unknown>, signal?: AbortSignal): Promise<{
73
+ content: Array<{
74
+ type: string;
75
+ text: string;
76
+ }>;
77
+ }>;
78
+ };
@@ -0,0 +1,151 @@
1
+ import { execSafe, optionalBool, optionalInt, optionalString, requireString, resolveFilePath, success, truncateOutput, } from "./utils.js";
2
+ // Conservative ref/hash validation — matches the pattern in gitWrite.ts
3
+ const VALID_REF_RE = /^[\w.\-/]+$/;
4
+ const MAX_OUTPUT_BYTES = 500 * 1024;
5
+ export function createGetCommitDetailsTool(workspace) {
6
+ return {
7
+ schema: {
8
+ name: "getCommitDetails",
9
+ description: "Get the full details of a git commit: author, date, commit message, changed files, " +
10
+ "and optionally the complete diff patch. Use getGitLog to find commit hashes first.",
11
+ annotations: { readOnlyHint: true },
12
+ inputSchema: {
13
+ $schema: "http://json-schema.org/draft-07/schema#",
14
+ type: "object",
15
+ additionalProperties: false,
16
+ required: ["commitHash"],
17
+ properties: {
18
+ commitHash: {
19
+ type: "string",
20
+ description: "Full or abbreviated commit hash",
21
+ },
22
+ includePatch: {
23
+ type: "boolean",
24
+ description: "Include the full diff patch in the output. Default: true. " +
25
+ "Set false to retrieve only metadata and file stats.",
26
+ },
27
+ filePath: {
28
+ type: "string",
29
+ description: "Optional absolute or workspace-relative file path to limit the diff output to a single file",
30
+ },
31
+ },
32
+ },
33
+ },
34
+ async handler(args, signal) {
35
+ const hash = requireString(args, "commitHash", 64);
36
+ if (!VALID_REF_RE.test(hash)) {
37
+ return success({ error: "Invalid commit hash" });
38
+ }
39
+ const includePatch = optionalBool(args, "includePatch") ?? true;
40
+ const rawPath = optionalString(args, "filePath");
41
+ const filterPath = rawPath
42
+ ? resolveFilePath(rawPath, workspace)
43
+ : undefined;
44
+ // git show with a custom pretty format, then --stat for file summary
45
+ // --format separates the header from the diff body
46
+ const showArgs = ["show", "--format=fuller", "--stat"];
47
+ if (!includePatch)
48
+ showArgs.push("--no-patch");
49
+ showArgs.push(hash);
50
+ if (filterPath)
51
+ showArgs.push("--", filterPath);
52
+ const result = await execSafe("git", showArgs, {
53
+ cwd: workspace,
54
+ maxBuffer: MAX_OUTPUT_BYTES + 64 * 1024,
55
+ signal,
56
+ });
57
+ if (result.exitCode !== 0) {
58
+ const msg = result.stderr.trim();
59
+ if (msg.includes("unknown revision") || msg.includes("bad object")) {
60
+ return success({ error: `Commit "${hash}" not found` });
61
+ }
62
+ return success({ error: msg || "git show failed" });
63
+ }
64
+ const { text, truncated } = truncateOutput(result.stdout, MAX_OUTPUT_BYTES);
65
+ return success({
66
+ output: text,
67
+ ...(truncated ? { truncated: true } : {}),
68
+ });
69
+ },
70
+ };
71
+ }
72
+ export function createGetDiffBetweenRefsTool(workspace) {
73
+ return {
74
+ schema: {
75
+ name: "getDiffBetweenRefs",
76
+ description: "Get the diff between two git refs (branches, tags, or commit hashes). " +
77
+ "Example: ref1='main' ref2='feature/my-branch' shows what the feature branch adds. " +
78
+ "Use statOnly to get a quick file-level summary without the full patch.",
79
+ annotations: { readOnlyHint: true },
80
+ inputSchema: {
81
+ $schema: "http://json-schema.org/draft-07/schema#",
82
+ type: "object",
83
+ additionalProperties: false,
84
+ required: ["ref1", "ref2"],
85
+ properties: {
86
+ ref1: {
87
+ type: "string",
88
+ description: "The base ref (branch, tag, or commit hash)",
89
+ },
90
+ ref2: {
91
+ type: "string",
92
+ description: "The comparison ref (branch, tag, or commit hash)",
93
+ },
94
+ filePath: {
95
+ type: "string",
96
+ description: "Optional absolute or workspace-relative file path to limit the diff to a single file",
97
+ },
98
+ context: {
99
+ type: "integer",
100
+ description: "Number of context lines around changes. Default: 3",
101
+ },
102
+ statOnly: {
103
+ type: "boolean",
104
+ description: "Return only the file-level stat summary instead of the full patch. Default: false.",
105
+ },
106
+ },
107
+ },
108
+ },
109
+ async handler(args, signal) {
110
+ const ref1 = requireString(args, "ref1", 256);
111
+ const ref2 = requireString(args, "ref2", 256);
112
+ if (!VALID_REF_RE.test(ref1))
113
+ return success({ error: "Invalid ref1" });
114
+ if (!VALID_REF_RE.test(ref2))
115
+ return success({ error: "Invalid ref2" });
116
+ const rawPath = optionalString(args, "filePath");
117
+ const filterPath = rawPath
118
+ ? resolveFilePath(rawPath, workspace)
119
+ : undefined;
120
+ const context = optionalInt(args, "context", 0, 100) ?? 3;
121
+ const statOnly = optionalBool(args, "statOnly") ?? false;
122
+ const diffArgs = ["diff"];
123
+ if (statOnly) {
124
+ diffArgs.push("--stat");
125
+ }
126
+ else {
127
+ diffArgs.push(`-U${context}`);
128
+ }
129
+ diffArgs.push(`${ref1}..${ref2}`);
130
+ if (filterPath)
131
+ diffArgs.push("--", filterPath);
132
+ const result = await execSafe("git", diffArgs, {
133
+ cwd: workspace,
134
+ maxBuffer: MAX_OUTPUT_BYTES + 64 * 1024,
135
+ signal,
136
+ });
137
+ if (result.exitCode !== 0) {
138
+ const msg = result.stderr.trim();
139
+ if (msg.includes("unknown revision") || msg.includes("bad object")) {
140
+ return success({
141
+ error: `One or both refs not found: "${ref1}", "${ref2}"`,
142
+ });
143
+ }
144
+ return success({ error: msg || "git diff failed" });
145
+ }
146
+ const { text, truncated } = truncateOutput(result.stdout, MAX_OUTPUT_BYTES);
147
+ return success({ diff: text, ...(truncated ? { truncated: true } : {}) });
148
+ },
149
+ };
150
+ }
151
+ //# sourceMappingURL=gitHistory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitHistory.js","sourceRoot":"","sources":["../../src/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BAAkB,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;oBACnE,OAAO,OAAO,CAAC;wBACb,KAAK,EAAE,gCAAgC,IAAI,OAAO,IAAI,GAAG;qBAC1D,CAAC,CAAC;gBACL,CAAC;gBACD,OAAO,OAAO,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,iBAAiB,EAAE,CAAC,CAAC;YACtD,CAAC;YAED,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,cAAc,CACxC,MAAM,CAAC,MAAM,EACb,gBAAgB,CACjB,CAAC;YACF,OAAO,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAC5E,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,335 @@
1
+ export declare function createGitAddTool(workspace: string): {
2
+ schema: {
3
+ name: string;
4
+ description: string;
5
+ annotations: {
6
+ destructiveHint: boolean;
7
+ };
8
+ inputSchema: {
9
+ type: "object";
10
+ properties: {
11
+ files: {
12
+ type: string;
13
+ items: {
14
+ type: string;
15
+ };
16
+ description: string;
17
+ };
18
+ addUntracked: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ };
23
+ additionalProperties: false;
24
+ };
25
+ };
26
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
27
+ content: Array<{
28
+ type: string;
29
+ text: string;
30
+ }>;
31
+ }>;
32
+ };
33
+ export declare function createGitCommitTool(workspace: string): {
34
+ schema: {
35
+ name: string;
36
+ description: string;
37
+ annotations: {
38
+ destructiveHint: boolean;
39
+ };
40
+ inputSchema: {
41
+ type: "object";
42
+ properties: {
43
+ message: {
44
+ type: string;
45
+ description: string;
46
+ };
47
+ files: {
48
+ type: string;
49
+ items: {
50
+ type: string;
51
+ };
52
+ description: string;
53
+ };
54
+ addAll: {
55
+ type: string;
56
+ description: string;
57
+ };
58
+ };
59
+ required: string[];
60
+ additionalProperties: false;
61
+ };
62
+ };
63
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
64
+ content: Array<{
65
+ type: string;
66
+ text: string;
67
+ }>;
68
+ }>;
69
+ };
70
+ export declare function createGitCheckoutTool(workspace: string): {
71
+ schema: {
72
+ name: string;
73
+ description: string;
74
+ annotations: {
75
+ destructiveHint: boolean;
76
+ };
77
+ inputSchema: {
78
+ type: "object";
79
+ properties: {
80
+ branch: {
81
+ type: string;
82
+ description: string;
83
+ };
84
+ create: {
85
+ type: string;
86
+ description: string;
87
+ };
88
+ base: {
89
+ type: string;
90
+ description: string;
91
+ };
92
+ };
93
+ required: string[];
94
+ additionalProperties: false;
95
+ };
96
+ };
97
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
98
+ content: Array<{
99
+ type: string;
100
+ text: string;
101
+ }>;
102
+ }>;
103
+ };
104
+ export declare function createGitBlameTool(workspace: string): {
105
+ schema: {
106
+ name: string;
107
+ description: string;
108
+ annotations: {
109
+ readOnlyHint: boolean;
110
+ };
111
+ inputSchema: {
112
+ type: "object";
113
+ properties: {
114
+ filePath: {
115
+ type: string;
116
+ description: string;
117
+ };
118
+ startLine: {
119
+ type: string;
120
+ description: string;
121
+ };
122
+ endLine: {
123
+ type: string;
124
+ description: string;
125
+ };
126
+ };
127
+ required: string[];
128
+ additionalProperties: false;
129
+ };
130
+ };
131
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
132
+ content: Array<{
133
+ type: string;
134
+ text: string;
135
+ }>;
136
+ }>;
137
+ };
138
+ export declare function createGitFetchTool(workspace: string): {
139
+ schema: {
140
+ name: string;
141
+ description: string;
142
+ annotations: {
143
+ readOnlyHint: boolean;
144
+ };
145
+ inputSchema: {
146
+ type: "object";
147
+ properties: {
148
+ remote: {
149
+ type: string;
150
+ description: string;
151
+ };
152
+ all: {
153
+ type: string;
154
+ description: string;
155
+ };
156
+ };
157
+ additionalProperties: false;
158
+ };
159
+ };
160
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
161
+ content: Array<{
162
+ type: string;
163
+ text: string;
164
+ }>;
165
+ }>;
166
+ };
167
+ export declare function createGitListBranchesTool(workspace: string): {
168
+ schema: {
169
+ name: string;
170
+ description: string;
171
+ annotations: {
172
+ readOnlyHint: boolean;
173
+ };
174
+ inputSchema: {
175
+ type: "object";
176
+ properties: {
177
+ includeRemote: {
178
+ type: string;
179
+ description: string;
180
+ };
181
+ };
182
+ additionalProperties: false;
183
+ };
184
+ };
185
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
186
+ content: Array<{
187
+ type: string;
188
+ text: string;
189
+ }>;
190
+ }>;
191
+ };
192
+ export declare function createGitPullTool(workspace: string): {
193
+ schema: {
194
+ name: string;
195
+ description: string;
196
+ annotations: {
197
+ destructiveHint: boolean;
198
+ };
199
+ inputSchema: {
200
+ type: "object";
201
+ properties: {
202
+ remote: {
203
+ type: string;
204
+ description: string;
205
+ };
206
+ branch: {
207
+ type: string;
208
+ description: string;
209
+ };
210
+ rebase: {
211
+ type: string;
212
+ description: string;
213
+ };
214
+ };
215
+ additionalProperties: false;
216
+ };
217
+ };
218
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
219
+ content: Array<{
220
+ type: string;
221
+ text: string;
222
+ }>;
223
+ }>;
224
+ };
225
+ export declare function createGitPushTool(workspace: string): {
226
+ schema: {
227
+ name: string;
228
+ description: string;
229
+ annotations: {
230
+ destructiveHint: boolean;
231
+ };
232
+ inputSchema: {
233
+ type: "object";
234
+ properties: {
235
+ remote: {
236
+ type: string;
237
+ description: string;
238
+ };
239
+ branch: {
240
+ type: string;
241
+ description: string;
242
+ };
243
+ setUpstream: {
244
+ type: string;
245
+ description: string;
246
+ };
247
+ force: {
248
+ type: string;
249
+ description: string;
250
+ };
251
+ };
252
+ additionalProperties: false;
253
+ };
254
+ };
255
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
256
+ content: Array<{
257
+ type: string;
258
+ text: string;
259
+ }>;
260
+ }>;
261
+ };
262
+ export declare function createGitStashTool(workspace: string): {
263
+ schema: {
264
+ name: string;
265
+ description: string;
266
+ annotations: {
267
+ destructiveHint: boolean;
268
+ };
269
+ inputSchema: {
270
+ type: "object";
271
+ properties: {
272
+ message: {
273
+ type: string;
274
+ description: string;
275
+ };
276
+ includeUntracked: {
277
+ type: string;
278
+ description: string;
279
+ };
280
+ };
281
+ additionalProperties: false;
282
+ };
283
+ };
284
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
285
+ content: Array<{
286
+ type: string;
287
+ text: string;
288
+ }>;
289
+ }>;
290
+ };
291
+ export declare function createGitStashPopTool(workspace: string): {
292
+ schema: {
293
+ name: string;
294
+ description: string;
295
+ annotations: {
296
+ destructiveHint: boolean;
297
+ };
298
+ inputSchema: {
299
+ type: "object";
300
+ properties: {
301
+ index: {
302
+ type: string;
303
+ description: string;
304
+ };
305
+ };
306
+ additionalProperties: false;
307
+ };
308
+ };
309
+ handler: (args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
310
+ content: Array<{
311
+ type: string;
312
+ text: string;
313
+ }>;
314
+ }>;
315
+ };
316
+ export declare function createGitStashListTool(workspace: string): {
317
+ schema: {
318
+ name: string;
319
+ description: string;
320
+ annotations: {
321
+ readOnlyHint: boolean;
322
+ };
323
+ inputSchema: {
324
+ type: "object";
325
+ properties: {};
326
+ additionalProperties: false;
327
+ };
328
+ };
329
+ handler: (_args: Record<string, unknown>, signal?: AbortSignal) => Promise<{
330
+ content: Array<{
331
+ type: string;
332
+ text: string;
333
+ }>;
334
+ }>;
335
+ };