Commit Graph

4113 Commits

Author SHA1 Message Date
can1357 959cd42798 refactor(internal-urls): renamed embedded docs protocol from pi:// to omp://
- Renamed the internal URL protocol handler from `pi` to `omp` and updated the router export/import wiring to use `OmpProtocolHandler` with the `omp://` scheme.
- Updated embedded documentation link rendering and related validation/error messages in the protocol handler to reference `omp://` URLs.
- Adjusted tests and prompt/docs references so `read` examples and harness documentation guidance now use the renamed `omp://` scheme.
2026-05-16 18:52:04 +02:00
Can Bölük 2d96feb6c6 Merge pull request #1100 from h8hawk/fix/read-search-pipe-separator-prompt
fix(coding-agent): clarified pipe separator in read/search tool prompts
2026-05-16 18:22:00 +02:00
Can Bölük cb968ed5f7 Merge pull request #1114 from jiwangyihao/acp-cancel-cleanup-boundary
fix(coding-agent): bound ACP cancel cleanup
2026-05-16 18:18:57 +02:00
can1357 a40c5b1bee refactor(coding-agent): restructured ACP cancel cleanup slot management
- Replaced `finishCleanup` callback with `isPromptTurnInFlight` predicate to unify settled+cleanup gating.
- Extracted `#beginCancelCleanup` (idempotent) and `#runCancelCleanup` to clarify ownership of slot eviction.
- Fork, queue, and close paths now all gate on the combined settled+cleanup window.
2026-05-16 18:18:46 +02:00
Can Bölük 58505b8423 Merge pull request #1109 from itzrnvr/fix/windows-pty-hang-root-cause
fix: PTY hangs on Windows — ConPTY deadlocks waiting for cursor position
2026-05-16 18:09:28 +02:00
can1357 32453aaff0 feat(agent): added AgentTelemetry across compaction and branch-summary
- Added optional AgentTelemetry to summary, handoff, branch-summary, and compact option types.
- Replaced one-shot `completeSimple` usage with `instrumentedCompleteSimple` across compaction, summary, and branch-summary calls and passed `oneshotKind`.
- Added `PiGenAIAttr.OneshotKind`, `InstrumentedChatSpanOptions`, and response-header forwarding in telemetry span lifecycle.
- Added `resolveTelemetry` propagation in coding-agent session and inspect-image paths to pass request-scoped telemetry.
- Added compaction telemetry test harness and span assertions for success, no-telemetry, and error cases.
2026-05-16 18:03:07 +02:00
Can Bölük 3e073e9175 Merge pull request #1115 from kidonng/patch-1
fix(tools): remove mention of Claude in `web_search` tool prompt
2026-05-16 17:56:16 +02:00
Can Bölük 7dd2bb8ff5 Merge pull request #1117 from can1357/farm/f6994a71/agents-provider-dedupe-home-walkup
fix(discovery): stop agents provider from scanning ~/.agent[s]/ as project
2026-05-16 17:56:04 +02:00
can1357 e3a238c876 fix(coding-agent): collapse refine plan into editor return 2026-05-16 17:29:23 +02:00
roboomp d895f2223a fix(discovery): stop agents provider from scanning ~/.agent[s]/ as project
`getProjectPathCandidates` walks up from cwd to repoRoot (or home as a
fallback). When cwd is anywhere under $HOME and no closer .git boundary
exists, that walk-up reaches the home directory and enumerates
`~/.agent/<segments>` and `~/.agents/<segments>` as project paths.
`getUserPathCandidates` then enumerates the very same directories as
user paths, so every skill/rule/prompt/command/AGENTS.md found there
loaded twice. The capability deduper marks the second copy as shadowed,
but the Extension Dashboard renders shadowed entries — so users see one
active + one greyed-out duplicate of every home-level skill.

Skip the home directory inside the walk-up while still terminating the
loop on it; ancestors above home are still visited if the cwd happens
to live above (e.g. monorepo `home: tempDir` test fixtures).

Tests:
- Drop the duplicated copy of `getProjectPathCandidates` from the
  monorepo-skills test; import the real one so behavior stays in sync.
- Replace the old "walk-up stops at home when no repo root" assertion
  (which encoded the buggy behavior) with one that pins the new
  contract: home-level `.agent[s]/skills` are NOT enumerated as
  project paths.
- Add an explicit regression assertion that project ∩ user candidate
  sets are empty when cwd is under home.

Fixes #1116
2026-05-16 15:04:42 +00:00
jiwangyihao aaddf0631c fix(coding-agent): gate ACP close during cancel cleanup 2026-05-16 21:46:13 +08:00
Kid 49215eead6 fix(tools): remove mention of Claude in web_search tool prompt 2026-05-16 18:38:53 +08:00
jiwangyihao 66bf82123e fix(coding-agent): reject stale ACP cancel prompts 2026-05-16 13:27:48 +08:00
Sanskar Singh 158b00266b fix: pass configured shell to PTY instead of hardcoding sh
The PTY runner hardcoded CommandBuilder::new("sh"), but on Windows the
user's shell might be a Git Bash absolute path that isn't on PATH. The
non-PTY path already uses the resolved shell from getShellConfig(). Now
the PTY path does the same, passing it through PtyStartOptions.shell.
2026-05-16 10:10:59 +05:30
jiwangyihao 917535da2b fix(coding-agent): bound ACP cancel cleanup 2026-05-16 12:38:55 +08:00
Sanskar Singh cffc94a978 fix: prevent ClosePseudoConsole deadlock hanging PTY on Windows
ConPTY's ClosePseudoConsole can deadlock when it tries to flush output
to a pipe that nobody is reading (microsoft/terminal#1810). This caused
the PTY Promise to never resolve on Windows, making bash commands with
pty:true hang indefinitely.

Root cause: portable-pty's drop(master) calls ClosePseudoConsole
synchronously. If ConPTY's internal render thread is blocked writing to
a full/undrained output pipe, ClosePseudoConsole waits forever.

Fix (three parts):

1. Rust (pty.rs): Reordered teardown to follow Microsoft's recommended
   shutdown sequence:
   - Drop writer first (close ConPTY input pipe)
   - Drain reader thread with 500ms timeout (consume output pipe)
   - Drop master in a background thread with recv_timeout(2s):
     * Clean case: ClosePseudoConsole completes, thread reclaimed
     * Hung case: timeout expires, main thread returns anyway
   - Replace child.wait() with try_wait() polling on Windows
     (WaitForSingleObject can also hang in ConPTY)

2. TypeScript (bash-pty-selection.ts): Remove the Windows blanket
   disable that prevented PTY from ever being used on Windows.

3. Tests: Updated to verify PTY works on Windows with UI context.
2026-05-16 07:02:24 +05:30
Sanskar Singh 5d1a14e72a fix(coding-agent,pi-natives): Windows PTY hang root-cause fix with opt-out
Replaces the blanket PTY disable on Windows (PR #1105) with a targeted fix:

- TypeScript: PI_FORCE_PTY env var allows explicit Windows PTY opt-in.
  PTY is still disabled by default on Windows to prevent hangs, but power
  users who need interactive workflows can override.

- Rust: Adds ct.heartbeat() checks during PTY setup (openpty, spawn, reader
  creation) so the existing timeout mechanism works even during setup.

- Rust (Windows): Wraps openpty() in a 5-second startup timeout thread.
  If ConPTY hangs during pseudo-console creation, the Promise rejects with
  a clear error instead of hanging forever.

Fixes #1103 #1106
2026-05-16 05:03:23 +05:30
Can Bölük 8f66bc5ece Merge branch 'main' into ssh-refresh 2026-05-16 00:25:07 +02:00
Gerben Meijer 694f5e9a54 Refresh SSH hosts without restart 2026-05-16 00:20:00 +02:00
can1357 b39bb840cd fix(ai/utils): stripped explicit true additionalProperties in schema adaptation
- Added cycle-safe recursive schema traversal helpers to strip explicit `additionalProperties: true` entries from schema map objects.
- Preserved meaningful `additionalProperties: false` and schema-valued declarations while continuing to sanitize nested schema nodes.
- Updated package changelogs to list the strict tool planning and loose output schema fixes under the 15.1.2 release.
2026-05-16 00:14:26 +02:00
can1357 ece3c9d165 fix(ai): resolved tool strictness for loose additionalProperties schemas
- Preserved object schemas with explicit `additionalProperties` settings by avoiding strict coercion to false.
- Probed schema strictness before sanitization and set `tool.strict` false for non-strict schemas.
- Set `tool.strict` false for `null`, `true`, and unconstrained `outputSchema` fallbacks.
- Documented the fix in Unreleased changelog entries for both `ai` and `coding-agent` packages.
- Added regression tests covering loose `additionalProperties` and yield strictness behavior across tools.
2026-05-16 00:12:47 +02:00
can1357 3e1b4107d3 chore: bump version to 15.1.2 2026-05-15 23:48:01 +02:00
can1357 37d4314f2d chore(config): organized publish type mapping from src to dist/types
- Added declaration-only compiler options to multiple package publish tsconfig files.
- Standardized publish include/exclude settings to emit types from src into dist/types.
- Added manifest rewrite helpers to remap type paths from ./src to ./dist/types/*.d.ts.
- Updated publish flow to append dist/types/extra files and skip publish build/rewrite for native packages.
2026-05-15 23:46:23 +02:00
can1357 85515f35a6 fix(coding-agent): added gap separators between noncontiguous search matches
- SearchTool now tracked the last emitted line and inserted ellipsis markers when noncontiguous match blocks were output.
- Display output gap markers were padded to align with code-frame gutters.
- Added a regression test that verified a no-context search emits an ellipsis between separated matches in the same file.
2026-05-15 23:46:23 +02:00
can1357 7282d92bf4 fix: normalized line-ending handling for text and TUI output flows
- Unified line-ending normalization to `replace(/\r\n?/g, "\\n")` in editor, scraper, benchmark, and utils modules.
- Added terminal-aware line sanitization in code-cell rendering to collapse inline carriage returns and avoid overwrite corruption.
- Tightened editor and paste sanitizers to trim control characters consistently after CR normalization.
2026-05-15 23:46:23 +02:00
can1357 2e6d96d3bc feat(coding-agent/tools): added open-ended line range shorthand for read selectors
- Updated read-line selector parsing to accept line-range selectors ending with a trailing dash.
- Mapped selectors with a trailing dash to open-ended ranges that read from the start line onward without requiring an explicit end.
- Updated read tool documentation to document `:50-` as the shorthand for reading from line 50 onward.
2026-05-15 23:46:23 +02:00
can1357 0d00f015ec feat(ai): added 2020-12 schema migration to ai strict validation
- Added draft-07-to-2020-12 schema upgrade logic for `$schema`, `definitions`, `$ref`, tuple, and nullable mapping.
- Integrated `upgradeJsonSchemaTo202012` into strict adaptation, validation, strict-mode, sanitizer, and wire/dereference flows.
- Replaced set-based traversal helpers with record maps, `for...in` loops, and epoch/`once` cycle guards.
- Added unreleased changelog entries and tests for schema normalization, `oneOf` to `anyOf`, and tuple validation edge cases.
2026-05-15 23:46:23 +02:00
can1357 09303733d5 docs(coding-agent/prompts): added hashline restriction against code reformatting
- Updated the hashline prompt to state the tool should never be used for code reformatting tasks.
- Added guidance to run the project's formatter for whitespace, indentation, and style-only edits.
2026-05-15 23:46:23 +02:00
can1357 4b1a68570d fix(coding-agent/hashline): handled CRLF line endings in hashline parsing
- Replaced per-line carriage-return stripping with CRLF-aware line splitting in hashline input and parser paths.
- Adjusted payload collection to trim trailing whitespace from edit separator lines and handle line matching without extra normalization.
- Removed the now-unused hashline utils module and stopped exporting it from the hashline index barrel.
2026-05-15 23:46:23 +02:00
can1357 5c7c5eccb8 fix(ai): corrected AI schema normalization to draft-2020-12 prefixItems
- Adopted draft-2020-12 tuple validation with `prefixItems`, rejecting array-valued `items`.
- Expanded strict-mode handling to recurse `prefixItems` entries and infer `array` when tuple prefixes exist.
- Normalized Anthropic schemas through `prefixItems`, keeping supported tuple constraints and dropping unsupported fields.
- Updated coding-agent schema metadata and tests to draft-2020-12 `$schema` targets, including MCP/theme fixtures.
- Added `trimTrailingWhitespace()` to strip trailing spaces/tabs and keep the original line when none exist.
2026-05-15 23:46:23 +02:00
roboomp 13d77ad6ee fix(coding-agent): disable interactive pty on windows
Fixes #1103
2026-05-15 21:41:11 +00:00
can1357 0bfea39f3c chore: bump version to 15.1.1 2026-05-15 21:22:43 +02:00
can1357 2f2e72c5ac fix: updated metadata URLs and Bun WebSocket types
- Added homepage metadata entries to the Rust and Python package manifests.
- Replaced OpenRouter HTTP-Referer values with https://omp.sh/ in completion and image requests.
- Updated Codex WebSocket typing and construction to use Bun.WebSocket for handshake header capture.
Fixes #1102
2026-05-15 21:22:03 +02:00
can1357 06aadd08f2 chore: bump version to 15.1.0 2026-05-15 19:16:17 +02:00
can1357 37eed1bd33 fix(coding-agent): prevented startup scan timeout warning when work completed first
- Updated `raceWithDeadline` to track whether the timeout branch won the race before logging.
- Deferred the startup scan timeout warning until after the race completed with a deferred result.
2026-05-15 19:09:17 +02:00
can1357 8b1364d4c2 feat(coding-agent): implemented one-shot generateHandoff in coding-agent
- Replaced event-driven handoff with one-shot `generateHandoff(...)` via `completeSimple`.
- Added cancellable `/handoff` command handling with a loader and Escape-to-abort flow.
- Removed legacy `compaction/handoff.ts` exports and added `generateHandoff(messages, model, apiKey, options)`.
- Fixed pre-cancelled handoff behavior to return `Handoff cancelled` and propagate abort signals.
- Updated handoff tests/mocks to assert `generateHandoff` invocation details and `AgentSession.handoff()` options.
2026-05-15 18:49:53 +02:00
can1357 e1aaf78874 refactor(compaction): moved compaction APIs to @oh-my-pi/pi-agent-core
- Relocated compaction, branch-summarization, pruning, and utils from coding-agent to packages/agent/src/compaction.
- Moved OpenAI remote compaction helpers from packages/ai to the new compaction module.
- Added handoff.ts with extractHandoffDocument, createHandoffContext, and renderHandoffPrompt helpers.
- Exposed new entries.ts with standalone SessionEntry types so coding-agent no longer owns them.
2026-05-15 18:31:12 +02:00
can1357 03f09e7ee9 fix(coding-agent/tools): ignore literal refs when scanning yield schemas
YieldTool's unresolved-ref fallback now skips literal-value positions such as const, enum, default, and examples when looking for unresolved schema refs. Valid schemas containing data literals like { "": "literal" } no longer degrade to the loose schema and still reject invalid yield payloads.
2026-05-15 18:31:12 +02:00
can1357 88e5e8a9a2 fix(coding-agent/task): make subagent runtime timeout sticky and abortable through setup
- Runtime-limit timeout is now tracked with a sticky runtimeLimitExceeded flag, so later caller aborts during teardown cannot downgrade the timeout state and let a late yield report success.
- Awaited setup operations before the first prompt are now raced against the subagent abort signal, including auth discovery, model refresh, model resolution, session open, session creation, extension session_start, prompt, and waitForIdle.
2026-05-15 18:31:12 +02:00
can1357 188711b858 fix(coding-agent/eval): close remaining Python dispose races
- disposeAllKernelSessions removes sessions from the registry before awaiting shutdown, preventing queued work from seeing a registered-but-disposing session and spawning a replacement kernel.
- replaceSessionKernel re-checks registry membership after old-kernel shutdown and after starting a replacement, shutting the replacement down if the session was disposed mid-replace.
- owner-scoped disposal now preserves ownerIds when shutdown is unconfirmed so a later disposeKernelSessionsByOwner(ownerId) can retry.
2026-05-15 18:31:12 +02:00
can1357 110a6a3244 fix(coding-agent): persisted bindings from async-wrapped cells via globalThis publish
- Detected async wrapper need via AST traversal instead of regex, enabling pre-demote analysis.
- Published demoted var bindings back to `this` (worker global) when inside the async wrapper, preventing function-scope from hiding them across cells.
- Added `collectBindingNames`/`getLexicalBindingNames` to extract names from destructured patterns.
2026-05-15 18:31:12 +02:00
can1357 ef72d90f2b fix(coding-agent/extensibility): restored TypeBox shim string-format and additionalProperties parity
- Type.String({ format, minLength, maxLength, pattern }) no longer drops the length/pattern constraints when a format selects a Zod format-specific schema (z.email, z.url, z.uuid, …). The instanceof z.ZodString guard never matched those subclasses; constraints are now applied via the shared _ZodString base so all format variants honor them.
- Type.Object without explicit additionalProperties now installs .loose() (matching TypeBox's preserve-extras default) instead of stripping unknown keys. additionalProperties: false continues to install .strict(); a schema value installs .catchall(schemaToZod(schema)).
2026-05-15 17:49:35 +02:00
can1357 46cff37ce4 fix(coding-agent/tools): yield falls back to loose schema on unresolved $ref
dereferenceJsonSchema leaves $ref strings in place when references are unresolvable (external URLs, missing definitions, certain cycles). The new yield-parameters builder now walks the resolved schema for any remaining $ref strings before installing validation; if any are found, it throws so the existing catch branch swaps in looseRecordSchema and disables strict validation. Previously YieldTool installed a validator that rejected every success payload with an unresolved-reference error.
2026-05-15 17:49:23 +02:00
can1357 b489200933 fix(coding-agent/modes): gated scratch folder icon on stripWorkPrefix
The status-line path segment was selecting theme.icon.scratchFolder for scratch directories regardless of opts.stripWorkPrefix, while the CHANGELOG promised both behaviors honor the option. Icon selection now uses the same opts.stripWorkPrefix !== false gate as the scratch path stripping, so disabling stripWorkPrefix keeps the regular folder icon even when the project directory is inside a scratch root.
2026-05-15 17:49:14 +02:00
can1357 c4672f11af fix(coding-agent/task): plugged wall-clock timer holes and propagated context stats
- Added defensive abort re-check after registering the abortSignal listener plus a checkAbort() immediately before await session.prompt(...), so a wall-clock timer that fires during pre-prompt setup is no longer lost between listener registration and the prompt call.
- Late yield events arriving after a wall-clock timeout no longer flip the result to success: a runtimeLimitExceeded flag derived from the internal abortReason forces wasAborted=true and exitCode=1 regardless of hasYield, while yield payloads remain captured in extractedToolData.
- Async task progress now copies contextTokens and contextWindow from the completed SingleResult onto AgentProgress, so backgrounded tasks still surface their context gauge to the UI.
2026-05-15 17:49:00 +02:00
can1357 dad6149393 fix(coding-agent/eval): fenced disposed Python sessions from queued work
- executeOnSession's runQueued callback now re-checks sessions.get(sessionId) === session at slot entry and before the dead-kernel replace retry; if the session was removed by disposeAllKernelSessions / disposeKernelSessionsByOwner / resetSession during the queue wait, the queued caller now rejects with PythonExecutionCancelledError instead of spawning an untracked replacement kernel on a stale session object.
- Both dispose paths now inspect KernelShutdownResult.confirmed and retain (or re-insert) sessions whose shutdown was unconfirmed or rejected, logging a warn so a later dispose can retry the kernel instead of orphaning the subprocess.
2026-05-15 17:48:36 +02:00
can1357 9ca04c9e8c fix(ai): preserved custom tool calls and threaded abort signal in remote compaction
- buildOpenAiNativeHistory now emits custom_tool_call / custom_tool_call_output for blocks with customWireName (apply_patch and other freeform tools), matching the normal Responses replay path; previously demoted to function_call which broke remote-compaction replay or mismatched the original call.
- requestOpenAiRemoteCompaction and requestRemoteCompaction accept an optional AbortSignal; the coding-agent compaction caller forwards the existing signal so cancellation now terminates the in-flight fetch instead of stranding the session in the compacting state until the server replies.
2026-05-15 17:47:32 +02:00
h8hawk b5e8b77417 fix(coding-agent): clarified pipe separator in read/search tool prompts
- Added note to read tool prompt that the pipe after the hashline anchor is a
  separator, not part of the file content.
- Added note to search tool prompt that the pipe before content is a separator.
2026-05-15 19:13:06 +03:30
can1357 7c9641c27a fix(coding-agent): cast validated bash args to BashToolInput in test 2026-05-15 17:01:51 +02:00
can1357 35beac2972 fix(coding-agent): defer persist when writer is mid-close
`SessionManager.close()` queues `#closePersistWriterInternal()` on the
persist chain. The task awaits `#persistWriter.close()`, which flips
`#closing = true` synchronously before yielding on its inner writer
`close()`. A concurrent `appendMessage()` landing in that yield window
hit the hot path, got the still-cached (but closing) writer back from
`#ensurePersistWriter()`, and threw `Error("Writer closed")` from
`writeSync`. The throw was stashed into `#persistError`; the next async
caller (`flush()` or a later `appendMessage()`) re-threw it as an
unhandled rejection with the original line-1282 stack.

Expose `NdjsonFileWriter.isOpen()` and treat a mid-close cached writer
as a miss in `#ensurePersistWriter()`. `_persist` now falls back to the
async `#rewriteFile()` cold path so the entry — already in
`#fileEntries` — still lands on disk once the close drains.
2026-05-15 17:00:18 +02:00