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    /// Exported n8n workflows without the full repository catalog.
14    N8n,
15    /// Exported Dify YAML apps without the full repository catalog.
16    Dify,
17    /// Agent Plugins, Skills, and native MCP configuration files.
18    Agent,
19    /// Mermaid flowchart diagrams and explicit diagram bindings.
20    Diagram,
21}
22
23impl ToolProfile {
24    #[must_use]
25    pub fn allows(self, tool: &str) -> bool {
26        match self {
27            Self::All => true,
28            Self::Code => tool != "seo_link_suggestions",
29            Self::N8n => matches!(
30                tool,
31                "n8n_inventory"
32                    | "n8n_trace"
33                    | "n8n_context"
34                    | "graph_stats"
35                    | "get_node"
36                    | "get_neighbors"
37                    | "query_graph"
38                    | "search_code"
39                    | "read_source"
40                    | "inspect_symbol"
41                    | "context_bundle"
42                    | "rebuild_graph"
43                    | "open_repo"
44                    | "list_known_repos"
45            ),
46            Self::Dify => matches!(
47                tool,
48                "dify_inventory"
49                    | "dify_trace"
50                    | "dify_context"
51                    | "graph_stats"
52                    | "get_node"
53                    | "get_neighbors"
54                    | "query_graph"
55                    | "search_code"
56                    | "read_source"
57                    | "inspect_symbol"
58                    | "context_bundle"
59                    | "rebuild_graph"
60                    | "open_repo"
61                    | "list_known_repos"
62            ),
63            Self::Agent => matches!(
64                tool,
65                "agent_inventory"
66                    | "agent_trace"
67                    | "agent_context"
68                    | "agent_change_impact"
69                    | "graph_stats"
70                    | "get_node"
71                    | "get_neighbors"
72                    | "query_graph"
73                    | "search_code"
74                    | "read_source"
75                    | "inspect_symbol"
76                    | "context_bundle"
77                    | "rebuild_graph"
78                    | "open_repo"
79                    | "list_known_repos"
80            ),
81            Self::Diagram => matches!(
82                tool,
83                "diagram_inventory"
84                    | "diagram_trace"
85                    | "diagram_context"
86                    | "change_impact"
87                    | "graph_stats"
88                    | "get_node"
89                    | "get_neighbors"
90                    | "query_graph"
91                    | "search_code"
92                    | "read_source"
93                    | "inspect_symbol"
94                    | "context_bundle"
95                    | "rebuild_graph"
96                    | "open_repo"
97                    | "list_known_repos"
98            ),
99            Self::Seo => matches!(
100                tool,
101                "graph_stats"
102                    | "get_node"
103                    | "get_neighbors"
104                    | "query_graph"
105                    | "shortest_path"
106                    | "search_code"
107                    | "read_source"
108                    | "context_bundle"
109                    | "list_communities"
110                    | "get_community"
111                    | "module_map"
112                    | "rebuild_graph"
113                    | "open_repo"
114                    | "list_known_repos"
115                    | "semantic_link"
116                    | "vector_search"
117                    | "seo_link_suggestions"
118                    | "memory_context"
119            ),
120        }
121    }
122}
123
124impl FromStr for ToolProfile {
125    type Err = String;
126
127    fn from_str(value: &str) -> Result<Self, Self::Err> {
128        match value {
129            "all" => Ok(Self::All),
130            "code" => Ok(Self::Code),
131            "seo" | "content" => Ok(Self::Seo),
132            "n8n" => Ok(Self::N8n),
133            "dify" => Ok(Self::Dify),
134            "agent" => Ok(Self::Agent),
135            "diagram" | "mermaid" => Ok(Self::Diagram),
136            _ => Err(format!(
137                "unknown tool profile {value:?}; expected all, code, seo, n8n, dify, agent, or diagram"
138            )),
139        }
140    }
141}