amcp / docs /PROJECT_STRUCTURE.md
moelove's picture
clean up
f679000
|
Raw
History Blame
3 kB

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