huskies: merge 824
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
//! Cleanup-worktrees bot command — stub module required by the commands registry.
|
||||
//!
|
||||
//! The real async implementation lives in
|
||||
//! `chat::transport::matrix::cleanup_worktrees`. This file exists so that
|
||||
//! `commands/mod.rs` can declare the module, keeping the registry consistent
|
||||
//! with the pattern used by other async commands (rmtree, start, rebuild, …).
|
||||
//!
|
||||
//! The fallback handler `handle_cleanup_worktrees_fallback` in `mod.rs` always
|
||||
//! returns `None`; the matrix transport intercepts the command before
|
||||
//! `try_handle_command` is reached.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::chat::commands::tests::{commands, try_cmd_addressed};
|
||||
|
||||
#[test]
|
||||
fn cleanup_worktrees_is_registered() {
|
||||
assert!(
|
||||
commands().iter().any(|c| c.name == "cleanup_worktrees"),
|
||||
"cleanup_worktrees must be in the command registry"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cleanup_worktrees_has_description() {
|
||||
let cmd = commands()
|
||||
.iter()
|
||||
.find(|c| c.name == "cleanup_worktrees")
|
||||
.expect("cleanup_worktrees must be registered");
|
||||
assert!(
|
||||
!cmd.description.is_empty(),
|
||||
"cleanup_worktrees must have a description"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cleanup_worktrees_fallback_returns_none() {
|
||||
// The sync fallback returns None — the async handler in the Matrix
|
||||
// transport handles the real work.
|
||||
let result = try_cmd_addressed(
|
||||
"Timmy",
|
||||
"@timmy:homeserver.local",
|
||||
"@timmy cleanup_worktrees",
|
||||
);
|
||||
assert!(
|
||||
result.is_none(),
|
||||
"cleanup_worktrees fallback must return None (handled async): {result:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
mod ambient;
|
||||
mod assign;
|
||||
mod backlog;
|
||||
mod cleanup_worktrees;
|
||||
mod cost;
|
||||
mod coverage;
|
||||
mod depends;
|
||||
@@ -256,6 +257,11 @@ pub fn commands() -> &'static [BotCommand] {
|
||||
description: "Show setup wizard progress; or `setup generate` / `setup confirm` / `setup skip` / `setup retry` to drive the wizard from chat",
|
||||
handler: setup::handle_setup,
|
||||
},
|
||||
BotCommand {
|
||||
name: "cleanup_worktrees",
|
||||
description: "List orphaned worktrees (dry run), or `cleanup_worktrees --confirm` to remove them",
|
||||
handler: handle_cleanup_worktrees_fallback,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -402,6 +408,17 @@ fn handle_rebuild_fallback(_ctx: &CommandContext) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Fallback handler for the `cleanup_worktrees` command when it is not
|
||||
/// intercepted by the async handler in `on_room_message`. In practice this is
|
||||
/// never called — cleanup_worktrees is detected and handled before
|
||||
/// `try_handle_command` is invoked. The entry exists in the registry only so
|
||||
/// `help` lists it.
|
||||
///
|
||||
/// Returns `None` to prevent the LLM from receiving "cleanup_worktrees" as a prompt.
|
||||
fn handle_cleanup_worktrees_fallback(_ctx: &CommandContext) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Tests
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user