2026-04-26 21:11:09 +00:00
|
|
|
//! MCP story tools — create, update, move, and manage stories, bugs, refactors,
|
2026-04-29 21:41:44 +00:00
|
|
|
//! spikes, and epics via MCP.
|
2026-04-26 21:11:09 +00:00
|
|
|
//!
|
|
|
|
|
//! This module is a thin adapter: it deserialises MCP payloads, delegates to
|
|
|
|
|
//! `crate::service::story` and `crate::http::workflow` for business logic,
|
|
|
|
|
//! and serialises responses.
|
|
|
|
|
|
|
|
|
|
mod bug;
|
|
|
|
|
mod criteria;
|
2026-04-29 21:41:44 +00:00
|
|
|
mod epic;
|
2026-04-26 21:11:09 +00:00
|
|
|
mod refactor;
|
|
|
|
|
mod spike;
|
|
|
|
|
mod story;
|
|
|
|
|
|
2026-05-15 01:58:33 +00:00
|
|
|
/// Build a compact origin JSON string for a newly-created work item (story 1088).
|
|
|
|
|
///
|
|
|
|
|
/// `args` may contain an `"origin"` object with `kind`, `id`, and `ts` fields
|
|
|
|
|
/// supplied by the caller (e.g. a coder agent passing its own identity). When
|
|
|
|
|
/// absent the default is `{"kind":"user","id":"","ts":<now>}`.
|
|
|
|
|
///
|
|
|
|
|
/// Callers that create items on behalf of system automation (e.g. gate-failure
|
|
|
|
|
/// auto-filing) should pass `kind = "system"` and `id = "<automation-name>"`.
|
|
|
|
|
pub(super) fn build_origin(args: &serde_json::Value) -> String {
|
|
|
|
|
let ts = std::time::SystemTime::now()
|
|
|
|
|
.duration_since(std::time::UNIX_EPOCH)
|
|
|
|
|
.unwrap_or_default()
|
|
|
|
|
.as_secs_f64();
|
|
|
|
|
|
|
|
|
|
if let Some(origin_obj) = args.get("origin").and_then(|v| v.as_object()) {
|
|
|
|
|
let kind = origin_obj
|
|
|
|
|
.get("kind")
|
|
|
|
|
.and_then(|v| v.as_str())
|
|
|
|
|
.unwrap_or("user");
|
|
|
|
|
let id = origin_obj.get("id").and_then(|v| v.as_str()).unwrap_or("");
|
|
|
|
|
let ts_val = origin_obj.get("ts").and_then(|v| v.as_f64()).unwrap_or(ts);
|
|
|
|
|
serde_json::json!({"kind": kind, "id": id, "ts": ts_val}).to_string()
|
|
|
|
|
} else {
|
|
|
|
|
serde_json::json!({"kind": "user", "id": "", "ts": ts}).to_string()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-04-26 21:11:09 +00:00
|
|
|
pub(crate) use bug::{tool_close_bug, tool_create_bug, tool_list_bugs};
|
|
|
|
|
pub(crate) use criteria::{
|
|
|
|
|
tool_add_criterion, tool_check_criterion, tool_edit_criterion, tool_ensure_acceptance,
|
|
|
|
|
tool_get_story_todos, tool_record_tests, tool_remove_criterion,
|
|
|
|
|
};
|
2026-04-29 21:41:44 +00:00
|
|
|
pub(crate) use epic::{tool_create_epic, tool_list_epics, tool_show_epic};
|
2026-04-26 21:11:09 +00:00
|
|
|
pub(crate) use refactor::{tool_create_refactor, tool_list_refactors};
|
|
|
|
|
pub(crate) use spike::tool_create_spike;
|
|
|
|
|
pub(crate) use story::{
|
2026-04-29 23:48:30 +00:00
|
|
|
tool_accept_story, tool_create_story, tool_delete_story, tool_freeze_story,
|
|
|
|
|
tool_get_pipeline_status, tool_list_upcoming, tool_purge_story, tool_unblock_story,
|
|
|
|
|
tool_unfreeze_story, tool_update_story, tool_validate_stories,
|
2026-04-26 21:11:09 +00:00
|
|
|
};
|