/** * Static op-coordinate → source-file map for the self-improvement fix-gen stage. * * Given a regression's `opCoord` (the `domain.operation` string produced by * {@link "../selfimprove/envelope-diff.js".DiffEntry.opCoord}, e.g. `tasks.show`), * this module resolves the **repo-relative** paths of the CLI handler and the * core module(s) most likely to contain the regression. The file list is fed into * the fix-gen prompt builder ({@link "./fix-gen-context.js"}) so the LLM receives * bounded, targeted code context rather than zero context or an unbounded repo * dump. * * ## Design: static map, not a registry query * * The ops catalog (the `OPERATIONS` array in `@cleocode/contracts`) encodes * `{ gateway, domain, operation }` but does NOT track source-file provenance. * Runtime nexus queries (`cleo nexus query`) would work but introduce an * in-process dependency on the nexus subsystem (an expensive side-effectful * import in the fix-gen hot path). A **static map keyed by `domain.operation`** * is the cost-free alternative: it is derived once (by reading the repo's known * handler layout), is small enough to inline, and carries zero import-time cost. * * The map covers the common `tasks` domain operations exercised by the canonical * scenarios. The entry for an unregistered `opCoord` returns an empty file list * (`{ handlerFiles: [], coreFiles: [] }`) — the fix-gen stage degrades gracefully * to "no context" (the model still receives the regression diff and may emit * `NO_PATCH`, which is the honest outcome when context is absent). * * ## File path convention * * Every path is **repo-relative** (no leading `/`). The file content loader * ({@link "./fix-gen-context.js"}) resolves them against `repoContext.projectRoot` * before reading. * * Import-time side-effect-free: no IO, no dynamic imports. * * @module @cleocode/core/selfimprove/op-source-map * @epic T11889 * @task T11988 */ /** * Resolved source files for one op-coordinate. * * - `handlerFiles`: the CLI dispatch handler(s) in `packages/cleo/src/dispatch/domains/` * - `coreFiles`: the core-logic module(s) in `packages/core/src/` (the file most * likely to contain the regression for this operation) * * Both lists are repo-relative. Either may be empty when not applicable. */ export interface OpSourceEntry { /** CLI dispatch handler files (repo-relative). */ readonly handlerFiles: readonly string[]; /** Core module files that implement the operation logic (repo-relative). */ readonly coreFiles: readonly string[]; } /** * Resolve the handler + core source files for a given op-coordinate. * * Returns the {@link OpSourceEntry} from the static map when the `opCoord` is * registered, or {@link EMPTY_ENTRY} when it is not. NEVER throws. The returned * lists contain repo-relative paths; callers resolve them against the project root * before reading. * * @param opCoord - The op coordinate to resolve (e.g. `'tasks.show'`). * @returns The resolved {@link OpSourceEntry} (may be empty for unknown ops). * * @example * ```ts * const { handlerFiles, coreFiles } = resolveOpSourceFiles('tasks.show'); * // handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'] * // coreFiles: ['packages/core/src/tasks/show.ts'] * ``` */ export declare function resolveOpSourceFiles(opCoord: string): OpSourceEntry; /** * Collect the unique set of source files for a list of op-coordinates. * * Deduplicates across entries so a scenario with two ops from the same handler * does not include the handler twice. Returns the merged `{ handlerFiles, coreFiles }` * with order preserved (first-seen wins for dedup). * * @param opCoords - The op-coordinate strings to collect files for. * @returns The merged, deduplicated {@link OpSourceEntry}. * * @example * ```ts * const entry = collectOpSourceFiles(['tasks.find', 'tasks.show']); * // entry.handlerFiles: ['packages/cleo/src/dispatch/domains/tasks.ts'] * // entry.coreFiles: ['packages/core/src/tasks/find.ts', 'packages/core/src/tasks/show.ts'] * ``` */ export declare function collectOpSourceFiles(opCoords: readonly string[]): OpSourceEntry; //# sourceMappingURL=op-source-map.d.ts.map