#[derive(Debug, Deserialize)]
struct SatdArgs {
paths: Vec<String>,
#[serde(default)]
include_resolved: bool,
}
pub struct SatdTool;
impl SatdTool {
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new() -> Self {
Self
}
}
impl Default for SatdTool {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl ToolHandler for SatdTool {
async fn handle(&self, args: Value, _extra: RequestHandlerExtra) -> Result<Value> {
debug!("Handling analyze.satd with args: {}", args);
let params: SatdArgs = serde_json::from_value(args)
.map_err(|e| Error::validation(format!("Invalid arguments: {e}")))?;
let paths: Vec<PathBuf> = params.paths.into_iter().map(PathBuf::from).collect();
let results = tool_functions::analyze_satd(&paths, params.include_resolved)
.await
.map_err(|e| Error::internal(format!("SATD analysis failed: {e}")))?;
Ok(results)
}
fn metadata(&self) -> Option<ToolInfo> {
let extra = json!({
"include_resolved": { "type": "boolean", "description": "Include items already marked resolved" }
});
Some(build_tool_info(
"analyze_satd",
"Detect self-admitted technical debt (TODO, FIXME, HACK markers) in source code.",
paths_object_schema(extra, vec!["paths"]),
))
}
}
#[derive(Debug, Deserialize)]
struct DeadCodeArgs {
paths: Vec<String>,
#[serde(default)]
include_tests: bool,
}
pub struct DeadCodeTool;
impl DeadCodeTool {
#[must_use]
#[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
pub fn new() -> Self {
Self
}
}
impl Default for DeadCodeTool {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl ToolHandler for DeadCodeTool {
async fn handle(&self, args: Value, _extra: RequestHandlerExtra) -> Result<Value> {
debug!("Handling analyze.dead-code with args: {}", args);
let params: DeadCodeArgs = serde_json::from_value(args)
.map_err(|e| Error::validation(format!("Invalid arguments: {e}")))?;
let paths: Vec<PathBuf> = params.paths.into_iter().map(PathBuf::from).collect();
let results = tool_functions::analyze_dead_code(&paths, params.include_tests)
.await
.map_err(|e| Error::internal(format!("Dead code analysis failed: {e}")))?;
Ok(results)
}
fn metadata(&self) -> Option<ToolInfo> {
let extra = json!({
"include_tests": { "type": "boolean", "description": "Include test files when searching for dead code" }
});
Some(build_tool_info(
"analyze_dead_code",
"Find unreachable or unused code (functions, types, or modules).",
paths_object_schema(extra, vec!["paths"]),
))
}
}