@agent-wiki/mcp 0.22.4 → 0.22.6
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 +31 -0
- package/dist/cli.js +177 -0
- package/dist/cli.js.map +1 -1
- package/dist/evidence-migration.js +1 -1
- package/dist/evidence-migration.js.map +1 -1
- package/dist/evidence-report.d.ts +17 -0
- package/dist/evidence-report.d.ts.map +1 -1
- package/dist/evidence-report.js +46 -2
- package/dist/evidence-report.js.map +1 -1
- package/dist/evidence-search.d.ts +71 -0
- package/dist/evidence-search.d.ts.map +1 -1
- package/dist/evidence-search.js +104 -1
- package/dist/evidence-search.js.map +1 -1
- package/dist/evidence-search.test.js +58 -1
- package/dist/evidence-search.test.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/okf-compat.d.ts +152 -0
- package/dist/okf-compat.d.ts.map +1 -0
- package/dist/okf-compat.js +604 -0
- package/dist/okf-compat.js.map +1 -0
- package/dist/okf-compat.test.d.ts +2 -0
- package/dist/okf-compat.test.d.ts.map +1 -0
- package/dist/okf-compat.test.js +234 -0
- package/dist/okf-compat.test.js.map +1 -0
- package/dist/okf-export.d.ts +63 -0
- package/dist/okf-export.d.ts.map +1 -0
- package/dist/okf-export.js +655 -0
- package/dist/okf-export.js.map +1 -0
- package/dist/okf-export.test.d.ts +2 -0
- package/dist/okf-export.test.d.ts.map +1 -0
- package/dist/okf-export.test.js +469 -0
- package/dist/okf-export.test.js.map +1 -0
- package/dist/okf-import.d.ts +136 -0
- package/dist/okf-import.d.ts.map +1 -0
- package/dist/okf-import.js +471 -0
- package/dist/okf-import.js.map +1 -0
- package/dist/okf-import.test.d.ts +2 -0
- package/dist/okf-import.test.d.ts.map +1 -0
- package/dist/okf-import.test.js +339 -0
- package/dist/okf-import.test.js.map +1 -0
- package/dist/okf-trust.test.d.ts +2 -0
- package/dist/okf-trust.test.d.ts.map +1 -0
- package/dist/okf-trust.test.js +223 -0
- package/dist/okf-trust.test.js.map +1 -0
- package/dist/okf.d.ts +128 -0
- package/dist/okf.d.ts.map +1 -0
- package/dist/okf.js +659 -0
- package/dist/okf.js.map +1 -0
- package/dist/search-currency.d.ts +44 -0
- package/dist/search-currency.d.ts.map +1 -0
- package/dist/search-currency.js +111 -0
- package/dist/search-currency.js.map +1 -0
- package/dist/search.d.ts +19 -0
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js.map +1 -1
- package/dist/server.d.ts +0 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +617 -21
- package/dist/server.js.map +1 -1
- package/dist/server.test.js +772 -0
- package/dist/server.test.js.map +1 -1
- package/dist/wiki-graph.d.ts +126 -0
- package/dist/wiki-graph.d.ts.map +1 -0
- package/dist/wiki-graph.js +479 -0
- package/dist/wiki-graph.js.map +1 -0
- package/dist/wiki-graph.test.d.ts +2 -0
- package/dist/wiki-graph.test.d.ts.map +1 -0
- package/dist/wiki-graph.test.js +216 -0
- package/dist/wiki-graph.test.js.map +1 -0
- package/dist/wiki.d.ts +140 -1
- package/dist/wiki.d.ts.map +1 -1
- package/dist/wiki.js +509 -23
- package/dist/wiki.js.map +1 -1
- package/dist/worklist.d.ts +43 -0
- package/dist/worklist.d.ts.map +1 -0
- package/dist/worklist.js +147 -0
- package/dist/worklist.js.map +1 -0
- package/dist/worklist.test.d.ts +2 -0
- package/dist/worklist.test.d.ts.map +1 -0
- package/dist/worklist.test.js +233 -0
- package/dist/worklist.test.js.map +1 -0
- package/docs/evidence-envelope.md +5 -0
- package/docs/okf-adoption-plan.md +566 -0
- package/docs/okf-compat-plan.md +418 -0
- package/docs/okf-extensions.md +245 -0
- package/docs/open-knowledge-format.md +280 -0
- package/docs/tools.md +264 -2
- package/package.json +1 -1
- package/schemas/agent-wiki-okf.schema.json +130 -0
- package/skills/agent-wiki/SKILL.md +7 -0
- package/skills/agent-wiki/references/tools-reference.md +80 -3
package/dist/okf.js
ADDED
|
@@ -0,0 +1,659 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import yaml from "js-yaml";
|
|
4
|
+
import { isSystemPage } from "./wiki.js";
|
|
5
|
+
import { VERSION } from "./version.js";
|
|
6
|
+
export const OKF_FORMAT = "agent-wiki-okf";
|
|
7
|
+
export const OKF_FORMAT_VERSION = "0.1";
|
|
8
|
+
export const OKF_MANIFEST_FILENAME = "agent-wiki.yaml";
|
|
9
|
+
const TOP_LEVEL_KEYS = new Set([
|
|
10
|
+
"format",
|
|
11
|
+
"format_version",
|
|
12
|
+
"name",
|
|
13
|
+
"version",
|
|
14
|
+
"license",
|
|
15
|
+
"owner",
|
|
16
|
+
"created_at",
|
|
17
|
+
"description",
|
|
18
|
+
"generator",
|
|
19
|
+
"source_policy",
|
|
20
|
+
"wiki_policy",
|
|
21
|
+
"evidence_policy",
|
|
22
|
+
"metadata",
|
|
23
|
+
]);
|
|
24
|
+
const SOURCE_POLICY_KEYS = new Set([
|
|
25
|
+
"raw_immutable",
|
|
26
|
+
"require_sha256",
|
|
27
|
+
"require_meta_sidecars",
|
|
28
|
+
]);
|
|
29
|
+
const WIKI_POLICY_KEYS = new Set([
|
|
30
|
+
"require_sources_for_grounded_pages",
|
|
31
|
+
"allow_synthesis_pages",
|
|
32
|
+
"stale_after_days",
|
|
33
|
+
]);
|
|
34
|
+
const EVIDENCE_POLICY_KEYS = new Set([
|
|
35
|
+
"allow_unsupported_pages",
|
|
36
|
+
"require_abstain_signal",
|
|
37
|
+
]);
|
|
38
|
+
const GENERATOR_KEYS = new Set(["name", "version"]);
|
|
39
|
+
export function runOkfFormatCheck(config) {
|
|
40
|
+
const packageRoot = config.workspace;
|
|
41
|
+
const manifestPath = join(packageRoot, OKF_MANIFEST_FILENAME);
|
|
42
|
+
const issues = [];
|
|
43
|
+
let manifest;
|
|
44
|
+
if (!existsSync(manifestPath)) {
|
|
45
|
+
issues.push({
|
|
46
|
+
severity: "error",
|
|
47
|
+
path: OKF_MANIFEST_FILENAME,
|
|
48
|
+
message: `Missing ${OKF_MANIFEST_FILENAME} package manifest.`,
|
|
49
|
+
suggestion: `Create ${OKF_MANIFEST_FILENAME} at the package root and validate it against schemas/agent-wiki-okf.schema.json.`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
try {
|
|
54
|
+
const parsed = yaml.load(readFileSync(manifestPath, "utf-8"));
|
|
55
|
+
manifest = validateManifest(parsed, issues);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
issues.push({
|
|
59
|
+
severity: "error",
|
|
60
|
+
path: OKF_MANIFEST_FILENAME,
|
|
61
|
+
message: `Could not parse ${OKF_MANIFEST_FILENAME}: ${err instanceof Error ? err.message : String(err)}`,
|
|
62
|
+
suggestion: "Fix the YAML syntax and run format-check again.",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
checkDirectory(config.rawDir, "raw/", true, issues);
|
|
67
|
+
checkDirectory(config.wikiDir, "wiki/", true, issues);
|
|
68
|
+
checkDirectory(config.schemasDir, "schemas/", false, issues);
|
|
69
|
+
if (manifest?.generator?.name === "agent-wiki" && manifest.generator.version !== VERSION) {
|
|
70
|
+
issues.push({
|
|
71
|
+
severity: "info",
|
|
72
|
+
path: "agent-wiki.yaml:generator.version",
|
|
73
|
+
message: `Manifest generator version is ${manifest.generator.version}; current agent-wiki version is ${VERSION}.`,
|
|
74
|
+
suggestion: "This is informational only. Rebuild package metadata when you want the manifest to reflect the current tool version.",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
ok: issues.every((issue) => issue.severity !== "error"),
|
|
79
|
+
format: OKF_FORMAT,
|
|
80
|
+
expectedFormatVersion: OKF_FORMAT_VERSION,
|
|
81
|
+
manifestPath,
|
|
82
|
+
packageRoot,
|
|
83
|
+
schema: "schemas/agent-wiki-okf.schema.json",
|
|
84
|
+
manifest,
|
|
85
|
+
issues,
|
|
86
|
+
checked: {
|
|
87
|
+
manifest: existsSync(manifestPath),
|
|
88
|
+
rawDir: directoryExists(config.rawDir),
|
|
89
|
+
wikiDir: directoryExists(config.wikiDir),
|
|
90
|
+
schemasDir: directoryExists(config.schemasDir),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export function buildOkfPackageReport(wiki, now = new Date()) {
|
|
95
|
+
const formatCheck = runOkfFormatCheck(wiki.config);
|
|
96
|
+
const inventory = buildPackageInventory(wiki);
|
|
97
|
+
const issues = [
|
|
98
|
+
...formatCheck.issues,
|
|
99
|
+
...buildConformanceIssues(formatCheck.manifest, inventory),
|
|
100
|
+
];
|
|
101
|
+
const conformance = summarizeConformance(issues);
|
|
102
|
+
return {
|
|
103
|
+
...formatCheck,
|
|
104
|
+
ok: conformance.status === "pass",
|
|
105
|
+
generatedAt: now.toISOString(),
|
|
106
|
+
issues,
|
|
107
|
+
inventory,
|
|
108
|
+
conformance,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export function runOkfPackageReport(wiki, opts) {
|
|
112
|
+
const report = buildOkfPackageReport(wiki, opts?.now ?? new Date());
|
|
113
|
+
if (!opts?.write)
|
|
114
|
+
return { report };
|
|
115
|
+
const evidenceDir = join(wiki.config.workspace, "evidence");
|
|
116
|
+
mkdirSync(evidenceDir, { recursive: true });
|
|
117
|
+
const writtenTo = join(evidenceDir, "okf-report.json");
|
|
118
|
+
report.inventory.evidence.okfReport = true;
|
|
119
|
+
writeFileSync(writtenTo, JSON.stringify(report, null, 2) + "\n");
|
|
120
|
+
return { report, writtenTo };
|
|
121
|
+
}
|
|
122
|
+
function buildPackageInventory(wiki) {
|
|
123
|
+
const rawDocs = wiki.rawList();
|
|
124
|
+
const integrity = wiki.rawVerify();
|
|
125
|
+
const coverage = wiki.rawCoverage({ limit: Number.MAX_SAFE_INTEGER });
|
|
126
|
+
const pages = wiki.listAllPages();
|
|
127
|
+
const classes = {
|
|
128
|
+
system: 0,
|
|
129
|
+
grounded: 0,
|
|
130
|
+
synthesis: 0,
|
|
131
|
+
unsupported: 0,
|
|
132
|
+
legacyUnsupported: 0,
|
|
133
|
+
other: 0,
|
|
134
|
+
};
|
|
135
|
+
let stale = 0;
|
|
136
|
+
let missingSources = 0;
|
|
137
|
+
for (const pagePath of pages) {
|
|
138
|
+
const page = wiki.read(pagePath);
|
|
139
|
+
if (!page)
|
|
140
|
+
continue;
|
|
141
|
+
const pageClass = classifyPage(pagePath, page);
|
|
142
|
+
classes[pageClass]++;
|
|
143
|
+
if (!isSystemPage(pagePath) && page.sources.length === 0 && pageClass !== "synthesis") {
|
|
144
|
+
missingSources++;
|
|
145
|
+
}
|
|
146
|
+
if (!isSystemPage(pagePath) && isStale(page, wiki.config.lint.checkStaleDays)) {
|
|
147
|
+
stale++;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const schemaFiles = listRelativeFiles(wiki.config.schemasDir);
|
|
151
|
+
const indexPages = pages.filter((p) => p.endsWith("/index.md"));
|
|
152
|
+
return {
|
|
153
|
+
raw: {
|
|
154
|
+
total: rawDocs.length,
|
|
155
|
+
primary: rawDocs.filter((doc) => !doc.path.startsWith("parsed/")).length,
|
|
156
|
+
parsedArtifacts: rawDocs.filter((doc) => doc.path.startsWith("parsed/")).length,
|
|
157
|
+
integrity: {
|
|
158
|
+
ok: integrity.filter((entry) => entry.status === "ok").length,
|
|
159
|
+
corrupted: integrity.filter((entry) => entry.status === "corrupted").length,
|
|
160
|
+
missingMeta: integrity.filter((entry) => entry.status === "missing-meta").length,
|
|
161
|
+
},
|
|
162
|
+
coverage: {
|
|
163
|
+
totalRaw: coverage.totalRaw,
|
|
164
|
+
coveredRaw: coverage.coveredRaw,
|
|
165
|
+
uncoveredRaw: coverage.uncoveredRaw,
|
|
166
|
+
coverageRatio: coverage.coverageRatio,
|
|
167
|
+
truncated: coverage.truncated,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
wiki: {
|
|
171
|
+
total: pages.length,
|
|
172
|
+
classes,
|
|
173
|
+
stale,
|
|
174
|
+
missingSources,
|
|
175
|
+
},
|
|
176
|
+
schemas: {
|
|
177
|
+
count: schemaFiles.length,
|
|
178
|
+
files: schemaFiles,
|
|
179
|
+
},
|
|
180
|
+
indexes: {
|
|
181
|
+
generatedPages: {
|
|
182
|
+
rootIndex: pages.includes("index.md"),
|
|
183
|
+
timeline: pages.includes("timeline.md"),
|
|
184
|
+
log: pages.includes("log.md"),
|
|
185
|
+
nestedIndexPages: indexPages.length,
|
|
186
|
+
},
|
|
187
|
+
caches: {
|
|
188
|
+
vectorIndex: existsSync(join(wiki.config.wikiDir, ".search-vectors.json")),
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
evidence: {
|
|
192
|
+
evidenceReport: pages.includes("evidence-report.md"),
|
|
193
|
+
okfReport: existsSync(join(wiki.config.workspace, "evidence", "okf-report.json")),
|
|
194
|
+
telemetryLogs: {
|
|
195
|
+
writeCounter: existsSync(join(wiki.config.workspace, ".agent-wiki", "evidence-write-counter.jsonl")),
|
|
196
|
+
unsupportedWrites: existsSync(join(wiki.config.workspace, ".agent-wiki", "evidence-write-log.jsonl")),
|
|
197
|
+
search: existsSync(join(wiki.config.workspace, ".agent-wiki", "evidence-search-log.jsonl")),
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
function buildConformanceIssues(manifest, inventory) {
|
|
203
|
+
const issues = [];
|
|
204
|
+
if (inventory.raw.integrity.corrupted > 0) {
|
|
205
|
+
issues.push({
|
|
206
|
+
severity: "error",
|
|
207
|
+
path: "raw/",
|
|
208
|
+
message: `${inventory.raw.integrity.corrupted} raw file(s) failed SHA-256 integrity verification.`,
|
|
209
|
+
suggestion: "Restore the original raw files or re-ingest them as new immutable versions.",
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (inventory.raw.integrity.missingMeta > 0) {
|
|
213
|
+
const requireMetaSidecars = manifest?.source_policy.require_meta_sidecars === true;
|
|
214
|
+
issues.push({
|
|
215
|
+
severity: requireMetaSidecars ? "error" : "warning",
|
|
216
|
+
path: "raw/",
|
|
217
|
+
message: `${inventory.raw.integrity.missingMeta} raw file(s) are missing .meta.yaml sidecars.`,
|
|
218
|
+
suggestion: "Re-ingest these files through raw_ingest so source metadata and hashes are recorded.",
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (inventory.raw.coverage.uncoveredRaw > 0) {
|
|
222
|
+
issues.push({
|
|
223
|
+
severity: "warning",
|
|
224
|
+
path: "raw/",
|
|
225
|
+
message: `${inventory.raw.coverage.uncoveredRaw} primary raw source(s) are not referenced by any wiki page.`,
|
|
226
|
+
suggestion: "Use raw_coverage to pick the next source to compile into wiki pages.",
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
const unsupported = inventory.wiki.classes.unsupported;
|
|
230
|
+
if (unsupported > 0) {
|
|
231
|
+
const policy = manifest?.evidence_policy.allow_unsupported_pages ?? "warn";
|
|
232
|
+
issues.push({
|
|
233
|
+
severity: policy === "reject" ? "error" : policy === "warn" ? "warning" : "info",
|
|
234
|
+
path: "wiki/",
|
|
235
|
+
message: `${unsupported} wiki page(s) are marked unsupported.`,
|
|
236
|
+
suggestion: "Add sources, mark true synthesis pages with synthesis: true, or keep them only if package policy allows unsupported pages.",
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (inventory.wiki.classes.legacyUnsupported > 0) {
|
|
240
|
+
issues.push({
|
|
241
|
+
severity: "warning",
|
|
242
|
+
path: "wiki/",
|
|
243
|
+
message: `${inventory.wiki.classes.legacyUnsupported} wiki page(s) are legacy-unsupported.`,
|
|
244
|
+
suggestion: "Resolve legacy pages by adding sources or marking legitimate synthesis.",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
if (inventory.wiki.classes.other > 0) {
|
|
248
|
+
issues.push({
|
|
249
|
+
severity: "warning",
|
|
250
|
+
path: "wiki/",
|
|
251
|
+
message: `${inventory.wiki.classes.other} wiki page(s) could not be classified as system, grounded, synthesis, unsupported, or legacyUnsupported.`,
|
|
252
|
+
suggestion: "Add sources, set synthesis: true, or review frontmatter.",
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
if (inventory.wiki.stale > 0) {
|
|
256
|
+
issues.push({
|
|
257
|
+
severity: "warning",
|
|
258
|
+
path: "wiki/",
|
|
259
|
+
message: `${inventory.wiki.stale} wiki page(s) are older than the configured staleness window.`,
|
|
260
|
+
suggestion: "Review and refresh stale pages or adjust lint.check_stale_days in runtime config.",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
if (inventory.schemas.count === 0) {
|
|
264
|
+
issues.push({
|
|
265
|
+
severity: "warning",
|
|
266
|
+
path: "schemas/",
|
|
267
|
+
message: "No schema/template files were found.",
|
|
268
|
+
suggestion: "Add reusable page/entity schemas when publishing OKF packages for other agents.",
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (!inventory.indexes.generatedPages.rootIndex || !inventory.indexes.generatedPages.timeline || !inventory.indexes.generatedPages.log) {
|
|
272
|
+
issues.push({
|
|
273
|
+
severity: "warning",
|
|
274
|
+
path: "wiki/",
|
|
275
|
+
message: "One or more generated system pages are missing.",
|
|
276
|
+
suggestion: "Run wiki_admin action:rebuild to regenerate index.md, timeline.md, and log.md.",
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
if (!inventory.evidence.evidenceReport) {
|
|
280
|
+
issues.push({
|
|
281
|
+
severity: "info",
|
|
282
|
+
path: "wiki/evidence-report.md",
|
|
283
|
+
message: "Evidence report has not been generated.",
|
|
284
|
+
suggestion: "Run wiki_admin action:evidence-report with write:true, or rebuild with evidence_report:true.",
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
return issues;
|
|
288
|
+
}
|
|
289
|
+
function summarizeConformance(issues) {
|
|
290
|
+
const errorCount = issues.filter((issue) => issue.severity === "error").length;
|
|
291
|
+
const warningCount = issues.filter((issue) => issue.severity === "warning").length;
|
|
292
|
+
const infoCount = issues.filter((issue) => issue.severity === "info").length;
|
|
293
|
+
return {
|
|
294
|
+
status: errorCount === 0 ? "pass" : "fail",
|
|
295
|
+
errorCount,
|
|
296
|
+
warningCount,
|
|
297
|
+
infoCount,
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function classifyPage(pagePath, page) {
|
|
301
|
+
if (isSystemPage(pagePath))
|
|
302
|
+
return "system";
|
|
303
|
+
if (page.frontmatter.synthesis === true || page.type === "synthesis")
|
|
304
|
+
return "synthesis";
|
|
305
|
+
if (page.sources.length > 0)
|
|
306
|
+
return "grounded";
|
|
307
|
+
if (page.frontmatter.unsupported === true)
|
|
308
|
+
return "unsupported";
|
|
309
|
+
if (page.frontmatter.legacyUnsupported === true)
|
|
310
|
+
return "legacyUnsupported";
|
|
311
|
+
return "other";
|
|
312
|
+
}
|
|
313
|
+
function isStale(page, staleAfterDays) {
|
|
314
|
+
if (!page.updated)
|
|
315
|
+
return false;
|
|
316
|
+
const updated = Date.parse(page.updated);
|
|
317
|
+
if (Number.isNaN(updated))
|
|
318
|
+
return false;
|
|
319
|
+
const ageMs = Date.now() - updated;
|
|
320
|
+
return ageMs > staleAfterDays * 24 * 60 * 60 * 1000;
|
|
321
|
+
}
|
|
322
|
+
function listRelativeFiles(root) {
|
|
323
|
+
if (!directoryExists(root))
|
|
324
|
+
return [];
|
|
325
|
+
const result = [];
|
|
326
|
+
const walk = (dir, prefix) => {
|
|
327
|
+
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
328
|
+
if (entry.name.startsWith("."))
|
|
329
|
+
continue;
|
|
330
|
+
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
331
|
+
const full = join(dir, entry.name);
|
|
332
|
+
if (entry.isDirectory()) {
|
|
333
|
+
walk(full, rel);
|
|
334
|
+
}
|
|
335
|
+
else if (entry.isFile()) {
|
|
336
|
+
result.push(rel);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
walk(root, "");
|
|
341
|
+
return result.sort();
|
|
342
|
+
}
|
|
343
|
+
function validateManifest(input, issues) {
|
|
344
|
+
if (!isRecord(input)) {
|
|
345
|
+
issues.push({
|
|
346
|
+
severity: "error",
|
|
347
|
+
path: OKF_MANIFEST_FILENAME,
|
|
348
|
+
message: "Manifest must be a YAML object.",
|
|
349
|
+
suggestion: "Use top-level key/value fields such as format, format_version, name, version, license, and owner.",
|
|
350
|
+
});
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
rejectUnknownKeys(input, TOP_LEVEL_KEYS, "agent-wiki.yaml", issues);
|
|
354
|
+
const format = requireString(input, "format", "agent-wiki.yaml:format", issues);
|
|
355
|
+
if (format !== undefined && format !== OKF_FORMAT) {
|
|
356
|
+
issues.push({
|
|
357
|
+
severity: "error",
|
|
358
|
+
path: "agent-wiki.yaml:format",
|
|
359
|
+
message: `format must be "${OKF_FORMAT}".`,
|
|
360
|
+
suggestion: `Set format: ${OKF_FORMAT}.`,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
const formatVersion = requireFormatVersion(input, issues);
|
|
364
|
+
const name = requireString(input, "name", "agent-wiki.yaml:name", issues);
|
|
365
|
+
if (name !== undefined && !/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(name)) {
|
|
366
|
+
issues.push({
|
|
367
|
+
severity: "error",
|
|
368
|
+
path: "agent-wiki.yaml:name",
|
|
369
|
+
message: "name must start with an alphanumeric character and contain only letters, numbers, '.', '_', or '-'.",
|
|
370
|
+
suggestion: "Use a portable package slug such as payroll-modernization-knowledge.",
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
const version = requireString(input, "version", "agent-wiki.yaml:version", issues);
|
|
374
|
+
const license = requireString(input, "license", "agent-wiki.yaml:license", issues);
|
|
375
|
+
const owner = requireString(input, "owner", "agent-wiki.yaml:owner", issues);
|
|
376
|
+
const createdAt = requireDateString(input, "created_at", "agent-wiki.yaml:created_at", issues);
|
|
377
|
+
if (createdAt !== undefined && !/^\d{4}-\d{2}-\d{2}($|T)/.test(createdAt)) {
|
|
378
|
+
issues.push({
|
|
379
|
+
severity: "error",
|
|
380
|
+
path: "agent-wiki.yaml:created_at",
|
|
381
|
+
message: "created_at must start with YYYY-MM-DD or be an ISO 8601 datetime.",
|
|
382
|
+
suggestion: "Use a value such as 2026-06-20.",
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
const description = optionalString(input, "description", "agent-wiki.yaml:description", issues);
|
|
386
|
+
const generator = validateGenerator(input.generator, issues);
|
|
387
|
+
const sourcePolicy = validateSourcePolicy(input.source_policy, issues);
|
|
388
|
+
const wikiPolicy = validateWikiPolicy(input.wiki_policy, issues);
|
|
389
|
+
const evidencePolicy = validateEvidencePolicy(input.evidence_policy, issues);
|
|
390
|
+
if (input.metadata !== undefined && !isRecord(input.metadata)) {
|
|
391
|
+
issues.push({
|
|
392
|
+
severity: "error",
|
|
393
|
+
path: "agent-wiki.yaml:metadata",
|
|
394
|
+
message: "metadata must be an object when present.",
|
|
395
|
+
suggestion: "Use metadata for freeform tool annotations.",
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
if (format !== OKF_FORMAT ||
|
|
399
|
+
formatVersion !== OKF_FORMAT_VERSION ||
|
|
400
|
+
!name ||
|
|
401
|
+
!version ||
|
|
402
|
+
!license ||
|
|
403
|
+
!owner ||
|
|
404
|
+
!createdAt ||
|
|
405
|
+
!sourcePolicy ||
|
|
406
|
+
!wikiPolicy ||
|
|
407
|
+
!evidencePolicy) {
|
|
408
|
+
return undefined;
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
format: OKF_FORMAT,
|
|
412
|
+
format_version: OKF_FORMAT_VERSION,
|
|
413
|
+
name,
|
|
414
|
+
version,
|
|
415
|
+
license,
|
|
416
|
+
owner,
|
|
417
|
+
created_at: createdAt,
|
|
418
|
+
...(description !== undefined ? { description } : {}),
|
|
419
|
+
...(generator !== undefined ? { generator } : {}),
|
|
420
|
+
source_policy: sourcePolicy,
|
|
421
|
+
wiki_policy: wikiPolicy,
|
|
422
|
+
evidence_policy: evidencePolicy,
|
|
423
|
+
...(isRecord(input.metadata) ? { metadata: input.metadata } : {}),
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
function validateGenerator(input, issues) {
|
|
427
|
+
if (input === undefined)
|
|
428
|
+
return undefined;
|
|
429
|
+
if (!isRecord(input)) {
|
|
430
|
+
issues.push({
|
|
431
|
+
severity: "error",
|
|
432
|
+
path: "agent-wiki.yaml:generator",
|
|
433
|
+
message: "generator must be an object when present.",
|
|
434
|
+
suggestion: "Use generator: { name: agent-wiki, version: <version> }.",
|
|
435
|
+
});
|
|
436
|
+
return undefined;
|
|
437
|
+
}
|
|
438
|
+
rejectUnknownKeys(input, GENERATOR_KEYS, "agent-wiki.yaml:generator", issues);
|
|
439
|
+
const name = requireString(input, "name", "agent-wiki.yaml:generator.name", issues);
|
|
440
|
+
const version = requireString(input, "version", "agent-wiki.yaml:generator.version", issues);
|
|
441
|
+
return name && version ? { name, version } : undefined;
|
|
442
|
+
}
|
|
443
|
+
function validateSourcePolicy(input, issues) {
|
|
444
|
+
if (!isRecord(input)) {
|
|
445
|
+
issues.push({
|
|
446
|
+
severity: "error",
|
|
447
|
+
path: "agent-wiki.yaml:source_policy",
|
|
448
|
+
message: "source_policy must be an object.",
|
|
449
|
+
suggestion: "Set source_policy.raw_immutable: true and source_policy.require_sha256: true.",
|
|
450
|
+
});
|
|
451
|
+
return undefined;
|
|
452
|
+
}
|
|
453
|
+
rejectUnknownKeys(input, SOURCE_POLICY_KEYS, "agent-wiki.yaml:source_policy", issues);
|
|
454
|
+
const rawImmutable = requireBoolean(input, "raw_immutable", "agent-wiki.yaml:source_policy.raw_immutable", issues);
|
|
455
|
+
const requireSha256 = requireBoolean(input, "require_sha256", "agent-wiki.yaml:source_policy.require_sha256", issues);
|
|
456
|
+
const requireMetaSidecars = optionalBoolean(input, "require_meta_sidecars", "agent-wiki.yaml:source_policy.require_meta_sidecars", issues);
|
|
457
|
+
if (rawImmutable === false) {
|
|
458
|
+
issues.push({
|
|
459
|
+
severity: "error",
|
|
460
|
+
path: "agent-wiki.yaml:source_policy.raw_immutable",
|
|
461
|
+
message: "source_policy.raw_immutable must be true for OKF v0.1.",
|
|
462
|
+
suggestion: "Set raw_immutable: true.",
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
if (requireSha256 === false) {
|
|
466
|
+
issues.push({
|
|
467
|
+
severity: "error",
|
|
468
|
+
path: "agent-wiki.yaml:source_policy.require_sha256",
|
|
469
|
+
message: "source_policy.require_sha256 must be true for OKF v0.1.",
|
|
470
|
+
suggestion: "Set require_sha256: true.",
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
if (rawImmutable !== true || requireSha256 !== true)
|
|
474
|
+
return undefined;
|
|
475
|
+
return {
|
|
476
|
+
raw_immutable: true,
|
|
477
|
+
require_sha256: true,
|
|
478
|
+
...(requireMetaSidecars !== undefined ? { require_meta_sidecars: requireMetaSidecars } : {}),
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function validateWikiPolicy(input, issues) {
|
|
482
|
+
if (!isRecord(input)) {
|
|
483
|
+
issues.push({
|
|
484
|
+
severity: "error",
|
|
485
|
+
path: "agent-wiki.yaml:wiki_policy",
|
|
486
|
+
message: "wiki_policy must be an object.",
|
|
487
|
+
suggestion: "Set wiki_policy.require_sources_for_grounded_pages and wiki_policy.allow_synthesis_pages.",
|
|
488
|
+
});
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
491
|
+
rejectUnknownKeys(input, WIKI_POLICY_KEYS, "agent-wiki.yaml:wiki_policy", issues);
|
|
492
|
+
const requireSources = requireBoolean(input, "require_sources_for_grounded_pages", "agent-wiki.yaml:wiki_policy.require_sources_for_grounded_pages", issues);
|
|
493
|
+
const allowSynthesis = requireBoolean(input, "allow_synthesis_pages", "agent-wiki.yaml:wiki_policy.allow_synthesis_pages", issues);
|
|
494
|
+
const staleAfterDays = optionalPositiveInteger(input, "stale_after_days", "agent-wiki.yaml:wiki_policy.stale_after_days", issues);
|
|
495
|
+
if (requireSources === undefined || allowSynthesis === undefined)
|
|
496
|
+
return undefined;
|
|
497
|
+
return {
|
|
498
|
+
require_sources_for_grounded_pages: requireSources,
|
|
499
|
+
allow_synthesis_pages: allowSynthesis,
|
|
500
|
+
...(staleAfterDays !== undefined ? { stale_after_days: staleAfterDays } : {}),
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
function validateEvidencePolicy(input, issues) {
|
|
504
|
+
if (!isRecord(input)) {
|
|
505
|
+
issues.push({
|
|
506
|
+
severity: "error",
|
|
507
|
+
path: "agent-wiki.yaml:evidence_policy",
|
|
508
|
+
message: "evidence_policy must be an object.",
|
|
509
|
+
suggestion: "Set evidence_policy.allow_unsupported_pages and evidence_policy.require_abstain_signal.",
|
|
510
|
+
});
|
|
511
|
+
return undefined;
|
|
512
|
+
}
|
|
513
|
+
rejectUnknownKeys(input, EVIDENCE_POLICY_KEYS, "agent-wiki.yaml:evidence_policy", issues);
|
|
514
|
+
const allowUnsupportedPages = requireString(input, "allow_unsupported_pages", "agent-wiki.yaml:evidence_policy.allow_unsupported_pages", issues);
|
|
515
|
+
const requireAbstainSignal = requireBoolean(input, "require_abstain_signal", "agent-wiki.yaml:evidence_policy.require_abstain_signal", issues);
|
|
516
|
+
if (allowUnsupportedPages !== undefined &&
|
|
517
|
+
allowUnsupportedPages !== "allow" &&
|
|
518
|
+
allowUnsupportedPages !== "warn" &&
|
|
519
|
+
allowUnsupportedPages !== "reject") {
|
|
520
|
+
issues.push({
|
|
521
|
+
severity: "error",
|
|
522
|
+
path: "agent-wiki.yaml:evidence_policy.allow_unsupported_pages",
|
|
523
|
+
message: 'evidence_policy.allow_unsupported_pages must be "allow", "warn", or "reject".',
|
|
524
|
+
suggestion: "Use warn for the current evidence-first default.",
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
if ((allowUnsupportedPages !== "allow" && allowUnsupportedPages !== "warn" && allowUnsupportedPages !== "reject") ||
|
|
528
|
+
requireAbstainSignal === undefined) {
|
|
529
|
+
return undefined;
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
allow_unsupported_pages: allowUnsupportedPages,
|
|
533
|
+
require_abstain_signal: requireAbstainSignal,
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function checkDirectory(path, label, required, issues) {
|
|
537
|
+
if (directoryExists(path))
|
|
538
|
+
return;
|
|
539
|
+
issues.push({
|
|
540
|
+
severity: required ? "error" : "warning",
|
|
541
|
+
path: label,
|
|
542
|
+
message: `${label} directory is ${required ? "required" : "recommended"} for OKF v0.1 packages.`,
|
|
543
|
+
suggestion: required
|
|
544
|
+
? `Create ${label} at the package root or run wiki_admin action:init.`
|
|
545
|
+
: `Create ${label} when you publish reusable page/entity schemas.`,
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
function directoryExists(path) {
|
|
549
|
+
return existsSync(path) && statSync(path).isDirectory();
|
|
550
|
+
}
|
|
551
|
+
function rejectUnknownKeys(record, allowed, path, issues) {
|
|
552
|
+
for (const key of Object.keys(record)) {
|
|
553
|
+
if (!allowed.has(key)) {
|
|
554
|
+
issues.push({
|
|
555
|
+
severity: "error",
|
|
556
|
+
path: `${path}.${key}`,
|
|
557
|
+
message: `Unknown manifest field "${key}".`,
|
|
558
|
+
suggestion: "Remove the field or place tool-specific annotations under metadata.",
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function requireString(record, key, path, issues) {
|
|
564
|
+
const value = record[key];
|
|
565
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
566
|
+
return value;
|
|
567
|
+
issues.push({
|
|
568
|
+
severity: "error",
|
|
569
|
+
path,
|
|
570
|
+
message: `${key} must be a non-empty string.`,
|
|
571
|
+
suggestion: `Set ${key} in ${OKF_MANIFEST_FILENAME}.`,
|
|
572
|
+
});
|
|
573
|
+
return undefined;
|
|
574
|
+
}
|
|
575
|
+
function optionalString(record, key, path, issues) {
|
|
576
|
+
const value = record[key];
|
|
577
|
+
if (value === undefined)
|
|
578
|
+
return undefined;
|
|
579
|
+
if (typeof value === "string")
|
|
580
|
+
return value;
|
|
581
|
+
issues.push({
|
|
582
|
+
severity: "error",
|
|
583
|
+
path,
|
|
584
|
+
message: `${key} must be a string when present.`,
|
|
585
|
+
suggestion: `Use a string value for ${key}.`,
|
|
586
|
+
});
|
|
587
|
+
return undefined;
|
|
588
|
+
}
|
|
589
|
+
function requireBoolean(record, key, path, issues) {
|
|
590
|
+
const value = record[key];
|
|
591
|
+
if (typeof value === "boolean")
|
|
592
|
+
return value;
|
|
593
|
+
issues.push({
|
|
594
|
+
severity: "error",
|
|
595
|
+
path,
|
|
596
|
+
message: `${key} must be a boolean.`,
|
|
597
|
+
suggestion: `Set ${key}: true or ${key}: false.`,
|
|
598
|
+
});
|
|
599
|
+
return undefined;
|
|
600
|
+
}
|
|
601
|
+
function optionalBoolean(record, key, path, issues) {
|
|
602
|
+
const value = record[key];
|
|
603
|
+
if (value === undefined)
|
|
604
|
+
return undefined;
|
|
605
|
+
if (typeof value === "boolean")
|
|
606
|
+
return value;
|
|
607
|
+
issues.push({
|
|
608
|
+
severity: "error",
|
|
609
|
+
path,
|
|
610
|
+
message: `${key} must be a boolean when present.`,
|
|
611
|
+
suggestion: `Set ${key}: true or ${key}: false.`,
|
|
612
|
+
});
|
|
613
|
+
return undefined;
|
|
614
|
+
}
|
|
615
|
+
function optionalPositiveInteger(record, key, path, issues) {
|
|
616
|
+
const value = record[key];
|
|
617
|
+
if (value === undefined)
|
|
618
|
+
return undefined;
|
|
619
|
+
if (Number.isInteger(value) && typeof value === "number" && value > 0)
|
|
620
|
+
return value;
|
|
621
|
+
issues.push({
|
|
622
|
+
severity: "error",
|
|
623
|
+
path,
|
|
624
|
+
message: `${key} must be a positive integer when present.`,
|
|
625
|
+
suggestion: "Use a positive number of days.",
|
|
626
|
+
});
|
|
627
|
+
return undefined;
|
|
628
|
+
}
|
|
629
|
+
function requireFormatVersion(record, issues) {
|
|
630
|
+
const value = record.format_version;
|
|
631
|
+
const normalized = typeof value === "number" ? String(value) : value;
|
|
632
|
+
if (normalized === OKF_FORMAT_VERSION)
|
|
633
|
+
return OKF_FORMAT_VERSION;
|
|
634
|
+
issues.push({
|
|
635
|
+
severity: "error",
|
|
636
|
+
path: "agent-wiki.yaml:format_version",
|
|
637
|
+
message: `format_version must be ${OKF_FORMAT_VERSION}.`,
|
|
638
|
+
suggestion: `Set format_version: ${OKF_FORMAT_VERSION}.`,
|
|
639
|
+
});
|
|
640
|
+
return undefined;
|
|
641
|
+
}
|
|
642
|
+
function requireDateString(record, key, path, issues) {
|
|
643
|
+
const value = record[key];
|
|
644
|
+
if (typeof value === "string" && value.trim() !== "")
|
|
645
|
+
return value;
|
|
646
|
+
if (value instanceof Date && !Number.isNaN(value.getTime()))
|
|
647
|
+
return value.toISOString().slice(0, 10);
|
|
648
|
+
issues.push({
|
|
649
|
+
severity: "error",
|
|
650
|
+
path,
|
|
651
|
+
message: `${key} must be a non-empty date string.`,
|
|
652
|
+
suggestion: `Set ${key} to YYYY-MM-DD or an ISO 8601 datetime.`,
|
|
653
|
+
});
|
|
654
|
+
return undefined;
|
|
655
|
+
}
|
|
656
|
+
function isRecord(value) {
|
|
657
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
658
|
+
}
|
|
659
|
+
//# sourceMappingURL=okf.js.map
|