agentman icon indicating copy to clipboard operation
agentman copied to clipboard

Docker build

Open AgentO3 opened this issue 1 year ago • 1 comments

Summary by Sourcery

Add YAML Agentfile support with auto-detection, structured output validation via JSONSchema and external schema files, environment variable expansion, and CLI enhancements for conversion and validation. Update documentation with examples for both Dockerfile and YAML formats, introduce extensive tests for new features, and configure CI workflows.

New Features:

  • Support parsing and auto-detecting YAML Agentfile format via a new YAML parser
  • Enable structured output validation using JSONSchema or external schema files through an OUTPUT_FORMAT directive
  • Implement environment variable expansion (${VAR} and $VAR) in Agentfiles and MCP server ENV values
  • Add CLI commands and flags (--format, --from-yaml, convert, validate) for format conversion and validation

Enhancements:

  • Extend build_from_agentfile to accept a format hint and auto-detect format
  • Enhance agent code generation to include RequestParams for response_format in both agno and fast-agent frameworks

CI:

  • Introduce GitHub Actions workflows for testing, linting, Docker build & push, and Claude bot integration

Documentation:

  • Revise README to showcase Dockerfile-style and YAML Agentfile formats, environment variable expansion, and structured output support
  • Add example projects demonstrating both formats and structured output workflows

Tests:

  • Add unit tests covering YAML parsing, format detection, conversion utilities, and JSONSchema validation
  • Expand existing tests to cover OUTPUT_FORMAT, env var expansion, and CLI conversion/validation

Chores:

  • Add jsonschema-based schema module for YAML Agentfile validation
  • Update pyproject.toml and CI configs to accommodate new linting rules and workflows

AgentO3 avatar Jul 20 '25 14:07 AgentO3

Reviewer's Guide

This PR introduces full YAML Agentfile support with auto-detection and conversion utilities, enriches the CLI with explicit format flags and new convert/validate commands, implements environment variable expansion in parsing, refactors list handling in code generation for consistency, updates documentation and examples for both Dockerfile and YAML formats, and expands test coverage and CI workflows to validate the new capabilities.

Sequence diagram for CLI build/run with format detection and environment variable expansion

sequenceDiagram
    actor User
    participant CLI as agentman CLI
    participant Parser as AgentfileParser/YamlParser
    participant Builder as AgentBuilder
    participant OS as OS/Env
    User->>CLI: agentman build/run [--format/--from-yaml] .
    CLI->>Parser: parse_file(agentfile_path, format_hint)
    Parser->>OS: Read Agentfile/Agentfile.yml
    Parser->>OS: Expand environment variables in values
    Parser-->>CLI: AgentfileConfig
    CLI->>Builder: build_all(AgentfileConfig)
    Builder->>OS: Generate agent files
    Builder-->>CLI: Build complete
    CLI-->>User: Success message

ER diagram for Agentfile YAML structure

erDiagram
    AGENTFILE {
        string apiVersion
        string kind
    }
    AGENT {
        string name
        string instruction
        string model
        boolean use_history
        boolean human_input
        boolean default
        OutputFormat output_format
    }
    MCP_SERVER {
        string name
        string command
        string[] args
        string transport
        string url
        map env
    }
    AGENTFILE ||--o{ AGENT : agents
    AGENTFILE ||--o{ MCP_SERVER : mcp_servers
    AGENT }o--|| OutputFormat : output_format

Class diagram for AgentfileParser, AgentfileYamlParser, and OutputFormat

classDiagram
    class AgentfileParser {
        +AgentfileConfig config
        +parse_file(filepath)
        +parse_content(content)
    }
    class AgentfileYamlParser {
        +AgentfileConfig config
        +parse_file(filepath)
        +parse_content(content)
    }
    class OutputFormat {
        +str type
        +Dict schema
        +str file
    }
    class Agent {
        +str name
        +str instruction
        +List servers
        +str model
        +bool use_history
        +bool human_input
        +bool default
        +OutputFormat output_format
        +to_decorator_string(...)
    }
    AgentfileParser --|> AgentfileYamlParser : format auto-detection
    Agent "1" -- "0..1" OutputFormat : output_format

Class diagram for CLI subcommands and conversion utilities

classDiagram
    class CLI {
        +build_cli(args)
        +run_cli(args)
        +convert_cli(args)
        +validate_cli(args)
    }
    class Converter {
        +convert_agentfile(input, output, target_format)
        +dockerfile_to_yaml(...)
        +yaml_to_dockerfile(...)
        +validate_agentfile(...)
    }
    CLI ..> Converter : uses

File-Level Changes

Change Details Files
Introduce YAML Agentfile parsing with auto-detection
  • Add AgentfileYamlParser and detect_yaml_format in a new yaml_parser module
  • Implement parse_agentfile to auto-detect format and delegate to the correct parser
src/agentman/yaml_parser.py
Extend build workflow and add conversion utilities
  • Update build_from_agentfile to accept an optional format_hint and branch parsing logic
  • Add converter functions (dockerfile_to_yaml, yaml_to_dockerfile, config_to_yaml_dict, config_to_dockerfile_content)
  • Expose convert_agentfile in the CLI for format conversions
src/agentman/agent_builder.py
src/agentman/converter.py
Enhance CLI with format flags, conversion, and validation subcommands
  • Add --format and --from-yaml flags to build and run commands for explicit format selection
  • Introduce 'convert' and 'validate' subcommands with corresponding handlers
src/agentman/cli.py
Enable environment variable expansion in Agentfile parsing
  • Add expand_env_vars supporting both ${VAR} and $VAR syntaxes
  • Apply expand_env_vars to SECRET and ENV values in both the Dockerfile and YAML parsers
src/agentman/agentfile_parser.py
src/agentman/yaml_parser.py
Refactor code generation to use consistent list structures
  • Replace inline list literals with tuple-wrapped lists in extend calls for imports and agent definitions
  • Simplify conditional logic and improve readability in the agno and fast_agent framework generators
src/agentman/frameworks/agno.py
src/agentman/frameworks/fast_agent.py
Update documentation and examples with dual-format support and env var usage
  • Expand README.md with usage examples for YAML and Dockerfile Agentfiles, format flags, and environment variable expansion
  • Add and update example projects under the examples/ directory for both formats
README.md
examples/
Expand tests and CI workflows for new features
  • Add comprehensive tests/test_yaml_parser.py covering YAML parsing, detection, and error cases
  • Update existing tests to align with parser refactorings and CLI changes
  • Introduce GitHub Actions workflows for testing, linting, coverage reporting, Docker image builds, and Claude bot integration
tests/test_yaml_parser.py
.github/workflows/test.yml
.github/workflows/docker-build.yml
.github/workflows/claude.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an issue from a review comment by replying to it. You can also reply to a review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull request title to generate a title at any time. You can also comment @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in the pull request body to generate a PR summary at any time exactly where you want it. You can also comment @sourcery-ai summary on the pull request to (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the pull request to resolve all Sourcery comments. Useful if you've already addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull request to dismiss all existing Sourcery reviews. Especially useful if you want to start fresh with a new review - don't forget to comment @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

  • Contact our support team for questions or feedback.
  • Visit our documentation for detailed guides and information.
  • Keep in touch with the Sourcery team by following us on X/Twitter, LinkedIn or GitHub.

sourcery-ai[bot] avatar Jul 20 '25 14:07 sourcery-ai[bot]