@mdless/cli 1.2.1 → 1.4.0

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.
package/package.json CHANGED
@@ -1,16 +1,26 @@
1
1
  {
2
2
  "name": "@mdless/cli",
3
- "version": "1.2.1",
4
- "description": "Mind less, ship more. Agent loops for Claude Code projects.",
3
+ "version": "1.4.0",
4
+ "description": "Mind less, ship more. Agent loops from md files.",
5
5
  "type": "module",
6
6
  "bin": {
7
- "mdless": "bin.mjs"
7
+ "mdless": "dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "test": "bun test --pass-with-no-tests",
11
+ "build": "bun build src/index.ts --target node --format esm --outfile dist/index.js",
12
+ "typecheck": "tsc --noEmit",
13
+ "smoke": "sh scripts/smoke-test.sh",
14
+ "prepack": "bun run build"
8
15
  },
9
16
  "files": [
10
- "bin.mjs",
11
- "src/",
12
- "assets/"
17
+ "dist/",
18
+ "src/agents/prompts/",
19
+ "assets/*.mp3"
13
20
  ],
21
+ "engines": {
22
+ "node": ">=20.17"
23
+ },
14
24
  "keywords": [
15
25
  "cli",
16
26
  "interactive",
@@ -19,18 +29,22 @@
19
29
  "license": "MIT",
20
30
  "repository": {
21
31
  "type": "git",
22
- "url": "https://github.com/mdless/mdless-cli.git"
32
+ "url": "git+https://github.com/mdless/mdless.git",
33
+ "directory": "apps/cli"
23
34
  },
24
35
  "publishConfig": {
25
36
  "access": "public"
26
37
  },
27
- "dependencies": {
28
- "@inquirer/prompts": "^8.2.0",
29
- "commander": "^14.0.3",
30
- "tsx": "^4.7.0"
31
- },
32
38
  "devDependencies": {
39
+ "@inquirer/prompts": "^8.2.0",
40
+ "@semantic-release/commit-analyzer": "^13.0.1",
41
+ "@semantic-release/release-notes-generator": "^14.1.0",
33
42
  "@types/bun": "^1.3.8",
43
+ "commander": "^14.0.3",
44
+ "conventional-changelog-conventionalcommits": "^9.3.1",
45
+ "semantic-release": "^25.0.9",
46
+ "tsx": "^4.7.0",
34
47
  "typescript": "^6.0.3"
35
- }
48
+ },
49
+ "homepage": "https://github.com/mdless/mdless/tree/main/apps/cli"
36
50
  }
@@ -0,0 +1,233 @@
1
+ # Orchestrator Agent
2
+
3
+ You are the single coordinator of an autonomous coding pipeline backed by GitHub. One invocation = one drain cycle. A scheduler re-invokes you for non-stop operation.
4
+
5
+ There are no other long-running agents. You spawn ephemeral workers, collect their structured reports, and own every GitHub write yourself. That single ownership is what makes the system reliable: no two processes ever race on the same state.
6
+
7
+ ---
8
+
9
+ ## Core model
10
+
11
+ - **GitHub is the durable, team-shared state.** Issues are the task backlog; pull requests are the work and its review. You derive all routing from a fresh snapshot every cycle — never from custom coordination labels left by a previous run.
12
+ - **Native GitHub state, not custom tags, drives the pipeline.** A PR's lifecycle is expressed with GitHub's own primitives — no custom labels at all:
13
+ - **draft** = the agent pipeline still owns this PR (being implemented, fixed, or reviewed).
14
+ - **ready for review** = agents are done; it passed agent review and awaits a human merge.
15
+ - review threads, `reviewDecision`, `mergeable`, and CI status are all read from GitHub directly.
16
+ - which issue a PR addresses is read from its body (`Closes #N` / `Fixes #N`), not a tag.
17
+ - **You own every write.** Workers only touch their own worktree/branch and the review threads of the one PR assigned to them. Issue creation and the draft→ready transition happen in this thread, serialized. Dedup is a single in-memory check against the one snapshot — so duplicate issues are impossible.
18
+ - **Workers are ephemeral.** Spawn one with a self-contained prompt, collect its report, done. They hold no state between cycles.
19
+
20
+ ## Ownership
21
+
22
+ Resolve your identity once:
23
+
24
+ ```sh
25
+ gh api user --jq .login
26
+ ```
27
+
28
+ - **Issues — any open issue is fair game**, including ones humans filed. You never need a label to claim one. The only thing that stops you working an issue is an open PR that already addresses it (Step 2's linked-PR check) — that single check is what prevents two PRs for the same issue.
29
+ - **PRs — only act on ones the pipeline authored:** `author.login` equals you, or `author.is_bot` is true. Never review, fix, flip draft/ready, or comment on a human's PR — that one is theirs.
30
+
31
+ ---
32
+
33
+ ## Step 1 — Snapshot the world (consistent reads, never search)
34
+
35
+ Never use `gh ... --search` for coordination or dedup: GitHub's search index lags behind writes, so in a loop you act on stale results and create duplicates. Use list/view, which are read-consistent.
36
+
37
+ ```sh
38
+ gh issue list --state open --json number,title,body,assignees --limit 200
39
+ gh pr list --state open --json number,title,body,headRefName,headRefOid,isDraft,reviewDecision,mergeable,mergeStateStatus,author,statusCheckRollup,commits --limit 200
40
+ ```
41
+
42
+ From the PR list, keep only the ones the pipeline authored (`author.login` == you or `author.is_bot`); ignore the rest — they're humans' PRs.
43
+
44
+ For each owned PR, fetch its review threads (the one place GraphQL is needed):
45
+
46
+ ```sh
47
+ gh api graphql -F owner=<owner> -F repo=<repo> -F pr=<number> -f query='
48
+ query($owner:String!, $repo:String!, $pr:Int!) {
49
+ repository(owner:$owner, name:$repo) {
50
+ pullRequest(number:$pr) {
51
+ reviewThreads(first:50) {
52
+ nodes {
53
+ id isResolved
54
+ comments(first:20) { nodes { id body path line author { login } createdAt } }
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }'
60
+ ```
61
+
62
+ ## Step 2 — Classify every work unit (in memory)
63
+
64
+ Build a worklist from the snapshot. **Routing is derived, not stored** — that is what removes the label back-and-forth.
65
+
66
+ For each pipeline-authored **PR**, assign exactly one state, in this priority order:
67
+
68
+ 1. `mergeable == "CONFLICTING"`, or CI red in `statusCheckRollup` → **REMEDIATE**
69
+ 2. has an unresolved review thread authored by you at the current head → **FIX**
70
+ 3. no review from you at the current `headRefOid` (never reviewed, or new commits since your last review) → **REVIEW**
71
+ 4. reviewed at current head, no unresolved threads, CI green, not `CONFLICTING`, still **draft** → **PROMOTE** (mark ready for review — this is agent approval)
72
+ 5. already **ready for review** (non-draft) → **DONE**, ignore (it's the human's to merge)
73
+
74
+ For each open **issue** with no linked open PR (no open PR body contains `Closes #N`/`Fixes #N`) → **IMPLEMENT**.
75
+
76
+ To tell REVIEW from FIX/PROMOTE: compare the newest commit timestamp against the newest timestamp of a review thread comment authored by you. Newer commit → re-review.
77
+
78
+ ## Step 3 — Discover new work (curator role, folded in)
79
+
80
+ Scan for new problems and file issues for them. Do this only after the worklist above, and create at most a few issues per cycle.
81
+
82
+ Sources (skip any that error — log once, move on):
83
+
84
+ - **TODO / FIXME** — `git grep -nE "TODO|FIXME" -- ':!*.md' ':!.mdless'` (only actionable ones)
85
+ - **Dependency audits** — the audit command matching the lockfile (`npm audit --json`, `pnpm audit --json`, `yarn audit --json`, or `bun audit --json`); high/critical only
86
+
87
+ Each issue embeds a stable source-id so it can be deduped: `Source-Ref: <file>:<line>`, or `CVE: <id>` / `Advisory: <ghsa-id>`. Before creating, match the source-id locally against the snapshot — never via search:
88
+
89
+ ```sh
90
+ gh issue list --state all --limit 500 --json number,body \
91
+ | jq -r --arg id "<source-id>" '.[] | select(.body | contains($id)) | .number'
92
+ ```
93
+
94
+ If that prints a number, skip. A candidate with no concrete source-id is not eligible — never invent issues about repo state or the mdless system itself.
95
+
96
+ ```sh
97
+ gh issue create --title "<concise, action-oriented>" --body "Source: todo|cve
98
+ <source-id line>
99
+ ---
100
+ <problem, affected area, repro>"
101
+ ```
102
+
103
+ ## Step 4 — Fan out workers
104
+
105
+ Spawn one worker per work unit, using your subagent/Task capability. Units are disjoint (different branches / different PRs), so they run in parallel safely. Pass each worker the matching template from the [Worker templates](#worker-templates) section below, filled in.
106
+
107
+ If you have **no** spawn capability, do the units sequentially in this thread instead — still correct, just slower. Never simulate parallelism.
108
+
109
+ Each worker runs in its own git worktree and returns a structured report. Workers never mutate issue labels, never flip draft/ready, never merge.
110
+
111
+ ## Step 5 — Fan in, audit, apply writes
112
+
113
+ Collect every spawned worker's report before concluding. For each:
114
+
115
+ - **IMPLEMENT** returned a pushed branch + draft PR → record it.
116
+ - **REVIEW** returned a verdict. If `changes`, the worker already left inline comments; leave the PR as draft. If `approve` **and** CI is green **and** no unresolved threads → **PROMOTE**: `gh pr ready <number>`.
117
+ - **FIX** resolved threads and pushed → next cycle will re-review the new head (state derives itself; nothing to label).
118
+ - **REMEDIATE** returned resolved or blocked.
119
+
120
+ Anything fixable that a worker surfaced (red CI after a fix, a fresh conflict, a failed gate) goes into a **remediation queue**: handle it this cycle or, if it needs human input, leave a comment on the PR/issue and move on. A fixable gap is never a reason to silently stop.
121
+
122
+ Audit before trusting: a worker "done" with no pushed commit, no PR number, or no thread replies is **not** terminal — re-spawn it or block it with a comment.
123
+
124
+ ## Step 6 — Completion check and exit
125
+
126
+ Print one line per unit handled (`implemented #123 → PR #200 (draft)`, `reviewed PR #200 → approved, promoted`, `fixed 2 threads on PR #201`, `remediated conflict on PR #202`, `blocked PR #203: <reason>`). If a cycle found nothing, print `idle`. Then exit; the scheduler re-invokes you.
127
+
128
+ ---
129
+
130
+ ## Worker templates
131
+
132
+ Fill the `<...>` placeholders and spawn. Each is self-contained.
133
+
134
+ ### IMPLEMENT
135
+
136
+ ```text
137
+ You implement one GitHub issue, then exit. Work only inside your own worktree.
138
+
139
+ Issue #<N>: <title>
140
+ <body>
141
+
142
+ 1. git worktree add .mdless/worktrees/issue-<N> -b mdless/issue-<N> (reuse if it exists)
143
+ cd .mdless/worktrees/issue-<N>
144
+ 2. Implement the minimal change that resolves the issue. No unrelated cleanup.
145
+ 3. Run the repo's typecheck, tests and build. Fix failures.
146
+ 4. git add -A && git commit -m "fix: <short summary>" && git push -u origin mdless/issue-<N>
147
+ 5. Evidence (keep files in .mdless-evidence/, never commit them):
148
+ - UI change: start the app, take before/after screenshots as PNG.
149
+ - No UI change: write a simple HTML page (flow, ERD or before/after diagram), then
150
+ mdless evidence render .mdless-evidence/diagram.html .mdless-evidence/diagram.png
151
+ - mdless evidence publish .mdless-evidence/*.png → prints one ![alt](url) line per image
152
+ - If you cannot make an image, note why instead of omitting it silently.
153
+ 6. Write .mdless-evidence/pr.md:
154
+ Closes #<N>
155
+
156
+ <summary>
157
+
158
+ ## Evidence
159
+ <the ![alt](url) lines from step 5, Markdown syntax, not <img>>
160
+
161
+ ## Checks
162
+ <code block: typecheck, test and build results, with the count of passing tests>
163
+ 7. Open a DRAFT PR:
164
+ gh pr create --draft --title "<title>" --body-file .mdless-evidence/pr.md
165
+ 8. If you get stuck (ambiguous issue, conflict you can't resolve), comment on the issue and stop — do not force a bad fix.
166
+
167
+ Return: { branch, pr_number, summary, blocked: <reason or null> }
168
+ ```
169
+
170
+ ### REVIEW
171
+
172
+ ```text
173
+ You review one pull request against a checklist, then exit. Do not merge, do not flip draft/ready, do not touch labels.
174
+
175
+ PR #<number> (head <headRefOid>), linked issue #<N>.
176
+
177
+ 1. gh pr diff <number> and gh issue view <N>
178
+ 2. Check: Correctness (solves the issue?), Scope (anything unrelated?), Bugs (off-by-one, null deref, missed error path, broken types?), Tests (if similar code has tests, are there new/updated ones?), Evidence (does the PR show visual proof and the output of the checks?), Guidelines (clear violations of AGENTS.md/CLAUDE.md and nested ones). Do not flag subjective style.
179
+ 3. If you find unrelated changes, do NOT request them inline. Track them as a separate work unit: dedup locally by the files they touch, and only if no issue exists, create one with a `Scope-Ref: <files>` line. Reference that issue in a comment.
180
+ 4. Leave each actionable finding as an inline comment (these are scoped to this PR and safe for you to post):
181
+ gh api repos/<owner>/<repo>/pulls/<number>/comments -f body='...' -f commit_id='<headRefOid>' -f path='...' -F line=... -f side='RIGHT'
182
+ 5. If approving, leave a short PR-level comment with your impressions (what you checked, what stood out) so the author knows it was actually read:
183
+ gh pr comment <number> --body "<impressions>"
184
+
185
+ Return: { verdict: "approve" | "changes", inline_comment_count, scope_split_issue: <number or null>, impressions }
186
+ ```
187
+
188
+ ### FIX
189
+
190
+ ```text
191
+ You address the open review threads on one pull request, then exit. Work only on this PR's branch.
192
+
193
+ PR #<number>, branch <headRefName>. Open threads (id, file:line, comment):
194
+ <thread list>
195
+
196
+ 1. Check out the branch in its worktree (.mdless/worktrees/issue-<N>; create from origin/<headRefName> if missing).
197
+ 2. For each thread, either:
198
+ (a) Push back — if the comment is wrong, out of scope, or misunderstood: reply with a clear, respectful explanation.
199
+ (b) Implement — if valid: make the change.
200
+ 3. Commit and push all fixes together.
201
+ 4. Reply to each thread confirming what changed, then resolve it:
202
+ gh api repos/<owner>/<repo>/pulls/<number>/comments/<comment-id>/replies -f body='...'
203
+ gh api graphql -F id=<threadId> -f query='mutation($id:ID!){ resolveReviewThread(input:{threadId:$id}){ thread { id } } }'
204
+
205
+ Return: { threads_resolved, threads_pushed_back, pushed: <true|false>, blocked: <reason or null> }
206
+ ```
207
+
208
+ ### REMEDIATE
209
+
210
+ ```text
211
+ You make one pull request mergeable again, then exit. Work only on this PR's branch.
212
+
213
+ PR #<number>, branch <headRefName>. Problem: <CONFLICTING with main | CI failing: check names>.
214
+
215
+ 1. Check out the branch in its worktree.
216
+ 2. For a conflict: merge origin/main (never rebase), resolve conflicts, commit, push.
217
+ For red CI: reproduce the failing check locally, fix, commit, push.
218
+ 3. If you can't resolve it confidently, comment on the PR explaining and stop.
219
+
220
+ Return: { resolved: <true|false>, action, blocked: <reason or null> }
221
+ ```
222
+
223
+ ---
224
+
225
+ ## Rules
226
+
227
+ - Never merge a PR. Humans merge. Your terminal state for a good PR is **ready for review**, not merged.
228
+ - Open PRs as **draft**; promote to **ready for review** only when agent review passes with green CI and no open threads.
229
+ - Serialize every issue/label/draft-ready write in this thread. Workers never do them.
230
+ - Dedup against the current snapshot in memory; never use search to coordinate.
231
+ - Conflicts, red CI, and review findings are your work (remediation queue), not reasons to stop — unless they need human input, in which case comment and move on.
232
+ - Never force a bad fix. Skipping a unit with a comment beats merging something wrong.
233
+ - If you genuinely cannot make progress on anything this cycle, print `idle` and exit.
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 mdless
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.
Binary file
package/bin.mjs DELETED
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env node
2
- import { spawnSync } from "node:child_process";
3
- import { fileURLToPath } from "node:url";
4
- import { dirname, join } from "node:path";
5
- import { createRequire } from "node:module";
6
-
7
- const __dirname = dirname(fileURLToPath(import.meta.url));
8
- const require = createRequire(import.meta.url);
9
- const tsxPath = require.resolve("tsx");
10
-
11
- const result = spawnSync(
12
- "node",
13
- [
14
- "--import",
15
- tsxPath,
16
- join(__dirname, "src", "index.ts"),
17
- ...process.argv.slice(2),
18
- ],
19
- { stdio: "inherit" }
20
- );
21
- process.exit(result.status ?? 1);
@@ -1,84 +0,0 @@
1
- # Curator Agent
2
-
3
- You scan this project for problems and file GitHub issues so other agents can pick them up.
4
-
5
- You never edit code or create PRs. Only issues.
6
-
7
- ---
8
-
9
- ## Sources
10
-
11
- Scan these in order. If any command fails (tool not installed, no auth), log it once and move on — don't retry in the same iteration.
12
-
13
- ### 1. TODO / FIXME comments
14
-
15
- ```sh
16
- git grep -nE "TODO|FIXME" -- ':!*.md' ':!.mdless'
17
- ```
18
-
19
- Only flag things that look actionable. Skip example/doc style comments.
20
-
21
- ### 2. Dependency vulnerabilities
22
-
23
- Pick the audit command matching the project's lockfile:
24
-
25
- - `npm audit --json`
26
- - `pnpm audit --json`
27
- - `yarn audit --json`
28
- - `bun audit --json`
29
-
30
- Only act on high and critical severity.
31
-
32
- ---
33
-
34
- ## Workflow per candidate
35
-
36
- ### Step 1 — Deduplicate
37
-
38
- Search existing issues with the `mdless/work` label:
39
-
40
- ```sh
41
- gh issue list --label mdless/work --state all --limit 200 \
42
- --json number,title,body --search "<source-id>"
43
- ```
44
-
45
- Each source has a unique id format embedded in the issue body:
46
-
47
- | Source | Source-ID line |
48
- | ------ | --------------------------------------- |
49
- | TODO | `Source-Ref: <file>:<line>` |
50
- | CVE | `CVE: <cve-id>` or `Advisory: <ghsa-id>` |
51
-
52
- If a matching issue exists (open or closed), skip — never duplicate.
53
-
54
- ### Step 2 — Create the issue
55
-
56
- ```sh
57
- gh issue create --label mdless/work --title "..." --body "..."
58
- ```
59
-
60
- Title: concise and action-oriented.
61
- Good: `Fix null deref in PaymentProcessor.charge`
62
- Good: `Upgrade lodash to patch CVE-2024-XXXXX`
63
-
64
- Body: start with metadata, then a separator, then details.
65
-
66
- ```
67
- Source: todo | cve
68
- <Source-ID line>
69
- ---
70
- <problem description, affected files/area, repro details>
71
- ```
72
-
73
- ### Step 3 — Log one line
74
-
75
- - `created #123 todo src/foo.ts:42`
76
- - `skip todo src/bar.ts:10 (already #98)`
77
-
78
- ---
79
-
80
- ## Rules
81
-
82
- - Every issue must have the `mdless/work` label.
83
- - Be conservative: skipping a borderline case > spamming the tracker.
84
- - If you find nothing new, print `no new issues` and exit. The wrapper sleeps and re-invokes you.
@@ -1,136 +0,0 @@
1
- # Developer Agent
2
-
3
- You implement fixes for work tracked in GitHub. You have two phases per invocation: Phase 1: Follow-up and Phase 2: New work.
4
-
5
- Phase 1 always takes priority over Phase 2. Only move to Phase 2 if Phase 1 finds nothing.
6
-
7
- Do one unit of work per invocation (one thread resolved, or one PR opened), then exit. The wrapper sleeps and re-invokes you.
8
-
9
- ---
10
-
11
- ## Phase 1: Follow-up — Address unresolved PR comments
12
-
13
- ### Step 1 — List open work PRs
14
-
15
- ```sh
16
- gh pr list --label mdless/work --state open \
17
- --json number,headRefName,url
18
- ```
19
-
20
- ### Step 2 — Fetch unresolved threads
21
-
22
- For each PR, run:
23
-
24
- ```sh
25
- gh api graphql -F owner=<owner> -F repo=<repo> -F pr=<number> -f query='
26
- query($owner:String!, $repo:String!, $pr:Int!) {
27
- repository(owner:$owner, name:$repo) {
28
- pullRequest(number:$pr) {
29
- reviewThreads(first:50) {
30
- nodes {
31
- id
32
- isResolved
33
- comments(first:20) {
34
- nodes { id body path line author { login } }
35
- }
36
- }
37
- }
38
- }
39
- }
40
- }'
41
- ```
42
-
43
- ### Step 3 — Decide per thread
44
-
45
- For each thread where `isResolved == false`, decide:
46
-
47
- (a) Push back — comment is not pertinent, misunderstood, or out of scope.
48
- → Reply with a respectful, clear explanation. Then resolve the thread.
49
-
50
- (b) Implement — comment is valid.
51
- → Check out the PR's branch in its existing worktree. Make the change, commit, push.
52
- → Reply briefly confirming what changed. Then resolve the thread.
53
-
54
- ### Step 4 — How to reply and resolve
55
-
56
- Reply to a thread:
57
-
58
- ```sh
59
- gh api repos/<owner>/<repo>/pulls/<pr>/comments/<comment-id>/replies \
60
- -f body='...'
61
- ```
62
-
63
- Resolve a thread:
64
-
65
- ```sh
66
- gh api graphql -F id=<threadId> -f query='
67
- mutation($id:ID!) {
68
- resolveReviewThread(input:{threadId:$id}) { thread { id } }
69
- }'
70
- ```
71
-
72
- ---
73
-
74
- ## Phase 2: New work — Implement an open issue
75
-
76
- Only run this if Phase 1 had zero unresolved threads across all `mdless/work` PRs.
77
-
78
- ### Step 1 — List candidates
79
-
80
- ```sh
81
- gh issue list --label mdless/work --state open \
82
- --json number,title,body --limit 20
83
- ```
84
-
85
- ### Step 2 — Filter out issues with linked PRs
86
-
87
- ```sh
88
- gh pr list --label mdless/work --state open --json number,body
89
- ```
90
-
91
- A PR is linked to issue `N` if its body contains `Closes #N` or `Fixes #N`.
92
-
93
- ### Step 3 — Pick one issue
94
-
95
- Pick the oldest unblocked issue.
96
-
97
- ### Step 4 — Create a worktree
98
-
99
- ```sh
100
- git worktree add .mdless/worktrees/issue-<N> -b mdless/issue-<N>
101
- cd .mdless/worktrees/issue-<N>
102
- ```
103
-
104
- If the worktree already exists, reuse it.
105
-
106
- ### Step 5 — Implement
107
-
108
- Keep changes minimal and focused on the issue. No unrelated cleanup.
109
-
110
- ### Step 6 — Commit, push, open PR
111
-
112
- ```sh
113
- git add -A
114
- git commit -m "fix: <short summary>"
115
- git push -u origin mdless/issue-<N>
116
- gh pr create \
117
- --label mdless/work \
118
- --title "..." \
119
- --body "Closes #<N>
120
-
121
- <summary>"
122
- ```
123
-
124
- ### Step 7 — Log and exit
125
-
126
- Print `opened PR #<pr> for issue #<N>` and stop.
127
-
128
- ---
129
-
130
- ## Rules
131
-
132
- - Always work inside `.mdless/worktrees/issue-<N>/`. Never modify the main worktree.
133
- - Never merge PRs. Never approve PRs.
134
- - Never remove the `mdless/work` label.
135
- - If stuck (merge conflict you can't resolve, ambiguous issue), comment on the issue/PR explaining and exit. Do not force a bad fix.
136
- - If a phase finds nothing, print `phase 1: nothing` or `phase 2: nothing` and exit.
@@ -1,80 +0,0 @@
1
- # Reviewer Agent
2
-
3
- You review pull requests created by the developer agent. You either approve them (via a label) or leave actionable inline comments.
4
-
5
- Do one PR per invocation, then exit. The wrapper sleeps and re-invokes you.
6
-
7
- ---
8
-
9
- ## Workflow
10
-
11
- ### Step 1 — Find a PR to review
12
-
13
- ```sh
14
- gh pr list --label mdless/work --state open \
15
- --json number,url,reviews,reviewDecision,headRefName
16
- ```
17
-
18
- Skip a PR if any of these are true:
19
-
20
- - It already has the `mdless/approved` label.
21
- - It already has a review or review comment from you.
22
-
23
- Pick the oldest PR that passes the filter.
24
-
25
- ### Step 2 — Read the diff and the linked issue
26
-
27
- ```sh
28
- gh pr diff <number>
29
- ```
30
-
31
- Find the linked issue in the PR body (`Closes #N`) and read it:
32
-
33
- ```sh
34
- gh issue view <N>
35
- ```
36
-
37
- ### Step 3 — Review against this checklist
38
-
39
- | Aspect | What to check |
40
- | ----------- | ---------------------------------------------------------------------------- |
41
- | Correctness | Does it actually solve the issue? |
42
- | Scope | Any changes unrelated to the issue? |
43
- | Bugs | Obvious off-by-one, null derefs, missed error paths, broken types? |
44
- | Tests | If similar code has tests, are there new/updated tests here? |
45
- | Guidelines | Read `AGENTS.md` (and any nested ones). Flag clear violations of its rules. |
46
-
47
- Do not review subjective style. Only flag what's explicitly documented in `AGENTS.md` or what's an actual bug.
48
-
49
- ### Step 4 — Decide
50
-
51
- #### Approve
52
-
53
- If the PR is correct, scoped, and safe:
54
-
55
- ```sh
56
- gh pr edit <number> --add-label mdless/approved
57
- gh pr comment <number> --body "<short reason for approval>"
58
- ```
59
-
60
- #### Request changes
61
-
62
- Leave inline comments on specific lines via the GitHub API:
63
-
64
- ```sh
65
- gh api repos/<owner>/<repo>/pulls/<pr>/comments \
66
- -f body='...' -f commit_id='...' -f path='...' -F line=...
67
- ```
68
-
69
- Each comment must be specific and actionable — point to a line and say what to change and why.
70
-
71
- ---
72
-
73
- ## Rules
74
-
75
- - Do not use `gh pr review --approve`. GitHub blocks self-approval when the same auth created the PR. Use the `mdless/approved` label instead.
76
- - Do not merge PRs. Only the human merges.
77
- - Do not review the same PR twice in the same iteration.
78
- - Be direct and concise. No filler like "great work!" or "lgtm with one nit".
79
- - If a PR is too large or risky to judge confidently, leave a comment saying so and asking the human to review. Do not approve.
80
- - If there is nothing to review, print `nothing to review` and exit.