story-kit: start 70_story_server_owned_agent_completion_remove_report_completion_dependency
This commit is contained in:
@@ -582,28 +582,6 @@ fn handle_tools_list(id: Option<Value>) -> JsonRpcResponse {
|
||||
"required": ["worktree_path"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "report_completion",
|
||||
"description": "Report that the agent has finished work on a story. Rejects if the worktree has uncommitted changes. Runs acceptance gates (cargo clippy + tests) automatically. Stores the completion status and gate results on the agent record for retrieval by wait_for_agent or the supervisor. Call this as your final action after committing all changes.",
|
||||
"inputSchema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"story_id": {
|
||||
"type": "string",
|
||||
"description": "Story identifier (e.g. '44_my_story')"
|
||||
},
|
||||
"agent_name": {
|
||||
"type": "string",
|
||||
"description": "Agent name (as configured in project.toml)"
|
||||
},
|
||||
"summary": {
|
||||
"type": "string",
|
||||
"description": "Brief summary of the work completed"
|
||||
}
|
||||
},
|
||||
"required": ["story_id", "agent_name", "summary"]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "accept_story",
|
||||
"description": "Accept a story: moves it from current/ to archived/ and auto-commits to master.",
|
||||
@@ -805,8 +783,6 @@ async fn handle_tools_call(
|
||||
"remove_worktree" => tool_remove_worktree(&args, ctx).await,
|
||||
// Editor tools
|
||||
"get_editor_command" => tool_get_editor_command(&args, ctx),
|
||||
// Completion reporting
|
||||
"report_completion" => tool_report_completion(&args, ctx).await,
|
||||
// Lifecycle tools
|
||||
"accept_story" => tool_accept_story(&args, ctx),
|
||||
// Story mutation tools (auto-commit to master)
|
||||
@@ -1185,40 +1161,6 @@ fn tool_get_editor_command(args: &Value, ctx: &AppContext) -> Result<String, Str
|
||||
Ok(format!("{editor} {worktree_path}"))
|
||||
}
|
||||
|
||||
async fn tool_report_completion(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 agent_name = args
|
||||
.get("agent_name")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: agent_name")?;
|
||||
let summary = args
|
||||
.get("summary")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or("Missing required argument: summary")?;
|
||||
|
||||
let report = ctx
|
||||
.agents
|
||||
.report_completion(story_id, agent_name, summary)
|
||||
.await?;
|
||||
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"story_id": story_id,
|
||||
"agent_name": agent_name,
|
||||
"summary": report.summary,
|
||||
"gates_passed": report.gates_passed,
|
||||
"gate_output": report.gate_output,
|
||||
"message": if report.gates_passed {
|
||||
"Completion accepted. All acceptance gates passed."
|
||||
} else {
|
||||
"Completion recorded but acceptance gates failed. Review gate_output for details."
|
||||
}
|
||||
}))
|
||||
.map_err(|e| format!("Serialization error: {e}"))
|
||||
}
|
||||
|
||||
fn tool_accept_story(args: &Value, ctx: &AppContext) -> Result<String, String> {
|
||||
let story_id = args
|
||||
.get("story_id")
|
||||
@@ -1591,7 +1533,7 @@ mod tests {
|
||||
assert!(names.contains(&"list_worktrees"));
|
||||
assert!(names.contains(&"remove_worktree"));
|
||||
assert!(names.contains(&"get_editor_command"));
|
||||
assert!(names.contains(&"report_completion"));
|
||||
assert!(!names.contains(&"report_completion"));
|
||||
assert!(names.contains(&"accept_story"));
|
||||
assert!(names.contains(&"check_criterion"));
|
||||
assert!(names.contains(&"set_test_plan"));
|
||||
@@ -1601,7 +1543,7 @@ mod tests {
|
||||
assert!(names.contains(&"merge_agent_work"));
|
||||
assert!(names.contains(&"move_story_to_merge"));
|
||||
assert!(names.contains(&"request_qa"));
|
||||
assert_eq!(tools.len(), 27);
|
||||
assert_eq!(tools.len(), 26);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1850,71 +1792,6 @@ mod tests {
|
||||
assert!(parsed.get("completion").is_some());
|
||||
}
|
||||
|
||||
// ── report_completion tool tests ──────────────────────────────
|
||||
|
||||
#[test]
|
||||
fn report_completion_in_tools_list() {
|
||||
let resp = handle_tools_list(Some(json!(1)));
|
||||
let tools = resp.result.unwrap()["tools"].as_array().unwrap().clone();
|
||||
let tool = tools
|
||||
.iter()
|
||||
.find(|t| t["name"] == "report_completion")
|
||||
.expect("report_completion missing from tools list");
|
||||
// Schema has required fields
|
||||
let required = tool["inputSchema"]["required"].as_array().unwrap();
|
||||
let req_names: Vec<&str> = required.iter().map(|v| v.as_str().unwrap()).collect();
|
||||
assert!(req_names.contains(&"story_id"));
|
||||
assert!(req_names.contains(&"agent_name"));
|
||||
assert!(req_names.contains(&"summary"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn report_completion_tool_missing_story_id() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result =
|
||||
tool_report_completion(&json!({"agent_name": "bot", "summary": "done"}), &ctx).await;
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("story_id"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn report_completion_tool_missing_agent_name() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result =
|
||||
tool_report_completion(&json!({"story_id": "44_test", "summary": "done"}), &ctx).await;
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("agent_name"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn report_completion_tool_missing_summary() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_report_completion(
|
||||
&json!({"story_id": "44_test", "agent_name": "bot"}),
|
||||
&ctx,
|
||||
)
|
||||
.await;
|
||||
assert!(result.is_err());
|
||||
assert!(result.unwrap_err().contains("summary"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn report_completion_tool_nonexistent_agent() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_report_completion(
|
||||
&json!({"story_id": "99_nope", "agent_name": "bot", "summary": "done"}),
|
||||
&ctx,
|
||||
)
|
||||
.await;
|
||||
assert!(result.is_err());
|
||||
let msg = result.unwrap_err();
|
||||
assert!(msg.contains("No agent"), "unexpected: {msg}");
|
||||
}
|
||||
|
||||
// ── Editor command tool tests ─────────────────────────────────
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user