An agent-managed museum exhibit, built in Rust with Gajae-Code / LazyCodex — developed and maintained with no human intervention.
Rust
Merge remote-tracking branch 'origin/rcc/plugins' into integration/dori-cleanroom
YeonGyu-Kim2929759ded8a
diff --cc rust/crates/commands/src/lib.rsindex 4c3358cf,3fe75ec1..5aa63a30--- a/rust/crates/commands/src/lib.rs+++ b/rust/crates/commands/src/lib.rs@@@ -201,9 -201,9 +201,9 @@@ const SLASH_COMMAND_SPECS: &[SlashCommaresume_supported: false,},SlashCommandSpec {- name: "plugins",- aliases: &[],- summary: "List or manage plugins",+ name: "plugin",+ aliases: &["plugins", "marketplace"],- summary: "Manage Claude Code plugins",++ summary: "Manage Claw Code plugins",argument_hint: Some("[list|install <path>|enable <name>|disable <name>|uninstall <id>|update <id>]",),diff --cc rust/crates/rusty-claude-cli/src/main.rsindex 9452cba9,3fbe74ce..65aff8d5--- a/rust/crates/rusty-claude-cli/src/main.rs+++ b/rust/crates/rusty-claude-cli/src/main.rs@@@ -23,6 -27,7 +27,7 @@@ use commands::};use compat_harness::{extract_manifest, UpstreamPaths};use init::initialize_repo;-use plugins::{PluginManager, PluginManagerConfig, PluginRegistry};++use plugins::{PluginManager, PluginManagerConfig};use render::{MarkdownStreamState, Spinner, TerminalRenderer};use runtime::{clear_oauth_credentials, generate_pkce_pair, generate_state, load_system_prompt,@@@ -1907,38 -2419,425 +2405,412 @@@ fn build_system_prompt() -> Result<Vec<)?)}- fn build_runtime_feature_config(- ) -> Result<runtime::RuntimeFeatureConfig, Box<dyn std::error::Error>> {-fn build_runtime_plugin_state() -> Result<- (- runtime::RuntimeFeatureConfig,- PluginRegistry,- GlobalToolRegistry,- ),- Box<dyn std::error::Error>,-> {++fn build_runtime_plugin_state(++) -> Result<(runtime::RuntimeFeatureConfig, GlobalToolRegistry), Box<dyn std::error::Error>> {let cwd = env::current_dir()?;- Ok(ConfigLoader::default_for(cwd)- .load()?- .feature_config()- .clone())+ let loader = ConfigLoader::default_for(&cwd);+ let runtime_config = loader.load()?;+ let plugin_manager = build_plugin_manager(&cwd, &loader, &runtime_config);- let plugin_registry = plugin_manager.plugin_registry()?;- let tool_registry = GlobalToolRegistry::with_plugin_tools(plugin_registry.aggregated_tools()?)?;- Ok((- runtime_config.feature_config().clone(),- plugin_registry,- tool_registry,- ))++ let tool_registry = GlobalToolRegistry::with_plugin_tools(plugin_manager.aggregated_tools()?)?;++ Ok((runtime_config.feature_config().clone(), tool_registry))}- fn build_runtime(- session: Session,- model: String,- system_prompt: Vec<String>,- enable_tools: bool,- emit_output: bool,- allowed_tools: Option<AllowedToolSet>,- permission_mode: PermissionMode,- ) -> Result<ConversationRuntime<ProviderRuntimeClient, CliToolExecutor>, Box<dyn std::error::Error>>- {- let feature_config = build_runtime_feature_config()?;- Ok(ConversationRuntime::new_with_features(- session,- ProviderRuntimeClient::new(model, enable_tools, emit_output, allowed_tools.clone())?,- CliToolExecutor::new(allowed_tools, emit_output),- permission_policy(permission_mode),- system_prompt,- feature_config,- ))+ fn build_plugin_manager(+ cwd: &Path,+ loader: &ConfigLoader,+ runtime_config: &runtime::RuntimeConfig,+ ) -> PluginManager {+ let plugin_settings = runtime_config.plugins();+ let mut plugin_config = PluginManagerConfig::new(loader.config_home().to_path_buf());+ plugin_config.enabled_plugins = plugin_settings.enabled_plugins().clone();+ plugin_config.external_dirs = plugin_settings+ .external_directories()+ .iter()+ .map(|path| resolve_plugin_path(cwd, loader.config_home(), path))+ .collect();+ plugin_config.install_root = plugin_settings+ .install_root()+ .map(|path| resolve_plugin_path(cwd, loader.config_home(), path));+ plugin_config.registry_path = plugin_settings+ .registry_path()+ .map(|path| resolve_plugin_path(cwd, loader.config_home(), path));+ plugin_config.bundled_root = plugin_settings+ .bundled_root()+ .map(|path| resolve_plugin_path(cwd, loader.config_home(), path));+ PluginManager::new(plugin_config)}- struct CliPermissionPrompter {- current_mode: PermissionMode,+ fn resolve_plugin_path(cwd: &Path, config_home: &Path, value: &str) -> PathBuf {+ let path = PathBuf::from(value);+ if path.is_absolute() {+ path+ } else if value.starts_with('.') {+ cwd.join(path)+ } else {+ config_home.join(path)+ }+ }++ #[derive(Debug, Clone, PartialEq, Eq)]+ struct InternalPromptProgressState {+ command_label: &'static str,+ task_label: String,+ step: usize,+ phase: String,+ detail: Option<String>,+ saw_final_text: bool,+ }++ #[derive(Debug, Clone, Copy, PartialEq, Eq)]+ enum InternalPromptProgressEvent {+ Started,+ Update,+ Heartbeat,+ Complete,+ Failed,+ }++ #[derive(Debug)]+ struct InternalPromptProgressShared {+ state: Mutex<InternalPromptProgressState>,+ output_lock: Mutex<()>,+ started_at: Instant,+ }++ #[derive(Debug, Clone)]+ struct InternalPromptProgressReporter {+ shared: Arc<InternalPromptProgressShared>,+ }++ #[derive(Debug)]+ struct InternalPromptProgressRun {+ reporter: InternalPromptProgressReporter,+ heartbeat_stop: Option<mpsc::Sender<()>>,+ heartbeat_handle: Option<thread::JoinHandle<()>>,+ }++ impl InternalPromptProgressReporter {+ fn ultraplan(task: &str) -> Self {+ Self {+ shared: Arc::new(InternalPromptProgressShared {+ state: Mutex::new(InternalPromptProgressState {+ command_label: "Ultraplan",+ task_label: task.to_string(),+ step: 0,+ phase: "planning started".to_string(),+ detail: Some(format!("task: {task}")),+ saw_final_text: false,+ }),+ output_lock: Mutex::new(()),+ started_at: Instant::now(),+ }),+ }+ }++ fn emit(&self, event: InternalPromptProgressEvent, error: Option<&str>) {+ let snapshot = self.snapshot();+ let line = format_internal_prompt_progress_line(event, &snapshot, self.elapsed(), error);+ self.write_line(&line);+ }++ fn mark_model_phase(&self) {+ let snapshot = {+ let mut state = self+ .shared+ .state+ .lock()+ .expect("internal prompt progress state poisoned");+ state.step += 1;+ state.phase = if state.step == 1 {+ "analyzing request".to_string()+ } else {+ "reviewing findings".to_string()+ };+ state.detail = Some(format!("task: {}", state.task_label));+ state.clone()+ };+ self.write_line(&format_internal_prompt_progress_line(+ InternalPromptProgressEvent::Update,+ &snapshot,+ self.elapsed(),+ None,+ ));+ }++ fn mark_tool_phase(&self, name: &str, input: &str) {+ let detail = describe_tool_progress(name, input);+ let snapshot = {+ let mut state = self+ .shared+ .state+ .lock()+ .expect("internal prompt progress state poisoned");+ state.step += 1;+ state.phase = format!("running {name}");+ state.detail = Some(detail);+ state.clone()+ };+ self.write_line(&format_internal_prompt_progress_line(+ InternalPromptProgressEvent::Update,+ &snapshot,+ self.elapsed(),+ None,+ ));+ }++ fn mark_text_phase(&self, text: &str) {+ let trimmed = text.trim();+ if trimmed.is_empty() {+ return;+ }+ let detail = truncate_for_summary(first_visible_line(trimmed), 120);+ let snapshot = {+ let mut state = self+ .shared+ .state+ .lock()+ .expect("internal prompt progress state poisoned");+ if state.saw_final_text {+ return;+ }+ state.saw_final_text = true;+ state.step += 1;+ state.phase = "drafting final plan".to_string();+ state.detail = (!detail.is_empty()).then_some(detail);+ state.clone()+ };+ self.write_line(&format_internal_prompt_progress_line(+ InternalPromptProgressEvent::Update,+ &snapshot,+ self.elapsed(),+ None,+ ));+ }++ fn emit_heartbeat(&self) {+ let snapshot = self.snapshot();+ self.write_line(&format_internal_prompt_progress_line(+ InternalPromptProgressEvent::Heartbeat,+ &snapshot,+ self.elapsed(),+ None,+ ));+ }++ fn snapshot(&self) -> InternalPromptProgressState {+ self.shared+ .state+ .lock()+ .expect("internal prompt progress state poisoned")+ .clone()+ }++ fn elapsed(&self) -> Duration {+ self.shared.started_at.elapsed()+ }++ fn write_line(&self, line: &str) {+ let _guard = self+ .shared+ .output_lock+ .lock()+ .expect("internal prompt progress output lock poisoned");+ let mut stdout = io::stdout();+ let _ = writeln!(stdout, "{line}");+ let _ = stdout.flush();+ }+ }++ impl InternalPromptProgressRun {+ fn start_ultraplan(task: &str) -> Self {+ let reporter = InternalPromptProgressReporter::ultraplan(task);+ reporter.emit(InternalPromptProgressEvent::Started, None);++ let (heartbeat_stop, heartbeat_rx) = mpsc::channel();+ let heartbeat_reporter = reporter.clone();+ let heartbeat_handle = thread::spawn(move || loop {+ match heartbeat_rx.recv_timeout(INTERNAL_PROGRESS_HEARTBEAT_INTERVAL) {+ Ok(()) | Err(RecvTimeoutError::Disconnected) => break,+ Err(RecvTimeoutError::Timeout) => heartbeat_reporter.emit_heartbeat(),+ }+ });++ Self {+ reporter,+ heartbeat_stop: Some(heartbeat_stop),+ heartbeat_handle: Some(heartbeat_handle),+ }+ }++ fn reporter(&self) -> InternalPromptProgressReporter {+ self.reporter.clone()+ }++ fn finish_success(&mut self) {+ self.stop_heartbeat();+ self.reporter+ .emit(InternalPromptProgressEvent::Complete, None);+ }++ fn finish_failure(&mut self, error: &str) {+ self.stop_heartbeat();+ self.reporter+ .emit(InternalPromptProgressEvent::Failed, Some(error));+ }++ fn stop_heartbeat(&mut self) {+ if let Some(sender) = self.heartbeat_stop.take() {+ let _ = sender.send(());+ }+ if let Some(handle) = self.heartbeat_handle.take() {+ let _ = handle.join();+ }+ }+ }++ impl Drop for InternalPromptProgressRun {+ fn drop(&mut self) {+ self.stop_heartbeat();+ }+ }++ fn format_internal_prompt_progress_line(+ event: InternalPromptProgressEvent,+ snapshot: &InternalPromptProgressState,+ elapsed: Duration,+ error: Option<&str>,+ ) -> String {+ let elapsed_seconds = elapsed.as_secs();+ let step_label = if snapshot.step == 0 {+ "current step pending".to_string()+ } else {+ format!("current step {}", snapshot.step)+ };+ let mut status_bits = vec![step_label, format!("phase {}", snapshot.phase)];+ if let Some(detail) = snapshot+ .detail+ .as_deref()+ .filter(|detail| !detail.is_empty())+ {+ status_bits.push(detail.to_string());+ }+ let status = status_bits.join(" · ");+ match event {+ InternalPromptProgressEvent::Started => {+ format!(+ "🧭 {} status · planning started · {status}",+ snapshot.command_label+ )+ }+ InternalPromptProgressEvent::Update => {+ format!("… {} status · {status}", snapshot.command_label)+ }+ InternalPromptProgressEvent::Heartbeat => format!(+ "… {} heartbeat · {elapsed_seconds}s elapsed · {status}",+ snapshot.command_label+ ),+ InternalPromptProgressEvent::Complete => format!(+ "✔ {} status · completed · {elapsed_seconds}s elapsed · {} steps total",+ snapshot.command_label, snapshot.step+ ),+ InternalPromptProgressEvent::Failed => format!(+ "✘ {} status · failed · {elapsed_seconds}s elapsed · {}",+ snapshot.command_label,+ error.unwrap_or("unknown error")+ ),+ }+ }++ fn describe_tool_progress(name: &str, input: &str) -> String {+ let parsed: serde_json::Value =+ serde_json::from_str(input).unwrap_or(serde_json::Value::String(input.to_string()));+ match name {+ "bash" | "Bash" => {+ let command = parsed+ .get("command")+ .and_then(|value| value.as_str())+ .unwrap_or_default();+ if command.is_empty() {+ "running shell command".to_string()+ } else {+ format!("command {}", truncate_for_summary(command.trim(), 100))+ }+ }+ "read_file" | "Read" => format!("reading {}", extract_tool_path(&parsed)),+ "write_file" | "Write" => format!("writing {}", extract_tool_path(&parsed)),+ "edit_file" | "Edit" => format!("editing {}", extract_tool_path(&parsed)),+ "glob_search" | "Glob" => {+ let pattern = parsed+ .get("pattern")+ .and_then(|value| value.as_str())+ .unwrap_or("?");+ let scope = parsed+ .get("path")+ .and_then(|value| value.as_str())+ .unwrap_or(".");+ format!("glob `{pattern}` in {scope}")+ }+ "grep_search" | "Grep" => {+ let pattern = parsed+ .get("pattern")+ .and_then(|value| value.as_str())+ .unwrap_or("?");+ let scope = parsed+ .get("path")+ .and_then(|value| value.as_str())+ .unwrap_or(".");+ format!("grep `{pattern}` in {scope}")+ }+ "web_search" | "WebSearch" => parsed+ .get("query")+ .and_then(|value| value.as_str())+ .map_or_else(+ || "running web search".to_string(),+ |query| format!("query {}", truncate_for_summary(query, 100)),+ ),+ _ => {+ let summary = summarize_tool_payload(input);+ if summary.is_empty() {+ format!("running {name}")+ } else {+ format!("{name}: {summary}")+ }+ }+ }+ }++ #[allow(clippy::needless_pass_by_value)]+ #[allow(clippy::too_many_arguments)]+ fn build_runtime(+ session: Session,+ model: String,+ system_prompt: Vec<String>,+ enable_tools: bool,+ emit_output: bool,+ allowed_tools: Option<AllowedToolSet>,+ permission_mode: PermissionMode,+ progress_reporter: Option<InternalPromptProgressReporter>,-) -> Result<ConversationRuntime<AnthropicRuntimeClient, CliToolExecutor>, Box<dyn std::error::Error>>-{- let (feature_config, plugin_registry, tool_registry) = build_runtime_plugin_state()?;- Ok(ConversationRuntime::new_with_plugins(++) -> Result<ConversationRuntime<AnthropicRuntimeClient, CliToolExecutor>, Box<dyn std::error::Error>> {++ let (feature_config, tool_registry) = build_runtime_plugin_state()?;++ Ok(ConversationRuntime::new_with_features(+ session,+ AnthropicRuntimeClient::new(+ model,+ enable_tools,+ emit_output,+ allowed_tools.clone(),+ tool_registry.clone(),+ progress_reporter,+ )?,+ CliToolExecutor::new(allowed_tools.clone(), emit_output, tool_registry.clone()),+ permission_policy(permission_mode, &tool_registry),+ system_prompt,+ feature_config,- plugin_registry,- )?)++ ))+ }++ struct CliPermissionPrompter {+ current_mode: PermissionMode,}impl CliPermissionPrompter {diff --cc rust/crates/tools/src/lib.rsindex 33fa3994,38fafe99..c22db4cc--- a/rust/crates/tools/src/lib.rs+++ b/rust/crates/tools/src/lib.rs@@@ -4,10 -4,11 +4,11 @@@ use std::process::Commanduse std::time::{Duration, Instant};use api::{- read_base_url, AnthropicClient, ContentBlockDelta, InputContentBlock, InputMessage,- MessageRequest, MessageResponse, OutputContentBlock, StreamEvent as ApiStreamEvent, ToolChoice,- ToolDefinition, ToolResultContentBlock,+ max_tokens_for_model, resolve_model_alias, ContentBlockDelta, InputContentBlock, InputMessage,+ MessageRequest, MessageResponse, OutputContentBlock, ProviderClient,+ StreamEvent as ApiStreamEvent, ToolChoice, ToolDefinition, ToolResultContentBlock,};-use plugins::{PluginManager, PluginManagerConfig, PluginTool};++use plugins::PluginTool;use reqwest::blocking::Client;use runtime::{edit_file, execute_bash, glob_search, grep_search, load_system_prompt, read_file, write_file,@@@ -55,6 -56,239 +56,161 @@@ pub struct ToolSpecpub required_permission: PermissionMode,}-#[derive(Debug, Clone, PartialEq)]-pub struct RegisteredTool {- pub definition: ToolDefinition,- pub required_permission: PermissionMode,- handler: RegisteredToolHandler,-}--#[allow(clippy::large_enum_variant)]-#[derive(Debug, Clone, PartialEq)]-enum RegisteredToolHandler {- Builtin,- Plugin(PluginTool),-}-+ #[derive(Debug, Clone, PartialEq)]+ pub struct GlobalToolRegistry {- entries: Vec<RegisteredTool>,++ plugin_tools: Vec<PluginTool>,+ }++ impl GlobalToolRegistry {+ #[must_use]+ pub fn builtin() -> Self {+ Self {- entries: mvp_tool_specs()- .into_iter()- .map(|spec| RegisteredTool {- definition: ToolDefinition {- name: spec.name.to_string(),- description: Some(spec.description.to_string()),- input_schema: spec.input_schema,- },- required_permission: spec.required_permission,- handler: RegisteredToolHandler::Builtin,- })- .collect(),++ plugin_tools: Vec::new(),+ }+ }++ pub fn with_plugin_tools(plugin_tools: Vec<PluginTool>) -> Result<Self, String> {- let mut registry = Self::builtin();- let mut seen = registry- .entries- .iter()- .map(|entry| {- (- normalize_registry_tool_name(&entry.definition.name),- entry.definition.name.clone(),- )- })- .collect::<BTreeMap<_, _>>();++ let builtin_names = mvp_tool_specs()++ .into_iter()++ .map(|spec| spec.name.to_string())++ .collect::<BTreeSet<_>>();++ let mut seen_plugin_names = BTreeSet::new();+- for tool in plugin_tools {- let normalized = normalize_registry_tool_name(&tool.definition().name);- if let Some(existing) = seen.get(&normalized) {++ for tool in &plugin_tools {++ let name = tool.definition().name.clone();++ if builtin_names.contains(&name) {+ return Err(format!(- "plugin tool `{}` from `{}` conflicts with already-registered tool `{existing}`",- tool.definition().name,- tool.plugin_id()++ "plugin tool `{name}` conflicts with a built-in tool name"+ ));+ }- seen.insert(normalized, tool.definition().name.clone());- registry.entries.push(RegisteredTool {- definition: ToolDefinition {- name: tool.definition().name.clone(),- description: tool.definition().description.clone(),- input_schema: tool.definition().input_schema.clone(),- },- required_permission: permission_mode_from_plugin_tool(tool.required_permission())?,- handler: RegisteredToolHandler::Plugin(tool),- });++ if !seen_plugin_names.insert(name.clone()) {++ return Err(format!("duplicate plugin tool name `{name}`"));++ }+ }+- Ok(registry)- }-- #[must_use]- pub fn entries(&self) -> &[RegisteredTool] {- &self.entries- }-- fn find_entry(&self, name: &str) -> Option<&RegisteredTool> {- let normalized = normalize_registry_tool_name(name);- self.entries.iter().find(|entry| {- normalize_registry_tool_name(entry.definition.name.as_str()) == normalized- })- }-- #[must_use]- pub fn definitions(&self, allowed_tools: Option<&BTreeSet<String>>) -> Vec<ToolDefinition> {- self.entries- .iter()- .filter(|entry| {- allowed_tools.is_none_or(|allowed| allowed.contains(entry.definition.name.as_str()))- })- .map(|entry| entry.definition.clone())- .collect()- }-- #[must_use]- pub fn permission_specs(- &self,- allowed_tools: Option<&BTreeSet<String>>,- ) -> Vec<(String, PermissionMode)> {- self.entries- .iter()- .filter(|entry| {- allowed_tools.is_none_or(|allowed| allowed.contains(entry.definition.name.as_str()))- })- .map(|entry| (entry.definition.name.clone(), entry.required_permission))- .collect()++ Ok(Self { plugin_tools })+ }+- pub fn normalize_allowed_tools(- &self,- values: &[String],- ) -> Result<Option<BTreeSet<String>>, String> {++ pub fn normalize_allowed_tools(&self, values: &[String]) -> Result<Option<BTreeSet<String>>, String> {+ if values.is_empty() {+ return Ok(None);+ }+- let canonical_names = self- .entries++ let builtin_specs = mvp_tool_specs();++ let canonical_names = builtin_specs+ .iter()- .map(|entry| entry.definition.name.clone())++ .map(|spec| spec.name.to_string())++ .chain(self.plugin_tools.iter().map(|tool| tool.definition().name.clone()))+ .collect::<Vec<_>>();+ let mut name_map = canonical_names+ .iter()- .map(|name| (normalize_registry_tool_name(name), name.clone()))++ .map(|name| (normalize_tool_name(name), name.clone()))+ .collect::<BTreeMap<_, _>>();++ for (alias, canonical) in [+ ("read", "read_file"),+ ("write", "write_file"),+ ("edit", "edit_file"),+ ("glob", "glob_search"),+ ("grep", "grep_search"),+ ] {- if canonical_names.iter().any(|name| name == canonical) {- name_map.insert(alias.to_string(), canonical.to_string());- }++ name_map.insert(alias.to_string(), canonical.to_string());+ }++ let mut allowed = BTreeSet::new();+ for value in values {+ for token in value+ .split(|ch: char| ch == ',' || ch.is_whitespace())+ .filter(|token| !token.is_empty())+ {- let normalized = normalize_registry_tool_name(token);++ let normalized = normalize_tool_name(token);+ let canonical = name_map.get(&normalized).ok_or_else(|| {+ format!(+ "unsupported tool in --allowedTools: {token} (expected one of: {})",+ canonical_names.join(", ")+ )+ })?;+ allowed.insert(canonical.clone());+ }+ }++ Ok(Some(allowed))+ }+- pub fn execute(&self, name: &str, input: &Value) -> Result<String, String> {- let entry = self- .find_entry(name)- .ok_or_else(|| format!("unsupported tool: {name}"))?;- match &entry.handler {- RegisteredToolHandler::Builtin => execute_tool(&entry.definition.name, input),- RegisteredToolHandler::Plugin(tool) => {- tool.execute(input).map_err(|error| error.to_string())- }- }++ #[must_use]++ pub fn definitions(&self, allowed_tools: Option<&BTreeSet<String>>) -> Vec<ToolDefinition> {++ let builtin = mvp_tool_specs()++ .into_iter()++ .filter(|spec| allowed_tools.is_none_or(|allowed| allowed.contains(spec.name)))++ .map(|spec| ToolDefinition {++ name: spec.name.to_string(),++ description: Some(spec.description.to_string()),++ input_schema: spec.input_schema,++ });++ let plugin = self++ .plugin_tools++ .iter()++ .filter(|tool| {++ allowed_tools.is_none_or(|allowed| allowed.contains(tool.definition().name.as_str()))++ })++ .map(|tool| ToolDefinition {++ name: tool.definition().name.clone(),++ description: tool.definition().description.clone(),++ input_schema: tool.definition().input_schema.clone(),++ });++ builtin.chain(plugin).collect()+ }-}+-impl Default for GlobalToolRegistry {- fn default() -> Self {- Self::builtin()++ #[must_use]++ pub fn permission_specs(++ &self,++ allowed_tools: Option<&BTreeSet<String>>,++ ) -> Vec<(String, PermissionMode)> {++ let builtin = mvp_tool_specs()++ .into_iter()++ .filter(|spec| allowed_tools.is_none_or(|allowed| allowed.contains(spec.name)))++ .map(|spec| (spec.name.to_string(), spec.required_permission));++ let plugin = self++ .plugin_tools++ .iter()++ .filter(|tool| {++ allowed_tools.is_none_or(|allowed| allowed.contains(tool.definition().name.as_str()))++ })++ .map(|tool| {++ (++ tool.definition().name.clone(),++ permission_mode_from_plugin(tool.required_permission()),++ )++ });++ builtin.chain(plugin).collect()+ }-}+-fn normalize_registry_tool_name(value: &str) -> String {- let trimmed = value.trim();- let chars = trimmed.chars().collect::<Vec<_>>();- let mut normalized = String::new();-- for (index, ch) in chars.iter().copied().enumerate() {- if matches!(ch, '-' | ' ' | '\t' | '\n') {- if !normalized.ends_with('_') {- normalized.push('_');- }- continue;- }-- if ch == '_' {- if !normalized.ends_with('_') {- normalized.push('_');- }- continue;- }-- if ch.is_uppercase() {- let prev = chars.get(index.wrapping_sub(1)).copied();- let next = chars.get(index + 1).copied();- let needs_separator = index > 0- && !normalized.ends_with('_')- && (prev.is_some_and(|prev| prev.is_lowercase() || prev.is_ascii_digit())- || (prev.is_some_and(char::is_uppercase)- && next.is_some_and(char::is_lowercase)));- if needs_separator {- normalized.push('_');- }- normalized.extend(ch.to_lowercase());- continue;++ pub fn execute(&self, name: &str, input: &Value) -> Result<String, String> {++ if mvp_tool_specs().iter().any(|spec| spec.name == name) {++ return execute_tool(name, input);+ }-- normalized.push(ch.to_ascii_lowercase());++ self.plugin_tools++ .iter()++ .find(|tool| tool.definition().name == name)++ .ok_or_else(|| format!("unsupported tool: {name}"))?++ .execute(input)++ .map_err(|error| error.to_string())+ }++}+- normalized.trim_matches('_').to_string()++fn normalize_tool_name(value: &str) -> String {++ value.trim().replace('-', "_").to_ascii_lowercase()+ }+-fn permission_mode_from_plugin_tool(value: &str) -> Result<PermissionMode, String> {++fn permission_mode_from_plugin(value: &str) -> PermissionMode {+ match value {- "read-only" => Ok(PermissionMode::ReadOnly),- "workspace-write" => Ok(PermissionMode::WorkspaceWrite),- "danger-full-access" => Ok(PermissionMode::DangerFullAccess),- other => Err(format!(- "unsupported plugin tool permission `{other}` (expected read-only, workspace-write, or danger-full-access)"- )),++ "read-only" => PermissionMode::ReadOnly,++ "workspace-write" => PermissionMode::WorkspaceWrite,++ "danger-full-access" => PermissionMode::DangerFullAccess,++ other => panic!("unsupported plugin permission: {other}"),+ }+ }+#[must_use]#[allow(clippy::too_many_lines)]pub fn mvp_tool_specs() -> Vec<ToolSpec> {