/** * Shared type definitions for ContextAtlas. * * These types anchor the shape of data flowing through the system. Changes * here ripple across language adapters, storage, query fusion, and MCP * handlers — update DESIGN.md when changing public shapes. */ /** * Stable identifier for a symbol. * Format: sym::: * Example: "sym:ts:src/orders/processor.ts:OrderProcessor" * * Line numbers are NOT part of the ID. They live as a field on the Symbol * record (`line`). This keeps IDs stable across cosmetic line moves so * atlas.json diffs stay meaningful (see ADR-01). * * Paths in IDs use forward-slash separators regardless of OS. * All path ingest goes through normalizePath() (see ADR-01). */ export type SymbolId = string; /** * Stable identifier for a reference site. * Format: "ref:::" * * Unlike Symbol IDs, Reference IDs DO include line — a reference is a * location in a file, not an entity. */ export type ReferenceId = string; export type LanguageCode = "typescript" | "python" | "go" | "ruby" | "csharp"; /** * Authoritative mapping from LanguageCode (used in config and interfaces) * to the short code used in symbol IDs. * * Per ADR-01, this is stable public API. Adding entries is additive; * changing existing short codes is a breaking change requiring a major * version bump. */ export declare const LANG_CODES: Record; /** Inverse mapping: short code → full LanguageCode. */ export declare const LANG_CODES_INVERSE: Record; export type SymbolKind = "class" | "interface" | "function" | "method" | "type" | "enum" | "variable" | "module" | "other"; export interface Symbol { id: SymbolId; name: string; kind: SymbolKind; path: string; line: number; signature?: string; language: LanguageCode; /** * Optional back-pointer to a parent symbol. Used by adapters that * flatten nested-child declarations to top-level Symbol records and * need to preserve the parent → child relationship — e.g., Go * interface methods flattened from interface children to sibling * top-level entries per ADR-14 §Decision 4. Left undefined for * top-level symbols with no parent relationship (functions, * classes, standalone vars/constants, etc.). */ parentId?: SymbolId; /** * SHA of the source file this symbol lives in. Optional on the adapter * boundary (adapters don't compute SHAs), required at the storage * boundary (indexer stamps SHA before insert). */ fileSha?: string; } export interface Reference { id: ReferenceId; symbolId: SymbolId; path: string; line: number; column?: number; } export type Severity = "hard" | "soft" | "context"; export interface Claim { id: number; source: string; sourcePath: string; /** SHA of the source document the claim was extracted from. */ sourceSha: string; severity: Severity; claim: string; rationale?: string; excerpt?: string; symbolIds: SymbolId[]; } export type BundleDepth = "summary" | "standard" | "deep"; export type BundleSignal = "refs" | "intent" | "git" | "types" | "tests"; export interface SymbolContextBundle { version: "1.0"; symbol: Symbol; intent?: Claim[]; refs?: { count: number; clusters: Array<{ module: string; count: number; topIds: ReferenceId[]; }>; }; types?: { extends?: string[]; implements?: string[]; usedByTypes?: string[]; }; git?: { /** ISO-8601 date of the most recent commit that touched the symbol's file. */ lastTouched: string; /** Author email of that most recent commit. */ lastTouchedAuthor: string; /** * Recent commits on the symbol's file, newest-first. Size is * bounded by `config.git.recentCommits`. */ recentCommits: Array<{ sha: string; date: string; message: string; authorEmail: string; }>; /** True when `commitCount >= config.git.recentCommits` (ADR-11). */ hot: boolean; /** Total commits in the stored window that touched the symbol's file. */ commitCount: number; /** Threshold used to decide `hot` — surfaced so renderers can explain it. */ hotThreshold: number; }; tests?: { files: string[]; relatedCount: number; }; diagnostics?: Diagnostic[]; } export interface Diagnostic { severity: "error" | "warning" | "info"; message: string; path: string; line: number; column?: number; } export interface LanguageAdapter { readonly language: LanguageCode; readonly extensions: readonly string[]; listSymbols(filePath: string): Promise; getSymbolDetails(id: SymbolId): Promise; findReferences(id: SymbolId): Promise; getDiagnostics(filePath: string): Promise; /** * Return the type relationships for a symbol. See ADR-07 for the * contract: direct children only on `usedByTypes`, generic constraints * excluded from `extends`, empty arrays are valid returns. */ getTypeInfo(id: SymbolId): Promise; /** * Return the doc-comment / docstring text attached to a symbol, or * null if no docstring is present (or the symbol is not found). * * Per v0.3 Stream B (Step 8 probe / Step 9 calibration / Step 10 * implementation): used by the extraction pipeline's docstring path. * Adapter implementations decide their substrate (gopls hover for * Go; tsserver hover or compiler-API JSDoc for TS; direct AST parse * via `ast.get_docstring()` for Python — pyright hover does NOT * surface docstrings per ADR-13). * * Returns null on: * - Symbol not found in adapter's symbol surface * - Symbol has no docstring * - Docstring text is empty/whitespace-only * * The returned string is the comment-syntax-stripped prose (no * JSDoc block delimiters, no leading per-line markers like `* ` * or `// `, no Python triple-quote wrappers) — matches the input * shape Step 9 calibration validated against EXTRACTION_PROMPT. */ getDocstring(id: SymbolId): Promise; initialize(rootPath: string): Promise; shutdown(): Promise; } /** * Type relationships for a symbol (ADR-07). * * `extends` and `implements` describe the forward direction: what this * symbol inherits from or implements. `usedByTypes` is the inverse * lookup: which types extend or implement this symbol. * * All three are arrays of plain names (not symbol IDs) because they're * rendered as-is in the compact bundle format. An ID-resolved variant * could be added in a later major version if callers need it. */ export interface TypeInfo { extends: string[]; implements: string[]; /** Direct children only; no transitive closure. */ usedByTypes: string[]; } export interface ContextAtlasConfig { version: 1; /** * Extraction path selection per ADR-02 v0.7 amendment + Path (iii) * 2-mode collapse + Q1.0.4 β-3 lock. Three accepted config values; * two substantive runtime modes + 1 legacy deprecated alias: * * - "claude-code-only" → Mode A (Skills path; default at v0.7+; * subscription-bounded; canonical .claude/skills/index-atlas/ * SKILL.md location; no Anthropic API key required) * - "anthropic-api-direct" → Mode B (Anthropic API direct; * preserves v0.1-v0.6 actual extraction behavior; renamed at * v0.7 for naming clarity; pay-per-use cost model) * - "anthropic-api-claude-code" → deprecated legacy alias for * "anthropic-api-direct"; backward-compat for v0.6 user * configs; stderr deprecation warning emitted at factory-time * per Q1.0.8 lock; alias removed at v0.8+ * * Default: "claude-code-only" (Mode A) per Q1.0.4 β-3 hybrid lock. * Absent-means-default; init writes explicit-default. * * YAML key is `architecture` (already lowercase); TS field * `architecture` (no case conversion needed). */ architecture?: "claude-code-only" | "anthropic-api-direct" | "anthropic-api-claude-code"; languages: LanguageCode[]; adrs: { path: string; format: "markdown-frontmatter"; symbolField?: string; }; docs: { include: string[]; }; git: { recentCommits: number; }; index: { model: string; }; atlas: { committed: boolean; path: string; localCache: string; }; /** * Optional source-code location (ADR-08 runtime extension). * When present, `source.root` is the path (resolved against the * config file's directory) where language adapters should * initialize. When absent, adapters initialize against the config * file's directory, matching the single-root common case. */ source?: { root: string; }; /** * Optional extraction-pipeline knobs (v0.2 Stream A #2 + * v0.3 Theme 1.2 Fix 2). * * `budgetWarnUsd`: when the cumulative API cost during an * extraction run exceeds this threshold, a single warning is * logged to stderr. Not a hard cap — the run continues. Absent * means no budget check. CLI flag `--budget-warn` overrides this * value at invocation time. * * `narrowAttribution`: claim-attribution narrowing rule (v0.3 * Theme 1.2 Fix 2; targets Phase 6 §5.1 muddy-bundle mechanism). * * **Default (Step 7 A1 ship): drop-with-fallback semantics.** * Absent / undefined falls through to the same behavior as * explicit `"drop-with-fallback"`. The legacy v0.2-baseline * frontmatter-merge mode is no longer reachable via this API — * rollback to that mode is at the version/codepath level * (Pattern 2 retention applies to the `"drop"` vs * `"drop-with-fallback"` axis, not to a config-level v0.2 * baseline). * * Two explicit values supported: * - `"drop"`: drop frontmatter inheritance entirely; claims * attach only to model-extracted candidates. Pure-drop mode; * zero-symbol claims stay invisible to `get_symbol_context` * (Option A regression risk). * - `"drop-with-fallback"`: identical to the default. Kept for * explicit configurability + symmetry with Pattern 2 flag- * retention discipline. * * CLI flag `--narrow-attribution=` overrides config. */ extraction?: { budgetWarnUsd?: number; narrowAttribution?: "drop" | "drop-with-fallback"; /** * Directory-aware test-file exclusion (v0.4 Step 2 / A4). * * Glob patterns (minimatch syntax) evaluated against repo- * relative forward-slash paths at file-discovery time. v0.4 * adds extraction-time exclusion as a new capability — v0.3 * had none; only query-time `isTestFile` ranking treated test * files specially. * * AUGMENT-ONLY in v0.4: user patterns ADD to per-language * defaults (`src/config/exclude-patterns.ts`); defaults always * apply. Empty `exclude_pattern: []` means no augmentation * (defaults still apply). For zero exclusions including * defaults, a future replace-mode flag is a v0.5+ candidate. * * YAML key is `exclude_pattern` (snake_case); TS shape is * `excludePattern` (camelCase) per parser convention. */ excludePattern?: string[]; /** * User-augmented architectural-intent regex patterns for * commit-message extraction (v0.4 Step 4 / Stream A). * * AUGMENT-ONLY in v0.4: user patterns ADD to the default-set * (`src/extraction/commit-message-extractor.ts` * `DEFAULT_SUBJECT_PREFIX_PATTERNS` + `DEFAULT_BODY_ANYWHERE_ * PATTERNS`); defaults always apply. Empty * `commit_message_filter: []` means no augmentation; defaults * still apply. For zero augmentation the YAML key can be * omitted entirely. * * User patterns are tested against `subject + "\n" + body[:200]` * surface. They use case-insensitive matching by default * (regex flag `i` applied at compile time). * * YAML key is `commit_message_filter` (snake_case); TS field is * `commitMessageFilter` (camelCase) per parser convention. */ commitMessageFilter?: string[]; }; /** * Optional cohort observability section per v0.6 Step 6.2 / * Q6.0.4 hybrid wiring (init writes config + mcp per-session * override) + Q6.2 ADR-20 cohort observability contract. * * `enabled`: when true, MCP server records per-tool-invocation * observations to `logPath`. Default false (no observation when * section absent OR enabled=false). * * `logPath`: filesystem path where observability log is written * (newline-delimited JSON; one observation per line). Defaults * to `.contextatlas/observe-log.jsonl` when section absent. * * `--observe` flag IS the consent signal per Q6.0.4 hybrid lock; * cohort participants opt-in by passing `--observe` to init or * mcp subcommand. Per ADR-20 cohort observability contract for * data handling + retention + participant rights. */ observability?: { enabled: boolean; logPath?: string; }; /** * Optional Language Server Protocol knobs per v0.7 Step 2.2.d * FO-6 (β) diagnostic substrate. Substantively launch-worthy * observability rather than dev-only scaffolding. * * `initializeTimeoutMs`: timeout for the LSP `initialize` request * during adapter spawn (default 30000ms = 30s). Substantial * codebases that stress the language server's initial-analysis * pass may need substantively longer timeouts. Users with * sufficient evidence can bump to 60000+ via this config. * * YAML key: `lsp.initialize_timeout_ms` (snake_case); TS shape * is `initializeTimeoutMs` (camelCase) per parser convention. */ lsp?: { initializeTimeoutMs?: number; }; /** * Optional MCP-server query-time knobs (v0.3 Theme 1.2 Fix 3). * These affect how the MCP server ranks/composes responses from * an already-extracted atlas; they do not affect extraction. * * `symbolContextBM25`: when true, `get_symbol_context` ranks the * intent (claim) section using FTS5 BM25 IF the caller provides * a `query` parameter — same ranking primitive as `find_by_intent` * (ADR-09), extended to per-symbol claim subsets per ADR-16. * Absent (default) preserves v0.2 deterministic ranking * (severity → source → claim_id). Even with the flag on, an * absent `query` parameter falls back to v0.2 ordering — the flag * activates the BM25 path, but the caller's query string drives * the actual re-ranking. */ mcp?: { symbolContextBM25?: boolean; }; } //# sourceMappingURL=types.d.ts.map