//! MCP story tools — create, update, move, and manage stories, bugs, refactors, //! spikes, and epics via MCP. //! //! 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; mod epic; mod refactor; mod spike; mod story; /// 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":}`. /// /// Callers that create items on behalf of system automation (e.g. gate-failure /// auto-filing) should pass `kind = "system"` and `id = ""`. 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() } } 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, }; pub(crate) use epic::{tool_create_epic, tool_list_epics, tool_show_epic}; pub(crate) use refactor::{tool_create_refactor, tool_list_refactors}; pub(crate) use spike::tool_create_spike; pub(crate) use story::{ 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, };