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,772 +0,0 @@
1
- /**
2
- * @fileoverview MCP (Model Context Protocol) SDK Adapter
3
- *
4
- * This module provides an adapter that bridges the MCP protocol to git operations,
5
- * handling request/response, tool registration/invocation, resource listing,
6
- * and error handling. It implements the JSON-RPC 2.0 specification for MCP
7
- * communication.
8
- *
9
- * The adapter supports:
10
- * - Tool registration and invocation with schema validation
11
- * - Resource registration and reading
12
- * - Prompt registration and retrieval
13
- * - Standard and custom MCP error codes
14
- * - Batch request processing
15
- * - Capability negotiation
16
- *
17
- * @module mcp/adapter
18
- *
19
- * @example
20
- * // Create and configure an MCP adapter
21
- * import { createMCPAdapter, MCPAdapter } from './adapter'
22
- *
23
- * const adapter = createMCPAdapter({
24
- * name: 'my-git-server',
25
- * version: '1.0.0',
26
- * capabilities: ['tools', 'resources']
27
- * })
28
- *
29
- * // Register git tools and start
30
- * adapter.registerGitTools()
31
- * await adapter.start()
32
- *
33
- * // Handle incoming requests
34
- * const response = await adapter.handleRequest({
35
- * jsonrpc: '2.0',
36
- * id: 1,
37
- * method: 'tools/list',
38
- * params: {}
39
- * })
40
- *
41
- * @example
42
- * // Handle raw JSON requests
43
- * const rawResponse = await adapter.handleRawRequest(
44
- * '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'
45
- * )
46
- */
47
- import { type MCPToolResult } from './tools';
48
- /**
49
- * JSON-RPC 2.0 error codes and MCP-specific error codes.
50
- *
51
- * @description
52
- * Enumeration of error codes used in MCP responses. Includes standard
53
- * JSON-RPC 2.0 error codes (negative 32xxx range) and MCP-specific
54
- * error codes for resource, tool, and prompt operations.
55
- *
56
- * @enum {number}
57
- *
58
- * @example
59
- * // Using error codes in responses
60
- * if (!tool) {
61
- * return {
62
- * jsonrpc: '2.0',
63
- * id: requestId,
64
- * error: {
65
- * code: MCPErrorCode.TOOL_NOT_FOUND,
66
- * message: 'Tool not found'
67
- * }
68
- * }
69
- * }
70
- */
71
- export declare enum MCPErrorCode {
72
- /** Parse error - Invalid JSON was received (-32700) */
73
- PARSE_ERROR = -32700,
74
- /** Invalid Request - The JSON sent is not a valid Request object (-32600) */
75
- INVALID_REQUEST = -32600,
76
- /** Method not found - The method does not exist or is not available (-32601) */
77
- METHOD_NOT_FOUND = -32601,
78
- /** Invalid params - Invalid method parameter(s) (-32602) */
79
- INVALID_PARAMS = -32602,
80
- /** Internal error - Internal JSON-RPC error (-32603) */
81
- INTERNAL_ERROR = -32603,
82
- /** Resource not found - The requested resource does not exist (-32001) */
83
- RESOURCE_NOT_FOUND = -32001,
84
- /** Tool not found - Maps to METHOD_NOT_FOUND as tools are methods (-32601) */
85
- TOOL_NOT_FOUND = -32601,
86
- /** Prompt not found - The requested prompt does not exist (-32003) */
87
- PROMPT_NOT_FOUND = -32003,
88
- /** Capability not supported - The requested capability is not enabled (-32004) */
89
- CAPABILITY_NOT_SUPPORTED = -32004
90
- }
91
- /**
92
- * Custom error class for MCP errors.
93
- *
94
- * @description
95
- * Error class that encapsulates MCP error information including a numeric
96
- * error code, human-readable message, and optional additional data. Can be
97
- * serialized to JSON-RPC error format using the toJSON() method.
98
- *
99
- * @class MCPError
100
- * @extends Error
101
- *
102
- * @example
103
- * // Throw an MCP error
104
- * throw new MCPError(
105
- * MCPErrorCode.TOOL_NOT_FOUND,
106
- * 'Tool "unknown_tool" not found',
107
- * { toolName: 'unknown_tool' }
108
- * )
109
- *
110
- * @example
111
- * // Convert to JSON-RPC error format
112
- * const error = new MCPError(MCPErrorCode.INVALID_PARAMS, 'Missing required field')
113
- * const jsonError = error.toJSON()
114
- * // { code: -32602, message: 'Missing required field' }
115
- */
116
- export declare class MCPError extends Error {
117
- /** The MCP error code */
118
- code: MCPErrorCode;
119
- /** Optional additional error data */
120
- data?: unknown;
121
- /**
122
- * Create a new MCP error.
123
- *
124
- * @param code - The MCP error code
125
- * @param message - Human-readable error message
126
- * @param data - Optional additional error data
127
- */
128
- constructor(code: MCPErrorCode, message: string, data?: unknown);
129
- /**
130
- * Convert the error to JSON-RPC error format.
131
- *
132
- * @returns Object suitable for JSON-RPC error responses
133
- */
134
- toJSON(): {
135
- code: MCPErrorCode;
136
- message: string;
137
- data?: unknown;
138
- };
139
- }
140
- /**
141
- * MCP capability types.
142
- *
143
- * @description
144
- * Type representing the different capabilities an MCP server can support.
145
- * Capabilities are negotiated during initialization.
146
- *
147
- * @typedef {'tools' | 'resources' | 'prompts'} MCPCapability
148
- */
149
- export type MCPCapability = 'tools' | 'resources' | 'prompts';
150
- /**
151
- * Server configuration for MCP adapter.
152
- *
153
- * @description
154
- * Configuration options for initializing an MCP adapter instance.
155
- * All fields are optional with sensible defaults.
156
- *
157
- * @interface MCPServerConfig
158
- *
159
- * @example
160
- * const config: MCPServerConfig = {
161
- * name: 'my-git-server',
162
- * version: '1.0.0',
163
- * capabilities: ['tools', 'resources']
164
- * }
165
- */
166
- export interface MCPServerConfig {
167
- /** Server name (default: 'gitx.do') */
168
- name?: string;
169
- /** Server version (default: '1.0.0') */
170
- version?: string;
171
- /** Enabled capabilities (default: ['tools']) */
172
- capabilities?: MCPCapability[];
173
- }
174
- /**
175
- * MCP request structure (JSON-RPC 2.0).
176
- *
177
- * @description
178
- * Represents an incoming MCP request following the JSON-RPC 2.0 specification.
179
- * Requests without an id are treated as notifications.
180
- *
181
- * @interface MCPRequest
182
- *
183
- * @example
184
- * const request: MCPRequest = {
185
- * jsonrpc: '2.0',
186
- * id: 1,
187
- * method: 'tools/call',
188
- * params: { name: 'git_status', arguments: {} }
189
- * }
190
- */
191
- export interface MCPRequest {
192
- /** JSON-RPC version (must be '2.0') */
193
- jsonrpc: '2.0';
194
- /** Request identifier (omit for notifications) */
195
- id?: string | number;
196
- /** The method to invoke */
197
- method: string;
198
- /** Method parameters */
199
- params?: Record<string, unknown>;
200
- }
201
- /**
202
- * MCP response structure (JSON-RPC 2.0).
203
- *
204
- * @description
205
- * Represents an outgoing MCP response. Contains either a result or an error,
206
- * never both. Responses include the id from the corresponding request.
207
- *
208
- * @interface MCPResponse
209
- *
210
- * @example
211
- * // Success response
212
- * const success: MCPResponse = {
213
- * jsonrpc: '2.0',
214
- * id: 1,
215
- * result: { tools: [...] }
216
- * }
217
- *
218
- * // Error response
219
- * const error: MCPResponse = {
220
- * jsonrpc: '2.0',
221
- * id: 1,
222
- * error: { code: -32601, message: 'Method not found' }
223
- * }
224
- */
225
- export interface MCPResponse {
226
- /** JSON-RPC version (always '2.0') */
227
- jsonrpc: '2.0';
228
- /** Request identifier from the corresponding request */
229
- id?: string | number;
230
- /** Result data (mutually exclusive with error) */
231
- result?: unknown;
232
- /** Error information (mutually exclusive with result) */
233
- error?: {
234
- /** Numeric error code */
235
- code: number;
236
- /** Human-readable error message */
237
- message: string;
238
- /** Additional error data */
239
- data?: unknown;
240
- };
241
- }
242
- /**
243
- * Tool information for registration.
244
- *
245
- * @description
246
- * Complete tool definition including metadata, input schema, and handler
247
- * function. Used when registering tools with the adapter.
248
- *
249
- * @interface MCPToolInfo
250
- *
251
- * @example
252
- * const toolInfo: MCPToolInfo = {
253
- * name: 'my_tool',
254
- * description: 'Does something useful',
255
- * inputSchema: {
256
- * type: 'object',
257
- * properties: { input: { type: 'string' } },
258
- * required: ['input']
259
- * },
260
- * handler: async (params) => ({
261
- * content: [{ type: 'text', text: 'Result' }]
262
- * })
263
- * }
264
- */
265
- export interface MCPToolInfo {
266
- /** Unique tool name */
267
- name: string;
268
- /** Human-readable description */
269
- description: string;
270
- /** JSON Schema for input parameters */
271
- inputSchema: {
272
- type: string;
273
- properties?: Record<string, unknown>;
274
- required?: string[];
275
- };
276
- /** Async function that executes the tool */
277
- handler: (params: Record<string, unknown>) => Promise<MCPToolResult>;
278
- }
279
- /**
280
- * Resource information for registration.
281
- *
282
- * @description
283
- * Defines a resource that can be read via the resources/read method.
284
- * Resources have a URI, name, and optional handler for dynamic content.
285
- *
286
- * @interface MCPResourceInfo
287
- *
288
- * @example
289
- * const resource: MCPResourceInfo = {
290
- * uri: 'git://repo/HEAD',
291
- * name: 'Current HEAD',
292
- * mimeType: 'text/plain',
293
- * description: 'The current HEAD commit',
294
- * handler: async () => ({ content: 'abc123...' })
295
- * }
296
- */
297
- export interface MCPResourceInfo {
298
- /** Unique resource URI */
299
- uri: string;
300
- /** Human-readable name */
301
- name: string;
302
- /** MIME type of the resource content */
303
- mimeType?: string;
304
- /** Human-readable description */
305
- description?: string;
306
- /** Async function to retrieve resource content */
307
- handler?: () => Promise<{
308
- content: string;
309
- }>;
310
- }
311
- /**
312
- * Prompt argument definition.
313
- *
314
- * @description
315
- * Defines an argument that can be passed to a prompt template.
316
- *
317
- * @interface MCPPromptArgument
318
- */
319
- export interface MCPPromptArgument {
320
- /** Argument name */
321
- name: string;
322
- /** Human-readable description */
323
- description?: string;
324
- /** Whether this argument is required */
325
- required?: boolean;
326
- }
327
- /**
328
- * Prompt information for registration.
329
- *
330
- * @description
331
- * Defines a prompt template that can be retrieved via prompts/get.
332
- * Prompts can have arguments and a handler to generate messages.
333
- *
334
- * @interface MCPPromptInfo
335
- *
336
- * @example
337
- * const prompt: MCPPromptInfo = {
338
- * name: 'commit-message',
339
- * description: 'Generate a commit message',
340
- * arguments: [
341
- * { name: 'changes', description: 'Description of changes', required: true }
342
- * ],
343
- * handler: async (args) => ({
344
- * messages: [{
345
- * role: 'user',
346
- * content: { type: 'text', text: `Write commit message for: ${args.changes}` }
347
- * }]
348
- * })
349
- * }
350
- */
351
- export interface MCPPromptInfo {
352
- /** Unique prompt name */
353
- name: string;
354
- /** Human-readable description */
355
- description?: string;
356
- /** Prompt arguments */
357
- arguments?: MCPPromptArgument[];
358
- /** Async function to generate prompt messages */
359
- handler?: (args: Record<string, unknown>) => Promise<{
360
- messages: Array<{
361
- role: string;
362
- content: {
363
- type: string;
364
- text: string;
365
- };
366
- }>;
367
- }>;
368
- }
369
- /**
370
- * MCP Adapter class that bridges MCP protocol to git operations.
371
- *
372
- * @description
373
- * The main adapter class that handles MCP protocol communication. It manages
374
- * tool, resource, and prompt registrations, processes JSON-RPC requests,
375
- * and returns properly formatted responses.
376
- *
377
- * The adapter supports the following MCP methods:
378
- * - initialize: Server initialization and capability negotiation
379
- * - tools/list: List all registered tools
380
- * - tools/call: Invoke a registered tool
381
- * - resources/list: List all registered resources
382
- * - resources/read: Read a resource's content
383
- * - prompts/list: List all registered prompts
384
- * - prompts/get: Get a prompt's generated messages
385
- *
386
- * @class MCPAdapter
387
- *
388
- * @example
389
- * // Create and use an adapter
390
- * const adapter = new MCPAdapter({
391
- * name: 'my-server',
392
- * version: '1.0.0',
393
- * capabilities: ['tools']
394
- * })
395
- *
396
- * adapter.registerGitTools()
397
- * await adapter.start()
398
- *
399
- * const response = await adapter.handleRequest({
400
- * jsonrpc: '2.0',
401
- * id: 1,
402
- * method: 'tools/list'
403
- * })
404
- */
405
- export declare class MCPAdapter {
406
- /** @internal */
407
- private config;
408
- /** @internal */
409
- private initialized;
410
- /** @internal */
411
- private tools;
412
- /** @internal */
413
- private resources;
414
- /** @internal */
415
- private prompts;
416
- /**
417
- * Create a new MCP adapter instance.
418
- *
419
- * @param config - Optional configuration options
420
- *
421
- * @example
422
- * const adapter = new MCPAdapter({
423
- * name: 'git-mcp-server',
424
- * version: '2.0.0',
425
- * capabilities: ['tools', 'resources', 'prompts']
426
- * })
427
- */
428
- constructor(config?: MCPServerConfig);
429
- /**
430
- * Get the server configuration.
431
- *
432
- * @description
433
- * Returns a copy of the current server configuration including name,
434
- * version, and enabled capabilities.
435
- *
436
- * @returns A copy of the server configuration
437
- *
438
- * @example
439
- * const config = adapter.getConfig()
440
- * console.log(`Server: ${config.name} v${config.version}`)
441
- */
442
- getConfig(): MCPServerConfig;
443
- /**
444
- * Check if adapter has a specific capability.
445
- *
446
- * @description
447
- * Tests whether a specific capability is enabled for this adapter.
448
- * Used internally to determine which methods are available.
449
- *
450
- * @param capability - The capability to check ('tools', 'resources', or 'prompts')
451
- * @returns True if the capability is enabled
452
- *
453
- * @example
454
- * if (adapter.hasCapability('resources')) {
455
- * adapter.registerResource(myResource)
456
- * }
457
- */
458
- hasCapability(capability: MCPCapability): boolean;
459
- /**
460
- * Check if the adapter is initialized.
461
- *
462
- * @description
463
- * Returns whether the adapter has been started and is ready to handle requests.
464
- *
465
- * @returns True if the adapter is initialized and running
466
- */
467
- isInitialized(): boolean;
468
- /**
469
- * Start the MCP adapter.
470
- *
471
- * @description
472
- * Initializes the adapter and prepares it to handle requests.
473
- * Must be called before processing any MCP requests.
474
- *
475
- * @returns Promise that resolves when the adapter is started
476
- * @throws {Error} If the adapter is already started
477
- *
478
- * @example
479
- * const adapter = new MCPAdapter()
480
- * await adapter.start()
481
- * // Adapter is now ready to handle requests
482
- */
483
- start(): Promise<void>;
484
- /**
485
- * Stop the MCP adapter.
486
- *
487
- * @description
488
- * Shuts down the adapter and clears all registered tools, resources,
489
- * and prompts. After stopping, the adapter must be restarted before
490
- * handling new requests.
491
- *
492
- * @returns Promise that resolves when the adapter is stopped
493
- * @throws {Error} If the adapter is not currently running
494
- *
495
- * @example
496
- * await adapter.stop()
497
- * // All registrations are cleared
498
- */
499
- stop(): Promise<void>;
500
- /**
501
- * Register a tool.
502
- *
503
- * @description
504
- * Adds a tool to the adapter's registry. The tool will be available
505
- * for listing via tools/list and invocation via tools/call.
506
- *
507
- * @param toolInfo - The tool definition to register
508
- * @returns void
509
- * @throws {Error} If a tool with the same name is already registered
510
- *
511
- * @example
512
- * adapter.registerTool({
513
- * name: 'my_tool',
514
- * description: 'Does something',
515
- * inputSchema: { type: 'object', properties: {} },
516
- * handler: async (params) => ({
517
- * content: [{ type: 'text', text: 'Done' }]
518
- * })
519
- * })
520
- */
521
- registerTool(toolInfo: MCPToolInfo): void;
522
- /**
523
- * Unregister a tool by name.
524
- *
525
- * @description
526
- * Removes a tool from the adapter's registry. The tool will no longer
527
- * be available for listing or invocation.
528
- *
529
- * @param name - The name of the tool to unregister
530
- * @returns void
531
- * @throws {Error} If no tool with the given name exists
532
- *
533
- * @example
534
- * adapter.unregisterTool('my_tool')
535
- */
536
- unregisterTool(name: string): void;
537
- /**
538
- * List all registered tools (without handlers).
539
- *
540
- * @description
541
- * Returns an array of all registered tools with their metadata.
542
- * Handler functions are omitted for serialization safety.
543
- *
544
- * @returns Array of tool definitions without handlers
545
- *
546
- * @example
547
- * const tools = adapter.listTools()
548
- * for (const tool of tools) {
549
- * console.log(`${tool.name}: ${tool.description}`)
550
- * }
551
- */
552
- listTools(): Array<Omit<MCPToolInfo, 'handler'>>;
553
- /**
554
- * Get a tool by name (without handler).
555
- *
556
- * @description
557
- * Retrieves a single tool's metadata by name. Returns undefined if
558
- * the tool is not found.
559
- *
560
- * @param name - The name of the tool to retrieve
561
- * @returns The tool definition without handler, or undefined if not found
562
- *
563
- * @example
564
- * const tool = adapter.getTool('git_status')
565
- * if (tool) {
566
- * console.log(tool.description)
567
- * }
568
- */
569
- getTool(name: string): Omit<MCPToolInfo, 'handler'> | undefined;
570
- /**
571
- * Register all git tools.
572
- *
573
- * @description
574
- * Convenience method that registers all built-in git tools from the
575
- * tools module. Skips any tools that are already registered.
576
- *
577
- * @returns void
578
- *
579
- * @example
580
- * const adapter = new MCPAdapter()
581
- * adapter.registerGitTools()
582
- * // All 18 git tools are now registered
583
- */
584
- registerGitTools(): void;
585
- /**
586
- * Register a resource.
587
- *
588
- * @description
589
- * Adds a resource to the adapter's registry. The resource will be
590
- * available for listing and reading via the resources/* methods.
591
- *
592
- * @param resourceInfo - The resource definition to register
593
- * @returns void
594
- *
595
- * @example
596
- * adapter.registerResource({
597
- * uri: 'git://repo/config',
598
- * name: 'Repository Config',
599
- * mimeType: 'application/json',
600
- * handler: async () => ({ content: JSON.stringify(config) })
601
- * })
602
- */
603
- registerResource(resourceInfo: MCPResourceInfo): void;
604
- /**
605
- * Register a prompt.
606
- *
607
- * @description
608
- * Adds a prompt template to the adapter's registry. The prompt will
609
- * be available for listing and retrieval via the prompts/* methods.
610
- *
611
- * @param promptInfo - The prompt definition to register
612
- * @returns void
613
- *
614
- * @example
615
- * adapter.registerPrompt({
616
- * name: 'review-code',
617
- * description: 'Review code changes',
618
- * handler: async () => ({
619
- * messages: [{ role: 'user', content: { type: 'text', text: '...' } }]
620
- * })
621
- * })
622
- */
623
- registerPrompt(promptInfo: MCPPromptInfo): void;
624
- /**
625
- * Handle a raw JSON string request.
626
- *
627
- * @description
628
- * Parses a raw JSON string as an MCP request and processes it.
629
- * Returns a parse error response if the JSON is invalid.
630
- *
631
- * @param rawRequest - Raw JSON string containing the request
632
- * @returns Promise resolving to the MCP response
633
- *
634
- * @example
635
- * const response = await adapter.handleRawRequest(
636
- * '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
637
- * )
638
- */
639
- handleRawRequest(rawRequest: string): Promise<MCPResponse>;
640
- /**
641
- * Handle a batch of requests.
642
- *
643
- * @description
644
- * Processes multiple MCP requests sequentially. Notifications (requests
645
- * without an id) are processed but do not produce responses.
646
- *
647
- * @param requests - Array of MCP requests to process
648
- * @returns Promise resolving to array of responses (excluding notifications)
649
- *
650
- * @example
651
- * const responses = await adapter.handleBatchRequest([
652
- * { jsonrpc: '2.0', id: 1, method: 'tools/list' },
653
- * { jsonrpc: '2.0', id: 2, method: 'initialize', params: {} }
654
- * ])
655
- */
656
- handleBatchRequest(requests: MCPRequest[]): Promise<MCPResponse[]>;
657
- /**
658
- * Handle a single MCP request.
659
- *
660
- * @description
661
- * Main request handler that routes MCP requests to the appropriate
662
- * method handler. Supports initialize, tools/*, resources/*, and prompts/*
663
- * methods. Returns undefined for notifications (requests without id).
664
- *
665
- * @param request - The MCP request to handle
666
- * @returns Promise resolving to response, or undefined for notifications
667
- *
668
- * @example
669
- * const response = await adapter.handleRequest({
670
- * jsonrpc: '2.0',
671
- * id: 1,
672
- * method: 'tools/call',
673
- * params: { name: 'git_status', arguments: {} }
674
- * })
675
- */
676
- handleRequest(request: MCPRequest): Promise<MCPResponse | undefined>;
677
- /**
678
- * Handle initialize request.
679
- *
680
- * @description
681
- * Processes the MCP initialize request and returns server information
682
- * and capabilities. This is the first request a client should send.
683
- *
684
- * @param request - The initialize request
685
- * @returns Response with server info and capabilities
686
- * @internal
687
- */
688
- private handleInitialize;
689
- /**
690
- * Handle tools/list request.
691
- * @param request - The tools/list request
692
- * @returns Response with list of registered tools
693
- * @internal
694
- */
695
- private handleToolsList;
696
- /**
697
- * Handle tools/call request.
698
- * @param request - The tools/call request with tool name and arguments
699
- * @returns Response with tool execution result
700
- * @internal
701
- */
702
- private handleToolsCall;
703
- /**
704
- * Validate tool parameters against schema.
705
- * @param tool - The tool to validate parameters for
706
- * @param params - The parameters to validate
707
- * @returns Validation result with errors array
708
- * @internal
709
- */
710
- private validateToolParams;
711
- /**
712
- * Handle resources/list request.
713
- * @param request - The resources/list request
714
- * @returns Response with list of registered resources
715
- * @internal
716
- */
717
- private handleResourcesList;
718
- /**
719
- * Handle resources/read request.
720
- * @param request - The resources/read request with URI
721
- * @returns Response with resource content
722
- * @internal
723
- */
724
- private handleResourcesRead;
725
- /**
726
- * Handle prompts/list request.
727
- * @param request - The prompts/list request
728
- * @returns Response with list of registered prompts
729
- * @internal
730
- */
731
- private handlePromptsList;
732
- /**
733
- * Handle prompts/get request.
734
- * @param request - The prompts/get request with name and arguments
735
- * @returns Response with generated prompt messages
736
- * @internal
737
- */
738
- private handlePromptsGet;
739
- /**
740
- * Create an error response.
741
- * @param id - Request ID
742
- * @param code - Error code
743
- * @param message - Error message
744
- * @param data - Optional additional error data
745
- * @returns Formatted error response
746
- * @internal
747
- */
748
- private errorResponse;
749
- }
750
- /**
751
- * Factory function to create an MCP adapter.
752
- *
753
- * @description
754
- * Convenience function for creating a new MCP adapter instance.
755
- * Equivalent to using `new MCPAdapter(config)`.
756
- *
757
- * @param config - Optional server configuration
758
- * @returns A new MCPAdapter instance
759
- *
760
- * @example
761
- * import { createMCPAdapter } from './adapter'
762
- *
763
- * const adapter = createMCPAdapter({
764
- * name: 'my-git-server',
765
- * capabilities: ['tools', 'resources']
766
- * })
767
- *
768
- * adapter.registerGitTools()
769
- * await adapter.start()
770
- */
771
- export declare function createMCPAdapter(config?: MCPServerConfig): MCPAdapter;
772
- //# sourceMappingURL=adapter.d.ts.map