Commit Graph

188 Commits

Author SHA1 Message Date
can1357 00cabe5513 Merge PR #8144: fix(extensions): preserve unsafe schemas during plugin install (@roboomp) 2026-08-13 01:14:49 +02:00
roboomp b7d83ed931 fix(cli): kept marketplace uninstall scope positional
The earlier dry-run change moved scope into an options object, silently
ignoring the legacy uninstallPlugin(id, "user") runtime shape still reachable
from compiled or plain-JS callers. Restore scope as the positional second
argument and carry dryRun in a trailing options bag, preserving the existing
call shape while keeping the non-mutating dry-run path.

Fixes #8178
2026-08-10 18:10:30 +00:00
roboomp 15a9346c29 fix(cli): preserved uninstall dry-run validation
Route marketplace dry-runs through MarketplaceManager's normal pre-mutation
validation so ambiguous or mismatched scopes fail exactly as real uninstalls
do. Move the manager's scope argument into an options object and add a dry-run
option that returns only after all removal planning has succeeded.

Fixes #8178
2026-08-10 18:02:21 +00:00
roboomp e414585155 fix(extensions): preserved unsafe schemas during install
- Lifted legacy Type.Unsafe documents into callable omptype schemas so Optional and Object composition preserve validation and required fields.
- Ran installed extension factories against the normal throwaway loader surface before accepting a plugin install.
- Added regression coverage and documented the stronger rollback gate.

Fixes #8143
2026-08-10 07:37:28 +00:00
can1357 2ad61c7b92 feat(discovery): added Agent Plugins 1.0.0 standard support
- New agent-plugins provider discovers packages with a root plugin.json
  targeting the canonical schema (agent-plugins.org) from marketplace
  installs, --plugin-dir, and configured extension roots; skills/ and
  mcp.json load per spec with closed-schema validation,
  ${PLUGIN_ROOT}/${PLUGIN_DATA} expansion, reserved subprocess
  environment, instance-keyed data dirs, and per-component isolation.
- Package-boundary containment (spec §4.1) is enforced before every
  read via the new contained-path helpers, including skill:// resource
  access from the read tool and bash; plugin skill files must
  realpath-resolve inside the plugin root (skills carry containRoot).
- Legacy claude-plugins/omp-plugins providers yield skills and MCP
  surfaces of standard-targeting roots to the new provider and skip
  fatally invalid packages.
2026-08-07 05:59:52 +02:00
can1357 1d181161b0 style: formatted legacy-pi shim changes with biome 2026-08-05 22:18:05 +02:00
can1357 21a7a32eb6 fix(plugins): only rewrite imported createRequire calls 2026-08-05 22:15:47 +02:00
roboomp 31ee049374 fix(plugins): resolve createRequire deps in legacy-pi shim
The legacy-pi load-time rewriter only recognized static require()/import
specifiers, so an extension resolving a bundled dependency through the
createRequire(base)(spec) factory form (e.g. gentle-pi loading
@heyhuynhgiabuu/pi-pretty) left the bare specifier untouched. In a
compiled binary that argument then fell through to native node_modules
resolution, which is unavailable under --compile, failing extension
validation and session load.

collectExtensionSpecifierReferences now detects createRequire(...)(spec)
factory invocations and records the invoked bare specifier as a require
reference, so the existing pipeline pins it to an absolute path. Relative
specifiers are left alone since they resolve against the createRequire
base, which is not rewritten.

Fixes #7728
2026-08-05 15:02:07 +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
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 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 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 72c66c87c1 fix(xdg): adopted legacy secret-placeholder.key and marketplaces.json at XDG paths 2026-08-01 20:46:25 +02:00
Parsifa1 ea437745a3 fix(xdg): move secret-placeholder.key, marketplaces.json, and run/ out of config root
These four paths bypassed DirResolver's XDG-aware rootSubdir/agentSubdir
hooks, resolving directly against getConfigRootDir()/getAgentDir() and
ignoring XDG state/data layout. Add XDG-aware path helpers in dirs.ts
and route all four through them:

- secret-placeholder.key → $XDG_STATE_HOME/omp/ (state, agent flattened)
- marketplaces.json      → $XDG_DATA_HOME/omp/  (data)
- run/daemons/<hash>/    → $XDG_STATE_HOME/omp/run/ (state)
- run/provider-inflight/ → $XDG_STATE_HOME/omp/run/ (state)

omp config init-xdg migrates secret-placeholder.key and marketplaces.json
from their legacy locations; run/ is ephemeral and rebuilds on restart.
2026-08-01 06:40:48 +00:00
usr-bin-roygbiv d8ec26dac7 perf(coding-agent): replace legacy Babel traversal 2026-07-27 00:51:45 +00:00
roboomp 68193c8240 test(extensibility): drop dynamic import from #6449 regression test
Extract the first-wins global registration into an exported
ensureGraphCommonJsRequireRegistered() seam and assert its idempotent
(first-wins) contract directly, instead of copying the module and importing
the copy at runtime. Removes the inline await import() banned under
packages/coding-agent and keeps regression coverage: the test fails if the
registration reverts to an unconditional set.

Fixes #6449
2026-07-23 23:08:30 +00:00
roboomp d69cf2106e fix(extensibility): guard legacy-pi-compat commonjs registration first-wins
On npm/source-link installs the @(scope)/pi-coding-agent root shim is served
from src/, so an extension's import evaluates a second instance of
legacy-pi-compat.ts. Its unconditional top-level
Reflect.set(globalThis, COMMONJS_REQUIRE_GLOBAL, evaluateGraphCommonJs)
clobbered the host bundle's populated CommonJS graph bridge with an empty-state
copy, breaking transitive CommonJS dependency resolution for legacy pi
extensions ("Missing graph-owned CommonJS definition").

Guard the registration to first-wins so the host-owned bridge survives a
second module instantiation.

Fixes #6449
2026-07-23 23:00:35 +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 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
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
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 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
can1357 7de519eabc Merge PR #5499: fix(plugins): preserve native CommonJS helper loading (@roboomp) 2026-07-14 23:11:10 +02:00
can1357 55ad1ff1bc Merge PR #5505: fix(plugins): refresh stale Bun git cache before reinstall (@roboomp) 2026-07-14 23:11:07 +02:00
roboomp 2439f77e70 fix(plugins): refreshed stale bun git cache before reinstall
Fetched current heads and tags into Bun's matching cached bare clone before running bun update.

Added an isolated HTTP git regression covering a moved branch with a stale cache.

Fixes #5401
2026-07-14 19:37:06 +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 edc0511433 Merge PR #4967: fix(plugin): handle pinned git source replacements (@roboomp) 2026-07-14 18:45:31 +02:00
can1357 d469064d1a fix: handle stale tests 2026-07-11 07:54:19 +02:00
can1357 33c161d9dd refactor(coding-agent): restructured plugin system and build logic
- Migrated legacy static bundled-module registry to a dynamic Bun-based in-memory plugin system.
- Removed over 4,000 lines of manually maintained registry files to reduce maintenance overhead.
- Implemented CJS absolute path rewriting and native-addon load hooks to improve FFI dependency resolution.
- Standardized binary build processes by centralizing compilation logic into shared utilities.
2026-07-11 07:33:22 +02:00
roboomp 63adfeece5 fix(plugin): handled pinned git source replacements
- Removed the stale pinned dependency edge before invoking Bun for same-repository git source replacements so Bun does not construct a dependency loop.

- Added a regression test for the pinned-to-unpinned GitHub plugin replacement path.

Fixes #4960
2026-07-09 18:35:43 +00:00
roboomp 1966d041f0 fix(cli): registered bundled namespace resolver
Registered the bundled virtual resolver on the omp-legacy-pi-bundled namespace while keeping the file-namespace scheme fallback for build-time resolution.

Updated the regression test to cover registry-key resolver inputs.

Fixes #4954
2026-07-09 18:30:25 +00:00
roboomp db0e81a221 fix(cli): resolved bundled extension imports
Routed bundled virtual specifiers through Bun's plugin namespace so compiled-binary extensions can import @oh-my-pi value exports.

Surfaced extension load failures during session startup.

Fixes #4954
2026-07-09 18:17:24 +00:00
can1357 d03ecad0bc merge PR #4690: fix(coding-agent): handle JSON imports in legacy plugin validator 2026-07-08 15:19:37 +02:00
roboomp f44fcdfb7d fix(coding-agent): hid marketplace clone temp paths
Displayed cloned marketplace catalog validation errors with repository-relative catalog paths and the original source identifier.

Fixes #4702
2026-07-06 11:05:50 +00:00
roboomp 47c172c70a fix(coding-agent): handled json imports in plugin validator
- Left JSON files imported with import attributes on Bun's native loader instead of registering them with the legacy source rewrite hook.
- Added a regression test for loadLegacyPiModule loading a JSON import-attribute target.

Fixes #4687
2026-07-06 08:17:32 +00:00
can1357 3e1808e2b5 fix(agent): handle installed legacy dependency reloads 2026-07-05 12:44:17 +02:00
roboomp 45deb2098d fix(agent): reloaded legacy bare dependency children
Included ESM extension-local bare dependency entries in the legacy extension graph so their relative children receive the same mtime cache-bust rewrite as extension source modules.

Skipped CommonJS dependency entries to preserve native Bun CJS default import behavior.

Added a regression test for a local node_modules ESM dependency whose unchanged entry re-exports an edited helper.

Fixes #4565
2026-07-05 02:53:28 +00:00
roboomp 65cd063d90 fix(agent): refreshed legacy pi graph hooks
Collected the current extension graph on every load and registered supplemental Bun hooks for modules added after the first import.

Preserved exact-path filters by tracking covered realpaths per entry instead of widening hooks to unrelated files.

Added a regression test for an entry-only extension that later adds helper and leaf modules, then reloads an edited leaf.

Fixes #4565
2026-07-04 20:56:38 +00:00
roboomp 2049c72b94 fix(agent): propagated mtime through legacy extension graph
Threaded the current load's mtime tag through rewriteExtensionPackageImports, rewriteExtensionBareImports, and a new relative-graph pass so ./helper.ts, #alias/*, and extension-local bare deps all rekey per reload.

Added a toGraphImportSpecifier helper that emits bare POSIX paths with ?mtime on POSIX and keeps file:// URLs on Windows/bundled targets, matching the entry loader.

Added a regression test covering same-process relative-helper reload freshness through the public loader.

Fixes #4565
2026-07-04 20:44:56 +00:00
roboomp d510851593 fix(agent): reloaded edited legacy pi modules
Loaded legacy Pi extension entries through raw POSIX filesystem specifiers so Bun keys the cache-busting mtime query.

Allowed the extension graph onLoad hook to match and normalize the mtime query before rewriting source.

Added a regression test covering same-process reload freshness and clean fileURLToPath-derived paths.

Fixes #4565
2026-07-04 20:26:27 +00:00
can1357 eb47ce1063 Merge remote-tracking branch 'origin/farm/a23a6b23/drain-plugin-install-pipes' 2026-07-02 23:43:11 +02:00
can1357 1c0e35f73e Merge remote-tracking branch 'origin/farm/813601d2/install-npm-pi-packages' 2026-07-02 23:43:08 +02:00