use crate::cli::{
CompareOutputFormatArg, GraphOutputFormatArg, KnowledgeSectionArg, RuleLifecycleArg,
SeverityArg, SignalSourceArg,
};
use clap::{Args, Subcommand};
use std::path::PathBuf;
#[derive(Args)]
pub struct InspectOptions {
#[command(subcommand)]
pub command: InspectCommands,
}
#[derive(Subcommand)]
pub enum InspectCommands {
#[command(
about = "Explain file context classification and rule decisions",
after_help = "EXAMPLES:\n \
repopilot inspect explain src/main.rs\n \
repopilot inspect explain src/main.rs --rule language.rust.panic-risk --signal rust.unwrap\n \
repopilot inspect explain src/App.tsx --format markdown --output explain.md"
)]
Explain(ExplainOptions),
#[command(
about = "Inspect RepoPilot bundled knowledge",
after_help = "EXAMPLES:\n \
repopilot inspect knowledge\n \
repopilot inspect knowledge --section languages\n \
repopilot inspect knowledge --section rules --format json"
)]
Knowledge(KnowledgeOptions),
#[command(
about = "Inspect RepoPilot local cache diagnostics",
after_help = "EXAMPLES:\n \
repopilot inspect cache\n \
repopilot inspect cache . --format json\n \
repopilot inspect cache . --format markdown --output cache.md"
)]
Cache(CacheInspectOptions),
#[command(
about = "Inspect RepoPilot Context Risk Graph decisions",
after_help = "EXAMPLES:\n \
repopilot inspect graph\n \
repopilot inspect graph . --format json\n \
repopilot inspect graph . --format markdown --output graph.md"
)]
Graph(GraphInspectOptions),
#[command(
about = "Inspect RepoPilot local feedback suppressions",
after_help = "EXAMPLES:\n \
repopilot inspect feedback\n \
repopilot inspect feedback . --format json\n \
repopilot inspect feedback . --evaluate --format json\n \
repopilot inspect feedback . --format markdown --output feedback.md"
)]
Feedback(FeedbackInspectOptions),
#[command(
about = "List registered RepoPilot rules",
after_help = "EXAMPLES:\n \
repopilot inspect rules\n \
repopilot inspect rules --format json\n \
repopilot inspect rules --lifecycle preview\n \
repopilot inspect rules --source text-heuristic"
)]
Rules(RuleListOptions),
#[command(
about = "Inspect one RepoPilot rule",
after_help = "EXAMPLES:\n \
repopilot inspect rule security.secret-candidate\n \
repopilot inspect rule architecture.circular-dependency --format json"
)]
Rule(RuleInspectOptions),
#[command(
name = "eval-rules",
about = "Evaluate rules against local fixture projects",
after_help = "EXAMPLES:\n \
repopilot inspect eval-rules\n \
repopilot inspect eval-rules --rule security.secret-candidate\n \
repopilot inspect eval-rules --format json"
)]
EvalRules(RuleEvalOptions),
}
#[derive(Args)]
pub struct ExplainOptions {
pub path: PathBuf,
#[arg(long)]
pub rule: Option<String>,
#[arg(long)]
pub signal: Option<String>,
#[arg(long, value_enum, default_value = "medium")]
pub severity: SeverityArg,
#[arg(long, value_enum, default_value = "console")]
pub format: CompareOutputFormatArg,
#[arg(short, long)]
pub output: Option<PathBuf>,
}
#[derive(Args)]
pub struct KnowledgeOptions {
#[arg(long, value_enum, default_value = "all")]
pub section: KnowledgeSectionArg,
#[arg(long, value_enum, default_value = "console")]
pub format: CompareOutputFormatArg,
#[arg(short, long)]
pub output: Option<PathBuf>,
}
#[derive(Args)]
pub struct CacheInspectOptions {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(long, value_enum, default_value = "console")]
pub format: CompareOutputFormatArg,
#[arg(short, long)]
pub output: Option<PathBuf>,
}
#[derive(Args)]
pub struct GraphInspectOptions {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(long)]
pub config: Option<PathBuf>,
#[arg(long, value_enum, default_value = "console")]
pub format: GraphOutputFormatArg,
#[arg(short, long)]
pub output: Option<PathBuf>,
}
#[derive(Args)]
pub struct FeedbackInspectOptions {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(long, value_enum, default_value = "console")]
pub format: CompareOutputFormatArg,
#[arg(long)]
pub evaluate: bool,
#[arg(short, long)]
pub output: Option<PathBuf>,
}
#[derive(Args)]
pub struct RuleListOptions {
#[arg(long, value_enum, default_value = "console")]
pub format: CompareOutputFormatArg,
#[arg(long, value_enum)]
pub lifecycle: Option<RuleLifecycleArg>,
#[arg(long, value_enum)]
pub source: Option<SignalSourceArg>,
#[arg(short, long)]
pub output: Option<PathBuf>,
}
#[derive(Args)]
pub struct RuleInspectOptions {
pub rule_id: String,
#[arg(long, value_enum, default_value = "console")]
pub format: CompareOutputFormatArg,
#[arg(short, long)]
pub output: Option<PathBuf>,
}
#[derive(Args)]
pub struct RuleEvalOptions {
#[arg(long)]
pub rule: Option<String>,
#[arg(long)]
pub fixtures: Option<PathBuf>,
#[arg(long, value_enum, default_value = "console")]
pub format: CompareOutputFormatArg,
#[arg(short, long)]
pub output: Option<PathBuf>,
}