The Studio Cockpit: Enhanced Interactive Console

Viewed 1

The m console command has been upgraded with a specialized REPLContext (the m object) to streamline interactive development and debugging.

The m Context Object

When starting the console with the --with-container flag, the framework injects an m object into the global namespace. This provides ergonomic access to hydrated application services without manual dependency resolution:

  • Database Sessions (m.session): Provides an async session factory context manager.
    async with m.session as s:
        # Use session s for database operations
    
  • Repositories (m.repo): Retrieve the repository for any registered DocType by name or class.
  • Metadata (m.metadata): Access the active SQLAlchemy MetaData object containing all discovered tables.
  • Configuration (m.config): Access the fully hydrated RootConfig and application settings.
  • Jobs (m.jobs): Inspect the global JobRegistry for discovered background tasks.

Features & Tooling

The Studio Cockpit integrates IPython and Rich to provide:

  • Top-level await support for all asynchronous framework calls.
  • Formatted inspection of system routes, job registrations, and schema metadata.
  • Container Access: The full DI container is also available for low-level service resolution.
uv run m console --with-container
0 Answers