trellis 2.0.7 → 2.0.10
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 +1031 -30
- package/dist/core/index.js +474 -2
- package/dist/decisions/index.js +5 -2
- package/dist/embeddings/index.js +5 -1
- package/dist/{index-3s0eak0p.js → index-3ejh8k6v.js} +26 -3
- package/dist/{index-1j1anhmr.js → index-5b01h414.js} +489 -335
- package/dist/index-5m0g9r0y.js +1100 -0
- package/dist/{index-8pce39mh.js → index-65z0xfjw.js} +17 -3
- package/dist/{index-zf6htvnm.js → index-7gvjxt27.js} +166 -2
- package/dist/index-hybgxe40.js +1174 -0
- package/dist/{index-gnw8d7d6.js → index-k5kf7sd0.js} +32 -3
- package/dist/{index-fd4e26s4.js → index-v9b4hqa7.js} +23 -15
- package/dist/index.js +20 -7
- package/dist/transformers.node-bx3q9d7k.js +33130 -0
- package/dist/ui/client.html +695 -0
- package/dist/vcs/index.js +3 -3
- package/package.json +5 -4
- package/src/cli/index.ts +1017 -1
- package/src/core/agents/harness.ts +336 -0
- package/src/core/agents/index.ts +18 -0
- package/src/core/agents/types.ts +90 -0
- package/src/core/index.ts +85 -2
- package/src/core/kernel/trellis-kernel.ts +593 -0
- package/src/core/ontology/builtins.ts +248 -0
- package/src/core/ontology/index.ts +34 -0
- package/src/core/ontology/registry.ts +209 -0
- package/src/core/ontology/types.ts +124 -0
- package/src/core/ontology/validator.ts +382 -0
- package/src/core/persist/backend.ts +10 -0
- package/src/core/persist/sqlite-backend.ts +298 -0
- package/src/core/plugins/index.ts +17 -0
- package/src/core/plugins/registry.ts +322 -0
- package/src/core/plugins/types.ts +126 -0
- package/src/core/query/datalog.ts +188 -0
- package/src/core/query/engine.ts +370 -0
- package/src/core/query/index.ts +34 -0
- package/src/core/query/parser.ts +481 -0
- package/src/core/query/types.ts +200 -0
- package/src/embeddings/auto-embed.ts +248 -0
- package/src/embeddings/index.ts +7 -0
- package/src/embeddings/model.ts +21 -4
- package/src/embeddings/types.ts +8 -1
- package/src/engine.ts +45 -3
- package/src/index.ts +9 -0
- package/src/sync/http-transport.ts +144 -0
- package/src/sync/index.ts +11 -0
- package/src/sync/multi-repo.ts +200 -0
- package/src/sync/ws-transport.ts +145 -0
- package/src/ui/client.html +695 -0
- package/src/ui/server.ts +419 -0
- package/src/watcher/fs-watcher.ts +41 -3
- package/dist/index-gkvhzm9f.js +0 -321
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
createVcsOp,
|
|
4
|
-
decisionEntityId
|
|
5
|
-
|
|
4
|
+
decisionEntityId,
|
|
5
|
+
init_ops,
|
|
6
|
+
init_types
|
|
7
|
+
} from "./index-v9b4hqa7.js";
|
|
8
|
+
import {
|
|
9
|
+
__esm
|
|
10
|
+
} from "./index-a76rekgs.js";
|
|
6
11
|
|
|
7
12
|
// src/decisions/hooks.ts
|
|
8
13
|
class HookRegistry {
|
|
@@ -81,6 +86,8 @@ function matchesPattern(pattern, toolName) {
|
|
|
81
86
|
const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
82
87
|
return new RegExp(`^${escaped}$`).test(toolName);
|
|
83
88
|
}
|
|
89
|
+
var init_hooks = () => {};
|
|
90
|
+
|
|
84
91
|
// src/decisions/auto-capture.ts
|
|
85
92
|
function wrapToolHandler(toolName, handler, opts) {
|
|
86
93
|
return async (params) => {
|
|
@@ -134,6 +141,7 @@ function summarize(result) {
|
|
|
134
141
|
const str = typeof result === "string" ? result : JSON.stringify(result, null, 0);
|
|
135
142
|
return str.length > 500 ? str.slice(0, 500) + "\u2026" : str;
|
|
136
143
|
}
|
|
144
|
+
var init_auto_capture = () => {};
|
|
137
145
|
|
|
138
146
|
// src/decisions/index.ts
|
|
139
147
|
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
@@ -268,5 +276,11 @@ function getDecision(ctx, id) {
|
|
|
268
276
|
return null;
|
|
269
277
|
return buildDecision(ctx, eid);
|
|
270
278
|
}
|
|
279
|
+
var init_decisions = __esm(() => {
|
|
280
|
+
init_hooks();
|
|
281
|
+
init_auto_capture();
|
|
282
|
+
init_ops();
|
|
283
|
+
init_types();
|
|
284
|
+
});
|
|
271
285
|
|
|
272
|
-
export { HookRegistry, wrapToolHandler, recordDecision, queryDecisions, getDecisionChain, getDecision };
|
|
286
|
+
export { HookRegistry, wrapToolHandler, recordDecision, queryDecisions, getDecisionChain, getDecision, init_decisions };
|
|
@@ -15,12 +15,23 @@ var init_types = __esm(() => {
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
// src/embeddings/model.ts
|
|
18
|
+
async function importTransformers() {
|
|
19
|
+
try {
|
|
20
|
+
return await import("./transformers.node-bx3q9d7k.js");
|
|
21
|
+
} catch {
|
|
22
|
+
try {
|
|
23
|
+
return await import("@xenova/transformers");
|
|
24
|
+
} catch {
|
|
25
|
+
throw new Error("No transformers library found. Install @huggingface/transformers (recommended) or @xenova/transformers.");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
18
29
|
async function loadModel(config = DEFAULT_MODEL_CONFIG) {
|
|
19
30
|
if (pipeline)
|
|
20
31
|
return pipeline;
|
|
21
32
|
if (!loadPromise) {
|
|
22
33
|
loadPromise = (async () => {
|
|
23
|
-
const { pipeline: createPipeline } = await
|
|
34
|
+
const { pipeline: createPipeline } = await importTransformers();
|
|
24
35
|
const opts = {};
|
|
25
36
|
if (config.cacheDir) {
|
|
26
37
|
opts.cache_dir = config.cacheDir;
|
|
@@ -652,6 +663,156 @@ var init_search = __esm(() => {
|
|
|
652
663
|
init_chunker();
|
|
653
664
|
});
|
|
654
665
|
|
|
666
|
+
// src/embeddings/auto-embed.ts
|
|
667
|
+
function entitySummaryText(entityId, facts, links) {
|
|
668
|
+
const type = facts.find((f) => f.a === "type")?.v ?? "Entity";
|
|
669
|
+
const name = facts.find((f) => f.a === "name" || f.a === "title")?.v ?? entityId;
|
|
670
|
+
const parts = [`${type}: ${name} (${entityId})`];
|
|
671
|
+
const attrs = facts.filter((f) => !["type", "name", "title", "createdAt", "updatedAt"].includes(f.a));
|
|
672
|
+
if (attrs.length > 0) {
|
|
673
|
+
parts.push(attrs.map((f) => ` ${f.a} = ${f.v}`).join(`
|
|
674
|
+
`));
|
|
675
|
+
}
|
|
676
|
+
if (links.length > 0) {
|
|
677
|
+
parts.push("Relations:");
|
|
678
|
+
parts.push(links.map((l) => ` ${l.a} \u2192 ${l.e2}`).join(`
|
|
679
|
+
`));
|
|
680
|
+
}
|
|
681
|
+
return parts.join(`
|
|
682
|
+
`);
|
|
683
|
+
}
|
|
684
|
+
function createAutoEmbedMiddleware(options) {
|
|
685
|
+
const store = new VectorStore(options.dbPath);
|
|
686
|
+
const embedFn = options.embedFn ?? embed;
|
|
687
|
+
const embedIndividual = options.embedIndividualFacts ?? false;
|
|
688
|
+
return {
|
|
689
|
+
name: "auto-embed",
|
|
690
|
+
handleOp: async (op, ctx, next) => {
|
|
691
|
+
await next(op, ctx);
|
|
692
|
+
try {
|
|
693
|
+
await _processOp(op, store, embedFn, embedIndividual);
|
|
694
|
+
} catch {}
|
|
695
|
+
},
|
|
696
|
+
close: () => {
|
|
697
|
+
store.close();
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
async function _processOp(op, store, embedFn, embedIndividual) {
|
|
702
|
+
const now = new Date().toISOString();
|
|
703
|
+
const entityIds = new Set;
|
|
704
|
+
if (op.facts)
|
|
705
|
+
for (const f of op.facts)
|
|
706
|
+
entityIds.add(f.e);
|
|
707
|
+
if (op.links)
|
|
708
|
+
for (const l of op.links) {
|
|
709
|
+
entityIds.add(l.e1);
|
|
710
|
+
entityIds.add(l.e2);
|
|
711
|
+
}
|
|
712
|
+
if (op.deleteFacts)
|
|
713
|
+
for (const f of op.deleteFacts)
|
|
714
|
+
entityIds.add(f.e);
|
|
715
|
+
if (op.deleteLinks)
|
|
716
|
+
for (const l of op.deleteLinks) {
|
|
717
|
+
entityIds.add(l.e1);
|
|
718
|
+
entityIds.add(l.e2);
|
|
719
|
+
}
|
|
720
|
+
if (op.deleteFacts || op.deleteLinks) {
|
|
721
|
+
for (const eid of entityIds) {
|
|
722
|
+
store.deleteByEntity(eid);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (op.facts && op.facts.length > 0) {
|
|
726
|
+
const factsByEntity = new Map;
|
|
727
|
+
for (const f of op.facts) {
|
|
728
|
+
const existing = factsByEntity.get(f.e) ?? [];
|
|
729
|
+
existing.push(f);
|
|
730
|
+
factsByEntity.set(f.e, existing);
|
|
731
|
+
}
|
|
732
|
+
const linksByEntity = new Map;
|
|
733
|
+
if (op.links) {
|
|
734
|
+
for (const l of op.links) {
|
|
735
|
+
const existing = linksByEntity.get(l.e1) ?? [];
|
|
736
|
+
existing.push(l);
|
|
737
|
+
linksByEntity.set(l.e1, existing);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
const records = [];
|
|
741
|
+
for (const [eid, facts] of factsByEntity) {
|
|
742
|
+
const links = linksByEntity.get(eid) ?? [];
|
|
743
|
+
const summaryText = entitySummaryText(eid, facts, links);
|
|
744
|
+
if (summaryText.trim()) {
|
|
745
|
+
try {
|
|
746
|
+
const vector = await embedFn(summaryText);
|
|
747
|
+
records.push({
|
|
748
|
+
id: `entity:${eid}:summary`,
|
|
749
|
+
entityId: eid,
|
|
750
|
+
content: summaryText,
|
|
751
|
+
chunkType: "summary_md",
|
|
752
|
+
updatedAt: now,
|
|
753
|
+
embedding: vector
|
|
754
|
+
});
|
|
755
|
+
} catch {}
|
|
756
|
+
}
|
|
757
|
+
if (embedIndividual) {
|
|
758
|
+
for (const fact of facts) {
|
|
759
|
+
if (["type", "createdAt", "updatedAt"].includes(fact.a))
|
|
760
|
+
continue;
|
|
761
|
+
const text = `${fact.a}: ${fact.v}`;
|
|
762
|
+
try {
|
|
763
|
+
const vector = await embedFn(text);
|
|
764
|
+
records.push({
|
|
765
|
+
id: `entity:${eid}:fact:${fact.a}`,
|
|
766
|
+
entityId: eid,
|
|
767
|
+
content: text,
|
|
768
|
+
chunkType: "doc_comment",
|
|
769
|
+
updatedAt: now,
|
|
770
|
+
embedding: vector
|
|
771
|
+
});
|
|
772
|
+
} catch {}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
if (records.length > 0) {
|
|
777
|
+
store.upsertBatch(records);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
async function buildRAGContext(query, vectorStore, embedFn = embed, options) {
|
|
782
|
+
const maxChunks = options?.maxChunks ?? 10;
|
|
783
|
+
const maxTokens = options?.maxTokens ?? 4000;
|
|
784
|
+
const minScore = options?.minScore ?? 0.1;
|
|
785
|
+
const queryVector = await embedFn(query);
|
|
786
|
+
const results = vectorStore.search(queryVector, {
|
|
787
|
+
limit: maxChunks * 2,
|
|
788
|
+
minScore
|
|
789
|
+
});
|
|
790
|
+
const chunks = [];
|
|
791
|
+
let totalChars = 0;
|
|
792
|
+
for (const r of results) {
|
|
793
|
+
if (chunks.length >= maxChunks)
|
|
794
|
+
break;
|
|
795
|
+
if (totalChars + r.chunk.content.length > maxTokens * 4)
|
|
796
|
+
break;
|
|
797
|
+
chunks.push({
|
|
798
|
+
content: r.chunk.content,
|
|
799
|
+
entityId: r.chunk.entityId,
|
|
800
|
+
score: r.score,
|
|
801
|
+
chunkType: r.chunk.chunkType
|
|
802
|
+
});
|
|
803
|
+
totalChars += r.chunk.content.length;
|
|
804
|
+
}
|
|
805
|
+
return {
|
|
806
|
+
query,
|
|
807
|
+
chunks,
|
|
808
|
+
estimatedTokens: Math.ceil(totalChars / 4)
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
var init_auto_embed = __esm(() => {
|
|
812
|
+
init_store();
|
|
813
|
+
init_model();
|
|
814
|
+
});
|
|
815
|
+
|
|
655
816
|
// src/embeddings/index.ts
|
|
656
817
|
var exports_embeddings = {};
|
|
657
818
|
__export(exports_embeddings, {
|
|
@@ -660,6 +821,7 @@ __export(exports_embeddings, {
|
|
|
660
821
|
loadModel: () => loadModel,
|
|
661
822
|
embedBatch: () => embedBatch,
|
|
662
823
|
embed: () => embed,
|
|
824
|
+
createAutoEmbedMiddleware: () => createAutoEmbedMiddleware,
|
|
663
825
|
cosineSimilarity: () => cosineSimilarity,
|
|
664
826
|
chunkSummary: () => chunkSummary,
|
|
665
827
|
chunkMilestone: () => chunkMilestone,
|
|
@@ -669,6 +831,7 @@ __export(exports_embeddings, {
|
|
|
669
831
|
chunkDocComments: () => chunkDocComments,
|
|
670
832
|
chunkDecision: () => chunkDecision,
|
|
671
833
|
chunkCodeEntities: () => chunkCodeEntities,
|
|
834
|
+
buildRAGContext: () => buildRAGContext,
|
|
672
835
|
VectorStore: () => VectorStore,
|
|
673
836
|
EmbeddingManager: () => EmbeddingManager,
|
|
674
837
|
DEFAULT_MODEL_CONFIG: () => DEFAULT_MODEL_CONFIG
|
|
@@ -678,7 +841,8 @@ var init_embeddings = __esm(() => {
|
|
|
678
841
|
init_model();
|
|
679
842
|
init_store();
|
|
680
843
|
init_search();
|
|
844
|
+
init_auto_embed();
|
|
681
845
|
init_chunker();
|
|
682
846
|
});
|
|
683
847
|
|
|
684
|
-
export { DEFAULT_MODEL_CONFIG, loadModel, embed, embedBatch, resetModel, VectorStore, cosineSimilarity, chunkIssue, chunkDecision, chunkMilestone, chunkMarkdown, chunkCodeEntities, chunkDocComments, chunkSummary, chunkFile, slidingWindow, EmbeddingManager, exports_embeddings, init_embeddings };
|
|
848
|
+
export { DEFAULT_MODEL_CONFIG, loadModel, embed, embedBatch, resetModel, init_model, VectorStore, cosineSimilarity, init_store, chunkIssue, chunkDecision, chunkMilestone, chunkMarkdown, chunkCodeEntities, chunkDocComments, chunkSummary, chunkFile, slidingWindow, EmbeddingManager, createAutoEmbedMiddleware, buildRAGContext, init_auto_embed, exports_embeddings, init_embeddings };
|