-
-
Notifications
You must be signed in to change notification settings - Fork 403
Let plugins provide agent skills #725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bb79773
Let plugins provide agent skills
i386 5cfa6f1
Fix skills CLI clippy warnings
i386 310f909
Merge remote-tracking branch 'mesh/main' into codex/plugin-skills
i386 d3ec0b0
Merge remote-tracking branch 'mesh/main' into codex/pr-725-merge-fix
i386 917f101
Address plugin skill review feedback
i386 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
194 changes: 194 additions & 0 deletions
194
crates/mesh-llm-host-runtime/src/cli/commands/skills.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| use anyhow::Result; | ||
| use mesh_llm_plugin_manager::{ | ||
| PluginSkillInstallOptions, SkillAgent, SkillInstallReport, SkillInstallStatus, | ||
| install_available_skills, | ||
| }; | ||
|
|
||
| use crate::cli::{SkillAgentArg, SkillCommand, output::json_mode_enabled}; | ||
|
|
||
| pub(crate) fn run_skills_command(command: &SkillCommand) -> Result<()> { | ||
| match command { | ||
| SkillCommand::Install { | ||
| agent, | ||
| all, | ||
| dry_run, | ||
| force, | ||
| } => install(agent, *all, *dry_run, *force), | ||
| } | ||
| } | ||
|
|
||
| pub(crate) fn install_skills_for_agent(agent: SkillAgent) { | ||
| match PluginSkillInstallOptions::for_agent(agent).and_then(|options| { | ||
| let report = install_available_skills(&options)?; | ||
| Ok(report) | ||
| }) { | ||
| Ok(report) => print_agent_install_summary(agent, &report), | ||
| Err(error) if !json_mode_enabled() => { | ||
| eprintln!( | ||
| "Could not install mesh plugin skills for {}: {error}", | ||
| agent.as_str() | ||
| ); | ||
| } | ||
| Err(_) => {} | ||
| } | ||
| } | ||
|
|
||
| fn install(agents: &[SkillAgentArg], all: bool, dry_run: bool, force: bool) -> Result<()> { | ||
| let mut options = PluginSkillInstallOptions::from_env()?; | ||
| options.skill_options.dry_run = dry_run; | ||
| options.skill_options.force = force; | ||
| if all { | ||
| options.skill_options.detected_only = false; | ||
| } | ||
| if !agents.is_empty() { | ||
| options.skill_options.agents = agents.iter().copied().map(Into::into).collect(); | ||
| options.skill_options.detected_only = false; | ||
| } | ||
| let report = install_available_skills(&options)?; | ||
| print_install_report(&report, dry_run)?; | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn print_agent_install_summary(agent: SkillAgent, report: &SkillInstallReport) { | ||
| if json_mode_enabled() { | ||
| return; | ||
| } | ||
| let changed = report | ||
| .actions | ||
| .iter() | ||
| .filter(|action| { | ||
| matches!( | ||
| action.status, | ||
| SkillInstallStatus::Installed | SkillInstallStatus::Updated | ||
| ) | ||
| }) | ||
| .count(); | ||
| if changed > 0 { | ||
| eprintln!( | ||
| "✅ Installed {changed} mesh plugin skill(s) for {}", | ||
| agent.as_str() | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| fn print_install_report(report: &SkillInstallReport, dry_run: bool) -> Result<()> { | ||
| if json_mode_enabled() { | ||
| println!("{}", serde_json::to_string_pretty(report)?); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| let heading = if dry_run { | ||
| "🧪 Mesh plugin skill install preview" | ||
| } else { | ||
| "🧠 Installing mesh plugin skills" | ||
| }; | ||
| eprintln!("{heading}"); | ||
|
|
||
| if report.available_skills == 0 { | ||
| eprintln!("🔎 No plugin skills found in installed plugins."); | ||
| eprintln!("📦 Plugins can expose skills with skills/<name>/SKILL.md."); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| eprintln!( | ||
| "📦 Found {}", | ||
| plural_count(report.available_skills, "plugin skill") | ||
| ); | ||
|
|
||
| if report.targets.is_empty() { | ||
| eprintln!("🔎 No supported agent skill targets detected."); | ||
| eprintln!("💡 Use --agent <agent> or --all to install anyway."); | ||
| return Ok(()); | ||
| } | ||
|
|
||
| eprintln!( | ||
| "🎯 Targeting {}:", | ||
| plural_count(report.targets.len(), "agent") | ||
| ); | ||
| for target in &report.targets { | ||
| let reason = target | ||
| .detection_reason | ||
| .as_deref() | ||
| .unwrap_or("explicit target"); | ||
| eprintln!( | ||
| " • {:<8} {} ({reason})", | ||
| target.agent.as_str(), | ||
| target.root.display() | ||
| ); | ||
| } | ||
|
|
||
| eprintln!("🛠️ Applying skills:"); | ||
| for action in &report.actions { | ||
| let Some(label) = action_status_label(&action.status, dry_run) else { | ||
| continue; | ||
| }; | ||
| eprintln!( | ||
| " {label:<17} {:<28} -> {:<8} {}", | ||
| skill_display_name(action), | ||
| action.agent.as_str(), | ||
| action.destination_dir.display() | ||
| ); | ||
| } | ||
|
|
||
| print_install_summary(report, dry_run); | ||
| Ok(()) | ||
| } | ||
|
|
||
| fn print_install_summary(report: &SkillInstallReport, dry_run: bool) { | ||
| let mut installed = 0; | ||
| let mut updated = 0; | ||
| let mut unchanged = 0; | ||
| let mut conflicts = 0; | ||
| for action in &report.actions { | ||
| match action.status { | ||
| SkillInstallStatus::Installed | SkillInstallStatus::WouldInstall => installed += 1, | ||
| SkillInstallStatus::Updated | SkillInstallStatus::WouldUpdate => updated += 1, | ||
| SkillInstallStatus::Unchanged => unchanged += 1, | ||
| SkillInstallStatus::SkippedConflict | SkillInstallStatus::WouldSkipConflict => { | ||
| conflicts += 1; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| let verb = if dry_run { "planned" } else { "complete" }; | ||
| let mut parts = vec![ | ||
| count_label(installed, "installed", "installed"), | ||
| count_label(updated, "updated", "updated"), | ||
| ]; | ||
| if unchanged > 0 { | ||
| parts.push(count_label(unchanged, "unchanged", "unchanged")); | ||
| } | ||
| if conflicts > 0 { | ||
| parts.push(count_label(conflicts, "conflict", "conflicts")); | ||
| } | ||
| eprintln!("✅ Skill install {verb}: {}", parts.join(", ")); | ||
| } | ||
|
|
||
| fn action_status_label(status: &SkillInstallStatus, dry_run: bool) -> Option<&'static str> { | ||
| match status { | ||
| SkillInstallStatus::Installed => Some("✅ installed"), | ||
| SkillInstallStatus::Updated => Some("♻️ updated"), | ||
| SkillInstallStatus::Unchanged if !dry_run => None, | ||
| SkillInstallStatus::Unchanged => Some("⏭️ unchanged"), | ||
| SkillInstallStatus::WouldInstall => Some("📝 would install"), | ||
| SkillInstallStatus::WouldUpdate => Some("📝 would update"), | ||
| SkillInstallStatus::WouldSkipConflict => Some("⚠️ would skip"), | ||
| SkillInstallStatus::SkippedConflict => Some("⚠️ skipped"), | ||
| } | ||
| } | ||
|
|
||
| fn skill_display_name(action: &mesh_llm_plugin_manager::SkillInstallAction) -> String { | ||
| format!("{}/{}", action.provider_name, action.skill_name) | ||
| } | ||
|
|
||
| fn plural_count(count: usize, noun: &str) -> String { | ||
| count_label(count, noun, &format!("{noun}s")) | ||
| } | ||
|
|
||
| fn count_label(count: usize, singular: &str, plural: &str) -> String { | ||
| if count == 1 { | ||
| format!("{count} {singular}") | ||
| } else { | ||
| format!("{count} {plural}") | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.