/** * pi-loom Context Injection — Symbolic Index + Progressive Disclosure * * Phase 3: Instead of raw text blocks, inject a compact symbolic index. * Each line is ~60-100 tokens with type prefix, date, entity, and memory_id. * Agent drills down via MCP: loom_detail, loom_timeline, loom_episode. * * Format: * [PI_LOOM] * ## Context * [D] 2026-06-15 | Arch: use sqlite-vec for search | loom-arch | #mem_a1b2c3 * [E] 2026-06-14 | CI: type error in handlers.ts → fixed | loom-bug | #mem_d4e5f6 * [M] 2026-06-14 | Modified src/store.ts: added embedding column | #mem_g7h8i9 * [I] Dream: "FTS5-only misses 40% of semantic queries" | #insight_j0k1 * * Prefix legend: * [H] Handoff — task/session transfer state * [P] Procedure/Profile — reusable playbooks or entity portraits * [D] Decision — architecture, implementation, strategy choices * [E] Error — tool errors, unexpected outcomes * [M] Memory — general facts, changes, observations * [I] Insight — Dream Engine discoveries * * Token budget: ~500-600 tokens. Falls back to minimal format when tight. */ import type { LoomStore, VisibilityFilter } from "./store.js"; /** * Build symbolic index for context injection. * Returns "" when store has no data — caller should skip injection. * * Budget controls (TDAM-inspired): * - maxCharsPerMemory: truncate individual lines to N chars (default: unlimited) * - maxTotalChars: hard cap on total output characters (default: from PI_LOOM_MAX_TOTAL_CHARS or unlimited) * - maxTokens: soft cap on estimated tokens (existing) * * Priority order: handoffs → procedures → profiles → insights → decisions/errors → recent high-importance. * When budget is tight, lower-priority sections are trimmed or dropped entirely. */ export declare function buildLoomContext(store: LoomStore, opts?: { factsCount?: number; keyCount?: number; recentCount?: number; maxTokens?: number; /** Optional scope for task/repo-aware context planning. */ scope_type?: string; scope_id?: string; /** Visibility boundary. Defaults to project/shared, excluding private. */ visibility?: VisibilityFilter; /** Max characters per memory line. Lines exceeding this are truncated with "…". */ maxCharsPerMemory?: number; /** Hard cap: total output characters. If exceeded, lowest-priority lines are dropped. */ maxTotalChars?: number; }): string;