opencode-review-helper 0.1.1 → 0.1.4
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/README.md +28 -49
- package/agents/code-reviewer.md +4 -7
- package/dist/cli.js +54 -9
- package/dist/cli.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -10,57 +10,24 @@ OpenCode plugin for reviewing AI-generated code changes. Helps humans efficientl
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
|
|
13
|
+
bunx opencode-review-helper setup
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
This will:
|
|
17
|
+
1. Add the plugin to your `~/.config/opencode/opencode.jsonc`
|
|
18
|
+
2. Let you choose which model to use for the impact-explorer sub-agent (default: `google/gemini-3-flash`)
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
"plugin": ["opencode-review-helper"]
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Setup
|
|
25
|
-
|
|
26
|
-
Configure the sub-agent model (optional):
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npx opencode-review-helper setup
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
This lets you choose which model to use for the impact-explorer sub-agent (default: `google/gemini-3-flash`).
|
|
20
|
+
Restart opencode after setup to load the plugin.
|
|
33
21
|
|
|
34
22
|
## Usage
|
|
35
23
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### `review_order`
|
|
39
|
-
|
|
40
|
-
Suggests optimal order to review changed files.
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
Use review_order to analyze the changed files
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Output:
|
|
47
|
-
- Prioritized file list with rationale
|
|
48
|
-
- Dependency graph showing import relationships
|
|
49
|
-
- Scores based on: type priority, dependents count, complexity
|
|
50
|
-
|
|
51
|
-
### `impact_analysis`
|
|
52
|
-
|
|
53
|
-
Finds code outside the changeset that could break.
|
|
24
|
+
The plugin provides a `review-helper:code-reviewer` agent that combines both tools. It:
|
|
54
25
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
26
|
+
1. Runs `review_order` to determine file review sequence
|
|
27
|
+
2. Runs `impact_analysis` to find affected external code
|
|
28
|
+
3. Formats the tool outputs into a combined report
|
|
58
29
|
|
|
59
|
-
|
|
60
|
-
- Direct consumers (files that import changed code)
|
|
61
|
-
- Transitive impact (files that use files that use changed code)
|
|
62
|
-
- Test coverage gaps (changed files without tests)
|
|
63
|
-
- Recommendations
|
|
30
|
+
The agent does NOT make up its own recommendations or analysis—it only presents what the tools return. It also does NOT automatically run tests or apply fixes.
|
|
64
31
|
|
|
65
32
|
## Configuration
|
|
66
33
|
|
|
@@ -102,15 +69,27 @@ Create `~/.config/opencode/review-helper.json` or `.opencode/review-helper.json`
|
|
|
102
69
|
| `impact_analysis.max_results_per_level` | Max results per category | `50` |
|
|
103
70
|
| `impact_analysis.exclude_patterns` | Glob patterns to skip | Test files |
|
|
104
71
|
|
|
105
|
-
##
|
|
72
|
+
## Tools
|
|
106
73
|
|
|
107
|
-
The plugin
|
|
74
|
+
The plugin also exposes two tools directly:
|
|
108
75
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
76
|
+
### `review_order`
|
|
77
|
+
|
|
78
|
+
Suggests optimal order to review changed files.
|
|
112
79
|
|
|
113
|
-
|
|
80
|
+
Output:
|
|
81
|
+
- Prioritized file list with rationale
|
|
82
|
+
- Dependency graph showing import relationships
|
|
83
|
+
- Scores based on: type priority, dependents count, complexity
|
|
84
|
+
|
|
85
|
+
### `impact_analysis`
|
|
86
|
+
|
|
87
|
+
Finds code outside the changeset that could break.
|
|
88
|
+
|
|
89
|
+
Output:
|
|
90
|
+
- Direct consumers (files that import changed code)
|
|
91
|
+
- Transitive impact (files that use files that use changed code)
|
|
92
|
+
- Test coverage gaps (changed files without tests)
|
|
114
93
|
|
|
115
94
|
## License
|
|
116
95
|
|
package/agents/code-reviewer.md
CHANGED
|
@@ -61,9 +61,9 @@ Use the `impact_analysis` tool:
|
|
|
61
61
|
- Flags files without test coverage
|
|
62
62
|
- Reports potential breaking changes
|
|
63
63
|
|
|
64
|
-
### Step 3:
|
|
64
|
+
### Step 3: Present Findings
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
Format and present the tool outputs clearly:
|
|
67
67
|
|
|
68
68
|
```
|
|
69
69
|
## Review Order
|
|
@@ -81,13 +81,10 @@ Present findings clearly:
|
|
|
81
81
|
|
|
82
82
|
### Test Coverage Gaps
|
|
83
83
|
- `src/models/user.ts` has no corresponding test file
|
|
84
|
-
|
|
85
|
-
## Recommendations
|
|
86
|
-
- Review migrations first - they affect all downstream code
|
|
87
|
-
- Check `src/api/auth.ts` for compatibility with User changes
|
|
88
|
-
- Consider adding tests for `src/models/user.ts`
|
|
89
84
|
```
|
|
90
85
|
|
|
86
|
+
Do NOT add your own recommendations or analysis beyond what the tools return.
|
|
87
|
+
|
|
91
88
|
## Key Principles
|
|
92
89
|
|
|
93
90
|
- **Focus on integration boundaries** - where AI often misses issues
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { saveGlobalConfig } from "./config.js";
|
|
3
3
|
import { createInterface } from "node:readline";
|
|
4
|
+
import { readFile, writeFile, mkdir } from "node:fs/promises";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import JSONC from "tiny-jsonc";
|
|
9
|
+
const PLUGIN_NAME = "opencode-review-helper";
|
|
4
10
|
const MODELS = [
|
|
5
11
|
{ value: "google/gemini-3-flash", label: "Google Gemini 3 Flash (fast, recommended)" },
|
|
6
12
|
{ value: "google/gemini-3-flash-lite", label: "Google Gemini 3 Flash Lite (fastest)" },
|
|
@@ -19,9 +25,52 @@ async function prompt(question) {
|
|
|
19
25
|
});
|
|
20
26
|
});
|
|
21
27
|
}
|
|
28
|
+
function getOpencodeConfigPath() {
|
|
29
|
+
const paths = [
|
|
30
|
+
join(homedir(), ".config", "opencode", "opencode.jsonc"),
|
|
31
|
+
join(homedir(), ".config", "opencode", "opencode.json"),
|
|
32
|
+
];
|
|
33
|
+
for (const p of paths) {
|
|
34
|
+
if (existsSync(p))
|
|
35
|
+
return p;
|
|
36
|
+
}
|
|
37
|
+
return paths[0];
|
|
38
|
+
}
|
|
39
|
+
async function ensurePluginInConfig() {
|
|
40
|
+
const configPath = getOpencodeConfigPath();
|
|
41
|
+
const configDir = join(homedir(), ".config", "opencode");
|
|
42
|
+
await mkdir(configDir, { recursive: true });
|
|
43
|
+
let config = {};
|
|
44
|
+
if (existsSync(configPath)) {
|
|
45
|
+
const content = await readFile(configPath, "utf-8");
|
|
46
|
+
try {
|
|
47
|
+
config = JSONC.parse(content);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
console.error(`Warning: Could not parse ${configPath}`);
|
|
51
|
+
return { added: false, path: configPath };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const plugins = config.plugin || [];
|
|
55
|
+
const hasPlugin = plugins.some((p) => p === PLUGIN_NAME || p.startsWith(`${PLUGIN_NAME}@`));
|
|
56
|
+
if (hasPlugin) {
|
|
57
|
+
return { added: false, path: configPath };
|
|
58
|
+
}
|
|
59
|
+
config.plugin = [...plugins, PLUGIN_NAME];
|
|
60
|
+
await writeFile(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
61
|
+
return { added: true, path: configPath };
|
|
62
|
+
}
|
|
22
63
|
async function setup() {
|
|
23
64
|
console.log("\n🔍 OpenCode Review Helper - Setup\n");
|
|
24
|
-
console.log("
|
|
65
|
+
console.log("Step 1: Configuring opencode.jsonc...\n");
|
|
66
|
+
const { added, path } = await ensurePluginInConfig();
|
|
67
|
+
if (added) {
|
|
68
|
+
console.log(` ✅ Added plugin to ${path}\n`);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.log(` ✅ Plugin already configured in ${path}\n`);
|
|
72
|
+
}
|
|
73
|
+
console.log("Step 2: Select model for impact-explorer sub-agent:\n");
|
|
25
74
|
MODELS.forEach((m, i) => {
|
|
26
75
|
console.log(` ${i + 1}. ${m.label}`);
|
|
27
76
|
});
|
|
@@ -49,23 +98,19 @@ async function setup() {
|
|
|
49
98
|
explorer: selectedModel,
|
|
50
99
|
},
|
|
51
100
|
});
|
|
52
|
-
console.log(`\n✅
|
|
101
|
+
console.log(`\n✅ Setup complete!`);
|
|
53
102
|
console.log(` Explorer model: ${selectedModel}`);
|
|
54
|
-
console.log(`
|
|
55
|
-
console.log(
|
|
56
|
-
console.log(' { "plugin": ["opencode-review-helper"] }\n');
|
|
103
|
+
console.log(` Plugin config: ~/.config/opencode/review-helper.json`);
|
|
104
|
+
console.log(`\n Restart opencode to use the plugin.\n`);
|
|
57
105
|
}
|
|
58
106
|
function showHelp() {
|
|
59
107
|
console.log(`
|
|
60
108
|
opencode-review-helper - OpenCode plugin for AI code review
|
|
61
109
|
|
|
62
110
|
Commands:
|
|
63
|
-
setup Configure the plugin (model selection)
|
|
111
|
+
setup Configure the plugin (adds to opencode.jsonc + model selection)
|
|
64
112
|
help Show this help message
|
|
65
113
|
|
|
66
|
-
Usage in opencode.jsonc:
|
|
67
|
-
{ "plugin": ["opencode-review-helper"] }
|
|
68
|
-
|
|
69
114
|
Tools provided:
|
|
70
115
|
review_order - Suggests optimal order to review changed files
|
|
71
116
|
impact_analysis - Finds code outside changeset that could be affected
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,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AAQ,CAAC;IACd,KAAK,IAAI,CAAC;IACV;QACE,QAAQ,EAAE,CAAC;QACX,MAAM;AACV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-review-helper",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "OpenCode plugin for reviewing AI-generated code changes - suggests review order and analyzes impact",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@opencode-ai/plugin": "^1.0.209",
|
|
27
|
+
"tiny-jsonc": "^1.0.2",
|
|
27
28
|
"zod": "^4.1.8"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|