Skip to content

Fix OMP 17.0.1 runtime import fallback - #2

Open
Horacehxw wants to merge 1 commit into
processmission:mainfrom
Horacehxw:fix/omp-17-runtime-imports
Open

Fix OMP 17.0.1 runtime import fallback#2
Horacehxw wants to merge 1 commit into
processmission:mainfrom
Horacehxw:fix/omp-17-runtime-imports

Conversation

@Horacehxw

Copy link
Copy Markdown

Problem

OMP 17.0.1 installs this plugin and reports it healthy, but its compiled legacy loader rewrites the OMP runtime imports to an unresolved omp-legacy-pi-bundled: scheme. The compaction hook then falls back to native compaction on first use.

Fix

  • detect only the compiled-host virtual-module resolution failure
  • run the completion request in a clean Bun subprocess where the plugin's installed dependencies resolve normally
  • use the existing portable conversation serializer only on that compatibility path
  • preserve the shared host runtime path for current OMP and the existing upstream Pi path
  • cover subprocess success, provider failure, and pre-aborted requests

Verification

  • bun test: 27 passed, 0 failed
  • bunx tsc --noEmit: passed
  • OMP 17.0.1 GitHub install: plugin list and doctor passed (4 ok, 0 warnings, 0 errors)
  • OMP 17.0.1 RPC smoke: installed plugin returned details.strategy = codex-context-checkpoint

Closes #1

Copilot AI review requested due to automatic review settings July 31, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an OMP 17.0.1-specific runtime import resolution regression by adding a compatibility fallback that runs the @oh-my-pi/pi-ai completion call in a clean Bun subprocess when the host’s compiled loader rewrites imports to an unresolvable virtual-module scheme.

Changes:

  • Adds a Bun-subprocess completion path (completeInBunSubprocess) and wires it into loadRuntimeBindings() only when the OMP legacy virtual-module resolution fails.
  • Introduces a Bun entrypoint helper (runtime-complete.ts) to execute the real @oh-my-pi/pi-ai completion in the subprocess.
  • Adds coverage for subprocess success, helper/provider failure surfacing, and pre-aborted requests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
index.ts Adds OMP 17.0.1 compatibility fallback that executes completions in a clean Bun subprocess when OMP’s compiled loader breaks module resolution.
runtime-complete.ts Bun subprocess helper that calls @oh-my-pi/pi-ai’s complete and returns a JSON result envelope.
test/omp-runtime.test.ts Tests the new Bun subprocess completion path, failure propagation, and abort behavior.
test/fixtures/runtime-complete.ts Test helper script used to simulate subprocess behavior and validate request/option serialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread index.ts
Comment on lines +128 to +149
await subprocess.stdin.write(JSON.stringify({ model, context, options: serializableOptions }));
await subprocess.stdin.end();
const [exitCode, output] = await Promise.all([
subprocess.exited,
subprocess.stdout.text(),
subprocess.stderr.text(),
]);
signal?.throwIfAborted();

let result: RuntimeCompleteResult;
try {
result = JSON.parse(output) as RuntimeCompleteResult;
} catch (error) {
throw new Error(`Bun compatibility helper returned invalid JSON (exit ${exitCode})`, { cause: error });
}
if (!result.ok) {
throw new Error(`Bun compatibility helper failed: ${result.error}`);
}
if (exitCode !== 0) {
throw new Error(`Bun compatibility helper exited with status ${exitCode}`);
}
return result.response;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OMP 17.0.1 installs cleanly but compaction falls back on runtime import resolution

2 participants