diff --git a/doc/api/cli.md b/doc/api/cli.md index 8c241e7202bdb8..40a051515279b9 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1381,6 +1381,18 @@ added: Enable experimental support for the QUIC protocol. +### `--experimental-repl-enhancements` + + + +> Stability: 1 - Experimental + +Enable experimental REPL enhancements including inline syntax highlighting, +auto-indentation, and function signature hints. See the +[REPL][] documentation for details. + ### `--experimental-sea-config` + +> Stability: 1 - Experimental + +These features require the `--experimental-repl-enhancements` flag. + +```bash +node --experimental-repl-enhancements +``` + +When the flag is enabled and `useColors` is `true`, the REPL highlights +JavaScript input using the following color scheme: + +* **Keywords** (`const`, `let`, `function`, `if`, `return`, etc.): Magenta +* **Strings** (single-quoted, double-quoted, and template literals): Green +* **Numbers**: Yellow +* **Boolean literals** (`true`, `false`), `null`, `undefined`, `NaN`, + `Infinity`: Yellow +* **Regular expressions**: Red +* **Comments** (line and block): Gray + +Syntax highlighting is applied only to the display; the internal `line` +property remains plain text. Highlighting can be disabled by passing +`syntaxHighlighting: false` to [`repl.start()`][]. + +### Auto-indentation + + + +> Stability: 1 - Experimental + +When the `--experimental-repl-enhancements` flag is enabled and entering +multi-line input (e.g., a function body or an object literal), the REPL +automatically indents continuation lines based on the current nesting +depth of braces (`{}`), brackets (`[]`), and parentheses (`()`). The REPL +uses 2-space indentation following the Node.js coding convention. + +### Function signature hints + + + +> Stability: 1 - Experimental + +When the `--experimental-repl-enhancements` flag is enabled and the user +types a function name followed by `(`, the REPL displays the function's +parameter list as a dimmed hint below the input line. This uses the V8 +inspector protocol to safely extract function signatures without side +effects. Signature hints require the `preview` option to be enabled and +the inspector to be available. + ## Class: `REPLServer`