Skip to content

Add Comprehensive Management CLI with Rich Formatting#12

Merged
tbille merged 11 commits intomainfrom
add-cli
Feb 24, 2026
Merged

Add Comprehensive Management CLI with Rich Formatting#12
tbille merged 11 commits intomainfrom
add-cli

Conversation

@tbille
Copy link
Contributor

@tbille tbille commented Feb 23, 2026

Summary

Transforms the any-llm CLI from a simple decryption tool into a full-featured management interface for the any-llm platform. This PR adds complete CRUD operations for projects, provider keys, budgets, and clients with modern terminal formatting and multiple output formats.

Key Features

🔧 Management Operations

  • Project Management: Create, list, update, and delete projects
  • Provider Key Management: CRUD operations with encryption key generation and automatic migration
  • Budget Management: Create and manage budgets with period-based tracking (daily/weekly/monthly)
  • Client Management: Full client lifecycle management with default client support

🎨 Enhanced UX

  • Rich table formatting with adaptive terminal width
  • Multiple output formats: table (default), JSON, YAML
  • Smart column truncation for narrow terminals
  • Authentication flow with token management and automatic refresh

🔐 Security Features

  • Encryption key generation with X25519 keypair creation
  • Automatic key migration when rotating encryption keys
  • Token-based authentication with 24-hour expiration and refresh logic

📚 Documentation

  • Agent-first development guide (AGENTS.md) as knowledge map
  • Restructured architecture docs into docs/architecture/
  • Comprehensive CLI usage guide with examples for all commands
  • Code style guide and development workflow documentation

Changes

Added:

  • client_management.py - Management API client with authentication (851 lines)
  • Crypto utilities for encryption, key generation, and formatting
  • Rich CLI with command groups: project, key, budget, client
  • Comprehensive test suite (404 new test lines)
  • Agent development guide and structured documentation

Enhanced:

  • CLI expanded from 25 to 1,112 lines with management commands
  • Client with token authentication and automatic refresh
  • README with complete CLI documentation

Dependencies:

  • pyyaml - YAML output format support
  • rich - Terminal formatting and tables

Testing

  • ✅ All 48 tests passing
  • ✅ Unit tests for CLI command structure and help text
  • ✅ Integration tests for authentication flows and management operations
  • ✅ Output format validation (table/JSON/YAML)

Backward Compatibility

All changes are fully backward compatible:

  • Existing decrypt functionality preserved and unchanged
  • New commands are additive, not breaking
  • Environment variables maintain same behavior
  • Library API unchanged for programmatic usage

Example Usage

# Authenticate
export ANY_LLM_USERNAME="user@example.com"
export ANY_LLM_PASSWORD="password"

# Manage projects
any-llm project list
any-llm project create "My Project"

# Generate new encryption key with migration
any-llm key generate <project-id> --old-key "ANY.v1...."

# List provider keys
any-llm key list <project-id>

# JSON output for scripting
any-llm --format json project list | jq '.data[0].id'

Commits

This PR consists of 11 atomic commits following single-responsibility principle:

  1. Dependencies (pyyaml, rich)
  2. Infrastructure (.gitignore updates)
  3. Crypto utilities (encryption, key generation)
  4. Management API client
  5. Client integration (token auth)
  6. Documentation restructure
  7. Agent development guide
  8. CLI expansion with management commands
  9. Comprehensive test suite
  10. README updates
  11. Development tooling

Stats: +4,636 lines, -57 lines across 18 files

Add pyyaml for YAML output support and rich for formatted table display in CLI.
Update ruff config to allow Any type in CLI output formatting functions.
Add .coverage and .ralph/ to .gitignore to exclude generated development
artifacts from version control.
Add encrypt_data() for sealed box encryption, generate_keypair() for
creating new X25519 keypairs, and format_any_llm_key() for outputting
keys in the standard ANY.v1 format. These utilities enable client-side
key rotation and migration workflows.
Introduce ManagementMixin providing authenticated access to project,
provider key, budget, and client management endpoints. Implements
token-based authentication with automatic refresh and comprehensive
error handling.
Add ManagementMixin to AnyLLMPlatformClient to expose project, key,
budget, and client management methods. Implement automatic token
refresh and validation for long-running sessions.
Move cryptography content from ARCHITECTURE.md to docs/architecture/
with improved organization. Split into CRYPTOGRAPHY.md and
PROJECT_STRUCTURE.md for better navigation and maintainability.
Introduce AGENTS.md as a knowledge map for AI coding agents and human
developers. Add structured documentation for development workflow,
code style guide, and CLI usage reference following agent-first
development principles.
Expand CLI from simple decrypt tool to full management interface with
command groups for projects, keys, budgets, and clients. Add rich table
formatting, JSON/YAML output options, and key generation with automatic
migration. Implement authentication flow for management operations while
preserving existing decrypt functionality.
Add unit tests for CLI command structure, help text, and error handling.
Add integration tests for project, key, budget, and client operations
with authentication flows and output format validation.
Replace basic CLI examples with detailed documentation for all command
groups (project, key, budget, client). Add authentication instructions,
key generation workflow, output format options, and real-world usage
examples.
Add test_local.sh for convenient local testing during development.
@tbille tbille merged commit 6039e97 into main Feb 24, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant