/** * Transcript harvester — out-of-band capture of the context humans type into * AI chats. The USER messages in those transcripts are the highest-signal * capture source aidimag has: they're the facts a human already decided were * worth teaching an AI ("we use X because Y", "never touch Z"). * * Sources (see transcript-sources.ts): Claude Code, Codex CLI, GitHub Copilot * (VS Code) and Cursor. `dim harvest` extracts durable, falsifiable claims * from those messages with the configured LLM provider (OpenAI/Ollama, same * fallback as knowledge ingestion) and queues them as proposals (source * `harvest:`) — nothing becomes active memory without `dim review`. * * Privacy: opt-in by invocation, local-only (transcripts never leave the * machine except to the LLM provider you configured), and secret-looking lines * are redacted before extraction. `--install-hook` wires a Claude Code * SessionEnd hook so harvesting runs automatically when a session closes. */ import type { MemoryStore } from "../db/store.js"; export { claudeProjectDir, userMessagesFromTranscript } from "./transcript-sources.js"; export interface SourceHarvestResult { source: string; label: string; sessionsScanned: number; messagesConsidered: number; proposed: number; duplicates: number; transcriptDir: string | null; } export interface HarvestResult { sessionsScanned: number; messagesConsidered: number; proposed: number; duplicates: number; provider: string | null; /** First detected source's transcript dir (back-compat; prefer `sources`). */ transcriptDir: string | null; /** Per-source breakdown — only sources whose tool/transcripts were found. */ sources: SourceHarvestResult[]; } /** Very conservative redaction: drop lines that look like secrets before they reach any LLM. */ export declare function redactSecrets(text: string): string; export declare const HARVEST_EXTRACT_INSTRUCTIONS = "You are reviewing messages a DEVELOPER typed into an AI coding assistant while working on their project. These messages often contain durable project knowledge the developer was teaching the AI: decisions, conventions, gotchas, failed approaches, architecture facts, rules.\n\nExtract that durable knowledge as FALSIFIABLE claims. Rules:\n\n1. Only durable, project-specific facts the HUMAN stated \u2014 not the task of the day, not questions, not generic programming advice.\n2. 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\".\n3. 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.\n4. Write each claim as a checkable statement about the codebase.\n5. kinds: DECISION, CONVENTION, GOTCHA, FAILED_APPROACH, ARCHITECTURE, INVARIANT, GUARDRAIL (set guardrail_level: never|ask-first|always), SKILL, TODO_CONTEXT.\n6. Scope with paths/symbols when the messages name them; else leave empty.\n7. In \"rationale\", QUOTE the fragment of the developer's message the claim came from.\n8. Extract 0\u20138 claims. Zero is fine \u2014 most sessions contain none. Do NOT invent.\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,\"rationale\":\"user said: \\\"we always extend BaseHandler for API handlers\\\"\"}]}"; /** * Harvest new/updated AI-chat sessions for this repo — across every detected * source — into the proposal queue. Cursor-tracked by transcript mtime per * source; `all` rescans everything (the proposal dedupe index absorbs repeats). */ export declare function harvestSessions(store: MemoryStore, repoRoot: string, opts?: { all?: boolean; sources?: string[]; }): Promise; /** Back-compat alias — harvests all detected sources, not just Claude Code. */ export declare const harvestClaudeSessions: typeof harvestSessions; /** * Wire `dim harvest -q` into the repo's Claude Code SessionEnd hook * (.claude/settings.json) so every session is harvested when it closes. * Additive: merges with existing settings, never clobbers other hooks. * (Codex/Copilot/Cursor have no session-end hook — those sources are swept * whenever `dim harvest` runs.) */ export declare function installClaudeSessionEndHook(repoRoot: string): { installed: boolean; settingsPath: string; };