Skip to content

refactor(pocket-pi): TypeScript build pipeline for the JS guest layer - #4

Merged
doodlewind merged 2 commits into
mainfrom
feat/ts-glue-build-pipeline
Jul 22, 2026
Merged

refactor(pocket-pi): TypeScript build pipeline for the JS guest layer#4
doodlewind merged 2 commits into
mainfrom
feat/ts-glue-build-pipeline

Conversation

@doodlewind

Copy link
Copy Markdown
Contributor

Phase 3 of the effort (follows the pi 0.81 bump + self-contained binary in #3). The JS glue was hand-dropped .js; now it's TypeScript under js/src/, compiled by one build step.

Does this affect future pi bumps? No.

The glue is Pocket Pi's own runtime layer, separate from pi (still a real, unmodified npm dependency that gets bundled). A bump stays npm update + rebuild + (if the newer pi needs a new builtin/global) add a shim — and the shim being .ts instead of .js changes nothing. The bundle output is JS regardless (esbuild takes a .ts entry). If anything, the typecheck makes the "fix what breaks" step safer.

Layout

js/src/runtime/**  → crates/pocket-pi/js/**             (per-file transpile; include_str!'d)
js/src/trimmed/**  → crates/pocket-pi/js/agent.bundle.js
js/src/pi-full/**  → crates/pocket-pi/js/pi-full.bundle.js(.gz) + harness scripts
  • One node js/build.mjs runs tsc --noEmit (typecheck) + esbuild (transpile the runtime glue, emit the harness scripts, bundle the trimmed + full pi). esbuild and typescript are real devDeps now (no more npx esbuild@…); build-pi-full.mjs folded in.
  • Rust include_str! paths are unchanged — the build emits .js exactly where they're expected. The emitted runtime .js + agent.bundle.js are committed so cargo still builds Rust-only; the full-pi bundle stays git-ignored.
  • tsconfig typechecks Pocket Pi's own orchestration code (the pi-full session harness). The runtime polyfills and the pi-ai/undici adapter glue are transpile-only — typechecking a polyfill against the very APIs it reimplements is counterproductive. env.d.ts declares the loose host/global surface.
  • The trimmed bundle now builds against pi 0.81 too (the pi-ai stub gains contentText/retryAssistantCall/uuidv7, which 0.81's pi-agent-core imports).

Tests / CI

Full suite green — 23 unit tests + 8 #[ignore] (bundle load, extension bind, extension tool turn, persistence, embedded full pi); tsc + clippy -D warnings clean.

🤖 Generated with Claude Code

doodlewind and others added 2 commits July 22, 2026 14:01
…peline

The JS glue was hand-dropped .js files. Now all of it is TypeScript under
js/src/, compiled by one build step (js/build.mjs) that emits the artifacts the
Rust crate embeds. This does NOT affect future pi bumps — the glue is Pocket Pi's
own runtime layer, entirely separate from pi (which is still a real unmodified
npm dependency, bundled). A bump stays `npm update` + rebuild + (if needed) add a
shim; the shim being .ts changes nothing.

Layout:
  js/src/runtime/**   → crates/pocket-pi/js/**            (per-file transpile; include_str!'d)
  js/src/trimmed/**   → crates/pocket-pi/js/agent.bundle.js
  js/src/pi-full/**   → crates/pocket-pi/js/pi-full.bundle.js(.gz) + harness scripts

- One `node js/build.mjs` runs tsc (typecheck) + esbuild (transpile runtime glue,
  emit harness scripts, bundle trimmed + full pi). esbuild/typescript are real
  devDeps now (no more `npx esbuild@…`). build-pi-full.mjs folded in.
- The emitted runtime .js and agent.bundle.js are committed so `cargo` still
  builds Rust-only; the full pi bundle stays git-ignored.
- tsconfig typechecks Pocket Pi's own orchestration code (the pi-full session
  harness); the runtime polyfills and pi-ai/undici adapter glue are transpile-
  only (typechecking a polyfill against the APIs it reimplements is
  counterproductive). env.d.ts declares the loose host/global surface.
- Rust include_str! paths are UNCHANGED (emit lands where they expect). Only the
  test harness paths moved (js/pi-full → crates/pocket-pi/js/pi-full for emitted
  scripts, js/src/pi-full for the example extension).

Along the way the trimmed bundle now builds against pi 0.81 too (pi-ai-stub gains
contentText/retryAssistantCall/uuidv7, which 0.81's pi-agent-core imports).

Full suite green (23 unit + 8 ignored: bundle load, extension bind + tool turn,
persistence, embedded full pi), typecheck + clippy clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@doodlewind
doodlewind merged commit 6a62574 into main Jul 22, 2026
1 check passed
@doodlewind
doodlewind deleted the feat/ts-glue-build-pipeline branch July 22, 2026 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant