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
#![cfg_attr(coverage_nightly, coverage(off))]
// Semantic search commands - extracted for file health (CB-040)
use crate::cli::OutputFormat;
#[cfg(feature = "mutation-testing")]
use clap::Args;
use clap::Subcommand;
use std::path::PathBuf;
/// Embed subcommands for semantic search
#[derive(Subcommand)]
#[cfg_attr(test, derive(Debug))]
#[command(after_help = "EXAMPLES:
# Sync embeddings for current codebase
pmat embed sync
# Check embedding database status
pmat embed status
# Clear all embeddings (requires confirmation)
pmat embed clear --confirm
# Sync with verbose output
pmat embed sync --verbose
# Check status in JSON format
pmat embed status --format json")]
/// Embed commands.
pub enum EmbedCommands {
/// Sync embeddings for codebase
Sync {
/// Path to analyze
#[arg(short, long, default_value = ".")]
path: PathBuf,
/// Filter by language
#[arg(long)]
language: Option<String>,
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
/// Show embedding database status
Status {
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
/// Clear all embeddings (requires --confirm)
Clear {
/// Confirm deletion
#[arg(long)]
confirm: bool,
},
}
/// Semantic search subcommands
#[derive(Subcommand)]
#[cfg_attr(test, derive(Debug))]
pub enum SemanticCommands {
/// Search code by natural language query
Search {
/// Natural language query
query: String,
/// Search mode
#[arg(long = "search-mode", value_enum, default_value = "hybrid")]
search_mode: SearchMode,
/// Filter by language
#[arg(long)]
language: Option<String>,
/// Max results to return
#[arg(long, default_value_t = 10)]
limit: usize,
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
/// Find code files similar to a reference file
Similar {
/// Reference file path
file_path: PathBuf,
/// Max results to return
#[arg(long, default_value_t = 10)]
limit: usize,
/// Output format
#[arg(long, value_enum, default_value = "table")]
format: OutputFormat,
},
}
/// Search mode for semantic search
#[derive(Clone, Debug, clap::ValueEnum, PartialEq)]
pub enum SearchMode {
/// Keyword-only search (ripgrep)
Keyword,
/// Vector-only search (semantic similarity)
Vector,
/// Hybrid search (keyword + vector with RRF)
Hybrid,
}
/// Clustering method for semantic analysis
#[derive(Clone, Debug, clap::ValueEnum, PartialEq)]
pub enum ClusterMethod {
/// K-means clustering
Kmeans,
/// Hierarchical clustering
Hierarchical,
/// DBSCAN density-based clustering
Dbscan,
}
/// Mutation testing arguments
#[cfg(feature = "mutation-testing")]
#[derive(Args, Debug, Clone)]
#[cfg_attr(test, derive(PartialEq))]
pub struct MutateArgs {
/// File or directory to mutate
#[arg(short, long, value_name = "PATH")]
pub target: PathBuf,
/// Programming language (rust, python, typescript, go, cpp)
#[arg(short, long)]
pub language: Option<String>,
/// Timeout per mutant in seconds
#[arg(long, default_value = "30")]
pub timeout: u64,
/// Parallel execution workers
#[arg(short, long)]
pub jobs: Option<usize>,
/// Output format (json, markdown, text)
#[arg(short = 'f', long, default_value = "text")]
pub output_format: String,
/// Output file (stdout if omitted)
#[arg(short, long)]
pub output: Option<PathBuf>,
/// Mutation score threshold (fail if below)
#[arg(long)]
pub threshold: Option<f64>,
/// Show only failures (survived mutants, compile errors, timeouts)
#[arg(long, default_value = "false")]
pub failures_only: bool,
// Sprint 70: cargo-mutants backend options
/// Use cargo-mutants backend for Rust mutation testing (requires cargo-mutants v24.7.0+)
///
/// Provides comprehensive Rust mutation testing using the industry-standard cargo-mutants tool.
/// Automatically detects cargo-mutants installation and validates version compatibility.
///
/// Example: pmat mutate --use-cargo-mutants --timeout 600
/// Guide: docs/user-guides/cargo-mutants-integration.md
#[arg(long)]
pub use_cargo_mutants: bool,
/// Cargo features to enable for mutation testing (comma-separated)
///
/// Only applies when --use-cargo-mutants is specified.
/// Enables specific Cargo features during mutation testing.
///
/// Example: --features "serde,logging"
#[arg(long, value_delimiter = ',')]
pub features: Option<Vec<String>>,
/// Enable all Cargo features during mutation testing
///
/// Only applies when --use-cargo-mutants is specified.
/// Equivalent to cargo test --all-features.
///
/// Example: --use-cargo-mutants --all-features
#[arg(long)]
pub all_features: bool,
/// Disable default Cargo features during mutation testing
///
/// Only applies when --use-cargo-mutants is specified.
/// Equivalent to cargo test --no-default-features.
///
/// Example: --use-cargo-mutants --no-default-features --features "minimal"
#[arg(long)]
pub no_default_features: bool,
/// Don't shuffle mutant execution order (deterministic results)
///
/// Only applies when --use-cargo-mutants is specified.
/// Mutants will be tested in sequential order for reproducible results.
///
/// Example: --use-cargo-mutants --no-shuffle
#[arg(long)]
pub no_shuffle: bool,
}