/** * Compiler facade — re-exports from focused modules. * * Schemas and types: ./compiler-schema.ts * Diff parsing: ./diff-parser.ts * Rule execution: ./rule-engine.ts * * This file retains: hashing, regex validation, file I/O, and LLM response parsing. */ import type { AstGrepYamlRule, CompiledRule, CompiledRulesFile, CompilerOutput } from './compiler-schema.js'; export type { AstContext, AstGrepYamlRule, AuthoredFixture, AuthoredProvenanceRecord, CompiledRule, CompiledRulesFile, CompilerOutput, DiffAddition, Legitimacy, MinedProvenanceRecord, NapiConfig, NonCompilableEntry, NonCompilableReasonCode, ProvenanceRecord, RegexValidation, RuleEventCallback, RuleEventContext, Violation, } from './compiler-schema.js'; export { AstGrepYamlRuleSchema, AuthoredFixtureSchema, type AuthoredNegativeFixture, AuthoredNegativeFixtureSchema, AuthoredProvenanceRecordSchema, CompiledRuleSchema, CompiledRulesFileSchema, CompilerOutputSchema, deriveRuleClass, isAuthoredProvenance, isMinedProvenance, LEDGER_RETRY_PENDING_CODES, LegitimacySchema, MinedProvenanceWireSchema, NapiConfigSchema, type NearMissSource, NearMissSourceSchema, NonCompilableEntryReadSchema, NonCompilableEntryWriteSchema, NonCompilableReasonCodeSchema, type PreimageSource, PreimageSourceSchema, provenanceKind, ProvenanceRecordSchema, shouldWriteToLedger, } from './compiler-schema.js'; export { extractAddedLines } from './diff-parser.js'; export { applyAstRulesToAdditions, applyRules, applyRulesToAdditions, type CoreLogger, extractJustification, fileMatchesGlobs, matchesGlob, type RuleEngineContext, } from './rule-engine.js'; /** Hash a lesson's heading + body to detect changes since compilation. */ export declare function hashLesson(heading: string, body: string): string; export { validateRegex } from './regex-validation.js'; /** * Load compiled rules from a JSON file. Returns empty array if file missing. * * Filters out rules with inert lifecycle status so the lint execution path, * rule tester, and every other consumer that enforces rules treats them as * silenced (#1336 — "The Archive Lie"). Three inert states qualify: * - `'archived'` — explicitly silenced via curation (#1336). * - `'untested-against-codebase'` — Stage 4 (mmnto-ai/totem#1682) ran * against the consumer's codebase and produced zero matches. The * rule's runtime behavior is unknown; the schema docstring at * `compiler-schema.ts:100-107` commits to inert-like-archived * semantics, and this filter is what enforces that contract. * - `'pending-verification'` — pack rule installed via `totem install` * in the cloud-compile bootstrap path (mmnto-ai/totem#1684). Stage 4 * has not yet run on the consumer's codebase. The rule stays inert * until the first-lint promotion interceptor runs the verifier and * replaces the status with one of the three terminal lifecycle * values. The interceptor itself runs BEFORE this filter and reads * from the unfiltered manifest via {@link loadCompiledRulesFile}. * * Rules without a `status` field (legacy manifests compiled before the * lifecycle state was added) are treated as active. * * Admin and write-path consumers that need to see archived rules (e.g. * `totem doctor --pr` lifecycle management, `totem compile` pruning) should * use {@link loadCompiledRulesFile} instead, which returns the unfiltered * manifest so inert entries remain visible for telemetry and state * transitions. */ export declare function loadCompiledRules(rulesPath: string, onWarn?: (msg: string) => void): CompiledRule[]; /** * The ONE predicate for "this compiled rule is enforced" — the mmnto-ai/totem#1345 * status filter as a named function (mmnto-ai/totem#2765). Every surface that * runs or COUNTS rules resolves through it: lint's loader above, `totem status` * (which counts through that loader), and `describeProject` — the orientation * banner and the MCP `describe_project` tool — which counts the unfiltered * file through this predicate directly so it can also report the inert split. * One predicate is what makes the three numbers agree by construction; a * second spelling of the status list is how the banner came to print the raw * total (485) while lint enforced 385. */ export declare function isActiveCompiledRule(rule: Pick): boolean; /** Load the full compiled rules file (rules + non-compilable cache). */ export declare function loadCompiledRulesFile(rulesPath: string, onWarn?: (msg: string) => void): CompiledRulesFile; /** Save compiled rules to a JSON file. */ export declare function saveCompiledRules(rulesPath: string, rules: CompiledRule[]): void; /** * Save the full compiled rules file (rules + non-compilable cache). * * Every `nonCompilable` entry is validated through the strict Write schema * before serialization per the Read/Write schema invariant (lesson * 400fed87). If a caller ever passes Read-schema-shaped data back through * save, we surface the bug as a `TotemParseError` rather than letting the * permissive union silently re-accept legacy shapes on disk. */ export declare function saveCompiledRulesFile(rulesPath: string, data: CompiledRulesFile): void; /** * Expand brace patterns, normalize shallow globs, and strip unsupported syntax. * e.g., "**\/*.{ts,js}" → ["**\/*.ts", "**\/*.js"] * e.g., "*.ts" → "**\/*.ts" (shallow → recursive) */ export declare function sanitizeFileGlobs(globs: unknown[]): string[]; /** * Build engine-specific fields for a compiled rule. * * Overloaded so only the `'ast-grep'` branch accepts a compound * `Record`; `'regex'` and `'ast'` are string-only. * This prevents callers from passing a compound object to the regex * engine and silently producing `"[object Object]"` via `String(pattern)`. */ export declare function engineFields(engine: 'regex' | 'ast', pattern: string): { pattern: string; astQuery?: string; }; export declare function engineFields(engine: 'ast-grep', pattern: string | Record): { pattern: string; astGrepPattern?: string; astGrepYamlRule?: AstGrepYamlRule; }; export declare function engineFields(engine: 'regex' | 'ast' | 'ast-grep', pattern: string | Record): { pattern: string; astGrepPattern?: string; astGrepYamlRule?: AstGrepYamlRule; astQuery?: string; }; export declare function parseCompilerResponse(response: string): CompilerOutput | null; //# sourceMappingURL=compiler.d.ts.map