use serde_json::Value;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct ToolManifest {
pub name: String,
pub description: String,
pub input_schema: Value,
pub scope: ToolScope,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ToolScope {
ReadOnly,
FileSystem,
Shell,
Network,
Memory,
Cloud,
}
pub struct ToolRegistry {
tools: HashMap<String, ToolManifest>,
}
impl ToolRegistry {
pub fn new() -> Self {
Self {
tools: HashMap::new(),
}
}
pub fn register(&mut self, manifest: ToolManifest) {
self.tools.insert(manifest.name.clone(), manifest);
}
pub fn get(&self, name: &str) -> Option<&ToolManifest> {
self.tools.get(name)
}
pub fn all(&self) -> Vec<&ToolManifest> {
self.tools.values().collect()
}
pub fn default_registry() -> Self {
let mut r = Self::new();
for (name, desc, scope) in BUILT_IN_TOOLS {
r.register(ToolManifest {
name: name.to_string(),
description: desc.to_string(),
input_schema: default_schema(name),
scope: *scope,
});
}
r
}
}
impl Default for ToolRegistry {
fn default() -> Self {
Self::default_registry()
}
}
const BUILT_IN_TOOLS: &[(&str, &str, ToolScope)] = &[
(
"sieve",
"Filter raw output to task-relevant lines",
ToolScope::ReadOnly,
),
(
"cartograph",
"Scan directory → structured project map",
ToolScope::FileSystem,
),
(
"chisel",
"Extract AST symbols from files",
ToolScope::FileSystem,
),
("sediment", "Persist facts into Vault", ToolScope::Memory),
(
"prism",
"Full AST parse + index of project directory",
ToolScope::FileSystem,
),
(
"compass",
"Fuse BM25 + graph + Vault into ranked results",
ToolScope::FileSystem,
),
(
"condenser",
"Compress content via Lens stack",
ToolScope::ReadOnly,
),
(
"archivist",
"Query Vault for facts (read-only)",
ToolScope::Memory,
),
(
"scout",
"Execute shell command with output compression",
ToolScope::Shell,
),
(
"chronicler",
"Generate session narrative (read-only)",
ToolScope::ReadOnly,
),
(
"alchemist",
"Transform noisy content → structured JSON",
ToolScope::ReadOnly,
),
(
"sentinel",
"Static security risk assessment",
ToolScope::ReadOnly,
),
(
"cartridge",
"Package current context into portable bundle",
ToolScope::ReadOnly,
),
(
"resonator",
"Dense-vector semantic search over ProjectIndex",
ToolScope::FileSystem,
),
(
"surveyor",
"Compute dependency topology and impact analysis",
ToolScope::FileSystem,
),
];
fn default_schema(name: &str) -> Value {
serde_json::json!({
"type": "object",
"title": name,
"properties": {
"input": { "type": "string" }
}
})
}