File size: 3,001 Bytes
f679000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Project Structure

## Overview

AMCP follows Python best practices with a clear separation of concerns:

```
AMCP/
β”œβ”€β”€ src/amcp/              # Main package source code
β”‚   β”œβ”€β”€ __init__.py        # Package initialization
β”‚   β”œβ”€β”€ __main__.py        # Entry point for python -m amcp
β”‚   β”œβ”€β”€ cli.py             # CLI interface (Typer)
β”‚   β”œβ”€β”€ agent.py           # Agent orchestration logic
β”‚   β”œβ”€β”€ agent_spec.py      # Agent specification handling
β”‚   β”œβ”€β”€ tools.py           # Built-in tools (read, grep, bash, etc.)
β”‚   β”œβ”€β”€ config.py          # Configuration management
β”‚   β”œβ”€β”€ mcp_client.py      # MCP server integration
β”‚   β”œβ”€β”€ chat.py            # Chat/LLM interaction
β”‚   └── readfile.py        # File reading utilities
β”‚
β”œβ”€β”€ tests/                 # Test suite
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ conftest.py        # Pytest fixtures
β”‚   β”œβ”€β”€ test_agent_spec.py
β”‚   β”œβ”€β”€ test_config.py
β”‚   └── test_tools.py
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml         # GitHub Actions CI/CD
β”‚
β”œβ”€β”€ docs/                  # Documentation
β”‚   └── PROJECT_STRUCTURE.md
β”‚
β”œβ”€β”€ pyproject.toml         # Project metadata & dependencies
β”œβ”€β”€ pytest.ini             # Pytest configuration
β”œβ”€β”€ Makefile               # Common development tasks
β”œβ”€β”€ .pre-commit-config.yaml # Pre-commit hooks
β”œβ”€β”€ .ruff.toml             # Ruff linter configuration
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
β”œβ”€β”€ CONTRIBUTING.md
β”œβ”€β”€ CHANGELOG.md
└── Dockerfile
```

## Key Design Decisions

### 1. Source Layout (`src/` layout)
- Prevents accidental imports of uninstalled code
- Clear separation between source and tests
- Recommended by PyPA

### 2. Testing
- Uses pytest for testing framework
- Fixtures in `conftest.py` for reusability
- Coverage reporting with pytest-cov
- Target: >80% code coverage

### 3. Code Quality
- Ruff for linting and formatting
- Type hints encouraged (mypy for type checking)
- Pre-commit hooks for automated checks

### 4. CI/CD
- GitHub Actions for automated testing
- Matrix testing across Python 3.11, 3.12, 3.13
- Automated coverage reporting

### 5. Configuration
- pyproject.toml as single source of truth
- Tool configurations centralized
- Optional dependencies for development

## Development Workflow

1. **Setup**: `make install` or `pip install -e ".[dev]"`
2. **Test**: `make test` or `pytest`
3. **Lint**: `make lint` or `ruff check src/ tests/`
4. **Format**: `make format` or `ruff format src/ tests/`
5. **Coverage**: `make test-cov`

## Module Responsibilities

- **cli.py**: Command-line interface, argument parsing
- **agent.py**: Core agent logic, tool orchestration
- **tools.py**: Built-in tool implementations
- **config.py**: Configuration loading/saving
- **mcp_client.py**: MCP protocol communication
- **chat.py**: LLM interaction, streaming responses