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