huskies: merge 1088
This commit is contained in:
@@ -12,6 +12,33 @@ 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":<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()
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
|
||||
Reference in New Issue
Block a user