@agentproto/corpus-cli 0.11.5 → 0.11.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare const VERSION: string;
11
11
  * threaded to the distiller as the extraction instruction, its `kinds` constrain
12
12
  * the emitted kinds, and its `aspect` is stamped on every produced entry as the
13
13
  * `aspect:<value>` facet tag (the query key). See
14
- * `@agentproto/corpus` `distill/lens.ts` + projects/guilde/docs/KNOWLEDGE-LENS-DESIGN.md.
14
+ * `@agentproto/corpus` `distill/lens.ts`.
15
15
  *
16
16
  * This is the CLI-side analog of the guild's built-in catalog
17
17
  * (`apps/api` `services/knowledge-generate/lenses.ts`): a workspace can override
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts","../src/ports/local-fs.adapter.ts","../src/ports/os-identity.adapter.ts","../src/lenses/builtin.ts","../src/lenses/resolve.ts"],"names":["path","existsSync","readFile"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAS,WAAA,GAAsB;AAC7B,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AACnD,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA;AAAA,MACf,YAAA,CAAa,OAAA,CAAQ,IAAA,EAAM,iBAAiB,GAAG,MAAM;AAAA,KACvD;AACA,IAAA,OAAO,IAAI,OAAA,IAAW,OAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,OAAA;AAAA,EACT;AACF;AAEO,IAAM,UAAkB,WAAA;ACexB,IAAM,gBAAN,MAAsC;AAAA,EAC1B,IAAA;AAAA,EAEjB,YAAY,IAAA,EAA4B;AACtC,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AAAA,EACnB;AAAA,EAEA,MAAM,OAAO,CAAA,EAA6B;AACxC,IAAA,IAAI;AAC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OAAA;AACpB,EAAA,MAAM,IAAI,SAAA;AAAA,IACR,CAAA,cAAA,EAAiB,EAAE,CAAA,aAAA,EAAgB,cAAA,GAAiB,IAAA,CAAK,IAAI,CAAA,IAAK,QAAQ,oBACtD,IAAA,CAAK,QAAA,EAAU,CAAA,EAAG,EAAE,KAAK,CAAC,CAAA,8CAAA;AAAA,GAChD;AACF;AAGA,eAAsB,gBAAgBF,KAAAA,EAA6B;AACjE,EAAA,IAAI,CAACC,UAAAA,CAAWD,KAAI,CAAA,EAAG;AACrB,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,uBAAA,EAA0BA,KAAI,CAAA,CAAE,CAAA;AAAA,EACtD;AACA,EAAA,MAAM,aAAa,QAAA,CAASA,KAAI,CAAA,CAAE,OAAA,CAAQ,YAAY,EAAE,CAAA;AACxD,EAAA,OAAO,aAAa,MAAME,QAAAA,CAASF,KAAAA,EAAM,MAAM,GAAG,UAAU,CAAA;AAC9D","file":"index.mjs","sourcesContent":["/**\n * CLI version — derived from the package's own package.json at runtime,\n * so it never drifts from the published version on a release bump.\n *\n * `import.meta.url` resolves to dist/cli.mjs in the published bundle and\n * to src/version.ts under tsx/vitest; in both, package.json sits one\n * directory up. A defensive fallback keeps --version from ever throwing.\n */\nimport { readFileSync } from \"node:fs\"\nimport { dirname, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nfunction readVersion(): string {\n try {\n const here = dirname(fileURLToPath(import.meta.url))\n const pkg = JSON.parse(\n readFileSync(resolve(here, \"../package.json\"), \"utf8\")\n ) as { version?: string }\n return pkg.version ?? \"0.0.0\"\n } catch {\n return \"0.0.0\"\n }\n}\n\nexport const VERSION: string = readVersion()\n","/**\n * NodeFsAdapter — `FsPort` implementation backed by node:fs.\n *\n * Atomic writes via temp + rename (the same posix pattern every\n * mature tool uses). Recursive `walk` skips hidden segments\n * (anything beginning with `.`). Advisory locks via lockfiles in\n * `.corpus-locks/` next to the target — single-process safe; for\n * multi-process the lockfile owner pid is recorded so callers can\n * see who holds the lock.\n */\n\nimport { randomBytes } from \"node:crypto\"\nimport {\n appendFile,\n mkdir,\n readFile,\n readdir,\n rename,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { existsSync } from \"node:fs\"\nimport type {\n FsPort,\n FsLockHandle,\n FsStat,\n} from \"@agentproto/corpus\"\n\nexport interface NodeFsAdapterOptions {\n /**\n * Absolute path to the workspace root. All FsPort paths are\n * resolved relative to this — the kit never sees host filesystem\n * paths.\n */\n readonly root: string\n}\n\nexport class NodeFsAdapter implements FsPort {\n private readonly root: string\n\n constructor(opts: NodeFsAdapterOptions) {\n this.root = opts.root\n }\n\n async exists(p: string): Promise<boolean> {\n try {\n await stat(this.resolve(p))\n return true\n } catch {\n return false\n }\n }\n\n async readFile(p: string): Promise<string> {\n return await readFile(this.resolve(p), \"utf8\")\n }\n\n /**\n * Atomic write: write to `${target}.tmp-{nonce}`, fsync, rename.\n * Rename is atomic on the same filesystem. Creates parent dirs as\n * needed (most callers expect mkdir -p semantics).\n */\n async writeFile(p: string, content: string): Promise<void> {\n const target = this.resolve(p)\n await mkdir(path.dirname(target), { recursive: true })\n const tmp = `${target}.tmp-${randomBytes(8).toString(\"hex\")}`\n await writeFile(tmp, content, \"utf8\")\n await rename(tmp, target)\n }\n\n async appendFile(p: string, content: string): Promise<void> {\n const target = this.resolve(p)\n await mkdir(path.dirname(target), { recursive: true })\n await appendFile(target, content, \"utf8\")\n }\n\n async readdir(p: string): Promise<readonly string[]> {\n const target = this.resolve(p)\n const entries = await readdir(target)\n return entries\n }\n\n async walk(p: string): Promise<readonly string[]> {\n const out: string[] = []\n const start = this.resolve(p)\n const rootForRelative = start\n const visit = async (dir: string): Promise<void> => {\n let entries: string[] = []\n try {\n entries = await readdir(dir)\n } catch {\n return\n }\n for (const ent of entries) {\n // Skip hidden segments — matches the FsPort contract.\n if (ent.startsWith(\".\")) continue\n const full = path.join(dir, ent)\n const s = await stat(full)\n if (s.isDirectory()) {\n await visit(full)\n } else if (s.isFile()) {\n const rel = path.relative(rootForRelative, full).split(path.sep).join(\"/\")\n out.push(rel)\n }\n }\n }\n await visit(start)\n return out\n }\n\n async stat(p: string): Promise<FsStat | null> {\n try {\n const s = await stat(this.resolve(p))\n return {\n kind: s.isDirectory() ? \"directory\" : \"file\",\n bytes: s.isFile() ? s.size : undefined,\n modifiedAt: s.mtime,\n }\n } catch {\n return null\n }\n }\n\n /**\n * Advisory lock via a lockfile. Spins waiting for the lockfile to\n * disappear, then creates it with exclusive flag. Released by\n * deleting it. Single-process safe; multi-process semi-safe (the\n * write is best-effort exclusive — adequate for the corpus's\n * promote-entry transaction which is rare and short-lived).\n */\n async lock(p: string): Promise<FsLockHandle> {\n const target = this.resolve(p)\n const lockDir = path.join(path.dirname(target), \".corpus-locks\")\n await mkdir(lockDir, { recursive: true })\n const lockFile = path.join(lockDir, path.basename(target) + \".lock\")\n const myToken = `${process.pid}-${randomBytes(4).toString(\"hex\")}`\n\n // Spin until we acquire. Cheap polling is fine for corpus\n // workloads — transactions are < 1s.\n while (true) {\n if (!existsSync(lockFile)) {\n try {\n await writeFile(lockFile, myToken, { encoding: \"utf8\", flag: \"wx\" })\n // Race: verify our token is the one that landed.\n const written = await readFile(lockFile, \"utf8\").catch(() => \"\")\n if (written === myToken) break\n } catch {\n // Lost the race — fall through and retry.\n }\n }\n await new Promise((r) => setTimeout(r, 25))\n }\n return {\n release: async () => {\n try {\n await rm(lockFile, { force: true })\n } catch {\n // Lockfile already gone — no-op.\n }\n },\n }\n }\n\n // ── Helpers ────────────────────────────────────────────────────\n\n /**\n * Resolve a workspace-relative path to an absolute host path.\n * Refuses to climb out of the workspace root (defense against\n * `../../etc/passwd`-style abuse) — the corpus kit's paths must\n * stay inside the workspace.\n */\n private resolve(p: string): string {\n const normalized = path.posix.normalize(\"/\" + p.replace(/^\\/+/, \"\"))\n // Drop the leading \"/\" so path.join joins correctly under root.\n const rel = normalized.slice(1)\n if (rel.startsWith(\"..\")) {\n throw new Error(\n `NodeFsAdapter: path \"${p}\" escapes the workspace root \"${this.root}\"`\n )\n }\n return path.join(this.root, rel)\n }\n}\n","/**\n * OsIdentityAdapter — `IdentityPort` resolved from OS user + cwd.\n *\n * Local-topology identity model:\n * - principal = `ws://users/{os-user}`\n * - identityTree = [\n * `ws://users/{os-user}`,\n * `ws://workspaces/{workspace-dir-name}`,\n * ]\n *\n * Roles + guilds + orgs don't exist locally — single-user, single-\n * workspace machine. Scope-policy in the corpus adapter matches\n * against this minimal tree, so AIP-10 `appliesTo` entries scoped\n * narrower than `ws://users/...` or `ws://workspaces/...` are\n * invisible to the local user. That's the intended local-topology\n * semantics: you only see what's scoped to you or your workspace.\n */\n\nimport os from \"node:os\"\nimport path from \"node:path\"\nimport type {\n CallerIdentity,\n IdentityPort,\n} from \"@agentproto/corpus\"\n\nexport interface OsIdentityAdapterOptions {\n readonly workspaceRoot: string\n /** Override the OS user (useful for tests). Falls back to os.userInfo(). */\n readonly userOverride?: string\n}\n\nexport class OsIdentityAdapter implements IdentityPort {\n private readonly cached: CallerIdentity\n\n constructor(opts: OsIdentityAdapterOptions) {\n // Env vars win over os.userInfo() — matches Unix convention (env is\n // explicit intent, OS detection is fallback). Also keeps tests\n // deterministic across CI environments where the OS user differs.\n const user =\n opts.userOverride ??\n process.env.USER ??\n process.env.USERNAME ??\n safeGetUser() ??\n \"anonymous\"\n const wsName = path.basename(opts.workspaceRoot) || \"default\"\n this.cached = Object.freeze({\n principal: `ws://users/${slugify(user)}`,\n identityTree: Object.freeze([\n `ws://users/${slugify(user)}`,\n `ws://workspaces/${slugify(wsName)}`,\n ]),\n displayName: user,\n })\n }\n\n async resolve(): Promise<CallerIdentity> {\n return this.cached\n }\n}\n\nfunction safeGetUser(): string | undefined {\n try {\n return os.userInfo().username\n } catch {\n return undefined\n }\n}\n\nfunction slugify(s: string): string {\n return s\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .replace(/-{2,}/g, \"-\")\n .slice(0, 64) || \"anonymous\"\n}\n","/**\n * Built-in lens catalog — lenses that ship with the `corpus` CLI and resolve by\n * id in ANY workspace, no declaration required (`corpus distill <ws> --lens craft`).\n *\n * A {@link Lens} is a named projection over the source pool: its `prompt` is\n * threaded to the distiller as the extraction instruction, its `kinds` constrain\n * the emitted kinds, and its `aspect` is stamped on every produced entry as the\n * `aspect:<value>` facet tag (the query key). See\n * `@agentproto/corpus` `distill/lens.ts` + projects/guilde/docs/KNOWLEDGE-LENS-DESIGN.md.\n *\n * This is the CLI-side analog of the guild's built-in catalog\n * (`apps/api` `services/knowledge-generate/lenses.ts`): a workspace can override\n * any of these — or add its own — by dropping a `lenses/<id>.md` declaration in\n * the workspace root (see {@link resolveLens}).\n */\n\nimport type { Lens } from \"@agentproto/corpus\"\n\n/**\n * `craft` — extract TRANSFERABLE WRITING-CRAFT MOVES: how a piece is written\n * (hook, structure, depth, voice, rhythm, ending), not what it is about. A `log`\n * lens — craft moves accumulate across sources; there is no consolidated artifact\n * to re-derive. Prompt validated in the studio (`/tmp/craft-lens.txt`), adapted\n * to the distiller's `{kind,title,body,confidence,tags}` item shape.\n */\nexport const CRAFT_LENS: Lens = {\n id: \"craft\",\n label: \"Writing craft\",\n aspect: \"craft\",\n mode: \"log\",\n // The distiller emits {kind,title,body,...}; a craft move is a technique\n // (pattern), a rule (principle), a shallow default it avoids (critique), or a\n // specific instance (example). \"summary\" is dropped — a summary is topic\n // content, not a transferable craft move.\n kinds: [\"pattern\", \"principle\", \"critique\", \"example\"],\n prompt: [\n \"Extract TRANSFERABLE WRITING-CRAFT MOVES from the source — reusable techniques a writer could apply to ANY topic. Study HOW the piece is written; IGNORE what it is about. Do NOT extract facts, claims, or lessons about the subject matter — only the craft.\",\n \"\",\n \"Focus on: how the first line hooks; structure and transitions; how depth is manufactured (specificity, tension, the earned turn, surprising-but-true facts); how voice and edge are earned without cringe; sentence rhythm and variation; how it ends. Prioritise the moves that separate memorable writing from generic filler.\",\n \"\",\n \"For each move:\",\n '- kind: \"pattern\" for a technique, \"principle\" for a rule, \"critique\" for a shallow/generic default the move avoids, \"example\" for a specific instance.',\n '- title: name the move crisply and imperatively (e.g. \"Delay the thesis until after a concrete image\").',\n \"- body: state the reusable technique in 1-2 topic-agnostic sentences; name the generic / AI-default it beats; and include a <=30-word verbatim snippet from the source where the move happens (omit the quote only when the move is purely structural).\",\n ].join(\"\\n\"),\n}\n\n/** Every built-in lens, keyed by id. */\nexport const BUILTIN_LENSES: Readonly<Record<string, Lens>> = {\n [CRAFT_LENS.id]: CRAFT_LENS,\n}\n\n/** The ids of every built-in lens — for `--lens` error messages. */\nexport function builtinLensIds(): readonly string[] {\n return Object.keys(BUILTIN_LENSES)\n}\n","/**\n * Lens resolution for the `corpus distill --lens` flag.\n *\n * A lens can be reached three ways, in priority order:\n * 1. `--lens <id>` → a workspace-declared `lenses/<id>.md` (overrides a\n * built-in of the same id), else a {@link BUILTIN_LENSES built-in}.\n * 2. `--lens-file <path>` → an ad-hoc lens declaration file, resolved by path\n * (the escape hatch; same `.md` format as a workspace lens).\n *\n * A lens declaration is a markdown file: frontmatter carries `id` / `label` /\n * `aspect` / `kinds` / `mode`, and the markdown BODY is the extraction prompt\n * (a long prompt reads far better as prose than as a YAML block scalar). The\n * `prompt` frontmatter key is accepted as a fallback when the body is empty.\n * This mirrors how sources and entries are authored in this corpus system, and\n * is the file-based analog of the guild's `guild.settings.knowledgeLenses`.\n */\n\nimport { existsSync } from \"node:fs\"\nimport { readFile } from \"node:fs/promises\"\nimport { basename, join } from \"node:path\"\nimport matter from \"gray-matter\"\nimport { z } from \"zod\"\nimport { isRefinedKind, type Lens, type LensMode, type RefinedKind } from \"@agentproto/corpus\"\nimport { BUILTIN_LENSES, builtinLensIds } from \"./builtin.js\"\n\n/** Thrown when a `--lens` / `--lens-file` cannot be resolved into a valid Lens. */\nexport class LensError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"LensError\"\n }\n}\n\n/** Lenient view of a lens declaration's frontmatter (each field degrades safely). */\nconst LENS_FRONTMATTER = z\n .object({\n id: z.string().optional().catch(undefined),\n label: z.string().optional().catch(undefined),\n aspect: z.string().optional().catch(undefined),\n prompt: z.string().optional().catch(undefined),\n mode: z.string().optional().catch(undefined),\n kinds: z.array(z.string()).optional().catch(undefined),\n synthesisPath: z.string().optional().catch(undefined),\n })\n .loose()\n\n/**\n * Parse a lens declaration file's contents into a {@link Lens}. `fallbackId` is\n * used when the frontmatter omits `id` (the workspace filename slug / `--lens`\n * value). Throws {@link LensError} when no prompt can be found.\n */\nexport function parseLensDoc(raw: string, fallbackId: string): Lens {\n const parsed = matter(raw)\n const fm = LENS_FRONTMATTER.parse(parsed.data)\n const prompt = (parsed.content.trim() || fm.prompt?.trim()) ?? \"\"\n if (!prompt) {\n throw new LensError(\n `lens \"${fm.id ?? fallbackId}\" has no prompt — put the extraction instruction in the markdown body or a \"prompt:\" frontmatter key.`\n )\n }\n const kinds: RefinedKind[] = (fm.kinds ?? []).filter(isRefinedKind)\n const mode: LensMode = fm.mode === \"synthesis\" ? \"synthesis\" : \"log\"\n return {\n id: fm.id ?? fallbackId,\n label: fm.label ?? fm.id ?? fallbackId,\n prompt,\n mode,\n ...(fm.aspect ? { aspect: fm.aspect } : {}),\n ...(kinds.length > 0 ? { kinds } : {}),\n ...(fm.synthesisPath ? { synthesisPath: fm.synthesisPath } : {}),\n }\n}\n\n/**\n * Resolve `--lens <id>`: a workspace `lenses/<id>.md` (override) wins over a\n * built-in of the same id. Throws {@link LensError} listing the built-ins when\n * neither exists.\n */\nexport async function resolveLens(id: string, workspaceRoot: string): Promise<Lens> {\n const wsPath = join(workspaceRoot, \"lenses\", `${id}.md`)\n if (existsSync(wsPath)) {\n return parseLensDoc(await readFile(wsPath, \"utf8\"), id)\n }\n const builtin = BUILTIN_LENSES[id]\n if (builtin) return builtin\n throw new LensError(\n `unknown lens \"${id}\". Built-in: ${builtinLensIds().join(\", \") || \"(none)\"}. ` +\n `Declare one at ${join(\"lenses\", `${id}.md`)} in the workspace, or pass --lens-file <path>.`\n )\n}\n\n/** Resolve `--lens-file <path>`: parse an ad-hoc lens declaration by path. */\nexport async function resolveLensFile(path: string): Promise<Lens> {\n if (!existsSync(path)) {\n throw new LensError(`--lens-file not found: ${path}`)\n }\n const fallbackId = basename(path).replace(/\\.[^.]+$/, \"\")\n return parseLensDoc(await readFile(path, \"utf8\"), fallbackId)\n}\n"]}
1
+ {"version":3,"sources":["../src/version.ts","../src/ports/local-fs.adapter.ts","../src/ports/os-identity.adapter.ts","../src/lenses/builtin.ts","../src/lenses/resolve.ts"],"names":["path","existsSync","readFile"],"mappings":";;;;;;;;;;;;;;;AAYA,SAAS,WAAA,GAAsB;AAC7B,EAAA,IAAI;AACF,IAAA,MAAM,IAAA,GAAO,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AACnD,IAAA,MAAM,MAAM,IAAA,CAAK,KAAA;AAAA,MACf,YAAA,CAAa,OAAA,CAAQ,IAAA,EAAM,iBAAiB,GAAG,MAAM;AAAA,KACvD;AACA,IAAA,OAAO,IAAI,OAAA,IAAW,OAAA;AAAA,EACxB,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,OAAA;AAAA,EACT;AACF;AAEO,IAAM,UAAkB,WAAA;ACexB,IAAM,gBAAN,MAAsC;AAAA,EAC1B,IAAA;AAAA,EAEjB,YAAY,IAAA,EAA4B;AACtC,IAAA,IAAA,CAAK,OAAO,IAAA,CAAK,IAAA;AAAA,EACnB;AAAA,EAEA,MAAM,OAAO,CAAA,EAA6B;AACxC,IAAA,IAAI;AACF,MAAA,MAAM,IAAA,CAAK,IAAA,CAAK,OAAA,CAAQ,CAAC,CAAC,CAAA;AAC1B,MAAA,OAAO,IAAA;AAAA,IACT,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO,KAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,CAAA,E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C,CAAA,8CAAA;AAAA,GAChD;AACF;AAGA,eAAsB,gBAAgBF,KAAAA,EAA6B;AACjE,EAAA,IAAI,CAACC,UAAAA,CAAWD,KAAI,CAAA,EAAG;AACrB,IAAA,MAAM,IAAI,SAAA,CAAU,CAAA,uBAAA,EAA0BA,KAAI,CAAA,CAAE,CAAA;AAAA,EACtD;AACA,EAAA,MAAM,aAAa,QAAA,CAASA,KAAI,CAAA,CAAE,OAAA,CAAQ,YAAY,EAAE,CAAA;AACxD,EAAA,OAAO,aAAa,MAAME,QAAAA,CAASF,KAAAA,EAAM,MAAM,GAAG,UAAU,CAAA;AAC9D","file":"index.mjs","sourcesContent":["/**\n * CLI version — derived from the package's own package.json at runtime,\n * so it never drifts from the published version on a release bump.\n *\n * `import.meta.url` resolves to dist/cli.mjs in the published bundle and\n * to src/version.ts under tsx/vitest; in both, package.json sits one\n * directory up. A defensive fallback keeps --version from ever throwing.\n */\nimport { readFileSync } from \"node:fs\"\nimport { dirname, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nfunction readVersion(): string {\n try {\n const here = dirname(fileURLToPath(import.meta.url))\n const pkg = JSON.parse(\n readFileSync(resolve(here, \"../package.json\"), \"utf8\")\n ) as { version?: string }\n return pkg.version ?? \"0.0.0\"\n } catch {\n return \"0.0.0\"\n }\n}\n\nexport const VERSION: string = readVersion()\n","/**\n * NodeFsAdapter — `FsPort` implementation backed by node:fs.\n *\n * Atomic writes via temp + rename (the same posix pattern every\n * mature tool uses). Recursive `walk` skips hidden segments\n * (anything beginning with `.`). Advisory locks via lockfiles in\n * `.corpus-locks/` next to the target — single-process safe; for\n * multi-process the lockfile owner pid is recorded so callers can\n * see who holds the lock.\n */\n\nimport { randomBytes } from \"node:crypto\"\nimport {\n appendFile,\n mkdir,\n readFile,\n readdir,\n rename,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\"\nimport path from \"node:path\"\nimport { existsSync } from \"node:fs\"\nimport type {\n FsPort,\n FsLockHandle,\n FsStat,\n} from \"@agentproto/corpus\"\n\nexport interface NodeFsAdapterOptions {\n /**\n * Absolute path to the workspace root. All FsPort paths are\n * resolved relative to this — the kit never sees host filesystem\n * paths.\n */\n readonly root: string\n}\n\nexport class NodeFsAdapter implements FsPort {\n private readonly root: string\n\n constructor(opts: NodeFsAdapterOptions) {\n this.root = opts.root\n }\n\n async exists(p: string): Promise<boolean> {\n try {\n await stat(this.resolve(p))\n return true\n } catch {\n return false\n }\n }\n\n async readFile(p: string): Promise<string> {\n return await readFile(this.resolve(p), \"utf8\")\n }\n\n /**\n * Atomic write: write to `${target}.tmp-{nonce}`, fsync, rename.\n * Rename is atomic on the same filesystem. Creates parent dirs as\n * needed (most callers expect mkdir -p semantics).\n */\n async writeFile(p: string, content: string): Promise<void> {\n const target = this.resolve(p)\n await mkdir(path.dirname(target), { recursive: true })\n const tmp = `${target}.tmp-${randomBytes(8).toString(\"hex\")}`\n await writeFile(tmp, content, \"utf8\")\n await rename(tmp, target)\n }\n\n async appendFile(p: string, content: string): Promise<void> {\n const target = this.resolve(p)\n await mkdir(path.dirname(target), { recursive: true })\n await appendFile(target, content, \"utf8\")\n }\n\n async readdir(p: string): Promise<readonly string[]> {\n const target = this.resolve(p)\n const entries = await readdir(target)\n return entries\n }\n\n async walk(p: string): Promise<readonly string[]> {\n const out: string[] = []\n const start = this.resolve(p)\n const rootForRelative = start\n const visit = async (dir: string): Promise<void> => {\n let entries: string[] = []\n try {\n entries = await readdir(dir)\n } catch {\n return\n }\n for (const ent of entries) {\n // Skip hidden segments — matches the FsPort contract.\n if (ent.startsWith(\".\")) continue\n const full = path.join(dir, ent)\n const s = await stat(full)\n if (s.isDirectory()) {\n await visit(full)\n } else if (s.isFile()) {\n const rel = path.relative(rootForRelative, full).split(path.sep).join(\"/\")\n out.push(rel)\n }\n }\n }\n await visit(start)\n return out\n }\n\n async stat(p: string): Promise<FsStat | null> {\n try {\n const s = await stat(this.resolve(p))\n return {\n kind: s.isDirectory() ? \"directory\" : \"file\",\n bytes: s.isFile() ? s.size : undefined,\n modifiedAt: s.mtime,\n }\n } catch {\n return null\n }\n }\n\n /**\n * Advisory lock via a lockfile. Spins waiting for the lockfile to\n * disappear, then creates it with exclusive flag. Released by\n * deleting it. Single-process safe; multi-process semi-safe (the\n * write is best-effort exclusive — adequate for the corpus's\n * promote-entry transaction which is rare and short-lived).\n */\n async lock(p: string): Promise<FsLockHandle> {\n const target = this.resolve(p)\n const lockDir = path.join(path.dirname(target), \".corpus-locks\")\n await mkdir(lockDir, { recursive: true })\n const lockFile = path.join(lockDir, path.basename(target) + \".lock\")\n const myToken = `${process.pid}-${randomBytes(4).toString(\"hex\")}`\n\n // Spin until we acquire. Cheap polling is fine for corpus\n // workloads — transactions are < 1s.\n while (true) {\n if (!existsSync(lockFile)) {\n try {\n await writeFile(lockFile, myToken, { encoding: \"utf8\", flag: \"wx\" })\n // Race: verify our token is the one that landed.\n const written = await readFile(lockFile, \"utf8\").catch(() => \"\")\n if (written === myToken) break\n } catch {\n // Lost the race — fall through and retry.\n }\n }\n await new Promise((r) => setTimeout(r, 25))\n }\n return {\n release: async () => {\n try {\n await rm(lockFile, { force: true })\n } catch {\n // Lockfile already gone — no-op.\n }\n },\n }\n }\n\n // ── Helpers ────────────────────────────────────────────────────\n\n /**\n * Resolve a workspace-relative path to an absolute host path.\n * Refuses to climb out of the workspace root (defense against\n * `../../etc/passwd`-style abuse) — the corpus kit's paths must\n * stay inside the workspace.\n */\n private resolve(p: string): string {\n const normalized = path.posix.normalize(\"/\" + p.replace(/^\\/+/, \"\"))\n // Drop the leading \"/\" so path.join joins correctly under root.\n const rel = normalized.slice(1)\n if (rel.startsWith(\"..\")) {\n throw new Error(\n `NodeFsAdapter: path \"${p}\" escapes the workspace root \"${this.root}\"`\n )\n }\n return path.join(this.root, rel)\n }\n}\n","/**\n * OsIdentityAdapter — `IdentityPort` resolved from OS user + cwd.\n *\n * Local-topology identity model:\n * - principal = `ws://users/{os-user}`\n * - identityTree = [\n * `ws://users/{os-user}`,\n * `ws://workspaces/{workspace-dir-name}`,\n * ]\n *\n * Roles + guilds + orgs don't exist locally — single-user, single-\n * workspace machine. Scope-policy in the corpus adapter matches\n * against this minimal tree, so AIP-10 `appliesTo` entries scoped\n * narrower than `ws://users/...` or `ws://workspaces/...` are\n * invisible to the local user. That's the intended local-topology\n * semantics: you only see what's scoped to you or your workspace.\n */\n\nimport os from \"node:os\"\nimport path from \"node:path\"\nimport type {\n CallerIdentity,\n IdentityPort,\n} from \"@agentproto/corpus\"\n\nexport interface OsIdentityAdapterOptions {\n readonly workspaceRoot: string\n /** Override the OS user (useful for tests). Falls back to os.userInfo(). */\n readonly userOverride?: string\n}\n\nexport class OsIdentityAdapter implements IdentityPort {\n private readonly cached: CallerIdentity\n\n constructor(opts: OsIdentityAdapterOptions) {\n // Env vars win over os.userInfo() — matches Unix convention (env is\n // explicit intent, OS detection is fallback). Also keeps tests\n // deterministic across CI environments where the OS user differs.\n const user =\n opts.userOverride ??\n process.env.USER ??\n process.env.USERNAME ??\n safeGetUser() ??\n \"anonymous\"\n const wsName = path.basename(opts.workspaceRoot) || \"default\"\n this.cached = Object.freeze({\n principal: `ws://users/${slugify(user)}`,\n identityTree: Object.freeze([\n `ws://users/${slugify(user)}`,\n `ws://workspaces/${slugify(wsName)}`,\n ]),\n displayName: user,\n })\n }\n\n async resolve(): Promise<CallerIdentity> {\n return this.cached\n }\n}\n\nfunction safeGetUser(): string | undefined {\n try {\n return os.userInfo().username\n } catch {\n return undefined\n }\n}\n\nfunction slugify(s: string): string {\n return s\n .toLowerCase()\n .replace(/[^a-z0-9-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .replace(/-{2,}/g, \"-\")\n .slice(0, 64) || \"anonymous\"\n}\n","/**\n * Built-in lens catalog — lenses that ship with the `corpus` CLI and resolve by\n * id in ANY workspace, no declaration required (`corpus distill <ws> --lens craft`).\n *\n * A {@link Lens} is a named projection over the source pool: its `prompt` is\n * threaded to the distiller as the extraction instruction, its `kinds` constrain\n * the emitted kinds, and its `aspect` is stamped on every produced entry as the\n * `aspect:<value>` facet tag (the query key). See\n * `@agentproto/corpus` `distill/lens.ts`.\n *\n * This is the CLI-side analog of the guild's built-in catalog\n * (`apps/api` `services/knowledge-generate/lenses.ts`): a workspace can override\n * any of these — or add its own — by dropping a `lenses/<id>.md` declaration in\n * the workspace root (see {@link resolveLens}).\n */\n\nimport type { Lens } from \"@agentproto/corpus\"\n\n/**\n * `craft` — extract TRANSFERABLE WRITING-CRAFT MOVES: how a piece is written\n * (hook, structure, depth, voice, rhythm, ending), not what it is about. A `log`\n * lens — craft moves accumulate across sources; there is no consolidated artifact\n * to re-derive. Prompt validated in the studio (`/tmp/craft-lens.txt`), adapted\n * to the distiller's `{kind,title,body,confidence,tags}` item shape.\n */\nexport const CRAFT_LENS: Lens = {\n id: \"craft\",\n label: \"Writing craft\",\n aspect: \"craft\",\n mode: \"log\",\n // The distiller emits {kind,title,body,...}; a craft move is a technique\n // (pattern), a rule (principle), a shallow default it avoids (critique), or a\n // specific instance (example). \"summary\" is dropped — a summary is topic\n // content, not a transferable craft move.\n kinds: [\"pattern\", \"principle\", \"critique\", \"example\"],\n prompt: [\n \"Extract TRANSFERABLE WRITING-CRAFT MOVES from the source — reusable techniques a writer could apply to ANY topic. Study HOW the piece is written; IGNORE what it is about. Do NOT extract facts, claims, or lessons about the subject matter — only the craft.\",\n \"\",\n \"Focus on: how the first line hooks; structure and transitions; how depth is manufactured (specificity, tension, the earned turn, surprising-but-true facts); how voice and edge are earned without cringe; sentence rhythm and variation; how it ends. Prioritise the moves that separate memorable writing from generic filler.\",\n \"\",\n \"For each move:\",\n '- kind: \"pattern\" for a technique, \"principle\" for a rule, \"critique\" for a shallow/generic default the move avoids, \"example\" for a specific instance.',\n '- title: name the move crisply and imperatively (e.g. \"Delay the thesis until after a concrete image\").',\n \"- body: state the reusable technique in 1-2 topic-agnostic sentences; name the generic / AI-default it beats; and include a <=30-word verbatim snippet from the source where the move happens (omit the quote only when the move is purely structural).\",\n ].join(\"\\n\"),\n}\n\n/** Every built-in lens, keyed by id. */\nexport const BUILTIN_LENSES: Readonly<Record<string, Lens>> = {\n [CRAFT_LENS.id]: CRAFT_LENS,\n}\n\n/** The ids of every built-in lens — for `--lens` error messages. */\nexport function builtinLensIds(): readonly string[] {\n return Object.keys(BUILTIN_LENSES)\n}\n","/**\n * Lens resolution for the `corpus distill --lens` flag.\n *\n * A lens can be reached three ways, in priority order:\n * 1. `--lens <id>` → a workspace-declared `lenses/<id>.md` (overrides a\n * built-in of the same id), else a {@link BUILTIN_LENSES built-in}.\n * 2. `--lens-file <path>` → an ad-hoc lens declaration file, resolved by path\n * (the escape hatch; same `.md` format as a workspace lens).\n *\n * A lens declaration is a markdown file: frontmatter carries `id` / `label` /\n * `aspect` / `kinds` / `mode`, and the markdown BODY is the extraction prompt\n * (a long prompt reads far better as prose than as a YAML block scalar). The\n * `prompt` frontmatter key is accepted as a fallback when the body is empty.\n * This mirrors how sources and entries are authored in this corpus system, and\n * is the file-based analog of the guild's `guild.settings.knowledgeLenses`.\n */\n\nimport { existsSync } from \"node:fs\"\nimport { readFile } from \"node:fs/promises\"\nimport { basename, join } from \"node:path\"\nimport matter from \"gray-matter\"\nimport { z } from \"zod\"\nimport { isRefinedKind, type Lens, type LensMode, type RefinedKind } from \"@agentproto/corpus\"\nimport { BUILTIN_LENSES, builtinLensIds } from \"./builtin.js\"\n\n/** Thrown when a `--lens` / `--lens-file` cannot be resolved into a valid Lens. */\nexport class LensError extends Error {\n constructor(message: string) {\n super(message)\n this.name = \"LensError\"\n }\n}\n\n/** Lenient view of a lens declaration's frontmatter (each field degrades safely). */\nconst LENS_FRONTMATTER = z\n .object({\n id: z.string().optional().catch(undefined),\n label: z.string().optional().catch(undefined),\n aspect: z.string().optional().catch(undefined),\n prompt: z.string().optional().catch(undefined),\n mode: z.string().optional().catch(undefined),\n kinds: z.array(z.string()).optional().catch(undefined),\n synthesisPath: z.string().optional().catch(undefined),\n })\n .loose()\n\n/**\n * Parse a lens declaration file's contents into a {@link Lens}. `fallbackId` is\n * used when the frontmatter omits `id` (the workspace filename slug / `--lens`\n * value). Throws {@link LensError} when no prompt can be found.\n */\nexport function parseLensDoc(raw: string, fallbackId: string): Lens {\n const parsed = matter(raw)\n const fm = LENS_FRONTMATTER.parse(parsed.data)\n const prompt = (parsed.content.trim() || fm.prompt?.trim()) ?? \"\"\n if (!prompt) {\n throw new LensError(\n `lens \"${fm.id ?? fallbackId}\" has no prompt — put the extraction instruction in the markdown body or a \"prompt:\" frontmatter key.`\n )\n }\n const kinds: RefinedKind[] = (fm.kinds ?? []).filter(isRefinedKind)\n const mode: LensMode = fm.mode === \"synthesis\" ? \"synthesis\" : \"log\"\n return {\n id: fm.id ?? fallbackId,\n label: fm.label ?? fm.id ?? fallbackId,\n prompt,\n mode,\n ...(fm.aspect ? { aspect: fm.aspect } : {}),\n ...(kinds.length > 0 ? { kinds } : {}),\n ...(fm.synthesisPath ? { synthesisPath: fm.synthesisPath } : {}),\n }\n}\n\n/**\n * Resolve `--lens <id>`: a workspace `lenses/<id>.md` (override) wins over a\n * built-in of the same id. Throws {@link LensError} listing the built-ins when\n * neither exists.\n */\nexport async function resolveLens(id: string, workspaceRoot: string): Promise<Lens> {\n const wsPath = join(workspaceRoot, \"lenses\", `${id}.md`)\n if (existsSync(wsPath)) {\n return parseLensDoc(await readFile(wsPath, \"utf8\"), id)\n }\n const builtin = BUILTIN_LENSES[id]\n if (builtin) return builtin\n throw new LensError(\n `unknown lens \"${id}\". Built-in: ${builtinLensIds().join(\", \") || \"(none)\"}. ` +\n `Declare one at ${join(\"lenses\", `${id}.md`)} in the workspace, or pass --lens-file <path>.`\n )\n}\n\n/** Resolve `--lens-file <path>`: parse an ad-hoc lens declaration by path. */\nexport async function resolveLensFile(path: string): Promise<Lens> {\n if (!existsSync(path)) {\n throw new LensError(`--lens-file not found: ${path}`)\n }\n const fallbackId = basename(path).replace(/\\.[^.]+$/, \"\")\n return parseLensDoc(await readFile(path, \"utf8\"), fallbackId)\n}\n"]}
@@ -772,7 +772,7 @@ declare function connectMcpHttp(opts: ConnectMcpHttpOptions): Promise<McpClientL
772
772
  * McpSink — a config-driven SinkPort that pushes each refined entry by calling
773
773
  * a configured MCP tool. Host-agnostic: the endpoint, tool name, and the
774
774
  * entry→args mapping all come from a sink manifest, so the corpus links to ANY
775
- * host (a Guilde guild KB, a Notion db, a vector store) without naming it.
775
+ * host (a Acme guild KB, a Notion db, a vector store) without naming it.
776
776
  *
777
777
  * The manifest's `args` is a template: string values containing `${slug}`,
778
778
  * `${title}`, `${body}`, `${sources}`, `${tags}`, `${access}`, `${uri}`,