Commit Graph

1134 Commits

Author SHA1 Message Date
can1357 8d144e17ec feat(coding-agent/eval): added local python-runner subprocess execution
- Replaced Python execution with a local `python -u runner.py` subprocess and NDJSON stdin/stdout framing.
- Removed shared-gateway architecture, including coordinator lifecycle APIs, `useSharedGateway` wiring, and `jupyter` CLI/actions.
- Simplified setup checks to a plain Python 3 availability probe and removed automatic dependency-install fallbacks.
- Updated kernel cancellation and display processing to use status frames, SIGINT/SIGTERM escalation, and normalized output coercion.
- Added `python-runner` integration and display tests while deleting legacy websocket and kernel lifecycle test suites.
2026-05-12 09:09:24 +02:00
can1357 dcf3f1c8a3 feat(coding-agent): added tool.<name>(args) execution in Python prelude
- Added `tool.<name>(args)` execution in Python prelude and docs, enabling direct tool call syntax.
- Added per-execution Python tool-bridge registration, env wiring, and executor lifecycle management.
- Implemented authenticated loopback `/v1/tool` handling with session/name validation and structured responses.
- Updated runtime and lint handling to permit controlled global eval usage in indirect eval paths.
- Added tests for success, failures, invalid bodies, and `emitStatus` propagation in Python tool bridges.
2026-05-12 08:43:36 +02:00
can1357 2f7b2aaccd feat(coding-agent/eval): stripped TypeScript syntax before import rewrites
- Added a stripTypeScript pass that heuristically detects TypeScript-like syntax and transpiles it with Bun's ts loader before rewriting.
- Integrated the new pass into wrapCode so import and lexical rewrites operate on transpiled input.
- Added an executeJs test that verifies interfaces, type annotations, and type assertions execute to the expected numeric result.
2026-05-12 08:42:52 +02:00
can1357 2d4d70e47e feat(coding-agent): added shared JS runtime for worker execution
- Added shared JS runtime infrastructure with RuntimeHooks, RuntimeOptions, JsRuntime, and indirectEval-based execution.
- Reworked worker execution to use runtime.run, track active runs, and clean pending tool calls on close.
- Added tool-call and tool-reply message variants and wired supervisor/worker to route run-scoped calls.
- Added shared helper globals (read, writeFile, diff, tree, env) for browser-tab JS execution.
2026-05-12 08:42:30 +02:00
can1357 efbaa59a05 fix(coding-agent): routed rewritten static imports through cwd-aware helper
- Rewrote static import lowering to emit `__omp_import__` calls instead of direct `import(...)` so rewritten code routes through worker context helpers.
- Added a `__omp_import__` runtime helper in `WorkerCore` that resolves specifiers against the session cwd via `Bun.resolveSync` while passing through URL-like modules unchanged.
- Updated static import rewrite tests to expect the new helper-based `__omp_import__` form, including import attribute cases.
2026-05-12 08:22:55 +02:00
can1357 95b29561c7 feat(history-storage): added substring fallback to search with FTS tokenization fix
- Fixed query tokenization to split on non-alphanumeric runs, aligning with FTS5 unicode61 indexer so punctuation-delimited terms like `git-commit` match correctly.
- Added LIKE-based substring fallback so infix queries FTS5 prefix matching cannot reach (e.g. `mit` matching `commit`) still return results.
- Merged FTS and substring results with deduplication, prioritizing FTS matches before substring-only matches up to the requested limit.
2026-05-12 08:22:46 +02:00
can1357 e3553b3211 test(coding-agent): align kNoAuth fallback test with #1008 behavior 2026-05-12 06:56:39 +02:00
Can Bölük 5dfe593828 Merge branch 'main' into fix/plugin-directory-extensions 2026-05-12 06:28:35 +02:00
Can Bölük 84c306f658 Merge pull request #1005 from tsagi2045/feat/ask-no-timeout-default
feat(coding-agent): default ask.timeout to 0 (wait indefinitely)
2026-05-12 06:27:38 +02:00
Can Bölük 66a9c483aa Merge branch 'main' into fix/windows-ssh-controlmaster 2026-05-12 06:24:23 +02:00
Can Bölük 7f94047453 Merge branch 'main' into fix/export-and-tree-support-developer-messages 2026-05-12 06:21:20 +02:00
can1357 9d2355d1cd fix(coding-agent): expose hasConfiguredAuth on ModelRegistry for external plugins (#993)
External plugins, extensions, and downstream wrappers (notably the upstream
`@mariozechner/pi-coding-agent` AgentSession routed through the legacy-pi-compat
shim) call `modelRegistry.hasConfiguredAuth(model)` before launching a subagent
to short-circuit when no API key is configured. Our `ModelRegistry` did not
expose that method, so the direct agent-launch path threw
`this._modelRegistry.hasConfiguredAuth is not a function` and exited with 0
tokens, 0 tool uses, ~100ms runtime — well before any model conversation began.
The `task` tool path bypassed the preflight and worked, masking the missing
API.

Add a thin `hasConfiguredAuth(model)` wrapper that returns true for keyless
providers and providers with stored auth, matching upstream semantics. Add a
focused regression test asserting the method exists and distinguishes
configured vs. unconfigured providers.

Fixes #993.
2026-05-12 06:20:58 +02:00
can1357 ebbe66a3d6 fix(coding-agent/browser): bundle tab-worker-entry for prebuilt binaries (#1011)
The Worker spawn in spawnTabWorker used `new Worker(new URL(...).href, ...)`
through a local variable, which Bun's --compile static analysis does not
recognize. As a result, tab-worker-entry.ts was never embedded in single-file
binaries (v14.5.13+), and the worker thread failed to load its entry at
/$bunfs/root/tab-worker-entry.ts, surfacing as the user-visible
"Timed out initializing browser tab worker".

Switch to a `with { type: "file" }` import of the entry module so the
bundler discovers and embeds it in both dev and compiled targets.

Regression test asserts `Bun.build` emits tab-worker-entry as an asset
alongside the tab-supervisor entry point — the same static-analysis pass
that powers `bun build --compile`.
2026-05-12 06:16:05 +02:00
can1357 9b687a6dc7 feat(coding-agent-tools): added date range filtering to issue/PR/commit/repo
- Added optional since/until/dateField parameters to issue, PR, commit, and repo search tools.
- Added parsing for relative and ISO date bounds and built inclusive/exclusive/range search qualifiers.
- Allowed issue/PR/commit/repo searches to proceed with only date ranges and no query string.
- Mapped tool-specific date fields (commits, repos) and rejected since/until for code search validation.
- Updated search tool docs and tests for date filter formats, mappings, and unsupported-code-search behavior.
2026-05-12 06:14:14 +02:00
can1357 ec649278bd fix(coding-agent): resolved async job owner filters for scoped cancelAll
- Added ownerId metadata to async jobs and to task/bash progress items from the session agent id.
- Extended async job registration and query methods with optional owner filters, and updated cancelAll to target matching owners.
- Updated session handoff and disposal so subagents inherit the parent manager, top-level sessions own it, and teardown cancels own jobs only.
- Added owner-aware async-job tests using hold/AbortSignal and scoped cancelAll assertions for running versus cancelled jobs.
2026-05-12 05:53:18 +02:00
can1357 a4d86a075a feat(coding-agent): added verbatim unicode rule to hashline prompt 2026-05-12 05:25:55 +02:00
can1357 1bde755933 feat(coding-agent): added global singletons for URL protocol handlers
- Added process-wide singleton instances for InternalUrlRouter, AsyncJobManager, and MCPManager.
- Changed internal URL protocols to resolve through registered sessions and scan all active roots/datasets for matches.
- Refactored agent, artifact, memory, rule, skill, jobs, and mcp handlers to use shared manager and rule/skill state.
- Removed per-session protocol/tool wiring and switched tests to initialize and reset global singleton state.
2026-05-12 05:07:52 +02:00
can1357 4623e7d3ea fix(coding-agent): marked streaming edit aggregates as errors when per-path edits fail
- Stored a failure counter during single-path edit execution and set isError on aggregate results when any entry edit failed.
- Set streaming-edit handling to always evaluate auto-generated-file checks, but only primed the file cache when edit.streamingAbort was enabled.
2026-05-12 04:44:38 +02:00
can1357 975941aba4 chore: remove garbage tests 2026-05-12 04:09:33 +02:00
can1357 2268fcc5bd feat(coding-agent/tools): surfaced display() outputs in eval tool responses
- Added helpers to stringify and truncate display() JSON values before including them in text responses.
- Updated eval execution to append formatted display output text alongside stdout and emit images as dedicated content blocks.
- Adjusted no-output messaging for image-only runs and removed detail-level image payload duplication when content already includes image blocks.
2026-05-12 03:23:47 +02:00
can1357 6d513c606f feat(coding-agent/modes): added timed expiry and cleanup for IRC chat messages
- Updated addMessageToChat in UI helpers and InteractiveModeContext to return rendered components instead of void.
- EventController now tracks IRC message components and removes them after a 10-second TTL, avoiding duplicate expiry scheduling per message signature.
- EventController dispose now clears all pending IRC expiry timers and tests were added for immediate render, TTL removal, duplicate suppression, and timer cleanup.
2026-05-12 03:11:49 +02:00
can1357 d186a1dafb refactor(coding-agent/prompts): moved system prompt constraints into project prompt
- Removed the shared date, workspace, and critical-response block from now-prompt.md.
- Added the same instructional block to project-prompt.md so the project prompt now carries those system constraints.
2026-05-12 03:11:21 +02:00
can1357 9bcbefb30e feat(coding-agent/edit): added hashline fallback preview for in-flight edits
- Added edit streaming fallback data to the edit render context and used it when no finalized patch text was available.
- Implemented hashline fallback rendering that strips envelope syntax, sanitizes text, and truncates output to a fixed number of lines with a streaming indicator.
- Updated tool execution to populate the fallback preview from the active edit strategy and added a renderer test for hashline envelope input while the diff is not yet computable.
2026-05-12 01:00:50 +02:00
David Marshall c8d4f22b59 fix(coding-agent): render developer-role messages in /export and /tree
The HTML export feed, sidebar tree, and TUI session tree did not handle
the developer role, so plan content injected after /plan approval (and
any other developer messages) was hidden from /export and shown as a
bare [developer] label in /tree.

Renders developer messages in the main feed with a dimmed
.developer-message style, labels them in the sidebar tree, counts them
in header stats, and shows their content in the TUI tree selector so
search matches the body.

Closes #753.

Co-Authored-By: omp <noreply@oh-my-pi.dev>
2026-05-11 10:42:17 -05:00
jiwangyihao 375ef060a7 fix(coding-agent): avoid SSH ControlMaster on Windows 2026-05-11 12:36:55 +08:00
Leo Kim 5c60e1c9f8 feat(coding-agent): default ask.timeout to 0 (wait indefinitely)
The 30 second default for 'ask.timeout' silently auto-selects the
recommended option mid-deliberation, which surprises users who are
weighing options the agent flagged as having materially different
tradeoffs. The setting was meant to be opt-in: 0 already means
'wait indefinitely' and plan mode already forces the timer off.

Flip the default to 0 so a fresh install matches the documented
'wait until the user replies' behavior, and update the AskTool
prompt so the model expects unlimited reply time by default. Users
who liked the auto-select can still set a positive timeout from
the Interaction settings tab.

Add a regression test asserting the dialog timeout is not passed
to the underlying selector when 'ask.timeout' is unset.
2026-05-11 10:54:09 +09:00
ephraimduncan 93420c5782 fix(coding-agent/plugins): resolve directory manifest extension entries to their index.{ts,js,mjs,cjs}
Plugin manifests that declare a directory entry (e.g. pi-goal's
`"pi": { "extensions": [".pi/extensions/pi-goal"] }`) were
pushed through to the legacy module loader unchanged. `Bun.file()`
on a directory throws "Directories cannot be read like files",
so every such plugin failed to load.

`resolvePluginPaths` now routes each joined manifest entry through
`resolveManifestEntryFile`, which:
- returns the path as-is when it is a file,
- returns the directory's `index.{ts,js,mjs,cjs}` when it is a
  directory containing one of those files,
- otherwise returns null (skip).

This mirrors the documented native auto-discovery behavior in
`resolveExtensionEntries` and the candidate list in
`extensibility/custom-commands/loader.ts`.

Closes #1001.
2026-05-11 00:05:00 +00: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 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 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 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 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 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 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 b989f57e66 chore: recording fix in changelog
Fixes #983
2026-05-10 04:55:43 +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 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 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
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 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
can1357 269a10bfb6 fix(lsp): updated diagnostics responses to display OK success state
- Updated LSP diagnostics output to return "OK" when no issues were found.
- Added a diagnostics-specific render case to show successful status and a success label for "OK" responses.
- Updated the regression test to expect the new "OK" diagnostics output.
2026-05-09 22:06:53 +02:00
can1357 af8504d081 feat(coding-agent/modes): converted non-PNG tool images to PNG for Kitty terminal rendering
- Added asynchronous Kitty conversion for assistant tool images using `convertToPng`, keyed per tool-call entry with cached and in-flight tracking.
- Updated assistant image rendering to prefer converted PNGs for Kitty terminals while preserving existing behavior for other protocols.
- Added a unit test that verifies WebP tool images are converted and rendered as Kitty image output instead of the raw image/webp fallback.
2026-05-09 22:01:56 +02:00
jiwangyihao a157b878f4 fix(plugins): 避免预解析动态相对导入 2026-05-10 03:35:46 +08:00