Aperture CLI
Aperture is a command-line interface (CLI) that dynamically generates commands from OpenAPI 3.x specifications. It's designed to provide a secure, reliable, and introspectable "tool-use" endpoint for autonomous AI agents and automated systems.
Features
- OpenAPI-Native: Directly consumes standard OpenAPI 3.x documents as the single source of truth
- Dynamic & Performant: Generates commands at runtime from pre-validated, cached API specifications
- Agent-First Design: Optimized for programmatic use with structured I/O, JSON output modes, and actionable errors
- Secure & Robust: Enforces strict separation of configuration from secrets using environment variables
- Spec Validation: Validates OpenAPI specs during registration with clear error messages for unsupported features
- Batch Processing: Execute multiple operations concurrently with rate limiting and error handling
- Response Caching: Intelligent caching with TTL support for improved performance
- Advanced Output: Multiple output formats (JSON, YAML, table) with JQ-based filtering
- Flag-Based Syntax: Consistent
--flagsyntax for all parameters (with legacy positional support)
Architecture
Aperture follows a two-phase approach:
- Setup Phase (
aperture config add): Parses, validates, and caches OpenAPI specifications - Runtime Phase (
aperture <context> <command>): Loads cached specs for fast command generation and execution
Configuration Structure
~/.config/aperture/
├── specs/ # Original OpenAPI specification files
├── .cache/ # Pre-processed binary cache files
└── config.toml # Global configuration (optional)
Security Model
Authentication is handled through custom x-aperture-secret extensions in OpenAPI specs that map security schemes to environment variables:
components:
securitySchemes:
apiToken:
type: http
scheme: bearer
x-aperture-secret:
source: env
name: API_TOKEN
Installation
Using Cargo (Recommended)
Build from Source
Optional Features
Aperture supports optional features that can be enabled during compilation:
JQ Support (Pure Rust Implementation)
The jq feature enables advanced JSON filtering using JQ syntax. This provides a pure Rust implementation without requiring external dependencies:
# Install with JQ support
# Build from source with JQ support
When enabled, you can use advanced JQ filters:
# Extract specific fields
# Complex filtering
Note: Without the jq feature, only basic field access is supported (e.g., .name, .data.items). For full JQ functionality including array operations, filters, and transformations, enable the feature during compilation.
Getting Started
Basic Usage
# Register an API specification
# List available APIs
# Execute API commands (dynamically generated from spec)
Base URL Management
Aperture provides flexible base URL configuration for different environments:
# Set a custom base URL for an API (overrides spec and environment variables)
# Configure environment-specific URLs
# View current URL configuration
# List all configured URLs across APIs
# Use environment-specific URL
APERTURE_ENV=staging
URL Resolution Priority:
- Explicit test parameter (for testing)
- Per-API configuration (with environment support)
APERTURE_BASE_URLenvironment variable (global override)- OpenAPI spec server URL (default)
- Fallback URL (
https://api.example.com)
Agent-Friendly Features
# Get JSON description of all available commands
# Output errors as structured JSON
# Preview request without execution
# Add idempotency key for safe retries
# Get specific user with flag-based syntax
Advanced Output Formatting
Aperture supports multiple output formats and data filtering:
# Output as formatted table
# Output as YAML
# Extract specific fields with JQ filtering
# Complex JQ transformations
Batch Operations & Automation
For high-volume automation, Aperture supports batch processing with concurrency controls:
# Execute multiple operations from a batch file
# Rate limiting for batch operations
Example batch file (JSON):
Response Caching
Improve performance with intelligent response caching:
# Enable caching with default TTL (300 seconds)
# Custom cache TTL
# Disable caching
# Manage cache
Command Syntax
Aperture now uses flag-based syntax by default for all parameters:
# Default flag-based syntax (recommended)
# Legacy positional syntax (backwards compatibility)
Development
This project is built with Rust and follows Test-Driven Development practices.
Prerequisites
- Rust (latest stable version)
- Cargo
Development Commands
# Build the project
# Run all tests
# Run tests for specific module
# Format code
# Check formatting and linting
# Run with debug output
RUST_LOG=debug
Testing
The project uses comprehensive testing strategies:
- Unit Tests: Located in
tests/directory - Integration Tests: End-to-end CLI testing using
assert_cmd - HTTP Mocking: API interaction testing using
wiremock
# Run integration tests
# Run with HTTP mocking
Project Status
This project is currently in active development. See docs/plan.md for detailed implementation progress and docs/architecture.md for the complete software design specification.
License
Licensed under the MIT License. See LICENSE for details.