Commit Graph
2890 Commits
Author SHA1 Message Date
can1357 cb45cba98e feat: implemented LINEID hashline parsing/output with pre/post atom ops
- 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.
2026-04-26 02:18:32 +02:00
Daman Singh b9af1f20b1 fix(session-observer): restore plugin cache closure and fix oversized entry scroll
Two regressions from 33dfce738:

1. selector-controller.ts imported nonexistent clearPluginRootsAndCaches
   (was clearClaudePluginRootsCache). The previous commit collapsed the
   inline closure that invalidated fs caches for plugin JSON files into
   a direct function reference that doesn't exist. Restored the original
   closure with its fs cache invalidation logic.

2. scrollToSelectedEntry() snapped oversized entries back to their top
   on every PgDn/PgUp, defeating the line-scroll fallback. The condition
   'entryTop < scrollOffset' fires whenever the user pages down within
   a tall entry. Fixed: only snap when the viewport has no overlap with
   the entry (completely above or completely below it).
2026-04-25 17:50:52 -05:00
Daman Singh 1cf488ec2f fix(session-observer): systematic TUI sanitization via sanitizeLine helper
- Add sanitizeLine() helper that composes replaceTabs + truncateToWidth,
  eliminating ad-hoc sanitization across render paths
- Add contentWidth() helper for consistent viewport width computation
- Replace all direct replaceTabs/truncateToWidth calls in lines.push
  with sanitizeLine: collapsed thinking, collapsed response, tool intent,
  tool args, tool error lines, tool result lines, collapsed user preview
- Replace ad-hoc magic numbers with TRUNCATE_LENGTHS and PREVIEW_LIMITS
  constants from render-utils (60->TITLE, 100->LONG, 4/5->COLLAPSED_LINES,
  15->EXPANDED_LINES, 2->COLLAPSED_LINES, 30->EXPANDED_LINES, 3->OUTPUT_COLLAPSED)
- Remove unused MAX_TOOL_RESULT_LINES_COLLAPSED/EXPANDED constants
2026-04-25 17:35:14 -05:00
Daman Singh 33dfce7388 fix(session-observer): remove type indirection and fix collapsed user preview sanitization
- Replace `ReturnType<typeof this.ctx.ui.showOverlay>` with concrete
  `OverlayHandle` type from @oh-my-pi/pi-tui
- Remove `as any` casts and redundant `as SessionMessageEntry` in
  #loadTranscript; discriminated union narrowing on `entry.type` and
  `msg.role` is sufficient
- Add missing `replaceTabs()` on collapsed user/developer preview text,
  matching every other collapsed render path
2026-04-25 17:19:09 -05:00
can1357 d82377cda8 revert: "read-to-open"
This reverts commit c48d2e6080.
2026-04-24 22:36:44 +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
can1357 4f8697234a chore: reformat 2026-04-24 14:04:56 +02:00
can1357 ec8405bb2c fix(pi-natives/shell): resolved shell minimizer bypass for compound/piped
- Updated minimizer mode selection so `Compound`, `Piped`, and `Unsupported` plans now skip minimization.
- Removed `MarkedCommands` mode and marker-stripping paths from shell minimizer and buffering flow.
- Updated minimizer tests and changelog to document compound/piped commands bypassing minimization.
- Deleted marker metadata and helper infrastructure (`markers.rs` types/helpers) and related imports.
2026-04-24 14:00:04 +02:00
can1357 f772dd9f6a feat(coding-agent/modes): implemented ACP extension methods for session and extension endpoints
- Added cached retrieval of all sessions in AcpAgent with a 60s TTL, in-flight deduplication, and cache invalidation when creating a session.
- Implemented `extMethod` handlers for `omp/sessions/listAll`, `omp/projects/list`, `omp/chats/byCwd`, `omp/usage`, and `omp/extensions` to return sorted/bounded session and project data.
- Added extension toggling through `omp/extensions/toggle` using stored disabled provider IDs and capability enable/disable functions.
2026-04-24 13:52:21 +02:00
can1357 57b5a7e8cb fix(coding-agent/modes): used expanded editor text for input handling when available
- Updated input handling to call getExpandedText when available and fall back to getText.
2026-04-24 09:54:10 +02:00
can1357 21d50d5703 feat(coding-agent): added mode-aware streaming preview for edit outputs
- Added mode-aware streaming mode resolution and strategy registration in tool execution flow.
- Changed edit rendering to propagate mode and file-scoped diff previews across edit/vim tool outputs.
- Added chunk-mode streaming helpers (`loadChunkSource`, `computeChunkDiff`, `dropIncompleteLastEdit`) with abort-aware error fallbacks.
- Added strategy-specific streaming preview support for replace, patch, hashline, apply_patch, and vim modes.
- Fixed streaming previews by dropping incomplete trailing edits and handling invalid chunk or aborted inputs.
- Expanded streaming and chunk-diff tests for partial JSON, open edits, empty paths, abort signals, and file loading checks.
2026-04-24 08:24:30 +02:00
Vu Anh Nguyenandcan1357 81fd90ecc0 Fix Mermaid markdown rendering on non-image terminals 2026-04-24 06:47:56 +02:00
can1357 601c029c20 fix: stabilize apply_patch custom tool integration 2026-04-24 00:25:21 +02:00
Hans Josephsenandcan1357 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 d24d11a274 fix: resolved AI/OAuth helper duplication via shared modules
- 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.
2026-04-23 21:02:14 +02:00
can1357 7453c10801 feat(coding-agent): added optional inline read preview toggle
- Added a new read.toolResultPreview boolean setting defaulting to false to control inline read result rendering.
- Updated read tool group rendering to show inline previews only when enabled and to hide duplicate summary rows for previewed entries.
- Passed the setting through event and UI helper constructors and added tests for default-off behavior and the duplicate-preview summary case.
2026-04-18 23:37:47 +02:00
can1357 23c66791bc fix: stabilize merged review follow-ups 2026-04-18 23:24:00 +02:00
can1357 c3524ea98e merge: PR #719 2026-04-18 23:22:54 +02:00
can1357 3581569ef1 merge: PR #714 2026-04-18 23:22:52 +02:00
Daman Singh 0a56142861 fix(session-observer): PgUp/PgDn line-scroll fallback and sanitize error messages
- PgUp/PgDn: when selection can't advance (at boundary or single
  oversized entry), fall back to line-based scrolling so the middle
  and bottom of tall entries are reachable
- Error messages: split on newlines and apply replaceTabs + truncateToWidth
  per line to prevent raw tabs/newlines from corrupting TUI layout
2026-04-18 16:15:03 -05:00
Daman Singh e4a43be98f fix(session-observer): handle oversized entry scroll and sanitize collapsed response lines
- #scrollToSelectedEntry: when entry is taller than viewport, scroll to
  show entry top instead of snapping to bottom, preventing long expanded
  entries from being unreadable
- #renderTextLines collapsed path: apply replaceTabs + truncateToWidth
  to each line, matching sanitization used by all other collapsed paths
2026-04-18 16:05:38 -05:00
Daman Singh 1d9d42d9c6 feat(session-observer): skip picker, jump directly to most recent sub-agent
Ctrl+S now opens the viewer immediately on the most recently active
sub-agent session — no intermediate picker list. If no sub-agents
exist, the overlay closes immediately.

- Removed picker mode entirely (setupPicker, refreshPickerItems,
  buildPickerItems, Mode type, selectList field)
- Constructor finds most recent sub-agent (preferring active ones,
  sorted by lastUpdate) and enters viewer directly
- Ctrl+S and Esc both close the overlay (no picker to go back to)
- Use [/] or Tab/Shift+Tab to cycle between agents inline
2026-04-18 15:41:30 -05:00
djdembeckandcan1357 f353873b75 refactor: extract local:// URL normalization to shared utility
Extract duplicate normalizeLocalScheme regex pattern into a shared function in path-utils.ts. Updated interactive-mode.ts, approved-plan.ts, agent-session.ts, bash-skill-urls.ts, and plan-mode-guard.ts to use the shared utility. Also fixed error message formatting (removed extra backslashes).
2026-04-18 22:40:07 +02:00
djdembeckandcan1357 5da806671e fix: prevent local:// URI from creating local: directory on Linux
On Linux, Node's path.normalize() collapses the double slash in
local://PLAN.md to local:/PLAN.md, creating a directory called local:
in the project root instead of routing through the local:// protocol handler.

Defense-in-depth fixes across 5 layers:

1. resolveToCwd() now throws if a path starts with any internal URL
   scheme prefix (local:, agent:, skill:, etc.), preventing all 59
   call sites from treating URIs as relative filesystem paths.

2. resolvePlanPath() now matches on local: prefix (not just local://)
   and normalizes local:/ to local:// before resolution, catching
   all slash variants.

3. Bash URL expansion regex and early-exit checks now also match
   local:/ (single slash), and normalize before resolution.

4. Edit preview/diff functions now gracefully skip internal URL paths
   instead of crashing via the resolveToCwd guard.

5. All startsWith('local://') checks updated to startsWith('local:')
   with normalization in agent-session, interactive-mode, and
   approved-plan modules.

Also adds local: to .gitignore to prevent accidental commits of the
leaked directory.
2026-04-18 22:40:07 +02:00
Yannick Wahnerandcan1357 97e84412a6 fix(status-line): strip complete ANSI escape sequences
Fixes #713

Signed-off-by: Yannick Wahner <yannick@forgeplane.io>
2026-04-18 22:35:59 +02:00
Data-Wanandcan1357 2075eb4fb5 fix: show read tool content preview by default
Previously ReadToolGroupComponent completely ignored the expanded
state and discarded result content, making read tool output invisible
in the TUI (only showed a one-line path summary with no file content).

Changes:
- Store expanded state in #expanded field (was discarded with _ prefix)
- Store result content text in ReadEntry.contentText (was thrown away)
- Show a small code preview (3 lines) by default in collapsed mode
- Show full file content when expanded via Ctrl+O
- Uses renderCodeCell with PREVIEW_LIMITS.OUTPUT_COLLAPSED for
  consistent truncation with "... N more lines (Ctrl+O for more)" hint

This brings read tool output in line with bash and grep tools which
already show previews when collapsed.
2026-04-18 22:30:23 +02:00
Daman Singh 6d4fe2a711 feat(session-observer): show model name in viewer header and picker list
Extract model from JSONL transcript (model_change entry or first assistant
message's model field) and display it in the viewer header:

  ScanCodingAgent [active] explore (2/5) · anthropic/claude-sonnet-4-6

Also show model in the picker list from AgentProgress.modelOverride,
so users can see which model each sub-agent is using before entering.
2026-04-18 15:29:10 -05:00
Daman Singh 1c154fc588 feat(session-observer): cycle through sub-agent sessions with [/] or Tab
While in viewer mode, press ] or Tab to jump to next sub-agent session,
[ or Shift+Tab for previous. Wraps around at boundaries.

- Header shows position indicator (2/5) when multiple sub-agents exist
- Footer hints updated to show [/]:prev/next agent
- Cycling resets scroll/selection and auto-skips to first non-user entry
- Clears transcript cache on switch for clean reload
2026-04-18 15:25:42 -05:00
Daman Singh 9fa037d394 fix(session-observer): show error assistant messages with empty content
When a model returns an error (connection error, rate limit, etc.),
the assistant message has content=[] and an errorMessage string.
Previously these were invisible because the content loop ran zero times.
Now renders them as '✗ Error: <message>' in the error color.
2026-04-18 15:13:13 -05:00
Daman Singh bf0378e5ae feat(session-observer): render markdown with theme colors
Use the TUI Markdown component and the active theme's markdown palette
for rendering content in the session observer viewer:

- Assistant text responses: markdown-rendered when expanded
- Thinking blocks: markdown-rendered when expanded (italic dim when collapsed)
- User/developer messages: markdown-rendered when expanded
- Tool results: unchanged (structured output, not markdown)

Uses getMarkdownTheme() which provides themed styling for headings,
code blocks, inline code, links, lists, bold, italic, blockquotes,
and syntax-highlighted fenced code blocks.
2026-04-18 15:07:04 -05:00
Daman Singh 96c6a1249d fix(session-observer): skip prompt on initial view, truncate user previews
Two issues from testing:
- On viewer open, selectedEntryIndex=0 points at the user prompt message
  which fills the entire viewport, hiding all actual work (thinking, tool
  calls). Now auto-selects first non-user entry and scrolls to it.
- Collapsed user/developer messages showed the full first line which can
  be very long. Now truncates to 60 chars with line count hint.
2026-04-18 15:03:17 -05:00
Daman Singh c272c177a2 fix(session-observer): use full-screen overlay, fix expand/collapse, remove truncation
Three issues from first test:
1. Viewer was cramped at bottom of screen because it replaced the
   editor container inline. Now uses TUI's showOverlay system with
   anchor=bottom-center, width=100%, maxHeight=100% for full terminal.
2. Text was truncated at hardcoded 90 chars. Removed MAX_TOOL_RESULT_LINE_WIDTH
   — let the TUI framework handle wrapping at actual terminal width.
3. Enter key didn't trigger expand/collapse. Added matchesKey(keyData, 'enter')
   alongside raw '\r'/'\n' checks.

Also: overrides Container.render() in viewer mode to produce viewport-
sliced output directly, with proper height computation from terminal rows.
2026-04-18 14:55:37 -05:00
Daman Singh 36729f1aa4 feat(session-observer): enhance viewer with scrolling, expand/collapse, rich rendering, and breadcrumb navigation
Beads 1-6: Full rewrite of session observer overlay to match OpenCode's
dive-in UX for sub-agent sessions.

- Raise truncation limits: thinking 200/2000 collapsed/expanded,
  tool args 500 chars, tool results 3/20 lines collapsed/expanded
- Rich per-tool-type result rendering: bash/python stdout preview,
  read/grep/find result lines, edit/write file summaries, task results
- Scrollable viewer: j/k/arrows for entry navigation, PgUp/PgDn for
  page jumps, g/G for top/bottom, scroll position indicator
- Per-entry expand/collapse: Enter toggles, selected entry highlighted,
  collapsed shows truncated preview, expanded shows full content
- Full-viewport viewer: uses terminal height minus header/footer chrome,
  breadcrumb header (Session Observer > AgentName), footer with key hints
- Breadcrumb navigation for nested sub-agents: detect .jsonl files in
  task tool results, Enter dives into nested session, Esc pops stack
2026-04-18 14:28:41 -05: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
某亚瑟 805cea12aa fix(search): map week recency to month for SearXNG, add to settings UI
- SearXNG time_range only supports day/month/year; map week→month
- Add SearXNG option to settings-defs.ts submenu so users can
  select it from the Settings UI (Providers tab)
2026-04-15 16:44:34 +08: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 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 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 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 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 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 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 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