gitx.do 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/README.md +40 -353
  2. package/dist/do/logger.d.ts +50 -0
  3. package/dist/do/logger.d.ts.map +1 -0
  4. package/dist/do/logger.js +122 -0
  5. package/dist/do/logger.js.map +1 -0
  6. package/dist/{durable-object → do}/schema.d.ts +3 -3
  7. package/dist/do/schema.d.ts.map +1 -0
  8. package/dist/{durable-object → do}/schema.js +4 -3
  9. package/dist/do/schema.js.map +1 -0
  10. package/dist/do/types.d.ts +267 -0
  11. package/dist/do/types.d.ts.map +1 -0
  12. package/dist/do/types.js +62 -0
  13. package/dist/do/types.js.map +1 -0
  14. package/dist/index.d.ts +15 -415
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +31 -483
  17. package/dist/index.js.map +1 -1
  18. package/package.json +13 -21
  19. package/dist/cli/commands/add.d.ts +0 -174
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -131
  22. package/dist/cli/commands/add.js.map +0 -1
  23. package/dist/cli/commands/blame.d.ts +0 -259
  24. package/dist/cli/commands/blame.d.ts.map +0 -1
  25. package/dist/cli/commands/blame.js +0 -609
  26. package/dist/cli/commands/blame.js.map +0 -1
  27. package/dist/cli/commands/branch.d.ts +0 -249
  28. package/dist/cli/commands/branch.d.ts.map +0 -1
  29. package/dist/cli/commands/branch.js +0 -693
  30. package/dist/cli/commands/branch.js.map +0 -1
  31. package/dist/cli/commands/commit.d.ts +0 -182
  32. package/dist/cli/commands/commit.d.ts.map +0 -1
  33. package/dist/cli/commands/commit.js +0 -437
  34. package/dist/cli/commands/commit.js.map +0 -1
  35. package/dist/cli/commands/diff.d.ts +0 -464
  36. package/dist/cli/commands/diff.d.ts.map +0 -1
  37. package/dist/cli/commands/diff.js +0 -958
  38. package/dist/cli/commands/diff.js.map +0 -1
  39. package/dist/cli/commands/log.d.ts +0 -239
  40. package/dist/cli/commands/log.d.ts.map +0 -1
  41. package/dist/cli/commands/log.js +0 -535
  42. package/dist/cli/commands/log.js.map +0 -1
  43. package/dist/cli/commands/merge.d.ts +0 -106
  44. package/dist/cli/commands/merge.d.ts.map +0 -1
  45. package/dist/cli/commands/merge.js +0 -55
  46. package/dist/cli/commands/merge.js.map +0 -1
  47. package/dist/cli/commands/review.d.ts +0 -457
  48. package/dist/cli/commands/review.d.ts.map +0 -1
  49. package/dist/cli/commands/review.js +0 -533
  50. package/dist/cli/commands/review.js.map +0 -1
  51. package/dist/cli/commands/status.d.ts +0 -269
  52. package/dist/cli/commands/status.d.ts.map +0 -1
  53. package/dist/cli/commands/status.js +0 -493
  54. package/dist/cli/commands/status.js.map +0 -1
  55. package/dist/cli/commands/web.d.ts +0 -199
  56. package/dist/cli/commands/web.d.ts.map +0 -1
  57. package/dist/cli/commands/web.js +0 -696
  58. package/dist/cli/commands/web.js.map +0 -1
  59. package/dist/cli/fs-adapter.d.ts +0 -656
  60. package/dist/cli/fs-adapter.d.ts.map +0 -1
  61. package/dist/cli/fs-adapter.js +0 -1179
  62. package/dist/cli/fs-adapter.js.map +0 -1
  63. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  64. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  65. package/dist/cli/fsx-cli-adapter.js +0 -619
  66. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  67. package/dist/cli/index.d.ts +0 -387
  68. package/dist/cli/index.d.ts.map +0 -1
  69. package/dist/cli/index.js +0 -523
  70. package/dist/cli/index.js.map +0 -1
  71. package/dist/cli/ui/components/DiffView.d.ts +0 -7
  72. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  73. package/dist/cli/ui/components/DiffView.js +0 -11
  74. package/dist/cli/ui/components/DiffView.js.map +0 -1
  75. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -6
  76. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  77. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  78. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  79. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -9
  80. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  81. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  82. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  83. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -6
  84. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  85. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  86. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  87. package/dist/cli/ui/components/NavigationList.d.ts +0 -9
  88. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  89. package/dist/cli/ui/components/NavigationList.js +0 -11
  90. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  91. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -8
  92. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  93. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  94. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  95. package/dist/cli/ui/components/index.d.ts +0 -7
  96. package/dist/cli/ui/components/index.d.ts.map +0 -1
  97. package/dist/cli/ui/components/index.js +0 -9
  98. package/dist/cli/ui/components/index.js.map +0 -1
  99. package/dist/cli/ui/terminal-ui.d.ts +0 -52
  100. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  101. package/dist/cli/ui/terminal-ui.js +0 -121
  102. package/dist/cli/ui/terminal-ui.js.map +0 -1
  103. package/dist/do/BashModule.d.ts +0 -871
  104. package/dist/do/BashModule.d.ts.map +0 -1
  105. package/dist/do/BashModule.js +0 -1143
  106. package/dist/do/BashModule.js.map +0 -1
  107. package/dist/do/FsModule.d.ts +0 -601
  108. package/dist/do/FsModule.d.ts.map +0 -1
  109. package/dist/do/FsModule.js +0 -1120
  110. package/dist/do/FsModule.js.map +0 -1
  111. package/dist/do/GitModule.d.ts +0 -635
  112. package/dist/do/GitModule.d.ts.map +0 -1
  113. package/dist/do/GitModule.js +0 -781
  114. package/dist/do/GitModule.js.map +0 -1
  115. package/dist/do/GitRepoDO.d.ts +0 -281
  116. package/dist/do/GitRepoDO.d.ts.map +0 -1
  117. package/dist/do/GitRepoDO.js +0 -479
  118. package/dist/do/GitRepoDO.js.map +0 -1
  119. package/dist/do/bash-ast.d.ts +0 -246
  120. package/dist/do/bash-ast.d.ts.map +0 -1
  121. package/dist/do/bash-ast.js +0 -888
  122. package/dist/do/bash-ast.js.map +0 -1
  123. package/dist/do/container-executor.d.ts +0 -491
  124. package/dist/do/container-executor.d.ts.map +0 -1
  125. package/dist/do/container-executor.js +0 -730
  126. package/dist/do/container-executor.js.map +0 -1
  127. package/dist/do/index.d.ts +0 -53
  128. package/dist/do/index.d.ts.map +0 -1
  129. package/dist/do/index.js +0 -91
  130. package/dist/do/index.js.map +0 -1
  131. package/dist/do/tiered-storage.d.ts +0 -403
  132. package/dist/do/tiered-storage.d.ts.map +0 -1
  133. package/dist/do/tiered-storage.js +0 -689
  134. package/dist/do/tiered-storage.js.map +0 -1
  135. package/dist/do/withBash.d.ts +0 -231
  136. package/dist/do/withBash.d.ts.map +0 -1
  137. package/dist/do/withBash.js +0 -244
  138. package/dist/do/withBash.js.map +0 -1
  139. package/dist/do/withFs.d.ts +0 -237
  140. package/dist/do/withFs.d.ts.map +0 -1
  141. package/dist/do/withFs.js +0 -387
  142. package/dist/do/withFs.js.map +0 -1
  143. package/dist/do/withGit.d.ts +0 -180
  144. package/dist/do/withGit.d.ts.map +0 -1
  145. package/dist/do/withGit.js +0 -271
  146. package/dist/do/withGit.js.map +0 -1
  147. package/dist/durable-object/object-store.d.ts +0 -633
  148. package/dist/durable-object/object-store.d.ts.map +0 -1
  149. package/dist/durable-object/object-store.js +0 -1161
  150. package/dist/durable-object/object-store.js.map +0 -1
  151. package/dist/durable-object/schema.d.ts.map +0 -1
  152. package/dist/durable-object/schema.js.map +0 -1
  153. package/dist/durable-object/wal.d.ts +0 -416
  154. package/dist/durable-object/wal.d.ts.map +0 -1
  155. package/dist/durable-object/wal.js +0 -445
  156. package/dist/durable-object/wal.js.map +0 -1
  157. package/dist/mcp/adapter.d.ts +0 -772
  158. package/dist/mcp/adapter.d.ts.map +0 -1
  159. package/dist/mcp/adapter.js +0 -895
  160. package/dist/mcp/adapter.js.map +0 -1
  161. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  162. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  163. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  164. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  165. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  166. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  167. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  168. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  169. package/dist/mcp/sandbox/template.d.ts +0 -17
  170. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/template.js +0 -71
  172. package/dist/mcp/sandbox/template.js.map +0 -1
  173. package/dist/mcp/sandbox.d.ts +0 -764
  174. package/dist/mcp/sandbox.d.ts.map +0 -1
  175. package/dist/mcp/sandbox.js +0 -1362
  176. package/dist/mcp/sandbox.js.map +0 -1
  177. package/dist/mcp/sdk-adapter.d.ts +0 -835
  178. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  179. package/dist/mcp/sdk-adapter.js +0 -974
  180. package/dist/mcp/sdk-adapter.js.map +0 -1
  181. package/dist/mcp/tools/do.d.ts +0 -32
  182. package/dist/mcp/tools/do.d.ts.map +0 -1
  183. package/dist/mcp/tools/do.js +0 -115
  184. package/dist/mcp/tools/do.js.map +0 -1
  185. package/dist/mcp/tools.d.ts +0 -548
  186. package/dist/mcp/tools.d.ts.map +0 -1
  187. package/dist/mcp/tools.js +0 -1934
  188. package/dist/mcp/tools.js.map +0 -1
  189. package/dist/ops/blame.d.ts +0 -551
  190. package/dist/ops/blame.d.ts.map +0 -1
  191. package/dist/ops/blame.js +0 -1037
  192. package/dist/ops/blame.js.map +0 -1
  193. package/dist/ops/branch.d.ts +0 -766
  194. package/dist/ops/branch.d.ts.map +0 -1
  195. package/dist/ops/branch.js +0 -950
  196. package/dist/ops/branch.js.map +0 -1
  197. package/dist/ops/commit-traversal.d.ts +0 -349
  198. package/dist/ops/commit-traversal.d.ts.map +0 -1
  199. package/dist/ops/commit-traversal.js +0 -821
  200. package/dist/ops/commit-traversal.js.map +0 -1
  201. package/dist/ops/commit.d.ts +0 -555
  202. package/dist/ops/commit.d.ts.map +0 -1
  203. package/dist/ops/commit.js +0 -826
  204. package/dist/ops/commit.js.map +0 -1
  205. package/dist/ops/merge-base.d.ts +0 -397
  206. package/dist/ops/merge-base.d.ts.map +0 -1
  207. package/dist/ops/merge-base.js +0 -691
  208. package/dist/ops/merge-base.js.map +0 -1
  209. package/dist/ops/merge.d.ts +0 -855
  210. package/dist/ops/merge.d.ts.map +0 -1
  211. package/dist/ops/merge.js +0 -1551
  212. package/dist/ops/merge.js.map +0 -1
  213. package/dist/ops/tag.d.ts +0 -247
  214. package/dist/ops/tag.d.ts.map +0 -1
  215. package/dist/ops/tag.js +0 -649
  216. package/dist/ops/tag.js.map +0 -1
  217. package/dist/ops/tree-builder.d.ts +0 -178
  218. package/dist/ops/tree-builder.d.ts.map +0 -1
  219. package/dist/ops/tree-builder.js +0 -271
  220. package/dist/ops/tree-builder.js.map +0 -1
  221. package/dist/ops/tree-diff.d.ts +0 -291
  222. package/dist/ops/tree-diff.d.ts.map +0 -1
  223. package/dist/ops/tree-diff.js +0 -705
  224. package/dist/ops/tree-diff.js.map +0 -1
  225. package/dist/pack/delta.d.ts +0 -248
  226. package/dist/pack/delta.d.ts.map +0 -1
  227. package/dist/pack/delta.js +0 -736
  228. package/dist/pack/delta.js.map +0 -1
  229. package/dist/pack/format.d.ts +0 -446
  230. package/dist/pack/format.d.ts.map +0 -1
  231. package/dist/pack/format.js +0 -572
  232. package/dist/pack/format.js.map +0 -1
  233. package/dist/pack/full-generation.d.ts +0 -612
  234. package/dist/pack/full-generation.d.ts.map +0 -1
  235. package/dist/pack/full-generation.js +0 -1378
  236. package/dist/pack/full-generation.js.map +0 -1
  237. package/dist/pack/generation.d.ts +0 -441
  238. package/dist/pack/generation.d.ts.map +0 -1
  239. package/dist/pack/generation.js +0 -707
  240. package/dist/pack/generation.js.map +0 -1
  241. package/dist/pack/index.d.ts +0 -502
  242. package/dist/pack/index.d.ts.map +0 -1
  243. package/dist/pack/index.js +0 -833
  244. package/dist/pack/index.js.map +0 -1
  245. package/dist/refs/branch.d.ts +0 -668
  246. package/dist/refs/branch.d.ts.map +0 -1
  247. package/dist/refs/branch.js +0 -897
  248. package/dist/refs/branch.js.map +0 -1
  249. package/dist/refs/storage.d.ts +0 -833
  250. package/dist/refs/storage.d.ts.map +0 -1
  251. package/dist/refs/storage.js +0 -1023
  252. package/dist/refs/storage.js.map +0 -1
  253. package/dist/refs/tag.d.ts +0 -860
  254. package/dist/refs/tag.d.ts.map +0 -1
  255. package/dist/refs/tag.js +0 -996
  256. package/dist/refs/tag.js.map +0 -1
  257. package/dist/storage/backend.d.ts +0 -425
  258. package/dist/storage/backend.d.ts.map +0 -1
  259. package/dist/storage/backend.js +0 -41
  260. package/dist/storage/backend.js.map +0 -1
  261. package/dist/storage/fsx-adapter.d.ts +0 -204
  262. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  263. package/dist/storage/fsx-adapter.js +0 -470
  264. package/dist/storage/fsx-adapter.js.map +0 -1
  265. package/dist/storage/lru-cache.d.ts +0 -691
  266. package/dist/storage/lru-cache.d.ts.map +0 -1
  267. package/dist/storage/lru-cache.js +0 -813
  268. package/dist/storage/lru-cache.js.map +0 -1
  269. package/dist/storage/object-index.d.ts +0 -585
  270. package/dist/storage/object-index.d.ts.map +0 -1
  271. package/dist/storage/object-index.js +0 -532
  272. package/dist/storage/object-index.js.map +0 -1
  273. package/dist/storage/r2-pack.d.ts +0 -1257
  274. package/dist/storage/r2-pack.d.ts.map +0 -1
  275. package/dist/storage/r2-pack.js +0 -1770
  276. package/dist/storage/r2-pack.js.map +0 -1
  277. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  278. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  279. package/dist/tiered/cdc-pipeline.js +0 -1880
  280. package/dist/tiered/cdc-pipeline.js.map +0 -1
  281. package/dist/tiered/migration.d.ts +0 -1104
  282. package/dist/tiered/migration.d.ts.map +0 -1
  283. package/dist/tiered/migration.js +0 -1214
  284. package/dist/tiered/migration.js.map +0 -1
  285. package/dist/tiered/parquet-writer.d.ts +0 -1145
  286. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  287. package/dist/tiered/parquet-writer.js +0 -1183
  288. package/dist/tiered/parquet-writer.js.map +0 -1
  289. package/dist/tiered/read-path.d.ts +0 -835
  290. package/dist/tiered/read-path.d.ts.map +0 -1
  291. package/dist/tiered/read-path.js +0 -487
  292. package/dist/tiered/read-path.js.map +0 -1
  293. package/dist/types/capability.d.ts +0 -1385
  294. package/dist/types/capability.d.ts.map +0 -1
  295. package/dist/types/capability.js +0 -36
  296. package/dist/types/capability.js.map +0 -1
  297. package/dist/types/index.d.ts +0 -13
  298. package/dist/types/index.d.ts.map +0 -1
  299. package/dist/types/index.js +0 -18
  300. package/dist/types/index.js.map +0 -1
  301. package/dist/types/objects.d.ts +0 -692
  302. package/dist/types/objects.d.ts.map +0 -1
  303. package/dist/types/objects.js +0 -837
  304. package/dist/types/objects.js.map +0 -1
  305. package/dist/types/storage.d.ts +0 -603
  306. package/dist/types/storage.d.ts.map +0 -1
  307. package/dist/types/storage.js +0 -191
  308. package/dist/types/storage.js.map +0 -1
  309. package/dist/types/worker-loader.d.ts +0 -60
  310. package/dist/types/worker-loader.d.ts.map +0 -1
  311. package/dist/types/worker-loader.js +0 -62
  312. package/dist/types/worker-loader.js.map +0 -1
  313. package/dist/utils/hash.d.ts +0 -197
  314. package/dist/utils/hash.d.ts.map +0 -1
  315. package/dist/utils/hash.js +0 -268
  316. package/dist/utils/hash.js.map +0 -1
  317. package/dist/utils/sha1.d.ts +0 -290
  318. package/dist/utils/sha1.d.ts.map +0 -1
  319. package/dist/utils/sha1.js +0 -582
  320. package/dist/utils/sha1.js.map +0 -1
  321. package/dist/wire/capabilities.d.ts +0 -1044
  322. package/dist/wire/capabilities.d.ts.map +0 -1
  323. package/dist/wire/capabilities.js +0 -941
  324. package/dist/wire/capabilities.js.map +0 -1
  325. package/dist/wire/path-security.d.ts +0 -157
  326. package/dist/wire/path-security.d.ts.map +0 -1
  327. package/dist/wire/path-security.js +0 -307
  328. package/dist/wire/path-security.js.map +0 -1
  329. package/dist/wire/pkt-line.d.ts +0 -345
  330. package/dist/wire/pkt-line.d.ts.map +0 -1
  331. package/dist/wire/pkt-line.js +0 -381
  332. package/dist/wire/pkt-line.js.map +0 -1
  333. package/dist/wire/receive-pack.d.ts +0 -1059
  334. package/dist/wire/receive-pack.d.ts.map +0 -1
  335. package/dist/wire/receive-pack.js +0 -1414
  336. package/dist/wire/receive-pack.js.map +0 -1
  337. package/dist/wire/smart-http.d.ts +0 -799
  338. package/dist/wire/smart-http.d.ts.map +0 -1
  339. package/dist/wire/smart-http.js +0 -945
  340. package/dist/wire/smart-http.js.map +0 -1
  341. package/dist/wire/upload-pack.d.ts +0 -727
  342. package/dist/wire/upload-pack.d.ts.map +0 -1
  343. package/dist/wire/upload-pack.js +0 -1138
  344. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,345 +0,0 @@
1
- /**
2
- * @fileoverview Git pkt-line Protocol Implementation
3
- *
4
- * This module implements the pkt-line format used in Git's wire protocol for
5
- * client-server communication. The pkt-line format provides a simple framing
6
- * mechanism for variable-length data.
7
- *
8
- * @module wire/pkt-line
9
- *
10
- * ## Format Overview
11
- *
12
- * Each packet consists of a 4-byte hex length prefix followed by the data:
13
- * - Length includes the 4-byte prefix itself
14
- * - Maximum packet size is 65520 bytes (65516 data + 4 prefix)
15
- *
16
- * ## Special Packets
17
- *
18
- * - **flush-pkt** (`0000`): Indicates end of a message section
19
- * - **delim-pkt** (`0001`): Delimiter used in protocol v2
20
- *
21
- * @see {@link https://git-scm.com/docs/protocol-common#_pkt_line_format} Git pkt-line Format
22
- *
23
- * @example Basic encoding and decoding
24
- * ```typescript
25
- * import { encodePktLine, decodePktLine, FLUSH_PKT } from './wire/pkt-line'
26
- *
27
- * // Encode a message
28
- * const encoded = encodePktLine('hello\n')
29
- * // Result: '000ahello\n'
30
- *
31
- * // Decode a message
32
- * const decoded = decodePktLine('000ahello\n')
33
- * // Result: { data: 'hello\n', bytesRead: 10 }
34
- *
35
- * // Use flush packet to end a section
36
- * const message = encodePktLine('line1\n') + encodePktLine('line2\n') + FLUSH_PKT
37
- * ```
38
- *
39
- * @example Streaming multiple packets
40
- * ```typescript
41
- * import { pktLineStream } from './wire/pkt-line'
42
- *
43
- * const stream = '0009line1\n0009line2\n0000'
44
- * const { packets, remaining } = pktLineStream(stream)
45
- *
46
- * for (const packet of packets) {
47
- * if (packet.type === 'flush') {
48
- * console.log('End of section')
49
- * } else {
50
- * console.log('Data:', packet.data)
51
- * }
52
- * }
53
- * ```
54
- */
55
- /**
56
- * Flush packet - indicates end of a message section.
57
- *
58
- * @description
59
- * The flush packet is a special 4-byte sequence `0000` that signals
60
- * the end of a logical section in the protocol. It's used to:
61
- * - End ref advertisements
62
- * - Separate negotiation phases
63
- * - Signal end of packfile transmission
64
- *
65
- * @example
66
- * ```typescript
67
- * // Build a complete ref advertisement
68
- * let response = encodePktLine('# service=git-upload-pack\n')
69
- * response += FLUSH_PKT // End service announcement
70
- * response += encodePktLine('abc123 refs/heads/main\n')
71
- * response += FLUSH_PKT // End ref list
72
- * ```
73
- */
74
- export declare const FLUSH_PKT = "0000";
75
- /**
76
- * Delimiter packet - used in protocol v2.
77
- *
78
- * @description
79
- * The delimiter packet `0001` is used in Git protocol v2 to separate
80
- * sections within a single message, such as between command parameters
81
- * and command arguments.
82
- *
83
- * @example
84
- * ```typescript
85
- * // Protocol v2 command format
86
- * let request = encodePktLine('command=fetch')
87
- * request += encodePktLine('agent=git/2.30.0')
88
- * request += DELIM_PKT // Separate metadata from arguments
89
- * request += encodePktLine('want abc123...')
90
- * request += FLUSH_PKT // End of request
91
- * ```
92
- */
93
- export declare const DELIM_PKT = "0001";
94
- /**
95
- * Maximum pkt-line data size in bytes.
96
- *
97
- * @description
98
- * The maximum data that can be included in a single pkt-line is 65516 bytes.
99
- * This is calculated as: 65520 (max packet) - 4 (length prefix) = 65516.
100
- *
101
- * Attempting to encode data larger than this will result in an error
102
- * or require splitting into multiple packets.
103
- */
104
- export declare const MAX_PKT_LINE_DATA = 65516;
105
- /**
106
- * Input type for pkt-line encoding/decoding functions.
107
- *
108
- * @description
109
- * Pkt-line functions accept both string and binary data:
110
- * - `string`: Used for text-based protocol messages
111
- * - `Uint8Array`: Used for binary data like packfiles
112
- */
113
- type PktLineInput = string | Uint8Array;
114
- /**
115
- * Result of decoding a single pkt-line.
116
- *
117
- * @description
118
- * Contains the decoded data and metadata about the packet:
119
- * - For data packets: `data` contains the payload, `bytesRead` is the packet size
120
- * - For flush packets: `data` is null, `type` is 'flush', `bytesRead` is 4
121
- * - For delimiter packets: `data` is null, `type` is 'delim', `bytesRead` is 4
122
- * - For incomplete data: `data` is null, `type` is 'incomplete', `bytesRead` is 0
123
- */
124
- interface DecodedPktLine {
125
- /** The decoded data payload, or null for special/incomplete packets */
126
- data: string | null;
127
- /** Packet type for special packets: 'flush', 'delim', or 'incomplete' */
128
- type?: 'flush' | 'delim' | 'incomplete';
129
- /** Number of bytes consumed from the input */
130
- bytesRead: number;
131
- }
132
- /**
133
- * A single packet in a pkt-line stream.
134
- *
135
- * @description
136
- * Represents one packet parsed from a stream:
137
- * - `data`: Packets with payload have `type: 'data'` and non-null `data`
138
- * - `flush`: Special packet with `type: 'flush'` and null `data`
139
- * - `delim`: Special packet with `type: 'delim'` and null `data`
140
- */
141
- interface StreamPacket {
142
- /** The packet data, or null for special packets */
143
- data: string | null;
144
- /** The packet type */
145
- type: 'data' | 'flush' | 'delim';
146
- }
147
- /**
148
- * Result of parsing a pkt-line stream.
149
- *
150
- * @description
151
- * Contains all successfully parsed packets and any remaining unparsed data.
152
- * The `remaining` field is useful for streaming scenarios where data arrives
153
- * in chunks and a packet might be split across chunks.
154
- */
155
- interface PktLineStreamResult {
156
- /** Array of parsed packets */
157
- packets: StreamPacket[];
158
- /** Any remaining unparsed data (incomplete packet) */
159
- remaining: string;
160
- }
161
- /**
162
- * Encode data into pkt-line format.
163
- *
164
- * @description
165
- * Encodes the given data with a 4-character hex length prefix. The length
166
- * includes the 4-byte prefix itself, so a 6-byte payload results in a
167
- * 10-byte packet with prefix "000a".
168
- *
169
- * For binary data containing non-printable characters, returns a Uint8Array.
170
- * For text data, returns a string for easier concatenation.
171
- *
172
- * @param data - The data to encode (string or Uint8Array)
173
- * @returns Encoded pkt-line as string (for text) or Uint8Array (for binary)
174
- *
175
- * @throws {Error} If data exceeds MAX_PKT_LINE_DATA bytes
176
- *
177
- * @example Encoding text data
178
- * ```typescript
179
- * const line = encodePktLine('hello\n')
180
- * // Result: '000ahello\n'
181
- * // Length: 4 (prefix) + 6 (data) = 10 = 0x000a
182
- * ```
183
- *
184
- * @example Encoding binary data
185
- * ```typescript
186
- * const binaryData = new Uint8Array([0x01, 0x02, 0x03])
187
- * const encoded = encodePktLine(binaryData)
188
- * // Result: Uint8Array with hex prefix + data
189
- * ```
190
- *
191
- * @example Building a multi-line message
192
- * ```typescript
193
- * let message = ''
194
- * message += encodePktLine('want abc123...\n') as string
195
- * message += encodePktLine('have def456...\n') as string
196
- * message += FLUSH_PKT
197
- * ```
198
- */
199
- export declare function encodePktLine(data: PktLineInput): string | Uint8Array;
200
- /**
201
- * Decode a pkt-line format message.
202
- *
203
- * @description
204
- * Parses a single pkt-line from the input and returns the decoded data
205
- * along with metadata about the packet. Handles special packets (flush,
206
- * delim) and incomplete data gracefully.
207
- *
208
- * The function validates packet size to prevent denial-of-service attacks
209
- * from maliciously large length values.
210
- *
211
- * @param input - The input to decode (string or Uint8Array)
212
- * @returns Object with decoded data, packet type (if special), and bytes consumed
213
- *
214
- * @throws {Error} If packet size exceeds MAX_PKT_LINE_DATA + 4
215
- *
216
- * @example Decoding a data packet
217
- * ```typescript
218
- * const result = decodePktLine('000ahello\n')
219
- * // result.data === 'hello\n'
220
- * // result.bytesRead === 10
221
- * // result.type === undefined (data packet)
222
- * ```
223
- *
224
- * @example Decoding a flush packet
225
- * ```typescript
226
- * const result = decodePktLine('0000remaining...')
227
- * // result.data === null
228
- * // result.type === 'flush'
229
- * // result.bytesRead === 4
230
- * ```
231
- *
232
- * @example Handling incomplete data
233
- * ```typescript
234
- * const result = decodePktLine('00') // Not enough for length prefix
235
- * // result.data === null
236
- * // result.type === 'incomplete'
237
- * // result.bytesRead === 0
238
- * ```
239
- */
240
- export declare function decodePktLine(input: PktLineInput): DecodedPktLine;
241
- /**
242
- * Create a flush-pkt (0000).
243
- *
244
- * @description
245
- * Returns the flush packet constant. Primarily useful for explicit intent
246
- * in code, as you can also use FLUSH_PKT directly.
247
- *
248
- * The flush packet signals the end of a logical section in the protocol.
249
- *
250
- * @returns The flush packet string '0000'
251
- *
252
- * @example
253
- * ```typescript
254
- * // These are equivalent:
255
- * const flush1 = encodeFlushPkt()
256
- * const flush2 = FLUSH_PKT
257
- *
258
- * // Using in a message
259
- * const message = encodePktLine('data\n') + encodeFlushPkt()
260
- * ```
261
- */
262
- export declare function encodeFlushPkt(): string;
263
- /**
264
- * Create a delim-pkt (0001).
265
- *
266
- * @description
267
- * Returns the delimiter packet constant. The delimiter packet is used
268
- * in Git protocol v2 to separate sections within a command.
269
- *
270
- * @returns The delimiter packet string '0001'
271
- *
272
- * @example
273
- * ```typescript
274
- * // Protocol v2 ls-refs command
275
- * let request = encodePktLine('command=ls-refs')
276
- * request += encodeDelimPkt() // Separator
277
- * request += encodePktLine('ref-prefix refs/heads/')
278
- * request += encodeFlushPkt() // End
279
- * ```
280
- */
281
- export declare function encodeDelimPkt(): string;
282
- /**
283
- * Parse a stream of pkt-lines.
284
- *
285
- * @description
286
- * Parses multiple pkt-lines from an input stream, returning all complete
287
- * packets and any remaining unparsed data. This is useful for:
288
- * - Processing multi-packet messages
289
- * - Handling streaming data that arrives in chunks
290
- * - Parsing complete protocol exchanges
291
- *
292
- * The function continues parsing until it encounters incomplete data
293
- * or reaches the end of input.
294
- *
295
- * @param input - The input stream to parse (string or Uint8Array)
296
- * @returns Object with parsed packets and any remaining unparsed data
297
- *
298
- * @example Parsing a complete message
299
- * ```typescript
300
- * const stream = '0009line1\n0009line2\n0000'
301
- * const { packets, remaining } = pktLineStream(stream)
302
- *
303
- * // packets = [
304
- * // { data: 'line1\n', type: 'data' },
305
- * // { data: 'line2\n', type: 'data' },
306
- * // { data: null, type: 'flush' }
307
- * // ]
308
- * // remaining = ''
309
- * ```
310
- *
311
- * @example Handling chunked data
312
- * ```typescript
313
- * // First chunk arrives
314
- * let buffer = '0009line1\n00' // Incomplete second packet
315
- * let result = pktLineStream(buffer)
316
- * // result.packets = [{ data: 'line1\n', type: 'data' }]
317
- * // result.remaining = '00'
318
- *
319
- * // Second chunk arrives
320
- * buffer = result.remaining + '09line2\n0000'
321
- * result = pktLineStream(buffer)
322
- * // result.packets = [
323
- * // { data: 'line2\n', type: 'data' },
324
- * // { data: null, type: 'flush' }
325
- * // ]
326
- * ```
327
- *
328
- * @example Processing ref advertisement
329
- * ```typescript
330
- * const refAdvert = '001e# service=git-upload-pack\n0000' +
331
- * '003fabc123... refs/heads/main\x00side-band-64k\n0000'
332
- *
333
- * const { packets } = pktLineStream(refAdvert)
334
- * for (const pkt of packets) {
335
- * if (pkt.type === 'flush') {
336
- * console.log('--- Section end ---')
337
- * } else if (pkt.data) {
338
- * console.log('Line:', pkt.data.trim())
339
- * }
340
- * }
341
- * ```
342
- */
343
- export declare function pktLineStream(input: PktLineInput): PktLineStreamResult;
344
- export {};
345
- //# sourceMappingURL=pkt-line.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pkt-line.d.ts","sourceRoot":"","sources":["../../src/wire/pkt-line.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,SAAS,SAAS,CAAA;AAE/B;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS,SAAS,CAAA;AAE/B;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,QAAQ,CAAA;AAEtC;;;;;;;GAOG;AACH,KAAK,YAAY,GAAG,MAAM,GAAG,UAAU,CAAA;AAEvC;;;;;;;;;GASG;AACH,UAAU,cAAc;IACtB,uEAAuE;IACvE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,yEAAyE;IACzE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,YAAY,CAAA;IACvC,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;GAQG;AACH,UAAU,YAAY;IACpB,mDAAmD;IACnD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,sBAAsB;IACtB,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;CACjC;AAED;;;;;;;GAOG;AACH,UAAU,mBAAmB;IAC3B,8BAA8B;IAC9B,OAAO,EAAE,YAAY,EAAE,CAAA;IACvB,sDAAsD;IACtD,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,GAAG,UAAU,CA0BrE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,cAAc,CA8CjE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,mBAAmB,CAkCtE"}