Skip to content

Commit 55ca734

Browse files
committed
Initial commit: archon-smart-mr-review
GitLab counterpart to archon-smart-pr-review for Archon. - Workflow YAML with Haiku-classified, conditional multi-agent routing - 9 command files: mr-fetch, review-scope, 5 review agents, synthesize-review, post-review - Posting pattern: resolvable Discussion threads per critical finding, auto-approval on 0 critical, reviewer assignment, ai-code-review commit status
0 parents  commit 55ca734

13 files changed

Lines changed: 2061 additions & 0 deletions

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Raphael Lechner
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.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# archon-gitlab-workflows
2+
3+
GitLab counterparts to the bundled GitHub-focused workflows for [Archon](https://github.com/coleam00/Archon).
4+
5+
These workflows use `glab` (the GitLab CLI) instead of `gh` and adapt the multi-agent review pattern to GitLab's MR (Merge Request) model — including resolvable Discussion threads, MR approval, reviewer assignment, and the `ai-code-review` commit status.
6+
7+
## Available workflows
8+
9+
| Workflow | GitHub counterpart | Status |
10+
|----------|--------------------|--------|
11+
| [`archon-smart-mr-review`](./archon-smart-mr-review/) | `archon-smart-pr-review` | ✅ Published |
12+
13+
## Prerequisites
14+
15+
- [Archon](https://archon.diy) installed
16+
- `glab` CLI installed and authenticated (`glab auth status`)
17+
- Access to the target MR (read + comment + approve)
18+
19+
## License
20+
21+
[MIT](./LICENSE)

archon-smart-mr-review/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# archon-smart-mr-review
2+
3+
GitLab counterpart to `archon-smart-pr-review`. Performs an efficient, complexity-adaptive code review of a GitLab MR.
4+
5+
## What it does
6+
7+
1. Loads MR via `glab`
8+
2. Haiku classifies MR complexity + which review agents are relevant
9+
3. Only relevant agents run in parallel (code-review, error-handling, test-coverage, comment-quality, docs-impact)
10+
4. Consolidates findings
11+
5. Posts resolvable Discussion threads per 🔴 Critical finding
12+
6. Summary comment with 🟡 warnings + 🟢 positives
13+
7. Approves on 0 critical findings
14+
8. Assigns itself as reviewer + sets commit status `ai-code-review`
15+
16+
## Smart-routing examples
17+
18+
- 3-line typo fix → only code-review, skip test-coverage + docs-impact
19+
- Renovate update → code-review (with dependency logic) + docs-impact
20+
- Refactor with new APIs → code-review + error-handling + test-coverage + docs-impact
21+
22+
## Prerequisites
23+
24+
- `glab auth status` shows logged in
25+
- Access to the MR (read + comment + approve)
26+
- Optional: `ARCHON_GITLAB_REVIEWER` env var (default: `ai-agent`)
27+
28+
## Input formats
29+
30+
| Format | Example |
31+
|--------|---------|
32+
| Plain IID | `12345`, `!12345` |
33+
| Repo-qualified | `group/project!12345` |
34+
| Web URL | `https://gitlab.example.com/group/project/-/merge_requests/123` |
35+
36+
## Usage
37+
38+
```bash
39+
archon workflow run archon-smart-mr-review --branch review/mr-12345 "Review MR !12345"
40+
```
41+
42+
## Warning
43+
44+
Posts REAL comments + Discussion threads on the MR, approves the MR (on 0 critical), and assigns itself as reviewer. Makes NO code changes (no self-fix — for that, see the `comprehensive` variant when released).
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
name: archon-smart-mr-review
2+
description: |
3+
Use when: User wants an efficient code review of a GitLab MR — adaptive to complexity.
4+
Triggers: "smart review", "review MR !123", "smart mr review", "efficient review",
5+
"quick review mr", "review and approve gitlab", "gitlab smart review".
6+
Does: Loads MR → Haiku classifies MR complexity + which agents are relevant →
7+
only relevant review agents run → consolidates →
8+
posts Discussion threads (resolvable) → approves on 0 Critical →
9+
adds reviewer → sets commit status.
10+
NOT for: When ALL review agents are wanted (use archon-comprehensive-mr-review),
11+
bug fixes with issue-ref (use archon-fix-gitlab-issue),
12+
MRs you just built (idea-to-mr / plan-to-mr review inline).
13+
14+
GitLab counterpart to `archon-smart-pr-review`.
15+
Posting pattern: Discussion threads per 🔴 Critical, auto-approval on 0 Critical,
16+
reviewer assignment, commit status `ai-code-review`.
17+
18+
Smart-routing examples:
19+
- 3-line typo fix → only code-review, skip test-coverage + docs-impact
20+
- Renovate update → only code-review (with dependency logic) + docs-impact
21+
- Refactor with new APIs → code-review + error-handling + test-coverage + docs-impact
22+
23+
⚠️ WARNING: Posts REAL comments + Discussion threads on the MR,
24+
approves the MR (on 0 Critical), and assigns itself as reviewer.
25+
Makes NO code changes on the MR (no self-fix).
26+
27+
Prerequisites:
28+
- `glab auth status` shows logged in
29+
- Access to the MR (read + comment + approve)
30+
- Optional: ENV `ARCHON_GITLAB_REVIEWER` (default: `ai-agent`)
31+
32+
Input: MR reference in user input — see archon-comprehensive-mr-review.
33+
34+
provider: claude
35+
model: sonnet
36+
37+
nodes:
38+
# ═══════════════════════════════════════════════════════════════
39+
# PHASE 1: LOAD MR
40+
# ═══════════════════════════════════════════════════════════════
41+
42+
- id: fetch-mr
43+
command: archon-gitlab-mr-fetch
44+
context: fresh
45+
46+
# ═══════════════════════════════════════════════════════════════
47+
# PHASE 2: SCOPE
48+
# ═══════════════════════════════════════════════════════════════
49+
50+
- id: review-scope
51+
command: archon-gitlab-review-scope
52+
depends_on: [fetch-mr]
53+
context: fresh
54+
55+
# ═══════════════════════════════════════════════════════════════
56+
# PHASE 3: CLASSIFICATION (Haiku)
57+
# ═══════════════════════════════════════════════════════════════
58+
59+
- id: classify
60+
prompt: |
61+
You are an MR complexity classifier for GitLab repos.
62+
Analyze the MR scope below and decide which review agents should run.
63+
64+
## MR Scope
65+
66+
$review-scope.output
67+
68+
## Rules
69+
70+
- **code_review**: ALWAYS `true` unless the diff is empty or touches only
71+
non-code files (README-only, config-only, .yaml-only without code).
72+
- **error_handling**: `true` when the diff touches code with try/except,
73+
error handling, async/await, or new failure paths.
74+
- **test_coverage**: `true` when the diff touches source code
75+
(not just tests/docs/config).
76+
- **comment_quality**: `true` when the diff adds/changes comments, docstrings,
77+
JSDoc, or significant inline documentation in code files.
78+
- **docs_impact**: `true` when the diff adds/removes/renames public APIs,
79+
commands, CLI flags, ENV variables, or user-facing features.
80+
ALSO on CLAUDE.md/README/docs/ changes.
81+
82+
## Special cases
83+
84+
- **Renovate / dependency update** (major/minor/patch bump in package.json,
85+
requirements.txt, go.mod, Docker tags etc.): code_review = true with focus
86+
on breaking-changes risk. test_coverage = false. error_handling = false.
87+
docs_impact = true if user-facing.
88+
- **Pure renaming / move** without logic change: code_review = true,
89+
rest false.
90+
- **Test-file-only updates**: test_coverage = false (they ARE tests),
91+
code_review = true.
92+
93+
Classify the complexity:
94+
- **trivial**: typo fixes, formatting, single-line, patch version bumps
95+
- **small**: 1–3 files, simple logic, no architectural changes
96+
- **medium**: 4–10 files, moderate logic changes, some cross-cutting
97+
- **large**: 10+ files, architectural changes, new subsystems,
98+
complex refactors, major version bumps
99+
100+
Reasoning should be in English and briefly explain which agents run and why.
101+
depends_on: [review-scope]
102+
model: haiku
103+
allowed_tools: []
104+
output_format:
105+
type: object
106+
properties:
107+
run_code_review:
108+
type: string
109+
enum: ["true", "false"]
110+
run_error_handling:
111+
type: string
112+
enum: ["true", "false"]
113+
run_test_coverage:
114+
type: string
115+
enum: ["true", "false"]
116+
run_comment_quality:
117+
type: string
118+
enum: ["true", "false"]
119+
run_docs_impact:
120+
type: string
121+
enum: ["true", "false"]
122+
complexity:
123+
type: string
124+
enum: ["trivial", "small", "medium", "large"]
125+
reasoning:
126+
type: string
127+
required:
128+
- run_code_review
129+
- run_error_handling
130+
- run_test_coverage
131+
- run_comment_quality
132+
- run_docs_impact
133+
- complexity
134+
- reasoning
135+
136+
# ═══════════════════════════════════════════════════════════════
137+
# PHASE 4: CONDITIONAL REVIEW AGENTS
138+
# ═══════════════════════════════════════════════════════════════
139+
140+
- id: code-review
141+
command: archon-gitlab-code-review-agent
142+
depends_on: [classify, review-scope]
143+
when: "$classify.output.run_code_review == 'true'"
144+
context: fresh
145+
146+
- id: error-handling
147+
command: archon-gitlab-error-handling-agent
148+
depends_on: [classify, review-scope]
149+
when: "$classify.output.run_error_handling == 'true'"
150+
context: fresh
151+
152+
- id: test-coverage
153+
command: archon-gitlab-test-coverage-agent
154+
depends_on: [classify, review-scope]
155+
when: "$classify.output.run_test_coverage == 'true'"
156+
context: fresh
157+
158+
- id: comment-quality
159+
command: archon-gitlab-comment-quality-agent
160+
depends_on: [classify, review-scope]
161+
when: "$classify.output.run_comment_quality == 'true'"
162+
context: fresh
163+
164+
- id: docs-impact
165+
command: archon-gitlab-docs-impact-agent
166+
depends_on: [classify, review-scope]
167+
when: "$classify.output.run_docs_impact == 'true'"
168+
context: fresh
169+
170+
# ═══════════════════════════════════════════════════════════════
171+
# PHASE 5: CONSOLIDATE
172+
# ═══════════════════════════════════════════════════════════════
173+
174+
- id: synthesize
175+
command: archon-gitlab-synthesize-review
176+
depends_on: [code-review, error-handling, test-coverage, comment-quality, docs-impact]
177+
trigger_rule: one_success
178+
context: fresh
179+
180+
# ═══════════════════════════════════════════════════════════════
181+
# PHASE 6: GITLAB ACTIONS (Threads + Approval + Reviewer)
182+
# ═══════════════════════════════════════════════════════════════
183+
184+
- id: post-review
185+
command: archon-gitlab-post-review
186+
depends_on: [synthesize]
187+
context: fresh
188+
189+
# ═══════════════════════════════════════════════════════════════
190+
# PHASE 7: SUMMARY
191+
# ═══════════════════════════════════════════════════════════════
192+
193+
- id: summary
194+
bash: |
195+
set -euo pipefail
196+
197+
MR_IID=$(cat "$ARTIFACTS_DIR/.mr-iid" 2>/dev/null || echo "—")
198+
MR_URL=$(cat "$ARTIFACTS_DIR/.mr-url" 2>/dev/null || echo "—")
199+
200+
echo "═════════════════════════════════════════════════════════════"
201+
echo " archon-smart-mr-review — DONE"
202+
echo "═════════════════════════════════════════════════════════════"
203+
echo " MR: !${MR_IID}"
204+
echo " URL: ${MR_URL}"
205+
echo ""
206+
207+
echo "─── Classification ───"
208+
if [ -f "$ARTIFACTS_DIR/review/scope.md" ]; then
209+
echo " (see scope.md)"
210+
fi
211+
echo ""
212+
213+
echo "─── Active review agents ───"
214+
for f in "$ARTIFACTS_DIR/review/"*-findings.md; do
215+
[ -f "$f" ] && {
216+
BASE=$(basename "$f" -findings.md)
217+
COUNT=$(grep -cE "^#{3}? Finding " "$f" 2>/dev/null || echo "?")
218+
echo " ${BASE}: ${COUNT} findings"
219+
}
220+
done
221+
echo ""
222+
223+
echo "─── Posting ───"
224+
if [ -f "$ARTIFACTS_DIR/review/findings-parsed.json" ]; then
225+
CRIT=$(jq -r '[.[] | select(.severity | startswith("🔴"))] | length' "$ARTIFACTS_DIR/review/findings-parsed.json" 2>/dev/null || echo "?")
226+
WARN=$(jq -r '[.[] | select(.severity | startswith("🟡"))] | length' "$ARTIFACTS_DIR/review/findings-parsed.json" 2>/dev/null || echo "?")
227+
POS=$(jq -r '[.[] | select(.severity | startswith("🟢"))] | length' "$ARTIFACTS_DIR/review/findings-parsed.json" 2>/dev/null || echo "?")
228+
echo " Critical: ${CRIT}"
229+
echo " Warnings: ${WARN}"
230+
echo " Positive: ${POS}"
231+
echo " Approved: $([ "${CRIT}" = "0" ] && echo "YES ✅" || echo "NO ❌")"
232+
fi
233+
echo ""
234+
echo "─── Artifacts ───"
235+
find "$ARTIFACTS_DIR" -type f \( -name "*.md" -o -name "*.json" \) | sort
236+
depends_on: [post-review]
237+
timeout: 15000

0 commit comments

Comments
 (0)