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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
/// Spec subcommands (master-plan-pmat-work-system.md S-001 to S-010)
#[derive(Debug, Clone, Subcommand)]
pub enum SpecCommands {
/// Validate specification with 100-point Popperian score (S-001)
/// Requires ≥95 points to be worked on
#[command(visible_aliases = &["validate", "v"])]
Score {
/// Specification file path
spec: PathBuf,
/// Output format: text, json, markdown
#[arg(short = 'f', long = "format", value_enum, default_value = "text")]
format: SpecOutputFormat,
/// Write output to file
#[arg(short = 'o', long = "output")]
output: Option<PathBuf>,
/// Show verbose claim validation
#[arg(short = 'v', long = "verbose")]
verbose: bool,
},
/// Auto-fix spec issues to meet 95-point threshold (S-003)
#[command(visible_aliases = &["fix", "c"])]
Comply {
/// Specification file path
spec: PathBuf,
/// Dry run (show what would be fixed without changing file)
#[arg(long)]
dry_run: bool,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "text")]
format: SpecOutputFormat,
},
/// Create new specification from template
#[command(visible_aliases = &["new", "n"])]
Create {
/// Specification name (will be slugified)
name: String,
/// Issue reference (e.g., "GH-123" or "#123")
#[arg(long)]
issue: Option<String>,
/// Epic to associate with
#[arg(long)]
epic: Option<String>,
/// Output directory (defaults to docs/specifications/)
#[arg(short = 'o', long = "output")]
output: Option<PathBuf>,
},
/// List all specifications with their scores
#[command(visible_aliases = &["ls", "l"])]
List {
/// Specifications directory (defaults to docs/specifications/)
#[arg(short = 'p', long = "path", default_value = "docs/specifications")]
path: PathBuf,
/// Filter by minimum score
#[arg(long)]
min_score: Option<u8>,
/// Show only specs below 95 threshold
#[arg(long)]
failing_only: bool,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "text")]
format: SpecOutputFormat,
},
/// Sync specs with roadmap (bidirectional ticket linking)
#[command(visible_aliases = &["sy", "link"])]
Sync {
/// Specifications directory
#[arg(short = 's', long = "specs", default_value = "docs/specifications")]
spec_path: PathBuf,
/// Roadmap file path
#[arg(short = 'r', long = "roadmap", default_value = "docs/roadmaps/roadmap.yaml")]
roadmap_path: PathBuf,
/// Dry run (show changes without applying)
#[arg(long)]
dry_run: bool,
/// Direction: spec-to-roadmap, roadmap-to-spec, or both
#[arg(short = 'd', long = "direction", value_enum, default_value = "both")]
direction: SpecSyncDirection,
},
/// Report specs without roadmap links (drift detection)
#[command(visible_aliases = &["orphans", "unlinked"])]
Drift {
/// Specifications directory
#[arg(short = 's', long = "specs", default_value = "docs/specifications")]
spec_path: PathBuf,
/// Roadmap file path
#[arg(short = 'r', long = "roadmap", default_value = "docs/roadmaps/roadmap.yaml")]
roadmap_path: PathBuf,
/// Output format
#[arg(short = 'f', long = "format", value_enum, default_value = "text")]
format: SpecOutputFormat,
},
}
/// Direction for spec-roadmap sync
#[derive(Debug, Clone, Copy, Default, clap::ValueEnum)]
pub enum SpecSyncDirection {
/// Update roadmap from spec tickets
SpecToRoadmap,
/// Update spec frontmatter from roadmap
RoadmapToSpec,
/// Bidirectional sync
#[default]
Both,
}
/// Output format for spec commands
#[derive(Debug, Clone, Copy, Default, clap::ValueEnum)]
pub enum SpecOutputFormat {
/// Human-readable text format
#[default]
Text,
/// JSON format for CI/CD
Json,
/// Markdown report format
Markdown,
}
/// Output format for kaizen command
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, clap::ValueEnum)]
pub enum KaizenOutputFormat {
/// Human-readable text format
#[default]
Text,
/// JSON format for CI/CD
Json,
/// Markdown report format
Markdown,
}
/// Output format for work annotate command
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, clap::ValueEnum)]
pub enum AnnotateOutputFormat {
/// Human-readable text format
#[default]
Text,
/// JSON format for CI/CD
Json,
/// Markdown report format
Markdown,
}
/// Debug subcommands for time-travel debugging
#[derive(Debug, Clone, Subcommand)]
pub enum DebugCommands {
/// Start DAP (Debug Adapter Protocol) server for time-travel debugging
#[command(visible_aliases = &["srv", "server"])]
Serve {
/// Port to bind DAP server (default: 5678)
#[arg(short, long, default_value = "5678")]
port: u16,
/// Host address to bind (default: 127.0.0.1)
#[arg(long, default_value = "127.0.0.1")]
host: String,
/// Directory to save recording files (.pmat format) [Sprint 76 - CAPTURE-003]
#[arg(long, value_name = "DIR")]
record_dir: Option<PathBuf>,
},
/// Replay execution recording with time-travel navigation
#[command(visible_aliases = &["play", "view"])]
Replay {
/// Path to execution recording file (.pmat format)
recording: PathBuf,
/// Start at specific snapshot position
#[arg(long)]
position: Option<usize>,
/// Enable interactive timeline navigation
#[arg(short, long)]
interactive: bool,
},
}
/// Quality gates subcommands
#[derive(Subcommand)]
#[cfg_attr(test, derive(Debug))]
pub enum QualityGatesCommand {
/// Initialize .pmat-gates.toml with defaults
Init {
/// Force overwrite existing file
#[arg(long)]
force: bool,
},
/// Validate configuration file
Validate,
/// Show current configuration
Show {
/// Output format
#[arg(long, value_enum, default_value = "toml")]
format: ConfigFormat,
},
}
/// Maintain subcommands for project maintenance tasks
#[derive(Subcommand)]
#[cfg_attr(test, derive(Debug))]
pub enum MaintainCommands {
/// Validate roadmap structure and ticket consistency
Roadmap {
/// Path to ROADMAP.md
#[arg(long, default_value = "ROADMAP.md")]
roadmap: PathBuf,
/// Path to tickets directory
#[arg(long, default_value = "docs/tickets")]
tickets_dir: PathBuf,
/// Check ticket status consistency
#[arg(long)]
validate: bool,
/// Show roadmap health report
#[arg(long)]
health: bool,
/// Auto-fix checkbox status based on ticket files
#[arg(long)]
fix: bool,
/// Auto-generate missing ticket files from roadmap entries
#[arg(long)]
generate_tickets: bool,
/// Dry-run mode (show changes without applying)
#[arg(long)]
dry_run: bool,
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
/// Validate project health (build, tests, coverage, complexity)
Health {
/// Project directory
#[arg(long, default_value = ".")]
project_dir: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
/// Quick mode: only build check (fastest, <10s)
#[arg(long)]
quick: bool,
/// Run all checks (build + tests + coverage + complexity + SATD)
#[arg(long)]
all: bool,
/// Check build status (default if no other flags specified)
#[arg(long)]
check_build: bool,
/// Check tests
#[arg(long)]
check_tests: bool,
/// Check coverage
#[arg(long)]
check_coverage: bool,
/// Check complexity
#[arg(long)]
check_complexity: bool,
/// Check SATD
#[arg(long)]
check_satd: bool,
},
/// Create bug report from captured error
#[command(visible_aliases = &["bug", "report"])]
BugReport {
/// Custom issue title
#[arg(long)]
title: Option<String>,
/// Preview issue without creating (dry-run)
#[arg(long)]
dry_run: bool,
/// Interactive confirmation before creating
#[arg(long, short)]
interactive: bool,
/// Clear captured error without creating report
#[arg(long)]
clear: bool,
},
/// Clean up development artifacts and caches
#[command(visible_aliases = &["clean", "cleanup", "purge"])]
CleanupResources {
/// Project directory to scan
#[arg(long, default_value = ".")]
project_dir: PathBuf,
/// Cleanup targets: rust, docker, node, git, logs, caches, all
#[arg(long, value_delimiter = ',', default_value = "rust")]
targets: Vec<String>,
/// Actually execute cleanup (default is dry-run)
#[arg(long, conflicts_with = "dry_run")]
execute: bool,
/// Preview what would be cleaned without deleting (this is the default)
#[arg(long)]
dry_run: bool,
/// Exclude patterns (glob syntax)
#[arg(long)]
exclude: Vec<String>,
/// Minimum age in days for cleanup candidates
#[arg(long, default_value = "0")]
min_age_days: u32,
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
}