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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Refined system prompt guidance for code quality and refactoring practices.
- Consolidated and clarified instructions on code cleanup, verification, and dependency selection.
- 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.
- 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.
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>
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
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
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
- 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.
- 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.
- 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.
- 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.
- 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.
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.
- 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.
- 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.
- 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.
- 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.
- 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.