codefleet 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. codefleet-0.3.0/.env.example +17 -0
  2. codefleet-0.3.0/.github/workflows/ci.yml +36 -0
  3. codefleet-0.3.0/.gitignore +12 -0
  4. codefleet-0.3.0/LICENSE +21 -0
  5. codefleet-0.3.0/PKG-INFO +24 -0
  6. codefleet-0.3.0/README.md +260 -0
  7. codefleet-0.3.0/demo/demo.gif +0 -0
  8. codefleet-0.3.0/demo/demo.py +96 -0
  9. codefleet-0.3.0/docs/codex-fleet-supervisor-spec.md +744 -0
  10. codefleet-0.3.0/examples/competitive-implement.json +28 -0
  11. codefleet-0.3.0/examples/parallel-implement-review.json +28 -0
  12. codefleet-0.3.0/examples/write-review-refine.json +28 -0
  13. codefleet-0.3.0/pyproject.toml +45 -0
  14. codefleet-0.3.0/src/codefleet/__init__.py +3 -0
  15. codefleet-0.3.0/src/codefleet/git_ops.py +115 -0
  16. codefleet-0.3.0/src/codefleet/models.py +233 -0
  17. codefleet-0.3.0/src/codefleet/result_schema.py +39 -0
  18. codefleet-0.3.0/src/codefleet/server.py +196 -0
  19. codefleet-0.3.0/src/codefleet/store.py +366 -0
  20. codefleet-0.3.0/src/codefleet/supervisor.py +554 -0
  21. codefleet-0.3.0/src/codefleet/worker_runtime.py +248 -0
  22. codefleet-0.3.0/src/codefleet/workflow.py +438 -0
  23. codefleet-0.3.0/tests/__init__.py +0 -0
  24. codefleet-0.3.0/tests/conftest.py +69 -0
  25. codefleet-0.3.0/tests/test_git_ops.py +168 -0
  26. codefleet-0.3.0/tests/test_models.py +392 -0
  27. codefleet-0.3.0/tests/test_result_schema.py +172 -0
  28. codefleet-0.3.0/tests/test_server.py +197 -0
  29. codefleet-0.3.0/tests/test_store.py +345 -0
  30. codefleet-0.3.0/tests/test_supervisor.py +757 -0
  31. codefleet-0.3.0/tests/test_worker_runtime.py +403 -0
  32. codefleet-0.3.0/tests/test_workflow.py +549 -0
@@ -0,0 +1,17 @@
1
+ # Base directory for fleet data (default: ~/.codex-fleet)
2
+ FLEET_BASE_DIR=~/.codex-fleet
3
+
4
+ # Default Codex model
5
+ FLEET_DEFAULT_MODEL=gpt-5.4
6
+
7
+ # Model reasoning effort (xhigh, high, medium, low)
8
+ FLEET_REASONING_EFFORT=xhigh
9
+
10
+ # Default worker timeout in seconds
11
+ FLEET_DEFAULT_TIMEOUT=600
12
+
13
+ # Maximum concurrent workers
14
+ FLEET_MAX_CONCURRENT=10
15
+
16
+ # Comma-separated list of allowed repo paths (empty = allow all)
17
+ FLEET_ALLOWED_REPOS=
@@ -0,0 +1,36 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ${{ matrix.os }}
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest]
15
+ python-version: ["3.11", "3.12", "3.13"]
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 uv
25
+ uses: astral-sh/setup-uv@v4
26
+
27
+ - name: Install dependencies
28
+ run: uv pip install --system -e ".[dev]"
29
+
30
+ - name: Run tests
31
+ run: python -m pytest tests/ -v --tb=short
32
+
33
+ - name: Run tests with coverage
34
+ if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest'
35
+ run: |
36
+ python -m pytest tests/ --cov=codefleet --cov-report=term-missing --cov-fail-under=80
@@ -0,0 +1,12 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .venv/
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .coverage
8
+ .pytest_cache/
9
+ .DS_Store
10
+ *.db
11
+ demo/*.cast
12
+ demo/*.svg
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: codefleet
3
+ Version: 0.3.0
4
+ Summary: Orchestrate fleets of AI coding agents (Codex, Gemini, Claude) with multi-stage workflows
5
+ Project-URL: Homepage, https://github.com/techinfobel/codefleet
6
+ Project-URL: Repository, https://github.com/techinfobel/codefleet
7
+ Project-URL: Issues, https://github.com/techinfobel/codefleet/issues
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: agents,ai,claude,codex,gemini,mcp,orchestration,workflow
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Requires-Python: >=3.11
19
+ Requires-Dist: mcp[cli]>=1.0.0
20
+ Requires-Dist: pydantic>=2.0.0
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
23
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
24
+ Requires-Dist: pytest>=7.0; extra == 'dev'
@@ -0,0 +1,260 @@
1
+ <p align="center">
2
+ <h1 align="center">codefleet</h1>
3
+ <p align="center">Orchestrate fleets of AI coding agents across providers</p>
4
+ </p>
5
+
6
+ <p align="center">
7
+ <a href="https://pypi.org/project/codefleet"><img src="https://img.shields.io/pypi/v/codefleet" alt="PyPI"></a>
8
+ <a href="https://pypi.org/project/codefleet"><img src="https://img.shields.io/pypi/pyversions/codefleet" alt="Python"></a>
9
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License"></a>
10
+ </p>
11
+
12
+ ---
13
+
14
+ An [MCP server](https://modelcontextprotocol.io/) that lets **Claude Code** dispatch work to **Codex**, **Gemini**, and **Claude** agents — running side-by-side in isolated git worktrees, with multi-stage workflows where agents collaborate across provider boundaries.
15
+
16
+ ```
17
+ Claude Code ──> codefleet ──> Codex worker (implement)
18
+ ──> Claude worker (review)
19
+ ──> Codex worker (refine from review)
20
+ ```
21
+
22
+ <p align="center">
23
+ <img src="demo/demo.gif" alt="codefleet demo" width="700">
24
+ </p>
25
+
26
+ ## Why
27
+
28
+ You have access to multiple AI coding agents. Each has different strengths. But there's no way to make them **work together** on the same codebase, passing results between stages, without manual copy-paste.
29
+
30
+ codefleet fixes this. Define a workflow, pick which agent runs each stage, and let the results flow automatically.
31
+
32
+ ## Install
33
+
34
+ ```bash
35
+ uv pip install codefleet
36
+ ```
37
+
38
+ Or with pip:
39
+ ```bash
40
+ pip install codefleet
41
+ ```
42
+
43
+ ### Prerequisites
44
+
45
+ At least one of these AI CLIs must be installed:
46
+
47
+ | Agent | Install | Verify |
48
+ |-------|---------|--------|
49
+ | **Codex** | `npm i -g @openai/codex` | `codex --version` |
50
+ | **Gemini** | `npm i -g @anthropic-ai/gemini-cli` | `gemini --version` |
51
+ | **Claude** | [claude.ai/download](https://claude.ai/download) | `claude --version` |
52
+
53
+ Plus **Git** and **Python 3.11+**.
54
+
55
+ ## Register with Claude Code
56
+
57
+ ```bash
58
+ claude mcp add codefleet -- uvx codefleet
59
+ ```
60
+
61
+ That's it. Restart Claude Code and the tools are available.
62
+
63
+ **With options:**
64
+ ```bash
65
+ claude mcp add codefleet \
66
+ --env FLEET_ALLOWED_REPOS=/path/to/repo-a,/path/to/repo-b \
67
+ --env FLEET_MAX_SPAWN_DEPTH=2 \
68
+ -- uvx codefleet
69
+ ```
70
+
71
+ **Verify:**
72
+ ```bash
73
+ claude mcp list
74
+ ```
75
+
76
+ ## Quick Start
77
+
78
+ Start Claude Code and ask it to use multi-agent workflows:
79
+
80
+ > "Use codefleet to add input validation to the registration endpoint. Have Codex implement it, Claude review it, then Codex refine based on the review."
81
+
82
+ Claude will call `create_workflow` with a 3-stage pipeline. Each stage runs the right agent automatically.
83
+
84
+ ### Single Worker
85
+
86
+ For simple one-off tasks, use `create_worker` directly:
87
+
88
+ > "Spin up a Codex worker to add rate limiting to the API gateway"
89
+
90
+ > "Launch a Claude worker to write tests for the auth module"
91
+
92
+ > "Use a Gemini worker to refactor the database models"
93
+
94
+ ## Workflows
95
+
96
+ The workflow engine runs a DAG of stages. Each stage picks an executor, gets a prompt template with variables from previous stages, and runs in an isolated (or inherited) git worktree.
97
+
98
+ ### Write -> Review -> Refine
99
+
100
+ The core pattern: one agent implements, another reviews, the first refines.
101
+
102
+ ```json
103
+ {
104
+ "name": "write-review-refine",
105
+ "task_prompt": "Add input validation to the registration endpoint",
106
+ "stages": [
107
+ {
108
+ "name": "implement",
109
+ "executor": "codex",
110
+ "prompt_template": "{task_prompt}",
111
+ "worktree_strategy": "new",
112
+ "depends_on": []
113
+ },
114
+ {
115
+ "name": "review",
116
+ "executor": "claude",
117
+ "prompt_template": "Review these changes:\n{stage_0_summary}\nFiles: {stage_0_files}",
118
+ "worktree_strategy": "inherit",
119
+ "depends_on": [0]
120
+ },
121
+ {
122
+ "name": "refine",
123
+ "executor": "codex",
124
+ "prompt_template": "Address this review:\n{stage_1_summary}\n{stage_1_next_steps}",
125
+ "worktree_strategy": "inherit",
126
+ "depends_on": [1]
127
+ }
128
+ ]
129
+ }
130
+ ```
131
+
132
+ ### Parallel Fan-Out + Review
133
+
134
+ Multiple agents work in parallel, then a reviewer checks all of them:
135
+
136
+ ```json
137
+ {
138
+ "stages": [
139
+ {"name": "module-a", "executor": "codex", "worktree_strategy": "new", "depends_on": []},
140
+ {"name": "module-b", "executor": "gemini", "worktree_strategy": "new", "depends_on": []},
141
+ {
142
+ "name": "review",
143
+ "executor": "claude",
144
+ "prompt_template": "Review both:\nA: {stage_0_summary}\nB: {stage_1_summary}",
145
+ "worktree_strategy": "new",
146
+ "depends_on": [0, 1]
147
+ }
148
+ ]
149
+ }
150
+ ```
151
+
152
+ ### Competitive Implementation
153
+
154
+ Two agents implement the same thing, then a judge picks the better one:
155
+
156
+ ```json
157
+ {
158
+ "stages": [
159
+ {"name": "codex-impl", "executor": "codex", "prompt_template": "{task_prompt}", "worktree_strategy": "new", "depends_on": []},
160
+ {"name": "claude-impl", "executor": "claude", "prompt_template": "{task_prompt}", "worktree_strategy": "new", "depends_on": []},
161
+ {
162
+ "name": "evaluate",
163
+ "executor": "claude",
164
+ "prompt_template": "Compare:\nA: {stage_0_summary}\nB: {stage_1_summary}\nWhich is better?",
165
+ "worktree_strategy": "new",
166
+ "depends_on": [0, 1]
167
+ }
168
+ ]
169
+ }
170
+ ```
171
+
172
+ See [`examples/`](examples/) for complete, copy-paste-ready workflow files.
173
+
174
+ ## Template Variables
175
+
176
+ Available in stage `prompt_template` strings:
177
+
178
+ | Variable | Value |
179
+ |----------|-------|
180
+ | `{task_prompt}` | The workflow's top-level task description |
181
+ | `{stage_N_summary}` | Summary from stage N's result |
182
+ | `{stage_N_files}` | Comma-separated list of files changed in stage N |
183
+ | `{stage_N_next_steps}` | Suggested next steps from stage N |
184
+ | `{stage_N_status}` | `"completed"` or `"blocked"` |
185
+ | `{stage_N_result}` | Full result JSON from stage N |
186
+
187
+ ## MCP Tools
188
+
189
+ ### Workers
190
+
191
+ | Tool | Description |
192
+ |------|-------------|
193
+ | `healthcheck` | Verify codefleet, agent CLIs, and Git are available |
194
+ | `create_worker` | Launch a single agent in an isolated git worktree |
195
+ | `get_worker_status` | Check worker status |
196
+ | `list_workers` | List workers, optionally filtered by status |
197
+ | `collect_worker_result` | Get parsed results and optional log tails |
198
+ | `cancel_worker` | Cancel a running worker |
199
+ | `cleanup_worker` | Remove worktree, branch, and artifacts |
200
+
201
+ ### Workflows
202
+
203
+ | Tool | Description |
204
+ |------|-------------|
205
+ | `create_workflow` | Start a multi-stage DAG workflow |
206
+ | `get_workflow_status` | Check workflow and per-stage status |
207
+ | `list_workflows` | List workflows with optional status filter |
208
+ | `cancel_workflow` | Cancel all running stages |
209
+ | `collect_workflow_result` | Get final or all-stage results |
210
+ | `cleanup_workflow` | Clean up all worktrees and branches |
211
+
212
+ ## Configuration
213
+
214
+ | Variable | Default | Description |
215
+ |----------|---------|-------------|
216
+ | `FLEET_DEFAULT_EXECUTOR` | `codex` | Default agent: `codex`, `gemini`, or `claude` |
217
+ | `FLEET_DEFAULT_MODEL` | `gpt-5.4` | Default Codex model |
218
+ | `FLEET_GEMINI_DEFAULT_MODEL` | `gemini-3.1-pro-preview` | Default Gemini model |
219
+ | `FLEET_CLAUDE_DEFAULT_MODEL` | `claude-sonnet-4-6` | Default Claude model |
220
+ | `FLEET_DEFAULT_TIMEOUT` | `600` | Per-worker timeout (seconds) |
221
+ | `FLEET_MAX_CONCURRENT` | `10` | Max simultaneous workers |
222
+ | `FLEET_MAX_SPAWN_DEPTH` | `2` | How deep agents can recursively spawn sub-agents |
223
+ | `FLEET_ALLOWED_REPOS` | *(all)* | Comma-separated allowlist of repo paths |
224
+ | `FLEET_BASE_DIR` | `~/.codex-fleet` | Data directory for workers and DB |
225
+
226
+ ## How It Works
227
+
228
+ 1. **Isolation** — each worker gets its own git worktree and branch (`{executor}/{task}/{id}`)
229
+ 2. **Supervision** — background threads monitor processes for completion/timeout
230
+ 3. **Structured output** — every agent writes a `result.json` with summary, files changed, test results, and next steps
231
+ 4. **Durability** — all state lives in SQLite (WAL mode), survives crashes and restarts
232
+ 5. **Concurrency control** — configurable limits on concurrent workers and spawn depth
233
+
234
+ ## Development
235
+
236
+ ```bash
237
+ git clone https://github.com/techinfobel/codefleet
238
+ cd codefleet
239
+ uv pip install -e ".[dev]"
240
+ python -m pytest tests/ -v # 187 tests
241
+ python -m pytest tests/ --cov # 93% coverage
242
+ ```
243
+
244
+ ## Recording the Demo
245
+
246
+ ```bash
247
+ # Install asciinema + agg (for GIF conversion)
248
+ brew install asciinema
249
+ cargo install --git https://github.com/asciinema/agg
250
+
251
+ # Record
252
+ asciinema rec demo/demo.cast -c "python demo/demo.py"
253
+
254
+ # Convert to GIF
255
+ agg demo/demo.cast demo/demo.gif --cols 80 --rows 24
256
+ ```
257
+
258
+ ## License
259
+
260
+ MIT
Binary file
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Simulated demo for asciinema/terminal recording.
4
+
5
+ Run: python demo/demo.py
6
+ Record: asciinema rec demo.cast -c "python demo/demo.py"
7
+ Convert: agg demo.cast demo.gif (or svg-term --in demo.cast --out demo.svg)
8
+ """
9
+
10
+ import sys
11
+ import time
12
+
13
+ # ANSI colors
14
+ BOLD = "\033[1m"
15
+ DIM = "\033[2m"
16
+ GREEN = "\033[32m"
17
+ BLUE = "\033[34m"
18
+ CYAN = "\033[36m"
19
+ YELLOW = "\033[33m"
20
+ MAGENTA = "\033[35m"
21
+ RESET = "\033[0m"
22
+ CHECK = f"{GREEN}\u2713{RESET}"
23
+ SPIN = ["\u280b", "\u2819", "\u2839", "\u2838", "\u283c", "\u2834", "\u2826", "\u2827", "\u2807", "\u280f"]
24
+
25
+
26
+ def typewrite(text, delay=0.03):
27
+ for ch in text:
28
+ sys.stdout.write(ch)
29
+ sys.stdout.flush()
30
+ time.sleep(delay)
31
+ print()
32
+
33
+
34
+ def spin_wait(msg, duration=1.5, result="done"):
35
+ frames = SPIN
36
+ end_time = time.monotonic() + duration
37
+ i = 0
38
+ while time.monotonic() < end_time:
39
+ sys.stdout.write(f"\r {CYAN}{frames[i % len(frames)]}{RESET} {msg}")
40
+ sys.stdout.flush()
41
+ time.sleep(0.1)
42
+ i += 1
43
+ sys.stdout.write(f"\r {CHECK} {msg} {DIM}({result}){RESET}\n")
44
+ sys.stdout.flush()
45
+
46
+
47
+ def main():
48
+ print()
49
+ print(f" {BOLD}codefleet{RESET} {DIM}v0.3.0{RESET} \u2014 orchestrate fleets of AI coding agents")
50
+ print()
51
+ time.sleep(0.5)
52
+
53
+ # Show the workflow being created
54
+ print(f" {BOLD}Workflow:{RESET} write \u2192 review \u2192 refine")
55
+ print(f" {DIM}Task: Add input validation to the registration endpoint{RESET}")
56
+ print()
57
+ time.sleep(0.3)
58
+
59
+ # Stage 1: Implement (Codex)
60
+ print(f" {YELLOW}Stage 1/3{RESET} \u2502 {BOLD}implement{RESET} {DIM}(codex / gpt-5.4){RESET}")
61
+ spin_wait("Creating worktree", 0.8, "codex/implement/w_a1b2c3")
62
+ spin_wait("Codex writing code", 2.0, "4 files changed")
63
+ spin_wait("Running tests", 1.0, "12 passed")
64
+ print(f" {CHECK} {GREEN}completed{RESET} \u2014 Added validation to register(), login(), update_profile()")
65
+ print()
66
+ time.sleep(0.3)
67
+
68
+ # Stage 2: Review (Claude)
69
+ print(f" {MAGENTA}Stage 2/3{RESET} \u2502 {BOLD}review{RESET} {DIM}(claude / claude-sonnet-4-6 / effort: high){RESET}")
70
+ spin_wait("Inheriting worktree from stage 1", 0.5, "same branch")
71
+ spin_wait("Claude reviewing changes", 2.5, "review complete")
72
+ print(f" {CHECK} {GREEN}completed{RESET} \u2014 3 issues found: missing email format check, no rate limit, weak password regex")
73
+ print()
74
+ time.sleep(0.3)
75
+
76
+ # Stage 3: Refine (Codex)
77
+ print(f" {BLUE}Stage 3/3{RESET} \u2502 {BOLD}refine{RESET} {DIM}(codex / gpt-5.4){RESET}")
78
+ spin_wait("Inheriting worktree from stage 2", 0.5, "same branch")
79
+ spin_wait("Codex addressing review feedback", 2.0, "3 files changed")
80
+ spin_wait("Running tests", 1.0, "15 passed")
81
+ print(f" {CHECK} {GREEN}completed{RESET} \u2014 All 3 review issues addressed, tests updated")
82
+ print()
83
+ time.sleep(0.5)
84
+
85
+ # Summary
86
+ print(f" {BOLD}{GREEN}\u2501\u2501\u2501 Workflow succeeded{RESET} {DIM}(3 stages, 2 executors, 38s){RESET}")
87
+ print()
88
+ print(f" {DIM}Files changed:{RESET} src/auth/validators.py, src/auth/routes.py,")
89
+ print(f" src/auth/tests/test_validators.py, src/auth/rate_limit.py")
90
+ print(f" {DIM}Branch:{RESET} codex/implement/w_a1b2c3")
91
+ print(f" {DIM}Commits:{RESET} 3 (implement + review-fixes + refinement)")
92
+ print()
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()