1. Fix blank line handling in readLineSimple - blank lines in piped input
are now treated as valid input instead of EOF. Only return null when
a true EOF is encountered with no pending data.
2. Replace std.fs.path.join with bun.path.join in saveHistory for
cross-platform path construction.
3. Fix enterEditorMode to use cross-platform APIs - replace
std.posix.STDIN_FILENO and std.posix.read with bun.FileDescriptor.stdin()
and bun.sys.read() for Windows compatibility.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Replace std.posix.STDIN_FILENO with bun.FileDescriptor.stdin()
- Use bun.sys.read() instead of std.posix.read() for cross-platform I/O
- Add conditional compilation to skip POSIX termios APIs on Windows
- Windows falls back to simple line reading mode
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Parse error messages now include line and column information when
available (e.g., "Parse error [1:5]: Unexpected token") to help users
locate the source of syntax errors more easily.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace std.fs.path.join with bun.path.join for cross-platform path
construction as suggested in code review. The bun.path helper provides
consistent path handling across platforms.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add $`command` syntax for running shell commands in REPL
- Transform $`...` to await Bun.$`...` for shell execution
- Fix event loop handling for async operations by calling autoTick()
- Now properly awaits Bun.sleep(), setTimeout(), and Bun.$ operations
- Add tests for shell commands and Bun.sleep
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix BracketDepth.template tracking: decrement template count when
closing template literal and check template depth in needsContinuation()
- Fix reverseSearch: show proper "not yet implemented" message instead
of confusing prompt that suggests waiting for input
- Fix evalDirect: await promises like eval() does for consistent async
behavior
- Fix getHistoryPath: use std.fs.path.join instead of manual string
formatting for cross-platform correctness
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix History.next() underflow guard for empty history
- Fix saveHistory to resolve relative paths to absolute
- Fix completion suffix bounds check for property completions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix .install command prefix parsing (.i alias used wrong offset)
- Fix loadFile to resolve paths to absolute paths first
- Remove silent fallback in saveToFile, emit warning instead
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Delete .bun_repl_history and add to .gitignore
- Fix memory leak in getCompletions for property names
- Use vm.waitForPromise instead of manual event loop polling
- Add proper cleanup for stores and arena on init failure
- Remove manual timeout from test helper
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The REPL now provides intelligent autocomplete for object properties
by dynamically querying the JSC runtime. When typing `obj.` and pressing
Tab, the REPL will show available properties from the actual object.
Features:
- Property completion for any object (e.g., `Bun.`, `console.`)
- Navigates nested paths (e.g., `Bun.file.`)
- Includes both own properties and prototype chain
Also adds tests for class persistence and destructuring to verify
the full AST transforms work correctly.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The REPL now saves command history to the user's home directory
($HOME/.bun_repl_history or %USERPROFILE%\.bun_repl_history on Windows).
History is automatically loaded when the REPL starts and saved on exit.
The .save command can still be used to save history to a custom file.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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>
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>
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>