@swarmvaultai/engine 0.1.9 → 0.1.11
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/index.js +86 -86
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1059,7 +1059,7 @@ import fs10 from "fs/promises";
|
|
|
1059
1059
|
import path14 from "path";
|
|
1060
1060
|
import { McpServer, ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
1061
1061
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
1062
|
-
import { z as
|
|
1062
|
+
import { z as z7 } from "zod";
|
|
1063
1063
|
|
|
1064
1064
|
// src/schema.ts
|
|
1065
1065
|
import fs4 from "fs/promises";
|
|
@@ -1172,7 +1172,7 @@ function buildSchemaPrompt(schema, instruction) {
|
|
|
1172
1172
|
import fs9 from "fs/promises";
|
|
1173
1173
|
import path13 from "path";
|
|
1174
1174
|
import matter7 from "gray-matter";
|
|
1175
|
-
import { z as
|
|
1175
|
+
import { z as z6 } from "zod";
|
|
1176
1176
|
|
|
1177
1177
|
// src/analysis.ts
|
|
1178
1178
|
import path6 from "path";
|
|
@@ -1407,10 +1407,9 @@ function conflictConfidence(claimA, claimB) {
|
|
|
1407
1407
|
import fs5 from "fs/promises";
|
|
1408
1408
|
import path9 from "path";
|
|
1409
1409
|
import matter2 from "gray-matter";
|
|
1410
|
-
import { z as
|
|
1410
|
+
import { z as z4 } from "zod";
|
|
1411
1411
|
|
|
1412
1412
|
// src/findings.ts
|
|
1413
|
-
import { z as z2 } from "zod";
|
|
1414
1413
|
function normalizeFindingSeverity(value) {
|
|
1415
1414
|
if (typeof value !== "string") {
|
|
1416
1415
|
return "info";
|
|
@@ -1424,29 +1423,28 @@ function normalizeFindingSeverity(value) {
|
|
|
1424
1423
|
}
|
|
1425
1424
|
return "info";
|
|
1426
1425
|
}
|
|
1427
|
-
var findingSeveritySchema = z2.any().transform((value) => normalizeFindingSeverity(value));
|
|
1428
1426
|
|
|
1429
1427
|
// src/orchestration.ts
|
|
1430
1428
|
import { spawn } from "child_process";
|
|
1431
1429
|
import path7 from "path";
|
|
1432
|
-
import { z as
|
|
1433
|
-
var orchestrationRoleResultSchema =
|
|
1434
|
-
summary:
|
|
1435
|
-
findings:
|
|
1436
|
-
|
|
1437
|
-
severity:
|
|
1438
|
-
message:
|
|
1439
|
-
relatedPageIds:
|
|
1440
|
-
relatedSourceIds:
|
|
1441
|
-
suggestedQuery:
|
|
1430
|
+
import { z as z2 } from "zod";
|
|
1431
|
+
var orchestrationRoleResultSchema = z2.object({
|
|
1432
|
+
summary: z2.string().optional(),
|
|
1433
|
+
findings: z2.array(
|
|
1434
|
+
z2.object({
|
|
1435
|
+
severity: z2.string().optional().default("info"),
|
|
1436
|
+
message: z2.string().min(1),
|
|
1437
|
+
relatedPageIds: z2.array(z2.string()).optional(),
|
|
1438
|
+
relatedSourceIds: z2.array(z2.string()).optional(),
|
|
1439
|
+
suggestedQuery: z2.string().optional()
|
|
1442
1440
|
})
|
|
1443
1441
|
).default([]),
|
|
1444
|
-
questions:
|
|
1445
|
-
proposals:
|
|
1446
|
-
|
|
1447
|
-
path:
|
|
1448
|
-
content:
|
|
1449
|
-
reason:
|
|
1442
|
+
questions: z2.array(z2.string().min(1)).default([]),
|
|
1443
|
+
proposals: z2.array(
|
|
1444
|
+
z2.object({
|
|
1445
|
+
path: z2.string().min(1),
|
|
1446
|
+
content: z2.string().min(1),
|
|
1447
|
+
reason: z2.string().min(1)
|
|
1450
1448
|
})
|
|
1451
1449
|
).default([])
|
|
1452
1450
|
});
|
|
@@ -1514,7 +1512,7 @@ async function runProviderRole(rootDir, role, roleConfig, input) {
|
|
|
1514
1512
|
return {
|
|
1515
1513
|
role,
|
|
1516
1514
|
summary: result.summary,
|
|
1517
|
-
findings: result.findings.map((finding) => ({ role, ...finding })),
|
|
1515
|
+
findings: result.findings.map((finding) => ({ role, ...finding, severity: normalizeFindingSeverity(finding.severity) })),
|
|
1518
1516
|
questions: result.questions,
|
|
1519
1517
|
proposals: result.proposals
|
|
1520
1518
|
};
|
|
@@ -1566,7 +1564,7 @@ async function runCommandRole(rootDir, role, executor, input) {
|
|
|
1566
1564
|
return {
|
|
1567
1565
|
role,
|
|
1568
1566
|
summary: parsed.summary,
|
|
1569
|
-
findings: parsed.findings.map((finding) => ({ role, ...finding })),
|
|
1567
|
+
findings: parsed.findings.map((finding) => ({ role, ...finding, severity: normalizeFindingSeverity(finding.severity) })),
|
|
1570
1568
|
questions: parsed.questions,
|
|
1571
1569
|
proposals: parsed.proposals
|
|
1572
1570
|
};
|
|
@@ -1617,7 +1615,7 @@ function summarizeRoleQuestions(results) {
|
|
|
1617
1615
|
// src/web-search/registry.ts
|
|
1618
1616
|
import path8 from "path";
|
|
1619
1617
|
import { pathToFileURL } from "url";
|
|
1620
|
-
import { z as
|
|
1618
|
+
import { z as z3 } from "zod";
|
|
1621
1619
|
|
|
1622
1620
|
// src/web-search/http-json.ts
|
|
1623
1621
|
function deepGet(value, pathValue) {
|
|
@@ -1699,10 +1697,10 @@ var HttpJsonWebSearchAdapter = class {
|
|
|
1699
1697
|
};
|
|
1700
1698
|
|
|
1701
1699
|
// src/web-search/registry.ts
|
|
1702
|
-
var customWebSearchModuleSchema =
|
|
1703
|
-
createAdapter:
|
|
1704
|
-
input: [
|
|
1705
|
-
output:
|
|
1700
|
+
var customWebSearchModuleSchema = z3.object({
|
|
1701
|
+
createAdapter: z3.function({
|
|
1702
|
+
input: [z3.string(), z3.custom(), z3.string()],
|
|
1703
|
+
output: z3.promise(z3.custom())
|
|
1706
1704
|
})
|
|
1707
1705
|
});
|
|
1708
1706
|
async function createWebSearchAdapter(id, config, rootDir) {
|
|
@@ -1737,15 +1735,15 @@ async function getWebSearchAdapterForTask(rootDir, task) {
|
|
|
1737
1735
|
}
|
|
1738
1736
|
|
|
1739
1737
|
// src/deep-lint.ts
|
|
1740
|
-
var deepLintResponseSchema =
|
|
1741
|
-
findings:
|
|
1742
|
-
|
|
1743
|
-
severity:
|
|
1744
|
-
code:
|
|
1745
|
-
message:
|
|
1746
|
-
relatedSourceIds:
|
|
1747
|
-
relatedPageIds:
|
|
1748
|
-
suggestedQuery:
|
|
1738
|
+
var deepLintResponseSchema = z4.object({
|
|
1739
|
+
findings: z4.array(
|
|
1740
|
+
z4.object({
|
|
1741
|
+
severity: z4.string().optional().default("info"),
|
|
1742
|
+
code: z4.enum(["coverage_gap", "contradiction_candidate", "missing_citation", "candidate_page", "follow_up_question"]),
|
|
1743
|
+
message: z4.string().min(1),
|
|
1744
|
+
relatedSourceIds: z4.array(z4.string()).default([]),
|
|
1745
|
+
relatedPageIds: z4.array(z4.string()).default([]),
|
|
1746
|
+
suggestedQuery: z4.string().optional()
|
|
1749
1747
|
})
|
|
1750
1748
|
).max(20)
|
|
1751
1749
|
});
|
|
@@ -1912,7 +1910,7 @@ async function runDeepLint(rootDir, structuralFindings, options = {}) {
|
|
|
1912
1910
|
deepLintResponseSchema
|
|
1913
1911
|
);
|
|
1914
1912
|
findings = response.findings.map((item) => ({
|
|
1915
|
-
severity: item.severity,
|
|
1913
|
+
severity: normalizeFindingSeverity(item.severity),
|
|
1916
1914
|
code: item.code,
|
|
1917
1915
|
message: item.message,
|
|
1918
1916
|
relatedSourceIds: item.relatedSourceIds,
|
|
@@ -2805,49 +2803,49 @@ function buildExploreHubPage(input) {
|
|
|
2805
2803
|
}
|
|
2806
2804
|
|
|
2807
2805
|
// src/output-artifacts.ts
|
|
2808
|
-
import { z as
|
|
2806
|
+
import { z as z5 } from "zod";
|
|
2809
2807
|
function escapeXml(value) {
|
|
2810
2808
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2811
2809
|
}
|
|
2812
2810
|
function clampNumber(value, min, max) {
|
|
2813
2811
|
return Math.min(max, Math.max(min, value));
|
|
2814
2812
|
}
|
|
2815
|
-
var chartSpecSchema =
|
|
2816
|
-
kind:
|
|
2817
|
-
title:
|
|
2818
|
-
subtitle:
|
|
2819
|
-
xLabel:
|
|
2820
|
-
yLabel:
|
|
2821
|
-
seriesLabel:
|
|
2822
|
-
data:
|
|
2823
|
-
|
|
2824
|
-
label:
|
|
2825
|
-
value:
|
|
2813
|
+
var chartSpecSchema = z5.object({
|
|
2814
|
+
kind: z5.enum(["bar", "line"]).default("bar"),
|
|
2815
|
+
title: z5.string().min(1),
|
|
2816
|
+
subtitle: z5.string().optional(),
|
|
2817
|
+
xLabel: z5.string().optional(),
|
|
2818
|
+
yLabel: z5.string().optional(),
|
|
2819
|
+
seriesLabel: z5.string().optional(),
|
|
2820
|
+
data: z5.array(
|
|
2821
|
+
z5.object({
|
|
2822
|
+
label: z5.string().min(1),
|
|
2823
|
+
value: z5.number().finite()
|
|
2826
2824
|
})
|
|
2827
2825
|
).min(2).max(12),
|
|
2828
|
-
notes:
|
|
2826
|
+
notes: z5.array(z5.string().min(1)).max(5).optional()
|
|
2829
2827
|
});
|
|
2830
|
-
var sceneSpecSchema =
|
|
2831
|
-
title:
|
|
2832
|
-
alt:
|
|
2833
|
-
background:
|
|
2834
|
-
width:
|
|
2835
|
-
height:
|
|
2836
|
-
elements:
|
|
2837
|
-
|
|
2838
|
-
kind:
|
|
2839
|
-
shape:
|
|
2840
|
-
x:
|
|
2841
|
-
y:
|
|
2842
|
-
width:
|
|
2843
|
-
height:
|
|
2844
|
-
radius:
|
|
2845
|
-
text:
|
|
2846
|
-
fontSize:
|
|
2847
|
-
fill:
|
|
2848
|
-
stroke:
|
|
2849
|
-
strokeWidth:
|
|
2850
|
-
opacity:
|
|
2828
|
+
var sceneSpecSchema = z5.object({
|
|
2829
|
+
title: z5.string().min(1),
|
|
2830
|
+
alt: z5.string().min(1),
|
|
2831
|
+
background: z5.string().optional(),
|
|
2832
|
+
width: z5.number().int().positive().max(2400).optional(),
|
|
2833
|
+
height: z5.number().int().positive().max(2400).optional(),
|
|
2834
|
+
elements: z5.array(
|
|
2835
|
+
z5.object({
|
|
2836
|
+
kind: z5.enum(["shape", "label"]),
|
|
2837
|
+
shape: z5.enum(["rect", "circle", "line"]).optional(),
|
|
2838
|
+
x: z5.number().finite(),
|
|
2839
|
+
y: z5.number().finite(),
|
|
2840
|
+
width: z5.number().finite().optional(),
|
|
2841
|
+
height: z5.number().finite().optional(),
|
|
2842
|
+
radius: z5.number().finite().optional(),
|
|
2843
|
+
text: z5.string().optional(),
|
|
2844
|
+
fontSize: z5.number().finite().optional(),
|
|
2845
|
+
fill: z5.string().optional(),
|
|
2846
|
+
stroke: z5.string().optional(),
|
|
2847
|
+
strokeWidth: z5.number().finite().optional(),
|
|
2848
|
+
opacity: z5.number().finite().optional()
|
|
2851
2849
|
})
|
|
2852
2850
|
).min(1).max(32)
|
|
2853
2851
|
});
|
|
@@ -4607,6 +4605,7 @@ async function syncVaultArtifacts(rootDir, input) {
|
|
|
4607
4605
|
const promotedPageIds = [];
|
|
4608
4606
|
const candidateHistory = {};
|
|
4609
4607
|
const records = [];
|
|
4608
|
+
const promoteCandidates = input.promoteCandidates ?? true;
|
|
4610
4609
|
for (const manifest of input.manifests) {
|
|
4611
4610
|
const analysis = input.analyses.find((item) => item.sourceId === manifest.sourceId);
|
|
4612
4611
|
if (!analysis) {
|
|
@@ -4725,7 +4724,7 @@ async function syncVaultArtifacts(rootDir, input) {
|
|
|
4725
4724
|
const projectIds = scopedProjectIdsFromSources(sourceIds, input.sourceProjects);
|
|
4726
4725
|
const schemaHash = effectiveHashForProject(input.schemas, projectIds[0] ?? null);
|
|
4727
4726
|
const previousEntry = input.previousState?.candidateHistory?.[pageId];
|
|
4728
|
-
const promoted = previousEntry?.status === "active" || shouldPromoteCandidate(previousEntry, sourceIds);
|
|
4727
|
+
const promoted = previousEntry?.status === "active" || promoteCandidates && shouldPromoteCandidate(previousEntry, sourceIds);
|
|
4729
4728
|
const relativePath = promoted ? activeAggregatePath(itemKind, slug) : candidatePagePathFor(itemKind, slug);
|
|
4730
4729
|
const fallbackPaths = [
|
|
4731
4730
|
path13.join(paths.wikiDir, activeAggregatePath(itemKind, slug)),
|
|
@@ -5333,8 +5332,8 @@ async function generateFollowUpQuestions(rootDir, question, answer) {
|
|
|
5333
5332
|
Current answer:
|
|
5334
5333
|
${answer}`
|
|
5335
5334
|
},
|
|
5336
|
-
|
|
5337
|
-
questions:
|
|
5335
|
+
z6.object({
|
|
5336
|
+
questions: z6.array(z6.string().min(1)).max(5)
|
|
5338
5337
|
})
|
|
5339
5338
|
);
|
|
5340
5339
|
return uniqueBy(response.questions, (item) => item).filter((item) => item !== question);
|
|
@@ -5357,7 +5356,8 @@ async function refreshVaultAfterOutputSave(rootDir) {
|
|
|
5357
5356
|
outputHashes: pageHashes(storedOutputs),
|
|
5358
5357
|
insightHashes: pageHashes(storedInsights),
|
|
5359
5358
|
previousState: await readJsonFile(paths.compileStatePath),
|
|
5360
|
-
approve: false
|
|
5359
|
+
approve: false,
|
|
5360
|
+
promoteCandidates: false
|
|
5361
5361
|
});
|
|
5362
5362
|
}
|
|
5363
5363
|
function resolveApprovalTargets(manifest, targets) {
|
|
@@ -6531,7 +6531,7 @@ async function bootstrapDemo(rootDir, input) {
|
|
|
6531
6531
|
}
|
|
6532
6532
|
|
|
6533
6533
|
// src/mcp.ts
|
|
6534
|
-
var SERVER_VERSION = "0.1.
|
|
6534
|
+
var SERVER_VERSION = "0.1.11";
|
|
6535
6535
|
async function createMcpServer(rootDir) {
|
|
6536
6536
|
const server = new McpServer({
|
|
6537
6537
|
name: "swarmvault",
|
|
@@ -6553,8 +6553,8 @@ async function createMcpServer(rootDir) {
|
|
|
6553
6553
|
{
|
|
6554
6554
|
description: "Search compiled wiki pages using the local full-text index.",
|
|
6555
6555
|
inputSchema: {
|
|
6556
|
-
query:
|
|
6557
|
-
limit:
|
|
6556
|
+
query: z7.string().min(1).describe("Search query"),
|
|
6557
|
+
limit: z7.number().int().min(1).max(25).optional().describe("Maximum number of results")
|
|
6558
6558
|
}
|
|
6559
6559
|
},
|
|
6560
6560
|
async ({ query, limit }) => {
|
|
@@ -6567,7 +6567,7 @@ async function createMcpServer(rootDir) {
|
|
|
6567
6567
|
{
|
|
6568
6568
|
description: "Read a generated wiki page by its path relative to wiki/.",
|
|
6569
6569
|
inputSchema: {
|
|
6570
|
-
path:
|
|
6570
|
+
path: z7.string().min(1).describe("Path relative to wiki/, for example sources/example.md")
|
|
6571
6571
|
}
|
|
6572
6572
|
},
|
|
6573
6573
|
async ({ path: relativePath }) => {
|
|
@@ -6583,7 +6583,7 @@ async function createMcpServer(rootDir) {
|
|
|
6583
6583
|
{
|
|
6584
6584
|
description: "List source manifests in the current workspace.",
|
|
6585
6585
|
inputSchema: {
|
|
6586
|
-
limit:
|
|
6586
|
+
limit: z7.number().int().min(1).max(100).optional().describe("Maximum number of manifests to return")
|
|
6587
6587
|
}
|
|
6588
6588
|
},
|
|
6589
6589
|
async ({ limit }) => {
|
|
@@ -6596,9 +6596,9 @@ async function createMcpServer(rootDir) {
|
|
|
6596
6596
|
{
|
|
6597
6597
|
description: "Ask a question against the compiled vault and optionally save the answer.",
|
|
6598
6598
|
inputSchema: {
|
|
6599
|
-
question:
|
|
6600
|
-
save:
|
|
6601
|
-
format:
|
|
6599
|
+
question: z7.string().min(1).describe("Question to ask the vault"),
|
|
6600
|
+
save: z7.boolean().optional().describe("Persist the answer to wiki/outputs"),
|
|
6601
|
+
format: z7.enum(["markdown", "report", "slides", "chart", "image"]).optional().describe("Output format")
|
|
6602
6602
|
}
|
|
6603
6603
|
},
|
|
6604
6604
|
async ({ question, save, format }) => {
|
|
@@ -6615,7 +6615,7 @@ async function createMcpServer(rootDir) {
|
|
|
6615
6615
|
{
|
|
6616
6616
|
description: "Ingest a local file path or URL into the SwarmVault workspace.",
|
|
6617
6617
|
inputSchema: {
|
|
6618
|
-
input:
|
|
6618
|
+
input: z7.string().min(1).describe("Local path or URL to ingest")
|
|
6619
6619
|
}
|
|
6620
6620
|
},
|
|
6621
6621
|
async ({ input }) => {
|
|
@@ -6628,7 +6628,7 @@ async function createMcpServer(rootDir) {
|
|
|
6628
6628
|
{
|
|
6629
6629
|
description: "Compile source manifests into wiki pages, graph data, and search index.",
|
|
6630
6630
|
inputSchema: {
|
|
6631
|
-
approve:
|
|
6631
|
+
approve: z7.boolean().optional().describe("Stage a review bundle without applying active page changes")
|
|
6632
6632
|
}
|
|
6633
6633
|
},
|
|
6634
6634
|
async ({ approve }) => {
|