Commit Graph

3142 Commits

Author SHA1 Message Date
Qiang e36bfcfba8 fix(coding-agent): handle truncation markers and nested anchors in hashline stripping
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
2026-04-16 09:26:08 +08:00
can1357 028f8c5436 chore: bump version to 14.1.2 2026-04-14 19:29:04 +02:00
can1357 308d7eb401 fix(tests): update chunk-mode regression tests to new edit schema
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.
2026-04-14 13:32:23 +02:00
can1357 89ca7f662e style: remove extra blank line 2026-04-14 13:18:08 +02:00
can1357 6d8f715c8f fix(coding-agent): preserve event emission order for non-message_update events
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.
2026-04-14 13:16:28 +02:00
can1357 59bbdd0194 fix(coding-agent): eagerly track agent_end handler work to prevent post-prompt recovery race
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.
2026-04-14 12:16:12 +02:00
can1357 bae191227d chore: bump version to 14.1.1 2026-04-14 10:53:45 +02:00
can1357 ed2fd6e3f3 feat(coding-agent): added edit tool consolidation via vim handlers
- 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.
2026-04-14 10:49:53 +02:00
can1357 9324fc4432 fix(scripts): resolved chunk-edit benchmark prompts to read test.rs
- 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.
2026-04-14 07:37:26 +02:00
can1357 33f4610917 fix(coding-agent): improved vim tool guidance and step execution behavior
- 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.
2026-04-14 07:16:27 +02:00
can1357 742cc5c163 feat(vim): added Vim ex :join and :join! support for line joining
- 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.
2026-04-13 23:06:24 +02:00
can1357 1bfbf79fea fix(coding-agent): corrected vim arg handling by dropping metadata fields
- 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.
2026-04-13 22:59:04 +02:00
can1357 755ada38a2 feat(coding-agent/vim): added ex append and insert command support
- 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.
2026-04-13 22:53:51 +02:00
can1357 9f9433c5ca feat(coding-agent): added contextual vim ex parsing for .,$,+,- addresses
- Added contextual Vim ex parsing for `.,$`, `+/-` addresses, copy/move destinations, and `del/ya` aliases.
- Added Vim engine handling for clamped ranges, no-op `update`, and register-aware `yank`/`put` command execution.
- Added regression tests for explicit ranges, yank/put, inline-cursor rendering, and `message_update` ordering.
- Updated session event flow by queuing `message_update` events, changed websocket default to `off`, and documented Unreleased notes.
2026-04-13 22:52:26 +02:00
can1357 8bd7310cb4 feat(coding-agent): implemented vim tool-call preview mapping per command
- 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.
2026-04-13 21:57:33 +02:00
can1357 786d752e48 feat(vim): added VimEngine text-object and insert/visual/normal commands
- 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 `->`.
2026-04-13 21:34:33 +02:00
can1357 cd3433e0db fix(coding-agent/edit): auto-corrected ~ chunk body indentation by stripping tabs
- 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.
2026-04-13 21:27:58 +02:00
can1357 014a8b8be9 feat(coding-agent/vim): added Vim ex and motion features for copy, move, and sort
- 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.
2026-04-13 21:27:47 +02:00
can1357 5caddcebd6 feat(cross-cutting): added fd crate export and moved fuzzy-find bindings
- 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"`.
2026-04-13 21:25:50 +02:00
can1357 10ba6bff89 fix(coding-agent): fixed vim command parsing and chunk edit fallback behavior
- 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.
2026-04-13 21:14:35 +02:00
can1357 6224c18239 fix(coding-agent): added warnings for conflicting chunk-edit operations
- 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.
2026-04-13 20:29:05 +02:00
can1357 550efebbcc fix(vim): prevented partial-insert corruption in vim tool execution
- 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.
2026-04-13 20:23:43 +02:00
can1357 b3537b0e3d docs(coding-agent/prompts): updated Vim tool prompt docs with strict kbd and insert guidance
- 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.
2026-04-13 17:02:58 +02:00
can1357 51251ed7c5 fix(chunk-edit): smart multi-op resolution + proper delete handling
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).
2026-04-13 17:01:26 +02:00
can1357 097f721d35 docs(chunk-edit): add sibling lines + Python indentation examples
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.
2026-04-13 17:01:26 +02:00
can1357 fb59c45439 feat(vim): added escape/CR literal parsing and count-aware G/gg motions
- 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.
2026-04-13 17:01:26 +02:00
can1357 212d56bc11 feat: added strict-mode fallback for OpenAI tool calls with all_strict
- 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.
2026-04-13 15:46:06 +02:00
can1357 939501f624 feat(coding-agent-async-tooling): added poll tool and async prompts
- 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.
2026-04-13 13:04:12 +02:00
can1357 779cf2eb4a feat(coding-agent-vim-tooling): added vim tooling special-key aliases
- 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.
2026-04-13 13:04:07 +02:00
can1357 8886e6ec06 fix(coding-agent-find-tool): corrected find glob ordering by mtime
- 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.
2026-04-13 13:03:59 +02:00
can1357 04f199f1f4 fix(coding-agent/async): used sequential bg_ IDs for default async job names
- 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.
2026-04-13 12:29:30 +02:00
can1357 c62ab2d53e chore(benchmarks-misc-fixes): cleaned benchmark task/pid validation
- 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.
2026-04-13 12:27:10 +02:00
can1357 dd023eb4de feat(coding-agent-vim-tool): added vim editing tool stack with parser, engine, and renderer wiring
- 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.
2026-04-13 12:26:59 +02:00
can1357 677a9371bc feat(tool/session-wiring): added session-mode edit tool wiring to swap tools
- 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.
2026-04-13 12:26:45 +02:00
can1357 43f4b28a7b feat(coding-agent-chunk-edit-protocol): added vim mode to chunk-edit API
- 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.
2026-04-13 12:26:37 +02:00
can1357 96bbddb186 fix(lsp): resolved lsp race by tracking progress tokens to gate actions
- 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.
2026-04-13 12:26:21 +02:00
can1357 655a3bffea feat(coding-agent): added multi-file edits in coding-agent with per-entry payloads
- 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.
2026-04-13 06:59:01 +02:00
can1357 11b7ba7846 fix(coding-agent): respected session title source when formatting terminal titles
- 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.
2026-04-13 06:22:37 +02:00
can1357 e992ba6d4e feat(pi-natives/chunk): implemented chunk grep tree output for safe edit
- 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.
2026-04-13 05:43:18 +02:00
can1357 6de07594e5 test(coding-agent): aligned chunk-mode tool tests with current native chunker output 2026-04-13 04:33:16 +02:00
can1357 9a3fb24204 test(coding-agent): added test coverage for editor border color update call
- 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.
2026-04-13 04:30:46 +02:00
can1357 df97efe883 test(coding-agent): updated tests for abbreviated chunk path conventions
- 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.
2026-04-13 04:24:59 +02:00
can1357 4bc79b9a67 fix: fixed session naming context and native import paths
- 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.
2026-04-13 01:12:15 +02:00
can1357 d2caf2770c feat: added /rename command to set session titles for status/header/tab display
- 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`.
2026-04-13 01:09:38 +02:00
can1357 debb76723d chore: catalog imports 2026-04-13 01:06:01 +02:00
can1357 897c485ed4 chore: reformat 2026-04-13 00:58:32 +02:00
can1357 b4887e37b7 fix: address PR regression follow-ups 2026-04-13 00:48:13 +02:00
can1357 d2202d0b0b fix(coding-agent): ignore auto titles for session accent 2026-04-13 00:42:24 +02:00
can1357 fafc5c24ed merge: PR #628 2026-04-13 00:31:40 +02:00
can1357 6eab1e0356 merge: PR #690 2026-04-13 00:31:39 +02:00