Commit Graph
2225 Commits
Author SHA1 Message Date
can1357 2cd8f52f4e feat(tools): added SQLite database operations with read/write support and query validation
- Added SQLite path parsing and candidate validation for `.sqlite`, `.db`, `.db3`, and `.sqlite3` targets in read/write flows.
- Added SQLite read operations for table lists, schema views, row lookups, paginated queries, and raw SELECT mode.
- Added SQLite write operations for insert, update-by-key, and delete-by-key using JSON5 row payloads.
- Updated selector routing to validate SQLite headers and fall back to normal file reads/writes when not databases.
- Secured read mode by enforcing query validation to block destructive SQL execution on SQLite inputs.
2026-04-11 08:57:58 +02:00
can1357 90f1672b2b fix(coding-agent): resolved duplicate -c in coding-agent git commands
- Added SHORT_LIVED_GIT_CONFIG constants and withShortLivedGitConfig helper for short-lived overrides.
- Updated runCommand to route git args through short-lived config normalization and avoid duplicate -c entries.
- Added scripts/release git() helper and replaced raw release git invocations with config-safe calls.
- Added git-process-config tests asserting status and stage spawn git with disabled core.fsmonitor/untrackedCache.
2026-04-11 08:54:27 +02:00
can1357 5277e44139 feat(coding-agent): added canonical aliases for model role resolution
- Added canonical model equivalence types, cache helpers, and registry APIs for provider variant lookup.
- Changed model resolution to apply canonical ID overrides/excludes with provider order before fallback matching.
- Added canonical and provider model views in list-models and selector UI with canonical sorting/persistence.
- Updated role/model persistence to store selectors while runtime now resolves concrete canonical-backed provider models.
2026-04-11 08:28:50 +02:00
can1357 0dab29c07c feat(coding-agent): added coding-agent prompt: no estimates/no shims
- Updated the system prompt to omit time estimates and duration predictions from responses.
- Reinforced coding guidance to avoid speculative abstractions and compatibility shims unless they are needed.
2026-04-11 07:23:45 +02:00
can1357 342cbc01c7 fix(ai): corrected ai usage report parsing to preserve partial payload data
- Fixed usage report generation to preserve partial data when parsing payloads are incomplete.
- Fixed planType resolution to fall back to raw `plan_type` when parsed planType is missing.
- Fixed usage metadata population to set accountId and keep the original raw payload when parsed raw output is absent.
- Fixed usage report rendering to label unlimited plans and display a clear `-- no limits` status line.
2026-04-11 07:02:27 +02:00
can1357 1c4c8c2851 Merge remote-tracking branch 'fork-inprealpha/feat/opencode-oauth-copilot' 2026-04-11 06:39:13 +02:00
can1357 77c8bf6e82 fix(chunk): corrected fenced code block indentation preservation and file validation
- Fixed markdown fenced code block rendering to preserve literal indentation instead of normalizing to tabs.
- Added validation to reject chunk selector operations on non-existent files with descriptive error message.
- Fixed chunk deletion to properly derive parent paths and mark ancestors with appropriate focus modes.
- Simplified path segment matching logic by removing unnecessary normalization of requested_segment parameter.
- Added comprehensive test coverage for fenced code block caret reads, indentation preservation, and file-not-found error handling.
2026-04-11 03:43:53 +02:00
can1357 7bf0e59d44 perf(coding-agent): optimized image compression with aggressive payload reduction strategy
- Reduced default image size limits to 1568px and 500KB to match Anthropic's internal thresholds.
- Optimized screenshot compression with 1024px max dimensions, 150KB budget, and 70% JPEG quality for aggressive payload reduction.
- Added fast-path optimization to skip re-encoding when images fit dimensions and are within 25% of byte budget.
- Refactored image encoding strategy to JPEG-only in quality/dimension reduction loops with improved quality ladder steps.
2026-04-11 03:42:26 +02:00
can1357 0394213f9d fix(chunk): corrected stale chunk selector resolution with CRC fallback matching
- Added fallback logic to resolve stale chunk selectors by matching same-parent CRC when exact selector not found.
- Fixed stale child selector reuse to match chunks by checksum for sibling chunks with identical names.
- Added condition to check for Section chunk kind with Replace operation in region nullification logic.
- Expanded documentation with critical warnings about chunk name truncation and guidance for markdown editing with whitespace preservation.
2026-04-10 22:52:16 +02:00
can1357 6cd077e075 feat(coding-agent): added designer role with model fallback support and Gemini 3.1
- Added designer model role for UI/UX design tasks with Gemini 3.1 Pro as default model.
- Implemented model role fallback list support enabling automatic fallback to next available model when primary is unavailable.
- Refactored model role resolution to support multiple fallback patterns per role with thinking level mapping.
- Updated designer agent to use pi/designer role alias instead of explicit model list, removing spawns configuration.
- Added test coverage for model resolver fallback patterns and designer role override preferences.
- Added test coverage for geminiImageTool X-Title header routing through OpenRouter.
2026-04-10 22:07:02 +02:00
can1357 157eb1009f chore(ai): added X-Title header to OpenRouter and Gemini API requests for identification
- Added X-Title header to OpenRouter and Gemini API requests for identification.
2026-04-10 22:02:11 +02:00
can1357 9817bc83ea fix(lsp): cleared stale diagnostics cache before refreshing file state
- Fixed stale diagnostics being reused after unrelated file publishes by clearing cached diagnostics before refreshing file state.
- Added regression test to verify diagnostics cache is cleared when refreshing files.
2026-04-10 22:01:36 +02:00
can1357 3aa927bc80 refactor(coding-agent): restructured result building to eliminate duplication
- Extracted result building logic into reusable buildResult function to eliminate duplication across three code paths.
- Consolidated import of natives module to use namespace import instead of destructured imports for consistency.
- Reorganized signal timeout initialization to occur before conditional branches for clarity.
- Added test case verifying mtime-based sorting of recursive filename matches.
2026-04-10 21:45:53 +02:00
can1357 cc2801e6ef feat(coding-agent): added HTML content extraction with Readability and GFM markdown support
- Added `extractReadableFromHtml()` utility function with dual-path content extraction using Readability library and CSS selector fallback.
- Integrated Turndown library with GitHub Flavored Markdown plugin for improved HTML-to-markdown conversion supporting tables, strikethrough, and task lists.
- Refactored `getPageReadable()` action to use new extraction function, consolidating content parsing logic and improving maintainability.
- Added TypeScript type declarations for turndown-plugin-gfm module with custom Turndown rules for enhanced markdown formatting.
2026-04-10 21:31:28 +02:00
can1357 7213aaf128 refactor(chunk): restructured chunk rendering to separate prologue and body line counts
- Refactored chunk rendering to compute prologue and body line counts separately via new `chunk_head_body_lines()` function.
- Updated ellipsis marker format from line count to line range selection syntax (e.g., 'to expand above/below').
- Modified `render()` method signature to accept `head_lines` and `body_lines` parameters for precise line count display.
- Simplified no-changes response in chunk edit mode to omit redundant text when content matches.
- Expanded chunk-edit documentation with compound statement examples and region suffix behavior for non-code formats.
2026-04-10 21:14:10 +02:00
can1357 9edc885a40 fix(ai): corrected duplicate synthetic tool results by tracking persisted call IDs
- Fixed duplicate synthetic tool results by tracking persisted tool call IDs and skipping synthesis when real results exist.
- Fixed Codex search streamed answer handling to detect and skip image placeholder text, preferring final answer.
- Added test coverage for duplicate tool result prevention in message transformation pipeline.
2026-04-10 20:13:25 +02:00
can1357 23e0952876 refactor(lsp): extracted diagnostic target resolution into utility function
- Extracted diagnostic target resolution logic into new `resolveDiagnosticTargets()` utility function with glob pattern support.
- Consolidated glob pattern detection and file matching logic by replacing conditional branches with unified utility call.
- Added file existence checking with stat before glob expansion to handle bracket paths as literal targets.
- Added test coverage for bracket path handling in diagnostic target resolution.
2026-04-10 20:12:19 +02:00
can1357 fa375d6eaa refactor: restructured chunk region notation from @head/@body/@tail/@decl to ^/~ suffix format
- Simplified chunk region notation from @head/@body/@tail/@decl to ^/~ suffix format across all modules.
- Removed ChunkRegion::Tail and ChunkRegion::Decl enum variants and updated region matching logic accordingly.
- Added call-with-callback pattern detection via try_promote_call_with_callback() and trailing_callback_body() functions.
- Updated documentation and test fixtures to reflect new region selector syntax throughout codebase.
2026-04-10 17:27:49 +02:00
inprealphaandGitHub 4a4032dbea Merge branch 'main' into feat/opencode-oauth-copilot 2026-04-10 20:41:36 +05:30
Abir Biswas bf3994ec6e fix(ai): harden Copilot OAuth with auth error handling, login tests, and rate-limit batching
- Detect 401/403 from Copilot and rewrite to actionable re-login message,
  invalidating stale credentials in the session layer (Fix 1)
- Add 9 unit tests for loginGitHubCopilot device-code flow (Fix 2)
- Centralize duplicated "opencode/1.3.15" User-Agent into a single
  exported COPILOT_USER_AGENT / OPENCODE_HEADERS constant (Fix 3)
- Batch model enablement to 5-at-a-time to avoid rate limits (Fix 4)
2026-04-10 20:36:13 +05:30
can1357 4a1ca64a7b docs(chunk): documented chunk-edit region semantics with table format and examples
- Restructured chunk-edit region documentation into table format for clarity and scannability.
- Clarified region semantics with concrete examples and consolidated redundant explanations.
2026-04-10 16:24:55 +02:00
can1357 bb550efc6b chore: cleaned up documentation, test infrastructure, and dependencies across tooling
- Enhanced chunk-edit tool documentation with clarifications on @decl region behavior and guidance for attribute/decorator modifications.
- Improved chunk edit implementation to handle @body region scanning and markdown blank-line preservation with additional test coverage.
- Added oracle model review synthesis to rate-edit-tool.py for aggregating findings across multiple model reviews.
- Updated test infrastructure to run TypeScript and Rust tests in parallel using cargo nextest with improved logging control.
- Updated TypeScript dependencies including @typescript/native-preview and typescript to latest versions.
2026-04-10 15:53:41 +02:00
can1357 476a689c6f refactor(coding-agent): migrated session cleanup to async iterator pattern
- Extracted `raceWithAbort()` utility to pi-utils package for reuse across projects.
- Replaced local `raceAbort()` implementation with imported `raceWithAbort()` from pi-utils.
- Refactored cleanup timer to use async iterator pattern with `timers.setInterval()` instead of callback-based `setInterval()`.
- Converted `#cleanupIdleSessions()` and `#disposeSession()` from async to synchronous methods with async cleanup loop delegated to `#runCleanupLoop()`.
2026-04-10 15:04:46 +02:00
can1357 f4b6b32262 refactor(modes): restructured event controller into dedicated handler methods for type safety
- Extracted large switch statement into 16 dedicated event handler methods for improved maintainability and type safety.
- Introduced AgentSessionEventHandlers type and handler dispatch map to enable compile-time verification of event coverage.
2026-04-10 14:49:06 +02:00
can1357 d60ee622a4 refactor: restructured hash API and cache tracking across TypeScript and Rust
- Migrated hash API calls from Bun.hash.xxHash64() to Bun.hash() across TypeScript packages for simplified hash generation.
- Consolidated mermaid cache failure tracking by replacing separate failed Set with null values in cache Map.
- Refactored schema-based child extraction in Rust by introducing promotion_fields tracking and schema_wrapper_child() helper function.
- Updated TypeScript configuration files with reformatted arrays and added compiler options for consistency.
2026-04-10 14:26:06 +02:00
can1357 b60c0cc3ce refactor: migrated tab width resolution to pi-utils with EditorConfig caching
- Extracted tab width resolution from pi-natives to pi-utils with EditorConfig caching support.
- Made tabWidth parameter required in native text functions (visibleWidth, truncateToWidth, wrapTextWithAnsi, sliceWithWidth, extractSegments).
- Removed process-wide tab width state management from pi-natives text module.
- Consolidated wrapper node promotion logic in chunk classification with abbreviated string representations.
- Removed path-clean and pathdiff dependencies from pi-natives.
- Updated all consuming packages to import tab width functions from pi-utils and pass explicit tabWidth parameters.
2026-04-10 14:18:36 +02:00
can1357 6bf09bedb0 refactor(chunk): restructured language classifiers to declarative rule tables
- Migrated language classifiers from imperative methods to declarative semantic rule tables with ClassifierTables and StructuralOverrides.
- Extracted node shape analysis into dedicated shape module with field priority constants and helper functions for AST traversal.
- Added schema module with language-aware node metadata and thread-local language context management.
- Centralized environment variable parsing across codebase using $flag(), $envpos(), and isBunTestRuntime() utilities.
- Added PI_CHUNK_AUTOINDENT configuration to control indentation normalization in chunk read/edit operations.
- Enhanced system prompt with instruction priority, output contract, tool persistence, and completeness guidelines.
2026-04-10 13:33:00 +02:00
can1357 55e27e842e refactor(coding-agent): extracted language detection into dedicated module
- Extracted language detection logic into dedicated module for reusability across LSP and theme subsystems.
- Unified extension-to-language mapping with dual identifiers (highlight and LSP) to eliminate duplication.
- Consolidated detectLanguageId and getLanguageFromPath into single source of truth in lang-from-path module.
2026-04-10 10:42:50 +02:00
can1357 5fb98634b1 feat: implemented merge conflict detection and resolution API for chunk state
- Added merge conflict detection and resolution API with hasConflicts() and conflictCount() methods to ChunkState.
- Implemented conflict marker parsing supporting standard and diff3-style formats with accept_ours() resolution.
- Extended ChunkKind enum with Hunk, Conflict, Ours, and Theirs variants for diff and merge conflict representation.
- Added virtual_content field to ChunkNode for rendering conflict branches and improved diff parsing with block-level file chunk handling.
- Implemented conflict metadata tracking across edits with validation preventing direct modifications to virtual conflict branches.
2026-04-10 07:44:12 +02:00
can1357 e102958f06 fix(edit): corrected hashlineParseText to handle undefined values
- Extended hashlineParseText to accept undefined in addition to null, preventing type errors when undefined is passed.
- Updated null check to use loose equality (==) to handle both null and undefined cases.
2026-04-09 20:13:58 +02:00
can1357 5d48656544 revert: restructured indentation from tab-based to space-based representation
This reverts commit 29376dac2b.
2026-04-09 20:02:57 +02:00
Can BölükandGitHub 77075ca406 Merge pull request #649 from bobags2/fix/ollama-use-openai-responses-api
fix: use OpenAI Responses API for Ollama instead of Completions
2026-04-09 19:27:17 +02:00
can1357 c0ba48cb68 fix(coding-agent): normalize cached Ollama discovery transport 2026-04-09 18:57:52 +02:00
can1357 a9e0f02657 refactor(review): render extra instructions from template 2026-04-09 18:57:51 +02:00
bobags2andcan1357 ff3cf964e8 fix: use OpenAI Responses API for Ollama instead of Completions
Ollama has supported the OpenAI Responses API since v0.6+. The Completions
stream is prone to stalling errors ("OpenAI completions stream stalled while
waiting for the next event"), especially with tool calls. The Responses API
is more robust and supports the same features.

Changes:
- pi-ai/openai-compat.ts: Changed ollamaModelManagerOptions() and
  fetchOllamaNativeModels() to use api: "openai-responses" instead
  of "openai-completions"
- coding-agent/model-registry.ts: Changed implicit ollama discovery
  provider from "openai-completions" to "openai-responses"

Users with existing model caches should clear them after upgrading
(e.g. delete the ollama entry from ~/.omp/agent/models.db).
2026-04-09 18:47:09 +02:00
Miroslav Drbalandcan1357 93f7953603 feat(review): support inline custom instructions in /review command
Pass args directly to /review to append them as additional instructions
to the generated prompt for all structured review modes (PR-style,
uncommitted, specific commit). When inline args are present, option 4
(custom editor) is suppressed from the menu. The no-UI (Task tool) path
forwards args as a focus hint.

Adds appendInstructions() helper to centralize the prompt append format.
2026-04-09 18:47:08 +02:00
Can BölükandGitHub d6993d0029 Merge pull request #648 from sundbp/session-observer-tmux-fix
fix(coding-agent): stop repetitive scrolling in session observer viewer
2026-04-09 18:44:38 +02:00
Can BölükandGitHub 1aa21a368a Merge pull request #646 from Blues-star/fix/windows-lsp-local-bin-detection
fix: TypeScript LSP detection on Windows
2026-04-09 18:44:30 +02:00
Patrik Sundberg bb5f332eca fix(coding-agent): stop repetitive scrolling in session observer viewer
Move live stats (tokens, tools, duration) from the header — which scrolls
above the TUI viewport for long transcripts — to a stable Text component
placed after the viewerContainer. Stats are updated in-place via setText()
so the diff algorithm sees changes near the bottom of rendered output,
avoiding the fullRender(true) trigger when firstChanged < viewportTop.

Previously every ~150ms progress update changed the header stats line,
which sat above the viewport for large transcripts. The TUI's safety
check (firstChanged < previousContentViewportTop) forced a full screen
clear and re-render each cycle. In multiplexers (tmux/zellij) this
produced visible repetitive scrolling because scrollback is preserved
across clears.
2026-04-09 02:19:41 +01:00
can1357 300a8e2ea3 refactor(chunk): restructured anchor markers from +++ syntax to [< >] format
- Changed anchor marker format from `+++`/`---` to `[<`/`>]` syntax in chunk rendering and documentation.
- Refactored render_i() to accept marker tuple (open, close) instead of single string for symmetric anchor pairs.
- Updated 94 lines of prompt documentation to reflect new anchor syntax in examples and instructions.
2026-04-09 02:35:32 +02:00
can1357 ea9c46262f feat(coding-agent): introduced /force command and ToolChoiceQueue for directive management
- Added `/force` slash command and `ToolChoiceQueue` system for managing tool-choice directives with lifecycle callbacks and requeue semantics.
- Added `setForcedToolChoice()`, `peekQueueInvoker()`, `buildToolChoice()`, `steer()`, and `getToolChoiceQueue()` methods to AgentSession and ToolSession APIs.
- Refactored tool-choice override mechanism from simple override to queue-based system with generator directives, lifecycle callbacks, and requeue preservation.
- Removed `PendingActionStore` class and replaced with `ToolChoiceQueue`; updated `ResolveTool` and custom tool loader to use queue invokers.
- Fixed tool-choice queue cleanup on agent loop abort and requeue semantics to preserve callbacks across abort cycles.
2026-04-08 22:10:37 +02:00
can1357 f49098eb76 config: configured PI_STRICT_EDIT_MODE for model-specific edit behavior
- Added PI_STRICT_EDIT_MODE environment variable to control model-specific edit mode defaults.
- Wrapped model-specific edit mode logic behind PI_STRICT_EDIT_MODE condition for conditional behavior.
- Replaced Bun.env direct access with $env utility for consistent environment variable handling.
- Updated rate-edit-tool and typescript-edit-benchmark to set PI_STRICT_EDIT_MODE in test environments.
2026-04-08 21:30:52 +02:00
can1357 ad9bc6943a feat(slash-commands): enabled slash commands to return remaining text as prompt input
- Enhanced slash command handlers to return remaining text as prompt input instead of consuming input entirely.
- Updated slash command parser to recognize both whitespace and colon (`:`) as command argument separators.
- Modified executeBuiltinSlashCommand return type to support string (remaining text) or boolean (consumed/not matched).
- Updated input controller to handle remaining text from slash commands and use it as prompt input.
2026-04-08 20:57:25 +02:00
can1357 29376dac2b refactor: restructured indentation from tab-based to space-based representation
- Renamed indent normalization functions from tab-based to space-based naming (normalize_to_tabs -> compact_indent, denormalize_from_tabs -> expand_indent).
- Changed canonical indentation representation from tab characters to single leading spaces per indent level across chunk rendering and editing.
- Updated documentation and type annotations to reflect space-based indentation convention in chunk edit tool and native bindings.
- Simplified indent expansion logic to count whitespace characters instead of parsing individual characters.
2026-04-08 20:56:25 +02:00
can1357 9bb1683445 feat(coding-agent): added URL selectors with :raw and line range syntax to read command
- Added support for embedded URL selectors with `:raw` and `:L#-L#` line range syntax in read command.
- Implemented `parseReadUrlTarget()` function to parse and validate URL read targets with line range support.
- Updated read CLI to delegate URL inputs through read tool pipeline instead of treating as local file paths.
- Added comprehensive test coverage for URL selector parsing and CLI URL delegation.
- Refactored URL handling in read tool to use structured `ParsedReadUrlTarget` object.
2026-04-08 19:47:51 +02:00
can1357 3cf7d1adc8 feat(coding-agent): added model-specific edit mode resolution for Claude variants
- Added model-specific edit mode resolution for Anthropic Claude variants (spark, nano, mini, haiku, flash) to default to replace mode.
2026-04-08 19:33:22 +02:00
can1357 9f9e0938e5 feat: introduced @decl chunk region selector for semantic declarations
- Added `@decl` chunk region selector for targeting semantic declarations without leading trivia.
- Updated chunk edit documentation with visual region boundary diagram and critical narrowest-region requirement warning.
- Implemented `Decl` variant across Rust types, NAPI bindings, and TypeScript definitions with full region range logic.
- Added inline hunks emission for effectively-leaf chunks to preserve hunks when children are filtered by focus.
- Improved type safety in LSP startup test by replacing truthy check with explicit function type check.
2026-04-08 17:49:39 +02:00
can1357 52719d1a7c refactor: restructured monorepo TypeScript config and build tasks for unified setup
- Migrated all package tsconfig files to extend tsconfig.workspace.json for unified TypeScript configuration across monorepo.
- Consolidated build and check scripts across 10+ packages to use biome for linting/formatting with separate type checking via tsgo.
- Renamed build scripts from build:native and build:binary to build for simplified command naming across packages/natives and packages/coding-agent.
- Refactored CI workflow to invoke bun tasks instead of inline shell scripts, reducing workflow complexity by 40+ lines.
- Removed sync-exports.ts and repro-stuck.ts scripts; deleted path aliases from tsconfig.base.json in favor of workspace-based configuration.
- Updated turbo.json with new task definitions (check:types, lint, fmt, fix) and removed build:native/embed:native tasks.
2026-04-08 17:05:20 +02:00
can1357 3f4384f6b1 fix(auto-generated-guard): corrected file not found handling in marker detection
- Fixed file not found error handling in auto-generated marker detection to gracefully return undefined instead of propagating errors.
- Made assertEditableFileContent function synchronous to simplify API and improve error handling consistency.
- Updated test assertions to match synchronous function behavior using toThrow instead of rejects patterns.
- Removed obsolete test case for doc comment preservation during replace operations.
2026-04-08 15:06:47 +02:00
can1357 4ca9bd9c78 refactor: migrated cloning logic to centralized utility for consistency
- Extracted `structuredCloneJSON()` utility to centralized package for consistent deep cloning with JSON fallback.
- Consolidated duplicate cloning logic across openai-responses, openai-responses-shared, and validation modules.
- Added resilience to message cloning in extension runner with try-catch fallback for non-cloneable objects.
- Optimized context emission in extension runner by skipping message cloning when no handlers exist.
- Added optional `contentIndex` field to AssistantMessageEvent variants for type consistency.
2026-04-08 14:51:35 +02:00