gitx.do 0.1.0 → 0.1.2

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 (344) hide show
  1. package/README.md +40 -353
  2. package/dist/do/logger.d.ts +50 -0
  3. package/dist/do/logger.d.ts.map +1 -0
  4. package/dist/do/logger.js +122 -0
  5. package/dist/do/logger.js.map +1 -0
  6. package/dist/{durable-object → do}/schema.d.ts +3 -3
  7. package/dist/do/schema.d.ts.map +1 -0
  8. package/dist/{durable-object → do}/schema.js +4 -3
  9. package/dist/do/schema.js.map +1 -0
  10. package/dist/do/types.d.ts +267 -0
  11. package/dist/do/types.d.ts.map +1 -0
  12. package/dist/do/types.js +62 -0
  13. package/dist/do/types.js.map +1 -0
  14. package/dist/index.d.ts +15 -415
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +31 -483
  17. package/dist/index.js.map +1 -1
  18. package/package.json +13 -21
  19. package/dist/cli/commands/add.d.ts +0 -174
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -131
  22. package/dist/cli/commands/add.js.map +0 -1
  23. package/dist/cli/commands/blame.d.ts +0 -259
  24. package/dist/cli/commands/blame.d.ts.map +0 -1
  25. package/dist/cli/commands/blame.js +0 -609
  26. package/dist/cli/commands/blame.js.map +0 -1
  27. package/dist/cli/commands/branch.d.ts +0 -249
  28. package/dist/cli/commands/branch.d.ts.map +0 -1
  29. package/dist/cli/commands/branch.js +0 -693
  30. package/dist/cli/commands/branch.js.map +0 -1
  31. package/dist/cli/commands/commit.d.ts +0 -182
  32. package/dist/cli/commands/commit.d.ts.map +0 -1
  33. package/dist/cli/commands/commit.js +0 -437
  34. package/dist/cli/commands/commit.js.map +0 -1
  35. package/dist/cli/commands/diff.d.ts +0 -464
  36. package/dist/cli/commands/diff.d.ts.map +0 -1
  37. package/dist/cli/commands/diff.js +0 -958
  38. package/dist/cli/commands/diff.js.map +0 -1
  39. package/dist/cli/commands/log.d.ts +0 -239
  40. package/dist/cli/commands/log.d.ts.map +0 -1
  41. package/dist/cli/commands/log.js +0 -535
  42. package/dist/cli/commands/log.js.map +0 -1
  43. package/dist/cli/commands/merge.d.ts +0 -106
  44. package/dist/cli/commands/merge.d.ts.map +0 -1
  45. package/dist/cli/commands/merge.js +0 -55
  46. package/dist/cli/commands/merge.js.map +0 -1
  47. package/dist/cli/commands/review.d.ts +0 -457
  48. package/dist/cli/commands/review.d.ts.map +0 -1
  49. package/dist/cli/commands/review.js +0 -533
  50. package/dist/cli/commands/review.js.map +0 -1
  51. package/dist/cli/commands/status.d.ts +0 -269
  52. package/dist/cli/commands/status.d.ts.map +0 -1
  53. package/dist/cli/commands/status.js +0 -493
  54. package/dist/cli/commands/status.js.map +0 -1
  55. package/dist/cli/commands/web.d.ts +0 -199
  56. package/dist/cli/commands/web.d.ts.map +0 -1
  57. package/dist/cli/commands/web.js +0 -696
  58. package/dist/cli/commands/web.js.map +0 -1
  59. package/dist/cli/fs-adapter.d.ts +0 -656
  60. package/dist/cli/fs-adapter.d.ts.map +0 -1
  61. package/dist/cli/fs-adapter.js +0 -1179
  62. package/dist/cli/fs-adapter.js.map +0 -1
  63. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  64. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  65. package/dist/cli/fsx-cli-adapter.js +0 -619
  66. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  67. package/dist/cli/index.d.ts +0 -387
  68. package/dist/cli/index.d.ts.map +0 -1
  69. package/dist/cli/index.js +0 -523
  70. package/dist/cli/index.js.map +0 -1
  71. package/dist/cli/ui/components/DiffView.d.ts +0 -7
  72. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  73. package/dist/cli/ui/components/DiffView.js +0 -11
  74. package/dist/cli/ui/components/DiffView.js.map +0 -1
  75. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -6
  76. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  77. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  78. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  79. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -9
  80. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  81. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  82. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  83. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -6
  84. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  85. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  86. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  87. package/dist/cli/ui/components/NavigationList.d.ts +0 -9
  88. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  89. package/dist/cli/ui/components/NavigationList.js +0 -11
  90. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  91. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -8
  92. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  93. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  94. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  95. package/dist/cli/ui/components/index.d.ts +0 -7
  96. package/dist/cli/ui/components/index.d.ts.map +0 -1
  97. package/dist/cli/ui/components/index.js +0 -9
  98. package/dist/cli/ui/components/index.js.map +0 -1
  99. package/dist/cli/ui/terminal-ui.d.ts +0 -52
  100. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  101. package/dist/cli/ui/terminal-ui.js +0 -121
  102. package/dist/cli/ui/terminal-ui.js.map +0 -1
  103. package/dist/do/BashModule.d.ts +0 -871
  104. package/dist/do/BashModule.d.ts.map +0 -1
  105. package/dist/do/BashModule.js +0 -1143
  106. package/dist/do/BashModule.js.map +0 -1
  107. package/dist/do/FsModule.d.ts +0 -601
  108. package/dist/do/FsModule.d.ts.map +0 -1
  109. package/dist/do/FsModule.js +0 -1120
  110. package/dist/do/FsModule.js.map +0 -1
  111. package/dist/do/GitModule.d.ts +0 -635
  112. package/dist/do/GitModule.d.ts.map +0 -1
  113. package/dist/do/GitModule.js +0 -781
  114. package/dist/do/GitModule.js.map +0 -1
  115. package/dist/do/GitRepoDO.d.ts +0 -281
  116. package/dist/do/GitRepoDO.d.ts.map +0 -1
  117. package/dist/do/GitRepoDO.js +0 -479
  118. package/dist/do/GitRepoDO.js.map +0 -1
  119. package/dist/do/bash-ast.d.ts +0 -246
  120. package/dist/do/bash-ast.d.ts.map +0 -1
  121. package/dist/do/bash-ast.js +0 -888
  122. package/dist/do/bash-ast.js.map +0 -1
  123. package/dist/do/container-executor.d.ts +0 -491
  124. package/dist/do/container-executor.d.ts.map +0 -1
  125. package/dist/do/container-executor.js +0 -730
  126. package/dist/do/container-executor.js.map +0 -1
  127. package/dist/do/index.d.ts +0 -53
  128. package/dist/do/index.d.ts.map +0 -1
  129. package/dist/do/index.js +0 -91
  130. package/dist/do/index.js.map +0 -1
  131. package/dist/do/tiered-storage.d.ts +0 -403
  132. package/dist/do/tiered-storage.d.ts.map +0 -1
  133. package/dist/do/tiered-storage.js +0 -689
  134. package/dist/do/tiered-storage.js.map +0 -1
  135. package/dist/do/withBash.d.ts +0 -231
  136. package/dist/do/withBash.d.ts.map +0 -1
  137. package/dist/do/withBash.js +0 -244
  138. package/dist/do/withBash.js.map +0 -1
  139. package/dist/do/withFs.d.ts +0 -237
  140. package/dist/do/withFs.d.ts.map +0 -1
  141. package/dist/do/withFs.js +0 -387
  142. package/dist/do/withFs.js.map +0 -1
  143. package/dist/do/withGit.d.ts +0 -180
  144. package/dist/do/withGit.d.ts.map +0 -1
  145. package/dist/do/withGit.js +0 -271
  146. package/dist/do/withGit.js.map +0 -1
  147. package/dist/durable-object/object-store.d.ts +0 -633
  148. package/dist/durable-object/object-store.d.ts.map +0 -1
  149. package/dist/durable-object/object-store.js +0 -1161
  150. package/dist/durable-object/object-store.js.map +0 -1
  151. package/dist/durable-object/schema.d.ts.map +0 -1
  152. package/dist/durable-object/schema.js.map +0 -1
  153. package/dist/durable-object/wal.d.ts +0 -416
  154. package/dist/durable-object/wal.d.ts.map +0 -1
  155. package/dist/durable-object/wal.js +0 -445
  156. package/dist/durable-object/wal.js.map +0 -1
  157. package/dist/mcp/adapter.d.ts +0 -772
  158. package/dist/mcp/adapter.d.ts.map +0 -1
  159. package/dist/mcp/adapter.js +0 -895
  160. package/dist/mcp/adapter.js.map +0 -1
  161. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  162. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  163. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  164. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  165. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  166. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  167. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  168. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  169. package/dist/mcp/sandbox/template.d.ts +0 -17
  170. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/template.js +0 -71
  172. package/dist/mcp/sandbox/template.js.map +0 -1
  173. package/dist/mcp/sandbox.d.ts +0 -764
  174. package/dist/mcp/sandbox.d.ts.map +0 -1
  175. package/dist/mcp/sandbox.js +0 -1362
  176. package/dist/mcp/sandbox.js.map +0 -1
  177. package/dist/mcp/sdk-adapter.d.ts +0 -835
  178. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  179. package/dist/mcp/sdk-adapter.js +0 -974
  180. package/dist/mcp/sdk-adapter.js.map +0 -1
  181. package/dist/mcp/tools/do.d.ts +0 -32
  182. package/dist/mcp/tools/do.d.ts.map +0 -1
  183. package/dist/mcp/tools/do.js +0 -115
  184. package/dist/mcp/tools/do.js.map +0 -1
  185. package/dist/mcp/tools.d.ts +0 -548
  186. package/dist/mcp/tools.d.ts.map +0 -1
  187. package/dist/mcp/tools.js +0 -1934
  188. package/dist/mcp/tools.js.map +0 -1
  189. package/dist/ops/blame.d.ts +0 -551
  190. package/dist/ops/blame.d.ts.map +0 -1
  191. package/dist/ops/blame.js +0 -1037
  192. package/dist/ops/blame.js.map +0 -1
  193. package/dist/ops/branch.d.ts +0 -766
  194. package/dist/ops/branch.d.ts.map +0 -1
  195. package/dist/ops/branch.js +0 -950
  196. package/dist/ops/branch.js.map +0 -1
  197. package/dist/ops/commit-traversal.d.ts +0 -349
  198. package/dist/ops/commit-traversal.d.ts.map +0 -1
  199. package/dist/ops/commit-traversal.js +0 -821
  200. package/dist/ops/commit-traversal.js.map +0 -1
  201. package/dist/ops/commit.d.ts +0 -555
  202. package/dist/ops/commit.d.ts.map +0 -1
  203. package/dist/ops/commit.js +0 -826
  204. package/dist/ops/commit.js.map +0 -1
  205. package/dist/ops/merge-base.d.ts +0 -397
  206. package/dist/ops/merge-base.d.ts.map +0 -1
  207. package/dist/ops/merge-base.js +0 -691
  208. package/dist/ops/merge-base.js.map +0 -1
  209. package/dist/ops/merge.d.ts +0 -855
  210. package/dist/ops/merge.d.ts.map +0 -1
  211. package/dist/ops/merge.js +0 -1551
  212. package/dist/ops/merge.js.map +0 -1
  213. package/dist/ops/tag.d.ts +0 -247
  214. package/dist/ops/tag.d.ts.map +0 -1
  215. package/dist/ops/tag.js +0 -649
  216. package/dist/ops/tag.js.map +0 -1
  217. package/dist/ops/tree-builder.d.ts +0 -178
  218. package/dist/ops/tree-builder.d.ts.map +0 -1
  219. package/dist/ops/tree-builder.js +0 -271
  220. package/dist/ops/tree-builder.js.map +0 -1
  221. package/dist/ops/tree-diff.d.ts +0 -291
  222. package/dist/ops/tree-diff.d.ts.map +0 -1
  223. package/dist/ops/tree-diff.js +0 -705
  224. package/dist/ops/tree-diff.js.map +0 -1
  225. package/dist/pack/delta.d.ts +0 -248
  226. package/dist/pack/delta.d.ts.map +0 -1
  227. package/dist/pack/delta.js +0 -736
  228. package/dist/pack/delta.js.map +0 -1
  229. package/dist/pack/format.d.ts +0 -446
  230. package/dist/pack/format.d.ts.map +0 -1
  231. package/dist/pack/format.js +0 -572
  232. package/dist/pack/format.js.map +0 -1
  233. package/dist/pack/full-generation.d.ts +0 -612
  234. package/dist/pack/full-generation.d.ts.map +0 -1
  235. package/dist/pack/full-generation.js +0 -1378
  236. package/dist/pack/full-generation.js.map +0 -1
  237. package/dist/pack/generation.d.ts +0 -441
  238. package/dist/pack/generation.d.ts.map +0 -1
  239. package/dist/pack/generation.js +0 -707
  240. package/dist/pack/generation.js.map +0 -1
  241. package/dist/pack/index.d.ts +0 -502
  242. package/dist/pack/index.d.ts.map +0 -1
  243. package/dist/pack/index.js +0 -833
  244. package/dist/pack/index.js.map +0 -1
  245. package/dist/refs/branch.d.ts +0 -668
  246. package/dist/refs/branch.d.ts.map +0 -1
  247. package/dist/refs/branch.js +0 -897
  248. package/dist/refs/branch.js.map +0 -1
  249. package/dist/refs/storage.d.ts +0 -833
  250. package/dist/refs/storage.d.ts.map +0 -1
  251. package/dist/refs/storage.js +0 -1023
  252. package/dist/refs/storage.js.map +0 -1
  253. package/dist/refs/tag.d.ts +0 -860
  254. package/dist/refs/tag.d.ts.map +0 -1
  255. package/dist/refs/tag.js +0 -996
  256. package/dist/refs/tag.js.map +0 -1
  257. package/dist/storage/backend.d.ts +0 -425
  258. package/dist/storage/backend.d.ts.map +0 -1
  259. package/dist/storage/backend.js +0 -41
  260. package/dist/storage/backend.js.map +0 -1
  261. package/dist/storage/fsx-adapter.d.ts +0 -204
  262. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  263. package/dist/storage/fsx-adapter.js +0 -470
  264. package/dist/storage/fsx-adapter.js.map +0 -1
  265. package/dist/storage/lru-cache.d.ts +0 -691
  266. package/dist/storage/lru-cache.d.ts.map +0 -1
  267. package/dist/storage/lru-cache.js +0 -813
  268. package/dist/storage/lru-cache.js.map +0 -1
  269. package/dist/storage/object-index.d.ts +0 -585
  270. package/dist/storage/object-index.d.ts.map +0 -1
  271. package/dist/storage/object-index.js +0 -532
  272. package/dist/storage/object-index.js.map +0 -1
  273. package/dist/storage/r2-pack.d.ts +0 -1257
  274. package/dist/storage/r2-pack.d.ts.map +0 -1
  275. package/dist/storage/r2-pack.js +0 -1770
  276. package/dist/storage/r2-pack.js.map +0 -1
  277. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  278. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  279. package/dist/tiered/cdc-pipeline.js +0 -1880
  280. package/dist/tiered/cdc-pipeline.js.map +0 -1
  281. package/dist/tiered/migration.d.ts +0 -1104
  282. package/dist/tiered/migration.d.ts.map +0 -1
  283. package/dist/tiered/migration.js +0 -1214
  284. package/dist/tiered/migration.js.map +0 -1
  285. package/dist/tiered/parquet-writer.d.ts +0 -1145
  286. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  287. package/dist/tiered/parquet-writer.js +0 -1183
  288. package/dist/tiered/parquet-writer.js.map +0 -1
  289. package/dist/tiered/read-path.d.ts +0 -835
  290. package/dist/tiered/read-path.d.ts.map +0 -1
  291. package/dist/tiered/read-path.js +0 -487
  292. package/dist/tiered/read-path.js.map +0 -1
  293. package/dist/types/capability.d.ts +0 -1385
  294. package/dist/types/capability.d.ts.map +0 -1
  295. package/dist/types/capability.js +0 -36
  296. package/dist/types/capability.js.map +0 -1
  297. package/dist/types/index.d.ts +0 -13
  298. package/dist/types/index.d.ts.map +0 -1
  299. package/dist/types/index.js +0 -18
  300. package/dist/types/index.js.map +0 -1
  301. package/dist/types/objects.d.ts +0 -692
  302. package/dist/types/objects.d.ts.map +0 -1
  303. package/dist/types/objects.js +0 -837
  304. package/dist/types/objects.js.map +0 -1
  305. package/dist/types/storage.d.ts +0 -603
  306. package/dist/types/storage.d.ts.map +0 -1
  307. package/dist/types/storage.js +0 -191
  308. package/dist/types/storage.js.map +0 -1
  309. package/dist/types/worker-loader.d.ts +0 -60
  310. package/dist/types/worker-loader.d.ts.map +0 -1
  311. package/dist/types/worker-loader.js +0 -62
  312. package/dist/types/worker-loader.js.map +0 -1
  313. package/dist/utils/hash.d.ts +0 -197
  314. package/dist/utils/hash.d.ts.map +0 -1
  315. package/dist/utils/hash.js +0 -268
  316. package/dist/utils/hash.js.map +0 -1
  317. package/dist/utils/sha1.d.ts +0 -290
  318. package/dist/utils/sha1.d.ts.map +0 -1
  319. package/dist/utils/sha1.js +0 -582
  320. package/dist/utils/sha1.js.map +0 -1
  321. package/dist/wire/capabilities.d.ts +0 -1044
  322. package/dist/wire/capabilities.d.ts.map +0 -1
  323. package/dist/wire/capabilities.js +0 -941
  324. package/dist/wire/capabilities.js.map +0 -1
  325. package/dist/wire/path-security.d.ts +0 -157
  326. package/dist/wire/path-security.d.ts.map +0 -1
  327. package/dist/wire/path-security.js +0 -307
  328. package/dist/wire/path-security.js.map +0 -1
  329. package/dist/wire/pkt-line.d.ts +0 -345
  330. package/dist/wire/pkt-line.d.ts.map +0 -1
  331. package/dist/wire/pkt-line.js +0 -381
  332. package/dist/wire/pkt-line.js.map +0 -1
  333. package/dist/wire/receive-pack.d.ts +0 -1059
  334. package/dist/wire/receive-pack.d.ts.map +0 -1
  335. package/dist/wire/receive-pack.js +0 -1414
  336. package/dist/wire/receive-pack.js.map +0 -1
  337. package/dist/wire/smart-http.d.ts +0 -799
  338. package/dist/wire/smart-http.d.ts.map +0 -1
  339. package/dist/wire/smart-http.js +0 -945
  340. package/dist/wire/smart-http.js.map +0 -1
  341. package/dist/wire/upload-pack.d.ts +0 -727
  342. package/dist/wire/upload-pack.d.ts.map +0 -1
  343. package/dist/wire/upload-pack.js +0 -1138
  344. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,548 +0,0 @@
1
- /**
2
- * @fileoverview MCP (Model Context Protocol) Git Tool Definitions
3
- *
4
- * This module provides tool definitions for git operations that can be
5
- * exposed via the Model Context Protocol for AI assistants. It defines
6
- * a comprehensive set of git tools including status, log, diff, commit,
7
- * branch, checkout, push, pull, clone, init, add, reset, merge, rebase,
8
- * stash, tag, remote, and fetch operations.
9
- *
10
- * The module uses a registry pattern for tool management, allowing dynamic
11
- * registration, validation, and invocation of tools. Each tool follows the
12
- * MCP specification with JSON Schema input validation and standardized
13
- * result formatting.
14
- *
15
- * @module mcp/tools
16
- *
17
- * @example
18
- * // Setting up repository context and invoking a tool
19
- * import { setRepositoryContext, invokeTool } from './tools'
20
- *
21
- * // Set up the repository context first
22
- * setRepositoryContext({
23
- * objectStore: myObjectStore,
24
- * refStore: myRefStore,
25
- * index: myIndex
26
- * })
27
- *
28
- * // Invoke a tool
29
- * const result = await invokeTool('git_status', { short: true })
30
- * console.log(result.content[0].text)
31
- *
32
- * @example
33
- * // Registering a custom tool
34
- * import { registerTool } from './tools'
35
- *
36
- * registerTool({
37
- * name: 'my_custom_tool',
38
- * description: 'A custom tool',
39
- * inputSchema: { type: 'object', properties: {} },
40
- * handler: async (params) => ({
41
- * content: [{ type: 'text', text: 'Hello!' }]
42
- * })
43
- * })
44
- */
45
- import { RefStore } from '../ops/branch';
46
- import type { CommitObject, TreeObject } from '../types/objects';
47
- /**
48
- * Repository context for MCP tool operations.
49
- *
50
- * @description
51
- * This interface provides access to the git repository's storage layers,
52
- * enabling MCP tools to read and write git objects, manage references,
53
- * and interact with the index and working directory.
54
- *
55
- * The context must be set globally using {@link setRepositoryContext} before
56
- * invoking any tools that require repository access.
57
- *
58
- * @interface RepositoryContext
59
- *
60
- * @example
61
- * const context: RepositoryContext = {
62
- * objectStore: {
63
- * getObject: async (sha) => { ... },
64
- * getCommit: async (sha) => { ... },
65
- * getTree: async (sha) => { ... },
66
- * getBlob: async (sha) => { ... },
67
- * storeObject: async (type, data) => { ... },
68
- * hasObject: async (sha) => { ... }
69
- * },
70
- * refStore: myRefStore,
71
- * index: { getEntries: async () => [...] }
72
- * }
73
- * setRepositoryContext(context)
74
- */
75
- export interface RepositoryContext {
76
- /**
77
- * Object store for reading and writing git objects.
78
- * @description Provides methods to access commits, trees, blobs, and raw objects.
79
- */
80
- objectStore: {
81
- /**
82
- * Get a raw git object by SHA.
83
- * @param sha - The 40-character hexadecimal SHA-1 hash
84
- * @returns The object with its type and data, or null if not found
85
- */
86
- getObject(sha: string): Promise<{
87
- type: string;
88
- data: Uint8Array;
89
- } | null>;
90
- /**
91
- * Get a parsed commit object by SHA.
92
- * @param sha - The commit SHA
93
- * @returns The parsed commit object, or null if not found
94
- */
95
- getCommit(sha: string): Promise<CommitObject | null>;
96
- /**
97
- * Get a parsed tree object by SHA.
98
- * @param sha - The tree SHA
99
- * @returns The parsed tree object, or null if not found
100
- */
101
- getTree(sha: string): Promise<TreeObject | null>;
102
- /**
103
- * Get blob content by SHA.
104
- * @param sha - The blob SHA
105
- * @returns The blob data, or null if not found
106
- */
107
- getBlob(sha: string): Promise<Uint8Array | null>;
108
- /**
109
- * Store a new git object.
110
- * @param type - The object type ('commit', 'tree', 'blob', 'tag')
111
- * @param data - The raw object data
112
- * @returns The SHA of the stored object
113
- */
114
- storeObject(type: string, data: Uint8Array): Promise<string>;
115
- /**
116
- * Check if an object exists.
117
- * @param sha - The object SHA to check
118
- * @returns True if the object exists
119
- */
120
- hasObject(sha: string): Promise<boolean>;
121
- };
122
- /**
123
- * Ref store for branch/tag operations.
124
- * @description Manages git references including HEAD, branches, and tags.
125
- */
126
- refStore: RefStore;
127
- /**
128
- * Index/staging area for status/diff operations.
129
- * @description Optional - required for git_status and staged diff operations.
130
- */
131
- index?: {
132
- /**
133
- * Get all entries in the index.
134
- * @returns Array of index entries with path, mode, SHA, and stage number
135
- */
136
- getEntries(): Promise<Array<{
137
- path: string;
138
- mode: string;
139
- sha: string;
140
- stage: number;
141
- }>>;
142
- };
143
- /**
144
- * Working directory interface for status operations.
145
- * @description Optional - required for working tree comparisons.
146
- */
147
- workdir?: {
148
- /**
149
- * Get all files in the working directory.
150
- * @returns Array of file entries with path, mode, and SHA
151
- */
152
- getFiles(): Promise<Array<{
153
- path: string;
154
- mode: string;
155
- sha: string;
156
- }>>;
157
- };
158
- }
159
- /**
160
- * Set the global repository context for MCP tools.
161
- *
162
- * @description
163
- * This function sets the global repository context that will be used by all
164
- * MCP git tools. The context provides access to the object store, ref store,
165
- * index, and working directory. This must be called before invoking any tools
166
- * that require repository access.
167
- *
168
- * @param ctx - The repository context to set, or null to clear it
169
- * @returns void
170
- *
171
- * @example
172
- * // Set up context before using tools
173
- * setRepositoryContext({
174
- * objectStore: myObjectStore,
175
- * refStore: myRefStore
176
- * })
177
- *
178
- * // Clear context when done
179
- * setRepositoryContext(null)
180
- */
181
- export declare function setRepositoryContext(ctx: RepositoryContext | null): void;
182
- /**
183
- * Get the global repository context.
184
- *
185
- * @description
186
- * Returns the currently set repository context, or null if no context has
187
- * been set. Tools use this internally to access repository data.
188
- *
189
- * @returns The current repository context, or null if not set
190
- *
191
- * @example
192
- * const ctx = getRepositoryContext()
193
- * if (ctx) {
194
- * const commit = await ctx.objectStore.getCommit(sha)
195
- * }
196
- */
197
- export declare function getRepositoryContext(): RepositoryContext | null;
198
- /**
199
- * JSON Schema definition for tool input parameters.
200
- *
201
- * @description
202
- * Defines the structure of JSON Schema objects used to describe and validate
203
- * tool input parameters. Supports standard JSON Schema features including
204
- * type validation, required fields, enums, numeric constraints, and patterns.
205
- *
206
- * @interface JSONSchema
207
- *
208
- * @example
209
- * const schema: JSONSchema = {
210
- * type: 'object',
211
- * properties: {
212
- * path: { type: 'string', description: 'File path' },
213
- * maxCount: { type: 'number', minimum: 1 }
214
- * },
215
- * required: ['path']
216
- * }
217
- */
218
- export interface JSONSchema {
219
- /** The JSON Schema type ('object', 'string', 'number', 'boolean', 'array') */
220
- type: string;
221
- /** Property definitions for object types */
222
- properties?: Record<string, JSONSchema>;
223
- /** List of required property names */
224
- required?: string[];
225
- /** Human-readable description of the schema */
226
- description?: string;
227
- /** Schema for array items */
228
- items?: JSONSchema;
229
- /** Allowed values for enum types */
230
- enum?: string[];
231
- /** Default value if not provided */
232
- default?: unknown;
233
- /** Minimum value for numeric types */
234
- minimum?: number;
235
- /** Maximum value for numeric types */
236
- maximum?: number;
237
- /** Regex pattern for string validation */
238
- pattern?: string;
239
- }
240
- /**
241
- * Represents the result of invoking an MCP tool.
242
- *
243
- * @description
244
- * The standard result format returned by all MCP tools. Contains an array
245
- * of content blocks that can include text, images, or resource references.
246
- * The isError flag indicates whether the result represents an error condition.
247
- *
248
- * @interface MCPToolResult
249
- *
250
- * @example
251
- * // Successful text result
252
- * const result: MCPToolResult = {
253
- * content: [{ type: 'text', text: 'On branch main\nnothing to commit' }]
254
- * }
255
- *
256
- * // Error result
257
- * const errorResult: MCPToolResult = {
258
- * content: [{ type: 'text', text: 'Repository not found' }],
259
- * isError: true
260
- * }
261
- */
262
- export interface MCPToolResult {
263
- /**
264
- * Array of content blocks in the result.
265
- * Each block has a type and corresponding data.
266
- */
267
- content: Array<{
268
- /** Content type: 'text', 'image', or 'resource' */
269
- type: 'text' | 'image' | 'resource';
270
- /** Text content (for type: 'text') */
271
- text?: string;
272
- /** Base64-encoded data (for type: 'image') */
273
- data?: string;
274
- /** MIME type for binary content */
275
- mimeType?: string;
276
- }>;
277
- /** If true, the result represents an error condition */
278
- isError?: boolean;
279
- }
280
- /**
281
- * Handler function type for MCP tools.
282
- *
283
- * @description
284
- * Type definition for tool handler functions. Handlers receive parameters
285
- * as a record of unknown values and must return a Promise resolving to
286
- * an MCPToolResult.
287
- *
288
- * @param params - The input parameters passed to the tool
289
- * @returns Promise resolving to the tool result
290
- *
291
- * @example
292
- * const handler: MCPToolHandler = async (params) => {
293
- * const { path } = params as { path?: string }
294
- * return {
295
- * content: [{ type: 'text', text: `Processed: ${path}` }]
296
- * }
297
- * }
298
- */
299
- export type MCPToolHandler = (params: Record<string, unknown>) => Promise<MCPToolResult>;
300
- /**
301
- * Defines an MCP tool with its schema and handler.
302
- *
303
- * @description
304
- * Complete tool definition including name, description, input schema
305
- * for parameter validation, and the async handler function that
306
- * implements the tool's functionality.
307
- *
308
- * @interface MCPTool
309
- *
310
- * @example
311
- * const myTool: MCPTool = {
312
- * name: 'my_tool',
313
- * description: 'Does something useful',
314
- * inputSchema: {
315
- * type: 'object',
316
- * properties: {
317
- * input: { type: 'string', description: 'The input value' }
318
- * },
319
- * required: ['input']
320
- * },
321
- * handler: async (params) => {
322
- * const { input } = params as { input: string }
323
- * return { content: [{ type: 'text', text: `Result: ${input}` }] }
324
- * }
325
- * }
326
- */
327
- export interface MCPTool {
328
- /** Unique name identifying the tool (e.g., 'git_status') */
329
- name: string;
330
- /** Human-readable description of what the tool does */
331
- description: string;
332
- /** JSON Schema defining the tool's input parameters */
333
- inputSchema: JSONSchema;
334
- /** Async function that implements the tool's functionality */
335
- handler: MCPToolHandler;
336
- }
337
- /**
338
- * Registry of available git tools.
339
- *
340
- * @description
341
- * Array containing all built-in git tool definitions. These tools are
342
- * automatically registered in the tool registry on module load. Each
343
- * tool implements a specific git operation following the MCP specification.
344
- *
345
- * Available tools:
346
- * - git_status: Show repository status
347
- * - git_log: Show commit history
348
- * - git_diff: Show differences between commits
349
- * - git_commit: Create a new commit
350
- * - git_branch: List, create, or delete branches
351
- * - git_checkout: Switch branches or restore files
352
- * - git_push: Upload commits to remote
353
- * - git_pull: Fetch and integrate from remote
354
- * - git_clone: Clone a repository
355
- * - git_init: Initialize a new repository
356
- * - git_add: Stage files for commit
357
- * - git_reset: Reset HEAD to a state
358
- * - git_merge: Merge branches
359
- * - git_rebase: Rebase commits
360
- * - git_stash: Stash changes
361
- * - git_tag: Manage tags
362
- * - git_remote: Manage remotes
363
- * - git_fetch: Fetch from remotes
364
- *
365
- * @example
366
- * // Access git tools array
367
- * import { gitTools } from './tools'
368
- *
369
- * for (const tool of gitTools) {
370
- * console.log(`Tool: ${tool.name} - ${tool.description}`)
371
- * }
372
- */
373
- export declare const gitTools: MCPTool[];
374
- /**
375
- * Register a new tool in the registry.
376
- *
377
- * @description
378
- * Adds a custom tool to the global tool registry. The tool must have a valid
379
- * handler function and a unique name. Once registered, the tool can be invoked
380
- * using {@link invokeTool}.
381
- *
382
- * Note: Built-in git tools are automatically registered on module load.
383
- *
384
- * @param tool - The tool definition to register
385
- * @returns void
386
- * @throws {Error} If tool handler is missing or not a function
387
- * @throws {Error} If a tool with the same name already exists
388
- *
389
- * @example
390
- * import { registerTool, invokeTool } from './tools'
391
- *
392
- * // Register a custom tool
393
- * registerTool({
394
- * name: 'custom_operation',
395
- * description: 'Performs a custom operation',
396
- * inputSchema: {
397
- * type: 'object',
398
- * properties: {
399
- * value: { type: 'string', description: 'Input value' }
400
- * },
401
- * required: ['value']
402
- * },
403
- * handler: async (params) => {
404
- * const { value } = params as { value: string }
405
- * return {
406
- * content: [{ type: 'text', text: `Processed: ${value}` }]
407
- * }
408
- * }
409
- * })
410
- *
411
- * // Now invoke the registered tool
412
- * const result = await invokeTool('custom_operation', { value: 'test' })
413
- */
414
- export declare function registerTool(tool: MCPTool): void;
415
- /**
416
- * Validate input parameters against a tool's schema.
417
- *
418
- * @description
419
- * Performs comprehensive validation of tool parameters against the tool's
420
- * JSON Schema definition. Checks for required parameters, type correctness,
421
- * enum values, numeric constraints, string patterns, and array item types.
422
- *
423
- * This function is called automatically by {@link invokeTool} before
424
- * executing a tool handler, but can also be used independently for
425
- * pre-validation.
426
- *
427
- * @param tool - The tool whose schema to validate against
428
- * @param params - The parameters to validate
429
- * @returns Validation result object with valid flag and array of error messages
430
- *
431
- * @example
432
- * import { validateToolInput, getTool } from './tools'
433
- *
434
- * const tool = getTool('git_commit')
435
- * if (tool) {
436
- * const validation = validateToolInput(tool, { path: '/repo' })
437
- * if (!validation.valid) {
438
- * console.error('Validation errors:', validation.errors)
439
- * // Output: ['Missing required parameter: message']
440
- * }
441
- * }
442
- *
443
- * @example
444
- * // Type validation example
445
- * const result = validateToolInput(tool, { maxCount: 'not-a-number' })
446
- * // result.errors: ["Parameter 'maxCount' has invalid type: expected number, got string"]
447
- */
448
- export declare function validateToolInput(tool: MCPTool, params: Record<string, unknown>): {
449
- valid: boolean;
450
- errors: string[];
451
- };
452
- /**
453
- * Invoke a tool by name with the given parameters.
454
- *
455
- * @description
456
- * Looks up a tool by name in the registry, validates the provided parameters
457
- * against the tool's schema, and executes the tool's handler. Validation
458
- * errors and execution errors are returned as MCPToolResult with isError=true
459
- * rather than throwing exceptions.
460
- *
461
- * This is the primary function for executing MCP tools. Ensure the repository
462
- * context is set via {@link setRepositoryContext} before invoking git tools.
463
- *
464
- * @param toolName - Name of the tool to invoke (e.g., 'git_status')
465
- * @param params - Parameters to pass to the tool handler
466
- * @returns Promise resolving to the tool result
467
- * @throws {Error} If the tool is not found in the registry
468
- *
469
- * @example
470
- * import { invokeTool, setRepositoryContext } from './tools'
471
- *
472
- * // Set up repository context first
473
- * setRepositoryContext(myRepoContext)
474
- *
475
- * // Invoke git_status tool
476
- * const status = await invokeTool('git_status', { short: true })
477
- * if (!status.isError) {
478
- * console.log(status.content[0].text)
479
- * }
480
- *
481
- * @example
482
- * // Invoke git_log with parameters
483
- * const log = await invokeTool('git_log', {
484
- * maxCount: 10,
485
- * oneline: true,
486
- * ref: 'main'
487
- * })
488
- *
489
- * @example
490
- * // Handle validation errors
491
- * const result = await invokeTool('git_commit', {})
492
- * if (result.isError) {
493
- * // result.content[0].text contains validation error message
494
- * console.error('Error:', result.content[0].text)
495
- * }
496
- */
497
- export declare function invokeTool(toolName: string, params: Record<string, unknown>): Promise<MCPToolResult>;
498
- /**
499
- * Get a list of all registered tools.
500
- *
501
- * @description
502
- * Returns an array of all tools in the registry with their names, descriptions,
503
- * and input schemas. Handler functions are omitted for security and serialization.
504
- * This is useful for discovery and documentation purposes.
505
- *
506
- * @returns Array of tool definitions without handler functions
507
- *
508
- * @example
509
- * import { listTools } from './tools'
510
- *
511
- * const tools = listTools()
512
- * console.log(`Available tools: ${tools.length}`)
513
- *
514
- * for (const tool of tools) {
515
- * console.log(`- ${tool.name}: ${tool.description}`)
516
- * console.log(` Required params: ${tool.inputSchema.required?.join(', ') || 'none'}`)
517
- * }
518
- */
519
- export declare function listTools(): Array<Omit<MCPTool, 'handler'>>;
520
- /**
521
- * Get a tool by name.
522
- *
523
- * @description
524
- * Retrieves a tool definition from the registry by its name. Returns the
525
- * complete tool object including the handler function. Returns undefined
526
- * if no tool with the given name exists.
527
- *
528
- * @param name - Name of the tool to retrieve (e.g., 'git_status')
529
- * @returns The complete tool definition if found, undefined otherwise
530
- *
531
- * @example
532
- * import { getTool } from './tools'
533
- *
534
- * const statusTool = getTool('git_status')
535
- * if (statusTool) {
536
- * console.log(`Description: ${statusTool.description}`)
537
- * console.log(`Parameters:`, Object.keys(statusTool.inputSchema.properties || {}))
538
- * }
539
- *
540
- * @example
541
- * // Check if a tool exists before using it
542
- * const tool = getTool('my_custom_tool')
543
- * if (!tool) {
544
- * console.error('Tool not found')
545
- * }
546
- */
547
- export declare function getTool(name: string): MCPTool | undefined;
548
- //# sourceMappingURL=tools.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAaH,OAAO,EAKL,QAAQ,EACT,MAAM,eAAe,CAAA;AAEtB,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAEhE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,WAAW,EAAE;QACX;;;;WAIG;QACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,UAAU,CAAA;SAAE,GAAG,IAAI,CAAC,CAAA;QAC1E;;;;WAIG;QACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAA;QACpD;;;;WAIG;QACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,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