Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): run the last bun-dependent tooling on Node (#3141)

Andrew Mikofalvy4f7566273b5e
diff --git a/packages/app/scripts/measure-fuzz.sh b/packages/app/scripts/measure-fuzz.sh
index 49f58f8b4..9473f5c34 100755
--- a/packages/app/scripts/measure-fuzz.sh
+++ b/packages/app/scripts/measure-fuzz.sh
@@ -15,7 +15,7 @@
# -----
# bash scripts/measure-fuzz.sh --seeds 1000 --context "pre-PR-218 baseline"
# bash scripts/measure-fuzz.sh --seed-replay 1776559905522 --context "reproduce PR #206 failing seed"
-# bun run measure:fuzz --seeds 100 --context "investigate fuzz rate shift"
+# pnpm run measure:fuzz --seeds 100 --context "investigate fuzz rate shift"
#
# Flags
# -----
@@ -59,7 +59,7 @@
# "failingSeeds":[1776559905522],
# "durationMs": 8912000,
# "host": "local-macos",
-# "bunVersion": "1.3.11",
+# "nodeVersion": "v24.18.0",
# "extra": { "outcome": "pass", // "pass" | "fail"
# "failClasses": [] } // per-failing-seed oracle class
# } // [{seed, class}, ...]
@@ -129,7 +129,7 @@ if [[ -z "$CONTEXT" ]]; then
fi
# Validate numeric inputs via shared helper. Non-numeric inputs would
-# export a non-numeric env to the child `bun test` and silently coerce
+# export a non-numeric env to the child test run and silently coerce
# to NaN→1 at the PRNG layer.
assert_numeric_flag "--seeds" "$SEEDS"
if [[ -n "$SEED_REPLAY" ]]; then
@@ -162,7 +162,7 @@ fi
TIMESTAMP="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
COMMIT="$(git rev-parse --short HEAD)"
INVOKED_BY="${USER:-unknown}"
-BUN_VERSION="$(bun --version 2>/dev/null || echo unknown)"
+NODE_VERSION="$(node --version 2>/dev/null || echo unknown)"
HOST="$(detect_host)"
@@ -180,12 +180,12 @@ START_MS="$(epoch_ms)"
TEST_EXIT=0
(
# Explicit exit: errexit is suppressed inside a piped compound, so a bare
- # failed cd would let bun test run from the wrong cwd.
+ # failed cd would let the test run from the wrong cwd.
cd "$APP_DIR" || exit 1
# --conditions development resolves workspace deps from source exports
# instead of an unbuilt dist/ (the fresh-worktree state) — without it the
# run dies on missing build artifacts.
- bun test --conditions development "$TEST_FILE" 2>&1
+ pnpm exec vitest run "$TEST_FILE" 2>&1
) | tee "$OUT_FILE" || TEST_EXIT=$?
END_MS="$(epoch_ms)"
@@ -196,8 +196,8 @@ DURATION_MS=$(( END_MS - START_MS ))
# `bridge-convergence.fuzz.test.ts`'s after-all hook:
# [fuzz] RESULT seeds=<n> passed=<n> failed=<n> failingSeeds=[<s1>,<s2>,...]
# Written via `process.stdout.write`, stdout-only. Parsing this decouples
-# the script from bun's human-readable `N pass / N fail` format (which is
-# fragile to bun output drift and stderr conflation via 2>&1). Mirrors
+# the script from the runner's human-readable summary format (which is
+# fragile to output drift and stderr conflation via 2>&1). Mirrors
# `measure-stress.sh`'s RESULT-line strategy for sibling-script symmetry.
#
# When RESULT is missing the test crashed before the after-all hook could
@@ -311,7 +311,7 @@ RECORD="$(jq -c -n \
--argjson failingSeeds "$FAILING_SEEDS_JSON" \
--argjson durationMs "$DURATION_MS" \
--arg host "$HOST" \
- --arg bunVersion "$BUN_VERSION" \
+ --arg nodeVersion "$NODE_VERSION" \
--argjson extra "$EXTRA_JSON" \
'{
timestamp: $timestamp,
@@ -326,7 +326,7 @@ RECORD="$(jq -c -n \
failingSeeds: $failingSeeds,
durationMs: $durationMs,
host: $host,
- bunVersion: $bunVersion,
+ nodeVersion: $nodeVersion,
extra: $extra
}')"
@@ -354,7 +354,7 @@ if [[ "$SEEDS_FAILED" != "0" ]]; then
echo "──────── failing seed replay commands ────────"
while IFS= read -r seed; do
[[ -z "$seed" ]] && continue
- echo " STRESS_FUZZ_SEED=$seed bun test --conditions development $TEST_FILE # in $APP_DIR"
+ echo " STRESS_FUZZ_SEED=$seed pnpm exec vitest run $TEST_FILE # in $APP_DIR"
done <<< "$FAILING_SEEDS_LIST"
echo ""
fi
diff --git a/packages/app/scripts/measure-stress.sh b/packages/app/scripts/measure-stress.sh
index d196fa726..68d81e9b3 100755
--- a/packages/app/scripts/measure-stress.sh
+++ b/packages/app/scripts/measure-stress.sh
@@ -18,7 +18,7 @@
# -----
# bash scripts/measure-stress.sh --seed 42 --context "pre-PR-218 baseline"
# bash scripts/measure-stress.sh --context "investigate 2026-04 rate shift"
-# bun run measure:stress --seed 1776381158793 --context "reproduce CI flake"
+# pnpm run measure:stress --seed 1776381158793 --context "reproduce CI flake"
#
# Flags
# -----
@@ -115,7 +115,7 @@ fi
TIMESTAMP="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
COMMIT="$(git rev-parse --short HEAD)"
INVOKED_BY="${USER:-unknown}"
-BUN_VERSION="$(bun --version 2>/dev/null || echo unknown)"
+NODE_VERSION="$(node --version 2>/dev/null || echo unknown)"
HOST="$(detect_host)"
@@ -130,12 +130,12 @@ START_MS="$(epoch_ms)"
TEST_EXIT=0
(
# Explicit exit: errexit is suppressed inside a piped compound, so a bare
- # failed cd would let bun test run from the wrong cwd.
+ # failed cd would let the test run from the wrong cwd.
cd "$APP_DIR" || exit 1
# --conditions development resolves workspace deps from source exports
# instead of an unbuilt dist/ (the fresh-worktree state) — without it the
# run dies on missing build artifacts.
- bun test --conditions development "$TEST_FILE" 2>&1
+ pnpm exec vitest run "$TEST_FILE" 2>&1
) | tee "$OUT_FILE" || TEST_EXIT=$?
END_MS="$(epoch_ms)"
@@ -153,15 +153,22 @@ DURATION_MS=$(( END_MS - START_MS ))
# (2) Machine-parseable result line — printed AFTER all assertions pass:
# [stress] RESULT outcome=pass seed=<n> edits=<n> convergenceMs=<n>
# Written via `process.stdout.write`, stdout-only (never stderr), so
-# the grep below is unambiguous and insensitive to bun output drift.
+# the grep below is unambiguous and insensitive to runner output drift.
#
-# Parsing the test's own structured lines — not bun test's human summary —
-# decouples the script from bun's output format (Minor #3 fix).
+# Parsing the test's own structured lines — not the runner's human summary —
+# decouples the script from the runner's output format.
ACTUAL_SEED_BANNER="$(grep -oE '\[server-authoritative stress\] seed=[0-9]+' "$OUT_FILE" \
| awk -F= '{print $2}' | head -1 || true)"
+# Secondary source: the RESULT line carries the same seed. It is emitted only on
+# a pass, so it cannot replace the banner for crash runs, but it keeps a passing
+# run attributable if the banner is ever lost again.
+ACTUAL_SEED_RESULT="$(grep -oE '^\[stress\] RESULT .*seed=[0-9]+' "$OUT_FILE" \
+ | grep -oE 'seed=[0-9]+' | awk -F= '{print $2}' | head -1 || true)"
if [[ -n "$ACTUAL_SEED_BANNER" ]]; then
ACTUAL_SEED="$ACTUAL_SEED_BANNER"
+elif [[ -n "$ACTUAL_SEED_RESULT" ]]; then
+ ACTUAL_SEED="$ACTUAL_SEED_RESULT"
elif [[ -n "$SEED" ]]; then
ACTUAL_SEED="$SEED"
else
@@ -186,7 +193,7 @@ HAS_RESULT_PASS="${HAS_RESULT_PASS:-0}"
# (post-test teardown failure). Abort without appending so
# the trend log stays a record of true measurements.
#
-# Note: on a successful run, exit code alone is not sufficient — a bun
+# Note: on a successful run, exit code alone is not sufficient — a runner
# test that ran but reported an assertion failure still has exit != 0.
# A pass requires both the RESULT line AND exit 0; they corroborate.
SEED_COUNT=1
@@ -195,7 +202,7 @@ if [[ "$TEST_EXIT" -eq 0 && "$HAS_RESULT_PASS" -ge 1 ]]; then
SEEDS_FAILED=0
RATE="0.0000"
FAILING_SEEDS_JSON="[]"
-elif [[ "$TEST_EXIT" -ne 0 && -n "$ACTUAL_SEED_BANNER" && "$HAS_RESULT_PASS" -eq 0 ]]; then
+elif [[ "$TEST_EXIT" -ne 0 && -n "$ACTUAL_SEED" && "$HAS_RESULT_PASS" -eq 0 ]]; then
OUTCOME="fail"
SEEDS_FAILED=1
RATE="1.0000"
@@ -247,7 +254,7 @@ RECORD="$(jq -c -n \
--argjson failingSeeds "$FAILING_SEEDS_JSON" \
--argjson durationMs "$DURATION_MS" \
--arg host "$HOST" \
- --arg bunVersion "$BUN_VERSION" \
+ --arg nodeVersion "$NODE_VERSION" \
--argjson extra "$EXTRA_JSON" \
'{
timestamp: $timestamp,
@@ -261,7 +268,7 @@ RECORD="$(jq -c -n \
failingSeeds: $failingSeeds,
durationMs: $durationMs,
host: $host,
- bunVersion: $bunVersion,
+ nodeVersion: $nodeVersion,
extra: $extra
}')"
@@ -281,7 +288,7 @@ echo ""
if [[ "$OUTCOME" == "fail" ]]; then
echo "──────── failure replay command ────────"
- echo " STRESS_SEED=$ACTUAL_SEED bun test --conditions development $TEST_FILE # in $APP_DIR"
+ echo " STRESS_SEED=$ACTUAL_SEED pnpm exec vitest run $TEST_FILE # in $APP_DIR"
echo ""
fi
diff --git a/packages/app/scripts/perf-prod.sh b/packages/app/scripts/perf-prod.sh
index 7fe630e39..06bef6b4c 100755
--- a/packages/app/scripts/perf-prod.sh
+++ b/packages/app/scripts/perf-prod.sh
@@ -4,7 +4,7 @@
#
# Orchestrates build → start CLI → run perf:profile N times → tear down.
# Gives developers a one-command path to measure against the built artifact
-# (equivalent to what ships to users) instead of `bun run dev` (Vite HMR
+# (equivalent to what ships to users) instead of `pnpm run dev` (Vite HMR
# + transform overhead, uncomparable).
#
# Usage:
@@ -19,7 +19,7 @@
# packages/app/scripts/perf-prod.sh --scenario=mode-toggle --runs=10
#
# What it does (precedent #22 shell-script conventions):
-# 1. Runs `bun run build` from repo root (turbo-cached; no-op when clean).
+# 1. Runs `pnpm run build` from repo root (turbo-cached; no-op when clean).
# 2. Starts TWO CLI processes on kernel-assigned ports:
# a. `open-knowledge start --port 0` — collab server (Hocuspocus +
# /api/*). Polls `.ok/server.lock` for bound port.
@@ -29,7 +29,7 @@
# Post-2026-04-16 CLI split: `ok start` is collab-only (no static
# assets), `ok ui` is the sole server of the React bundle. Playwright
# must navigate against the UI port, NOT the collab port.
-# 3. Runs `bun run perf:profile --scenario=<name> --target=http://localhost:<ui-port> --headless`
+# 3. Runs `pnpm run perf:profile --scenario=<name> --target=http://localhost:<ui-port> --headless`
# N times. Results land at `packages/app/tests/perf/results/<scenario>.<ts>.json`.
# 4. Sends SIGTERM to both processes; CLI's CC8 shutdown ordering releases
# both locks cleanly. Waits up to 5s for both locks to disappear.
@@ -98,9 +98,9 @@ RESULTS_DIR="$REPO_ROOT/packages/app/tests/perf/results"
echo "[perf-prod] Building app + cli (turbo cache-friendly; no-op when clean)…"
cd "$REPO_ROOT"
-if ! bun run build >/dev/null 2>&1; then
- echo "error: bun run build failed — re-run manually to see output:" >&2
- echo " cd $REPO_ROOT && bun run build" >&2
+if ! pnpm run build >/dev/null 2>&1; then
+ echo "error: pnpm run build failed — re-run manually to see output:" >&2
+ echo " cd $REPO_ROOT && pnpm run build" >&2
exit 2
fi
@@ -155,7 +155,7 @@ UI_LOG="$(mktemp -t perf-prod-ui.XXXXXX.log)"
#
# TODO: replace with upstream totalist fix — see tmp/ship/
# totalist-sirv-crash-brief.md for the full repro + fix options. The
-# brief proposes a `bun patch [email protected]` that wraps readdirSync +
+# brief proposes a `pnpm patch [email protected]` that wraps readdirSync +
# statSync in try/catch (ENOENT/EACCES/ENOTDIR → skip). Once that patch
# lands, this pre-flight becomes dead code and can be deleted.
if [[ -d "$REPO_ROOT/tmp" ]]; then
@@ -277,12 +277,12 @@ for i in $(seq 1 "$RUNS"); do
# KEY=value tokens space-separated. An empty string is a no-op.
if [[ -n "$EXTRA_ENV" ]]; then
# shellcheck disable=SC2086
- if ! env $EXTRA_ENV bun run perf:profile --scenario="$SCENARIO" --target="http://localhost:$PORT" --headless; then
+ if ! env $EXTRA_ENV pnpm run perf:profile --scenario="$SCENARIO" --target="http://localhost:$PORT" --headless; then
run_failures=$((run_failures + 1))
echo "[perf-prod] WARN: run $i exited non-zero — continuing" >&2
fi
else
- if ! bun run perf:profile --scenario="$SCENARIO" --target="http://localhost:$PORT" --headless; then
+ if ! pnpm run perf:profile --scenario="$SCENARIO" --target="http://localhost:$PORT" --headless; then
run_failures=$((run_failures + 1))
echo "[perf-prod] WARN: run $i exited non-zero — continuing" >&2
fi
diff --git a/packages/app/tests/stress/server-authoritative-stress.test.ts b/packages/app/tests/stress/server-authoritative-stress.test.ts
index 03772aa52..07d24154f 100644
--- a/packages/app/tests/stress/server-authoritative-stress.test.ts
+++ b/packages/app/tests/stress/server-authoritative-stress.test.ts
@@ -195,8 +195,12 @@ describe('server-authoritative stress (US-013)', () => {
} else {
seed = Date.now();
}
- console.log(
- `[server-authoritative stress] seed=${seed}${process.env.STRESS_SEED ? ' (replay)' : ''}`,
+ // Raw stdout, not console.log: measure-stress.sh greps this banner out of
+ // the captured run to recover the replay seed, and it is the ONLY seed
+ // source when the run crashes before the RESULT line. Test runners
+ // intercept and reformat console output, which drops it from the capture.
+ process.stdout.write(
+ `[server-authoritative stress] seed=${seed}${process.env.STRESS_SEED ? ' (replay)' : ''}\n`,
);
const rng = createPRNG(seed);
const clientCount = 5;
diff --git a/packages/core/tests/perf/run-regression-gate.ts b/packages/core/tests/perf/run-regression-gate.ts
index 02e487d00..a6f6c7879 100644
--- a/packages/core/tests/perf/run-regression-gate.ts
+++ b/packages/core/tests/perf/run-regression-gate.ts
@@ -38,10 +38,14 @@ function findFreshestResults(): string {
async function main(): Promise<void> {
// 1) run the bench
- const bench = spawnSync('bun', ['test', resolve(HERE, 'markdown-bench.test.ts')], {
- env: { ...process.env, RUN_BENCH: '1' },
- stdio: 'inherit',
- });
+ const bench = spawnSync(
+ 'pnpm',
+ ['exec', 'vitest', 'run', resolve(HERE, 'markdown-bench.test.ts')],
+ {
+ env: { ...process.env, RUN_BENCH: '1' },
+ stdio: 'inherit',
+ },
+ );
if (bench.status !== 0) {
console.error(`bench run failed with exit code ${bench.status ?? 'null'}`);
process.exit(bench.status ?? 1);