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.
- package/dist/cli/index.js +1 -1
- package/dist/embeddings/index.js +1 -1
- package/dist/{index-7gvjxt27.js → index-2917tjd8.js} +1 -1
- package/package.json +2 -10
- package/dist/transformers.node-bx3q9d7k.js +0 -33130
- package/src/cli/index.ts +0 -3356
- package/src/core/agents/harness.ts +0 -380
- package/src/core/agents/index.ts +0 -18
- package/src/core/agents/types.ts +0 -90
- package/src/core/index.ts +0 -118
- package/src/core/kernel/middleware.ts +0 -44
- package/src/core/kernel/trellis-kernel.ts +0 -593
- package/src/core/ontology/builtins.ts +0 -248
- package/src/core/ontology/index.ts +0 -34
- package/src/core/ontology/registry.ts +0 -209
- package/src/core/ontology/types.ts +0 -124
- package/src/core/ontology/validator.ts +0 -382
- package/src/core/persist/backend.ts +0 -74
- package/src/core/persist/sqlite-backend.ts +0 -298
- package/src/core/plugins/index.ts +0 -17
- package/src/core/plugins/registry.ts +0 -322
- package/src/core/plugins/types.ts +0 -126
- package/src/core/query/datalog.ts +0 -188
- package/src/core/query/engine.ts +0 -370
- package/src/core/query/index.ts +0 -34
- package/src/core/query/parser.ts +0 -481
- package/src/core/query/types.ts +0 -200
- package/src/core/store/eav-store.ts +0 -467
- package/src/decisions/auto-capture.ts +0 -136
- package/src/decisions/hooks.ts +0 -163
- package/src/decisions/index.ts +0 -261
- package/src/decisions/types.ts +0 -103
- package/src/embeddings/auto-embed.ts +0 -248
- package/src/embeddings/chunker.ts +0 -327
- package/src/embeddings/index.ts +0 -48
- package/src/embeddings/model.ts +0 -112
- package/src/embeddings/search.ts +0 -305
- package/src/embeddings/store.ts +0 -313
- package/src/embeddings/types.ts +0 -92
- package/src/engine.ts +0 -1125
- package/src/garden/cluster.ts +0 -330
- package/src/garden/garden.ts +0 -306
- package/src/garden/index.ts +0 -29
- package/src/git/git-exporter.ts +0 -286
- package/src/git/git-importer.ts +0 -329
- package/src/git/git-reader.ts +0 -189
- package/src/git/index.ts +0 -22
- package/src/identity/governance.ts +0 -211
- package/src/identity/identity.ts +0 -224
- package/src/identity/index.ts +0 -30
- package/src/identity/signing-middleware.ts +0 -97
- package/src/index.ts +0 -29
- package/src/links/index.ts +0 -49
- package/src/links/lifecycle.ts +0 -400
- package/src/links/parser.ts +0 -484
- package/src/links/ref-index.ts +0 -186
- package/src/links/resolver.ts +0 -314
- package/src/links/types.ts +0 -108
- package/src/mcp/index.ts +0 -22
- package/src/mcp/server.ts +0 -1278
- package/src/semantic/csharp-parser.ts +0 -493
- package/src/semantic/go-parser.ts +0 -585
- package/src/semantic/index.ts +0 -34
- package/src/semantic/java-parser.ts +0 -456
- package/src/semantic/python-parser.ts +0 -659
- package/src/semantic/ruby-parser.ts +0 -446
- package/src/semantic/rust-parser.ts +0 -784
- package/src/semantic/semantic-merge.ts +0 -210
- package/src/semantic/ts-parser.ts +0 -681
- package/src/semantic/types.ts +0 -175
- package/src/sync/http-transport.ts +0 -144
- package/src/sync/index.ts +0 -43
- package/src/sync/memory-transport.ts +0 -66
- package/src/sync/multi-repo.ts +0 -200
- package/src/sync/reconciler.ts +0 -237
- package/src/sync/sync-engine.ts +0 -258
- package/src/sync/types.ts +0 -104
- package/src/sync/ws-transport.ts +0 -145
- package/src/ui/client.html +0 -695
- package/src/ui/server.ts +0 -419
- package/src/vcs/blob-store.ts +0 -124
- package/src/vcs/branch.ts +0 -150
- package/src/vcs/checkpoint.ts +0 -64
- package/src/vcs/decompose.ts +0 -469
- package/src/vcs/diff.ts +0 -409
- package/src/vcs/engine-context.ts +0 -26
- package/src/vcs/index.ts +0 -23
- package/src/vcs/issue.ts +0 -800
- package/src/vcs/merge.ts +0 -425
- package/src/vcs/milestone.ts +0 -124
- package/src/vcs/ops.ts +0 -59
- package/src/vcs/types.ts +0 -213
- package/src/vcs/vcs-middleware.ts +0 -81
- package/src/watcher/fs-watcher.ts +0 -255
- package/src/watcher/index.ts +0 -9
- package/src/watcher/ingestion.ts +0 -116
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Semantic Merge Engine
|
|
3
|
-
*
|
|
4
|
-
* DESIGN.md §4.4 — Patch Commutativity and Conflict Detection.
|
|
5
|
-
* Two patches commute when they operate on disjoint entities.
|
|
6
|
-
* Two patches conflict when they both modify the same entity
|
|
7
|
-
* in incompatible ways.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type {
|
|
11
|
-
SemanticPatch,
|
|
12
|
-
SemanticMergeConflict,
|
|
13
|
-
SemanticMergeResult,
|
|
14
|
-
} from './types.js';
|
|
15
|
-
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
|
-
// Patch entity extraction
|
|
18
|
-
// ---------------------------------------------------------------------------
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Extract the entity ID that a patch operates on.
|
|
22
|
-
* Returns null for patches that don't target a specific entity.
|
|
23
|
-
*/
|
|
24
|
-
function patchEntityId(patch: SemanticPatch): string | null {
|
|
25
|
-
switch (patch.kind) {
|
|
26
|
-
case 'symbolAdd':
|
|
27
|
-
return patch.entity.id;
|
|
28
|
-
case 'symbolRemove':
|
|
29
|
-
return patch.entityId;
|
|
30
|
-
case 'symbolModify':
|
|
31
|
-
return patch.entityId;
|
|
32
|
-
case 'symbolRename':
|
|
33
|
-
return patch.entityId;
|
|
34
|
-
case 'symbolMove':
|
|
35
|
-
return patch.entityId;
|
|
36
|
-
case 'importAdd':
|
|
37
|
-
case 'importRemove':
|
|
38
|
-
case 'importModify':
|
|
39
|
-
return `import:${patch.fileId}:${patch.source}`;
|
|
40
|
-
case 'exportAdd':
|
|
41
|
-
case 'exportRemove':
|
|
42
|
-
return `export:${patch.fileId}:${patch.name}`;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function patchEntityName(patch: SemanticPatch): string {
|
|
47
|
-
switch (patch.kind) {
|
|
48
|
-
case 'symbolAdd':
|
|
49
|
-
return patch.entity.name;
|
|
50
|
-
case 'symbolRemove':
|
|
51
|
-
return patch.entityName;
|
|
52
|
-
case 'symbolModify':
|
|
53
|
-
return patch.entityName;
|
|
54
|
-
case 'symbolRename':
|
|
55
|
-
return patch.oldName;
|
|
56
|
-
case 'symbolMove':
|
|
57
|
-
return patch.entityName;
|
|
58
|
-
case 'importAdd':
|
|
59
|
-
case 'importRemove':
|
|
60
|
-
case 'importModify':
|
|
61
|
-
return patch.source;
|
|
62
|
-
case 'exportAdd':
|
|
63
|
-
case 'exportRemove':
|
|
64
|
-
return patch.name;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function patchEntityKind(patch: SemanticPatch): string {
|
|
69
|
-
switch (patch.kind) {
|
|
70
|
-
case 'symbolAdd':
|
|
71
|
-
return patch.entity.kind;
|
|
72
|
-
case 'importAdd':
|
|
73
|
-
case 'importRemove':
|
|
74
|
-
case 'importModify':
|
|
75
|
-
return 'import';
|
|
76
|
-
case 'exportAdd':
|
|
77
|
-
case 'exportRemove':
|
|
78
|
-
return 'export';
|
|
79
|
-
default:
|
|
80
|
-
return 'symbol';
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// ---------------------------------------------------------------------------
|
|
85
|
-
// Commutativity check
|
|
86
|
-
// ---------------------------------------------------------------------------
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Check if two patches commute (can be applied in either order).
|
|
90
|
-
* Returns true if they operate on disjoint entities or are identical.
|
|
91
|
-
*/
|
|
92
|
-
export function patchesCommute(a: SemanticPatch, b: SemanticPatch): boolean {
|
|
93
|
-
const idA = patchEntityId(a);
|
|
94
|
-
const idB = patchEntityId(b);
|
|
95
|
-
|
|
96
|
-
// Disjoint entities always commute
|
|
97
|
-
if (idA !== idB) return true;
|
|
98
|
-
|
|
99
|
-
// Same entity — check specific combinations
|
|
100
|
-
// Identical patches commute (idempotent)
|
|
101
|
-
if (a.kind === b.kind && JSON.stringify(a) === JSON.stringify(b)) return true;
|
|
102
|
-
|
|
103
|
-
// importAdd + importAdd on same source — deduplicate (commutes)
|
|
104
|
-
if (a.kind === 'importAdd' && b.kind === 'importAdd') return true;
|
|
105
|
-
|
|
106
|
-
// symbolMove + symbolModify — commutes (modify at new location)
|
|
107
|
-
if (
|
|
108
|
-
(a.kind === 'symbolMove' && b.kind === 'symbolModify') ||
|
|
109
|
-
(a.kind === 'symbolModify' && b.kind === 'symbolMove')
|
|
110
|
-
) {
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Everything else on the same entity does NOT commute
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// ---------------------------------------------------------------------------
|
|
119
|
-
// Semantic merge
|
|
120
|
-
// ---------------------------------------------------------------------------
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Merge two sets of semantic patches (ours and theirs) against a common base.
|
|
124
|
-
* Produces a merged patch list or structured conflicts.
|
|
125
|
-
*/
|
|
126
|
-
export function semanticMerge(
|
|
127
|
-
oursPatches: SemanticPatch[],
|
|
128
|
-
theirsPatches: SemanticPatch[],
|
|
129
|
-
filePath: string = '',
|
|
130
|
-
): SemanticMergeResult {
|
|
131
|
-
const merged: SemanticPatch[] = [];
|
|
132
|
-
const conflicts: SemanticMergeConflict[] = [];
|
|
133
|
-
|
|
134
|
-
// Index theirs by entity ID
|
|
135
|
-
const theirsByEntity = new Map<string, SemanticPatch[]>();
|
|
136
|
-
for (const patch of theirsPatches) {
|
|
137
|
-
const id = patchEntityId(patch) ?? '__no_entity__';
|
|
138
|
-
if (!theirsByEntity.has(id)) theirsByEntity.set(id, []);
|
|
139
|
-
theirsByEntity.get(id)!.push(patch);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const processedTheirsEntities = new Set<string>();
|
|
143
|
-
|
|
144
|
-
// Process ours patches
|
|
145
|
-
for (const ourPatch of oursPatches) {
|
|
146
|
-
const entityId = patchEntityId(ourPatch) ?? '__no_entity__';
|
|
147
|
-
const theirPatches = theirsByEntity.get(entityId);
|
|
148
|
-
|
|
149
|
-
if (!theirPatches || theirPatches.length === 0) {
|
|
150
|
-
// Only we changed this entity — apply ours
|
|
151
|
-
merged.push(ourPatch);
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
processedTheirsEntities.add(entityId);
|
|
156
|
-
|
|
157
|
-
// Check commutativity with each of their patches on the same entity
|
|
158
|
-
let allCommute = true;
|
|
159
|
-
for (const theirPatch of theirPatches) {
|
|
160
|
-
if (!patchesCommute(ourPatch, theirPatch)) {
|
|
161
|
-
allCommute = false;
|
|
162
|
-
|
|
163
|
-
// Determine suggestion
|
|
164
|
-
let suggestion: SemanticMergeConflict['suggestion'] = undefined;
|
|
165
|
-
if (ourPatch.kind === 'symbolRemove' || theirPatch.kind === 'symbolRemove') {
|
|
166
|
-
suggestion = undefined; // delete/edit — human decision
|
|
167
|
-
} else if (ourPatch.kind === 'symbolModify' && theirPatch.kind === 'symbolModify') {
|
|
168
|
-
suggestion = undefined; // both modified — human decision
|
|
169
|
-
} else if (ourPatch.kind === 'symbolRename' && theirPatch.kind === 'symbolModify') {
|
|
170
|
-
suggestion = 'combine'; // rename + modify — can auto-resolve
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
conflicts.push({
|
|
174
|
-
entityId,
|
|
175
|
-
entityName: patchEntityName(ourPatch),
|
|
176
|
-
entityKind: patchEntityKind(ourPatch),
|
|
177
|
-
filePath,
|
|
178
|
-
ours: ourPatch,
|
|
179
|
-
theirs: theirPatch,
|
|
180
|
-
suggestion,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (allCommute) {
|
|
186
|
-
// Both commute — apply both
|
|
187
|
-
merged.push(ourPatch);
|
|
188
|
-
for (const tp of theirPatches) {
|
|
189
|
-
// Deduplicate identical patches
|
|
190
|
-
if (JSON.stringify(tp) !== JSON.stringify(ourPatch)) {
|
|
191
|
-
merged.push(tp);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// Process theirs patches that don't overlap with ours
|
|
198
|
-
for (const theirPatch of theirsPatches) {
|
|
199
|
-
const entityId = patchEntityId(theirPatch) ?? '__no_entity__';
|
|
200
|
-
if (!processedTheirsEntities.has(entityId)) {
|
|
201
|
-
merged.push(theirPatch);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return {
|
|
206
|
-
clean: conflicts.length === 0,
|
|
207
|
-
patches: merged,
|
|
208
|
-
conflicts,
|
|
209
|
-
};
|
|
210
|
-
}
|