/** * Hashline structured edits (E008, lifted from omp's `packages/hashline` * format): read a file as numbered `LINE:TEXT` rows under a content-derived * `[path#TAG]` header; edit by naming line ranges (`PUT N.=M:` replaces, * `CUT N.=M` deletes) with the TAG validated against the live file. Numbers * are the ORIGINAL lines, so a stale read is refused instead of silently * mis-applying. This is omp's core DX win — no fuzzy old_string matching. * * op=edit is a mutation: it sits behind the {@link PermissionGate} (diff * preview + approval, shadow-snapshot hook), and every op runs the shared * {@link guardPath} boundary check BEFORE any file read. */ import { Type } from "typebox"; import type { AgentTool } from "@earendil-works/pi-agent-core"; import type { PermissionGate } from "./permission-gate.js"; import { type MutationHooks } from "./tools.js"; /** Content-derived 4-hex tag binding a read to the exact file state. */ export declare function fileTag(content: string): string; /** Render a file as numbered rows under its `[path#TAG]` header. */ export declare function formatHashline(relPath: string, content: string): string; export interface Hunk { /** "PUT" replaces the inclusive range with `body`; "CUT" deletes it. */ op: "PUT" | "CUT"; /** 1-based inclusive start line (original numbering). */ start: number; /** 1-based inclusive end line (original numbering). */ end: number; /** Replacement rows (PUT only). */ body?: string[]; } /** * Apply hunks to `content`, validating `tag` first. Returns the new content * or an error string. Hunks must be disjoint and in ascending order. */ export declare function applyHashline(content: string, tag: string, hunks: Hunk[]): { content?: string; error?: string; }; declare const HashlineParams: Type.TObject<{ op: Type.TUnion<[Type.TLiteral<"read">, Type.TLiteral<"edit">]>; path: Type.TString; tag: Type.TOptional; hunks: Type.TOptional, Type.TLiteral<"CUT">]>; start: Type.TInteger; end: Type.TInteger; body: Type.TOptional>; }>>>; }>; /** * hashline_edit: line-anchored structured edits with staleness validation. * op=read is read-only (still floor-guarded); op=edit is a MUTATION behind the * permission gate — the boundary check runs BEFORE any read (an unguarded read * first is a confirmed-guess oracle over floor files, same as edit_file), the * gate preview is a before/after diff, and `beforeMutation` fires after * approval, before the write. */ export declare function hashlineEditTool(cwd: string, gate: PermissionGate, hooks?: MutationHooks): AgentTool; export {}; //# sourceMappingURL=hashline.d.ts.map