Commit Graph

15 Commits

Author SHA1 Message Date
Claude Bot
3e55d2b19e fix(repl): address CodeRabbit review comments
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>
2026-01-20 22:49:41 +00:00
Claude Bot
55d23bdc12 fix(repl): use cross-platform file descriptor APIs for Windows compatibility
- 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>
2026-01-20 22:34:16 +00:00
Claude Bot
0976fd30ee fix(repl): include source location in parse error messages
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>
2026-01-20 22:23:04 +00:00
Claude Bot
a1fde6caad refactor(repl): use bun.path.join for history path construction
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>
2026-01-20 22:15:06 +00:00
Claude Bot
aa5ea829a2 feat(repl): add shell command support and fix async event loop handling
- 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>
2026-01-20 22:11:14 +00:00
Claude Bot
4815c10efe fix(repl): address fourth round of CodeRabbit review comments
- 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>
2026-01-20 22:00:59 +00:00
Claude Bot
eb804bd8e0 fix more review feedback issues
- 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>
2026-01-20 21:45:33 +00:00
Claude Bot
702e8448d6 address additional code review feedback
- 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>
2026-01-20 21:26:55 +00:00
Claude Bot
be79d67802 address code review feedback for REPL
- 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>
2026-01-20 21:11:55 +00:00
autofix-ci[bot]
f5018d71df [autofix.ci] apply automated fixes 2026-01-20 20:53:57 +00:00
Claude Bot
261f429fd1 feat(repl): add JSC-based autocomplete for object properties
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>
2026-01-20 20:44:24 +00:00
Claude Bot
018358d8a1 feat(repl): persist history to ~/.bun_repl_history
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>
2026-01-20 20:35:31 +00:00
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