Skip to main content

autom8/commands/
mod.rs

1//! CLI command handlers for autom8.
2//!
3//! This module contains the implementation of all CLI subcommands.
4//! Each command has its own module with handler functions.
5//!
6//! # Commands
7//!
8//! - [`run`] - Run implementation from a spec file
9//! - [`status`] - Check current run status
10//! - [`resume`] - Resume an interrupted run
11//! - [`clean`] - Clean up spec files
12//! - [`config`] - View and modify configuration
13//! - [`init`] - Initialize project config
14//! - [`projects`] - List known projects
15//! - [`list`] - Tree view of projects
16//! - [`describe`] - Show project details
17//! - [`pr_review`] - Analyze and fix PR review comments
18//! - [`monitor`] - TUI dashboard
19//! - [`gui`] - Native GUI application
20//! - [`default`] - Interactive spec creation flow
21
22mod clean;
23mod config;
24mod default;
25mod describe;
26mod gui;
27mod improve;
28mod init;
29mod list;
30mod monitor;
31mod pr_review;
32mod projects;
33mod resume;
34mod run;
35mod status;
36
37pub use clean::{
38    clean_command, clean_data_direct, clean_orphaned_direct, clean_worktrees_direct,
39    format_bytes_display, remove_project_direct, CleanOptions, CleanupSummary, DataCleanupSummary,
40    DirectCleanOptions, RemovalSummary, SkippedSession, SkippedWorktree,
41};
42pub use config::{
43    config_display_command, config_reset_command, config_set_command, ConfigScope, ConfigSubcommand,
44};
45pub use default::default_command;
46pub use describe::describe_command;
47pub use gui::gui_command;
48pub use improve::{
49    build_improve_prompt, gather_git_context, improve_command, load_follow_up_context,
50    FollowUpContext, GitContext,
51};
52pub use init::init_command;
53pub use list::list_command;
54pub use monitor::monitor_command;
55pub use pr_review::pr_review_command;
56pub use projects::projects_command;
57pub use resume::resume_command;
58pub use run::{run_command, run_with_file};
59pub use status::{all_sessions_status_command, global_status_command, status_command};
60
61use std::path::Path;
62
63/// Input type based on file extension.
64#[derive(Debug, Clone, Copy, PartialEq)]
65pub enum InputType {
66    /// JSON spec file (spec-<feature>.json)
67    Json,
68    /// Markdown spec file (spec-<feature>.md)
69    Markdown,
70}
71
72/// Detect input type based on file extension.
73pub fn detect_input_type(path: &Path) -> InputType {
74    match path.extension().and_then(|e| e.to_str()) {
75        Some("json") => InputType::Json,
76        _ => InputType::Markdown,
77    }
78}
79
80/// Ensure project config directory exists.
81///
82/// Used by commands that need project-specific configuration.
83///
84/// # Errors
85///
86/// Returns an error if the directory cannot be created.
87pub fn ensure_project_dir() -> crate::error::Result<()> {
88    crate::config::ensure_project_config_dir()?;
89    Ok(())
90}