/** * Shared claim-extraction contract for knowledge ingestion. Both summarizer paths * use this so they produce identical, reviewable output: * - the LLM fallback (`dim knowledge sync`) feeds these instructions to a model; * - the MCP `knowledge_ingest` prompt feeds them to the connected agent. * * The extractor turns a project document into typed, scoped, FALSIFIABLE claims — * never a single blob. Claims become proposals (source `knowledge:`) and, once * approved with `dim review`, PINNED memories. */ import type { GuardrailLevel, MemoryKind } from "../types.js"; export interface ExtractedClaim { kind: MemoryKind; claim: string; paths?: string[]; symbols?: string[]; /** only for kind === "GUARDRAIL" */ guardrailLevel?: GuardrailLevel; /** only for kind === "FAILED_APPROACH": conditions under which the failure applies */ appliesWhen?: string[]; /** short note on why this is durable / where in the doc it came from */ rationale?: string; /** optional STATIC_CHECK shell command that passes iff the claim holds */ staticCheck?: string; } export declare const KNOWLEDGE_EXTRACT_INSTRUCTIONS = "You are extracting durable, project-specific knowledge from a document a developer dropped into the knowledge inbox (a design doc, ADR, style guide, runbook, or notes).\n\nTurn it into a small set of FALSIFIABLE claims. Rules:\n\n1. BE SPECIFIC. Every claim must name concrete files, modules, functions, config keys, or commands. Bad: \"The project uses a specific tool for code completion\" (useless). Good: \"The UI is a single-page app generated from src/ui/page.ts which inlines all CSS and JS into one HTML file served by the Express server in src/ui/server.ts\". Bad: \"The project uses a specific file format for README files\" (which format? why?).\n2. REJECT generic statements. If a claim could apply to any repo, discard it. \"Uses TypeScript\" is useless. \"All API handlers in src/api/ must extend BaseHandler and register via src/api/registry.ts\" is useful.\n3. Only DURABLE, NON-OBVIOUS facts about THIS project \u2014 rules, decisions, architecture, invariants, guardrails, procedures. Skip generic advice, tutorials, and anything a quick file read already shows.\n4. Write each claim as a checkable statement. Bad: \"auth is complex\". Good: \"JWT refresh in src/auth/refresh.ts must run before the middleware chain; reordering breaks session renewal\".\n5. Pick the right kind:\n - DECISION: a choice + the rejected alternative\n - CONVENTION: a rule the repo follows\n - GOTCHA: surprising behavior that costs time\n - FAILED_APPROACH: something tried that did NOT work\n - ARCHITECTURE: how components fit together\n - INVARIANT: something that must always/never hold\n - GUARDRAIL: a behavioral rule for future agents \u2014 set guardrail_level to \"never\" (refuse), \"ask-first\" (confirm), or \"always\" (do automatically)\n - SKILL: a reusable step-by-step procedure (write the steps as \"1) ... 2) ...\")\n - TODO_CONTEXT: unfinished work + the context to resume it\n6. Scope each claim with paths/symbols it applies to when the document names them; otherwise leave them empty (repo-wide).\n7. Extract 0\u201312 claims. Zero is fine. Do NOT pad, and do NOT invent rules the document doesn't support.\n\nRespond with ONLY a JSON object of this exact shape:\n{\"claims\":[{\"kind\":\"CONVENTION\",\"claim\":\"All API handlers in src/api/ must extend BaseHandler and register via src/api/registry.ts\",\"paths\":[\"src/api/registry.ts\"],\"symbols\":[\"BaseHandler\"],\"guardrail_level\":null,\"applies_when\":[],\"rationale\":\"from ADR-003: API handler registration pattern\"}]}"; /** Build the user message for the LLM: instructions + the document. */ export declare function buildExtractionUser(filename: string, content: string): string; /** * Tolerantly parse a model/agent response into validated claims. Accepts a bare * array or an object with a `claims` array, and ignores anything malformed rather * than throwing — a bad doc should never crash ingestion. */ export declare function parseClaims(raw: string): ExtractedClaim[]; /** Collapse claims repeated across chunks (normalized text match). */ export declare function dedupeClaims(claims: ExtractedClaim[]): ExtractedClaim[];