storkit: merge 420_story_loc_for_a_specified_file_bot_command_and_web_ui_slash_command

This commit is contained in:
dave
2026-03-28 08:56:06 +00:00
parent f4ce0e017b
commit d6f82393f5
5 changed files with 116 additions and 36 deletions
+11
View File
@@ -265,6 +265,17 @@ pub(super) fn tool_move_story(args: &Value, ctx: &AppContext) -> Result<String,
.map_err(|e| format!("Serialization error: {e}"))
}
/// MCP tool: count lines in a specific file relative to the project root.
pub(super) fn tool_loc_file(args: &Value, ctx: &AppContext) -> Result<String, String> {
let file_path = args
.get("file_path")
.and_then(|v| v.as_str())
.ok_or_else(|| "Missing required argument: file_path".to_string())?;
let project_root = ctx.state.get_project_root()?;
Ok(crate::chat::commands::loc::loc_single_file(&project_root, file_path))
}
#[cfg(test)]
mod tests {
use super::*;
+18 -1
View File
@@ -1136,6 +1136,20 @@ fn handle_tools_list(id: Option<Value>) -> JsonRpcResponse {
},
"required": ["story_id"]
}
},
{
"name": "loc_file",
"description": "Return the line count for a specific file. Path is resolved relative to the project root. Returns an error if the file does not exist.",
"inputSchema": {
"type": "object",
"properties": {
"file_path": {
"type": "string",
"description": "Path to the file, relative to the project root (e.g. 'server/src/main.rs')"
}
},
"required": ["file_path"]
}
}
]
}),
@@ -1226,6 +1240,8 @@ async fn handle_tools_call(
"git_log" => git_tools::tool_git_log(&args, ctx).await,
// Story triage
"status" => status_tools::tool_status(&args, ctx).await,
// File line count
"loc_file" => diagnostics::tool_loc_file(&args, ctx),
_ => Err(format!("Unknown tool: {tool_name}")),
};
@@ -1342,7 +1358,8 @@ mod tests {
assert!(names.contains(&"git_commit"));
assert!(names.contains(&"git_log"));
assert!(names.contains(&"status"));
assert_eq!(tools.len(), 49);
assert!(names.contains(&"loc_file"));
assert_eq!(tools.len(), 50);
}
#[test]