- Added a lookahead helper to detect `\` continuation lines after blank lines during range replacements.
- Converted interior blank lines to explicit continuation-sentinel inserts when followed by a continuation, preserving open replacement state.
- Extended atom parser tests to cover implicit blank-`\` handling for range and single-anchor replacements, including trailing-blank termination.
- Updated adjacent-duplicate auto-fix logic to remove a line from each detected pair when bracket balance changed.
- Adjusted the validation to accept the corrected file only after all removals restore original bracket balance.
- Added a regression test for one edit creating duplicate block closers in two unrelated segments and asserting the auto-fix warning.
- Allowed bare `LidA..LidB` to recover a missing-range-delete typo and accepted `|` as a legacy range replacement separator while validating ranges and replacement text.
- Enabled indented hashline statements to parse as replacement edits and added a preflight pass that validates all atom sections before any file write occurs.
- Updated hash-mismatch messaging, prompt wording, and tests to reflect hash-only rebase candidates and the new range/section behaviors.
- Updated the Atom grammar to parse replacement blocks via a set block rule that no longer targets range replacements only.
- Extended continuation preprocessing to allow backslash lines after single-line replace operations (including legacy `@` and `|` forms) while preserving the active-replacement check.
- Added tests and prompt documentation for single-line continuation cases and for rejection of backslash-like text outside an active replacement.
- Added atom edit support for Lid ranges, before-anchor inserts, and no-op Lid=TEXT success handling.
- Expanded hashline recovery to scan shifted hashes, match unique alternates, and emit ±5 anchor-shift hints.
- Added edit failure categorization with per-category counts, percentages, and detailed report lines.
- Added regression coverage for shifted-hash recovery, range continuation, cursor shorthand, and split-file atom ops.
- Reversed atom mode parsing of cursor anchors so "^" now resolved to BOF and "$" to EOF.
- Updated the atom command documentation and examples to reflect the corrected BOF/EOF markers.
- Adjusted parser tests to expect prepend via "^" and append via "$" with corresponding cursor kinds.
- Atom edit application stopped throwing when a `-Lid|OLD` delete anchor's OLD payload mismatched the current line.
- Delete hunks now ignore the OLD payload and rely on Lid hash anchoring for validation and rebasing.
- Atom edge-case tests were updated to verify mismatched OLD payloads are now accepted when hashes still match.
- Removed the guard that rejected edits when multiple mutating anchors were auto-rebased in atom anchor validation.
- Updated atom hash-mismatch tests to show multiple set and delete anchors can rebase together and still return warning messages.
- Auto-split `+@Lid` and `+-Lid` lines in `parseDiffLine` into their intended op plus a blank insert.
- Split non-contiguous delete runs into contiguous sub-runs in `normalizeHunks` and attached inserts to the last run.
- Added regression coverage for op-prefixed auto-splitting and non-contiguous delete insertion placement.
- Rejected malformed atom diff lines (orphan '-' and unrecognized ops) with parse errors.
- Tracked mutating set/delete anchors during validation and errored when multiple stale anchors required auto-rebase.
- Added duplicate-line auto-fix in applyAtomEdits when bracket balance restores, emitting Auto-fixed warnings.
- Updated atom prompts/changelog and expanded tests for unknown ops, auto-rebase, and duplicate-line handling.
- Updated atom mode diff output to use path-prefixed preview text and removed the explicit summary header.
- Changed hashline preview generation to truncate unchanged runs by direct slicing and reduced placeholder spacing for line prefixes.
- Updated hashline preview expectations in tests to match the new compact unchanged-line formatting.
- Added compact Lark grammar processing and applied it to OpenAI custom-format tools before conversion.
- Reworked atom mode into `---PATH` compact commands with new grammar, parser, and rm/mv file operations.
- Updated `hline`/`href`/`hrefr` helper behavior and hashline mismatch guidance using shared anchor state.
- Standardized path formatting with `formatPathRelativeToCwd` across LSP, prompts, and edit/search/write tools.
- Added benchmark run-path handling, including `.gitignore` runs mapping, absolute reports, and safer snapshot output.
- Added tests for compact grammar payloads, atom parsing/execution, renderer streaming, and path-list outputs.
- Removed the newline guard for `replace.with` in atom edit parsing so multiline replacement text is accepted.
- Updated atom tests to assert replacing a matching line with multiline content now succeeds.
- Stopped clearing `optimisticUserMessageSignature` during session-context rendering so interactive status preserves in-progress signatures.
- Replaced atom sed parsing and operations with replace-based edit schema (`find`, `with`, `all`) and `replace_file`.
- Removed bracketed/range locator handling and delimiter-based block APIs, including `splice_block` workflows.
- Restricted Atom locator parsing to one anchor or `$` with line > 0 and enforced line-only targets.
- Updated atom docs and tests to cover the new replace semantics, anchor-only edits, and literal newline limits.
- update BUG 3 regex to match "splice locator" warning text
- drop the "rejects mixing splice_block with other anchor edits" test;
splice_block intentionally coexists with other anchor edits
- Removed the `F` sed flag and `literal` field, keeping only `pat`, `rep`, and `g`, and dropped the obsolete `F` test.
- Updated sed parsing, serialization, and error text to remove `splice_block` exclusivity and explain regex escaping.
- Reworked atom prompt format to `<ops>/<splice>/<sed>`, with shared `{path, edits}` calls and strict one-loc/one-verb rules.
- Updated docs (`read.md` and `CHANGELOG.md`) to remove `F:true` anti-patterns and add current `line+hash` and sed behavior guidance.
- Replaced `AgentTool` `nointent` and `deriveIntent` with a unified `intent` option that supports `omit`, `optional`, `require`, or a callback function.
- Updated agent tool schema injection and execution paths to inject `_i` as required/optional/omitted and to derive intent through the new `intent` callback.
- Aligned atom-edit tests with the updated default sed behavior (`g` now off by default and explicit `g: true` for global replacement).
- Replaced `atom.sed` string syntax with `{pat,rep,g?,F?,i?}` objects in schema, prompts, and tests.
- Changed sed validation defaults so `pat` is regex, `g` defaults to global replacement, and `F:true` forces literal matching.
- Fixed `sed` edge cases by allowing sequential same-anchor edits, handling zero-length matches, and preserving chaining.
- Updated native build flow to local `--profile` defaults, refactored enum generation, and switched totals to `total_ms`.
Drop three pieces of well-intentioned-but-fragile string mangling that
were quietly mutating model edit content:
- `maybeAutocorrectEscapedTabIndentation` in both hashline and atom edit
modes (plus the `PI_HASHLINE_AUTOCORRECT_ESCAPED_TABS` env toggle and
`isEscapedTabAutocorrectEnabled` helper). Literal `\\t` in edit content
is now preserved verbatim.
- `maybeWarnSuspiciousUnicodeEscapePlaceholder` and the
`runHashlinePreflightSanitizers` wrapper. The warning was misleading:
it flagged `\\uDDDD` as suspicious without distinguishing intentional
literal text from a likely-malformed escape, and it was the only
remaining caller.
- The hand-rolled JSON-unescape fallback in
`decodePartialJsonStringFragment` (renderer.ts). The fallback used
`String.fromCharCode` (mishandling lone surrogates) and only covered a
subset of JSON escapes, so the same fragment decoded one way mid-stream
and a different way after `JSON.parse` succeeded. Now we trim a
trailing partial `\\u`/odd-backslash escape and surface the raw
fragment if `JSON.parse` still fails.
- Added a guard in applySedToLine that probes matches and rejects sed patterns that match empty strings.
- Updated atom edit error handling to label invalid sed expressions as rejected rather than failed to compile.
- Adjusted sed tests to expect the new rejection wording and added coverage for zero-length pattern `s/()/X/`.
- Updated `read` selector parsing for file and URL reads to accept optional leading `L` and `+` count-style ranges.
- Adjusted truncation notices and schema/help text to emit and suggest `sel` offsets without the `L` prefix, including continuation and suggestion messages.
- Updated hashline/output parsing and related tests to recognize the new `sel` formatting in truncation notices.
- Renamed atom tool schema fields and internal `AtomEdit` operation from `set` to `splice` in edit parsing and application.
- Adjusted resolver and conflict checks to use `splice` semantics, including file-loc rejection, blank-line deletion handling, and sed precedence.
- Updated atom edit documentation and tests to describe and verify the new `splice`-based API.
- Updated `formatMatchLine` to emit `*` for matched lines, a leading space for context, and a `|` anchor/content separator.
- Revised grep/hashline mismatch messages and prompts to describe the new marker and separator format.
- Aligned affected atom and hashline tests with the updated match-line prefixes and separators.
- Updated atom edit location parsing to treat "$" as a file-wide target for prepend, append, and sed, and rejected "^" as a supported locator.
- Added a new sed_file operation that runs line-wise substitutions across the full file, preserving ordering and trailing-newline semantics while failing when no lines match.
- Removed per-entry path overrides from atom resolution and made read selector parsing return "none" for unrecognized selectors to defer handling to specialized readers.
- Added `sed` atom editing with `g`, `i`, and `F` flags, path/anchor parsing, and conflict handling updates.
- Changed hashline and grep/read output to `LINE+ID|content` with `>` match prefixes and `:` context prefixes.
- Fixed atom anchor parsing for path-qualified locs, hyphenated single anchors, and content hints after `|` or `:`.
- Updated prompts, changelog, and tests to document and validate the new hashline and `sed` formats.
- Removed the atom tool's `sub` verb from its schema, parser, conflict checks, and edit application.
- Updated atom documentation, examples, and tests to reject `sub`-based replacements in favor of `set` replacements.
- Adjusted Anthropic strict-tool handling by dropping `write` from the allowlist and updating alignment expectations.
- Added auto-rebasing for stale atom and hashline anchors within ±2 lines, with warning diagnostics.
- Removed atom range-locator support and dropped `between` ops, updating docs/tests for `sub` over `set` nudges.
- Changed no-op handling to track unchanged hashline edits and emit contextual hints for unchanged ranges.
- Expanded Anthropic strict error handling to retry on schema-too-complex and compiled-grammar-too-large errors.
- Added anchor-retargeting warning checks and updated edit tests to expect locator and range-locator rejections.
- Updated python tool-call fixtures by adding `title` to executed-cell payloads and adjusting related test expectations.
- Adjusted hashline tests to expect colon-prefixed anchors in format, diff preview, and parse assertions.
- Updated ast-edit test regexes and split logic to parse colon-delimited hashline prefixes.
- Disabled strict schema enforcement on AskTool to relax request validation.
- Removed the optional `cwd` field from Python tool parameters and used `session.cwd` for warmup and execution context.
- Updated atom edit test fixtures to pass `set` as arrays instead of scalar strings.
- Added locator-based atom edits with required `loc`, including inline `file:line`, range, and `^`/`$` selectors.
- Added path resolution via top-level path, entry path, or `path:loc` selectors and flattened multi-target atom execution.
- Removed `del`; required `set/pre/post` to use line arrays and mapped `set: []` to deletion semantics.
- Changed `sub` payloads to required `[find, replace]` tuples and tightened parsing to accept null optional verbs and array-or-null lines.
- Added `CodeFrameMarker` and `formatCodeFrameLine()` to centralize code-frame gutter formatting.
- Extended diff rendering to preserve `|` and `│` separators, aligning gutter markers and line numbers.
- Reworked AST, grep, hashline, Vim, and diff renderers to use shared line formatting with computed `lineNumberWidth`.
- Updated atom editing flow and tests, including `resolveAtomEntryPaths` migration and new loc-based/edge-case coverage.
- Adjusted benchmark runner early-stop configuration by passing `buildEarlyStop` through prompt collection.
- Changed hashline/atom parsing to require full `line+suffix` anchors and emit full-anchor guidance on failures.
- Updated atom/hashline prompt docs, `atom.test.ts`, and changelog entries to require exact full anchors like `160sr`.
- Added preformatted `displayContent` for read/grep/ast tools and switched renderers to prefer it in TUI output.
- Updated mismatch and grep/ast renderers to show context with `*` markers and gutter lines, removing legacy helpers.
- Expanded hashline and chunk bigram tables to 647 entries and moved chunk checksums to a 40-item namespace.
- Changed hashline anchors from `LINE#ID`/`:` to concatenated `LINEID`\t forms across parsing and tool outputs.
- Removed line-number padding and routed diff/read/grep/renderer output through raw numbers, tabs, and `toDisplayLine` formatting.
- Renamed atom ops to `pre`/`post`, removed `ins`, and updated schemas, prompts, and tests for new insertion behavior.
- Added `examples` support to `StringEnum` schemas and propagated it to tool metadata.
- Added concise descriptions and example values across coding-agent tool schemas for clearer guidance.
- Documented the new StringEnum examples capability in `packages/ai/CHANGELOG.md`.
- Cast `real` to `HASHLINE_BIGRAMS` elements in `staleBigramFor` test setup.
- Updated the atom edit schema and tool prompt docs to replace the standalone `between` form with a 2-tuple `set` form for exclusive block-body replacement.
- Adjusted `resolveAtomToolEdit` so `set` accepts either a single anchor or `[open, close]`, translates tuple input to an internal between-style op, and rejects tuple values that are not anchor strings.
- Expanded tests to verify tuple-based `set` resolution and to enforce validation errors for invalid `set` array inputs.
- Added `between` atom edits with `after`/`before` anchors and logged them in changelog docs.
- Added `between` docs to prompt tooling, including two-anchor exception and anchor-order rules.
- Added `between` validation to reject stale anchors, invalid ranges, overlap, and nested interior edits.
- Reworked `applyAtomEdits` to apply `between` operations as bottom-up interior splices and adjacent-line inserts.
- Updated `file_path` schema description in review tool to "Path to the file".
- Added `AtomEdit` tests for `between` parsing and edge-case success/failure coverage.
- Added raw read output propagation so read/archive commands bypass anchors, line numbers, and chunk formatting.
- Fixed atom/hashline editing by tightening hashline prefixes and applying grouped anchor edits in stable order.
- Hardened chunk parsing and path handling by using `bigram_end` checks and resolving edit paths via shared `args.path` fallback.
- Updated path-related behavior for chunk, replace, patch, and hashline previews to honor optional edit paths.
- Removed mode-level param validators and replaced them with runtime handling, then removed obsolete validation tests.
- Added `atom` edit mode to `EditTool` with single-point hashline-style dispatch and `executeAtomSingle`.
- Added `AtomToolEdit`/`AtomParams` schema and `atom` prompt docs to require one op per edit entry.
- Changed `EditTool` entry processing to inherit per-entry `path` from a top-level request `path` fallback.
- Added top-level `path` defaults to patch and replace schemas and now reject missing entry paths.
- Added an `atom` streaming strategy and registered it in `EDIT_MODE_STRATEGIES` for live mode support.
- Enabled hashline read anchors for `atom` mode via `file-display-mode.ts` path-display logic.
- Added `atom` unit tests covering schema checks, anchor conflicts, and hash mismatch diagnostics.
- Aligned hashline and chunk token handling to `HASHLINE_BIGRAMS` in `computeLineHash` and parsing regexes.
- Removed hashline file-level `move`/`delete` options from schemas and execution so edits are in-place updates only.
- Hardened hashline prefix parsing to reject non-bigram IDs, preventing false stripping of `#` comment lines.
- Updated `read()`/prompt wording so raw reads skip prefixes and examples now show anchors like `123#th`.
- Updated hashline chunk tests for new `HASHLINE_BIGRAMS` IDs and replaced stale hash constants.
The previous mismatch text ('1 line has changed since last read. Use
the updated LINE#ID references shown below.') reads like a successful
edit followed by an informational note. Providers whose tool-result
plumbing does not surface `isError: true` to the model (e.g. Qwen via
the OpenAI-completions shim, where mitmproxy traces show the model only
receives the content text) treat the response as a success and proceed
with stale state.
Reword the message to start with 'Edit rejected:' and explicitly state
'The edit was NOT applied' so the failure is unambiguous in plaintext.
The structural payload (>>> markers, updated LINE#IDs) is unchanged.
Fixes#742
Slots a new "apply_patch" variant alongside the existing edit modes
(replace, patch, hashline, chunk, vim). The mode accepts a single input
string containing a Codex *** Begin Patch / *** End Patch envelope,
parses it with a new lenient parser (heredoc-tolerant), and fans each
file-op out to the existing executePatchSingle so LSP writethrough,
plan-mode guards, fs-cache invalidation and diagnostics are shared
with the patch mode.
Exposes both tool shapes from the spec: the JSON function-tool variant
(§1.2, {input: string}) and the OpenAI custom-tool / Lark-grammar
"freeform" variant (§1.1, raw patch string). The edit tool advertises
a Lark grammar via customFormat and a wire name via customWireName;
openai-responses emits it as a grammar-constrained custom tool when a
model opts in with applyPatchToolType: "freeform" in models.json.
custom_tool_call / custom_tool_call_output are plumbed end-to-end
through the shared responses code (emission, streaming, history
replay), and the agent-loop dispatcher matches tool calls by either
name or customWireName so returned calls route correctly.
Also threads preview/diff rendering for apply_patch through the TUI
(tool-execution + edit renderer) so streaming patches show per-file
diffs like the other edit modes.
Default edit mode is unchanged (hashline); opt in via edit.mode or
PI_EDIT_VARIANT=apply_patch.
- Standardized missing-file read errors and now return `File not found: <path>` for absent edit targets.
- Centralized AI provider, usage, and OAuth helpers into shared modules to remove duplicated logic.
- Migrated OAuth/API-key login flows to shared factory helpers and removed inline prompt/token-exchange code.
- Reused shared tools and formatter utilities for discovery, stream tails, LSP batching, and source formatting.
- Consolidated repeated test helpers and fixtures into shared modules, replacing inline helper duplicates.