Commit Graph

143 Commits

Author SHA1 Message Date
can1357 e9888367d1 refactor: migrated packages to internal utility modules and removed external dependencies
- Implemented in-house, zero-dependency utility modules in `pi-utils` covering DOM manipulation, markdown parsing, templating, browser automation helpers, and terminal buffers.
- Migrated packages across the repository to consume the new internal utilities and `omptype` schema validators instead of external dependencies.
- Removed multiple external runtime and development dependencies including Zod, Marked, LRU cache, Turndown, and Puppeteer browser packages.
2026-08-05 13:39:09 +02:00
roboomp 2cfaa7adbc fix(coding-agent): restored legacy convertToPng export
- Restored the package-root image conversion contract through the legacy compatibility shim.

- Covered PNG passthrough, image conversion, and decoder failure behavior.

Fixes #7610
2026-08-04 07:31:16 +00:00
can1357 bc39ffa265 feat: introduced omptype validation package and migrated workspace dependencies
- Introduce `@oh-my-pi/omptype` as a new ArkType-compatible schema validation package featuring a lazy JIT runtime, JSON Schema emission, and compatibility adapters.
- Replace `arktype` across workspace packages and test utilities with `@oh-my-pi/omptype`.
- Add benchmark suites, tests, and documentation for the new validation engine and adapters.
- Update workspace build, test runner, and release configurations to include the new package.
2026-08-03 21:56:48 +02:00
can1357 0244e18e43 fix(extensions): refreshed formerly synchronous sources on reload walks
- A reload that drops a module's last require() edge leaves the permanent
  hooks serving it from the synchronous snapshot map, which was only
  refreshed while the path stayed flagged; an edit after the downgrade
  replayed stale bytes. Ensure now re-rewrites and refreshes the snapshot
  for every ever-synchronous path on each graph walk.
- Added the mirror reload regression (require edge dropped + source edited).
2026-08-03 05:42:07 +02:00
can1357 e1ac59e5df fix(extensions): served sync-upgraded modules from earlier async load hooks
- A reload that adds a require() edge to an already-hooked ESM module never
  re-registers hooks, and the original async onLoad filter keeps matching;
  require() rejects async onLoad results, so the async hook now serves the
  pre-rewritten synchronous source inline when one exists.
- Added a same-process reload regression covering the async-to-sync upgrade.
2026-08-03 05:33:06 +02:00
can1357 c83bff390d Merge PR #7406: fix(coding-agent): restore legacy compaction exports (@roboomp) 2026-08-03 05:26:10 +02:00
roboomp b53b1d1e65 fix(extensions): rewalked sync-upgraded ESM graphs
Requeued already-processed ESM modules when a later CommonJS require upgraded them to synchronous loading, propagating the sync marker through their descendants.

Added an end-to-end regression covering normal discovery before a lazy CommonJS require of the same ESM graph.

Fixes #7402
2026-08-02 22:17:59 +00:00
roboomp 326fee3387 fix(coding-agent): preserved legacy simple stream options
- Routed streamSimpleOpenAIResponses through the central simple-stream dispatcher.
- Added wire-level coverage for hidden reasoning summary translation.

Fixes #7403
2026-08-02 22:15:12 +00:00
roboomp fb62feeecf fix(extensions): retained lazy ESM sources
Kept pre-rewritten synchronous ESM sources available to permanent load hooks after the initial extension import settles, while refreshing them on reload.

Added an end-to-end regression for a CommonJS dependency that lazily requires a nested ESM cluster.

Fixes #7402
2026-08-02 22:09:44 +00:00
roboomp c34c2830ce fix(coding-agent): restored legacy compaction shims
- Re-exported serializeConversation from the legacy coding-agent package root.
- Aliased the upstream simple OpenAI Responses stream name to OMPs equivalent.
- Added regression coverage for both compatibility exports.

Fixes #7403
2026-08-02 22:03:20 +00:00
roboomp e682e25b24 fix(extensions): resolved compiled dependency graphs
Resolved nested ESM imports required by CommonJS packages, deterministic dual-package graph convergence, and package-main directory requires in compiled binaries.

Added focused graph-rewrite regressions and documented the fix.

Fixes #7402
2026-08-02 22:02:44 +00:00
can1357 be834905a6 test(extensions): tighten nested wildcard coverage 2026-08-01 20:13:39 +02:00
Harsha Vardhan 98f0c58224 fix(extensions): bundle nested wildcard export subpaths for compiled binaries
The compiled registry enumerated each `exports` wildcard with a single-level
glob and explicitly skipped any key containing a slash, so a nested subpath
like `slash-commands/helpers/active-oauth-account` never entered the bundled
registry. Node matches `*` across `/`, so that import is legitimate: it
resolves from source, then falls through to `Bun.resolveSync` inside a
compiled binary and dies under bunfs. Reproducible on the published 17.2.1
binary with a real extension (`quota-hud.ts`).

Enumeration is now recursive, with every path segment held to the same
private/hidden rules as the leaf, so a `.private/` or `_internal/` directory
is no more exported than a private file. Directory index modules stay
excluded: `./x/*` must not serve `x/y` from `y/index.ts`, which Node would
not resolve either.
2026-08-02 01:14:33 +10:00
roboomp 922e7a58ef fix(coding-agent): re-export compact from legacy pi shim
Legacy pi extensions import `compact` from the `@earendil-works/pi-coding-agent`
package root (aliased to the legacy shim). It lives in
`@oh-my-pi/pi-agent-core/compaction` (same module as the already-bridged
`estimateTokens`) and the coding-agent barrel does not forward it, so the shim's
`export * from "../index"` left it off the surface and a named import failed
Bun's static export check during plugin validation
(`omp plugin install npm:pi-claude-bridge`).

`keyHint` (also named in the report) already resolves via the modes/components
barrel, so only `compact` needed bridging.

Fixes #7174
2026-07-31 12:07:44 +00:00
roboomp 766ccbf24a fix(coding-agent): add createEditTool/createWriteTool to legacy pi shim
The legacy @oh-my-pi/pi-coding-agent shim exported the read/bash/grep/find/ls
tool factories but omitted the edit and write ones. pi extensions importing
createEditTool or createWriteTool (e.g. gentle-pi) failed Bun's static export
check during extension validation, blocking omp install.

Added createEditTool/createEditToolDefinition and createWriteTool/
createWriteToolDefinition, mirroring the upstream pi surface and the existing
sibling factories. The unsupported operations seam throws a descriptive error
like createGrepTool does.

Fixes #7094
2026-07-30 14:36:10 +00:00
Diogo Soares Rodrigues 6eaf090ccc fix(cursor): repair pi_edit and close the scoped-grep approval bypass
Three defects the exec bridge shipped with, all found by review.

`pi_edit` never worked. The session removes `edit` from the tool
registry for Cursor so the model is steered to full-file `write`
(8ba0498eb), but that same registry is the bridge's tool source, so the
native frame — which the server sends regardless of the advertised
catalog — resolved nothing and answered `Tool "edit" not available`.
Retaining the instance is not enough either: `PiEditExecArgs` carries
`old_text`/`new_text` pairs, which only `replace` accepts, while the
default mode is `hashline` (`{ input: string }`). `EditTool` now takes
an optional mode, and the bridge resolves a pinned `replace` instance
through its fallback resolver.

A `pi_grep` frame carrying `context` or `limit` escaped the approval
gate. Honoring those needs a per-call tool, and the per-call instance
was built raw while every registry tool is wrapped — so exactly those
calls skipped `tools.approval.grep` and the exec-tier SSH check. Both
callsites now go through one `createBridgeGrepFactory`.

Advisors ignored the same two fields: only the primary session supplied
the factory. They now get it too, gated on the advisor actually holding
`grep` so the factory cannot grant a denied tool.

Also moves the pure Pi arg translation to `providers/cursor-pi-args`.
The legacy shim shares it and is compiled into the bundled virtual
registry, where `./providers/*` cannot match a nested specifier — it
fell through to `Bun.resolveSync`, unsatisfiable under bunfs (#3442) —
and the exec module would have dragged the protobuf graph along.

Verified against real files and the real module graph: `pi_edit` mutates
a temp file, the bundled probe executes the shim's shared module in a
subprocess, and the grep test drives the shared factory. Mutation-
checked: returning a raw tool from the factory, ignoring the pinned edit
mode, dropping the `getTool` fallback, or moving the helpers back to a
nested path each fails a test.

(cherry picked from commit e46ba22b634e449005f7c22b6d0efd19a45ce1f8)
2026-07-30 01:42:23 +02:00
can1357 f2251b7d59 chore: normalize changelogs and formatting after merging open fixes 2026-07-29 23:09:40 +02:00
can1357 e0415a9e90 test: cover legacy pi CLI exports
(cherry picked from commit a0e11651f72a69c80486dffbb8dbdd96d6a382f5)
2026-07-29 23:08:25 +02:00
can1357 a0e53f73c0 Merge PR #6848: fix(coding-agent): restore isRetryableAssistantError in legacy pi-ai shim (@roboomp) 2026-07-28 10:59:35 +02:00
roboomp 846cd36d92 fix(coding-agent): bridge isContextOverflow in legacy pi-ai shim
Upstream @earendil-works/pi-ai re-exported isContextOverflow from its
package root, but omp's @oh-my-pi/pi-ai barrel forwards only
./error/rate-limit, so the shim's `export * from "@oh-my-pi/pi-ai"` left
it off the surface. Plugins importing it (pi-blackhole) tripped Bun's
static named-export check during validation, both on disk and through the
omp-legacy-pi-bundled: virtual namespace.

Audited the upstream root surface rather than fix one symbol at a time:
of its runtime exports only isContextOverflow (now under
@oh-my-pi/pi-ai/error) and parseJsonWithRepair/parseStreamingJson/
repairJson (relocated to @oh-my-pi/pi-utils) still exist in omp. Bridge
exactly that set through the shim and pin it with a regression test that
exercises each helper's behavior.

Fixes #6859
2026-07-28 05:34:20 +00:00
roboomp d4956e6de2 fix(coding-agent): restore isRetryableAssistantError in legacy pi-ai shim
Historical @earendil-works/pi-ai exports isRetryableAssistantError from its
package root (utils/retry.ts), but OMP's legacy-pi-ai-shim re-exports
@oh-my-pi/pi-ai, whose root never carried the symbol. Plugins importing it
(e.g. @router-for-me/pi-cliproxyapi-provider >= 1.4.9) failed Bun's static
named-export validation, rolling back install.

Port the upstream transient-error classifier into the shim, preserving the
provider-error wording tables so legacy retry semantics match.

Fixes #6847
2026-07-28 03:35:46 +00:00
omp-eval c8b37c8d2e fix(plugins): return bare Kitty delete sequences from legacy pi-tui shim
Upstream Pi's deleteKittyImage/deleteAllKittyImages return unwrapped control
sequences; legacy callers such as pi-sprite wrap tmux passthrough themselves.
Aliasing OMP's auto-wrapping encodeKittyDeleteImage (and hand-wrapping
deleteAllKittyImages) double-wrapped under tmux, so the outer terminal dropped
the delete command. Match the upstream bare-sequence contract and pin it in
the regression test.
2026-07-26 15:41:31 +02:00
can1357 5905ec0430 Merge PR #6507: fix(plugins): restore pi-sprite legacy compatibility (@roboomp) 2026-07-26 15:41:31 +02:00
can1357 e1b607f9ee Merge PR #6584: fix(coding-agent): re-export estimateTokens from legacy pi shim (@roboomp) 2026-07-26 15:41:30 +02:00
roboomp 52b5e7f838 fix(coding-agent): restored legacy pi automode compatibility
Restored the historical clampThinkingLevel export through the legacy pi-ai shim and exposed ModelRegistry.getApiKeyAndHeaders for extension request authentication.

Added compatibility and auth result regression coverage.

Fixes #6648
2026-07-25 22:14:11 +00:00
roboomp 7f1da393df fix(coding-agent): re-export estimateTokens from legacy pi shim
Legacy pi's @earendil-works/pi-coding-agent re-exported estimateTokens
from its coding-agent package root. In omp it lives in
@oh-my-pi/pi-agent-core/compaction and the coding-agent barrel does not
forward it, so the shim's `export * from "../index"` left it off the
surface. A named import tripped Bun's static export check during plugin
validation (e.g. `omp plugin install pi-blackhole`).

Re-export estimateTokens from the shim and pin it with a regression test.

Fixes #6583
2026-07-25 05:35:08 +00:00
roboomp c5685a0080 fix(plugins): restored pi-sprite legacy compatibility
- Added the legacy createExtensionRuntime adapter with fresh pre-bind state.

- Restored terminal capability and Kitty image deletion helpers required by pi-sprite.

- Covered package-root imports and runtime behavior with regression tests.

Fixes #6506
2026-07-24 11:18:20 +00:00
can1357 be94acbf71 fix(extensions): handle TypeScript import-equals require specifiers
Collect TSImportEqualsDeclaration/TSExternalModuleReference targets so
legacy .ts/.cts extensions using `import x = require("pkg")` get their
bare dependencies pinned like plain require() calls. Fold of the #6256
follow-up (comicchang/oh-my-pi@1e54b68) requested on #6324.
2026-07-23 11:37:12 +02:00
Jeff Scott Ward 0b9adcb4c8 fix(extensions): resolve transitive CJS deps
Preserve runtime package resolution in compiled binaries across CommonJS
dependency graphs and mixed-module packages.

Refs #6173
Co-authored-by: Comic Chang <comicchang@gmail.com>
2026-07-22 19:38:23 -04:00
Comic Chang 1ede6ae628 fix(extensions): load legacy plugins in compiled binaries 2026-07-22 18:42:14 -04:00
can1357 b9072f1991 fix(extensibility): validate Type.Unsafe against the draft-2020-12 upgraded schema
Aligns the shim's runtime safeParse/__validator with the wire/tool-call
path, so legacy draft-07 documents (tuple items) accept the same values
validateToolArguments does. Adds a regression test.
2026-07-22 21:13:21 +02:00
roboomp 040c1d5891 fix(extensibility): validated unsafe schemas at runtime
Used the shared JSON Schema validator for Type.Unsafe so direct safeParse calls and composed shim schemas reject invalid values while preserving valid input identity.

Added direct and composed runtime regression assertions.
2026-07-21 22:42:09 +00:00
roboomp 49e63c1f2c fix(extensibility): added Type.Unsafe to typebox shim
Preserved raw JSON Schema documents while keeping the shim validator identity-based, allowing provider wire conversion and runtime argument validation to consume MCP input schemas.

Added direct shim and remapped-extension regression coverage.

Fixes #6221
2026-07-21 22:34:44 +00:00
can1357 1bf08608a4 Merge PR #4964: fix(cli): resolve bundled extension imports (@roboomp)
# Conflicts:
#	packages/coding-agent/src/extensibility/plugins/legacy-pi-compat.ts
#	packages/coding-agent/src/main.ts
#	packages/coding-agent/src/prompts/system/workflow-notice.md
#	packages/coding-agent/test/extensibility/legacy-pi-bundled-virtual.test.ts
2026-07-20 22:53:16 +02:00
roboomp 5082763d49 fix(extensibility): guarantee string getPackageDir in compiled shim builds
omp's canonical getPackageDir() returns undefined inside a bun --compile
binary (import.meta.dir is /$bunfs/root, no owning package.json — issue
#1423). Re-exporting it directly broke pi's string-valued contract:
legacy extensions doing path.join(getPackageDir(), ...) crashed at
runtime in the shipped binary, the primary distribution.

Wrap the canonical helper so the shim always returns a string, falling
back to the executable's directory in compiled mode (where the binary is
the install root). PI_PACKAGE_DIR and dev/source/npm-dist walk-up still
win. Test covers the compiled-mode fallback via isCompiledBinary spy.

Fixes #5968
2026-07-18 06:50:00 +00:00
roboomp 4a25993682 fix(extensibility): re-export getPackageDir/getProjectDir from legacy pi shim
The legacy pi compatibility shim only forwarded getAgentDir (via
`export * from "../index"`). getProjectDir and getPackageDir were absent,
so any pi extension importing either from @earendil-works/pi-coding-agent
failed Bun's static export check during extension validation and the
install was rolled back.

Re-export getProjectDir from @oh-my-pi/pi-utils and getPackageDir from
omp's canonical config helper (returns the coding-agent package root,
matching pi semantics).

Fixes #5968
2026-07-18 06:41:55 +00:00
can1357 0f26558d03 chore: reformat 2026-07-17 07:40:21 +02:00
can1357 cf434411f6 merge PR #5744 via eval/pr-5744: fix(tui): reinstated host stdin listeners removed during tool load 2026-07-17 04:40:04 +02:00
can1357 5d3ad91900 fix(plugins): preserve CommonJS ESM interop 2026-07-17 04:18:10 +02:00
can1357 9a413bf812 fix(coding-agent): restore flowing stdin after guarded load 2026-07-17 03:57:12 +02:00
roboomp d2aeaeced6 fix(tui): reinstated host stdin listeners removed during tool load
The host guard's stdin restore only dropped listeners a module added; a
module that removed a snapshot listener (e.g. a factory calling
process.stdin.removeAllListeners("data") when a subagent re-runs preloaded
factories against a live parent TUI) permanently stripped ProcessTerminal's
input handler. Reconcile each guarded event back to the pre-load snapshot:
when membership changed, removeAllListeners then re-add the snapshot in
order, restoring both additions dropped and removals reinstated. Snapshot
via rawListeners so once-wrapped handlers round-trip intact.

Fixes #5618
2026-07-16 19:48:08 +00:00
roboomp 1fea9b149f fix(tui): guarded stdin against custom-tool import hijack
Custom tool/extension/hook/plugin modules under ~/.claude/tools are
evaluated with live side effects during createAgentSession. A module that
attaches a stdin consumer at import time — an MCP StdioServerTransport
built at module top level, or a bare process.stdin.resume() — steals
Bun's single stdin reader, so the TUI receives exactly one data event and
goes permanently deaf after the first keypress. Under tmux the terminal's
automatic DA1 reply is that one event, so the first user keystroke is
already dead: the input-deafness reported in #5378/#5618.

Broadened the loader's withExitGuard (renamed withHostGuard) to also
snapshot and restore process.stdin around third-party module evaluation:
any data/readable/end/close/error listener the module adds is removed, and
the stream's paused and raw-mode state is restored to the pre-load
snapshot. The exit guard already fenced process.exit; stdin is the same
class of host-state hijack.

Fixes #5618
2026-07-16 19:35:43 +00:00
roboomp 8f15dbf106 fix(plugins): preserved commonjs sibling requires
- Added a graph-owned CommonJS evaluator with shared module.exports and cycle-aware caching.

- Covered sibling require interop across ESM-imported CommonJS modules.

Fixes #5658
2026-07-16 06:11:32 +00:00
roboomp 83c7e69306 test(plugins): covered native addon commonjs wrapping
- Exercised a graph-owned CommonJS dependency whose native addon require is pinned before synchronous wrapping.

Fixes #5658
2026-07-16 05:58:40 +00:00
roboomp 2cf0c402f9 fix(plugins): refreshed commonjs helpers on reload
- Rebuilt synchronous CommonJS wrappers from current source for every legacy extension load.

- Added a same-process helper edit regression.

Fixes #5658
2026-07-16 05:53:19 +00:00
roboomp 33340f82ce fix(plugins): restored legacy commonjs compatibility
- Added DefaultPackageManager discovery compatibility for legacy extensions.

- Loaded graph-owned CommonJS modules through synchronous default bridges.

Fixes #5658
2026-07-16 05:41:35 +00:00
roboomp 24960899ac fix(coding-agent): lazily loaded compiled extension modules
Generated per-module loaders instead of eagerly evaluating the entire bundled compatibility graph during extension bootstrap.

This prevents appserver startup from cycling through its own retained command modules before the Unix socket is created.

Fixes #5568
2026-07-15 10:54:13 +00:00
roboomp 7881fce976 fix(plugins): preserved native commonjs helper loading
Kept synchronous require() targets on Bun’s native loader while retaining hooks for native-addon rewrites.

Added regression coverage for ESM extensions loading CommonJS helper files.

Fixes #5373
2026-07-14 19:22:00 +00:00
can1357 f9f6ed9e8d feat(coding-agent): replaced legacy pi/ role alias prefix with
- Replaced legacy `pi/` role alias prefix with canonical `@` syntax across model resolution, documentation, and tests.
- Added support for bare `*` default alias and multiple alias prefix detection with custom role resolution in `resolveConfiguredRolePattern()`.
- Enhanced thinking suffix parsing to accept unambiguous abbreviations (minimum 2 characters) for effort and level selectors.
- Extended `resolveCliModel()` and `filterAvailableModelsByEnabledPatterns()` to accept settings parameter for role alias resolution from `--model` flag.
2026-07-13 23:26:33 +02:00
roboomp 459682cc63 fix(plugins): skipped invalid custom tool entries
Validated custom tool factory results before registering plugin-provided tools so one malformed feature entry is reported and skipped instead of crashing startup.

Added regression coverage for null entries and mixed valid/null factory arrays.

Fixes #5189
2026-07-11 14:31:07 +00:00