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
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
use super::args::{AuditOutputFormat, LintFormat, LintProfileArg, MakeOutputFormat, ReportFormat};
use clap::{Subcommand, ValueEnum};
use std::path::PathBuf;
/// Comply subcommands (SPEC-COMPLY-2026-001)
#[derive(Subcommand)]
pub enum ComplyCommands {
/// Initialize .bashrs/comply.toml manifest
Init {
/// Scopes to track
#[arg(long, value_enum, default_value = "project")]
scope: ComplyScopeArg,
/// Enable pzsh integration
#[arg(long)]
pzsh: bool,
/// Strict mode (all rules enforced, zero tolerance)
#[arg(long)]
strict: bool,
},
/// Layer 1 (Jidoka): Automated compliance verification
Check {
/// Project path
#[arg(short, long, default_value = ".")]
path: PathBuf,
/// Scope to check
#[arg(long, value_enum)]
scope: Option<ComplyScopeArg>,
/// Exit with error if non-compliant (grade F)
#[arg(long)]
strict: bool,
/// Show only non-compliant artifacts
#[arg(long)]
failures_only: bool,
/// Minimum acceptable score (exit non-zero if below)
#[arg(long)]
min_score: Option<u32>,
/// Output format
#[arg(short, long, value_enum, default_value = "text")]
format: ComplyFormat,
},
/// Show current compliance status (alias for check)
Status {
/// Project path
#[arg(short, long, default_value = ".")]
path: PathBuf,
/// Output format
#[arg(short, long, value_enum, default_value = "text")]
format: ComplyFormat,
},
/// Manage tracked artifacts
Track {
#[command(subcommand)]
command: ComplyTrackCommands,
},
/// List all compliance rules with descriptions and weights
Rules {
/// Output format
#[arg(short, long, value_enum, default_value = "text")]
format: ComplyFormat,
},
/// Generate compliance report (Phase 2)
Report {
/// Project path
#[arg(short, long, default_value = ".")]
path: PathBuf,
/// Output format
#[arg(short, long, value_enum, default_value = "markdown")]
format: ComplyFormat,
/// Write output to file
#[arg(short, long)]
output: Option<PathBuf>,
/// Scope to report
#[arg(long, value_enum)]
scope: Option<ComplyScopeArg>,
},
/// Install pre-commit compliance hooks (Phase 2)
Enforce {
/// Enforcement tier (1=fast, 2=standard, 3=strict)
#[arg(long, default_value = "1")]
tier: u8,
/// Remove enforcement hooks
#[arg(long)]
uninstall: bool,
},
/// Show compliance delta since last check (Phase 2)
Diff {
/// Project path
#[arg(short, long, default_value = ".")]
path: PathBuf,
/// Compare against last comply check
#[arg(long)]
since_last: bool,
},
}
/// Track subcommands
#[derive(Subcommand)]
pub enum ComplyTrackCommands {
/// Auto-discover artifacts in project
Discover {
/// Project path
#[arg(short, long, default_value = ".")]
path: PathBuf,
/// Scope to discover
#[arg(long, value_enum, default_value = "project")]
scope: ComplyScopeArg,
},
/// List tracked artifacts
List {
/// Project path
#[arg(short, long, default_value = ".")]
path: PathBuf,
/// Scope to list
#[arg(long, value_enum)]
scope: Option<ComplyScopeArg>,
},
}
/// Scope argument for comply commands
#[derive(Clone, Copy, Debug, Default, ValueEnum)]
pub enum ComplyScopeArg {
/// Project artifacts (*.sh, Makefile, Dockerfile)
#[default]
Project,
/// User config files (~/.zshrc, ~/.bashrc)
User,
/// System config files (/etc/profile, read-only)
System,
/// All scopes
All,
}
/// Output format for comply commands
#[derive(Clone, Copy, Debug, Default, ValueEnum)]
pub enum ComplyFormat {
/// Human-readable text
#[default]
Text,
/// JSON format for CI/CD
Json,
/// Markdown report
Markdown,
}
#[derive(Subcommand)]
pub enum MakeCommands {
/// Transpile Rust DSL to Makefile
Build {
/// Input Rust file with Makefile DSL
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output Makefile path
#[arg(short, long, default_value = "Makefile")]
output: PathBuf,
},
/// Parse Makefile to AST
Parse {
/// Input Makefile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "text")]
format: MakeOutputFormat,
},
/// Purify Makefile (determinism + idempotency)
Purify {
/// Input Makefile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output file (defaults to stdout or in-place with --fix)
#[arg(short, long)]
output: Option<PathBuf>,
/// Apply fixes in-place (creates .bak backup)
#[arg(long)]
fix: bool,
/// Show detailed transformation report
#[arg(long)]
report: bool,
/// Report format
#[arg(long, value_enum, default_value = "human")]
format: ReportFormat,
/// Generate test suite for purified Makefile
#[arg(long)]
with_tests: bool,
/// Generate property-based tests (100+ cases)
#[arg(long)]
property_tests: bool,
/// Preserve formatting (keep blank lines, multi-line format)
#[arg(long)]
preserve_formatting: bool,
/// Maximum line length (default: unlimited)
#[arg(long)]
max_line_length: Option<usize>,
/// Skip blank line removal transformation
#[arg(long)]
skip_blank_line_removal: bool,
/// Skip multi-line consolidation transformation
#[arg(long)]
skip_consolidation: bool,
},
/// Lint Makefile for quality issues
Lint {
/// Input Makefile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: LintFormat,
/// Apply automatic fixes
#[arg(long)]
fix: bool,
/// Output file (defaults to in-place with --fix)
#[arg(short, long)]
output: Option<PathBuf>,
/// Filter by specific rules (comma-separated: MAKE001,MAKE003)
#[arg(long)]
rules: Option<String>,
},
}
#[derive(Subcommand)]
pub enum DockerfileCommands {
/// Transpile Rust DSL to Dockerfile
Build {
/// Input Rust file with Dockerfile DSL
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output Dockerfile path
#[arg(short, long, default_value = "Dockerfile")]
output: PathBuf,
/// Base image (e.g., "rust:1.75-alpine")
#[arg(long)]
base_image: Option<String>,
},
/// Purify Dockerfile (auto-fix security and best practices issues)
Purify {
/// Input Dockerfile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output file (defaults to stdout or in-place with --fix)
#[arg(short, long)]
output: Option<PathBuf>,
/// Apply fixes in-place (creates .bak backup)
#[arg(long)]
fix: bool,
/// Don't create backup with --fix (dangerous!)
#[arg(long)]
no_backup: bool,
/// Show changes without applying (dry-run mode)
#[arg(long)]
dry_run: bool,
/// Show detailed transformation report
#[arg(long)]
report: bool,
/// Report format
#[arg(long, value_enum, default_value = "human")]
format: ReportFormat,
/// Don't add USER directive (for special cases)
#[arg(long)]
skip_user: bool,
/// Don't purify bash in RUN commands
#[arg(long)]
skip_bash_purify: bool,
},
/// Lint Dockerfile for issues (existing functionality)
Lint {
/// Input Dockerfile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: LintFormat,
/// Filter by specific rules (comma-separated: DOCKER001,DOCKER003)
#[arg(long)]
rules: Option<String>,
},
/// Profile Docker image runtime performance (requires Docker daemon)
Profile {
/// Input Dockerfile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Measure build time and layer cache efficiency
#[arg(long)]
build: bool,
/// Show layer-by-layer timing analysis
#[arg(long)]
layers: bool,
/// Measure container startup time to healthy state
#[arg(long)]
startup: bool,
/// Measure container memory usage during runtime
#[arg(long)]
memory: bool,
/// Measure container CPU usage during runtime
#[arg(long)]
cpu: bool,
/// Run custom workload script for profiling
#[arg(long, value_name = "SCRIPT")]
workload: Option<PathBuf>,
/// Duration for runtime profiling (e.g., "30s", "1m")
#[arg(long, default_value = "30s")]
duration: String,
/// Apply platform-specific constraints (coursera)
#[arg(long, value_enum)]
profile: Option<LintProfileArg>,
/// Simulate platform resource limits during profiling
#[arg(long)]
simulate_limits: bool,
/// Run full runtime validation suite
#[arg(long)]
full: bool,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: ReportFormat,
},
/// Check Docker image size and detect bloat patterns
SizeCheck {
/// Input Dockerfile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Show verbose size breakdown by layer
#[arg(long)]
verbose: bool,
/// Show per-layer size analysis
#[arg(long)]
layers: bool,
/// Detect common size bloat patterns
#[arg(long)]
detect_bloat: bool,
/// Verify estimate against actual built image
#[arg(long)]
verify: bool,
/// Build image and verify size (requires Docker)
#[arg(long)]
docker_verify: bool,
/// Apply platform-specific size constraints (coursera = 10GB)
#[arg(long, value_enum)]
profile: Option<LintProfileArg>,
/// Exit with error if estimated size exceeds limit
#[arg(long)]
strict: bool,
/// Custom maximum size limit (e.g., "5GB", "500MB")
#[arg(long, value_name = "SIZE")]
max_size: Option<String>,
/// Show compression opportunities
#[arg(long)]
compression_analysis: bool,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: ReportFormat,
},
/// Run full validation pipeline (lint + size + optional runtime profiling)
FullValidate {
/// Input Dockerfile
#[arg(value_name = "FILE")]
input: PathBuf,
/// Apply platform-specific validation (coursera)
#[arg(long, value_enum)]
profile: Option<LintProfileArg>,
/// Include size verification
#[arg(long)]
size_check: bool,
/// Include graded lab validation (for Coursera)
#[arg(long)]
graded: bool,
/// Include runtime profiling (requires Docker daemon)
#[arg(long)]
runtime: bool,
/// Exit with error on any warning
#[arg(long)]
strict: bool,
/// Output format
#[arg(long, value_enum, default_value = "human")]
format: ReportFormat,
},
}
include!("args_tools_devcontainer.rs");