convert hand-written enum as_str matches to strum derives workspace-wide

This commit is contained in:
damocles 2026-09-11 21:06:54 +02:00
commit 299add158f
14 changed files with 70 additions and 113 deletions

View file

@ -12,8 +12,9 @@ use serde::{Deserialize, Serialize};
/// config) and expands it to the matching tool names for `--allowedTools`.
/// When the env var is absent the harness falls back to `AGENT_DEFAULT`.
/// See `docs/process/conventions.md::Tool groups`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, strum::IntoStaticStr)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum ToolGroup {
/// `send`, `recv`, `ack_until`
Messaging,
@ -154,21 +155,12 @@ impl ToolGroup {
];
/// The `snake_case` wire name for this group (matches `serde(rename_all =
/// "snake_case")` serialisation).
/// "snake_case")` serialisation) — derived (`#[strum(serialize_all =
/// "snake_case")]`) from the same convention rather than a hand-written
/// match kept in sync with it by hand.
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
Self::Messaging => "messaging",
Self::Meta => "meta",
Self::Inbox => "inbox",
Self::Lifecycle => "lifecycle",
Self::Approvals => "approvals",
Self::Scheduling => "scheduling",
Self::Diagnostics => "diagnostics",
Self::Forge => "forge",
Self::Execution => "execution",
Self::WebTools => "web_tools",
}
self.into()
}
/// Short human-readable description suitable for a tooltip or help text.
@ -213,8 +205,9 @@ impl ToolGroup {
/// `snake_case`) via `meta::render_flake`. The harness reads this to
/// conditionally register capability-gated MCP tools so claude only
/// sees tools it can actually invoke. See `docs/process/conventions.md::Capabilities`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, strum::IntoStaticStr)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum Capability {
/// Agent can lifecycle-manage the root agent (kill/start/restart)
/// on behalf of the hive when the root has crashed. Named capability
@ -247,14 +240,12 @@ impl Capability {
Self::QueryAgentState,
];
/// Canonical `snake_case` name for this capability (matches serde).
/// Canonical `snake_case` name for this capability (matches serde) —
/// derived rather than a hand-written match, same as
/// [`ToolGroup::as_str`].
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
Self::ManageRootAgent => "manage_root_agent",
Self::ReadHostJournal => "read_host_journal",
Self::QueryAgentState => "query_agent_state",
}
self.into()
}
/// Short human-readable description suitable for a tooltip or help text.