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
use crate;
use crateQualityProxyService;
use async_trait;
use ;
use Deserialize;
use Value;
use ;
/// Input parameters for the quality proxy tool.
/// Tool handler for proxying code changes through quality gates.
///
/// This handler intercepts code operations from AI agents and ensures
/// they meet quality standards before being applied. It supports three
/// enforcement modes: strict (reject low-quality code), advisory (warn
/// but allow), and auto-fix (automatically refactor to meet standards).
///
/// # Example
///
/// ```ignore
/// use pmat::mcp_pmcp::quality_proxy_handler::QualityProxyTool;
/// use pmcp::ToolHandler;
///
/// let tool = QualityProxyTool;
/// assert_eq!(tool.name(), "quality_proxy");
/// ```ignore
///
/// # Strict Mode Example
///
/// ```ignore
/// use pmat::mcp_pmcp::quality_proxy_handler::{QualityProxyTool, QualityProxyInput};
/// use pmcp::ToolHandler;
/// use serde_json::json;
///
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// let tool = QualityProxyTool;
///
/// // Intercept a file write operation
/// let input = json!({
/// "operation": "write",
/// "file_path": "src/new_feature.rs",
/// "content": "fn complex_function() { /* code */ }",
/// "mode": "strict",
/// "quality_config": {
/// "max_complexity": 10,
/// "allow_satd": false,
/// "require_docs": true
/// }
/// });
///
/// // Quality proxy validates before allowing write
/// let result = tool.handle(input, Default::default()).await?;
///
/// // Check if operation was approved
/// assert!(result["approved"].is_boolean());
/// if !result["approved"].as_bool().unwrap_or(false) {
/// println!("Quality violations: {}", result["violations"]);
/// }
/// # Ok(())
/// # }
/// ```ignore
///
/// # Auto-Fix Mode Example
///
/// ```ignore
/// use pmat::mcp_pmcp::quality_proxy_handler::QualityProxyTool;
/// use pmcp::ToolHandler;
/// use serde_json::json;
///
/// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
/// let tool = QualityProxyTool;
///
/// // Enable auto-fix mode
/// let input = json!({
/// "operation": "edit",
/// "file_path": "src/messy_code.rs",
/// "old_content": "fn f(){if(true){return 1;}return 0;}",
/// "new_content": "fn f(){if(true){return 1;}return 0;}//Needs refactoring",
/// "mode": "auto_fix",
/// "quality_config": {
/// "max_complexity": 5,
/// "allow_satd": false,
/// "auto_format": true
/// }
/// });
///
/// // Quality proxy automatically improves the code
/// let result = tool.handle(input, Default::default()).await?;
///
/// // Get the improved version
/// if result["auto_fixed"].as_bool().unwrap_or(false) {
/// let fixed_content = result["fixed_content"].as_str().unwrap();
/// println!("Auto-fixed code: {}", fixed_content);
/// }
/// # Ok(())
/// # }
/// ```ignore
///
/// # Quality Configuration
///
/// ```ignore
/// use pmat::mcp_pmcp::quality_proxy_handler::QualityConfigInput;
///
/// // Strict configuration for production
/// let strict_config = QualityConfigInput {
/// max_complexity: 8,
/// allow_satd: false,
/// require_docs: true,
/// auto_format: true,
/// };
///
/// // Relaxed configuration for prototyping
/// let relaxed_config = QualityConfigInput {
/// max_complexity: 20,
/// allow_satd: false, // Still no TODOs!
/// require_docs: false,
/// auto_format: false,
/// };
/// ```ignore
;
include!;
include!;