Skip to main content

lean_ctx/cli/addon_cmd/
mod.rs

1//! `lean-ctx addon` — manage community addons (MCP extensions) (#858).
2//!
3//! Thin CLI over [`crate::core::addons`]: browse the registry, install an addon
4//! (from the registry or a local `lean-ctx-addon.toml`), and remove it. `add`
5//! and `remove` wire external code into the MCP gateway, so both pass through
6//! the shared confirmation gate (`cli::prompt`).
7
8use std::path::Path;
9
10use super::addon_deps::{
11    addon_self_ref, install_declared_deps, refresh_pack_dependencies, resolve_declared_deps,
12};
13use super::prompt;
14use crate::core::addons::manifest::AddonManifest;
15use crate::core::addons::revocation::RevocationList;
16use crate::core::addons::store::{ArtifactReceipt, InstalledStore};
17use crate::core::addons::{artifact_install, bootstrap, install, registry};
18
19mod authoring;
20mod commands;
21mod display;
22mod management;
23
24#[allow(unreachable_pub, unused_imports)]
25pub use authoring::*;
26pub use commands::*;
27#[allow(unreachable_pub, unused_imports)]
28pub use display::*;
29#[allow(unreachable_pub, unused_imports)]
30pub use management::*;
31
32/// Read the value following `flag` in `args` (e.g. `--reason "text"`).
33pub(super) fn flag_value(args: &[String], flag: &str) -> Option<String> {
34    args.iter()
35        .position(|a| a == flag)
36        .and_then(|i| args.get(i + 1))
37        .map(|s| s.trim().to_string())
38        .filter(|s| !s.is_empty())
39}