Commit Graph

243 Commits

Author SHA1 Message Date
can1357 ecd1554eba feat: renamed subagent handoff flow to use yield instead of submit_result
- Renamed subagent completion flow from `submit_result` to `yield` across SDK tools, prompts, and docs.
- Updated executor/task handling to require and parse `yield` calls, replacing legacy submit-result extraction and state flags.
- Added `subagent-yield-reminder` and updated system prompts to require `yield` with `result.data` or `result.error`.
- Renamed hidden-tool and registration plumbing to `yield`, including discovery helpers and renderer/test surface.
2026-04-26 00:29:52 +02:00
can1357 480d40f2a8 fix: corrected optional edit path fallback across chunk hashline modes
- 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.
2026-04-26 00:29:18 +02:00
can1357 ce17e4d1da fix(coding-agent): harden CPU info and PR push target
Fixes #779

Fixes #778
2026-04-25 18:56:47 +02:00
can1357 d82377cda8 revert: "read-to-open"
This reverts commit c48d2e6080.
2026-04-24 22:36:44 +02:00
can1357 99a21b95ba feat(pi-natives-chunk): enabled row chunk support in pi-natives-chunk
- Added markdown `Row` chunk support by introducing `ChunkKind::Row`, mapping it to tag `"row"`, and emitting row chunks for table rows.
- Updated Go chunk parsing to support method signatures (`func (recv) Name`), prefer method parsing in signatures, and adjust root rules to classify package/import chunks correctly.
- Changed chunk-edit behavior to add read-only `read:true`, replace `write:null` deletes with explicit `delete`, and require one explicit action per entry.
- Added safer chunk-edit execution with region matching, replacement reindentation, table-row append handling, and stricter warnings/errors for boundary and invalid operations.
2026-04-24 21:26:56 +02:00
can1357 e3ca350f95 fix(coding-agent): added partial JSON path extraction for streamed edit calls
- Added helper utilities in the edit renderer to parse partial JSON fragments and extract the `path` field.
- Used the extracted path as a fallback when resolving the edit target file, enabling partial streamed edit calls to show the path.
- Built and stored the render context before call rendering, and added a test covering partial JSON edit path rendering.
2026-04-24 19:38:38 +02:00
can1357 c48d2e6080 feat(coding-agent): implemented read-to-open tool aliasing in runtime
- Canonicalized file and CLI defaults from `read` to `open` across tool registration and prompts.
- Added `resolveToolAlias()` and applied alias-normalized tool selection so legacy `read` maps to `open`.
- Updated runtime, UI, and export layers to treat `open` as first-class while preserving `read` compatibility.
- Renamed read prompt docs to `open.md`/`open-chunk.md` and refreshed system guidance to recommend `open`.
- Updated tool-related tests and expectations from `read` to `open` (including test fixtures and aliases).
2026-04-24 19:13:11 +02:00
makoMakoGo 311608eff3 fix(coding-agent/codex-search): force web_search tool_choice and add citation fallback
When the Codex Responses API synthesizes an answer without emitting
url_citation annotations, previously-empty sources made cited results
look ungrounded. Add:

- tool_choice: { type: "web_search" } so Codex must call the tool
- markdown-link + bare-URL extraction from the answer as a fallback
  that only runs when no structured citations were returned

The model-resolution path is unchanged; getBundledModels already
returns a usable Codex catalog on main.

Closes #724
2026-04-24 07:34:15 +02:00
JunghwanNA 0d6968f7a6 Keep sqlite where filters inside the paginated helper
The SQLite read helper is documented as a structured selector path
with explicit pagination, while raw SQL already has a separate
q=SELECT escape hatch. This change rejects SQL control syntax outside
quoted strings so helper filters cannot override LIMIT/OFFSET, while
still allowing semicolons inside quoted literals such as LIKE '%;%'.

Constraint: Preserve the documented q=SELECT raw SQL path unchanged
Rejected: Replace where= with a new filter DSL | too broad for a regression fix
Confidence: high
Scope-risk: narrow
Directive: Keep table?where=... as a structured helper; if broader SQL is needed, route it through q=SELECT instead
Tested: bun --cwd=packages/natives run build; bun --cwd=packages/coding-agent run check; bun --cwd=packages/coding-agent test test/tools/sqlite.test.ts
Not-tested: Manual interactive omp read invocation against a live SQLite file
2026-04-24 07:25:09 +02:00
can1357 7f81179b40 feat(config): add commands.enableOpencode{User,Project} settings
Mirror the existing `commands.enableClaudeUser`/`commands.enableClaudeProject`
schema entries so the OpenCode discovery provider exposes the same
user/project toggle surface as Claude. Default remains true to preserve
current behavior.

Fixes #661
2026-04-24 06:33:20 +02:00
can1357 cafa86a6cf fix(tools/sqlite): reject comments, terminators, and pagination keywords in where=
The structured SQLite helper interpolates `where=` directly into SQL.
A crafted clause like `where=1=1 LIMIT 1000000 --` could comment out
the helper's bound `LIMIT ? OFFSET ?`, returning the full table in
violation of the documented pagination contract.

Validate where= at the selector boundary and reject SQL comments,
statement terminators, and pagination/attach/pragma keywords. Raw SQL
remains available via ?q=SELECT... for callers that need it.

Fixes #735
2026-04-24 06:33:20 +02:00
can1357 661449df09 test(coding-agent/core): removed stale chunk-tree test suite from core
- Removed stale test suite file `packages/coding-agent/test/core/chunk-tree.test.ts`.
2026-04-24 05:54:10 +02:00
can1357 c5666e153f feat(grep): route comma-separated explicit files to exact-file grep
resolveMultiSearchPath now reports `exactFilePaths` when every token
resolves to a plain file (no globs, no suffix glob) and accepts a
single resolvable token so partially-missing lists still search the
resolvable subset. grep iterates those exact files individually
instead of collapsing them into a brace-union glob, which preserves
the user's explicit file set even when siblings share a basename.

Also adds a small `[grep] match lines use ':'; context lines use '-'`
banner when context lines are rendered, and splits the per-file
rendering helpers so files with no remaining matches no longer emit
empty headers.
2026-04-24 05:49:10 +02:00
can1357 e51f0b5321 fix(ast-edit): detect stale previews on apply
Apply now recomputes per-file replacement counts from the actual apply
pass and compares them against the preview. If totals or per-file
counts drift (file changed between preview and apply, or apply matched
nothing), the tool returns an isError result explaining that the
preview is stale instead of silently claiming success with mismatched
numbers.
2026-04-24 05:49:02 +02:00
can1357 6b976f6eeb fix(coding-agent/lsp): serialized LSP writes and retried references after project load
- Queued outbound JSON-RPC messages behind a per-client promise queue to serialize writes.
- Added a project-load gate for project-aware LSP operations before diagnostics and reference lookups.
- Retried declaration-only references with a short delay until project metadata is available, then proceeded with normal results.
2026-04-24 05:08:11 +02:00
can1357 1a3a3830b3 fix(coding-agent): validated bare-path chunk deletes in chunk mode
- Relaxed chunk-mode parameter validation to accept `{path}`-only edits as valid delete operations.
- Updated the invalid-parameters help text to document accepted chunk delete payloads.
- Added a test that verifies a bare `{path}` edit removes the targeted chunk when null values are stripped.
2026-04-24 04:35:59 +02:00
can1357 6b8b46c410 fix(coding-agent/edit): fixed apply_patch streaming preview parsing behavior
- Added a streaming parser path for apply_patch envelopes that tolerates incomplete patch bodies.
- Updated apply patch preview expansion to return best-effort hunks when the renderer is in partial mode.
- Added a renderer test confirming streaming apply_patch input shows file paths without end-marker parse errors.
2026-04-24 00:48:03 +02:00
can1357 7e9d568346 fix(coding-agent/tools): replaced tabs with spaces in diagnostic rendering output
- Applied tab sanitization to LSP diagnostic parsing, fallback entries, and rendered diagnostics output.
- Updated tool diagnostics formatting to strip tabs from parsed file, source, message, code, and summary fields.
- Added regression tests confirming rendered diagnostics contain no tab characters and preserve message text after sanitization.
2026-04-24 00:43:55 +02:00
can1357 601c029c20 fix: stabilize apply_patch custom tool integration 2026-04-24 00:25:21 +02:00
Hans Josephsen 2a367bf043 feat(coding-agent/edit): add codex apply_patch as a new edit mode
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.
2026-04-24 00:15:17 +02:00
can1357 820776d0cc test(coding-agent): align prompt wording assertions 2026-04-23 23:05:24 +02:00
can1357 214600265e merge: PR #706
# Conflicts:
#	packages/coding-agent/CHANGELOG.md
2026-04-18 23:22:51 +02:00
djdembeck 5e45bee73f refactor: improve path handling with normalization refactor
- Refactor path normalization to combine expandPath and normalizeLocalScheme
- Add validation in utils.ts to reject local:// paths as filesystem paths
- Fix bash-skill-urls regex to handle hyphen-prefixed local:/ patterns
- Add tests for hyphen-prefixed and @local: patterns
2026-04-18 22:41:09 +02:00
djdembeck c7c3d4a82d fix: avoid matching local:/ in filesystem paths
- Add negative lookbehind to regex in bash-skill-urls to prevent matching local:/
  inside paths like /repo/local:/PLAN.md
- Normalize local scheme before expanding paths in path-utils
- Add test cases for both changes
2026-04-18 22:41:09 +02:00
djdembeck 91998d326d fix: handle local:/ single-slash URL pattern
Expands the regex pattern to match local:/ (single-slash) URLs in addition to local:// (triple-slash), preventing potential Linux path leaks.

- Add regex patterns for single-quoted, double-quoted, and unquoted local:/ URLs
- Add test coverage for all three quote styles
2026-04-18 22:41:08 +02:00
Sam Biggins 22f429235e fix(web-search): decoupled Tavily topic from recency filter
Removed unconditional topic:news coupling in buildRequestBody that scoped
Tavily index to news publications whenever recency was set. Technical queries
with --recency now search the general index filtered by time only.

Tightened SearchParams.recency contract in base.ts: providers MUST interpret
recency as a pure time filter and MUST NOT change topic scope as a side effect.
2026-04-18 22:36:33 +02:00
can1357 1e439a05d4 fix(coding-agent/tools): demoted existing in_progress todos when starting another task
- Updated todo start handling to set the requested task to in_progress while demoting all other in_progress tasks to pending.
- Added task note rendering in summary output by prefixing each note line with "Note:".
- Set GIT_OPTIONAL_LOCKS to 0 in git execution options and added tests for out-of-order start jumps and note summaries.
2026-04-16 14:58:58 +02:00
Can Bölük 4a731f1ecc feat(coding-agent): added todo-write mutation fields in place of ops
- Replaced todo_write's `ops` payload with top-level mutation fields (`phases`, `complete`, `start`, `add_notes`, etc.).
- Removed in-place task content and note updates; moved note writes to append-only `add_notes` calls.
- Matched `add_tasks.phase` by phase ID or name and appended new note text to existing notes.
- Changed execution to drop strict in-progress update sequencing, support `start`, and auto-promote next pending task.
- Updated tests and prompt docs to use direct payloads (`phases`, `complete`, `add_tasks`) instead of `ops`.
2026-04-15 18:53:48 +02:00
can1357 381a658f6a refactor(ai): restructured stream first-event watchdog handling
- Reworked `idle-iterator` to replace the first-event watchdog wrapper with a shared timeout handle passed through stream iteration.
- Updated Anthropic and OpenAI/Azure response-completion streams to pass the watchdog into `iterateWithIdleTimeout` and rely on unified first-event timeout logic.
- Raised the default first-stream-event timeout from 60 seconds to 100 seconds.
2026-04-15 18:50:41 +02:00
can1357 8f1da70d79 feat(coding-agent): enabled simple-mode routing in task tool execution
- Added task.simple to settings and schema with default, schema-free, and independent modes.
- Added mode-aware task schema and validation to enforce context/schema rules per simple mode.
- Updated prompts and template rendering to tailor headers and guidance for each simple mode.
- Added simple-mode capabilities and updated TaskTool execution for mode-aware context behavior.
- Added tests for independent rendering and mode-specific rejection of invalid context or schema inputs.
2026-04-15 18:13:47 +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 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 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 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 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 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 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 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 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