Run and debug
Run and Debug starts your program under a debugger, stops at breakpoints and lets you inspect variables, the call stack and the console. Agents can drive the same debugger themselves: set breakpoints, start a session and read the state when it stops.
What it is#
IZ Code uses the debug protocol (DAP) and the debugger extensions you already know from VS Code. Launch configurations live in .vscode/launch.json and tasks in .vscode/tasks.json, so a project that is set up for debugging in VS Code works as is.
IZ Code does not ship language debuggers. Install the debugger extension for your language from the Extensions panel, for example JavaScript Debugger (ms-vscode.js-debug) for Node.js and browser pages.
The Run and Debug view#
Click Run and Debug in the Activity Bar. The view has:
- a configuration picker with Start Debugging (▶) and a More Actions... menu with Start Without Debugging, Stop, Restart, Open launch.json, Add Configuration..., Enable All Breakpoints, Disable All Breakpoints, Remove All Breakpoints and Open Debug Console;
- Variables, Watch, Call Stack, Breakpoints and Loaded Scripts sections, plus any views a debugger extension adds (for example a Network view);
- a floating debug toolbar while a session runs, with Continue, Pause, Step Over, Step Into, Step Out, Restart and Stop. Drag it to move it; double-click to put it back.
When more than one session runs (a compound configuration, or a parent and child process), a session picker lets you switch between them.
Debug a program#
- Install a debugger extension Open the Extensions panel and install the debugger for your language.
- Create a launch configuration
In Run and Debug, choose Create a launch.json file, then Add Configuration.... IZ Code adds a starter configuration for the debugger that fits the open file (pick one if asked). Your existing comments and formatting in
launch.jsonare kept. - Set breakpoints Click a line's gutter to add a breakpoint. In the Breakpoints section you can add a function breakpoint, turn breakpoints on and off, and choose which Exceptions to break on.
- Start debugging Pick the configuration and click Start Debugging. The editor opens the file where the program stopped and highlights the current line.
- Inspect and step Read Variables and the Call Stack, add expressions to Watch, evaluate expressions in the Debug Console, and step with the toolbar.
A minimal Node.js configuration:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run app",
"program": "${workspaceFolder}/src/index.js"
}
]
}Compound configurations ("compounds") and preLaunchTask work as in VS Code. If a pre-launch task fails, IZ Code asks whether to Debug Anyway.
To debug a web page in IZ Code's own browser tab, use a configuration of type editor-browser. See Browser preview.
Let the agent debug#
With Let agents use Run and Debug on, agents get a short guide in each new session and these tools:
| Tool | What it does |
|---|---|
debugListLaunchConfigs | Lists the configurations in launch.json. |
debugSuggestLaunchConfig | Suggests a configuration from the installed debugger extensions. |
debugStart | Starts a named configuration or an inline one, and can wait until the program stops. |
debugListSessions, debugGetStatus | Shows running sessions and whether they are stopped. |
debugSetBreakpoints | Sets the breakpoints of a file (replaces the file's list). |
debugContinue, debugStepOver, debugStepIn, debugStepOut | Resumes or steps. |
debugGetCallStack, debugGetVariables, debugEvaluate | Reads the stack, variables and expression values. |
debugGetConsoleOutput | Reads the program's output. |
debugListExceptionFilters, debugSetExceptionBreakpoints | Breaks on exceptions. |
debugStop | Ends a session. |
listBuildTasks, runBuildTask | Lists and runs tasks from .vscode/tasks.json. |
A typical request: "The total is wrong for an empty cart. Put a breakpoint in calculateTotal, run the tests under the debugger and tell me what items holds." The agent sets the breakpoint, starts the session, waits for the stop, reads the variables and reports back. Sessions the agent starts appear in the Run and Debug view like your own, so you can take over at any point.
sequenceDiagram
participant A as Agent
participant D as Debugger
participant P as Your program
A->>D: debugSetBreakpoints
A->>D: debugStart
D->>P: Launch
P-->>D: Stops at breakpoint
A->>D: debugGetVariables
D-->>A: Variable valuesIn a workspace with several folders, the agent can name the folder whose launch.json to use.
Settings#
| Setting | Values | Default |
|---|---|---|
izcode.debug.enableChatTools (Settings ▸ Run and Debug ▸ Let agents use Run and Debug) | true, false | true |
Off removes the guide and the debug*, listBuildTasks and runBuildTask tools, and refuses every call to them. In a project's .izcode/settings.json you can only turn it off, not on.
Limits#
Related#
Debug pages in a browser tab.
BrowserMulti-root workspacesLaunch configurations per folder.
Multi-rootPermissions and toolsWhich agent tools ask first.
Permissions