import { type MarketplaceRef } from '@weareikko/agent-context'; import { type PostingMode } from './posting.js'; import { type ReviewDepth, type ReviewInputMode, type Severity, type ThinkingLevel } from './types.js'; export type GitLabAuthHeader = 'PRIVATE-TOKEN' | 'JOB-TOKEN'; /** Source-control backends the reviewer can target. */ export declare const PLATFORMS: readonly ['gitlab', 'github']; export type Platform = (typeof PLATFORMS)[number]; /** Default GitHub server (web) URL, honoring `GITHUB_SERVER_URL` on Enterprise. */ export declare const DEFAULT_GITHUB_SERVER_URL = "https://github.com"; /** * The single source of truth for the tool's own `CODE_REVIEW_*` settings. * * Each entry is the suffix after the `CODE_REVIEW_` prefix (e.g. `MODEL` for * `CODE_REVIEW_MODEL`). These are read directly across `config.ts`/`otel.ts` * and must NEVER be de-prefixed by {@link applyCodeReviewEnvPrefix}. * * Note: `API_KEY` is reserved. `CODE_REVIEW_API_KEY` was intentionally retired * as the AI provider key and must not be revived as one. */ export declare const RESERVED_ENV_SUFFIXES: readonly ['API_KEY', 'BASE_URL', 'DECOMPOSE_HINT_LINES', 'MAX_DIFF_CHARS', 'MAX_TOKENS', 'MIN_SEVERITY', 'MODEL', 'MODEL_POOL', 'PLATFORM', 'OTEL', 'OTEL_CAPTURE_CONTENT', 'POSTING_MODE', 'POST_SUMMARY', 'FORCE_REVIEW', 'VERBOSE', 'SKILLS', 'MARKETPLACES', 'REFRESH_SKILLS', 'THINKING_LEVEL', 'MCP', 'DISABLE_MCP', 'MCP_ENV', 'MCP_DISCOVERY', 'LABELS_ON_FINDINGS', 'LABELS_ON_CLEAN']; /** * Optional namespacing shim for provider/infra environment variables. * * For each `CODE_REVIEW_` variable whose `` is not a reserved tool * setting (see {@link RESERVED_ENV_SUFFIXES}), this exposes `` in the same * env object. The prefixed value wins when both `CODE_REVIEW_` and a * plain `` are set — the tool's scoped value should override an unrelated * CI-wide variable of the same name. * * This lets credentials and infra vars that `@earendil-works/pi-ai` reads * (`ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY`, `OLLAMA_HOST`, * ambient AWS/Vertex creds, …) — and the GitLab tokens — be * scoped under `CODE_REVIEW_` in shared CI without enumerating pi-ai's * provider list. * * Must run once at startup BEFORE config/key resolution: `getEnvApiKey` and * pi-ai's request-time reads both read `process.env` directly, so mutating it * in-process is what makes those reads pick up the de-prefixed values. * * Empty prefixed values are ignored (treated as unset). Double-prefixed names * (e.g. `CODE_REVIEW_CODE_REVIEW_MODEL`) are also skipped so a de-prefixed * suffix can never clobber the tool's own reserved `CODE_REVIEW_*` settings. * * @returns the same `env` object it was given, mutated in place. */ export declare function applyCodeReviewEnvPrefix(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv; /** * Default pi-ai's prompt-cache retention to `long` when the caller has not set * it. pi-ai reads `PI_CACHE_RETENTION` from `process.env` at request time; `long` * asks providers that support it (e.g. OpenAI's `openai-responses` API) to keep * the cached system-prompt prefix for up * to 24h so reviews spaced hours apart still reuse it. It is a safe no-op for * providers/models without long-retention support (e.g. Anthropic), where it * behaves exactly like the default `short`. * * Overridable: an explicit `PI_CACHE_RETENTION` (or `CODE_REVIEW_PI_CACHE_RETENTION`, * mapped by {@link applyCodeReviewEnvPrefix} first) is left untouched. */ export declare function applyDefaultCacheRetention(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv; export interface Config { /** * The source-control backend to review against. Auto-detected from the * environment by default (see {@link detectPlatform}); `--platform` / * `CODE_REVIEW_PLATFORM` is an explicit override that always wins. */ platform: Platform; project: string; mr: string; gitlabUrl: string; gitlabToken: string; gitlabAuthHeader: GitLabAuthHeader; /** `owner/repo` slug of the GitHub repository (`GITHUB_REPOSITORY`). */ githubRepository: string; /** Pull-request number as a string, mirroring {@link Config.mr}. */ githubPr: string; /** Token used for the GitHub REST API (`GITHUB_TOKEN` / `--github-token`). */ githubToken: string; /** GitHub REST API base; defaults to {@link DEFAULT_GITHUB_API_URL}. */ githubApiUrl: string; /** GitHub server (web) URL; defaults to {@link DEFAULT_GITHUB_SERVER_URL}. */ githubServerUrl: string; /** * Web URL of the repository under review (`CI_PROJECT_URL` on GitLab CI, * `GITHUB_SERVER_URL` + `GITHUB_REPOSITORY` on GitHub Actions). Used to link * in-repo skills to their source in the summary footer; empty outside CI, and * those skills then appear unlinked. */ projectWebUrl: string; model: string; /** * Optional pool of `provider/modelId` models for heterogeneous `full`-depth * review. When non-empty, multi-angle Find maps each angle to a pool member and * the adversarial verifier prefers a member other than the one that authored a * finding. Empty (the default) means the effective pool is just `[model]`, which * reproduces single-model behaviour byte-for-byte. Sourced from `--model-pool` * or `CODE_REVIEW_MODEL_POOL` (comma-separated). */ modelPool: string[]; minSeverity: Severity; thinkingLevel: ThinkingLevel; /** * How many stages of the review pipeline run. `single` keeps the legacy * single-pass behaviour; `verify` adds an adversarial Verify + Synthesize pass. */ reviewDepth: ReviewDepth; /** * How the change is presented to the reviewer: `auto` (inline while it fits the * budget, disk on overflow), `inline`, `disk`, or `commits`. Sourced from * `--input-mode` / `CODE_REVIEW_INPUT_MODE`; default `auto`. Optional on the * type so existing `Config` fixtures need not set it — `resolveConfig` always * populates it and read sites default to `auto`. */ inputMode?: ReviewInputMode; /** * Optional `provider/modelId` for the Verify stage (`verify`/`full` depth). When * set, every adversarial verifier runs on this model instead of the pool's * cross-family pick — pairing a cheap, high-recall Find model with a strong, * high-precision verifier. Empty (default) keeps the pool-based selection. * Sourced from `--verify-model` or `CODE_REVIEW_VERIFY_MODEL`. */ verifyModel: string; postingMode: PostingMode; apiKey: string; /** Custom base URL for the AI provider API (e.g. Ollama or other OpenAI-compatible endpoints). */ baseUrl: string; /** Maximum output tokens to request from the model. 0 uses the model's default. */ maxTokens: number; /** * Maximum cumulative diff characters sent to the reviewer. Files past this * budget are dropped and surfaced as a size-skip callout. Defaults to 100_000. */ maxDiffChars: number; /** * When > 0, an MR whose reviewed diff changes more lines than this threshold * gets a "consider decomposing this MR" hint in the summary. 0 = off (default). */ decomposeHintLines: number; /** * Lines of surrounding context per diff hunk (`git diff --unified`). More * context helps the model reason about each change but inflates tokens and * fits fewer files in the char budget; less context fits more files. 0 uses * the built-in default. Sourced from `--diff-context` / `CODE_REVIEW_DIFF_CONTEXT`. */ diffContext: number; /** * When true, diffs for files dropped by the char budget are staged on disk so * the reviewer can read them on demand instead of losing them (retrieval mode). * Default true. Disable with `--no-retrieve-skipped` / * `CODE_REVIEW_RETRIEVE_SKIPPED=0`. */ retrieveSkipped: boolean; reviewFile: string; output: string; dryRun: boolean; noPost: boolean; postSummary: boolean; forceReview: boolean; verbose: boolean; cwd: string; skills: string[]; /** Claude-plugin marketplaces referenced by name in `skills` specs. */ marketplaces: MarketplaceRef[]; /** Re-clone `git:` / `git+ssh:` skills, bypassing the on-disk clone cache. */ refreshGitSkills: boolean; /** * `--mcp` / `CODE_REVIEW_MCP` specs (repeatable / comma-separated), in the * order given: `file:`, `:`, or * `:/`. See `parseMcpSpec` in `@weareikko/agent-context`. */ mcp: string[]; /** MCP server names to drop, applied last over every source (`--disable-mcp` / `CODE_REVIEW_DISABLE_MCP`). */ disableMcp: string[]; /** * Environment variable names an MCP server definition may read through * `${VAR}` expansion (`--mcp-env` / `CODE_REVIEW_MCP_ENV`). Empty by default: * server definitions are not always operator-authored, so the reviewer's own * secrets are never exposed to them unless named here. */ mcpEnv: string[]; /** * Auto-discover `.mcp.json` files walked from the git root to `cwd` (same * walk as skill auto-discovery). Default `false` — those files are content of * the repository under review, and connecting a server means running a command * or calling a URL the merge request chose. Opt in with `--mcp-discovery` / * `CODE_REVIEW_MCP_DISCOVERY=true`, and only for repositories whose * contributors you trust. */ mcpDiscovery: boolean; /** * Labels added to the MR/PR when the review published at least one fresh * (non-duplicate) comment; the {@link Config.labelsOnClean} set is removed at * the same time. Sourced from `--labels-on-findings` / * `CODE_REVIEW_LABELS_ON_FINDINGS` (comma-separated). Empty by default. */ labelsOnFindings: string[]; /** * Labels added to the MR/PR when the review published no fresh comment; the * {@link Config.labelsOnFindings} set is removed at the same time. Sourced from * `--labels-on-clean` / `CODE_REVIEW_LABELS_ON_CLEAN` (comma-separated). Empty * by default. With both sets empty, labels are never touched. */ labelsOnClean: string[]; } export type ParsedArgs = Record; export declare function parseArgs(argv: string[]): ParsedArgs; /** * Extract the provider name from a `"provider/modelId"` model string. * Returns an empty string when the model string contains no slash. */ export declare function parseModelProvider(model: string): string; /** * Resolve the API key for the given model's provider, delegating entirely to * `@earendil-works/pi-ai`'s `getEnvApiKey`. That helper reads the provider's * standard environment variable (e.g. `ANTHROPIC_API_KEY` / `ANTHROPIC_OAUTH_TOKEN`, * `OPENAI_API_KEY`, `GEMINI_API_KEY`, `OPENROUTER_API_KEY`, …) and resolves * ambient credentials (Amazon Bedrock, Google Vertex ADC). The key is therefore * always provider-specific — a key for provider X is never used for provider Y. * * Ollama is a local OpenAI-compatible endpoint that needs no key, so a * placeholder is returned. The `--api-key` flag takes precedence in * `resolveConfig`. * * NOTE: `getEnvApiKey` reads `process.env` directly (not a passed-in env), so * tests stub `process.env` or pass `--api-key` to control the resolved key. */ export declare function resolveProviderApiKey(model: string): string; /** * Extract a pull-request number from a GitHub Actions event payload JSON string * (the file `GITHUB_EVENT_PATH` points at). Prefers `.pull_request.number`, then * the top-level `.number` (present on `issue_comment` events). Returns `''` when * the JSON is unparsable or carries no number. */ export declare function parsePrNumberFromEvent(json: string): string; /** * Extract a pull-request number from a `GITHUB_REF` of the form * `refs/pull//merge` (or `/head`). Returns `''` for any other ref shape. */ export declare function parsePrNumberFromRef(ref: string | undefined): string; /** * Resolve the GitHub pull-request number, in priority order: `--pr` flag, then * the `GITHUB_EVENT_PATH` payload (`.pull_request.number` ?? `.number`), then a * `refs/pull//merge` `GITHUB_REF`. Returns `''` when none apply. */ export declare function resolveGitHubPr(args: ParsedArgs, env: NodeJS.ProcessEnv, readEventFile?: (path: string) => string | undefined): string; /** * Determine the review platform for this run. * * Precedence: * 1. Explicit `--platform` / `CODE_REVIEW_PLATFORM` (throws on an unknown value). * 2. CI markers: `GITHUB_ACTIONS === 'true'` → github; `GITLAB_CI === 'true'` * or a present `CI_PROJECT_ID` / `CI_SERVER_URL` → gitlab. * 3. Inference from which platform's required identifiers are present * (`GITHUB_REPOSITORY` + a PR number vs. `CI_PROJECT_ID` + `CI_MERGE_REQUEST_IID`). * * Throws a {@link ConfigError} when both platforms' identifiers are present * (ambiguous) or neither is (undetectable), with a hint to set `--platform`. */ export declare function detectPlatform(args: ParsedArgs, env: NodeJS.ProcessEnv, readEventFile?: (path: string) => string | undefined): Platform; /** * Web URL of the repository under review, as the CI environment reports it: * GitLab exposes it directly, GitHub composes it from the server and the * `owner/repo` slug. Returns `undefined` outside CI, where no such URL exists. * Shared by the config (skill source links) and the OTel attribute builder. */ export declare function resolveProjectWebUrl(env?: NodeJS.ProcessEnv): string | undefined; export declare function resolveConfig(argv?: string[], env?: NodeJS.ProcessEnv): Config; export declare function validateConfig(config: Config): void; export { type Severity, type ThinkingLevel }; //# sourceMappingURL=config.d.ts.map