story-kit: merge 176_bug_stories_moved_to_current_get_supervisor_instead_of_coder
This commit is contained in:
@@ -442,7 +442,7 @@ fn handle_tools_list(id: Option<Value>) -> JsonRpcResponse {
|
||||
},
|
||||
"agent_name": {
|
||||
"type": "string",
|
||||
"description": "Agent name from project.toml config. If omitted, uses the first configured agent."
|
||||
"description": "Agent name from project.toml config. If omitted, uses the first coder agent (stage = \"coder\"). Supervisor must be requested explicitly by name."
|
||||
}
|
||||
},
|
||||
"required": ["story_id"]
|
||||
@@ -2890,6 +2890,71 @@ mod tests {
|
||||
assert!(result.unwrap_err().contains("story_id"));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn tool_start_agent_no_agent_name_no_coder_returns_clear_error() {
|
||||
// Config has only a supervisor — start_agent without agent_name should
|
||||
// refuse rather than silently assigning supervisor.
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let sk = tmp.path().join(".story_kit");
|
||||
std::fs::create_dir_all(&sk).unwrap();
|
||||
std::fs::write(
|
||||
sk.join("project.toml"),
|
||||
r#"
|
||||
[[agent]]
|
||||
name = "supervisor"
|
||||
stage = "other"
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_start_agent(&json!({"story_id": "42_my_story"}), &ctx).await;
|
||||
assert!(result.is_err());
|
||||
let err = result.unwrap_err();
|
||||
assert!(
|
||||
err.contains("coder"),
|
||||
"error should mention 'coder', got: {err}"
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn tool_start_agent_no_agent_name_picks_coder_not_supervisor() {
|
||||
// Config has supervisor first, then coder-1. Without agent_name the
|
||||
// coder should be selected, not supervisor. The call will fail due to
|
||||
// missing git repo / worktree, but the error must NOT be about
|
||||
// "No coder agent configured".
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let sk = tmp.path().join(".story_kit");
|
||||
std::fs::create_dir_all(&sk).unwrap();
|
||||
std::fs::write(
|
||||
sk.join("project.toml"),
|
||||
r#"
|
||||
[[agent]]
|
||||
name = "supervisor"
|
||||
stage = "other"
|
||||
|
||||
[[agent]]
|
||||
name = "coder-1"
|
||||
stage = "coder"
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
let ctx = test_ctx(tmp.path());
|
||||
let result = tool_start_agent(&json!({"story_id": "42_my_story"}), &ctx).await;
|
||||
// May succeed or fail for infrastructure reasons (no git repo), but
|
||||
// must NOT fail with "No coder agent configured".
|
||||
if let Err(err) = result {
|
||||
assert!(
|
||||
!err.contains("No coder agent configured"),
|
||||
"should not fail on agent selection, got: {err}"
|
||||
);
|
||||
// Should also not complain about supervisor being absent.
|
||||
assert!(
|
||||
!err.contains("supervisor"),
|
||||
"should not select supervisor, got: {err}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn tool_create_worktree_missing_story_id() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in New Issue
Block a user