@scolladon/tsgit 1.1.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 (119) hide show
  1. package/README.md +29 -252
  2. package/dist/cjs/adapters/browser/index.cjs +1 -1
  3. package/dist/cjs/adapters/memory/index.cjs +1 -1
  4. package/dist/cjs/adapters/memory/index.cjs.map +1 -1
  5. package/dist/cjs/adapters/node/index.cjs +1 -1
  6. package/dist/cjs/adapters/node/index.cjs.map +1 -1
  7. package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs +2 -0
  8. package/dist/cjs/chunks/browser-http-transport-D4NH-8oJ.cjs.map +1 -0
  9. package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
  10. package/dist/cjs/chunks/{error-CqLvhejR.cjs → error-CDLOBdNU.cjs} +2 -2
  11. package/dist/cjs/chunks/error-CDLOBdNU.cjs.map +1 -0
  12. package/dist/cjs/chunks/index-BVArBKuk.cjs +2 -0
  13. package/dist/cjs/chunks/index-BVArBKuk.cjs.map +1 -0
  14. package/dist/cjs/chunks/index-DE9HSiWf.cjs +2 -0
  15. package/dist/cjs/chunks/index-DE9HSiWf.cjs.map +1 -0
  16. package/dist/cjs/chunks/{logger-C8Z5BfFF.cjs → logger-CVG0zcPH.cjs} +2 -2
  17. package/dist/cjs/chunks/{logger-C8Z5BfFF.cjs.map → logger-CVG0zcPH.cjs.map} +1 -1
  18. package/dist/cjs/chunks/{memory-http-transport-Pjyme5KN.cjs → memory-http-transport-DXwDGKtR.cjs} +2 -2
  19. package/dist/cjs/chunks/memory-http-transport-DXwDGKtR.cjs.map +1 -0
  20. package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs +2 -0
  21. package/dist/cjs/chunks/node-http-transport-vrbnNEDb.cjs.map +1 -0
  22. package/dist/cjs/chunks/{progress-CntEbiuo.cjs → progress-Bj2w-90A.cjs} +2 -2
  23. package/dist/cjs/chunks/{progress-CntEbiuo.cjs.map → progress-Bj2w-90A.cjs.map} +1 -1
  24. package/dist/cjs/chunks/repository-BJwTSiGf.cjs +2 -0
  25. package/dist/cjs/chunks/repository-BJwTSiGf.cjs.map +1 -0
  26. package/dist/cjs/commands/index.cjs +1 -1
  27. package/dist/cjs/index.browser.cjs +1 -1
  28. package/dist/cjs/index.cjs +1 -1
  29. package/dist/cjs/index.default.cjs +1 -1
  30. package/dist/cjs/index.node.cjs +1 -1
  31. package/dist/cjs/index.node.cjs.map +1 -1
  32. package/dist/cjs/primitives/index.cjs +1 -1
  33. package/dist/esm/adapters/browser/index.js +1 -1
  34. package/dist/esm/adapters/memory/index.js +1 -1
  35. package/dist/esm/adapters/memory/index.js.map +1 -1
  36. package/dist/esm/adapters/node/index.js +1 -1
  37. package/dist/esm/adapters/node/index.js.map +1 -1
  38. package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js +2 -0
  39. package/dist/esm/chunks/browser-http-transport-DL8bkNdg.js.map +1 -0
  40. package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
  41. package/dist/esm/chunks/{error-BN9rdQ33.js → error-MOmSzp9Z.js} +2 -2
  42. package/dist/esm/chunks/error-MOmSzp9Z.js.map +1 -0
  43. package/dist/esm/chunks/index-BjmofbKE.js +2 -0
  44. package/dist/esm/chunks/index-BjmofbKE.js.map +1 -0
  45. package/dist/esm/chunks/index-Jh5R-UmU.js +2 -0
  46. package/dist/esm/chunks/index-Jh5R-UmU.js.map +1 -0
  47. package/dist/esm/chunks/{logger-BLZbLzva.js → logger-DP2cCpvL.js} +2 -2
  48. package/dist/esm/chunks/{logger-BLZbLzva.js.map → logger-DP2cCpvL.js.map} +1 -1
  49. package/dist/esm/chunks/memory-http-transport-COJU6VOL.js +2 -0
  50. package/dist/esm/chunks/memory-http-transport-COJU6VOL.js.map +1 -0
  51. package/dist/esm/chunks/node-http-transport-DYCFIJbc.js +2 -0
  52. package/dist/esm/chunks/node-http-transport-DYCFIJbc.js.map +1 -0
  53. package/dist/esm/chunks/{progress-DJU_f66N.js → progress-NePjO3Kd.js} +2 -2
  54. package/dist/esm/chunks/{progress-DJU_f66N.js.map → progress-NePjO3Kd.js.map} +1 -1
  55. package/dist/esm/chunks/repository-Cs-dbHqO.js +2 -0
  56. package/dist/esm/chunks/repository-Cs-dbHqO.js.map +1 -0
  57. package/dist/esm/commands/index.js +1 -1
  58. package/dist/esm/index.browser.js +1 -1
  59. package/dist/esm/index.default.js +1 -1
  60. package/dist/esm/index.js +1 -1
  61. package/dist/esm/index.node.js +1 -1
  62. package/dist/esm/index.node.js.map +1 -1
  63. package/dist/esm/primitives/index.js +1 -1
  64. package/dist/types/adapters/browser/index.d.cts +2 -1
  65. package/dist/types/adapters/browser/index.d.ts +2 -1
  66. package/dist/types/adapters/memory/index.d.cts +21 -2
  67. package/dist/types/adapters/memory/index.d.ts +21 -2
  68. package/dist/types/adapters/node/index.d.cts +64 -3
  69. package/dist/types/adapters/node/index.d.ts +64 -3
  70. package/dist/types/chunks/{context-o5TPfMB2.d.ts → context-BORy7yXb.d.ts} +97 -2
  71. package/dist/types/chunks/{context-D84z1i5F.d.cts → context-CMrHCVwK.d.cts} +97 -2
  72. package/dist/types/chunks/reflog-entry-BIf-zt__.d.cts +331 -0
  73. package/dist/types/chunks/reflog-entry-D9P2hCgv.d.ts +331 -0
  74. package/dist/types/chunks/{repository-23evW2h-.d.cts → repository-BqibvTOu.d.cts} +21 -3
  75. package/dist/types/chunks/{repository-BT7Xq1kJ.d.ts → repository-C4rN09Am.d.ts} +21 -3
  76. package/dist/types/chunks/write-tree-B8G6kgTy.d.cts +154 -0
  77. package/dist/types/chunks/write-tree-BXCDChvv.d.ts +154 -0
  78. package/dist/types/commands/index.d.cts +152 -6
  79. package/dist/types/commands/index.d.ts +152 -6
  80. package/dist/types/index.browser.d.cts +4 -4
  81. package/dist/types/index.browser.d.ts +4 -4
  82. package/dist/types/index.d.cts +4 -4
  83. package/dist/types/index.d.ts +4 -4
  84. package/dist/types/index.default.d.cts +4 -4
  85. package/dist/types/index.default.d.ts +4 -4
  86. package/dist/types/index.node.d.cts +4 -4
  87. package/dist/types/index.node.d.ts +4 -4
  88. package/dist/types/primitives/index.d.cts +192 -7
  89. package/dist/types/primitives/index.d.ts +192 -7
  90. package/package.json +40 -2
  91. package/dist/cjs/chunks/browser-http-transport-DcG05jw3.cjs +0 -2
  92. package/dist/cjs/chunks/browser-http-transport-DcG05jw3.cjs.map +0 -1
  93. package/dist/cjs/chunks/error-CqLvhejR.cjs.map +0 -1
  94. package/dist/cjs/chunks/index-BcxdLkNe.cjs +0 -2
  95. package/dist/cjs/chunks/index-BcxdLkNe.cjs.map +0 -1
  96. package/dist/cjs/chunks/index-D5Nd-Mks.cjs +0 -2
  97. package/dist/cjs/chunks/index-D5Nd-Mks.cjs.map +0 -1
  98. package/dist/cjs/chunks/memory-http-transport-Pjyme5KN.cjs.map +0 -1
  99. package/dist/cjs/chunks/node-http-transport-UkW5eEm3.cjs +0 -2
  100. package/dist/cjs/chunks/node-http-transport-UkW5eEm3.cjs.map +0 -1
  101. package/dist/cjs/chunks/repository-B_jx2AKW.cjs +0 -2
  102. package/dist/cjs/chunks/repository-B_jx2AKW.cjs.map +0 -1
  103. package/dist/esm/chunks/browser-http-transport-COFgnEyq.js +0 -2
  104. package/dist/esm/chunks/browser-http-transport-COFgnEyq.js.map +0 -1
  105. package/dist/esm/chunks/error-BN9rdQ33.js.map +0 -1
  106. package/dist/esm/chunks/index-BdV37p4e.js +0 -2
  107. package/dist/esm/chunks/index-BdV37p4e.js.map +0 -1
  108. package/dist/esm/chunks/index-BkRJ9-Im.js +0 -2
  109. package/dist/esm/chunks/index-BkRJ9-Im.js.map +0 -1
  110. package/dist/esm/chunks/memory-http-transport-DRYdYgiE.js +0 -2
  111. package/dist/esm/chunks/memory-http-transport-DRYdYgiE.js.map +0 -1
  112. package/dist/esm/chunks/node-http-transport-Bp5cFZCt.js +0 -2
  113. package/dist/esm/chunks/node-http-transport-Bp5cFZCt.js.map +0 -1
  114. package/dist/esm/chunks/repository-DiagDiT_.js +0 -2
  115. package/dist/esm/chunks/repository-DiagDiT_.js.map +0 -1
  116. package/dist/types/chunks/diff-change-Bm1zvVsC.d.cts +0 -59
  117. package/dist/types/chunks/diff-change-alGRzD_j.d.ts +0 -59
  118. package/dist/types/chunks/write-tree-DNjhjS3t.d.ts +0 -282
  119. package/dist/types/chunks/write-tree-DVp0RJ_r.d.cts +0 -282
@@ -97,6 +97,11 @@ interface FileSystem {
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. */
@@ -206,6 +211,66 @@ 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
@@ -260,6 +325,28 @@ 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
+ }
340
+ /**
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
+
263
350
  /**
264
351
  * Repository physical layout — where the working tree and.git directory live.
265
352
  * Renamed in from the previous `RepositoryConfig` (port-tier) to free that
@@ -350,6 +437,13 @@ interface Context {
350
437
  readonly logger?: Logger;
351
438
  /** Optional abort signal for cancelling long-running operations. */
352
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;
353
447
  }
354
448
  interface CreateContextParts {
355
449
  readonly fs: FileSystem;
@@ -364,9 +458,10 @@ interface CreateContextParts {
364
458
  readonly config?: RepositoryConfig;
365
459
  readonly logger?: Logger;
366
460
  readonly signal?: AbortSignal;
461
+ readonly hooks?: HookRunner;
367
462
  }
368
463
  /** Assemble a frozen Context from its constituent ports + layout. */
369
464
  declare function createContext(parts: CreateContextParts): Context;
370
465
 
371
- export { ObjectId as O, RefName as R, FilePath as d, createContext as j, noopLogger as n, wrapLoggerSanitizer as w };
372
- 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 };
@@ -97,6 +97,11 @@ interface FileSystem {
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. */
@@ -206,6 +211,66 @@ 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
@@ -260,6 +325,28 @@ 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
+ }
340
+ /**
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
+
263
350
  /**
264
351
  * Repository physical layout — where the working tree and.git directory live.
265
352
  * Renamed in from the previous `RepositoryConfig` (port-tier) to free that
@@ -350,6 +437,13 @@ interface Context {
350
437
  readonly logger?: Logger;
351
438
  /** Optional abort signal for cancelling long-running operations. */
352
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;
353
447
  }
354
448
  interface CreateContextParts {
355
449
  readonly fs: FileSystem;
@@ -364,9 +458,10 @@ interface CreateContextParts {
364
458
  readonly config?: RepositoryConfig;
365
459
  readonly logger?: Logger;
366
460
  readonly signal?: AbortSignal;
461
+ readonly hooks?: HookRunner;
367
462
  }
368
463
  /** Assemble a frozen Context from its constituent ports + layout. */
369
464
  declare function createContext(parts: CreateContextParts): Context;
370
465
 
371
- export { ObjectId as O, RefName as R, FilePath as d, createContext as j, noopLogger as n, wrapLoggerSanitizer as w };
372
- 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 };