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,705 +0,0 @@
1
- /**
2
- * @fileoverview Tree Diff Operations
3
- *
4
- * This module provides functionality for comparing Git trees and detecting
5
- * changes between them, including added, deleted, modified, renamed, and
6
- * copied files.
7
- *
8
- * ## Features
9
- *
10
- * - Compare two tree objects to detect changes
11
- * - Detect file additions, deletions, modifications
12
- * - Rename detection based on content similarity
13
- * - Copy detection
14
- * - Binary file detection
15
- * - Path filtering with glob patterns
16
- * - Type change detection (file to symlink, etc.)
17
- *
18
- * ## Usage Example
19
- *
20
- * ```typescript
21
- * import { diffTrees, DiffStatus } from './ops/tree-diff'
22
- *
23
- * // Compare two trees
24
- * const result = await diffTrees(store, oldTreeSha, newTreeSha, {
25
- * detectRenames: true,
26
- * similarityThreshold: 50
27
- * })
28
- *
29
- * // Process changes
30
- * for (const entry of result.entries) {
31
- * switch (entry.status) {
32
- * case DiffStatus.ADDED:
33
- * console.log(`+ ${entry.path}`)
34
- * break
35
- * case DiffStatus.DELETED:
36
- * console.log(`- ${entry.path}`)
37
- * break
38
- * case DiffStatus.MODIFIED:
39
- * console.log(`M ${entry.path}`)
40
- * break
41
- * case DiffStatus.RENAMED:
42
- * console.log(`R ${entry.oldPath} -> ${entry.path}`)
43
- * break
44
- * }
45
- * }
46
- *
47
- * console.log(`Stats: ${result.stats.added} added, ${result.stats.deleted} deleted`)
48
- * ```
49
- *
50
- * @module ops/tree-diff
51
- */
52
- /**
53
- * Status of a file in a diff.
54
- *
55
- * These status codes match Git's diff status output.
56
- *
57
- * @enum {string}
58
- */
59
- export var DiffStatus;
60
- (function (DiffStatus) {
61
- /** File was added */
62
- DiffStatus["ADDED"] = "A";
63
- /** File was deleted */
64
- DiffStatus["DELETED"] = "D";
65
- /** File was modified */
66
- DiffStatus["MODIFIED"] = "M";
67
- /** File was renamed */
68
- DiffStatus["RENAMED"] = "R";
69
- /** File was copied */
70
- DiffStatus["COPIED"] = "C";
71
- /** File type changed (e.g., file to symlink) */
72
- DiffStatus["TYPE_CHANGED"] = "T";
73
- /** Unmerged (conflict) */
74
- DiffStatus["UNMERGED"] = "U";
75
- })(DiffStatus || (DiffStatus = {}));
76
- /**
77
- * File mode constants for Git objects
78
- */
79
- export var FileMode;
80
- (function (FileMode) {
81
- /** Regular file (not executable) */
82
- FileMode["REGULAR"] = "100644";
83
- /** Executable file */
84
- FileMode["EXECUTABLE"] = "100755";
85
- /** Symbolic link */
86
- FileMode["SYMLINK"] = "120000";
87
- /** Git submodule (gitlink) */
88
- FileMode["GITLINK"] = "160000";
89
- /** Directory (tree) */
90
- FileMode["TREE"] = "040000";
91
- })(FileMode || (FileMode = {}));
92
- /**
93
- * Check if a file appears to be binary based on its content
94
- *
95
- * A file is considered binary if it contains null bytes in the first
96
- * 8000 bytes (similar to Git's heuristic).
97
- *
98
- * @param content - File content to check
99
- * @returns true if the file appears to be binary
100
- */
101
- export function isBinaryContent(content) {
102
- // Check first 8000 bytes for null bytes
103
- const checkLength = Math.min(content.length, 8000);
104
- for (let i = 0; i < checkLength; i++) {
105
- if (content[i] === 0x00) {
106
- return true;
107
- }
108
- }
109
- return false;
110
- }
111
- /**
112
- * Calculate similarity between two blobs for rename/copy detection
113
- *
114
- * Uses a simple heuristic based on shared content.
115
- *
116
- * @param store - Object store for retrieving blob contents
117
- * @param oldSha - SHA of the old blob
118
- * @param newSha - SHA of the new blob
119
- * @returns Promise resolving to similarity percentage (0-100)
120
- */
121
- export async function calculateSimilarity(store, oldSha, newSha) {
122
- // If same SHA, 100% similar
123
- if (oldSha === newSha) {
124
- return 100;
125
- }
126
- const [oldBlob, newBlob] = await Promise.all([
127
- store.getBlob(oldSha),
128
- store.getBlob(newSha)
129
- ]);
130
- if (!oldBlob || !newBlob) {
131
- return 0;
132
- }
133
- // Use a simple character-by-character comparison for similarity
134
- // This is a basic approach; a more sophisticated algorithm would use
135
- // something like xdiff or Myers diff
136
- const oldStr = new TextDecoder().decode(oldBlob);
137
- const newStr = new TextDecoder().decode(newBlob);
138
- if (oldStr === newStr) {
139
- return 100;
140
- }
141
- // Count matching characters at each position
142
- const maxLen = Math.max(oldStr.length, newStr.length);
143
- if (maxLen === 0) {
144
- return 100;
145
- }
146
- let matches = 0;
147
- const minLen = Math.min(oldStr.length, newStr.length);
148
- for (let i = 0; i < minLen; i++) {
149
- if (oldStr[i] === newStr[i]) {
150
- matches++;
151
- }
152
- }
153
- return Math.round((matches / maxLen) * 100);
154
- }
155
- /**
156
- * Parse a file mode string and determine its type
157
- *
158
- * @param mode - File mode string (e.g., '100644', '040000')
159
- * @returns Object with mode information
160
- */
161
- export function parseMode(mode) {
162
- return {
163
- isFile: mode === FileMode.REGULAR || mode === FileMode.EXECUTABLE,
164
- isDirectory: mode === FileMode.TREE,
165
- isSymlink: mode === FileMode.SYMLINK,
166
- isSubmodule: mode === FileMode.GITLINK,
167
- isExecutable: mode === FileMode.EXECUTABLE
168
- };
169
- }
170
- /**
171
- * Check if a mode change represents a significant type change
172
- *
173
- * @param oldMode - Old file mode
174
- * @param newMode - New file mode
175
- * @returns true if the mode change is significant (e.g., file to symlink)
176
- */
177
- export function isModeChangeSignificant(oldMode, newMode) {
178
- if (oldMode === newMode) {
179
- return false;
180
- }
181
- const oldParsed = parseMode(oldMode);
182
- const newParsed = parseMode(newMode);
183
- // Type changes are significant (file to symlink, file to submodule, etc.)
184
- if (oldParsed.isFile && newParsed.isSymlink)
185
- return true;
186
- if (oldParsed.isFile && newParsed.isSubmodule)
187
- return true;
188
- if (oldParsed.isSymlink && newParsed.isFile)
189
- return true;
190
- if (oldParsed.isSymlink && newParsed.isSubmodule)
191
- return true;
192
- if (oldParsed.isSubmodule && newParsed.isFile)
193
- return true;
194
- if (oldParsed.isSubmodule && newParsed.isSymlink)
195
- return true;
196
- // Regular to executable is not significant
197
- return false;
198
- }
199
- /**
200
- * Simple glob pattern matching
201
- */
202
- function matchGlob(pattern, path) {
203
- // Convert glob pattern to regex
204
- const regexPattern = pattern
205
- .replace(/\./g, '\\.')
206
- .replace(/\*\*/g, '<<<DOUBLESTAR>>>')
207
- .replace(/\*/g, '[^/]*')
208
- .replace(/<<<DOUBLESTAR>>>/g, '.*')
209
- .replace(/\?/g, '.');
210
- const regex = new RegExp(`^${regexPattern}$`);
211
- return regex.test(path);
212
- }
213
- /**
214
- * Filter diff entries by pathspecs
215
- *
216
- * @param entries - Diff entries to filter
217
- * @param pathspecs - Glob patterns to include
218
- * @param excludePaths - Paths to exclude
219
- * @returns Filtered entries
220
- */
221
- export function filterByPathspecs(entries, pathspecs, excludePaths) {
222
- if (!pathspecs && !excludePaths) {
223
- return entries;
224
- }
225
- return entries.filter(entry => {
226
- // Check exclude paths first
227
- if (excludePaths) {
228
- for (const pattern of excludePaths) {
229
- if (matchGlob(pattern, entry.path)) {
230
- return false;
231
- }
232
- }
233
- }
234
- // If no include pathspecs, include everything not excluded
235
- if (!pathspecs || pathspecs.length === 0) {
236
- return true;
237
- }
238
- // Check if path matches any include pattern
239
- for (const pattern of pathspecs) {
240
- if (matchGlob(pattern, entry.path)) {
241
- return true;
242
- }
243
- }
244
- return false;
245
- });
246
- }
247
- /**
248
- * Recursively walk a tree and collect all entries with full paths
249
- *
250
- * @param store - Object store for retrieving tree contents
251
- * @param treeSha - SHA of the tree to walk
252
- * @param prefix - Path prefix for entries
253
- * @returns Promise resolving to flat list of entries with full paths
254
- */
255
- export async function walkTree(store, treeSha, prefix) {
256
- const tree = await store.getTree(treeSha);
257
- if (!tree) {
258
- return [];
259
- }
260
- const results = [];
261
- for (const entry of tree.entries) {
262
- const fullPath = prefix ? `${prefix}/${entry.name}` : entry.name;
263
- if (entry.mode === FileMode.TREE) {
264
- // Recurse into subdirectory
265
- const subEntries = await walkTree(store, entry.sha, fullPath);
266
- results.push(...subEntries);
267
- }
268
- else {
269
- results.push({ ...entry, fullPath });
270
- }
271
- }
272
- return results;
273
- }
274
- /**
275
- * Helper to get type category for mode comparison
276
- */
277
- function getModeType(mode) {
278
- if (mode === FileMode.REGULAR || mode === FileMode.EXECUTABLE) {
279
- return 'file';
280
- }
281
- if (mode === FileMode.SYMLINK) {
282
- return 'symlink';
283
- }
284
- if (mode === FileMode.GITLINK) {
285
- return 'submodule';
286
- }
287
- if (mode === FileMode.TREE) {
288
- return 'tree';
289
- }
290
- return 'unknown';
291
- }
292
- /**
293
- * Compare two trees and return the differences
294
- *
295
- * @param store - Object store for retrieving tree contents
296
- * @param oldTreeSha - SHA of the old tree (null for initial commit comparison)
297
- * @param newTreeSha - SHA of the new tree (null to compare against empty)
298
- * @param options - Diff options
299
- * @returns Promise resolving to diff result
300
- */
301
- export async function diffTrees(store, oldTreeSha, newTreeSha, options = {}) {
302
- const { detectRenames: enableRenames = false, detectCopies: enableCopies = false, similarityThreshold = 50, pathspecs, excludePaths, detectBinary = false, recursive = true } = options;
303
- // Handle null on both sides
304
- if (oldTreeSha === null && newTreeSha === null) {
305
- return {
306
- entries: [],
307
- stats: { added: 0, deleted: 0, modified: 0, renamed: 0, copied: 0 }
308
- };
309
- }
310
- // Get old tree entries
311
- let oldEntries = new Map();
312
- if (oldTreeSha !== null) {
313
- const oldTree = await store.getTree(oldTreeSha);
314
- if (!oldTree) {
315
- throw new Error(`Tree not found: ${oldTreeSha}`);
316
- }
317
- if (recursive) {
318
- const entries = await walkTree(store, oldTreeSha);
319
- for (const entry of entries) {
320
- oldEntries.set(entry.fullPath, entry);
321
- }
322
- }
323
- else {
324
- for (const entry of oldTree.entries) {
325
- oldEntries.set(entry.name, { ...entry, fullPath: entry.name });
326
- }
327
- }
328
- }
329
- // Get new tree entries
330
- let newEntries = new Map();
331
- if (newTreeSha !== null) {
332
- const newTree = await store.getTree(newTreeSha);
333
- if (!newTree) {
334
- throw new Error(`Tree not found: ${newTreeSha}`);
335
- }
336
- if (recursive) {
337
- const entries = await walkTree(store, newTreeSha);
338
- for (const entry of entries) {
339
- newEntries.set(entry.fullPath, entry);
340
- }
341
- }
342
- else {
343
- for (const entry of newTree.entries) {
344
- newEntries.set(entry.name, { ...entry, fullPath: entry.name });
345
- }
346
- }
347
- }
348
- const diffEntries = [];
349
- // Find deleted and modified files
350
- for (const [path, oldEntry] of oldEntries) {
351
- const newEntry = newEntries.get(path);
352
- if (!newEntry) {
353
- // File was deleted
354
- diffEntries.push({
355
- path,
356
- status: DiffStatus.DELETED,
357
- oldMode: oldEntry.mode,
358
- newMode: null,
359
- oldSha: oldEntry.sha,
360
- newSha: null
361
- });
362
- }
363
- else if (oldEntry.sha !== newEntry.sha || oldEntry.mode !== newEntry.mode) {
364
- // File was modified or type changed
365
- const oldType = getModeType(oldEntry.mode);
366
- const newType = getModeType(newEntry.mode);
367
- if (oldType !== newType) {
368
- // Type changed (e.g., file to symlink)
369
- diffEntries.push({
370
- path,
371
- status: DiffStatus.TYPE_CHANGED,
372
- oldMode: oldEntry.mode,
373
- newMode: newEntry.mode,
374
- oldSha: oldEntry.sha,
375
- newSha: newEntry.sha
376
- });
377
- }
378
- else {
379
- // Content or mode modified
380
- diffEntries.push({
381
- path,
382
- status: DiffStatus.MODIFIED,
383
- oldMode: oldEntry.mode,
384
- newMode: newEntry.mode,
385
- oldSha: oldEntry.sha,
386
- newSha: newEntry.sha
387
- });
388
- }
389
- }
390
- }
391
- // Find added files
392
- for (const [path, newEntry] of newEntries) {
393
- if (!oldEntries.has(path)) {
394
- diffEntries.push({
395
- path,
396
- status: DiffStatus.ADDED,
397
- oldMode: null,
398
- newMode: newEntry.mode,
399
- oldSha: null,
400
- newSha: newEntry.sha
401
- });
402
- }
403
- }
404
- // Detect binary files if enabled
405
- if (detectBinary) {
406
- for (const entry of diffEntries) {
407
- const sha = entry.newSha || entry.oldSha;
408
- if (sha) {
409
- const blob = await store.getBlob(sha);
410
- if (blob) {
411
- entry.isBinary = isBinaryContent(blob);
412
- }
413
- }
414
- }
415
- }
416
- // Detect renames if enabled
417
- let finalEntries = diffEntries;
418
- if (enableRenames) {
419
- finalEntries = await detectRenames(store, finalEntries, { similarityThreshold });
420
- }
421
- // Detect copies if enabled
422
- if (enableCopies) {
423
- // Build map of existing paths from old tree
424
- const existingPaths = new Map();
425
- for (const [path, entry] of oldEntries) {
426
- existingPaths.set(path, entry.sha);
427
- }
428
- finalEntries = await detectCopies(store, finalEntries, existingPaths, { similarityThreshold });
429
- }
430
- // Apply path filters
431
- if (pathspecs || excludePaths) {
432
- finalEntries = filterByPathspecs(finalEntries, pathspecs, excludePaths);
433
- }
434
- // Calculate stats
435
- const stats = {
436
- added: 0,
437
- deleted: 0,
438
- modified: 0,
439
- renamed: 0,
440
- copied: 0
441
- };
442
- for (const entry of finalEntries) {
443
- switch (entry.status) {
444
- case DiffStatus.ADDED:
445
- stats.added++;
446
- break;
447
- case DiffStatus.DELETED:
448
- stats.deleted++;
449
- break;
450
- case DiffStatus.MODIFIED:
451
- case DiffStatus.TYPE_CHANGED:
452
- stats.modified++;
453
- break;
454
- case DiffStatus.RENAMED:
455
- stats.renamed++;
456
- break;
457
- case DiffStatus.COPIED:
458
- stats.copied++;
459
- break;
460
- }
461
- }
462
- return { entries: finalEntries, stats };
463
- }
464
- /**
465
- * Detect renames in a set of diff entries
466
- *
467
- * This function takes a list of added and deleted files and attempts to
468
- * match them based on content similarity to detect renames.
469
- *
470
- * @param store - Object store for retrieving blob contents
471
- * @param entries - Initial diff entries (before rename detection)
472
- * @param options - Diff options (particularly similarityThreshold)
473
- * @returns Promise resolving to entries with renames detected
474
- */
475
- export async function detectRenames(store, entries, options = {}) {
476
- const { similarityThreshold = 50 } = options;
477
- const deleted = entries.filter(e => e.status === DiffStatus.DELETED);
478
- const added = entries.filter(e => e.status === DiffStatus.ADDED);
479
- const other = entries.filter(e => e.status !== DiffStatus.DELETED && e.status !== DiffStatus.ADDED);
480
- const matchedDeleted = new Set();
481
- const matchedAdded = new Set();
482
- const renames = [];
483
- // Try to match deleted files with added files
484
- for (const del of deleted) {
485
- if (matchedDeleted.has(del.path))
486
- continue;
487
- let bestMatch = null;
488
- let bestSimilarity = 0;
489
- for (const add of added) {
490
- if (matchedAdded.has(add.path))
491
- continue;
492
- // Check if same SHA (exact rename)
493
- if (del.oldSha === add.newSha) {
494
- bestMatch = add;
495
- bestSimilarity = 100;
496
- break;
497
- }
498
- // Calculate similarity if both SHAs exist
499
- if (del.oldSha && add.newSha) {
500
- const similarity = await calculateSimilarity(store, del.oldSha, add.newSha);
501
- if (similarity >= similarityThreshold && similarity > bestSimilarity) {
502
- bestMatch = add;
503
- bestSimilarity = similarity;
504
- }
505
- }
506
- }
507
- if (bestMatch && bestSimilarity >= similarityThreshold) {
508
- matchedDeleted.add(del.path);
509
- matchedAdded.add(bestMatch.path);
510
- renames.push({
511
- path: bestMatch.path,
512
- oldPath: del.path,
513
- status: DiffStatus.RENAMED,
514
- oldMode: del.oldMode,
515
- newMode: bestMatch.newMode,
516
- oldSha: del.oldSha,
517
- newSha: bestMatch.newSha,
518
- similarity: bestSimilarity
519
- });
520
- }
521
- }
522
- // Collect unmatched deleted and added entries
523
- const result = [...other, ...renames];
524
- for (const del of deleted) {
525
- if (!matchedDeleted.has(del.path)) {
526
- result.push(del);
527
- }
528
- }
529
- for (const add of added) {
530
- if (!matchedAdded.has(add.path)) {
531
- result.push(add);
532
- }
533
- }
534
- return result;
535
- }
536
- /**
537
- * Detect copies in a set of diff entries
538
- *
539
- * This function takes a list of diff entries and attempts to detect
540
- * if any added files are copies of existing files.
541
- *
542
- * @param store - Object store for retrieving blob contents
543
- * @param entries - Initial diff entries
544
- * @param existingPaths - Map of existing paths to their SHAs
545
- * @param options - Diff options
546
- * @returns Promise resolving to entries with copies detected
547
- */
548
- export async function detectCopies(store, entries, existingPaths, options = {}) {
549
- const { similarityThreshold = 50 } = options;
550
- const result = [];
551
- for (const entry of entries) {
552
- if (entry.status !== DiffStatus.ADDED) {
553
- result.push(entry);
554
- continue;
555
- }
556
- let bestMatch = null;
557
- let bestSimilarity = 0;
558
- for (const [path, sha] of existingPaths) {
559
- // Check for exact match
560
- if (sha === entry.newSha) {
561
- bestMatch = { path, sha };
562
- bestSimilarity = 100;
563
- break;
564
- }
565
- // Calculate similarity
566
- if (entry.newSha) {
567
- const similarity = await calculateSimilarity(store, sha, entry.newSha);
568
- if (similarity >= similarityThreshold && similarity > bestSimilarity) {
569
- bestMatch = { path, sha };
570
- bestSimilarity = similarity;
571
- }
572
- }
573
- }
574
- if (bestMatch && bestSimilarity >= similarityThreshold) {
575
- result.push({
576
- path: entry.path,
577
- oldPath: bestMatch.path,
578
- status: DiffStatus.COPIED,
579
- oldMode: entry.newMode, // Use same mode for copied source
580
- newMode: entry.newMode,
581
- oldSha: bestMatch.sha,
582
- newSha: entry.newSha,
583
- similarity: bestSimilarity
584
- });
585
- }
586
- else {
587
- result.push(entry);
588
- }
589
- }
590
- return result;
591
- }
592
- /**
593
- * Compare a tree to the index (staging area)
594
- *
595
- * @param store - Object store for retrieving tree contents
596
- * @param treeSha - SHA of the tree to compare (typically HEAD)
597
- * @param index - Index entries to compare against
598
- * @param options - Diff options
599
- * @returns Promise resolving to diff result
600
- */
601
- export async function diffTreeToIndex(store, treeSha, index, options = {}) {
602
- // Get tree entries
603
- const treeEntries = new Map();
604
- if (treeSha !== null) {
605
- const entries = await walkTree(store, treeSha);
606
- for (const entry of entries) {
607
- treeEntries.set(entry.fullPath, { mode: entry.mode, sha: entry.sha });
608
- }
609
- }
610
- // Build index map
611
- const indexEntries = new Map();
612
- for (const entry of index) {
613
- if (entry.stage === 0) {
614
- indexEntries.set(entry.path, entry);
615
- }
616
- }
617
- const diffEntries = [];
618
- // Find deleted and modified files
619
- for (const [path, treeEntry] of treeEntries) {
620
- const indexEntry = indexEntries.get(path);
621
- if (!indexEntry) {
622
- // File was deleted (in index)
623
- diffEntries.push({
624
- path,
625
- status: DiffStatus.DELETED,
626
- oldMode: treeEntry.mode,
627
- newMode: null,
628
- oldSha: treeEntry.sha,
629
- newSha: null
630
- });
631
- }
632
- else if (treeEntry.sha !== indexEntry.sha || treeEntry.mode !== indexEntry.mode) {
633
- // File was modified
634
- diffEntries.push({
635
- path,
636
- status: DiffStatus.MODIFIED,
637
- oldMode: treeEntry.mode,
638
- newMode: indexEntry.mode,
639
- oldSha: treeEntry.sha,
640
- newSha: indexEntry.sha
641
- });
642
- }
643
- }
644
- // Find added files
645
- for (const [path, indexEntry] of indexEntries) {
646
- if (!treeEntries.has(path)) {
647
- diffEntries.push({
648
- path,
649
- status: DiffStatus.ADDED,
650
- oldMode: null,
651
- newMode: indexEntry.mode,
652
- oldSha: null,
653
- newSha: indexEntry.sha
654
- });
655
- }
656
- }
657
- // Apply filters if needed
658
- let finalEntries = diffEntries;
659
- if (options.pathspecs || options.excludePaths) {
660
- finalEntries = filterByPathspecs(finalEntries, options.pathspecs, options.excludePaths);
661
- }
662
- // Calculate stats
663
- const stats = {
664
- added: 0,
665
- deleted: 0,
666
- modified: 0,
667
- renamed: 0,
668
- copied: 0
669
- };
670
- for (const entry of finalEntries) {
671
- switch (entry.status) {
672
- case DiffStatus.ADDED:
673
- stats.added++;
674
- break;
675
- case DiffStatus.DELETED:
676
- stats.deleted++;
677
- break;
678
- case DiffStatus.MODIFIED:
679
- stats.modified++;
680
- break;
681
- case DiffStatus.RENAMED:
682
- stats.renamed++;
683
- break;
684
- case DiffStatus.COPIED:
685
- stats.copied++;
686
- break;
687
- }
688
- }
689
- return { entries: finalEntries, stats };
690
- }
691
- /**
692
- * Compare a tree to working directory entries
693
- *
694
- * @param store - Object store for retrieving tree contents
695
- * @param treeSha - SHA of the tree to compare
696
- * @param workingEntries - Working directory file entries
697
- * @param options - Diff options
698
- * @returns Promise resolving to diff result
699
- */
700
- export async function diffTreeToWorktree(store, treeSha, workingEntries, options = {}) {
701
- // This is essentially the same as diffTreeToIndex
702
- // Working directory entries are represented the same way
703
- return diffTreeToIndex(store, treeSha, workingEntries, options);
704
- }
705
- //# sourceMappingURL=tree-diff.js.map