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,204 +0,0 @@
1
- /**
2
- * @fileoverview FSx Storage Adapter for gitx
3
- *
4
- * This module provides a storage backend implementation that uses fsx.do for
5
- * both content-addressable storage (CAS) and file system operations. It bridges
6
- * gitx's StorageBackend interface with fsx's CAS and fs operations.
7
- *
8
- * **Features**:
9
- * - Content-addressable storage using fsx CAS (putObject, getObject, hasObject)
10
- * - Reference storage using fsx file operations
11
- * - Full file system operations for index, config, and other Git files
12
- *
13
- * @module storage/fsx-adapter
14
- *
15
- * @example
16
- * ```typescript
17
- * import { createFSxAdapter } from './storage/fsx-adapter'
18
- *
19
- * const storage = createFSxAdapter('/repos/my-repo/.git')
20
- *
21
- * // Store a blob
22
- * const sha = await storage.putObject('blob', content)
23
- *
24
- * // Work with refs
25
- * await storage.setRef('refs/heads/main', {
26
- * name: 'refs/heads/main',
27
- * target: sha,
28
- * type: 'direct'
29
- * })
30
- * ```
31
- */
32
- import type { StorageBackend, StoredObjectResult, ObjectType } from './backend';
33
- import type { Ref } from '../refs/storage';
34
- /**
35
- * Configuration options for FSxStorageAdapter
36
- */
37
- export interface FSxStorageAdapterOptions {
38
- /**
39
- * Root path for the Git repository (typically .git directory)
40
- */
41
- rootPath: string;
42
- }
43
- /**
44
- * FSx storage adapter implementing the StorageBackend interface.
45
- *
46
- * @description
47
- * This adapter uses fsx for all storage operations:
48
- * - CAS operations use fsx's git-compatible object storage
49
- * - Refs are stored as files at {rootPath}/refs/{refname}
50
- * - File operations are relative to the rootPath
51
- */
52
- export declare class FSxStorageAdapter implements StorageBackend {
53
- private rootPath;
54
- private storage;
55
- /**
56
- * Create a new FSxStorageAdapter
57
- *
58
- * @param rootPath - The root path for the Git repository (typically .git directory)
59
- */
60
- constructor(rootPath: string);
61
- /**
62
- * Resolve a relative path to an absolute path within the repository
63
- *
64
- * @param p - Relative path within the repository
65
- * @returns Absolute path
66
- */
67
- private resolvePath;
68
- /**
69
- * Get the path for an object based on its SHA
70
- *
71
- * @param sha - 40-character SHA-1 hash
72
- * @returns Path in format: objects/xx/yyyy...
73
- */
74
- private getObjectPath;
75
- /**
76
- * Get the path for a ref
77
- *
78
- * @param name - Ref name (e.g., 'refs/heads/main', 'HEAD')
79
- * @returns Absolute path to the ref file
80
- */
81
- private getRefPath;
82
- /**
83
- * Store a Git object and return its SHA-1 hash.
84
- *
85
- * @description
86
- * Creates a Git object in the format: "{type} {size}\0{content}",
87
- * computes its SHA-1 hash, compresses it with zlib, and stores it.
88
- *
89
- * @param type - Object type: 'blob', 'tree', 'commit', or 'tag'
90
- * @param content - Raw object content (without Git header)
91
- * @returns 40-character lowercase hexadecimal SHA-1 hash
92
- */
93
- putObject(type: ObjectType, content: Uint8Array): Promise<string>;
94
- /**
95
- * Retrieve a Git object by its SHA-1 hash.
96
- *
97
- * @param sha - 40-character SHA-1 hash (case-insensitive)
98
- * @returns Object with type and content, or null if not found
99
- */
100
- getObject(sha: string): Promise<StoredObjectResult | null>;
101
- /**
102
- * Check if a Git object exists in storage.
103
- *
104
- * @param sha - 40-character SHA-1 hash (case-insensitive)
105
- * @returns True if the object exists, false otherwise
106
- */
107
- hasObject(sha: string): Promise<boolean>;
108
- /**
109
- * Delete a Git object from storage.
110
- *
111
- * @param sha - 40-character SHA-1 hash (case-insensitive)
112
- */
113
- deleteObject(sha: string): Promise<void>;
114
- /**
115
- * Get a reference by name.
116
- *
117
- * @param name - Full ref name (e.g., 'HEAD', 'refs/heads/main')
118
- * @returns The reference or null if not found
119
- */
120
- getRef(name: string): Promise<Ref | null>;
121
- /**
122
- * Create or update a reference.
123
- *
124
- * @param name - Full ref name (e.g., 'HEAD', 'refs/heads/main')
125
- * @param ref - The reference object
126
- */
127
- setRef(name: string, ref: Ref): Promise<void>;
128
- /**
129
- * Delete a reference.
130
- *
131
- * @param name - Full ref name to delete
132
- */
133
- deleteRef(name: string): Promise<void>;
134
- /**
135
- * List references matching an optional prefix.
136
- *
137
- * @param prefix - Optional prefix to filter refs (e.g., 'refs/heads/')
138
- * @returns Array of matching references
139
- */
140
- listRefs(prefix?: string): Promise<Ref[]>;
141
- /**
142
- * Read a raw file from the repository.
143
- *
144
- * @param path - Path relative to Git directory
145
- * @returns File contents as Uint8Array, or null if not found
146
- */
147
- readFile(path: string): Promise<Uint8Array | null>;
148
- /**
149
- * Write a raw file to the repository.
150
- *
151
- * @param path - Path relative to Git directory
152
- * @param content - File contents as Uint8Array
153
- */
154
- writeFile(path: string, content: Uint8Array): Promise<void>;
155
- /**
156
- * Delete a raw file from the repository.
157
- *
158
- * @param path - Path relative to Git directory
159
- */
160
- deleteFile(path: string): Promise<void>;
161
- /**
162
- * Check if a file or directory exists.
163
- *
164
- * @param path - Path relative to Git directory
165
- * @returns True if the path exists
166
- */
167
- exists(path: string): Promise<boolean>;
168
- /**
169
- * List contents of a directory.
170
- *
171
- * @param path - Path relative to Git directory
172
- * @returns Array of file and directory names
173
- */
174
- readdir(path: string): Promise<string[]>;
175
- /**
176
- * Create a directory.
177
- *
178
- * @param path - Path relative to Git directory
179
- * @param options - Options for directory creation
180
- */
181
- mkdir(path: string, options?: {
182
- recursive?: boolean;
183
- }): Promise<void>;
184
- }
185
- /**
186
- * Create an FSx storage adapter.
187
- *
188
- * @description
189
- * Factory function for creating an FSxStorageAdapter instance.
190
- *
191
- * @param rootPath - The root path for the Git repository (typically .git directory)
192
- * @returns A StorageBackend instance backed by fsx
193
- *
194
- * @example
195
- * ```typescript
196
- * const storage = createFSxAdapter('/repos/my-project/.git')
197
- *
198
- * // Use the storage backend
199
- * const sha = await storage.putObject('blob', content)
200
- * const ref = await storage.getRef('HEAD')
201
- * ```
202
- */
203
- export declare function createFSxAdapter(rootPath: string): StorageBackend;
204
- //# sourceMappingURL=fsx-adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fsx-adapter.d.ts","sourceRoot":"","sources":["../../src/storage/fsx-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAe1C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB;AA6GD;;;;;;;;GAQG;AACH,qBAAa,iBAAkB,YAAW,cAAc;IACtD,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,OAAO,CAAgB;IAE/B;;;;OAIG;gBACS,QAAQ,EAAE,MAAM;IAW5B;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAiBnB;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAOrB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;IAQlB;;;;;;;;;;OAUG;IACG,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBvE;;;;;OAKG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAyBhE;;;;;OAKG;IACG,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAc9C;;;;OAIG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9C;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAkB/C;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAanD;;;;OAIG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C;;;;;OAKG;IACG,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAuD/C;;;;;OAKG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;IAKxD;;;;;OAKG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAYjE;;;;OAIG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAK7C;;;;;OAKG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAS5C;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAU9C;;;;;OAKG;IACG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAI5E;AAMD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAEjE"}
@@ -1,470 +0,0 @@
1
- /**
2
- * @fileoverview FSx Storage Adapter for gitx
3
- *
4
- * This module provides a storage backend implementation that uses fsx.do for
5
- * both content-addressable storage (CAS) and file system operations. It bridges
6
- * gitx's StorageBackend interface with fsx's CAS and fs operations.
7
- *
8
- * **Features**:
9
- * - Content-addressable storage using fsx CAS (putObject, getObject, hasObject)
10
- * - Reference storage using fsx file operations
11
- * - Full file system operations for index, config, and other Git files
12
- *
13
- * @module storage/fsx-adapter
14
- *
15
- * @example
16
- * ```typescript
17
- * import { createFSxAdapter } from './storage/fsx-adapter'
18
- *
19
- * const storage = createFSxAdapter('/repos/my-repo/.git')
20
- *
21
- * // Store a blob
22
- * const sha = await storage.putObject('blob', content)
23
- *
24
- * // Work with refs
25
- * await storage.setRef('refs/heads/main', {
26
- * name: 'refs/heads/main',
27
- * target: sha,
28
- * type: 'direct'
29
- * })
30
- * ```
31
- */
32
- import { parseRefContent, serializeRefContent } from '../refs/storage';
33
- import { sha1 } from '../../../fsx/src/cas/hash';
34
- import { createGitObject, parseGitObject } from '../../../fsx/src/cas/git-object';
35
- import { compress, decompress } from '../../../fsx/src/cas/compression';
36
- // ============================================================================
37
- // In-Memory Storage for Development/Testing
38
- // ============================================================================
39
- /**
40
- * Simple in-memory storage for development and testing
41
- * In production, this would be backed by fsx's R2 or SQLite storage
42
- */
43
- class InMemoryStorage {
44
- files = new Map();
45
- directories = new Set();
46
- constructor() {
47
- // Initialize root directory
48
- this.directories.add('/');
49
- }
50
- async read(path) {
51
- return this.files.get(path) ?? null;
52
- }
53
- async write(path, data) {
54
- this.files.set(path, data);
55
- // Ensure parent directories exist
56
- const parts = path.split('/');
57
- let current = '';
58
- for (let i = 0; i < parts.length - 1; i++) {
59
- current += (i === 0 ? '' : '/') + parts[i];
60
- if (current) {
61
- this.directories.add(current);
62
- }
63
- }
64
- }
65
- async delete(path) {
66
- this.files.delete(path);
67
- }
68
- async exists(path) {
69
- return this.files.has(path) || this.directories.has(path);
70
- }
71
- async readdir(path) {
72
- const normalizedPath = path.endsWith('/') ? path.slice(0, -1) : path;
73
- const entries = new Set();
74
- // Check files
75
- const fileKeys = Array.from(this.files.keys());
76
- for (const filePath of fileKeys) {
77
- if (filePath.startsWith(normalizedPath + '/')) {
78
- const rest = filePath.slice(normalizedPath.length + 1);
79
- const firstPart = rest.split('/')[0];
80
- if (firstPart) {
81
- entries.add(firstPart);
82
- }
83
- }
84
- }
85
- // Check directories
86
- const dirEntries = Array.from(this.directories);
87
- for (const dirPath of dirEntries) {
88
- if (dirPath.startsWith(normalizedPath + '/')) {
89
- const rest = dirPath.slice(normalizedPath.length + 1);
90
- const firstPart = rest.split('/')[0];
91
- if (firstPart) {
92
- entries.add(firstPart);
93
- }
94
- }
95
- }
96
- return Array.from(entries).sort();
97
- }
98
- async mkdir(path, options) {
99
- if (options?.recursive) {
100
- const parts = path.split('/').filter(Boolean);
101
- let current = '';
102
- for (const part of parts) {
103
- current += '/' + part;
104
- this.directories.add(current);
105
- }
106
- }
107
- else {
108
- this.directories.add(path);
109
- }
110
- }
111
- }
112
- // ============================================================================
113
- // FSxStorageAdapter Implementation
114
- // ============================================================================
115
- const encoder = new TextEncoder();
116
- const decoder = new TextDecoder();
117
- /**
118
- * FSx storage adapter implementing the StorageBackend interface.
119
- *
120
- * @description
121
- * This adapter uses fsx for all storage operations:
122
- * - CAS operations use fsx's git-compatible object storage
123
- * - Refs are stored as files at {rootPath}/refs/{refname}
124
- * - File operations are relative to the rootPath
125
- */
126
- export class FSxStorageAdapter {
127
- rootPath;
128
- storage;
129
- /**
130
- * Create a new FSxStorageAdapter
131
- *
132
- * @param rootPath - The root path for the Git repository (typically .git directory)
133
- */
134
- constructor(rootPath) {
135
- // Normalize root path - remove trailing slash
136
- this.rootPath = rootPath.endsWith('/') ? rootPath.slice(0, -1) : rootPath;
137
- // Use in-memory storage for now - in production this would be injected
138
- this.storage = new InMemoryStorage();
139
- }
140
- // ==========================================================================
141
- // Helper Methods
142
- // ==========================================================================
143
- /**
144
- * Resolve a relative path to an absolute path within the repository
145
- *
146
- * @param p - Relative path within the repository
147
- * @returns Absolute path
148
- */
149
- resolvePath(p) {
150
- // Handle empty path
151
- if (!p) {
152
- return this.rootPath;
153
- }
154
- // Handle absolute paths - just return as-is if already under rootPath
155
- if (p.startsWith('/')) {
156
- if (p.startsWith(this.rootPath)) {
157
- return p;
158
- }
159
- // Join with rootPath
160
- return this.rootPath + p;
161
- }
162
- // Relative path - join with rootPath
163
- return this.rootPath + '/' + p;
164
- }
165
- /**
166
- * Get the path for an object based on its SHA
167
- *
168
- * @param sha - 40-character SHA-1 hash
169
- * @returns Path in format: objects/xx/yyyy...
170
- */
171
- getObjectPath(sha) {
172
- const normalizedSha = sha.toLowerCase();
173
- const dir = normalizedSha.slice(0, 2);
174
- const filename = normalizedSha.slice(2);
175
- return this.resolvePath(`objects/${dir}/${filename}`);
176
- }
177
- /**
178
- * Get the path for a ref
179
- *
180
- * @param name - Ref name (e.g., 'refs/heads/main', 'HEAD')
181
- * @returns Absolute path to the ref file
182
- */
183
- getRefPath(name) {
184
- return this.resolvePath(name);
185
- }
186
- // ==========================================================================
187
- // Content-Addressable Storage (CAS) Operations
188
- // ==========================================================================
189
- /**
190
- * Store a Git object and return its SHA-1 hash.
191
- *
192
- * @description
193
- * Creates a Git object in the format: "{type} {size}\0{content}",
194
- * computes its SHA-1 hash, compresses it with zlib, and stores it.
195
- *
196
- * @param type - Object type: 'blob', 'tree', 'commit', or 'tag'
197
- * @param content - Raw object content (without Git header)
198
- * @returns 40-character lowercase hexadecimal SHA-1 hash
199
- */
200
- async putObject(type, content) {
201
- // Create the git object (header + content)
202
- const gitObject = createGitObject(type, content);
203
- // Compute SHA-1 hash of the uncompressed git object
204
- const hash = await sha1(gitObject);
205
- // Compress the git object with zlib
206
- const compressedData = await compress(gitObject);
207
- // Get the storage path from the hash
208
- const objectPath = this.getObjectPath(hash);
209
- // Ensure parent directory exists
210
- const dirPath = objectPath.substring(0, objectPath.lastIndexOf('/'));
211
- await this.storage.mkdir(dirPath, { recursive: true });
212
- // Write the compressed data to storage
213
- await this.storage.write(objectPath, compressedData);
214
- // Return the 40-character hex hash
215
- return hash;
216
- }
217
- /**
218
- * Retrieve a Git object by its SHA-1 hash.
219
- *
220
- * @param sha - 40-character SHA-1 hash (case-insensitive)
221
- * @returns Object with type and content, or null if not found
222
- */
223
- async getObject(sha) {
224
- // Normalize to lowercase
225
- const normalizedSha = sha.toLowerCase();
226
- // Get the storage path
227
- const objectPath = this.getObjectPath(normalizedSha);
228
- // Read compressed data from storage
229
- const compressedData = await this.storage.read(objectPath);
230
- if (!compressedData) {
231
- return null;
232
- }
233
- // Decompress the data
234
- const decompressed = await decompress(compressedData);
235
- // Parse git object format
236
- const { type, content } = parseGitObject(decompressed);
237
- return {
238
- type: type,
239
- content
240
- };
241
- }
242
- /**
243
- * Check if a Git object exists in storage.
244
- *
245
- * @param sha - 40-character SHA-1 hash (case-insensitive)
246
- * @returns True if the object exists, false otherwise
247
- */
248
- async hasObject(sha) {
249
- // Validate hash format
250
- if (!sha || (sha.length !== 40 && sha.length !== 64)) {
251
- return false;
252
- }
253
- if (!/^[0-9a-fA-F]+$/.test(sha)) {
254
- return false;
255
- }
256
- const normalizedSha = sha.toLowerCase();
257
- const objectPath = this.getObjectPath(normalizedSha);
258
- return this.storage.exists(objectPath);
259
- }
260
- /**
261
- * Delete a Git object from storage.
262
- *
263
- * @param sha - 40-character SHA-1 hash (case-insensitive)
264
- */
265
- async deleteObject(sha) {
266
- const normalizedSha = sha.toLowerCase();
267
- const objectPath = this.getObjectPath(normalizedSha);
268
- await this.storage.delete(objectPath);
269
- }
270
- // ==========================================================================
271
- // Reference Operations
272
- // ==========================================================================
273
- /**
274
- * Get a reference by name.
275
- *
276
- * @param name - Full ref name (e.g., 'HEAD', 'refs/heads/main')
277
- * @returns The reference or null if not found
278
- */
279
- async getRef(name) {
280
- const refPath = this.getRefPath(name);
281
- const data = await this.storage.read(refPath);
282
- if (!data) {
283
- return null;
284
- }
285
- const content = decoder.decode(data);
286
- const { type, target } = parseRefContent(content);
287
- return {
288
- name,
289
- target,
290
- type
291
- };
292
- }
293
- /**
294
- * Create or update a reference.
295
- *
296
- * @param name - Full ref name (e.g., 'HEAD', 'refs/heads/main')
297
- * @param ref - The reference object
298
- */
299
- async setRef(name, ref) {
300
- const refPath = this.getRefPath(name);
301
- // Ensure parent directory exists
302
- const dirPath = refPath.substring(0, refPath.lastIndexOf('/'));
303
- if (dirPath && dirPath !== this.rootPath) {
304
- await this.storage.mkdir(dirPath, { recursive: true });
305
- }
306
- const content = serializeRefContent(ref);
307
- await this.storage.write(refPath, encoder.encode(content));
308
- }
309
- /**
310
- * Delete a reference.
311
- *
312
- * @param name - Full ref name to delete
313
- */
314
- async deleteRef(name) {
315
- const refPath = this.getRefPath(name);
316
- await this.storage.delete(refPath);
317
- }
318
- /**
319
- * List references matching an optional prefix.
320
- *
321
- * @param prefix - Optional prefix to filter refs (e.g., 'refs/heads/')
322
- * @returns Array of matching references
323
- */
324
- async listRefs(prefix) {
325
- const refs = [];
326
- // Helper function to recursively read refs from a directory
327
- const readRefsFromDir = async (dirPath, refPrefix) => {
328
- const fullDirPath = this.resolvePath(dirPath);
329
- const exists = await this.storage.exists(fullDirPath);
330
- if (!exists) {
331
- return;
332
- }
333
- const entries = await this.storage.readdir(fullDirPath);
334
- for (const entry of entries) {
335
- const entryPath = `${dirPath}/${entry}`;
336
- const fullEntryPath = this.resolvePath(entryPath);
337
- const refName = `${refPrefix}${entry}`;
338
- // Try to read as a ref file
339
- const data = await this.storage.read(fullEntryPath);
340
- if (data) {
341
- // It's a file - parse as ref
342
- const content = decoder.decode(data);
343
- try {
344
- const { type, target } = parseRefContent(content);
345
- refs.push({ name: refName, target, type });
346
- }
347
- catch {
348
- // Not a valid ref file, skip
349
- }
350
- }
351
- else {
352
- // It might be a directory - recurse
353
- await readRefsFromDir(entryPath, refName + '/');
354
- }
355
- }
356
- };
357
- // Start from refs directory
358
- const refsDir = prefix ? prefix.replace(/\/$/, '') : 'refs';
359
- await readRefsFromDir(refsDir, prefix || 'refs/');
360
- // Also check HEAD if no prefix or if listing all
361
- if (!prefix) {
362
- const headRef = await this.getRef('HEAD');
363
- if (headRef) {
364
- refs.unshift(headRef);
365
- }
366
- }
367
- return refs;
368
- }
369
- // ==========================================================================
370
- // Raw File Operations
371
- // ==========================================================================
372
- /**
373
- * Read a raw file from the repository.
374
- *
375
- * @param path - Path relative to Git directory
376
- * @returns File contents as Uint8Array, or null if not found
377
- */
378
- async readFile(path) {
379
- const fullPath = this.resolvePath(path);
380
- return this.storage.read(fullPath);
381
- }
382
- /**
383
- * Write a raw file to the repository.
384
- *
385
- * @param path - Path relative to Git directory
386
- * @param content - File contents as Uint8Array
387
- */
388
- async writeFile(path, content) {
389
- const fullPath = this.resolvePath(path);
390
- // Ensure parent directory exists
391
- const dirPath = fullPath.substring(0, fullPath.lastIndexOf('/'));
392
- if (dirPath && dirPath !== this.rootPath) {
393
- await this.storage.mkdir(dirPath, { recursive: true });
394
- }
395
- await this.storage.write(fullPath, content);
396
- }
397
- /**
398
- * Delete a raw file from the repository.
399
- *
400
- * @param path - Path relative to Git directory
401
- */
402
- async deleteFile(path) {
403
- const fullPath = this.resolvePath(path);
404
- await this.storage.delete(fullPath);
405
- }
406
- /**
407
- * Check if a file or directory exists.
408
- *
409
- * @param path - Path relative to Git directory
410
- * @returns True if the path exists
411
- */
412
- async exists(path) {
413
- const fullPath = this.resolvePath(path);
414
- return this.storage.exists(fullPath);
415
- }
416
- // ==========================================================================
417
- // Directory Operations
418
- // ==========================================================================
419
- /**
420
- * List contents of a directory.
421
- *
422
- * @param path - Path relative to Git directory
423
- * @returns Array of file and directory names
424
- */
425
- async readdir(path) {
426
- const fullPath = this.resolvePath(path);
427
- try {
428
- return await this.storage.readdir(fullPath);
429
- }
430
- catch {
431
- // Return empty array if directory doesn't exist
432
- return [];
433
- }
434
- }
435
- /**
436
- * Create a directory.
437
- *
438
- * @param path - Path relative to Git directory
439
- * @param options - Options for directory creation
440
- */
441
- async mkdir(path, options) {
442
- const fullPath = this.resolvePath(path);
443
- await this.storage.mkdir(fullPath, options);
444
- }
445
- }
446
- // ============================================================================
447
- // Factory Function
448
- // ============================================================================
449
- /**
450
- * Create an FSx storage adapter.
451
- *
452
- * @description
453
- * Factory function for creating an FSxStorageAdapter instance.
454
- *
455
- * @param rootPath - The root path for the Git repository (typically .git directory)
456
- * @returns A StorageBackend instance backed by fsx
457
- *
458
- * @example
459
- * ```typescript
460
- * const storage = createFSxAdapter('/repos/my-project/.git')
461
- *
462
- * // Use the storage backend
463
- * const sha = await storage.putObject('blob', content)
464
- * const ref = await storage.getRef('HEAD')
465
- * ```
466
- */
467
- export function createFSxAdapter(rootPath) {
468
- return new FSxStorageAdapter(rootPath);
469
- }
470
- //# sourceMappingURL=fsx-adapter.js.map