/** * Agent-facing tool FAMILIES — terminal, file, search, git (T1741 · epic T11456). * * The six richer tool families layered over the atomic primitives and registered * into the {@link ./agent-registry.js | AgentToolRegistry}, on top of the thin * built-ins in {@link ./builtin-agent-tools.js}: * * - **AC1** `run_shell` — terminal execution with PTY + non-PTY (spawn) modes * (PTY via the OPTIONAL, lazily-loaded `node-pty`; transparent spawn fallback). * - **AC2** `read_file_paged` — file read with `offset`/`limit` pagination. * - **AC3** `write_file_atomic` — atomic (tmp-then-rename) write. * - **AC4** `apply_patch` — fuzzy (whitespace-tolerant) text replacement. * - **AC5** `search_files` — ripgrep-backed search with graceful degradation * to `grep` when `rg` is absent. * - **AC6** `git_status` / `git_diff` / `git_log` / `git_commit` — workspace- * confined git operations. * * Every family performs ALL side effects through the injected * {@link GuardedToolSurface} (deny-first chokepoint) — there is NO raw `fs` / * `child_process` use here. The pure helpers (patch matching, search-output * parsing, git parsing) are exported for direct unit testing with mocked * backends (AC8). Import-time side-effect-free. * * @epic T11456 * @task T1741 * @see ./guard.js — the deny-first chokepoint every executable routes through */ import type { ApplyPatchResult, GitLogEntry, GitStatusEntry, ReadFilePagedResult, SearchFilesMatch } from '@cleocode/contracts/tools/agent-tools'; import type { AgentToolRegistry } from './agent-registry.js'; /** * Slice a file's text into a paginated window. Pure helper — no I/O — so it is * unit-testable in isolation (AC8). * * @param content - The full file text. * @param offset - 0-based starting line (clamped to `[0, totalLines]`). * @param limit - Max lines to return; `undefined` → to end of file. * @returns The paginated {@link ReadFilePagedResult} body for `path`. */ export declare function paginateLines(content: string, path: string, offset?: number, limit?: number): ReadFilePagedResult; /** Outcome of {@link applyFuzzyPatch} — the new content + how it matched. */ export interface FuzzyPatchOutcome { /** The patched content (unchanged when `matchKind === 'none'`). */ readonly content: string; /** How `oldText` was located. */ readonly matchKind: ApplyPatchResult['matchKind']; /** 0-based line where the replacement began (when applied). */ readonly startLine?: number; } /** * Apply a text replacement, falling back to whitespace-tolerant fuzzy matching * when an exact substring match is not found. Pure function of its inputs — no * I/O — so it is unit-testable with no filesystem (AC8). * * Strategy: * 1. **Exact** — a verbatim `indexOf(oldText)` substring replacement (first hit). * 2. **Fuzzy** (when enabled) — compare `oldText` line-trimmed against every * same-length window of the file's line-trimmed lines; the first window that * matches is replaced (preserving the file's other lines). * 3. **None** — no match; content returned unchanged. * * @param content - The current file content. * @param oldText - The block to locate. * @param newText - The replacement. * @param fuzzy - Permit fuzzy matching (default `true`). * @returns The {@link FuzzyPatchOutcome}. */ export declare function applyFuzzyPatch(content: string, oldText: string, newText: string, fuzzy?: boolean): FuzzyPatchOutcome; /** * Parse ripgrep `--vimgrep`/`-n` style output (`path:line:col:text` or * `path:line:text`) into structured matches. Pure helper (AC8). * * @param stdout - ripgrep stdout. * @param maxResults - Cap on returned matches. * @returns The parsed matches and whether the cap truncated them. */ export declare function parseRipgrepOutput(stdout: string, maxResults: number): { matches: SearchFilesMatch[]; truncated: boolean; }; /** * Parse `git status --porcelain=v1` output into structured entries. Pure (AC8). * * @param stdout - porcelain-v1 stdout. * @returns The parsed status entries. */ export declare function parseGitStatus(stdout: string): GitStatusEntry[]; /** * The `--pretty=format:` argument for {@link parseGitLog} — SHA, author name, * ISO date, subject, unit-separated. */ export declare const GIT_LOG_FORMAT = "%H\u001F%an\u001F%aI\u001F%s"; /** * Parse `git log --pretty=format:` output. Pure (AC8). * * @param stdout - The git-log stdout. * @returns The parsed commit entries, newest-first. */ export declare function parseGitLog(stdout: string): GitLogEntry[]; /** * Register the agent-facing tool FAMILIES (terminal, file, search, git) into * `registry`. Pure registration — no I/O, no scan; side effects happen later * through the injected {@link GuardedToolSurface}. * * @param registry - The registry to populate. */ export declare function registerAgentToolFamilies(registry: AgentToolRegistry): void; //# sourceMappingURL=agent-tool-families.d.ts.map