Commit Graph

1512 Commits

Author SHA1 Message Date
can1357 fc8d527d0a fix(coding-agent): improved progress rendering logic
- Prevented rendering an empty progress section.
- Ensured progress displays for initial states without results.
2026-02-22 15:23:07 +01:00
Miroslav Drbal 8231ec3a7d fix(edit): do not strip leading '-' from replacement content
DIFF_PLUS_RE matched both '+' and '-' (unified-diff markers), but '-'
is also a valid Markdown/YAML list prefix. When all replacement lines
start with '- ', the 50%-threshold heuristic in stripNewLinePrefixes
fires and strips every leading '-', corrupting list-item content.

Narrow the regex to match only '+' (added-line markers), which is the
stated intent of the docstring and the safe strip target. Removed
lines ('-') are never valid replacement content in any case.

Reproducer: passing content=["- [x] item"] as a bare string to a
set/replace op — the '-' is silently dropped, writing ' [x] item'.
Passing content as string[] bypasses stripNewLinePrefixes entirely and
was the workaround, but the root cause should be fixed.
2026-02-22 15:22:34 +01:00
can1357 14634ab4e5 fix(task): corrected task progress display and async execution tracking
- Fixed task progress display to hide tool count and token metrics when zero, reducing visual clutter in status output.
- Refactored async task execution to use job progress reporting API instead of direct update callbacks, improving progress tracking accuracy.
- Implemented pre-allocation of unique IDs for batch tasks to prevent artifact collisions across concurrent executions.
- Extracted async details builder into reusable function to consolidate state construction logic.
2026-02-22 13:06:28 +01:00
can1357 4b7232c49c feat(task): enabled independent parallel execution with per-task progress tracking
- Improved parallel task execution to schedule multiple background jobs independently instead of batching all tasks into a single job, enabling true concurrent execution.
- Enhanced task progress tracking to report per-task status (pending, running, completed, failed, aborted) with individual timing and token metrics for each background task.
- Updated background task messaging to provide real-time progress counts (e.g., '2/5 finished') and distinguish between single and multiple task jobs.
- Refactored task scheduling loop to track per-task progress state and emit granular async updates during execution.
2026-02-22 13:02:57 +01:00
can1357 8b17a91a74 feat(coding-agent): introduced stripInternalArgs utility to filter harness-internal keys
- Added stripInternalArgs() utility function to filter harness-internal keys from tool arguments.
- Hidden agent__intent parameter from UI and log displays across agent, session, MCP, and tool-execution components.
- Implemented HIDDEN_ARG_KEYS constant to centrally manage internal argument filtering.
- Updated formatArgsInline() to exclude internal keys when rendering tool arguments.
2026-02-22 12:56:21 +01:00
can1357 23f472e44d fix status-line gap fill when right segments are present 2026-02-22 12:48:02 +01:00
can1357 84edd931ff fix async job disposal pending state and cancelAll test ordering 2026-02-22 12:47:51 +01:00
can1357 b0dd430754 feat(tools): added markdown rendering support for Python cell output
- Added support for rendering markdown output from Python cells with proper formatting and theme styling.
- Updated Python tool to detect and handle markdown display output separately from plain text.
- Extended KernelDisplayOutput type to include markdown output type.
- Modified formatCellOutputLines to render markdown content using Markdown component when detected.
2026-02-22 12:46:27 +01:00
can1357 476b858b3a feat(coding-agent): added async background job execution with configurable concurrency limits
- Added async background job execution for bash and task tools with configurable concurrency limits and automatic result delivery.
- Added cancel_job tool and /jobs slash command to manage and inspect running background jobs with status display.
- Added jobs:// internal protocol handler for querying job status and retrieving job execution details.
- Added async.enabled and async.maxJobs settings to control background job execution behavior.
- Enhanced status line to display count of running background jobs with visual indicator.
- Implemented AsyncJobManager with exponential backoff retry delivery, job lifecycle tracking, and automatic eviction.

Fixes #56.
2026-02-22 12:44:57 +01:00
can1357 7ab8abbcf2 feat(scrapers): added retry mechanisms and data fallbacks
- Added retry logic to PubMed and OpenLibrary fetches.
- Implemented XML parsing fallback for Chocolatey package details.
- Restructured Hackage scraper to use .json and .cabal for metadata.
- Generated informative markdown for OpenCorporates API failures.
- Updated User-Agent headers for Repology.
2026-02-22 11:53:05 +01:00
can1357 c5ddb79bf8 docs(coding-agent): clarified code quality and refactoring guidance in system prompt
- Refined system prompt guidance for code quality and refactoring practices.
- Consolidated and clarified instructions on code cleanup, verification, and dependency selection.
2026-02-22 11:36:39 +01:00
can1357 469f1546f9 refactor(coding-agent): migrated artifact management to SessionManager for centralized control
- Moved artifact management from ToolSession to SessionManager for centralized lifecycle control and caching.
- Replaced getArtifactManager() with allocateOutputArtifact() async method in ToolSession interface for simplified artifact allocation.
- Updated bash, fetch, python, and ssh tools to call session.allocateOutputArtifact() directly with optional chaining fallback.
- Fixed Lobsters scraper to handle user fields as strings instead of nested objects in API responses.
2026-02-22 11:28:58 +01:00
can1357 3bbced9b83 feat: added canonical model ID support to GitLab Duo with fallback
- Enhanced GitLab Duo model mapping to support canonical model IDs with fallback lookup.
- Simplified Anthropic auth resolution from 4-tier to 3-tier priority system.
- Fixed artifact manager cache invalidation by validating session file before reuse.
- Improved JSONL parsing in stats package with streaming parser and error handling.
2026-02-22 11:23:32 +01:00
can1357 0375aa0f83 fix: formatCount -> formatNumber 2026-02-22 11:07:57 +01:00
Joshua Christman be40b889e3 fix(coding-agent): use valid JSON schema for submit_result when no output schema specified
Replace Type.Any() with Type.Object({}, { additionalProperties: true }) in the
submit_result tool's fallback data schema. Type.Any() serializes to
{"description": "..."} which lacks the required 'type' field for valid
JSON Schema. Strict providers (e.g. MiniMax, Cloud Code Assist) reject this
with 400 Unrecognized schema errors.

The fix produces {"type": "object", "additionalProperties": true, ...}
which conforms to JSON Schema draft 2020-12 while preserving the same
permissive acceptance of arbitrary structured output.

Fixes schema rejection observed with:
- MiniMax API (via zuccaro/bryce proxy)
- Cloud Code Assist (Claude) - related to #45

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-22 11:02:31 +01:00
can1357 abf8c1efc9 refactor: unslop common utilities 2026-02-22 11:01:11 +01:00
can1357 a95d432f7b refactor(agent): consolidated and clarified system prompt
- Consolidated agent behavioral rules into unified sections.
- Clarified procedural steps and code modification guardrails.
- Emphasized debugging before rerouting and thorough verification.
- Removed redundant sections and relocated output style rules.
2026-02-22 10:41:36 +01:00
can1357 6e66a13a8f fix(config): enabled todo reminders by default in settings schema
- Changed default value of todo.reminders setting from false to true to enable reminders by default.
2026-02-22 10:40:08 +01:00
can1357 ca097c5f8b refactor(coding-agent): restructured system prompt pipeline to remove git context loading
- Removed git context loading from system prompt pipeline, eliminating GitContext interface and loadGitContext() function.
- Refactored prepPrompt from async IIFE to synchronous IIFE with Promise.all().then() chain for cleaner async handling.
- Enhanced system prompt with discipline guidelines covering code cleanup, work methodology, testing standards, and handoff requirements.
- Removed Version Control section from system prompt, shifting focus from git context to code quality and testing practices.
2026-02-22 02:18:33 +01:00
can1357 42a00ba425 refactor(session): restructured byte truncation to unified windowed function reducing duplication
- Refactored byte truncation to use unified `truncateBytesWindowed` function supporting both head and tail modes, reducing code duplication.
- Optimized `truncateHead` and `truncateTail` to avoid full Buffer allocation by processing content incrementally with character-level scanning.
- Improved `TailBuffer.append()` to handle large incoming chunks more efficiently by detecting when a single chunk dominates the tail budget.
- Enhanced `OutputSink.push()` to avoid creating giant intermediate strings when spilling to files by windowing large chunks before concatenation.
- Refactored newline counting to use a constant `NL` for consistency across the module.
2026-02-22 01:59:18 +01:00
can1357 b2bbc80ee8 refactor: consolidated shared auth and utilities
- Migrated AuthCredentialStore and AuthStorage to shared modules, standardizing credential management and soft deletion.
- Consolidated Anthropic authentication and various other formatting/utility helpers into shared modules.
- Improved unicode normalization in patch logic with regex for efficiency and correctness.
- Enhanced JTD type guards for robust schema validation.
2026-02-22 01:58:04 +01:00
can1357 5acdf950fd docs(coding-agent): emphasized Task tool use for subagents
- Highlighted critical instructions for parallelization using the Task tool.
- Reinforced the necessity to always use subagents for independent work streams.
- Simplified wording for conditions requiring task decomposition.
2026-02-22 01:44:19 +01:00
can1357 888a3b3307 refactor(coding-agent): migrated credential and utility logic to shared modules
- Extracted credential storage to shared @oh-my-pi/pi-ai package with AuthCredentialStore and AuthStorage classes.
- Consolidated UI formatting logic from ToolUIKit class into standalone utility functions across render-utils and output-meta modules.
- Moved utility functions (parseCommandArgs, substituteArgs, expandPath, normalizeUnicode) to dedicated modules for improved code reuse.
- Extracted JTD type definitions and type guards to jtd-utils module for shared use across schema conversion tools.
- Updated Claude model pricing and added cache read costs in models.json for accurate billing calculations.
- Refactored agent-storage to delegate credential management to AuthCredentialStore instead of direct SQLite operations.
2026-02-22 01:35:32 +01:00
can1357 6a7914b41f feat(ai): introduced GitLab Duo provider with OAuth and 16 models
- Added GitLab Duo provider with support for Claude, GPT-5, and Duo Chat models via GitLab AI Gateway.
- Added OAuth authentication for GitLab Duo with automatic token refresh, PKCE security, and 25-minute token caching.
- Added 16 new GitLab Duo models including Claude Opus/Sonnet/Haiku and GPT-5 variants with reasoning and multimodal support.
- Added `isOAuth` option to Anthropic provider for OAuth bearer token authentication mode.
- Exported `streamGitLabDuo`, `getGitLabDuoModels`, and `clearGitLabDuoDirectAccessCache` functions for GitLab Duo integration.
2026-02-22 01:02:26 +01:00
can1357 e4225d6829 refactor(coding-agent): consolidated output utilities into streaming-output module
- Consolidated truncation and output utilities from tools/truncate.ts and tools/output-utils.ts into session/streaming-output.ts with improved UTF-8 boundary handling.
- Renamed formatSize() to formatBytes() across codebase for consistency and clarity in byte-level formatting.
- Refactored OutputSink to use windowed byte truncation instead of full-buffer encoding, improving memory efficiency on large outputs.
- Migrated from Buffer to Uint8Array in web scrapers for better cross-platform compatibility and native browser support.
- Added getArtifactManager() lazy-initialization method to ToolSession for deferred artifact manager instantiation.
- Simplified API surface with wildcard exports from tools and session modules, reducing import complexity.
2026-02-22 01:02:26 +01:00
can1357 1932e175f5 feat(coding-agent): added Buffer.toBase64() polyfill for Bun compatibility
- Added Buffer.toBase64() polyfill for Bun compatibility to enable base64 encoding of buffers.
- Added test coverage for Buffer.toBase64() polyfill to verify base64 encoding functionality.
2026-02-21 22:59:04 +01:00
can1357 0b1514da61 feat(coding-agent): added overlay UI option and fixed viewport sync race conditions
- Added overlay option to custom UI hooks for bottom-centered component display.
- Added automatic chat transcript rebuild when returning from custom or debug UI modes.
- Fixed race condition in bash interactive component preventing output append after closure.
- Extracted environment variable configuration into reusable NO_PAGER_ENV constant for bash execution.
- Fixed viewport synchronization issue in TUI causing terminal desync during full re-renders.
2026-02-21 22:52:59 +01:00
can1357 93e28a8029 refactor: consolidated timing instrumentation to centralized logger methods
- Migrated timing instrumentation from custom utils/timings module to centralized logger.time() and logger.timeAsync() methods across coding-agent and natives packages.
- Removed PI_DEBUG_STARTUP environment variable and debugStartup() function, consolidating debug output to logger.debug() for conditional logging.
- Replaced custom TextDecoder buffer decoding with native toString('utf-8') method in natives package for simplified string conversion.
- Added RingBuffer<T> circular buffer implementation to pi-utils with comprehensive test coverage for efficient queue operations.
- Enhanced logger interface with time() and timeAsync() methods providing unified operation timing and performance tracking across packages.
2026-02-21 22:42:18 +01:00
can1357 30a5475593 refactor(ai): standardized Google API headers and user agents
- Consolidated Gemini CLI and Antigravity headers into central definitions.
- Split Antigravity headers into distinct authentication and streaming sets.
- Enabled User-Agent configuration via environment variables.
- Ensured consistent header usage across relevant services.
2026-02-21 21:56:48 +01:00
can1357 f0b2029867 refactor(coding-agent): use centralized getAntigravityHeaders() for full header blocks
Export getAntigravityHeaders() from pi-ai and replace duplicated
ANTIGRAVITY_HEADERS constants in gemini-image tool and Gemini search
provider with calls to the centralized function.

Fixes #132
2026-02-21 21:28:18 +01:00
can1357 f33e2eef54 fix(coding-agent): use centralized getAntigravityUserAgent() for User-Agent headers
Replace hardcoded "antigravity/1.11.5 darwin/arm64" User-Agent strings with
the centralized getAntigravityUserAgent() function from @oh-my-pi/pi-ai in
gemini-image tool and Gemini search provider.

Fixes #132
2026-02-21 21:25:34 +01:00
can1357 643eb12df6 fix(coding-agent): correct omp-stats subpath imports for tarball installs 2026-02-21 16:59:37 +01:00
can1357 fc2c3c2c7c fix(coding-agent): corrected shell session state reset and hard timeout handling for command execution
- Fixed persistent shell session state not being reset after command abort or hard timeout.
- Fixed hard timeout handling to properly interrupt long-running commands exceeding grace period.
- Introduced hard timeout mechanism with Promise.race() to enforce absolute timeout limit and prevent command hangs.
- Replaced shell command execution with explicit timeout and SIGKILL signal handling in shell-snapshot.
- Simplified bash command normalization to use only explicit head/tail parameters from tool input.
- Exported getAntigravityUserAgent() function for centralized User-Agent header construction.
2026-02-21 16:52:37 +01:00
can1357 82c0d9bb4b fix(bash): corrected concurrent subagent interference via sessionKey parameter
- Added sessionKey parameter to bash execution to prevent concurrent subagent interference.
2026-02-21 16:33:26 +01:00
can1357 d5b28d6d3b feat(mcp): added browser MCP server filtering to prevent conflicts with builtin tool
- Added filterBrowser configuration option to disable MCP browser servers when builtin browser tool is enabled.
- Added isBrowserMCPServer() function to detect browser automation MCP servers by name, URL, or command patterns.
- Added filterBrowserMCPServers() function to remove browser MCP servers from loaded configurations.
- Added BrowserFilterResult type for browser MCP server filtering results.
2026-02-21 16:30:14 +01:00
can1357 17e9a8bff1 fix(coding-agent): correct import path for untilAborted 2026-02-21 16:10:58 +01:00
can1357 94b4f4dcfd feat(coding-agent): parallelized system prompt preparation with timeout protection
- Added timeout protection (5 seconds) for system prompt preparation with graceful fallback to minimal context on timeout.
- Replaced glob-based AGENTS.md discovery with depth-limited directory traversal (depth 1-4) for improved performance and control.
- Refactored system prompt preparation to parallelize file loading operations with a 5-second timeout to prevent startup hangs.
- Parallelized context file, skills, git, and AGENTS.md discovery to reduce startup latency.

Fixes #129.
2026-02-21 16:05:07 +01:00
can1357 bdf37ccde2 refactor(coding-agent): simplified git timeout handling with AbortSignal
- Simplified git command timeout handling by replacing manual Promise.race with AbortSignal.timeout and untilAborted utility.
- Consolidated timeout logic to single 3000ms value and unified git command invocation pattern.
2026-02-21 15:57:05 +01:00
can1357 39190cbe37 refactor(coding-agent): remove unused RenderCallOptions type 2026-02-21 15:50:31 +01:00
DeprecatedLuke faf90b274b refactor(coding-agent)!: standardize renderCall signatures to (args, options, theme) 2026-02-21 15:50:31 +01:00
can1357 f0fb643117 feat(ai): implemented configurable model refresh strategies with global fallback resolution
- Added configurable model refresh strategies (online, online-if-uncached) to control model discovery behavior.
- Implemented global model.dev fallback resolution with context window and token prioritization for improved model attribute consistency.
- Incremented model cache schema version to support improved global model fallback resolution.
- Enhanced model generation script with dedicated functions for building model reference maps and applying fallback attributes.
2026-02-21 14:44:46 +01:00
can1357 3b7e7ba805 feat(coding-agent): enabled high-level thinking by default for reasoning
- Changed default thinking level from 'off' to 'high' for improved reasoning and planning.
2026-02-21 14:31:06 +01:00
Miroslav Drbal 8be261cd29 fix(mcp): strip $schema and nullable from MCP tool schemas before AJV validation
MCP servers using JSON Schema draft 2020-12 (e.g. servers built with Rust rmcp/schemars)
emit "$schema": "https://json-schema.org/draft/2020-12/schema" and "nullable": true in
tool inputSchemas. AJV (configured for draft-07) throws:

  Error: no schema with key or ref "https://json-schema.org/draft/2020-12/schema"

This causes all tool calls from these servers to fail argument validation silently.

Add sanitizeSchema() in convertSchema() — the single chokepoint for all MCP tool schemas
(MCPTool and DeferredMCPTool) — that recursively strips before schemas reach AJV or any
LLM provider:

- $schema: meta-schema declaration, not a validation keyword. AJV rejects unknown URIs.
- nullable: OpenAPI 3.0 extension, not standard JSON Schema. AJV rejects unknown keywords
  in strict mode.

This approach keeps AJV on draft-07 with no version switch. Switching to Ajv2020 was
considered but rejected: it would introduce the symmetric failure for servers that still
emit draft-07 $schema URIs.
2026-02-21 09:42:58 +01:00
can1357 baf381e78c feat(ai): added SQLite-backed model cache with peekApiKey support
- Exported readModelCache and writeModelCache functions for SQLite-backed model cache access.
- Migrated model cache storage from per-provider JSON files to unified SQLite database (models.db).
- Renamed cachePath option to cacheDbPath in ModelManagerOptions for database-backed storage.
- Improved non-authoritative cache handling with 5-minute retry backoff instead of per-startup retries.
- Added peekApiKey method to AuthStorage for non-blocking API key retrieval during model discovery.
- Added <turn_aborted> guidance marker as synthetic user message for aborted/errored assistant messages.
2026-02-20 23:35:53 +01:00
can1357 5d32f93c0d fix(ai): improved error handling and provider robustness
- Added raw HTTP request dumps to error messages for 400 status codes.
- Implemented client-side retry for Anthropic streaming on transient errors.
- Preserved context by converting aborted assistant tool calls to text.
- Optimized model registry refresh in coding agent sessions.
2026-02-20 22:22:04 +01:00
can1357 119e07c793 refactor(ai): centralized message transformation logic
- Centralized and generalized message transformation logic.
- Implemented provider-specific tool call ID normalization.
- Ensured API compatibility by generating synthetic tool results for orphaned calls.
- Simplified Anthropic client and request parameter construction.

Fixes #120
2026-02-20 20:35:04 +01:00
can1357 c199779a05 fix(task): corrected submit_result to terminate only on success
- Fixed submit_result tool to only terminate on successful execution instead of always terminating.
- Removed deferred termination logic and simplified abort behavior to call requestAbort immediately.
- Added submitResultCalled flag tracking to properly manage tool execution state.
- Added test coverage for submit_result tool retry behavior after execution errors.
2026-02-20 20:03:37 +01:00
can1357 a15c39ae7d feat(coding-agent/task): added subprocess output finalization with submit_result validation
- Exported `finalizeSubprocessOutput()` function and `SubmitResultItem` interface for subprocess output finalization with submit_result validation.
- Added automatic reminders (up to 3) when subagent stops without calling submit_result tool, aborting with exit code 1 after final reminder.
- Extracted subprocess output finalization logic into dedicated `finalizeSubprocessOutput()` function for improved testability and reusability.
- Added comprehensive test coverage for subagent warning injection, reminder behavior, and abort handling in executor module.
2026-02-20 17:15:02 +01:00
can1357 83e914d075 fix(submit-result): corrected submit_result validation to prevent false completion flags
- Added validation to submit_result tool to ensure status field is present and correctly typed as 'success' or 'aborted'.
- Fixed executor to only mark submitResultCalled when submit_result tool succeeds or aborts, preventing false positives on validation failures.
- Added type guards and error state checks to prevent setting completion flags on malformed tool execution results.
- Added comprehensive test coverage for submit_result extraction with valid and malformed payload validation.
2026-02-20 15:23:33 +01:00
can1357 7caef79598 docs(coding-agent): clarified system prompt to emphasize action-driven workflow and verification
- Updated system prompt guidance to emphasize action-driven workflow and verification of behavioral changes.
2026-02-20 14:01:57 +01:00