Skip to content

Latest commit

 

History

History
145 lines (114 loc) · 6.31 KB

development.md

File metadata and controls

145 lines (114 loc) · 6.31 KB

Development

How to build, test, and release this package. Contributor workflow lives in CONTRIBUTING.md.

Layout

src/copper_pilot_cli/   Python package (validate/ holds the review graph engine)
tests/                  pytest suite
examples/               Runnable examples
docs/                   User and developer docs
skills/                 Portable Agent Skill for other harnesses
plugins/                Claude Code plugin (not in the PyPI wheel)
.claude-plugin/         Plugin marketplace manifest
.github/                CI, issue forms, pull request template

The terminal presentation layer started as a source fork of Deep Agents Code. See UPSTREAM.md and NOTICE.

Environment

Python 3.11 or newer. From the repository root:

python3 -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -e ".[dev]"

make help lists targets. Equivalent commands:

Target Command
make fmt python -m ruff format src tests examples
make lint ruff format --check, ruff check, ty check src/copper_pilot_cli
make test python -m pytest -m "not live"

CI also runs pip-audit, piplicenses (fails on GPL/AGPL/UNKNOWN), a wheel build, and copper-pilot --version / copper-pilot-cli --version. Required CI covers every supported stable Python minor on Linux and the minimum supported minor on macOS and Windows. Python 3.15 is probed weekly, outside pull requests, by .github/workflows/forward-python.yml. When that scheduled run is green, add the Programming Language :: Python :: 3.15 classifier, add 3.15 to the required CI matrix, and retarget the scheduled probe at the next unreleased Python.

Tests

  • Default suite: make test or pytest -m "not live".
  • Live suite: pytest -m live. Needs copper-pilot auth login. Skips when no credential is stored.
  • ESP32 example helpers are covered in tests/test_esp32_example.py. Running python examples/001_esp32/main.py needs KiCad 10 and a live account.
  • tests/test_validate.py covers the validate engine with a fake kicad-cli and fake hosted turns; tests/test_validate_live.py runs validate --until S2 on examples/001_esp32 under pytest -m live.

Do not commit credentials, .venv/, or dist/.

Bring your own agent

src/copper_pilot_cli/agents/ holds the Claude Agent and Codex drivers. Tests use fakes only: tests/fakes/fake_codex_app_server.py (a scripted codex app-server), a scripted Claude Agent SDK transport in tests/test_byo_claude.py (the dev extra installs claude-agent-sdk; the tests skip without it), and a fake tools socket in tests/byo_fakes.py. A canary test asserts the server guide never reaches sessions.db or the log. The [claude] extra's metadata is MIT, so the license gate passes; its wheel also bundles a proprietary Claude Code binary that the CLI never executes.

Hosted protocol

The client speaks protocol v1. Agent turns, and plan turns that carry plan context, use /api/copperpilot/analyze/agent/ws. Ask turns and plan turns without that context use /api/copperpilot/analyze/chat/ws.

make_chat_start in copper_protocol.py bounds history before the socket send, matching the desktop harness:

Attempt Message cap History cap Frame cap
1 64 KiB 4 MiB 12 MiB
2 32 KiB 2 MiB 8 MiB
3 8 KiB 128 KiB 8 MiB
4 4 KiB 64 KiB 8 MiB

History is kept newest-first. Inline data: attachments are replaced before the byte caps apply. A query or workspace snapshot that still cannot fit raises ProtocolError with code="PAYLOAD_TOO_LARGE".

A WebSocket error frame keeps code, status, block_reason, can_purchase_overage, and retryable on both ProtocolError and the copper.error event. Absent fields stay absent. The interactive UI and MCP error string use public_message; --json and the MCP event digest keep the object.

classify_error in copper_protocol.py ports the desktop client's error categories (timeout, connection, server, rate_limit, usage_limit, authentication, invalid_request, payload_too_large, protocol, network, aborted, unknown) with a retryable flag, including websocket handshakes the server refuses with an HTTP status (InvalidStatus: 5xx and 429 retry, auth and other 4xx do not). The graph node in copper_graph.py owns the retry loop, the stitched "Resume where we left off" re-prompt, partial-progress checkpointing, and the background shell wait; copper_background.py owns the foreground-to-background shell contract. Transport-level failures before the first frame are retried once inside HostedChatClient.stream; everything after that is the node's job.

Device login and the WebSocket User-Agent (CopperPilot CLI/<version>) read the installed package version. That version comes from VERSION.

POST /api/copperpilot/analyze/token_limits is the account-usage read. It returns percentages and reset state even when chat is blocked. Do not add token counts, plan allocations, Stripe checkout, or a per-chat context meter here. The server does not expose those on this contract.

Release

Version is the contents of VERSION. make release writes that file, regenerates HISTORY.md with gitchangelog, commits both, tags X.Y.Z (no v prefix), and pushes. GitHub Actions then publishes to PyPI and attaches the dist artifacts to the GitHub Release.

make release   # prompts for X.Y.Z

The tag must match VERSION. See .github/workflows/release.yml.

MCP Registry

After the PyPI upload, the mcp-registry job in release.yml publishes server.json to the official MCP Registry (https://registry.modelcontextprotocol.io) as io.github.CopperPilot/copper-pilot-cli, with the tag's version written into it. It signs in with GitHub Actions OIDC (the CopperPilot org namespace; no secret). The registry proves we own the PyPI package by finding the <!-- mcp-name: io.github.CopperPilot/copper-pilot-cli --> line in README.md, so keep that line. Registry versions are immutable: a tag publishes once. Clients start the server with uvx copper-pilot-cli mcp.

Check a release with curl -s "https://registry.modelcontextprotocol.io/v0/servers?search=copper-pilot-cli".