Skip to content

Commit ad9d59a

Browse files
authored
Merge pull request #2 from o3-cloud/claude/issue-1-20250714_144116
feat: Add YAML format support for Agentfile configurations
2 parents 491124c + c9340ec commit ad9d59a

File tree

28 files changed

+2658
-291
lines changed

28 files changed

+2658
-291
lines changed

.github/workflows/test.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Test Python ${{ matrix.python-version }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v4
28+
with:
29+
enable-cache: true
30+
31+
- name: Install dependencies
32+
run: |
33+
uv sync --extra dev
34+
35+
- name: Run tests with coverage
36+
run: |
37+
uv run pytest --cov=src/agentman --cov-report=xml --cov-report=term-missing
38+
39+
- name: Upload coverage to Codecov
40+
uses: codecov/codecov-action@v4
41+
with:
42+
file: ./coverage.xml
43+
fail_ci_if_error: false
44+
env:
45+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
46+
47+
lint:
48+
name: Code Quality
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Set up Python 3.11
54+
uses: actions/setup-python@v5
55+
with:
56+
python-version: "3.11"
57+
58+
- name: Install uv
59+
uses: astral-sh/setup-uv@v4
60+
with:
61+
enable-cache: true
62+
63+
- name: Install dependencies
64+
run: |
65+
uv sync --extra dev
66+
67+
- name: Run black
68+
run: |
69+
uv run black --check src tests
70+
71+
- name: Run isort
72+
run: |
73+
uv run isort --check-only src tests
74+
75+
- name: Run pylint
76+
run: |
77+
uv run pylint src/agentman

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ htmlcov/
1313
.coverage
1414

1515
# Generated files
16-
agent/
16+
agent/
17+
build/

README.md

Lines changed: 172 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ mkdir url-to-social && cd url-to-social
101101
```
102102

103103
**2. Create an `Agentfile`:**
104+
105+
*Option A: Dockerfile format (traditional)*
104106
```dockerfile
105107
FROM yeahdongcn/agentman-base:latest
106108
MODEL anthropic/claude-3-sonnet
@@ -126,6 +128,33 @@ SEQUENCE url_analyzer social_writer
126128
CMD ["python", "agent.py"]
127129
```
128130

131+
*Option B: YAML format (recommended for complex workflows)*
132+
```yaml
133+
# Agentfile.yml
134+
apiVersion: v1
135+
kind: Agent
136+
base:
137+
model: anthropic/claude-3-sonnet
138+
mcp_servers:
139+
- name: fetch
140+
command: uvx
141+
args:
142+
- mcp-server-fetch
143+
transport: stdio
144+
agents:
145+
- name: url_analyzer
146+
instruction: Given a URL, provide a comprehensive summary of the content
147+
servers:
148+
- fetch
149+
- name: social_writer
150+
instruction: Transform any text into a compelling 280-character social media post
151+
chains:
152+
- name: content_pipeline
153+
sequence:
154+
- url_analyzer
155+
- social_writer
156+
```
157+
129158
**3. Build and run:**
130159
```bash
131160
agentman run --from-agentfile -t url-to-social .
@@ -267,6 +296,47 @@ EXPOSE 8080 # Expose ports
267296
CMD ["python", "agent.py"] # Container startup command
268297
```
269298

299+
### 📄 File Format Support
300+
301+
Agentman supports two file formats for defining your agent configurations:
302+
303+
#### **Dockerfile-style Agentfile (Default)**
304+
The traditional Docker-like syntax using an `Agentfile` without extension:
305+
306+
```dockerfile
307+
FROM yeahdongcn/agentman-base:latest
308+
MODEL anthropic/claude-3-sonnet
309+
FRAMEWORK fast-agent
310+
311+
AGENT assistant
312+
INSTRUCTION You are a helpful AI assistant
313+
```
314+
315+
#### **YAML Agentfile**
316+
Modern declarative YAML format using `Agentfile.yml` or `Agentfile.yaml`:
317+
318+
```yaml
319+
apiVersion: v1
320+
kind: Agent
321+
base:
322+
model: anthropic/claude-3-sonnet
323+
framework: fast-agent
324+
agents:
325+
- name: assistant
326+
instruction: You are a helpful AI assistant
327+
```
328+
329+
**Key advantages of YAML format:**
330+
- **🎯 Better structure** for complex multi-agent configurations
331+
- **📝 Native support** for lists, nested objects, and comments
332+
- **🔍 IDE support** with syntax highlighting and validation
333+
- **📊 Clear hierarchy** for routers, chains, and orchestrators
334+
335+
**Usage:**
336+
- **Build**: `agentman build .` (auto-detects format)
337+
- **Run**: `agentman run --from-agentfile .` (works with both formats)
338+
- **Convert**: Agentman can automatically convert between formats
339+
270340
### Framework Configuration
271341

272342
Choose between supported AI agent frameworks:
@@ -290,6 +360,7 @@ FRAMEWORK agno # Alternative: Agno framework
290360

291361
Define external MCP servers that provide tools and capabilities:
292362

363+
**Dockerfile format:**
293364
```dockerfile
294365
MCP_SERVER filesystem
295366
COMMAND uvx
@@ -298,10 +369,23 @@ TRANSPORT stdio
298369
ENV PATH_PREFIX /app/data
299370
```
300371

372+
**YAML format:**
373+
```yaml
374+
mcp_servers:
375+
- name: filesystem
376+
command: uvx
377+
args:
378+
- mcp-server-filesystem
379+
transport: stdio
380+
env:
381+
PATH_PREFIX: /app/data
382+
```
383+
301384
### Agent Definitions
302385

303386
Create individual agents with specific roles and capabilities:
304387

388+
**Dockerfile format:**
305389
```dockerfile
306390
AGENT assistant
307391
INSTRUCTION You are a helpful AI assistant specialized in data analysis
@@ -311,23 +395,64 @@ USE_HISTORY true
311395
HUMAN_INPUT false
312396
```
313397

398+
**YAML format:**
399+
```yaml
400+
agents:
401+
- name: assistant
402+
instruction: You are a helpful AI assistant specialized in data analysis
403+
servers:
404+
- filesystem
405+
- brave
406+
model: anthropic/claude-3-sonnet
407+
use_history: true
408+
human_input: false
409+
```
410+
314411
### Workflow Orchestration
315412

316413
**Chains** (Sequential processing):
414+
415+
*Dockerfile format:*
317416
```dockerfile
318417
CHAIN data_pipeline
319418
SEQUENCE data_loader data_processor data_exporter
320419
CUMULATIVE true
321420
```
322421

422+
*YAML format:*
423+
```yaml
424+
chains:
425+
- name: data_pipeline
426+
sequence:
427+
- data_loader
428+
- data_processor
429+
- data_exporter
430+
cumulative: true
431+
```
432+
323433
**Routers** (Conditional routing):
434+
435+
*Dockerfile format:*
324436
```dockerfile
325437
ROUTER query_router
326438
AGENTS sql_agent api_agent file_agent
327439
INSTRUCTION Route queries based on data source type
328440
```
329441

442+
*YAML format:*
443+
```yaml
444+
routers:
445+
- name: query_router
446+
agents:
447+
- sql_agent
448+
- api_agent
449+
- file_agent
450+
instruction: Route queries based on data source type
451+
```
452+
330453
**Orchestrators** (Complex coordination):
454+
455+
*Dockerfile format:*
331456
```dockerfile
332457
ORCHESTRATOR project_manager
333458
AGENTS developer tester deployer
@@ -336,10 +461,24 @@ PLAN_ITERATIONS 5
336461
HUMAN_INPUT true
337462
```
338463

464+
*YAML format:*
465+
```yaml
466+
orchestrators:
467+
- name: project_manager
468+
agents:
469+
- developer
470+
- tester
471+
- deployer
472+
plan_type: iterative
473+
plan_iterations: 5
474+
human_input: true
475+
```
476+
339477
### Secrets Management
340478

341479
Secure handling of API keys and sensitive configuration:
342480

481+
**Dockerfile format:**
343482
```dockerfile
344483
# Environment variable references
345484
SECRET OPENAI_API_KEY
@@ -355,6 +494,23 @@ BASE_URL https://api.example.com
355494
TIMEOUT 30
356495
```
357496

497+
**YAML format:**
498+
```yaml
499+
secrets:
500+
- name: OPENAI_API_KEY
501+
values: {} # Environment variable reference
502+
- name: ANTHROPIC_API_KEY
503+
values: {}
504+
- name: DATABASE_URL
505+
values:
506+
DATABASE_URL: postgresql://localhost:5432/mydb
507+
- name: CUSTOM_API
508+
values:
509+
API_KEY: your_key_here
510+
BASE_URL: https://api.example.com
511+
TIMEOUT: 30
512+
```
513+
358514
### Default Prompt Support
359515

360516
Agentman automatically detects and integrates `prompt.txt` files, providing zero-configuration default prompts for your agents.
@@ -426,21 +582,36 @@ This ensures your agent automatically executes the default prompt when the conta
426582

427583
## 🎯 Example Projects
428584

585+
All example projects in the `/examples` directory include both Dockerfile-style `Agentfile` and YAML format `Agentfile.yml` for comparison and learning. You can use either format to build and run the examples.
586+
429587
### 1. GitHub Profile Manager (with Default Prompt)
430588

431589
A comprehensive GitHub profile management agent that automatically loads a default prompt.
432590

433591
**Project Structure:**
434592
```
435593
github-profile-manager/
436-
├── Agentfile
594+
├── Agentfile # Dockerfile format
595+
├── Agentfile.yml # YAML format (same functionality)
437596
├── prompt.txt # Default prompt automatically loaded
438597
└── agent/ # Generated files
439598
├── agent.py
440599
├── prompt.txt # Copied during build
441600
└── ...
442601
```
443602

603+
**Build with either format:**
604+
```bash
605+
# Using Dockerfile format
606+
agentman build -f Agentfile .
607+
608+
# Using YAML format
609+
agentman build -f Agentfile.yml .
610+
611+
# Auto-detection (picks first available)
612+
agentman build .
613+
```
614+
444615
**prompt.txt:**
445616
```text
446617
I am a GitHub user with the username "yeahdongcn" and I need help updating my GitHub profile information.

0 commit comments

Comments
 (0)