agent-loop-tool 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-loop-tool
3
+ Version: 0.1.0
4
+ Summary: Checkpoint-gated developer/reviewer loop across Claude Code, Codex, Grok, and Antigravity CLIs.
5
+ Author: Dwaraka Ramana Turlapati
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/dcurioustech/agent-loop
8
+ Project-URL: Issues, https://github.com/dcurioustech/agent-loop/issues
9
+ Keywords: ai,agents,claude,codex,code-review,cli
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Software Development
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ # agent-loop
21
+
22
+ A checkpoint-gated developer/reviewer loop. One coding-agent CLI plays **developer** and writes the code for the current checkpoint; another plays **reviewer** and approves or sends it back. The loop commits per checkpoint, refuses to run on `main`/`master`, and halts after a configurable number of failed review attempts.
23
+
24
+ Originally extracted from a Flutter project's `run_loop.sh`. Project-agnostic: build / test / lint commands are declared per project in `plan_checkpoints.json`.
25
+
26
+ ## Install
27
+
28
+ The PyPI distribution is `agent-loop-tool`; the installed command is
29
+ `agent-loop`. Until the first PyPI release, install from the repository
30
+ (requires repository access):
31
+
32
+ ```console
33
+ pipx install git+https://github.com/dcurioustech/agent-loop.git
34
+ # or
35
+ uv tool install git+https://github.com/dcurioustech/agent-loop.git
36
+ ```
37
+
38
+ After the first PyPI release, use `pipx install agent-loop-tool` or
39
+ `uv tool install agent-loop-tool`.
40
+
41
+ Requires at least one of these CLIs on PATH, depending on the roles you pick:
42
+
43
+ | Provider | Install |
44
+ |----------|----------------------------------------|
45
+ | claude | <https://docs.claude.com/claude-code> |
46
+ | codex | <https://github.com/openai/codex> |
47
+ | grok | <https://docs.x.ai/docs/grok-cli> |
48
+ | antigravity | <https://antigravity.google/docs/cli-overview> (binary: `agy`) |
49
+
50
+ ## Usage
51
+
52
+ In a consumer repo containing `plan_checkpoints.json`:
53
+
54
+ ```
55
+ agent-loop validate # schema-check the state file
56
+ agent-loop status # one-line summary per checkpoint
57
+ agent-loop run # developer=claude, reviewer=codex (defaults)
58
+ agent-loop run --developer codex --reviewer claude
59
+ agent-loop run --developer grok --reviewer antigravity
60
+ agent-loop run --developer antigravity --reviewer claude
61
+ agent-loop run --developer-model claude-opus-4-8 --reviewer-model gpt-5-codex
62
+ ```
63
+
64
+ ### Choosing the model
65
+
66
+ `--developer` / `--reviewer` pick the CLI; the *model* is resolved per role with this
67
+ precedence (first match wins):
68
+
69
+ 1. `--developer-model` / `--reviewer-model` on the command line
70
+ 2. a `models` block in `plan_checkpoints.json` (see schema below)
71
+ 3. whatever default the CLI itself resolves (its config file / env / built-in)
72
+
73
+ So if you set nothing, each CLI keeps using its own default model — the loop never
74
+ overrides it. Model names are provider-specific, so a value pinned for one role only
75
+ makes sense for the CLI you assigned to that role. Under the hood the model is passed as
76
+ `--model <name>` (claude/grok) or `-m <name>` (codex/antigravity).
77
+
78
+ Safety envs (per provider, off by default):
79
+
80
+ ```
81
+ ALLOW_AUTO_MODE_CLAUDE=1 # claude --dangerously-skip-permissions
82
+ ALLOW_AUTO_MODE_CODEX=1 # codex exec --dangerously-bypass-approvals-and-sandbox
83
+ ALLOW_AUTO_MODE_GROK=1 # grok --always-approve
84
+ ALLOW_AUTO_MODE_ANTIGRAVITY=1 # agy --dangerously-skip-permissions
85
+ ```
86
+
87
+ The loop refuses to start unless the assigned provider's auto mode gate is set, so unattended runs cannot stall on a permission prompt.
88
+
89
+ ## Run logs and the audit trail
90
+
91
+ Every run writes a log to `loop_<YYYYMMDD>_<HHMMSS>.log`. Where that lands is resolved in this order:
92
+
93
+ 1. `--log-dir <path>` — explicit CLI flag, wins over everything.
94
+ 2. `LOG_DIR=<path>` — environment override.
95
+ 3. `<repo-root>/logs` — the default, resolved from the git root regardless of your current working directory (falls back to a relative `logs/` outside a git repo).
96
+
97
+ ### Logs are committed as audit artifacts
98
+
99
+ Logs under the repository are **tracked and committed**, not ignored. The loop commits them alongside code at each checkpoint (`built`, `revision`, `approved`) and on every exit path (`audit: halted`, `audit: run failed`, `audit: completed run`), so a run's history survives in git even when it fails.
100
+
101
+ Two consequences worth knowing:
102
+
103
+ - **Each commit holds a partial log.** The log is still being appended to while the loop commits it, so a checkpoint commit captures the log *as of that moment*. The closing `audit:` commit flushes the tail. Bytes written after that land in the next run's first commit — partial by design, never lost.
104
+ - **A modified log does not block the next run.** The preflight worktree check ignores changes under the log directory (and only there); real source changes still refuse to start the loop.
105
+
106
+ Point `--log-dir` outside the repository and the loop warns that logs will not be committed, then runs normally.
107
+
108
+ ### What the log contains
109
+
110
+ Agent stdout and stderr are streamed into the log as well as to your terminal, so the log can hold the agents' actual working output, not just the loop's own bookkeeping — subject to `--audit-level`, below. Alongside it the loop emits structured, one-line JSON events that are easy to grep or parse:
111
+
112
+ | Event | Emitted when |
113
+ | --- | --- |
114
+ | `AGENT_TRACE` | A developer/reviewer invocation starts, its prompt, and its result (`action` is `start`, `prompt`, or `finish`) |
115
+ | `REVIEW_COMMENT` | The reviewer returns, carrying its notes and resulting status |
116
+ | `APPROVAL_COMMENT` | A checkpoint is approved, or skipped because it already was |
117
+ | `COMMIT_STATEMENT` | A commit is made (with hash) or found unnecessary |
118
+ | `RUN_OUTCOME` | The run ends: `completed`, `halted`, or `failed` |
119
+
120
+ ```console
121
+ $ grep RUN_OUTCOME logs/loop_20260816_101500.log
122
+ [agent-loop] RUN_OUTCOME {"branch": "feature-x", "event": "RUN_OUTCOME", "outcome": "completed"}
123
+ ```
124
+
125
+ ### `--audit-level`: how much of that ends up in git
126
+
127
+ Because logs are committed, anything an agent prints — or writes into a checkpoint's `review_notes` — becomes part of permanent git history the moment its commit is made. `--audit-level` controls how much of that actually reaches the log:
128
+
129
+ | Level | Raw agent stdout/stderr | Prompts, review notes, comments | Structured events |
130
+ | --- | --- | --- | --- |
131
+ | `full` | logged as-is | logged as-is | logged |
132
+ | `redacted` | scrubbed for known secret shapes first | scrubbed first | logged |
133
+ | `off` (default) | not logged at all | replaced with a `<suppressed: N chars>` placeholder | logged |
134
+
135
+ Resolution order: `--audit-level <level>` flag, then `AGENT_LOOP_AUDIT_LEVEL` env var, then `off`.
136
+
137
+ ```console
138
+ agent-loop run --audit-level full # everything, unfiltered
139
+ agent-loop run --audit-level redacted # best-effort secret scrub
140
+ agent-loop run # off — structured log events only (default)
141
+ ```
142
+
143
+ At every level, agents still receive the real, unredacted prompt — `--audit-level` only changes what gets *logged*, never what an agent is told to do. The state file retains `review_notes` as written by the agents and is committed with checkpoint changes, regardless of audit level.
144
+
145
+ **`redacted` is a best-effort net, not a guarantee.** It catches known secret *shapes* — AWS access keys, GitHub/Slack/OpenAI tokens, bearer tokens, PEM private-key blocks, `key: value`-style assignments — via regex over live, line-streamed subprocess output. It cannot catch a project's own custom secret formats, and a secret split across two flushed writes can slip through. Treat committed logs as something a human should skim before pushing, not as pre-cleared for a public remote. `off` suppresses raw content in the log, but does not redact the state file.
146
+
147
+ The `--log-dir` worktree exemption above only ever tolerates changes to log *files*; it has no bearing on what those files contain — that's entirely `--audit-level`'s job.
148
+
149
+ ## Generating a plan (`agent-loop init`)
150
+
151
+ `agent-loop init` turns a feature description into a schema-valid `plan_checkpoints.json`
152
+ by asking a coding-agent CLI to break it into ordered, independently reviewable
153
+ checkpoints. It runs the provider once, non-interactively, captures its output, and
154
+ only writes the state file after the result parses as JSON and passes the same
155
+ validation `load_state` applies — nothing is written on a provider error, a timeout,
156
+ malformed output, or a schema failure.
157
+
158
+ Plain-English input:
159
+
160
+ ```
161
+ agent-loop init "Add a login page with email/password auth and a logout button"
162
+ ```
163
+
164
+ Markdown input (e.g. an existing design doc):
165
+
166
+ ```
167
+ agent-loop init --feature-file docs/feature.md
168
+ ```
169
+
170
+ Either form accepts:
171
+
172
+ | Flag | Default |
173
+ |----------------|-----------------------------------------------------------------------|
174
+ | `--state` | `plan_checkpoints.json` |
175
+ | `--branch` | sanitized `feature/<slug>` derived from the feature text (or the `--feature-file` filename) |
176
+ | `--plan-file` | `docs/implementation_plan.md` for plain-English input, or the `--feature-file` path for Markdown input |
177
+ | `--provider` | `claude` — any provider from `agent-loop run`'s table can generate the plan |
178
+ | `--model` | the provider CLI's own default |
179
+ | `--timeout` | `1800` seconds |
180
+ | `--force` | off — refuses to overwrite an existing `--state` file |
181
+
182
+ ```
183
+ agent-loop init "Add CSV export to the reports page" \
184
+ --provider codex --model gpt-5-codex --timeout 600 --branch feature/csv-export
185
+ ```
186
+
187
+ By default `init` refuses to touch an existing state file so you don't accidentally
188
+ clobber checkpoint progress; pass `--force` to regenerate and overwrite it. A target
189
+ branch of `main`/`master` is rejected before the provider is ever invoked, same as
190
+ `agent-loop run`. Generated checkpoints always start `pending` with `attempts: 0` and
191
+ empty `review_notes`, regardless of what the provider returned for those fields.
192
+
193
+ A freshly generated file is immediately usable:
194
+
195
+ ```
196
+ agent-loop init "Add a login page" && agent-loop validate && agent-loop status
197
+ ```
198
+
199
+ ## Bootstrapping a new consumer repo
200
+
201
+ Download the example as your starting point and edit `branch`, `plan_file`, and the project block to match your stack:
202
+
203
+ ```
204
+ curl -L https://raw.githubusercontent.com/dcurioustech/agent-loop/main/examples/plan_checkpoints.example.json \
205
+ -o plan_checkpoints.json
206
+ agent-loop validate
207
+ ```
208
+
209
+ The example covers all three checkpoint statuses (`pending` / `built` / `approved`) and shows a per-checkpoint `test_cmd` override on top of the project-level default.
210
+
211
+ ## `plan_checkpoints.json` schema
212
+
213
+ ```jsonc
214
+ {
215
+ "plan_file": "docs/implementation_plan.md",
216
+ "branch": "feature-branch",
217
+ "project": {
218
+ "build_cmd": "flutter build web --release",
219
+ "test_cmd": "flutter test",
220
+ "lint_cmd": "flutter analyze",
221
+ "verify_in_review": true
222
+ },
223
+ "models": { // optional; per-role model, overridden by CLI flags
224
+ "developer": "claude-opus-4-8",
225
+ "reviewer": "gpt-5-codex"
226
+ },
227
+ "checkpoints": [
228
+ {
229
+ "id": "phase0",
230
+ "name": "...",
231
+ "status": "pending", // pending | built | approved
232
+ "scope": "...",
233
+ "exit_criteria": ["..."], // non-empty; each entry a non-empty string
234
+ "attempts": 0, // non-negative integer
235
+ "review_notes": ""
236
+ }
237
+ ]
238
+ }
239
+ ```
240
+
241
+ Per-checkpoint `build_cmd` / `test_cmd` / `lint_cmd` overrides are also supported. The reviewer prompt includes these commands so the agent knows how to verify.
@@ -0,0 +1,20 @@
1
+ agent_loop/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ agent_loop/audit.py,sha256=_xY02kksxAgF-_35uk1ewV2D9tWTfId_Craa7eQOTVU,4825
3
+ agent_loop/cli.py,sha256=vS7b_cd2-1llZLiJxI45tWynNomKcObGmOFkWf57rfE,11513
4
+ agent_loop/git_ops.py,sha256=E4_X7TD7v5rr5c447Gx2gLC53YF6cJNRAoVEgQV3IMg,4468
5
+ agent_loop/orchestrator.py,sha256=Hjm6meFlGj2Y2T39gSjqDoxD5HnHVgYbWaMGhZ2T5ZI,10667
6
+ agent_loop/plan_init.py,sha256=Q3Xyc3ONUoLxR1sVrkMnLt7nghnHGDrAYvwRwxzq6P4,13793
7
+ agent_loop/safety.py,sha256=edvRSTy-di9nU4KOs7M3Up1dkpIbgQQsCfd6XczJgo0,2778
8
+ agent_loop/state.py,sha256=6GQAH8TZp2Un52sO_SFK_1RNRNZ4NlRaDIh8Q0CMv38,9169
9
+ agent_loop/providers/__init__.py,sha256=1Lz43vhw5mKpll3QZ2_FORo-dGFgBVGPy-5iAodkezc,869
10
+ agent_loop/providers/antigravity.py,sha256=EqSn-du32ZRX6KiIVym-Ul1FBPWHZzx_OKdYxE8tqZI,479
11
+ agent_loop/providers/base.py,sha256=YJnnMuLavtRfsQ3KQoyLdGYBC4_GvdKaoJCKhyNjoa8,4975
12
+ agent_loop/providers/claude.py,sha256=ZD5PiXy9_6uDyWtHnBUzK9UTOnZk2wcpEaeFHX7wYwE,515
13
+ agent_loop/providers/codex.py,sha256=ca6RYFWnDLylK6B_4pg6c7Chbs885_I2Dv45NB7wtdU,595
14
+ agent_loop/providers/grok.py,sha256=jWIFHotBbalH9J6BKfs5C1sUdWGZTA9Q-nDlv2gpaYM,444
15
+ agent_loop_tool-0.1.0.dist-info/licenses/LICENSE,sha256=6Q43B85RfGXT4eqpD0BDASjbBba_Ml8HGVgnpOoR2R4,1081
16
+ agent_loop_tool-0.1.0.dist-info/METADATA,sha256=IJkSpsgmwa9qDwBgtz_pJeooclUUMSbgoV9SAh9iw_g,11869
17
+ agent_loop_tool-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
18
+ agent_loop_tool-0.1.0.dist-info/entry_points.txt,sha256=bqHynD6ndjOLDWtUEP_oti6yj5t4TOZRo_oBWx1Ggrc,51
19
+ agent_loop_tool-0.1.0.dist-info/top_level.txt,sha256=eCVBukZEG5MCbqiGDinc9hr6NUsqxFHRwob1Y4rW_3w,11
20
+ agent_loop_tool-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agent-loop = agent_loop.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Dwaraka Ramana Turlapati
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 @@
1
+ agent_loop