huskies: merge 629_refactor_migrate_commanddispatch_and_commandcontext_to_services_bundle

This commit is contained in:
dave
2026-04-25 20:41:19 +00:00
parent 2a3f88fdcf
commit 14b158d0b2
27 changed files with 407 additions and 544 deletions
+19 -39
View File
@@ -9,7 +9,7 @@ pub(super) fn handle_git(ctx: &CommandContext) -> Option<String> {
// Current branch
let branch = Command::new("git")
.args(["rev-parse", "--abbrev-ref", "HEAD"])
.current_dir(ctx.project_root)
.current_dir(ctx.effective_root())
.output()
.ok()
.filter(|o| o.status.success())
@@ -19,7 +19,7 @@ pub(super) fn handle_git(ctx: &CommandContext) -> Option<String> {
// Porcelain status for staged + unstaged changes
let status_output = Command::new("git")
.args(["status", "--porcelain"])
.current_dir(ctx.project_root)
.current_dir(ctx.effective_root())
.output()
.ok()
.filter(|o| o.status.success())
@@ -32,7 +32,7 @@ pub(super) fn handle_git(ctx: &CommandContext) -> Option<String> {
// Ahead/behind: --left-right gives "N\tM" (ahead\tbehind)
let ahead_behind = Command::new("git")
.args(["rev-list", "--count", "--left-right", "HEAD...@{u}"])
.current_dir(ctx.project_root)
.current_dir(ctx.effective_root())
.output()
.ok()
.filter(|o| o.status.success())
@@ -77,20 +77,8 @@ pub(super) fn handle_git(ctx: &CommandContext) -> Option<String> {
#[cfg(test)]
mod tests {
use crate::agents::AgentPool;
use std::collections::HashSet;
use std::sync::{Arc, Mutex};
use super::super::{CommandDispatch, try_handle_command};
fn test_ambient_rooms() -> Arc<Mutex<HashSet<String>>> {
Arc::new(Mutex::new(HashSet::new()))
}
fn test_agents() -> Arc<AgentPool> {
Arc::new(AgentPool::new_test(3000))
}
#[test]
fn git_command_is_registered() {
use super::super::commands;
@@ -118,15 +106,13 @@ mod tests {
let repo_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap_or(std::path::Path::new("."));
let agents = test_agents();
let ambient_rooms = test_ambient_rooms();
let services =
crate::services::Services::new_test(repo_root.to_path_buf(), "Timmy".to_string());
let room_id = "!test:example.com".to_string();
let dispatch = CommandDispatch {
bot_name: "Timmy",
services: &services,
project_root: &services.project_root,
bot_user_id: "@timmy:homeserver.local",
project_root: repo_root,
agents: &agents,
ambient_rooms: &ambient_rooms,
room_id: &room_id,
};
let result = try_handle_command(&dispatch, "@timmy git");
@@ -138,15 +124,13 @@ mod tests {
let repo_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap_or(std::path::Path::new("."));
let agents = test_agents();
let ambient_rooms = test_ambient_rooms();
let services =
crate::services::Services::new_test(repo_root.to_path_buf(), "Timmy".to_string());
let room_id = "!test:example.com".to_string();
let dispatch = CommandDispatch {
bot_name: "Timmy",
services: &services,
project_root: &services.project_root,
bot_user_id: "@timmy:homeserver.local",
project_root: repo_root,
agents: &agents,
ambient_rooms: &ambient_rooms,
room_id: &room_id,
};
let output = try_handle_command(&dispatch, "@timmy git").unwrap();
@@ -161,15 +145,13 @@ mod tests {
let repo_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap_or(std::path::Path::new("."));
let agents = test_agents();
let ambient_rooms = test_ambient_rooms();
let services =
crate::services::Services::new_test(repo_root.to_path_buf(), "Timmy".to_string());
let room_id = "!test:example.com".to_string();
let dispatch = CommandDispatch {
bot_name: "Timmy",
services: &services,
project_root: &services.project_root,
bot_user_id: "@timmy:homeserver.local",
project_root: repo_root,
agents: &agents,
ambient_rooms: &ambient_rooms,
room_id: &room_id,
};
let output = try_handle_command(&dispatch, "@timmy git").unwrap();
@@ -184,15 +166,13 @@ mod tests {
let repo_root = std::path::Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.unwrap_or(std::path::Path::new("."));
let agents = test_agents();
let ambient_rooms = test_ambient_rooms();
let services =
crate::services::Services::new_test(repo_root.to_path_buf(), "Timmy".to_string());
let room_id = "!test:example.com".to_string();
let dispatch = CommandDispatch {
bot_name: "Timmy",
services: &services,
project_root: &services.project_root,
bot_user_id: "@timmy:homeserver.local",
project_root: repo_root,
agents: &agents,
ambient_rooms: &ambient_rooms,
room_id: &room_id,
};
let output = try_handle_command(&dispatch, "@timmy git").unwrap();