@agent-wiki/mcp 0.22.2 → 0.22.4
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/README.md +19 -1
- package/dist/cobol/__tests__/parser.test.js +134 -0
- package/dist/cobol/__tests__/parser.test.js.map +1 -1
- package/dist/cobol/parser.d.ts.map +1 -1
- package/dist/cobol/parser.js +50 -4
- package/dist/cobol/parser.js.map +1 -1
- package/dist/evidence-report.d.ts +53 -1
- package/dist/evidence-report.d.ts.map +1 -1
- package/dist/evidence-report.js +182 -3
- package/dist/evidence-report.js.map +1 -1
- package/dist/evidence-report.test.js +176 -0
- package/dist/evidence-report.test.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +143 -35
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +76 -0
- package/dist/server.test.js.map +1 -1
- package/docs/evidence-envelope.md +21 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -358,9 +358,9 @@ export function createServer(wikiPath, workspace) {
|
|
|
358
358
|
description: "Wiki administration and maintenance. Select `action` to control behavior:\n" +
|
|
359
359
|
"- `init`: Initialize a new knowledge base — creates wiki/, raw/, schemas/ directories and default templates.\n" +
|
|
360
360
|
"- `config`: Show current workspace configuration: directories, lint settings, search settings, entity templates.\n" +
|
|
361
|
-
"- `rebuild`: Rebuild index.md, timeline.md, code knowledge graphs, and optionally the vector index (when search.hybrid is enabled).\n" +
|
|
361
|
+
"- `rebuild`: Rebuild index.md, timeline.md, code knowledge graphs, and optionally the vector index (when search.hybrid is enabled). Set evidence_report=true to also regenerate the evidence report and persist it to wiki/evidence-report.md as part of the rebuild.\n" +
|
|
362
362
|
"- `lint`: Run comprehensive health checks: contradictions, orphan pages, broken links, raw file integrity (SHA-256), synthesis page integrity. Set apply_fixes=true to auto-repair fixable issues.\n" +
|
|
363
|
-
"- `evidence-report`: Aggregate evidence-first telemetry into a corpus-level Markdown report (source coverage, lineage diagnostics, 4-week write trend). Set write=true to also persist the report to wiki/evidence-report.md.",
|
|
363
|
+
"- `evidence-report`: Aggregate evidence-first telemetry into a corpus-level Markdown report (source coverage, lineage diagnostics, 4-week write trend, Phase 2b readiness gates). Set write=true to also persist the report to wiki/evidence-report.md.",
|
|
364
364
|
inputSchema: {
|
|
365
365
|
type: "object",
|
|
366
366
|
properties: {
|
|
@@ -385,6 +385,10 @@ export function createServer(wikiPath, workspace) {
|
|
|
385
385
|
type: "boolean",
|
|
386
386
|
description: "[evidence-report] If true, persist the report to wiki/evidence-report.md in addition to returning it. Default: false.",
|
|
387
387
|
},
|
|
388
|
+
evidence_report: {
|
|
389
|
+
type: "boolean",
|
|
390
|
+
description: "[rebuild] If true, also regenerate the evidence report and persist it to wiki/evidence-report.md as part of the rebuild. Useful for keeping the dashboard fresh without a separate evidence-report call. Default: false.",
|
|
391
|
+
},
|
|
388
392
|
},
|
|
389
393
|
required: ["action"],
|
|
390
394
|
},
|
|
@@ -1654,6 +1658,75 @@ function readPagesContent(wiki, paths, sectionFilter, perPageLimit, includeToc)
|
|
|
1654
1658
|
}
|
|
1655
1659
|
return pages;
|
|
1656
1660
|
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Best-effort regeneration of `wiki/evidence-report.md`. Called from
|
|
1663
|
+
* `runPostRebuildEvidence` below, which both the inline and batched
|
|
1664
|
+
* rebuild paths invoke. The rebuild never fails on evidence
|
|
1665
|
+
* bookkeeping, but the flag is operator-requested — both callers
|
|
1666
|
+
* surface success or failure into their visible response so `ok:true`
|
|
1667
|
+
* never implies the regen happened when it didn't.
|
|
1668
|
+
*/
|
|
1669
|
+
function regenerateEvidenceReport(wiki) {
|
|
1670
|
+
try {
|
|
1671
|
+
const er = runEvidenceReport(wiki, { write: true });
|
|
1672
|
+
// `write: true` always sets `writtenTo`; the null-check is here only
|
|
1673
|
+
// because the public signature keeps `writtenTo?: string` rather than
|
|
1674
|
+
// paying for overloads to narrow it for a single caller.
|
|
1675
|
+
if (!er.writtenTo) {
|
|
1676
|
+
return { ok: false, error: "runEvidenceReport(write:true) returned no writtenTo path" };
|
|
1677
|
+
}
|
|
1678
|
+
return { ok: true, writtenTo: er.writtenTo };
|
|
1679
|
+
}
|
|
1680
|
+
catch (err) {
|
|
1681
|
+
return { ok: false, error: err instanceof Error ? err.message : String(err) };
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
/**
|
|
1685
|
+
* Single source of truth for the post-rebuild evidence bookkeeping that
|
|
1686
|
+
* both `wiki_admin action:rebuild` (inline) and the end-of-batch rebuild
|
|
1687
|
+
* path execute: (1) one-shot migration of pre-existing pages, (2) weekly
|
|
1688
|
+
* digest line into wiki/log.md, (3) optional opt-in evidence-report regen.
|
|
1689
|
+
*
|
|
1690
|
+
* Returns:
|
|
1691
|
+
* - `parts`: message fragments for the inline handler to append to its
|
|
1692
|
+
* ok-message. The batch handler does not surface these and may
|
|
1693
|
+
* discard them — current behavior is to omit migration / digest
|
|
1694
|
+
* messages from batch responses (they remain in log.md).
|
|
1695
|
+
* - `evidence`: the regen result when `regenerateReport` was true,
|
|
1696
|
+
* `null` otherwise. Both call sites consume this to surface failure
|
|
1697
|
+
* into their visible response shape.
|
|
1698
|
+
*/
|
|
1699
|
+
function runPostRebuildEvidence(wiki, opts) {
|
|
1700
|
+
const parts = [];
|
|
1701
|
+
let migration = null;
|
|
1702
|
+
try {
|
|
1703
|
+
const pluginIds = listPlugins().map((p) => p.id);
|
|
1704
|
+
migration = migrateExistingPagesForEvidence(wiki, pluginIds);
|
|
1705
|
+
}
|
|
1706
|
+
catch { /* never fails the rebuild */ }
|
|
1707
|
+
if (migration && !migration.alreadyMigrated && migration.totalPages > 0) {
|
|
1708
|
+
parts.push(`Evidence migration: ${migration.totalPages} pages — ` +
|
|
1709
|
+
`${migration.grounded} grounded, ` +
|
|
1710
|
+
`${migration.syntheses + migration.preExistingSynthesis} synthesis, ` +
|
|
1711
|
+
`${migration.legacy} legacy-unsupported`);
|
|
1712
|
+
}
|
|
1713
|
+
try {
|
|
1714
|
+
const week = summarizeLastWeek(wiki.config.workspace);
|
|
1715
|
+
if (week.totalWrites > 0 || week.unsupportedTransitions > 0) {
|
|
1716
|
+
const ratioStr = week.wouldRejectRatio === null
|
|
1717
|
+
? ""
|
|
1718
|
+
: ` — ${(week.wouldRejectRatio * 100).toFixed(1)}% blocked-or-would-block under Phase 2b`;
|
|
1719
|
+
wiki.log("evidence", "log.md", `Last 7 days: ${week.unsupportedWrites} unsupported `
|
|
1720
|
+
+ `+ ${week.rejectedWrites} rejected `
|
|
1721
|
+
+ `/ ${week.totalWrites} wiki_write(s) `
|
|
1722
|
+
+ `(${week.unsupportedTransitions} new unsupported pages)`
|
|
1723
|
+
+ `${ratioStr}.`);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
catch { /* never fails the rebuild */ }
|
|
1727
|
+
const evidence = opts.regenerateReport ? regenerateEvidenceReport(wiki) : null;
|
|
1728
|
+
return { parts, evidence };
|
|
1729
|
+
}
|
|
1657
1730
|
export async function handleTool(wiki, name, args, opts) {
|
|
1658
1731
|
switch (name) {
|
|
1659
1732
|
// ═══ RAW LAYER ═══
|
|
@@ -2220,18 +2293,6 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2220
2293
|
if (wiki.config.search.hybrid) {
|
|
2221
2294
|
vectorStats = await wiki.rebuildVectorIndex().catch(() => undefined);
|
|
2222
2295
|
}
|
|
2223
|
-
// Evidence-first phase 2a: one-shot migration of pre-existing pages
|
|
2224
|
-
// (gated by marker file under .agent-wiki/) so existing compiler
|
|
2225
|
-
// artifacts and user pages don't all flag as "unsupported" the day
|
|
2226
|
-
// phase 2a ships. Also emit a one-line weekly count of unsupported
|
|
2227
|
-
// writes into wiki/log.md so the maintainer has a running signal
|
|
2228
|
-
// ahead of the phase 4 dashboard.
|
|
2229
|
-
let migration = null;
|
|
2230
|
-
try {
|
|
2231
|
-
const pluginIds = listPlugins().map((p) => p.id);
|
|
2232
|
-
migration = migrateExistingPagesForEvidence(wiki, pluginIds);
|
|
2233
|
-
}
|
|
2234
|
-
catch { /* ignore — evidence bookkeeping never fails a rebuild */ }
|
|
2235
2296
|
const parts = ["Index and timeline rebuilt"];
|
|
2236
2297
|
if (graphStats) {
|
|
2237
2298
|
parts.push(`Knowledge graph: ${graphStats.nodes} nodes, ${graphStats.edges} edges`);
|
|
@@ -2239,27 +2300,31 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2239
2300
|
if (vectorStats) {
|
|
2240
2301
|
parts.push(`Vector index: ${vectorStats.pagesProcessed} pages embedded${vectorStats.errors > 0 ? `, ${vectorStats.errors} errors` : ""}`);
|
|
2241
2302
|
}
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2303
|
+
// Single source of truth for post-rebuild evidence bookkeeping;
|
|
2304
|
+
// batch's end-of-batch path invokes the same helper for parity.
|
|
2305
|
+
const regenerateReport = args.evidence_report ?? false;
|
|
2306
|
+
const bookkeeping = runPostRebuildEvidence(wiki, { regenerateReport });
|
|
2307
|
+
parts.push(...bookkeeping.parts);
|
|
2308
|
+
if (bookkeeping.evidence) {
|
|
2309
|
+
parts.push(bookkeeping.evidence.ok
|
|
2310
|
+
? `Evidence report written to ${bookkeeping.evidence.writtenTo}`
|
|
2311
|
+
: `Evidence report regeneration failed: ${bookkeeping.evidence.error}`);
|
|
2312
|
+
}
|
|
2313
|
+
// On regen failure, surface a structured field alongside ok:true so
|
|
2314
|
+
// programmatic callers can detect partial-success without sniffing
|
|
2315
|
+
// the message string. Matches the batch handler's deferred-entry
|
|
2316
|
+
// shape (`evidenceReport: { ok: false, error }`).
|
|
2317
|
+
const response = {
|
|
2318
|
+
ok: true,
|
|
2319
|
+
message: parts.join(". ") + ".",
|
|
2320
|
+
};
|
|
2321
|
+
if (bookkeeping.evidence && !bookkeeping.evidence.ok) {
|
|
2322
|
+
response.evidenceReport = {
|
|
2323
|
+
ok: false,
|
|
2324
|
+
error: bookkeeping.evidence.error,
|
|
2325
|
+
};
|
|
2260
2326
|
}
|
|
2261
|
-
|
|
2262
|
-
return JSON.stringify({ ok: true, message: parts.join(". ") + "." });
|
|
2327
|
+
return JSON.stringify(response);
|
|
2263
2328
|
}
|
|
2264
2329
|
// wiki_classify removed — wiki_write auto-classifies
|
|
2265
2330
|
// wiki_synthesize removed — agent can wiki_read multiple pages
|
|
@@ -2795,6 +2860,15 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2795
2860
|
let needsRebuild = false;
|
|
2796
2861
|
let needsTimeline = false;
|
|
2797
2862
|
let needsGraphRebuild = false;
|
|
2863
|
+
// Carries through any `wiki_admin action:rebuild evidence_report:true`
|
|
2864
|
+
// op from this batch — the end-of-batch rebuild block below regenerates
|
|
2865
|
+
// the report once so the opt-in flag survives dedup.
|
|
2866
|
+
let needsEvidenceReport = false;
|
|
2867
|
+
// Deferred entries from rebuild ops that asked for evidence_report:true.
|
|
2868
|
+
// Held by reference so we can mutate them in place on regen failure —
|
|
2869
|
+
// keeps the 1-op→1-result invariant and the established `{ tool, result }`
|
|
2870
|
+
// shape rather than introducing a sibling entry on failure.
|
|
2871
|
+
const rebuildEntriesAwaitingEvidence = [];
|
|
2798
2872
|
const results = [];
|
|
2799
2873
|
for (const op of ops) {
|
|
2800
2874
|
if (op.tool === "batch") {
|
|
@@ -2807,7 +2881,19 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2807
2881
|
if (isRebuild) {
|
|
2808
2882
|
needsRebuild = true;
|
|
2809
2883
|
needsTimeline = true;
|
|
2810
|
-
|
|
2884
|
+
const entry = {
|
|
2885
|
+
tool: op.tool,
|
|
2886
|
+
result: { ok: true, deferred: "merged into end-of-batch rebuild" },
|
|
2887
|
+
};
|
|
2888
|
+
results.push(entry);
|
|
2889
|
+
// Match the in-handler `(args.X as boolean) ?? false` convention
|
|
2890
|
+
// (e.g. wiki_lint's apply_fixes) so the same input shape produces
|
|
2891
|
+
// the same behavior across every wiki_admin entry point.
|
|
2892
|
+
const opEvidenceReport = op.args?.evidence_report ?? false;
|
|
2893
|
+
if (opEvidenceReport) {
|
|
2894
|
+
needsEvidenceReport = true;
|
|
2895
|
+
rebuildEntriesAwaitingEvidence.push(entry);
|
|
2896
|
+
}
|
|
2811
2897
|
continue;
|
|
2812
2898
|
}
|
|
2813
2899
|
try {
|
|
@@ -2862,8 +2948,30 @@ export async function handleTool(wiki, name, args, opts) {
|
|
|
2862
2948
|
if (needsRebuild) {
|
|
2863
2949
|
const pageCache = wiki.buildPageCache();
|
|
2864
2950
|
wiki.rebuildIndex(pageCache);
|
|
2951
|
+
// Yield to the event loop so the MCP transport can answer client
|
|
2952
|
+
// pings between the two rebuilds. Mirrors the inline rebuild path
|
|
2953
|
+
// (relevant on slow filesystems like OneDrive-synced workspaces).
|
|
2954
|
+
await new Promise((r) => setImmediate(r));
|
|
2865
2955
|
if (needsTimeline)
|
|
2866
2956
|
wiki.rebuildTimeline(pageCache);
|
|
2957
|
+
// Single source of truth for migration + weekly log + optional
|
|
2958
|
+
// regen — same helper the inline rebuild path uses, so the two
|
|
2959
|
+
// produce equivalent side effects (log.md, .agent-wiki/ marker).
|
|
2960
|
+
const bookkeeping = runPostRebuildEvidence(wiki, {
|
|
2961
|
+
regenerateReport: needsEvidenceReport,
|
|
2962
|
+
});
|
|
2963
|
+
if (bookkeeping.evidence && !bookkeeping.evidence.ok) {
|
|
2964
|
+
// Surface failure in-place on the deferred entry so the caller
|
|
2965
|
+
// gets one result per op, keeping `count: results.length` honest
|
|
2966
|
+
// and the shape uniform with the rest of this handler.
|
|
2967
|
+
for (const entry of rebuildEntriesAwaitingEvidence) {
|
|
2968
|
+
const prior = entry.result;
|
|
2969
|
+
entry.result = {
|
|
2970
|
+
...prior,
|
|
2971
|
+
evidenceReport: { ok: false, error: bookkeeping.evidence.error },
|
|
2972
|
+
};
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2867
2975
|
}
|
|
2868
2976
|
return JSON.stringify({ results, count: results.length }, null, 2);
|
|
2869
2977
|
}
|