@agent-wiki/mcp 0.21.0 → 0.21.3
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/cobol/__tests__/field-lineage.test.js +141 -1
- package/dist/cobol/__tests__/field-lineage.test.js.map +1 -1
- package/dist/cobol/__tests__/parser.test.js +32 -0
- package/dist/cobol/__tests__/parser.test.js.map +1 -1
- package/dist/cobol/field-lineage.d.ts +21 -0
- package/dist/cobol/field-lineage.d.ts.map +1 -1
- package/dist/cobol/field-lineage.js +104 -11
- package/dist/cobol/field-lineage.js.map +1 -1
- package/dist/cobol/parser.d.ts.map +1 -1
- package/dist/cobol/parser.js +7 -0
- package/dist/cobol/parser.js.map +1 -1
- package/dist/evidence-report.d.ts +10 -0
- package/dist/evidence-report.d.ts.map +1 -1
- package/dist/evidence-report.js +23 -1
- package/dist/evidence-report.js.map +1 -1
- package/dist/evidence-report.test.js +32 -0
- package/dist/evidence-report.test.js.map +1 -1
- package/dist/evidence.d.ts +17 -3
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +33 -4
- package/dist/evidence.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +54 -20
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +182 -0
- package/dist/server.test.js.map +1 -1
- package/docs/evidence-envelope.md +61 -2
- package/docs/tools.md +67 -1
- package/package.json +1 -1
package/dist/evidence.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* EvidenceEnvelope — unified evidence contract for retrieval / query tools.
|
|
3
3
|
*
|
|
4
|
-
* Phase 0 of the evidence-first program (#78)
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Originally introduced as Phase 0 of the evidence-first program (#78);
|
|
5
|
+
* Phases 1–4 have shipped with consumers across `wiki_search`,
|
|
6
|
+
* `wiki_search_read`, `code_*`, and `raw_read` / `raw_coverage`. See
|
|
7
|
+
* docs/evidence-envelope.md for the contract and adoption history.
|
|
7
8
|
*
|
|
8
9
|
* Strictly language-agnostic. Each plugin owns its own domain-tier-to-envelope
|
|
9
10
|
* mapping under its own `src/<plugin>/` directory. The core module never
|
|
@@ -12,5 +13,33 @@
|
|
|
12
13
|
* The envelope is purely additive on tool responses. Consumers branch on
|
|
13
14
|
* `confidence` and `abstain` without parsing tool-specific evidence detail.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Factory for the most common envelope shape: a successful round-trippable
|
|
18
|
+
* read or query backed by a parsed source. Strong + deterministic + not
|
|
19
|
+
* abstaining. Use when the result was derived directly from raw/ content
|
|
20
|
+
* with no inference layer.
|
|
21
|
+
*/
|
|
22
|
+
export function strongDeterministic(rationale, provenance = []) {
|
|
23
|
+
return {
|
|
24
|
+
confidence: "strong",
|
|
25
|
+
basis: "deterministic",
|
|
26
|
+
abstain: false,
|
|
27
|
+
rationale,
|
|
28
|
+
provenance,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Factory for the negative counterpart: the query was deterministic (we
|
|
33
|
+
* looked at the parsed source / corpus state) and found nothing. Absent +
|
|
34
|
+
* abstain so callers don't act on a vacuous response.
|
|
35
|
+
*/
|
|
36
|
+
export function absentDeterministic(rationale, provenance = []) {
|
|
37
|
+
return {
|
|
38
|
+
confidence: "absent",
|
|
39
|
+
basis: "deterministic",
|
|
40
|
+
abstain: true,
|
|
41
|
+
rationale,
|
|
42
|
+
provenance,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
16
45
|
//# sourceMappingURL=evidence.js.map
|
package/dist/evidence.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA2BH;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,aAAmC,EAAE;IAErC,OAAO;QACL,UAAU,EAAE,QAAQ;QACpB,KAAK,EAAE,eAAe;QACtB,OAAO,EAAE,KAAK;QACd,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,aAAmC,EAAE;IAErC,OAAO;QACL,UAAU,EAAE,QAAQ;QACpB,KAAK,EAAE,eAAe;QACtB,OAAO,EAAE,IAAI;QACb,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAcnE,OAAO,EAAE,IAAI,EAA4E,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAcnE,OAAO,EAAE,IAAI,EAA4E,MAAM,WAAW,CAAC;AAgB3G,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CA8qB1E;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAQtD,wGAAwG;AACxG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAOrF;AA8qBD,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0FAA0F;IAC1F,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAmHD,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,MAAM,GAAG,YAAY,EAAE,CAAC,CAk3ClC;AAID,wBAAsB,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBpF"}
|
package/dist/server.js
CHANGED
|
@@ -17,6 +17,7 @@ import { rotateEventLog, summarizeLastWeek } from "./evidence-write-log.js";
|
|
|
17
17
|
import { appendSearchEvent, rotateSearchLog } from "./evidence-search-log.js";
|
|
18
18
|
import { runEvidenceReport } from "./evidence-report.js";
|
|
19
19
|
import { migrateExistingPagesForEvidence } from "./evidence-migration.js";
|
|
20
|
+
import { absentDeterministic, strongDeterministic } from "./evidence.js";
|
|
20
21
|
import { join, resolve, basename, extname } from "node:path";
|
|
21
22
|
import { Wiki, splitSections, buildToc, findSectionByHeading, matchSimpleGlob, safePath } from "./wiki.js";
|
|
22
23
|
import { extractDocument, chunkSegments, guessMime } from "./extraction.js";
|
|
@@ -26,6 +27,7 @@ import { RequestQueue } from "./queue.js";
|
|
|
26
27
|
import { registerPlugin, getPlugin, getPluginForFile, listPlugins, summarizeModel } from "./code-analysis.js";
|
|
27
28
|
import { cobolPlugin } from "./cobol/plugin.js";
|
|
28
29
|
import { canonicalNodeId, deserializeGraph, displayLabel, graphEdgesFrom, graphImpactOf } from "./cobol/graph.js";
|
|
30
|
+
import { normalizeLoadedFieldLineage } from "./cobol/field-lineage.js";
|
|
29
31
|
// Register built-in plugins
|
|
30
32
|
registerPlugin(cobolPlugin);
|
|
31
33
|
export function createServer(wikiPath, workspace) {
|
|
@@ -782,7 +784,9 @@ async function loadFieldLineageArtifact(wiki, language) {
|
|
|
782
784
|
throw new Error(`Compiled field lineage not found for "${plugin.id}". Run code_parse on both ${plugin.id.toUpperCase()} program files (.cbl/.cob) AND copybook files (.cpy) — field lineage requires data from both to build the cross-file index.`);
|
|
783
785
|
}
|
|
784
786
|
try {
|
|
785
|
-
|
|
787
|
+
// Normalize pre-#30 artifacts that lack summary.diagnosticsByKind /
|
|
788
|
+
// diagnostics so the rest of the codebase can trust the typed shape.
|
|
789
|
+
return normalizeLoadedFieldLineage(JSON.parse(rawResult.content));
|
|
786
790
|
}
|
|
787
791
|
catch (err) {
|
|
788
792
|
throw new Error(`Failed to parse compiled field lineage for "${plugin.id}": ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -1459,14 +1463,19 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
1459
1463
|
sort: sortArg,
|
|
1460
1464
|
tag: args.tag,
|
|
1461
1465
|
});
|
|
1462
|
-
|
|
1466
|
+
// Coverage is computed by SHA-256 comparison between raw/ and wiki/
|
|
1467
|
+
// frontmatter `sources:` — round-trippable, no inference.
|
|
1468
|
+
const evidence = strongDeterministic(`Coverage ${report.coveredRaw}/${report.totalRaw} `
|
|
1469
|
+
+ `(${(report.coverageRatio * 100).toFixed(1)}%) computed via SHA-256 over raw/.`);
|
|
1470
|
+
return JSON.stringify({ ...report, evidence }, null, 2);
|
|
1463
1471
|
}
|
|
1464
1472
|
case "raw_versions": {
|
|
1465
1473
|
const result = wiki.rawVersions(args.filename);
|
|
1466
1474
|
return JSON.stringify({ versions: result.versions, latest: result.latest, count: result.versions.length }, null, 2);
|
|
1467
1475
|
}
|
|
1468
1476
|
case "raw_read": {
|
|
1469
|
-
const
|
|
1477
|
+
const filename = args.filename;
|
|
1478
|
+
const result = await wiki.rawRead(filename, {
|
|
1470
1479
|
pages: args.pages,
|
|
1471
1480
|
sheet: args.sheet,
|
|
1472
1481
|
offset: args.offset,
|
|
@@ -1474,11 +1483,14 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
1474
1483
|
});
|
|
1475
1484
|
if (!result)
|
|
1476
1485
|
throw new Error(`Raw file not found: ${args.filename}`);
|
|
1486
|
+
// Round-trippable file read: strong + deterministic across every shape
|
|
1487
|
+
// (text, paginated text, binary metadata, image with content block).
|
|
1488
|
+
const evidence = strongDeterministic(`Read raw/${filename} (${result.binary ? "binary" : "text"}).`, [{ raw: filename }]);
|
|
1477
1489
|
if (result.binary) {
|
|
1478
1490
|
if (result.imageData) {
|
|
1479
1491
|
// Return text first (consistent with raw_add/raw_fetch), then image block
|
|
1480
1492
|
return [
|
|
1481
|
-
{ type: "text", text: JSON.stringify({ meta: result.meta, binary: true }, null, 2) },
|
|
1493
|
+
{ type: "text", text: JSON.stringify({ meta: result.meta, binary: true, evidence }, null, 2) },
|
|
1482
1494
|
{ type: "image", data: result.imageData.data, mimeType: result.imageData.mimeType },
|
|
1483
1495
|
];
|
|
1484
1496
|
}
|
|
@@ -1486,6 +1498,7 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
1486
1498
|
meta: result.meta,
|
|
1487
1499
|
binary: true,
|
|
1488
1500
|
note: result.note ?? `Binary file (${result.meta?.mimeType ?? "unknown type"}, ${result.meta?.size != null ? result.meta.size + " bytes" : "unknown size"}). Content cannot be read as text. Use the file path directly if you need to process it.`,
|
|
1501
|
+
evidence,
|
|
1489
1502
|
}, null, 2);
|
|
1490
1503
|
}
|
|
1491
1504
|
const content = result.content;
|
|
@@ -1501,6 +1514,7 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
1501
1514
|
binary: false,
|
|
1502
1515
|
content: finalContent,
|
|
1503
1516
|
...(result.paginationMeta ? { pagination: result.paginationMeta } : {}),
|
|
1517
|
+
evidence,
|
|
1504
1518
|
}, null, 2);
|
|
1505
1519
|
}
|
|
1506
1520
|
// raw_verify removed — use wiki_lint instead (includes SHA-256 checks)
|
|
@@ -2110,6 +2124,12 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2110
2124
|
}
|
|
2111
2125
|
}
|
|
2112
2126
|
}
|
|
2127
|
+
// Parse is round-trippable — every artifact is derived from the source
|
|
2128
|
+
// file by the plugin's `parse` + `normalize`. Strong + deterministic
|
|
2129
|
+
// regardless of how many wiki pages or graph artifacts get rebuilt.
|
|
2130
|
+
const evidence = strongDeterministic(`Parsed ${filePath} via plugin "${plugin.id}": `
|
|
2131
|
+
+ `${normalized.units.length} unit(s), ${normalized.procedures.length} procedure(s), `
|
|
2132
|
+
+ `${normalized.symbols.length} symbol(s), ${normalized.relations.length} relation(s).`, [{ raw: filePath }]);
|
|
2113
2133
|
const output = {
|
|
2114
2134
|
summary,
|
|
2115
2135
|
normalizedModel: {
|
|
@@ -2120,6 +2140,7 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2120
2140
|
},
|
|
2121
2141
|
artifacts,
|
|
2122
2142
|
wikiPages: writtenPages,
|
|
2143
|
+
evidence,
|
|
2123
2144
|
};
|
|
2124
2145
|
if (variableTrace) {
|
|
2125
2146
|
output.variableTrace = variableTrace;
|
|
@@ -2153,20 +2174,8 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2153
2174
|
// Trace is intra-file structural lookup — strong when references found,
|
|
2154
2175
|
// absent + abstain when nothing matches the requested name.
|
|
2155
2176
|
const traceEnvelope = refs.length > 0
|
|
2156
|
-
? {
|
|
2157
|
-
|
|
2158
|
-
basis: "deterministic",
|
|
2159
|
-
abstain: false,
|
|
2160
|
-
rationale: `${refs.length} reference(s) to \`${varName}\` in ${filePath}.`,
|
|
2161
|
-
provenance: [{ raw: filePath }],
|
|
2162
|
-
}
|
|
2163
|
-
: {
|
|
2164
|
-
confidence: "absent",
|
|
2165
|
-
basis: "deterministic",
|
|
2166
|
-
abstain: true,
|
|
2167
|
-
rationale: `No references to \`${varName}\` found in ${filePath}.`,
|
|
2168
|
-
provenance: [{ raw: filePath }],
|
|
2169
|
-
};
|
|
2177
|
+
? strongDeterministic(`${refs.length} reference(s) to \`${varName}\` in ${filePath}.`, [{ raw: filePath }])
|
|
2178
|
+
: absentDeterministic(`No references to \`${varName}\` found in ${filePath}.`, [{ raw: filePath }]);
|
|
2170
2179
|
return JSON.stringify({ variable: varName, file: filePath, evidence: traceEnvelope, references: refs }, null, 2);
|
|
2171
2180
|
}
|
|
2172
2181
|
case "code_impact": {
|
|
@@ -2190,7 +2199,16 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2190
2199
|
const maxDepth = Math.min(50, Math.max(1, Math.floor(args.max_depth ?? 10)));
|
|
2191
2200
|
const model = await loadParsedNormalizedModel(wiki, filePath);
|
|
2192
2201
|
const response = buildProcedureFlowResponse(model, { path: filePath, procedure, procedureKind, maxDepth });
|
|
2193
|
-
|
|
2202
|
+
// Flow is read directly off the normalized model (deterministic). Empty
|
|
2203
|
+
// procedures sets means the file genuinely has no PROCEDURE DIVISION
|
|
2204
|
+
// bodies — absent + abstain so callers don't act on a vacuous response.
|
|
2205
|
+
const summary = response.summary;
|
|
2206
|
+
const hasContent = summary.sections + summary.paragraphs > 0;
|
|
2207
|
+
const evidence = hasContent
|
|
2208
|
+
? strongDeterministic(`Procedure flow for ${filePath}: ${summary.sections} section(s), `
|
|
2209
|
+
+ `${summary.paragraphs} paragraph(s), ${summary.performRelations} PERFORM relation(s).`, [{ raw: filePath }])
|
|
2210
|
+
: absentDeterministic(`${filePath} has no sections or paragraphs in the parsed model.`, [{ raw: filePath }]);
|
|
2211
|
+
return JSON.stringify({ ...response, evidence }, null, 2);
|
|
2194
2212
|
}
|
|
2195
2213
|
case "code_field_lineage": {
|
|
2196
2214
|
const language = (args.language ?? "cobol").trim().toLowerCase();
|
|
@@ -2259,14 +2277,23 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2259
2277
|
frontier = nextFields;
|
|
2260
2278
|
}
|
|
2261
2279
|
const allVisited = [...visited].filter((f) => f !== startField);
|
|
2280
|
+
const totalEdges = levels.reduce((s, l) => s + l.edges.length, 0);
|
|
2281
|
+
// Edges come directly from the parsed model's relations[] —
|
|
2282
|
+
// deterministic. Empty result means the field has no `dataflow` /
|
|
2283
|
+
// `call-param` neighbors in the requested direction → absent + abstain.
|
|
2284
|
+
const evidence = totalEdges > 0
|
|
2285
|
+
? strongDeterministic(`Transitive ${direction} dataflow from \`${startField}\` in ${filePath}: `
|
|
2286
|
+
+ `${allVisited.length} reachable field(s), ${totalEdges} edge(s).`, [{ raw: filePath }])
|
|
2287
|
+
: absentDeterministic(`No ${direction} dataflow edges from \`${startField}\` in ${filePath}.`, [{ raw: filePath }]);
|
|
2262
2288
|
return JSON.stringify({
|
|
2263
2289
|
file: filePath,
|
|
2264
2290
|
field: startField,
|
|
2265
2291
|
direction,
|
|
2266
2292
|
transitive: true,
|
|
2267
2293
|
total_fields: allVisited.length,
|
|
2268
|
-
total_edges:
|
|
2294
|
+
total_edges: totalEdges,
|
|
2269
2295
|
levels,
|
|
2296
|
+
evidence,
|
|
2270
2297
|
}, null, 2);
|
|
2271
2298
|
}
|
|
2272
2299
|
let edges = allEdges;
|
|
@@ -2274,10 +2301,17 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2274
2301
|
edges = edges.filter((r) => r.from === fromField);
|
|
2275
2302
|
if (toField)
|
|
2276
2303
|
edges = edges.filter((r) => r.to === toField);
|
|
2304
|
+
const filterDesc = [fromField && `from=\`${fromField}\``, toField && `to=\`${toField}\``]
|
|
2305
|
+
.filter(Boolean)
|
|
2306
|
+
.join(", ") || "no field filter";
|
|
2307
|
+
const evidence = edges.length > 0
|
|
2308
|
+
? strongDeterministic(`${edges.length} dataflow edge(s) in ${filePath} (${filterDesc}).`, [{ raw: filePath }])
|
|
2309
|
+
: absentDeterministic(`No dataflow edges match ${filterDesc} in ${filePath}.`, [{ raw: filePath }]);
|
|
2277
2310
|
return JSON.stringify({
|
|
2278
2311
|
file: filePath,
|
|
2279
2312
|
total: edges.length,
|
|
2280
2313
|
edges: edges.map(formatEdge),
|
|
2314
|
+
evidence,
|
|
2281
2315
|
}, null, 2);
|
|
2282
2316
|
}
|
|
2283
2317
|
// ═══ KNOWLEDGE INGESTION ═══
|