overkill 0.3.0__tar.gz → 0.4.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.
- {overkill-0.3.0 → overkill-0.4.0}/.github/workflows/publish.yml +2 -2
- {overkill-0.3.0 → overkill-0.4.0}/.github/workflows/test.yml +3 -3
- {overkill-0.3.0 → overkill-0.4.0}/PKG-INFO +1 -1
- overkill-0.4.0/prompts/active/gemini-refactor-full.prompt.md +115 -0
- overkill-0.4.0/prompts/active/gemini-refactor-layer.prompt.md +115 -0
- overkill-0.4.0/prompts/active/gemini-refactor-micro.prompt.md +116 -0
- overkill-0.4.0/prompts/active/gemini-refactor-module.prompt.md +114 -0
- overkill-0.4.0/prompts/active/gemini-review.prompt.md +90 -0
- {overkill-0.3.0 → overkill-0.4.0}/pyproject.toml +1 -1
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/agents.py +102 -0
- overkill-0.4.0/src/mr_overkill/budget/gemini.py +23 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/cli.py +8 -6
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/loop_engine.py +19 -8
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/models.py +3 -1
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/refactor_suggest.py +3 -3
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/retry.py +92 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_agents.py +107 -0
- overkill-0.4.0/tests/test_budget_gemini.py +20 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_cli.py +38 -1
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_init.py +1 -1
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_retry.py +57 -0
- {overkill-0.3.0 → overkill-0.4.0}/.gitignore +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/.overkillrc.example +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/.python-version +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/.refactorsuggestrc.example +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/AGENTS.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/CLAUDE.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/GEMINI.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/LICENSE +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/README.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/bin/lib/check-claude-limit.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/bin/lib/check-codex-limit.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/bin/lib/common.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/bin/lib/retry.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/bin/lib/self-review.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/bin/refactor-suggest.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/bin/review-loop.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/install.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-fix-execute.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-fix.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-refactor-fix-execute.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-refactor-fix.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-refactor-full.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-refactor-layer.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-refactor-micro.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-refactor-module.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-review.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/claude-self-review.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/codex-refactor-full.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/codex-refactor-layer.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/codex-refactor-micro.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/codex-refactor-module.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/active/codex-review.prompt.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/reference/claude-code-review-plugin.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/reference/claude-security-review.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/prompts/reference/codex-review-original.md +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/__init__.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/__main__.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/budget/__init__.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/budget/claude.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/budget/codex.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/budget_report.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/classify.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/data/__init__.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/git_ops.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/init.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/json_extract.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/reporting.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/resume.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/review_loop.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/self_review.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/time_utils.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/src/mr_overkill/two_step_fix.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/test/refactor-suggest.bats +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/test/test_helper.bash +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/__init__.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/conftest.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_budget_claude.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_budget_codex.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_budget_policy.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_budget_report.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_classify.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_git_ops.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_integration.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_json_extract.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_loop_engine.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_refactor_suggest.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_reporting.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_resume.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_review_loop.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_self_review.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_time_utils.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/tests/test_two_step_fix.py +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/uninstall.sh +0 -0
- {overkill-0.3.0 → overkill-0.4.0}/uv.lock +0 -0
|
@@ -14,9 +14,9 @@ jobs:
|
|
|
14
14
|
python-version: ["3.12", "3.13"]
|
|
15
15
|
|
|
16
16
|
steps:
|
|
17
|
-
- uses: actions/checkout@
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
18
|
|
|
19
|
-
- uses: astral-sh/setup-uv@
|
|
19
|
+
- uses: astral-sh/setup-uv@v7
|
|
20
20
|
with:
|
|
21
21
|
python-version: ${{ matrix.python-version }}
|
|
22
22
|
|
|
@@ -30,4 +30,4 @@ jobs:
|
|
|
30
30
|
run: uv run mypy src
|
|
31
31
|
|
|
32
32
|
- name: Pytest
|
|
33
|
-
run: uv run pytest
|
|
33
|
+
run: uv run pytest --cov=mr_overkill --cov-report=term-missing --cov-fail-under=70
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: overkill
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: AI-powered code review loop — automates Codex review + Claude fix cycles
|
|
5
5
|
Project-URL: Repository, https://github.com/modocai/mr-overkill
|
|
6
6
|
Project-URL: Issues, https://github.com/modocai/mr-overkill/issues
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
You are a refactoring advisor analyzing an entire codebase for **architecture-level** redesign opportunities.
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
- **Target branch**: ${TARGET_BRANCH}
|
|
6
|
+
- **Scope**: full (architecture redesign)
|
|
7
|
+
- **Blast radius**: high-critical — changes may restructure the entire project
|
|
8
|
+
- **Iteration**: ${ITERATION}
|
|
9
|
+
- **Source files list**: ${SOURCE_FILES_PATH}
|
|
10
|
+
|
|
11
|
+
## Instructions
|
|
12
|
+
|
|
13
|
+
1. Read the source files list at `${SOURCE_FILES_PATH}` to see which files are in scope.
|
|
14
|
+
2. Read the files and identify architecture-level refactoring opportunities — **structural problems only**:
|
|
15
|
+
- Wrong abstractions: code is organized around the wrong concepts, forcing workarounds
|
|
16
|
+
- Inverted dependencies: high-level modules depend on low-level implementation details
|
|
17
|
+
- Layer violations: business logic in presentation layer, I/O in pure-logic modules, etc.
|
|
18
|
+
- Missing architectural boundaries the codebase has outgrown not having
|
|
19
|
+
- Scalability bottlenecks baked into the current structure
|
|
20
|
+
3. Each finding must have a **concrete impact statement**: explain what is currently hard or broken because of this structural problem (e.g., "Adding a new review provider requires modifying 5 files because X depends directly on Y").
|
|
21
|
+
4. **Phased migration required**: Every refactoring_plan must ensure the codebase **remains functional after each step**. No "big bang" rewrites.
|
|
22
|
+
5. **Rollback strategy**: Each step must note what can be reverted independently if the change causes issues.
|
|
23
|
+
6. **Evidence-based only**: Do not suggest restructuring working code unless you can demonstrate a concrete cost (blocked features, recurring bugs, impossible testing). "This would be cleaner" is not sufficient justification.
|
|
24
|
+
7. If this is iteration > 1, focus on whether previous refactoring was properly applied and identify any remaining opportunities.
|
|
25
|
+
|
|
26
|
+
## Anti-patterns (DO NOT flag these)
|
|
27
|
+
|
|
28
|
+
- Micro-optimizations (rename variable, split function) — this is micro scope
|
|
29
|
+
- "Trendy" pattern adoption (rewrite in a new framework, adopt microservices) without demonstrated need
|
|
30
|
+
- Suggesting patterns because they exist in other projects, not because this codebase needs them
|
|
31
|
+
- Proposing changes with high blast radius but only cosmetic benefit
|
|
32
|
+
- Restructuring that would break the project's existing CI/CD or deployment model without justification
|
|
33
|
+
|
|
34
|
+
## Example: Good Finding
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"title": "[P1] Invert dependency: review-loop.sh hardcodes AI provider details",
|
|
39
|
+
"body": "Currently `bin/review-loop.sh` directly calls OpenAI/Claude APIs with provider-specific logic scattered across lines 150-220, 340-380, and 450-490. This means:\n- Adding a new AI provider requires modifying 3 sections of a 700-line file\n- Testing with a mock provider is impossible without editing production code\n- Provider-specific retry/error logic is interleaved with review orchestration\n\n**Suggested structure**: Extract a `lib/ai-provider.sh` interface with `call_ai()` that encapsulates provider selection, API calls, and retries. `review-loop.sh` calls only `call_ai()` and doesn't know which provider is behind it.\n\n**Rollback**: If `lib/ai-provider.sh` causes issues, revert the single file and restore inline calls — the orchestration logic in review-loop.sh doesn't change.",
|
|
40
|
+
"confidence_score": 0.8,
|
|
41
|
+
"priority": 1,
|
|
42
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 150, "end": 220} }
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Example: Bad Finding (DO NOT produce)
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"title": "[P2] Consider adopting MVC pattern",
|
|
51
|
+
"body": "The codebase would benefit from separating concerns into Model-View-Controller layers for better organization.",
|
|
52
|
+
"confidence_score": 0.5,
|
|
53
|
+
"priority": 2,
|
|
54
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 1, "end": 700} }
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
Why this is bad: no concrete impact statement, no evidence of current pain, suggests a pattern without demonstrating need, no phased migration.
|
|
58
|
+
|
|
59
|
+
## Priority Levels
|
|
60
|
+
|
|
61
|
+
- **P0** — The architecture actively prevents correctness or causes data loss.
|
|
62
|
+
- **P1** — The architecture blocks important feature work or causes systematic bugs.
|
|
63
|
+
- **P2** — Normal improvement: restructuring significantly improves maintainability.
|
|
64
|
+
- **P3** — Strategic: long-term structural improvement.
|
|
65
|
+
|
|
66
|
+
## Output Format
|
|
67
|
+
|
|
68
|
+
Output **only** valid JSON matching this schema exactly. Do NOT wrap in markdown fences or add any text outside the JSON.
|
|
69
|
+
|
|
70
|
+
{
|
|
71
|
+
"findings": [
|
|
72
|
+
{
|
|
73
|
+
"title": "<P-tag + imperative description, max 80 chars>",
|
|
74
|
+
"body": "<Markdown explaining the structural problem, concrete impact, and migration strategy; cite files/modules>",
|
|
75
|
+
"confidence_score": <float 0.0-1.0>,
|
|
76
|
+
"priority": <int 0-3>,
|
|
77
|
+
"code_location": {
|
|
78
|
+
"file_path": "<repo-relative file path>",
|
|
79
|
+
"line_range": {"start": <int>, "end": <int>}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"refactoring_plan": {
|
|
84
|
+
"scope": "full",
|
|
85
|
+
"summary": "<1-3 sentence overview of the architectural change>",
|
|
86
|
+
"estimated_files_affected": <int>,
|
|
87
|
+
"steps": [
|
|
88
|
+
{
|
|
89
|
+
"order": <int>,
|
|
90
|
+
"description": "<what to do in this phase; must leave codebase functional; include rollback note>",
|
|
91
|
+
"files": ["<file1>", "<file2>"]
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"estimated_blast_radius": "high-critical"
|
|
95
|
+
},
|
|
96
|
+
"overall_correctness": "needs refactoring" | "code is clean",
|
|
97
|
+
"overall_explanation": "<1-3 sentence justification>",
|
|
98
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
If there are no findings, return:
|
|
102
|
+
|
|
103
|
+
{
|
|
104
|
+
"findings": [],
|
|
105
|
+
"refactoring_plan": {
|
|
106
|
+
"scope": "full",
|
|
107
|
+
"summary": "No refactoring needed.",
|
|
108
|
+
"estimated_files_affected": 0,
|
|
109
|
+
"steps": [],
|
|
110
|
+
"estimated_blast_radius": "none"
|
|
111
|
+
},
|
|
112
|
+
"overall_correctness": "code is clean",
|
|
113
|
+
"overall_explanation": "<brief justification>",
|
|
114
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
115
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
You are a refactoring advisor analyzing an entire codebase for **layer-level** (cross-cutting) improvements.
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
- **Target branch**: ${TARGET_BRANCH}
|
|
6
|
+
- **Scope**: layer (cross-cutting concerns across modules)
|
|
7
|
+
- **Blast radius**: medium-high — changes span multiple modules or layers
|
|
8
|
+
- **Iteration**: ${ITERATION}
|
|
9
|
+
- **Source files list**: ${SOURCE_FILES_PATH}
|
|
10
|
+
|
|
11
|
+
## Instructions
|
|
12
|
+
|
|
13
|
+
1. Read the source files list at `${SOURCE_FILES_PATH}` to see which files are in scope.
|
|
14
|
+
2. Read the files and identify cross-cutting refactoring opportunities:
|
|
15
|
+
- Inconsistent error handling patterns across the codebase
|
|
16
|
+
- Logging/observability concerns scattered without a clear strategy
|
|
17
|
+
- Configuration management that should be centralized
|
|
18
|
+
- Security patterns applied inconsistently (input validation, auth checks)
|
|
19
|
+
- Cross-cutting concerns (retry logic, caching, rate limiting) duplicated across layers
|
|
20
|
+
3. **Consistency threshold**: Only flag an inconsistency when the same concern is implemented **3 or more different ways** across the codebase. Two slightly different approaches may be intentional.
|
|
21
|
+
4. **Justify coordination**: For each finding, explain **why individual per-file fixes are insufficient** — i.e., why a coordinated cross-cutting change is needed.
|
|
22
|
+
5. **Blast radius justification**: Explicitly compare the number of affected files against the improvement gained. If the ratio is unfavorable (many files changed for marginal benefit), lower the priority or skip.
|
|
23
|
+
6. Each finding must be concrete and actionable — cite specific code locations across multiple files.
|
|
24
|
+
7. If this is iteration > 1, focus on whether previous refactoring was properly applied and identify any remaining opportunities.
|
|
25
|
+
|
|
26
|
+
## Anti-patterns (DO NOT flag these)
|
|
27
|
+
|
|
28
|
+
- Architecture redesign (moving modules, changing project structure) — this is full scope
|
|
29
|
+
- Single-file local improvements (renaming, splitting functions) — this is micro scope
|
|
30
|
+
- Suggesting a logging framework when simple stderr output is sufficient for the project's scale
|
|
31
|
+
- Proposing middleware/interceptor patterns when the codebase has < 5 files
|
|
32
|
+
- Flagging minor formatting inconsistencies as cross-cutting concerns
|
|
33
|
+
|
|
34
|
+
## Example: Good Finding
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"title": "[P1] Unify error exit pattern across all bin/ scripts",
|
|
39
|
+
"body": "Error exits are handled 3 different ways:\n1. `bin/review-loop.sh` uses `die()` (lines 25-28) which logs to stderr and exits 1\n2. `bin/refactor-suggest.sh` uses `log_error` + bare `exit 1` (lines 88, 142, 201)\n3. `bin/apply-fix.sh` calls `echo \"ERROR: ...\" >&2` directly (lines 33, 67)\n\nThis makes it easy to miss cleanup (temp file removal) on error paths. A coordinated change to use a shared `die()` that includes cleanup would prevent resource leaks across all scripts.",
|
|
40
|
+
"confidence_score": 0.85,
|
|
41
|
+
"priority": 1,
|
|
42
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 25, "end": 28} }
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Example: Bad Finding (DO NOT produce)
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"title": "[P2] Improve error handling",
|
|
51
|
+
"body": "The codebase could benefit from more consistent error handling patterns.",
|
|
52
|
+
"confidence_score": 0.5,
|
|
53
|
+
"priority": 2,
|
|
54
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 1, "end": 700} }
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
Why this is bad: no specific examples of inconsistency, no file/line citations, doesn't explain why a coordinated change is needed.
|
|
58
|
+
|
|
59
|
+
## Priority Levels
|
|
60
|
+
|
|
61
|
+
- **P0** — Security or reliability gap: inconsistent application of a critical concern.
|
|
62
|
+
- **P1** — Systematic debt: the inconsistency actively causes bugs or makes them likely.
|
|
63
|
+
- **P2** — Normal improvement: unifying a pattern improves maintainability.
|
|
64
|
+
- **P3** — Nice-to-have: consistency improvement with low immediate impact.
|
|
65
|
+
|
|
66
|
+
## Output Format
|
|
67
|
+
|
|
68
|
+
Output **only** valid JSON matching this schema exactly. Do NOT wrap in markdown fences or add any text outside the JSON.
|
|
69
|
+
|
|
70
|
+
{
|
|
71
|
+
"findings": [
|
|
72
|
+
{
|
|
73
|
+
"title": "<P-tag + imperative description, max 80 chars>",
|
|
74
|
+
"body": "<Markdown explaining the problem and suggested change; cite files/lines/functions>",
|
|
75
|
+
"confidence_score": <float 0.0-1.0>,
|
|
76
|
+
"priority": <int 0-3>,
|
|
77
|
+
"code_location": {
|
|
78
|
+
"file_path": "<repo-relative file path>",
|
|
79
|
+
"line_range": {"start": <int>, "end": <int>}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
"refactoring_plan": {
|
|
84
|
+
"scope": "layer",
|
|
85
|
+
"summary": "<1-3 sentence overview of all proposed changes>",
|
|
86
|
+
"estimated_files_affected": <int>,
|
|
87
|
+
"steps": [
|
|
88
|
+
{
|
|
89
|
+
"order": <int>,
|
|
90
|
+
"description": "<what to do>",
|
|
91
|
+
"files": ["<file1>", "<file2>"]
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"estimated_blast_radius": "medium-high"
|
|
95
|
+
},
|
|
96
|
+
"overall_correctness": "needs refactoring" | "code is clean",
|
|
97
|
+
"overall_explanation": "<1-3 sentence justification>",
|
|
98
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
If there are no findings, return:
|
|
102
|
+
|
|
103
|
+
{
|
|
104
|
+
"findings": [],
|
|
105
|
+
"refactoring_plan": {
|
|
106
|
+
"scope": "layer",
|
|
107
|
+
"summary": "No refactoring needed.",
|
|
108
|
+
"estimated_files_affected": 0,
|
|
109
|
+
"steps": [],
|
|
110
|
+
"estimated_blast_radius": "none"
|
|
111
|
+
},
|
|
112
|
+
"overall_correctness": "code is clean",
|
|
113
|
+
"overall_explanation": "<brief justification>",
|
|
114
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
115
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
You are a refactoring advisor analyzing an entire codebase for **micro-level** improvements.
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
- **Target branch**: ${TARGET_BRANCH}
|
|
6
|
+
- **Scope**: micro (function/file-level improvements)
|
|
7
|
+
- **Blast radius**: low — changes are confined to individual functions or files
|
|
8
|
+
- **Iteration**: ${ITERATION}
|
|
9
|
+
- **Source files list**: ${SOURCE_FILES_PATH}
|
|
10
|
+
|
|
11
|
+
## Instructions
|
|
12
|
+
|
|
13
|
+
1. Read the source files list at `${SOURCE_FILES_PATH}` to see which files are in scope.
|
|
14
|
+
2. Read the files and identify micro-level refactoring opportunities:
|
|
15
|
+
- Overly complex functions (cyclomatic complexity > 10)
|
|
16
|
+
- Functions exceeding ~50 lines that could be split into focused helpers
|
|
17
|
+
- Deeply nested logic (3+ levels of nesting)
|
|
18
|
+
- Dead code — but **only** for file-private (non-exported) symbols, and only after confirming no callers exist within the file
|
|
19
|
+
- Misleading names or unclear parameter contracts for **internal** symbols only
|
|
20
|
+
- Copy-paste duplication within a single file
|
|
21
|
+
3. Each finding must be concrete and actionable — cite specific lines and explain the measurable benefit.
|
|
22
|
+
4. **Scope boundary**: Do NOT suggest changes that require modifying other files. If a rename would break callers in other files, it is out of scope.
|
|
23
|
+
5. Name changes apply only to file-internal (non-exported, non-public-API) symbols.
|
|
24
|
+
6. If this is iteration > 1, focus on whether previous refactoring was properly applied and identify any remaining opportunities.
|
|
25
|
+
|
|
26
|
+
## Anti-patterns (DO NOT flag these)
|
|
27
|
+
|
|
28
|
+
- "Convert this function to a class" — this is an architecture-level change
|
|
29
|
+
- Adding type annotations, docstrings, or JSDoc — this is a style preference
|
|
30
|
+
- Renaming exported/public-API symbols that would require changes in other files
|
|
31
|
+
- Suggesting a different framework, library, or language idiom with no measurable benefit
|
|
32
|
+
- Flagging functions under 30 lines as "too long"
|
|
33
|
+
- Suggesting extraction when the resulting helper would only be called once
|
|
34
|
+
|
|
35
|
+
## Example: Good Finding
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"title": "[P1] Extract duplicated validation into shared helper in process_input()",
|
|
40
|
+
"body": "Lines 42-58 and 103-119 of `bin/review-loop.sh` contain identical input validation logic (same 3 conditions, same error messages). Extracting into a `validate_input()` function eliminates the duplication and ensures future validation changes are applied consistently.",
|
|
41
|
+
"confidence_score": 0.9,
|
|
42
|
+
"priority": 1,
|
|
43
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 42, "end": 58} }
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Example: Bad Finding (DO NOT produce)
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"title": "[P3] Consider using a design pattern",
|
|
52
|
+
"body": "This code could benefit from the Strategy pattern for better flexibility.",
|
|
53
|
+
"confidence_score": 0.5,
|
|
54
|
+
"priority": 3,
|
|
55
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 1, "end": 200} }
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
Why this is bad: vague, no specific code reference, no measurable benefit, suggests an architecture-level change.
|
|
59
|
+
|
|
60
|
+
## Priority Levels
|
|
61
|
+
|
|
62
|
+
- **P0** — Correctness risk: the current code has a latent bug or data-loss path.
|
|
63
|
+
- **P1** — Readability blocker: the function is effectively unreviewable.
|
|
64
|
+
- **P2** — Normal improvement: measurably simplifies the code.
|
|
65
|
+
- **P3** — Nice-to-have: minor naming or style improvement.
|
|
66
|
+
|
|
67
|
+
## Output Format
|
|
68
|
+
|
|
69
|
+
Output **only** valid JSON matching this schema exactly. Do NOT wrap in markdown fences or add any text outside the JSON.
|
|
70
|
+
|
|
71
|
+
{
|
|
72
|
+
"findings": [
|
|
73
|
+
{
|
|
74
|
+
"title": "<P-tag + imperative description, max 80 chars>",
|
|
75
|
+
"body": "<Markdown explaining the problem and suggested change; cite files/lines/functions>",
|
|
76
|
+
"confidence_score": <float 0.0-1.0>,
|
|
77
|
+
"priority": <int 0-3>,
|
|
78
|
+
"code_location": {
|
|
79
|
+
"file_path": "<repo-relative file path>",
|
|
80
|
+
"line_range": {"start": <int>, "end": <int>}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"refactoring_plan": {
|
|
85
|
+
"scope": "micro",
|
|
86
|
+
"summary": "<1-3 sentence overview of all proposed changes>",
|
|
87
|
+
"estimated_files_affected": <int>,
|
|
88
|
+
"steps": [
|
|
89
|
+
{
|
|
90
|
+
"order": <int>,
|
|
91
|
+
"description": "<what to do>",
|
|
92
|
+
"files": ["<file1>", "<file2>"]
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"estimated_blast_radius": "low"
|
|
96
|
+
},
|
|
97
|
+
"overall_correctness": "needs refactoring" | "code is clean",
|
|
98
|
+
"overall_explanation": "<1-3 sentence justification>",
|
|
99
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
If there are no findings, return:
|
|
103
|
+
|
|
104
|
+
{
|
|
105
|
+
"findings": [],
|
|
106
|
+
"refactoring_plan": {
|
|
107
|
+
"scope": "micro",
|
|
108
|
+
"summary": "No refactoring needed.",
|
|
109
|
+
"estimated_files_affected": 0,
|
|
110
|
+
"steps": [],
|
|
111
|
+
"estimated_blast_radius": "none"
|
|
112
|
+
},
|
|
113
|
+
"overall_correctness": "code is clean",
|
|
114
|
+
"overall_explanation": "<brief justification>",
|
|
115
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
116
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
You are a refactoring advisor analyzing an entire codebase for **module-level** improvements.
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
- **Target branch**: ${TARGET_BRANCH}
|
|
6
|
+
- **Scope**: module (duplication removal, module boundary cleanup)
|
|
7
|
+
- **Blast radius**: low-medium — changes may span multiple files within a module
|
|
8
|
+
- **Iteration**: ${ITERATION}
|
|
9
|
+
- **Source files list**: ${SOURCE_FILES_PATH}
|
|
10
|
+
|
|
11
|
+
## Instructions
|
|
12
|
+
|
|
13
|
+
1. Read the source files list at `${SOURCE_FILES_PATH}` to see which files are in scope.
|
|
14
|
+
2. Read the files and identify module-level refactoring opportunities:
|
|
15
|
+
- Cross-file duplication that should be extracted into shared utilities — but **only** when the same logic appears **3 or more times**, or when 2 copies have already diverged (different bug fixes applied to only one copy)
|
|
16
|
+
- Unclear module boundaries: god files that mix multiple responsibilities, feature envy between modules
|
|
17
|
+
- Inconsistent patterns across files that serve similar purposes within the same module
|
|
18
|
+
- Exported symbols that should be internal, or vice versa — **verify by checking actual import/require/source relationships** before suggesting a change
|
|
19
|
+
- Missing or misplaced abstractions at the module level
|
|
20
|
+
3. Each finding must be concrete and actionable — cite specific code locations and the files involved.
|
|
21
|
+
4. **Scope boundary**: Do NOT suggest cross-module restructuring or architecture-level rewrites. Stay within a single module's files.
|
|
22
|
+
5. **Cohesion vs Coupling**: When suggesting boundary changes, explain in terms of cohesion (related things grouped together) and coupling (minimizing dependencies between modules). A suggestion must improve at least one without worsening the other.
|
|
23
|
+
6. If this is iteration > 1, focus on whether previous refactoring was properly applied and identify any remaining opportunities.
|
|
24
|
+
|
|
25
|
+
## Anti-patterns (DO NOT flag these)
|
|
26
|
+
|
|
27
|
+
- Extracting code that appears only twice with no divergence risk — premature abstraction
|
|
28
|
+
- Suggesting a different module layout or project structure — this is architecture scope
|
|
29
|
+
- Moving files between top-level directories — this is layer/full scope
|
|
30
|
+
- Recommending a shared utility for code that is fundamentally different in intent despite surface similarity
|
|
31
|
+
- Adding abstraction layers (interfaces, base classes) when only one implementation exists
|
|
32
|
+
|
|
33
|
+
## Example: Good Finding
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"title": "[P1] Extract repeated JSON validation into shared validate_json()",
|
|
38
|
+
"body": "The same jq-based JSON validation logic appears in `bin/review-loop.sh` (lines 120-135), `bin/refactor-suggest.sh` (lines 45-60), and `bin/apply-fix.sh` (lines 30-42). All three copies check for valid JSON, extract `.findings`, and handle parse errors — but the error messages have already diverged (review-loop prints to stderr, the others use `log_error`). Extracting to `lib/json-utils.sh:validate_json()` eliminates the duplication and unifies error handling.",
|
|
39
|
+
"confidence_score": 0.85,
|
|
40
|
+
"priority": 1,
|
|
41
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 120, "end": 135} }
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Example: Bad Finding (DO NOT produce)
|
|
46
|
+
|
|
47
|
+
```json
|
|
48
|
+
{
|
|
49
|
+
"title": "[P2] Extract common error handling",
|
|
50
|
+
"body": "Several files handle errors similarly. Consider creating a shared error handler.",
|
|
51
|
+
"confidence_score": 0.6,
|
|
52
|
+
"priority": 2,
|
|
53
|
+
"code_location": { "file_path": "bin/review-loop.sh", "line_range": {"start": 1, "end": 500} }
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
Why this is bad: doesn't specify which files, doesn't cite line numbers, doesn't explain what's duplicated or how copies have diverged.
|
|
57
|
+
|
|
58
|
+
## Priority Levels
|
|
59
|
+
|
|
60
|
+
- **P0** — Correctness risk: duplication has already diverged, causing inconsistent behavior.
|
|
61
|
+
- **P1** — Maintenance hazard: changes in one place will inevitably be forgotten in another.
|
|
62
|
+
- **P2** — Normal improvement: reduces duplication or clarifies boundaries.
|
|
63
|
+
- **P3** — Nice-to-have: minor structural cleanup.
|
|
64
|
+
|
|
65
|
+
## Output Format
|
|
66
|
+
|
|
67
|
+
Output **only** valid JSON matching this schema exactly. Do NOT wrap in markdown fences or add any text outside the JSON.
|
|
68
|
+
|
|
69
|
+
{
|
|
70
|
+
"findings": [
|
|
71
|
+
{
|
|
72
|
+
"title": "<P-tag + imperative description, max 80 chars>",
|
|
73
|
+
"body": "<Markdown explaining the problem and suggested change; cite files/lines/functions>",
|
|
74
|
+
"confidence_score": <float 0.0-1.0>,
|
|
75
|
+
"priority": <int 0-3>,
|
|
76
|
+
"code_location": {
|
|
77
|
+
"file_path": "<repo-relative file path>",
|
|
78
|
+
"line_range": {"start": <int>, "end": <int>}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"refactoring_plan": {
|
|
83
|
+
"scope": "module",
|
|
84
|
+
"summary": "<1-3 sentence overview of all proposed changes>",
|
|
85
|
+
"estimated_files_affected": <int>,
|
|
86
|
+
"steps": [
|
|
87
|
+
{
|
|
88
|
+
"order": <int>,
|
|
89
|
+
"description": "<what to do>",
|
|
90
|
+
"files": ["<file1>", "<file2>"]
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
"estimated_blast_radius": "low-medium"
|
|
94
|
+
},
|
|
95
|
+
"overall_correctness": "needs refactoring" | "code is clean",
|
|
96
|
+
"overall_explanation": "<1-3 sentence justification>",
|
|
97
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
If there are no findings, return:
|
|
101
|
+
|
|
102
|
+
{
|
|
103
|
+
"findings": [],
|
|
104
|
+
"refactoring_plan": {
|
|
105
|
+
"scope": "module",
|
|
106
|
+
"summary": "No refactoring needed.",
|
|
107
|
+
"estimated_files_affected": 0,
|
|
108
|
+
"steps": [],
|
|
109
|
+
"estimated_blast_radius": "none"
|
|
110
|
+
},
|
|
111
|
+
"overall_correctness": "code is clean",
|
|
112
|
+
"overall_explanation": "<brief justification>",
|
|
113
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
114
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
You are a code reviewer analyzing a proposed change.
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
- **Current branch**: ${CURRENT_BRANCH}
|
|
6
|
+
- **Target branch**: ${TARGET_BRANCH}
|
|
7
|
+
- **Review iteration**: ${ITERATION}
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
Start by running the following command to get the diff:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
git diff ${TARGET_BRANCH}...${CURRENT_BRANCH}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Then **actively explore the codebase** to understand context before flagging issues:
|
|
18
|
+
|
|
19
|
+
- Read surrounding code when a change touches a function or module.
|
|
20
|
+
- Search for patterns, variables, or functions elsewhere before calling them dead code or flagging a naming issue.
|
|
21
|
+
- Find related files (e.g. tests, configs) that may clarify intent.
|
|
22
|
+
|
|
23
|
+
Review the diff according to the guidelines below.
|
|
24
|
+
|
|
25
|
+
## Review Guidelines — HIGH SIGNAL ONLY
|
|
26
|
+
|
|
27
|
+
We only want findings where you are confident the issue is real. **If you are not certain an issue is real, do not flag it.** False positives erode trust and waste reviewer time.
|
|
28
|
+
|
|
29
|
+
1. Only flag issues the original author would fix if they knew about them.
|
|
30
|
+
2. The issue must be **introduced by this diff** — do not flag pre-existing problems.
|
|
31
|
+
3. The issue must be discrete, actionable, and concretely provable.
|
|
32
|
+
4. Do not flag trivial style issues unless they obscure meaning or violate documented standards.
|
|
33
|
+
5. Do not speculate — you must identify the exact code location and explain why it is a problem.
|
|
34
|
+
6. If this is iteration > 1, focus on whether issues from prior reviews have been properly fixed, and identify any new issues introduced by the fixes.
|
|
35
|
+
7. **Only flag issues where your confidence is >= 0.85.** If you cannot reach that threshold after investigating, do not include the finding.
|
|
36
|
+
|
|
37
|
+
### Do NOT flag (false positive filter)
|
|
38
|
+
|
|
39
|
+
- Pre-existing issues not introduced by this diff.
|
|
40
|
+
- Something that appears to be a bug but is actually correct when you read the surrounding code.
|
|
41
|
+
- Pedantic nitpicks that a senior engineer would not flag in a real review.
|
|
42
|
+
- Issues that a linter or formatter will catch — do not run the linter to verify.
|
|
43
|
+
- Potential issues that depend on specific inputs or state that are not demonstrated in the diff.
|
|
44
|
+
- General code quality concerns (e.g. lack of test coverage, general security hygiene) unless they are concretely exploitable.
|
|
45
|
+
|
|
46
|
+
## Priority Levels
|
|
47
|
+
|
|
48
|
+
- **P0** — Drop everything. Blocking release, operations, or major usage. Universal issues not dependent on assumptions.
|
|
49
|
+
- **P1** — Urgent. Should be addressed in the next cycle.
|
|
50
|
+
- **P2** — Normal. To be fixed eventually.
|
|
51
|
+
- **P3** — Low. Nice to have.
|
|
52
|
+
|
|
53
|
+
## Comment Guidelines
|
|
54
|
+
|
|
55
|
+
- One comment per distinct issue.
|
|
56
|
+
- Brief (at most 1 paragraph body).
|
|
57
|
+
- Clearly state the scenarios/inputs required for the bug to manifest.
|
|
58
|
+
- Matter-of-fact tone, no flattery.
|
|
59
|
+
- Code snippets max 3 lines, wrapped in markdown code tags.
|
|
60
|
+
|
|
61
|
+
## Output Format
|
|
62
|
+
|
|
63
|
+
Output **only** valid JSON matching this schema exactly. Do NOT wrap in markdown fences or add any text outside the JSON.
|
|
64
|
+
|
|
65
|
+
{
|
|
66
|
+
"findings": [
|
|
67
|
+
{
|
|
68
|
+
"title": "<P-tag + imperative description, max 80 chars>",
|
|
69
|
+
"body": "<Markdown explaining why this is a problem; cite files/lines/functions>",
|
|
70
|
+
"confidence_score": <float 0.0-1.0>,
|
|
71
|
+
"priority": <int 0-3>,
|
|
72
|
+
"code_location": {
|
|
73
|
+
"file_path": "<repo-relative file path, e.g. src/main.ts>",
|
|
74
|
+
"line_range": {"start": <int>, "end": <int>}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
"overall_correctness": "patch is correct" | "patch is incorrect",
|
|
79
|
+
"overall_explanation": "<1-3 sentence justification>",
|
|
80
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
If there are no findings, return:
|
|
84
|
+
|
|
85
|
+
{
|
|
86
|
+
"findings": [],
|
|
87
|
+
"overall_correctness": "patch is correct",
|
|
88
|
+
"overall_explanation": "<brief justification>",
|
|
89
|
+
"overall_confidence_score": <float 0.0-1.0>
|
|
90
|
+
}
|