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,833 +0,0 @@
1
- /**
2
- * @fileoverview Git Reference Storage System
3
- *
4
- * This module provides a complete implementation of Git reference management,
5
- * including branches, tags, HEAD, and symbolic refs. It supports both loose refs
6
- * (individual files) and packed refs (consolidated file).
7
- *
8
- * **Key Concepts**:
9
- * - **Direct refs**: Point directly to a SHA-1 hash (e.g., branch pointing to commit)
10
- * - **Symbolic refs**: Point to another ref (e.g., HEAD -> refs/heads/main)
11
- * - **Loose refs**: Individual ref files in .git/refs/
12
- * - **Packed refs**: Consolidated refs in .git/packed-refs for efficiency
13
- *
14
- * **Backend Support**:
15
- * - `RefStorageBackend`: Full-featured backend with locking and packed refs
16
- * - `StorageBackend`: Simpler backend interface (optional, from storage/backend.ts)
17
- *
18
- * @module refs/storage
19
- *
20
- * @example
21
- * ```typescript
22
- * import { RefStorage, isValidRefName, isValidSha } from './refs/storage'
23
- *
24
- * // Create storage with RefStorageBackend (full features)
25
- * const storage = new RefStorage(backend)
26
- *
27
- * // Or create with StorageBackend (simpler, optional)
28
- * const storage = new RefStorage({ storageBackend: myStorageBackend })
29
- *
30
- * // Resolve HEAD to get current commit
31
- * const resolved = await storage.resolveRef('HEAD')
32
- * console.log(`Current commit: ${resolved.sha}`)
33
- *
34
- * // Update a branch
35
- * await storage.updateRef('refs/heads/feature', newCommitSha, { create: true })
36
- *
37
- * // List all branches
38
- * const branches = await storage.listBranches()
39
- * ```
40
- */
41
- import type { StorageBackend } from '../storage/backend';
42
- /**
43
- * Type discriminator for reference types.
44
- *
45
- * @description
46
- * - `direct`: Points directly to a SHA-1 hash
47
- * - `symbolic`: Points to another ref name (follows chain on resolution)
48
- */
49
- export type RefType = 'direct' | 'symbolic';
50
- /**
51
- * Represents a Git reference (branch, tag, HEAD, etc.).
52
- *
53
- * @description
54
- * References are named pointers in Git. They can point directly to objects
55
- * (like commits) or symbolically to other refs.
56
- *
57
- * @example
58
- * ```typescript
59
- * // Direct ref (branch pointing to commit)
60
- * const branch: Ref = {
61
- * name: 'refs/heads/main',
62
- * target: 'abc123def456...',
63
- * type: 'direct'
64
- * }
65
- *
66
- * // Symbolic ref (HEAD pointing to branch)
67
- * const head: Ref = {
68
- * name: 'HEAD',
69
- * target: 'refs/heads/main',
70
- * type: 'symbolic'
71
- * }
72
- * ```
73
- */
74
- export interface Ref {
75
- /** Full ref name (e.g., 'refs/heads/main', 'HEAD') */
76
- name: string;
77
- /** Target - SHA-1 hash for direct refs, ref name for symbolic refs */
78
- target: string;
79
- /** Whether this is a direct or symbolic reference */
80
- type: RefType;
81
- }
82
- /**
83
- * Options for updating a reference.
84
- *
85
- * @description
86
- * Provides control over ref update behavior including atomic operations
87
- * (compare-and-swap), creation, and force updates.
88
- */
89
- export interface UpdateRefOptions {
90
- /** If true, create the ref if it doesn't exist (default: false) */
91
- create?: boolean;
92
- /**
93
- * Expected old value for compare-and-swap (CAS) operation.
94
- * - `null`: Expect ref to NOT exist (atomic create)
95
- * - SHA string: Expect ref to have this exact value
96
- * - undefined: No CAS check
97
- */
98
- oldValue?: string | null;
99
- /** Force update even if not a fast-forward (for branch updates) */
100
- force?: boolean;
101
- /** Reason for the update (stored in reflog if implemented) */
102
- reason?: string;
103
- /** Use an existing lock instead of acquiring a new one */
104
- lock?: RefLock;
105
- }
106
- /**
107
- * Options for listing references.
108
- *
109
- * @description
110
- * Controls which refs are included in listing operations.
111
- */
112
- export interface ListRefsOptions {
113
- /** Glob pattern to filter refs (e.g., 'refs/heads/*', 'refs/tags/v*') */
114
- pattern?: string;
115
- /** Include HEAD in the listing (default: false) */
116
- includeHead?: boolean;
117
- /** Include symbolic refs in the listing (default: false) */
118
- includeSymbolic?: boolean;
119
- }
120
- /**
121
- * Options for resolving references.
122
- */
123
- export interface ResolveRefOptions {
124
- /**
125
- * Maximum depth for following symbolic refs (default: 10).
126
- * Prevents infinite loops from circular refs.
127
- */
128
- maxDepth?: number;
129
- }
130
- /**
131
- * Result of resolving a reference.
132
- *
133
- * @description
134
- * Contains the resolved SHA and the chain of refs followed during resolution.
135
- * Useful for understanding ref structure and debugging.
136
- */
137
- export interface ResolvedRef {
138
- /** The original ref that was resolved */
139
- ref: Ref;
140
- /** The final SHA-1 target after following all symbolic refs */
141
- sha: string;
142
- /** Chain of refs followed during resolution (for debugging/display) */
143
- chain: Ref[];
144
- }
145
- /**
146
- * Error thrown when a ref operation fails.
147
- *
148
- * @description
149
- * Provides structured error information including error code
150
- * and the ref name that caused the error.
151
- *
152
- * @example
153
- * ```typescript
154
- * try {
155
- * await storage.updateRef('refs/heads/main', sha)
156
- * } catch (e) {
157
- * if (e instanceof RefError) {
158
- * switch (e.code) {
159
- * case 'NOT_FOUND': // Ref doesn't exist
160
- * case 'CONFLICT': // CAS failed
161
- * case 'LOCKED': // Ref is locked
162
- * }
163
- * }
164
- * }
165
- * ```
166
- */
167
- export declare class RefError extends Error {
168
- readonly code: RefErrorCode;
169
- readonly refName?: string | undefined;
170
- /**
171
- * Create a new RefError.
172
- *
173
- * @param message - Human-readable error message
174
- * @param code - Error code for programmatic handling
175
- * @param refName - The ref that caused the error (optional)
176
- */
177
- constructor(message: string, code: RefErrorCode, refName?: string | undefined);
178
- }
179
- /**
180
- * Error codes for ref operations.
181
- *
182
- * @description
183
- * - `NOT_FOUND`: Ref doesn't exist
184
- * - `ALREADY_EXISTS`: Ref already exists (when creating)
185
- * - `INVALID_NAME`: Ref name fails validation
186
- * - `LOCKED`: Another process holds the ref lock
187
- * - `CONFLICT`: CAS operation failed (value changed)
188
- * - `CIRCULAR_REF`: Symbolic ref chain loops back on itself
189
- * - `MAX_DEPTH_EXCEEDED`: Too many symbolic ref redirects
190
- * - `INVALID_SHA`: SHA format is invalid
191
- */
192
- export type RefErrorCode = 'NOT_FOUND' | 'ALREADY_EXISTS' | 'INVALID_NAME' | 'LOCKED' | 'CONFLICT' | 'CIRCULAR_REF' | 'MAX_DEPTH_EXCEEDED' | 'INVALID_SHA';
193
- /**
194
- * Lock handle for atomic ref updates.
195
- *
196
- * @description
197
- * Ref locks prevent concurrent modifications to the same ref.
198
- * Always release locks when done, preferably in a finally block.
199
- *
200
- * @example
201
- * ```typescript
202
- * const lock = await storage.acquireLock('refs/heads/main')
203
- * try {
204
- * const ref = await storage.getRef('refs/heads/main')
205
- * // ... modify and write ref ...
206
- * } finally {
207
- * await lock.release()
208
- * }
209
- * ```
210
- */
211
- export interface RefLock {
212
- /** The ref being locked */
213
- refName: string;
214
- /** Release the lock - should be idempotent */
215
- release(): Promise<void>;
216
- /** Check if this lock is still held by us */
217
- isHeld(): boolean;
218
- }
219
- /**
220
- * Storage backend interface for refs.
221
- *
222
- * @description
223
- * Implement this interface to provide ref storage.
224
- * The backend is responsible for persistence, locking, and packed refs.
225
- */
226
- export interface RefStorageBackend {
227
- /**
228
- * Read a single ref from storage.
229
- *
230
- * @param name - Full ref name
231
- * @returns The ref or null if not found
232
- */
233
- readRef(name: string): Promise<Ref | null>;
234
- /**
235
- * Write a ref to storage.
236
- *
237
- * @param ref - The ref to write
238
- */
239
- writeRef(ref: Ref): Promise<void>;
240
- /**
241
- * Delete a ref from storage.
242
- *
243
- * @param name - Full ref name
244
- * @returns True if deleted, false if not found
245
- */
246
- deleteRef(name: string): Promise<boolean>;
247
- /**
248
- * List all refs matching a pattern.
249
- *
250
- * @param pattern - Optional glob pattern
251
- * @returns Array of matching refs
252
- */
253
- listRefs(pattern?: string): Promise<Ref[]>;
254
- /**
255
- * Acquire an exclusive lock on a ref.
256
- *
257
- * @param name - Full ref name
258
- * @param timeout - Lock acquisition timeout in ms
259
- * @returns Lock handle
260
- * @throws RefError with code 'LOCKED' if lock cannot be acquired
261
- */
262
- acquireLock(name: string, timeout?: number): Promise<RefLock>;
263
- /**
264
- * Read packed refs file.
265
- *
266
- * @returns Map of ref names to SHA values
267
- */
268
- readPackedRefs(): Promise<Map<string, string>>;
269
- /**
270
- * Write packed refs file.
271
- *
272
- * @param refs - Map of ref names to SHA values
273
- */
274
- writePackedRefs(refs: Map<string, string>): Promise<void>;
275
- }
276
- /**
277
- * Options for creating a RefStorage instance.
278
- *
279
- * @description
280
- * Supports two modes of operation:
281
- * 1. Pass a RefStorageBackend directly for full features (locking, packed refs)
282
- * 2. Pass options object with storageBackend for simpler StorageBackend integration
283
- *
284
- * When using StorageBackend:
285
- * - Locking operations become no-ops (always succeed)
286
- * - Packed refs operations are not available
287
- * - Basic ref operations delegate to StorageBackend methods
288
- */
289
- export interface RefStorageOptions {
290
- /**
291
- * Optional StorageBackend for simpler ref operations.
292
- * When provided, ref operations delegate to this backend.
293
- */
294
- storageBackend?: StorageBackend;
295
- }
296
- /**
297
- * Validate a ref name according to Git rules.
298
- *
299
- * @description
300
- * Git has specific rules for valid ref names. This function implements
301
- * the validation from `git check-ref-format`.
302
- *
303
- * **Rules**:
304
- * - Cannot be empty or just '@'
305
- * - Cannot end with '/' or '.lock'
306
- * - Cannot contain '..', '@{', control chars, space, ~, ^, :, ?, *, [, \
307
- * - Components cannot start or end with '.'
308
- * - HEAD is always valid
309
- *
310
- * @param name - Ref name to validate
311
- * @returns True if the name is valid
312
- *
313
- * @see https://git-scm.com/docs/git-check-ref-format
314
- *
315
- * @example
316
- * ```typescript
317
- * isValidRefName('refs/heads/main') // true
318
- * isValidRefName('refs/heads/feature/x') // true
319
- * isValidRefName('HEAD') // true
320
- * isValidRefName('refs/heads/../main') // false (contains ..)
321
- * isValidRefName('refs/heads/.hidden') // false (component starts with .)
322
- * isValidRefName('refs/heads/foo.lock') // false (ends with .lock)
323
- * ```
324
- */
325
- export declare function isValidRefName(name: string): boolean;
326
- /**
327
- * Validate a SHA-1 hash string.
328
- *
329
- * @description
330
- * SHA-1 hashes must be exactly 40 hexadecimal characters.
331
- * This validates the format, not whether the object exists.
332
- *
333
- * @param sha - SHA string to validate
334
- * @returns True if the string is a valid SHA-1 format
335
- *
336
- * @example
337
- * ```typescript
338
- * isValidSha('abc123def456789...') // true (if 40 hex chars)
339
- * isValidSha('abc123') // false (too short)
340
- * isValidSha('xyz...') // false (invalid hex)
341
- * isValidSha(null) // false
342
- * ```
343
- */
344
- export declare function isValidSha(sha: string): boolean;
345
- /**
346
- * Parse ref file content into type and target.
347
- *
348
- * @description
349
- * Ref files either contain a SHA directly or "ref: <target>" for symbolic refs.
350
- *
351
- * @param content - Raw ref file content
352
- * @returns Parsed type and target
353
- *
354
- * @example
355
- * ```typescript
356
- * // Direct ref
357
- * parseRefContent('abc123def456...\n')
358
- * // => { type: 'direct', target: 'abc123def456...' }
359
- *
360
- * // Symbolic ref
361
- * parseRefContent('ref: refs/heads/main\n')
362
- * // => { type: 'symbolic', target: 'refs/heads/main' }
363
- * ```
364
- */
365
- export declare function parseRefContent(content: string): {
366
- type: RefType;
367
- target: string;
368
- };
369
- /**
370
- * Serialize a ref to file content format.
371
- *
372
- * @description
373
- * Converts a Ref object to the string format stored in ref files.
374
- *
375
- * @param ref - Ref to serialize
376
- * @returns File content string (with trailing newline)
377
- *
378
- * @example
379
- * ```typescript
380
- * serializeRefContent({ name: 'HEAD', target: 'refs/heads/main', type: 'symbolic' })
381
- * // => 'ref: refs/heads/main\n'
382
- *
383
- * serializeRefContent({ name: 'refs/heads/main', target: 'abc123...', type: 'direct' })
384
- * // => 'abc123...\n'
385
- * ```
386
- */
387
- export declare function serializeRefContent(ref: Ref): string;
388
- /**
389
- * Parse packed-refs file content.
390
- *
391
- * @description
392
- * The packed-refs file contains multiple refs in a space-efficient format.
393
- * Format: "<sha> <refname>" on each line, with optional comments (#) and
394
- * peeled entries (^sha for annotated tags).
395
- *
396
- * @param content - Raw packed-refs file content
397
- * @returns Map of ref names to SHA values
398
- *
399
- * @example
400
- * ```typescript
401
- * const content = `# pack-refs with: peeled fully-peeled sorted
402
- * abc123 refs/heads/main
403
- * def456 refs/tags/v1.0.0
404
- * ^aaa111
405
- * `
406
- * const refs = parsePackedRefs(content)
407
- * // Map { 'refs/heads/main' => 'abc123', 'refs/tags/v1.0.0' => 'def456' }
408
- * ```
409
- */
410
- export declare function parsePackedRefs(content: string): Map<string, string>;
411
- /**
412
- * Serialize refs to packed-refs file format.
413
- *
414
- * @description
415
- * Creates the content for a packed-refs file from a map of refs.
416
- * Refs are sorted alphabetically for consistency.
417
- *
418
- * @param refs - Map of ref names to SHA values
419
- * @returns Packed-refs file content
420
- *
421
- * @example
422
- * ```typescript
423
- * const refs = new Map([
424
- * ['refs/heads/main', 'abc123...'],
425
- * ['refs/tags/v1.0.0', 'def456...']
426
- * ])
427
- * const content = serializePackedRefs(refs)
428
- * // '# pack-refs with: peeled fully-peeled sorted\nabc123... refs/heads/main\n...'
429
- * ```
430
- */
431
- export declare function serializePackedRefs(refs: Map<string, string>): string;
432
- /**
433
- * Reference storage manager.
434
- *
435
- * @description
436
- * Provides a high-level API for managing Git references. Handles ref
437
- * resolution, updates with locking, symbolic refs, and packed refs.
438
- *
439
- * Supports two backend modes:
440
- * 1. RefStorageBackend - Full features including locking and packed refs
441
- * 2. StorageBackend - Simpler interface with basic ref operations
442
- *
443
- * @example
444
- * ```typescript
445
- * // With RefStorageBackend (full features)
446
- * const storage = new RefStorage(myBackend)
447
- *
448
- * // With StorageBackend (simpler)
449
- * const storage = new RefStorage({ storageBackend: myStorageBackend })
450
- *
451
- * // Get current branch
452
- * const head = await storage.getHead()
453
- * if (head.type === 'symbolic') {
454
- * console.log(`On branch: ${head.target}`)
455
- * }
456
- *
457
- * // Resolve to SHA
458
- * const resolved = await storage.resolveRef('HEAD')
459
- * console.log(`Current commit: ${resolved.sha}`)
460
- *
461
- * // Create a branch
462
- * await storage.updateRef('refs/heads/feature', commitSha, { create: true })
463
- * ```
464
- */
465
- export declare class RefStorage {
466
- private backend?;
467
- private storageBackend?;
468
- /**
469
- * Create a new RefStorage instance.
470
- *
471
- * @param backendOrOptions - Either a RefStorageBackend directly, or options with storageBackend
472
- *
473
- * @example
474
- * ```typescript
475
- * // Direct backend
476
- * const storage = new RefStorage(myRefStorageBackend)
477
- *
478
- * // Options with StorageBackend
479
- * const storage = new RefStorage({ storageBackend: myStorageBackend })
480
- * ```
481
- */
482
- constructor(backendOrOptions: RefStorageBackend | RefStorageOptions);
483
- /**
484
- * Internal helper to get a lock (or no-op lock for StorageBackend).
485
- *
486
- * @description
487
- * When using StorageBackend, returns a no-op lock since StorageBackend
488
- * doesn't support locking. Callers should still use try/finally to release.
489
- */
490
- private getLock;
491
- /**
492
- * Internal helper to write a ref.
493
- */
494
- private writeRef;
495
- /**
496
- * Internal helper to delete a ref.
497
- */
498
- private removeRef;
499
- /**
500
- * Internal helper to list refs.
501
- */
502
- private getAllRefs;
503
- /**
504
- * Get a ref by name.
505
- *
506
- * @description
507
- * Retrieves a ref without resolving symbolic refs.
508
- * Use `resolveRef` to follow symbolic refs to their final target.
509
- *
510
- * @param name - Full ref name
511
- * @returns The ref or null if not found
512
- * @throws Error if no backend is configured
513
- *
514
- * @example
515
- * ```typescript
516
- * const head = await storage.getRef('HEAD')
517
- * if (head && head.type === 'symbolic') {
518
- * console.log(`HEAD points to ${head.target}`)
519
- * }
520
- * ```
521
- */
522
- getRef(name: string): Promise<Ref | null>;
523
- /**
524
- * Resolve a ref to its final SHA target.
525
- *
526
- * @description
527
- * Follows symbolic refs until reaching a direct ref, then returns
528
- * the SHA and the chain of refs followed.
529
- *
530
- * @param name - Ref name to resolve
531
- * @param options - Resolution options (maxDepth)
532
- * @returns Resolved ref with SHA and chain
533
- * @throws RefError with code 'NOT_FOUND' if ref doesn't exist
534
- * @throws RefError with code 'CIRCULAR_REF' if circular reference detected
535
- * @throws RefError with code 'MAX_DEPTH_EXCEEDED' if too many redirects
536
- *
537
- * @example
538
- * ```typescript
539
- * const resolved = await storage.resolveRef('HEAD')
540
- * console.log(`SHA: ${resolved.sha}`)
541
- * console.log(`Chain: ${resolved.chain.map(r => r.name).join(' -> ')}`)
542
- * // Chain: HEAD -> refs/heads/main
543
- * ```
544
- */
545
- resolveRef(name: string, options?: ResolveRefOptions): Promise<ResolvedRef>;
546
- /**
547
- * Update or create a ref.
548
- *
549
- * @description
550
- * Creates a new ref or updates an existing one. Supports atomic
551
- * compare-and-swap operations via oldValue option.
552
- *
553
- * Note: For atomic operations, callers can acquire a lock via acquireLock()
554
- * and pass it via options.lock to avoid double-locking.
555
- *
556
- * @param name - Full ref name
557
- * @param target - SHA-1 hash to point to
558
- * @param options - Update options (create, oldValue, force, lock)
559
- * @returns The updated/created ref
560
- * @throws RefError with code 'INVALID_NAME' if ref name is invalid
561
- * @throws RefError with code 'INVALID_SHA' if SHA format is invalid
562
- * @throws RefError with code 'ALREADY_EXISTS' if creating and ref exists
563
- * @throws RefError with code 'CONFLICT' if oldValue doesn't match
564
- * @throws RefError with code 'NOT_FOUND' if ref doesn't exist and not creating
565
- *
566
- * @example
567
- * ```typescript
568
- * // Create a new branch
569
- * await storage.updateRef('refs/heads/feature', sha, { create: true })
570
- *
571
- * // Atomic update (fails if someone else modified)
572
- * await storage.updateRef('refs/heads/main', newSha, { oldValue: currentSha })
573
- *
574
- * // Force update (skips fast-forward check)
575
- * await storage.updateRef('refs/heads/main', sha, { force: true })
576
- * ```
577
- */
578
- updateRef(name: string, target: string, options?: UpdateRefOptions): Promise<Ref>;
579
- /**
580
- * Delete a ref.
581
- *
582
- * @description
583
- * Removes a ref from storage. HEAD cannot be deleted.
584
- * Uses locking for atomic compare-and-swap operations when oldValue is specified.
585
- *
586
- * @param name - Full ref name to delete
587
- * @param options - Delete options (oldValue for CAS)
588
- * @returns True if deleted, false if ref didn't exist
589
- * @throws RefError with code 'INVALID_NAME' for HEAD or invalid names
590
- * @throws RefError with code 'CONFLICT' if oldValue doesn't match
591
- *
592
- * @example
593
- * ```typescript
594
- * // Simple delete
595
- * const deleted = await storage.deleteRef('refs/heads/old-branch')
596
- *
597
- * // Atomic delete (only if value matches)
598
- * await storage.deleteRef('refs/heads/feature', { oldValue: expectedSha })
599
- * ```
600
- */
601
- deleteRef(name: string, options?: UpdateRefOptions): Promise<boolean>;
602
- /**
603
- * List refs matching a pattern.
604
- *
605
- * @description
606
- * Returns refs filtered by pattern and options.
607
- * By default, excludes HEAD and symbolic refs.
608
- *
609
- * @param options - Listing options (pattern, includeHead, includeSymbolic)
610
- * @returns Array of matching refs
611
- *
612
- * @example
613
- * ```typescript
614
- * // List all refs
615
- * const all = await storage.listRefs()
616
- *
617
- * // List branches only
618
- * const branches = await storage.listRefs({ pattern: 'refs/heads/*' })
619
- *
620
- * // Include HEAD
621
- * const withHead = await storage.listRefs({ includeHead: true })
622
- * ```
623
- */
624
- listRefs(options?: ListRefsOptions): Promise<Ref[]>;
625
- /**
626
- * List all branches.
627
- *
628
- * @description
629
- * Convenience method to list refs under refs/heads/.
630
- *
631
- * @returns Array of branch refs
632
- *
633
- * @example
634
- * ```typescript
635
- * const branches = await storage.listBranches()
636
- * for (const branch of branches) {
637
- * console.log(branch.name.replace('refs/heads/', ''))
638
- * }
639
- * ```
640
- */
641
- listBranches(): Promise<Ref[]>;
642
- /**
643
- * List all tags.
644
- *
645
- * @description
646
- * Convenience method to list refs under refs/tags/.
647
- *
648
- * @returns Array of tag refs
649
- *
650
- * @example
651
- * ```typescript
652
- * const tags = await storage.listTags()
653
- * for (const tag of tags) {
654
- * console.log(tag.name.replace('refs/tags/', ''))
655
- * }
656
- * ```
657
- */
658
- listTags(): Promise<Ref[]>;
659
- /**
660
- * Get HEAD ref.
661
- *
662
- * @description
663
- * Returns the HEAD ref. Every repository should have HEAD.
664
- *
665
- * @returns The HEAD ref
666
- * @throws RefError with code 'NOT_FOUND' if HEAD doesn't exist
667
- *
668
- * @example
669
- * ```typescript
670
- * const head = await storage.getHead()
671
- * if (head.type === 'symbolic') {
672
- * console.log(`On branch: ${head.target}`)
673
- * } else {
674
- * console.log(`Detached at: ${head.target}`)
675
- * }
676
- * ```
677
- */
678
- getHead(): Promise<Ref>;
679
- /**
680
- * Update HEAD (can be symbolic or detached).
681
- *
682
- * @description
683
- * Sets HEAD to point to a branch (symbolic) or commit (detached).
684
- * Uses locking to ensure atomic updates to HEAD.
685
- *
686
- * @param target - Branch ref name (symbolic) or SHA (detached)
687
- * @param symbolic - If true, create symbolic ref; if false, direct ref
688
- * @returns The updated HEAD ref
689
- *
690
- * @example
691
- * ```typescript
692
- * // Switch to branch
693
- * await storage.updateHead('refs/heads/main', true)
694
- *
695
- * // Detach HEAD at commit
696
- * await storage.updateHead(commitSha, false)
697
- * ```
698
- */
699
- updateHead(target: string, symbolic?: boolean): Promise<Ref>;
700
- /**
701
- * Check if HEAD is detached.
702
- *
703
- * @description
704
- * HEAD is detached when it points directly to a commit SHA
705
- * rather than symbolically to a branch.
706
- *
707
- * @returns True if HEAD is detached (points to SHA directly)
708
- *
709
- * @example
710
- * ```typescript
711
- * if (await storage.isHeadDetached()) {
712
- * console.log('You are in detached HEAD state')
713
- * }
714
- * ```
715
- */
716
- isHeadDetached(): Promise<boolean>;
717
- /**
718
- * Create a symbolic ref.
719
- *
720
- * @description
721
- * Creates a ref that points to another ref name (not a SHA).
722
- * Used primarily for HEAD pointing to a branch.
723
- * Uses locking to ensure atomic creation.
724
- *
725
- * @param name - Name for the new symbolic ref
726
- * @param target - Target ref name (not SHA)
727
- * @returns The created symbolic ref
728
- * @throws RefError with code 'INVALID_NAME' if name is invalid
729
- * @throws RefError with code 'CIRCULAR_REF' if name equals target
730
- *
731
- * @example
732
- * ```typescript
733
- * // Make HEAD point to main branch
734
- * await storage.createSymbolicRef('HEAD', 'refs/heads/main')
735
- * ```
736
- */
737
- createSymbolicRef(name: string, target: string): Promise<Ref>;
738
- /**
739
- * Acquire a lock for updating a ref.
740
- *
741
- * @description
742
- * Acquires an exclusive lock on a ref. Use this for complex operations
743
- * that need to read-modify-write atomically.
744
- *
745
- * @param name - Full ref name to lock
746
- * @param timeout - Lock acquisition timeout in milliseconds
747
- * @returns Lock handle - must be released when done
748
- *
749
- * @example
750
- * ```typescript
751
- * const lock = await storage.acquireLock('refs/heads/main', 5000)
752
- * try {
753
- * // Perform atomic operations
754
- * await storage.updateRef('refs/heads/main', sha, { lock })
755
- * } finally {
756
- * await lock.release()
757
- * }
758
- * ```
759
- */
760
- acquireLock(name: string, timeout?: number): Promise<RefLock>;
761
- /**
762
- * Pack loose refs into packed-refs file.
763
- *
764
- * @description
765
- * Consolidates loose ref files into a single packed-refs file.
766
- * This improves performance for repositories with many refs.
767
- * HEAD and symbolic refs are not packed.
768
- *
769
- * Uses a transactional approach by acquiring locks on all refs being packed
770
- * to ensure consistency during the packing operation.
771
- *
772
- * @example
773
- * ```typescript
774
- * // After creating many branches/tags
775
- * await storage.packRefs()
776
- * ```
777
- */
778
- packRefs(): Promise<void>;
779
- }
780
- /**
781
- * Resolve a ref to its final SHA target.
782
- *
783
- * @description
784
- * Convenience function that wraps RefStorage.resolveRef.
785
- *
786
- * @param storage - RefStorage instance
787
- * @param name - Ref name to resolve
788
- * @param options - Resolution options
789
- * @returns The final SHA target
790
- *
791
- * @example
792
- * ```typescript
793
- * const sha = await resolveRef(storage, 'HEAD')
794
- * ```
795
- */
796
- export declare function resolveRef(storage: RefStorage, name: string, options?: ResolveRefOptions): Promise<string>;
797
- /**
798
- * Update a ref.
799
- *
800
- * @description
801
- * Convenience function that wraps RefStorage.updateRef.
802
- *
803
- * @param storage - RefStorage instance
804
- * @param name - Full ref name
805
- * @param target - SHA target
806
- * @param options - Update options
807
- * @returns The updated ref
808
- */
809
- export declare function updateRef(storage: RefStorage, name: string, target: string, options?: UpdateRefOptions): Promise<Ref>;
810
- /**
811
- * Delete a ref.
812
- *
813
- * @description
814
- * Convenience function that wraps RefStorage.deleteRef.
815
- *
816
- * @param storage - RefStorage instance
817
- * @param name - Full ref name to delete
818
- * @param options - Delete options
819
- * @returns True if deleted
820
- */
821
- export declare function deleteRef(storage: RefStorage, name: string, options?: UpdateRefOptions): Promise<boolean>;
822
- /**
823
- * List refs.
824
- *
825
- * @description
826
- * Convenience function that wraps RefStorage.listRefs.
827
- *
828
- * @param storage - RefStorage instance
829
- * @param options - Listing options
830
- * @returns Array of refs
831
- */
832
- export declare function listRefs(storage: RefStorage, options?: ListRefsOptions): Promise<Ref[]>;
833
- //# sourceMappingURL=storage.d.ts.map