"""
Suzent CLI — Your Digital Co-worker Manager.

This package splits CLI commands into focused modules:
- main:   start, doctor, update, upgrade, setup-build-tools
- node:   list, status, describe, invoke (companion devices)
- agent:  chat, status
- config: show, get, set
"""

import typer

from suzent.cli.agent import agent_app
from suzent.cli.config import config_app
from suzent.cli.main import (
    register_commands,
    configure_logging,
    load_environment,
    _configure_console_encoding,
)
from suzent.cli.cron import cron_app
from suzent.cli.heartbeat import heartbeat_app
from suzent.cli.mcp import mcp_app
from suzent.cli.node import node_app
from suzent.cli.pair import pair_app
from suzent.cli.skill import skill_app

app = typer.Typer(help="Suzent CLI - Your Digital Co-worker Manager")


@app.callback()
def main(
    verbose: bool = typer.Option(
        False, "--verbose", "-v", help="Enable verbose logging (DEBUG level)"
    ),
):
    """
    Suzent CLI - Your Digital Co-worker Manager.
    """
    _configure_console_encoding()
    configure_logging(verbose)
    load_environment()


# Register top-level commands (start, doctor, update, upgrade, setup-build_tools)
register_commands(app)

# Attach subcommand groups
app.add_typer(node_app, name="nodes")
app.add_typer(agent_app, name="agent")
app.add_typer(config_app, name="config")
app.add_typer(cron_app, name="cron")
app.add_typer(heartbeat_app, name="heartbeat")
app.add_typer(pair_app, name="pair")
app.add_typer(mcp_app, name="mcp")
app.add_typer(skill_app, name="skill")

if __name__ == "__main__":
    app()
