The hashline prefix stripping logic uses an "all-or-nothing" heuristic:
it only strips N#XX: anchors when every non-empty line carries one.
When the Read tool truncation notice (e.g. [Showing lines 1-300 of
332. Use sel=L301 to continue]) is present in content passed to the
Edit or Write tool, that marker line breaks the heuristic, causing ALL
anchors to be written to disk verbatim. On subsequent reads, those
persisted anchors get double-prefixed (1#NX:1#BQ:---), compounding
the corruption.
This can happen when the AI model pastes Read tool output (including
the truncation marker) back into an Edit/Write call. While this is
arguably a model-level issue, the toolchain should be resilient against
it rather than silently corrupting files.
Changes:
- Add READ_TRUNCATION_NOTICE_RE to detect Read tool truncation markers
- Update collectLinePrefixStats to exclude truncation marker lines from
the non-empty line count so they no longer break the stripping heuristic
- Add stripLeadingHashlinePrefixes helper for recursive stripping of
nested/double-prefixed anchors (handles already-corrupted content)
- Add filterTruncationNotices helper to remove truncation marker lines
- Update both stripNewLinePrefixes and stripHashlinePrefixes to filter
truncation markers and use recursive anchor stripping
- Add 5 new test cases covering truncation markers and nested anchors
The tests were using the old { sel, op, content } format which is no longer
recognized after the edit tool consolidation. Updated to use the new
{ path: 'file:selector', write/insert } format.
The #emitSessionEvent refactoring changed the order: #emit was called before
#emitExtensionEvent, but for non-message_update events this introduced
microtask timing issues that broke auto-compaction and handoff tests.
Fix: keep the original order (extension first, then emit) for non-message_update
events. Only message_update events use fire-and-forget extension queueing with
emit-first ordering.
The #emitSessionEvent refactoring introduced a microtask gap between session
event emission and the compaction check in #handleAgentEvent. This allowed
#waitForPostPromptRecovery to run before #postPromptTasksPromise was created,
causing deferred handoff tasks to be missed.
Fix: track the handler's agent_end work as a post-prompt task synchronously
before the await, ensuring #waitForPostPromptRecovery always blocks until the
compaction check completes.
- Removed the standalone vim tool and normalized built-in/requested tooling to edit.
- Updated session and SDK tool activation to dedupe lowercase names and track edit state via the edit key.
- Added vim-mode argument detection and delegated edit rendering/execution into Vim handlers under edit.
- Updated Vim step handling to auto-reorder numeric-positioned commands, including cc/C/S/s/i/I/A cases.
- Renamed prompt/changelog text and test expectations to reflect edit-only tool naming and usage.
- Fixed Vim path normalization to allow colon-prefixed targets without raising ToolError.
- Documented the new Vim path behavior in the package changelog.
- Updated chunk-edit benchmark prompts to read `test.rs` for edit and retry operations.
- Updated vim benchmark flow to use `vim`+`read`, import expected content, and display final expected output.
- Expanded benchmark fixtures to generate Rust `test.rs`, compute unified diffs, and add richer pool logic.
- Updated vim tool prompts to keep file paths separate from commands and to stress bottom-up multi-location edits.
- Added automatic reordering of simple `NGo`/`NGO` insertion steps to execute from highest to lowest line.
- Added command-path validation and Vim parser fixes for counted `i` inserts and clearer `;`/`,` error guidance.
- Implemented parsing of `:j`/`:join` and `:j!`/`:join!` ex commands and mapped them to a new `join` command shape with a whitespace-trim flag.
- Added VimEngine handling for `join` to concatenate addressed lines (or the current plus next line by default), optionally normalizing whitespace and reporting line count in the status message.
- Updated vim prompt guidance, changelog notes, and tests to document and verify both normal and `:join!` join behavior.
- Removed live Vim preview state fields and priming/cleanup flow from tool execution and rendering.
- Changed vim insert-mode exit logic to close insert mode unless the final step is paused.
- Updated changelog entries and Vim edit-file prompts to clarify insertion behavior and examples.
- Updated vim tool argument handling to clone args directly and ignore __toolCallId/__cwd metadata.
- Parser now recognizes ex-style :append and :insert commands and extracts text arguments.
- The Vim engine now executes parsed :append and :insert command cases by inserting lines at resolved ranges.
- Prompt docs were updated to clarify line-opening behavior and required ex-command syntax.
- Added vim tool-call IDs across EventController, UiHelpers, and ToolExecution for per-call preview mapping.
- Extended Vim type and command parsing with update/write, edit, global, yank, and put handling.
- Added Vim engine support for new commands and motions, including gJ, g*, g#, g_, |, and gu/gU/g~.
- Reworked Vim tool flow to cache per-file engine clones, reuse tool details, and stream inserts in chunks.
- Updated vim.md and changelog to document new vim keys, ex aliases, and fixed :global preview behavior.
- Added parser and renderer tests plus a tmp/vim_test.txt fixture for chunked, cursor, and partial-insert cases.
- Added `C-u` and `C-o` insert-mode commands in `VimEngine.#executeInsert` for line clear and one-shot normal actions.
- Added visual insert operators `J`, `u`, `U`, `p`, and `P` to join or case-transform a selection and replace it with register content.
- Added normal-mode `+`, `-`, `_`, `*`, and `#` commands in `VimEngine` for line-motion and whole-word search navigation.
- Added paragraph text object `p` in `#resolveParagraphTextObject` to support `ip`/`ap` paragraph selections.
- Added `gv`, `gJ`, `ZZ`, and `ZQ` handling in `VimEngine` for reselection, range join, and save/quit shortcuts.
- Changed vim tab breadcrumb rendering in `render.ts` from ` -> ` to `->`.
- Normalized chunk write handling for body-region (~) edits by trimming common leading tabs from non-first non-empty lines before applying the content.
- Updated indentation detection to rely on non-empty lines only, preventing blank lines from skewing the minimum-indent calculation.
- Updated the warning text to describe the automatic indentation correction and clarified that ~ body content should be written at column 0.
- Added support for :copy, :move, and :sort ex commands with range selection and destination/flag handling.
- Stored last character-find state to enable ; and , repeat motions for f/F/t/T searches.
- Implemented Yank, R-mode, and gg/gU/gu command handling in normal-mode execution paths.
- Removed `SearchDb` APIs and `searchDb` fields, dropping db-backed state from native and agent sessions.
- Replaced crate export `fff` with `fd`, moving fuzzy-find bindings into `fd.rs`.
- Removed `SearchDb`/picker fast-path logic from `glob` and `grep`, simplifying scan flow and dropping db args.
- Removed `SearchDb`/`getSearchDb` wiring from extension, tool, and task context constructors across coding-agent.
- Added over-indentation validation warnings in chunk-edit normalization for suspicious `~` body line formatting.
- Removed `bytes`, `fff-grep`, `fff-search`, and `blake3` deps, adding `grep-searcher = "0.1"`.
- Changed chunk edit normalization to prefer write operations, then replace, insert, then delete, with empty write values now treated as clear-content writes.
- Allowed space motions in vim input as `<Space>`, handled them as movement and rendered in error output via token display.
- Adjusted benchmark retry flow to reset files on each retry, reduced per-run call limits, and lowered the default per-turn timeout.
- Normalized chunk edit parsing now detected and warned on entries with multiple write/replace/insert operations, selected one operation by precedence, and ignored the rest.
- Execution now appended those normalization warnings and included them when a chunk edit produced no content changes.
- Updated chunk-edit and vim tool guidance plus vim rendering to document stricter edit usage and expose the current cursor position in output.
- Added rollback handling for pending INSERT-mode changes whenever a non-final kbd sequence leaves insert mode, and updated the resulting VimInputError with guidance for using `insert` and escaping insert transitions.
- Hardened VimTool execution by resetting stale insert state before processing commands and by only applying empty inserts when Vim remains in INSERT mode.
- Adjusted Vim search handling to mimic Vim magic escaping and taught `o`/`O` numeric prefixes to act like `Go`/`GO` line inserts, then updated the expected error message test.
- Clarified the Vim tool prompt to require `file` and clearly separate key commands from insert text.
- Added updated usage examples and best-practice guidance for whole-file replacement, line edits, search/replace, and undo.
- Documented key/mode constraints, including insert-entry requirements and required `<Esc>` handling between non-final commands.
When models send multiple operation fields (write + replace + insert),
pick the most substantive: insert > replace > write > delete.
This prevents errors for confused models that populate all fields.
Also properly maps write:null to the delete op instead of put-empty,
and adds the missing case-delete handler in toNativeEditOperation
(fixing a pre-existing TS exhaustiveness error).
Adds explicit examples showing that multiple sibling body lines all start
at column 0, and a Python-specific example for body replacement. This
reduces indentation confusion for weaker models that previously assumed
sibling lines needed relative indentation.
- Fixed `G`/`gg` motions to distinguish "no count" (go to last/first line) from explicit count.
- Added parsing for literal `\x1b`/`\r` bytes and backslash escape sequences (`\r`, `\e`, `\n`, `\t`).
- Updated `#readCount` to return `hasCount` flag propagated through operator and motion resolution.
- Synced vim buffer fingerprint from disk on reuse to handle LSP writethrough reformats.
- Added `toolStrictMode` support with `all_strict`/`none`/`mixed` options to OpenAI compatibility.
- Fixed OpenAI-completion strict-mode flows by capturing failed HTTP responses and retrying once as non-strict.
- Fixed completion error reporting by surfacing captured status, headers, and JSON `type`/`param`/`code` details.
- Improved strict-schema enforcement with WeakMap memoization and circular-schema detection in sanitization.
- Fixed OpenRouter provider lookup by resolving fallback model IDs for suffix and date variants in registry resolution.
- Refactored benchmark tooling and added async RPC error-window tracking for scheduled run execution.
- Replaced deprecated `await` tool wiring with `poll` in tool exports and built-in tool registry.
- Updated bash and task prompts plus start-result messaging to direct users to the `poll` tool.
- Added effective timeout metadata to Bash tool results and rendered output to show that effective timeout.
- Implemented bounded auto-background wait logic that backgrounds jobs when the timeout window is exhausted.
- Added `<escape>` and `<return>` as special-key aliases in `parser.ts`, mapping to `Esc` and `CR`.
- Clarified Vim tool behavior so `open` replaces the active buffer and non-paused `kbd` calls auto-save.
- Updated the Vim prompt contract to treat `insert` as raw text entered only after entering INSERT mode.
- Increased `scripts/vim-edit-benchmark.py` `request_timeout` from 60s to 120s for longer edit runs.
- Propagated `combinedSignal` into `doGlob` so cancellation is honored during glob execution.
- Skipped fallback `doGlob(false)` when `timeoutSignal` was aborted to avoid redundant work.
- Sorted `result.matches` by descending `mtime` in JS to return the most recent hits first.
- Trimmed preferredId once before evaluating fallback conditions.
- Replaced Snowflake-based default ID creation with an incremental bg_* scan.
- Returned the first bg_* value not currently present in #jobs for deterministic IDs.
- Added `vim` as an edit variant in benchmark CLI/config and rating script coverage.
- Expanded benchmark execution so `vim` is treated as a mutation tool for retries, stats, and edit intent checks.
- Adjusted `TaskTool` output schema precedence so explicit params override agent frontmatter.
- Fixed `TaskTool` success counting by excluding aborted tasks from success totals.
- Improved validation guidance in `SubmitResultTool`/`TodoWriteTool` for clearer recovery when payloads are missing or invalid.
- Added background command PID regression coverage in `executeBash` to confirm a real, terminateable PID is returned.
- Added `VimTool` in `src/tools/vim.ts` with `open`, `kbd`, `insert`, and `pause` actions.
- Implemented `src/vim/{buffer,engine,parser,commands,render,types}.ts` for interactive Vim modes and operators.
- Updated `src/tools/index.ts` to normalize `edit`/`vim` tool selection and skip the inactive edit variant.
- Added `vim` registration in `BUILTIN_TOOLS` and `toolRenderers` for discoverability and output formatting.
- Added streaming renderer snapshots with viewport, caret focus, and diff output for `vim` calls.
- Added `test/tools/vim.test.ts` and `scripts/vim-edit-benchmark.py` coverage for the new editor stack.
- Updated `AgentSession` and `createAgentSession` to resolve active edit tool names via `resolveEditToolName`.
- Filtered inactive edit variants with `filterInactiveEditToolName` so tool listings expose the active edit mode.
- Normalized requested edit-capable tool names with `normalizeToolNamesForEditMode` during activation and startup.
- Synced edit-tool mode after model changes so the active tool swaps between `edit` and `vim` automatically.
- Enabled per-file partial updates by threading `onUpdate` through `EditTool` and `executePerFile`.
- Updated `ToolExecutionComponent` to render multi-file edit `perFileResult` entries as separate boxes with pending state.
- Added `vim` as a supported edit mode and resolved mode-specific active tool names.
- Migrated chunk-edit requests from legacy `op`/`content` to `path` plus `write`, `replace`, and `insert`.
- Replaced chunk-edit internals with `put`/`replace`/`delete` operations and ID-based selection.
- Updated chunk prompts/output docs to document ID-based selectors and `write: null` deletions.
- Switched chunk and grep render output to `@`/dash-style anchors and updated file-count behavior for multi-file edits.
- Updated multi-file result rendering with distinct file counting and pending-file progress indicator.
- Refreshed chunk-mode and chunk-tree tests for the new contract and anchor style.
- Tracked `$/progress` begin/end notifications to keep active work-done progress tokens.
- Added `projectLoaded` signaling with timeout fallback while awaiting initial project load completion.
- Blocked cross-file LSP actions until project load finished to avoid premature file-index lookups.
- Handled `window/workDoneProgress/create` requests by acknowledging them for progress-capable servers.
- Extended `LspClient` with `activeProgressTokens`, `projectLoaded`, and `resolveProjectLoaded` for startup sync.
- Updated LSP regression and diagnostics tests to initialize new `LspClient` state fields.
- Added multi-file edit payload support by requiring per-entry `edits` arrays across patch, hashline, replace, and chunk modes.
- Changed edit schemas and validators to move `path` (and `sel`->`path`) and op data into each edit entry.
- Changed edit execution flow to parse `file:selector` paths, run single-entry executors per file, and return grouped per-file results.
- Updated chunk diff rendering and test expectations to emit consistent anchor gutters with spaced pipes and `^` head-line markers.
- Propagated session title source through terminal-title update calls so auto and user names are handled consistently across controllers.
- Suppressed auto-generated names in status-line segments and completion messages by falling back to cwd-based titles.
- Updated title formatter tests to verify auto-generated and user-specified session titles produce different terminal labels.
- Added hierarchical chunk grep output grouped by directory, file, and chunk with aligned chunk anchors.
- Updated chunk rendering to show clipped head/tail context with explicit truncation and expand markers.
- Changed chunk edit and streaming validation to use chunkToolEditSchema-based checks for safe edit detection.
- Enhanced grep rendering to use structured ChunkedGrepMatch data with displayPath and chunk checksum metadata.
- Updated selector-controller session-delete test mocks to include updateEditorBorderColor.
- Extended session deletion expectations to verify updateEditorBorderColor is called.
- Refined a long chunk-mode test string assertion to multiline formatting for readability.
- Updated chunk-mode and core chunk tests to use abbreviated chunk selectors introduced by path truncation.
- Adjusted expected chunk-path and error-path strings for markdown, Rust, and TLA+ fixtures to match the new naming scheme.
- Updated SIXEL sanitization assertions to check for the new "visible columns omitted" truncation message.
- Passed the user context when setting the session name during subprocess execution.
- Updated native build scripts to import detectHostAvx2Support from the correct shared module paths.
- Added `/rename <title>` slash command to set explicit session names and update header/tab titles.
- Added `session_name` status segment with hash-derived accent color for session titles.
- Fixed shell execution failure sanitization to preserve all `execResult` fields after redacting stderr.
- Fixed tool execution completion output to pass original `toolResult` text instead of sanitized `content`.