Commit Graph
3225 Commits
Author SHA1 Message Date
can1357 0a3c192d7d fix(pi-natives): bound shell reader shutdown wait
Fixes #230
2026-03-01 11:40:25 +01:00
can1357 a97d03b7fb test(tui): harden overflow append regression coverage 2026-03-01 11:37:20 +01:00
can1357 05ffa7ede1 fix(coding-agent): normalize Exa MCP tool payload parsing
Fixes #229
2026-03-01 11:36:34 +01:00
can1357 6c55076fe4 docs(coding-agent/prompts): removed incorrect indentation example from hashline documentation
- Deleted the 'Bad' example that incorrectly demonstrated guessing indentation as spaces instead of using actual tabs.
- Kept the 'Good' example that correctly shows using real tab characters in JSON to match file indentation.
2026-03-01 11:32:30 +01:00
can1357 7db7eb5a76 fix(tui): corrected append rendering during viewport overflow with offscreen header changes
- Fixed append rendering logic to correctly handle offscreen header changes during content overflow growth, preserving scroll history integrity.
- Fixed visible tail line updates when appending new content during viewport overflow conditions.
- Refactored append detection logic to distinguish pure appends from appends with offscreen changes, improving rendering accuracy.
- Added regression tests for offscreen header changes and tail line updates during content overflow.
2026-03-01 11:30:15 +01:00
can1357 49f37ef257 fix(ai): corrected tool argument coercion for malformed JSON with trailing braces
- Fixed tool argument coercion to handle malformed JSON with trailing wrapper braces by parsing leading JSON containers.
- Relaxed JSON detection heuristics to check only leading braces instead of requiring matching closing braces.
- Added test case for array strings with trailing wrapper braces from nested JSON malformation.
2026-03-01 11:29:58 +01:00
can1357 81f718d5ef feat(coding-agent): enabled AST tools auto-inclusion and AbortSignal cancellation
- Added auto-inclusion of ast_grep and ast_edit tools when their text-based counterparts are enabled.
- Made AST tool recommendations conditional in bash tool prompt based on session availability.
- Replaced timeout-based cancellation with AbortSignal-based cancellation in ask tool.
- Added auto-correction of escaped tab indentation in edits via PI_HASHLINE_AUTOCORRECT_ESCAPED_TABS environment variable.
- Added warning detection for suspicious Unicode escape placeholder in edit content.
2026-03-01 11:27:07 +01:00
can1357 5347d89e76 fix(coding-agent): corrected variable initialization order in formatPromptContent
- Corrected variable initialization order in formatPromptContent to prevent stale trimmedStart value when ASCII symbol replacement occurs.
- Updated bash.md documentation to use ellipsis (...) instead of three dots (...) for consistency with ASCII symbol replacement behavior.
- Added test case verifying table row compaction and content deduplication during pre-render with ASCII symbol replacement.
2026-03-01 11:21:17 +01:00
can1357 1643cd4673 feat(ask): migrated ask tool to AbortSignal-based cancellation for unified abort handling
- Replaced timeout-based cancellation with AbortSignal-based cancellation in ask tool for unified abort handling.
- Added signal parameter to UIContext select() and input() methods to support external cancellation propagation.
- Fixed race condition in dialog overlay handling by replacing direct resolve() calls with settled flag wrapper.
- Added comprehensive test coverage for ask tool cancellation behavior across user-initiated and timeout scenarios.
2026-03-01 11:19:32 +01:00
can1357 3321cb8061 feat(coding-agent): enforced tool decision requirement in plan mode
- Enforced tool decision in plan mode--agent now requires calling either `ask` or `exit_plan_mode` when a turn ends without a required tool call.
- Fixed cancellation behavior of `ask` tool to abort the current turn instead of returning a normal cancelled selection, while timeout-driven auto-cancel still returns without aborting.
- Added plan-mode-tool-decision-reminder system prompt to guide agent when required tools are not called.
- Improved agent_end event handling to use fallback assistant message when #lastAssistantMessage is unavailable.
2026-03-01 11:16:54 +01:00
can1357 8663794c56 feat(coding-agent): added escaped tab auto-correction and Unicode escape detection
- Added auto-correction for escaped tab indentation in edits via PI_HASHLINE_AUTOCORRECT_ESCAPED_TABS environment variable.
- Added warning detection for suspicious Unicode escape placeholder \uDDDD in edit content.
- Clarified hashline documentation that \t in JSON represents real tab characters, not literal backslash-t strings.
- Added comprehensive test coverage for escaped tab auto-correction and Unicode escape detection.
2026-03-01 10:59:15 +01:00
can1357 625be8618a fix(natives): corrected strikethrough reset logic to preserve colors on line wraps
- Fixed strikethrough reset logic to properly handle combined underline and strike attributes without resetting colors.
- Refactored write_line_end_reset to emit correct ANSI codes (24m for underline, 29m for strike) when both attributes are present.
- Added test case verifying strikethrough resets at line wraps while preserving foreground and background colors.
- Added TypeScript test case for strikethrough styling behavior across wrapped lines.
2026-03-01 10:50:52 +01:00
can1357 75d9b2bbc8 fix(tui): corrected cursor positioning instability during scrollback append
- Fixed cursor positioning instability when appending content under external cursor relocation by using absolute screen addressing instead of relative cursor movement.
- Extracted cursor movement logic into #moveToScreenPosition() helper to ensure consistent absolute positioning across all rendering paths.
- Added regression test verifying scrollback stability during rapid content append with external cursor relocation.
2026-03-01 10:50:26 +01:00
can1357 93f1682ab4 docs(coding-agent/prompts): clarified plan mode constraints with template variables
- Clarified plan mode constraints and tool invocation patterns with template variables for dynamic tool names.
- Improved readability of critical directives by converting bullet points to parallel grammatical structure.
- Replaced hardcoded tool names (ask, exit_plan_mode) with template variables ({{askToolName}}, {{exitToolName}}) for flexibility.
2026-03-01 10:40:29 +01:00
can1357 0f61b88d34 chore: bump version to 13.5.2 2026-03-01 10:00:20 +01:00
can1357 c8324d1284 chore: disable exp. checkpoint tool by default 2026-03-01 09:59:58 +01:00
can1357 28289f607b test(tui): added regression tests for viewport stability during resize storms
- Added five new test cases covering viewport consistency across repeated width reflows, aggressive resize storms, height-only resizes with cursor drift, streaming content under resize, and forced renders with cursor relocation.
- Added test for scrollback boundedness during mixed width/height resize storms on static content.
- Added test for scrollback integrity when appending lines during aggressive resize operations.
2026-03-01 09:55:02 +01:00
can1357 70de19815e feat(coding-agent): introduced checkpoint/rewind tools for context cost optimization
- Added checkpoint and rewind tools to create context checkpoints before exploratory work and rewind to replace exploration messages with concise reports.
- Added checkpoint.enabled setting to control availability of checkpoint and rewind tools in agent sessions.
- Added getCheckpointState() and setCheckpointState() methods to agent session API for checkpoint state management.
- Implemented checkpoint state tracking with message count, entry ID, and timestamp to enable context cost optimization during investigations.
2026-03-01 09:42:02 +01:00
can1357 1c30f5c972 feat: introduced render_mermaid tool for ASCII diagram output
- Added render_mermaid tool to convert Mermaid diagrams to ASCII output with configurable rendering options.
- Added renderMermaid.enabled setting to control availability of the render_mermaid tool.
- Changed Mermaid rendering from PNG terminal graphics to ASCII text format across theme and TUI components.
- Migrated mermaid utilities from pi-tui to pi-utils package with new ASCII rendering functions.
- Removed PNG-based mermaid rendering APIs (getMermaidImage, renderMermaidToPng) in favor of ASCII alternatives.
2026-03-01 09:40:57 +01:00
can1357 0fbd76d3fa feat(coding-agent/modes): added debug transcript export command to dump visible TUI conversation
- Added transcript export option to debug menu that writes visible TUI conversation to a temporary text file.
- Implemented handleDebugTranscriptCommand in CommandController to render chat messages, strip ANSI codes, and write to temp directory.
- Updated InteractiveModeContext interface and InteractiveMode to expose the new debug transcript command handler.
2026-03-01 08:53:49 +01:00
can1357 e7c9ff4d4f chore: bump version to 13.5.1 2026-03-01 08:32:59 +01:00
can1357 33e06a4302 fix(tui): corrected viewport shift handling to prevent stale content during mixed updates
- Fixed viewport shift handling to prevent stale content when mixed updates remap screen rows.
- Added fallback to full viewport repaint when viewport shifts occur outside pure append-scroll scenarios.
- Clarified viewport patching safety constraints in comments to document incremental update limitations.
2026-03-01 08:32:39 +01:00
can1357 86769d96c8 chore: bump version to 13.5.0 2026-03-01 08:22:45 +01:00
can1357 71ee90f988 fix(tui): harden viewport rendering and cursor state
Refactor TUI rendering into explicit hard-reset and viewport-repaint paths with safer differential fallbacks for offscreen/overflow cases.

Replace legacy viewport bookkeeping with screen-relative cursor/viewport tracking, force startup render initialization, and clamp stop() cursor movement to prevent overscroll artifacts.

Synchronize cursor dedup cache across all render write paths to avoid stale #lastCursorSequence behavior after full redraws.

Remove PI_TUI_RESIZE_CLEAR_STRATEGY and lock resize behavior to deterministic semantics (width hard reset, height viewport repaint).

Expand terminal regression coverage with new render-regressions tests and substantial overlay/scroll stress scenarios to guard scrollback growth, anchoring drift, and no-op churn.
2026-03-01 08:22:00 +01:00
can1357 971f34f56b docs(coding-agent): documented hashline tool JSON safety requirements and helper
- Added `hlinejsonref` Handlebars helper for embedding hashline references inside JSON blocks in prompts.
- Enhanced hashline tool documentation with explicit prohibition on formatting-only edits.
- Added mandatory rule requiring indentation in `lines` to match surrounding context exactly from `read` output.
- Updated all hashline examples to use `hlinejsonref` instead of `hlineref` for JSON-safe references.
2026-03-01 08:09:24 +01:00
can1357 62004d9954 feat(coding-agent): introduced librarian and oracle agents with expanded tool support
- Added librarian and oracle agents for library research and technical diagnostics.
- Expanded tool support across explore, plan, and reviewer agents with lsp, fetch, web_search, and ast_grep.
- Added dependencies and risks output fields to explore agent for enhanced analysis.
- Renamed explore agent output field from query to summary with expanded description.
2026-03-01 06:06:15 +01:00
can1357 8c89b5c38d refactor(agent): extracted tool result emission into dedicated function
- Extracted tool result emission logic into dedicated emitToolResult function to eliminate duplication.
- Consolidated tool execution result handling to emit results immediately after execution rather than deferring to post-processing loop.
- Simplified post-execution loop by delegating result emission to emitToolResult and removing redundant message construction.
2026-03-01 06:04:29 +01:00
can1357 34e061032b chore: bump version to 13.4.1 2026-03-01 04:03:39 +01:00
can1357 40e921284b fix(coding-agent): send resolve reminder on push 2026-03-01 04:03:20 +01:00
can1357 e3caff6c06 docs(coding-agent): clarified tool documentation for ast-edit and hashline
- Simplified ast-edit tool documentation by removing preview/resolve workflow references and clarifying output behavior.
- Added critical guidance to hashline tool documentation on proper line deletion to prevent duplication.
2026-03-01 03:59:23 +01:00
maximharandGitHub 3e51168616 Use Copilot live limits for context/max token mapping (#226) 2026-03-01 03:48:17 +01:00
can1357 646d461b38 chore: bump version to 13.4.0 2026-03-01 03:38:44 +01:00
can1357 6da102a11b feat(coding-agent): pass reason to apply/reject callbacks in PendingAction
PendingAction.apply() and reject() now receive the reason string that was
passed to resolve(). This lets custom tools surface the agent's rationale
in their apply/discard output or use it for logging.

- PendingAction interface: apply(reason) and reject?(reason)
- CustomToolPendingAction: same signatures, reject is optional
- CustomToolLoader: threads reject through when building PendingAction
- AstEditTool: accepts _reason (unused, reserved for future tracing)
- resolve.test: covers reason forwarding on apply and reject paths,
  and verifies reject return value replaces the default discard message
- docs/resolve-tool-runtime.md: updated interface table, built-in
  producer description, usage example, and developer guidance
2026-03-01 03:36:43 +01:00
can1357 c3d0bd9773 feat(coding-agent): deferrable tools, LIFO pending-action stack, custom tool pushPendingAction
- Introduce `deferrable?: boolean` on AgentTool, CustomTool, and ToolDefinition.
  AstEditTool sets it to true; resolve is now injected only when at least one
  active tool is deferrable (previously unconditional).

- Replace single-slot PendingActionStore (set/get/clear) with a LIFO stack
  (push/peek/pop/clear). Multiple deferrable tools can stage independent
  preview actions; resolve always consumes the topmost one first.

- Wire pendingActionStore through discoverAndLoadCustomTools / loadCustomTools /
  CustomToolLoader so custom tools can call pushPendingAction(action) to
  register a resolve-compatible pending action with label, apply callback,
  optional details, and optional sourceToolName.

- Export HIDDEN_TOOLS and ResolveTool from the SDK for manual tool composition.

- Add CustomToolPendingAction type and pushPendingAction to CustomToolAPI.

- Update createAgentSession to re-inject or remove resolve after the deferrable
  audit, consistent with createTools behavior.

- Add LIFO resolve test, update existing tests (set -> push, get -> peek).

- Add docs/resolve-tool-runtime.md covering PendingActionStore internals,
  built-in producer example, and custom tool usage guide.
2026-03-01 02:57:31 +01:00
can1357 fe93866a6a fix(tui): stop duplicate resize rerenders without losing history 2026-03-01 02:45:41 +01:00
can1357 cd6ed4ce8c refactor(tools): restructured tool rendering to inline highlighted format
- Simplified resolve tool output rendering from boxed layout to inline highlighted format for cleaner display.
- Updated resolve tool to parse source tool name from label using colon separator instead of separate metadata field.
- Replaced CachedOutputBlock with direct line rendering using padToWidth and inverse styling.
- Removed actionBadge helper function and consolidated action/state logic into single rendering path.
- Updated 1 test to verify inline rendering behavior and label parsing.
2026-03-01 02:44:52 +01:00
can1357 29d8768c70 feat(tui): added viewport-only resize strategy to reduce scrollback pollution
- Added `PI_TUI_RESIZE_CLEAR_STRATEGY` environment variable to control terminal resize behavior: `viewport` (default) renders only visible content to minimize scrollback pollution, or `scrollback` clears all history.
- Changed resize redraw logic to support viewport-only rendering strategy, reducing scrollback accumulation during terminal resizing.
- Added 2 integration tests to verify viewport and scrollback resize strategies work correctly.
2026-03-01 02:35:58 +01:00
can1357 0a49a4a9a7 fix(tui): corrected loader text overflow and terminal clear behavior
- Fixed loader component text overflow by truncating lines exceeding terminal width using column-aware slicing.
- Improved terminal clear logic on resize to use hard clear (\x1b[2J) preventing stale wrapped cells.
- Added test coverage for loader component line clamping to verify rendered lines fit within terminal width.
- Refactored terminal clear conditional logic from ternary to multi-line if-else for improved maintainability.
2026-03-01 02:35:43 +01:00
can1357 67e1aa40bf feat(coding-agent): introduced resolve tool for AST edit preview confirmation with reasoning
- Added `resolve` tool to apply or discard pending AST edit previews with required reasoning.
- Changed `ast_edit` tool to always return previews by default; removed `preview` parameter.
- Added `getToolChoice` callback option to dynamically override tool choice per LLM call.
- Implemented PendingActionStore for managing deferred tool action state across agent sessions.
- Updated agent loop to support dynamic tool choice resolution via optional callback.
2026-03-01 02:35:43 +01:00
can1357 a065662cd9 refactor(ast-tools): simplify params, cap parse errors
- ast_grep: drop include_meta (always true now); update prompt examples
- ast_edit: dry_run -> preview; max_replacements -> limit; max_files
  removed from schema, always read from $PI_MAX_AST_FILES (default 1000)
- cap parse errors at PARSE_ERRORS_LIMIT (20) in both text output and
  TUI; show 'N / total' summary when over limit
- export PARSE_ERRORS_LIMIT from render-utils, no hardcoded magic numbers
2026-03-01 02:02:57 +01:00
can1357 69cadd7f60 chore: renamed AST tools 2026-03-01 01:45:22 +01:00
can1357 85c5fad2bc refactor: replace named re-exports with star re-exports in barrel files
Convert export { A, B, ... } from and export type { ... } from blocks
to export * from across all packages (ai, coding-agent, natives, tui, utils).
2026-02-28 22:34:02 +01:00
can1357 3f4659c181 docs(coding-agent): clarified hashline prompt to prevent tab indentation errors
- Added clarification to hashline prompt about literal space indentation in JSON entries to prevent tab character mistakes.
2026-02-28 22:12:10 +01:00
can1357 e42b7bf3ce feat: removed normative rewrite experiment from public API and patch processing
- Removed normativeRewrite setting and buildNormativeUpdateInput() function from public API.
- Removed $normative property and TNormative generic parameter from ToolResultMessage and AgentToolResult interfaces.
- Deleted normative.ts patch normalization module and related helper functions for diff anchor processing.
- Removed rewriteAssistantToolCallArgs() and #rewriteToolCallArgs() methods that modified tool call arguments.
2026-02-28 22:11:46 +01:00
can1357 dc2fde6e0f fix(coding-agent): use vi.spyOn for fetch mocking in exa tests
Replace direct globalThis.fetch assignment with vi.spyOn + vi.restoreAllMocks
to prevent mock leaking to other test files.
2026-02-28 21:59:40 +01:00
can1357 a5470157da fix(coding-agent): fallback to Exa MCP without API key
Fixes #224
2026-02-28 21:49:58 +01:00
can1357 6a81ed9fa7 fix: resolve type errors in web-search-anthropic test 2026-02-28 21:34:28 +01:00
can1357 02dd71d847 fix(ast): allow empty replacements and stop trimming patterns/rewrites
Remove the non-empty validation on `out` in both the TypeScript tool
layer and the Rust native layer. An empty replacement template now
deletes the matched AST node, which is the natural semantics.

Also remove .trim() calls on pattern and rewrite strings — trimming
silently destroys intentional whitespace and serves no purpose since
ast-grep matches on AST structure, not raw text.
2026-02-28 21:17:58 +01:00
can1357 924a70d9b4 refactor(ai): migrated Unicode handling to native toWellFormed() API
- Replaced custom `sanitizeSurrogates()` utility with native `String.prototype.toWellFormed()` across all provider implementations.
- Removed `sanitize-unicode.ts` utility module and all imports of `sanitizeSurrogates` function from 10 provider files.
- Updated Unicode surrogate handling in message conversion, response processing, and system prompt handling to use built-in JavaScript API.
- Documented removal of `sanitizeSurrogates()` utility and migration to native `toWellFormed()` in CHANGELOG.
2026-02-28 21:17:58 +01:00
can1357 7d0807ec36 feat(ai,coding-agent): Google fingerprint hardening
providers/google-gemini-cli:
- parseGeminiCliCredentials() handles legacy, alias (project_id/refresh/expires),
  and enriched credential JSON formats
- shouldRefreshGeminiCliCredentials() + refreshGeminiCliCredentialsIfNeeded()
  proactively refresh OAuth tokens 60s before expiry for both providers
- normalizeAntigravityTools() converts parametersJsonSchema -> parameters
  in function declarations for Antigravity compatibility
- VALIDATED tool calling config applied for Antigravity + Claude model combos
- maxOutputTokens removed from generation config for Antigravity non-Claude models
- Antigravity system instruction injection scoped to Claude + gemini-3-pro-high models
- Antigravity session ID: signed decimal int63 derived from SHA-256 of first user
  message (or random bounded int63), replacing truncated hex hash
- Antigravity requestId uses agent-{uuid}; non-Antigravity requests omit
  requestId/userAgent/requestType from payload
- ANTIGRAVITY_DAILY_ENDPOINT corrected to daily-cloudcode-pa.googleapis.com;
  sandbox kept as fallback
- ANTIGRAVITY_SYSTEM_INSTRUCTION exported

oauth/google-antigravity:
- PKCE removed from OAuth flow (no code_challenge)
- loadCodeAssist metadata ideType changed to ANTIGRAVITY
- discoverProject uses single production endpoint; falls back to onboardUser LRO
  (up to 5 retries, 2s interval) instead of hardcoded default project ID
- ANTIGRAVITY_LOAD_CODE_ASSIST_METADATA exported

oauth/google-gemini-cli:
- PKCE removed from OAuth flow

oauth/index:
- getOAuthApiKey includes refreshToken, expiresAt, email, accountId in
  Gemini/Antigravity JSON payload for proactive refresh support

discovery/antigravity:
- Tries production daily endpoint first, sandbox as fallback
- Removed recommended/agentModelSorts filter; applies denylist instead
- ANTIGRAVITY_DISCOVERY_DENYLIST filters low-quality/internal models
- Request body no longer includes project field

coding-agent:
- gemini_image: corrected responseModalities to uppercase IMAGE/TEXT
- Gemini web search: endpoint fallback (daily->sandbox) with retry on 429/5xx,
  aligned Antigravity request metadata, ANTIGRAVITY_SYSTEM_INSTRUCTION injection
- buildGeminiRequestTools() helper for composable googleSearch/codeExecution/urlContext
- Web search schema: expose max_tokens, temperature, num_search_results params
- Web search: explicit provider falls back to auto chain when unavailable

Tests: google-antigravity-auth, google-gemini-cli-alignment, web-search-gemini
2026-02-28 21:17:57 +01:00