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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#![cfg_attr(coverage_nightly, coverage(off))]
// Config and Hooks commands - extracted for file health (CB-040)
use crate::cli::OutputFormat;
use clap::Subcommand;
/// Configuration management commands
#[derive(Subcommand, Clone)]
#[cfg_attr(test, derive(Debug))]
pub enum ConfigCommands {
/// Show complete configuration
Show {
/// Output format
#[arg(long, value_enum, default_value = "json")]
format: ConfigFormat,
},
/// Get specific configuration value
Get {
/// Configuration key path (e.g., `hooks.quality_gates.max_cyclomatic_complexity`)
key: String,
},
/// Validate configuration file
Validate {
/// Fix configuration issues automatically
#[arg(long)]
fix: bool,
},
/// Show configuration source hierarchy
Sources,
}
/// Pre-commit hook management commands
#[derive(Subcommand, Clone)]
#[cfg_attr(test, derive(Debug))]
pub enum HooksCommands {
/// Initialize pre-commit hooks (alias for install)
Init {
/// Enable interactive mode for configuration
#[arg(long)]
interactive: bool,
/// Force installation (overwrite existing)
#[arg(long)]
force: bool,
/// Create backup of existing hooks
#[arg(long, default_value = "true")]
backup: bool,
/// Enable TDG quality enforcement hooks
#[arg(long)]
tdg_enforcement: bool,
},
/// Install or update pre-commit hooks
Install {
/// Enable interactive mode for configuration
#[arg(long)]
interactive: bool,
/// Force installation (overwrite existing)
#[arg(long)]
force: bool,
/// Create backup of existing hooks
#[arg(long, default_value = "true")]
backup: bool,
/// Enable TDG quality enforcement hooks
#[arg(long)]
tdg_enforcement: bool,
/// Install hooks across all sovereign AI stack repos
#[arg(long)]
stack: bool,
/// Update existing hooks when using --stack (overwrite)
#[arg(long, requires = "stack")]
update: bool,
},
/// Remove PMAT-managed hooks
Uninstall {
/// Restore backup if available
#[arg(long)]
restore_backup: bool,
},
/// Show hook installation status
Status {
/// Show status across all sovereign AI stack repos
#[arg(long)]
stack: bool,
/// Output format for stack status
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
/// Verify hooks work with current configuration
Verify {
/// Fix issues automatically
#[arg(long)]
fix: bool,
},
/// Regenerate hooks from current configuration
Refresh,
/// Run pre-commit hooks (for CI/CD integration)
Run {
/// Run on all files instead of just staged
#[arg(long)]
all_files: bool,
/// Verbose output
#[arg(long, short)]
verbose: bool,
/// Enable O(1) cache check (skip if unchanged)
#[arg(long, default_value = "true")]
cache: bool,
},
/// O(1) cache management for hooks
Cache {
#[command(subcommand)]
action: HooksCacheAction,
},
}
/// Cache actions for O(1) hooks
#[derive(Subcommand, Clone)]
#[cfg_attr(test, derive(Debug))]
pub enum HooksCacheAction {
/// Initialize cache directory structure
Init,
/// Show cache status and metrics
Status {
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
/// Clear cache (forces full re-run on next commit)
Clear {
/// Clear specific gate cache only
#[arg(long)]
gate: Option<String>,
},
/// Show detailed metrics (hit rate, timing)
Metrics {
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
}
/// Configuration output format
#[derive(Debug, Clone, clap::ValueEnum)]
#[cfg_attr(test, derive(PartialEq))]
pub enum ConfigFormat {
/// JSON format
Json,
/// TOML format
Toml,
/// Environment variables format
Env,
}