Skip to main content

majordomus_cli/capability/
mod.rs

1//! The canonical capability model and its registry: the one place a capability is
2//! defined. MCP, HTTP, OpenAPI, the CLI's introspection and the generated documentation
3//! are projections of what lives here and define nothing of their own.
4//!
5//! Two sources feed the registry: typed executable capabilities written in Rust
6//! ([`builtin`]) and declarative objects the repository's layer declares
7//! (`declarative`). Both normalise into the same [`Capability`] descriptor; a consumer
8//! cannot tell, and need not care, which source an entry came from except through its
9//! provenance.
10//!
11//! ```
12//! use majordomus_cli::capability::{builtin, CapabilityRegistry, HttpMethod};
13//!
14//! // the application composed from its modules, validated on the way in
15//! let registry = CapabilityRegistry::builder()
16//!     .with_modules(builtin::modules())
17//!     .build()
18//!     .expect("the composed application is valid");
19//!
20//! // one descriptor, and every projection is a way of asking for it
21//! let by_id = registry.get("repository.info").expect("a canonical id");
22//! let by_route = registry
23//!     .by_http(HttpMethod::Get, "/api/v1/repository")
24//!     .expect("the route it declares");
25//! let by_tool = registry
26//!     .by_mcp_tool("majordomus_repository")
27//!     .expect("the MCP tool it declares");
28//! assert_eq!(by_id.id, by_route.id);
29//! assert_eq!(by_id.id, by_tool.id);
30//!
31//! // and nothing was told about it: the exposures are on the descriptor itself
32//! assert_eq!(by_id.exposure.http.as_ref().unwrap().path, "/api/v1/repository");
33//! ```
34
35pub(crate) mod benchmark;
36pub mod builtin;
37pub(crate) mod checkout;
38pub mod closure;
39pub(crate) mod declarative;
40pub mod executor;
41pub mod handler;
42pub mod model;
43pub(crate) mod module;
44pub mod readings;
45pub mod registry;
46pub mod rustdoc;
47pub mod schema;
48
49pub use benchmark::{BenchmarkCases, CaseContext, CaseProvider, NamedCase};
50pub use closure::{Finding, Matrix as ProjectionMatrix, Projection, Row as ProjectionRow};
51pub use executor::CapabilityExecutor;
52pub use handler::{CapabilityError, Context, Executable, Handler};
53pub use model::{
54    Availability, BenchmarkPolicy, BenchmarkPrecondition, CachePolicy, Capability, CapabilityId,
55    CapabilityKind, CliExposure, Concurrency, Effect, ExecutionPolicy, Exposure, Hints,
56    HttpExposure, HttpMethod, McpExposure, McpResource, ModuleId, Provenance, SkillExposure,
57    Stability, Visibility, WaiverReason, RESERVED_SKILL_NAMES,
58};
59pub use module::ModuleDescriptor;
60pub use registry::{CapabilityRegistry, Entry, RegistryError};
61pub use schema::CanonicalSchema;