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
//! Organizational Intelligence Plugin - Binary Entry Point
//! Toyota Way: Thin entry point, testable business logic in cli_handlers module
use anyhow::Result;
use clap::Parser;
use organizational_intelligence_plugin::cli_handlers;
use organizational_intelligence_plugin::{Cli, Commands};
use std::env;
use tracing::Level;
#[tokio::main]
async fn main() -> Result<()> {
// Parse CLI arguments
let cli = Cli::parse();
// Initialize logging
let level = if cli.verbose {
Level::DEBUG
} else {
Level::INFO
};
tracing_subscriber::fmt::fmt().with_max_level(level).init();
tracing::info!(
"🚀 Organizational Intelligence Plugin v{}",
env!("CARGO_PKG_VERSION")
);
// Handle commands by calling handlers (all business logic is testable)
match cli.command {
Commands::ReviewPr {
baseline,
files,
format,
output,
} => cli_handlers::handle_review_pr(baseline, files, format, output).await,
Commands::Summarize {
input,
output,
strip_pii,
top_n,
min_frequency,
include_examples,
} => {
cli_handlers::handle_summarize(
input,
output,
strip_pii,
top_n,
min_frequency,
include_examples,
)
.await
}
Commands::Analyze {
org,
output,
max_concurrent,
model,
ml_confidence,
} => {
let github_token = env::var("GITHUB_TOKEN").ok();
let analyzer_version = env!("CARGO_PKG_VERSION").to_string();
cli_handlers::handle_analyze(
org,
output,
max_concurrent,
github_token,
analyzer_version,
model,
ml_confidence,
)
.await
}
Commands::ExtractTrainingData {
repo,
output,
min_confidence,
max_commits,
create_splits,
viz,
} => {
cli_handlers::handle_extract_training_data(
repo,
output,
min_confidence,
max_commits,
create_splits,
viz,
)
.await
}
Commands::TrainClassifier {
input,
output,
n_estimators,
max_depth,
max_features,
} => {
cli_handlers::handle_train_classifier(
input,
output,
n_estimators,
max_depth,
max_features,
)
.await
}
Commands::Export {
repo,
output,
format,
max_commits,
min_confidence,
} => cli_handlers::handle_export(repo, output, format, max_commits, min_confidence).await,
Commands::ImportDepyler {
input,
output,
min_confidence,
merge,
create_splits,
} => {
cli_handlers::handle_import_depyler(input, output, min_confidence, merge, create_splits)
.await
}
Commands::Localize {
passed_coverage,
failed_coverage,
passed_count,
failed_count,
formula,
top_n,
output,
format,
enrich_tdg,
repo,
rag,
knowledge_base,
fusion,
similar_bugs,
ensemble,
ensemble_model,
include_churn,
calibrated,
calibration_model,
confidence_threshold,
} => {
cli_handlers::handle_localize(
passed_coverage,
failed_coverage,
passed_count,
failed_count,
formula,
top_n,
output,
format,
enrich_tdg,
repo,
rag,
knowledge_base,
fusion,
similar_bugs,
ensemble,
ensemble_model,
include_churn,
calibrated,
calibration_model,
confidence_threshold,
)
.await
}
}
}