Commit Graph

692 Commits

Author SHA1 Message Date
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 7a3dc2963a test(coding-agent): restructured streaming abort tests with timing control for isolation
- Refactored test suite to use top-level hooks instead of describe block for improved test isolation.
- Enhanced streaming mock to support delayed delta emission via waitBeforeFirstDelta promise.
- Improved auto-generated file abort test with precise timing control to verify abort occurs before delta updates.
2026-04-08 15:28:08 +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 757bdca7a1 feat: added assistant message event interception for streaming edit abort control
- Added `onAssistantMessageEvent` callback to Agent API for inspecting and aborting assistant streaming events.
- Added `setAssistantMessageEventInterceptor()` method to dynamically update assistant message event handlers.
- Converted `checkAutoGeneratedFileContent()` from async to synchronous for improved streaming edit abort detection performance.
- Implemented LRU caching in auto-generated file detection with early path-based checks to prevent unnecessary edits.
- Refactored streaming edit pre-caching to use assistant message event interception for real-time abort capability.
- Extracted `peekFile()` utility for efficient file prefix reading with pooled buffer reuse strategy.
2026-04-08 14:51:15 +02:00
can1357 211e5369a0 refactor(coding-agent): migrated image utilities to shared pi-utils package
- Extracted image metadata detection and MIME type utilities to @oh-my-pi/pi-utils package for shared use across projects.
- Consolidated image-input.ts and mime.ts modules into image-loading.ts with simplified API removing redundant metadata parameters.
- Updated all import paths across coding-agent to use readImageMetadata from @oh-my-pi/pi-utils instead of local utilities.
- Added peek-file utility module to @oh-my-pi/pi-utils with buffer pooling for efficient file header reading.
2026-04-08 14:42:51 +02:00
can1357 2bdc80eedc fix: AsyncDrain double-allocation bug and history test singleton isolation 2026-04-08 12:52:32 +02:00
can1357 468601935c fix(test): use awaitable add() in history storage compat test 2026-04-08 12:43:36 +02:00
can1357 88595b541c fix(test): use setImmediate drain instead of sleep for history insert timing 2026-04-08 12:30:12 +02:00
can1357 edab058993 refactor: remove pi-ref lazy barrel import, fix test mocks for Bun 1.3.11
- Remove pi-ref.ts deferred barrel import (no longer needed after circular dep fix)
- Update extension/hook/custom-tool/custom-command loaders to use direct imports
- Fix warmPythonEnvironment mock return type in python tool tests (add docs field)
2026-04-08 12:21:17 +02:00
can1357 003eccce52 fix: remove unused type alias and fix test compatibility with Bun 1.3.11
- Remove unused ParsedChunkTarget type alias (lint error)
- Increase setImmediate timing in history storage compat test
- Mock warmPythonEnvironment in python tool tests
- Fix tlaplus LSP test to spy on $which instead of Bun.which
2026-04-08 12:17:37 +02:00
can1357 26d7783370 fix(chunk): corrected chunk boundary calculations to prevent out-of-range violations
- Added bounds clamping to prologue and epilogue byte calculations to prevent out-of-range boundary violations.
- Extended chunk boundaries for indent-based languages when epilogue exceeds calculated range with trailing newline.
- Added comprehensive test coverage for Python chunk editing operations including body/head replacement and indentation preservation.
- Extracted working directory formatting logic into reusable utility function and applied tab sanitization to bash command previews.
2026-04-08 11:50:42 +02:00
can1357 fee6b7858a refactor: restructured chunk region API and storage layer for consistency
- Renamed ChunkRegion::Inner variant to Body across Rust and TypeScript for clearer semantics.
- Renamed chunk edit tool parameter from target to sel and made op required instead of optional.
- Removed region aliases (prologue, epilogue, inner) and simplified region validation to accept only head, body, tail.
- Replaced db.exec() calls with db.run() for SQL execution in auth-storage, agent-storage, and history-storage.
- Enhanced chunk edit documentation with comprehensive examples, indentation rules, and CRC refresh guidance.
- Improved chunk statement merging logic to consolidate leaf statements into parent function bodies by default.
2026-04-08 11:49:14 +02:00
can1357 4c03bad90d feat(coding-agent): added Auto QA tool and Python environment warmup for tool reliability
- Added Auto QA tool (`report_tool_issue`) for automated tracking of unexpected tool behavior with environment variable and setting support.
- Added Python tool environment warmup on first execution to ensure prelude helpers are available before use.
- Fixed Python prelude introspection to respect execution timeout and signal options, preventing hangs.
- Refactored prelude documentation caching and loading logic into reusable helper functions with test environment awareness.
- Enhanced kernel introspection with optional timeout and signal parameters for better execution control.
- Added system prompt guidance to encourage agents to report tool issues via Auto QA when available.
2026-04-08 11:49:13 +02:00
can1357 4058582a5a refactor: restructured chunk syntax and region semantics for clarity
- Refactored chunk anchor format from bracket notation to marker-based syntax with +++ and --- delimiters.
- Renamed chunk edit regions from @container/@prologue/@body/@epilogue to @head/@inner/@tail for clearer semantics.
- Simplified line-number selector resolution to auto-convert line targets to chunk paths with checksum format.
- Removed PI_DEV debug addon loading logic; PI_DEV now only enables loader diagnostics without changing candidate filenames.
- Added full-name aliases for chunk kind patterns (decls, expr, fn, meth, mod, params, ret, stmts, var) alongside abbreviated forms.
- Refactored sanitize_node_kind() to return &str instead of String; adjusted identifier passing logic across AST modules.
2026-04-08 11:49:13 +02:00
can1357 16ad914da0 feat(coding-agent): added LSP status updates to welcome banner on warmup completion
- Added real-time LSP server status updates in welcome banner when background warmup completes.
- Changed welcome banner status icon from warning to muted pending symbol for improved visual clarity.
- Extracted LSP server conversion logic into dedicated helper methods for better maintainability.
- Added comprehensive test coverage for interactive mode LSP startup welcome banner updates.
2026-04-08 08:58:39 +02:00
can1357 7f88a0c24c refactor: restructured logger.time() API to accept function references with wall-clock markers
- Refactored logger.time() API to accept function references and arguments separately instead of wrapped callbacks.
- Replaced RingBuffer-based timing with wall-clock markers and async span tracking for improved timing accuracy.
- Updated 20+ call sites across executor, kernel, main, and tools modules to use new logger.time() signature.
- Removed parsePath() helper function and inlined path.split() calls in settings module.
- Added test case verifying model selection without auth validation during startup.
2026-04-08 08:47:32 +02:00
can1357 53c8d33758 feat(acp): implemented multi-session support with forking and lifecycle management
- Added multi-session support to ACP mode enabling session forking, resumption, and closure operations.
- Added session model state reporting and unstable_setSessionModel RPC command for direct model configuration.
- Added turn-level usage tracking and stable message ID tracking for assistant chunks in ACP responses.
- Added Settings.cloneForCwd() method and ExtensionRunner.getFlagValues() for configuration isolation across sessions.
- Fixed ACP session cleanup to properly cancel in-flight prompts and dispose resources on disconnect.
- Refactored AcpAgent to manage multiple concurrent sessions with per-session lifecycle instead of single session.
2026-04-08 06:54:33 +02:00
can1357 58c0d52679 refactor: restructured chunk tree initialization and extraction logic for clarity
- Refactored chunk tree initialization to use explicit prologue/epilogue byte boundaries instead of None values.
- Extracted chunk resolution logic to use split_selector_crc_and_region() helper for improved code reuse.
- Reorganized package.json exports across multiple modules (autoresearch, cli, dap, edit, modes) for better API surface clarity.
- Updated test expectations for Go receiver method rendering and chunk selector formats to match refactored output.
- Consolidated notebook conversion logic and removed unused _createErrorToolResult helper function.
- Improved leading trivia preservation in chunk edits by detecting and maintaining line prefix whitespace.
2026-04-08 06:30:50 +02:00
can1357 821ec9570d feat(coding-agent): enabled bidirectional RPC tool execution with host-owned custom tools
- Added RPC host-owned custom tools framework enabling bidirectional tool execution between RPC client and host.
- Added `set_host_tools` RPC command and `refreshRpcHostTools()` method for dynamic tool registry management.
- Added RpcHostToolBridge and RpcHostToolAdapter classes with abort signal handling for cancellable tool execution.
- Added `defineRpcClientTool` helper and customTools option to RpcClient for embedding host tool definitions.
- Added comprehensive test suite covering RPC host tool execution, cancellation, and client-host communication.
2026-04-08 06:23:27 +02:00
can1357 a21a542afd refactor(prompt-templates): migrated prompt utilities to pi-utils package
- Extracted prompt rendering and formatting utilities from coding-agent to centralized pi-utils package with new API surface (prompt.render, prompt.format, prompt.registerHelper).
- Migrated parseFrontmatter utility from coding-agent to pi-utils package; updated 8 files to import from @oh-my-pi/pi-utils.
- Removed 170-line prompt-format.ts module and consolidated 192 lines of Handlebars helper registrations into pi-utils prompt module.
- Updated 60+ files across coding-agent and typescript-edit-benchmark to use new prompt.render() and prompt.format() API from pi-utils.
- Simplified prompt-templates.ts by delegating core functionality to pi-utils while retaining custom helper registrations (jtdToTypeScript, jsonStringify, etc.).
2026-04-08 05:47:35 +02:00
can1357 6d07944654 refactor: migrated binary detection to $which() utility across codebase
- Replaced all Bun.which() calls with $which() utility from @oh-my-pi/pi-utils across 22 files.
- Removed findBashOnPath() wrapper function from procmgr.ts, consolidating binary path resolution.
- Updated AGENTS.md documentation to reflect new $which() API usage pattern.
- Centralized binary detection logic through shared utility, reducing code duplication.
2026-04-08 05:28:22 +02:00
can1357 ca01e8a7a8 feat: introduced region-based chunk targeting with @container, @prologue, @body, @epilogue selectors
- Added region-based chunk targeting with @container, @prologue, @body, @epilogue selectors for precise edit operations.
- Simplified chunk edit operations from 6 variants to 5 (replace, before, after, prepend, append) with unified region parameter.
- Removed checksum requirement from insert operations; only replace operations require #CRC suffix in selector.
- Added canonical indentation normalization with normalize_indent parameter for consistent tab-based rendering across file types.
- Refactored chunk selector format from separate crc/anchor fields to unified selector#CRC@region syntax for mutations.
- Added UnsupportedRegion status to chunk read operations for explicit handling of region availability per chunk type.
2026-04-08 05:18:22 +02:00
can1357 0f3cced15e refactor(edit): restructured edit tool with substring find and focused chunk rendering
- Reorganized edit tool from `patch/` to `edit/` directory with dedicated mode subdirectories (chunk, patch, hashline, replace).
- Replaced line-scoped edit operations with substring-based `find` parameter and added `replace_body` operation for preserving signatures.
- Added chunk focus modes (Expanded, Collapsed, Container) and focused rendering to display only touched chunks and adjacent siblings.
- Implemented notebook (ipynb) language support with virtual source conversion and cell-based chunk parsing.
- Enhanced chunk edit error messages with consistent checksum mismatch reporting and improved chunk selector auto-resolution.
- Extracted edit mode implementations into separate modules with improved helper functions and LSP integration for diagnostics.
2026-04-08 04:18:59 +02:00
can1357 d19d51770f feat(coding-agent): enabled eager todo skip for queries and commands
- Eager todo enforcement now skips prompts ending with question marks or exclamation marks, treating them as queries or commands rather than statements requiring task planning.
- Added 2 test cases validating that eager todo enforcement is skipped for prompts ending with question and exclamation marks.
2026-04-08 03:48:46 +02:00
can1357 45bade9612 feat(chunk): added canonical chunk paths with CRC validation and selector resolution
- Added fully-qualified anchor paths in chunk read output showing complete path hierarchy with CRC checksums.
- Added exact chunk selector resolution with CRC validation to enforce canonical chunk paths in edit operations.
- Added `?` selector option to read syntax-aware chunks by canonical path listing when anchor paths are unclear.
- Improved tree-sitter range handling with `end_row_as_line()` function to correctly convert half-open ranges to 1-indexed line numbers.
- Extracted anchor label logic into `chunk_anchor_label()` const function and consolidated style-based selection.
- Removed --dev flag support from native build pipeline and dev:native npm scripts.
2026-04-07 23:31:39 +02:00
can1357 e6d36e2d8a fix(coding-agent): corrected plan review previews to re-append at chat tail on refresh
- Fixed plan review previews to re-append at the chat tail on refresh, keeping them adjacent to the active selector instead of updating off-screen.
- Added comprehensive test coverage for plan review rendering behavior across multiple refresh cycles.
2026-04-07 22:38:49 +02:00
Can Bölük 8d1636bc3b Merge pull request #637 from vmcall/fix/copilot-claude-task-stream
fix: hardened anthropic stream retry handling
2026-04-07 20:14:14 +02:00
can1357 87a3b6ca03 refactor(patch): restructured chunk edit schema to use explicit op enum and anchor field
- Refactored chunk edit schema to use explicit `op` enum field (replace, delete, append, prepend, after, before) instead of multiple boolean/string flags.
- Renamed chunk edit parameters from `after`/`before` field names to `anchor` for sibling-relative insert operations.
- Simplified chunk edit validation logic by consolidating nested conditionals into switch statement on operation type.
- Fixed `log_experiment` to correctly identify run-modified files by removing pre-run dirty path filtering.
- Simplified chunk edit and read prompt documentation to emphasize read-first workflow with consolidated examples.
2026-04-07 05:53:40 +02:00
can1357 ad4c5917a4 refactor(chunk): restructured selector resolution and state lookup with unified classification
- Refactored chunk selector resolution to extract and preserve raw selector strings separately from parsed CRC checksums.
- Reorganized chunk state lookup infrastructure with dedicated maps for checksum, leaf, and suffix-based chunk resolution.
- Simplified batch operation CRC validation to auto-accept stale checksums for subsequent operations on the same chunk.
- Unified TypeScript interface and Nix attrset chunk classification with consistent naming and nested expression handling.
- Extracted clipboard utility functions to dedicated module with improved OSC 52 and Termux support.
- Updated chunk read formatting with anchorStyle parameter and ellipsis standardization for improved consistency.
2026-04-07 05:51:21 +02:00
can1357 0d8696702f refactor(chunk): simplified chunk edit API with flat schema and target#CRC format
- Replaced nested operation objects with a flat edit schema using a single `target` field.
- Merged `sel` and `crc` into a unified `target: "chunk#CRC"` string copied from read output.
- Replaced `operations` array with `edits` and added `append`, `prepend`, `after`, `before` fields for insert positioning.
- Removed `defaultSelector` and `defaultCrc` top-level params; CRC is now always explicit per-edit.
2026-04-07 05:51:20 +02:00
can1357 9b78a6fa85 refactor(natives): migrated native bindings to NAPI-RS with auto-generated types
- Migrated native bindings from TypeScript wrappers to NAPI-RS generated modules with auto-generated type definitions and runtime enums.
- Replaced chunk tree API with stateful ChunkState class supporting render, edit, and resolve operations with improved error handling.
- Converted callback signatures to error-first pattern (error, result) for shell, PTY, glob, and grep operations.
- Introduced type-safe enums for MacOSAppearance, GrepOutputMode, KeyEventType, ImageFormat, and AstMatchStrictness replacing string literals.
- Refactored chunk tree implementation with dedicated modules for edit, indent, resolve, and state management with comprehensive validation.
- Moved clipboard utilities from native bindings to coding-agent package with improved OSC 52 and Termux compatibility.
2026-04-07 02:00:59 +02:00
Carl d50a416c52 fix: hardened anthropic stream retry handling 2026-04-06 22:41:41 +02:00
can1357 24a0d0ebde feat(chunk): added anchorStyle option and modernized render format
- Added `anchorStyle` setting ("full", "kind", "bare") to control anchor name verbosity in chunk output.
- Changed anchor tag delimiters from `` to `[…]` and gutter separator from `│` to `|`.
- Changed edit response to render only changed hunks with context instead of the full chunk tree.
2026-04-06 22:11:44 +02:00
can1357 6c6e79f0a7 fix(chunk-tree): corrected zero-width insert indent detection logic
- Fixed zero-width insert detection to derive target indent from neighboring lines instead of replaced range.
- Improved indent selection for body-level insertions by picking deeper indent between two neighbors.
- Updated error messages to clarify insert vs splice operations and line range validation.
- Modified assertChecksum() return type to handle cases with default CRC and no explicit selector.
2026-04-06 20:59:19 +02:00
can1357 5e106e22db refactor(chunk): distributed AST classification to language modules
- Distributed language-specific AST classification logic from defaults module to individual language modules for 15+ languages.
- Simplified defaults module to minimal catch-all fallbacks, removing 341 lines of match-based classification logic.
- Consolidated chunk edit operations by removing splice operation and unifying with line-scoped replace parameters.
- Simplified chunk rendering output format by reducing thresholds and changing line count display from 'lines' to 'ln' suffix.
- Removed PI_CHUNK_SPLICES environment variable and chunkSplicesEnabled conditional logic throughout codebase.
2026-04-06 20:52:07 +02:00
can1357 79e2f8b2b1 feat(coding-agent): introduced keyed union format for chunk operations
- Changed chunk edit operation format from flat `op` field to nested keyed union structure with operation name as object key.
- Added parseKeyedChunkOp() function to normalize both keyed and legacy flat operation formats for backward compatibility.
- Enhanced chunk selector sanitization with filename prefix stripping and case-insensitive CRC checksum matching.
- Updated chunk edit prompt documentation and test suite to reflect new nested operation JSON structure.
2026-04-06 18:50:08 +02:00
can1357 266aabf29f feat(autoresearch): enabled selective segment creation and working tree preservation in experiments
- Added `new_segment` parameter to `init_experiment` to force new segment creation when contract fields match.
- Added `skip_restore` parameter to `log_experiment` to preserve working tree state and pre-existing uncommitted changes.
- Changed `log_experiment` to revert only run-modified files instead of entire working tree, preserving user changes.
- Changed `init_experiment` to detect matching contract fields and skip re-initialization unless `new_segment=true`.
- Added git status parsing utilities to track pre-run dirty paths and distinguish tracked vs untracked modifications.
- Removed secondary metrics validation requirement, making secondary metrics informational only.
2026-04-06 18:49:52 +02:00
can1357 51467abc5a style(coding-agent): standardized indentation and added connection timeout to benchmark runner
- Fixed indentation and formatting across multiple files for consistency.
- Reformatted code blocks to use tabs instead of spaces and improved line breaks for readability.
- Added connection timeout configuration to benchmark runner for early abort on no events.
- Implemented two-phase timeout strategy in benchmark runner with connection and activity phases.
2026-04-06 18:45:41 +02:00
can1357 8718c62ea2 chore: update tests, lockfiles, and misc cleanups 2026-04-06 18:41:17 +02:00
can1357 3d292b0b49 refactor(autoresearch): overhaul tools, state management, and contract handling 2026-04-06 18:41:04 +02:00
can1357 03fd34de63 feat(edit): add chunk edit mode with syntax-aware chunk-addressed edits 2026-04-06 18:40:51 +02:00
can1357 b5dfbe28ac feat(natives): add TLA+/PlusCal and Handlebars language support 2026-04-06 18:40:45 +02:00
can1357 97e2acdf60 feat(lsp): added diagnostic versioning to suppress stale LSP results
- Added LSP diagnostic versioning support to track document versions and suppress stale diagnostics.
- Added options parameter to `waitForDiagnostics` and `getDiagnosticsForFile` with version filtering capabilities.
- Enabled `versionSupport` in LSP client capabilities to receive diagnostic version information from servers.
- Added test coverage for stale diagnostic suppression scenarios in LSP diagnostic freshness.
2026-04-06 01:16:26 +02:00
can1357 efbfa60517 fix(ci): restore Copilot 1M context and stabilize plan-role tests 2026-04-05 18:05:09 +02:00
can1357 3d29a48e7a fix(coding-agent): fixed memory leak by cancelling idle compaction
- Fixed memory leak by cancelling idle compaction timer on event controller disposal.
- Fixed session resumption to preserve last non-empty session when starting fresh.
- Fixed stash detection to use git ref resolution instead of output parsing for reliability.
- Fixed secret obfuscation to deobfuscate restored session messages locally while keeping LLM messages obfuscated.
- Fixed stash pop operation to preserve staged changes with --index flag after task branch merges.
- Changed idle compaction settings from enum to numeric type for flexible configuration.
2026-04-05 03:50:52 +02:00
Can Bölük 9b92461fa2 Merge pull request #610 from loftiskg/loftiskg/fix-plan-mode-thinking-level
fix(plan-mode): propagate thinking level when entering/exiting plan mode
2026-04-05 01:19:45 +02:00
can1357 511fddd8de revert: language-specific import management experiment
This reverts commit f044f3ba75.
2026-04-04 21:35:39 +02:00
can1357 db995107af chore: reformat 2026-04-04 16:10:34 +02:00
can1357 85d0d366c5 fix(coding-agent): resolved PR checkout worktree paths to canonical form
- Fixed PR checkout tool to resolve worktree paths to canonical form using fs.realpath().
- Refactored test mocks to use vi.spyOn for git module functions instead of inline implementations.
- Updated test setup to pass Settings.isolated() with edit.manageImports enabled to EditTool.
- Added afterEach hooks across test suites to restore mocks after each test execution.
2026-04-04 16:08:48 +02:00
Patrik Sundberg 4d641a52b4 feat(coding-agent): add session observer (Ctrl+S) to view subagent sessions
Wire EventBus through task runtime so subagent lifecycle and progress
events propagate to the TUI. Add SessionObserverRegistry to track
active sessions, and a session observer overlay accessible via Ctrl+S
that shows a picker of running subagents and a read-only transcript
viewer that reads the subagent's session JSONL file to display
thinking, text, tool calls, and results.

- Add TASK_SUBAGENT_LIFECYCLE_CHANNEL for start/end events
- Add SubagentProgressPayload.sessionFile for session file tracking
- Pass eventBus through sdk.ts -> main.ts -> InteractiveMode
- SessionObserverRegistry with multi-listener onChange pattern
- Overlay picker preserves selection position across live refreshes
- Viewer renders full transcript from session JSONL (thinking, text,
  tool calls with smart arg summaries, inline tool results)
2026-04-04 15:53:31 +02:00