trellis 2.0.13 → 2.1.2

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 (96) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/embeddings/index.js +1 -1
  3. package/dist/{index-7gvjxt27.js → index-2917tjd8.js} +1 -1
  4. package/package.json +2 -10
  5. package/dist/transformers.node-bx3q9d7k.js +0 -33130
  6. package/src/cli/index.ts +0 -3356
  7. package/src/core/agents/harness.ts +0 -380
  8. package/src/core/agents/index.ts +0 -18
  9. package/src/core/agents/types.ts +0 -90
  10. package/src/core/index.ts +0 -118
  11. package/src/core/kernel/middleware.ts +0 -44
  12. package/src/core/kernel/trellis-kernel.ts +0 -593
  13. package/src/core/ontology/builtins.ts +0 -248
  14. package/src/core/ontology/index.ts +0 -34
  15. package/src/core/ontology/registry.ts +0 -209
  16. package/src/core/ontology/types.ts +0 -124
  17. package/src/core/ontology/validator.ts +0 -382
  18. package/src/core/persist/backend.ts +0 -74
  19. package/src/core/persist/sqlite-backend.ts +0 -298
  20. package/src/core/plugins/index.ts +0 -17
  21. package/src/core/plugins/registry.ts +0 -322
  22. package/src/core/plugins/types.ts +0 -126
  23. package/src/core/query/datalog.ts +0 -188
  24. package/src/core/query/engine.ts +0 -370
  25. package/src/core/query/index.ts +0 -34
  26. package/src/core/query/parser.ts +0 -481
  27. package/src/core/query/types.ts +0 -200
  28. package/src/core/store/eav-store.ts +0 -467
  29. package/src/decisions/auto-capture.ts +0 -136
  30. package/src/decisions/hooks.ts +0 -163
  31. package/src/decisions/index.ts +0 -261
  32. package/src/decisions/types.ts +0 -103
  33. package/src/embeddings/auto-embed.ts +0 -248
  34. package/src/embeddings/chunker.ts +0 -327
  35. package/src/embeddings/index.ts +0 -48
  36. package/src/embeddings/model.ts +0 -112
  37. package/src/embeddings/search.ts +0 -305
  38. package/src/embeddings/store.ts +0 -313
  39. package/src/embeddings/types.ts +0 -92
  40. package/src/engine.ts +0 -1125
  41. package/src/garden/cluster.ts +0 -330
  42. package/src/garden/garden.ts +0 -306
  43. package/src/garden/index.ts +0 -29
  44. package/src/git/git-exporter.ts +0 -286
  45. package/src/git/git-importer.ts +0 -329
  46. package/src/git/git-reader.ts +0 -189
  47. package/src/git/index.ts +0 -22
  48. package/src/identity/governance.ts +0 -211
  49. package/src/identity/identity.ts +0 -224
  50. package/src/identity/index.ts +0 -30
  51. package/src/identity/signing-middleware.ts +0 -97
  52. package/src/index.ts +0 -29
  53. package/src/links/index.ts +0 -49
  54. package/src/links/lifecycle.ts +0 -400
  55. package/src/links/parser.ts +0 -484
  56. package/src/links/ref-index.ts +0 -186
  57. package/src/links/resolver.ts +0 -314
  58. package/src/links/types.ts +0 -108
  59. package/src/mcp/index.ts +0 -22
  60. package/src/mcp/server.ts +0 -1278
  61. package/src/semantic/csharp-parser.ts +0 -493
  62. package/src/semantic/go-parser.ts +0 -585
  63. package/src/semantic/index.ts +0 -34
  64. package/src/semantic/java-parser.ts +0 -456
  65. package/src/semantic/python-parser.ts +0 -659
  66. package/src/semantic/ruby-parser.ts +0 -446
  67. package/src/semantic/rust-parser.ts +0 -784
  68. package/src/semantic/semantic-merge.ts +0 -210
  69. package/src/semantic/ts-parser.ts +0 -681
  70. package/src/semantic/types.ts +0 -175
  71. package/src/sync/http-transport.ts +0 -144
  72. package/src/sync/index.ts +0 -43
  73. package/src/sync/memory-transport.ts +0 -66
  74. package/src/sync/multi-repo.ts +0 -200
  75. package/src/sync/reconciler.ts +0 -237
  76. package/src/sync/sync-engine.ts +0 -258
  77. package/src/sync/types.ts +0 -104
  78. package/src/sync/ws-transport.ts +0 -145
  79. package/src/ui/client.html +0 -695
  80. package/src/ui/server.ts +0 -419
  81. package/src/vcs/blob-store.ts +0 -124
  82. package/src/vcs/branch.ts +0 -150
  83. package/src/vcs/checkpoint.ts +0 -64
  84. package/src/vcs/decompose.ts +0 -469
  85. package/src/vcs/diff.ts +0 -409
  86. package/src/vcs/engine-context.ts +0 -26
  87. package/src/vcs/index.ts +0 -23
  88. package/src/vcs/issue.ts +0 -800
  89. package/src/vcs/merge.ts +0 -425
  90. package/src/vcs/milestone.ts +0 -124
  91. package/src/vcs/ops.ts +0 -59
  92. package/src/vcs/types.ts +0 -213
  93. package/src/vcs/vcs-middleware.ts +0 -81
  94. package/src/watcher/fs-watcher.ts +0 -255
  95. package/src/watcher/index.ts +0 -9
  96. package/src/watcher/ingestion.ts +0 -116
package/src/vcs/diff.ts DELETED
@@ -1,409 +0,0 @@
1
- /**
2
- * Diff Engine
3
- *
4
- * File-level diff with unified text output (Tier 0 / P3).
5
- * Compares two points in history by reconstructing file states from the
6
- * op stream and producing file-level diffs with optional unified text diffs
7
- * via the blob store.
8
- *
9
- * DESIGN.md §4.5 — "At Tier 0 (before AST parsing is available), the diff
10
- * engine falls back to file-level comparison."
11
- */
12
-
13
- import type { VcsOp } from './types.js';
14
- import type { BlobStore } from './blob-store.js';
15
-
16
- // ---------------------------------------------------------------------------
17
- // Types
18
- // ---------------------------------------------------------------------------
19
-
20
- export interface FileLevelDiff {
21
- kind: 'fileAdded' | 'fileModified' | 'fileDeleted' | 'fileRenamed';
22
- path: string;
23
- oldPath?: string;
24
- oldContentHash?: string;
25
- newContentHash?: string;
26
- /** Unified diff text (only for fileModified when blob content is available). */
27
- unifiedDiff?: string;
28
- }
29
-
30
- export interface DiffResult {
31
- diffs: FileLevelDiff[];
32
- filesChanged: string[];
33
- stats: {
34
- added: number;
35
- modified: number;
36
- removed: number;
37
- renamed: number;
38
- };
39
- }
40
-
41
- export interface FileState {
42
- contentHash?: string;
43
- deleted?: boolean;
44
- }
45
-
46
- // ---------------------------------------------------------------------------
47
- // Core diff function
48
- // ---------------------------------------------------------------------------
49
-
50
- /**
51
- * Compute file-level diffs between two file state snapshots.
52
- * Optionally produces unified text diffs when a blob store is provided.
53
- */
54
- export function diffFileStates(
55
- stateA: Map<string, FileState>,
56
- stateB: Map<string, FileState>,
57
- blobStore?: BlobStore | null,
58
- ): DiffResult {
59
- const diffs: FileLevelDiff[] = [];
60
-
61
- // Detect additions and modifications
62
- for (const [path, bState] of stateB) {
63
- if (bState.deleted) continue;
64
-
65
- const aState = stateA.get(path);
66
-
67
- if (!aState || aState.deleted) {
68
- // File added
69
- diffs.push({
70
- kind: 'fileAdded',
71
- path,
72
- newContentHash: bState.contentHash,
73
- });
74
- } else if (aState.contentHash !== bState.contentHash) {
75
- // File modified
76
- const diff: FileLevelDiff = {
77
- kind: 'fileModified',
78
- path,
79
- oldContentHash: aState.contentHash,
80
- newContentHash: bState.contentHash,
81
- };
82
-
83
- // Generate unified diff if blob store available
84
- if (blobStore && aState.contentHash && bState.contentHash) {
85
- const oldContent = blobStore.get(aState.contentHash);
86
- const newContent = blobStore.get(bState.contentHash);
87
- if (oldContent && newContent) {
88
- diff.unifiedDiff = generateUnifiedDiff(
89
- path,
90
- oldContent.toString('utf-8'),
91
- newContent.toString('utf-8'),
92
- );
93
- }
94
- }
95
-
96
- diffs.push(diff);
97
- }
98
- }
99
-
100
- // Detect deletions
101
- for (const [path, aState] of stateA) {
102
- if (aState.deleted) continue;
103
-
104
- const bState = stateB.get(path);
105
- if (!bState || bState.deleted) {
106
- diffs.push({
107
- kind: 'fileDeleted',
108
- path,
109
- oldContentHash: aState.contentHash,
110
- });
111
- }
112
- }
113
-
114
- const stats = {
115
- added: diffs.filter((d) => d.kind === 'fileAdded').length,
116
- modified: diffs.filter((d) => d.kind === 'fileModified').length,
117
- removed: diffs.filter((d) => d.kind === 'fileDeleted').length,
118
- renamed: diffs.filter((d) => d.kind === 'fileRenamed').length,
119
- };
120
-
121
- return {
122
- diffs,
123
- filesChanged: diffs.map((d) => d.path),
124
- stats,
125
- };
126
- }
127
-
128
- // ---------------------------------------------------------------------------
129
- // File state reconstruction from ops
130
- // ---------------------------------------------------------------------------
131
-
132
- /**
133
- * Build cumulative file state from an array of ops up to (and including)
134
- * the op with the given hash. If no hash given, uses all ops.
135
- */
136
- export function buildFileStateAtOp(
137
- ops: VcsOp[],
138
- atOpHash?: string,
139
- ): Map<string, FileState> {
140
- const state = new Map<string, FileState>();
141
-
142
- for (const op of ops) {
143
- if (op.vcs?.filePath) {
144
- switch (op.kind) {
145
- case 'vcs:fileAdd':
146
- case 'vcs:fileModify':
147
- state.set(op.vcs.filePath, { contentHash: op.vcs.contentHash });
148
- break;
149
- case 'vcs:fileDelete':
150
- state.set(op.vcs.filePath, { deleted: true });
151
- break;
152
- case 'vcs:fileRename':
153
- if (op.vcs.oldFilePath) {
154
- state.set(op.vcs.oldFilePath, { deleted: true });
155
- }
156
- state.set(op.vcs.filePath, { contentHash: op.vcs.contentHash });
157
- break;
158
- }
159
- }
160
-
161
- if (atOpHash && op.hash === atOpHash) break;
162
- }
163
-
164
- return state;
165
- }
166
-
167
- /**
168
- * Diff two op hashes in the same op stream.
169
- */
170
- export function diffOpRange(
171
- ops: VcsOp[],
172
- fromHash: string,
173
- toHash: string,
174
- blobStore?: BlobStore | null,
175
- ): DiffResult {
176
- const stateA = buildFileStateAtOp(ops, fromHash);
177
- const stateB = buildFileStateAtOp(ops, toHash);
178
- return diffFileStates(stateA, stateB, blobStore);
179
- }
180
-
181
- // ---------------------------------------------------------------------------
182
- // Unified diff generation (Myers algorithm)
183
- // ---------------------------------------------------------------------------
184
-
185
- interface EditOp {
186
- kind: 'equal' | 'insert' | 'delete';
187
- line: string;
188
- }
189
-
190
- /**
191
- * Generate a unified diff string from two text inputs.
192
- */
193
- export function generateUnifiedDiff(
194
- filePath: string,
195
- oldText: string,
196
- newText: string,
197
- contextLines: number = 3,
198
- ): string {
199
- const oldLines = oldText.split('\n');
200
- const newLines = newText.split('\n');
201
- const edits = myersDiff(oldLines, newLines);
202
- const hunks = buildHunks(edits, contextLines);
203
-
204
- if (hunks.length === 0) return '';
205
-
206
- const lines: string[] = [`--- a/${filePath}`, `+++ b/${filePath}`];
207
-
208
- for (const hunk of hunks) {
209
- lines.push(
210
- `@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@`,
211
- );
212
- for (const edit of hunk.edits) {
213
- switch (edit.kind) {
214
- case 'equal':
215
- lines.push(` ${edit.line}`);
216
- break;
217
- case 'delete':
218
- lines.push(`-${edit.line}`);
219
- break;
220
- case 'insert':
221
- lines.push(`+${edit.line}`);
222
- break;
223
- }
224
- }
225
- }
226
-
227
- return lines.join('\n');
228
- }
229
-
230
- /**
231
- * Myers diff algorithm — computes the shortest edit script between two
232
- * arrays of lines. Returns a sequence of equal/insert/delete operations.
233
- */
234
- export function myersDiff(oldLines: string[], newLines: string[]): EditOp[] {
235
- const n = oldLines.length;
236
- const m = newLines.length;
237
-
238
- if (n === 0 && m === 0) return [];
239
- if (n === 0)
240
- return newLines.map((line) => ({ kind: 'insert' as const, line }));
241
- if (m === 0)
242
- return oldLines.map((line) => ({ kind: 'delete' as const, line }));
243
-
244
- const max = n + m;
245
-
246
- // v[k] = furthest x on diagonal k. Offset by max so indices are non-negative.
247
- const size = 2 * max + 1;
248
- const v = new Int32Array(size);
249
- const trace: Int32Array[] = [];
250
-
251
- const off = max; // offset so k=0 maps to index max
252
-
253
- // Forward pass
254
- outer: for (let d = 0; d <= max; d++) {
255
- trace.push(v.slice());
256
- for (let k = -d; k <= d; k += 2) {
257
- let x: number;
258
- if (k === -d || (k !== d && v[k - 1 + off] < v[k + 1 + off])) {
259
- x = v[k + 1 + off]; // move down (insert from new)
260
- } else {
261
- x = v[k - 1 + off] + 1; // move right (delete from old)
262
- }
263
- let y = x - k;
264
-
265
- // Follow diagonal (equal lines)
266
- while (x < n && y < m && oldLines[x] === newLines[y]) {
267
- x++;
268
- y++;
269
- }
270
-
271
- v[k + off] = x;
272
-
273
- if (x >= n && y >= m) break outer;
274
- }
275
- }
276
-
277
- // Backtrack to recover the edit path as a list of (x,y) waypoints
278
- let x = n;
279
- let y = m;
280
- const edits: EditOp[] = [];
281
-
282
- for (let d = trace.length - 1; d >= 0; d--) {
283
- const tv = trace[d];
284
- const k = x - y;
285
-
286
- // Determine which k-diagonal we came from
287
- let prevK: number;
288
- if (d === 0) {
289
- // We're at the start; emit remaining diagonals and break
290
- while (x > 0 && y > 0) {
291
- x--;
292
- y--;
293
- edits.push({ kind: 'equal', line: oldLines[x] });
294
- }
295
- break;
296
- }
297
-
298
- if (k === -d || (k !== d && tv[k - 1 + off] < tv[k + 1 + off])) {
299
- prevK = k + 1; // previous move was down (insert)
300
- } else {
301
- prevK = k - 1; // previous move was right (delete)
302
- }
303
-
304
- const prevX = tv[prevK + off];
305
- const prevY = prevX - prevK;
306
-
307
- // Emit diagonal (equal) lines from (x,y) back to just after the edit
308
- while (x > prevX && y > prevY) {
309
- x--;
310
- y--;
311
- edits.push({ kind: 'equal', line: oldLines[x] });
312
- }
313
-
314
- // Emit the edit itself
315
- if (prevK === k + 1) {
316
- // Was insert (moved down: y increased)
317
- y--;
318
- edits.push({ kind: 'insert', line: newLines[y] });
319
- } else {
320
- // Was delete (moved right: x increased)
321
- x--;
322
- edits.push({ kind: 'delete', line: oldLines[x] });
323
- }
324
- }
325
-
326
- edits.reverse();
327
- return edits;
328
- }
329
-
330
- // ---------------------------------------------------------------------------
331
- // Hunk builder
332
- // ---------------------------------------------------------------------------
333
-
334
- interface Hunk {
335
- oldStart: number;
336
- oldCount: number;
337
- newStart: number;
338
- newCount: number;
339
- edits: EditOp[];
340
- }
341
-
342
- function buildHunks(edits: EditOp[], contextLines: number): Hunk[] {
343
- if (edits.length === 0) return [];
344
-
345
- // Find change indices
346
- const changeIndices: number[] = [];
347
- for (let i = 0; i < edits.length; i++) {
348
- if (edits[i].kind !== 'equal') {
349
- changeIndices.push(i);
350
- }
351
- }
352
-
353
- if (changeIndices.length === 0) return [];
354
-
355
- // Group changes into hunks with context
356
- const hunks: Hunk[] = [];
357
- let hunkStart = Math.max(0, changeIndices[0] - contextLines);
358
- let hunkEnd = Math.min(edits.length - 1, changeIndices[0] + contextLines);
359
-
360
- for (let i = 1; i < changeIndices.length; i++) {
361
- const changeStart = changeIndices[i] - contextLines;
362
- const changeEnd = Math.min(
363
- edits.length - 1,
364
- changeIndices[i] + contextLines,
365
- );
366
-
367
- if (changeStart <= hunkEnd + 1) {
368
- // Merge with current hunk
369
- hunkEnd = changeEnd;
370
- } else {
371
- // Emit current hunk and start new one
372
- hunks.push(createHunk(edits, hunkStart, hunkEnd));
373
- hunkStart = changeStart;
374
- hunkEnd = changeEnd;
375
- }
376
- }
377
-
378
- // Emit final hunk
379
- hunks.push(createHunk(edits, hunkStart, hunkEnd));
380
-
381
- return hunks;
382
- }
383
-
384
- function createHunk(edits: EditOp[], start: number, end: number): Hunk {
385
- const hunkEdits = edits.slice(start, end + 1);
386
-
387
- // Compute old/new line numbers
388
- let oldLine = 1;
389
- let newLine = 1;
390
- for (let i = 0; i < start; i++) {
391
- if (edits[i].kind === 'equal' || edits[i].kind === 'delete') oldLine++;
392
- if (edits[i].kind === 'equal' || edits[i].kind === 'insert') newLine++;
393
- }
394
-
395
- let oldCount = 0;
396
- let newCount = 0;
397
- for (const edit of hunkEdits) {
398
- if (edit.kind === 'equal' || edit.kind === 'delete') oldCount++;
399
- if (edit.kind === 'equal' || edit.kind === 'insert') newCount++;
400
- }
401
-
402
- return {
403
- oldStart: oldLine,
404
- oldCount,
405
- newStart: newLine,
406
- newCount,
407
- edits: hunkEdits,
408
- };
409
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Engine Context
3
- *
4
- * Shared interface that module functions (branch, milestone, checkpoint)
5
- * use to access engine internals without depending on the engine class.
6
- */
7
-
8
- import type { EAVStore, Fact } from '../core/store/eav-store.js';
9
- import type { VcsOp } from './types.js';
10
-
11
- export interface EngineContext {
12
- /** The EAV store for querying/mutating graph state. */
13
- store: EAVStore;
14
-
15
- /** Agent ID for op attribution. */
16
- agentId: string;
17
-
18
- /** Get all ops from the log. */
19
- readAllOps(): VcsOp[];
20
-
21
- /** Get the last op in the log. */
22
- getLastOp(): VcsOp | undefined;
23
-
24
- /** Apply an op (decompose + persist + auto-checkpoint flag). */
25
- applyOp(op: VcsOp): void;
26
- }
package/src/vcs/index.ts DELETED
@@ -1,23 +0,0 @@
1
- /**
2
- * TrellisVCS Core — Public Surface
3
- *
4
- * @module vcs
5
- *
6
- * Re-exports all core VCS primitives: op types and constructors, EAV
7
- * decomposition, branch/milestone/checkpoint management, file-level
8
- * diff and three-way merge, the content-addressed blob store, and the
9
- * shared {@link EngineContext} interface.
10
- */
11
-
12
- export * from './types.js';
13
- export * from './ops.js';
14
- export * from './decompose.js';
15
- export * from './vcs-middleware.js';
16
- export * from './blob-store.js';
17
- export * from './engine-context.js';
18
- export * from './branch.js';
19
- export * from './milestone.js';
20
- export * from './checkpoint.js';
21
- export * from './diff.js';
22
- export * from './merge.js';
23
- export * from './issue.js';