fix(pi-fff): isomorphic bun/node SDK lazy-load - #669
Conversation
|
[triage-bot] CI note: Honk-Honk 🪿 |
a265a46 to
fbdf9f8
Compare
|
@gustav-fff iterate |
|
[triage-bot] DIRECTED: need a concrete direction — "iterate" is ambiguous. Candidates I see:
Which one, or all? Honk-Honk 🪿 |
|
[triage-bot] DIRECTED: iterated on option 2 (drop the cross-runtime fallback). Pushed 24b02ed.
Diff: -20 / +5 in Left options 1 (drop Honk-Honk 🪿 |
|
@gustav-fff hello - fix the CI and verify that it works with oh-my-pi on whatever machine you are |
|
[triage-bot] DIRECTED: CI fix: pushed 23d76af — oh-my-pi verify: no omp on this machine — closest available runtime is `pi` (earendil-works) which is node-shebanged here (`#!/usr/bin/env node`, so `detectRuntime()` returns `node`). What I verified:
What I could NOT verify: end-to-end under the real oh-my-pi validator — omp isn't installable here without a repro command. If you can share the omp invocation that reproduced the original failure on `main`, I can rerun it against this branch. Honk-Honk 🪿 |
|
okay @gustav-fff now rebase |
Detect bun vs node at runtime and dynamically import the matching SDK (@ff-labs/fff-bun on bun, @ff-labs/fff-node on node) via a variable package name so oh-my-pi's static extension validator does not chase ffi-rs' optional native binaries through the module graph. Closes #668
Drop the cross-runtime SDK fallback in loadSdk. Falling back to the node SDK on a bun host re-introduces the ffi-rs cost this PR is meant to avoid, and hides packaging bugs where the correct SDK is missing.
23d76af to
be23eb5
Compare
|
[triage-bot] DIRECTED: rebased on origin/main. Head is now be23eb5 (was 23d76af).
Honk-Honk 🪿 |
Brings in upstream 0.10.0 batch: SDK file-watcher exposure (dmtrKovalenko#674), stable FffResult C accessors (dmtrKovalenko#681), pi-fff non-cwd + isomorphic SDK fixes (dmtrKovalenko#622, dmtrKovalenko#669), picker_ui fuzzy-match highlight (dmtrKovalenko#673), README FAQ (dmtrKovalenko#680), vimdoc regen (dmtrKovalenko#683). Conflict resolution: - All crate Cargo.toml + workspace: take ours (0.17.0). Upstream's 0.10.0 is its own independent release line; the fork stays on 0.17.0. fff-mcp keeps its daemon-only deps (fff-ipc/dirs/libc). - fff-core/src/lib.rs: keep BOTH the fork's content_staleness_recheck test module and upstream's new pub watch module (non-overlapping). - install-mcp.sh: keep ours — the fork installs from HEAD/source and points at abhijit-s, so upstream's v0.10.0 release-pinning + SHAs do not apply. - Cargo.lock: ours (no reconciliation needed on build). Verified: build-daemon green; fff-search suite incl. upstream's new watch:: tests + the fork's 4 content_staleness_recheck regressions; daemon crate tests — all 0 failures.
…694) PR #669 made sdk.ts dynamically import @ff-labs/fff-bun when running under bun, but only added it as an optional peer dependency. Package managers do not install optional peers by default, so `pi install npm:@ff-labs/pi-fff` on a bun-only host produced a node_modules tree without @ff-labs/fff-bun and pi crashed at session_start with "Cannot find module '@ff-labs/fff-bun'". Promote both SDKs to regular deps. Bundle size cost is minor (SDKs are TS shims over the same optional native bins) and this guarantees the dynamic import in sdk.ts always resolves regardless of runtime or installer. Closes #689 Co-authored-by: gustav-fff <286169375+gustav-fff@users.noreply.github.com>
Closes #668
Root cause
packages/pi-fff/src/index.ts:21had a top-levelimport { FileFinder } from "@ff-labs/fff-node".@ff-labs/fff-nodepullsffi-rsand the optional per-platform native binary packages (@ff-labs/fff-bin-*) into its module graph. oh-my-pi statically resolves every extension import to validate the extension; the optional native package for a foreign platform is not on disk, so validation fails even though the runtime install would be fine.Reporter also flagged that pi runs under both bun and node — but pi-fff only ever loaded the node SDK, so bun hosts paid the ffi-rs cost instead of using
@ff-labs/fff-bunwhich shares the sameFileFinderApi.Fix
FileFindervalue import; keep@ff-labs/fff-nodefor type-only imports (erased at compile time, invisible to the static validator).detectRuntime()checksglobalThis.Bunandprocess.versions.bun.loadSdk()does a variable-nameawait import(pkg)for the runtime-appropriate SDK, with a fallback to the other one. Variable-name import defeats static resolvers.sdkPromiseso a single load survives concurrent tool calls.ensureFinder()nowawait loadSdk()beforeFileFinder.create(...); the existing in-flight-promise guard from pi-fff: parallel ffgrep calls can hang indefinitely due to unsynchronized ensureFinder singleton #403 still serializes creation.package.json: add@ff-labs/fff-bunas an optional peer dependency so bun-hosted pi pulls it in without forcing node-hosted pi to install it.Both SDKs implement the identical
FileFinderApi(packages/shared/fff-api.ts:528), so the call sites don't change.Steps to reproduce
Expected: extension loads under oh-my-pi.
Actual: validator errors on the unresolved optional native package.
How verified
cd packages/pi-fff && bun run typecheck— clean.bun test test/— 18/18 pass (added mock for@ff-labs/fff-bunalongside@ff-labs/fff-nodesince bun-hosted tests now prefer the bun SDK).bun run format— no changes.Not verified end-to-end against a real oh-my-pi install — that would need the pi validator in the loop. @dmtrKovalenko please smoke-test under omp before releasing.
Automated triage via Gustav. Honk-Honk 🪿