cli

module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: EUPL-1.2

README

AI Workflow Framework - CLI

Go Version

A Go CLI tool for orchestrating AI agents (Claude, Gemini, Codex, OpenAI-Compatible APIs) through YAML-configured workflows with state machine execution.

Features

  • State Machine Execution - Define workflows as state machines with conditional transitions based on exit codes, command output, or custom expressions
  • Inline Error Handling - Specify error messages and exit codes directly on steps without creating separate terminal states
  • Agent Steps - Invoke AI agents via CLI tools (Claude, Codex, Gemini) or direct HTTP (OpenAI, Ollama, vLLM, Groq) with prompt templates, response parsing, and accurate token tracking
  • Output Formatting for Agent Steps - Automatically strip markdown code fences and validate JSON output
  • External Prompt Files - Load agent prompts from .md files with full template interpolation, helper functions, and local override support
  • External Script Files - Load commands from external script files with shebang-based interpreter dispatch, template interpolation, path resolution, and local override support
  • Conversation Mode - Multi-turn conversations with native session resume for CLI providers (claude, codex, gemini, opencode), automatic context window management for HTTP providers, mid-conversation context injection via inject_context field, and token tracking across all turns
  • OpenAI-Compatible Provider - Use any Chat Completions API (OpenAI, Ollama, vLLM, Groq) with native HTTP integration, accurate token reporting, and no CLI tool required
  • Parallel Execution - Run multiple steps concurrently with configurable strategies
  • Loop Constructs - For-each and while loops with full context access
  • Sub-Workflows - Invoke workflows from other workflows with input/output mapping
  • Retry with Backoff - Automatic retry with exponential, linear, or constant backoff
  • Workflow Templates - Reusable step patterns with parameters
  • Input Validation - Type checking, patterns, enums, file validation
  • Dry-Run Mode - Preview execution plan without running commands
  • Interactive Mode - Step-by-step execution with prompts
  • Interactive Input Collection - Automatically prompt for missing required inputs in terminal sessions
  • Structured Error Codes - Hierarchical error taxonomy (USER.INPUT.MISSING_FILE) with awf error lookup command
  • Actionable Error Hints - Context-aware suggestions ("Did you mean?") with fuzzy matching, suppressible via --no-hints
  • Audit Trail - Structured JSONL audit log with paired start/end entries per execution, secret masking, configurable path, and atomic writes
  • Plugin System - Extend AWF with custom operations, validators, and step types via gRPC plugins (HashiCorp go-plugin); validators run custom rules during awf validate, custom step types register new type: values for workflow steps; includes sdk.Serve() entry point for plugin authors, and install/update/remove from GitHub Releases with checksum verification
  • Built-in GitHub Plugin - Declarative GitHub operations (get_issue, create_pr, batch) with auth fallback and concurrent execution
  • Built-in HTTP Operation - Declarative REST API calls (GET, POST, PUT, DELETE) with configurable timeout, response capture, and retryable status codes
  • Built-in Notification Plugin - Workflow completion alerts via desktop and webhooks with configurable backends

Installation

curl -fsSL https://raw.githubusercontent.com/awf-project/cli/main/scripts/install.sh | sh

Or via Go:

go install github.com/awf-project/cli/cmd/awf@latest

Or build from source:

git clone https://github.com/awf-project/cli.git
cd cli && make build && make install

See Installation Guide for details.

Quick Start

# Initialize AWF
awf init

# Run example workflow
awf run example

# Create your own workflow
cat > .awf/workflows/hello.yaml << 'EOF'
name: hello
version: "1.0.0"

inputs:
  - name: name
    type: string
    default: World

states:
  initial: greet
  greet:
    type: step
    command: echo "Hello, {{.inputs.name}}!"
    on_success: done
  done:
    type: terminal
    status: success
EOF

# Run with input
awf run hello --input name=World

See Quick Start Guide for more.

⚠️ Security & Risk Disclaimer

AWF is a powerful orchestration tool that grants AI agents and workflows direct access to your system's shell. While this enables complex automation, it carries significant risks:

  1. Arbitrary Code Execution: Workflows behave like shell scripts. Never run a workflow definition (YAML) from an untrusted source without auditing it first.
  2. AI Non-Determinism: AI agents (LLMs) can produce incorrect, unexpected, or destructive output ("hallucinations"). A prompt that seems safe might generate a harmful command in a specific context.
  3. No Sandboxing: By default, AWF executes commands with the same privileges as the user running the CLI.

Best Practices for Safe Execution:

  • Audit Workflows: Always review the YAML and prompt files before execution.
  • Use Dry-Run: Preview the execution plan using awf run --dry-run.
  • Interactive Mode: Use awf run --interactive to approve commands step-by-step.
  • Isolate Execution: Run risky workflows or those from external sources within a sandboxed environment (e.g., Docker, VM).

Commands

Command Description
awf init Initialize AWF in current directory
awf run <workflow> Execute a workflow
awf validate <workflow> Validate workflow syntax
awf diagram <workflow> Generate workflow diagram (DOT format)
awf error [code] Lookup error codes with descriptions and resolutions
awf list List available workflows
awf list prompts List available prompt files
awf resume Resume interrupted workflow
awf history Show execution history
awf status <id> Check workflow status
awf config show Display project configuration
awf plugin list List installed plugins
awf plugin install <owner/repo> Install a plugin from GitHub Releases
awf plugin update [name] Update an installed plugin
awf plugin remove <name> Remove an installed plugin
awf plugin search [query] Search for plugins on GitHub
awf plugin enable <name> Enable a plugin
awf plugin disable <name> Disable a plugin
awf version Show version information
awf completion <shell> Generate shell autocompletion

See Command Reference for all options.

Example Workflow

name: code-review
version: "1.0.0"

inputs:
  - name: file
    type: string
    required: true
    validation:
      file_exists: true

states:
  initial: read

  read:
    type: step
    command: cat "{{.inputs.file}}"
    on_success: analyze
    on_failure: {message: "File not found: {{.inputs.file}}", status: 1}

  analyze:
    type: agent
    provider: claude
    prompt: |
      Review this code for bugs, security issues, and improvements:
      {{.states.read.Output}}
    output_format: json
    options:
      model: claude-sonnet-4-20250514
    timeout: 120
    on_success: report
    on_failure: {message: "Analysis failed: {{.states.analyze.Output}}"}

  report:
    type: step
    command: echo "Severity: {{.states.analyze.JSON.severity}} — {{.states.analyze.JSON.summary}}"
    on_success: done

  done:
    type: terminal
    status: success
awf run code-review --input file=main.go

See Examples for more workflows.

Documentation

📖 Browse the documentation site — searchable, with dark mode.

Or read locally:

Section Description
Getting Started Installation and first steps
User Guide Commands, workflow syntax, templates
Reference Exit codes, error codes, interpolation, validation
Development Architecture, contributing, testing

Architecture

AWF follows hexagonal (clean) architecture:

Interfaces (CLI) → Application (Services) → Domain (Entities, Ports)
                                                    ↑
                        Infrastructure (YAML, JSON, Shell) ─┘

See Architecture for details.

Development

make build          # Build binary
make test           # Run all tests
make lint           # Run linter
make lint-arch      # Check architecture constraints
make test-coverage  # Generate coverage report
make quality        # Run all quality checks
make proto-gen      # Regenerate protobuf Go code
make docs           # Build documentation site
make docs-serve     # Serve documentation site locally
make docs-clean     # Clean documentation build artifacts

See Testing Guide for conventions.

Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for your changes
  4. Submit a Pull Request

Support the Project

AWF is maintained by Alexandre Balmes and relies on community support to ensure continued development, maintenance, and reliability.

Why Sponsor?

Your support helps:

  • Maintenance: Bug fixes, security updates, dependency upgrades
  • Improvements: New features, performance optimizations
  • Quality: Documentation, testing, code reviews
  • Reliability: CI/CD, release management, long-term support
How to Support

Direct sponsorship:

Commercial engagement:

Hiring services from the author's companies directly funds AWF development:

All commercial clients receive a free commercial license for AWF.

License

Open Source License

This project is licensed under the EUPL-1.2 (European Union Public License).

  • Individuals: Free to use, modify, and distribute
  • Companies: Free to use under EUPL-1.2 terms (copyleft - modifications must be shared)
  • GPL Compatibility: EUPL-1.2 is compatible with GPL
Commercial License

Companies seeking exemption from copyleft obligations can obtain a commercial license.

Free commercial license for:

Contact: [email protected]

Directories

Path Synopsis
cmd
awf command
examples
internal
application
Package application provides application services that orchestrate domain operations.
Package application provides application services that orchestrate domain operations.
domain/errors
Package errors provides structured error handling with hierarchical error codes.
Package errors provides structured error handling with hierarchical error codes.
domain/operation
Package operation provides the domain interface and registry for executable operations.
Package operation provides the domain interface and registry for executable operations.
domain/pluginmodel
Package plugin provides domain entities for the plugin system.
Package plugin provides domain entities for the plugin system.
domain/ports
Package ports defines the boundary interfaces for the hexagonal architecture.
Package ports defines the boundary interfaces for the hexagonal architecture.
domain/workflow
Package workflow provides the core domain entities for AWF workflow execution.
Package workflow provides the core domain entities for AWF workflow execution.
infrastructure/agents
Package agents implements infrastructure adapters for AI agent integration.
Package agents implements infrastructure adapters for AI agent integration.
infrastructure/audit
Package audit provides infrastructure adapters for structured audit trail persistence.
Package audit provides infrastructure adapters for structured audit trail persistence.
infrastructure/config
Package config provides project configuration file loading and parsing.
Package config provides project configuration file loading and parsing.
infrastructure/diagram
Package diagram provides DOT format generation for workflow visualization.
Package diagram provides DOT format generation for workflow visualization.
infrastructure/errors
Package errors provides infrastructure adapters for error formatting.
Package errors provides infrastructure adapters for error formatting.
infrastructure/executor
Package executor provides infrastructure adapters for command execution.
Package executor provides infrastructure adapters for command execution.
infrastructure/expression
Package expression provides expression evaluation and validation adapters.
Package expression provides expression evaluation and validation adapters.
infrastructure/github
Package github implements infrastructure adapters for GitHub CLI operations.
Package github implements infrastructure adapters for GitHub CLI operations.
infrastructure/http
Package http implements infrastructure adapters for HTTP request operations.
Package http implements infrastructure adapters for HTTP request operations.
infrastructure/logger
Package logger provides infrastructure adapters for structured logging.
Package logger provides infrastructure adapters for structured logging.
infrastructure/notify
Package notify implements infrastructure adapters for notification operations.
Package notify implements infrastructure adapters for notification operations.
infrastructure/pluginmgr
Package plugin implements infrastructure adapters for the plugin system.
Package plugin implements infrastructure adapters for the plugin system.
infrastructure/repository
Package repository provides infrastructure adapters for workflow and template persistence.
Package repository provides infrastructure adapters for workflow and template persistence.
infrastructure/store
Package store provides infrastructure adapters for state persistence and execution history.
Package store provides infrastructure adapters for state persistence and execution history.
interfaces/cli
Package cli provides the Cobra-based command-line interface for AWF.
Package cli provides the Cobra-based command-line interface for AWF.
interfaces/cli/ui
Package ui provides user interface components for the AWF CLI.
Package ui provides user interface components for the AWF CLI.
testutil
Package testutil provides shared test infrastructure for AWF CLI tests.
Package testutil provides shared test infrastructure for AWF CLI tests.
pkg
expression
Package expression provides boolean expression evaluation for workflow conditions.
Package expression provides boolean expression evaluation for workflow conditions.
interpolation
Package interpolation provides template variable interpolation for AWF workflows.
Package interpolation provides template variable interpolation for AWF workflows.
output
Package output provides format-specific post-processing for agent step outputs.
Package output provides format-specific post-processing for agent step outputs.
plugin/sdk
Package sdk provides the public API for building AWF plugins.
Package sdk provides the public API for building AWF plugins.
retry
Package retry provides configurable retry logic with backoff strategies.
Package retry provides configurable retry logic with backoff strategies.
stringutil
Package stringutil provides string manipulation and comparison utilities.
Package stringutil provides string manipulation and comparison utilities.
validation
Package validation provides input validation utilities for workflow parameters.
Package validation provides input validation utilities for workflow parameters.
proto
plugin/v1
Package pluginv1 contains the generated protobuf and gRPC code for the AWF plugin protocol.
Package pluginv1 contains the generated protobuf and gRPC code for the AWF plugin protocol.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL