Commit Graph

3 Commits

Author SHA1 Message Date
Claude Bot
73cd4e92bb feat(repl): integrate full transpiler with replMode for AST transforms
This replaces the simple string-based let/const->var transform with
Bun's full transpiler in replMode, enabling:

- Proper hoisting of let/const/var/function/class declarations
- Top-level await support via async IIFE wrapping
- Result capture in { value: expr } wrapper
- Object literal disambiguation (wrapping { } in parens)
- Class and function declarations that persist across lines

The REPL now properly awaits promises by running the event loop
until they resolve, allowing `await Promise.resolve(42)` to work.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:28:02 +00:00
Claude Bot
efa6eab698 feat(repl): add simple REPL transforms for let/const persistence
Add a simple string-based transform that converts top-level `let` and
`const` declarations to `var`, which allows variables to persist across
REPL lines since `var` declarations become properties of the global
object in sloppy mode.

This is a temporary solution until we can properly integrate the
AST-based repl_transforms.zig module with the transpiler pipeline.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 18:34:12 +00:00
Claude Bot
d0bf75f88f feat(repl): implement native Zig REPL for bun repl
This implements a new REPL in Zig that replaces the previous bunx-based
REPL. The new REPL provides:

- Interactive line editing with cursor movement and history navigation
- Syntax highlighting using QuickAndDirtyJavaScriptSyntaxHighlighter
- Multi-line input with bracket matching detection
- REPL commands (.help, .exit, .clear, .load, .save, .editor, .timing)
- JavaScript evaluation using the global eval() function
- Pretty-printed output for evaluated expressions
- Support for both TTY (interactive) and non-TTY (piped) input

The REPL properly initializes the JSC VirtualMachine with the API lock
held, enabling safe JavaScript execution. It uses Bun's transpiler
infrastructure and output formatting.

TODO:
- Implement REPL transforms for variable persistence across lines
- Integrate package installation
- Add shell mode integration
- Implement JSC-based autocomplete

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 18:26:35 +00:00