gek 0.1.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.
- gek-0.1.0/LICENSE +21 -0
- gek-0.1.0/PKG-INFO +239 -0
- gek-0.1.0/README.md +217 -0
- gek-0.1.0/pyproject.toml +50 -0
- gek-0.1.0/pyproject.toml.orig +37 -0
- gek-0.1.0/src/gek/__init__.py +9 -0
- gek-0.1.0/src/gek/__main__.py +3 -0
- gek-0.1.0/src/gek/agent.py +321 -0
- gek-0.1.0/src/gek/cli.py +112 -0
- gek-0.1.0/src/gek/config.py +168 -0
- gek-0.1.0/src/gek/explain.py +118 -0
- gek-0.1.0/src/gek/gitrepo.py +270 -0
- gek-0.1.0/src/gek/llm.py +136 -0
- gek-0.1.0/src/gek/logs.py +146 -0
- gek-0.1.0/src/gek/mcp_bridge.py +99 -0
- gek-0.1.0/src/gek/prompts.py +90 -0
- gek-0.1.0/src/gek/roles.py +135 -0
- gek-0.1.0/src/gek/swarm.py +377 -0
- gek-0.1.0/src/gek/tools.py +85 -0
gek-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 voxathon
|
|
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.
|
gek-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gek
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An asynchronous swarm harness: an LLM orchestrator spawns role-based agents that coordinate through a git repo.
|
|
5
|
+
Keywords: agents,llm,swarm,orchestration,git,litellm,mcp
|
|
6
|
+
Author: voxathon
|
|
7
|
+
Author-email: voxathon <moxxie@knolastna.me>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Dist: litellm>=1.50
|
|
18
|
+
Requires-Dist: python-dotenv>=1.0
|
|
19
|
+
Requires-Dist: mcp>=2.0
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# gek
|
|
24
|
+
|
|
25
|
+
An asynchronous swarm harness. Not a call tree.
|
|
26
|
+
|
|
27
|
+
An LLM **orchestrator** wakes up, reads `git log`, writes **role templates**,
|
|
28
|
+
grants them powers, spawns **agents** into them, kills the ones that go feral,
|
|
29
|
+
and goes back to sleep. Agents are cattle: each gets its own git worktree and
|
|
30
|
+
branch, works out its own goal from its role's mandate, commits, posts to a
|
|
31
|
+
shared chatter branch, and ends by finishing or by being killed by a role that
|
|
32
|
+
holds `kill` over it. Nothing blocks on anything. State lives in git, not in
|
|
33
|
+
agents, and not even in the orchestrator, which has no memory between wakes
|
|
34
|
+
beyond what's in the log.
|
|
35
|
+
|
|
36
|
+
## If you just came back after months
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
uv run gek explain # what is this, what happened last run, what's in the repo
|
|
40
|
+
uv run gek explain --run 2026 # a specific run (id prefix)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Then read `swarm/logs/README.txt` for the log format, and the newest
|
|
44
|
+
`swarm/logs/<run>/gek.log` for the blow-by-blow.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
Needs Python 3.12+, [uv](https://docs.astral.sh/uv/), and **git 2.38 or newer**
|
|
49
|
+
(merges use `git merge-tree --write-tree`; Debian 12 ships 2.39).
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
uv tool install gek # or, from a checkout: uv sync, then prefix commands with `uv run`
|
|
53
|
+
mkdir myswarm && cd myswarm
|
|
54
|
+
gek init --goal "what the swarm should do" # writes config.json, .env, swarm/repo.git
|
|
55
|
+
# put your key in .env, pick models in config.json
|
|
56
|
+
gek run
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Agents with the `shell` power can do anything your user can. Run swarms that
|
|
60
|
+
have it inside a throwaway VM, not on a machine you care about.
|
|
61
|
+
|
|
62
|
+
## Console
|
|
63
|
+
|
|
64
|
+
`gek run` prints a curated feed: wakes and sleeps, roles written or rejected,
|
|
65
|
+
spawns, commits, chatter posts, merges, kills, exits, inbox messages, errors.
|
|
66
|
+
Everything else goes only to the log files. `-v` echoes every event to stderr;
|
|
67
|
+
`-q` prints nothing.
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
15:25:05 [orchestrator] wakes (#1): start
|
|
71
|
+
15:25:05 + role coder (create) powers=[shell]: write code under src/
|
|
72
|
+
15:25:05 -> coder/5ddd spawned: write src/hello.py
|
|
73
|
+
15:25:07 * coder/5ddd committed on role/coder/5ddd: add hello
|
|
74
|
+
15:25:07 ~ coder/5ddd says: hello.py ready on role/coder/5ddd
|
|
75
|
+
15:25:08 >> reviewer/1fba merged role/coder/5ddd into main: fast-forward to 6ce14b03d6
|
|
76
|
+
15:25:09 XX reviewer/1fba killed coder/462c: dawdling
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
To start from an existing project instead of an empty repo:
|
|
80
|
+
`uv run gek init --seed path/to/some/repo`. Its default branch becomes `main`.
|
|
81
|
+
|
|
82
|
+
## Commands
|
|
83
|
+
|
|
84
|
+
| Command | What it does |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| `gek init [--goal G] [--seed REPO] [--dir D]` | create config.json, .env, and the swarm repo |
|
|
87
|
+
| `gek run [--goal G] [-v \| -q]` | run until the orchestrator halts, the token budget runs out, or Ctrl-C |
|
|
88
|
+
| `gek inbox "message" [--as NAME]` | post to the orchestrator's inbox (works while a run is going; wakes it) |
|
|
89
|
+
| `gek explain [--run ID]` | human summary of a run and the repo |
|
|
90
|
+
|
|
91
|
+
`-c path/to/config.json` goes before the command: `gek -c other.json run`.
|
|
92
|
+
|
|
93
|
+
## The repo is the medium
|
|
94
|
+
|
|
95
|
+
Everything lives in `swarm/repo.git` (bare). Look at it with any git tool.
|
|
96
|
+
|
|
97
|
+
| Ref | What lives there | Who writes |
|
|
98
|
+
| --- | --- | --- |
|
|
99
|
+
| `main` | the work | roles with the `merge` power only |
|
|
100
|
+
| `role/<role>/<hex>` | one branch per agent | that agent (`commit` tool) |
|
|
101
|
+
| `swarm/chatter` | status, handoffs, spawns, kills, exits, sleeps (empty commits) | everyone |
|
|
102
|
+
| `swarm/roles` | `roles/<name>.json` templates | orchestrator |
|
|
103
|
+
| `swarm/inbox` | messages for the orchestrator | roles with `interrupt`, humans via `gek inbox` |
|
|
104
|
+
|
|
105
|
+
Commits carry trailers (`Role:`, `Instance:`, `Kills:`, `Reason:`, `Exit:`,
|
|
106
|
+
`Spawned:`, `Sleep:`), so `git log swarm/chatter --grep "Kills:"` and friends work.
|
|
107
|
+
|
|
108
|
+
Agent worktrees are under `swarm/wt/` while the agent lives and are removed
|
|
109
|
+
when it ends. Its branch stays. Uncommitted work dies with the agent, on purpose.
|
|
110
|
+
The orchestrator can spawn a fresh agent onto a dead one's branch with `resume_branch`.
|
|
111
|
+
|
|
112
|
+
## Powers
|
|
113
|
+
|
|
114
|
+
The orchestrator can grant anything up to the **ceiling** in config.json, and
|
|
115
|
+
nothing above it. A template above the ceiling is rejected with the reason,
|
|
116
|
+
and the rejection is logged.
|
|
117
|
+
|
|
118
|
+
| Power | Meaning |
|
|
119
|
+
| --- | --- |
|
|
120
|
+
| `writes: [prefixes]` | paths the role may commit under (`""` or `"*"` = anywhere). Enforced at commit time. |
|
|
121
|
+
| `shell` | `run` tool: shell commands in its worktree |
|
|
122
|
+
| `merge` | `merge` and `diff` tools: merge branches into main (conflicts are reported, main untouched) |
|
|
123
|
+
| `interrupt` | `interrupt` tool: post to the inbox, which wakes the orchestrator |
|
|
124
|
+
| `kill: [roles]` | `kill` and `list_agents` tools for agents of those roles (`"*"` = any) |
|
|
125
|
+
| `mcp: {server: [tool globs]}` | connect to that MCP server and see only matching tools, as `mcp__<server>__<tool>` |
|
|
126
|
+
|
|
127
|
+
Every agent also gets `read_log`, `list_files`, `read_file`, `post`, `finish`,
|
|
128
|
+
and `write_file`/`commit` if it has any `writes`.
|
|
129
|
+
|
|
130
|
+
Honest caveat: `shell` is a big hole. A role with a shell can do anything your
|
|
131
|
+
user account can. The writes check only stops it committing outside its scope.
|
|
132
|
+
|
|
133
|
+
MCP servers are configured in `mcp_servers` (stdio only for now):
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
"mcp_servers": { "fetch": { "command": "uvx", "args": ["mcp-server-fetch"], "env": {} } },
|
|
137
|
+
"ceiling": { "mcp": { "fetch": ["*"] } }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Wake and sleep
|
|
141
|
+
|
|
142
|
+
The orchestrator wakes on: start, its own timer (it chooses the sleep length,
|
|
143
|
+
clamped to `min_sleep_s`..`max_sleep_s`), anything posted to `swarm/inbox`
|
|
144
|
+
(polled every `inbox_poll_s`, so `gek inbox` from another terminal works), and
|
|
145
|
+
an agent exiting (`wake_on_agent_exit`). Interrupts are debounced
|
|
146
|
+
(`debounce_s`) and never wake it twice within `min_sleep_s`.
|
|
147
|
+
|
|
148
|
+
Each wake starts fresh: the prior, the goal, the ceiling, current roles and
|
|
149
|
+
agents, and the git log since the last wake. It ends the wake with `sleep` or
|
|
150
|
+
`halt`. Ctrl-C kills live agents (on the record) and stops cleanly.
|
|
151
|
+
|
|
152
|
+
## Config
|
|
153
|
+
|
|
154
|
+
`config.json` (everything not set falls back to defaults in `src/gek/config.py`):
|
|
155
|
+
|
|
156
|
+
| Key | Meaning |
|
|
157
|
+
| --- | --- |
|
|
158
|
+
| `swarm_dir` | where repo.git, wt/ and logs/ live (relative to config.json) |
|
|
159
|
+
| `goal` | what the swarm is for; shown to every actor |
|
|
160
|
+
| `api.api_base_env`, `api.api_key_env` | names of the env vars holding base URL and key |
|
|
161
|
+
| `models.orchestrator`, `models.default` | litellm model names |
|
|
162
|
+
| `models.aliases` | names roles can use in their `model` field, e.g. `"cheap": "openai/some-small-model"` |
|
|
163
|
+
| `llm.timeout_s`, `llm.num_retries`, `llm.temperature`, `llm.extra_params` | passed to litellm |
|
|
164
|
+
| `orchestrator.*` | sleep bounds, debounce, inbox poll, steps per wake, log size per wake |
|
|
165
|
+
| `agents.max_alive`, `agents.max_steps` | swarm size cap, steps per agent (a role can set its own `max_steps`) |
|
|
166
|
+
| `agents.max_tool_output_chars`, `agents.shell_timeout_s` | tool output cap, shell timeout |
|
|
167
|
+
| `budget.max_total_tokens` | stop the swarm once this many tokens are spent (0 = no cap) |
|
|
168
|
+
| `ceiling` | the most power the orchestrator may grant |
|
|
169
|
+
| `mcp_servers` | MCP servers available to grant |
|
|
170
|
+
|
|
171
|
+
`.env` holds secrets, loaded from next to config.json and from the current directory:
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
GEK_API_BASE=https://app.vllm-sr.ai/v1
|
|
175
|
+
GEK_API_KEY=...
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
For an OpenAI-compatible endpoint like that one, model names are
|
|
179
|
+
`openai/<model-name-the-server-expects>`. The default `openai/auto` is a guess:
|
|
180
|
+
set the real names in config.json.
|
|
181
|
+
|
|
182
|
+
## Logs
|
|
183
|
+
|
|
184
|
+
Overly extensive, by request. Per run, in `swarm/logs/<run>/`:
|
|
185
|
+
|
|
186
|
+
- `events.jsonl`: every event (model calls with full responses and usage, every
|
|
187
|
+
tool call and result, every git command, spawns, kills, exits, merges, role
|
|
188
|
+
changes, inbox messages, budget notes). One JSON object per line with
|
|
189
|
+
`ts`, `t`, `run`, `seq`, `kind`, `actor`, `data`.
|
|
190
|
+
- `gek.log`: the same, readable.
|
|
191
|
+
- `agents/<id>.jsonl`: each actor's whole conversation, every message once.
|
|
192
|
+
- `meta.json`: run id, versions, config snapshot.
|
|
193
|
+
- `mcp-<server>-<agent>.stderr.log`: whatever MCP servers print to stderr.
|
|
194
|
+
|
|
195
|
+
`swarm/logs/README.txt` lists every event kind. The future TUI reads these.
|
|
196
|
+
|
|
197
|
+
## Layout
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
src/gek/
|
|
201
|
+
cli.py commands
|
|
202
|
+
config.py config.json + .env, defaults
|
|
203
|
+
logs.py RunLog: events.jsonl, gek.log, transcripts
|
|
204
|
+
gitrepo.py git plumbing: swarm refs, worktrees, merges, log
|
|
205
|
+
roles.py role templates, powers, ceiling validation
|
|
206
|
+
llm.py litellm calls, token accounting, budget
|
|
207
|
+
tools.py tool registry with logged execution
|
|
208
|
+
mcp_bridge.py MCP servers as grantable, filtered tools
|
|
209
|
+
agent.py one agent: worktree, tools, loop, teardown
|
|
210
|
+
swarm.py roles, spawning, killing, the orchestrator wake loop
|
|
211
|
+
prompts.py the orchestrator prior and the agent system prompt
|
|
212
|
+
explain.py `gek explain`
|
|
213
|
+
tests/smoke.py end-to-end run with a scripted fake model (no API key needed)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Publishing
|
|
217
|
+
|
|
218
|
+
```
|
|
219
|
+
uv build # dist/gek-X.Y.Z.tar.gz and .whl; config.json, .env, swarm/ are excluded
|
|
220
|
+
uv publish --token pypi-... # or set UV_PUBLISH_TOKEN
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Bump `version` in pyproject.toml and `__version__` in `src/gek/__init__.py` together.
|
|
224
|
+
|
|
225
|
+
## Smoke test
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
uv run python tests/smoke.py
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Plays a whole scripted swarm in a temp dir: roles written (one rejected),
|
|
232
|
+
a coder commits and gets refused for writing outside its scope, a reviewer
|
|
233
|
+
merges its branch and kills a dawdling second coder that was using an MCP
|
|
234
|
+
tool, an outside `gek inbox` message arrives, the orchestrator halts. Prints
|
|
235
|
+
`gek explain` and a list of PASS/FAIL checks.
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
MIT. See [LICENSE](LICENSE).
|
gek-0.1.0/README.md
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# gek
|
|
2
|
+
|
|
3
|
+
An asynchronous swarm harness. Not a call tree.
|
|
4
|
+
|
|
5
|
+
An LLM **orchestrator** wakes up, reads `git log`, writes **role templates**,
|
|
6
|
+
grants them powers, spawns **agents** into them, kills the ones that go feral,
|
|
7
|
+
and goes back to sleep. Agents are cattle: each gets its own git worktree and
|
|
8
|
+
branch, works out its own goal from its role's mandate, commits, posts to a
|
|
9
|
+
shared chatter branch, and ends by finishing or by being killed by a role that
|
|
10
|
+
holds `kill` over it. Nothing blocks on anything. State lives in git, not in
|
|
11
|
+
agents, and not even in the orchestrator, which has no memory between wakes
|
|
12
|
+
beyond what's in the log.
|
|
13
|
+
|
|
14
|
+
## If you just came back after months
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
uv run gek explain # what is this, what happened last run, what's in the repo
|
|
18
|
+
uv run gek explain --run 2026 # a specific run (id prefix)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then read `swarm/logs/README.txt` for the log format, and the newest
|
|
22
|
+
`swarm/logs/<run>/gek.log` for the blow-by-blow.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
Needs Python 3.12+, [uv](https://docs.astral.sh/uv/), and **git 2.38 or newer**
|
|
27
|
+
(merges use `git merge-tree --write-tree`; Debian 12 ships 2.39).
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
uv tool install gek # or, from a checkout: uv sync, then prefix commands with `uv run`
|
|
31
|
+
mkdir myswarm && cd myswarm
|
|
32
|
+
gek init --goal "what the swarm should do" # writes config.json, .env, swarm/repo.git
|
|
33
|
+
# put your key in .env, pick models in config.json
|
|
34
|
+
gek run
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Agents with the `shell` power can do anything your user can. Run swarms that
|
|
38
|
+
have it inside a throwaway VM, not on a machine you care about.
|
|
39
|
+
|
|
40
|
+
## Console
|
|
41
|
+
|
|
42
|
+
`gek run` prints a curated feed: wakes and sleeps, roles written or rejected,
|
|
43
|
+
spawns, commits, chatter posts, merges, kills, exits, inbox messages, errors.
|
|
44
|
+
Everything else goes only to the log files. `-v` echoes every event to stderr;
|
|
45
|
+
`-q` prints nothing.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
15:25:05 [orchestrator] wakes (#1): start
|
|
49
|
+
15:25:05 + role coder (create) powers=[shell]: write code under src/
|
|
50
|
+
15:25:05 -> coder/5ddd spawned: write src/hello.py
|
|
51
|
+
15:25:07 * coder/5ddd committed on role/coder/5ddd: add hello
|
|
52
|
+
15:25:07 ~ coder/5ddd says: hello.py ready on role/coder/5ddd
|
|
53
|
+
15:25:08 >> reviewer/1fba merged role/coder/5ddd into main: fast-forward to 6ce14b03d6
|
|
54
|
+
15:25:09 XX reviewer/1fba killed coder/462c: dawdling
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
To start from an existing project instead of an empty repo:
|
|
58
|
+
`uv run gek init --seed path/to/some/repo`. Its default branch becomes `main`.
|
|
59
|
+
|
|
60
|
+
## Commands
|
|
61
|
+
|
|
62
|
+
| Command | What it does |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| `gek init [--goal G] [--seed REPO] [--dir D]` | create config.json, .env, and the swarm repo |
|
|
65
|
+
| `gek run [--goal G] [-v \| -q]` | run until the orchestrator halts, the token budget runs out, or Ctrl-C |
|
|
66
|
+
| `gek inbox "message" [--as NAME]` | post to the orchestrator's inbox (works while a run is going; wakes it) |
|
|
67
|
+
| `gek explain [--run ID]` | human summary of a run and the repo |
|
|
68
|
+
|
|
69
|
+
`-c path/to/config.json` goes before the command: `gek -c other.json run`.
|
|
70
|
+
|
|
71
|
+
## The repo is the medium
|
|
72
|
+
|
|
73
|
+
Everything lives in `swarm/repo.git` (bare). Look at it with any git tool.
|
|
74
|
+
|
|
75
|
+
| Ref | What lives there | Who writes |
|
|
76
|
+
| --- | --- | --- |
|
|
77
|
+
| `main` | the work | roles with the `merge` power only |
|
|
78
|
+
| `role/<role>/<hex>` | one branch per agent | that agent (`commit` tool) |
|
|
79
|
+
| `swarm/chatter` | status, handoffs, spawns, kills, exits, sleeps (empty commits) | everyone |
|
|
80
|
+
| `swarm/roles` | `roles/<name>.json` templates | orchestrator |
|
|
81
|
+
| `swarm/inbox` | messages for the orchestrator | roles with `interrupt`, humans via `gek inbox` |
|
|
82
|
+
|
|
83
|
+
Commits carry trailers (`Role:`, `Instance:`, `Kills:`, `Reason:`, `Exit:`,
|
|
84
|
+
`Spawned:`, `Sleep:`), so `git log swarm/chatter --grep "Kills:"` and friends work.
|
|
85
|
+
|
|
86
|
+
Agent worktrees are under `swarm/wt/` while the agent lives and are removed
|
|
87
|
+
when it ends. Its branch stays. Uncommitted work dies with the agent, on purpose.
|
|
88
|
+
The orchestrator can spawn a fresh agent onto a dead one's branch with `resume_branch`.
|
|
89
|
+
|
|
90
|
+
## Powers
|
|
91
|
+
|
|
92
|
+
The orchestrator can grant anything up to the **ceiling** in config.json, and
|
|
93
|
+
nothing above it. A template above the ceiling is rejected with the reason,
|
|
94
|
+
and the rejection is logged.
|
|
95
|
+
|
|
96
|
+
| Power | Meaning |
|
|
97
|
+
| --- | --- |
|
|
98
|
+
| `writes: [prefixes]` | paths the role may commit under (`""` or `"*"` = anywhere). Enforced at commit time. |
|
|
99
|
+
| `shell` | `run` tool: shell commands in its worktree |
|
|
100
|
+
| `merge` | `merge` and `diff` tools: merge branches into main (conflicts are reported, main untouched) |
|
|
101
|
+
| `interrupt` | `interrupt` tool: post to the inbox, which wakes the orchestrator |
|
|
102
|
+
| `kill: [roles]` | `kill` and `list_agents` tools for agents of those roles (`"*"` = any) |
|
|
103
|
+
| `mcp: {server: [tool globs]}` | connect to that MCP server and see only matching tools, as `mcp__<server>__<tool>` |
|
|
104
|
+
|
|
105
|
+
Every agent also gets `read_log`, `list_files`, `read_file`, `post`, `finish`,
|
|
106
|
+
and `write_file`/`commit` if it has any `writes`.
|
|
107
|
+
|
|
108
|
+
Honest caveat: `shell` is a big hole. A role with a shell can do anything your
|
|
109
|
+
user account can. The writes check only stops it committing outside its scope.
|
|
110
|
+
|
|
111
|
+
MCP servers are configured in `mcp_servers` (stdio only for now):
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
"mcp_servers": { "fetch": { "command": "uvx", "args": ["mcp-server-fetch"], "env": {} } },
|
|
115
|
+
"ceiling": { "mcp": { "fetch": ["*"] } }
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Wake and sleep
|
|
119
|
+
|
|
120
|
+
The orchestrator wakes on: start, its own timer (it chooses the sleep length,
|
|
121
|
+
clamped to `min_sleep_s`..`max_sleep_s`), anything posted to `swarm/inbox`
|
|
122
|
+
(polled every `inbox_poll_s`, so `gek inbox` from another terminal works), and
|
|
123
|
+
an agent exiting (`wake_on_agent_exit`). Interrupts are debounced
|
|
124
|
+
(`debounce_s`) and never wake it twice within `min_sleep_s`.
|
|
125
|
+
|
|
126
|
+
Each wake starts fresh: the prior, the goal, the ceiling, current roles and
|
|
127
|
+
agents, and the git log since the last wake. It ends the wake with `sleep` or
|
|
128
|
+
`halt`. Ctrl-C kills live agents (on the record) and stops cleanly.
|
|
129
|
+
|
|
130
|
+
## Config
|
|
131
|
+
|
|
132
|
+
`config.json` (everything not set falls back to defaults in `src/gek/config.py`):
|
|
133
|
+
|
|
134
|
+
| Key | Meaning |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| `swarm_dir` | where repo.git, wt/ and logs/ live (relative to config.json) |
|
|
137
|
+
| `goal` | what the swarm is for; shown to every actor |
|
|
138
|
+
| `api.api_base_env`, `api.api_key_env` | names of the env vars holding base URL and key |
|
|
139
|
+
| `models.orchestrator`, `models.default` | litellm model names |
|
|
140
|
+
| `models.aliases` | names roles can use in their `model` field, e.g. `"cheap": "openai/some-small-model"` |
|
|
141
|
+
| `llm.timeout_s`, `llm.num_retries`, `llm.temperature`, `llm.extra_params` | passed to litellm |
|
|
142
|
+
| `orchestrator.*` | sleep bounds, debounce, inbox poll, steps per wake, log size per wake |
|
|
143
|
+
| `agents.max_alive`, `agents.max_steps` | swarm size cap, steps per agent (a role can set its own `max_steps`) |
|
|
144
|
+
| `agents.max_tool_output_chars`, `agents.shell_timeout_s` | tool output cap, shell timeout |
|
|
145
|
+
| `budget.max_total_tokens` | stop the swarm once this many tokens are spent (0 = no cap) |
|
|
146
|
+
| `ceiling` | the most power the orchestrator may grant |
|
|
147
|
+
| `mcp_servers` | MCP servers available to grant |
|
|
148
|
+
|
|
149
|
+
`.env` holds secrets, loaded from next to config.json and from the current directory:
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
GEK_API_BASE=https://app.vllm-sr.ai/v1
|
|
153
|
+
GEK_API_KEY=...
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
For an OpenAI-compatible endpoint like that one, model names are
|
|
157
|
+
`openai/<model-name-the-server-expects>`. The default `openai/auto` is a guess:
|
|
158
|
+
set the real names in config.json.
|
|
159
|
+
|
|
160
|
+
## Logs
|
|
161
|
+
|
|
162
|
+
Overly extensive, by request. Per run, in `swarm/logs/<run>/`:
|
|
163
|
+
|
|
164
|
+
- `events.jsonl`: every event (model calls with full responses and usage, every
|
|
165
|
+
tool call and result, every git command, spawns, kills, exits, merges, role
|
|
166
|
+
changes, inbox messages, budget notes). One JSON object per line with
|
|
167
|
+
`ts`, `t`, `run`, `seq`, `kind`, `actor`, `data`.
|
|
168
|
+
- `gek.log`: the same, readable.
|
|
169
|
+
- `agents/<id>.jsonl`: each actor's whole conversation, every message once.
|
|
170
|
+
- `meta.json`: run id, versions, config snapshot.
|
|
171
|
+
- `mcp-<server>-<agent>.stderr.log`: whatever MCP servers print to stderr.
|
|
172
|
+
|
|
173
|
+
`swarm/logs/README.txt` lists every event kind. The future TUI reads these.
|
|
174
|
+
|
|
175
|
+
## Layout
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
src/gek/
|
|
179
|
+
cli.py commands
|
|
180
|
+
config.py config.json + .env, defaults
|
|
181
|
+
logs.py RunLog: events.jsonl, gek.log, transcripts
|
|
182
|
+
gitrepo.py git plumbing: swarm refs, worktrees, merges, log
|
|
183
|
+
roles.py role templates, powers, ceiling validation
|
|
184
|
+
llm.py litellm calls, token accounting, budget
|
|
185
|
+
tools.py tool registry with logged execution
|
|
186
|
+
mcp_bridge.py MCP servers as grantable, filtered tools
|
|
187
|
+
agent.py one agent: worktree, tools, loop, teardown
|
|
188
|
+
swarm.py roles, spawning, killing, the orchestrator wake loop
|
|
189
|
+
prompts.py the orchestrator prior and the agent system prompt
|
|
190
|
+
explain.py `gek explain`
|
|
191
|
+
tests/smoke.py end-to-end run with a scripted fake model (no API key needed)
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Publishing
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
uv build # dist/gek-X.Y.Z.tar.gz and .whl; config.json, .env, swarm/ are excluded
|
|
198
|
+
uv publish --token pypi-... # or set UV_PUBLISH_TOKEN
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Bump `version` in pyproject.toml and `__version__` in `src/gek/__init__.py` together.
|
|
202
|
+
|
|
203
|
+
## Smoke test
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
uv run python tests/smoke.py
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Plays a whole scripted swarm in a temp dir: roles written (one rejected),
|
|
210
|
+
a coder commits and gets refused for writing outside its scope, a reviewer
|
|
211
|
+
merges its branch and kills a dawdling second coder that was using an MCP
|
|
212
|
+
tool, an outside `gek inbox` message arrives, the orchestrator halts. Prints
|
|
213
|
+
`gek explain` and a list of PASS/FAIL checks.
|
|
214
|
+
|
|
215
|
+
## License
|
|
216
|
+
|
|
217
|
+
MIT. See [LICENSE](LICENSE).
|
gek-0.1.0/pyproject.toml
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "gek"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "An asynchronous swarm harness: an LLM orchestrator spawns role-based agents that coordinate through a git repo."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.12"
|
|
9
|
+
keywords = [
|
|
10
|
+
"agents",
|
|
11
|
+
"llm",
|
|
12
|
+
"swarm",
|
|
13
|
+
"orchestration",
|
|
14
|
+
"git",
|
|
15
|
+
"litellm",
|
|
16
|
+
"mcp",
|
|
17
|
+
]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
20
|
+
"Environment :: Console",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"litellm>=1.50",
|
|
29
|
+
"python-dotenv>=1.0",
|
|
30
|
+
"mcp>=2.0",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[[project.authors]]
|
|
34
|
+
name = "voxathon"
|
|
35
|
+
email = "moxxie@knolastna.me"
|
|
36
|
+
|
|
37
|
+
[project.scripts]
|
|
38
|
+
gek = "gek:main"
|
|
39
|
+
|
|
40
|
+
[build-system]
|
|
41
|
+
requires = ["uv_build>=0.8.0,<0.13.0"]
|
|
42
|
+
build-backend = "uv_build"
|
|
43
|
+
|
|
44
|
+
[tool.uv.build-backend]
|
|
45
|
+
source-exclude = [
|
|
46
|
+
"config.json",
|
|
47
|
+
".env",
|
|
48
|
+
"swarm",
|
|
49
|
+
"**/__pycache__",
|
|
50
|
+
]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "gek"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "An asynchronous swarm harness: an LLM orchestrator spawns role-based agents that coordinate through a git repo."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "voxathon", email = "moxxie@knolastna.me" }
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
keywords = ["agents", "llm", "swarm", "orchestration", "git", "litellm", "mcp"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"litellm>=1.50",
|
|
24
|
+
"python-dotenv>=1.0",
|
|
25
|
+
"mcp>=2.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.scripts]
|
|
29
|
+
gek = "gek:main"
|
|
30
|
+
|
|
31
|
+
[build-system]
|
|
32
|
+
requires = ["uv_build>=0.8.0,<0.13.0"]
|
|
33
|
+
build-backend = "uv_build"
|
|
34
|
+
|
|
35
|
+
[tool.uv.build-backend]
|
|
36
|
+
# ship the package, README and tests; never the local config, secrets or swarm state
|
|
37
|
+
source-exclude = ["config.json", ".env", "swarm", "**/__pycache__"]
|