Skip to content

Commit c778b8d

Browse files
jman4162claude
andcommitted
Initial commit: APAB v0.2.0
MCP-driven phased-array antenna design toolkit with 17 tools, 5 examples, full test suite (188 tests), and CI/CD workflows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent bcbb483 commit c778b8d

96 files changed

Lines changed: 8821 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install -e ".[dev]"
25+
26+
- name: Ruff check
27+
run: ruff check src/ tests/
28+
29+
- name: Mypy
30+
run: mypy src/apab/

.github/workflows/tests.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -e ".[dev,ollama]"
28+
29+
- name: Run tests
30+
run: pytest tests/ -v --timeout=60
31+
32+
- name: Run tests with coverage
33+
if: matrix.python-version == '3.12'
34+
run: |
35+
coverage run -m pytest tests/ -v --timeout=60
36+
coverage report --fail-under=70

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
*.egg
7+
*.egg-info/
8+
dist/
9+
build/
10+
*.whl
11+
12+
# Virtual environments
13+
.venv/
14+
venv/
15+
env/
16+
17+
# IDE
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
*~
23+
24+
# Testing / Coverage
25+
.pytest_cache/
26+
.mypy_cache/
27+
.coverage
28+
htmlcov/
29+
.ruff_cache/
30+
31+
# OS
32+
.DS_Store
33+
Thumbs.db
34+
35+
# Claude Code
36+
.claude/
37+
38+
# Project artifacts
39+
workspace/
40+
*.hdf5
41+
*.h5

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.2.0] - 2025-02-07
9+
10+
### Added
11+
- **Agent orchestrator** with LLM tool-calling loop (`apab design`, `apab run`)
12+
- **17 MCP tools** covering unit-cell simulation, array patterns, system analysis, trade studies, I/O, and plotting
13+
- **EdgeFEM integration** for full-wave unit-cell frequency sweeps and surface impedance
14+
- **phased-array-modeling wrapper** (PAMPatternEngine) with full 2-D patterns, multi-beam, null steering, and hardware impairments
15+
- **phased-array-systems wrapper** (PASSystemEngine) with comms/radar link budgets and DOE trade studies with Pareto extraction
16+
- **Active impedance utilities** — reflection coefficient, impedance, scan-blindness detection
17+
- **Touchstone and far-field CSV importers** with flexible format support
18+
- **5 LLM providers** — Ollama (full), OpenAI/Anthropic/Gemini/OpenAI-compatible (stubs)
19+
- **CLI commands**: `init`, `design`, `run`, `report`, `mcp serve`
20+
- **Pydantic v2 configuration** with YAML load/save and full schema validation
21+
- **Workspace management** with run bundles, artifact directories, and caching
22+
- **5 working examples** demonstrating array patterns, coupling, trade studies, agent sessions, and Touchstone import
23+
- **188 passing tests** covering all layers
24+
- **Path traversal protection** via `is_within_workspace()` in all file-writing MCP tools
25+
- **Error handling** in all MCP tool functions with structured error JSON responses
26+
- **Logging** across MCP tools, domain wrappers, and CLI
27+
- **CI/CD** with GitHub Actions for testing (Python 3.10-3.13) and linting (ruff + mypy)
28+
29+
### Fixed
30+
- NumPy 2.x compatibility — polyfill for removed `np.trapz` function
31+
- `pa.compute_directivity` now receives 2D meshgrids instead of 1D arrays
32+
33+
## [0.1.0] - 2024-12-01
34+
35+
### Added
36+
- Initial project scaffold and specification (SPEC.md)
37+
- Core Pydantic schemas and configuration system
38+
- Basic CLI framework

CLAUDE.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
APAB (Agentic Phased Array Builder) is a Python package that connects an LLM to MCP-exposed engineering tools for phased-array antenna design and analysis. It plans and executes workflows end-to-end: full-wave unit-cell simulation with mutual coupling (over frequency, scan angle, polarization) propagated into array-level patterns and system-level metrics.
8+
9+
The full-wave solver is **EdgeFEM** (not VectorEM).
10+
11+
## Build & Development Commands
12+
13+
```bash
14+
# Install in development mode (once pyproject.toml exists)
15+
pip install -e ".[dev]"
16+
17+
# Run all tests
18+
pytest tests/
19+
20+
# Run a single test
21+
pytest tests/test_file.py::test_name -v
22+
23+
# Type checking
24+
mypy src/apab/
25+
26+
# Linting
27+
ruff check src/ tests/
28+
29+
# CLI entry points
30+
apab init # scaffold project
31+
apab design # interactive agent session
32+
apab run # non-interactive from config
33+
apab report # generate report from run bundle
34+
apab mcp serve # run as MCP server
35+
```
36+
37+
## Architecture (Four Layers)
38+
39+
1. **Agent Orchestrator** (`src/apab/agent/`) - Talks to LLM providers via a `LLMProvider` protocol. Uses tool-calling to dispatch actions to MCP tools. Default: Ollama with `qwen2.5-coder:14b`, offline-capable.
40+
41+
2. **MCP Tool Layer** (`src/apab/mcp/`) - First-party MCP server exposing tools for simulation (EdgeFEM), array patterns (phased-array-modeling), system trades (phased-array-systems), export/plot/report, and optional external EM adapters.
42+
43+
3. **Execution/Compute Layer** (`src/apab/compute/`) - Local execution by default. `ComputeBackend` protocol designed for future cloud backends (AWS/GCP) via entry points (`apab.compute_backends`).
44+
45+
4. **Artifact + Provenance Layer** - Run bundles at `workspace/runs/<run_id>/` containing manifest, config, logs, and artifacts. Cache keys include config/geometry/sweep hashes and dependency versions.
46+
47+
## Key Required Dependencies
48+
49+
- **edgefem** (PyPI) - Full-wave unit-cell solver backend (`jman4162/EdgeFEM`)
50+
- **phased-array-modeling** (PyPI) - Array factor/patterns/impairments (`jman4162/Phased-Array-Antenna-Model`)
51+
- **phased-array-systems** (GitHub: `jman4162/phased-array-systems`) - System-level trades/scenarios
52+
53+
## Plugin/Extension Points (Entry Points)
54+
55+
| Group | Purpose |
56+
|---|---|
57+
| `apab.llm_providers` | LLM provider plugins (Ollama, OpenAI, Anthropic, Gemini, OpenAI-compatible) |
58+
| `apab.em_adapters` | External EM tool adapters (HFSS, CST, FEKO) |
59+
| `apab.compute_backends` | Compute backend plugins (local, future AWS/GCP) |
60+
61+
## Key Protocols
62+
63+
- `LLMProvider` - Provider abstraction in `src/apab/providers/`. Implementations: `OllamaProvider`, `OpenAIProvider`, `AnthropicProvider`, `GeminiProvider`, `OpenAICompatibleProvider`.
64+
- `FullWaveUnitCellSolver` - Solver protocol. EdgeFEM integrated via `EdgeFEMAdapter`.
65+
- `FullWaveFiniteArraySolver` - Reserved for future finite-array simulations.
66+
- `ExternalEMToolAdapter` - For commercial EM tools (HFSS/CST/FEKO).
67+
- `ComputeBackend` - For local and future cloud execution.
68+
69+
## Configuration
70+
71+
Project config lives in `apab.yaml`, validated by Pydantic. Key sections: `project`, `llm`, `mcp`, `compute`, `solver`, `unit_cell`, `sweep`, `array`, `outputs`. See SPEC.md section 7 for full example.
72+
73+
## Data Model
74+
75+
Core data arrays use the shape convention `S[f, scan, pol, i, j]` (complex). Derived quantities: `Z_active[f, scan, pol]`, `Gamma_active[f, scan, pol]`. Storage: HDF5 (primary), NPZ (cache), Touchstone (`.sNp` export). All schemas must be JSON/YAML-serializable.
76+
77+
## Security Constraints
78+
79+
- Workspace-only filesystem access by default
80+
- Local-first, offline-capable defaults (safe mode ON)
81+
- Remote LLM providers and cloud compute require explicit opt-in
82+
- `llm.redaction_mode` levels: `none` (local default), `metadata_only`, `strict`
83+
- All tool calls and remote LLM egress must be audit-logged

0 commit comments

Comments
 (0)