@scolladon/tsgit 0.9.0 → 1.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 (143) hide show
  1. package/README.md +116 -1
  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-BBF8uw-f.cjs → browser-http-transport-DcG05jw3.cjs} +2 -2
  9. package/dist/cjs/chunks/{browser-http-transport-BBF8uw-f.cjs.map → browser-http-transport-DcG05jw3.cjs.map} +1 -1
  10. package/dist/cjs/chunks/context-BcoAzPuU.cjs.map +1 -1
  11. package/dist/cjs/chunks/error-CqLvhejR.cjs +2 -0
  12. package/dist/cjs/chunks/error-CqLvhejR.cjs.map +1 -0
  13. package/dist/cjs/chunks/index-BcxdLkNe.cjs +2 -0
  14. package/dist/cjs/chunks/index-BcxdLkNe.cjs.map +1 -0
  15. package/dist/cjs/chunks/index-D5Nd-Mks.cjs +2 -0
  16. package/dist/cjs/chunks/index-D5Nd-Mks.cjs.map +1 -0
  17. package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs → logger-C8Z5BfFF.cjs} +2 -2
  18. package/dist/cjs/chunks/{logger-Cz9r6yt5.cjs.map → logger-C8Z5BfFF.cjs.map} +1 -1
  19. package/dist/cjs/chunks/memory-http-transport-Pjyme5KN.cjs +2 -0
  20. package/dist/cjs/chunks/memory-http-transport-Pjyme5KN.cjs.map +1 -0
  21. package/dist/cjs/chunks/node-http-transport-UkW5eEm3.cjs +2 -0
  22. package/dist/cjs/chunks/node-http-transport-UkW5eEm3.cjs.map +1 -0
  23. package/dist/cjs/chunks/{progress-CK7CT9vU.cjs → progress-CntEbiuo.cjs} +2 -2
  24. package/dist/cjs/chunks/{progress-CK7CT9vU.cjs.map → progress-CntEbiuo.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-B_jx2AKW.cjs +2 -0
  28. package/dist/cjs/chunks/repository-B_jx2AKW.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-CRPPmib5.js → browser-http-transport-COFgnEyq.js} +2 -2
  49. package/dist/esm/chunks/{browser-http-transport-CRPPmib5.js.map → browser-http-transport-COFgnEyq.js.map} +1 -1
  50. package/dist/esm/chunks/context-CumKOV7K.js.map +1 -1
  51. package/dist/esm/chunks/error-BN9rdQ33.js +2 -0
  52. package/dist/esm/chunks/error-BN9rdQ33.js.map +1 -0
  53. package/dist/esm/chunks/index-BdV37p4e.js +2 -0
  54. package/dist/esm/chunks/index-BdV37p4e.js.map +1 -0
  55. package/dist/esm/chunks/index-BkRJ9-Im.js +2 -0
  56. package/dist/esm/chunks/index-BkRJ9-Im.js.map +1 -0
  57. package/dist/esm/chunks/{logger-Cg7fUh8D.js → logger-BLZbLzva.js} +2 -2
  58. package/dist/esm/chunks/{logger-Cg7fUh8D.js.map → logger-BLZbLzva.js.map} +1 -1
  59. package/dist/esm/chunks/memory-http-transport-DRYdYgiE.js +2 -0
  60. package/dist/esm/chunks/memory-http-transport-DRYdYgiE.js.map +1 -0
  61. package/dist/esm/chunks/node-http-transport-Bp5cFZCt.js +2 -0
  62. package/dist/esm/chunks/node-http-transport-Bp5cFZCt.js.map +1 -0
  63. package/dist/esm/chunks/progress-DJU_f66N.js +2 -0
  64. package/dist/esm/chunks/{progress-OxUHmDV4.js.map → progress-DJU_f66N.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-DiagDiT_.js +2 -0
  68. package/dist/esm/chunks/repository-DiagDiT_.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 -2
  83. package/dist/types/adapters/browser/index.d.ts +2 -2
  84. package/dist/types/adapters/memory/index.d.cts +4 -2
  85. package/dist/types/adapters/memory/index.d.ts +4 -2
  86. package/dist/types/adapters/node/index.d.cts +117 -3
  87. package/dist/types/adapters/node/index.d.ts +117 -3
  88. package/dist/types/chunks/{context-Ku1aP8Ie.d.cts → context-D84z1i5F.d.cts} +39 -21
  89. package/dist/types/chunks/{context-C6df52Qs.d.ts → context-o5TPfMB2.d.ts} +39 -21
  90. package/dist/types/chunks/{diff-change-BwO75AgS.d.cts → diff-change-Bm1zvVsC.d.cts} +1 -1
  91. package/dist/types/chunks/{diff-change-CUWN3OSK.d.ts → diff-change-alGRzD_j.d.ts} +1 -1
  92. package/dist/types/chunks/{http-transport--_NdQOiw.d.cts → http-transport-DirKfK2S.d.cts} +1 -1
  93. package/dist/types/chunks/{http-transport--_NdQOiw.d.ts → http-transport-DirKfK2S.d.ts} +1 -1
  94. package/dist/types/chunks/{repository-Cv4Y0T9t.d.cts → repository-23evW2h-.d.cts} +5 -4
  95. package/dist/types/chunks/{repository-BBKJnr8a.d.ts → repository-BT7Xq1kJ.d.ts} +5 -4
  96. package/dist/types/chunks/write-tree-DNjhjS3t.d.ts +282 -0
  97. package/dist/types/chunks/write-tree-DVp0RJ_r.d.cts +282 -0
  98. package/dist/types/commands/index.d.cts +82 -36
  99. package/dist/types/commands/index.d.ts +82 -36
  100. package/dist/types/index.browser.d.cts +5 -5
  101. package/dist/types/index.browser.d.ts +5 -5
  102. package/dist/types/index.d.cts +5 -5
  103. package/dist/types/index.d.ts +5 -5
  104. package/dist/types/index.default.d.cts +5 -5
  105. package/dist/types/index.default.d.ts +5 -5
  106. package/dist/types/index.node.d.cts +5 -5
  107. package/dist/types/index.node.d.ts +5 -5
  108. package/dist/types/operators/index.d.cts +17 -1
  109. package/dist/types/operators/index.d.ts +17 -1
  110. package/dist/types/primitives/index.d.cts +223 -186
  111. package/dist/types/primitives/index.d.ts +223 -186
  112. package/dist/types/transport/index.d.cts +1 -1
  113. package/dist/types/transport/index.d.ts +1 -1
  114. package/package.json +70 -23
  115. package/dist/cjs/chunks/error-DL4SHCBJ.cjs +0 -2
  116. package/dist/cjs/chunks/error-DL4SHCBJ.cjs.map +0 -1
  117. package/dist/cjs/chunks/error-DN8Vnwr4.cjs +0 -2
  118. package/dist/cjs/chunks/error-DN8Vnwr4.cjs.map +0 -1
  119. package/dist/cjs/chunks/index-iUd-bwwm.cjs +0 -2
  120. package/dist/cjs/chunks/index-iUd-bwwm.cjs.map +0 -1
  121. package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs +0 -2
  122. package/dist/cjs/chunks/memory-http-transport-DGll7Af4.cjs.map +0 -1
  123. package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs +0 -2
  124. package/dist/cjs/chunks/merge-base-DlGWnkxP.cjs.map +0 -1
  125. package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs +0 -2
  126. package/dist/cjs/chunks/node-http-transport-CuOgJlws.cjs.map +0 -1
  127. package/dist/cjs/chunks/repository-Cbzk-Qwz.cjs +0 -2
  128. package/dist/cjs/chunks/repository-Cbzk-Qwz.cjs.map +0 -1
  129. package/dist/esm/chunks/error-CAlAXhN3.js +0 -2
  130. package/dist/esm/chunks/error-CAlAXhN3.js.map +0 -1
  131. package/dist/esm/chunks/error-DVZkS_ub.js +0 -2
  132. package/dist/esm/chunks/error-DVZkS_ub.js.map +0 -1
  133. package/dist/esm/chunks/index-gUdap5AF.js +0 -2
  134. package/dist/esm/chunks/index-gUdap5AF.js.map +0 -1
  135. package/dist/esm/chunks/memory-http-transport-Cv1sbkCX.js +0 -2
  136. package/dist/esm/chunks/memory-http-transport-Cv1sbkCX.js.map +0 -1
  137. package/dist/esm/chunks/merge-base-opORz-S1.js +0 -2
  138. package/dist/esm/chunks/merge-base-opORz-S1.js.map +0 -1
  139. package/dist/esm/chunks/node-http-transport-CuXVJf0s.js +0 -2
  140. package/dist/esm/chunks/node-http-transport-CuXVJf0s.js.map +0 -1
  141. package/dist/esm/chunks/progress-OxUHmDV4.js +0 -2
  142. package/dist/esm/chunks/repository-BaEhU6zt.js +0 -2
  143. package/dist/esm/chunks/repository-BaEhU6zt.js.map +0 -1
@@ -1,217 +1,254 @@
1
- import { O as ObjectId, b as FilePath, a as Context, j as RefName } from '../chunks/context-Ku1aP8Ie.cjs';
2
- import { A as AuthorIdentity, F as FileMode, T as TreeDiff } from '../chunks/diff-change-BwO75AgS.cjs';
3
- import '../chunks/http-transport--_NdQOiw.cjs';
4
-
5
- interface Blob {
6
- readonly type: 'blob';
7
- readonly id: ObjectId;
8
- readonly content: Uint8Array;
9
- }
10
-
11
- interface ExtraHeader {
12
- readonly key: string;
13
- readonly value: string;
14
- }
15
- interface CommitData {
16
- readonly tree: ObjectId;
17
- readonly parents: ReadonlyArray<ObjectId>;
18
- readonly author: AuthorIdentity;
19
- readonly committer: AuthorIdentity;
20
- readonly message: string;
21
- readonly gpgSignature?: string;
22
- readonly extraHeaders: ReadonlyArray<ExtraHeader>;
23
- }
24
- interface Commit {
25
- readonly type: 'commit';
26
- readonly id: ObjectId;
27
- readonly data: CommitData;
28
- }
29
-
30
- type ObjectType = 'blob' | 'tree' | 'commit' | 'tag';
31
-
32
- interface TagData {
33
- readonly object: ObjectId;
34
- readonly objectType: ObjectType;
35
- readonly tagName: string;
36
- readonly tagger?: AuthorIdentity;
37
- readonly message: string;
38
- readonly gpgSignature?: string;
39
- readonly extraHeaders: ReadonlyArray<ExtraHeader>;
40
- }
41
- interface Tag {
42
- readonly type: 'tag';
43
- readonly id: ObjectId;
44
- readonly data: TagData;
45
- }
46
-
47
- interface TreeEntry {
48
- readonly mode: FileMode;
49
- readonly name: string;
50
- readonly id: ObjectId;
51
- }
52
- interface Tree {
53
- readonly type: 'tree';
54
- readonly id: ObjectId;
55
- readonly entries: ReadonlyArray<TreeEntry>;
56
- }
57
-
58
- type GitObject = Blob | Tree | Commit | Tag;
59
-
60
- interface IndexEntryFlags {
61
- readonly assumeValid: boolean;
62
- readonly extended: boolean;
63
- readonly stage: 0 | 1 | 2 | 3;
64
- }
65
- interface IndexEntry {
66
- readonly ctimeSeconds: number;
67
- readonly ctimeNanoseconds: number;
68
- readonly mtimeSeconds: number;
69
- readonly mtimeNanoseconds: number;
70
- readonly dev: number;
71
- readonly ino: number;
72
- readonly mode: FileMode;
73
- readonly uid: number;
74
- readonly gid: number;
75
- readonly fileSize: number;
76
- readonly id: ObjectId;
77
- readonly flags: IndexEntryFlags;
78
- readonly path: FilePath;
79
- }
80
- interface IndexExtension {
81
- readonly signature: string;
82
- readonly data: Uint8Array;
83
- }
84
- interface GitIndex {
85
- readonly version: 2;
86
- readonly entries: ReadonlyArray<IndexEntry>;
87
- readonly extensions: ReadonlyArray<IndexExtension>;
88
- }
89
-
90
- interface RenameDetectOptions {
91
- readonly limit?: number;
92
- readonly maxSameIdDeletes?: number;
93
- }
1
+ import { G as GitIndex, I as IndexEntry } from '../chunks/write-tree-DVp0RJ_r.cjs';
2
+ export { C as CreateCommitInput, D as DiffTreesInput, a as DiffTreesOptions, M as MAX_COMMIT_MESSAGE_BYTES, b as MAX_GITIGNORE_BYTES, c as MAX_HAVES, d as MAX_INDEX_BYTES, e as MAX_PEEL_DEPTH, f as MAX_PUSH_OBJECTS, g as MAX_SYMBOLIC_REF_DEPTH, h as MAX_WALK_QUEUE_SIZE, i as MAX_WALK_SEEDS, j as MAX_WORKING_TREE_BLOB_BYTES, R as ReadObjectOptions, k as ResolveRefOptions, U as UpdateRefOptions, W as WalkCommitsOptions, l as WalkIgnorePredicate, m as WalkTreeEntry, n as WalkTreeOptions, o as WalkWorkingTreeEntry, p as WalkWorkingTreeOptions, q as createCommit, r as diffTrees, s as getRepoRoot, t as mergeBase, u as readBlob, v as readIndex, w as readObject, x as readTree, y as resolveRef, z as updateRef, A as walkCommits, B as walkTree, E as walkWorkingTree, F as writeObject, H as writeSymbolicRef, J as writeTree } from '../chunks/write-tree-DVp0RJ_r.cjs';
3
+ import { d as FilePath, O as ObjectId, b as Context } from '../chunks/context-D84z1i5F.cjs';
4
+ import { F as FileMode } from '../chunks/diff-change-Bm1zvVsC.cjs';
5
+ export { T as TreeDiff } from '../chunks/diff-change-Bm1zvVsC.cjs';
6
+ import { b as HttpTransport } from '../chunks/http-transport-DirKfK2S.cjs';
94
7
 
95
8
  /**
96
- * Phase 7 primitive option shapes, walker value types, and shared constants.
97
- * Defined in one location to avoid circular imports between primitive modules.
9
+ * Pure helper that diffs a current GitIndex against a target tree's flat
10
+ * entry list and emits an ordered ChangesetEntry list. No FS, no ctx; the
11
+ * impure write side lives in `apply-changeset.ts`.
12
+ *
13
+ * Stage-0 entries only — unmerged stages are invisible to checkout (Phase
14
+ * 13.1 design step 5).
98
15
  */
99
16
 
100
- /** Max symbolic-ref dereferences resolveRef will follow. */
101
- declare const MAX_SYMBOLIC_REF_DEPTH = 5;
102
- /** Max tag-peel hops resolveRef / readTree will follow when peeling. */
103
- declare const MAX_PEEL_DEPTH = 5;
104
- /** Max seeds walkCommits.from can contain. */
105
- declare const MAX_WALK_SEEDS = 1024;
106
- /** Hard cap on walkCommits' pending queue size to prevent unbounded heap growth. */
107
- declare const MAX_WALK_QUEUE_SIZE: number;
108
- /** Max .git/index file size readIndex will accept. */
109
- declare const MAX_INDEX_BYTES: number;
110
- /** Max commit message byte length createCommit will accept. */
111
- declare const MAX_COMMIT_MESSAGE_BYTES: number;
112
- interface ReadObjectOptions {
113
- readonly verifyHash?: boolean;
114
- }
115
- interface ResolveRefOptions {
116
- readonly peel?: boolean;
117
- readonly maxSymbolicDepth?: number;
118
- readonly maxPeelDepth?: number;
17
+ interface ChangesetEntry {
18
+ readonly kind: 'add' | 'update' | 'delete' | 'noop';
19
+ readonly path: FilePath;
20
+ readonly mode: FileMode;
21
+ readonly id: ObjectId | undefined;
22
+ readonly previousId: ObjectId | undefined;
23
+ readonly previousMode: FileMode | undefined;
119
24
  }
120
- interface UpdateRefOptions {
121
- readonly expected?: ObjectId | 'absent';
122
- readonly delete?: boolean;
25
+ interface ChangesetStats {
26
+ readonly add: number;
27
+ readonly update: number;
28
+ readonly delete: number;
29
+ readonly noop: number;
123
30
  }
124
- interface WalkCommitsOptions {
125
- readonly from: ReadonlyArray<ObjectId>;
126
- readonly until?: ReadonlyArray<ObjectId>;
127
- readonly order?: 'topo' | 'first-parent';
128
- readonly ignoreMissing?: boolean;
129
- readonly verifyHash?: boolean;
31
+ interface Changeset {
32
+ readonly entries: ReadonlyArray<ChangesetEntry>;
33
+ readonly stats: ChangesetStats;
130
34
  }
131
- interface WalkTreeEntry {
35
+ interface TargetEntry {
132
36
  readonly path: FilePath;
133
37
  readonly id: ObjectId;
134
38
  readonly mode: FileMode;
135
39
  }
136
- interface WalkTreeOptions {
137
- readonly recursive?: boolean;
138
- readonly maxDepth?: number;
139
- readonly maxEntries?: number;
140
- }
141
- interface CreateCommitInput {
142
- readonly tree: ObjectId;
143
- readonly parents: ReadonlyArray<ObjectId>;
144
- readonly author: AuthorIdentity;
145
- readonly committer: AuthorIdentity;
146
- readonly message: string;
147
- readonly gpgSignature?: string;
148
- readonly extraHeaders?: ReadonlyArray<ExtraHeader>;
40
+ declare const computeChangeset: (currentIndex: GitIndex, targetTree: ReadonlyArray<TargetEntry>) => Changeset;
41
+
42
+ interface ApplyChangesetOpts {
43
+ readonly changeset: Changeset;
44
+ readonly force: boolean;
45
+ readonly workdir: string;
149
46
  }
150
- type DiffTreesInput = Tree | ObjectId | undefined;
151
- interface DiffTreesOptions {
152
- readonly detectRenames?: boolean;
153
- readonly renameOptions?: RenameDetectOptions;
47
+ interface ApplyChangesetResult {
48
+ readonly writtenEntries: ReadonlyArray<IndexEntry>;
49
+ readonly written: number;
50
+ readonly deleted: number;
154
51
  }
52
+ declare const applyChangeset: (ctx: Context, opts: ApplyChangesetOpts) => Promise<ApplyChangesetResult>;
155
53
 
156
- declare function createCommit(ctx: Context, input: CreateCommitInput): Promise<ObjectId>;
54
+ /**
55
+ * Project a target tree onto a fresh stage-0 IndexEntry list, preserving
56
+ * stat-cache fields from the prior index where the path's `id` AND `mode`
57
+ * both match (the "stat-cache donor" strategy).
58
+ *
59
+ * Pure with respect to the working tree: this primitive never calls
60
+ * `fs.lstat`, `fs.read`, or any working-tree-side API. It only reads git
61
+ * objects via `walkTree` → `readObject` for nested trees.
62
+ *
63
+ * Used by `reset --mixed` to rebuild the index from a target
64
+ * commit's tree. Will be re-used by `reset --hard` composed
65
+ * with `materializeTree` to also write the working tree.
66
+ *
67
+ * ## Preconditions
68
+ *
69
+ * `currentIndex` MUST be read under the same `acquireIndexLock` that will
70
+ * later commit the result. Reading the index BEFORE the lock is acquired
71
+ * lets a concurrent writer mutate it between the donor-map build and the
72
+ * commit, producing a result that reflects neither the pre-reset nor the
73
+ * post-reset state. See `reset.ts:rebuildIndexFromCommit` for the
74
+ * canonical pattern: acquire → read → build → commit → release-in-finally.
75
+ */
157
76
 
158
- declare function diffTrees(ctx: Context, a: DiffTreesInput, b: DiffTreesInput, options?: DiffTreesOptions): Promise<TreeDiff>;
77
+ interface BuildIndexFromTreeOpts {
78
+ readonly targetTree: ObjectId;
79
+ readonly currentIndex: GitIndex;
80
+ }
81
+ declare const buildIndexFromTree: (ctx: Context, opts: BuildIndexFromTreeOpts) => Promise<ReadonlyArray<IndexEntry>>;
82
+
83
+ interface BuildPackInput {
84
+ readonly oids: ReadonlyArray<ObjectId>;
85
+ }
86
+ interface BuildPackResult {
87
+ readonly bytes: Uint8Array;
88
+ /** Hex SHA of the pack body, also the trailer (last 20 bytes). */
89
+ readonly sha: string;
90
+ readonly objectCount: number;
91
+ }
92
+ declare const buildPack: (ctx: Context, input: BuildPackInput) => Promise<BuildPackResult>;
93
+
94
+ interface EnumeratePushObjectsInput {
95
+ /**
96
+ * Object ids the caller wants on the remote. Each MUST resolve to a
97
+ * commit or an annotated tag (tags are unwrapped to commits before the
98
+ * commit walk).
99
+ */
100
+ readonly wants: ReadonlyArray<ObjectId>;
101
+ /** Object ids the remote already has (server's advertised ref tips). */
102
+ readonly haves: ReadonlyArray<ObjectId>;
103
+ /** Hard cap on objects emitted. Defaults to MAX_PUSH_OBJECTS. */
104
+ readonly maxObjects?: number;
105
+ }
106
+ declare function enumeratePushObjects(ctx: Context, input: EnumeratePushObjectsInput): AsyncIterable<ObjectId>;
107
+
108
+ interface FetchPackInput {
109
+ /** Advertised refs the caller wants. MUST be non-empty (server-side requirement). */
110
+ readonly wants: ReadonlyArray<ObjectId>;
111
+ /** Objects the caller already has (negotiation). Empty for clone, populated for fetch. */
112
+ readonly haves: ReadonlyArray<ObjectId>;
113
+ /** Negotiated capabilities (intersection of advertised + supported). */
114
+ readonly capabilities: ReadonlyArray<string>;
115
+ /** Base remote URL (the same URL passed to clone). */
116
+ readonly url: string;
117
+ /** Progress op label — clone uses 'clone:write-objects', fetch uses 'fetch:write-objects'. */
118
+ readonly progressOp: string;
119
+ /**
120
+ * Shallow clone depth. When set, sends `deepen N` and consumes the
121
+ * accompanying `shallow <oid>` / `unshallow <oid>` response block.
122
+ *
123
+ */
124
+ readonly depth?: number;
125
+ }
126
+ interface FetchPackResult {
127
+ readonly packPath: string;
128
+ readonly idxPath: string;
129
+ readonly objectCount: number;
130
+ /** Hex-encoded SHA of the pack trailer; also the on-disk filename stem. */
131
+ readonly packSha: string;
132
+ /** Commits the server advertised as new shallow boundaries (empty when depth is unset). */
133
+ readonly shallow: ReadonlyArray<ObjectId>;
134
+ /** Commits the server advertised as no-longer-shallow (empty when depth is unset). */
135
+ readonly unshallow: ReadonlyArray<ObjectId>;
136
+ }
137
+ declare const fetchPack: (ctx: Context, transport: HttpTransport, input: FetchPackInput) => Promise<FetchPackResult>;
159
138
 
160
139
  /**
161
- * Compute a merge base the first commit reachable from BOTH `a` and `b`.
140
+ * Compose `walkTree computeChangeset applyChangeset` to update the
141
+ * working tree to a target tree's contents.
142
+ *
143
+ * - Branch switch mode: `paths === undefined` — diff the entire current
144
+ * index against the entire target tree.
145
+ * - Path-restore mode: `paths !== undefined` — restrict both sides of
146
+ * the diff to those paths.
162
147
  *
163
- * Algorithm: bidirectional BFS with two visited sets. After each layer
164
- * advance, check the intersection. When non-empty, return the
165
- * lexicographically smallest oid (deterministic tie-breaker).
148
+ * Returns the new IndexEntry list for the caller to commit, plus
149
+ * written/deleted counts. The primitive does NOT commit the index — the
150
+ * caller decides.
166
151
  *
167
- * Returns `undefined` for unrelated histories. Documented limitation: cherry-picks
168
- * and criss-cross merges may yield non-optimal bases — `recursive`-strategy
169
- * multi-base resolution is v2.
152
+ * ## Stat-source contract for `newIndexEntries` (load-bearing for)
153
+ *
154
+ * - **Paths that were written/added** (`add` or `update` changeset entries):
155
+ * the IndexEntry carries **post-write `lstat`-derived stat fields**
156
+ * (ctime/mtime/dev/ino/uid/gid/fileSize). These reflect the file we just
157
+ * wrote, so the next `status` runs the fast `isStatClean` path.
158
+ * - **Paths whose changeset classification was `noop`** (skipped — index
159
+ * already matched target by `id + mode`): the IndexEntry is the caller's
160
+ * `currentIndex` entry verbatim. Donor stats survive across the call.
161
+ * - `reset --hard` therefore MUST set `forceRewriteAll: true` so every noop
162
+ * upgrades to update and the post-write stats land in the output. Without
163
+ * that, a locally-modified working-tree file that the index still records
164
+ * as clean would survive the reset, AND the donor stats would be stale
165
+ * relative to the actual disk state.
170
166
  */
171
- declare const mergeBase: (ctx: Context, a: ObjectId, b: ObjectId) => Promise<ObjectId | undefined>;
167
+
168
+ interface MaterializeTreeOpts {
169
+ readonly targetTree: ObjectId;
170
+ readonly currentIndex: GitIndex;
171
+ readonly force?: boolean;
172
+ readonly paths?: ReadonlySet<FilePath>;
173
+ /**
174
+ * When true, every target-tree path is written to the working tree
175
+ * unconditionally — even paths the index→target diff classified as `noop`
176
+ * (same `id` AND `mode`). Required by `reset --hard`, where the working
177
+ * tree may diverge from the index (uncommitted local modifications); the
178
+ * standard index→target diff cannot see that drift, so noops would skip
179
+ * paths the caller wants overwritten. Default `false` keeps the Phase
180
+ * 13.1 checkout behaviour: clean files are never spuriously rewritten.
181
+ */
182
+ readonly forceRewriteAll?: boolean;
183
+ }
184
+ interface MaterializeTreeResult {
185
+ readonly newIndexEntries: ReadonlyArray<IndexEntry>;
186
+ readonly written: number;
187
+ readonly deleted: number;
188
+ }
189
+ declare const materializeTree: (ctx: Context, opts: MaterializeTreeOpts) => Promise<MaterializeTreeResult>;
172
190
 
173
191
  /**
174
- * Pure path helpers composing `ctx.layout.gitDir` with known sub-paths.
175
- * No I/O. No port access. Primitive step 3.
192
+ * Read `.git/shallow`. Returns an empty set when the file does not exist or
193
+ * contains no oids. Malformed lines are tolerated (skipped) — canonical
194
+ * git behaves the same; a corrupted shallow file should not block a fetch.
176
195
  */
177
-
196
+ declare const readShallow: (ctx: Context) => Promise<ReadonlySet<ObjectId>>;
197
+ interface ShallowUpdate {
198
+ readonly shallow: ReadonlyArray<ObjectId>;
199
+ readonly unshallow: ReadonlyArray<ObjectId>;
200
+ }
178
201
  /**
179
- * Repository working-tree root. Returns the workDir from the current context;
180
- * facade-tier code (Phase 10) is responsible for discovery / realpath pinning
181
- * at construction time. Primitives consume the already-resolved path.
202
+ * Apply a set of shallow / unshallow updates to `.git/shallow`. Writes
203
+ * atomically via lock-rename; deletes the file when the resulting set is
204
+ * empty.
182
205
  */
183
- declare const getRepoRoot: (ctx: Context) => FilePath;
184
-
185
- declare function readBlob(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<Blob>;
186
-
187
- declare function readIndex(ctx: Context): Promise<GitIndex>;
188
-
189
- declare function readObject(ctx: Context, id: ObjectId, options?: ReadObjectOptions): Promise<GitObject>;
190
-
191
- declare function readTree(ctx: Context, ref: RefName | ObjectId): Promise<Tree>;
192
-
193
- declare function resolveRef(ctx: Context, name: RefName | 'HEAD', options?: ResolveRefOptions): Promise<ObjectId>;
194
-
195
- declare function updateRef(ctx: Context, name: RefName, newId: ObjectId, options?: UpdateRefOptions): Promise<void>;
196
-
197
- declare function walkCommits(ctx: Context, options: WalkCommitsOptions): AsyncIterable<Commit>;
198
-
199
- declare function walkTree(ctx: Context, treeIdOrObject: ObjectId | Tree, options?: WalkTreeOptions): AsyncIterable<WalkTreeEntry>;
200
-
201
- declare function writeObject(ctx: Context, object: GitObject): Promise<ObjectId>;
206
+ declare const updateShallow: (ctx: Context, updates: ShallowUpdate) => Promise<void>;
202
207
 
203
208
  /**
204
- * Write a symbolic ref atomically. Used for HEAD updates that point at a
205
- * branch, branch renames affecting the current HEAD, and `clone`/`init`
206
- * to set the initial HEAD.
209
+ * Synthesise a nested `Tree` object from a flat `GitIndex` and return the
210
+ * root tree's `ObjectId`. Sub-trees are written to the object store as a
211
+ * side-effect of the recursive descent — only stage-0 entries contribute.
212
+ *
213
+ * Used by `checkout({ paths, source: 'index' })` to restore
214
+ * the working tree from staged content even when the index has diverged
215
+ * from HEAD via `add` / `rm`. The previous placeholder fell back to
216
+ * HEAD's tree, which silently lost the divergence.
217
+ *
218
+ * The synthesis is the inverse of `buildIndexFromTree`:
219
+ * "tree → index" and "index → tree" form a round-trip identity for any
220
+ * stage-0-only index.
221
+ *
222
+ * Pure with respect to the working tree — never calls `fs.lstat`,
223
+ * `fs.read`, or any working-tree-side API. Only writes git objects via
224
+ * the existing `writeTree` primitive.
207
225
  *
208
- * Single-level only in v1: target MUST be a direct ref name (no chained
209
- * symrefs). Validation runs through `validateRefName` for both `name` and
210
- * `target` invalid inputs throw INVALID_REF before any I/O.
226
+ * ## Safety
227
+ *
228
+ * - **Path validation**:.7 hoisted segment-level validation into
229
+ * `parseIndex` (`src/domain/git-index/path-validator.ts`). Every
230
+ * `IndexEntry` reaching this primitive THROUGH THE CANONICAL PARSER
231
+ * carries a `FilePath` value already free of `..`, `.`, empty segments,
232
+ * and leading-slash absolute paths. However, the primitive is also
233
+ * reachable from callers that construct `IndexEntry` records outside
234
+ * the parser (test fixtures, in-memory adapters, future synthesisers).
235
+ * Defence-in-depth: every entry is re-validated here so the primitive
236
+ * stays safe even when the parser-trusted path is bypassed.
237
+ * - **Depth cap**: synthesis bounds recursion at `MAX_TREE_DEPTH` (4096,
238
+ * matching git's canonical limit). The cap is enforced at the input
239
+ * boundary by counting slashes — by the time recursion would catch a
240
+ * pathological depth, the JS engine has already exhausted its call
241
+ * stack. Path validation does NOT subsume this check: a path can be
242
+ * safe segment-by-segment (no `..`/`.`/empty) and still be 10 000
243
+ * levels deep.
211
244
  */
212
- declare const writeSymbolicRef: (ctx: Context, name: RefName, target: RefName) => Promise<void>;
213
245
 
214
- declare function writeTree(ctx: Context, entries: ReadonlyArray<TreeEntry>): Promise<ObjectId>;
246
+ /**
247
+ * Public entry: pass the `entries` array directly (typically
248
+ * `index.entries`, but callers holding a filtered list may supply it
249
+ * without wrapping in a fake `GitIndex`).
250
+ */
251
+ declare const synthesizeTreeFromIndex: (ctx: Context, entries: ReadonlyArray<IndexEntry>) => Promise<ObjectId>;
215
252
 
216
- export { MAX_COMMIT_MESSAGE_BYTES, MAX_INDEX_BYTES, MAX_PEEL_DEPTH, MAX_SYMBOLIC_REF_DEPTH, MAX_WALK_QUEUE_SIZE, MAX_WALK_SEEDS, TreeDiff, createCommit, diffTrees, getRepoRoot, mergeBase, readBlob, readIndex, readObject, readTree, resolveRef, updateRef, walkCommits, walkTree, writeObject, writeSymbolicRef, writeTree };
217
- export type { CreateCommitInput, DiffTreesInput, DiffTreesOptions, ReadObjectOptions, ResolveRefOptions, UpdateRefOptions, WalkCommitsOptions, WalkTreeEntry, WalkTreeOptions };
253
+ export { applyChangeset, buildIndexFromTree, buildPack, computeChangeset, enumeratePushObjects, fetchPack, materializeTree, readShallow, synthesizeTreeFromIndex, updateShallow };
254
+ export type { ApplyChangesetOpts, ApplyChangesetResult, BuildIndexFromTreeOpts, BuildPackInput, BuildPackResult, Changeset, ChangesetEntry, ChangesetStats, EnumeratePushObjectsInput, FetchPackInput, FetchPackResult, MaterializeTreeOpts, MaterializeTreeResult };