Files
deepagents/libs/code/deepagents_code/__init__.py
T
Mason Daugherty 4f94a30c11 feat(code): in-app Debug Console (#4564)
Deep Agents Code now includes an in-app Debug Console. Press `Ctrl+\` to
inspect session details and filter, view, or copy recent application
logs without enabling file-based debug logging.

---

Debugging client-side TUI problems currently requires restarting with
file logging enabled and tailing a log in another terminal. This adds an
in-app Debug Console, modeled on Mistral Vibe's console, so users can
inspect session state and recent application logs without leaving the
TUI.

Open the console with `Ctrl+\` or the hidden `/debug` command. It shows
a point-in-time snapshot of the version, model, thread, working
directory, auto-approve state, sandbox, MCP servers, token usage, and
debug-log path. Below that, it tails recent `deepagents_code.*` records
from an always-on bounded in-memory buffer and supports filtering by
severity.

The buffer captures `INFO` and above by default, or the level selected
with `DEEPAGENTS_CODE_LOG_LEVEL`. `DEEPAGENTS_CODE_DEBUG` continues to
enable append-only file logging and defaults capture to `DEBUG`.
`Ctrl+L` clears the current console view without clearing the underlying
buffer; `c` copies the visible filtered records retained since the last
clear, and clicking a record copies only that record.

---------

Co-authored-by: open-swe[bot] <open-swe@users.noreply.github.com>
2026-07-13 02:48:48 -04:00

43 lines
1.4 KiB
Python

"""Deep Agents Code - Interactive AI coding assistant."""
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from deepagents_code._debug import configure_debug_logging
from deepagents_code._debug_buffer import install_log_buffer
from deepagents_code._version import __version__
if TYPE_CHECKING:
from collections.abc import Callable
install_log_buffer(logging.getLogger(__name__)) # noqa: RUF067 # attach the always-on tail first so warnings from configure_debug_logging are captured
configure_debug_logging(logging.getLogger(__name__)) # noqa: RUF067 # package logger must be configured before child modules emit logs; sets the final level over the buffer's INFO floor
__all__ = [
"__version__",
"cli_main", # noqa: F822 # resolved lazily by __getattr__
]
def __getattr__(name: str) -> Callable[[], None]:
"""Lazy import for `cli_main` to avoid loading `main.py` at package import.
`main.py` pulls in `argparse`, signal handling, and other startup machinery
that isn't needed when submodules like `config` or `widgets` are
imported directly.
Returns:
The requested callable.
Raises:
AttributeError: If *name* is not a lazily-provided attribute.
"""
if name == "cli_main":
from deepagents_code.main import cli_main
return cli_main
msg = f"module {__name__!r} has no attribute {name!r}"
raise AttributeError(msg)