fix(pi): resolve session APIs from OMP hosts
Summary
- Resolve Pi session APIs from either the running
@earendil-works/pi-coding-agentpackage or the OMP@oh-my-pi/pi-coding-agentpackage while preserving host-first resolution. - Add the OMP package as the final bare-import fallback and report both supported package names in resolution errors.
- Make a failed session-discovery page immediately retryable instead of leaving the backfill lease live for ten minutes.
Root cause
loadDefaultPiSessionApi() walked up from the live host entry but accepted only the Earendil package name. A pure OMP install therefore rejected its own @oh-my-pi/pi-coding-agent manifest, then retried only the Earendil bare specifier. The same rejection happened inside the first paged backfill read, after runSessionProjectBackfill() had acquired its lease, so the rejected read left that holder marked running until the lease TTL expired.
Correctness and scope
- The live host entry remains the first resolution strategy, so an extension-tree copy cannot supersede the runtime that owns the session format.
- Existing export-condition selection, source-checkout handling, path containment, memoization, and Pi fallback behavior are unchanged.
- Failure cleanup remains holder-fenced: it only expires the lease if the failing runner still owns it, never releases a replacement holder, and rethrows the original discovery error.
- Regression coverage uses the published OMP 18.2.1 manifest shape (
exports["."].import = "./src/index.ts") and proves a rejected page can be retried immediately by a new holder.
Validation
- Focused resolver tests: 26 passed.
- Focused backfill tests: 10 passed.
- Full Pi plugin suite: 1,158 passed, 1 skipped, 0 failed.
- Pi plugin and shared plugin: typecheck, Biome lint, and production builds passed.
- Full shared-plugin parallel run: 4,856 passed; 7 unrelated load-sensitive tests failed under the ZGC parallel run (four 30-second timeouts plus three perf/race assertions). Every failed file passed when rerun serially: 338 passed, 0 failed.
git diff --checkpassed.
Fixes #455
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Fixes Pi session API resolution so OMP-only installs can load session APIs from their own package, including hosts whose exports point directly to TypeScript source, and makes failed session discovery immediately retryable instead of leaving the backfill lease locked for ten minutes.
- Session APIs now resolve from either
@earendil-works/pi-coding-agentor@oh-my-pi/pi-coding-agent, keeping the running host entry as the first resolution strategy. - Declared TypeScript entries are loaded directly; only build-output targets go through the dist-to-src mapping.
- Adds
@oh-my-pi/pi-coding-agentas the final bare-import fallback and reports both supported package names in resolution errors. - A failed session-discovery page now expires the lease immediately so a new holder can retry, rather than waiting for the ten-minute TTL.
Fixes #455
Greptile Summary
The PR enables session API resolution from both Pi and OMP hosts while preserving host-first lookup, and makes failed session-discovery pages immediately retryable.
- The latest changes prioritize source counterparts over TypeScript dist output while retaining direct imports for declared source exports.
- The OMP bare-import regression test now isolates its module mock in a subprocess.
- The previously reported OMP source-export issue is fully fixed; no actionable new issues were identified.
Confidence Score: 5/5
The PR appears safe to merge, with the prior source-export issue fixed and no actionable new findings.
Direct OMP TypeScript source exports remain loadable, while dist exports now prefer their source counterparts as intended. The fallback-test mock is isolated from the parent suite, and no outstanding previous finding or confirmed repository-rule violation remains.
Important Files Changed
| Filename | Overview |
|---|---|
| packages/pi-plugin/src/dreamer/pi-session-api.ts | Recognizes both host packages and preserves source-checkout precedence while accepting direct OMP source exports. |
| packages/pi-plugin/src/dreamer/pi-session-api.test.ts | Adds OMP resolver coverage, isolates the fallback mock, and verifies source precedence over TypeScript dist output. |
| packages/plugin/src/features/magic-context/session-project-backfill.ts | Adds holder-fenced lease expiration after discovery failures while preserving the original error. |
| packages/plugin/src/features/magic-context/session-project-backfill.test.ts | Covers immediate acquisition by a replacement holder after page discovery fails. |
Reviews (3): Last reviewed commit: "fix(pi): preserve source mapping before ..." | Re-trigger Greptile