the-loopy-one 0.2.1__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.
- the_loopy_one-0.2.1/.gitignore +231 -0
- the_loopy_one-0.2.1/PKG-INFO +151 -0
- the_loopy_one-0.2.1/README.md +125 -0
- the_loopy_one-0.2.1/pyproject.toml +56 -0
- the_loopy_one-0.2.1/tests/fixtures/test_checkout_integration.py +24 -0
- the_loopy_one-0.2.1/tests/test_cli.py +147 -0
- the_loopy_one-0.2.1/tests/test_routing.py +717 -0
- the_loopy_one-0.2.1/tests/test_webhook_routing_integration.py +514 -0
- the_loopy_one-0.2.1/the_loop/__init__.py +7 -0
- the_loopy_one-0.2.1/the_loop/__main__.py +8 -0
- the_loopy_one-0.2.1/the_loop/cli.py +35 -0
- the_loopy_one-0.2.1/the_loop/commands/__init__.py +10 -0
- the_loopy_one-0.2.1/the_loop/commands/base.py +48 -0
- the_loopy_one-0.2.1/the_loop/commands/gh_webhook.py +211 -0
- the_loopy_one-0.2.1/the_loop/commands/scenarios.py +144 -0
- the_loopy_one-0.2.1/the_loop/commands/sessions_cmd.py +153 -0
- the_loopy_one-0.2.1/the_loop/harness/__init__.py +26 -0
- the_loopy_one-0.2.1/the_loop/harness/base.py +140 -0
- the_loopy_one-0.2.1/the_loop/harness/claude_code.py +31 -0
- the_loopy_one-0.2.1/the_loop/harness/cursor_agent.py +33 -0
- the_loopy_one-0.2.1/the_loop/scenarios/__init__.py +167 -0
- the_loopy_one-0.2.1/the_loop/sessions/__init__.py +10 -0
- the_loopy_one-0.2.1/the_loop/sessions/registry.py +236 -0
- the_loopy_one-0.2.1/the_loop/webhook/__init__.py +5 -0
- the_loopy_one-0.2.1/the_loop/webhook/dispatcher.py +383 -0
- the_loopy_one-0.2.1/the_loop/webhook/router.py +183 -0
- the_loopy_one-0.2.1/the_loop/webhook/server.py +115 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
|
|
220
|
+
# the-loop CLI runtime artifacts
|
|
221
|
+
.the-loop/*.pid
|
|
222
|
+
cli/build/
|
|
223
|
+
cli/dist/
|
|
224
|
+
cli/*.egg-info/
|
|
225
|
+
cli/.pytest_cache/
|
|
226
|
+
|
|
227
|
+
# the-loop: not-yet-durable learning candidates (write-gate queue)
|
|
228
|
+
.the-loop/learnings-pending/
|
|
229
|
+
|
|
230
|
+
# the-loop: webhook->session routing registry (runtime state)
|
|
231
|
+
.the-loop/sessions/
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: the-loopy-one
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Summary: Lightweight, extensible CLI for the-loop — quality-of-life commands the the-loop plugin can use (e.g. a GitHub webhook receiver).
|
|
5
|
+
Project-URL: Homepage, https://github.com/MadaraUchiha-314/the-loop
|
|
6
|
+
Project-URL: Repository, https://github.com/MadaraUchiha-314/the-loop
|
|
7
|
+
Project-URL: Issues, https://github.com/MadaraUchiha-314/the-loop/issues
|
|
8
|
+
Author: MadaraUchiha-314
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: cli,pdlc,the-loop,webhook
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Provides-Extra: config
|
|
21
|
+
Requires-Dist: pyyaml>=6; extra == 'config'
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: commitizen>=3; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
|
|
27
|
+
# the-loop CLI
|
|
28
|
+
|
|
29
|
+
A lightweight, **extensible** command-line companion to the the-loop plugin, written in
|
|
30
|
+
Python (stdlib-only core — zero runtime dependencies). Python is intentional: it leaves
|
|
31
|
+
room to add self-learning / ML capabilities later (mostly exposed as Python SDKs).
|
|
32
|
+
|
|
33
|
+
## Install
|
|
34
|
+
|
|
35
|
+
From PyPI (published as **`the-loopy-one`** — the base name `the-loop` was taken; the
|
|
36
|
+
import package and CLI keep the natural `the_loop`/`the-loop`):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install the-loopy-one # or: uv pip install the-loopy-one
|
|
40
|
+
pip install "the-loopy-one[config]" # + PyYAML, for reading .the-loop/config.yaml defaults
|
|
41
|
+
the-loop --help
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
For local development the-loop uses **uv** (its declared Python package manager). From the
|
|
45
|
+
repo root:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
uv sync # installs the workspace (this CLI + dev tooling) from uv.lock
|
|
49
|
+
uv run the-loop --help # run the CLI
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Or install this package on its own with any PEP 517 installer:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
uv pip install -e . # or: pip install -e .
|
|
56
|
+
uv pip install -e ".[config]" # PyYAML, for reading .the-loop/config.yaml defaults
|
|
57
|
+
uv pip install -e ".[dev]" # pytest + commitizen
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
This exposes the primary CLI: `the-loop`. Releases are **automatic**: on merge to `main`,
|
|
61
|
+
`.github/workflows/release.yml` runs `cz bump` to derive the next version from the
|
|
62
|
+
Conventional Commits / PR titles since the last tag (`feat` → minor, `fix` → patch,
|
|
63
|
+
`BREAKING CHANGE` → major), tags it, and publishes to PyPI via Trusted Publishing (OIDC —
|
|
64
|
+
no stored token). Merges with no `feat`/`fix`/breaking change publish nothing. See
|
|
65
|
+
`docs/decisions/decision-019.md`.
|
|
66
|
+
|
|
67
|
+
## Commands
|
|
68
|
+
|
|
69
|
+
### `gh-webhook` — GitHub webhook receiver
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
the-loop gh-webhook start [--host 127.0.0.1] [--port 8787] [--path /gh-webhook] \
|
|
73
|
+
[--pidfile .the-loop/gh-webhook.pid] \
|
|
74
|
+
[--secret-env THE_LOOP_GH_WEBHOOK_SECRET] \
|
|
75
|
+
[--route | --no-route]
|
|
76
|
+
the-loop gh-webhook stop [--pidfile .the-loop/gh-webhook.pid]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- Verifies the GitHub `X-Hub-Signature-256` HMAC when the secret env var is set
|
|
80
|
+
(export `THE_LOOP_GH_WEBHOOK_SECRET=...`). The secret is read from the environment,
|
|
81
|
+
never a flag, so it doesn't leak into process listings.
|
|
82
|
+
- `GET /health` returns `200 ok`.
|
|
83
|
+
- Defaults can come from `.the-loop/config.yaml` (`webhooks.ghWebhook`) when PyYAML is
|
|
84
|
+
installed; flags always override.
|
|
85
|
+
- **`--route`** (default from `webhooks.ghWebhook.routing.enabled`) routes each verified
|
|
86
|
+
event to the registered harness session working that item: the router extracts the
|
|
87
|
+
work item(s) from the payload (issue/PR number, PR head-branch `issue-<n>` convention,
|
|
88
|
+
closing keywords, `workflow_run`/`check_*` PRs), deduplicates on `X-GitHub-Delivery`,
|
|
89
|
+
and the dispatcher resumes the matched session via its official CLI
|
|
90
|
+
(`claude -p … --resume <session-id>` / `cursor-agent -p … --resume <chat-id>`), one
|
|
91
|
+
event at a time per session, in parallel across sessions. Unmatched events follow
|
|
92
|
+
`routing.spawnOnUnmatched` (`never` drops; `always` spawns + registers a session).
|
|
93
|
+
Design: `docs/specs/issue-15/design.md`, `docs/decisions/decision-016.md`.
|
|
94
|
+
|
|
95
|
+
### `sessions` — link work items to harness sessions (webhook routing)
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
the-loop sessions register --work-item github:OWNER/REPO#N --harness claude \
|
|
99
|
+
--harness-session-id "$CLAUDE_SESSION_ID" [--cwd .] [--force]
|
|
100
|
+
the-loop sessions list [--status active|closed] [--format table|json]
|
|
101
|
+
the-loop sessions close --work-item github:OWNER/REPO#N
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- The registry lives in `webhooks.ghWebhook.routing.registryDir` (default
|
|
105
|
+
`.the-loop/sessions/`, git-ignored) as one human-inspectable JSON file per session;
|
|
106
|
+
writes are atomic, so concurrent sessions on the same machine are safe.
|
|
107
|
+
- One work item ↔ one active session; `--force` replaces a stale registration.
|
|
108
|
+
- Claude Code sessions register with `$CLAUDE_SESSION_ID`; Cursor sessions register
|
|
109
|
+
with the chat id they were launched with (non-interactive `cursor-agent ls` is
|
|
110
|
+
unreliable for id discovery, so the id is captured at registration time).
|
|
111
|
+
- When a work item's PR is merged or closed, the receiver **auto-closes** the session
|
|
112
|
+
(on the `pull_request` `closed` event) — no manual `sessions close` needed.
|
|
113
|
+
|
|
114
|
+
**Label-gated auto-execution** (`spawnOnUnmatched: labeled`): give an issue/PR the
|
|
115
|
+
configurable `routing.autoExecuteLabel` (default `the-loop: auto-execute`) and the
|
|
116
|
+
receiver spawns a session and starts `/the-loop:work-on` on it — then routes that item's
|
|
117
|
+
later activity (comments, reviews, CI, its linked PR) to the same session, and
|
|
118
|
+
auto-closes on PR merge. Label presence is read straight from the webhook payload (no
|
|
119
|
+
extra API call). A new issue *without* the label is received and ignored.
|
|
120
|
+
|
|
121
|
+
### `scenarios` — query the Gherkin scenarios integration tests cover
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
the-loop scenarios [--root .] [--glob PATTERN ...] [--format table|markdown|json]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- Scans integration-test files for the Gherkin-syntax docstrings the-loop requires
|
|
128
|
+
(`Feature:` / `Scenario:` / Given-When-Then, plus an optional `Requirement:` link to a
|
|
129
|
+
`requirements.md`) and presents them as a table — so a coding-agent harness can answer
|
|
130
|
+
"what scenarios are tested?" without running anything.
|
|
131
|
+
- Language-agnostic: Python docstrings, JS/TS block comments and Go comments all work.
|
|
132
|
+
- Globs come from `--glob` (repeatable), else `testing.integrationTestGlobs` in
|
|
133
|
+
`.the-loop/config.yaml` (when PyYAML is installed), else built-in defaults covering
|
|
134
|
+
common layouts.
|
|
135
|
+
- `--format markdown` emits a GitHub-flavoured table (for PR briefings); `--format json`
|
|
136
|
+
is machine-readable (includes each scenario's steps and `file:line`).
|
|
137
|
+
|
|
138
|
+
## Adding a command (extensibility)
|
|
139
|
+
|
|
140
|
+
1. Create `the_loop/commands/<your_command>.py`.
|
|
141
|
+
2. Subclass `Command`, set `name`/`help`, implement `add_arguments` and `run`, and
|
|
142
|
+
decorate the class with `@register`.
|
|
143
|
+
3. Import the module in `the_loop/commands/__init__.py`.
|
|
144
|
+
|
|
145
|
+
The CLI discovers registered commands automatically.
|
|
146
|
+
|
|
147
|
+
## Test
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
pytest # from this directory
|
|
151
|
+
```
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# the-loop CLI
|
|
2
|
+
|
|
3
|
+
A lightweight, **extensible** command-line companion to the the-loop plugin, written in
|
|
4
|
+
Python (stdlib-only core — zero runtime dependencies). Python is intentional: it leaves
|
|
5
|
+
room to add self-learning / ML capabilities later (mostly exposed as Python SDKs).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
From PyPI (published as **`the-loopy-one`** — the base name `the-loop` was taken; the
|
|
10
|
+
import package and CLI keep the natural `the_loop`/`the-loop`):
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install the-loopy-one # or: uv pip install the-loopy-one
|
|
14
|
+
pip install "the-loopy-one[config]" # + PyYAML, for reading .the-loop/config.yaml defaults
|
|
15
|
+
the-loop --help
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For local development the-loop uses **uv** (its declared Python package manager). From the
|
|
19
|
+
repo root:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv sync # installs the workspace (this CLI + dev tooling) from uv.lock
|
|
23
|
+
uv run the-loop --help # run the CLI
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or install this package on its own with any PEP 517 installer:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv pip install -e . # or: pip install -e .
|
|
30
|
+
uv pip install -e ".[config]" # PyYAML, for reading .the-loop/config.yaml defaults
|
|
31
|
+
uv pip install -e ".[dev]" # pytest + commitizen
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This exposes the primary CLI: `the-loop`. Releases are **automatic**: on merge to `main`,
|
|
35
|
+
`.github/workflows/release.yml` runs `cz bump` to derive the next version from the
|
|
36
|
+
Conventional Commits / PR titles since the last tag (`feat` → minor, `fix` → patch,
|
|
37
|
+
`BREAKING CHANGE` → major), tags it, and publishes to PyPI via Trusted Publishing (OIDC —
|
|
38
|
+
no stored token). Merges with no `feat`/`fix`/breaking change publish nothing. See
|
|
39
|
+
`docs/decisions/decision-019.md`.
|
|
40
|
+
|
|
41
|
+
## Commands
|
|
42
|
+
|
|
43
|
+
### `gh-webhook` — GitHub webhook receiver
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
the-loop gh-webhook start [--host 127.0.0.1] [--port 8787] [--path /gh-webhook] \
|
|
47
|
+
[--pidfile .the-loop/gh-webhook.pid] \
|
|
48
|
+
[--secret-env THE_LOOP_GH_WEBHOOK_SECRET] \
|
|
49
|
+
[--route | --no-route]
|
|
50
|
+
the-loop gh-webhook stop [--pidfile .the-loop/gh-webhook.pid]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- Verifies the GitHub `X-Hub-Signature-256` HMAC when the secret env var is set
|
|
54
|
+
(export `THE_LOOP_GH_WEBHOOK_SECRET=...`). The secret is read from the environment,
|
|
55
|
+
never a flag, so it doesn't leak into process listings.
|
|
56
|
+
- `GET /health` returns `200 ok`.
|
|
57
|
+
- Defaults can come from `.the-loop/config.yaml` (`webhooks.ghWebhook`) when PyYAML is
|
|
58
|
+
installed; flags always override.
|
|
59
|
+
- **`--route`** (default from `webhooks.ghWebhook.routing.enabled`) routes each verified
|
|
60
|
+
event to the registered harness session working that item: the router extracts the
|
|
61
|
+
work item(s) from the payload (issue/PR number, PR head-branch `issue-<n>` convention,
|
|
62
|
+
closing keywords, `workflow_run`/`check_*` PRs), deduplicates on `X-GitHub-Delivery`,
|
|
63
|
+
and the dispatcher resumes the matched session via its official CLI
|
|
64
|
+
(`claude -p … --resume <session-id>` / `cursor-agent -p … --resume <chat-id>`), one
|
|
65
|
+
event at a time per session, in parallel across sessions. Unmatched events follow
|
|
66
|
+
`routing.spawnOnUnmatched` (`never` drops; `always` spawns + registers a session).
|
|
67
|
+
Design: `docs/specs/issue-15/design.md`, `docs/decisions/decision-016.md`.
|
|
68
|
+
|
|
69
|
+
### `sessions` — link work items to harness sessions (webhook routing)
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
the-loop sessions register --work-item github:OWNER/REPO#N --harness claude \
|
|
73
|
+
--harness-session-id "$CLAUDE_SESSION_ID" [--cwd .] [--force]
|
|
74
|
+
the-loop sessions list [--status active|closed] [--format table|json]
|
|
75
|
+
the-loop sessions close --work-item github:OWNER/REPO#N
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- The registry lives in `webhooks.ghWebhook.routing.registryDir` (default
|
|
79
|
+
`.the-loop/sessions/`, git-ignored) as one human-inspectable JSON file per session;
|
|
80
|
+
writes are atomic, so concurrent sessions on the same machine are safe.
|
|
81
|
+
- One work item ↔ one active session; `--force` replaces a stale registration.
|
|
82
|
+
- Claude Code sessions register with `$CLAUDE_SESSION_ID`; Cursor sessions register
|
|
83
|
+
with the chat id they were launched with (non-interactive `cursor-agent ls` is
|
|
84
|
+
unreliable for id discovery, so the id is captured at registration time).
|
|
85
|
+
- When a work item's PR is merged or closed, the receiver **auto-closes** the session
|
|
86
|
+
(on the `pull_request` `closed` event) — no manual `sessions close` needed.
|
|
87
|
+
|
|
88
|
+
**Label-gated auto-execution** (`spawnOnUnmatched: labeled`): give an issue/PR the
|
|
89
|
+
configurable `routing.autoExecuteLabel` (default `the-loop: auto-execute`) and the
|
|
90
|
+
receiver spawns a session and starts `/the-loop:work-on` on it — then routes that item's
|
|
91
|
+
later activity (comments, reviews, CI, its linked PR) to the same session, and
|
|
92
|
+
auto-closes on PR merge. Label presence is read straight from the webhook payload (no
|
|
93
|
+
extra API call). A new issue *without* the label is received and ignored.
|
|
94
|
+
|
|
95
|
+
### `scenarios` — query the Gherkin scenarios integration tests cover
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
the-loop scenarios [--root .] [--glob PATTERN ...] [--format table|markdown|json]
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
- Scans integration-test files for the Gherkin-syntax docstrings the-loop requires
|
|
102
|
+
(`Feature:` / `Scenario:` / Given-When-Then, plus an optional `Requirement:` link to a
|
|
103
|
+
`requirements.md`) and presents them as a table — so a coding-agent harness can answer
|
|
104
|
+
"what scenarios are tested?" without running anything.
|
|
105
|
+
- Language-agnostic: Python docstrings, JS/TS block comments and Go comments all work.
|
|
106
|
+
- Globs come from `--glob` (repeatable), else `testing.integrationTestGlobs` in
|
|
107
|
+
`.the-loop/config.yaml` (when PyYAML is installed), else built-in defaults covering
|
|
108
|
+
common layouts.
|
|
109
|
+
- `--format markdown` emits a GitHub-flavoured table (for PR briefings); `--format json`
|
|
110
|
+
is machine-readable (includes each scenario's steps and `file:line`).
|
|
111
|
+
|
|
112
|
+
## Adding a command (extensibility)
|
|
113
|
+
|
|
114
|
+
1. Create `the_loop/commands/<your_command>.py`.
|
|
115
|
+
2. Subclass `Command`, set `name`/`help`, implement `add_arguments` and `run`, and
|
|
116
|
+
decorate the class with `@register`.
|
|
117
|
+
3. Import the module in `the_loop/commands/__init__.py`.
|
|
118
|
+
|
|
119
|
+
The CLI discovers registered commands automatically.
|
|
120
|
+
|
|
121
|
+
## Test
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pytest # from this directory
|
|
125
|
+
```
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Three distinct names, deliberately (see docs/decisions/decision-019.md):
|
|
2
|
+
# - distribution (PyPI) name : the-loopy-one -> `pip install the-loopy-one`
|
|
3
|
+
# - import package name : the_loop -> `import the_loop`
|
|
4
|
+
# - console script name : the-loop -> `the-loop --help`
|
|
5
|
+
# The base name `the-loop` was unavailable on PyPI, so the distribution is published as
|
|
6
|
+
# `the-loopy-one`; the import package and CLI keep the natural `the_loop`/`the-loop`.
|
|
7
|
+
[project]
|
|
8
|
+
name = "the-loopy-one"
|
|
9
|
+
version = "0.2.1"
|
|
10
|
+
description = "Lightweight, extensible CLI for the-loop — quality-of-life commands the the-loop plugin can use (e.g. a GitHub webhook receiver)."
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
requires-python = ">=3.9"
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
authors = [{ name = "MadaraUchiha-314" }]
|
|
15
|
+
keywords = ["the-loop", "cli", "webhook", "pdlc"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Operating System :: OS Independent",
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
24
|
+
"Topic :: Software Development :: Build Tools",
|
|
25
|
+
]
|
|
26
|
+
# Core CLI has ZERO runtime dependencies (stdlib only) to stay very lightweight.
|
|
27
|
+
dependencies = []
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
# Optional: richer config-file parsing. The CLI works without it (flags + env).
|
|
31
|
+
config = ["pyyaml>=6"]
|
|
32
|
+
dev = ["pytest>=8", "commitizen>=3"]
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
the-loop = "the_loop.__main__:main"
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/MadaraUchiha-314/the-loop"
|
|
39
|
+
Repository = "https://github.com/MadaraUchiha-314/the-loop"
|
|
40
|
+
Issues = "https://github.com/MadaraUchiha-314/the-loop/issues"
|
|
41
|
+
|
|
42
|
+
[build-system]
|
|
43
|
+
requires = ["hatchling"]
|
|
44
|
+
build-backend = "hatchling.build"
|
|
45
|
+
|
|
46
|
+
[tool.hatch.build.targets.wheel]
|
|
47
|
+
packages = ["the_loop"]
|
|
48
|
+
|
|
49
|
+
[tool.ruff]
|
|
50
|
+
line-length = 88
|
|
51
|
+
target-version = "py39"
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
# Let `pytest` find the package without an editable install (run from cli/).
|
|
55
|
+
pythonpath = ["."]
|
|
56
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Fixture integration test used by the scenarios-extractor tests.
|
|
2
|
+
|
|
3
|
+
Feature: Checkout pricing
|
|
4
|
+
Requirement: docs/specs/issue-11/requirements.md#R2
|
|
5
|
+
|
|
6
|
+
Scenario: Cart total includes regional tax
|
|
7
|
+
Given a cart with one $10.00 item
|
|
8
|
+
When the cart is priced in a 10% tax region
|
|
9
|
+
Then the order total is $11.00
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def test_cart_total_includes_regional_tax():
|
|
14
|
+
assert 10.00 * 1.10 == 11.0
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def test_free_shipping_over_threshold():
|
|
18
|
+
"""
|
|
19
|
+
Scenario: Free shipping over the threshold
|
|
20
|
+
Given a cart subtotal of $60.00
|
|
21
|
+
When the free-shipping threshold is $50.00
|
|
22
|
+
Then shipping is $0.00
|
|
23
|
+
"""
|
|
24
|
+
assert True
|