@agentskit/doc-bridge 0.1.0-alpha.1 → 0.1.0-alpha.2

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.
Files changed (61) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -1
  3. package/dist/cli/program.js +283 -105
  4. package/dist/cli/program.js.map +1 -1
  5. package/dist/config/index.d.ts +1 -1
  6. package/dist/config/index.js +6 -3
  7. package/dist/config/index.js.map +1 -1
  8. package/dist/{index-CD_zmKXf.d.ts → index-CPUJbTbg.d.ts} +19 -10
  9. package/dist/index.d.ts +5 -4
  10. package/dist/index.js +278 -100
  11. package/dist/index.js.map +1 -1
  12. package/docs/DOGFOOD.md +92 -0
  13. package/package.json +27 -9
  14. package/scripts/prepare.mjs +44 -0
  15. package/src/cli/program.ts +933 -0
  16. package/src/config/defaults.ts +63 -0
  17. package/src/config/define-config.ts +6 -0
  18. package/src/config/index.ts +15 -0
  19. package/src/config/load-config.ts +138 -0
  20. package/src/config/schema.ts +294 -0
  21. package/src/federation/llms.ts +145 -0
  22. package/src/gates/run-gates.ts +274 -0
  23. package/src/index-builder/build-handoffs.ts +217 -0
  24. package/src/index-builder/build-index.ts +137 -0
  25. package/src/index-builder/capabilities.ts +37 -0
  26. package/src/index-builder/content-hash.ts +19 -0
  27. package/src/index-builder/human-adapters/core.ts +100 -0
  28. package/src/index-builder/human-adapters/docusaurus.ts +113 -0
  29. package/src/index-builder/human-adapters/fumadocs.ts +70 -0
  30. package/src/index-builder/human-adapters/index.ts +52 -0
  31. package/src/index-builder/human-adapters/plain-markdown.ts +10 -0
  32. package/src/index-builder/llms-txt.ts +19 -0
  33. package/src/index-builder/plugins/human-markdown.ts +7 -0
  34. package/src/index-builder/plugins/pnpm-monorepo.ts +72 -0
  35. package/src/index-builder/scan-corpus.ts +181 -0
  36. package/src/index.ts +120 -0
  37. package/src/intelligence/adapter.ts +90 -0
  38. package/src/intelligence/chat.ts +148 -0
  39. package/src/intelligence/peers.ts +59 -0
  40. package/src/intelligence/rag.ts +98 -0
  41. package/src/lib/glob-expand.ts +33 -0
  42. package/src/lib/markdown.ts +90 -0
  43. package/src/lib/package-manager.ts +104 -0
  44. package/src/lib/paths.ts +6 -0
  45. package/src/lib/walk.ts +45 -0
  46. package/src/mcp/server.ts +276 -0
  47. package/src/memory/ingest.ts +51 -0
  48. package/src/memory/pipeline.ts +119 -0
  49. package/src/query/load-index.ts +25 -0
  50. package/src/query/query.ts +142 -0
  51. package/src/query/search.ts +58 -0
  52. package/src/retriever/doc-bridge-retriever.ts +62 -0
  53. package/src/schemas/agent-handoff.ts +82 -0
  54. package/src/schemas/doc-bridge-index.ts +106 -0
  55. package/src/schemas/json-schemas.ts +156 -0
  56. package/src/schemas/memory-candidate.ts +37 -0
  57. package/src/shims/agentskit-peers.d.ts +80 -0
  58. package/src/validate.ts +67 -0
  59. package/src/version.ts +1 -0
  60. package/tsconfig.json +21 -0
  61. package/tsup.config.ts +15 -0
@@ -1,5 +1,5 @@
1
1
  // src/cli/program.ts
2
- import { existsSync as existsSync9, mkdirSync as mkdirSync2, readFileSync as readFileSync14, writeFileSync as writeFileSync2 } from "fs";
2
+ import { existsSync as existsSync10, mkdirSync as mkdirSync2, readFileSync as readFileSync15, writeFileSync as writeFileSync2 } from "fs";
3
3
  import { dirname as dirname4, resolve as resolve6 } from "path";
4
4
  import { createInterface } from "readline/promises";
5
5
 
@@ -20,7 +20,7 @@ var applyConfigDefaults = (config) => {
20
20
  agent: {
21
21
  ...config.corpus.agent,
22
22
  index: agentIndex,
23
- include: config.corpus.agent.include ?? ["**/*.md"],
23
+ include: config.corpus.agent.include ?? ["**/*.{md,mdx}"],
24
24
  exclude: config.corpus.agent.exclude ?? [...DEFAULT_AGENT_EXCLUDE]
25
25
  }
26
26
  },
@@ -113,9 +113,11 @@ var OwnershipEntrySchema = z.object({
113
113
  humanDoc: z.string().min(1).max(512).optional()
114
114
  }).strict();
115
115
  var RoutingConfigSchema = z.object({
116
- plugin: z.enum(["pnpm-monorepo", "npm-workspaces", "yarn-workspaces", "custom"]).optional(),
116
+ plugin: z.enum(["pnpm-monorepo", "npm-workspaces", "yarn-workspaces", "pattern-files", "custom"]).optional(),
117
117
  options: z.object({
118
118
  packages: z.array(z.string().min(1).max(256)).max(128).optional(),
119
+ /** Infer ownership from corpus paths/frontmatter (default true). */
120
+ ownershipFromCorpus: z.boolean().optional(),
119
121
  ownership: z.record(z.string().min(1).max(256), OwnershipEntrySchema).optional(),
120
122
  intents: z.array(
121
123
  z.object({
@@ -135,7 +137,8 @@ var RoutingConfigSchema = z.object({
135
137
  }).strict().optional()
136
138
  }).strict();
137
139
  var GatesConfigSchema = z.object({
138
- preset: z.enum(["minimal", "standard", "strict"]).optional(),
140
+ /** minimal: freshness · standard: + human links · strict: + okf-type · playbook: freshness + okf soft style */
141
+ preset: z.enum(["minimal", "standard", "strict", "playbook"]).optional(),
139
142
  include: z.array(
140
143
  z.enum([
141
144
  "index-freshness",
@@ -343,16 +346,80 @@ var projectRootFromConfigPath = (configFilePath, projectRootField) => {
343
346
  };
344
347
 
345
348
  // src/index-builder/build-index.ts
346
- import { mkdirSync, readFileSync as readFileSync7, writeFileSync } from "fs";
347
- import { dirname as dirname3, join as join9 } from "path";
349
+ import { mkdirSync, readFileSync as readFileSync8, writeFileSync } from "fs";
350
+ import { dirname as dirname3, join as join10 } from "path";
348
351
 
349
352
  // src/lib/paths.ts
350
353
  import { resolve as resolve2 } from "path";
351
354
  var toPosix = (value) => value.split("\\").join("/");
352
355
 
356
+ // src/lib/package-manager.ts
357
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
358
+ import { join as join2 } from "path";
359
+ var detectPackageManager = (root) => {
360
+ if (existsSync2(join2(root, "pnpm-lock.yaml")) || existsSync2(join2(root, "pnpm-workspace.yaml"))) {
361
+ return "pnpm";
362
+ }
363
+ if (existsSync2(join2(root, "yarn.lock"))) return "yarn";
364
+ if (existsSync2(join2(root, "bun.lockb")) || existsSync2(join2(root, "bun.lock"))) return "bun";
365
+ if (existsSync2(join2(root, "package-lock.json"))) return "npm";
366
+ try {
367
+ const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
368
+ const pm = pkg.packageManager?.split("@")[0];
369
+ if (pm === "pnpm" || pm === "npm" || pm === "yarn" || pm === "bun") return pm;
370
+ } catch {
371
+ }
372
+ return "npm";
373
+ };
374
+ var defaultChecksForTarget = (root, opts) => {
375
+ const pm = detectPackageManager(root);
376
+ if (/\.mdx?$/.test(opts.packagePath) || opts.packagePath.includes("/pillars/")) {
377
+ try {
378
+ const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
379
+ const scripts = pkg.scripts ?? {};
380
+ if (scripts["check:okf-type"]) return ["pnpm run check:okf-type"];
381
+ if (scripts["docs:bridge:gate"]) return ["pnpm run docs:bridge:gate"];
382
+ if (scripts.test) return [pm === "pnpm" ? "pnpm test" : "npm test"];
383
+ } catch {
384
+ }
385
+ }
386
+ const isWorkspace = existsSync2(join2(root, "pnpm-workspace.yaml")) || existsSync2(join2(root, "lerna.json")) || Boolean(
387
+ (() => {
388
+ try {
389
+ const pkg = JSON.parse(readFileSync2(join2(root, "package.json"), "utf8"));
390
+ return Boolean(pkg.workspaces);
391
+ } catch {
392
+ return false;
393
+ }
394
+ })()
395
+ );
396
+ const filter = opts.packageName ?? (opts.packagePath.startsWith("packages/") || opts.packagePath.startsWith("apps/") ? opts.packageId : void 0);
397
+ if (pm === "pnpm") {
398
+ if (isWorkspace && filter) {
399
+ const base = [`pnpm --filter ${filter} test`];
400
+ if (opts.strict) base.push(`pnpm --filter ${filter} lint`);
401
+ return base;
402
+ }
403
+ return opts.strict ? ["pnpm test", "pnpm run lint"] : ["pnpm test"];
404
+ }
405
+ if (pm === "yarn") {
406
+ if (isWorkspace && filter) {
407
+ return opts.strict ? [`yarn workspace ${filter} test`, `yarn workspace ${filter} lint`] : [`yarn workspace ${filter} test`];
408
+ }
409
+ return opts.strict ? ["yarn test", "yarn lint"] : ["yarn test"];
410
+ }
411
+ if (pm === "bun") {
412
+ return opts.strict ? ["bun test", "bun run lint"] : ["bun test"];
413
+ }
414
+ if (isWorkspace && filter) {
415
+ return opts.strict ? [`npm test -w ${filter}`, `npm run lint -w ${filter}`] : [`npm test -w ${filter}`];
416
+ }
417
+ return opts.strict ? ["npm test", "npm run lint"] : ["npm test"];
418
+ };
419
+
353
420
  // src/index-builder/scan-corpus.ts
354
- import { readFileSync as readFileSync2 } from "fs";
355
- import { join as join3 } from "path";
421
+ import { readFileSync as readFileSync3 } from "fs";
422
+ import { join as join4 } from "path";
356
423
 
357
424
  // src/lib/markdown.ts
358
425
  var parseFrontmatter = (markdown) => {
@@ -428,7 +495,7 @@ var slugFromPath = (relPath) => {
428
495
 
429
496
  // src/lib/walk.ts
430
497
  import { readdirSync, statSync } from "fs";
431
- import { join as join2 } from "path";
498
+ import { join as join3 } from "path";
432
499
  var DEFAULT_SKIP = /* @__PURE__ */ new Set(["node_modules", ".git", "dist", "coverage", ".doc-bridge"]);
433
500
  var walkFiles = (root, opts) => {
434
501
  const extensions = opts?.extensions ?? [".md"];
@@ -442,7 +509,7 @@ var walkFiles = (root, opts) => {
442
509
  return;
443
510
  }
444
511
  for (const name of entries) {
445
- const abs = join2(dir, name);
512
+ const abs = join3(dir, name);
446
513
  let st;
447
514
  try {
448
515
  st = statSync(abs);
@@ -466,13 +533,13 @@ var walkFiles = (root, opts) => {
466
533
 
467
534
  // src/index-builder/scan-corpus.ts
468
535
  var scanAgentCorpus = (root, config) => {
469
- const agentRoot = join3(root, config.corpus.agent.root);
536
+ const agentRoot = join4(root, config.corpus.agent.root);
470
537
  const files = walkFiles(agentRoot, { extensions: [".md", ".mdx"] });
471
538
  const corpusRelRoot = toPosix(config.corpus.agent.root);
472
539
  return files.map((abs) => {
473
540
  const relToCorpus = toPosix(abs.replace(`${toPosix(agentRoot)}/`, ""));
474
541
  const relPath = `${corpusRelRoot}/${relToCorpus}`;
475
- const raw = readFileSync2(abs, "utf8");
542
+ const raw = readFileSync3(abs, "utf8");
476
543
  const { data: frontmatter } = parseFrontmatter(raw);
477
544
  const id = frontmatterString(frontmatter, "id") ?? frontmatterString(frontmatter, "package") ?? slugFromPath(relToCorpus);
478
545
  const title = firstHeading(raw) ?? id;
@@ -490,16 +557,29 @@ var scanAgentCorpus = (root, config) => {
490
557
  });
491
558
  };
492
559
  var guessAgentDocForPackage = (corpus, packageId) => {
493
- const exact = corpus.find(
494
- (doc) => frontmatterString(doc.frontmatter, "package") === packageId || doc.relPath.endsWith(`/packages/${packageId}.md`) || doc.relPath.endsWith(`/${packageId}.md`) || doc.id === packageId
495
- );
496
- return exact?.path;
560
+ const candidates = [
561
+ (doc) => frontmatterString(doc.frontmatter, "package") === packageId,
562
+ (doc) => doc.id === packageId,
563
+ (doc) => doc.relPath.endsWith(`/packages/${packageId}.md`),
564
+ (doc) => doc.relPath.endsWith(`/packages/${packageId}.mdx`),
565
+ (doc) => doc.relPath.endsWith(`/packages/${packageId}/index.md`),
566
+ (doc) => doc.relPath.endsWith(`/packages/${packageId}/index.mdx`),
567
+ (doc) => doc.relPath.endsWith(`/${packageId}.md`),
568
+ (doc) => doc.relPath.endsWith(`/${packageId}.mdx`),
569
+ (doc) => doc.relPath.includes(`/packages/${packageId}/`)
570
+ ];
571
+ for (const match of candidates) {
572
+ const hit = corpus.find(match);
573
+ if (hit) return hit.path;
574
+ }
575
+ return void 0;
497
576
  };
498
577
  var ownershipFromFrontmatter = (corpus) => {
499
578
  const out = [];
500
579
  for (const doc of corpus) {
501
- const id = frontmatterString(doc.frontmatter, "package") ?? (frontmatterString(doc.frontmatter, "type") === "package" ? frontmatterString(doc.frontmatter, "id") ?? doc.id : void 0);
502
- const path = frontmatterString(doc.frontmatter, "editRoot") ?? frontmatterString(doc.frontmatter, "path");
580
+ const type = frontmatterString(doc.frontmatter, "type");
581
+ const id = frontmatterString(doc.frontmatter, "package") ?? (type === "package" || type === "module" || type === "pattern" ? frontmatterString(doc.frontmatter, "id") ?? doc.id : void 0);
582
+ const path = frontmatterString(doc.frontmatter, "editRoot") ?? frontmatterString(doc.frontmatter, "path") ?? (type === "package" || type === "module" ? `packages/${id}` : void 0);
503
583
  if (!id || !path) continue;
504
584
  const purpose = frontmatterString(doc.frontmatter, "purpose") ?? doc.description;
505
585
  const checks = frontmatterStringList(doc.frontmatter, "checks");
@@ -515,13 +595,55 @@ var ownershipFromFrontmatter = (corpus) => {
515
595
  }
516
596
  return out;
517
597
  };
598
+ var ownershipFromCorpus = (corpus) => {
599
+ const out = [];
600
+ const seen = /* @__PURE__ */ new Set();
601
+ for (const doc of corpus) {
602
+ if (frontmatterString(doc.frontmatter, "package") && frontmatterString(doc.frontmatter, "editRoot")) {
603
+ continue;
604
+ }
605
+ let id;
606
+ let path;
607
+ let purpose = frontmatterString(doc.frontmatter, "purpose") ?? doc.description;
608
+ const packagesFile = /(?:^|\/)packages\/([^/]+)\.(?:md|mdx)$/.exec(doc.relPath);
609
+ const packagesIndex = /(?:^|\/)packages\/([^/]+)\/index\.(?:md|mdx)$/.exec(doc.relPath);
610
+ const registryReadme = /(?:^|\/)registry\/([^/]+)\/README\.(?:md|mdx)$/i.exec(doc.relPath);
611
+ const patternFile = /(?:^|\/)pillars\/[^/]+\/([^/]+(?:-pattern)?)\.(?:md|mdx)$/.exec(doc.relPath);
612
+ const topLevelPkg = /(?:^|\/)for-agents\/([^/]+)\.(?:md|mdx)$/.exec(doc.relPath);
613
+ if (packagesFile?.[1] && packagesFile[1] !== "index") {
614
+ id = packagesFile[1];
615
+ path = `packages/${id}`;
616
+ } else if (packagesIndex?.[1]) {
617
+ id = packagesIndex[1];
618
+ path = `packages/${id}`;
619
+ } else if (registryReadme?.[1]) {
620
+ id = registryReadme[1];
621
+ path = `registry/${id}`;
622
+ } else if (patternFile?.[1] && patternFile[1] !== "index" && patternFile[1] !== "universal") {
623
+ id = patternFile[1];
624
+ path = doc.path;
625
+ purpose = purpose ?? `Playbook pattern: ${id}`;
626
+ } else if (topLevelPkg?.[1] && topLevelPkg[1] !== "index" && topLevelPkg[1] !== "INDEX") {
627
+ id = topLevelPkg[1];
628
+ path = `packages/${id}`;
629
+ }
630
+ if (!id || !path || seen.has(id)) continue;
631
+ seen.add(id);
632
+ const humanDoc = frontmatterString(doc.frontmatter, "humanDoc");
633
+ const checks = frontmatterStringList(doc.frontmatter, "checks");
634
+ out.push({
635
+ id,
636
+ path,
637
+ agentDoc: doc.path,
638
+ ...purpose ? { purpose } : {},
639
+ ...checks ? { checks } : {},
640
+ ...humanDoc ? { humanDoc } : {}
641
+ });
642
+ }
643
+ return out;
644
+ };
518
645
 
519
646
  // src/index-builder/build-handoffs.ts
520
- var defaultChecks = (config) => {
521
- const preset = config.gates?.preset ?? "minimal";
522
- if (preset === "strict" || preset === "standard") return ["npm test", "npm run lint"];
523
- return ["npm test"];
524
- };
525
647
  var collectPackages = (config, discovered, corpus) => {
526
648
  const byId = /* @__PURE__ */ new Map();
527
649
  for (const [id, entry] of Object.entries(config.routing?.options?.ownership ?? {})) {
@@ -539,7 +661,11 @@ var collectPackages = (config, discovered, corpus) => {
539
661
  ...pkg.name ? { name: pkg.name } : existing.name ? { name: existing.name } : {}
540
662
  });
541
663
  }
542
- for (const seed of ownershipFromFrontmatter(corpus)) {
664
+ const seeds = [
665
+ ...ownershipFromFrontmatter(corpus),
666
+ ...config.routing?.options?.ownershipFromCorpus === false ? [] : ownershipFromCorpus(corpus)
667
+ ];
668
+ for (const seed of seeds) {
543
669
  const existing = byId.get(seed.id);
544
670
  if (!existing) {
545
671
  byId.set(seed.id, { id: seed.id, path: seed.path });
@@ -551,22 +677,51 @@ var collectPackages = (config, discovered, corpus) => {
551
677
  }
552
678
  return [...byId.values()].sort((a, b) => a.id.localeCompare(b.id));
553
679
  };
554
- var buildLookup = (config, packages, corpus, indexOutFile, humanDocs = {}) => {
680
+ var resolveHumanDoc = (packageId, override, fmHuman, humanDocs = {}) => {
681
+ if (override) return override;
682
+ if (fmHuman) return fmHuman;
683
+ if (humanDocs[packageId]) return humanDocs[packageId];
684
+ const aliases = [
685
+ packageId,
686
+ packageId.replace(/^@[^/]+\//, ""),
687
+ packageId.replace(/^os-/, ""),
688
+ packageId.replace(/-pattern$/, "")
689
+ ];
690
+ for (const alias of aliases) {
691
+ if (humanDocs[alias]) return humanDocs[alias];
692
+ }
693
+ return void 0;
694
+ };
695
+ var buildLookup = (config, packages, corpus, indexOutFile, humanDocs = {}, root = process.cwd()) => {
555
696
  const ownership = {};
556
697
  const handoffs = {};
557
- const checks = defaultChecks(config);
558
- const fmSeeds = new Map(ownershipFromFrontmatter(corpus).map((seed) => [seed.id, seed]));
698
+ const strict = (config.gates?.preset ?? "minimal") !== "minimal";
699
+ const fmSeeds = new Map(
700
+ [...ownershipFromFrontmatter(corpus), ...ownershipFromCorpus(corpus)].map((seed) => [
701
+ seed.id,
702
+ seed
703
+ ])
704
+ );
559
705
  for (const pkg of packages) {
560
706
  const override = config.routing?.options?.ownership?.[pkg.id];
561
707
  const fm = fmSeeds.get(pkg.id);
562
708
  const agentDoc = override?.agentDoc ?? fm?.agentDoc ?? guessAgentDocForPackage(corpus, pkg.id) ?? config.corpus.agent.index;
563
709
  const startHere = agentDoc ?? "";
564
710
  const purpose = override?.purpose ?? fm?.purpose;
565
- const humanDoc = override?.humanDoc ?? fm?.humanDoc ?? humanDocs[pkg.id];
711
+ const path = override?.path ?? fm?.path ?? pkg.path;
712
+ const checks = [
713
+ ...override?.checks ?? fm?.checks ?? defaultChecksForTarget(root, {
714
+ packageId: pkg.id,
715
+ packagePath: path,
716
+ ...pkg.name ? { packageName: pkg.name } : {},
717
+ strict
718
+ })
719
+ ];
720
+ const humanDoc = resolveHumanDoc(pkg.id, override?.humanDoc, fm?.humanDoc, humanDocs);
566
721
  const record = {
567
722
  id: pkg.id,
568
- path: override?.path ?? fm?.path ?? pkg.path,
569
- checks: [...override?.checks ?? fm?.checks ?? checks],
723
+ path,
724
+ checks,
570
725
  ...override?.group ? { group: override.group } : {},
571
726
  ...override?.layer ? { layer: override.layer } : {},
572
727
  ...purpose ? { purpose } : {},
@@ -620,7 +775,7 @@ var buildLookup = (config, packages, corpus, indexOutFile, humanDocs = {}) => {
620
775
  };
621
776
 
622
777
  // src/version.ts
623
- var PACKAGE_VERSION = "0.1.0-alpha.1";
778
+ var PACKAGE_VERSION = "0.1.0-alpha.2";
624
779
 
625
780
  // src/index-builder/capabilities.ts
626
781
  var renderCapabilitiesJson = (config, index, paths) => {
@@ -689,13 +844,13 @@ ${lines.join("\n")}
689
844
  };
690
845
 
691
846
  // src/index-builder/human-adapters/docusaurus.ts
692
- import { existsSync as existsSync2, readFileSync as readFileSync4 } from "fs";
693
- import { join as join5 } from "path";
847
+ import { existsSync as existsSync3, readFileSync as readFileSync5 } from "fs";
848
+ import { join as join6 } from "path";
694
849
  import vm2 from "vm";
695
850
 
696
851
  // src/index-builder/human-adapters/core.ts
697
- import { readFileSync as readFileSync3 } from "fs";
698
- import { join as join4 } from "path";
852
+ import { readFileSync as readFileSync4 } from "fs";
853
+ import { join as join5 } from "path";
699
854
  var optionString = (options, keys) => {
700
855
  for (const key of keys) {
701
856
  const value = options?.[key];
@@ -726,10 +881,10 @@ var humanUrl = (slug, urlPrefix) => {
726
881
  };
727
882
  var scanMarkdownDocs = (root, humanRoot, options) => {
728
883
  const out = [];
729
- const absRoot = join4(root, humanRoot);
884
+ const absRoot = join5(root, humanRoot);
730
885
  for (const abs of walkFiles(absRoot, { extensions: [".md", ".mdx"] })) {
731
886
  const relToHumanRoot = toPosix(abs.replace(`${toPosix(absRoot)}/`, ""));
732
- const raw = readFileSync3(abs, "utf8");
887
+ const raw = readFileSync4(abs, "utf8");
733
888
  if (options?.includeRelPath && !options.includeRelPath(relToHumanRoot, raw)) continue;
734
889
  out.push({
735
890
  id: options?.idForDoc?.(relToHumanRoot, raw) ?? docId(relToHumanRoot, raw),
@@ -768,8 +923,8 @@ var docusaurusRecordId = (relPath, raw) => {
768
923
  return frontmatter.package ?? frontmatter.module ?? docusaurusSidebarId(relPath, raw);
769
924
  };
770
925
  var sidebarsValue = (file) => {
771
- if (!existsSync2(file)) return void 0;
772
- const raw = readFileSync4(file, "utf8").replace(/import\s+type\s+[\s\S]*?;?\n/g, "").replace(/:\s*[A-Za-z0-9_.$<>{}\[\],\s]+(?=\s*=)/g, "").replace(/\s+satisfies\s+[A-Za-z0-9_.$<>{}\[\],\s]+(?=\s*(?:;|\n|$))/g, "").replace(/export\s+default/, "module.exports =");
926
+ if (!existsSync3(file)) return void 0;
927
+ const raw = readFileSync5(file, "utf8").replace(/import\s+type\s+[\s\S]*?;?\n/g, "").replace(/:\s*[A-Za-z0-9_.$<>{}\[\],\s]+(?=\s*=)/g, "").replace(/\s+satisfies\s+[A-Za-z0-9_.$<>{}\[\],\s]+(?=\s*(?:;|\n|$))/g, "").replace(/export\s+default/, "module.exports =");
773
928
  const sandbox = { module: { exports: {} }, exports: {} };
774
929
  vm2.runInNewContext(raw, sandbox, { timeout: 250 });
775
930
  return sandbox.module.exports;
@@ -799,7 +954,7 @@ var visitSidebar = (value, filter) => {
799
954
  };
800
955
  var readSidebars = (root, sidebarsFile) => {
801
956
  if (!sidebarsFile) return { enabled: false, ids: /* @__PURE__ */ new Set(), autogenDirs: [] };
802
- const value = sidebarsValue(join5(root, sidebarsFile));
957
+ const value = sidebarsValue(join6(root, sidebarsFile));
803
958
  const filter = { ids: /* @__PURE__ */ new Set(), autogenDirs: [] };
804
959
  visitSidebar(value, filter);
805
960
  return { enabled: true, ...filter };
@@ -828,13 +983,13 @@ var docusaurusAdapter = {
828
983
  };
829
984
 
830
985
  // src/index-builder/human-adapters/fumadocs.ts
831
- import { existsSync as existsSync3, readFileSync as readFileSync5 } from "fs";
832
- import { join as join6 } from "path";
986
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
987
+ import { join as join7 } from "path";
833
988
  var readMetaPages = (dir) => {
834
- const file = join6(dir, "meta.json");
835
- if (!existsSync3(file)) return void 0;
989
+ const file = join7(dir, "meta.json");
990
+ if (!existsSync4(file)) return void 0;
836
991
  try {
837
- const meta = JSON.parse(readFileSync5(file, "utf8"));
992
+ const meta = JSON.parse(readFileSync6(file, "utf8"));
838
993
  return Array.isArray(meta.pages) ? meta.pages.filter((page) => typeof page === "string") : void 0;
839
994
  } catch {
840
995
  return void 0;
@@ -849,7 +1004,7 @@ var isListedByMeta = (contentRoot, relPath) => {
849
1004
  if (isDotFile(relPath)) return false;
850
1005
  const parts = relPath.split("/");
851
1006
  for (let i = 0; i < parts.length; i += 1) {
852
- const dir = join6(contentRoot, ...parts.slice(0, i));
1007
+ const dir = join7(contentRoot, ...parts.slice(0, i));
853
1008
  const pages = readMetaPages(dir);
854
1009
  if (!pages?.length || pages.includes("...")) continue;
855
1010
  const key = pageKey(parts[i] ?? "");
@@ -862,9 +1017,16 @@ var fumadocsAdapter = {
862
1017
  scan: ({ root, config }) => {
863
1018
  const contentDir = optionString(config.options, ["contentDir", "root"]);
864
1019
  if (!contentDir) return [];
865
- const contentRoot = join6(root, contentDir);
1020
+ const contentRoot = join7(root, contentDir);
1021
+ const excludePrefixes = Array.isArray(config.options?.excludePrefixes) ? config.options.excludePrefixes.filter((v) => typeof v === "string") : typeof config.options?.excludePrefix === "string" ? [config.options.excludePrefix] : [];
1022
+ if (!excludePrefixes.includes("for-agents")) excludePrefixes.push("for-agents");
866
1023
  return scanMarkdownDocs(root, contentDir, {
867
- includeRelPath: (relPath) => isListedByMeta(contentRoot, relPath),
1024
+ includeRelPath: (relPath) => {
1025
+ if (excludePrefixes.some((prefix) => relPath === prefix || relPath.startsWith(`${prefix}/`))) {
1026
+ return false;
1027
+ }
1028
+ return isListedByMeta(contentRoot, relPath);
1029
+ },
868
1030
  urlPrefix: config.options?.urlPrefix,
869
1031
  stripGroups: true
870
1032
  });
@@ -875,7 +1037,7 @@ var fumadocsAdapter = {
875
1037
  var plainMarkdownAdapter = {
876
1038
  plugin: "plain-markdown",
877
1039
  scan: ({ root, config }) => {
878
- const humanRoot = optionString(config.options, ["root"]) ?? "docs";
1040
+ const humanRoot = optionString(config.options, ["contentDir", "root", "docsDir"]) ?? "docs";
879
1041
  return scanMarkdownDocs(root, humanRoot, { urlPrefix: config.options?.urlPrefix });
880
1042
  }
881
1043
  };
@@ -894,10 +1056,14 @@ var humanConfigs = (config) => {
894
1056
  var scanHumanDocRecords = (root, config) => {
895
1057
  const out = [];
896
1058
  const seen = /* @__PURE__ */ new Set();
1059
+ const agentRoot = config.corpus.agent.root.replace(/\/$/, "");
897
1060
  for (const human of humanConfigs(config)) {
898
1061
  const adapter = ADAPTERS.find((candidate) => candidate.plugin === human.plugin);
899
1062
  if (!adapter) continue;
900
1063
  for (const record of adapter.scan({ root, config: human })) {
1064
+ if (record.path === agentRoot || record.path.startsWith(`${agentRoot}/`) || record.path.includes("/for-agents/") || record.path.endsWith("/for-agents")) {
1065
+ continue;
1066
+ }
901
1067
  if (seen.has(record.id)) continue;
902
1068
  seen.add(record.id);
903
1069
  out.push(record);
@@ -908,26 +1074,26 @@ var scanHumanDocRecords = (root, config) => {
908
1074
  var scanHumanDocs = (root, config) => Object.fromEntries(scanHumanDocRecords(root, config).map((doc) => [doc.id, doc.url]));
909
1075
 
910
1076
  // src/index-builder/plugins/pnpm-monorepo.ts
911
- import { existsSync as existsSync5, readFileSync as readFileSync6 } from "fs";
912
- import { basename as basename2, join as join8 } from "path";
1077
+ import { existsSync as existsSync6, readFileSync as readFileSync7 } from "fs";
1078
+ import { basename as basename2, join as join9 } from "path";
913
1079
 
914
1080
  // src/lib/glob-expand.ts
915
- import { existsSync as existsSync4, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
916
- import { join as join7 } from "path";
1081
+ import { existsSync as existsSync5, readdirSync as readdirSync2, statSync as statSync2 } from "fs";
1082
+ import { join as join8 } from "path";
917
1083
  var expandWorkspaceGlobs = (root, patterns) => {
918
1084
  const dirs = /* @__PURE__ */ new Set();
919
1085
  for (const pattern of patterns) {
920
1086
  const normalized = toPosix(pattern).replace(/\/$/, "");
921
1087
  if (!normalized.includes("*")) {
922
- const abs = join7(root, normalized);
923
- if (existsSync4(abs)) dirs.add(toPosix(abs));
1088
+ const abs = join8(root, normalized);
1089
+ if (existsSync5(abs)) dirs.add(toPosix(abs));
924
1090
  continue;
925
1091
  }
926
1092
  const star = normalized.indexOf("*");
927
- const base = join7(root, normalized.slice(0, star).replace(/\/$/, ""));
928
- if (!existsSync4(base)) continue;
1093
+ const base = join8(root, normalized.slice(0, star).replace(/\/$/, ""));
1094
+ if (!existsSync5(base)) continue;
929
1095
  for (const name of readdirSync2(base)) {
930
- const abs = join7(base, name);
1096
+ const abs = join8(base, name);
931
1097
  try {
932
1098
  if (statSync2(abs).isDirectory()) dirs.add(toPosix(abs));
933
1099
  } catch {
@@ -959,10 +1125,10 @@ var parsePnpmWorkspace = (yaml) => {
959
1125
  return patterns;
960
1126
  };
961
1127
  var readPackageJson = (dir) => {
962
- const file = join8(dir, "package.json");
963
- if (!existsSync5(file)) return null;
1128
+ const file = join9(dir, "package.json");
1129
+ if (!existsSync6(file)) return null;
964
1130
  try {
965
- return JSON.parse(readFileSync6(file, "utf8"));
1131
+ return JSON.parse(readFileSync7(file, "utf8"));
966
1132
  } catch {
967
1133
  return null;
968
1134
  }
@@ -971,9 +1137,9 @@ var discoverPnpmPackages = (root, config) => {
971
1137
  const explicit = config.routing?.options?.packages;
972
1138
  let patterns = explicit;
973
1139
  if (!patterns?.length) {
974
- const workspaceFile = join8(root, "pnpm-workspace.yaml");
975
- if (existsSync5(workspaceFile)) {
976
- patterns = parsePnpmWorkspace(readFileSync6(workspaceFile, "utf8"));
1140
+ const workspaceFile = join9(root, "pnpm-workspace.yaml");
1141
+ if (existsSync6(workspaceFile)) {
1142
+ patterns = parsePnpmWorkspace(readFileSync7(workspaceFile, "utf8"));
977
1143
  }
978
1144
  }
979
1145
  if (!patterns?.length) return [];
@@ -994,7 +1160,7 @@ var discoverPnpmPackages = (root, config) => {
994
1160
  var projectName = (root, config) => {
995
1161
  if (config.project?.name) return config.project.name;
996
1162
  try {
997
- const pkg = JSON.parse(readFileSync7(join9(root, "package.json"), "utf8"));
1163
+ const pkg = JSON.parse(readFileSync8(join10(root, "package.json"), "utf8"));
998
1164
  if (pkg.name) return pkg.name;
999
1165
  } catch {
1000
1166
  }
@@ -1002,7 +1168,7 @@ var projectName = (root, config) => {
1002
1168
  };
1003
1169
  var existingGeneratedAt = (indexPath, contentHash) => {
1004
1170
  try {
1005
- const index = JSON.parse(readFileSync7(indexPath, "utf8"));
1171
+ const index = JSON.parse(readFileSync8(indexPath, "utf8"));
1006
1172
  return index.contentHash === contentHash && typeof index.generatedAt === "string" ? index.generatedAt : void 0;
1007
1173
  } catch {
1008
1174
  return void 0;
@@ -1013,14 +1179,14 @@ var buildDocBridgeIndex = (opts) => {
1013
1179
  const config = opts.config;
1014
1180
  const write = opts.write ?? true;
1015
1181
  const outFile = config.index?.outFile ?? ".doc-bridge/index.json";
1016
- const indexPath = join9(root, outFile);
1182
+ const indexPath = join10(root, outFile);
1017
1183
  const corpus = scanAgentCorpus(root, config);
1018
1184
  const knowledge = corpus.map(({ absPath: _a, relPath: _r, frontmatter: _f, ...entry }) => entry);
1019
1185
  const shouldDiscover = config.routing?.plugin === "pnpm-monorepo" || Boolean(config.routing?.options?.packages?.length) || config.routing?.plugin === "npm-workspaces" || config.routing?.plugin === "yarn-workspaces";
1020
1186
  const discovered = shouldDiscover ? discoverPnpmPackages(root, config) : [];
1021
1187
  const packages = collectPackages(config, discovered, corpus);
1022
1188
  const humanDocs = scanHumanDocs(root, config);
1023
- const { lookup, handoffs } = buildLookup(config, packages, corpus, outFile, humanDocs);
1189
+ const { lookup, handoffs } = buildLookup(config, packages, corpus, outFile, humanDocs, root);
1024
1190
  const hashPayload = {
1025
1191
  schemaVersion: 1,
1026
1192
  knowledge,
@@ -1048,7 +1214,7 @@ var buildDocBridgeIndex = (opts) => {
1048
1214
  if (config.index?.llmsTxt?.enabled !== false) {
1049
1215
  const llmsOut = config.index?.llmsTxt?.outFile ?? "llms.txt";
1050
1216
  llmsTxtRelPath = toPosix(llmsOut);
1051
- llmsTxtPath = join9(root, llmsOut);
1217
+ llmsTxtPath = join10(root, llmsOut);
1052
1218
  if (write) {
1053
1219
  writeFileSync(
1054
1220
  llmsTxtPath,
@@ -1060,7 +1226,7 @@ var buildDocBridgeIndex = (opts) => {
1060
1226
  let capabilitiesPath;
1061
1227
  if (config.index?.capabilities?.enabled !== false) {
1062
1228
  const capabilitiesOut = config.index?.capabilities?.outFile ?? ".doc-bridge/capabilities.json";
1063
- capabilitiesPath = join9(root, capabilitiesOut);
1229
+ capabilitiesPath = join10(root, capabilitiesOut);
1064
1230
  if (write) {
1065
1231
  mkdirSync(dirname3(capabilitiesPath), { recursive: true });
1066
1232
  writeFileSync(
@@ -1082,7 +1248,7 @@ var buildDocBridgeIndex = (opts) => {
1082
1248
  };
1083
1249
 
1084
1250
  // src/federation/llms.ts
1085
- import { existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
1251
+ import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
1086
1252
  import { resolve as resolve3 } from "path";
1087
1253
 
1088
1254
  // src/query/search.ts
@@ -1164,8 +1330,8 @@ var defaultFetchText = async (url) => {
1164
1330
  var sourceText = async (root, source, fetchText) => {
1165
1331
  if (/^https?:\/\//.test(source)) return fetchText(source);
1166
1332
  const path = resolve3(root, source);
1167
- if (!existsSync6(path)) throw new Error(`Federation source not found: ${source}`);
1168
- return readFileSync8(path, "utf8");
1333
+ if (!existsSync7(path)) throw new Error(`Federation source not found: ${source}`);
1334
+ return readFileSync9(path, "utf8");
1169
1335
  };
1170
1336
  var sameOrigin = (base, target) => {
1171
1337
  if (!/^https?:\/\//.test(base) || !/^https?:\/\//.test(target)) return true;
@@ -1241,11 +1407,11 @@ var retrieveHybridChunks = async (root, config, index, query, options = {}) => {
1241
1407
  };
1242
1408
 
1243
1409
  // src/gates/run-gates.ts
1244
- import { readFileSync as readFileSync10 } from "fs";
1410
+ import { readFileSync as readFileSync11 } from "fs";
1245
1411
 
1246
1412
  // src/query/load-index.ts
1247
- import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
1248
- import { join as join10, resolve as resolve4 } from "path";
1413
+ import { existsSync as existsSync8, readFileSync as readFileSync10 } from "fs";
1414
+ import { join as join11, resolve as resolve4 } from "path";
1249
1415
 
1250
1416
  // src/schemas/agent-handoff.ts
1251
1417
  import { z as z2 } from "zod";
@@ -1450,11 +1616,11 @@ var IndexNotFoundError = class extends Error {
1450
1616
  }
1451
1617
  path;
1452
1618
  };
1453
- var indexFilePath = (root, config) => join10(root, config.index?.outFile ?? ".doc-bridge/index.json");
1619
+ var indexFilePath = (root, config) => join11(root, config.index?.outFile ?? ".doc-bridge/index.json");
1454
1620
  var loadDocBridgeIndex = (root, config) => {
1455
1621
  const path = indexFilePath(root, config);
1456
- if (!existsSync7(path)) throw new IndexNotFoundError(path);
1457
- const raw = JSON.parse(readFileSync9(path, "utf8"));
1622
+ if (!existsSync8(path)) throw new IndexNotFoundError(path);
1623
+ const raw = JSON.parse(readFileSync10(path, "utf8"));
1458
1624
  return parseDocBridgeIndex(raw);
1459
1625
  };
1460
1626
 
@@ -1518,7 +1684,7 @@ var runOkfTypeGate = (root, config) => {
1518
1684
  const required = config.corpus.agent.okf?.requireType ?? config.gates?.preset === "strict";
1519
1685
  if (!required) return { id: "okf-type", ok: true, message: "OKF type frontmatter not required" };
1520
1686
  const allowed = config.corpus.agent.okf?.allowedTypes;
1521
- const bad = scanAgentCorpus(root, config).filter((doc) => doc.path !== config.corpus.agent.index).map((doc) => ({ path: doc.path, type: frontmatterType(readFileSync10(doc.absPath, "utf8")) })).filter((doc) => !doc.type || allowed && !allowed.includes(doc.type));
1687
+ const bad = scanAgentCorpus(root, config).filter((doc) => doc.path !== config.corpus.agent.index).map((doc) => ({ path: doc.path, type: frontmatterType(readFileSync11(doc.absPath, "utf8")) })).filter((doc) => !doc.type || allowed && !allowed.includes(doc.type));
1522
1688
  if (bad.length) {
1523
1689
  return {
1524
1690
  id: "okf-type",
@@ -1539,13 +1705,22 @@ var DOCS_STYLE_RULES = {
1539
1705
  "examples",
1540
1706
  "no-stale-wording"
1541
1707
  ],
1542
- "playbook-okf": ["title", "purpose", "owner-source", "no-stale-wording"]
1708
+ /** Full playbook OKF style (strict). */
1709
+ "playbook-okf": ["title", "purpose", "owner-source", "no-stale-wording"],
1710
+ /** Soft profile for large existing OKF corpora (title + no stale placeholders). */
1711
+ "playbook-okf-soft": ["title", "no-stale-wording"],
1712
+ "title-only": ["title"]
1543
1713
  };
1544
1714
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1545
1715
  var docsStyleOptions = (config) => {
1546
1716
  const raw = config.gates?.options?.["docs-style"];
1547
- if (!isRecord(raw)) return { profile: "playbook-okf", required: DOCS_STYLE_RULES["playbook-okf"] };
1548
- const profile = raw.profile === "google-dev-docs" || raw.profile === "playbook-okf" || raw.profile === "custom" ? raw.profile : "playbook-okf";
1717
+ if (!isRecord(raw)) {
1718
+ if (config.gates?.preset === "playbook") {
1719
+ return { profile: "playbook-okf-soft", required: DOCS_STYLE_RULES["playbook-okf-soft"] };
1720
+ }
1721
+ return { profile: "playbook-okf", required: DOCS_STYLE_RULES["playbook-okf"] };
1722
+ }
1723
+ const profile = raw.profile === "google-dev-docs" || raw.profile === "playbook-okf" || raw.profile === "playbook-okf-soft" || raw.profile === "title-only" || raw.profile === "custom" ? raw.profile : "playbook-okf";
1549
1724
  const customRequired = Array.isArray(raw.required) ? raw.required.filter(
1550
1725
  (rule) => [
1551
1726
  "title",
@@ -1583,7 +1758,7 @@ var runDocsStyleGate = (root, config) => {
1583
1758
  }
1584
1759
  const bad = scanAgentCorpus(root, config).filter((doc) => doc.path !== config.corpus.agent.index).map((doc) => ({
1585
1760
  path: doc.path,
1586
- missing: missingStyleRules(readFileSync10(doc.absPath, "utf8"), required)
1761
+ missing: missingStyleRules(readFileSync11(doc.absPath, "utf8"), required)
1587
1762
  })).filter((doc) => doc.missing.length > 0);
1588
1763
  if (bad.length) {
1589
1764
  return {
@@ -1607,7 +1782,10 @@ var runGates = (root, config, ids) => {
1607
1782
  var resolveGateIds = (config) => {
1608
1783
  const preset = config.gates?.preset ?? "minimal";
1609
1784
  const ids = new Set(
1610
- preset === "minimal" ? ["index-freshness"] : preset === "strict" ? ["index-freshness", "human-guide-links", "okf-type"] : ["index-freshness", "human-guide-links"]
1785
+ preset === "minimal" ? ["index-freshness"] : preset === "strict" ? ["index-freshness", "human-guide-links", "okf-type", "docs-style"] : preset === "playbook" ? (
1786
+ // okf-type only — docs-style soft is opt-in via include (large corpora vary)
1787
+ ["index-freshness", "okf-type"]
1788
+ ) : ["index-freshness", "human-guide-links"]
1611
1789
  );
1612
1790
  for (const id of config.gates?.include ?? []) {
1613
1791
  if (SUPPORTED_GATES.includes(id)) ids.add(id);
@@ -1720,7 +1898,7 @@ var runQuery = (index, config, req) => {
1720
1898
  };
1721
1899
 
1722
1900
  // src/intelligence/adapter.ts
1723
- import { join as join11 } from "path";
1901
+ import { join as join12 } from "path";
1724
1902
 
1725
1903
  // src/intelligence/peers.ts
1726
1904
  var PeerMissingError = class extends Error {
@@ -1835,20 +2013,20 @@ var resolveIntelligenceRuntime = async (config) => {
1835
2013
  }
1836
2014
  return { adapter, embed, provider, ...model ? { model } : {} };
1837
2015
  };
1838
- var defaultVectorStorePath = (root) => join11(root, ".doc-bridge", "vectors");
2016
+ var defaultVectorStorePath = (root) => join12(root, ".doc-bridge", "vectors");
1839
2017
 
1840
2018
  // src/intelligence/rag.ts
1841
- import { readFileSync as readFileSync11 } from "fs";
1842
- import { join as join12 } from "path";
2019
+ import { readFileSync as readFileSync12 } from "fs";
2020
+ import { join as join13 } from "path";
1843
2021
  var loadDocuments = (root, index, sources) => {
1844
2022
  const includeAgent = sources.includes("agent") || sources.length === 0;
1845
2023
  const docs = [];
1846
2024
  if (includeAgent) {
1847
2025
  for (const entry of index.knowledge) {
1848
- const abs = join12(root, entry.path);
2026
+ const abs = join13(root, entry.path);
1849
2027
  let content = "";
1850
2028
  try {
1851
- content = readFileSync11(abs, "utf8");
2029
+ content = readFileSync12(abs, "utf8");
1852
2030
  } catch {
1853
2031
  content = [entry.title, entry.description].filter(Boolean).join("\n\n");
1854
2032
  }
@@ -1866,7 +2044,7 @@ var createDocBridgeRag = async (root, config, index) => {
1866
2044
  const { embed } = await resolveIntelligenceRuntime(config);
1867
2045
  const ragMod = await importPeer("@agentskit/rag");
1868
2046
  const memoryMod = await importPeer("@agentskit/memory");
1869
- const storePath = typeof config.intelligence?.retriever?.options?.storePath === "string" ? join12(root, config.intelligence.retriever.options.storePath) : defaultVectorStorePath(root);
2047
+ const storePath = typeof config.intelligence?.retriever?.options?.storePath === "string" ? join13(root, config.intelligence.retriever.options.storePath) : defaultVectorStorePath(root);
1870
2048
  const store = memoryMod.fileVectorMemory({ path: storePath });
1871
2049
  const rag = ragMod.createRAG({
1872
2050
  embed,
@@ -2001,15 +2179,15 @@ var startInkChat = async (root, config, index) => {
2001
2179
  };
2002
2180
 
2003
2181
  // src/memory/ingest.ts
2004
- import { existsSync as existsSync8, readFileSync as readFileSync12 } from "fs";
2005
- import { join as join13 } from "path";
2182
+ import { existsSync as existsSync9, readFileSync as readFileSync13 } from "fs";
2183
+ import { join as join14 } from "path";
2006
2184
  var memoryFact = (raw, id) => firstParagraph(raw) ?? firstHeading(raw) ?? id;
2007
2185
  var relativePath = (root, abs) => toPosix(abs).replace(`${toPosix(root)}/`, "");
2008
2186
  var ingestMarkdownDir = (root, dir, source, confidence) => {
2009
- if (!existsSync8(dir)) return [];
2187
+ if (!existsSync9(dir)) return [];
2010
2188
  return walkFiles(dir, { extensions: [".md", ".mdc"] }).map((abs) => {
2011
2189
  const rel = relativePath(root, abs);
2012
- const raw = readFileSync12(abs, "utf8");
2190
+ const raw = readFileSync13(abs, "utf8");
2013
2191
  const id = slugFromPath(rel);
2014
2192
  return {
2015
2193
  schemaVersion: 1,
@@ -2024,10 +2202,10 @@ var ingestMarkdownDir = (root, dir, source, confidence) => {
2024
2202
  });
2025
2203
  };
2026
2204
  var ingestCursorRules = (root) => {
2027
- const dir = join13(root, ".cursor", "rules");
2205
+ const dir = join14(root, ".cursor", "rules");
2028
2206
  return ingestMarkdownDir(root, dir, "cursor", 0.6);
2029
2207
  };
2030
- var ingestAgentMemory = (root) => ingestMarkdownDir(root, join13(root, ".agent-memory"), "agent-memory", 0.7);
2208
+ var ingestAgentMemory = (root) => ingestMarkdownDir(root, join14(root, ".agent-memory"), "agent-memory", 0.7);
2031
2209
  var ingestMemoryCandidates = (root) => [
2032
2210
  ...ingestAgentMemory(root),
2033
2211
  ...ingestCursorRules(root)
@@ -2113,7 +2291,7 @@ var draftMemoryPromotion = (classifications) => {
2113
2291
  };
2114
2292
 
2115
2293
  // src/mcp/server.ts
2116
- import { readFileSync as readFileSync13, realpathSync } from "fs";
2294
+ import { readFileSync as readFileSync14, realpathSync } from "fs";
2117
2295
  import { relative, resolve as resolve5 } from "path";
2118
2296
  import { z as z5, ZodError } from "zod";
2119
2297
  var MCP_TOOLS = [
@@ -2234,7 +2412,7 @@ var handleMcpRequest = (ctx, request) => {
2234
2412
  return {
2235
2413
  protocolVersion: "2024-11-05",
2236
2414
  capabilities: { tools: {} },
2237
- serverInfo: { name: "ak-docs", version: "0.1.0-alpha.1" }
2415
+ serverInfo: { name: "ak-docs", version: PACKAGE_VERSION }
2238
2416
  };
2239
2417
  }
2240
2418
  if (request.method === "tools/list") return { tools: MCP_TOOLS };
@@ -2259,7 +2437,7 @@ var handleMcpRequest = (ctx, request) => {
2259
2437
  }
2260
2438
  if (name === "doc.get") {
2261
2439
  const relPath = findDocPath(index(), parseToolArgs("doc.get", DocGetArgsSchema, args));
2262
- return textResult(readFileSync13(resolveDocPath(ctx.root, relPath), "utf8"));
2440
+ return textResult(readFileSync14(resolveDocPath(ctx.root, relPath), "utf8"));
2263
2441
  }
2264
2442
  if (name === "gate.status") return textResult(runGates(ctx.root, ctx.config));
2265
2443
  if (name === "retriever.query") {
@@ -2482,7 +2660,7 @@ var readIndexedDoc = (root, config, idOrPath) => {
2482
2660
  if (abs !== rootAbs && !abs.startsWith(`${rootAbs}/`)) {
2483
2661
  throw new Error(`Indexed doc escapes project root: ${entry.path}`);
2484
2662
  }
2485
- return readFileSync14(abs, "utf8");
2663
+ return readFileSync15(abs, "utf8");
2486
2664
  };
2487
2665
  var runAskRepl = async (root, config) => {
2488
2666
  const index = loadDocBridgeIndex(root, config);
@@ -2558,7 +2736,7 @@ var diagnosticNextCommands = (config, result) => {
2558
2736
  ];
2559
2737
  };
2560
2738
  var writeIfMissing = (path, contents) => {
2561
- if (existsSync9(path)) return false;
2739
+ if (existsSync10(path)) return false;
2562
2740
  mkdirSync2(dirname4(path), { recursive: true });
2563
2741
  writeFileSync2(path, contents, "utf8");
2564
2742
  return true;
@@ -2673,7 +2851,7 @@ var bootstrapAgentDocs = (root, config) => {
2673
2851
  const created = [];
2674
2852
  const skipped = [];
2675
2853
  for (const doc of scanHumanDocRecords(root, config)) {
2676
- const raw = readFileSync14(doc.path, "utf8");
2854
+ const raw = readFileSync15(doc.path, "utf8");
2677
2855
  const body = raw.replace(/^---\n[\s\S]*?\n---\n?/, "");
2678
2856
  const title = firstHeading(body) ?? doc.id;
2679
2857
  const description = firstParagraph(body);
@@ -2742,7 +2920,7 @@ var runCli = (argv) => {
2742
2920
  }
2743
2921
  try {
2744
2922
  const abs = resolve6(file);
2745
- const raw = readFileSync14(abs, "utf8");
2923
+ const raw = readFileSync15(abs, "utf8");
2746
2924
  const handoff = parseAgentHandoff(JSON.parse(raw));
2747
2925
  writeJson({ ok: true, handoff });
2748
2926
  return 0;