Commit Graph

5081 Commits

Author SHA1 Message Date
can1357 cd78eabb6a fix(coding-agent/tools): restricted IRC tool availability for main agent in sync mode
- Updated `irc` tool availability logic to require both `irc` settings and concurrency support.
- Imported `MAIN_AGENT_ID` and suppressed IRC access for the main agent when async mode is disabled, preventing sync-mode peer messaging.
2026-05-10 21:46:16 +02:00
can1357 e82ce532b0 fix(coding-agent): registered agents before system prompt rebuild
- Pre-registered agents in the global registry before rebuilding the system prompt so peers can discover each other in initial IRC blocks.
- Replaced immediate registry replacement with attachSession to bind the live session and latest sessionFile to the pre-registered entry.
- Ensured pre-registered agents are unregistered during creation failure cleanup when no session was established.
2026-05-10 21:46:01 +02:00
can1357 1721f34a41 refactor(coding-agent): migrated system prompt templates to bracket-based tag markers
- Replaced project, subagent, and system prompt templates to use bracket-style `[TAG]...[/TAG]` markers instead of `<|START_*|>`/`<|END_*|>` markers.
- Updated system-prompt and subagent reminder tests to assert the new bracket tag format for role, context, and contract blocks.
- Added an Unreleased changelog entry for the subagent batch registry initialization behavior.
2026-05-10 21:45:11 +02:00
can1357 4976fa7b9e chore: bump version to 14.9.3 2026-05-10 20:31:48 +02:00
can1357 0f37afed1e chore: reformat 2026-05-10 20:31:26 +02:00
Can Bölük 7afea8c38b Merge pull request #996 from apoc/fix/format-prompts-windows-path
fix(scripts): use import.meta.dir instead of URL.pathname for Windows compatibility
2026-05-10 20:30:55 +02:00
can1357 8b92ec937e feat: gpt-5 harmony errata fixes
- Replaced `===== ... =====` eval cell headers with `*** Begin ` / `*** End ` markers; legacy format remains renderable in HTML exports.
- Replaced hashline patch grammar with `*** Begin Patch` / `*** End Patch` envelope; old inputs without the envelope are still accepted.
- Extracted `sniffEvalLanguage` into a shared `sniff.ts` module reused by the parser and tool.
- Added `docs/ERRATA-GPT5-HARMONY.md` and `scripts/session-stats/harmony_backtest.py` documenting and backtesting the GPT-5 Harmony-header leak defect.
2026-05-10 19:52:44 +02:00
can1357 f19d206fa5 refactor(coding-agent): removed head/tail params and bash-normalize module
- Deleted `bash-normalize.ts` and its tests; output truncation is handled by the streaming tail buffer and artifact spillover.
- Removed `head`/`tail` schema fields from `bashSchema` and `BashToolInput`.
- Updated system prompt and bash tool prompt to forbid `| head`/`| tail` pipes and other anti-patterns, directing the agent to use dedicated tools instead.
2026-05-10 19:34:51 +02:00
can1357 4e0ca3c0e6 fix(ai/providers): expanded retryable error handling for Anthropic provider
- Expanded retry detection in the Anthropic provider to include an isRetryableError fallback after existing pattern checks.
- Imported the shared retry helper and returned true when generic retryable errors were matched.
2026-05-10 19:34:33 +02:00
Can Bölük dff01135a0 Merge pull request #809 from apoc/fix/irc-poll-teardown-guard
fix(irc): stop background exchange poll loop on session dispose
2026-05-10 19:34:27 +02:00
Miroslav Drbal a878665de9 fix(irc): stop background exchange poll loop on session dispose
The 50ms retry loop in #scheduleBackgroundExchangeFlush had no guard
against session teardown. If dispose() was called while streaming,
the setTimeout callbacks kept firing and attempted emitExternalEvent
on a disconnected agent.

- Add #isDisposed flag; set it at the top of dispose() before any
  async teardown so poll ticks that fire mid-teardown bail out cleanly
- Clear #pendingBackgroundExchanges in dispose() to drop queued
  messages that will never be rendered
- Widen the attempt() bail condition to include #isDisposed so the
  loop terminates even if new messages arrived between the dispose()
  clear and the next tick
2026-05-10 17:52:26 +02:00
Miroslav Drbal edb1e171e5 fix(scripts): use import.meta.dir instead of URL.pathname for Windows compatibility
new URL(...).pathname returns a POSIX-style /D:/... path on Windows, which
is not a valid filesystem path. import.meta.dir gives the correct native path
on all platforms.
2026-05-10 16:51:14 +02:00
can1357 8cc1aba65f fix(coding-agent): applied immutable metadata to internal URL resolution
- Added immutable metadata to protocol handlers and had the router copy each handler's setting onto resolved internal resources.
- Updated read and search tools to honor `resource.immutable`, and made search suppress hashline anchors only for immutable source paths while preserving them for mutable files.
- Expanded internal URL tests to cover mutable local resources and mixed immutable/mutable search input hashline behavior.
2026-05-10 12:46:05 +02:00
can1357 32e1b41889 feat(coding-agent): added prompt markers to system prompt assembly
- Added explicit prompt markers and wrappers across system templates, including `[env]`, `[role]`, `[coop]`, `[closure]`, and `[now]`.
- Removed `renderTemplate` and `sectionSeparator` flows, deleted `task/template.ts`, and switched to per-task `renderSubagentUserPrompt` rendering.
- Updated system prompt assembly to `shortenPath`-normalize `cwd`, append rendered now metadata, and preserve trailing `[now]` blocks.
- Removed legacy template tests and added prompt-composition tests for ordered `[contract]`->`[project]`->`[now]` blocks and context-only system placement.
- Reworked shared prompt utilities by collapsing consecutive blank lines and removing obsolete `OPENING_HBS`/`LIST_ITEM` helper behavior.
2026-05-10 12:27:45 +02:00
can1357 f1d01fa14e refactor(coding-agent/hashline): removed special structural-line hash path
- Removed the brace-only structural bigram helper path from the line hash logic.
- Punctuation-only lines now follow the non-significant-character path using index-seeded xxHash hashing for their hash.
- Updated the hashline line-hash comment to describe that non-significant lines use the line-number-seeded seed.
2026-05-10 12:14:16 +02:00
can1357 2cccc7d326 feat(coding-agent/tools): added compound read selectors combining line ranges and raw output
- Extended splitPathAndSel to detect compound selectors that combine a line range with `raw` in either order.
- Updated read selector parsing to support `:lines:raw` and `:raw:lines` selectors and propagate raw-mode handling through internal URL, archive, and notebook paths.
- Added tests covering compound selector syntax and confirming it returns verbatim content without anchors or line-number prefixes.
2026-05-10 09:45:10 +02:00
can1357 1c77a28b85 feat(export): added collapsible HTML tool-header chips for intent metadata
- Added a collapsible tools header with chips and intent metadata styles in HTML exports.
- Added eval tool support with cell-level parsing and inferred language syntax highlighting.
- Added dedicated renderers for search, recipe, and irc tool calls and separated `_i` intent from tool args.
- Enhanced edit, ast_edit, find, search, and gh renderers with richer headers, fields, and option badges.
- Changed power-assertion state so assertions were prompt-scoped and no longer blocked after aborts.
2026-05-10 09:44:17 +02:00
can1357 67120478d8 fix(coding-agent): disabled hashline anchors for immutable sources
- Extended file-display resolution to accept an immutable flag and suppress hashline anchors when immutable sources are requested.
- Plumbed immutable propagation through ReadTool and SearchTool so internal URL reads and searches pass that context.
- Added a regression test confirming artifact:// search output no longer includes hashline anchors.
2026-05-10 09:39:42 +02:00
can1357 a410ac18d6 feat: added macOS power assertion schema and begin/end/reset handling
- Added macOS power assertion settings for idle, system, user, and display with schema defaults.
- Added idle, system, and user options to MacOSPowerAssertionOptions in TS typings and Rust, preserving display.
- Changed agent-session power flow to use begin/end/reset in-flight helpers and avoid manual counter updates.
- Updated power assertions to combine multiple kinds per native handle and support safe repeated-stop behavior.
- Updated unreleased changelog notes to document the breaking behavior and canceled-prompt unblock correction.
2026-05-10 09:24:08 +02:00
can1357 d25942da2a chore: bump version to 14.9.2 2026-05-10 08:01:16 +02:00
can1357 2e46257e9e feat: added listWorkspace binding and moved AGENTS.md lookup into tree
- Added `listWorkspace` native binding and API types, exporting bounded workspace trees with AGENTS.md candidates.
- Reworked `buildWorkspaceTree` and `buildDirectoryTree` to call `listWorkspace` with 5s timeout defaults.
- Replaced startup AGENTS.md discovery with workspace-tree-only scanning and removed legacy AgentsMdSearch session plumbing.
- Updated `WorkspaceTree` and system prompt context to expose `agentsMdFiles` and aligned tests/changelog expectations.
2026-05-10 07:59:53 +02:00
can1357 2ae3a4b111 refactor(hashline): removed inline modify edit kind
- Dropped the `modify` edit type and its `< ANCHORTEXT` / `+ ANCHORTEXT` syntax.
- Removed associated parser rules, regex patterns, apply logic, and tests.
- Deleted the "Append WITHIN a line" example from the prompt docs.
2026-05-10 07:56:29 +02:00
can1357 3ae1d1a8dc fix(coding-agent-extensibility): patched extension handler timeout logic
- Added a 30s timeout for extension handlers in runner.ts so stalled callbacks now emit warnings and stop.
- Consolidated duplicated extension handler error handling by routing calls through #runHandlerWithTimeout.
2026-05-10 07:46:01 +02:00
can1357 7dec6953ac fix(coding-agent/task): skipped refreshing modelRegistry when inherited from parent
- Introduced a flag to detect when an explicit modelRegistry was supplied to runSubprocess.
- Skipped modelRegistry.refresh() when reusing the parent registry and retained refresh when creating a new one.
- Added a debug log to indicate when a parent modelRegistry is reused and refresh is bypassed.
2026-05-10 07:19:26 +02:00
can1357 4a6c56772f fix(coding-agent/mcp): fixed SSE parsing by draining the stream in a single pass
- Refactored SSE response parsing to read the stream with a single in-progress drain loop.
- Resolved the matching request promise when the expected JSON-RPC result or error arrives and continued dispatching remaining SSE messages on the same stream.
- Adjusted error handling to reject on abort/timeout or missing response and clear the timeout when stream parsing completes.
2026-05-10 06:47:19 +02:00
can1357 5d830a5453 fix(task): fixed task renderer handling of missing tasks arrays during streaming
- Updated task call rendering to use `args.tasks?.length ?? 0` when displaying agent counts.
- Prevented runtime warnings in streaming task calls when the `tasks` array was still undefined.
2026-05-10 06:45:02 +02:00
can1357 b1a898f18c docs(coding-agent/prompts): documented anchor behavior for stacked patch edit operations
- Updated the hashline prompt to clarify that anchors must use the file state from the most recent read.
- Added guidance warning not to renumber line references when stacking multiple patch operations.
2026-05-10 06:34:15 +02:00
can1357 e973081a13 chore: bump version to 14.9.1 2026-05-10 05:31:37 +02:00
can1357 4388bb9845 fix(ai/providers): used provider error messages for aborted stream terminations
- Anthropic streaming now populated output.errorMessage from refusal stop_details, including category and explanation when available.
- Stream handlers for Bedrock, Azure OpenAI, Google, Google Vertex, Google Gemini CLI, and OpenAI now threw output.errorMessage when stopReason indicated aborted or error instead of a generic unknown message.
2026-05-10 05:31:25 +02:00
can1357 b12bb9653e chore: bump version to 14.9.0 2026-05-10 05:18:32 +02:00
can1357 e17e64004d fix(coding-agent/task): fall back to parent active model when subagent model has no auth
Reporter screenshot showed a parent session on DeepSeek V4 Pro dispatching
a task subagent that resolved to `qwen3.6-plus-free` — an opencode-zen
model the user had no working credentials for. The dispatch hit a
provider that could not serve the model and surfaced a confusing API
rejection instead of using the parent's already-authenticated model.

Adds `resolveModelOverrideWithAuthFallback`, an auth-aware wrapper
around `resolveModelOverride` that checks the resolved subagent model's
credentials via `modelRegistry.getApiKey` + `isAuthenticated` and
falls back to the parent session's active model pattern when the
primary has no working auth. The parent's active model is plumbed
through `ExecutorOptions.parentActiveModelPattern` from `TaskTool`
into `runSubprocess`. If neither has working auth (or they resolve to
the same model), the primary resolution is preserved so the existing
error path still surfaces a meaningful failure downstream.

Fixes #985
2026-05-10 05:17:39 +02:00
can1357 f74120b2b7 fix(coding-agent): strict provider routing + compaction auth fallback
- Model resolver: provider-prefixed `<provider>/<id>` selectors are now
  strict. If the provider is known and the exact pair does not resolve,
  return undefined instead of silently crossing provider boundaries
  (e.g. routing `anthropic/claude-3-7-sonnet` to amazon-bedrock when
  the user only has Anthropic auth). Unqualified resolution is unchanged.

- Compaction: when the current model's provider has no credentials,
  manual compaction now retries across compaction model candidates and
  falls back to an authenticated role; if no usable fallback exists, it
  throws a clear provider-specific pre-stream error instead of bubbling
  a 503 `auth_unavailable` from the provider stream.

Fixes #986
Fixes #980
2026-05-10 05:09:29 +02:00
can1357 0507cf1ba3 fix(ai): replaced silent image drop with placeholder for non-vision models
- Image blocks sent to models without vision support now emit `[image omitted: model does not support vision]` instead of being silently dropped, preventing opaque 404 errors.
- Fix applies to user messages and tool-result payloads across Anthropic, OpenAI completions/responses, Codex, and Google providers.
- Extracted shared `vision-guard.ts` with `partitionVisionContent`, `joinTextWithImagePlaceholder`, and `NON_VISION_IMAGE_PLACEHOLDER`.
- Added regression tests covering all five provider paths.

Fixes #967
Fixes #968
2026-05-10 05:01:52 +02:00
can1357 b989f57e66 chore: recording fix in changelog
Fixes #983
2026-05-10 04:55:43 +02:00
can1357 ce0b545147 chore: reformat 2026-05-10 04:54:07 +02:00
can1357 f10349a2f9 tweak(welcome): slim logo, diagonal gradient
- Trim logo from 14w to 12w (2-wide legs).
- Diagonal BL→TR gradient instead of per-line LTR.
- Truecolor: 3-stop magenta→violet→cyan path that skips the deep-blue valley.
- 256-color: same 6-stop ramp as fallback.
- Compute the colored logo once at module load instead of per render.
2026-05-10 04:53:53 +02:00
can1357 9f386dd6e5 feat(ai,coding-agent): raw SSE diagnostics + steady-state idle watchdog
Adds an opt-in onSseEvent callback across HTTP-streaming providers (Anthropic, OpenAI Responses/Completions, Azure OpenAI Responses, OpenAI Codex SSE, Google Gemini CLI, GitLab Duo, Kimi, Synthetic) so callers can inspect raw SSE frames without altering parsed output. Provider fetch wrapping only tees response bodies when an observer is wired; standalone packages/ai consumers without onSseEvent are not penalized.

Adds streamIdleTimeoutMs (env: PI_STREAM_IDLE_TIMEOUT_MS, with PI_OPENAI_STREAM_IDLE_TIMEOUT_MS as a backward-compatible alias). Anthropic now enforces a steady-state idle watchdog (default 120s) in addition to the first-event watchdog. OpenAI Responses, Azure Responses, and Codex (SSE + WebSocket) gain a semantic-progress predicate so response.in_progress-style keepalives no longer keep stalled tool calls alive forever.

Adds a coding-agent debug-panel raw SSE viewer backed by a per-session bounded buffer (1000 records / 512KB) that AgentSession populates unconditionally so users can post-hoc inspect a stuck stream from the TUI.
2026-05-10 04:53:41 +02:00
can1357 0cf851658e fix(coding-agent): required explicit hashline ranges for single-line delete and replace
- Updated the hashline grammar to require a full `LID .. LID` range for block operations.
- Enhanced `parseRange` to reject single-anchor syntax and malformed ranges, and to require duplicated anchors for one-line edits.
- Reworked hashline prompt examples/tests accordingly and added coverage for single-anchor delete/replace forms.
2026-05-10 04:53:41 +02:00
Can Bölük 57c4c23811 Merge pull request #991 from dmarsh-gusto/feat/auth-credential-disabled-hook
feat(ai): emit onCredentialDisabled hook from AuthStorage
2026-05-10 04:53:35 +02:00
Can Bölük f5430220ce Merge branch 'main' into feat/auth-credential-disabled-hook 2026-05-10 04:53:27 +02:00
Can Bölük 3308fcbf03 Merge pull request #987 from apoc/feat/rpc-login-commands
feat(rpc): add get_login_providers and login commands
2026-05-10 04:52:52 +02:00
Can Bölük b0e70330f8 Merge pull request #988 from apoc/fix/reviewer-cross-boundary-tracing
fix(reviewer): add cross-boundary dispatch tracing obligation
2026-05-10 04:52:39 +02:00
Can Bölük 9394a169fc Merge pull request #990 from jiwangyihao/fix/windows-legacy-pi-loader
fix(plugins): load legacy Pi extensions with Windows-safe paths
2026-05-10 04:50:24 +02:00
Can Bölük 7e106c2383 Merge pull request #971 from apoc/fix/anthropic-session-id-cloaking
fix(ai): stable metadata user_id per session to prevent session count inflation
2026-05-10 04:46:18 +02:00
Can Bölük c0990c9180 Merge pull request #979 from bjin/fix/plan-review-resubmit-rendering
fix(coding-agent): append plan review previews on resubmit
2026-05-10 04:45:51 +02:00
David Marshall 6a7d3f75fe feat(ai): emit onCredentialDisabled hook from AuthStorage
Adds an optional onCredentialDisabled callback to AuthStorage so callers
can react when a credential is soft-disabled (e.g. OAuth refresh fails
with invalid_grant). Handler exceptions are caught and logged so the
disable path always completes.

Includes tests covering: definitive refresh failures fire the event,
transient failures don't, and a throwing handler still lets the
credential get disabled.

Co-Authored-By: omp <noreply@oh-my-pi.dev>
2026-05-09 17:05:29 -05:00
can1357 1802de9c0a fix(coding-agent): resolved eval context import rewrite via Babel AST
- Replaced regex-based import rewriting in `rewriteStaticImports` with Babel AST parsing.
- Handled default, namespace, named, and side-effect imports, preserving `import ... with` options.
- Returned original source on no top-level imports, parse failures, or unchanged non-import regions.
- Added `@babel/parser` dependency and tests/changelog coverage for top-level static-import rewrite behavior.
2026-05-09 23:10:15 +02:00
can1357 85003caaaf feat(coding-agent): added hashline entrypoint and redirected callers
- Added `./hashline` package exports and redirected callers to the new hashline entrypoint.
- Moved hashline logic out of `edit/` to `src/hashline` and removed `edit/modes/hashline`/`edit/line-hash` paths.
- Added hashline parsers, anchors, types, and diff helpers with stricter input and mismatch validation.
- Implemented preflight and cache-recovery execution flows to reapply edits and handle stale anchor mismatches.
- Documented the hashline API relocation as breaking changes in `CHANGELOG.md`.
2026-05-09 23:10:02 +02:00
can1357 0a24c5a892 docs(coding-agent/prompts): expanded hashline guidance for self-contained multiline replacements
- Clarified the hashline guidance to select a self-contained syntactic unit before narrowing the edit operation.
- Added a multiline destructuring/call example showing the full construct replacement pattern and safer alternatives.
- Updated anti-pattern instructions to reject partial-boundary replacement payloads and continuation-fragment edits.
2026-05-09 23:09:45 +02:00
can1357 cbdd8a65e5 fix(coding-agent/edit): removed anchor auto-rebase during hashline mismatch validation
- Removed hashline anchor auto-rebase logic, including the ±5-line rebase window and `tryRebaseAnchor` fallback.
- Validation now reports hash mismatches directly as hard `HashMismatch` entries and surfaces them via `HashlineMismatchError` without mutating anchor lines.
- Updated the changelog to document anchor auto-rebase removal and the immediate re-read recovery behavior.
2026-05-09 23:09:45 +02:00