fix(cli/doctor-pi): skip unrelated local packages when probing embedding runtime - #414
fix(cli/doctor-pi): skip unrelated local packages when probing embedding runtime#414qsgy-edge wants to merge 2 commits into
Conversation
…ing runtime piPluginDirCandidates treated every non-npm: entry in Pi packages[] as a candidate plugin tree, so local dev-path extensions (any package.json, regardless of name) were probed for the embedding runtime. The first broken candidate made doctor report 'native runtime and WASM fallback both unavailable' and stop, even when the real magic-context install was healthy. Now only directories whose package.json names @cortexkit/pi-magic-context qualify as candidates, and broken candidates no longer abort the scan — a stale local dev tree cannot mask a healthy managed install. Repro: register any local-path Pi extension (D:\repo\my-extension) in settings.json packages[], run 'doctor --harness pi' — doctor blamed the extension's package.json for missing onnxruntime-web deps instead of reporting the actual plugin install.
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…nstall Address review findings (Greptile P1, cubic-dev-ai P2): the loop still stopped at the first candidate with a working WASM fallback, reporting a degraded runtime even when a later managed install had the native binding. Record the best degraded candidate and keep probing; only report the fallback WARN when no candidate is fully OK. Tests: add regression coverage for (1) unrelated local packages never probed (unverified, not a broken-runtime WARN, when only unrelated packages are registered), and (2) a WASM-only dev tree not masking a later native-capable install.
|
Both review findings addressed in 296e340:
Also added Test run: 20 tests, 17 pass, 3 pre-existing failures (DB schema / legacy config migration, reproduced on clean master). |
There was a problem hiding this comment.
Thanks for isolating this — the premise holds (on master piPluginDirCandidates probes every local-path entry and aborts on the first broken one), the package-name filter is the right direction, and your regression is red on master. Three asks before merge:
-
Pick the best result across all candidates, native OK > WASM OK > broken. The loop still stops on an earlier
wasm-fallback, so an earlier local tree with a broken native binding but working WASM makes a later healthy native managed install report as degraded (greptile's P1 — I reproduced it with a variant of your test). Please add that exact regression: broken-native + working-WASM candidate first, healthy native candidate later, assert the nativePASS. -
When every candidate fails, name every candidate. Only
firstBrokensurvives into the warning today; the all-broken message should list each path with its native/WASM reason so the user can tell which tree is stale. -
Treat a local dev path as a second loaded identity. Pi keys
npm:@cortexkit/pi-magic-contextand a local directory whosepackage.jsoncarries that name as different identities and loads both; the duplicate-load conflict check still only recognizes the npm spelling, so the doctor output should not imply the managed install is the sole runtime that will load. Please make the conflict diagnostic identity-aware and cover the local+npm case.
One formatter violation at :801-803 — run the repo's pinned biome (packages/cli/node_modules/.bin/biome check). On this Mac the CLI suite is 385/0 on your head; I could not verify the three Windows-only failures you mention, so if they are real please paste them.
Problem
piPluginDirCandidatestreats every non-npm:entry in Pisettings.jsonpackages[]as a candidate plugin tree. Local dev-path extensions — any directory with apackage.json, regardless of what package it is — get probed for the embedding runtime.On a machine with a local-path Pi extension registered (e.g.
D:\repo\my-extension),doctor --harness pireports:The doctor blames an unrelated extension's
package.jsonfor missing embedding deps it was never expected to have, and stops at the first broken candidate — never probing the real magic-context install (~/.pi/agent/npm/node_modules/@cortexkit/pi-magic-context), which may be perfectly healthy.Fix
Two small changes in
packages/cli/src/commands/doctor-pi.ts:isPiMagicContextPackageDir: local dev-path entries only qualify as embedding-runtime candidates when theirpackage.jsonnameis@cortexkit/pi-magic-context. Unrelated extensions are no longer probed (this reuses the same name checkfindPiMagicContextCacheDirsalready applies).Repro (before)
npx @cortexkit/magic-context@latest doctor --harness pi # WARN Embedding provider: local — ... both unavailable (blames my-extension)After
npx @cortexkit/magic-context@latest doctor --harness pi # PASS Embedding provider: local (native runtime selected and OK)Verified against the reporter's real environment: doctor goes from
PASS 11 / WARN 1 / FAIL 0toPASS 12 / WARN 0 / FAIL 0.Tests
New regression test: registers an unrelated local-path plugin plus a broken local dev tree of the plugin itself alongside a healthy managed install, asserts
PASS Embedding provider: local (native runtime selected and OK)and no falseboth unavailableWARN.bun test src/commands/doctor-pi.test.ts: 15 pass, 3 pre-existing fails (DB schema / legacy config migration on Windows; reproduced on cleanmasterwithgit stash), 72 expect calls.tsc --noEmitclean. Biome flags only pre-existing CRLF line-ending noise in the file (reproduced onmaster).Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes
doctor --harness piso unrelated local-path packages are no longer probed for the embedding runtime, and broken or degraded candidates no longer abort the scan before a healthy managed install is checked.Bug Fixes
package.jsonnames@cortexkit/pi-magic-contextqualify as embedding-runtime candidates.Written for commit 296e340. Summary will update on new commits.
Greptile Summary
The PR makes Pi doctor inspect only local paths that declare the Magic Context Pi package and continue past degraded candidates until it finds the best available runtime.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains; the previously reported WASM-fallback masking issue is fixed by continuing the scan until a native-capable candidate is found.
Important Files Changed
Reviews (2): Last reviewed commit: "fix(cli/doctor-pi): don't let a WASM fal..." | Re-trigger Greptile