@scolladon/tsgit 1.0.0 → 1.2.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 (144) hide show
  1. package/README.md +29 -137
  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/browser-http-transport-D4NH-8oJ.cjs +2 -0
  9. package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs.map +1 -0
  10. package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
  11. package/dist/cjs/chunks/error-CDLOBdNU.cjs +2 -0
  12. package/dist/cjs/chunks/error-CDLOBdNU.cjs.map +1 -0
  13. package/dist/cjs/chunks/index-BVArBKuk.cjs +2 -0
  14. package/dist/cjs/chunks/index-BVArBKuk.cjs.map +1 -0
  15. package/dist/cjs/chunks/index-DE9HSiWf.cjs +2 -0
  16. package/dist/cjs/chunks/index-DE9HSiWf.cjs.map +1 -0
  17. package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs → logger-CVG0zcPH.cjs} +2 -2
  18. package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs.map → logger-CVG0zcPH.cjs.map} +1 -1
  19. package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs +2 -0
  20. package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs.map +1 -0
  21. package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs +2 -0
  22. package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs.map +1 -0
  23. package/dist/cjs/chunks/{progress-CK7CT9vU.cjs → progress-Bj2w-90A.cjs} +2 -2
  24. package/dist/cjs/chunks/{progress-CK7CT9vU.cjs.map → progress-Bj2w-90A.cjs.map} +1 -1
  25. package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs +2 -0
  26. package/dist/cjs/chunks/readable-stream-MTA6D0Zh.cjs.map +1 -0
  27. package/dist/cjs/chunks/repository-BJwTSiGf.cjs +2 -0
  28. package/dist/cjs/chunks/repository-BJwTSiGf.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.default.cjs +1 -1
  34. package/dist/cjs/index.default.cjs.map +1 -1
  35. package/dist/cjs/index.node.cjs +1 -1
  36. package/dist/cjs/index.node.cjs.map +1 -1
  37. package/dist/cjs/operators/index.cjs +1 -1
  38. package/dist/cjs/operators/index.cjs.map +1 -1
  39. package/dist/cjs/primitives/index.cjs +1 -1
  40. package/dist/cjs/primitives/index.cjs.map +1 -1
  41. package/dist/cjs/transport/index.cjs.map +1 -1
  42. package/dist/esm/adapters/browser/index.js +1 -1
  43. package/dist/esm/adapters/browser/index.js.map +1 -1
  44. package/dist/esm/adapters/memory/index.js +1 -1
  45. package/dist/esm/adapters/memory/index.js.map +1 -1
  46. package/dist/esm/adapters/node/index.js +1 -1
  47. package/dist/esm/adapters/node/index.js.map +1 -1
  48. package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js +2 -0
  49. package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js.map +1 -0
  50. package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
  51. package/dist/esm/chunks/error-MOmSzp9Z.js +2 -0
  52. package/dist/esm/chunks/error-MOmSzp9Z.js.map +1 -0
  53. package/dist/esm/chunks/index-BjmofbKE.js +2 -0
  54. package/dist/esm/chunks/index-BjmofbKE.js.map +1 -0
  55. package/dist/esm/chunks/index-Jh5R-UmU.js +2 -0
  56. package/dist/esm/chunks/index-Jh5R-UmU.js.map +1 -0
  57. package/dist/esm/chunks/{logger-84ixEPbQ.js → logger-DP2cCpvL.js} +2 -2
  58. package/dist/esm/chunks/{logger-84ixEPbQ.js.map → logger-DP2cCpvL.js.map} +1 -1
  59. package/dist/esm/chunks/memory-http-transport-COJU6VOL.js +2 -0
  60. package/dist/esm/chunks/memory-http-transport-COJU6VOL.js.map +1 -0
  61. package/dist/esm/chunks/node-http-transport-DYCFIJbc.js +2 -0
  62. package/dist/esm/chunks/node-http-transport-DYCFIJbc.js.map +1 -0
  63. package/dist/esm/chunks/{progress-OTDhgmPO.js → progress-NePjO3Kd.js} +2 -2
  64. package/dist/esm/chunks/{progress-OTDhgmPO.js.map → progress-NePjO3Kd.js.map} +1 -1
  65. package/dist/esm/chunks/readable-stream-CGuf8k1J.js +2 -0
  66. package/dist/esm/chunks/readable-stream-CGuf8k1J.js.map +1 -0
  67. package/dist/esm/chunks/repository-Cs-dbHqO.js +2 -0
  68. package/dist/esm/chunks/repository-Cs-dbHqO.js.map +1 -0
  69. package/dist/esm/commands/index.js +1 -1
  70. package/dist/esm/index.browser.js +1 -1
  71. package/dist/esm/index.browser.js.map +1 -1
  72. package/dist/esm/index.default.js +1 -1
  73. package/dist/esm/index.default.js.map +1 -1
  74. package/dist/esm/index.js +1 -1
  75. package/dist/esm/index.node.js +1 -1
  76. package/dist/esm/index.node.js.map +1 -1
  77. package/dist/esm/operators/index.js +1 -1
  78. package/dist/esm/operators/index.js.map +1 -1
  79. package/dist/esm/primitives/index.js +1 -1
  80. package/dist/esm/primitives/index.js.map +1 -1
  81. package/dist/esm/transport/index.js.map +1 -1
  82. package/dist/types/adapters/browser/index.d.cts +2 -1
  83. package/dist/types/adapters/browser/index.d.ts +2 -1
  84. package/dist/types/adapters/memory/index.d.cts +23 -2
  85. package/dist/types/adapters/memory/index.d.ts +23 -2
  86. package/dist/types/adapters/node/index.d.cts +178 -3
  87. package/dist/types/adapters/node/index.d.ts +178 -3
  88. package/dist/types/chunks/{context-CTaXSPiP.d.ts → context-BORy7yXb.d.ts} +133 -20
  89. package/dist/types/chunks/{context-d36639-i.d.cts → context-CMrHCVwK.d.cts} +133 -20
  90. package/dist/types/chunks/reflog-entry-BIf-zt__.d.cts +331 -0
  91. package/dist/types/chunks/reflog-entry-D9P2hCgv.d.ts +331 -0
  92. package/dist/types/chunks/{repository-CFT9j9H6.d.cts → repository-BqibvTOu.d.cts} +23 -4
  93. package/dist/types/chunks/{repository-ntg7eXb2.d.ts → repository-C4rN09Am.d.ts} +23 -4
  94. package/dist/types/chunks/write-tree-B8G6kgTy.d.cts +154 -0
  95. package/dist/types/chunks/write-tree-BXCDChvv.d.ts +154 -0
  96. package/dist/types/commands/index.d.cts +229 -37
  97. package/dist/types/commands/index.d.ts +229 -37
  98. package/dist/types/index.browser.d.cts +4 -4
  99. package/dist/types/index.browser.d.ts +4 -4
  100. package/dist/types/index.d.cts +4 -4
  101. package/dist/types/index.d.ts +4 -4
  102. package/dist/types/index.default.d.cts +4 -4
  103. package/dist/types/index.default.d.ts +4 -4
  104. package/dist/types/index.node.d.cts +4 -4
  105. package/dist/types/index.node.d.ts +4 -4
  106. package/dist/types/operators/index.d.cts +17 -1
  107. package/dist/types/operators/index.d.ts +17 -1
  108. package/dist/types/primitives/index.d.cts +393 -171
  109. package/dist/types/primitives/index.d.ts +393 -171
  110. package/package.json +76 -10
  111. package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs +0 -2
  112. package/dist/cjs/chunks/browser-http-transport-BBF8uw-f.cjs.map +0 -1
  113. package/dist/cjs/chunks/error-DL4SHCBJ.cjs +0 -2
  114. package/dist/cjs/chunks/error-DL4SHCBJ.cjs.map +0 -1
  115. package/dist/cjs/chunks/error-DN8Vnwr4.cjs +0 -2
  116. package/dist/cjs/chunks/error-DN8Vnwr4.cjs.map +0 -1
  117. package/dist/cjs/chunks/index-iUd-bwwm.cjs +0 -2
  118. package/dist/cjs/chunks/index-iUd-bwwm.cjs.map +0 -1
  119. package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs +0 -2
  120. package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs.map +0 -1
  121. package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs +0 -2
  122. package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs.map +0 -1
  123. package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs +0 -2
  124. package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs.map +0 -1
  125. package/dist/cjs/chunks/repository-Cfo6Bj8T.cjs +0 -2
  126. package/dist/cjs/chunks/repository-Cfo6Bj8T.cjs.map +0 -1
  127. package/dist/esm/chunks/browser-http-transport-mZQKkInJ.js +0 -2
  128. package/dist/esm/chunks/browser-http-transport-mZQKkInJ.js.map +0 -1
  129. package/dist/esm/chunks/error-CnIcr6IG.js +0 -2
  130. package/dist/esm/chunks/error-CnIcr6IG.js.map +0 -1
  131. package/dist/esm/chunks/error-DTEP18A3.js +0 -2
  132. package/dist/esm/chunks/error-DTEP18A3.js.map +0 -1
  133. package/dist/esm/chunks/index-CJc-SKMj.js +0 -2
  134. package/dist/esm/chunks/index-CJc-SKMj.js.map +0 -1
  135. package/dist/esm/chunks/memory-http-transport-BmHjaEWj.js +0 -2
  136. package/dist/esm/chunks/memory-http-transport-BmHjaEWj.js.map +0 -1
  137. package/dist/esm/chunks/merge-base-DmuOYxfP.js +0 -2
  138. package/dist/esm/chunks/merge-base-DmuOYxfP.js.map +0 -1
  139. package/dist/esm/chunks/node-http-transport-Bz3noIS3.js +0 -2
  140. package/dist/esm/chunks/node-http-transport-Bz3noIS3.js.map +0 -1
  141. package/dist/esm/chunks/repository-qcX3-LkP.js +0 -2
  142. package/dist/esm/chunks/repository-qcX3-LkP.js.map +0 -1
  143. package/dist/types/chunks/diff-change-B09vxnxy.d.cts +0 -59
  144. package/dist/types/chunks/diff-change-D7xSeCn9.d.ts +0 -59
@@ -83,20 +83,25 @@ interface FileSystem {
83
83
  /**
84
84
  * Write bytes to file. Fails with FILE_EXISTS if the file already exists (exclusive create).
85
85
  *
86
- * Contract obligations (Phase 7 §14.17):
86
+ * Contract obligations:
87
87
  * - **Parent-directory creation:** the adapter MUST ensure parent directories exist before the
88
- * exclusive write. Equivalent to `mkdir -p dirname(path)` before `open(path, O_EXCL)`. If the
89
- * parent is removed between the implicit mkdir and the open (e.g. concurrent `git gc` prunes
90
- * the fanout), the adapter retries once: re-create the parent, re-attempt the open. On a second
91
- * ENOENT the error propagates as FILE_NOT_FOUND.
88
+ * exclusive write. Equivalent to `mkdir -p dirname(path)` before `open(path, O_EXCL)`. If the
89
+ * parent is removed between the implicit mkdir and the open (e.g. concurrent `git gc` prunes
90
+ * the fanout), the adapter retries once: re-create the parent, re-attempt the open. On a second
91
+ * ENOENT the error propagates as FILE_NOT_FOUND.
92
92
  * - **Symlink-safe ancestor check:** the adapter MUST reject writes where any ancestor directory
93
- * of `path` is a symbolic link whose resolved target is outside the containment root. This
94
- * closes the attack where an attacker replaces `objects/xx/` with a symlink pointing elsewhere.
95
- * Implementation: lstat-walk the ancestor chain, or use `openat`-style relative opens.
93
+ * of `path` is a symbolic link whose resolved target is outside the containment root. This
94
+ * closes the attack where an attacker replaces `objects/xx/` with a symlink pointing elsewhere.
95
+ * Implementation: lstat-walk the ancestor chain, or use `openat`-style relative opens.
96
96
  */
97
97
  readonly writeExclusive: (path: string, data: Uint8Array) => Promise<void>;
98
98
  /** Write UTF-8 string to file, creating parent directories as needed. */
99
99
  readonly writeUtf8: (path: string, content: string) => Promise<void>;
100
+ /**
101
+ * Append UTF-8 to a file, creating parent directories and the file as
102
+ * needed. Atomic per-call for line-sized writes (relies on `O_APPEND`).
103
+ */
104
+ readonly appendUtf8: (path: string, content: string) => Promise<void>;
100
105
  /** Check if path exists. */
101
106
  readonly exists: (path: string) => Promise<boolean>;
102
107
  /** Get file/directory metadata. Throws FILE_NOT_FOUND if not found. Follows symlinks. */
@@ -140,7 +145,7 @@ interface FileSystem {
140
145
  * - Node: `fs.open(path, O_NOFOLLOW | (mode === 'write' ? O_WRONLY : O_RDONLY))`.
141
146
  * - Memory: rejects with `PERMISSION_DENIED` when the leaf is a memory symlink entry.
142
147
  * - Browser OPFS: throws `UNSUPPORTED_OPERATION` (OPFS has no symlinks; callers can
143
- * fall back to a plain `read`/`write` because the no-follow guarantee holds vacuously).
148
+ * fall back to a plain `read`/`write` because the no-follow guarantee holds vacuously).
144
149
  *
145
150
  * Throws `FILE_NOT_FOUND` if the leaf does not exist (in `read` mode).
146
151
  * Throws `PERMISSION_DENIED` if the leaf is a symlink.
@@ -206,13 +211,73 @@ interface LruCache<V> {
206
211
  readonly entryCount: number;
207
212
  }
208
213
 
214
+ /**
215
+ * The lifecycle hooks tsgit invokes. Extend the union to add a hook.
216
+ *
217
+ * Kept in the domain layer because both the `HookRunner` port and the
218
+ * `HOOK_FAILED` command error reference it — a port may import domain, but
219
+ * domain may never import a port.
220
+ */
221
+ type HookName = 'pre-commit' | 'commit-msg' | 'pre-push';
222
+
223
+ /**
224
+ * A single hook invocation. The port is stateless — every fact the adapter
225
+ * needs to resolve and spawn the hook travels in this request.
226
+ */
227
+ interface HookRequest {
228
+ /** Hook to run. */
229
+ readonly name: HookName;
230
+ /** Absolute directory holding hook scripts — `core.hooksPath` or `${gitDir}/hooks`. */
231
+ readonly hooksDir: string;
232
+ /** Working directory for the spawned process — the working-tree root. */
233
+ readonly workDir: string;
234
+ /** Absolute `.git` directory — exported to the hook environment as `GIT_DIR`. */
235
+ readonly gitDir: string;
236
+ /** Positional arguments (e.g. the `COMMIT_EDITMSG` path for `commit-msg`). */
237
+ readonly args: ReadonlyArray<string>;
238
+ /** Bytes piped to the hook's stdin. Empty string ⇒ stdin closed empty. */
239
+ readonly stdin: string;
240
+ /** Cancels a running hook — the adapter kills the child when it aborts. */
241
+ readonly signal?: AbortSignal;
242
+ }
243
+ /**
244
+ * Outcome of a hook invocation.
245
+ *
246
+ * `skipped` — the hook file is absent or not executable; nothing ran. Git
247
+ * treats both as "no hook, proceed".
248
+ *
249
+ * `ran` — the hook ran to completion; `exitCode` is authoritative (a non-zero
250
+ * value is the caller's signal to abort).
251
+ */
252
+ type HookResult = {
253
+ readonly kind: 'skipped';
254
+ } | {
255
+ readonly kind: 'ran';
256
+ readonly exitCode: number;
257
+ readonly stdout: string;
258
+ readonly stderr: string;
259
+ };
260
+ /**
261
+ * Runs git lifecycle hooks. Optional on `Context`: when absent, hooks are
262
+ * inert (the browser has no runner; a host may opt out).
263
+ */
264
+ interface HookRunner {
265
+ /**
266
+ * Resolve `${hooksDir}/${name}`; when it exists and is executable, spawn it
267
+ * with `args`, `stdin`, `cwd = workDir`, and `GIT_DIR` in the environment.
268
+ * Resolves with the exit code and captured output. NEVER rejects for a
269
+ * non-zero exit — interpreting the exit code is the caller's policy.
270
+ */
271
+ readonly run: (request: HookRequest) => Promise<HookResult>;
272
+ }
273
+
209
274
  /**
210
275
  * General-purpose level-based logger consumed by the facade and any cross-cutting
211
276
  * concern (dispose, validation, lifecycle). Independent from the transport-tier
212
277
  * `Logger` in `transport/types.ts`, which is event-based and HTTP-shaped.
213
278
  *
214
279
  * The facade wraps user-supplied loggers with sanitization at construction time
215
- * (see Phase 10 design §8.5). Implementations should be tolerant of high call
280
+ * . Implementations should be tolerant of high call
216
281
  * frequency and MUST NOT throw — a throwing logger crashes nothing.
217
282
  */
218
283
  interface Logger {
@@ -225,8 +290,8 @@ interface Logger {
225
290
  declare const noopLogger: Logger;
226
291
  /**
227
292
  * Wrap a user-supplied logger so every `message` + every string value in the
228
- * `context` object passes through `sanitize()` (Phase 9 §4.7) before reaching
229
- * the sink. Per design §8.5 the facade applies this at construction time so no
293
+ * `context` object passes through `sanitize()` before reaching
294
+ * the sink. the facade applies this at construction time so no
230
295
  * downstream caller ever feeds raw control bytes to a user-controlled sink.
231
296
  *
232
297
  * Methods that the user did not supply are absent on the wrapper (preserves
@@ -237,7 +302,7 @@ declare const wrapLoggerSanitizer: (logger: Logger) => Logger;
237
302
 
238
303
  /**
239
304
  * Progress reporter shape consumed by long-running commands. The facade
240
- * (Phase 10) accepts a user-supplied implementation via
305
+ * accepts a user-supplied implementation via
241
306
  * `OpenRepositoryOptions.progress` and plumbs it onto `Context.progress`.
242
307
  *
243
308
  * Reporters are synchronous and fire-and-forget. The facade wraps every call
@@ -260,21 +325,51 @@ interface ProgressReporter {
260
325
  readonly end: (op: string) => void;
261
326
  }
262
327
 
328
+ /** Outcome of a promisor-remote lazy fetch (ADR-081). */
329
+ interface PromisorFetchOutcome {
330
+ /**
331
+ * False when the repository has no promisor remote configured — the caller
332
+ * (`readObject`) then falls through to its normal `OBJECT_NOT_FOUND`.
333
+ */
334
+ readonly attempted: boolean;
335
+ /** Objects the caller asked for. */
336
+ readonly requested: number;
337
+ /** Objects that were missing locally and were fetched from the promisor. */
338
+ readonly fetched: number;
339
+ }
263
340
  /**
264
- * Repository physical layout where the working tree and .git directory live.
265
- * Renamed in Phase 10 from the previous `RepositoryConfig` (port-tier) to free that
341
+ * Capability for fetching objects that a partial clone omitted, from the
342
+ * configured promisor remote. Wired onto `Context` by `openRepository` and
343
+ * consumed by `readObject` on a miss — the dependency-inverting seam that lets
344
+ * a primitive trigger a command-tier fetch without importing upward.
345
+ */
346
+ interface PromisorRemote {
347
+ fetch(oids: ReadonlyArray<ObjectId>): Promise<PromisorFetchOutcome>;
348
+ }
349
+
350
+ /**
351
+ * Repository physical layout — where the working tree and.git directory live.
352
+ * Renamed in from the previous `RepositoryConfig` (port-tier) to free that
266
353
  * name for the facade-tier `RepositoryConfig` shape (auth/parallelism/etc.).
267
354
  */
268
355
  interface RepositoryLayout {
269
356
  /** Absolute path to the repository root (working tree). */
270
357
  readonly workDir: string;
271
- /** Absolute path to the .git directory (usually `${workDir}/.git`, but may differ for bare repos or worktrees). */
358
+ /** Absolute path to the.git directory (usually `${workDir}/.git`, but may differ for bare repos or worktrees). */
272
359
  readonly gitDir: string;
273
360
  /** Whether this is a bare repository. */
274
361
  readonly bare: boolean;
362
+ /**
363
+ * Home directory for `~`-expansion in config-driven paths (e.g.
364
+ * `core.excludesFile = ~/.config/git/ignore`). Populated by the node
365
+ * shim from `os.homedir()`; memory adapter accepts an option; browser
366
+ * leaves it `undefined`. When `undefined`, loaders that need home
367
+ * expansion treat the source as missing.
368
+ */
369
+ readonly homeDir?: string;
275
370
  }
276
371
  /**
277
- * Author / committer identity — Phase 9 §4.7 shape.
372
+ * Author / committer identity shape.
278
373
  */
279
374
  interface AuthorIdentity {
280
375
  readonly name: string;
@@ -292,7 +387,7 @@ type AuthStrategy = {
292
387
  readonly password: string;
293
388
  };
294
389
  /**
295
- * Facade-tier configuration. Phase 10 introduces this shape; it carries the
390
+ * Facade-tier configuration. introduces this shape; it carries the
296
391
  * auth/parallelism/SSRF/network options the facade plumbs into network-pipeline.
297
392
  * All fields are optional — primitives and commands consult only the keys they need.
298
393
  */
@@ -304,7 +399,17 @@ interface RepositoryConfig {
304
399
  readonly upstreamRef?: RefName;
305
400
  readonly allowInsecure?: boolean;
306
401
  readonly allowPrivateNetworks?: boolean;
402
+ /**
403
+ * Hard cap (bytes) on a single pack body buffered in memory by `fetchPack`.
404
+ * Server-controlled byte counts above this raise `PACK_TOO_LARGE`. Default
405
+ * 512 MiB. Lower it for hardened deployments that clone only small repos.
406
+ */
307
407
  readonly maxResponseBytes?: number;
408
+ /**
409
+ * Hard cap on the entry-count field declared in a received pack header.
410
+ * Server-controlled `uint32` values above this raise `PACK_TOO_LARGE` before
411
+ * `fetchPack` allocates per-entry state. Default 50_000_000.
412
+ */
308
413
  readonly maxObjectsPerPack?: number;
309
414
  readonly detectRenames?: boolean;
310
415
  readonly breakStaleLockMs?: number;
@@ -332,6 +437,13 @@ interface Context {
332
437
  readonly logger?: Logger;
333
438
  /** Optional abort signal for cancelling long-running operations. */
334
439
  readonly signal?: AbortSignal;
440
+ /** Optional hook runner. Absent ⇒ hooks are inert (browser, or opted out). */
441
+ readonly hooks?: HookRunner;
442
+ /**
443
+ * Optional promisor-remote capability. Populated by `openRepository`;
444
+ * `readObject` consults it to lazy-fetch an object a partial clone omitted.
445
+ */
446
+ readonly promisor?: PromisorRemote;
335
447
  }
336
448
  interface CreateContextParts {
337
449
  readonly fs: FileSystem;
@@ -346,9 +458,10 @@ interface CreateContextParts {
346
458
  readonly config?: RepositoryConfig;
347
459
  readonly logger?: Logger;
348
460
  readonly signal?: AbortSignal;
461
+ readonly hooks?: HookRunner;
349
462
  }
350
463
  /** Assemble a frozen Context from its constituent ports + layout. */
351
464
  declare function createContext(parts: CreateContextParts): Context;
352
465
 
353
- export { ObjectId as O, RefName as R, FilePath as d, createContext as j, noopLogger as n, wrapLoggerSanitizer as w };
354
- export type { AuthStrategy as A, Compressor as C, DirEntry as D, FileHandle as F, HashService as H, InflateStreamResult as I, Logger as L, ProgressReporter as P, AuthorIdentity as a, Context as b, CreateContextParts as c, FileStat as e, FileSystem as f, Hasher as g, RepositoryConfig as h, RepositoryLayout as i };
466
+ export { ObjectId as O, RefName as R, FilePath as d, createContext as p, noopLogger as q, wrapLoggerSanitizer as w };
467
+ export type { AuthStrategy as A, Compressor as C, DirEntry as D, FileHandle as F, HashService as H, InflateStreamResult as I, Logger as L, ProgressReporter as P, AuthorIdentity as a, Context as b, CreateContextParts as c, FileStat as e, FileSystem as f, Hasher as g, HookName as h, HookRequest as i, HookResult as j, HookRunner as k, PromisorFetchOutcome as l, PromisorRemote as m, RepositoryConfig as n, RepositoryLayout as o };
@@ -0,0 +1,331 @@
1
+ import { O as ObjectId, d as FilePath, R as RefName, e as FileStat } from './context-CMrHCVwK.cjs';
2
+
3
+ interface AuthorIdentity {
4
+ readonly name: string;
5
+ readonly email: string;
6
+ readonly timestamp: number;
7
+ readonly timezoneOffset: string;
8
+ }
9
+
10
+ interface Blob {
11
+ readonly type: 'blob';
12
+ readonly id: ObjectId;
13
+ readonly content: Uint8Array;
14
+ }
15
+
16
+ interface ExtraHeader {
17
+ readonly key: string;
18
+ readonly value: string;
19
+ }
20
+ interface CommitData {
21
+ readonly tree: ObjectId;
22
+ readonly parents: ReadonlyArray<ObjectId>;
23
+ readonly author: AuthorIdentity;
24
+ readonly committer: AuthorIdentity;
25
+ readonly message: string;
26
+ readonly gpgSignature?: string;
27
+ readonly extraHeaders: ReadonlyArray<ExtraHeader>;
28
+ }
29
+ interface Commit {
30
+ readonly type: 'commit';
31
+ readonly id: ObjectId;
32
+ readonly data: CommitData;
33
+ }
34
+
35
+ declare const FILE_MODE: {
36
+ readonly REGULAR: "100644";
37
+ readonly EXECUTABLE: "100755";
38
+ readonly SYMLINK: "120000";
39
+ readonly DIRECTORY: "40000";
40
+ readonly GITLINK: "160000";
41
+ };
42
+ type FileMode = (typeof FILE_MODE)[keyof typeof FILE_MODE];
43
+
44
+ type ObjectType = 'blob' | 'tree' | 'commit' | 'tag';
45
+
46
+ interface TagData {
47
+ readonly object: ObjectId;
48
+ readonly objectType: ObjectType;
49
+ readonly tagName: string;
50
+ readonly tagger?: AuthorIdentity;
51
+ readonly message: string;
52
+ readonly gpgSignature?: string;
53
+ readonly extraHeaders: ReadonlyArray<ExtraHeader>;
54
+ }
55
+ interface Tag {
56
+ readonly type: 'tag';
57
+ readonly id: ObjectId;
58
+ readonly data: TagData;
59
+ }
60
+
61
+ interface TreeEntry {
62
+ readonly mode: FileMode;
63
+ readonly name: string;
64
+ readonly id: ObjectId;
65
+ }
66
+ interface Tree {
67
+ readonly type: 'tree';
68
+ readonly id: ObjectId;
69
+ readonly entries: ReadonlyArray<TreeEntry>;
70
+ }
71
+
72
+ type GitObject = Blob | Tree | Commit | Tag;
73
+
74
+ interface AddChange {
75
+ readonly type: 'add';
76
+ readonly newPath: FilePath;
77
+ readonly newId: ObjectId;
78
+ readonly newMode: FileMode;
79
+ }
80
+ interface DeleteChange {
81
+ readonly type: 'delete';
82
+ readonly oldPath: FilePath;
83
+ readonly oldId: ObjectId;
84
+ readonly oldMode: FileMode;
85
+ }
86
+ interface ModifyChange {
87
+ readonly type: 'modify';
88
+ readonly path: FilePath;
89
+ readonly oldId: ObjectId;
90
+ readonly newId: ObjectId;
91
+ readonly oldMode: FileMode;
92
+ readonly newMode: FileMode;
93
+ }
94
+ interface RenameChange {
95
+ readonly type: 'rename';
96
+ readonly oldPath: FilePath;
97
+ readonly newPath: FilePath;
98
+ readonly id: ObjectId;
99
+ readonly mode: FileMode;
100
+ }
101
+ interface TypeChangeChange {
102
+ readonly type: 'type-change';
103
+ readonly path: FilePath;
104
+ readonly oldId: ObjectId;
105
+ readonly newId: ObjectId;
106
+ readonly oldMode: FileMode;
107
+ readonly newMode: FileMode;
108
+ }
109
+ type DiffChange = AddChange | DeleteChange | ModifyChange | RenameChange | TypeChangeChange;
110
+ interface TreeDiff {
111
+ readonly changes: ReadonlyArray<DiffChange>;
112
+ }
113
+
114
+ interface RenameDetectOptions {
115
+ readonly limit?: number;
116
+ readonly maxSameIdDeletes?: number;
117
+ }
118
+
119
+ /**
120
+ * Primitive option shapes, walker value types, and shared constants.
121
+ * Defined in one location to avoid circular imports between primitive modules.
122
+ */
123
+
124
+ /** Max symbolic-ref dereferences resolveRef will follow. */
125
+ declare const MAX_SYMBOLIC_REF_DEPTH = 5;
126
+ /** Max tag-peel hops resolveRef / readTree will follow when peeling. */
127
+ declare const MAX_PEEL_DEPTH = 5;
128
+ /** Max seeds walkCommits.from can contain. */
129
+ declare const MAX_WALK_SEEDS = 1024;
130
+ /** Hard cap on walkCommits' pending queue size to prevent unbounded heap growth. */
131
+ declare const MAX_WALK_QUEUE_SIZE: number;
132
+ /** Max.git/index file size readIndex will accept. */
133
+ declare const MAX_INDEX_BYTES: number;
134
+ /** Max commit message byte length createCommit will accept. */
135
+ declare const MAX_COMMIT_MESSAGE_BYTES: number;
136
+ /**
137
+ * Per-file size cap enforced by `add --all` before reading working-tree
138
+ * bytes into memory. Mirrors `MAX_CONFLICT_OUTPUT_BYTES` (256 MiB) so the
139
+ * write-side memory ceiling matches the read-side ceiling.
140
+ * See `docs/adr/032-add-all-large-file-guard.md`.
141
+ */
142
+ declare const MAX_WORKING_TREE_BLOB_BYTES: number;
143
+ /**
144
+ * Per-file cap on `.gitignore`, `.git/info/exclude`, and the global
145
+ * excludesFile. 1 MiB leaves a 20× margin over real-world max-size
146
+ * gitignore corpora. See `docs/adr/036-gitignore-bounded-read.md`.
147
+ */
148
+ declare const MAX_GITIGNORE_BYTES: number;
149
+ /**
150
+ * Per-file cap on a single `.git/logs/<ref>` reflog file. 16 MiB is generous
151
+ * — `reflog expire` is the size-management story; this guard only stops an
152
+ * adversarial or corrupt log from being buffered unbounded into memory.
153
+ */
154
+ declare const MAX_REFLOG_BYTES: number;
155
+ interface ReadObjectOptions {
156
+ readonly verifyHash?: boolean;
157
+ /**
158
+ * Reject objects whose serialised payload exceeds this byte count, before
159
+ * inflating the full content into memory. Counts the raw object content
160
+ * (post-inflate, pre-loose-header). When unset, no cap applies.
161
+ *
162
+ * Used by `merge`'s content merger to bound peak memory when an adversarial
163
+ * remote ships pathologically large blobs. See `docs/design/phase-13-8-
164
+ * bounded-object-reads.md`.
165
+ */
166
+ readonly maxBytes?: number;
167
+ }
168
+ interface ResolveRefOptions {
169
+ readonly peel?: boolean;
170
+ readonly maxSymbolicDepth?: number;
171
+ readonly maxPeelDepth?: number;
172
+ }
173
+ /**
174
+ * `updateRef` option shapes. A write requires a `reflogMessage` — git's
175
+ * builtins always supply a reason string; the type checker forces every
176
+ * present and future ref write to state why the ref moved. A delete drops the
177
+ * reflog file, so it carries no message.
178
+ */
179
+ type UpdateRefOptions = {
180
+ readonly delete?: false;
181
+ readonly expected?: ObjectId | 'absent';
182
+ readonly reflogMessage: string;
183
+ } | {
184
+ readonly delete: true;
185
+ readonly expected?: ObjectId | 'absent';
186
+ };
187
+ interface WalkCommitsOptions {
188
+ readonly from: ReadonlyArray<ObjectId>;
189
+ readonly until?: ReadonlyArray<ObjectId>;
190
+ readonly order?: 'topo' | 'first-parent';
191
+ readonly ignoreMissing?: boolean;
192
+ readonly verifyHash?: boolean;
193
+ /**
194
+ * Commits whose parents must NOT be enqueued. Used for shallow boundaries
195
+ * . The commit itself is still yielded — only its parents are
196
+ * skipped. Callers that want to also skip the boundary commit pass it in
197
+ * `until`.
198
+ */
199
+ readonly shallow?: ReadonlySet<ObjectId>;
200
+ }
201
+ /** Maximum `have` lines a single-round fetch will send. */
202
+ declare const MAX_HAVES = 256;
203
+ /** Hard cap on objects enumerated for a single push. design */
204
+ declare const MAX_PUSH_OBJECTS = 1000000;
205
+ interface WalkTreeEntry {
206
+ readonly path: FilePath;
207
+ readonly id: ObjectId;
208
+ readonly mode: FileMode;
209
+ }
210
+ interface WalkTreeOptions {
211
+ readonly recursive?: boolean;
212
+ readonly maxDepth?: number;
213
+ readonly maxEntries?: number;
214
+ }
215
+ interface WalkWorkingTreeEntry {
216
+ readonly path: FilePath;
217
+ readonly stat: FileStat;
218
+ }
219
+ type WalkIgnorePredicate = (path: FilePath, isDirectory: boolean) => boolean | Promise<boolean>;
220
+ interface WalkWorkingTreeOptions {
221
+ readonly maxDepth?: number;
222
+ readonly maxEntries?: number;
223
+ /**
224
+ * predicate. Invoked on every directory BEFORE descent
225
+ * (returning `true` prunes the entire subtree, skipping its `lstat`
226
+ * cost) and on every leaf BEFORE yielding (returning `true` drops
227
+ * the leaf). May be sync or async.
228
+ */
229
+ readonly ignore?: WalkIgnorePredicate;
230
+ }
231
+ interface CreateCommitInput {
232
+ readonly tree: ObjectId;
233
+ readonly parents: ReadonlyArray<ObjectId>;
234
+ readonly author: AuthorIdentity;
235
+ readonly committer: AuthorIdentity;
236
+ readonly message: string;
237
+ readonly gpgSignature?: string;
238
+ readonly extraHeaders?: ReadonlyArray<ExtraHeader>;
239
+ }
240
+ type DiffTreesInput = Tree | ObjectId | undefined;
241
+ interface DiffTreesOptions {
242
+ readonly detectRenames?: boolean;
243
+ readonly renameOptions?: RenameDetectOptions;
244
+ }
245
+ /**
246
+ * Per-file cap on a single `.gitmodules` blob. 1 MiB matches the
247
+ * `MAX_GITIGNORE_BYTES` budget: real `.gitmodules` files are KB-scale even in
248
+ * very large superprojects, so a 1 MiB ceiling is a generous DoS guard
249
+ * applied before inflate.
250
+ */
251
+ declare const MAX_GITMODULES_BYTES: number;
252
+ /**
253
+ * Recursion backstop for `walkSubmodules` — the cycle guard (visited gitdir
254
+ * set) handles the genuine-cycle case; this cap stops a pathologically deep
255
+ * but acyclic nest from running away.
256
+ */
257
+ declare const MAX_SUBMODULE_DEPTH = 100;
258
+ /** One submodule surfaced by `walkSubmodules`: a gitlink joined with its `.gitmodules` row. */
259
+ interface SubmoduleEntry {
260
+ /**
261
+ * The `[submodule "<name>"]` subsection name in the `.gitmodules` of the
262
+ * tree that contains this gitlink. Falls back to `path` when no row matches
263
+ * the gitlink (a gitlink committed without a corresponding config entry).
264
+ */
265
+ readonly name: string;
266
+ /** Slash-joined path from the *superproject* root to the gitlink. */
267
+ readonly path: FilePath;
268
+ /** `submodule.<name>.url` — absent when no `.gitmodules` row matched. */
269
+ readonly url?: string;
270
+ /** `submodule.<name>.branch` — absent when the key is unset. */
271
+ readonly branch?: string;
272
+ /** The commit object id the gitlink pins (the tree entry's id). */
273
+ readonly commit: ObjectId;
274
+ /** Recursion depth; 0 for a direct submodule of the superproject. */
275
+ readonly depth: number;
276
+ /** Path of the containing submodule; absent for `depth === 0` entries. */
277
+ readonly parent?: FilePath;
278
+ }
279
+ /**
280
+ * One entry yielded by `catFileBatch` — a discriminated union so that a
281
+ * single bad id never aborts the stream. `ok: true` carries the parsed
282
+ * object plus its canonical payload size (matches the `<size>` field of
283
+ * `git cat-file --batch`'s header). `ok: false` is shaped to extend later:
284
+ * `reason` is a literal union so a future variant is an additive change.
285
+ */
286
+ /**
287
+ * Optional knobs for the `catFileBatch` primitive — currently a single
288
+ * `maxBytes` cap forwarded to each per-id `readObject` call so a long
289
+ * batch over untrusted ids cannot exhaust the heap. Defaults to no cap.
290
+ */
291
+ interface CatFileBatchOptions {
292
+ /**
293
+ * Per-object byte cap. Rejected pre-inflate; same semantics as
294
+ * `ReadObjectOptions.maxBytes`. When unset, no cap applies (parity
295
+ * with `readObject`).
296
+ */
297
+ readonly maxBytes?: number;
298
+ }
299
+ type CatFileBatchEntry = {
300
+ readonly ok: true;
301
+ readonly id: ObjectId;
302
+ readonly type: GitObject['type'];
303
+ readonly size: number;
304
+ readonly object: GitObject;
305
+ } | {
306
+ readonly ok: false;
307
+ readonly id: ObjectId;
308
+ readonly reason: 'missing';
309
+ };
310
+ interface WalkSubmodulesOptions {
311
+ /** Tree-ish to walk. Default: `HEAD`. */
312
+ readonly ref?: RefName | ObjectId;
313
+ /** Descend into nested submodules' own `.gitmodules`. Default: `false`. */
314
+ readonly recursive?: boolean;
315
+ /**
316
+ * Cap on recursion depth. Default: `MAX_SUBMODULE_DEPTH`. Entries at exactly
317
+ * this depth are yielded but not recursed into.
318
+ */
319
+ readonly maxDepth?: number;
320
+ }
321
+
322
+ /** One line of a reflog file: a single ref movement from `oldId` to `newId`. */
323
+ interface ReflogEntry {
324
+ readonly oldId: ObjectId;
325
+ readonly newId: ObjectId;
326
+ readonly identity: AuthorIdentity;
327
+ readonly message: string;
328
+ }
329
+
330
+ export { MAX_COMMIT_MESSAGE_BYTES as M, MAX_GITIGNORE_BYTES as e, MAX_GITMODULES_BYTES as f, MAX_HAVES as g, MAX_INDEX_BYTES as h, MAX_PEEL_DEPTH as i, MAX_PUSH_OBJECTS as j, MAX_REFLOG_BYTES as k, MAX_SUBMODULE_DEPTH as l, MAX_SYMBOLIC_REF_DEPTH as m, MAX_WALK_QUEUE_SIZE as n, MAX_WALK_SEEDS as o, MAX_WORKING_TREE_BLOB_BYTES as p };
331
+ export type { AuthorIdentity as A, Blob as B, CatFileBatchEntry as C, DiffTreesInput as D, FileMode as F, GitObject as G, ReadObjectOptions as R, SubmoduleEntry as S, Tree as T, UpdateRefOptions as U, WalkCommitsOptions as W, CatFileBatchOptions as a, Commit as b, CreateCommitInput as c, DiffTreesOptions as d, ReflogEntry as q, ResolveRefOptions as r, TreeDiff as s, TreeEntry as t, WalkIgnorePredicate as u, WalkSubmodulesOptions as v, WalkTreeEntry as w, WalkTreeOptions as x, WalkWorkingTreeEntry as y, WalkWorkingTreeOptions as z };