@agent-wiki/mcp 0.21.0 → 0.21.1

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.
@@ -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): interface only, no consumers
5
- * yet. Phase 1+ adopts incrementally per the adoption sequence in
6
- * docs/evidence-envelope.md.
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
@@ -29,4 +30,17 @@ export interface EvidenceEnvelope {
29
30
  abstain: boolean;
30
31
  rationale: string;
31
32
  }
33
+ /**
34
+ * Factory for the most common envelope shape: a successful round-trippable
35
+ * read or query backed by a parsed source. Strong + deterministic + not
36
+ * abstaining. Use when the result was derived directly from raw/ content
37
+ * with no inference layer.
38
+ */
39
+ export declare function strongDeterministic(rationale: string, provenance?: EvidenceProvenance[]): EvidenceEnvelope;
40
+ /**
41
+ * Factory for the negative counterpart: the query was deterministic (we
42
+ * looked at the parsed source / corpus state) and found nothing. Absent +
43
+ * abstain so callers don't act on a vacuous response.
44
+ */
45
+ export declare function absentDeterministic(rationale: string, provenance?: EvidenceProvenance[]): EvidenceEnvelope;
32
46
  //# sourceMappingURL=evidence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9D,MAAM,MAAM,aAAa,GACrB,eAAe,GACf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,kBAAkB,EAAO,GACpC,gBAAgB,CAQlB"}
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): interface only, no consumers
5
- * yet. Phase 1+ adopts incrementally per the adoption sequence in
6
- * docs/evidence-envelope.md.
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
- export {};
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
@@ -1 +1 @@
1
- {"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
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"}
@@ -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;AAe3G,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;AA4qBD,qDAAqD;AACrD,MAAM,WAAW,cAAc;IAC7B,wFAAwF;IACxF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,0FAA0F;IAC1F,gBAAg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C,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";
@@ -1459,14 +1460,19 @@ export async function handleTool(wiki, name, args, opts) {
1459
1460
  sort: sortArg,
1460
1461
  tag: args.tag,
1461
1462
  });
1462
- return JSON.stringify(report, null, 2);
1463
+ // Coverage is computed by SHA-256 comparison between raw/ and wiki/
1464
+ // frontmatter `sources:` — round-trippable, no inference.
1465
+ const evidence = strongDeterministic(`Coverage ${report.coveredRaw}/${report.totalRaw} `
1466
+ + `(${(report.coverageRatio * 100).toFixed(1)}%) computed via SHA-256 over raw/.`);
1467
+ return JSON.stringify({ ...report, evidence }, null, 2);
1463
1468
  }
1464
1469
  case "raw_versions": {
1465
1470
  const result = wiki.rawVersions(args.filename);
1466
1471
  return JSON.stringify({ versions: result.versions, latest: result.latest, count: result.versions.length }, null, 2);
1467
1472
  }
1468
1473
  case "raw_read": {
1469
- const result = await wiki.rawRead(args.filename, {
1474
+ const filename = args.filename;
1475
+ const result = await wiki.rawRead(filename, {
1470
1476
  pages: args.pages,
1471
1477
  sheet: args.sheet,
1472
1478
  offset: args.offset,
@@ -1474,11 +1480,14 @@ export async function handleTool(wiki, name, args, opts) {
1474
1480
  });
1475
1481
  if (!result)
1476
1482
  throw new Error(`Raw file not found: ${args.filename}`);
1483
+ // Round-trippable file read: strong + deterministic across every shape
1484
+ // (text, paginated text, binary metadata, image with content block).
1485
+ const evidence = strongDeterministic(`Read raw/${filename} (${result.binary ? "binary" : "text"}).`, [{ raw: filename }]);
1477
1486
  if (result.binary) {
1478
1487
  if (result.imageData) {
1479
1488
  // Return text first (consistent with raw_add/raw_fetch), then image block
1480
1489
  return [
1481
- { type: "text", text: JSON.stringify({ meta: result.meta, binary: true }, null, 2) },
1490
+ { type: "text", text: JSON.stringify({ meta: result.meta, binary: true, evidence }, null, 2) },
1482
1491
  { type: "image", data: result.imageData.data, mimeType: result.imageData.mimeType },
1483
1492
  ];
1484
1493
  }
@@ -1486,6 +1495,7 @@ export async function handleTool(wiki, name, args, opts) {
1486
1495
  meta: result.meta,
1487
1496
  binary: true,
1488
1497
  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.`,
1498
+ evidence,
1489
1499
  }, null, 2);
1490
1500
  }
1491
1501
  const content = result.content;
@@ -1501,6 +1511,7 @@ export async function handleTool(wiki, name, args, opts) {
1501
1511
  binary: false,
1502
1512
  content: finalContent,
1503
1513
  ...(result.paginationMeta ? { pagination: result.paginationMeta } : {}),
1514
+ evidence,
1504
1515
  }, null, 2);
1505
1516
  }
1506
1517
  // raw_verify removed — use wiki_lint instead (includes SHA-256 checks)
@@ -2110,6 +2121,12 @@ export async function handleTool(wiki, name, args, opts) {
2110
2121
  }
2111
2122
  }
2112
2123
  }
2124
+ // Parse is round-trippable — every artifact is derived from the source
2125
+ // file by the plugin's `parse` + `normalize`. Strong + deterministic
2126
+ // regardless of how many wiki pages or graph artifacts get rebuilt.
2127
+ const evidence = strongDeterministic(`Parsed ${filePath} via plugin "${plugin.id}": `
2128
+ + `${normalized.units.length} unit(s), ${normalized.procedures.length} procedure(s), `
2129
+ + `${normalized.symbols.length} symbol(s), ${normalized.relations.length} relation(s).`, [{ raw: filePath }]);
2113
2130
  const output = {
2114
2131
  summary,
2115
2132
  normalizedModel: {
@@ -2120,6 +2137,7 @@ export async function handleTool(wiki, name, args, opts) {
2120
2137
  },
2121
2138
  artifacts,
2122
2139
  wikiPages: writtenPages,
2140
+ evidence,
2123
2141
  };
2124
2142
  if (variableTrace) {
2125
2143
  output.variableTrace = variableTrace;
@@ -2153,20 +2171,8 @@ export async function handleTool(wiki, name, args, opts) {
2153
2171
  // Trace is intra-file structural lookup — strong when references found,
2154
2172
  // absent + abstain when nothing matches the requested name.
2155
2173
  const traceEnvelope = refs.length > 0
2156
- ? {
2157
- confidence: "strong",
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
- };
2174
+ ? strongDeterministic(`${refs.length} reference(s) to \`${varName}\` in ${filePath}.`, [{ raw: filePath }])
2175
+ : absentDeterministic(`No references to \`${varName}\` found in ${filePath}.`, [{ raw: filePath }]);
2170
2176
  return JSON.stringify({ variable: varName, file: filePath, evidence: traceEnvelope, references: refs }, null, 2);
2171
2177
  }
2172
2178
  case "code_impact": {
@@ -2190,7 +2196,16 @@ export async function handleTool(wiki, name, args, opts) {
2190
2196
  const maxDepth = Math.min(50, Math.max(1, Math.floor(args.max_depth ?? 10)));
2191
2197
  const model = await loadParsedNormalizedModel(wiki, filePath);
2192
2198
  const response = buildProcedureFlowResponse(model, { path: filePath, procedure, procedureKind, maxDepth });
2193
- return JSON.stringify(response, null, 2);
2199
+ // Flow is read directly off the normalized model (deterministic). Empty
2200
+ // procedures sets means the file genuinely has no PROCEDURE DIVISION
2201
+ // bodies — absent + abstain so callers don't act on a vacuous response.
2202
+ const summary = response.summary;
2203
+ const hasContent = summary.sections + summary.paragraphs > 0;
2204
+ const evidence = hasContent
2205
+ ? strongDeterministic(`Procedure flow for ${filePath}: ${summary.sections} section(s), `
2206
+ + `${summary.paragraphs} paragraph(s), ${summary.performRelations} PERFORM relation(s).`, [{ raw: filePath }])
2207
+ : absentDeterministic(`${filePath} has no sections or paragraphs in the parsed model.`, [{ raw: filePath }]);
2208
+ return JSON.stringify({ ...response, evidence }, null, 2);
2194
2209
  }
2195
2210
  case "code_field_lineage": {
2196
2211
  const language = (args.language ?? "cobol").trim().toLowerCase();
@@ -2259,14 +2274,23 @@ export async function handleTool(wiki, name, args, opts) {
2259
2274
  frontier = nextFields;
2260
2275
  }
2261
2276
  const allVisited = [...visited].filter((f) => f !== startField);
2277
+ const totalEdges = levels.reduce((s, l) => s + l.edges.length, 0);
2278
+ // Edges come directly from the parsed model's relations[] —
2279
+ // deterministic. Empty result means the field has no `dataflow` /
2280
+ // `call-param` neighbors in the requested direction → absent + abstain.
2281
+ const evidence = totalEdges > 0
2282
+ ? strongDeterministic(`Transitive ${direction} dataflow from \`${startField}\` in ${filePath}: `
2283
+ + `${allVisited.length} reachable field(s), ${totalEdges} edge(s).`, [{ raw: filePath }])
2284
+ : absentDeterministic(`No ${direction} dataflow edges from \`${startField}\` in ${filePath}.`, [{ raw: filePath }]);
2262
2285
  return JSON.stringify({
2263
2286
  file: filePath,
2264
2287
  field: startField,
2265
2288
  direction,
2266
2289
  transitive: true,
2267
2290
  total_fields: allVisited.length,
2268
- total_edges: levels.reduce((s, l) => s + l.edges.length, 0),
2291
+ total_edges: totalEdges,
2269
2292
  levels,
2293
+ evidence,
2270
2294
  }, null, 2);
2271
2295
  }
2272
2296
  let edges = allEdges;
@@ -2274,10 +2298,17 @@ export async function handleTool(wiki, name, args, opts) {
2274
2298
  edges = edges.filter((r) => r.from === fromField);
2275
2299
  if (toField)
2276
2300
  edges = edges.filter((r) => r.to === toField);
2301
+ const filterDesc = [fromField && `from=\`${fromField}\``, toField && `to=\`${toField}\``]
2302
+ .filter(Boolean)
2303
+ .join(", ") || "no field filter";
2304
+ const evidence = edges.length > 0
2305
+ ? strongDeterministic(`${edges.length} dataflow edge(s) in ${filePath} (${filterDesc}).`, [{ raw: filePath }])
2306
+ : absentDeterministic(`No dataflow edges match ${filterDesc} in ${filePath}.`, [{ raw: filePath }]);
2277
2307
  return JSON.stringify({
2278
2308
  file: filePath,
2279
2309
  total: edges.length,
2280
2310
  edges: edges.map(formatEdge),
2311
+ evidence,
2281
2312
  }, null, 2);
2282
2313
  }
2283
2314
  // ═══ KNOWLEDGE INGESTION ═══