huskies: merge 572_story_edit_criterion_mcp_tool_to_update_acceptance_criteria_text

This commit is contained in:
dave
2026-04-15 12:59:49 +00:00
parent 52b21c22b1
commit ec40b4771b
4 changed files with 109 additions and 4 deletions
+24 -1
View File
@@ -513,6 +513,28 @@ fn handle_tools_list(id: Option<Value>) -> JsonRpcResponse {
"required": ["story_id", "criterion_index"]
}
},
{
"name": "edit_criterion",
"description": "Update the text of an existing acceptance criterion in place, preserving its checked/unchecked state. Uses a 0-based index counting all criteria (both checked and unchecked).",
"inputSchema": {
"type": "object",
"properties": {
"story_id": {
"type": "string",
"description": "Story identifier (filename stem, e.g. '28_my_story')"
},
"criterion_index": {
"type": "integer",
"description": "0-based index of the criterion to edit (counts all criteria)"
},
"new_text": {
"type": "string",
"description": "New text for the criterion (without the '- [ ] ' or '- [x] ' prefix)"
}
},
"required": ["story_id", "criterion_index", "new_text"]
}
},
{
"name": "add_criterion",
"description": "Add an acceptance criterion to an existing story file. Appends '- [ ] {criterion}' after the last existing criterion in the '## Acceptance Criteria' section. Auto-commits via the filesystem watcher.",
@@ -1242,6 +1264,7 @@ async fn handle_tools_call(id: Option<Value>, params: &Value, ctx: &AppContext)
"accept_story" => story_tools::tool_accept_story(&args, ctx),
// Story mutation tools (auto-commit to master)
"check_criterion" => story_tools::tool_check_criterion(&args, ctx),
"edit_criterion" => story_tools::tool_edit_criterion(&args, ctx),
"add_criterion" => story_tools::tool_add_criterion(&args, ctx),
"update_story" => story_tools::tool_update_story(&args, ctx),
// Spike lifecycle tools
@@ -1426,7 +1449,7 @@ mod tests {
assert!(names.contains(&"loc_file"));
assert!(names.contains(&"dump_crdt"));
assert!(names.contains(&"get_version"));
assert_eq!(tools.len(), 63);
assert_eq!(tools.len(), 64);
}
#[test]
+25 -2
View File
@@ -5,8 +5,9 @@ use crate::agents::{
use crate::http::context::AppContext;
use crate::http::workflow::{
add_criterion_to_file, check_criterion_in_file, create_bug_file, create_refactor_file,
create_spike_file, create_story_file, list_bug_files, list_refactor_files, load_pipeline_state,
load_upcoming_stories, update_story_in_file, validate_story_dirs,
create_spike_file, create_story_file, edit_criterion_in_file, list_bug_files,
list_refactor_files, load_pipeline_state, load_upcoming_stories, update_story_in_file,
validate_story_dirs,
};
use crate::io::story_metadata::{
check_archived_deps, check_archived_deps_from_list, parse_front_matter, parse_unchecked_todos,
@@ -331,6 +332,28 @@ pub(super) fn tool_check_criterion(args: &Value, ctx: &AppContext) -> Result<Str
))
}
pub(super) fn tool_edit_criterion(args: &Value, ctx: &AppContext) -> Result<String, String> {
let story_id = args
.get("story_id")
.and_then(|v| v.as_str())
.ok_or("Missing required argument: story_id")?;
let criterion_index = args
.get("criterion_index")
.and_then(|v| v.as_u64())
.ok_or("Missing required argument: criterion_index")? as usize;
let new_text = args
.get("new_text")
.and_then(|v| v.as_str())
.ok_or("Missing required argument: new_text")?;
let root = ctx.state.get_project_root()?;
edit_criterion_in_file(&root, story_id, criterion_index, new_text)?;
Ok(format!(
"Criterion {criterion_index} updated for story '{story_id}'."
))
}
pub(super) fn tool_add_criterion(args: &Value, ctx: &AppContext) -> Result<String, String> {
let story_id = args
.get("story_id")