SIGN IN SIGN UP

Add --smoke-tree-sitter flag and fail builds with empty embed

Freebuff 0.0.64 still crashed for users with the same wasm error even
though it was built from a commit that contained the base64 embed. The
runtime stack trace pointed at the path-resolution fallback in
init-node.ts:76, meaning the embed didn't reach the SDK bundle's
globalThis check at runtime — the binary fell through to fs.existsSync
which never works on Windows bunfs paths.

Two hardening passes so this can't ship silently again:

- cli/src/pre-init/tree-sitter-wasm.ts: hidden `--smoke-tree-sitter`
  flag, handled in the very first import. Calls Parser.init({ wasmBinary
  }) directly with the embedded base64 and exits 0/1. Lives here (not
  commander) on purpose — it tests *the embed*, not the broader init
  path that has a path-resolution fallback that would mask a broken
  embed by passing in dev mode.
- cli/scripts/build-binary.ts: post-bun-compile, scan the output binary
  for the wasm's base64 prefix. Build fails if the bytes didn't actually
  make it through bundling (e.g. bun dropping a huge string literal,
  bundle cache reading a stale empty stub). Always-on log of which path
  the wasm was resolved from so CI logs make the embed step diagnosable.
  More resilient resolve: search workspace root, cli/node_modules, and
  sdk/node_modules before falling back to createRequire — Windows CI's
  `bun install --cwd cli` lays out web-tree-sitter differently than
  a hoisted root install.
- packages/code-map/src/init-node.ts: accept bunfs paths
  (`/~BUN/root/...`) without an fs.existsSync check. fs.existsSync
  inconsistently returns false for bun --compile asset paths on Windows
  even though the runtime can read them, so the existing path-resolution
  fallback was permanently broken on Windows. Belt-and-braces: this
  makes the fallback work even if the embed step regresses.
- cli/scripts/smoke-binary.ts: run --smoke-tree-sitter as a deterministic
  pre-check before the long-window boot smoke. A broken embed fails fast
  with a clear "exit code 1, no boot ok marker" error instead of a 10s
  timeout that depends on render-loop timing.

Verified locally: build embeds 205KB wasm as 274KB base64, post-build
verification finds the prefix in the compiled binary, --smoke-tree-sitter
exits 0 with "tree-sitter smoke ok", full smoke passes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
J
James Grugett committed
1b6333e46ea717c4d347dfce1f63efdf05f1394c
Parent: 6b3dcd1