import type { ContextBundle } from '../context/types.js'; import type { Intent } from '../context/types.js'; import type { Category, Mode } from '../config/categories.js'; import type { UserProvidedSource } from './types.js'; /** * Single authoritative context assembly. All context sources merge here, * in priority order, so downstream strategies never have to juggle parallel * streams and readers can trace exactly why something was or wasn't included. */ export interface GroundingInputs { bundle?: ContextBundle; webSearchContext?: string; webSearchSources?: string[]; platformInstructions?: string; platformHints?: string[]; acceptedExamples?: AcceptedExample[]; userProvidedSources?: UserProvidedSource[]; } export interface AcceptedExample { originalPrompt: string; optimizedPrompt: string; category: Category; platform?: string; intent?: Intent; ts: number; } export interface GroundingOutput { /** Ready-to-inject user-prompt block. Empty string if nothing applies. */ block: string; /** Which sources contributed, in order. Useful for trace. */ sources: string[]; } /** * Priority order (highest → lowest). Documented so contributors don't add * a 4th silo silently: * * 0. Caller-provided sources (ground_prompt explicit grounding — per-call) * 1. User pinned instructions (authoritative; the user said "always do X") * 2. Project rules (CLAUDE.md / AGENTS.md / .cursorrules / clarify.md) * 3. Active file context (what they're working on) * 4. Session: prior accepted examples for similar prompts (few-shot) * 5. Web search (if enabled; contextualizes open-ended requests) * 6. Workspace metadata (frameworks, languages, package name) * 7. Target model capability hints (for the downstream LLM's strengths) * 8. Custom platform instructions (.md file + inline) * 9. Built-in platform syntax hints */ export declare function buildGroundingContext(inputs: GroundingInputs): GroundingOutput; /** * Reconcile user-supplied mode with the intent-derived recommended mode. * User-supplied wins unless it's undefined or the literal default — in which * case the analyzer's recommendation applies. */ export declare function reconcileMode(userMode: Mode | undefined, analyzerRecommended: Mode | undefined, userExplicitlyPassed: boolean): { mode: Mode; source: 'user' | 'analyzer' | 'default'; }; /** * Shape the LLM call to match the target model's capabilities. Small, * local models choke on 2KB system prompts and drown in high-max-token * budgets; large models benefit from richer system prompts. */ export interface PromptShape { systemPromptBudget: 'compact' | 'standard' | 'rich'; maxTokens: number; temperature: number; includeExamples: boolean; } export declare function getPromptShape(bundle: ContextBundle | undefined, intent: Intent | undefined): PromptShape;