Skip to main content

weavatrix_rust/operations/catalog/
profile.rs

1use std::str::FromStr;
2
3/// Selects a bounded operation catalog independently of any transport.
4#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
5pub enum ToolProfile {
6    /// Code intelligence plus semantic, SEO, and memory extensions.
7    #[default]
8    All,
9    /// Repository and coding-agent intelligence without SEO-specific tools.
10    Code,
11    /// Content-graph, search, semantic, and SEO analysis.
12    Seo,
13}
14
15impl ToolProfile {
16    #[must_use]
17    pub fn allows(self, tool: &str) -> bool {
18        match self {
19            Self::All => true,
20            Self::Code => tool != "seo_link_suggestions",
21            Self::Seo => matches!(
22                tool,
23                "graph_stats"
24                    | "get_node"
25                    | "get_neighbors"
26                    | "query_graph"
27                    | "shortest_path"
28                    | "search_code"
29                    | "read_source"
30                    | "context_bundle"
31                    | "list_communities"
32                    | "get_community"
33                    | "module_map"
34                    | "rebuild_graph"
35                    | "open_repo"
36                    | "list_known_repos"
37                    | "semantic_link"
38                    | "vector_search"
39                    | "seo_link_suggestions"
40                    | "memory_context"
41            ),
42        }
43    }
44}
45
46impl FromStr for ToolProfile {
47    type Err = String;
48
49    fn from_str(value: &str) -> Result<Self, Self::Err> {
50        match value {
51            "all" => Ok(Self::All),
52            "code" => Ok(Self::Code),
53            "seo" | "content" => Ok(Self::Seo),
54            _ => Err(format!(
55                "unknown tool profile {value:?}; expected all, code, or seo"
56            )),
57        }
58    }
59}