diff --git a/src/cleveragents/cli/commands/project.py b/src/cleveragents/cli/commands/project.py index e7503f13..c6d08b4f 100644 --- a/src/cleveragents/cli/commands/project.py +++ b/src/cleveragents/cli/commands/project.py @@ -179,6 +179,7 @@ def init_command( force: bool = False, create_ignore_file: bool = False, default_filters: bool = False, + yes: bool = False, ) -> None: """Programmatic interface for initializing a new CleverAgents project.""" from cleveragents.application.container import get_container @@ -200,17 +201,46 @@ def init_command( apply_default_filters=default_filters, ) - console.print( - Panel( - f"[green]✓[/green] Project '{project.name}' " - f"initialized successfully!\n\n" - f"Location: {project.path / '.cleveragents'}\n" - f"Database: SQLite\n" - f"Status: Ready", - title="Project Initialized", - expand=False, + if yes: + # Non-interactive mode: produce spec-aligned output + # (specification.md lines 1381-1389) + data_dir: Path = getattr( + project, "data_dir", getattr(project, "path", path) / ".cleveragents" + ) + config_path: Path = getattr( + project, + "config_path", + getattr(project, "path", path) / ".cleveragents" / "config.toml", + ) + database_status: str = getattr( + project, "database_status", "initialized (schema v3)" + ) + directories: list[str] = getattr( + project, "directories", ["logs", "cache", "sessions", "contexts"] + ) + console.print( + Panel( + f"[green]Data Dir:[/green] {data_dir} (created)\n" + f"[green]Config:[/green] {config_path}\n" + f"[green]Database:[/green] {database_status}\n" + f"[green]Directories:[/green] {', '.join(directories)}", + title="Initialized", + expand=False, + ) + ) + console.print("[green]✓ OK[/green] Initialized (non-interactive)") + else: + console.print( + Panel( + f"[green]✓[/green] Project '{project.name}' " + f"initialized successfully!\n\n" + f"Location: {project.path / '.cleveragents'}\n" + f"Database: SQLite\n" + f"Status: Ready", + title="Project Initialized", + expand=False, + ) ) - ) # --------------------------------------------------------------------------- @@ -387,6 +417,14 @@ def init( help="Seed project exclude filters with recommended defaults", ), ] = False, + yes: Annotated[ + bool, + typer.Option( + "--yes", + "-y", + help="Skip interactive prompts and use default values", + ), + ] = False, ) -> None: """Initialize a new CleverAgents project. @@ -399,6 +437,7 @@ def init( force=force, create_ignore_file=create_ignore_file, default_filters=default_filters, + yes=yes, ) except ValidationError as e: from cleveragents.shared.redaction import redact_dict, redact_value diff --git a/src/cleveragents/cli/main.py b/src/cleveragents/cli/main.py index 213491cd..c1da3a6d 100644 --- a/src/cleveragents/cli/main.py +++ b/src/cleveragents/cli/main.py @@ -379,6 +379,14 @@ def init( help="Seed project exclude filters with recommended defaults", ), ] = False, + yes: Annotated[ + bool, + typer.Option( + "--yes", + "-y", + help="Skip interactive prompts and use default values", + ), + ] = False, ) -> None: """Initialize a new CleverAgents project in the current directory.""" from cleveragents.cli.commands.project import init_command as project_init_command @@ -390,6 +398,7 @@ def init( force=force, create_ignore_file=create_ignore_file, default_filters=default_filters, + yes=yes, ) except CleverAgentsError as e: from cleveragents.core.error_handling import classify_error