gitx.do 0.0.1

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 (167) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +156 -0
  3. package/dist/durable-object/object-store.d.ts +113 -0
  4. package/dist/durable-object/object-store.d.ts.map +1 -0
  5. package/dist/durable-object/object-store.js +387 -0
  6. package/dist/durable-object/object-store.js.map +1 -0
  7. package/dist/durable-object/schema.d.ts +17 -0
  8. package/dist/durable-object/schema.d.ts.map +1 -0
  9. package/dist/durable-object/schema.js +43 -0
  10. package/dist/durable-object/schema.js.map +1 -0
  11. package/dist/durable-object/wal.d.ts +111 -0
  12. package/dist/durable-object/wal.d.ts.map +1 -0
  13. package/dist/durable-object/wal.js +200 -0
  14. package/dist/durable-object/wal.js.map +1 -0
  15. package/dist/index.d.ts +24 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +101 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/mcp/adapter.d.ts +231 -0
  20. package/dist/mcp/adapter.d.ts.map +1 -0
  21. package/dist/mcp/adapter.js +502 -0
  22. package/dist/mcp/adapter.js.map +1 -0
  23. package/dist/mcp/sandbox.d.ts +261 -0
  24. package/dist/mcp/sandbox.d.ts.map +1 -0
  25. package/dist/mcp/sandbox.js +983 -0
  26. package/dist/mcp/sandbox.js.map +1 -0
  27. package/dist/mcp/sdk-adapter.d.ts +413 -0
  28. package/dist/mcp/sdk-adapter.d.ts.map +1 -0
  29. package/dist/mcp/sdk-adapter.js +672 -0
  30. package/dist/mcp/sdk-adapter.js.map +1 -0
  31. package/dist/mcp/tools.d.ts +133 -0
  32. package/dist/mcp/tools.d.ts.map +1 -0
  33. package/dist/mcp/tools.js +1604 -0
  34. package/dist/mcp/tools.js.map +1 -0
  35. package/dist/ops/blame.d.ts +148 -0
  36. package/dist/ops/blame.d.ts.map +1 -0
  37. package/dist/ops/blame.js +754 -0
  38. package/dist/ops/blame.js.map +1 -0
  39. package/dist/ops/branch.d.ts +215 -0
  40. package/dist/ops/branch.d.ts.map +1 -0
  41. package/dist/ops/branch.js +608 -0
  42. package/dist/ops/branch.js.map +1 -0
  43. package/dist/ops/commit-traversal.d.ts +209 -0
  44. package/dist/ops/commit-traversal.d.ts.map +1 -0
  45. package/dist/ops/commit-traversal.js +755 -0
  46. package/dist/ops/commit-traversal.js.map +1 -0
  47. package/dist/ops/commit.d.ts +221 -0
  48. package/dist/ops/commit.d.ts.map +1 -0
  49. package/dist/ops/commit.js +606 -0
  50. package/dist/ops/commit.js.map +1 -0
  51. package/dist/ops/merge-base.d.ts +223 -0
  52. package/dist/ops/merge-base.d.ts.map +1 -0
  53. package/dist/ops/merge-base.js +581 -0
  54. package/dist/ops/merge-base.js.map +1 -0
  55. package/dist/ops/merge.d.ts +385 -0
  56. package/dist/ops/merge.d.ts.map +1 -0
  57. package/dist/ops/merge.js +1203 -0
  58. package/dist/ops/merge.js.map +1 -0
  59. package/dist/ops/tag.d.ts +182 -0
  60. package/dist/ops/tag.d.ts.map +1 -0
  61. package/dist/ops/tag.js +608 -0
  62. package/dist/ops/tag.js.map +1 -0
  63. package/dist/ops/tree-builder.d.ts +82 -0
  64. package/dist/ops/tree-builder.d.ts.map +1 -0
  65. package/dist/ops/tree-builder.js +246 -0
  66. package/dist/ops/tree-builder.js.map +1 -0
  67. package/dist/ops/tree-diff.d.ts +243 -0
  68. package/dist/ops/tree-diff.d.ts.map +1 -0
  69. package/dist/ops/tree-diff.js +657 -0
  70. package/dist/ops/tree-diff.js.map +1 -0
  71. package/dist/pack/delta.d.ts +68 -0
  72. package/dist/pack/delta.d.ts.map +1 -0
  73. package/dist/pack/delta.js +343 -0
  74. package/dist/pack/delta.js.map +1 -0
  75. package/dist/pack/format.d.ts +84 -0
  76. package/dist/pack/format.d.ts.map +1 -0
  77. package/dist/pack/format.js +261 -0
  78. package/dist/pack/format.js.map +1 -0
  79. package/dist/pack/full-generation.d.ts +327 -0
  80. package/dist/pack/full-generation.d.ts.map +1 -0
  81. package/dist/pack/full-generation.js +1159 -0
  82. package/dist/pack/full-generation.js.map +1 -0
  83. package/dist/pack/generation.d.ts +118 -0
  84. package/dist/pack/generation.d.ts.map +1 -0
  85. package/dist/pack/generation.js +459 -0
  86. package/dist/pack/generation.js.map +1 -0
  87. package/dist/pack/index.d.ts +181 -0
  88. package/dist/pack/index.d.ts.map +1 -0
  89. package/dist/pack/index.js +552 -0
  90. package/dist/pack/index.js.map +1 -0
  91. package/dist/refs/branch.d.ts +224 -0
  92. package/dist/refs/branch.d.ts.map +1 -0
  93. package/dist/refs/branch.js +170 -0
  94. package/dist/refs/branch.js.map +1 -0
  95. package/dist/refs/storage.d.ts +208 -0
  96. package/dist/refs/storage.d.ts.map +1 -0
  97. package/dist/refs/storage.js +421 -0
  98. package/dist/refs/storage.js.map +1 -0
  99. package/dist/refs/tag.d.ts +230 -0
  100. package/dist/refs/tag.d.ts.map +1 -0
  101. package/dist/refs/tag.js +188 -0
  102. package/dist/refs/tag.js.map +1 -0
  103. package/dist/storage/lru-cache.d.ts +188 -0
  104. package/dist/storage/lru-cache.d.ts.map +1 -0
  105. package/dist/storage/lru-cache.js +410 -0
  106. package/dist/storage/lru-cache.js.map +1 -0
  107. package/dist/storage/object-index.d.ts +140 -0
  108. package/dist/storage/object-index.d.ts.map +1 -0
  109. package/dist/storage/object-index.js +166 -0
  110. package/dist/storage/object-index.js.map +1 -0
  111. package/dist/storage/r2-pack.d.ts +394 -0
  112. package/dist/storage/r2-pack.d.ts.map +1 -0
  113. package/dist/storage/r2-pack.js +1062 -0
  114. package/dist/storage/r2-pack.js.map +1 -0
  115. package/dist/tiered/cdc-pipeline.d.ts +316 -0
  116. package/dist/tiered/cdc-pipeline.d.ts.map +1 -0
  117. package/dist/tiered/cdc-pipeline.js +771 -0
  118. package/dist/tiered/cdc-pipeline.js.map +1 -0
  119. package/dist/tiered/migration.d.ts +242 -0
  120. package/dist/tiered/migration.d.ts.map +1 -0
  121. package/dist/tiered/migration.js +592 -0
  122. package/dist/tiered/migration.js.map +1 -0
  123. package/dist/tiered/parquet-writer.d.ts +248 -0
  124. package/dist/tiered/parquet-writer.d.ts.map +1 -0
  125. package/dist/tiered/parquet-writer.js +555 -0
  126. package/dist/tiered/parquet-writer.js.map +1 -0
  127. package/dist/tiered/read-path.d.ts +141 -0
  128. package/dist/tiered/read-path.d.ts.map +1 -0
  129. package/dist/tiered/read-path.js +204 -0
  130. package/dist/tiered/read-path.js.map +1 -0
  131. package/dist/types/objects.d.ts +53 -0
  132. package/dist/types/objects.d.ts.map +1 -0
  133. package/dist/types/objects.js +291 -0
  134. package/dist/types/objects.js.map +1 -0
  135. package/dist/types/storage.d.ts +117 -0
  136. package/dist/types/storage.d.ts.map +1 -0
  137. package/dist/types/storage.js +8 -0
  138. package/dist/types/storage.js.map +1 -0
  139. package/dist/utils/hash.d.ts +31 -0
  140. package/dist/utils/hash.d.ts.map +1 -0
  141. package/dist/utils/hash.js +60 -0
  142. package/dist/utils/hash.js.map +1 -0
  143. package/dist/utils/sha1.d.ts +26 -0
  144. package/dist/utils/sha1.d.ts.map +1 -0
  145. package/dist/utils/sha1.js +127 -0
  146. package/dist/utils/sha1.js.map +1 -0
  147. package/dist/wire/capabilities.d.ts +236 -0
  148. package/dist/wire/capabilities.d.ts.map +1 -0
  149. package/dist/wire/capabilities.js +437 -0
  150. package/dist/wire/capabilities.js.map +1 -0
  151. package/dist/wire/pkt-line.d.ts +67 -0
  152. package/dist/wire/pkt-line.d.ts.map +1 -0
  153. package/dist/wire/pkt-line.js +145 -0
  154. package/dist/wire/pkt-line.js.map +1 -0
  155. package/dist/wire/receive-pack.d.ts +302 -0
  156. package/dist/wire/receive-pack.d.ts.map +1 -0
  157. package/dist/wire/receive-pack.js +885 -0
  158. package/dist/wire/receive-pack.js.map +1 -0
  159. package/dist/wire/smart-http.d.ts +321 -0
  160. package/dist/wire/smart-http.d.ts.map +1 -0
  161. package/dist/wire/smart-http.js +654 -0
  162. package/dist/wire/smart-http.js.map +1 -0
  163. package/dist/wire/upload-pack.d.ts +333 -0
  164. package/dist/wire/upload-pack.d.ts.map +1 -0
  165. package/dist/wire/upload-pack.js +850 -0
  166. package/dist/wire/upload-pack.js.map +1 -0
  167. package/package.json +61 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Tree Builder - builds git tree objects from index entries
3
+ *
4
+ * Supports:
5
+ * - File modes (100644 regular, 100755 executable, 040000 directory, 120000 symlink, 160000 submodule)
6
+ * - Proper tree entry format (mode + space + name + null + sha)
7
+ * - Sorted entries (git requires lexicographic ordering)
8
+ * - Nested tree building for directory hierarchies
9
+ * - Tree SHA computation
10
+ * - Tree deduplication
11
+ */
12
+ import { TreeEntry } from '../types/objects';
13
+ import type { BasicObjectStore as ObjectStore } from '../types/storage';
14
+ /**
15
+ * Index entry from git index file
16
+ */
17
+ export interface IndexEntry {
18
+ path: string;
19
+ sha: string;
20
+ mode: string;
21
+ flags: number;
22
+ size: number;
23
+ mtime: number;
24
+ ctime: number;
25
+ }
26
+ /**
27
+ * ObjectStore interface for tree builder operations.
28
+ * Re-exported from storage types for convenience.
29
+ */
30
+ export type { ObjectStore };
31
+ /**
32
+ * Tree node for building hierarchy
33
+ */
34
+ export interface TreeNode {
35
+ name: string;
36
+ path: string;
37
+ isDirectory: boolean;
38
+ children: Map<string, TreeNode>;
39
+ entry?: IndexEntry;
40
+ }
41
+ /**
42
+ * Result of building a tree
43
+ */
44
+ export interface BuildTreeResult {
45
+ sha: string;
46
+ entries: TreeEntry[];
47
+ treeCount: number;
48
+ uniqueTreeCount: number;
49
+ deduplicatedCount: number;
50
+ subtrees?: Record<string, BuildTreeResult>;
51
+ }
52
+ /**
53
+ * Build a tree hierarchy from index entries
54
+ */
55
+ export declare function buildTreeHierarchy(entries: IndexEntry[]): TreeNode;
56
+ /**
57
+ * Sort tree entries according to git conventions
58
+ * Directories are sorted as if they have a trailing slash
59
+ */
60
+ export declare function sortTreeEntries(entries: TreeEntry[]): TreeEntry[];
61
+ /**
62
+ * Create a tree object and store it
63
+ */
64
+ export declare function createTreeObject(store: ObjectStore, entries: TreeEntry[]): Promise<{
65
+ sha: string;
66
+ type: 'tree';
67
+ data: Uint8Array;
68
+ }>;
69
+ /**
70
+ * Deduplicate trees based on their content hash
71
+ * Returns a map of canonical tree content to path, and mapping of paths to canonical paths
72
+ */
73
+ export declare function deduplicateTrees(trees: Map<string, TreeEntry[]>): {
74
+ deduplicated: Map<string, TreeEntry[]>;
75
+ mapping: Map<string, string>;
76
+ };
77
+ /**
78
+ * Build tree from index entries
79
+ * This is the main entry point for tree building
80
+ */
81
+ export declare function buildTreeFromIndex(store: ObjectStore, entries: IndexEntry[]): Promise<BuildTreeResult>;
82
+ //# sourceMappingURL=tree-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-builder.d.ts","sourceRoot":"","sources":["../../src/ops/tree-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAA;AASvE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;GAGG;AACH,YAAY,EAAE,WAAW,EAAE,CAAA;AAE3B;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,OAAO,CAAA;IACpB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC/B,KAAK,CAAC,EAAE,UAAU,CAAA;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,SAAS,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAC3C;AAsCD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,QAAQ,CAsClE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAUjE;AAgCD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,SAAS,EAAE,GACnB,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAI1D;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,GAC9B;IAAE,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAsB1E;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,UAAU,EAAE,GACpB,OAAO,CAAC,eAAe,CAAC,CAkG1B"}
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Tree Builder - builds git tree objects from index entries
3
+ *
4
+ * Supports:
5
+ * - File modes (100644 regular, 100755 executable, 040000 directory, 120000 symlink, 160000 submodule)
6
+ * - Proper tree entry format (mode + space + name + null + sha)
7
+ * - Sorted entries (git requires lexicographic ordering)
8
+ * - Nested tree building for directory hierarchies
9
+ * - Tree SHA computation
10
+ * - Tree deduplication
11
+ */
12
+ import { hexToBytes } from '../utils/hash';
13
+ // Valid file modes in git
14
+ const VALID_MODES = new Set(['100644', '100755', '040000', '120000', '160000']);
15
+ // Text encoder/decoder
16
+ const encoder = new TextEncoder();
17
+ /**
18
+ * Validate an index entry
19
+ */
20
+ function validateEntry(entry) {
21
+ // Check mode
22
+ if (!VALID_MODES.has(entry.mode)) {
23
+ throw new Error(`Invalid file mode: ${entry.mode}`);
24
+ }
25
+ // Check SHA format (40 hex characters)
26
+ if (!/^[0-9a-f]{40}$/.test(entry.sha)) {
27
+ throw new Error(`Invalid SHA format: ${entry.sha}`);
28
+ }
29
+ // Check path
30
+ if (!entry.path || entry.path.length === 0) {
31
+ throw new Error('Empty path not allowed');
32
+ }
33
+ if (entry.path.startsWith('/')) {
34
+ throw new Error('Path must not start with /');
35
+ }
36
+ if (entry.path.includes('//')) {
37
+ throw new Error('Path must not contain double slashes');
38
+ }
39
+ // Check for . or .. components
40
+ const parts = entry.path.split('/');
41
+ for (const part of parts) {
42
+ if (part === '.' || part === '..') {
43
+ throw new Error(`Path must not contain . or .. components: ${entry.path}`);
44
+ }
45
+ }
46
+ }
47
+ /**
48
+ * Build a tree hierarchy from index entries
49
+ */
50
+ export function buildTreeHierarchy(entries) {
51
+ const root = {
52
+ name: '',
53
+ path: '',
54
+ isDirectory: true,
55
+ children: new Map()
56
+ };
57
+ for (const entry of entries) {
58
+ const parts = entry.path.split('/');
59
+ let current = root;
60
+ for (let i = 0; i < parts.length; i++) {
61
+ const part = parts[i];
62
+ const isLast = i === parts.length - 1;
63
+ const currentPath = parts.slice(0, i + 1).join('/');
64
+ if (!current.children.has(part)) {
65
+ const node = {
66
+ name: part,
67
+ path: currentPath,
68
+ isDirectory: !isLast,
69
+ children: new Map(),
70
+ entry: isLast ? entry : undefined
71
+ };
72
+ current.children.set(part, node);
73
+ }
74
+ else if (isLast) {
75
+ // Update entry for duplicate paths (last one wins)
76
+ const existing = current.children.get(part);
77
+ existing.entry = entry;
78
+ existing.isDirectory = false;
79
+ }
80
+ current = current.children.get(part);
81
+ }
82
+ }
83
+ return root;
84
+ }
85
+ /**
86
+ * Sort tree entries according to git conventions
87
+ * Directories are sorted as if they have a trailing slash
88
+ */
89
+ export function sortTreeEntries(entries) {
90
+ return [...entries].sort((a, b) => {
91
+ // Directories sort as if they have trailing slash
92
+ const aName = a.mode === '040000' ? a.name + '/' : a.name;
93
+ const bName = b.mode === '040000' ? b.name + '/' : b.name;
94
+ // Use byte-wise comparison (localeCompare with raw mode)
95
+ if (aName < bName)
96
+ return -1;
97
+ if (aName > bName)
98
+ return 1;
99
+ return 0;
100
+ });
101
+ }
102
+ /**
103
+ * Create tree object data from entries
104
+ */
105
+ function createTreeData(entries) {
106
+ // Sort entries
107
+ const sorted = sortTreeEntries(entries);
108
+ // Build entry content
109
+ const entryParts = [];
110
+ for (const entry of sorted) {
111
+ const modeName = encoder.encode(`${entry.mode} ${entry.name}\0`);
112
+ const sha20 = hexToBytes(entry.sha);
113
+ const entryData = new Uint8Array(modeName.length + 20);
114
+ entryData.set(modeName);
115
+ entryData.set(sha20, modeName.length);
116
+ entryParts.push(entryData);
117
+ }
118
+ // Combine all parts
119
+ const totalLength = entryParts.reduce((sum, part) => sum + part.length, 0);
120
+ const content = new Uint8Array(totalLength);
121
+ let offset = 0;
122
+ for (const part of entryParts) {
123
+ content.set(part, offset);
124
+ offset += part.length;
125
+ }
126
+ return content;
127
+ }
128
+ /**
129
+ * Create a tree object and store it
130
+ */
131
+ export async function createTreeObject(store, entries) {
132
+ const data = createTreeData(entries);
133
+ const sha = await store.storeObject('tree', data);
134
+ return { sha, type: 'tree', data };
135
+ }
136
+ /**
137
+ * Deduplicate trees based on their content hash
138
+ * Returns a map of canonical tree content to path, and mapping of paths to canonical paths
139
+ */
140
+ export function deduplicateTrees(trees) {
141
+ const contentToPath = new Map();
142
+ const deduplicated = new Map();
143
+ const mapping = new Map();
144
+ for (const [path, entries] of trees) {
145
+ // Create a content key from sorted entries
146
+ const sorted = sortTreeEntries(entries);
147
+ const key = sorted.map(e => `${e.mode}:${e.name}:${e.sha}`).join('|');
148
+ if (contentToPath.has(key)) {
149
+ // Duplicate - map to existing path
150
+ mapping.set(path, contentToPath.get(key));
151
+ }
152
+ else {
153
+ // New unique tree
154
+ contentToPath.set(key, path);
155
+ deduplicated.set(path, entries);
156
+ mapping.set(path, path);
157
+ }
158
+ }
159
+ return { deduplicated, mapping };
160
+ }
161
+ /**
162
+ * Build tree from index entries
163
+ * This is the main entry point for tree building
164
+ */
165
+ export async function buildTreeFromIndex(store, entries) {
166
+ // Validate all entries first
167
+ for (const entry of entries) {
168
+ validateEntry(entry);
169
+ }
170
+ // Build hierarchy
171
+ const hierarchy = buildTreeHierarchy(entries);
172
+ // Track stats
173
+ let treeCount = 0;
174
+ let uniqueTreeCount = 0;
175
+ const treeContentToSha = new Map();
176
+ /**
177
+ * Recursively build tree for a node
178
+ */
179
+ async function buildNode(node) {
180
+ const treeEntries = [];
181
+ const nodeSubtrees = {};
182
+ // Process children
183
+ const children = Array.from(node.children.values());
184
+ for (const child of children) {
185
+ if (child.isDirectory) {
186
+ // Recursively build subtree
187
+ const subtreeResult = await buildNode(child);
188
+ nodeSubtrees[child.name] = subtreeResult;
189
+ treeEntries.push({
190
+ mode: '040000',
191
+ name: child.name,
192
+ sha: subtreeResult.sha
193
+ });
194
+ }
195
+ else if (child.entry) {
196
+ // File entry
197
+ treeEntries.push({
198
+ mode: child.entry.mode,
199
+ name: child.name,
200
+ sha: child.entry.sha
201
+ });
202
+ }
203
+ }
204
+ // Sort entries
205
+ const sortedEntries = sortTreeEntries(treeEntries);
206
+ treeCount++;
207
+ // Check for deduplication
208
+ const contentKey = sortedEntries.map(e => `${e.mode}:${e.name}:${e.sha}`).join('|');
209
+ let sha;
210
+ if (treeContentToSha.has(contentKey)) {
211
+ // Reuse existing tree SHA
212
+ sha = treeContentToSha.get(contentKey);
213
+ }
214
+ else {
215
+ // Create new tree object
216
+ const treeObj = await createTreeObject(store, sortedEntries);
217
+ sha = treeObj.sha;
218
+ treeContentToSha.set(contentKey, sha);
219
+ uniqueTreeCount++;
220
+ }
221
+ return {
222
+ sha,
223
+ entries: sortedEntries,
224
+ subtrees: nodeSubtrees
225
+ };
226
+ }
227
+ // Build from root
228
+ const result = await buildNode(hierarchy);
229
+ // Convert BuildResult to BuildTreeResult format
230
+ function convertToResult(br) {
231
+ const subtreesConverted = {};
232
+ for (const [name, sub] of Object.entries(br.subtrees)) {
233
+ subtreesConverted[name] = convertToResult(sub);
234
+ }
235
+ return {
236
+ sha: br.sha,
237
+ entries: br.entries,
238
+ treeCount,
239
+ uniqueTreeCount,
240
+ deduplicatedCount: treeCount - uniqueTreeCount,
241
+ subtrees: Object.keys(subtreesConverted).length > 0 ? subtreesConverted : undefined
242
+ };
243
+ }
244
+ return convertToResult(result);
245
+ }
246
+ //# sourceMappingURL=tree-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-builder.js","sourceRoot":"","sources":["../../src/ops/tree-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1C,0BAA0B;AAC1B,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;AAE/E,uBAAuB;AACvB,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AA4CjC;;GAEG;AACH,SAAS,aAAa,CAAC,KAAiB;IACtC,aAAa;IACb,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;IACrD,CAAC;IA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,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;YACrC,eAAe,EAAE,CAAA;QACnB,CAAC;QAED,OAAO;YACL,GAAG;YACH,OAAO,EAAE,aAAa;YACtB,QAAQ,EAAE,YAAY;SACvB,CAAA;IACH,CAAC;IAED,kBAAkB;IAClB,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,SAAS,CAAC,CAAA;IAEzC,gDAAgD;IAChD,SAAS,eAAe,CAAC,EAAe;QACtC,MAAM,iBAAiB,GAAoC,EAAE,CAAA;QAC7D,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;YACtD,iBAAiB,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,GAAG,CAAC,CAAA;QAChD,CAAC;QAED,OAAO;YACL,GAAG,EAAE,EAAE,CAAC,GAAG;YACX,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,SAAS;YACT,eAAe;YACf,iBAAiB,EAAE,SAAS,GAAG,eAAe;YAC9C,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;SACpF,CAAA;IACH,CAAC;IAED,OAAO,eAAe,CAAC,MAAM,CAAC,CAAA;AAChC,CAAC"}
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Tree Diff Operations
3
+ *
4
+ * This module provides functionality for comparing Git trees and detecting
5
+ * changes between them, including added, deleted, modified, renamed, and
6
+ * copied files.
7
+ */
8
+ import type { TreeEntry } from '../types/objects';
9
+ import type { TreeDiffObjectStore as ObjectStore } from '../types/storage';
10
+ /**
11
+ * Status of a file in a diff
12
+ */
13
+ export declare enum DiffStatus {
14
+ /** File was added */
15
+ ADDED = "A",
16
+ /** File was deleted */
17
+ DELETED = "D",
18
+ /** File was modified */
19
+ MODIFIED = "M",
20
+ /** File was renamed */
21
+ RENAMED = "R",
22
+ /** File was copied */
23
+ COPIED = "C",
24
+ /** File type changed (e.g., file to symlink) */
25
+ TYPE_CHANGED = "T",
26
+ /** Unmerged (conflict) */
27
+ UNMERGED = "U"
28
+ }
29
+ /**
30
+ * File mode constants for Git objects
31
+ */
32
+ export declare enum FileMode {
33
+ /** Regular file (not executable) */
34
+ REGULAR = "100644",
35
+ /** Executable file */
36
+ EXECUTABLE = "100755",
37
+ /** Symbolic link */
38
+ SYMLINK = "120000",
39
+ /** Git submodule (gitlink) */
40
+ GITLINK = "160000",
41
+ /** Directory (tree) */
42
+ TREE = "040000"
43
+ }
44
+ /**
45
+ * Represents a single entry in a diff result
46
+ */
47
+ export interface DiffEntry {
48
+ /** Path to the file (new path for renames/copies) */
49
+ path: string;
50
+ /** Status of the change */
51
+ status: DiffStatus;
52
+ /** Old file mode (null for added files) */
53
+ oldMode: string | null;
54
+ /** New file mode (null for deleted files) */
55
+ newMode: string | null;
56
+ /** Old object SHA (null for added files) */
57
+ oldSha: string | null;
58
+ /** New object SHA (null for deleted files) */
59
+ newSha: string | null;
60
+ /** Original path (for renames/copies) */
61
+ oldPath?: string;
62
+ /** Similarity percentage (for renames/copies, 0-100) */
63
+ similarity?: number;
64
+ /** Whether the file is binary */
65
+ isBinary?: boolean;
66
+ }
67
+ /**
68
+ * Options for tree diff operations
69
+ */
70
+ export interface DiffOptions {
71
+ /** Enable rename detection (default: true) */
72
+ detectRenames?: boolean;
73
+ /** Enable copy detection (default: false) */
74
+ detectCopies?: boolean;
75
+ /** Similarity threshold for rename/copy detection (0-100, default: 50) */
76
+ similarityThreshold?: number;
77
+ /** Filter paths by glob patterns (include) */
78
+ pathspecs?: string[];
79
+ /** Paths to exclude */
80
+ excludePaths?: string[];
81
+ /** Include binary file detection (default: true) */
82
+ detectBinary?: boolean;
83
+ /** Maximum file size to consider for rename/copy detection */
84
+ maxRenameSize?: number;
85
+ /** Whether to recurse into subdirectories (default: true) */
86
+ recursive?: boolean;
87
+ /** Only show names, not full diff info */
88
+ nameOnly?: boolean;
89
+ /** Show only file status, not diff content */
90
+ nameStatus?: boolean;
91
+ }
92
+ /**
93
+ * Result of a tree diff operation
94
+ */
95
+ export interface DiffResult {
96
+ /** List of diff entries */
97
+ entries: DiffEntry[];
98
+ /** Statistics about the diff */
99
+ stats: {
100
+ added: number;
101
+ deleted: number;
102
+ modified: number;
103
+ renamed: number;
104
+ copied: number;
105
+ };
106
+ }
107
+ /**
108
+ * ObjectStore interface for tree diff operations.
109
+ * Re-exported from storage types for convenience.
110
+ */
111
+ export type { ObjectStore };
112
+ /**
113
+ * Represents an index entry for diff-to-index operations
114
+ */
115
+ export interface IndexEntry {
116
+ path: string;
117
+ mode: string;
118
+ sha: string;
119
+ /** Stage number (0 = normal, 1-3 = merge conflict stages) */
120
+ stage: number;
121
+ /** File modification time */
122
+ mtime?: number;
123
+ /** File size */
124
+ size?: number;
125
+ }
126
+ /**
127
+ * Check if a file appears to be binary based on its content
128
+ *
129
+ * A file is considered binary if it contains null bytes in the first
130
+ * 8000 bytes (similar to Git's heuristic).
131
+ *
132
+ * @param content - File content to check
133
+ * @returns true if the file appears to be binary
134
+ */
135
+ export declare function isBinaryContent(content: Uint8Array): boolean;
136
+ /**
137
+ * Calculate similarity between two blobs for rename/copy detection
138
+ *
139
+ * Uses a simple heuristic based on shared content.
140
+ *
141
+ * @param store - Object store for retrieving blob contents
142
+ * @param oldSha - SHA of the old blob
143
+ * @param newSha - SHA of the new blob
144
+ * @returns Promise resolving to similarity percentage (0-100)
145
+ */
146
+ export declare function calculateSimilarity(store: ObjectStore, oldSha: string, newSha: string): Promise<number>;
147
+ /**
148
+ * Parse a file mode string and determine its type
149
+ *
150
+ * @param mode - File mode string (e.g., '100644', '040000')
151
+ * @returns Object with mode information
152
+ */
153
+ export declare function parseMode(mode: string): {
154
+ isFile: boolean;
155
+ isDirectory: boolean;
156
+ isSymlink: boolean;
157
+ isSubmodule: boolean;
158
+ isExecutable: boolean;
159
+ };
160
+ /**
161
+ * Check if a mode change represents a significant type change
162
+ *
163
+ * @param oldMode - Old file mode
164
+ * @param newMode - New file mode
165
+ * @returns true if the mode change is significant (e.g., file to symlink)
166
+ */
167
+ export declare function isModeChangeSignificant(oldMode: string, newMode: string): boolean;
168
+ /**
169
+ * Filter diff entries by pathspecs
170
+ *
171
+ * @param entries - Diff entries to filter
172
+ * @param pathspecs - Glob patterns to include
173
+ * @param excludePaths - Paths to exclude
174
+ * @returns Filtered entries
175
+ */
176
+ export declare function filterByPathspecs(entries: DiffEntry[], pathspecs?: string[], excludePaths?: string[]): DiffEntry[];
177
+ /**
178
+ * Recursively walk a tree and collect all entries with full paths
179
+ *
180
+ * @param store - Object store for retrieving tree contents
181
+ * @param treeSha - SHA of the tree to walk
182
+ * @param prefix - Path prefix for entries
183
+ * @returns Promise resolving to flat list of entries with full paths
184
+ */
185
+ export declare function walkTree(store: ObjectStore, treeSha: string, prefix?: string): Promise<Array<TreeEntry & {
186
+ fullPath: string;
187
+ }>>;
188
+ /**
189
+ * Compare two trees and return the differences
190
+ *
191
+ * @param store - Object store for retrieving tree contents
192
+ * @param oldTreeSha - SHA of the old tree (null for initial commit comparison)
193
+ * @param newTreeSha - SHA of the new tree (null to compare against empty)
194
+ * @param options - Diff options
195
+ * @returns Promise resolving to diff result
196
+ */
197
+ export declare function diffTrees(store: ObjectStore, oldTreeSha: string | null, newTreeSha: string | null, options?: DiffOptions): Promise<DiffResult>;
198
+ /**
199
+ * Detect renames in a set of diff entries
200
+ *
201
+ * This function takes a list of added and deleted files and attempts to
202
+ * match them based on content similarity to detect renames.
203
+ *
204
+ * @param store - Object store for retrieving blob contents
205
+ * @param entries - Initial diff entries (before rename detection)
206
+ * @param options - Diff options (particularly similarityThreshold)
207
+ * @returns Promise resolving to entries with renames detected
208
+ */
209
+ export declare function detectRenames(store: ObjectStore, entries: DiffEntry[], options?: DiffOptions): Promise<DiffEntry[]>;
210
+ /**
211
+ * Detect copies in a set of diff entries
212
+ *
213
+ * This function takes a list of diff entries and attempts to detect
214
+ * if any added files are copies of existing files.
215
+ *
216
+ * @param store - Object store for retrieving blob contents
217
+ * @param entries - Initial diff entries
218
+ * @param existingPaths - Map of existing paths to their SHAs
219
+ * @param options - Diff options
220
+ * @returns Promise resolving to entries with copies detected
221
+ */
222
+ export declare function detectCopies(store: ObjectStore, entries: DiffEntry[], existingPaths: Map<string, string>, options?: DiffOptions): Promise<DiffEntry[]>;
223
+ /**
224
+ * Compare a tree to the index (staging area)
225
+ *
226
+ * @param store - Object store for retrieving tree contents
227
+ * @param treeSha - SHA of the tree to compare (typically HEAD)
228
+ * @param index - Index entries to compare against
229
+ * @param options - Diff options
230
+ * @returns Promise resolving to diff result
231
+ */
232
+ export declare function diffTreeToIndex(store: ObjectStore, treeSha: string | null, index: IndexEntry[], options?: DiffOptions): Promise<DiffResult>;
233
+ /**
234
+ * Compare a tree to working directory entries
235
+ *
236
+ * @param store - Object store for retrieving tree contents
237
+ * @param treeSha - SHA of the tree to compare
238
+ * @param workingEntries - Working directory file entries
239
+ * @param options - Diff options
240
+ * @returns Promise resolving to diff result
241
+ */
242
+ export declare function diffTreeToWorktree(store: ObjectStore, treeSha: string | null, workingEntries: IndexEntry[], options?: DiffOptions): Promise<DiffResult>;
243
+ //# sourceMappingURL=tree-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-diff.d.ts","sourceRoot":"","sources":["../../src/ops/tree-diff.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,mBAAmB,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE1E;;GAEG;AACH,oBAAY,UAAU;IACpB,qBAAqB;IACrB,KAAK,MAAM;IACX,uBAAuB;IACvB,OAAO,MAAM;IACb,wBAAwB;IACxB,QAAQ,MAAM;IACd,uBAAuB;IACvB,OAAO,MAAM;IACb,sBAAs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