Skip to content

Commit 8e62733

Browse files
committed
feat(repl): add an interactive command-line debugger
Debug Robot Framework runs straight from the terminal — pause a run, see where you are, inspect and change state, run keywords in the live context, and step through execution, no editor required. It's the scriptable, terminal-native counterpart to the VS Code extension's graphical debugger. - **Two ways in.** `robotcode robot-debug <paths>` (alias `run-debug`) runs a real suite through the normal runner with the debugger attached — same output, options and arguments as `robotcode robot`, and the run keeps streaming as you step, continue or detach. `robotcode repl` (alias `shell`) now has the debugger built in too, so breakpoints fire while you try keywords at the prompt. - **Pause where you want.** Line and keyword breakpoints (`--break login.robot:42`, `--break "Open Browser"`), an embedded `Breakpoint` step in a `.robot` file, `--stop-on-entry`, and breaking on failures (uncaught failures by default, plus `--break-on-all-exceptions`, `--break-on-failed-test` and `--break-on-failed-suite`). Every stop shows why, which keyword, and where. - **Step through it.** `.step`/`.next`/`.return`/`.continue`/`.until`, plus `.detach` (stop debugging but let the run finish) and `.abort` (end it now). - **Inspect and change state.** Walk the call stack (`.where`/`.up`/`.down`/ `.frame`), list variables by scope (`.vars`), evaluate in the selected frame (`.print`/`.pprint`/`.whatis`), auto-show expressions at every stop (`.display`), set variables (`.set`), and run any keyword right at the prompt in the paused context. - **Manage breakpoints live.** List them and add conditional, one-shot, logpoint or command-list breakpoints; set conditions, ignore N hits, delete, and disable/enable by number (`.breakpoints`/`.condition`/`.ignore`/`.delete`/ `.disable`/`.enable`/`.commands`/`.tbreak`). Arm exception breakpoints on the fly with `.catch`. - **Read source and docs in place.** `.list` shows the source at the stop, `.source <kw>` a named keyword's definition; the full shell command set (`.kw`, `.doc`, `.imports`, `.save`, …) works at the debug prompt too. On the rich prompt these open in a scrollable full-screen viewer with search and links; on the plain prompt they print inline. - **Built for humans and agents alike.** Context-aware completion, syntax highlighting, persistent history and multi-line editing on the rich prompt; `--plain` (or `--backend` / `ROBOTCODE_REPL_*`) gives a bare prompt that reads commands from stdin, and the rich prompt falls back to plain automatically on piped input — so the debugger drives cleanly from scripts, CI or AI agents. - Long commands accept any unambiguous prefix; one-letter aliases mirror pdb.
1 parent 1edfe13 commit 8e62733

25 files changed

Lines changed: 5462 additions & 311 deletions

docs/03_reference/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ This reference provides a comprehensive resource for effectively using and confi
1414

1515
- [**Discovering Tests, Tasks and Suites**](discovering-tests.md): A task-oriented guide to the `robotcode discover` family of commands — turning a project's source files into a tree, flat lists, tag indexes, or a file inventory without ever executing a test. Covers Robot-native and search filters, the `TestItem` JSON schema used by editor integrations, and CI recipes for sharding, tag reports, and parse-error gates.
1616

17-
- [**Interactive Robot Framework REPL**](repl.md): A task-oriented guide to the `robotcode repl` command — a live keyword-driven shell for exploring libraries, prototyping snippets, debugging keyword behaviour and capturing ad-hoc sessions as a normal `output.xml` / `log.html`. Covers the prompt model, state persistence, file-execution and `--inspect` mode, output capture, and recipes for library exploration and CI smoke checks.
17+
- [**Interactive Robot Framework REPL**](repl.md): A task-oriented guide to the `robotcode repl` command — a live keyword-driven shell for exploring libraries, prototyping snippets, debugging keyword behaviour and capturing ad-hoc sessions as a normal `output.xml` / `log.html`. Covers the prompt model, state persistence, file-execution and `--inspect` mode, output capture, and recipes for library exploration and CI smoke checks. Also covers the built-in `pdb`-style **command-line debugger** (`robotcode robot-debug`) — breakpoints, stepping, the call stack, per-frame variables, and source listing.
18+
19+
- [**Working with AI Agents**](ai-agents.md): How **RobotCode** lets AI coding agents (GitHub Copilot Chat, Claude Code, Codex, and other Open-Plugins-compatible tools) work through the project's own `robotcode` CLI instead of guessing. Covers the bundled VS Code chat plugin and its toggle, installing the plugin in other agents via the marketplace, what the agent is taught to do (discover, libdoc, REPL, results, analyze on the resolved project), and the CLI's AI-agent detection that keeps captured terminal output clean.
1820

1921
Together, these sections provide the knowledge needed to fully customize `robotcode` for a flexible and efficient testing workflow.

docs/03_reference/repl.md

Lines changed: 223 additions & 36 deletions
Large diffs are not rendered by default.

packages/repl/src/robotcode/repl/Repl/repl.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,30 @@
44

55

66
class Repl:
7+
"""Marker library backing the RobotCode REPL/debugger integration.
8+
9+
``Breakpoint`` is the one keyword meant for use in your own suites (to pause
10+
into the debug prompt under ``robotcode robot-debug``); ``Repl`` and ``Exit``
11+
are used internally by ``robotcode repl`` and aren't normally called by hand.
12+
"""
13+
714
ROBOT_LIBRARY_SCOPE = "GLOBAL"
815
ROBOT_LIBRARY_VERSION = __version__
916

1017
def repl(self) -> None:
11-
pass
18+
"""Internal marker keyword that opens the interactive REPL prompt.
19+
20+
Called by the synthetic suite ``robotcode repl`` runs; not meant to be
21+
used directly in your own tests.
22+
"""
23+
24+
def breakpoint(self) -> None:
25+
"""No-op marker keyword: the RobotCode debugger pauses here when attached.
26+
27+
Place ``Breakpoint`` in a suite (after ``Library robotcode.repl.Repl``)
28+
to drop into the debug prompt at that point under ``robotcode robot-debug``;
29+
in a normal ``robot`` run it does nothing.
30+
"""
1231

1332
def exit(self, exit_code: int = 0) -> None:
1433
sys.exit(exit_code)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Synchronous, logger-driven Robot Framework debug core.
2+
3+
The `DebugController` consumes the keyword event stream (start/end) emitted by
4+
the interpreter's logger (see `BaseInterpreter.register_observer`) and
5+
drives pausing/stepping/inspection through a small `Frontend` protocol. It is
6+
deliberate that this core knows nothing about threads, sockets, or DAP — those
7+
are concerns of a particular front-end. The CLI front-end is the
8+
`ConsoleInterpreter` itself (it implements `Frontend.wait_at_stop`).
9+
"""
10+
11+
from .controller import DebugController
12+
from .types import (
13+
Breakpoint,
14+
DebugTerminated,
15+
Frontend,
16+
ResumeAction,
17+
Scope,
18+
StackFrame,
19+
StopEvent,
20+
StopReason,
21+
Variable,
22+
)
23+
24+
__all__ = [
25+
"Breakpoint",
26+
"DebugController",
27+
"DebugTerminated",
28+
"Frontend",
29+
"ResumeAction",
30+
"Scope",
31+
"StackFrame",
32+
"StopEvent",
33+
"StopReason",
34+
"Variable",
35+
]

0 commit comments

Comments
 (0)