artifactize 0.27.2

The AI-native collaboration layer for one-of-a-kind teammates and their agents: split a project into Artifacts with their own evals, and reuse every review while it still holds.
//! Parse and route request commands.

mod actions;
mod inspect;
mod issues;

use std::path::Path;

use artifactize_core::{
    runtime::Verdict,
    types::{RequestId, ReviewerId, RunId},
};
use clap::Subcommand;
use issues::IssuesSource;

#[derive(Debug, Subcommand)]
pub enum RequestCommand {
    /// List saved waiting, claimed, and settled requests.
    List {
        /// Only requests from this Run.
        #[arg(long, value_name = "RUN_ID")]
        run: Option<RunId>,
    },
    /// Read full saved audit, claim and summary as JSON.
    Show { id: RequestId },
    /// Read bounded runtime evidence without loading the full request audit.
    Logs {
        id: RequestId,
        #[command(flatten)]
        query: artifactize_core::inspect::LogOptions,
    },
    /// Acquire the Human reviewer lock.
    Claim {
        id: RequestId,
        /// Reviewer name (defaults to the signed-in user).
        #[arg(long, value_name = "NAME")]
        reviewer: Option<ReviewerId>,
    },
    /// Release your Human reviewer lock while the request still waits.
    Unclaim {
        id: RequestId,
        /// Reviewer name (defaults to the signed-in user).
        #[arg(long, value_name = "NAME")]
        reviewer: Option<ReviewerId>,
    },
    /// Run a predefined Human tool as the claimant.
    Tool {
        id: RequestId,
        tool: artifactize_core::config::ToolName,
        /// Reviewer name (defaults to the signed-in user).
        #[arg(long, value_name = "NAME")]
        reviewer: Option<ReviewerId>,
    },
    /// Submit a person's verdict: GREEN with no issue, or RED with the issues to change.
    Submit {
        id: RequestId,
        #[arg(long, value_enum)]
        verdict: Verdict,
        #[command(flatten)]
        issues: IssuesSource,
        /// Reviewer name (defaults to the signed-in user).
        #[arg(long, value_name = "NAME")]
        reviewer: Option<ReviewerId>,
    },
}

pub(super) async fn execute(
    state: &Path,
    command: RequestCommand,
    json: bool,
) -> Result<u8, String> {
    match command {
        RequestCommand::List { run } => inspect::list(state, run, json).await?,
        RequestCommand::Show { id } => inspect::show(state, &id).await?,
        RequestCommand::Logs { id, query } => inspect::logs(state, id, query).await?,
        RequestCommand::Claim { id, reviewer } => actions::claim(state, id, reviewer).await?,
        RequestCommand::Unclaim { id, reviewer } => actions::unclaim(state, id, reviewer).await?,
        RequestCommand::Tool { id, tool, reviewer } => {
            return actions::tool(state, id, tool, reviewer, json).await;
        }
        RequestCommand::Submit {
            id,
            verdict,
            issues,
            reviewer,
        } => {
            actions::submit(state, id, verdict, issues, reviewer).await?;
        }
    }
    Ok(0)
}

#[cfg(test)]
mod tests;