/** * hashline-apply.ts — op-model → patch-string translator. * * PURE TRANSLATION ONLY. This module maps the host edit dialect * ({op, pos, end, lines}) onto the hashline patch grammar. It does NO hashing, * NO staleness validation, and NO merge recovery — all of that lives in the * Rust binary and is authoritative. The generated patch text is handed to * `hashline patch -` (stdin envelope form). * * Op → patch translation table (binary-native, verified against v0.9.1): * * replace {pos:"N:hh", lines} → SWAP N:hh:\n+ * replace {pos:"N:hh", end:"M:aa"} → SWAP N:hh..M:\n+ * append {pos:"N:hh", lines} → INS.POST N:hh:\n+ * append {} (no pos) → INS.TAIL:\n+ * prepend {pos:"N:hh", lines} → INS.PRE N:hh:\n+ * prepend {} (no pos) → INS.HEAD:\n+ * replace {} with empty lines / delete {pos} → DEL N:hh * delete {pos, end:"M"} → DEL N:hh..M * * Range note: the binary validates the hash only when it directly follows the * FIRST line number (`SWAP N:hh..M:` / `DEL N:hh..M`). A space-separated * `N:hh M:aa` form is NOT accepted. The end-of-range hash is a line-number * range hint, not a content hash; wrappers emit `N:hh..M` and let the binary * validate the start anchor. * * Payload escapes (patch_format.rs): a row `+TEXT` is a literal line; `++TEXT` * decodes to `+TEXT`; `+-TEXT` decodes to `-TEXT`; a lone `+` is a blank line. * `lines: []` on a replace is emitted as DEL. */ /** Edit operation dialect understood by the plugin tools. */ export interface EditOperation { op: "replace" | "append" | "prepend" | "delete" | "replace_block" | "delete_block" | "insert_block_after"; /** Anchor `N:hh` (from hashline_read output). Required for replace/delete, optional for append/prepend. */ /** Anchor `N:hh` for line ops; plain 1-based line number (number) for block ops. */ pos?: string | number; /** Inclusive end anchor `N:hh` for range operations. */ end?: string; /** New content lines. Omit/empty for delete. */ lines?: string[]; } /** * Escape a payload row per the patch grammar. * * Body rows are always `+` + payload. The parser's escape tokens (`++` -> literal * `+`, `+-` -> literal `-`; patch_format.rs) mean a payload that itself starts * with `+` or `-` is written correctly by simply prefixing the row marker — * `+lead` becomes `++lead`, `-lead` becomes `+-lead`. A lone `+` is a blank * line. (Matches pi-hashline's escapePayloadLine.) */ export declare function escapePayloadLine(line: string): string; /** Render the payload rows for a body edit (`SWAP`/`INS.*`). */ export declare function renderBody(anchor: string, lines: string[]): string; /** Translate a single edit op into one or more patch grammar lines. */ export declare function translateEdit(edit: EditOperation): string[]; /** * Build the full patch string for a batch of edits. Multi-op batches are * wrapped in the `*** Begin Patch` / `*** End Patch` envelope and piped via * stdin (`hashline patch -`). */ export declare function buildPatchText(edits: EditOperation[]): string; /** Build a short UI title summarizing the edit batch (for context.metadata). */ export declare function buildEditTitle(args: { path: string; edits?: EditOperation[]; }): string; //# sourceMappingURL=hashline-apply.d.ts.map