@scolladon/tsgit 2.0.1 → 3.0.0

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 (152) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/adapters/browser/index.cjs +1 -1
  3. package/dist/cjs/adapters/browser/index.cjs.map +1 -1
  4. package/dist/cjs/adapters/memory/index.cjs +1 -1
  5. package/dist/cjs/adapters/memory/index.cjs.map +1 -1
  6. package/dist/cjs/adapters/node/index.cjs +1 -1
  7. package/dist/cjs/adapters/node/index.cjs.map +1 -1
  8. package/dist/cjs/chunks/adapter-detect-D7DFJtuk.cjs +2 -0
  9. package/dist/cjs/chunks/adapter-detect-D7DFJtuk.cjs.map +1 -0
  10. package/dist/cjs/chunks/adler32-CrRRuL2P.cjs +2 -0
  11. package/dist/cjs/chunks/adler32-CrRRuL2P.cjs.map +1 -0
  12. package/dist/cjs/chunks/browser-http-transport-nGm6alox.cjs +2 -0
  13. package/dist/cjs/chunks/browser-http-transport-nGm6alox.cjs.map +1 -0
  14. package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
  15. package/dist/cjs/chunks/error-CA80UqXF.cjs +2 -0
  16. package/dist/cjs/chunks/error-CA80UqXF.cjs.map +1 -0
  17. package/dist/cjs/chunks/index-01WCH0eg.cjs +2 -0
  18. package/dist/cjs/chunks/index-01WCH0eg.cjs.map +1 -0
  19. package/dist/cjs/chunks/memory-http-transport-7hpDW8o3.cjs +2 -0
  20. package/dist/cjs/chunks/memory-http-transport-7hpDW8o3.cjs.map +1 -0
  21. package/dist/cjs/chunks/node-http-transport-CoqnAvIL.cjs +2 -0
  22. package/dist/cjs/chunks/node-http-transport-CoqnAvIL.cjs.map +1 -0
  23. package/dist/cjs/chunks/{progress-CxU62NC1.cjs → progress-CjhUeyxd.cjs} +2 -2
  24. package/dist/cjs/chunks/{progress-CxU62NC1.cjs.map → progress-CjhUeyxd.cjs.map} +1 -1
  25. package/dist/cjs/chunks/repository-DJNNrfQr.cjs +2 -0
  26. package/dist/cjs/chunks/repository-DJNNrfQr.cjs.map +1 -0
  27. package/dist/cjs/chunks/write-sparse-checkout-DzVubBcI.cjs +2 -0
  28. package/dist/cjs/chunks/write-sparse-checkout-DzVubBcI.cjs.map +1 -0
  29. package/dist/cjs/commands/index.cjs +1 -1
  30. package/dist/cjs/index.browser.cjs +1 -1
  31. package/dist/cjs/index.browser.cjs.map +1 -1
  32. package/dist/cjs/index.cjs +1 -1
  33. package/dist/cjs/index.cjs.map +1 -1
  34. package/dist/cjs/index.default.cjs +1 -1
  35. package/dist/cjs/index.default.cjs.map +1 -1
  36. package/dist/cjs/index.node.cjs +1 -1
  37. package/dist/cjs/index.node.cjs.map +1 -1
  38. package/dist/cjs/primitives/index.cjs +1 -1
  39. package/dist/cjs/primitives/index.cjs.map +1 -1
  40. package/dist/esm/adapters/browser/index.js +1 -1
  41. package/dist/esm/adapters/browser/index.js.map +1 -1
  42. package/dist/esm/adapters/memory/index.js +1 -1
  43. package/dist/esm/adapters/memory/index.js.map +1 -1
  44. package/dist/esm/adapters/node/index.js +1 -1
  45. package/dist/esm/adapters/node/index.js.map +1 -1
  46. package/dist/esm/chunks/adapter-detect-CTTG6hpk.js +2 -0
  47. package/dist/esm/chunks/adapter-detect-CTTG6hpk.js.map +1 -0
  48. package/dist/esm/chunks/adler32-BfvKJOAO.js +2 -0
  49. package/dist/esm/chunks/adler32-BfvKJOAO.js.map +1 -0
  50. package/dist/esm/chunks/browser-http-transport-DD0YKmIW.js +2 -0
  51. package/dist/esm/chunks/browser-http-transport-DD0YKmIW.js.map +1 -0
  52. package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
  53. package/dist/esm/chunks/error-BD0nFV6t.js +2 -0
  54. package/dist/esm/chunks/error-BD0nFV6t.js.map +1 -0
  55. package/dist/esm/chunks/index-BEI7XKaV.js +2 -0
  56. package/dist/esm/chunks/index-BEI7XKaV.js.map +1 -0
  57. package/dist/esm/chunks/memory-http-transport-D13LBPvu.js +2 -0
  58. package/dist/esm/chunks/memory-http-transport-D13LBPvu.js.map +1 -0
  59. package/dist/esm/chunks/node-http-transport-doU9Y8WN.js +2 -0
  60. package/dist/esm/chunks/node-http-transport-doU9Y8WN.js.map +1 -0
  61. package/dist/esm/chunks/{progress-BZobfl7p.js → progress-CLPpgZJ6.js} +2 -2
  62. package/dist/esm/chunks/{progress-BZobfl7p.js.map → progress-CLPpgZJ6.js.map} +1 -1
  63. package/dist/esm/chunks/repository-dCH3DdLQ.js +2 -0
  64. package/dist/esm/chunks/repository-dCH3DdLQ.js.map +1 -0
  65. package/dist/esm/chunks/write-sparse-checkout-D4tNUXOp.js +2 -0
  66. package/dist/esm/chunks/write-sparse-checkout-D4tNUXOp.js.map +1 -0
  67. package/dist/esm/commands/index.js +1 -1
  68. package/dist/esm/index.browser.js +1 -1
  69. package/dist/esm/index.browser.js.map +1 -1
  70. package/dist/esm/index.default.js +1 -1
  71. package/dist/esm/index.default.js.map +1 -1
  72. package/dist/esm/index.js +1 -1
  73. package/dist/esm/index.js.map +1 -1
  74. package/dist/esm/index.node.js +1 -1
  75. package/dist/esm/index.node.js.map +1 -1
  76. package/dist/esm/primitives/index.js +1 -1
  77. package/dist/esm/primitives/index.js.map +1 -1
  78. package/dist/types/adapters/browser/index.d.cts +5 -3
  79. package/dist/types/adapters/browser/index.d.ts +5 -3
  80. package/dist/types/adapters/memory/index.d.cts +31 -4
  81. package/dist/types/adapters/memory/index.d.ts +31 -4
  82. package/dist/types/adapters/node/index.d.cts +53 -5
  83. package/dist/types/adapters/node/index.d.ts +53 -5
  84. package/dist/types/chunks/{context-CCL0_F8R.d.ts → context-CNtbFlwI.d.ts} +119 -6
  85. package/dist/types/chunks/{context-YDw6qicq.d.cts → context-D_A7-uau.d.cts} +119 -6
  86. package/dist/types/chunks/{http-transport--_NdQOiw.d.cts → http-transport-DirKfK2S.d.cts} +1 -1
  87. package/dist/types/chunks/{http-transport--_NdQOiw.d.ts → http-transport-DirKfK2S.d.ts} +1 -1
  88. package/dist/types/chunks/index-BJDekgCP.d.ts +1122 -0
  89. package/dist/types/chunks/index-CMLLVz9B.d.cts +1122 -0
  90. package/dist/types/chunks/index-E_KapqW9.d.ts +2439 -0
  91. package/dist/types/chunks/index-wwZiot4c.d.cts +2439 -0
  92. package/dist/types/chunks/progress-Cp-huK45.d.cts +1171 -0
  93. package/dist/types/chunks/progress-hcn9r2H3.d.ts +1171 -0
  94. package/dist/types/chunks/reflog-entry-BGJr9VfU.d.cts +688 -0
  95. package/dist/types/chunks/reflog-entry-DecZqJna.d.ts +688 -0
  96. package/dist/types/chunks/{repository-BeifCqp0.d.cts → repository-DASBgOb9.d.cts} +58 -20
  97. package/dist/types/chunks/{repository-FoS_Laoy.d.ts → repository-Dxhwpzd6.d.ts} +58 -20
  98. package/dist/types/commands/index.d.cts +4 -1259
  99. package/dist/types/commands/index.d.ts +4 -1259
  100. package/dist/types/index.browser.d.cts +7 -8
  101. package/dist/types/index.browser.d.ts +7 -8
  102. package/dist/types/index.d.cts +61 -124
  103. package/dist/types/index.d.ts +61 -124
  104. package/dist/types/index.default.d.cts +7 -8
  105. package/dist/types/index.default.d.ts +7 -8
  106. package/dist/types/index.node.d.cts +7 -8
  107. package/dist/types/index.node.d.ts +7 -8
  108. package/dist/types/primitives/index.d.cts +4 -692
  109. package/dist/types/primitives/index.d.ts +4 -692
  110. package/dist/types/transport/index.d.cts +1 -1
  111. package/dist/types/transport/index.d.ts +1 -1
  112. package/package.json +21 -21
  113. package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs +0 -2
  114. package/dist/cjs/chunks/adapter-detect-CD_LcgaH.cjs.map +0 -1
  115. package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs +0 -2
  116. package/dist/cjs/chunks/browser-http-transport-CiMRqtDS.cjs.map +0 -1
  117. package/dist/cjs/chunks/error-CfjFO3x_.cjs +0 -2
  118. package/dist/cjs/chunks/error-CfjFO3x_.cjs.map +0 -1
  119. package/dist/cjs/chunks/index-BWCq_5BJ.cjs +0 -2
  120. package/dist/cjs/chunks/index-BWCq_5BJ.cjs.map +0 -1
  121. package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs +0 -2
  122. package/dist/cjs/chunks/memory-http-transport-BVL6VgB-.cjs.map +0 -1
  123. package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs +0 -2
  124. package/dist/cjs/chunks/node-http-transport-BvfVcf02.cjs.map +0 -1
  125. package/dist/cjs/chunks/repository-BEg2zNtx.cjs +0 -2
  126. package/dist/cjs/chunks/repository-BEg2zNtx.cjs.map +0 -1
  127. package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs +0 -2
  128. package/dist/cjs/chunks/walk-submodules-D2Sp7JEB.cjs.map +0 -1
  129. package/dist/esm/chunks/adapter-detect-DkZhhUhd.js +0 -2
  130. package/dist/esm/chunks/adapter-detect-DkZhhUhd.js.map +0 -1
  131. package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js +0 -2
  132. package/dist/esm/chunks/browser-http-transport-4rJkHcQu.js.map +0 -1
  133. package/dist/esm/chunks/error-Dc-SRSJK.js +0 -2
  134. package/dist/esm/chunks/error-Dc-SRSJK.js.map +0 -1
  135. package/dist/esm/chunks/index-jH0UMhh-.js +0 -2
  136. package/dist/esm/chunks/index-jH0UMhh-.js.map +0 -1
  137. package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js +0 -2
  138. package/dist/esm/chunks/memory-http-transport-CA1WxWBp.js.map +0 -1
  139. package/dist/esm/chunks/node-http-transport-DPa2lK3T.js +0 -2
  140. package/dist/esm/chunks/node-http-transport-DPa2lK3T.js.map +0 -1
  141. package/dist/esm/chunks/repository-DF6ePd1x.js +0 -2
  142. package/dist/esm/chunks/repository-DF6ePd1x.js.map +0 -1
  143. package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js +0 -2
  144. package/dist/esm/chunks/walk-submodules-Dq9oGwP8.js.map +0 -1
  145. package/dist/types/chunks/index-entry-DtEbVpOG.d.cts +0 -47
  146. package/dist/types/chunks/index-entry-UD4dvtKh.d.ts +0 -47
  147. package/dist/types/chunks/progress-7KKiXXfX.d.ts +0 -405
  148. package/dist/types/chunks/progress-By8yFaUE.d.cts +0 -405
  149. package/dist/types/chunks/reflog-entry-BbNnXCTC.d.cts +0 -368
  150. package/dist/types/chunks/reflog-entry-CSzjnZd4.d.ts +0 -368
  151. package/dist/types/chunks/write-tree-C3oNxOlX.d.cts +0 -196
  152. package/dist/types/chunks/write-tree-DRI-LzSr.d.ts +0 -196
@@ -0,0 +1,1171 @@
1
+ import { F as FilePath, R as RefName, O as ObjectId, j as HookName, H as HashConfig, c as Context, g as FileSystem, h as HashService, a as Compressor, P as ProgressReporter } from './context-D_A7-uau.cjs';
2
+ import { aM as ConfigScope, o as FileMode, r as GitObject, G as GitIndex, aN as IndexEntry$1, k as DiffChange, L as LineKey, a6 as Tree } from './reflog-entry-BGJr9VfU.cjs';
3
+ import { aQ as GlobMatcher } from './index-CMLLVz9B.cjs';
4
+ import { b as HttpTransport } from './http-transport-DirKfK2S.cjs';
5
+
6
+ interface RefStatus {
7
+ readonly name: string;
8
+ readonly accepted: boolean;
9
+ readonly reason?: string;
10
+ }
11
+ interface ReceivePackResponse {
12
+ readonly unpackOk: boolean;
13
+ readonly unpackError?: string;
14
+ readonly refUpdates: ReadonlyArray<RefStatus>;
15
+ }
16
+
17
+ type CommandError = {
18
+ readonly code: 'WORKING_TREE_DIRTY';
19
+ readonly localChanges: ReadonlyArray<FilePath>;
20
+ readonly untracked: ReadonlyArray<FilePath>;
21
+ } | {
22
+ readonly code: 'PATHSPEC_NO_MATCH';
23
+ readonly pattern: string;
24
+ } | {
25
+ readonly code: 'PATHSPEC_OUTSIDE_REPO';
26
+ readonly path: FilePath;
27
+ } | {
28
+ readonly code: 'NOTHING_TO_COMMIT';
29
+ } | {
30
+ readonly code: 'EMPTY_COMMIT_MESSAGE';
31
+ } | {
32
+ readonly code: 'AUTHOR_UNCONFIGURED';
33
+ } | {
34
+ readonly code: 'BRANCH_EXISTS';
35
+ readonly name: RefName;
36
+ } | {
37
+ readonly code: 'BRANCH_NOT_FOUND';
38
+ readonly name: RefName;
39
+ } | {
40
+ readonly code: 'TAG_EXISTS';
41
+ readonly name: RefName;
42
+ } | {
43
+ readonly code: 'TAG_NOT_FOUND';
44
+ readonly name: RefName;
45
+ } | {
46
+ readonly code: 'CANNOT_DELETE_CHECKED_OUT_BRANCH';
47
+ readonly name: RefName;
48
+ } | {
49
+ readonly code: 'INVALID_URL';
50
+ readonly reason: string;
51
+ } | {
52
+ readonly code: 'BLOCKED_HOST';
53
+ readonly host: string;
54
+ readonly reason: string;
55
+ } | {
56
+ readonly code: 'TOO_MANY_REDIRECTS';
57
+ readonly count: number;
58
+ } | {
59
+ readonly code: 'UNSUPPORTED_SCHEME';
60
+ readonly scheme: string;
61
+ } | {
62
+ readonly code: 'TARGET_DIRECTORY_NOT_EMPTY';
63
+ readonly path: FilePath;
64
+ } | {
65
+ readonly code: 'REMOTE_ADVERTISES_NO_REFS';
66
+ } | {
67
+ readonly code: 'NO_PROMISOR_REMOTE';
68
+ } | {
69
+ readonly code: 'NON_FAST_FORWARD';
70
+ readonly ref: RefName;
71
+ readonly local: ObjectId;
72
+ readonly remote: ObjectId;
73
+ } | {
74
+ readonly code: 'PUSH_REJECTED';
75
+ readonly ref: RefName;
76
+ readonly reason: string;
77
+ readonly reportStatus: ReceivePackResponse;
78
+ } | {
79
+ readonly code: 'MERGE_HAS_CONFLICTS';
80
+ readonly count: number;
81
+ readonly paths: ReadonlyArray<FilePath>;
82
+ readonly truncated?: boolean;
83
+ } | {
84
+ readonly code: 'CHECKOUT_OVERWRITE_DIRTY';
85
+ readonly localChanges: ReadonlyArray<FilePath>;
86
+ readonly untracked: ReadonlyArray<FilePath>;
87
+ } | {
88
+ readonly code: 'REVPARSE_AMBIGUOUS';
89
+ readonly expression: string;
90
+ readonly candidates: ReadonlyArray<ObjectId>;
91
+ } | {
92
+ readonly code: 'REVPARSE_UNRESOLVED';
93
+ readonly expression: string;
94
+ } | {
95
+ readonly code: 'PATH_NOT_IN_TREE';
96
+ readonly rev: string;
97
+ readonly path: string;
98
+ } | {
99
+ readonly code: 'WORKTREE_FILE_ABSENT';
100
+ readonly path: string;
101
+ } | {
102
+ readonly code: 'EMPTY_PATHSPEC';
103
+ } | {
104
+ readonly code: 'OPERATION_IN_PROGRESS';
105
+ readonly operation: 'merge' | 'rebase' | 'cherry-pick' | 'revert';
106
+ } | {
107
+ readonly code: 'NO_OPERATION_IN_PROGRESS';
108
+ readonly operation: 'merge' | 'rebase' | 'cherry-pick' | 'revert';
109
+ } | {
110
+ readonly code: 'MAX_REFSPECS_EXCEEDED';
111
+ readonly count: number;
112
+ readonly limit: number;
113
+ } | {
114
+ readonly code: 'REMOTE_NOT_CONFIGURED';
115
+ readonly remote: string;
116
+ } | {
117
+ readonly code: 'NO_UPSTREAM_CONFIGURED';
118
+ readonly branch: RefName;
119
+ } | {
120
+ readonly code: 'REMOTE_EXISTS';
121
+ readonly remote: string;
122
+ } | {
123
+ readonly code: 'REMOTE_NAME_INVALID';
124
+ readonly name: string;
125
+ readonly reason: string;
126
+ } | {
127
+ readonly code: 'INVALID_OPTION';
128
+ readonly option: string;
129
+ readonly reason: string;
130
+ } | {
131
+ readonly code: 'REPOSITORY_DISPOSED';
132
+ } | {
133
+ readonly code: 'ADAPTER_UNAVAILABLE';
134
+ readonly runtime: 'node' | 'browser' | 'memory';
135
+ readonly reason: string;
136
+ } | {
137
+ readonly code: 'WORKING_TREE_FILE_TOO_LARGE';
138
+ readonly path: FilePath;
139
+ readonly size: number;
140
+ readonly limit: number;
141
+ } | {
142
+ readonly code: 'GITIGNORE_FILE_TOO_LARGE';
143
+ readonly path: FilePath;
144
+ readonly size: number;
145
+ readonly limit: number;
146
+ } | {
147
+ readonly code: 'GITATTRIBUTES_FILE_TOO_LARGE';
148
+ readonly path: FilePath;
149
+ readonly size: number;
150
+ readonly limit: number;
151
+ } | {
152
+ readonly code: 'SPARSE_PATTERN_FILE_TOO_LARGE';
153
+ readonly path: FilePath;
154
+ readonly size: number;
155
+ readonly limit: number;
156
+ } | {
157
+ readonly code: 'HOOK_FAILED';
158
+ readonly hook: HookName;
159
+ readonly exitCode: number;
160
+ readonly stderr: string;
161
+ } | {
162
+ readonly code: 'CLEAN_FILTER_FAILED';
163
+ readonly path: FilePath;
164
+ readonly filter: string;
165
+ readonly exitCode: number;
166
+ } | {
167
+ readonly code: 'SMUDGE_FILTER_FAILED';
168
+ readonly path: FilePath;
169
+ readonly filter: string;
170
+ readonly exitCode: number;
171
+ } | {
172
+ readonly code: 'CONFIG_KEY_INVALID';
173
+ readonly key: string;
174
+ readonly reason: 'empty-section' | 'missing-name' | 'bad-character';
175
+ readonly position?: number;
176
+ } | {
177
+ readonly code: 'CONFIG_VALUE_INVALID';
178
+ readonly key: string;
179
+ readonly reason: 'control-character';
180
+ readonly position: number;
181
+ } | {
182
+ readonly code: 'CONFIG_PARSE_ERROR';
183
+ readonly line: number;
184
+ readonly source?: string;
185
+ readonly partialSectionName?: string;
186
+ } | {
187
+ readonly code: 'CONFIG_MISSING_VALUE';
188
+ readonly key: string;
189
+ readonly source: string;
190
+ readonly line: number;
191
+ } | {
192
+ readonly code: 'CONFIG_BAD_NUMERIC_VALUE';
193
+ readonly key: string;
194
+ readonly source: string;
195
+ readonly value: string;
196
+ readonly reason: 'invalid unit' | 'out of range';
197
+ } | {
198
+ readonly code: 'CONFIG_BAD_ZLIB_LEVEL';
199
+ readonly level: number;
200
+ } | {
201
+ readonly code: 'CONFIG_MULTIPLE_VALUES';
202
+ readonly key: string;
203
+ readonly count: number;
204
+ readonly requested: 'read' | 'overwrite' | 'remove';
205
+ readonly scope?: ConfigScope;
206
+ } | {
207
+ readonly code: 'CONFIG_INVALID_FILE';
208
+ readonly sectionName: string;
209
+ readonly source: string;
210
+ } | {
211
+ readonly code: 'CONFIG_SECTION_NOT_FOUND';
212
+ readonly name: string;
213
+ readonly scope: ConfigScope;
214
+ } | {
215
+ readonly code: 'CONFIG_SCOPE_NOT_AVAILABLE';
216
+ readonly scope: ConfigScope;
217
+ readonly reason: 'browser-adapter' | 'worktree-extension-unset';
218
+ } | {
219
+ readonly code: 'CONFIG_SYSTEM_PATH_UNRESOLVED';
220
+ } | {
221
+ readonly code: 'MV_SOURCE_NOT_TRACKED';
222
+ readonly source: FilePath;
223
+ readonly destination: FilePath;
224
+ } | {
225
+ readonly code: 'MV_BAD_SOURCE';
226
+ readonly source: FilePath;
227
+ readonly destination: FilePath;
228
+ } | {
229
+ readonly code: 'MV_DESTINATION_EXISTS';
230
+ readonly source: FilePath;
231
+ readonly destination: FilePath;
232
+ } | {
233
+ readonly code: 'MV_INTO_SELF';
234
+ readonly source: FilePath;
235
+ readonly destination: FilePath;
236
+ } | {
237
+ readonly code: 'MV_DESTINATION_NOT_DIRECTORY';
238
+ readonly source: FilePath;
239
+ readonly destination: FilePath;
240
+ } | {
241
+ readonly code: 'MV_DESTINATION_DIRECTORY_MISSING';
242
+ readonly source: FilePath;
243
+ readonly destination: FilePath;
244
+ } | {
245
+ readonly code: 'MV_MULTIPLE_SOURCES_SAME_TARGET';
246
+ readonly source: FilePath;
247
+ readonly destination: FilePath;
248
+ } | {
249
+ readonly code: 'MV_OVERLAPPING_SOURCES';
250
+ readonly child: FilePath;
251
+ readonly parent: FilePath;
252
+ } | {
253
+ readonly code: 'RM_STAGED_CHANGES';
254
+ readonly paths: ReadonlyArray<FilePath>;
255
+ } | {
256
+ readonly code: 'RM_LOCAL_MODIFICATIONS';
257
+ readonly paths: ReadonlyArray<FilePath>;
258
+ } | {
259
+ readonly code: 'RM_STAGED_AND_LOCAL_CHANGES';
260
+ readonly paths: ReadonlyArray<FilePath>;
261
+ } | {
262
+ readonly code: 'NO_INITIAL_COMMIT';
263
+ } | {
264
+ readonly code: 'STASH_NOT_FOUND';
265
+ readonly index: number;
266
+ readonly stackSize: number;
267
+ } | {
268
+ readonly code: 'STASH_APPLY_WOULD_OVERWRITE';
269
+ readonly paths: ReadonlyArray<FilePath>;
270
+ } | {
271
+ readonly code: 'AMBIGUOUS_OID_PREFIX';
272
+ readonly prefix: string;
273
+ readonly candidates: ReadonlyArray<ObjectId>;
274
+ } | {
275
+ readonly code: 'INVALID_SEQUENCER_TODO';
276
+ readonly reason: string;
277
+ } | {
278
+ readonly code: 'CHERRY_PICK_MERGE_NO_MAINLINE';
279
+ readonly commit: ObjectId;
280
+ } | {
281
+ readonly code: 'REVERT_MERGE_NO_MAINLINE';
282
+ readonly commit: ObjectId;
283
+ } | {
284
+ readonly code: 'NO_NAMES';
285
+ readonly oid: ObjectId;
286
+ } | {
287
+ readonly code: 'NO_ANNOTATED_NAMES';
288
+ readonly oid: ObjectId;
289
+ } | {
290
+ readonly code: 'NO_REACHABLE_NAMES';
291
+ readonly oid: ObjectId;
292
+ } | {
293
+ readonly code: 'NO_EXACT_MATCH';
294
+ readonly oid: ObjectId;
295
+ } | {
296
+ readonly code: 'CANNOT_DESCRIBE';
297
+ readonly oid: ObjectId;
298
+ } | {
299
+ readonly code: 'BUNDLE_EMPTY';
300
+ readonly reason: 'no-refs' | 'no-objects';
301
+ } | {
302
+ readonly code: 'BUNDLE_READ_FAILED';
303
+ readonly path: string;
304
+ } | {
305
+ readonly code: 'BUNDLE_BAD_HEADER';
306
+ readonly path: string;
307
+ readonly reason: string;
308
+ } | {
309
+ readonly code: 'BUNDLE_UNSUPPORTED_VERSION';
310
+ readonly path?: string;
311
+ readonly version: number;
312
+ } | {
313
+ readonly code: 'BUNDLE_PREREQUISITE_NOT_COMMIT';
314
+ readonly oid: ObjectId;
315
+ readonly objectType: string;
316
+ } | {
317
+ readonly code: 'NOTES_ALREADY_EXIST';
318
+ readonly object: ObjectId;
319
+ } | {
320
+ readonly code: 'NOTES_OBJECT_HAS_NONE';
321
+ readonly object: ObjectId;
322
+ } | {
323
+ readonly code: 'NOTES_REF_OUTSIDE';
324
+ readonly ref: string;
325
+ };
326
+
327
+ type DiffError = {
328
+ readonly code: 'INVALID_TREE_FOR_DIFF';
329
+ readonly reason: string;
330
+ } | {
331
+ readonly code: 'INVALID_DIFF_INPUT';
332
+ readonly reason: string;
333
+ };
334
+ declare const invalidTreeForDiff: (reason: string) => TsgitError;
335
+ declare const invalidDiffInput: (reason: string) => TsgitError;
336
+
337
+ type MergeError = {
338
+ readonly code: 'INVALID_MERGE_TREE';
339
+ readonly reason: string;
340
+ } | {
341
+ readonly code: 'INVALID_MERGE_INPUT';
342
+ readonly reason: string;
343
+ };
344
+
345
+ type ObjectType = 'blob' | 'tree' | 'commit' | 'tag';
346
+ type DomainObjectError = {
347
+ readonly code: 'INVALID_OBJECT_ID';
348
+ readonly value: string;
349
+ } | {
350
+ readonly code: 'INVALID_OBJECT_HEADER';
351
+ readonly reason: string;
352
+ } | {
353
+ readonly code: 'INVALID_TREE_ENTRY';
354
+ readonly offset: number;
355
+ readonly reason: string;
356
+ } | {
357
+ readonly code: 'INVALID_COMMIT';
358
+ readonly reason: string;
359
+ } | {
360
+ readonly code: 'INVALID_TAG';
361
+ readonly reason: string;
362
+ } | {
363
+ readonly code: 'INVALID_FILE_MODE';
364
+ readonly value: string;
365
+ } | {
366
+ readonly code: 'INVALID_IDENTITY';
367
+ readonly line: string;
368
+ readonly reason: string;
369
+ } | {
370
+ readonly code: 'OBJECT_NOT_FOUND';
371
+ readonly id: ObjectId;
372
+ } | {
373
+ readonly code: 'OBJECT_HASH_MISMATCH';
374
+ readonly expected: ObjectId;
375
+ readonly actual: ObjectId;
376
+ } | {
377
+ readonly code: 'UNEXPECTED_OBJECT_TYPE';
378
+ readonly expected: ObjectType;
379
+ readonly actual: ObjectType;
380
+ readonly id: ObjectId;
381
+ } | {
382
+ readonly code: 'TREE_CYCLE_DETECTED';
383
+ readonly id: ObjectId;
384
+ } | {
385
+ readonly code: 'TREE_DEPTH_EXCEEDED';
386
+ readonly depth: number;
387
+ } | {
388
+ readonly code: 'TREE_ENTRY_LIMIT_EXCEEDED';
389
+ readonly count: number;
390
+ readonly limit: number;
391
+ } | {
392
+ readonly code: 'OBJECT_TOO_LARGE';
393
+ readonly id: ObjectId;
394
+ readonly actualSize: number;
395
+ readonly limit: number;
396
+ };
397
+ declare const invalidObjectId: (value: string) => TsgitError;
398
+ declare const invalidObjectHeader: (reason: string) => TsgitError;
399
+ declare const invalidTreeEntry: (offset: number, reason: string) => TsgitError;
400
+ declare const invalidCommit: (reason: string) => TsgitError;
401
+ declare const invalidTag: (reason: string) => TsgitError;
402
+ declare const invalidFileMode: (value: string) => TsgitError;
403
+ declare const invalidIdentity: (line: string, reason: string) => TsgitError;
404
+
405
+ type ProtocolError = {
406
+ readonly code: 'INVALID_PKT_LENGTH';
407
+ readonly value: string;
408
+ } | {
409
+ readonly code: 'PKT_LENGTH_RESERVED';
410
+ readonly value: number;
411
+ } | {
412
+ readonly code: 'PKT_TOO_LARGE';
413
+ readonly value: number;
414
+ } | {
415
+ readonly code: 'PKT_TRUNCATED';
416
+ readonly remaining: number;
417
+ } | {
418
+ readonly code: 'INVALID_BASE_URL';
419
+ readonly reason: string;
420
+ } | {
421
+ readonly code: 'MISSING_SERVICE_HEADER';
422
+ readonly expected: string;
423
+ readonly actual: string;
424
+ } | {
425
+ readonly code: 'MISSING_CAPABILITIES';
426
+ } | {
427
+ readonly code: 'INVALID_REF_LINE';
428
+ readonly line: string;
429
+ } | {
430
+ readonly code: 'DUPLICATE_REF';
431
+ readonly name: string;
432
+ } | {
433
+ readonly code: 'INVALID_SIDEBAND_CHANNEL';
434
+ readonly channel: number;
435
+ } | {
436
+ readonly code: 'SIDEBAND_FATAL';
437
+ readonly message: string;
438
+ } | {
439
+ readonly code: 'UNKNOWN_ACK_STATUS';
440
+ readonly value: string;
441
+ } | {
442
+ readonly code: 'INVALID_REPORT_STATUS';
443
+ readonly line: string;
444
+ } | {
445
+ readonly code: 'EMPTY_WANTS';
446
+ } | {
447
+ readonly code: 'EMPTY_RECEIVE_UPDATES';
448
+ } | {
449
+ readonly code: 'REFSPEC_INVALID';
450
+ readonly raw: string;
451
+ readonly reason: string;
452
+ } | {
453
+ readonly code: 'TOO_MANY_ADVERTISED_REFS';
454
+ readonly count: number;
455
+ readonly limit: number;
456
+ } | {
457
+ readonly code: 'INVALID_FILTER_SPEC';
458
+ readonly spec: string;
459
+ readonly reason: string;
460
+ } | {
461
+ readonly code: 'REMOTE_FILTER_UNSUPPORTED';
462
+ };
463
+
464
+ type ReflogError = {
465
+ readonly code: 'INVALID_REFLOG_ENTRY';
466
+ readonly reason: string;
467
+ } | {
468
+ readonly code: 'REFLOG_NOT_FOUND';
469
+ readonly ref: RefName;
470
+ } | {
471
+ readonly code: 'REFLOG_ENTRY_OUT_OF_RANGE';
472
+ readonly ref: RefName;
473
+ readonly requested: number;
474
+ readonly available: number;
475
+ };
476
+
477
+ type RefsError = {
478
+ readonly code: 'INVALID_REF';
479
+ readonly reason: string;
480
+ } | {
481
+ readonly code: 'INVALID_PACKED_REFS';
482
+ readonly reason: string;
483
+ } | {
484
+ readonly code: 'REF_NOT_FOUND';
485
+ readonly name: RefName;
486
+ } | {
487
+ readonly code: 'REF_CHAIN_TOO_DEEP';
488
+ readonly depth: number;
489
+ readonly chain: ReadonlyArray<RefName>;
490
+ } | {
491
+ readonly code: 'REF_CYCLE_DETECTED';
492
+ readonly chain: ReadonlyArray<RefName>;
493
+ } | {
494
+ readonly code: 'REF_LOCKED';
495
+ readonly name: RefName;
496
+ } | {
497
+ readonly code: 'REF_UPDATE_CONFLICT';
498
+ readonly name: RefName;
499
+ readonly expected: ObjectId | 'absent';
500
+ readonly actual: ObjectId | 'absent';
501
+ };
502
+
503
+ type RepositoryError = {
504
+ readonly code: 'NOT_A_REPOSITORY';
505
+ readonly path: FilePath;
506
+ } | {
507
+ readonly code: 'BARE_REPOSITORY';
508
+ readonly operation: string;
509
+ } | {
510
+ readonly code: 'ALREADY_INITIALIZED';
511
+ readonly path: FilePath;
512
+ };
513
+
514
+ /**
515
+ * Platform-abstracted stat shape for working-tree entries. Aligns with
516
+ * `src/ports/file-system.ts:FileStat` — `mtimeNs` and `ino` are optional so
517
+ * the browser adapter (which exposes neither) can satisfy the shape.
518
+ *
519
+ * `mode` is included so race detection covers chmod-only changes
520
+ * (executable-bit flips, permission tweaks). Racy-stat detection prefers
521
+ * `mtimeNs` when present, falls back to `mtimeMs`, and falls back further
522
+ * to SHA-trailer comparison for the index file specifically.
523
+ */
524
+ interface WorkdirStat {
525
+ readonly mode: FileMode;
526
+ readonly size: number;
527
+ readonly mtimeMs: number;
528
+ readonly mtimeNs?: bigint;
529
+ readonly ino?: bigint;
530
+ }
531
+ /**
532
+ * Pure data shape for a working-tree row. `kind` discriminates the four
533
+ * entry shapes the walker emits; the surfaced `mode` field mirrors
534
+ * `stat.mode` for ergonomic access.
535
+ */
536
+ interface WorkdirEntryRow {
537
+ readonly source: 'workdir';
538
+ readonly path: FilePath;
539
+ readonly mode: FileMode;
540
+ readonly kind: 'file' | 'symlink' | 'directory' | 'submodule';
541
+ readonly stat: WorkdirStat;
542
+ }
543
+
544
+ type StorageError = {
545
+ readonly code: 'INVALID_PACK_HEADER';
546
+ readonly reason: string;
547
+ } | {
548
+ readonly code: 'INVALID_PACK_INDEX';
549
+ readonly reason: string;
550
+ } | {
551
+ readonly code: 'INVALID_PACK_ENTRY';
552
+ readonly offset: number;
553
+ readonly reason: string;
554
+ } | {
555
+ readonly code: 'INVALID_DELTA';
556
+ readonly reason: string;
557
+ } | {
558
+ readonly code: 'DELTA_CHAIN_TOO_DEEP';
559
+ readonly depth: number;
560
+ };
561
+
562
+ /** Submodule-tier error codes. */
563
+ type SubmoduleError = {
564
+ readonly code: 'RELATIVE_URL_UNRESOLVABLE';
565
+ readonly url: string;
566
+ } | {
567
+ readonly code: 'SUBMODULE_HAS_MODIFICATIONS';
568
+ readonly path: string;
569
+ } | {
570
+ readonly code: 'SUBMODULE_PATH_EXISTS';
571
+ readonly path: string;
572
+ };
573
+
574
+ /** Worktree-tier error codes. */
575
+ type WorktreeError = {
576
+ readonly code: 'WORKTREE_PATH_EXISTS';
577
+ readonly path: string;
578
+ } | {
579
+ readonly code: 'BRANCH_CHECKED_OUT';
580
+ readonly branch: string;
581
+ readonly path: string;
582
+ } | {
583
+ readonly code: 'WORKTREE_LOCKED';
584
+ readonly path: string;
585
+ readonly reason: string;
586
+ } | {
587
+ readonly code: 'WORKTREE_DIRTY';
588
+ readonly path: string;
589
+ } | {
590
+ readonly code: 'NOT_A_WORKTREE';
591
+ readonly path: string;
592
+ };
593
+
594
+ type AdapterError = {
595
+ readonly code: 'FILE_NOT_FOUND';
596
+ readonly path: string;
597
+ } | {
598
+ readonly code: 'FILE_EXISTS';
599
+ readonly path: string;
600
+ } | {
601
+ readonly code: 'NOT_A_DIRECTORY';
602
+ readonly path: string;
603
+ } | {
604
+ readonly code: 'DIRECTORY_NOT_EMPTY';
605
+ readonly path: string;
606
+ } | {
607
+ readonly code: 'PERMISSION_DENIED';
608
+ readonly path: string;
609
+ } | {
610
+ readonly code: 'UNSUPPORTED_OPERATION';
611
+ readonly operation: string;
612
+ readonly reason: string;
613
+ } | {
614
+ readonly code: 'HASH_FAILED';
615
+ readonly reason: string;
616
+ } | {
617
+ readonly code: 'COMPRESS_FAILED';
618
+ readonly reason: string;
619
+ } | {
620
+ readonly code: 'DECOMPRESS_FAILED';
621
+ readonly reason: string;
622
+ } | {
623
+ readonly code: 'HTTP_ERROR';
624
+ readonly statusCode: number;
625
+ readonly reason: string;
626
+ } | {
627
+ readonly code: 'NETWORK_ERROR';
628
+ readonly reason: string;
629
+ };
630
+ /** Cross-cutting application-tier codes raised by primitives (not adapters). */
631
+ type ApplicationError = {
632
+ readonly code: 'INVALID_WALK_INPUT';
633
+ readonly reason: string;
634
+ } | {
635
+ readonly code: 'OPERATION_ABORTED';
636
+ } | {
637
+ readonly code: 'RESOURCE_LOCKED';
638
+ readonly resource: 'index' | 'ref';
639
+ readonly path: string;
640
+ readonly mtimeMs?: number;
641
+ } | {
642
+ readonly code: 'PACK_TOO_LARGE';
643
+ readonly objectCount: number;
644
+ readonly limit: number;
645
+ } | {
646
+ readonly code: 'SNAPSHOT_REQUIRED';
647
+ readonly reason: string;
648
+ } | {
649
+ readonly code: 'WORKDIR_RACE';
650
+ readonly path: string;
651
+ readonly observed: WorkdirStat;
652
+ readonly current: WorkdirStat;
653
+ } | {
654
+ readonly code: 'ORDER_INVARIANT_VIOLATION';
655
+ readonly previous: string;
656
+ readonly current: string;
657
+ };
658
+ type TsgitErrorData = DomainObjectError | StorageError | RefsError | ReflogError | IndexError | AdapterError | DiffError | MergeError | ApplicationError | ProtocolError | RepositoryError | CommandError | SubmoduleError | WorktreeError;
659
+ declare class TsgitError extends Error {
660
+ readonly data: TsgitErrorData;
661
+ readonly name = "TsgitError";
662
+ constructor(data: TsgitErrorData);
663
+ }
664
+
665
+ type IndexError = {
666
+ readonly code: 'INVALID_INDEX_HEADER';
667
+ readonly reason: string;
668
+ } | {
669
+ readonly code: 'INVALID_INDEX_ENTRY';
670
+ readonly offset: number;
671
+ readonly reason: string;
672
+ };
673
+ declare const invalidIndexHeader: (reason: string) => TsgitError;
674
+ declare const invalidIndexEntry: (offset: number, reason: string) => TsgitError;
675
+
676
+ declare const stripspace: (message: string) => string;
677
+
678
+ declare function bytesToHex(bytes: Uint8Array): string;
679
+ declare function hexToBytes(hex: string): Uint8Array;
680
+ declare function compareBytes(a: Uint8Array, b: Uint8Array): number;
681
+
682
+ /**
683
+ * Length in bytes of an object's canonical payload — the body that follows
684
+ * `<type> <size>\0` on disk. Equal to the `size` field of git's
685
+ * `cat-file --batch` header.
686
+ *
687
+ * Blobs are O(1) (a slice of an existing buffer). Trees / commits / tags
688
+ * re-serialise the body to measure it; that matches the cost of
689
+ * `serializeObject` and is the price of not threading the on-disk size
690
+ * through the read pipeline. Acceptable for v1 — see
691
+ * `docs/design/cat-file-batch.md` §4.1.
692
+ */
693
+ declare const payloadByteLength: (object: GitObject, hash: HashConfig) => number;
694
+
695
+ declare function parseIndex(bytes: Uint8Array): GitIndex;
696
+
697
+ /**
698
+ * Lexicographic comparator for index entries. Git stores entries
699
+ * byte-sorted by path; this returns the standard `-1 / 0 / +1` triple so
700
+ * `Array.prototype.sort` produces ascending path order and leaves
701
+ * equal-path entries in their original (stable) order.
702
+ */
703
+ declare function compareEntryPath(a: IndexEntry$1, b: IndexEntry$1): number;
704
+ declare function serializeIndex(index: GitIndex): Uint8Array;
705
+
706
+ type ModeKind = 'file' | 'symlink' | 'directory' | 'gitlink';
707
+ declare function kindOf(mode: FileMode): ModeKind;
708
+ declare function isSameKind(a: FileMode, b: FileMode): boolean;
709
+ declare function isGitlink(mode: FileMode): boolean;
710
+
711
+ interface PatchFile {
712
+ readonly change: DiffChange;
713
+ readonly oldContent?: Uint8Array;
714
+ readonly newContent?: Uint8Array;
715
+ /** Override the binary-vs-text decision for the PATCH surface. `'binary'` forces the
716
+ * `Binary files … differ` / binary-body branch; `'text'` forces the text-hunk branch
717
+ * even over NUL content; `undefined` uses the default `isBinary` content-sniff. */
718
+ readonly patchBinaryOverride?: 'binary' | 'text';
719
+ /** Override the numstat decision (consumed by computeStatFields via diff-trees, NOT by
720
+ * this serializer). Carried on PatchFile so a single resolve pass attaches both. */
721
+ readonly numstatBinaryOverride?: 'binary' | 'text';
722
+ }
723
+ interface PatchPathPrefix {
724
+ readonly old: string;
725
+ readonly new: string;
726
+ }
727
+ interface PatchOptions {
728
+ readonly contextLines?: number;
729
+ readonly pathPrefix?: PatchPathPrefix;
730
+ readonly lineKey?: LineKey;
731
+ readonly ignoreBlankLines?: boolean;
732
+ }
733
+ interface EmitOptions {
734
+ readonly lineKey?: LineKey;
735
+ readonly ignoreBlankLines?: boolean;
736
+ }
737
+ type EditKind = 'context' | 'delete' | 'insert';
738
+ interface BodyLine {
739
+ readonly kind: EditKind;
740
+ readonly text: string;
741
+ readonly trailingNoNewline: boolean;
742
+ }
743
+ interface OutputHunk {
744
+ readonly oldStart: number;
745
+ readonly oldLen: number;
746
+ readonly newStart: number;
747
+ readonly newLen: number;
748
+ readonly body: ReadonlyArray<BodyLine>;
749
+ }
750
+ /**
751
+ * Group the line-level diff of two blobs into unified-diff hunks (the shared
752
+ * core behind both the unified-diff serializer and range-diff's `## ` text). Each
753
+ * hunk carries its old/new line spans and a typed body (`context`/`delete`/
754
+ * `insert`). The `@@ -a,b +c,d @@` line numbers and the body prefixes are the
755
+ * caller's to render.
756
+ */
757
+ declare function computeHunks(oldBytes: Uint8Array, newBytes: Uint8Array, contextLines: number, options?: EmitOptions): ReadonlyArray<OutputHunk>;
758
+ declare function renderPatch(files: ReadonlyArray<PatchFile>, opts?: PatchOptions): string;
759
+
760
+ declare function comparePaths(a: FilePath, b: FilePath): number;
761
+ declare function sortByPath<T>(items: ReadonlyArray<T>, pathOf: (item: T) => FilePath): T[];
762
+
763
+ interface PathspecEntry {
764
+ /** Original raw pattern (including any leading `!`), for diagnostics. */
765
+ readonly pattern: string;
766
+ /** Pattern with the leading `!` (if any) stripped — the part that compiled to `compiled`. */
767
+ readonly body: string;
768
+ /** True when the original pattern started with `!`. */
769
+ readonly negated: boolean;
770
+ /**
771
+ * True when the body (post-`!`) contains no glob metacharacters.
772
+ * Literal entries match the exact path AND any descendant — Git's
773
+ * `git add src` semantics where `src` covers everything under it.
774
+ */
775
+ readonly isLiteral: boolean;
776
+ /** Compiled glob matcher. Always tested against the candidate path verbatim. */
777
+ readonly compiled: GlobMatcher;
778
+ }
779
+ type Pathspec = ReadonlyArray<PathspecEntry>;
780
+
781
+ /**
782
+ * Three index-entry boolean flags lifted out of git's wire format. Each is
783
+ * a real index attribute; they collectively cover the bits status / add /
784
+ * checkout consult.
785
+ *
786
+ * - `assumeUnchanged` (git-update-index `--assume-unchanged`): the user has
787
+ * promised the file does not change; tools may skip stat checks.
788
+ * - `skipWorktree` (sparse-checkout): the file is tracked but should not be
789
+ * materialized in the working tree.
790
+ * - `intentToAdd` (`git add --intent-to-add`): the entry exists with mode +
791
+ * path but its content has not yet been staged; oid is the empty blob.
792
+ */
793
+ interface IndexFlags {
794
+ readonly assumeUnchanged: boolean;
795
+ readonly skipWorktree: boolean;
796
+ readonly intentToAdd: boolean;
797
+ }
798
+ /**
799
+ * Stat snapshot persisted alongside each index entry by git's stat-cache.
800
+ * May be stale (the file may have been modified since the index was
801
+ * written); validity is determined by comparing against a fresh `lstat`
802
+ * per git's racy-stat rules. Fields mirror the optional-precision shape
803
+ * already used by `src/ports/file-system.ts:FileStat`.
804
+ */
805
+ interface IndexCachedStat {
806
+ readonly mtimeMs: number;
807
+ readonly mtimeNs?: bigint;
808
+ readonly size: number;
809
+ readonly ino?: bigint;
810
+ }
811
+ /**
812
+ * Pure data shape for an index-source row. Stage > 0 means the entry is
813
+ * part of an unmerged path (1 = base, 2 = ours, 3 = theirs); stage 0 is
814
+ * the resolved / normal entry.
815
+ */
816
+ interface IndexEntryRow {
817
+ readonly source: 'index';
818
+ readonly path: FilePath;
819
+ readonly oid: ObjectId;
820
+ readonly mode: FileMode;
821
+ readonly stage: 0 | 1 | 2 | 3;
822
+ readonly flags: IndexFlags;
823
+ readonly cachedStat?: IndexCachedStat;
824
+ }
825
+
826
+ /**
827
+ * Extracts the entry shape `E` from a `Snapshot<E>` constraint. Used by
828
+ * the join row types to project each slot's entry shape onto the merged
829
+ * row.
830
+ */
831
+ type EntryOf<X> = X extends {
832
+ entries(opts?: unknown): AsyncIterable<infer E>;
833
+ } ? E : never;
834
+ /**
835
+ * Outer-join row — `path` is mandatory, every named slot is OPTIONAL.
836
+ * A slot is `undefined` for rows where that source did not contribute
837
+ * an entry at the given path.
838
+ */
839
+ type OuterJoinRow<S> = {
840
+ readonly path: FilePath;
841
+ } & {
842
+ readonly [K in keyof S]?: EntryOf<S[K]>;
843
+ };
844
+ /**
845
+ * Inner-join row — `path` is mandatory and every named slot is REQUIRED
846
+ * (no `?`). Only rows where every source contributed an entry at the
847
+ * given path are emitted.
848
+ */
849
+ type InnerJoinRow<S> = {
850
+ readonly path: FilePath;
851
+ } & {
852
+ readonly [K in keyof S]: EntryOf<S[K]>;
853
+ };
854
+
855
+ /**
856
+ * Discriminator for snapshot sources. Each `Snapshot` handle carries a
857
+ * `kind` field so consumers can dispatch on the underlying source at
858
+ * runtime (matching the static discriminator on the entry's `source` field).
859
+ *
860
+ * Compound state heads (`mergeHead`, `cherryPickHead`, etc.) resolve to a
861
+ * tree but advertise their own kind so callers can distinguish a
862
+ * fresh-cloned `head` from a `mergeHead` at the snapshot-handle level.
863
+ */
864
+ type SnapshotKind = 'tree' | 'commit' | 'index' | 'workdir' | 'mergeHead' | 'cherryPickHead' | 'revertHead' | 'fetchHead' | 'stash';
865
+
866
+ /**
867
+ * Pure data shape for a tree-source row. Carried inside `TreeEntry`
868
+ * (application tier) which adds I/O methods. Domain layering rule:
869
+ * this file has zero outward imports beyond `domain/objects/`.
870
+ */
871
+ interface TreeEntryRow {
872
+ readonly source: 'tree';
873
+ readonly path: FilePath;
874
+ readonly oid: ObjectId;
875
+ readonly mode: FileMode;
876
+ readonly kind: 'file' | 'symlink' | 'submodule';
877
+ }
878
+
879
+ /**
880
+ * Options shared by every resolver port. The `bypassCache` flag asks a
881
+ * caching adapter to skip its cache for this call; raw adapters ignore it.
882
+ */
883
+ interface ResolveOptions {
884
+ readonly bypassCache?: boolean;
885
+ }
886
+ /**
887
+ * Predicate used by `WorkdirEnumerator` to prune working-tree traversal.
888
+ * Mirrors the existing `WalkIgnorePredicate` shape (14.3) so the same
889
+ * `repo.ignoreMatcher()` builder can be used at both the legacy walker
890
+ * surface and the new snapshot surface.
891
+ *
892
+ * Invoked on every directory BEFORE descent (returning `true` prunes the
893
+ * entire subtree, skipping its `lstat` cost) and on every leaf BEFORE
894
+ * yielding (returning `true` drops the leaf). Composes with `paths`
895
+ * (pathspec inclusion filter) via logical AND.
896
+ */
897
+ type WalkIgnorePredicate = (path: FilePath, isDirectory: boolean) => boolean | Promise<boolean>;
898
+ /**
899
+ * Options for `WorkdirEnumerator.enumerate`. The snapshot layer translates
900
+ * `WorkdirSnapshotOptions` (which carries higher-level concerns like
901
+ * `consistency`) down to this shape; the enumerator port itself stays
902
+ * focused on what to enumerate.
903
+ */
904
+ interface WorkdirEnumOptions {
905
+ readonly paths?: Pathspec;
906
+ readonly excludes?: WalkIgnorePredicate;
907
+ readonly maxDepth?: number;
908
+ readonly maxEntries?: number;
909
+ readonly signal?: AbortSignal;
910
+ }
911
+ /**
912
+ * Resolves `.git/index` to its parsed `GitIndex` structure. Caching
913
+ * adapters (see `src/adapters/snapshot-resolvers/caching-index-resolver.ts`)
914
+ * implement freshness via the `WriteEventStream` + `GenerationView` ports;
915
+ * raw adapters parse on every call.
916
+ *
917
+ * Callers MUST treat the returned value as deeply frozen — implementations
918
+ * are free to share the same `GitIndex` reference across calls.
919
+ */
920
+ interface IndexResolver {
921
+ resolve(ctx: Context, opts?: ResolveOptions): Promise<GitIndex>;
922
+ }
923
+ /**
924
+ * Resolves a tree object by its oid. Caching adapters use a content-addressed
925
+ * LRU (oids are immutable, no invalidation needed). Throws on type
926
+ * mismatch — the oid must address a tree.
927
+ */
928
+ interface TreeResolver {
929
+ resolve(ctx: Context, treeId: ObjectId, opts?: ResolveOptions): Promise<Tree>;
930
+ }
931
+ /**
932
+ * Streams working-tree entries in canonical git path order. Honors
933
+ * `ctx.signal` and the optional `opts.signal`; aborts surface as
934
+ * `operationAborted()` from the iterator.
935
+ */
936
+ interface WorkdirEnumerator {
937
+ enumerate(ctx: Context, opts: WorkdirEnumOptions): AsyncIterable<WorkdirEntryRow>;
938
+ }
939
+
940
+ /**
941
+ * Application-tier wrapper around `IndexEntryRow`. Inherits the sync data
942
+ * fields (path/oid/mode/stage/flags/cachedStat) and adds `read()`, which
943
+ * pulls the blob bytes by oid via the existing object resolver chain.
944
+ *
945
+ * Index entries' `cachedStat` reflects the index's stat-cache; it MAY
946
+ * disagree with the live filesystem. Consumers that need fresh stat
947
+ * data should consult a `WorkdirSnapshot` instead.
948
+ */
949
+ interface IndexEntry extends IndexEntryRow {
950
+ read(): Promise<Uint8Array>;
951
+ }
952
+
953
+ /**
954
+ * Application-tier wrapper around `TreeEntryRow`. Inherits the sync data
955
+ * fields (path/oid/mode/kind) and adds the I/O method `read()`, which
956
+ * pulls the blob bytes for this entry's oid via the existing object
957
+ * resolver chain.
958
+ *
959
+ * Each entry binds to the `Context` it was created with. Holding an entry
960
+ * past its context's lifetime is undefined — the resolver may reject the
961
+ * read with an aborted-operation error if the context's signal fires.
962
+ */
963
+ interface TreeEntry extends TreeEntryRow {
964
+ read(): Promise<Uint8Array>;
965
+ }
966
+
967
+ /**
968
+ * Discriminator for write-target categories used across the CQS port triple
969
+ * — `WriteEventEmitter` (command), `WriteEventStream` (subscribe), and
970
+ * `GenerationView` (query). See ADR-157 for the rationale of splitting
971
+ * those three concerns across separate port files; `WriteScope` lives in
972
+ * its own file so none of the three ports needs to import another's
973
+ * declaration, preserving the CQS split at the import-graph level.
974
+ */
975
+ type WriteScope = 'index' | 'refs' | 'objects';
976
+
977
+ /**
978
+ * Query side of the write-event triple (ADR-157). Read primitives depend on
979
+ * this interface only — they query the current generation per scope but
980
+ * cannot emit or subscribe.
981
+ *
982
+ * `current(scope)` is monotonic per scope: each successful `WriteEventEmitter.emit(scope)`
983
+ * increments the corresponding counter exactly once. Scopes are independent
984
+ * — `emit('index')` does not affect `current('refs')` or `current('objects')`.
985
+ */
986
+ interface GenerationView {
987
+ current(scope: WriteScope): number;
988
+ }
989
+
990
+ /**
991
+ * Command side of the write-event triple (ADR-157). Write-boundary primitives
992
+ * depend on this interface only — they cannot observe events, only emit them.
993
+ *
994
+ * Implementations MUST be called AFTER a successful write but BEFORE
995
+ * releasing any acquired lock. See `docs/understand/caching.md` for the
996
+ * lock-ordering protocol; in-process readers rely on the
997
+ * emit-before-release ordering to avoid TOCTOU windows.
998
+ */
999
+ interface WriteEventEmitter {
1000
+ emit(scope: WriteScope): void;
1001
+ }
1002
+
1003
+ /**
1004
+ * Disposable handle returned from `WriteEventStream.subscribe`. Matches the
1005
+ * shape of TC39 Explicit Resource Management's `Disposable` so callers can
1006
+ * use `using` syntax once the project's TS target supports it.
1007
+ */
1008
+ interface Disposable {
1009
+ dispose(): void;
1010
+ }
1011
+ /**
1012
+ * Subscribe side of the write-event triple (ADR-157). Cache adapters depend
1013
+ * on this interface only — they observe events but cannot emit them.
1014
+ *
1015
+ * Subscribers receive identical event sequences regardless of subscription
1016
+ * order. Disposing a subscription removes the listener; the next event is
1017
+ * not delivered to that listener.
1018
+ */
1019
+ interface WriteEventStream {
1020
+ subscribe(listener: (scope: WriteScope) => void): Disposable;
1021
+ }
1022
+
1023
+ /**
1024
+ * Application-tier wrapper around `WorkdirEntryRow`. Inherits the sync
1025
+ * data fields (path/mode/kind/stat) and adds four named I/O methods:
1026
+ *
1027
+ * - `hash()` — reads the file, computes its blob-hash (`blob <size>\0` +
1028
+ * bytes hashed by `ctx.hash`). For a symlink, hashes the
1029
+ * link target bytes (git's convention).
1030
+ * - `read()` — raw file bytes (no hash). For a symlink, returns the
1031
+ * target as UTF-8 bytes.
1032
+ * - `readLink()` — symlink target string. Throws `UNSUPPORTED_OPERATION`
1033
+ * when `kind !== 'symlink'`.
1034
+ * - `verify()` — re-`lstat`s the entry; throws `WORKDIR_RACE` if any
1035
+ * of `(mode, size, mtimeMs)` differs from the row's
1036
+ * original stat. The opt-in race-detection hook for
1037
+ * `add -p` / `checkout --detect-races` style callers.
1038
+ *
1039
+ * Each entry binds to the `Context` it was created with; the absolute
1040
+ * workdir path is computed once at creation and shared by every method.
1041
+ */
1042
+ interface WorkdirEntry extends WorkdirEntryRow {
1043
+ hash(): Promise<ObjectId>;
1044
+ read(): Promise<Uint8Array>;
1045
+ readLink(): Promise<string>;
1046
+ verify(): Promise<void>;
1047
+ }
1048
+
1049
+ /**
1050
+ * Lazy, atomic-iteration view of a row source (tree / index / workdir / …).
1051
+ * Snapshots are descriptions, not data — no I/O happens until the consumer
1052
+ * starts iterating. See design §8 and ADR-149.
1053
+ *
1054
+ * Iteration-stability invariant: once a snapshot's `entries()` resolves its
1055
+ * underlying source on the first iteration, every subsequent iteration on
1056
+ * the same handle replays from that captured source. Concurrent writes
1057
+ * routed through `WriteEventEmitter.emit(scope)` invalidate the underlying
1058
+ * resolver cache for *new* snapshots but never disturb in-flight iterations.
1059
+ */
1060
+ interface Snapshot<E extends SnapshotEntry> {
1061
+ readonly kind: SnapshotKind;
1062
+ entries(opts?: SnapshotOptions): AsyncIterable<E>;
1063
+ }
1064
+ type SnapshotEntry = TreeEntry | IndexEntry | WorkdirEntry;
1065
+ type TreeSnapshot = Snapshot<TreeEntry>;
1066
+ type IndexSnapshot = Snapshot<IndexEntry>;
1067
+ type WorkdirSnapshot = Snapshot<WorkdirEntry>;
1068
+ interface SnapshotOptions {
1069
+ readonly paths?: Pathspec;
1070
+ readonly recurse?: boolean;
1071
+ readonly maxDepth?: number;
1072
+ readonly maxEntries?: number;
1073
+ readonly bypassCache?: boolean;
1074
+ readonly signal?: AbortSignal;
1075
+ }
1076
+
1077
+ /**
1078
+ * A point-in-time view of a stash entry. The trio (index, workdir,
1079
+ * untracked) is exposed as plain properties — discoverable at hand-out
1080
+ * time, not behind a method (ADR-156 + design §9.1).
1081
+ *
1082
+ * `untracked` is `null` when the stash was created without
1083
+ * `--include-untracked`. Consumers branch on the property's value, not
1084
+ * on whether a method exists.
1085
+ */
1086
+ interface StashSnapshot {
1087
+ readonly kind: 'stash';
1088
+ readonly index: TreeSnapshot;
1089
+ readonly workdir: TreeSnapshot;
1090
+ readonly untracked: TreeSnapshot | null;
1091
+ }
1092
+
1093
+ interface WorkdirSnapshotOptions extends SnapshotOptions {
1094
+ readonly excludes?: WalkIgnorePredicate;
1095
+ readonly consistency?: 'eager' | 'verified';
1096
+ }
1097
+
1098
+ interface SnapshotFactory {
1099
+ head(opts?: SnapshotOptions): TreeSnapshot;
1100
+ commit(oid: ObjectId, opts?: SnapshotOptions): TreeSnapshot;
1101
+ tree(oid: ObjectId, opts?: SnapshotOptions): TreeSnapshot;
1102
+ index(opts?: SnapshotOptions): IndexSnapshot;
1103
+ workdir(opts?: WorkdirSnapshotOptions): WorkdirSnapshot;
1104
+ mergeHead(opts?: SnapshotOptions): Promise<TreeSnapshot | null>;
1105
+ cherryPickHead(opts?: SnapshotOptions): Promise<TreeSnapshot | null>;
1106
+ revertHead(opts?: SnapshotOptions): Promise<TreeSnapshot | null>;
1107
+ fetchHead(opts?: SnapshotOptions): Promise<TreeSnapshot | null>;
1108
+ stashEntry(stashIndex: number, opts?: SnapshotOptions): Promise<StashSnapshot | null>;
1109
+ }
1110
+
1111
+ /**
1112
+ * The four adapter ports the facade plumbs into the Context. Each runtime
1113
+ * shim (`index.node.ts`, `index.browser.ts`, `index.default.ts` — wired in
1114
+ * Step 5) provides a `detectAdapter(): AdapterSet` that returns the runtime-
1115
+ * appropriate set.
1116
+ */
1117
+ interface AdapterSet {
1118
+ readonly fs: FileSystem;
1119
+ readonly hash: HashService;
1120
+ readonly compressor: Compressor;
1121
+ readonly transport: HttpTransport;
1122
+ }
1123
+ /**
1124
+ * Prototype-pollution-safe runtime check. Returns true only when `process` is
1125
+ * an object that owns BOTH `versions` and `versions.node` as own properties —
1126
+ * an attacker who pollutes `Object.prototype.versions` cannot make this
1127
+ * return true.
1128
+ *
1129
+ * Used as a manual fallback only; the primary detection mechanism is
1130
+ * `package.json` conditional exports (resolved at bundle time, immune to
1131
+ * runtime pollution).
1132
+ */
1133
+ declare const isNode: () => boolean;
1134
+ /**
1135
+ * Returns true when both `window` and `navigator` exist AS OWN globals on
1136
+ * `globalThis` AND have non-undefined values. Two-stage check:
1137
+ * - `hasOwn` rejects properties inherited from a polluted `Object.prototype`.
1138
+ * - `typeof` rejects own properties that have been assigned `undefined`
1139
+ * (e.g., test harnesses that stub the global to undefined).
1140
+ */
1141
+ declare const isBrowser: () => boolean;
1142
+ /**
1143
+ * Three-way runtime classification used by manual call sites. Node takes
1144
+ * precedence over browser when both look present (e.g., test environments
1145
+ * with jsdom + a real Node process).
1146
+ */
1147
+ declare const detectRuntime: () => "node" | "browser" | "memory";
1148
+
1149
+ /** No-op reporter — default when the caller does not provide one. */
1150
+ declare const noopProgress: ProgressReporter;
1151
+ /**
1152
+ * Built-in reporter that emits one line per call to a user-supplied `sink`.
1153
+ *
1154
+ * Format:
1155
+ * start(op) → "<safeOp>: start"
1156
+ * start(op, total) → "<safeOp>: start/<total>"
1157
+ * update(op, c) → "<safeOp>: <c>"
1158
+ * update(op, c, t) → "<safeOp>: <c>/<t>"
1159
+ * update(op, c, t, txt) → "<safeOp>: <c>/<t> <safeText>"
1160
+ * end(op) → "<safeOp>: done"
1161
+ *
1162
+ * `op` is sanitized identically to `text` (defense-in-depth: a programming bug
1163
+ * that wires a sideband-derived string into `op` cannot inject control characters).
1164
+ *
1165
+ * A throwing `sink` cannot crash the reporter — every call is wrapped in
1166
+ * try/catch.
1167
+ */
1168
+ declare const consoleProgress: (sink: (line: string) => void) => ProgressReporter;
1169
+
1170
+ export { invalidCommit as $, bytesToHex as N, compareBytes as Q, compareEntryPath as U, comparePaths as V, computeHunks as X, consoleProgress as Y, detectRuntime as Z, hexToBytes as _, invalidDiffInput as a0, invalidFileMode as a1, invalidIdentity as a2, invalidIndexEntry as a3, invalidIndexHeader as a4, invalidObjectHeader as a5, invalidObjectId as a6, invalidTag as a7, invalidTreeEntry as a8, invalidTreeForDiff as a9, isBrowser as aa, isGitlink as ab, isNode as ac, isSameKind as ad, kindOf as ae, noopProgress as af, parseIndex as ag, payloadByteLength as ah, renderPatch as ai, serializeIndex as aj, sortByPath as ak, stripspace as al, TsgitError as v };
1171
+ export type { AdapterSet as A, BodyLine as B, WorkdirSnapshot as C, DiffError as D, EntryOf as E, WorkdirSnapshotOptions as F, GenerationView as G, WorkdirStat as H, IndexCachedStat as I, WriteEventEmitter as J, WriteEventStream as K, WriteScope as L, ModeKind as M, OuterJoinRow as O, PatchFile as P, ResolveOptions as R, Snapshot as S, TreeEntry as T, WalkIgnorePredicate as W, Disposable as a, DomainObjectError as b, IndexEntry as c, IndexEntryRow as d, IndexError as e, IndexFlags as f, IndexResolver as g, IndexSnapshot as h, InnerJoinRow as i, OutputHunk as j, PatchOptions as k, PatchPathPrefix as l, Pathspec as m, SnapshotEntry as n, SnapshotFactory as o, SnapshotKind as p, SnapshotOptions as q, StashSnapshot as r, TreeEntryRow as s, TreeResolver as t, TreeSnapshot as u, WorkdirEntry as w, WorkdirEntryRow as x, WorkdirEnumOptions as y, WorkdirEnumerator as z };