gitx.do 0.1.1 → 0.1.3

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 (376) 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 -469
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +39 -481
  17. package/dist/index.js.map +1 -1
  18. package/dist/mcp/auth.d.ts +77 -0
  19. package/dist/mcp/auth.d.ts.map +1 -0
  20. package/dist/mcp/auth.js +278 -0
  21. package/dist/mcp/auth.js.map +1 -0
  22. package/dist/mcp/index.d.ts +13 -0
  23. package/dist/mcp/index.d.ts.map +1 -0
  24. package/dist/mcp/index.js +19 -0
  25. package/dist/mcp/index.js.map +1 -0
  26. package/dist/mcp/server.d.ts +200 -0
  27. package/dist/mcp/server.d.ts.map +1 -0
  28. package/dist/mcp/server.js +275 -0
  29. package/dist/mcp/server.js.map +1 -0
  30. package/dist/mcp/tool-registry.d.ts +47 -0
  31. package/dist/mcp/tool-registry.d.ts.map +1 -0
  32. package/dist/mcp/tool-registry.js +284 -0
  33. package/dist/mcp/tool-registry.js.map +1 -0
  34. package/dist/mcp/tools.d.ts +103 -515
  35. package/dist/mcp/tools.d.ts.map +1 -1
  36. package/dist/mcp/tools.js +676 -3087
  37. package/dist/mcp/tools.js.map +1 -1
  38. package/dist/mcp/types.d.ts +124 -0
  39. package/dist/mcp/types.d.ts.map +1 -0
  40. package/dist/mcp/types.js +9 -0
  41. package/dist/mcp/types.js.map +1 -0
  42. package/package.json +19 -21
  43. package/dist/cli/commands/add.d.ts +0 -176
  44. package/dist/cli/commands/add.d.ts.map +0 -1
  45. package/dist/cli/commands/add.js +0 -979
  46. package/dist/cli/commands/add.js.map +0 -1
  47. package/dist/cli/commands/blame.d.ts +0 -259
  48. package/dist/cli/commands/blame.d.ts.map +0 -1
  49. package/dist/cli/commands/blame.js +0 -609
  50. package/dist/cli/commands/blame.js.map +0 -1
  51. package/dist/cli/commands/branch.d.ts +0 -249
  52. package/dist/cli/commands/branch.d.ts.map +0 -1
  53. package/dist/cli/commands/branch.js +0 -693
  54. package/dist/cli/commands/branch.js.map +0 -1
  55. package/dist/cli/commands/checkout.d.ts +0 -73
  56. package/dist/cli/commands/checkout.d.ts.map +0 -1
  57. package/dist/cli/commands/checkout.js +0 -725
  58. package/dist/cli/commands/checkout.js.map +0 -1
  59. package/dist/cli/commands/commit.d.ts +0 -182
  60. package/dist/cli/commands/commit.d.ts.map +0 -1
  61. package/dist/cli/commands/commit.js +0 -457
  62. package/dist/cli/commands/commit.js.map +0 -1
  63. package/dist/cli/commands/diff.d.ts +0 -464
  64. package/dist/cli/commands/diff.d.ts.map +0 -1
  65. package/dist/cli/commands/diff.js +0 -959
  66. package/dist/cli/commands/diff.js.map +0 -1
  67. package/dist/cli/commands/log.d.ts +0 -239
  68. package/dist/cli/commands/log.d.ts.map +0 -1
  69. package/dist/cli/commands/log.js +0 -535
  70. package/dist/cli/commands/log.js.map +0 -1
  71. package/dist/cli/commands/merge.d.ts +0 -106
  72. package/dist/cli/commands/merge.d.ts.map +0 -1
  73. package/dist/cli/commands/merge.js +0 -852
  74. package/dist/cli/commands/merge.js.map +0 -1
  75. package/dist/cli/commands/review.d.ts +0 -457
  76. package/dist/cli/commands/review.d.ts.map +0 -1
  77. package/dist/cli/commands/review.js +0 -558
  78. package/dist/cli/commands/review.js.map +0 -1
  79. package/dist/cli/commands/stash.d.ts +0 -157
  80. package/dist/cli/commands/stash.d.ts.map +0 -1
  81. package/dist/cli/commands/stash.js +0 -655
  82. package/dist/cli/commands/stash.js.map +0 -1
  83. package/dist/cli/commands/status.d.ts +0 -269
  84. package/dist/cli/commands/status.d.ts.map +0 -1
  85. package/dist/cli/commands/status.js +0 -492
  86. package/dist/cli/commands/status.js.map +0 -1
  87. package/dist/cli/commands/web.d.ts +0 -199
  88. package/dist/cli/commands/web.d.ts.map +0 -1
  89. package/dist/cli/commands/web.js +0 -697
  90. package/dist/cli/commands/web.js.map +0 -1
  91. package/dist/cli/fs-adapter.d.ts +0 -656
  92. package/dist/cli/fs-adapter.d.ts.map +0 -1
  93. package/dist/cli/fs-adapter.js +0 -1177
  94. package/dist/cli/fs-adapter.js.map +0 -1
  95. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  96. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  97. package/dist/cli/fsx-cli-adapter.js +0 -619
  98. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  99. package/dist/cli/index.d.ts +0 -387
  100. package/dist/cli/index.d.ts.map +0 -1
  101. package/dist/cli/index.js +0 -579
  102. package/dist/cli/index.js.map +0 -1
  103. package/dist/cli/ui/components/DiffView.d.ts +0 -12
  104. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  105. package/dist/cli/ui/components/DiffView.js +0 -11
  106. package/dist/cli/ui/components/DiffView.js.map +0 -1
  107. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
  108. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  109. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  110. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  111. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
  112. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  113. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  114. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  115. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
  116. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  117. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  118. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  119. package/dist/cli/ui/components/NavigationList.d.ts +0 -14
  120. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  121. package/dist/cli/ui/components/NavigationList.js +0 -11
  122. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  123. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
  124. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  125. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  126. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  127. package/dist/cli/ui/components/index.d.ts +0 -7
  128. package/dist/cli/ui/components/index.d.ts.map +0 -1
  129. package/dist/cli/ui/components/index.js +0 -9
  130. package/dist/cli/ui/components/index.js.map +0 -1
  131. package/dist/cli/ui/terminal-ui.d.ts +0 -85
  132. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  133. package/dist/cli/ui/terminal-ui.js +0 -121
  134. package/dist/cli/ui/terminal-ui.js.map +0 -1
  135. package/dist/do/BashModule.d.ts +0 -871
  136. package/dist/do/BashModule.d.ts.map +0 -1
  137. package/dist/do/BashModule.js +0 -1143
  138. package/dist/do/BashModule.js.map +0 -1
  139. package/dist/do/FsModule.d.ts +0 -612
  140. package/dist/do/FsModule.d.ts.map +0 -1
  141. package/dist/do/FsModule.js +0 -1120
  142. package/dist/do/FsModule.js.map +0 -1
  143. package/dist/do/GitModule.d.ts +0 -635
  144. package/dist/do/GitModule.d.ts.map +0 -1
  145. package/dist/do/GitModule.js +0 -784
  146. package/dist/do/GitModule.js.map +0 -1
  147. package/dist/do/GitRepoDO.d.ts +0 -281
  148. package/dist/do/GitRepoDO.d.ts.map +0 -1
  149. package/dist/do/GitRepoDO.js +0 -479
  150. package/dist/do/GitRepoDO.js.map +0 -1
  151. package/dist/do/bash-ast.d.ts +0 -246
  152. package/dist/do/bash-ast.d.ts.map +0 -1
  153. package/dist/do/bash-ast.js +0 -888
  154. package/dist/do/bash-ast.js.map +0 -1
  155. package/dist/do/container-executor.d.ts +0 -491
  156. package/dist/do/container-executor.d.ts.map +0 -1
  157. package/dist/do/container-executor.js +0 -731
  158. package/dist/do/container-executor.js.map +0 -1
  159. package/dist/do/index.d.ts +0 -53
  160. package/dist/do/index.d.ts.map +0 -1
  161. package/dist/do/index.js +0 -91
  162. package/dist/do/index.js.map +0 -1
  163. package/dist/do/tiered-storage.d.ts +0 -403
  164. package/dist/do/tiered-storage.d.ts.map +0 -1
  165. package/dist/do/tiered-storage.js +0 -689
  166. package/dist/do/tiered-storage.js.map +0 -1
  167. package/dist/do/withBash.d.ts +0 -231
  168. package/dist/do/withBash.d.ts.map +0 -1
  169. package/dist/do/withBash.js +0 -244
  170. package/dist/do/withBash.js.map +0 -1
  171. package/dist/do/withFs.d.ts +0 -237
  172. package/dist/do/withFs.d.ts.map +0 -1
  173. package/dist/do/withFs.js +0 -387
  174. package/dist/do/withFs.js.map +0 -1
  175. package/dist/do/withGit.d.ts +0 -180
  176. package/dist/do/withGit.d.ts.map +0 -1
  177. package/dist/do/withGit.js +0 -271
  178. package/dist/do/withGit.js.map +0 -1
  179. package/dist/durable-object/object-store.d.ts +0 -633
  180. package/dist/durable-object/object-store.d.ts.map +0 -1
  181. package/dist/durable-object/object-store.js +0 -1164
  182. package/dist/durable-object/object-store.js.map +0 -1
  183. package/dist/durable-object/schema.d.ts.map +0 -1
  184. package/dist/durable-object/schema.js.map +0 -1
  185. package/dist/durable-object/wal.d.ts +0 -416
  186. package/dist/durable-object/wal.d.ts.map +0 -1
  187. package/dist/durable-object/wal.js +0 -445
  188. package/dist/durable-object/wal.js.map +0 -1
  189. package/dist/mcp/adapter.d.ts +0 -772
  190. package/dist/mcp/adapter.d.ts.map +0 -1
  191. package/dist/mcp/adapter.js +0 -895
  192. package/dist/mcp/adapter.js.map +0 -1
  193. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  194. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  195. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  196. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  197. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  198. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  199. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  200. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  201. package/dist/mcp/sandbox/template.d.ts +0 -17
  202. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  203. package/dist/mcp/sandbox/template.js +0 -71
  204. package/dist/mcp/sandbox/template.js.map +0 -1
  205. package/dist/mcp/sandbox.d.ts +0 -764
  206. package/dist/mcp/sandbox.d.ts.map +0 -1
  207. package/dist/mcp/sandbox.js +0 -1362
  208. package/dist/mcp/sandbox.js.map +0 -1
  209. package/dist/mcp/sdk-adapter.d.ts +0 -835
  210. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  211. package/dist/mcp/sdk-adapter.js +0 -974
  212. package/dist/mcp/sdk-adapter.js.map +0 -1
  213. package/dist/mcp/tools/do.d.ts +0 -32
  214. package/dist/mcp/tools/do.d.ts.map +0 -1
  215. package/dist/mcp/tools/do.js +0 -117
  216. package/dist/mcp/tools/do.js.map +0 -1
  217. package/dist/ops/blame.d.ts +0 -551
  218. package/dist/ops/blame.d.ts.map +0 -1
  219. package/dist/ops/blame.js +0 -1037
  220. package/dist/ops/blame.js.map +0 -1
  221. package/dist/ops/branch.d.ts +0 -766
  222. package/dist/ops/branch.d.ts.map +0 -1
  223. package/dist/ops/branch.js +0 -950
  224. package/dist/ops/branch.js.map +0 -1
  225. package/dist/ops/commit-traversal.d.ts +0 -349
  226. package/dist/ops/commit-traversal.d.ts.map +0 -1
  227. package/dist/ops/commit-traversal.js +0 -821
  228. package/dist/ops/commit-traversal.js.map +0 -1
  229. package/dist/ops/commit.d.ts +0 -555
  230. package/dist/ops/commit.d.ts.map +0 -1
  231. package/dist/ops/commit.js +0 -826
  232. package/dist/ops/commit.js.map +0 -1
  233. package/dist/ops/merge-base.d.ts +0 -397
  234. package/dist/ops/merge-base.d.ts.map +0 -1
  235. package/dist/ops/merge-base.js +0 -691
  236. package/dist/ops/merge-base.js.map +0 -1
  237. package/dist/ops/merge.d.ts +0 -855
  238. package/dist/ops/merge.d.ts.map +0 -1
  239. package/dist/ops/merge.js +0 -1551
  240. package/dist/ops/merge.js.map +0 -1
  241. package/dist/ops/tag.d.ts +0 -247
  242. package/dist/ops/tag.d.ts.map +0 -1
  243. package/dist/ops/tag.js +0 -649
  244. package/dist/ops/tag.js.map +0 -1
  245. package/dist/ops/tree-builder.d.ts +0 -178
  246. package/dist/ops/tree-builder.d.ts.map +0 -1
  247. package/dist/ops/tree-builder.js +0 -271
  248. package/dist/ops/tree-builder.js.map +0 -1
  249. package/dist/ops/tree-diff.d.ts +0 -291
  250. package/dist/ops/tree-diff.d.ts.map +0 -1
  251. package/dist/ops/tree-diff.js +0 -705
  252. package/dist/ops/tree-diff.js.map +0 -1
  253. package/dist/pack/delta.d.ts +0 -248
  254. package/dist/pack/delta.d.ts.map +0 -1
  255. package/dist/pack/delta.js +0 -740
  256. package/dist/pack/delta.js.map +0 -1
  257. package/dist/pack/format.d.ts +0 -446
  258. package/dist/pack/format.d.ts.map +0 -1
  259. package/dist/pack/format.js +0 -572
  260. package/dist/pack/format.js.map +0 -1
  261. package/dist/pack/full-generation.d.ts +0 -612
  262. package/dist/pack/full-generation.d.ts.map +0 -1
  263. package/dist/pack/full-generation.js +0 -1378
  264. package/dist/pack/full-generation.js.map +0 -1
  265. package/dist/pack/generation.d.ts +0 -441
  266. package/dist/pack/generation.d.ts.map +0 -1
  267. package/dist/pack/generation.js +0 -707
  268. package/dist/pack/generation.js.map +0 -1
  269. package/dist/pack/index.d.ts +0 -502
  270. package/dist/pack/index.d.ts.map +0 -1
  271. package/dist/pack/index.js +0 -833
  272. package/dist/pack/index.js.map +0 -1
  273. package/dist/refs/branch.d.ts +0 -683
  274. package/dist/refs/branch.d.ts.map +0 -1
  275. package/dist/refs/branch.js +0 -881
  276. package/dist/refs/branch.js.map +0 -1
  277. package/dist/refs/storage.d.ts +0 -833
  278. package/dist/refs/storage.d.ts.map +0 -1
  279. package/dist/refs/storage.js +0 -1023
  280. package/dist/refs/storage.js.map +0 -1
  281. package/dist/refs/tag.d.ts +0 -860
  282. package/dist/refs/tag.d.ts.map +0 -1
  283. package/dist/refs/tag.js +0 -996
  284. package/dist/refs/tag.js.map +0 -1
  285. package/dist/storage/backend.d.ts +0 -425
  286. package/dist/storage/backend.d.ts.map +0 -1
  287. package/dist/storage/backend.js +0 -41
  288. package/dist/storage/backend.js.map +0 -1
  289. package/dist/storage/fsx-adapter.d.ts +0 -204
  290. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  291. package/dist/storage/fsx-adapter.js +0 -518
  292. package/dist/storage/fsx-adapter.js.map +0 -1
  293. package/dist/storage/lru-cache.d.ts +0 -691
  294. package/dist/storage/lru-cache.d.ts.map +0 -1
  295. package/dist/storage/lru-cache.js +0 -813
  296. package/dist/storage/lru-cache.js.map +0 -1
  297. package/dist/storage/object-index.d.ts +0 -585
  298. package/dist/storage/object-index.d.ts.map +0 -1
  299. package/dist/storage/object-index.js +0 -532
  300. package/dist/storage/object-index.js.map +0 -1
  301. package/dist/storage/r2-pack.d.ts +0 -1257
  302. package/dist/storage/r2-pack.d.ts.map +0 -1
  303. package/dist/storage/r2-pack.js +0 -1773
  304. package/dist/storage/r2-pack.js.map +0 -1
  305. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  306. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  307. package/dist/tiered/cdc-pipeline.js +0 -1880
  308. package/dist/tiered/cdc-pipeline.js.map +0 -1
  309. package/dist/tiered/migration.d.ts +0 -1104
  310. package/dist/tiered/migration.d.ts.map +0 -1
  311. package/dist/tiered/migration.js +0 -1217
  312. package/dist/tiered/migration.js.map +0 -1
  313. package/dist/tiered/parquet-writer.d.ts +0 -1145
  314. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  315. package/dist/tiered/parquet-writer.js +0 -1183
  316. package/dist/tiered/parquet-writer.js.map +0 -1
  317. package/dist/tiered/read-path.d.ts +0 -835
  318. package/dist/tiered/read-path.d.ts.map +0 -1
  319. package/dist/tiered/read-path.js +0 -487
  320. package/dist/tiered/read-path.js.map +0 -1
  321. package/dist/types/capability.d.ts +0 -1385
  322. package/dist/types/capability.d.ts.map +0 -1
  323. package/dist/types/capability.js +0 -36
  324. package/dist/types/capability.js.map +0 -1
  325. package/dist/types/index.d.ts +0 -13
  326. package/dist/types/index.d.ts.map +0 -1
  327. package/dist/types/index.js +0 -18
  328. package/dist/types/index.js.map +0 -1
  329. package/dist/types/interfaces.d.ts +0 -673
  330. package/dist/types/interfaces.d.ts.map +0 -1
  331. package/dist/types/interfaces.js +0 -26
  332. package/dist/types/interfaces.js.map +0 -1
  333. package/dist/types/objects.d.ts +0 -692
  334. package/dist/types/objects.d.ts.map +0 -1
  335. package/dist/types/objects.js +0 -837
  336. package/dist/types/objects.js.map +0 -1
  337. package/dist/types/storage.d.ts +0 -603
  338. package/dist/types/storage.d.ts.map +0 -1
  339. package/dist/types/storage.js +0 -191
  340. package/dist/types/storage.js.map +0 -1
  341. package/dist/types/worker-loader.d.ts +0 -60
  342. package/dist/types/worker-loader.d.ts.map +0 -1
  343. package/dist/types/worker-loader.js +0 -62
  344. package/dist/types/worker-loader.js.map +0 -1
  345. package/dist/utils/hash.d.ts +0 -198
  346. package/dist/utils/hash.d.ts.map +0 -1
  347. package/dist/utils/hash.js +0 -272
  348. package/dist/utils/hash.js.map +0 -1
  349. package/dist/utils/sha1.d.ts +0 -325
  350. package/dist/utils/sha1.d.ts.map +0 -1
  351. package/dist/utils/sha1.js +0 -635
  352. package/dist/utils/sha1.js.map +0 -1
  353. package/dist/wire/capabilities.d.ts +0 -1044
  354. package/dist/wire/capabilities.d.ts.map +0 -1
  355. package/dist/wire/capabilities.js +0 -941
  356. package/dist/wire/capabilities.js.map +0 -1
  357. package/dist/wire/path-security.d.ts +0 -157
  358. package/dist/wire/path-security.d.ts.map +0 -1
  359. package/dist/wire/path-security.js +0 -307
  360. package/dist/wire/path-security.js.map +0 -1
  361. package/dist/wire/pkt-line.d.ts +0 -345
  362. package/dist/wire/pkt-line.d.ts.map +0 -1
  363. package/dist/wire/pkt-line.js +0 -381
  364. package/dist/wire/pkt-line.js.map +0 -1
  365. package/dist/wire/receive-pack.d.ts +0 -1059
  366. package/dist/wire/receive-pack.d.ts.map +0 -1
  367. package/dist/wire/receive-pack.js +0 -1414
  368. package/dist/wire/receive-pack.js.map +0 -1
  369. package/dist/wire/smart-http.d.ts +0 -799
  370. package/dist/wire/smart-http.d.ts.map +0 -1
  371. package/dist/wire/smart-http.js +0 -945
  372. package/dist/wire/smart-http.js.map +0 -1
  373. package/dist/wire/upload-pack.d.ts +0 -727
  374. package/dist/wire/upload-pack.d.ts.map +0 -1
  375. package/dist/wire/upload-pack.js +0 -1141
  376. package/dist/wire/upload-pack.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,507 +1,65 @@
1
1
  /**
2
- * @fileoverview gitx.do - Complete Git Implementation for Cloudflare Workers
2
+ * @fileoverview gitx.do - Git on Cloudflare Durable Objects
3
3
  *
4
- * This is the main entry point for the gitx.do library, providing a complete
5
- * Git implementation designed to run on Cloudflare Workers with Durable Objects
6
- * and R2 storage.
7
- *
8
- * **Architecture Overview**:
9
- * - **Types**: Core Git object types (blob, tree, commit, tag)
10
- * - **Pack Operations**: Packfile format handling and index management
11
- * - **Git Operations**: Core commands (merge, blame, commit, branch)
12
- * - **MCP Integration**: Model Context Protocol for AI assistant integration
13
- * - **Wire Protocol**: Git Smart HTTP protocol implementation
14
- * - **Storage**: R2 packfile storage and object indexing
15
- * - **Tiered Storage**: Hot/Warm/Cold storage with migration
4
+ * This package provides the Cloudflare Workers/Durable Objects integration
5
+ * for gitx. It depends on @dotdo/gitx for the pure git implementation.
16
6
  *
17
7
  * @module gitx.do
18
8
  *
19
9
  * @example
20
10
  * ```typescript
21
- * import {
22
- * // Types
23
- * type CommitObject,
24
- * parseCommit,
25
- * serializeCommit,
26
- *
27
- * // Operations
28
- * createCommit,
29
- * merge,
30
- * blame,
31
- *
32
- * // Storage
33
- * R2PackStorage,
34
- * ObjectIndex,
11
+ * import { GitRepoDO, GitModule, withGit } from 'gitx.do'
35
12
  *
36
- * // Wire Protocol
37
- * handleInfoRefs,
38
- * handleUploadPack,
39
- * } from 'gitx.do'
13
+ * // Use GitRepoDO for full repository management
14
+ * export { GitRepoDO }
40
15
  *
41
- * // Create a commit
42
- * const commit = await createCommit(storage, {
43
- * tree: treeSha,
44
- * parents: [parentSha],
45
- * message: 'Add new feature',
46
- * author: { name: 'Alice', email: 'alice@example.com' }
47
- * })
48
- * ```
49
- */
50
- // =============================================================================
51
- // Types - Core Git object types and interfaces
52
- // =============================================================================
53
- /**
54
- * Git object types and serialization.
55
- *
56
- * @description
57
- * Core types for Git objects (blob, tree, commit, tag) including:
58
- * - Type definitions for each object type
59
- * - Type guard functions for runtime type checking
60
- * - Serialization functions for converting to Git format
61
- * - Deserialization functions for parsing Git format
62
- *
63
- * @example
64
- * ```typescript
65
- * import { isCommit, parseCommit, serializeCommit } from 'gitx.do'
66
- *
67
- * // Parse raw commit data
68
- * const commit = parseCommit(rawData)
69
- *
70
- * // Check type at runtime
71
- * if (isCommit(obj)) {
72
- * console.log(obj.message)
16
+ * // Or use mixins for custom DOs
17
+ * class MyDO extends withGit(DurableObject) {
18
+ * async doSomething() {
19
+ * await this.git.clone('https://github.com/org/repo')
20
+ * }
73
21
  * }
74
22
  * ```
75
23
  */
76
- export {
77
- // Type guards
78
- isBlob, isTree, isCommit, isTag,
79
- // Validation constants
80
- SHA_PATTERN, VALID_MODES,
81
- // Validation functions
82
- isValidSha, isValidObjectType, isValidMode, validateTreeEntry, validateAuthor, validateCommit, validateTag,
83
- // Serialization
84
- serializeBlob, serializeTree, serializeCommit, serializeTag,
85
- // Deserialization
86
- parseBlob, parseTree, parseCommit, parseTag, } from './types/objects';
87
- /**
88
- * Storage interface types and validation.
89
- *
90
- * @description
91
- * Core storage interfaces for Git object stores and commit providers:
92
- * - {@link ObjectStore}: Full-featured object storage with refs
93
- * - {@link BasicObjectStore}: Minimal object CRUD
94
- * - {@link RefObjectStore}: Object store with ref management
95
- * - {@link TreeDiffObjectStore}: Specialized for tree operations
96
- * - {@link CommitProvider}: Commit retrieval interface
97
- * - {@link BasicCommitProvider}: Minimal commit access
98
- *
99
- * Plus validation helpers for storage operations.
100
- *
101
- * @example
102
- * ```typescript
103
- * import {
104
- * type ObjectStore,
105
- * validateRefName,
106
- * assertValidSha
107
- * } from 'gitx.do'
108
- *
109
- * // Validate before storing
110
- * assertValidSha(treeSha, 'tree')
111
- * const refResult = validateRefName('refs/heads/main')
112
- * ```
113
- */
114
- export {
115
- // Validation functions
116
- validateRefName, validateRefUpdate, validateStoreParams, assertValidSha, assertValidRefName, } from './types/storage';
117
24
  // =============================================================================
118
- // Pack Operations - Packfile format and index handling
25
+ // Re-export core git types from @dotdo/gitx
119
26
  // =============================================================================
120
- /**
121
- * Packfile format handling.
122
- *
123
- * @description
124
- * Functions for reading and writing Git packfiles including:
125
- * - Pack header parsing and creation
126
- * - Variable-length integer encoding/decoding
127
- * - Object type and size encoding
128
- *
129
- * @example
130
- * ```typescript
131
- * import { createPackfile, parsePackHeader } from 'gitx.do'
132
- *
133
- * // Create a packfile from objects
134
- * const packData = await createPackfile(objects)
135
- *
136
- * // Parse pack header
137
- * const header = parsePackHeader(packData)
138
- * console.log(`Pack contains ${header.objectCount} objects`)
139
- * ```
140
- */
141
- export {
142
- // Constants
143
- PACK_SIGNATURE, PACK_VERSION,
144
- // Enums
145
- PackObjectType,
146
- // Type conversions
147
- packObjectTypeToString, stringToPackObjectType,
148
- // Variable-length encoding
149
- encodeVarint, decodeVarint, encodeTypeAndSize, decodeTypeAndSize,
150
- // Pack header
151
- parsePackHeader, parsePackObject, createPackfile, } from './pack/format';
152
- /**
153
- * Pack index operations.
154
- *
155
- * @description
156
- * Functions for reading and writing pack index files (.idx) including:
157
- * - Index parsing and creation
158
- * - Object lookup by SHA
159
- * - CRC32 calculation for verification
160
- *
161
- * @example
162
- * ```typescript
163
- * import { createPackIndex, lookupObject } from 'gitx.do'
164
- *
165
- * // Create index for a packfile
166
- * const index = await createPackIndex(packData)
167
- *
168
- * // Look up an object
169
- * const result = lookupObject(index, sha)
170
- * if (result) {
171
- * console.log(`Object at offset ${result.offset}`)
172
- * }
173
- * ```
174
- */
175
- export {
176
- // Constants
177
- PACK_INDEX_SIGNATURE, PACK_INDEX_MAGIC, PACK_INDEX_VERSION, LARGE_OFFSET_THRESHOLD,
178
- // Main functions
179
- parsePackIndex, createPackIndex, lookupObject, verifyPackIndex, serializePackIndex,
180
- // Utility functions
181
- getFanoutRange, calculateCRC32, binarySearchObjectId, binarySearchSha, parseFanoutTable, readPackOffset, } from './pack/index';
27
+ export * from '@dotdo/gitx';
182
28
  // =============================================================================
183
- // Git Operations - Core git commands (merge, blame, commit, branch)
29
+ // Cloudflare-specific Schema Management
184
30
  // =============================================================================
185
- /**
186
- * Merge operations.
187
- *
188
- * @description
189
- * Functions for performing Git merges including:
190
- * - Three-way merge algorithm
191
- * - Merge base finding
192
- * - Conflict detection and resolution
193
- * - Content merging for text files
194
- *
195
- * @example
196
- * ```typescript
197
- * import { merge, findMergeBase, resolveConflict } from 'gitx.do'
198
- *
199
- * // Find merge base
200
- * const base = await findMergeBase(storage, commit1, commit2)
201
- *
202
- * // Perform merge
203
- * const result = await merge(storage, {
204
- * ours: 'main',
205
- * theirs: 'feature',
206
- * strategy: 'recursive'
207
- * })
208
- *
209
- * if (result.conflicts.length > 0) {
210
- * // Handle conflicts
211
- * }
212
- * ```
213
- */
214
- export { merge, findMergeBase, resolveConflict, abortMerge, continueMerge, getMergeState, isMergeInProgress, mergeContent, isBinaryFile, } from './ops/merge';
215
- /**
216
- * Blame operations.
217
- *
218
- * @description
219
- * Functions for git blame functionality including:
220
- * - Line-by-line attribution
221
- * - Rename tracking across history
222
- * - Range-based blame
223
- * - Blame output formatting
224
- *
225
- * @example
226
- * ```typescript
227
- * import { blame, blameFile, formatBlame } from 'gitx.do'
228
- *
229
- * // Get blame for a file
230
- * const result = await blameFile(storage, 'src/index.ts', { commit: 'HEAD' })
231
- *
232
- * // Format for display
233
- * const output = formatBlame(result, { showEmail: true })
234
- * ```
235
- */
236
- export { blame, blameFile, blameLine, blameRange, getBlameForCommit, trackContentAcrossRenames, detectRenames, buildBlameHistory, formatBlame, parseBlameOutput, } from './ops/blame';
237
- /**
238
- * Commit operations.
239
- *
240
- * @description
241
- * Functions for creating and working with commits including:
242
- * - Commit creation and amendment
243
- * - Commit message formatting and validation
244
- * - Signature handling (GPG)
245
- * - Author/timestamp utilities
246
- *
247
- * @example
248
- * ```typescript
249
- * import { createCommit, createAuthor, formatTimestamp } from 'gitx.do'
250
- *
251
- * const author = createAuthor('Alice', 'alice@example.com')
252
- * const commit = await createCommit(storage, {
253
- * tree: treeSha,
254
- * parents: [parentSha],
255
- * author,
256
- * message: 'Add new feature'
257
- * })
258
- * ```
259
- */
260
- export { createCommit, amendCommit, buildCommitObject, formatCommitMessage, parseCommitMessage, validateCommitMessage, isCommitSigned, extractCommitSignature, addSignatureToCommit, isEmptyCommit, getCurrentTimezone, formatTimestamp, parseTimestamp, createAuthor, } from './ops/commit';
261
- /**
262
- * Branch operations.
263
- *
264
- * @description
265
- * Functions for branch management including:
266
- * - Branch creation, deletion, and renaming
267
- * - Branch listing and filtering
268
- * - Upstream tracking configuration
269
- * - Branch validation
270
- *
271
- * @example
272
- * ```typescript
273
- * import { createBranch, listBranches, getCurrentBranch } from 'gitx.do'
274
- *
275
- * // Create a new branch
276
- * await createBranch(storage, 'feature/new-thing', { startPoint: 'main' })
277
- *
278
- * // List all branches
279
- * const branches = await listBranches(storage, { includeRemotes: true })
280
- *
281
- * // Get current branch
282
- * const current = await getCurrentBranch(storage)
283
- * ```
284
- */
285
- export { createBranch, deleteBranch, listBranches, renameBranch, checkoutBranch, getCurrentBranch, getBranchInfo, branchExists, setBranchTracking, getBranchTracking, removeBranchTracking, getDefaultBranch, setDefaultBranch, isValidBranchName, normalizeBranchName, } from './ops/branch';
31
+ export { SchemaManager, SCHEMA_VERSION, SCHEMA_SQL, } from './do/schema';
286
32
  // =============================================================================
287
- // MCP (Model Context Protocol) - AI assistant integration
33
+ // Cloudflare-specific Types
288
34
  // =============================================================================
289
- /**
290
- * MCP tool definitions.
291
- *
292
- * @description
293
- * Tools for integrating with AI assistants via MCP including:
294
- * - Tool registration and discovery
295
- * - Input validation
296
- * - Tool invocation
297
- *
298
- * @example
299
- * ```typescript
300
- * import { gitTools, invokeTool, validateToolInput } from 'gitx.do'
301
- *
302
- * // List available tools
303
- * const tools = gitTools
304
- *
305
- * // Validate and invoke a tool
306
- * if (validateToolInput('git_status', input)) {
307
- * const result = await invokeTool('git_status', input, context)
308
- * }
309
- * ```
310
- */
311
35
  export {
312
- // Tool definitions
313
- gitTools, registerTool, validateToolInput, invokeTool, listTools, getTool, } from './mcp/tools';
314
- /**
315
- * MCP adapter.
316
- *
317
- * @description
318
- * Adapter for MCP protocol communication including:
319
- * - Request/response handling
320
- * - Capability negotiation
321
- * - Error handling
322
- *
323
- * @example
324
- * ```typescript
325
- * import { createMCPAdapter, MCPError, MCPErrorCode } from 'gitx.do'
326
- *
327
- * const adapter = createMCPAdapter({
328
- * name: 'gitx.do',
329
- * version: '1.0.0'
330
- * })
331
- *
332
- * const response = await adapter.handleRequest(request)
333
- * ```
334
- */
335
- export {
336
- // Adapter
337
- MCPAdapter, createMCPAdapter, MCPError, MCPErrorCode, } from './mcp/adapter';
36
+ // Error types
37
+ GitRepoDOErrorCode, GitRepoDOError,
38
+ // Logging types
39
+ LogLevel, } from './do/types';
338
40
  // =============================================================================
339
- // Wire Protocol - Git Smart HTTP protocol implementation
41
+ // Logger utilities
340
42
  // =============================================================================
341
- /**
342
- * Smart HTTP protocol handlers.
343
- *
344
- * @description
345
- * Functions for handling Git Smart HTTP protocol including:
346
- * - Info/refs endpoint handling
347
- * - Upload-pack (fetch/clone)
348
- * - Receive-pack (push)
349
- * - Capability negotiation
350
- *
351
- * @example
352
- * ```typescript
353
- * import { handleInfoRefs, handleUploadPack, handleReceivePack } from 'gitx.do'
354
- *
355
- * // Handle info/refs request
356
- * const refs = await handleInfoRefs(request, { service: 'git-upload-pack' })
357
- *
358
- * // Handle fetch request
359
- * const pack = await handleUploadPack(request, storage)
360
- * ```
361
- */
362
- export {
363
- // Request handlers
364
- handleInfoRefs, handleUploadPack, handleReceivePack,
365
- // Formatting
366
- formatRefAdvertisement, formatUploadPackResponse, formatReceivePackResponse,
367
- // Parsing
368
- parseUploadPackRequest, parseReceivePackRequest, parseCapabilities, capabilitiesToStrings,
369
- // Utilities
370
- validateContentType, createErrorResponse,
371
- // Constants
372
- CONTENT_TYPE_UPLOAD_PACK_ADVERTISEMENT, CONTENT_TYPE_RECEIVE_PACK_ADVERTISEMENT, CONTENT_TYPE_UPLOAD_PACK_REQUEST, CONTENT_TYPE_UPLOAD_PACK_RESULT, CONTENT_TYPE_RECEIVE_PACK_REQUEST, CONTENT_TYPE_RECEIVE_PACK_RESULT, ZERO_SHA, } from './wire/smart-http';
373
- /**
374
- * Pkt-line encoding/decoding.
375
- *
376
- * @description
377
- * Functions for Git pkt-line format handling including:
378
- * - Line encoding/decoding
379
- * - Flush and delimiter packets
380
- * - Stream processing
381
- *
382
- * @example
383
- * ```typescript
384
- * import { encodePktLine, decodePktLine, FLUSH_PKT } from 'gitx.do'
385
- *
386
- * // Encode a line
387
- * const encoded = encodePktLine('want abc123')
388
- *
389
- * // Decode a line
390
- * const { line, remaining } = decodePktLine(data)
391
- * ```
392
- */
393
- export {
394
- // Encoding/decoding
395
- encodePktLine, decodePktLine, encodeFlushPkt, encodeDelimPkt, pktLineStream,
396
- // Constants
397
- FLUSH_PKT, DELIM_PKT, MAX_PKT_LINE_DATA, } from './wire/pkt-line';
43
+ export { createLogger, createChildLogger, noopLogger, } from './do/logger';
398
44
  // =============================================================================
399
- // Storage - R2 packfile storage and object indexing
45
+ // MCP Server
400
46
  // =============================================================================
401
- /**
402
- * R2 pack storage.
403
- *
404
- * @description
405
- * Functions for storing packfiles in Cloudflare R2 including:
406
- * - Packfile upload/download
407
- * - Multi-pack index management
408
- * - Pack locking for concurrent access
409
- *
410
- * @example
411
- * ```typescript
412
- * import { R2PackStorage, uploadPackfile, listPackfiles } from 'gitx.do'
413
- *
414
- * const storage = new R2PackStorage(r2Bucket, { prefix: 'git/packs' })
415
- *
416
- * // Upload a packfile
417
- * const result = await uploadPackfile(storage, packData, { withIndex: true })
418
- *
419
- * // List all packfiles
420
- * const packs = await listPackfiles(storage)
421
- * ```
422
- */
423
- export {
424
- // Class
425
- R2PackStorage, R2PackError,
426
- // Standalone functions
427
- uploadPackfile, downloadPackfile, getPackfileMetadata, listPackfiles, deletePackfile, createMultiPackIndex, parseMultiPackIndex, lookupObjectInMultiPack, acquirePackLock, releasePackLock, } from './storage/r2-pack';
428
- /**
429
- * Object index.
430
- *
431
- * @description
432
- * Functions for tracking object locations across storage tiers including:
433
- * - Location recording and lookup
434
- * - Batch operations
435
- * - Statistics
436
- *
437
- * @example
438
- * ```typescript
439
- * import { ObjectIndex, recordLocation, lookupLocation } from 'gitx.do'
440
- *
441
- * const index = new ObjectIndex(storage)
442
- *
443
- * // Record object location
444
- * await recordLocation(index, sha, { tier: 'hot', location: 'local' })
445
- *
446
- * // Look up location
447
- * const location = await lookupLocation(index, sha)
448
- * ```
449
- */
450
- export {
451
- // Class
452
- ObjectIndex,
453
- // Standalone functions
454
- recordLocation, lookupLocation, batchLookup, getStats, } from './storage/object-index';
47
+ export { registerTool, unregisterTool, invokeTool, getToolRegistry, clearToolRegistry, useMiddleware, clearMiddleware,
48
+ // Git tools
49
+ gitTools, gitStatusToolSchema, gitLogToolSchema, gitDiffToolSchema, gitShowToolSchema, gitCommitToolSchema, gitBranchToolSchema, gitCheckoutToolSchema, gitAddToolSchema, gitResetToolSchema, gitMergeToolSchema, gitRebaseToolSchema, gitStashToolSchema, gitTagToolSchema, gitRemoteToolSchema, gitFetchToolSchema, gitPushToolSchema, gitPullToolSchema, gitCloneToolSchema, gitInitToolSchema, gitBlameToolSchema,
50
+ // Auth
51
+ gitAuthMiddleware, requireGitAuth, requireGitWrite, requireGitAdmin,
52
+ // Server
53
+ createGitMCPServer, } from './mcp/index';
455
54
  // =============================================================================
456
- // Tiered Storage - Hot/Warm/Cold storage with migration
55
+ // TODO: Additional exports to be added as migration continues
457
56
  // =============================================================================
458
- /**
459
- * Tier migration.
460
- *
461
- * @description
462
- * Functions for managing object migration between storage tiers including:
463
- * - Migration policies
464
- * - Access tracking
465
- * - Concurrent access handling
466
- *
467
- * @example
468
- * ```typescript
469
- * import { TierMigrator, AccessTracker } from 'gitx.do'
470
- *
471
- * const tracker = new AccessTracker(storage)
472
- * await tracker.recordAccess(sha)
473
- *
474
- * const migrator = new TierMigrator(storage, { policy: 'lru' })
475
- * await migrator.migrate(sha, 'hot', 'warm')
476
- * ```
477
- */
478
- export {
479
- // Classes
480
- TierMigrator, AccessTracker, MigrationError, MigrationRollback, ConcurrentAccessHandler, } from './tiered/migration';
481
- /**
482
- * Tiered read path.
483
- *
484
- * @description
485
- * Functions for reading objects across storage tiers including:
486
- * - Automatic tier traversal
487
- * - Caching strategies
488
- * - Read optimization
489
- *
490
- * @example
491
- * ```typescript
492
- * import { TieredReader, type TieredStorageConfig } from 'gitx.do'
493
- *
494
- * const config: TieredStorageConfig = {
495
- * hot: { backend: hotBackend, maxSize: 1_000_000 },
496
- * warm: { backend: warmBackend },
497
- * cold: { backend: coldBackend }
498
- * }
499
- *
500
- * const reader = new TieredReader(config)
501
- * const result = await reader.read(sha)
502
- * ```
503
- */
504
- export {
505
- // Class
506
- TieredReader, TieredObjectStoreStub, } from './tiered/read-path';
57
+ // - GitRepoDO
58
+ // - GitModule
59
+ // - FsModule
60
+ // - withGit, withFs mixins
61
+ // - TieredStorage
62
+ // - ObjectStore
63
+ // - WAL
64
+ // - Container executor
507
65
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,gFAAgF;AAChF,+CAA+C;AAC/C,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO;AAUL,cAAc;AACd,MAAM,EACN,MAAM,EACN,QAAQ,EACR,KAAK;AACL,uBAAuB;AACvB,WAAW,EACX,WAAW;AACX,uBAAuB;AACvB,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,WAAW;AACX,gBAAgB;AAChB,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY;AACZ,kBAAkB;AAClB,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO;AAGL,uBAAuB;AACvB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GAQnB,MAAM,iBAAiB,CAAA;AAsIxB,gFAAgF;AAChF,uDAAuD;AACvD,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO;AACL,YAAY;AACZ,cAAc,EACd,YAAY;AACZ,QAAQ;AACR,cAAc;AACd,mBAAmB;AACnB,sBAAsB,EACtB,sBAAsB;AACtB,2BAA2B;AAC3B,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,iBAAiB;AACjB,c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e,EACf,iBAAiB,EACjB,aAAa,EACb,eAAe;AACf,YAAY;AACZ,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB;AAClB,OAAO;AACP,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,eAAe;AAGf,SAAS;AACT,kBAAkB,GAEnB,MAAM,aAAa,CAAA;AAEpB,gFAAgF;AAChF,8DAA8D;AAC9D,gFAAgF;AAChF,cAAc;AACd,cAAc;AACd,aAAa;AACb,2BAA2B;AAC3B,kBAAkB;AAClB,gBAAgB;AAChB,QAAQ;AACR,uBAAuB"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Git MCP Authentication Middleware
3
+ *
4
+ * Provides OAuth 2.1 authentication via oauth.do for MCP git operations.
5
+ * Implements token introspection (RFC 7662) for access control.
6
+ *
7
+ * ## Authentication Flow
8
+ *
9
+ * 1. MCP client sends request with Bearer token
10
+ * 2. Middleware introspects token via oauth.do
11
+ * 3. Scopes determine access level:
12
+ * - `read` or `git:read` - read-only access
13
+ * - `write` or `git:write` - full access
14
+ * - `admin` or `git:admin` - admin access
15
+ *
16
+ * ## Usage with Hono
17
+ *
18
+ * ```typescript
19
+ * import { Hono } from 'hono'
20
+ * import { gitAuthMiddleware, requireGitWrite } from 'gitx.do/mcp'
21
+ *
22
+ * const app = new Hono()
23
+ *
24
+ * // Apply auth middleware to all routes
25
+ * app.use('/*', gitAuthMiddleware({
26
+ * introspectionUrl: 'https://oauth.do/introspect',
27
+ * clientId: env.OAUTH_CLIENT_ID,
28
+ * clientSecret: env.OAUTH_CLIENT_SECRET,
29
+ * }))
30
+ *
31
+ * // Protect write operations
32
+ * app.post('/git/commit', requireGitWrite(), async (c) => {
33
+ * const auth = c.get('gitAuth')
34
+ * // ...
35
+ * })
36
+ * ```
37
+ *
38
+ * @module mcp/auth
39
+ */
40
+ import type { MiddlewareHandler } from 'hono';
41
+ import type { GitAuthContext, GitAuthConfig } from './types';
42
+ export type { GitAuthContext, GitAuthConfig } from './types';
43
+ /**
44
+ * Extend Hono's ContextVariableMap with gitAuth
45
+ */
46
+ declare module 'hono' {
47
+ interface ContextVariableMap {
48
+ gitAuth: GitAuthContext;
49
+ }
50
+ }
51
+ /**
52
+ * Create authentication middleware for Hono
53
+ */
54
+ export declare function gitAuthMiddleware(config: GitAuthConfig): MiddlewareHandler;
55
+ /**
56
+ * Middleware that requires authentication
57
+ */
58
+ export declare function requireGitAuth(): MiddlewareHandler;
59
+ /**
60
+ * Middleware that requires write access
61
+ */
62
+ export declare function requireGitWrite(): MiddlewareHandler;
63
+ /**
64
+ * Middleware that requires admin access
65
+ */
66
+ export declare function requireGitAdmin(): MiddlewareHandler;
67
+ /**
68
+ * Authenticate a standalone request (for non-Hono use)
69
+ */
70
+ export declare function authenticateRequest(request: Request, config: GitAuthConfig): Promise<{
71
+ success: true;
72
+ context: GitAuthContext;
73
+ } | {
74
+ success: false;
75
+ error: string;
76
+ }>;
77
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/mcp/auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,MAAM,CAAA;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAG5D,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5D;;GAEG;AACH,OAAO,QAAQ,MAAM,CAAC;IACpB,UAAU,kBAAkB;QAC1B,OAAO,EAAE,cAAc,CAAA;KACxB;CACF;AAyJD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAkD1E;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,iBAAiB,CAalD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,CAanD;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,iBAAiB,CAoBnD;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAiCzF"}