1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use clap::{Args, Parser, Subcommand};
use crate::model::ScanMode;
#[derive(Debug, Parser)]
#[command(
name = "runbook",
version,
about = "Generate a local runbook for AI coding agents."
)]
pub struct Cli {
#[command(subcommand)]
pub command: CommandArgs,
}
#[derive(Debug, Subcommand)]
pub enum CommandArgs {
/// Scan this machine and the current project.
Scan(ScanArgs),
/// List functional tool categories or inspect candidates for a task.
Category(CategoryArgs),
/// List or update explicit repository-local tool preferences.
Prefer(PreferCommandArgs),
}
#[derive(Debug, Args)]
pub struct ScanArgs {
/// Scan only machine-level tools.
#[arg(long, conflicts_with = "local")]
pub global: bool,
/// Scan only current-project requirements.
#[arg(long, conflicts_with = "global")]
pub local: bool,
/// Print only detected tool names.
#[arg(long)]
pub minimal: bool,
}
impl ScanArgs {
pub fn mode(&self) -> ScanMode {
if self.global {
ScanMode::Global
} else if self.local {
ScanMode::Local
} else {
ScanMode::All
}
}
}
#[derive(Debug, Args)]
pub struct CategoryArgs {
/// One or more tool categories to inspect. Omit to list categories.
pub categories: Vec<String>,
/// Include tools for this language plus cross-language tools.
#[arg(long)]
pub lang: Option<String>,
/// Include only tools for this platform.
#[arg(long)]
pub platform: Option<String>,
}
#[derive(Debug, Args)]
pub struct PreferCommandArgs {
#[command(subcommand)]
pub action: Option<PreferArgs>,
}
#[derive(Debug, Subcommand)]
pub enum PreferArgs {
/// Record a confirmed repository preference.
Set(PreferSetArgs),
/// Remove a stale repository preference.
Unset(PreferUnsetArgs),
}
#[derive(Debug, Args)]
pub struct PreferSetArgs {
/// Tool category for the preference.
pub category: String,
/// Language key for the preference.
#[arg(long)]
pub lang: String,
/// Tool name, binary, or alias to prefer.
#[arg(long)]
pub tool: String,
/// Human, repository-specific reason for the preference.
#[arg(long)]
pub reason: String,
}
#[derive(Debug, Args)]
pub struct PreferUnsetArgs {
/// Tool category for the preference.
pub category: String,
/// Language key for the preference.
#[arg(long)]
pub lang: String,
}