gitx.do 0.1.1 → 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 (356) 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 +14 -469
  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 -176
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -979
  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/checkout.d.ts +0 -73
  32. package/dist/cli/commands/checkout.d.ts.map +0 -1
  33. package/dist/cli/commands/checkout.js +0 -725
  34. package/dist/cli/commands/checkout.js.map +0 -1
  35. package/dist/cli/commands/commit.d.ts +0 -182
  36. package/dist/cli/commands/commit.d.ts.map +0 -1
  37. package/dist/cli/commands/commit.js +0 -457
  38. package/dist/cli/commands/commit.js.map +0 -1
  39. package/dist/cli/commands/diff.d.ts +0 -464
  40. package/dist/cli/commands/diff.d.ts.map +0 -1
  41. package/dist/cli/commands/diff.js +0 -959
  42. package/dist/cli/commands/diff.js.map +0 -1
  43. package/dist/cli/commands/log.d.ts +0 -239
  44. package/dist/cli/commands/log.d.ts.map +0 -1
  45. package/dist/cli/commands/log.js +0 -535
  46. package/dist/cli/commands/log.js.map +0 -1
  47. package/dist/cli/commands/merge.d.ts +0 -106
  48. package/dist/cli/commands/merge.d.ts.map +0 -1
  49. package/dist/cli/commands/merge.js +0 -852
  50. package/dist/cli/commands/merge.js.map +0 -1
  51. package/dist/cli/commands/review.d.ts +0 -457
  52. package/dist/cli/commands/review.d.ts.map +0 -1
  53. package/dist/cli/commands/review.js +0 -558
  54. package/dist/cli/commands/review.js.map +0 -1
  55. package/dist/cli/commands/stash.d.ts +0 -157
  56. package/dist/cli/commands/stash.d.ts.map +0 -1
  57. package/dist/cli/commands/stash.js +0 -655
  58. package/dist/cli/commands/stash.js.map +0 -1
  59. package/dist/cli/commands/status.d.ts +0 -269
  60. package/dist/cli/commands/status.d.ts.map +0 -1
  61. package/dist/cli/commands/status.js +0 -492
  62. package/dist/cli/commands/status.js.map +0 -1
  63. package/dist/cli/commands/web.d.ts +0 -199
  64. package/dist/cli/commands/web.d.ts.map +0 -1
  65. package/dist/cli/commands/web.js +0 -697
  66. package/dist/cli/commands/web.js.map +0 -1
  67. package/dist/cli/fs-adapter.d.ts +0 -656
  68. package/dist/cli/fs-adapter.d.ts.map +0 -1
  69. package/dist/cli/fs-adapter.js +0 -1177
  70. package/dist/cli/fs-adapter.js.map +0 -1
  71. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  72. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  73. package/dist/cli/fsx-cli-adapter.js +0 -619
  74. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  75. package/dist/cli/index.d.ts +0 -387
  76. package/dist/cli/index.d.ts.map +0 -1
  77. package/dist/cli/index.js +0 -579
  78. package/dist/cli/index.js.map +0 -1
  79. package/dist/cli/ui/components/DiffView.d.ts +0 -12
  80. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  81. package/dist/cli/ui/components/DiffView.js +0 -11
  82. package/dist/cli/ui/components/DiffView.js.map +0 -1
  83. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
  84. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  85. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  86. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  87. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
  88. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  89. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  90. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  91. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
  92. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  93. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  94. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  95. package/dist/cli/ui/components/NavigationList.d.ts +0 -14
  96. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  97. package/dist/cli/ui/components/NavigationList.js +0 -11
  98. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  99. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
  100. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  101. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  102. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  103. package/dist/cli/ui/components/index.d.ts +0 -7
  104. package/dist/cli/ui/components/index.d.ts.map +0 -1
  105. package/dist/cli/ui/components/index.js +0 -9
  106. package/dist/cli/ui/components/index.js.map +0 -1
  107. package/dist/cli/ui/terminal-ui.d.ts +0 -85
  108. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  109. package/dist/cli/ui/terminal-ui.js +0 -121
  110. package/dist/cli/ui/terminal-ui.js.map +0 -1
  111. package/dist/do/BashModule.d.ts +0 -871
  112. package/dist/do/BashModule.d.ts.map +0 -1
  113. package/dist/do/BashModule.js +0 -1143
  114. package/dist/do/BashModule.js.map +0 -1
  115. package/dist/do/FsModule.d.ts +0 -612
  116. package/dist/do/FsModule.d.ts.map +0 -1
  117. package/dist/do/FsModule.js +0 -1120
  118. package/dist/do/FsModule.js.map +0 -1
  119. package/dist/do/GitModule.d.ts +0 -635
  120. package/dist/do/GitModule.d.ts.map +0 -1
  121. package/dist/do/GitModule.js +0 -784
  122. package/dist/do/GitModule.js.map +0 -1
  123. package/dist/do/GitRepoDO.d.ts +0 -281
  124. package/dist/do/GitRepoDO.d.ts.map +0 -1
  125. package/dist/do/GitRepoDO.js +0 -479
  126. package/dist/do/GitRepoDO.js.map +0 -1
  127. package/dist/do/bash-ast.d.ts +0 -246
  128. package/dist/do/bash-ast.d.ts.map +0 -1
  129. package/dist/do/bash-ast.js +0 -888
  130. package/dist/do/bash-ast.js.map +0 -1
  131. package/dist/do/container-executor.d.ts +0 -491
  132. package/dist/do/container-executor.d.ts.map +0 -1
  133. package/dist/do/container-executor.js +0 -731
  134. package/dist/do/container-executor.js.map +0 -1
  135. package/dist/do/index.d.ts +0 -53
  136. package/dist/do/index.d.ts.map +0 -1
  137. package/dist/do/index.js +0 -91
  138. package/dist/do/index.js.map +0 -1
  139. package/dist/do/tiered-storage.d.ts +0 -403
  140. package/dist/do/tiered-storage.d.ts.map +0 -1
  141. package/dist/do/tiered-storage.js +0 -689
  142. package/dist/do/tiered-storage.js.map +0 -1
  143. package/dist/do/withBash.d.ts +0 -231
  144. package/dist/do/withBash.d.ts.map +0 -1
  145. package/dist/do/withBash.js +0 -244
  146. package/dist/do/withBash.js.map +0 -1
  147. package/dist/do/withFs.d.ts +0 -237
  148. package/dist/do/withFs.d.ts.map +0 -1
  149. package/dist/do/withFs.js +0 -387
  150. package/dist/do/withFs.js.map +0 -1
  151. package/dist/do/withGit.d.ts +0 -180
  152. package/dist/do/withGit.d.ts.map +0 -1
  153. package/dist/do/withGit.js +0 -271
  154. package/dist/do/withGit.js.map +0 -1
  155. package/dist/durable-object/object-store.d.ts +0 -633
  156. package/dist/durable-object/object-store.d.ts.map +0 -1
  157. package/dist/durable-object/object-store.js +0 -1164
  158. package/dist/durable-object/object-store.js.map +0 -1
  159. package/dist/durable-object/schema.d.ts.map +0 -1
  160. package/dist/durable-object/schema.js.map +0 -1
  161. package/dist/durable-object/wal.d.ts +0 -416
  162. package/dist/durable-object/wal.d.ts.map +0 -1
  163. package/dist/durable-object/wal.js +0 -445
  164. package/dist/durable-object/wal.js.map +0 -1
  165. package/dist/mcp/adapter.d.ts +0 -772
  166. package/dist/mcp/adapter.d.ts.map +0 -1
  167. package/dist/mcp/adapter.js +0 -895
  168. package/dist/mcp/adapter.js.map +0 -1
  169. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  170. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  172. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  173. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  174. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  175. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  176. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  177. package/dist/mcp/sandbox/template.d.ts +0 -17
  178. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  179. package/dist/mcp/sandbox/template.js +0 -71
  180. package/dist/mcp/sandbox/template.js.map +0 -1
  181. package/dist/mcp/sandbox.d.ts +0 -764
  182. package/dist/mcp/sandbox.d.ts.map +0 -1
  183. package/dist/mcp/sandbox.js +0 -1362
  184. package/dist/mcp/sandbox.js.map +0 -1
  185. package/dist/mcp/sdk-adapter.d.ts +0 -835
  186. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  187. package/dist/mcp/sdk-adapter.js +0 -974
  188. package/dist/mcp/sdk-adapter.js.map +0 -1
  189. package/dist/mcp/tools/do.d.ts +0 -32
  190. package/dist/mcp/tools/do.d.ts.map +0 -1
  191. package/dist/mcp/tools/do.js +0 -117
  192. package/dist/mcp/tools/do.js.map +0 -1
  193. package/dist/mcp/tools.d.ts +0 -548
  194. package/dist/mcp/tools.d.ts.map +0 -1
  195. package/dist/mcp/tools.js +0 -3170
  196. package/dist/mcp/tools.js.map +0 -1
  197. package/dist/ops/blame.d.ts +0 -551
  198. package/dist/ops/blame.d.ts.map +0 -1
  199. package/dist/ops/blame.js +0 -1037
  200. package/dist/ops/blame.js.map +0 -1
  201. package/dist/ops/branch.d.ts +0 -766
  202. package/dist/ops/branch.d.ts.map +0 -1
  203. package/dist/ops/branch.js +0 -950
  204. package/dist/ops/branch.js.map +0 -1
  205. package/dist/ops/commit-traversal.d.ts +0 -349
  206. package/dist/ops/commit-traversal.d.ts.map +0 -1
  207. package/dist/ops/commit-traversal.js +0 -821
  208. package/dist/ops/commit-traversal.js.map +0 -1
  209. package/dist/ops/commit.d.ts +0 -555
  210. package/dist/ops/commit.d.ts.map +0 -1
  211. package/dist/ops/commit.js +0 -826
  212. package/dist/ops/commit.js.map +0 -1
  213. package/dist/ops/merge-base.d.ts +0 -397
  214. package/dist/ops/merge-base.d.ts.map +0 -1
  215. package/dist/ops/merge-base.js +0 -691
  216. package/dist/ops/merge-base.js.map +0 -1
  217. package/dist/ops/merge.d.ts +0 -855
  218. package/dist/ops/merge.d.ts.map +0 -1
  219. package/dist/ops/merge.js +0 -1551
  220. package/dist/ops/merge.js.map +0 -1
  221. package/dist/ops/tag.d.ts +0 -247
  222. package/dist/ops/tag.d.ts.map +0 -1
  223. package/dist/ops/tag.js +0 -649
  224. package/dist/ops/tag.js.map +0 -1
  225. package/dist/ops/tree-builder.d.ts +0 -178
  226. package/dist/ops/tree-builder.d.ts.map +0 -1
  227. package/dist/ops/tree-builder.js +0 -271
  228. package/dist/ops/tree-builder.js.map +0 -1
  229. package/dist/ops/tree-diff.d.ts +0 -291
  230. package/dist/ops/tree-diff.d.ts.map +0 -1
  231. package/dist/ops/tree-diff.js +0 -705
  232. package/dist/ops/tree-diff.js.map +0 -1
  233. package/dist/pack/delta.d.ts +0 -248
  234. package/dist/pack/delta.d.ts.map +0 -1
  235. package/dist/pack/delta.js +0 -740
  236. package/dist/pack/delta.js.map +0 -1
  237. package/dist/pack/format.d.ts +0 -446
  238. package/dist/pack/format.d.ts.map +0 -1
  239. package/dist/pack/format.js +0 -572
  240. package/dist/pack/format.js.map +0 -1
  241. package/dist/pack/full-generation.d.ts +0 -612
  242. package/dist/pack/full-generation.d.ts.map +0 -1
  243. package/dist/pack/full-generation.js +0 -1378
  244. package/dist/pack/full-generation.js.map +0 -1
  245. package/dist/pack/generation.d.ts +0 -441
  246. package/dist/pack/generation.d.ts.map +0 -1
  247. package/dist/pack/generation.js +0 -707
  248. package/dist/pack/generation.js.map +0 -1
  249. package/dist/pack/index.d.ts +0 -502
  250. package/dist/pack/index.d.ts.map +0 -1
  251. package/dist/pack/index.js +0 -833
  252. package/dist/pack/index.js.map +0 -1
  253. package/dist/refs/branch.d.ts +0 -683
  254. package/dist/refs/branch.d.ts.map +0 -1
  255. package/dist/refs/branch.js +0 -881
  256. package/dist/refs/branch.js.map +0 -1
  257. package/dist/refs/storage.d.ts +0 -833
  258. package/dist/refs/storage.d.ts.map +0 -1
  259. package/dist/refs/storage.js +0 -1023
  260. package/dist/refs/storage.js.map +0 -1
  261. package/dist/refs/tag.d.ts +0 -860
  262. package/dist/refs/tag.d.ts.map +0 -1
  263. package/dist/refs/tag.js +0 -996
  264. package/dist/refs/tag.js.map +0 -1
  265. package/dist/storage/backend.d.ts +0 -425
  266. package/dist/storage/backend.d.ts.map +0 -1
  267. package/dist/storage/backend.js +0 -41
  268. package/dist/storage/backend.js.map +0 -1
  269. package/dist/storage/fsx-adapter.d.ts +0 -204
  270. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  271. package/dist/storage/fsx-adapter.js +0 -518
  272. package/dist/storage/fsx-adapter.js.map +0 -1
  273. package/dist/storage/lru-cache.d.ts +0 -691
  274. package/dist/storage/lru-cache.d.ts.map +0 -1
  275. package/dist/storage/lru-cache.js +0 -813
  276. package/dist/storage/lru-cache.js.map +0 -1
  277. package/dist/storage/object-index.d.ts +0 -585
  278. package/dist/storage/object-index.d.ts.map +0 -1
  279. package/dist/storage/object-index.js +0 -532
  280. package/dist/storage/object-index.js.map +0 -1
  281. package/dist/storage/r2-pack.d.ts +0 -1257
  282. package/dist/storage/r2-pack.d.ts.map +0 -1
  283. package/dist/storage/r2-pack.js +0 -1773
  284. package/dist/storage/r2-pack.js.map +0 -1
  285. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  286. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  287. package/dist/tiered/cdc-pipeline.js +0 -1880
  288. package/dist/tiered/cdc-pipeline.js.map +0 -1
  289. package/dist/tiered/migration.d.ts +0 -1104
  290. package/dist/tiered/migration.d.ts.map +0 -1
  291. package/dist/tiered/migration.js +0 -1217
  292. package/dist/tiered/migration.js.map +0 -1
  293. package/dist/tiered/parquet-writer.d.ts +0 -1145
  294. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  295. package/dist/tiered/parquet-writer.js +0 -1183
  296. package/dist/tiered/parquet-writer.js.map +0 -1
  297. package/dist/tiered/read-path.d.ts +0 -835
  298. package/dist/tiered/read-path.d.ts.map +0 -1
  299. package/dist/tiered/read-path.js +0 -487
  300. package/dist/tiered/read-path.js.map +0 -1
  301. package/dist/types/capability.d.ts +0 -1385
  302. package/dist/types/capability.d.ts.map +0 -1
  303. package/dist/types/capability.js +0 -36
  304. package/dist/types/capability.js.map +0 -1
  305. package/dist/types/index.d.ts +0 -13
  306. package/dist/types/index.d.ts.map +0 -1
  307. package/dist/types/index.js +0 -18
  308. package/dist/types/index.js.map +0 -1
  309. package/dist/types/interfaces.d.ts +0 -673
  310. package/dist/types/interfaces.d.ts.map +0 -1
  311. package/dist/types/interfaces.js +0 -26
  312. package/dist/types/interfaces.js.map +0 -1
  313. package/dist/types/objects.d.ts +0 -692
  314. package/dist/types/objects.d.ts.map +0 -1
  315. package/dist/types/objects.js +0 -837
  316. package/dist/types/objects.js.map +0 -1
  317. package/dist/types/storage.d.ts +0 -603
  318. package/dist/types/storage.d.ts.map +0 -1
  319. package/dist/types/storage.js +0 -191
  320. package/dist/types/storage.js.map +0 -1
  321. package/dist/types/worker-loader.d.ts +0 -60
  322. package/dist/types/worker-loader.d.ts.map +0 -1
  323. package/dist/types/worker-loader.js +0 -62
  324. package/dist/types/worker-loader.js.map +0 -1
  325. package/dist/utils/hash.d.ts +0 -198
  326. package/dist/utils/hash.d.ts.map +0 -1
  327. package/dist/utils/hash.js +0 -272
  328. package/dist/utils/hash.js.map +0 -1
  329. package/dist/utils/sha1.d.ts +0 -325
  330. package/dist/utils/sha1.d.ts.map +0 -1
  331. package/dist/utils/sha1.js +0 -635
  332. package/dist/utils/sha1.js.map +0 -1
  333. package/dist/wire/capabilities.d.ts +0 -1044
  334. package/dist/wire/capabilities.d.ts.map +0 -1
  335. package/dist/wire/capabilities.js +0 -941
  336. package/dist/wire/capabilities.js.map +0 -1
  337. package/dist/wire/path-security.d.ts +0 -157
  338. package/dist/wire/path-security.d.ts.map +0 -1
  339. package/dist/wire/path-security.js +0 -307
  340. package/dist/wire/path-security.js.map +0 -1
  341. package/dist/wire/pkt-line.d.ts +0 -345
  342. package/dist/wire/pkt-line.d.ts.map +0 -1
  343. package/dist/wire/pkt-line.js +0 -381
  344. package/dist/wire/pkt-line.js.map +0 -1
  345. package/dist/wire/receive-pack.d.ts +0 -1059
  346. package/dist/wire/receive-pack.d.ts.map +0 -1
  347. package/dist/wire/receive-pack.js +0 -1414
  348. package/dist/wire/receive-pack.js.map +0 -1
  349. package/dist/wire/smart-http.d.ts +0 -799
  350. package/dist/wire/smart-http.d.ts.map +0 -1
  351. package/dist/wire/smart-http.js +0 -945
  352. package/dist/wire/smart-http.js.map +0 -1
  353. package/dist/wire/upload-pack.d.ts +0 -727
  354. package/dist/wire/upload-pack.d.ts.map +0 -1
  355. package/dist/wire/upload-pack.js +0 -1141
  356. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,1044 +0,0 @@
1
- /**
2
- * @fileoverview Git wire protocol capability negotiation
3
- *
4
- * This module implements the capability negotiation mechanism used in Git's wire protocol.
5
- * Capabilities are exchanged during the initial handshake between git client and server
6
- * to determine what features are supported by both sides, enabling backward compatibility
7
- * and feature detection.
8
- *
9
- * ## Protocol Versions
10
- *
11
- * **Protocol v1:**
12
- * - Capabilities are sent as a space-separated list after the first ref line
13
- * - Format: `<oid> <refname>\0<cap1> <cap2> cap3=value...`
14
- * - The NUL byte (`\0`) separates ref information from capabilities
15
- * - Only the first ref line contains capabilities
16
- *
17
- * **Protocol v2:**
18
- * - Capabilities are advertised line by line in the initial handshake
19
- * - Starts with `version 2` line
20
- * - Each capability on its own line, with optional values after `=`
21
- * - More structured and extensible than v1
22
- *
23
- * ## Common Capabilities
24
- *
25
- * **Fetch operations:**
26
- * - `multi_ack`, `multi_ack_detailed`: Improved negotiation
27
- * - `thin-pack`: Send thin packs requiring client to resolve deltas
28
- * - `side-band`, `side-band-64k`: Multiplexed data channels
29
- * - `ofs-delta`: Use offset-based delta encoding
30
- * - `shallow`: Support shallow clone operations
31
- *
32
- * **Push operations:**
33
- * - `report-status`, `report-status-v2`: Push result reporting
34
- * - `atomic`: All-or-nothing ref updates
35
- * - `delete-refs`: Allow ref deletion
36
- * - `push-options`: Support push options
37
- *
38
- * ## Usage Example
39
- *
40
- * ```typescript
41
- * import {
42
- * parseCapabilityString,
43
- * findCommonCapabilities,
44
- * buildCapabilityString,
45
- * DEFAULT_FETCH_CAPABILITIES_V1
46
- * } from './capabilities';
47
- *
48
- * // Parse capabilities from server advertisement
49
- * const serverCaps = parseCapabilityString('abc123... refs/heads/main\0multi_ack side-band-64k');
50
- *
51
- * // Find common capabilities
52
- * const clientCaps = DEFAULT_FETCH_CAPABILITIES_V1.map(name => ({ name }));
53
- * const common = findCommonCapabilities(clientCaps, serverCaps);
54
- *
55
- * // Build capability string for request
56
- * const capString = buildCapabilityString([
57
- * { name: 'multi_ack' },
58
- * { name: 'agent', value: 'gitdo/1.0' }
59
- * ]);
60
- * ```
61
- *
62
- * @module wire/capabilities
63
- * @see {@link https://git-scm.com/docs/protocol-capabilities} - Protocol capabilities reference
64
- * @see {@link https://git-scm.com/docs/protocol-v2} - Protocol v2 specification
65
- */
66
- /**
67
- * Git wire protocol version.
68
- *
69
- * @description
70
- * Represents the Git wire protocol version used for communication.
71
- * Version 1 is the traditional protocol, while version 2 offers improved
72
- * capability negotiation and command structure.
73
- *
74
- * @example
75
- * ```typescript
76
- * const version: ProtocolVersion = 2;
77
- *
78
- * if (version === 2) {
79
- * // Use v2 command-based protocol
80
- * } else {
81
- * // Use v1 ref advertisement protocol
82
- * }
83
- * ```
84
- */
85
- export type ProtocolVersion = 1 | 2;
86
- /**
87
- * Standard protocol v1 capabilities.
88
- *
89
- * @description
90
- * Union type of all standard capability names supported in Git protocol v1.
91
- * These capabilities control various aspects of fetch and push operations.
92
- *
93
- * **Negotiation capabilities:**
94
- * - `multi_ack`: Multiple acknowledgment during negotiation
95
- * - `multi_ack_detailed`: Extended ack with common/ready/continue states
96
- *
97
- * **Pack transfer capabilities:**
98
- * - `thin-pack`: Allow thin packs requiring delta base reconstruction
99
- * - `side-band`, `side-band-64k`: Multiplexed data/progress/error channels
100
- * - `ofs-delta`: Use offset-based delta references (more efficient)
101
- * - `include-tag`: Include tags that point to requested objects
102
- *
103
- * **Shallow clone capabilities:**
104
- * - `shallow`: Basic shallow clone support
105
- * - `deepen-since`: Shallow by date
106
- * - `deepen-not`: Shallow excluding specific refs
107
- * - `deepen-relative`: Deepen relative to current shallow boundary
108
- *
109
- * **Push capabilities:**
110
- * - `report-status`, `report-status-v2`: Detailed push result reporting
111
- * - `delete-refs`: Allow ref deletion via push
112
- * - `atomic`: Atomic ref updates (all-or-nothing)
113
- * - `push-options`: Support for push options
114
- * - `push-cert`: Push certificate for signed pushes
115
- * - `quiet`: Suppress progress output
116
- *
117
- * **Other capabilities:**
118
- * - `no-progress`: Client doesn't want progress messages
119
- * - `allow-tip-sha1-in-want`: Allow fetching by SHA-1 at ref tips
120
- * - `allow-reachable-sha1-in-want`: Allow fetching any reachable SHA-1
121
- * - `filter`: Partial clone filtering support
122
- * - `agent`: Client/server identification
123
- * - `symref`: Symbolic ref information (e.g., HEAD -> refs/heads/main)
124
- * - `object-format`: Hash algorithm (sha1 or sha256)
125
- *
126
- * @example
127
- * ```typescript
128
- * const caps: CapabilityV1[] = ['multi_ack_detailed', 'side-band-64k', 'thin-pack'];
129
- *
130
- * const entries: CapabilityEntry[] = caps.map(name => ({ name }));
131
- * ```
132
- */
133
- export type CapabilityV1 = 'multi_ack' | 'multi_ack_detailed' | 'thin-pack' | 'side-band' | 'side-band-64k' | 'ofs-delta' | 'shallow' | 'deepen-since' | 'deepen-not' | 'deepen-relative' | 'no-progress' | 'include-tag' | 'report-status' | 'report-status-v2' | 'delete-refs' | 'quiet' | 'atomic' | 'push-options' | 'allow-tip-sha1-in-want' | 'allow-reachable-sha1-in-want' | 'push-cert' | 'filter' | 'agent' | 'symref' | 'object-format';
134
- /**
135
- * Protocol v2 capabilities/commands.
136
- *
137
- * @description
138
- * Union type of capabilities and commands available in Git protocol v2.
139
- * Protocol v2 uses a command-based model where capabilities are more
140
- * like available services.
141
- *
142
- * **Commands:**
143
- * - `ls-refs`: List refs (replaces ref advertisement)
144
- * - `fetch`: Fetch objects (replaces upload-pack negotiation)
145
- * - `object-info`: Query object information without fetching
146
- * - `bundle-uri`: Bundle URI advertisement
147
- *
148
- * **Other capabilities:**
149
- * - `agent`: Client/server identification
150
- * - `server-option`: Support for server-specific options
151
- * - `object-format`: Hash algorithm (sha1 or sha256)
152
- * - `session-id`: Session tracking for debugging
153
- * - `wait-for-done`: Wait for client "done" before sending pack
154
- *
155
- * @example
156
- * ```typescript
157
- * const v2Caps: CapabilityV2[] = ['ls-refs', 'fetch', 'agent'];
158
- * ```
159
- */
160
- export type CapabilityV2 = 'agent' | 'ls-refs' | 'fetch' | 'server-option' | 'object-format' | 'session-id' | 'wait-for-done' | 'object-info' | 'bundle-uri';
161
- /**
162
- * Capability with optional value.
163
- *
164
- * @description
165
- * Represents a single capability entry that may have an associated value.
166
- * Some capabilities are boolean (presence indicates support), while others
167
- * carry values (e.g., `agent=git/2.30.0`, `symref=HEAD:refs/heads/main`).
168
- *
169
- * @example
170
- * ```typescript
171
- * // Boolean capability (no value)
172
- * const multiAck: CapabilityEntry = { name: 'multi_ack' };
173
- *
174
- * // Capability with value
175
- * const agent: CapabilityEntry = { name: 'agent', value: 'gitdo/1.0' };
176
- *
177
- * // Symref capability (multiple values possible)
178
- * const symref: CapabilityEntry = { name: 'symref', value: 'HEAD:refs/heads/main' };
179
- * ```
180
- */
181
- export interface CapabilityEntry {
182
- /**
183
- * The capability name (e.g., 'multi_ack', 'agent', 'symref').
184
- * Must not contain spaces, NUL bytes, or newlines.
185
- */
186
- name: string;
187
- /**
188
- * Optional value for the capability.
189
- * Format depends on the capability (e.g., 'git/2.30.0' for agent).
190
- * @default undefined
191
- */
192
- value?: string;
193
- }
194
- /**
195
- * Parsed capability set.
196
- *
197
- * @description
198
- * A collection of capabilities parsed from a protocol exchange,
199
- * along with the protocol version. Provides efficient lookup
200
- * via a Map structure.
201
- *
202
- * @example
203
- * ```typescript
204
- * const capSet: CapabilitySet = {
205
- * version: 1,
206
- * capabilities: new Map([
207
- * ['multi_ack', undefined],
208
- * ['side-band-64k', undefined],
209
- * ['agent', 'git/2.30.0'],
210
- * ['symref', 'HEAD:refs/heads/main']
211
- * ])
212
- * };
213
- *
214
- * // Check if capability exists
215
- * if (capSet.capabilities.has('multi_ack')) {
216
- * console.log('Server supports multi_ack');
217
- * }
218
- *
219
- * // Get capability value
220
- * const agent = capSet.capabilities.get('agent');
221
- * ```
222
- */
223
- export interface CapabilitySet {
224
- /**
225
- * Protocol version being used (1 or 2).
226
- */
227
- version: ProtocolVersion;
228
- /**
229
- * Map of capability name to optional value.
230
- * The key is the capability name, value is the capability value or undefined.
231
- */
232
- capabilities: Map<string, string | undefined>;
233
- }
234
- /**
235
- * Ref advertisement with capabilities (protocol v1).
236
- *
237
- * @description
238
- * Represents a single ref line from the server's ref advertisement.
239
- * The first ref line includes capabilities after a NUL byte separator.
240
- *
241
- * @example
242
- * ```typescript
243
- * // First ref (with capabilities)
244
- * const firstRef: RefAdvertisement = {
245
- * oid: 'abc123def456...',
246
- * name: 'refs/heads/main',
247
- * capabilities: {
248
- * version: 1,
249
- * capabilities: new Map([['multi_ack', undefined]])
250
- * }
251
- * };
252
- *
253
- * // Subsequent ref (no capabilities)
254
- * const otherRef: RefAdvertisement = {
255
- * oid: 'def789abc012...',
256
- * name: 'refs/heads/feature'
257
- * };
258
- * ```
259
- */
260
- export interface RefAdvertisement {
261
- /**
262
- * The SHA-1 hash of the ref's target object.
263
- * 40 hexadecimal characters for SHA-1.
264
- */
265
- oid: string;
266
- /**
267
- * The full ref name (e.g., 'refs/heads/main', 'refs/tags/v1.0').
268
- */
269
- name: string;
270
- /**
271
- * Capabilities advertised by the server.
272
- * Only present on the first ref line in protocol v1.
273
- * @default undefined
274
- */
275
- capabilities?: CapabilitySet;
276
- }
277
- /**
278
- * Protocol v2 server capabilities response.
279
- *
280
- * @description
281
- * Parsed server capability advertisement for protocol v2.
282
- * Unlike v1, protocol v2 separates commands (services) from
283
- * general capabilities and provides structured sub-capability values.
284
- *
285
- * @example
286
- * ```typescript
287
- * const serverCaps: ServerCapabilitiesV2 = {
288
- * version: 2,
289
- * commands: ['ls-refs', 'fetch', 'server-option'],
290
- * agent: 'git/2.40.0',
291
- * objectFormat: 'sha1',
292
- * capabilities: new Map([
293
- * ['fetch', 'shallow filter'],
294
- * ['ls-refs', 'symrefs peel']
295
- * ])
296
- * };
297
- *
298
- * if (serverCaps.commands.includes('fetch')) {
299
- * console.log('Server supports fetch command');
300
- * }
301
- * ```
302
- */
303
- export interface ServerCapabilitiesV2 {
304
- /**
305
- * Protocol version, always 2 for this interface.
306
- */
307
- version: 2;
308
- /**
309
- * List of supported commands/services.
310
- * Common commands: 'ls-refs', 'fetch', 'server-option'.
311
- */
312
- commands: string[];
313
- /**
314
- * Agent identification string (e.g., 'git/2.40.0').
315
- * @default undefined
316
- */
317
- agent?: string;
318
- /**
319
- * Object hash format used by the repository.
320
- * @default undefined (implies 'sha1')
321
- */
322
- objectFormat?: 'sha1' | 'sha256';
323
- /**
324
- * Map of capability names to values.
325
- * Commands may have sub-capabilities as values (e.g., 'fetch' -> 'shallow filter').
326
- */
327
- capabilities: Map<string, string | undefined>;
328
- }
329
- /**
330
- * Want line with capabilities for fetch request.
331
- *
332
- * @description
333
- * Represents a client's fetch request specifying which objects are wanted
334
- * and what capabilities the client supports. Capabilities are only sent
335
- * with the first want line.
336
- *
337
- * @example
338
- * ```typescript
339
- * const request: WantRequest = {
340
- * wants: [
341
- * 'abc123def456789012345678901234567890abcd',
342
- * 'def456789012345678901234567890abcdef12'
343
- * ],
344
- * capabilities: [
345
- * { name: 'multi_ack_detailed' },
346
- * { name: 'side-band-64k' },
347
- * { name: 'agent', value: 'gitdo/1.0' }
348
- * ]
349
- * };
350
- *
351
- * const lines = buildFetchRequest(request);
352
- * // First line: "want abc123... multi_ack_detailed side-band-64k agent=gitdo/1.0\n"
353
- * // Second line: "want def456...\n"
354
- * ```
355
- */
356
- export interface WantRequest {
357
- /**
358
- * SHA-1 hashes of objects the client wants to receive.
359
- * These are typically commit objects at ref tips.
360
- */
361
- wants: string[];
362
- /**
363
- * Capabilities to advertise to the server.
364
- * Sent only with the first want line.
365
- */
366
- capabilities: CapabilityEntry[];
367
- }
368
- /**
369
- * Have line for negotiation.
370
- *
371
- * @description
372
- * Represents objects the client already has, used during negotiation
373
- * to determine the minimal set of objects to send.
374
- *
375
- * @example
376
- * ```typescript
377
- * const haves: HaveRequest = {
378
- * haves: [
379
- * 'abc123def456789012345678901234567890abcd',
380
- * 'def456789012345678901234567890abcdef12'
381
- * ],
382
- * done: true
383
- * };
384
- * ```
385
- */
386
- export interface HaveRequest {
387
- /**
388
- * SHA-1 hashes of objects the client already has.
389
- * Used to find common ancestors and minimize data transfer.
390
- */
391
- haves: string[];
392
- /**
393
- * Whether this is the final batch of have lines.
394
- * When true, indicates the client is ready to receive the packfile.
395
- * @default undefined
396
- */
397
- done?: boolean;
398
- }
399
- /**
400
- * Version negotiation result.
401
- *
402
- * @description
403
- * Result of protocol version negotiation between client and server.
404
- * The agreed version determines the communication format.
405
- *
406
- * @example
407
- * ```typescript
408
- * const result = negotiateVersion('version 2', 2);
409
- * // result.version === 2
410
- * // result.serverSupportsV2 === true
411
- *
412
- * const resultV1 = negotiateVersion('abc123... refs/heads/main\0multi_ack', 2);
413
- * // resultV1.version === 1
414
- * // resultV1.serverSupportsV2 === false
415
- * ```
416
- */
417
- export interface VersionNegotiationResult {
418
- /**
419
- * The protocol version that will be used.
420
- * This is the lower of the client's preference and server's support.
421
- */
422
- version: ProtocolVersion;
423
- /**
424
- * Whether the server advertised protocol v2 support.
425
- */
426
- serverSupportsV2: boolean;
427
- /**
428
- * Capability names supported by both client and server.
429
- */
430
- commonCapabilities: string[];
431
- }
432
- /**
433
- * Default client capabilities for fetch operations (protocol v1).
434
- *
435
- * @description
436
- * A sensible set of capabilities for fetch operations that provides
437
- * good performance while maintaining compatibility. These are commonly
438
- * supported by modern Git servers.
439
- *
440
- * - `multi_ack_detailed`: Efficient negotiation with detailed feedback
441
- * - `side-band-64k`: Large multiplexed data channels for progress/data
442
- * - `thin-pack`: Receive thin packs (smaller transfer size)
443
- * - `ofs-delta`: Efficient delta encoding
444
- * - `agent`: Identify the client
445
- *
446
- * @example
447
- * ```typescript
448
- * const clientCaps = DEFAULT_FETCH_CAPABILITIES_V1.map(name => ({ name }));
449
- * // Add agent value
450
- * clientCaps.find(c => c.name === 'agent')!.value = 'gitdo/1.0';
451
- *
452
- * const selected = selectFetchCapabilities(serverCaps, clientCaps);
453
- * ```
454
- */
455
- export declare const DEFAULT_FETCH_CAPABILITIES_V1: CapabilityV1[];
456
- /**
457
- * Default client capabilities for push operations (protocol v1).
458
- *
459
- * @description
460
- * A sensible set of capabilities for push operations that provides
461
- * detailed feedback and compatibility with modern Git servers.
462
- *
463
- * - `report-status`: Receive detailed push result status
464
- * - `side-band-64k`: Multiplexed channels for status/errors
465
- * - `agent`: Identify the client
466
- * - `quiet`: Suppress unnecessary progress output
467
- *
468
- * @example
469
- * ```typescript
470
- * const pushCaps = DEFAULT_PUSH_CAPABILITIES_V1.map(name => ({ name }));
471
- * pushCaps.find(c => c.name === 'agent')!.value = 'gitdo/1.0';
472
- * ```
473
- */
474
- export declare const DEFAULT_PUSH_CAPABILITIES_V1: CapabilityV1[];
475
- /**
476
- * Minimum required capabilities for basic fetch.
477
- *
478
- * @description
479
- * Capabilities that must be present for fetch to work correctly.
480
- * Currently empty as Git is designed to work with minimal capabilities,
481
- * but this can be populated if specific capabilities become required.
482
- *
483
- * @example
484
- * ```typescript
485
- * const missing = validateRequiredCapabilities(serverCaps, REQUIRED_FETCH_CAPABILITIES);
486
- * if (missing.length > 0) {
487
- * throw new Error(`Server missing required capabilities: ${missing.join(', ')}`);
488
- * }
489
- * ```
490
- */
491
- export declare const REQUIRED_FETCH_CAPABILITIES: CapabilityV1[];
492
- /**
493
- * Parse a capability string from ref advertisement (protocol v1).
494
- *
495
- * @description
496
- * Extracts capabilities from a protocol v1 ref advertisement line.
497
- * The capabilities appear after a NUL byte (`\0`) separator following
498
- * the ref information. This is only present on the first ref line.
499
- *
500
- * Line format: `<oid> <refname>\0<cap1> <cap2> cap3=value...`
501
- *
502
- * @param line - The ref advertisement line containing capabilities
503
- * @returns Parsed capability set with version 1
504
- *
505
- * @throws {Error} If the line doesn't contain a NUL byte separator
506
- *
507
- * @example
508
- * ```typescript
509
- * // Parse from first ref line
510
- * const line = 'abc123def456789012345678901234567890abcd refs/heads/main\0multi_ack side-band-64k agent=git/2.30.0';
511
- * const caps = parseCapabilityString(line);
512
- *
513
- * console.log(caps.version); // 1
514
- * console.log(caps.capabilities.has('multi_ack')); // true
515
- * console.log(caps.capabilities.get('agent')); // 'git/2.30.0'
516
- * ```
517
- */
518
- export declare function parseCapabilityString(line: string): CapabilitySet;
519
- /**
520
- * Parse individual capability entries from a space-separated string.
521
- *
522
- * @description
523
- * Parses a whitespace-separated capability string into individual entries.
524
- * Handles both simple capabilities (`multi_ack`) and capabilities with
525
- * values (`agent=git/2.30.0`).
526
- *
527
- * @param capString - Space-separated capability string
528
- * @returns Array of capability entries
529
- *
530
- * @example
531
- * ```typescript
532
- * // Simple capabilities
533
- * const caps1 = parseCapabilities('multi_ack thin-pack ofs-delta');
534
- * // [{ name: 'multi_ack' }, { name: 'thin-pack' }, { name: 'ofs-delta' }]
535
- *
536
- * // Capabilities with values
537
- * const caps2 = parseCapabilities('agent=git/2.30.0 symref=HEAD:refs/heads/main');
538
- * // [{ name: 'agent', value: 'git/2.30.0' }, { name: 'symref', value: 'HEAD:refs/heads/main' }]
539
- *
540
- * // Empty string
541
- * const caps3 = parseCapabilities('');
542
- * // []
543
- * ```
544
- */
545
- export declare function parseCapabilities(capString: string): CapabilityEntry[];
546
- /**
547
- * Parse a ref advertisement line (protocol v1).
548
- *
549
- * @description
550
- * Parses a single line from the server's ref advertisement. The first
551
- * line has a special format including capabilities after a NUL byte,
552
- * while subsequent lines contain only the OID and ref name.
553
- *
554
- * First line format: `<oid> <refname>\0<capabilities>`
555
- * Subsequent lines: `<oid> <refname>`
556
- *
557
- * @param line - The pkt-line data (without length prefix)
558
- * @param isFirst - Whether this is the first line (contains capabilities)
559
- * @returns Parsed ref advertisement
560
- *
561
- * @throws {Error} If the first line is missing the NUL byte
562
- * @throws {Error} If the line is missing the space between OID and refname
563
- * @throws {Error} If the OID is not 40 characters (SHA-1)
564
- *
565
- * @example
566
- * ```typescript
567
- * // Parse first line (with capabilities)
568
- * const firstLine = 'abc123def456789012345678901234567890abcd refs/heads/main\0multi_ack side-band-64k\n';
569
- * const firstRef = parseRefAdvertisement(firstLine, true);
570
- * // {
571
- * // oid: 'abc123def456789012345678901234567890abcd',
572
- * // name: 'refs/heads/main',
573
- * // capabilities: { version: 1, capabilities: Map {...} }
574
- * // }
575
- *
576
- * // Parse subsequent line (no capabilities)
577
- * const otherLine = 'def456789012345678901234567890abcdef12 refs/heads/feature\n';
578
- * const otherRef = parseRefAdvertisement(otherLine, false);
579
- * // {
580
- * // oid: 'def456789012345678901234567890abcdef12',
581
- * // name: 'refs/heads/feature'
582
- * // }
583
- * ```
584
- */
585
- export declare function parseRefAdvertisement(line: string, isFirst: boolean): RefAdvertisement;
586
- /**
587
- * Parse protocol v2 capability advertisement.
588
- *
589
- * @description
590
- * Parses the server's capability advertisement in protocol v2 format.
591
- * Protocol v2 uses a line-by-line format starting with "version 2",
592
- * followed by capability lines. Commands and capabilities are distinguished
593
- * by whether they have values.
594
- *
595
- * Response format:
596
- * ```
597
- * version 2
598
- * agent=git/2.30.0
599
- * ls-refs
600
- * fetch=shallow filter
601
- * server-option
602
- * object-format=sha1
603
- * ```
604
- *
605
- * @param lines - Array of pkt-line data (without length prefixes)
606
- * @returns Parsed server capabilities
607
- *
608
- * @throws {Error} If lines is empty or doesn't start with "version 2"
609
- *
610
- * @example
611
- * ```typescript
612
- * const lines = [
613
- * 'version 2',
614
- * 'agent=git/2.40.0',
615
- * 'ls-refs',
616
- * 'fetch=shallow filter',
617
- * 'server-option',
618
- * 'object-format=sha1'
619
- * ];
620
- *
621
- * const serverCaps = parseServerCapabilitiesV2(lines);
622
- * // {
623
- * // version: 2,
624
- * // commands: ['ls-refs', 'fetch', 'server-option'],
625
- * // agent: 'git/2.40.0',
626
- * // objectFormat: 'sha1',
627
- * // capabilities: Map { 'ls-refs' => undefined, 'fetch' => 'shallow filter', ... }
628
- * // }
629
- *
630
- * if (serverCaps.commands.includes('fetch')) {
631
- * console.log('Server supports fetch with:', serverCaps.capabilities.get('fetch'));
632
- * }
633
- * ```
634
- */
635
- export declare function parseServerCapabilitiesV2(lines: string[]): ServerCapabilitiesV2;
636
- /**
637
- * Build a capability string for want/have request (protocol v1).
638
- *
639
- * @description
640
- * Constructs a space-separated capability string from an array of
641
- * capability entries. Capabilities with values are formatted as
642
- * `name=value`, while those without are just the name.
643
- *
644
- * @param capabilities - Capabilities to include
645
- * @returns Space-separated capability string
646
- *
647
- * @example
648
- * ```typescript
649
- * const caps: CapabilityEntry[] = [
650
- * { name: 'multi_ack_detailed' },
651
- * { name: 'side-band-64k' },
652
- * { name: 'agent', value: 'gitdo/1.0' }
653
- * ];
654
- *
655
- * const str = buildCapabilityString(caps);
656
- * // 'multi_ack_detailed side-band-64k agent=gitdo/1.0'
657
- * ```
658
- */
659
- export declare function buildCapabilityString(capabilities: CapabilityEntry[]): string;
660
- /**
661
- * Build a want line with capabilities (first want only).
662
- *
663
- * @description
664
- * Constructs a want line for a fetch request. The first want line
665
- * includes capabilities, while subsequent want lines contain only
666
- * the object ID.
667
- *
668
- * Format: `want <oid> <capabilities>\n` (first line)
669
- * Format: `want <oid>\n` (subsequent lines)
670
- *
671
- * @param oid - The object ID to want (40-character SHA-1 hex string)
672
- * @param capabilities - Capabilities to include (optional, first want only)
673
- * @returns Formatted want line with trailing newline
674
- *
675
- * @example
676
- * ```typescript
677
- * // First want line with capabilities
678
- * const firstWant = buildWantLine(
679
- * 'abc123def456789012345678901234567890abcd',
680
- * [{ name: 'multi_ack' }, { name: 'agent', value: 'gitdo/1.0' }]
681
- * );
682
- * // 'want abc123def456789012345678901234567890abcd multi_ack agent=gitdo/1.0\n'
683
- *
684
- * // Subsequent want line (no capabilities)
685
- * const nextWant = buildWantLine('def456789012345678901234567890abcdef12');
686
- * // 'want def456789012345678901234567890abcdef12\n'
687
- * ```
688
- */
689
- export declare function buildWantLine(oid: string, capabilities?: CapabilityEntry[]): string;
690
- /**
691
- * Build a have line for negotiation.
692
- *
693
- * @description
694
- * Constructs a have line used during fetch negotiation. Have lines
695
- * inform the server what objects the client already has, allowing
696
- * the server to determine the minimal set of objects to send.
697
- *
698
- * Format: `have <oid>\n`
699
- *
700
- * @param oid - The object ID we have (40-character SHA-1 hex string)
701
- * @returns Formatted have line with trailing newline
702
- *
703
- * @example
704
- * ```typescript
705
- * const haveLine = buildHaveLine('abc123def456789012345678901234567890abcd');
706
- * // 'have abc123def456789012345678901234567890abcd\n'
707
- *
708
- * // OID is normalized to lowercase
709
- * const normalized = buildHaveLine('ABC123DEF456789012345678901234567890ABCD');
710
- * // 'have abc123def456789012345678901234567890abcd\n'
711
- * ```
712
- */
713
- export declare function buildHaveLine(oid: string): string;
714
- /**
715
- * Build a complete want/have request.
716
- *
717
- * @description
718
- * Constructs all want lines for a fetch request. The first want line
719
- * includes the client's capabilities, while subsequent want lines
720
- * contain only the object IDs.
721
- *
722
- * @param request - The want request containing object IDs and capabilities
723
- * @returns Array of formatted want lines (ready for pkt-line encoding)
724
- *
725
- * @example
726
- * ```typescript
727
- * const request: WantRequest = {
728
- * wants: [
729
- * 'abc123def456789012345678901234567890abcd',
730
- * 'def456789012345678901234567890abcdef12',
731
- * '123456789012345678901234567890abcdef00'
732
- * ],
733
- * capabilities: [
734
- * { name: 'multi_ack_detailed' },
735
- * { name: 'side-band-64k' }
736
- * ]
737
- * };
738
- *
739
- * const lines = buildFetchRequest(request);
740
- * // [
741
- * // 'want abc123... multi_ack_detailed side-band-64k\n',
742
- * // 'want def456...\n',
743
- * // 'want 123456...\n'
744
- * // ]
745
- * ```
746
- */
747
- export declare function buildFetchRequest(request: WantRequest): string[];
748
- /**
749
- * Build protocol v2 command request.
750
- *
751
- * @description
752
- * Constructs a protocol v2 command request. Protocol v2 uses a structured
753
- * format with command specification, capabilities, and optional arguments.
754
- *
755
- * Request format:
756
- * ```
757
- * command=<cmd>
758
- * capability1
759
- * capability2=value
760
- * 0001 (delimiter - added by caller)
761
- * <command-specific args>
762
- * 0000 (flush - added by caller)
763
- * ```
764
- *
765
- * @param command - The v2 command (e.g., 'fetch', 'ls-refs')
766
- * @param capabilities - Client capabilities to advertise
767
- * @param args - Command-specific arguments (optional)
768
- * @returns Array of lines (ready for pkt-line encoding)
769
- *
770
- * @example
771
- * ```typescript
772
- * // ls-refs request
773
- * const lsRefsLines = buildV2CommandRequest(
774
- * 'ls-refs',
775
- * [{ name: 'agent', value: 'gitdo/1.0' }],
776
- * ['peel', 'symrefs', 'ref-prefix refs/heads/']
777
- * );
778
- * // [
779
- * // 'command=ls-refs',
780
- * // 'agent=gitdo/1.0',
781
- * // 'peel',
782
- * // 'symrefs',
783
- * // 'ref-prefix refs/heads/'
784
- * // ]
785
- *
786
- * // fetch request
787
- * const fetchLines = buildV2CommandRequest(
788
- * 'fetch',
789
- * [{ name: 'agent', value: 'gitdo/1.0' }, { name: 'thin-pack' }],
790
- * ['want abc123...', 'have def456...', 'done']
791
- * );
792
- * ```
793
- */
794
- export declare function buildV2CommandRequest(command: string, capabilities: CapabilityEntry[], args?: string[]): string[];
795
- /**
796
- * Negotiate protocol version with server.
797
- *
798
- * @description
799
- * Determines the protocol version to use based on the server's advertisement
800
- * and the client's preference. The negotiated version is the highest version
801
- * supported by both parties.
802
- *
803
- * @param serverAdvertisement - First line from server's response
804
- * @param preferredVersion - Client's preferred protocol version (default: 2)
805
- * @returns Negotiation result with agreed version
806
- *
807
- * @example
808
- * ```typescript
809
- * // Server supports v2, client prefers v2
810
- * const v2Result = negotiateVersion('version 2', 2);
811
- * // { version: 2, serverSupportsV2: true, commonCapabilities: [] }
812
- *
813
- * // Server is v1 only, client prefers v2
814
- * const v1Result = negotiateVersion('abc123... refs/heads/main\0multi_ack', 2);
815
- * // { version: 1, serverSupportsV2: false, commonCapabilities: [] }
816
- *
817
- * // Client explicitly wants v1
818
- * const explicitV1 = negotiateVersion('version 2', 1);
819
- * // { version: 1, serverSupportsV2: true, commonCapabilities: [] }
820
- * ```
821
- */
822
- export declare function negotiateVersion(serverAdvertisement: string, preferredVersion?: ProtocolVersion): VersionNegotiationResult;
823
- /**
824
- * Find common capabilities between client and server.
825
- *
826
- * @description
827
- * Determines which capabilities are supported by both the client and server.
828
- * This is used to select the optimal set of capabilities for the session.
829
- *
830
- * @param clientCaps - Client's supported capabilities
831
- * @param serverCaps - Server's advertised capabilities
832
- * @returns Array of capability names supported by both parties
833
- *
834
- * @example
835
- * ```typescript
836
- * const clientCaps: CapabilityEntry[] = [
837
- * { name: 'multi_ack_detailed' },
838
- * { name: 'side-band-64k' },
839
- * { name: 'thin-pack' },
840
- * { name: 'ofs-delta' }
841
- * ];
842
- *
843
- * const serverCaps: CapabilitySet = {
844
- * version: 1,
845
- * capabilities: new Map([
846
- * ['multi_ack', undefined],
847
- * ['multi_ack_detailed', undefined],
848
- * ['side-band-64k', undefined],
849
- * ['shallow', undefined]
850
- * ])
851
- * };
852
- *
853
- * const common = findCommonCapabilities(clientCaps, serverCaps);
854
- * // ['multi_ack_detailed', 'side-band-64k']
855
- * ```
856
- */
857
- export declare function findCommonCapabilities(clientCaps: CapabilityEntry[], serverCaps: CapabilitySet): string[];
858
- /**
859
- * Check if a specific capability is supported.
860
- *
861
- * @description
862
- * Checks whether a capability is present in the capability set.
863
- * This is a convenience wrapper around Map.has().
864
- *
865
- * @param capSet - The capability set to check
866
- * @param name - The capability name to look for
867
- * @returns True if the capability is present
868
- *
869
- * @example
870
- * ```typescript
871
- * const caps: CapabilitySet = {
872
- * version: 1,
873
- * capabilities: new Map([
874
- * ['multi_ack', undefined],
875
- * ['side-band-64k', undefined],
876
- * ['agent', 'git/2.30.0']
877
- * ])
878
- * };
879
- *
880
- * hasCapability(caps, 'multi_ack'); // true
881
- * hasCapability(caps, 'side-band-64k'); // true
882
- * hasCapability(caps, 'thin-pack'); // false
883
- * ```
884
- */
885
- export declare function hasCapability(capSet: CapabilitySet, name: string): boolean;
886
- /**
887
- * Get the value of a capability (if it has one).
888
- *
889
- * @description
890
- * Retrieves the value associated with a capability. Returns undefined
891
- * if the capability is not present or has no value.
892
- *
893
- * @param capSet - The capability set to query
894
- * @param name - The capability name
895
- * @returns The capability value, or undefined if not present/no value
896
- *
897
- * @example
898
- * ```typescript
899
- * const caps: CapabilitySet = {
900
- * version: 1,
901
- * capabilities: new Map([
902
- * ['multi_ack', undefined],
903
- * ['agent', 'git/2.30.0'],
904
- * ['symref', 'HEAD:refs/heads/main']
905
- * ])
906
- * };
907
- *
908
- * getCapabilityValue(caps, 'agent'); // 'git/2.30.0'
909
- * getCapabilityValue(caps, 'symref'); // 'HEAD:refs/heads/main'
910
- * getCapabilityValue(caps, 'multi_ack'); // undefined (present but no value)
911
- * getCapabilityValue(caps, 'thin-pack'); // undefined (not present)
912
- * ```
913
- */
914
- export declare function getCapabilityValue(capSet: CapabilitySet, name: string): string | undefined;
915
- /**
916
- * Create a capability set from entries.
917
- *
918
- * @description
919
- * Constructs a CapabilitySet from an array of capability entries.
920
- * This is useful for creating capability sets programmatically.
921
- *
922
- * @param version - Protocol version (1 or 2)
923
- * @param entries - Array of capability entries
924
- * @returns A new CapabilitySet
925
- *
926
- * @example
927
- * ```typescript
928
- * const entries: CapabilityEntry[] = [
929
- * { name: 'multi_ack_detailed' },
930
- * { name: 'side-band-64k' },
931
- * { name: 'agent', value: 'gitdo/1.0' }
932
- * ];
933
- *
934
- * const capSet = createCapabilitySet(1, entries);
935
- * // {
936
- * // version: 1,
937
- * // capabilities: Map {
938
- * // 'multi_ack_detailed' => undefined,
939
- * // 'side-band-64k' => undefined,
940
- * // 'agent' => 'gitdo/1.0'
941
- * // }
942
- * // }
943
- * ```
944
- */
945
- export declare function createCapabilitySet(version: ProtocolVersion, entries: CapabilityEntry[]): CapabilitySet;
946
- /**
947
- * Select optimal capabilities for a fetch operation.
948
- *
949
- * @description
950
- * Filters client-preferred capabilities to only those supported by the server.
951
- * The client's values are preserved (not the server's), maintaining client
952
- * identification and preferences.
953
- *
954
- * @param serverCaps - Server's advertised capabilities
955
- * @param clientPrefs - Client's preferred capabilities (in priority order)
956
- * @returns Array of capabilities to use (subset of client preferences)
957
- *
958
- * @example
959
- * ```typescript
960
- * const serverCaps: CapabilitySet = {
961
- * version: 1,
962
- * capabilities: new Map([
963
- * ['multi_ack', undefined],
964
- * ['side-band-64k', undefined],
965
- * ['thin-pack', undefined]
966
- * ])
967
- * };
968
- *
969
- * const clientPrefs: CapabilityEntry[] = [
970
- * { name: 'multi_ack_detailed' }, // Not supported by server
971
- * { name: 'multi_ack' }, // Supported
972
- * { name: 'side-band-64k' }, // Supported
973
- * { name: 'ofs-delta' }, // Not supported
974
- * { name: 'agent', value: 'gitdo/1.0' } // Not in server caps
975
- * ];
976
- *
977
- * const selected = selectFetchCapabilities(serverCaps, clientPrefs);
978
- * // [
979
- * // { name: 'multi_ack' },
980
- * // { name: 'side-band-64k' }
981
- * // ]
982
- * ```
983
- */
984
- export declare function selectFetchCapabilities(serverCaps: CapabilitySet, clientPrefs: CapabilityEntry[]): CapabilityEntry[];
985
- /**
986
- * Validate that a capability name is well-formed.
987
- *
988
- * @description
989
- * Checks that a capability name follows the Git protocol requirements.
990
- * Capability names must be non-empty and cannot contain spaces, NUL bytes,
991
- * or newline characters.
992
- *
993
- * @param name - The capability name to validate
994
- * @returns True if the name is valid
995
- *
996
- * @example
997
- * ```typescript
998
- * isValidCapabilityName('multi_ack'); // true
999
- * isValidCapabilityName('side-band-64k'); // true
1000
- * isValidCapabilityName('agent'); // true
1001
- * isValidCapabilityName(''); // false (empty)
1002
- * isValidCapabilityName('multi ack'); // false (contains space)
1003
- * isValidCapabilityName('cap\0name'); // false (contains NUL)
1004
- * isValidCapabilityName('cap\nname'); // false (contains newline)
1005
- * ```
1006
- */
1007
- export declare function isValidCapabilityName(name: string): boolean;
1008
- /**
1009
- * Validate that required capabilities are present.
1010
- *
1011
- * @description
1012
- * Checks a capability set for the presence of all required capabilities.
1013
- * Returns an array of missing capability names. An empty array indicates
1014
- * all requirements are satisfied.
1015
- *
1016
- * @param capSet - The capability set to validate
1017
- * @param required - Array of required capability names
1018
- * @returns Array of missing capability names (empty if all present)
1019
- *
1020
- * @example
1021
- * ```typescript
1022
- * const caps: CapabilitySet = {
1023
- * version: 1,
1024
- * capabilities: new Map([
1025
- * ['multi_ack', undefined],
1026
- * ['side-band-64k', undefined]
1027
- * ])
1028
- * };
1029
- *
1030
- * // All present
1031
- * const missing1 = validateRequiredCapabilities(caps, ['multi_ack']);
1032
- * // []
1033
- *
1034
- * // Some missing
1035
- * const missing2 = validateRequiredCapabilities(caps, ['multi_ack', 'thin-pack', 'ofs-delta']);
1036
- * // ['thin-pack', 'ofs-delta']
1037
- *
1038
- * if (missing2.length > 0) {
1039
- * throw new Error(`Server missing capabilities: ${missing2.join(', ')}`);
1040
- * }
1041
- * ```
1042
- */
1043
- export declare function validateRequiredCapabilities(capSet: CapabilitySet, required: string[]): string[];
1044
- //# sourceMappingURL=capabilities.d.ts.map