Skip to content

feat(adapters): JS/TS and Python adapters with native locations (#12) - #17

Merged
joncrangle merged 9 commits into
masterfrom
feat/12-js-python-adapters
Sep 9, 2026
Merged

joncrangle merged 9 commits into
masterfrom
feat/12-js-python-adapters

Conversation

@joncrangle

Copy link
Copy Markdown
Owner

Closes #12.

Replace legacy JS/TS and Python wrappers with runtime-specific adapters executing user source unchanged, using native call-site/frame locations and a spoof-proof framed event protocol.

What changed:

  • New shared framed protocol (adapters/framed.lua): RS + per-run nonce + JSON, strict validation, malformed records ignored
  • New javascript adapter: single ESM launcher for Node/Bun/Deno; console interception via Error().stack filtered to user file; native util.format semantics; import failures reported without killing pending async work; native V8 and file:// stack parsing; no currentLine rewriting or offset arithmetic
  • New python adapter: source execd unchanged with its own filename; print() via caller-frame walk with sep/end/file/flush preserved; native tracebacks to deepest user frame; handles CPython printing tracebacks through print(file=sys.stderr); no try:-indent or manufactured LINE errors
  • Runtime wiring: all JS/TS runtimes use javascript adapter, python/uv use python adapter; temp-file execution with adapter-managed cleanup; deno runs with --allow-read for file URLs
  • Legacy JS/Python wrappers and parser branches kept as fallback

Tests:

  • 20 new spec tests (framed/javascript/python adapter specs) passing
  • All pre-existing specs unaffected; e2e runtimes_spec expectations verified per runtime locally (node/bun/deno/python)
  • Full minitest needs CI

JS console.warn now emits warning kind (was stdout, rendered grey). Renderer maps warning to highlights.warning (DiagnosticWarn) and error/stderr to DiagnosticError, stdout to Comment; mapping lives only in renderer. Python helper labels prints during exception handling as error diagnostics via native exc_info with unchanged sources and native frame locations. Harden renderer/adapter specs with highlight-group assertions.
…irst decoding

Preserve project-relative resolution by creating adapter source files in the run cwd (with OS-temp fallback) and prepending the source dir to sys.path. Decode nonce-authenticated framed records before legacy wrapper-noise filtering. Map native JS syntax-error path:line preambles (helper + Lua fallback) and omit null coordinates instead of emitting JSON null, which vim.NIL failed to validate and silently dropped events. Preserve explicit Python print end= terminators. Add integration tests for imports, noise survival, syntax locations, end=, and padded-selection extmark rows.
Project-local source files use run-unique leaf names (never tempname basenames) with O_EXCL wx creation, retrying on collision: pre-existing user files can never be truncated. Falls back to existence-checked creation where luv predates wx, and to the OS temp dir when the project dir is unusable. Adds collision and uniqueness regression tests.
Generate run-unique leaf names from pid + hrtime + monotonic counter instead of reseeding the process-global RNG. Uniqueness never depended on randomness; the exclusive-create loop remains the safety net.
Google's Chrome repo intermittently serves inconsistent metadata (Hash Sum mismatch), failing dependency setup on Ubuntu runners before any test runs. It is unrelated to our dependencies.
Prints exit code, captured streams, node version, and temp file readability when the project-relative import test sees unexpected event counts. Revert once root-caused.
The Chrome repo lives under varying list filenames per image; the first fix only removed one name. Grep out every source referencing dl.google.com so a broken upstream mirror cannot fail Ubuntu setup.
@joncrangle
joncrangle merged commit d7cc2dd into master Sep 9, 2026
4 checks passed
@joncrangle
joncrangle deleted the feat/12-js-python-adapters branch September 9, 2026 18:05
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.

Execute JavaScript/TypeScript and Python with minimal source transformation

1 participant