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,855 +0,0 @@
1
- /**
2
- * @fileoverview Three-way Merge Implementation for Git
3
- *
4
- * This module provides a complete implementation of Git's three-way merge algorithm,
5
- * enabling branch merging with automatic conflict detection and resolution capabilities.
6
- *
7
- * ## Overview
8
- *
9
- * The three-way merge algorithm works by:
10
- * 1. Finding the common ancestor (merge base) of two commits
11
- * 2. Comparing both branches against this base to identify changes
12
- * 3. Automatically merging non-conflicting changes
13
- * 4. Detecting and reporting conflicts for manual resolution
14
- *
15
- * ## Supported Features
16
- *
17
- * - Fast-forward merges when possible
18
- * - Three-way content merging for text files
19
- * - Binary file detection and handling
20
- * - Multiple conflict types (content, add-add, modify-delete, etc.)
21
- * - Conflict resolution strategies (ours, theirs, custom)
22
- * - Merge state persistence for multi-step conflict resolution
23
- *
24
- * ## Usage Example
25
- *
26
- * ```typescript
27
- * import { merge, resolveConflict, continueMerge } from './ops/merge'
28
- *
29
- * // Perform a merge
30
- * const result = await merge(storage, currentBranchSha, featureBranchSha, {
31
- * message: 'Merge feature branch',
32
- * allowFastForward: true
33
- * })
34
- *
35
- * if (result.status === 'conflicted') {
36
- * // Resolve conflicts
37
- * for (const conflict of result.conflicts) {
38
- * await resolveConflict(storage, conflict.path, { resolution: 'ours' })
39
- * }
40
- * // Complete the merge
41
- * await continueMerge(storage)
42
- * }
43
- * ```
44
- *
45
- * @module ops/merge
46
- */
47
- /**
48
- * Types of merge conflicts that can occur during a three-way merge.
49
- *
50
- * @description
51
- * Each conflict type represents a different scenario where automatic
52
- * merging is not possible and manual intervention is required.
53
- *
54
- * - `content`: Both sides modified the same file with different changes
55
- * - `add-add`: Both sides added the same file with different content
56
- * - `modify-delete`: One side modified a file that the other side deleted
57
- * - `delete-modify`: One side deleted a file that the other side modified
58
- * - `rename-rename`: Both sides renamed the same file to different names
59
- * - `rename-delete`: One side renamed a file that the other side deleted
60
- * - `directory-file`: One side has a directory where the other has a file
61
- */
62
- export type ConflictType = 'content' | 'add-add' | 'modify-delete' | 'delete-modify' | 'rename-rename' | 'rename-delete' | 'directory-file';
63
- /**
64
- * Available merge strategies for combining branches.
65
- *
66
- * @description
67
- * Different strategies determine how the merge algorithm handles
68
- * combining changes from multiple branches.
69
- *
70
- * - `recursive`: Default three-way merge with recursive conflict resolution
71
- * - `ours`: Automatically resolve all conflicts favoring the current branch
72
- * - `theirs`: Automatically resolve all conflicts favoring the merged branch
73
- * - `octopus`: Merge multiple branches simultaneously (no conflict resolution)
74
- * - `subtree`: Merge into a subdirectory of the current tree
75
- */
76
- export type MergeStrategy = 'recursive' | 'ours' | 'theirs' | 'octopus' | 'subtree';
77
- /**
78
- * Status indicating the outcome of a merge operation.
79
- *
80
- * @description
81
- * The merge status determines what action, if any, needs to be taken
82
- * after a merge operation completes.
83
- *
84
- * - `fast-forward`: Branch pointer was simply moved forward (no merge commit)
85
- * - `merged`: Changes were successfully combined into a merge commit
86
- * - `conflicted`: Merge has conflicts requiring manual resolution
87
- * - `up-to-date`: Target branch is already merged; nothing to do
88
- * - `aborted`: Merge was cancelled and changes were rolled back
89
- * - `in-progress`: Merge started but not yet completed (conflicts pending)
90
- */
91
- export type MergeStatus = 'fast-forward' | 'merged' | 'conflicted' | 'up-to-date' | 'aborted' | 'in-progress';
92
- /**
93
- * Represents the position and content of conflict markers in a file.
94
- *
95
- * @description
96
- * When a content conflict occurs, the file is written with standard Git
97
- * conflict markers. This interface describes the location and content
98
- * of each conflicting section.
99
- *
100
- * @example
101
- * ```typescript
102
- * // A typical conflict marker structure in a file:
103
- * // <<<<<<< ours
104
- * // our changes here
105
- * // =======
106
- * // their changes here
107
- * // >>>>>>> theirs
108
- *
109
- * const marker: ConflictMarker = {
110
- * startLine: 10,
111
- * endLine: 16,
112
- * baseContent: 'original line',
113
- * oursContent: 'our changes here',
114
- * theirsContent: 'their changes here'
115
- * }
116
- * ```
117
- */
118
- export interface ConflictMarker {
119
- /** Line number where the conflict marker starts (1-indexed) */
120
- startLine: number;
121
- /** Line number where the conflict marker ends (1-indexed) */
122
- endLine: number;
123
- /** The conflicting content from the base (common ancestor) version */
124
- baseContent?: string;
125
- /** The conflicting content from our (current branch) version */
126
- oursContent: string;
127
- /** The conflicting content from their (merged branch) version */
128
- theirsContent: string;
129
- }
130
- /**
131
- * Represents a single merge conflict that requires resolution.
132
- *
133
- * @description
134
- * A MergeConflict contains all information needed to understand and
135
- * resolve a conflict between two versions of a file. It includes
136
- * references to all three versions (base, ours, theirs) when available.
137
- *
138
- * @example
139
- * ```typescript
140
- * const conflict: MergeConflict = {
141
- * type: 'content',
142
- * path: 'src/utils.ts',
143
- * baseSha: 'abc123...',
144
- * oursSha: 'def456...',
145
- * theirsSha: 'ghi789...',
146
- * baseMode: '100644',
147
- * oursMode: '100644',
148
- * theirsMode: '100644',
149
- * conflictedContent: mergedContentWithMarkers,
150
- * markers: [{ startLine: 10, endLine: 16, ... }]
151
- * }
152
- * ```
153
- */
154
- export interface MergeConflict {
155
- /** The type of conflict that occurred */
156
- type: ConflictType;
157
- /** Path to the conflicted file relative to repository root */
158
- path: string;
159
- /** SHA of the file in the base (common ancestor) commit */
160
- baseSha?: string;
161
- /** SHA of the file in our (current branch) commit */
162
- oursSha?: string;
163
- /** SHA of the file in their (merged branch) commit */
164
- theirsSha?: string;
165
- /** File mode (permissions) in the base version */
166
- baseMode?: string;
167
- /** File mode (permissions) in our version */
168
- oursMode?: string;
169
- /** File mode (permissions) in their version */
170
- theirsMode?: string;
171
- /** Merged content with conflict markers embedded (for content conflicts) */
172
- conflictedContent?: Uint8Array;
173
- /** Detailed information about each conflict region in the file */
174
- markers?: ConflictMarker[];
175
- /** Original path if this conflict involves a rename */
176
- originalPath?: string;
177
- /** Renamed paths when both sides renamed the same file differently */
178
- renamedPaths?: {
179
- /** Path the file was renamed to in our branch */
180
- ours?: string;
181
- /** Path the file was renamed to in their branch */
182
- theirs?: string;
183
- };
184
- }
185
- /**
186
- * Configuration options for merge operations.
187
- *
188
- * @description
189
- * These options control how the merge algorithm behaves, including
190
- * whether to allow fast-forward merges, how to handle conflicts,
191
- * and metadata for the resulting merge commit.
192
- *
193
- * @example
194
- * ```typescript
195
- * const options: MergeOptions = {
196
- * strategy: 'recursive',
197
- * allowFastForward: true,
198
- * message: 'Merge feature/new-feature into main',
199
- * author: {
200
- * name: 'Developer',
201
- * email: 'dev@example.com'
202
- * },
203
- * detectRenames: true,
204
- * renameThreshold: 60
205
- * }
206
- * ```
207
- */
208
- export interface MergeOptions {
209
- /** Merge strategy to use (default: 'recursive') */
210
- strategy?: MergeStrategy;
211
- /** Whether to allow fast-forward merges when possible (default: true) */
212
- allowFastForward?: boolean;
213
- /** Only allow fast-forward merges; fail if not possible (default: false) */
214
- fastForwardOnly?: boolean;
215
- /** Automatically resolve conflicts using the specified strategy (default: false) */
216
- autoResolve?: boolean;
217
- /** Strategy for automatic conflict resolution when autoResolve is true */
218
- conflictStrategy?: 'ours' | 'theirs' | 'union';
219
- /** Commit message for the merge commit */
220
- message?: string;
221
- /** Stage changes but do not create a merge commit (default: false) */
222
- noCommit?: boolean;
223
- /** Squash all commits from the merged branch into a single change (default: false) */
224
- squash?: boolean;
225
- /** Additional branch SHAs for octopus merges */
226
- additionalBranches?: string[];
227
- /** Similarity threshold for rename detection (0-100, default: 50) */
228
- renameThreshold?: number;
229
- /** Enable rename detection during merge (default: true) */
230
- detectRenames?: boolean;
231
- /** Enable copy detection during merge (default: false) */
232
- detectCopies?: boolean;
233
- /** Author information for the merge commit */
234
- author?: {
235
- /** Author's name */
236
- name: string;
237
- /** Author's email address */
238
- email: string;
239
- /** Unix timestamp in seconds */
240
- timestamp?: number;
241
- /** Timezone offset (e.g., '+0000', '-0500') */
242
- timezone?: string;
243
- };
244
- /** Committer information for the merge commit (defaults to author if not specified) */
245
- committer?: {
246
- /** Committer's name */
247
- name: string;
248
- /** Committer's email address */
249
- email: string;
250
- /** Unix timestamp in seconds */
251
- timestamp?: number;
252
- /** Timezone offset (e.g., '+0000', '-0500') */
253
- timezone?: string;
254
- };
255
- }
256
- /**
257
- * Statistics about files changed during a merge operation.
258
- *
259
- * @description
260
- * Provides a summary of what changes were made during the merge,
261
- * useful for displaying merge summaries to users.
262
- */
263
- export interface MergeStats {
264
- /** Number of files that were added */
265
- filesAdded: number;
266
- /** Number of files that were modified */
267
- filesModified: number;
268
- /** Number of files that were deleted */
269
- filesDeleted: number;
270
- /** Number of files that were renamed */
271
- filesRenamed: number;
272
- /** Number of binary files that were changed */
273
- binaryFilesChanged: number;
274
- /** Total lines added across all text files */
275
- linesAdded: number;
276
- /** Total lines removed across all text files */
277
- linesRemoved: number;
278
- }
279
- /**
280
- * Result returned from a merge operation.
281
- *
282
- * @description
283
- * Contains complete information about the merge outcome, including
284
- * the status, any conflicts that occurred, and statistics about
285
- * the changes made.
286
- *
287
- * @example
288
- * ```typescript
289
- * const result = await merge(storage, oursSha, theirsSha, options)
290
- *
291
- * switch (result.status) {
292
- * case 'fast-forward':
293
- * console.log(`Fast-forwarded to ${result.treeSha}`)
294
- * break
295
- * case 'merged':
296
- * console.log(`Created merge commit ${result.commitSha}`)
297
- * break
298
- * case 'conflicted':
299
- * console.log(`${result.conflicts?.length} conflicts to resolve`)
300
- * break
301
- * case 'up-to-date':
302
- * console.log('Already up to date')
303
- * break
304
- * }
305
- * ```
306
- */
307
- export interface MergeResult {
308
- /** The outcome status of the merge operation */
309
- status: MergeStatus;
310
- /** SHA of the created merge commit (if a commit was created) */
311
- commitSha?: string;
312
- /** SHA of the resulting merged tree */
313
- treeSha?: string;
314
- /** SHA of the common ancestor commit used as merge base */
315
- baseSha?: string;
316
- /** SHA of the current branch's commit before the merge */
317
- oursSha: string;
318
- /** SHA of the commit that was merged in */
319
- theirsSha: string;
320
- /** List of conflicts if status is 'conflicted' */
321
- conflicts?: MergeConflict[];
322
- /** Statistics about files changed during the merge */
323
- stats?: MergeStats;
324
- /** The merge commit message */
325
- message?: string;
326
- /** Whether this was a fast-forward merge (no merge commit created) */
327
- fastForward: boolean;
328
- }
329
- /**
330
- * Persistent state of an in-progress merge operation.
331
- *
332
- * @description
333
- * When a merge results in conflicts, this state is persisted to allow
334
- * the user to resolve conflicts and continue the merge in a separate
335
- * operation. Corresponds to Git's .git/MERGE_HEAD and related files.
336
- *
337
- * @example
338
- * ```typescript
339
- * const state = await storage.readMergeState()
340
- * if (state) {
341
- * console.log(`Merge in progress from ${state.mergeHead}`)
342
- * console.log(`${state.unresolvedConflicts.length} conflicts remaining`)
343
- * }
344
- * ```
345
- */
346
- export interface MergeState {
347
- /** SHA of the commit being merged (stored in MERGE_HEAD) */
348
- mergeHead: string;
349
- /** SHA of HEAD before the merge started (stored in ORIG_HEAD) */
350
- origHead: string;
351
- /** Commit message for the eventual merge commit */
352
- message: string;
353
- /** Special merge mode if applicable */
354
- mode?: 'squash' | 'no-ff';
355
- /** Conflicts that have not yet been resolved */
356
- unresolvedConflicts: MergeConflict[];
357
- /** Conflicts that have been resolved */
358
- resolvedConflicts: MergeConflict[];
359
- /** Options that were passed to the original merge operation */
360
- options: MergeOptions;
361
- }
362
- /**
363
- * Options for resolving an individual merge conflict.
364
- *
365
- * @description
366
- * Specifies how to resolve a particular conflict. Can use one of the
367
- * three-way merge versions (ours, theirs, base) or provide custom content.
368
- *
369
- * @example
370
- * ```typescript
371
- * // Use our version
372
- * await resolveConflict(storage, 'file.ts', { resolution: 'ours' })
373
- *
374
- * // Use their version
375
- * await resolveConflict(storage, 'file.ts', { resolution: 'theirs' })
376
- *
377
- * // Provide custom merged content
378
- * await resolveConflict(storage, 'file.ts', {
379
- * resolution: 'custom',
380
- * customContent: encoder.encode('manually merged content')
381
- * })
382
- * ```
383
- */
384
- export interface ResolveOptions {
385
- /** Which version to use for resolution */
386
- resolution: 'ours' | 'theirs' | 'base' | 'custom';
387
- /** Custom content when resolution is 'custom' */
388
- customContent?: Uint8Array;
389
- /** Custom file mode when resolution is 'custom' */
390
- customMode?: string;
391
- }
392
- /**
393
- * Result of resolving a single conflict.
394
- *
395
- * @description
396
- * Indicates whether the conflict was successfully resolved and how
397
- * many conflicts remain to be resolved before the merge can continue.
398
- */
399
- export interface ResolveResult {
400
- /** Whether the resolution was successful */
401
- success: boolean;
402
- /** Path of the file that was resolved */
403
- path: string;
404
- /** Error message if resolution failed */
405
- error?: string;
406
- /** Number of conflicts still remaining after this resolution */
407
- remainingConflicts: number;
408
- }
409
- /**
410
- * Result of merge management operations (abort, continue).
411
- *
412
- * @description
413
- * Used for operations that manage merge state rather than performing
414
- * the actual merge, such as aborting or continuing a conflicted merge.
415
- */
416
- export interface MergeOperationResult {
417
- /** Whether the operation completed successfully */
418
- success: boolean;
419
- /** Error message if the operation failed */
420
- error?: string;
421
- /** Current HEAD SHA after the operation */
422
- headSha?: string;
423
- /** Human-readable status message */
424
- message?: string;
425
- }
426
- /**
427
- * Extended object type that may include parsed commit/tree data.
428
- *
429
- * @description
430
- * Internal type used to represent Git objects that may have been
431
- * pre-parsed for efficiency in testing or caching scenarios.
432
- *
433
- * @internal
434
- */
435
- interface ExtendedObject {
436
- /** Object type ('commit', 'tree', 'blob', 'tag') */
437
- type: string;
438
- /** Raw object data */
439
- data: Uint8Array;
440
- /** Pre-parsed tree SHA for commit objects */
441
- tree?: string;
442
- /** Pre-parsed parent SHAs for commit objects */
443
- parents?: string[];
444
- /** Pre-parsed entries for tree objects */
445
- entries?: Array<{
446
- mode: string;
447
- name: string;
448
- sha: string;
449
- }>;
450
- }
451
- /**
452
- * Storage interface required for merge operations.
453
- *
454
- * @description
455
- * Defines the storage layer abstraction that merge operations use to
456
- * read and write Git objects, references, and merge state. Implementations
457
- * must provide all methods for merge functionality to work correctly.
458
- *
459
- * @example
460
- * ```typescript
461
- * class GitStorage implements MergeStorage {
462
- * async readObject(sha: string) {
463
- * // Read from .git/objects
464
- * }
465
- * async writeObject(type: string, data: Uint8Array) {
466
- * // Write to .git/objects and return SHA
467
- * }
468
- * // ... other methods
469
- * }
470
- * ```
471
- */
472
- export interface MergeStorage {
473
- /**
474
- * Read a Git object by its SHA.
475
- * @param sha - The 40-character hexadecimal SHA
476
- * @returns The object if found, null otherwise
477
- */
478
- readObject(sha: string): Promise<ExtendedObject | null>;
479
- /**
480
- * Write a Git object and return its SHA.
481
- * @param type - Object type ('commit', 'tree', 'blob', 'tag')
482
- * @param data - Raw object content
483
- * @returns The SHA of the written object
484
- */
485
- writeObject(type: string, data: Uint8Array): Promise<string>;
486
- /**
487
- * Read a Git reference (branch, tag, etc.).
488
- * @param ref - Reference path (e.g., 'refs/heads/main')
489
- * @returns The SHA the reference points to, or null
490
- */
491
- readRef(ref: string): Promise<string | null>;
492
- /**
493
- * Write/update a Git reference.
494
- * @param ref - Reference path
495
- * @param sha - SHA to point the reference to
496
- */
497
- writeRef(ref: string, sha: string): Promise<void>;
498
- /**
499
- * Read the current merge state if a merge is in progress.
500
- * @returns Merge state if present, null otherwise
501
- */
502
- readMergeState(): Promise<MergeState | null>;
503
- /**
504
- * Persist merge state for conflict resolution.
505
- * @param state - The merge state to persist
506
- */
507
- writeMergeState(state: MergeState): Promise<void>;
508
- /**
509
- * Delete merge state after merge completes or is aborted.
510
- */
511
- deleteMergeState(): Promise<void>;
512
- /**
513
- * Stage a file in the index.
514
- * @param path - File path
515
- * @param sha - Blob SHA
516
- * @param mode - File mode
517
- * @param stage - Stage number (0 for normal, 1-3 for conflicts)
518
- */
519
- stageFile(path: string, sha: string, mode: string, stage?: number): Promise<void>;
520
- /**
521
- * Get all entries from the current index.
522
- * @returns Map of path to index entry
523
- */
524
- getIndex(): Promise<Map<string, {
525
- sha: string;
526
- mode: string;
527
- stage: number;
528
- }>>;
529
- }
530
- /**
531
- * Performs a three-way merge between the current branch and another commit.
532
- *
533
- * @description
534
- * This function implements Git's three-way merge algorithm:
535
- * 1. Find the common ancestor (merge base) of the two commits
536
- * 2. Compare both sides against the base to identify changes
537
- * 3. Apply non-conflicting changes automatically
538
- * 4. Identify and report conflicts for manual resolution
539
- *
540
- * The merge can result in several outcomes:
541
- * - **fast-forward**: If the current branch is an ancestor of the target,
542
- * the branch pointer is simply moved forward
543
- * - **merged**: Changes were successfully combined into a merge commit
544
- * - **conflicted**: Some changes conflict and require manual resolution
545
- * - **up-to-date**: The target is already merged; nothing to do
546
- *
547
- * @param storage - The storage interface for reading/writing Git objects
548
- * @param oursSha - SHA of the current branch's HEAD commit
549
- * @param theirsSha - SHA of the commit to merge into the current branch
550
- * @param options - Configuration options for the merge operation
551
- *
552
- * @returns A promise resolving to the merge result with status and any conflicts
553
- *
554
- * @throws {Error} When commit objects cannot be read
555
- * @throws {Error} When tree objects cannot be parsed
556
- * @throws {Error} When fastForwardOnly is true but fast-forward is not possible
557
- *
558
- * @example
559
- * ```typescript
560
- * // Basic merge
561
- * const result = await merge(storage, 'abc123', 'def456', {
562
- * message: 'Merge feature branch'
563
- * })
564
- *
565
- * if (result.status === 'merged') {
566
- * console.log('Merge successful:', result.commitSha)
567
- * }
568
- * ```
569
- *
570
- * @example
571
- * ```typescript
572
- * // Fast-forward only merge
573
- * try {
574
- * const result = await merge(storage, 'abc123', 'def456', {
575
- * fastForwardOnly: true
576
- * })
577
- * console.log('Fast-forwarded to:', result.treeSha)
578
- * } catch (error) {
579
- * console.log('Cannot fast-forward, branches have diverged')
580
- * }
581
- * ```
582
- *
583
- * @example
584
- * ```typescript
585
- * // Merge with auto-resolve conflicts using 'ours' strategy
586
- * const result = await merge(storage, 'abc123', 'def456', {
587
- * autoResolve: true,
588
- * conflictStrategy: 'ours',
589
- * message: 'Merge with our changes taking precedence'
590
- * })
591
- * ```
592
- */
593
- export declare function merge(storage: MergeStorage, oursSha: string, theirsSha: string, options?: MergeOptions): Promise<MergeResult>;
594
- /**
595
- * Resolves a single merge conflict with the specified strategy.
596
- *
597
- * @description
598
- * After a merge results in conflicts, use this function to resolve
599
- * individual files. The resolution can use one of the three versions
600
- * (ours, theirs, base) or provide custom merged content.
601
- *
602
- * Once all conflicts are resolved, use {@link continueMerge} to create
603
- * the merge commit and complete the operation.
604
- *
605
- * @param storage - The storage interface for reading/writing objects
606
- * @param path - Path to the conflicted file to resolve
607
- * @param options - Resolution options specifying which version to use
608
- *
609
- * @returns A promise resolving to the resolution result
610
- *
611
- * @throws {Error} When no merge is in progress
612
- * @throws {Error} When the specified path has no conflict
613
- *
614
- * @example
615
- * ```typescript
616
- * // Resolve using our version
617
- * const result = await resolveConflict(storage, 'src/file.ts', {
618
- * resolution: 'ours'
619
- * })
620
- * console.log(`${result.remainingConflicts} conflicts remaining`)
621
- * ```
622
- *
623
- * @example
624
- * ```typescript
625
- * // Resolve using their version
626
- * await resolveConflict(storage, 'config.json', {
627
- * resolution: 'theirs'
628
- * })
629
- * ```
630
- *
631
- * @example
632
- * ```typescript
633
- * // Resolve with manually merged content
634
- * const mergedContent = new TextEncoder().encode(`
635
- * // Manually resolved: kept both features
636
- * export function feature1() { ... }
637
- * export function feature2() { ... }
638
- * `)
639
- *
640
- * await resolveConflict(storage, 'src/features.ts', {
641
- * resolution: 'custom',
642
- * customContent: mergedContent
643
- * })
644
- * ```
645
- */
646
- export declare function resolveConflict(storage: MergeStorage, path: string, options: ResolveOptions): Promise<ResolveResult>;
647
- /**
648
- * Aborts an in-progress merge operation.
649
- *
650
- * @description
651
- * Cancels the current merge and restores the repository to its state
652
- * before the merge began. Any conflict resolutions or staged changes
653
- * from the merge will be discarded.
654
- *
655
- * This is equivalent to `git merge --abort`.
656
- *
657
- * @param storage - The storage interface
658
- *
659
- * @returns A promise resolving to the operation result
660
- *
661
- * @throws {Error} When no merge is in progress
662
- *
663
- * @example
664
- * ```typescript
665
- * // User decides to cancel the merge
666
- * const result = await abortMerge(storage)
667
- *
668
- * if (result.success) {
669
- * console.log('Merge aborted, HEAD restored to', result.headSha)
670
- * } else {
671
- * console.error('Failed to abort:', result.error)
672
- * }
673
- * ```
674
- */
675
- export declare function abortMerge(storage: MergeStorage): Promise<MergeOperationResult>;
676
- /**
677
- * Continues a merge after all conflicts have been resolved.
678
- *
679
- * @description
680
- * After resolving all conflicts using {@link resolveConflict}, call this
681
- * function to create the merge commit and complete the merge operation.
682
- * The merge state will be cleaned up automatically.
683
- *
684
- * This is equivalent to `git merge --continue` or `git commit` after
685
- * resolving conflicts.
686
- *
687
- * @param storage - The storage interface
688
- * @param message - Optional commit message (overrides the stored message)
689
- *
690
- * @returns A promise resolving to the operation result with the new commit SHA
691
- *
692
- * @throws {Error} When no merge is in progress
693
- * @throws {Error} When unresolved conflicts remain
694
- *
695
- * @example
696
- * ```typescript
697
- * // After resolving all conflicts
698
- * const result = await continueMerge(storage)
699
- *
700
- * if (result.success) {
701
- * console.log('Merge completed:', result.headSha)
702
- * } else {
703
- * console.error('Cannot continue:', result.error)
704
- * }
705
- * ```
706
- *
707
- * @example
708
- * ```typescript
709
- * // Continue with a custom commit message
710
- * const result = await continueMerge(storage, 'Merge feature-x with conflict resolution')
711
- * ```
712
- */
713
- export declare function continueMerge(storage: MergeStorage, message?: string): Promise<MergeOperationResult>;
714
- /**
715
- * Finds the best common ancestor (merge base) of two commits.
716
- *
717
- * @description
718
- * Implements the merge base algorithm by finding the most recent commit
719
- * that is an ancestor of both input commits. This is the commit from
720
- * which both branches diverged.
721
- *
722
- * Uses a breadth-first search from both commits to find their
723
- * intersection in the commit graph.
724
- *
725
- * @param storage - The storage interface for reading commit objects
726
- * @param commit1 - SHA of the first commit
727
- * @param commit2 - SHA of the second commit
728
- *
729
- * @returns A promise resolving to the merge base SHA, or null if no common ancestor exists
730
- *
731
- * @example
732
- * ```typescript
733
- * const base = await findMergeBase(storage, 'feature-sha', 'main-sha')
734
- * if (base) {
735
- * console.log('Common ancestor:', base)
736
- * } else {
737
- * console.log('No common history')
738
- * }
739
- * ```
740
- */
741
- export declare function findMergeBase(storage: MergeStorage, commit1: string, commit2: string): Promise<string | null>;
742
- /**
743
- * Performs a content-level three-way merge on text files.
744
- *
745
- * @description
746
- * Takes three versions of a file (base, ours, theirs) and attempts to
747
- * automatically merge them. Non-conflicting changes are combined
748
- * automatically. Conflicting changes are marked with standard Git
749
- * conflict markers.
750
- *
751
- * The algorithm:
752
- * 1. Compute the diff hunks from base to ours
753
- * 2. Compute the diff hunks from base to theirs
754
- * 3. Process hunks in order, detecting overlaps
755
- * 4. Non-overlapping hunks are applied automatically
756
- * 5. Overlapping hunks with identical changes are deduplicated
757
- * 6. Overlapping hunks with different changes create conflict markers
758
- *
759
- * @param base - Content of the base (common ancestor) version
760
- * @param ours - Content of our (current branch) version
761
- * @param theirs - Content of their (merged branch) version
762
- *
763
- * @returns Object containing merged content, conflict flag, and marker locations
764
- *
765
- * @example
766
- * ```typescript
767
- * const result = mergeContent(baseContent, oursContent, theirsContent)
768
- *
769
- * if (result.hasConflicts) {
770
- * console.log('Content has conflicts at:', result.markers)
771
- * // Write file with conflict markers for manual resolution
772
- * await writeFile(path, result.merged)
773
- * } else {
774
- * console.log('Content merged cleanly')
775
- * await writeFile(path, result.merged)
776
- * }
777
- * ```
778
- */
779
- export declare function mergeContent(base: Uint8Array, ours: Uint8Array, theirs: Uint8Array): {
780
- merged: Uint8Array;
781
- hasConflicts: boolean;
782
- markers: ConflictMarker[];
783
- };
784
- /**
785
- * Determines if a file is binary (non-text) based on its content.
786
- *
787
- * @description
788
- * Uses Git's heuristic: a file is considered binary if it contains
789
- * null bytes (0x00) within the first 8000 bytes, or if it has
790
- * specific binary file magic numbers (PNG, JPEG, GIF).
791
- *
792
- * Binary files cannot be automatically merged and always result
793
- * in conflicts when both sides modify them.
794
- *
795
- * @param content - File content to analyze
796
- *
797
- * @returns true if the file appears to be binary, false for text files
798
- *
799
- * @example
800
- * ```typescript
801
- * const content = await readFile('image.png')
802
- * if (isBinaryFile(content)) {
803
- * console.log('Cannot perform text merge on binary file')
804
- * }
805
- * ```
806
- */
807
- export declare function isBinaryFile(content: Uint8Array): boolean;
808
- /**
809
- * Gets the current merge state if a merge is in progress.
810
- *
811
- * @description
812
- * Returns the persisted merge state, which includes information about
813
- * the merge in progress, any unresolved conflicts, and the original
814
- * merge options.
815
- *
816
- * @param storage - The storage interface
817
- *
818
- * @returns A promise resolving to the merge state, or null if no merge is in progress
819
- *
820
- * @example
821
- * ```typescript
822
- * const state = await getMergeState(storage)
823
- * if (state) {
824
- * console.log('Merging', state.mergeHead, 'into', state.origHead)
825
- * console.log('Unresolved conflicts:', state.unresolvedConflicts.length)
826
- * } else {
827
- * console.log('No merge in progress')
828
- * }
829
- * ```
830
- */
831
- export declare function getMergeState(storage: MergeStorage): Promise<MergeState | null>;
832
- /**
833
- * Checks if a merge is currently in progress.
834
- *
835
- * @description
836
- * Quick check to determine if there's an active merge that hasn't
837
- * been completed or aborted. Useful for UI state and command validation.
838
- *
839
- * @param storage - The storage interface
840
- *
841
- * @returns A promise resolving to true if a merge is in progress
842
- *
843
- * @example
844
- * ```typescript
845
- * if (await isMergeInProgress(storage)) {
846
- * console.log('Please complete or abort the current merge first')
847
- * } else {
848
- * // Safe to start a new merge
849
- * await merge(storage, oursSha, theirsSha, options)
850
- * }
851
- * ```
852
- */
853
- export declare function isMergeInProgress(storage: MergeStorage): Promise<boolean>;
854
- export {};
855
- //# sourceMappingURL=merge.d.ts.map