The great storkit name conversion
This commit is contained in:
@@ -735,7 +735,14 @@ async fn on_room_message(
|
||||
let room_id_str = incoming_room_id.to_string();
|
||||
let is_ambient = ctx.ambient_rooms.lock().unwrap().contains(&room_id_str);
|
||||
|
||||
if !is_addressed && !is_ambient {
|
||||
// Always let "ambient on" through — it is the one command that must work
|
||||
// even when the bot is not mentioned and ambient mode is off, otherwise
|
||||
// there is no way to re-enable ambient mode without an @-mention.
|
||||
let is_ambient_on = body
|
||||
.to_ascii_lowercase()
|
||||
.contains("ambient on");
|
||||
|
||||
if !is_addressed && !is_ambient && !is_ambient_on {
|
||||
slog!(
|
||||
"[matrix-bot] Ignoring unaddressed message from {}",
|
||||
ev.sender
|
||||
|
||||
@@ -104,9 +104,7 @@ pub async fn handle_delete(
|
||||
let (path, stage, story_id) = match found {
|
||||
Some(f) => f,
|
||||
None => {
|
||||
return format!(
|
||||
"No story, bug, or spike with number **{story_number}** found."
|
||||
);
|
||||
return format!("No story, bug, or spike with number **{story_number}** found.");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -135,9 +133,7 @@ pub async fn handle_delete(
|
||||
let mut stopped_agents: Vec<String> = Vec::new();
|
||||
for (sid, agent_name) in &running_agents {
|
||||
if let Err(e) = agents.stop_agent(project_root, sid, agent_name).await {
|
||||
return format!(
|
||||
"Failed to stop agent '{agent_name}' for story {story_number}: {e}"
|
||||
);
|
||||
return format!("Failed to stop agent '{agent_name}' for story {story_number}: {e}");
|
||||
}
|
||||
stopped_agents.push(agent_name.clone());
|
||||
}
|
||||
@@ -151,7 +147,7 @@ pub async fn handle_delete(
|
||||
}
|
||||
|
||||
// Commit the deletion to git.
|
||||
let commit_msg = format!("story-kit: delete {story_id}");
|
||||
let commit_msg = format!("storkit: delete {story_id}");
|
||||
let work_rel = std::path::PathBuf::from(".storkit").join("work");
|
||||
let _ = std::process::Command::new("git")
|
||||
.args(["add", "-A"])
|
||||
@@ -171,9 +167,7 @@ pub async fn handle_delete(
|
||||
response.push_str(&format!(" Stopped agent(s): {agent_list}."));
|
||||
}
|
||||
|
||||
crate::slog!(
|
||||
"[matrix-bot] delete command: removed {story_id} from {stage} (bot={bot_name})"
|
||||
);
|
||||
crate::slog!("[matrix-bot] delete command: removed {story_id} from {stage} (bot={bot_name})");
|
||||
|
||||
response
|
||||
}
|
||||
@@ -240,25 +234,45 @@ mod tests {
|
||||
fn extract_with_full_user_id() {
|
||||
let cmd =
|
||||
extract_delete_command("@timmy:home.local delete 42", "Timmy", "@timmy:home.local");
|
||||
assert_eq!(cmd, Some(DeleteCommand::Delete { story_number: "42".to_string() }));
|
||||
assert_eq!(
|
||||
cmd,
|
||||
Some(DeleteCommand::Delete {
|
||||
story_number: "42".to_string()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_with_display_name() {
|
||||
let cmd = extract_delete_command("Timmy delete 310", "Timmy", "@timmy:home.local");
|
||||
assert_eq!(cmd, Some(DeleteCommand::Delete { story_number: "310".to_string() }));
|
||||
assert_eq!(
|
||||
cmd,
|
||||
Some(DeleteCommand::Delete {
|
||||
story_number: "310".to_string()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_with_localpart() {
|
||||
let cmd = extract_delete_command("@timmy delete 7", "Timmy", "@timmy:home.local");
|
||||
assert_eq!(cmd, Some(DeleteCommand::Delete { story_number: "7".to_string() }));
|
||||
assert_eq!(
|
||||
cmd,
|
||||
Some(DeleteCommand::Delete {
|
||||
story_number: "7".to_string()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn extract_case_insensitive_command() {
|
||||
let cmd = extract_delete_command("Timmy DELETE 99", "Timmy", "@timmy:home.local");
|
||||
assert_eq!(cmd, Some(DeleteCommand::Delete { story_number: "99".to_string() }));
|
||||
assert_eq!(
|
||||
cmd,
|
||||
Some(DeleteCommand::Delete {
|
||||
story_number: "99".to_string()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -285,7 +299,12 @@ mod tests {
|
||||
// Without mention prefix the raw text is "delete 42" — cmd is "delete", args "42"
|
||||
// strip_mention returns the full trimmed text when no prefix matches,
|
||||
// so this is a valid delete command addressed to no-one (ambient mode).
|
||||
assert_eq!(cmd, Some(DeleteCommand::Delete { story_number: "42".to_string() }));
|
||||
assert_eq!(
|
||||
cmd,
|
||||
Some(DeleteCommand::Delete {
|
||||
story_number: "42".to_string()
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// -- handle_delete (integration-style, uses temp filesystem) -----------
|
||||
@@ -295,7 +314,14 @@ mod tests {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let project_root = tmp.path();
|
||||
// Create the pipeline directories.
|
||||
for stage in &["1_backlog", "2_current", "3_qa", "4_merge", "5_done", "6_archived"] {
|
||||
for stage in &[
|
||||
"1_backlog",
|
||||
"2_current",
|
||||
"3_qa",
|
||||
"4_merge",
|
||||
"5_done",
|
||||
"6_archived",
|
||||
] {
|
||||
std::fs::create_dir_all(project_root.join(".storkit").join("work").join(stage))
|
||||
.unwrap();
|
||||
}
|
||||
@@ -332,11 +358,7 @@ mod tests {
|
||||
let backlog_dir = project_root.join(".storkit").join("work").join("1_backlog");
|
||||
std::fs::create_dir_all(&backlog_dir).unwrap();
|
||||
let story_path = backlog_dir.join("42_story_some_feature.md");
|
||||
std::fs::write(
|
||||
&story_path,
|
||||
"---\nname: Some Feature\n---\n\n# Story 42\n",
|
||||
)
|
||||
.unwrap();
|
||||
std::fs::write(&story_path, "---\nname: Some Feature\n---\n\n# Story 42\n").unwrap();
|
||||
|
||||
// Initial commit so git doesn't complain about no commits.
|
||||
std::process::Command::new("git")
|
||||
|
||||
Reference in New Issue
Block a user