Fix OMP 17.0.1 runtime import fallback - #2
Open
Horacehxw wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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 intoloadRuntimeBindings()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-aicompletion 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 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Verification
bun test: 27 passed, 0 failedbunx tsc --noEmit: passeddetails.strategy = codex-context-checkpointCloses #1