/** * Repo commands — thin handlers over the Repository Explorer (P6-07, * DESIGN.md §18, §11, PRD FR-080–FR-088). * * Each handler applies parse-level defaults/validation, builds the * Explorer request, and returns the normalized Explorer result as * base data. The handlers own NO Provider client, raw MCP name, * ZRead parser, traversal transport, cache policy, retry, or close. * * Provider selection, capability support, configuration, Adapter * construction, and adapter.repository agreement live in * `src/index.ts`. The Explorer receives a `RepositoryCapability` * plus shared `ExecutionDependencies` and owns path canonicalization, * BFS, and result projection. * * Handler interface (P6-07A): mirrors the shared Search command * pattern. `deps: RepoHandlerDependencies` is REQUIRED — production * and direct tests cross the same compile-checked Interface. An * optional trailing `CommandContext` follows when a caller wants to * surface per-invocation context; the handlers do not currently read * it. A `CommandContext` is NOT a valid substitute for `deps`: a * direct caller who omits `deps` fails loudly with a TypeError * before reaching the Explorer rather than silently degrading. */ import type { CommandContext, CommandResult } from "../command-invocation.js"; import type { RepositoryBrief, RepositoryCapability, RepositoryTreeResult, RepoBriefFocus } from "../capabilities/repository.js"; import type { ExecutionDependencies } from "../lib/execution.js"; import { type LadderRule } from "../lib/output-budget.js"; /** * Sealed v1 probe set. Opening the set later is additive — do NOT * mutate this constant at runtime. */ export declare const REPO_BRIEF_FOCUS: readonly RepoBriefFocus[]; /** * Probe query constants per DESIGN D7. These are NOT constructed at * call time — they are literal constants so the brief's evidence * chain (search.query inside the envelope) is reproducible byte-for- * byte across providers and reruns. */ export declare const README_QUERY = "README"; export declare const MANIFEST_QUERY = "package.json pyproject.toml Cargo.toml go.mod"; /** * Pure tree-derived file selection (DESIGN D1 / D7 steps 5–8). The * tree is the path inventory — search excerpts carry no paths, so * file selection MUST be tree-derived. The returned `manifests` array * is in canonical kind order; `readme` is the single shallowest * README match. Non-file entries (directories) are ignored even when * their `name` happens to look like a README/manifest. */ export declare function selectBriefFiles(tree: RepositoryTreeResult): { readme?: string; manifests: string[]; }; /** * Parse the `--focus` flag value. Splits on `,`, trims, drops empties, * validates against the sealed `REPO_BRIEF_FOCUS` set, dedupes * preserving first occurrence, and rejects empty-after-processing. * * The error message names the sealed set so a consumer can fix the * value without consulting docs (DESIGN D7 step 3). */ export declare function parseBriefFocus(raw: string): readonly RepoBriefFocus[]; /** * Parse the `--depth` flag value. Positive integer (≥ 1); `undefined` * means "unset — use the Explorer's default". Accepts only numbers and * numeric strings (CLI parses flags as strings); every other runtime * type — booleans, null, objects — is rejected BEFORE coercion so a * `true` can never ride `Number(true) === 1` past validation. */ export declare function parseBriefDepth(raw: unknown): number | undefined; /** * Parse the `--max-chars` flag value. Positive integer (≥ 1); * `undefined` means "unset — use the Explorer's default upper bound". * Same runtime-type gate as `parseBriefDepth`: only numbers and numeric * strings are coerced. */ export declare function parseBriefMaxChars(raw: unknown): number | undefined; export interface RepoSearchOptions { language?: "en" | "zh"; noCache?: boolean; } export interface RepoTreeOptions { path?: string; depth?: number; noCache?: boolean; } export interface RepoReadOptions { noCache?: boolean; } export interface RepoBriefOptions { /** * Requested focus, a subset of the sealed `REPO_BRIEF_FOCUS` set, in * caller order. Omitted defaults to all four. Non-empty; each token * must be a sealed member (DESIGN D7 step 3). Duplicate tokens are * collapsed preserving first occurrence, matching `parseBriefFocus`, * so direct handler callers cannot smuggle duplicates into the * envelope's `focus` field. */ focus?: readonly RepoBriefFocus[]; /** Tree-only scope (DESIGN D3: search/read have no path parameter). */ path?: string; /** Tree-only depth; defaults to the Explorer's default (1). */ depth?: number; /** Bypasses the response cache for every probe. */ noCache?: boolean; } /** * Dependencies injected by `src/index.ts` after Provider selection, * capability support check, configuration check, Adapter * construction, and adapter.repository agreement. The handlers * never resolve a Provider descriptor themselves. Required — a * caller that omits `deps` is malformed and fails loudly. */ export interface RepoHandlerDependencies { readonly capability: RepositoryCapability; readonly execution: ExecutionDependencies; /** * Invocation-resolved credential values used to redact failed-probe * error messages. Injected by `src/index.ts` already resolved from * the invocation's env (including injected credentials absent from * ambient `process.env`). Omitted → the ambient `configuredSecrets()` * fallback, mirroring `invokeCommand`'s output/error boundary. */ readonly secrets?: readonly string[]; } /** * Repository Search. Validates parse-level request shape, delegates * to the Explorer with the injected Repository Capability, and * returns the normalized Search result as base data. */ export declare function repoSearch(repo: string, query: string, options: RepoSearchOptions, deps: RepoHandlerDependencies, _context?: CommandContext): Promise; /** * Repository Tree. Validates parse-level request shape (including * depth), delegates to the Explorer's BFS traversal, and returns * the normalized Tree result as base data. Tree is never * character-limited; `maxChars` is intentionally not accepted. */ export declare function repoTree(repo: string, options: RepoTreeOptions, deps: RepoHandlerDependencies, _context?: CommandContext): Promise; /** * Repository File read. Validates parse-level request shape, * delegates to the Explorer with the injected Repository Capability, * and returns the normalized File result as base data. */ export declare function repoRead(repo: string, path: string, options: RepoReadOptions, deps: RepoHandlerDependencies, _context?: CommandContext): Promise; /** * Repository Brief. Composes the three Explorer operations into one * schema-version-1 envelope (DESIGN D2/D3/D4). Fixed probe order: * tree → search("README") → search(manifest names) → read loop (README * first, then manifests in canonical kind order, cap 4 total reads). * * Parse-level validation (DESIGN D7): `validateRepo`, `--depth` a * positive integer, `--focus` a non-empty subset of the sealed set * (default all four). Forwarding (DESIGN D3): `--no-cache` to every * call; `--depth`/`--path` to the tree only. T5 (ADR-0007) + fix-round * F-2: `--max-chars` is NOT an option here at all — the dispatcher * seam (index.ts) consumes it once against the assembled envelope via * BRIEF_LADDER; passing it to `repoBrief` directly is a loud * ValidationError, never a silent no-op. * * Every Explorer call runs settled (DESIGN D6): a throw becomes a * `failed` probe record and the brief continues. Exit policy: ≥1 probe * `ok` → `{kind: "data"}` (exit 0); every probe terminal and failed → * the last error is rethrown so the executor routes it through the * standard stderr boundary (exit 1). */ export declare function repoBrief(repo: string, options: RepoBriefOptions, deps: RepoHandlerDependencies, _context?: CommandContext): Promise>; /** The repo-brief Output Budget ladder (ordered; ADR-0007 T5). */ export declare const BRIEF_LADDER: readonly [LadderRule, LadderRule, LadderRule, LadderRule]; export declare const REPO_HELP: string; //# sourceMappingURL=repo.d.ts.map