Skip to content
A simple 8-bit icon depicts a computer monitor displaying a code editor with colored lines, a play button for running code, and a pause icon indicating a breakpoint. A blue bug symbol in the corner represents debugging, while a log file icon sits beside the window, and a gear icon suggests settings. The design uses five flat corporate colors and geometric shapes on a transparent background.

Debugging Scripts

The GenAIScript script files are executable JavaScript and can be debugged using the Visual Studio Code Debugger, just like any other JavaScript program.

A screenshot of a debugging session in a code editor with a breakpoint set on a line of code. The editor is displaying several panels including the watch variables, call stack, and a terminal output. The code is partially visible with a function definition and JSON configuration data.
  • Open the .genai.mjs file to debug and add breakpoints.
  • Right click in the editor of the file you want in env.files.
  • Select the GenAIScript from the picker.
  • Add a files field in the script function
script({
...,
files: "*.md"
})
  • Click on the Debug icon button on the editor menu (hidden under the run button).

The debugger will launch the cli and run the script in debug mode. The debugger will stop at the breakpoints you set.

The JavaScript executes in an external node process. Therefore,

  • The trace preview and output is not supported while debugging.

Keep iterating the script or add tests.