Labsco
cloudmesh-ai logo

CloudMesh AI

from cloudmesh-ai

Vendor-neutral gate between AI agents and production infrastructure. Deterministic policy engine, human-in-the-loop approval with diffs, JSONL audit log, graduated autonomy via empirical track record.

๐Ÿ”ฅ๐Ÿ”ฅFreeAdvanced setup

cloudmesh-ai-cmc

Quick Links:

cloudmesh-ai-cmc is an extensible Command Line Interface (CLI) framework designed to integrate AI-driven tools and custom extensions seamlessly. It serves as the central orchestrator for the Cloudmesh AI ecosystem, providing a robust registry system for managing commands and a developer-friendly environment for rapid extension creation.

About

The cmc tool serves as a central hub for AI extensions. Whether you are performing system diagnostics, generating documentation, or running speed tests, cmc provides a consistent interface to interact with various AI models and tools.

Its core strength lies in its Extension Registry, which allows you to load plugins from:

  • Core: Built-in extensions bundled with the package.
  • Pip: Extensions installed via pip using entry points.
  • Registry: Local extensions registered via a path on your filesystem.

Key Features

High-Performance Architecture

  • Lazy Loading: To ensure near-instant startup times, cloudmesh-ai-cmc implements a lazy-loading mechanism. Extension code is only imported into memory at the moment the specific command is invoked.
  • Dynamic Extension Management: Extensions can be loaded from pip-installed packages (via entry points) or dynamically from local filesystem paths.

Developer-First Tooling

  • Rapid Scaffolding: The cmc command create utility eliminates boilerplate friction by instantly generating the required directory structure.
  • Flexible Integration Patterns: Supports multiple registration styles:
    • Simple: Function-based entry points for quick tools.
    • Advanced: The register(cli) pattern for complex, nested command groups using click.

Rich Documentation Experience

  • Terminal-Native Docs: The docs command renders formatted Markdown directly in the terminal using rich.
  • Integrated Man Pages: Every extension can provide a detailed manual page accessible via cmc man <command>.

Interactive Shell

The cmc shell provides an immersive environment for interacting with the CMC ecosystem without needing to restart the CLI for every command.

Key Features

  • Tab Completion: Intelligent autocomplete for all registered CMC commands, sub-commands, and internal shell utilities.
  • Persistent History: Command history is saved to ~/.config/cloudmesh/ai/cmc_history, allowing you to recall previous commands across sessions.
  • Dynamic Updates: The command completer is refreshed on every loop, meaning newly added or enabled plugins are immediately available for autocomplete.

Internal Shell Commands

In addition to standard cmc commands, the shell supports several built-in utilities:

CommandDescriptionExample
helpDisplays the shell help menu.help
set <K>=<V>Sets a temporary environment variable for the current session.set API_KEY=secret123
h <num>Displays the last <num> commands from the history file.h 10
exit / quit / qExits the interactive shell.exit

Usage Example

# 1. Enter the interactive shell
cmc shell

# 2. Inside the shell, run a CMC command (with tab completion)
cmc> version

# 3. Set a session variable for a plugin
cmc> set MODEL_NAME=gpt-4o

# 4. Run a command that uses that variable
cmc> doctor

# 5. View recent history
cmc> h 5

# 6. Exit the shell
cmc> exit

Logging and Debugging

cmc uses a configurable logging system. You can control the granularity of the output using the CMC_LOGGING_LEVEL environment variable or the --debug flag.

Log Levels

  • ERROR: Only critical errors are shown.
  • WARNING: Errors and potential issues are shown (Default).
  • INFO: General operational messages.
  • DEBUG: Detailed diagnostic information, including extension loading and validation steps.

Usage

# Using the CLI flag
cmc --debug doctor

Developer's Guide

Extension Patterns

1. Simple Extension (Function-based)

Best for single-purpose tools. Define a click command in your module:

import click

version = "0.1.0"
description = "My awesome AI extension"
dependencies = []  # List of other plugin names this plugin depends on

@click.command()
def entry_point():
    """Plugin description here."""
    click.echo("Hello from the new plugin!")

2. Advanced Extension (The register Pattern)

Best for complex tools with sub-commands. Implement a register function:

import click

@click.command()
def start():
    click.echo("Service started!")

def register(cli):
    @cli.group(name="myservice")
    def service_group():
        """Manage the custom service."""
        pass
    service_group.add_command(start)

Distribution Comparison

FeatureCore ExtensionPip Extension
LoadingFilesystem ScanEntry Points
InstallationCopy to command/pip install
Update CycleInstant (on save)Requires re-install
Use CaseRapid PrototypingProduction Release

Telemetry & Observability

CMC includes a built-in telemetry system to track AI tool performance and reliability.

Tracked Metrics

Every command execution captures: * Duration: Total execution time in seconds (duration_sec). * Status: started, completed, or failed. * System Context: CPU model, GPU presence/model, and total memory. * Custom KPIs: Extension-specific metrics passed to the telemetry sink.

Storage Backends

Telemetry can be routed to multiple sinks: * JSONL: Structured logs for machine ingestion. * SQLite: Relational storage for complex querying. * Text: Human-readable logs for quick debugging.

Control

To disable telemetry globally, set the following environment variable: CLOUDMESH_AI_TELEMETRY_DISABLED=true

Documentation and Help

# View the global AI documentation index
cmc docs

# View the specific manual for the speedtest tool
cmc man speedtest

Sample Output: Version

cmc version 0.1.0

Architecture

The CMC framework uses a delegating registry to maintain a small memory footprint while supporting a vast library of tools.

graph TD
    A[User Input: cmc <cmd>] --> B[SubcommandHelpGroup]
    B --> C{Is Command Lazy?}
    C -- Yes --> D[LazyCommand Registry]
    D --> E[importlib.import_module]
    E --> F[DelegatingCommand Wrapper]
    C -- No --> G[Direct Execution]
    F --> H[Extension Logic]
    G --> H

The DelegatingCommand wrapper is critical for enterprise stability; it isolates the core framework from extensions that may have been compiled against different versions of the click library, preventing runtime type-mismatch crashes.