/** * Spec-to-File Mapper * * Reads existing OpenSpec specs and builds a bidirectional mapping * between spec domains and source files. This is the core data structure * that enables drift detection. */ import type { SpecMap } from '../../types/index.js'; export interface SpecMapperOptions { rootPath: string; openspecPath: string; repoStructurePath?: string; } /** * Extract source files from the spec header line: * > Source files: src/foo.ts, src/bar.ts */ export declare function parseSpecHeader(content: string): { sourceFiles: string[]; generatedDate: string | null; }; /** * Extract file references, requirements, and entities from spec body */ export declare function parseSpecReferences(content: string): { files: string[]; requirements: string[]; entities: string[]; }; /** * One `### Requirement:` block with the implementation anchors written inside it. * * Anchors are read ONLY from backtick-quoted tokens on an `**Implementation**:` * line (and its indented continuation lines) inside the block. Requirement prose, * scenario text, and inline code spans elsewhere in the block are never treated as * anchors — the link index must not invent coverage from narrative. */ export interface SpecRequirementBlock { /** Requirement name exactly as written after `### Requirement:`. */ name: string; /** 1-based line of the requirement heading. */ line: number; /** Raw anchor tokens, in document order, deduplicated. */ anchors: string[]; } /** * Parse every requirement block and its requirement-scoped implementation anchors. * * A block runs from its `### Requirement:` heading to the next `#`-level heading of * the same or higher rank (`### ` / `## ` / `# `); `#### Scenario:` blocks stay inside * their requirement. */ export declare function parseRequirementBlocks(content: string): SpecRequirementBlock[]; /** * Try to infer a domain for a file path based on directory structure. * Uses word-boundary matching to avoid false positives (e.g., domain "auth" * should match "auth-service.ts" but not "authorize.ts"). */ export declare function inferDomainFromPath(filePath: string, knownDomains: string[]): string | null; /** * Build a bidirectional map between spec domains and source files */ export declare function buildSpecMap(options: SpecMapperOptions): Promise; /** * Load spec content for a domain, reading the spec file from disk. * Returns the markdown content truncated to maxChars, or null if unavailable. */ export declare function getSpecContent(domain: string, specMap: SpecMap, rootPath: string, maxChars?: number): Promise; /** * Find which domains a file maps to, using direct lookup + directory inference */ export declare function matchFileToDomains(filePath: string, specMap: SpecMap): string[]; export interface ADRMapping { id: string; title: string; adrPath: string; relatedDomains: string[]; relatedLayers: string[]; status: string; } export interface ADRMap { byId: Map; byDomain: Map; } /** * Parse the ## Related section from an ADR file to extract domains and layers. */ export declare function parseADRRelated(content: string): { domains: string[]; layers: string[]; }; /** * Build an ADR map by reading all ADR files from the decisions directory. * Returns null if no decisions directory exists. */ export declare function buildADRMap(options: SpecMapperOptions): Promise; //# sourceMappingURL=spec-mapper.d.ts.map