"""VGTC CLI entry point.""" from __future__ import annotations import asyncio import logging import sys import click from hermes.config.settings import get_settings @click.group() @click.option("--debug", is_flag=True, help="Enable debug mode") @click.option("--config", type=str, help="Config file path") @click.pass_context def main(ctx: click.Context, debug: bool, config: str | None) -> None: """VGTC — AI-powered Global Trade Compliance Platform.""" ctx.ensure_object(dict) ctx.obj["debug"] = debug settings = get_settings() if debug: settings.debug = True logging.basicConfig(level=logging.DEBUG) else: logging.basicConfig(level=logging.INFO) @main.command() @click.option("--host", default="0.0.0.0", help="Host to bind to") @click.option("--port", default=8000, type=int, help="Port to bind to") @click.pass_context def serve(ctx: click.Context, host: str, port: int) -> None: """Start the API server.""" import uvicorn settings = get_settings() settings.debug = ctx.obj.get("debug", False) uvicorn.run( "hermes.api.app:create_app", host=host, port=port, reload=settings.debug, factory=True, ) @main.command() @click.argument("query") @click.option("--output", "-o", type=str, help="Output file path") @click.pass_context def research(ctx: click.Context, query: str, output: str | None) -> None: """Conduct research on a topic.""" from hermes.agents.orchestrator.agent import OrchestratorAgent async def _run() -> None: orchestrator = OrchestratorAgent() report = await orchestrator.execute_research(query) click.echo(f"\n{'='*60}") click.echo(f"Research: {report.title}") click.echo(f"{'='*60}") click.echo(f"Summary: {report.summary}") click.echo("") if report.findings: for i, finding in enumerate(report.findings, 1): click.echo(f"--- Finding {i} ({finding.category}) ---") safe_desc = finding.description[:600].encode(sys.stdout.encoding, errors='replace').decode(sys.stdout.encoding) click.echo(safe_desc) click.echo("") if output: with open(output, "w", encoding="utf-8") as f: f.write(report.content) click.echo(f"Report saved to: {output}") asyncio.run(_run()) @main.command() @click.argument("owner") @click.argument("repo") @click.option("--output", "-o", type=str, help="Output file path") @click.pass_context def analyze(ctx: click.Context, owner: str, repo: str, output: str | None) -> None: """Analyze a GitHub repository.""" async def _run() -> None: from hermes.agents.orchestrator.agent import OrchestratorAgent orchestrator = OrchestratorAgent() report = await orchestrator.execute_repo_analysis(owner, repo) click.echo(f"\nAnalysis: {report.title}") click.echo(f"Summary: {report.summary}") click.echo(f"Findings: {len(report.findings)}") if output: with open(output, "w", encoding="utf-8") as f: f.write(report.content) click.echo(f"\nReport saved to: {output}") asyncio.run(_run()) @main.command() @click.argument("path") @click.option("--output", "-o", type=str, help="Output file path") @click.pass_context def scan(ctx: click.Context, path: str, output: str | None) -> None: """Perform security scan.""" async def _run() -> None: from hermes.agents.orchestrator.agent import OrchestratorAgent orchestrator = OrchestratorAgent() report = await orchestrator.execute_security_scan(path) click.echo(f"\nSecurity Scan: {report.title}") click.echo(f"Summary: {report.summary}") click.echo(f"Findings: {len(report.findings)}") if output: with open(output, "w", encoding="utf-8") as f: f.write(report.content) click.echo(f"\nReport saved to: {output}") asyncio.run(_run()) @main.command() @click.pass_context def tools(ctx: click.Context) -> None: """List available MCP tools.""" from hermes.tools.base.registry import tool_registry from hermes.tools.register import register_default_tools register_default_tools() click.echo("\nAvailable MCP Tools:") click.echo("-" * 60) for schema in tool_registry.list_schemas(): click.echo(f"\n{schema['name']}") click.echo(f" Description: {schema['description']}") params = schema.get("inputSchema", {}).get("properties", {}) if params: click.echo(" Parameters:") for param, info in params.items(): click.echo(f" - {param}: {info.get('description', '')}") @main.command() @click.pass_context def status(ctx: click.Context) -> None: """Show system status.""" from hermes.tools.base.registry import tool_registry from hermes.tools.register import register_default_tools register_default_tools() settings = get_settings() click.echo("\nVGTC Platform Status") click.echo("=" * 40) click.echo(f"Environment: {settings.environment}") click.echo(f"Debug: {settings.debug}") click.echo(f"MCP Port: {settings.mcp.port}") click.echo(f"Tools Registered: {len(tool_registry.list_tools())}") click.echo(f"Model: {settings.model.name}") if __name__ == "__main__": main()