opencode-dev-framework 0.1.25 → 0.1.28
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/dist/index.js +51 -20
- package/dist/protect.d.ts +2 -2
- package/dist/protect.js +29 -38
- package/dist/registry.d.ts +11 -6
- package/package.json +1 -1
- package/rules/40-delegation.md +6 -2
- package/templates/.opencode/agents/code-reviewer.md +80 -0
- package/templates/.opencode/skills/code-review/SKILL.md +67 -0
- package/templates/.opencode/skills/peer-review/SKILL.md +29 -23
package/dist/index.js
CHANGED
|
@@ -21,6 +21,18 @@ import { checkToolCall } from "./protect.js";
|
|
|
21
21
|
import { clearSessionDirectory, getHookState, getStateForSession, setBaseDirectory, setHookState, setSessionDirectory, } from "./registry.js";
|
|
22
22
|
import { injectConstitution, loadConstitution } from "./rules.js";
|
|
23
23
|
import { buildTools } from "./tools.js";
|
|
24
|
+
/**
|
|
25
|
+
* Module-level fallback logger, captured at plugin init. `safeLog` uses it when
|
|
26
|
+
* a hook's `HookState.log` is missing or was stripped, so a logging failure can
|
|
27
|
+
* never crash a hook. The original `state.log is not a function` error (seen when
|
|
28
|
+
* switching `off` -> `standard` at runtime) happened because a hook fired against
|
|
29
|
+
* a `HookState` whose `log` was never populated.
|
|
30
|
+
*/
|
|
31
|
+
let fallbackLog = async () => { };
|
|
32
|
+
function safeLog(state, level, message, extra) {
|
|
33
|
+
const fn = typeof state.log === "function" ? state.log : fallbackLog;
|
|
34
|
+
return fn(level, message, extra);
|
|
35
|
+
}
|
|
24
36
|
/**
|
|
25
37
|
* Reload the in-memory config if the config file on disk changed since we last
|
|
26
38
|
* loaded it. This makes out-of-process edits (e.g. a `/df-profile` change made
|
|
@@ -80,7 +92,14 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
80
92
|
const typedConfig = opencodeConfig;
|
|
81
93
|
const state = getHookState(ctx.directory);
|
|
82
94
|
if (state) {
|
|
83
|
-
|
|
95
|
+
// OpenCode's native `permission` is a per-agent tool-to-mode object
|
|
96
|
+
// (e.g. `{ edit: "deny", bash: "deny" }`), not an array. Adopt it when
|
|
97
|
+
// it is a plain object; anything else (array, string, undefined) is
|
|
98
|
+
// ignored so the guardrail falls back to its own evaluation. See
|
|
99
|
+
// hostDenies in protect.ts.
|
|
100
|
+
const perm = typedConfig.permission;
|
|
101
|
+
state.hostPermissions =
|
|
102
|
+
perm !== undefined && typeof perm === "object" && !Array.isArray(perm) ? perm : undefined;
|
|
84
103
|
}
|
|
85
104
|
// `df-profile`, `df-verify`, `df-status`, and `df-help` are all registered
|
|
86
105
|
// as TUI commands (keymap layer with `slashName`) in `tui.tsx`. TUI
|
|
@@ -97,9 +116,12 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
97
116
|
if (input.sessionID) {
|
|
98
117
|
setSessionDirectory(input.sessionID, state.directory);
|
|
99
118
|
}
|
|
119
|
+
if (state.config.profile === "off") {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
100
122
|
const next = injectConstitution(output.system, state.constitution);
|
|
101
123
|
if (next !== output.system) {
|
|
102
|
-
await state
|
|
124
|
+
await safeLog(state, "info", "constitution injected into system prompt");
|
|
103
125
|
output.system = next;
|
|
104
126
|
}
|
|
105
127
|
},
|
|
@@ -109,6 +131,9 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
109
131
|
throw new Error("[opencode-dev-framework] plugin state is not available; guardrail cannot evaluate this tool call");
|
|
110
132
|
}
|
|
111
133
|
await reloadConfigIfChanged(state);
|
|
134
|
+
if (state.config.profile === "off") {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
112
137
|
const result = checkToolCall(state.config, input.tool, output.args, state.directory, state.hostPermissions);
|
|
113
138
|
if (result.decision === "allow") {
|
|
114
139
|
return;
|
|
@@ -120,10 +145,10 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
120
145
|
pattern: result.matchedPattern,
|
|
121
146
|
};
|
|
122
147
|
if (result.decision === "warn") {
|
|
123
|
-
await state
|
|
148
|
+
await safeLog(state, "warn", message, extra);
|
|
124
149
|
return;
|
|
125
150
|
}
|
|
126
|
-
await state
|
|
151
|
+
await safeLog(state, "error", message, extra);
|
|
127
152
|
throw new Error(`[opencode-dev-framework] ${message}`);
|
|
128
153
|
},
|
|
129
154
|
"experimental.session.stopping": async (input, output) => {
|
|
@@ -149,11 +174,11 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
149
174
|
// Standing down: clear the tracker so the session.idle fallback does
|
|
150
175
|
// not re-run the same failing gate commands a second time.
|
|
151
176
|
state.tracker.clearChangedFiles();
|
|
152
|
-
await state
|
|
177
|
+
await safeLog(state, "warn", `completion gate has blocked ${maxBlocks} times; standing down but checks are still failing`, { failedSteps: report.failedSteps.map((step) => step.name) });
|
|
153
178
|
return;
|
|
154
179
|
}
|
|
155
180
|
const summary = summarizeGate(report);
|
|
156
|
-
await state
|
|
181
|
+
await safeLog(state, "error", summary, {
|
|
157
182
|
failedSteps: report.failedSteps.map((step) => step.name),
|
|
158
183
|
});
|
|
159
184
|
output.context.push(`opencode-dev-framework completion gate blocked you from finishing (block ${blockCount}/${maxBlocks}). ` +
|
|
@@ -175,6 +200,9 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
175
200
|
return;
|
|
176
201
|
}
|
|
177
202
|
await reloadConfigIfChanged(state);
|
|
203
|
+
if (state.config.profile === "off") {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
178
206
|
if (event.type === "file.edited") {
|
|
179
207
|
const filePath = event.properties.file;
|
|
180
208
|
state.tracker.add(filePath, state.directory);
|
|
@@ -190,15 +218,18 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
190
218
|
precommitAvailable: state.precommitAvailable,
|
|
191
219
|
});
|
|
192
220
|
if (outcome.skipped) {
|
|
193
|
-
await state
|
|
221
|
+
await safeLog(state, "debug", summarizeLint(outcome), {
|
|
222
|
+
filePath,
|
|
223
|
+
reason: outcome.reason,
|
|
224
|
+
});
|
|
194
225
|
return;
|
|
195
226
|
}
|
|
196
227
|
if (!isLintFailure(outcome)) {
|
|
197
|
-
await state
|
|
228
|
+
await safeLog(state, "info", summarizeLint(outcome), { filePath });
|
|
198
229
|
return;
|
|
199
230
|
}
|
|
200
231
|
const summary = summarizeLint(outcome);
|
|
201
|
-
await state
|
|
232
|
+
await safeLog(state, "error", summary, {
|
|
202
233
|
filePath,
|
|
203
234
|
command: outcome.command?.join(" "),
|
|
204
235
|
stdout: outcome.result?.stdout,
|
|
@@ -213,11 +244,8 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
213
244
|
return;
|
|
214
245
|
}
|
|
215
246
|
if (event.type === "session.idle") {
|
|
216
|
-
if (state.config.profile === "off") {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
247
|
if (!state.config.gate) {
|
|
220
|
-
await state
|
|
248
|
+
await safeLog(state, "warn", "plugin config is incomplete (missing gate section), skipping completion gate", { directory: state.directory });
|
|
221
249
|
return;
|
|
222
250
|
}
|
|
223
251
|
const changedFiles = state.tracker.getChangedFiles();
|
|
@@ -227,17 +255,17 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
227
255
|
state.tracker.clearChangedFiles();
|
|
228
256
|
const summary = summarizeGate(report);
|
|
229
257
|
if (!report.ran) {
|
|
230
|
-
await state
|
|
258
|
+
await safeLog(state, "debug", summary);
|
|
231
259
|
return;
|
|
232
260
|
}
|
|
233
261
|
if (report.ok) {
|
|
234
|
-
await state
|
|
262
|
+
await safeLog(state, "info", summary);
|
|
235
263
|
return;
|
|
236
264
|
}
|
|
237
265
|
// The gate cannot physically block on session.idle (the turn already
|
|
238
266
|
// ended), so failure visibility is the enforcement mechanism.
|
|
239
267
|
const level = state.config.gate.block_on_failure ? "error" : "warn";
|
|
240
|
-
await state
|
|
268
|
+
await safeLog(state, level, summary, {
|
|
241
269
|
failedSteps: report.failedSteps.map((step) => ({
|
|
242
270
|
name: step.name,
|
|
243
271
|
command: step.command?.join(" "),
|
|
@@ -252,6 +280,7 @@ export function buildHooks(ctx, config, log, run = runCommand, tracker = createC
|
|
|
252
280
|
}
|
|
253
281
|
export const devFramework = async (ctx) => {
|
|
254
282
|
const log = createLogger(ctx.client);
|
|
283
|
+
fallbackLog = log;
|
|
255
284
|
let config;
|
|
256
285
|
try {
|
|
257
286
|
config = loadConfig(ctx.directory);
|
|
@@ -271,10 +300,12 @@ export const devFramework = async (ctx) => {
|
|
|
271
300
|
}
|
|
272
301
|
return {};
|
|
273
302
|
}
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
303
|
+
// Hooks are now registered for every profile; each enforcement hook gates its
|
|
304
|
+
// own behavior by `state.config.profile` (off => no-op). Registering always
|
|
305
|
+
// guarantees HookState.log is populated at init, so a runtime `off` -> `standard`
|
|
306
|
+
// switch (via /df-profile) takes effect on the next hook call via
|
|
307
|
+
// reloadConfigIfChanged — no restart required — and a hook can never crash on a
|
|
308
|
+
// missing `log` (see safeLog).
|
|
278
309
|
setBaseDirectory(ctx.directory);
|
|
279
310
|
const { constitution, warning } = await loadConstitution(config, ctx.directory);
|
|
280
311
|
if (warning) {
|
package/dist/protect.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* shell commands. Pure functions — the OpenCode hook wiring lives in
|
|
4
4
|
* src/index.ts.
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
6
|
+
import type { OpenCodePermission } from "./registry.js";
|
|
7
7
|
import type { ResolvedConfig } from "./types.js";
|
|
8
8
|
export type GuardDecision = "allow" | "warn" | "deny";
|
|
9
9
|
export interface GuardResult {
|
|
@@ -41,4 +41,4 @@ export declare function matchDangerousCommand(command: string): DangerousCommand
|
|
|
41
41
|
* `protect_off: true`), when the tool is not guarded, or when nothing
|
|
42
42
|
* matched. Otherwise returns `deny` or `warn` per `protect_mode`.
|
|
43
43
|
*/
|
|
44
|
-
export declare function checkToolCall(config: ResolvedConfig, tool: string, args: unknown, directory?: string, hostPermissions?:
|
|
44
|
+
export declare function checkToolCall(config: ResolvedConfig, tool: string, args: unknown, directory?: string, hostPermissions?: OpenCodePermission): GuardResult;
|
package/dist/protect.js
CHANGED
|
@@ -79,44 +79,35 @@ export function matchProtectedPath(config, filePath, directory) {
|
|
|
79
79
|
export function matchDangerousCommand(command) {
|
|
80
80
|
return DANGEROUS_COMMANDS.find(({ pattern }) => pattern.test(command));
|
|
81
81
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
/**
|
|
83
|
+
* Check whether the host OpenCode config already denies this tool.
|
|
84
|
+
*
|
|
85
|
+
* OpenCode's native `permission` config is a tool-to-mode object (e.g.
|
|
86
|
+
* `{ edit: "deny", bash: "deny" }`). The plugin consults it only to avoid
|
|
87
|
+
* double-blocking: if OpenCode already globally denies the tool a call
|
|
88
|
+
* targets, the plugin stands down and lets OpenCode enforce the denial itself.
|
|
89
|
+
*
|
|
90
|
+
* The mapping from this plugin's tool names to OpenCode's permission keys is:
|
|
91
|
+
* - file tools (edit/write/patch) -> `edit`
|
|
92
|
+
* - shell tools (bash/shell) -> `bash`
|
|
93
|
+
*
|
|
94
|
+
* Only a literal `"deny"` mode stands the plugin down. OpenCode's `bash` may
|
|
95
|
+
* instead be an object map (per-command), whose keys are ambiguous, so we
|
|
96
|
+
* conservatively keep guarding there — at worst redundant noise, never a
|
|
97
|
+
* crash or a missed block. Any non-object input (array, string, undefined) is
|
|
98
|
+
* ignored, falling back to the plugin's own evaluation.
|
|
99
|
+
*/
|
|
100
|
+
function hostDenies(tool, hostPermissions) {
|
|
101
|
+
if (hostPermissions === undefined ||
|
|
102
|
+
typeof hostPermissions !== "object" ||
|
|
103
|
+
Array.isArray(hostPermissions)) {
|
|
97
104
|
return false;
|
|
98
105
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
if (perm.permission && !permissionMatchesTool(perm.permission, tool)) {
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
if (perm.pattern) {
|
|
107
|
-
const matcher = picomatch(perm.pattern, { dot: true });
|
|
108
|
-
let candidate = target;
|
|
109
|
-
if (directory !== undefined && isAbsolute(target)) {
|
|
110
|
-
candidate = relative(directory, target);
|
|
111
|
-
}
|
|
112
|
-
candidate = candidate.replace(/^\.\//, "");
|
|
113
|
-
if (!matcher(candidate) && !matcher(basename(candidate))) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return true;
|
|
106
|
+
const key = FILE_TOOLS.has(tool) ? "edit" : SHELL_TOOLS.has(tool) ? "bash" : undefined;
|
|
107
|
+
if (key === undefined) {
|
|
108
|
+
return false;
|
|
118
109
|
}
|
|
119
|
-
return
|
|
110
|
+
return hostPermissions[key] === "deny";
|
|
120
111
|
}
|
|
121
112
|
function enforce(config, reason, matchedPattern) {
|
|
122
113
|
if (config.protect_mode === "deny") {
|
|
@@ -140,9 +131,9 @@ export function checkToolCall(config, tool, args, directory, hostPermissions) {
|
|
|
140
131
|
if (filePath === undefined) {
|
|
141
132
|
return { decision: "allow" };
|
|
142
133
|
}
|
|
143
|
-
// If the host permission model already denies this
|
|
134
|
+
// If the host permission model already denies this tool, do not duplicate
|
|
144
135
|
// the block here.
|
|
145
|
-
if (hostDenies(tool,
|
|
136
|
+
if (hostDenies(tool, hostPermissions)) {
|
|
146
137
|
return { decision: "allow" };
|
|
147
138
|
}
|
|
148
139
|
const pattern = matchProtectedPath(config, filePath, directory);
|
|
@@ -156,7 +147,7 @@ export function checkToolCall(config, tool, args, directory, hostPermissions) {
|
|
|
156
147
|
if (command === undefined) {
|
|
157
148
|
return { decision: "allow" };
|
|
158
149
|
}
|
|
159
|
-
if (hostDenies(tool,
|
|
150
|
+
if (hostDenies(tool, hostPermissions)) {
|
|
160
151
|
return { decision: "allow" };
|
|
161
152
|
}
|
|
162
153
|
const dangerous = matchDangerousCommand(command);
|
package/dist/registry.d.ts
CHANGED
|
@@ -2,11 +2,16 @@ import type { ChangedFileTracker } from "./gate.js";
|
|
|
2
2
|
import type { RunCommand } from "./host.js";
|
|
3
3
|
import type { LogFn } from "./logger.js";
|
|
4
4
|
import type { ResolvedConfig } from "./types.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
/**
|
|
6
|
+
* OpenCode's native `permission` config is a per-agent, tool-to-mode object
|
|
7
|
+
* (e.g. `{ edit: "deny", bash: "deny", read: "allow", task: {...} }`), not an
|
|
8
|
+
* array. The plugin consults it only to avoid double-blocking: when OpenCode
|
|
9
|
+
* already globally denies a tool, the guardrail stands down and lets OpenCode
|
|
10
|
+
* enforce the denial. Path-scoped rules (e.g. "deny writes to .env") are not
|
|
11
|
+
* expressible in OpenCode's permission model, so the plugin keeps guarding
|
|
12
|
+
* those itself.
|
|
13
|
+
*/
|
|
14
|
+
export type OpenCodePermission = Record<string, unknown>;
|
|
10
15
|
export interface HookState {
|
|
11
16
|
/** Project directory this state belongs to. Stored here (rather than
|
|
12
17
|
* closure-captured by hooks) so every hook invocation is self-contained. */
|
|
@@ -21,7 +26,7 @@ export interface HookState {
|
|
|
21
26
|
/** Cached result of checking whether `pre-commit` is available. */
|
|
22
27
|
precommitAvailable?: boolean;
|
|
23
28
|
/** Snapshot of host permissions from OpenCode's effective config. */
|
|
24
|
-
hostPermissions?:
|
|
29
|
+
hostPermissions?: OpenCodePermission;
|
|
25
30
|
/** Show a non-chat TUI toast (used for slash-command results). */
|
|
26
31
|
showToast?: (message: string, variant?: "info" | "success" | "warning" | "error") => void;
|
|
27
32
|
/** mtime (ms) of the config file at last load; used to detect out-of-process
|
package/package.json
CHANGED
package/rules/40-delegation.md
CHANGED
|
@@ -20,6 +20,10 @@ a description and ask them to report findings; do not ask them to edit product c
|
|
|
20
20
|
- **`test-grounder`** — audits whether your claims are backed by evidence: is there a
|
|
21
21
|
test that fails without the change? do the cited commands actually pass? did you
|
|
22
22
|
verify the edge cases? Use it before declaring a task done.
|
|
23
|
+
- **`code-reviewer`** — checks changed code for correctness defects: logic errors,
|
|
24
|
+
unsafe edge cases, security issues, and concurrency/resource leaks. Use it after
|
|
25
|
+
a batch of edits, alongside `style-enforcer` and `pattern-guardian`, before the
|
|
26
|
+
completion gate. (Investigation-only, like the others.)
|
|
23
27
|
|
|
24
28
|
You may also ask the built-in review or planning agents for a general high-signal
|
|
25
29
|
second opinion — the best moment is after planning, before implementing, and again
|
|
@@ -42,8 +46,8 @@ checks yourself with the skills in this section.
|
|
|
42
46
|
## Skills
|
|
43
47
|
|
|
44
48
|
For explicit, repeatable workflows you can invoke the bundled skills:
|
|
45
|
-
**`peer-review`**, **`ground-in-tests`**, and
|
|
46
|
-
steps above so you run them consistently.
|
|
49
|
+
**`peer-review`**, **`code-review`**, **`ground-in-tests`**, and
|
|
50
|
+
**`match-patterns`**. They codify the steps above so you run them consistently.
|
|
47
51
|
|
|
48
52
|
## Acting on feedback
|
|
49
53
|
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-reviewer
|
|
3
|
+
description: >
|
|
4
|
+
Correctness reviewer. Scans changed code for bugs, logic errors, security
|
|
5
|
+
issues, and unsafe edge cases — independent of style and pattern concerns.
|
|
6
|
+
Use after a batch of edits and before declaring a non-trivial change done.
|
|
7
|
+
Investigation only — never edits.
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
You are the **code-reviewer**: your only job is to catch correctness problems in
|
|
11
|
+
changed code — the things that break at runtime, corrupt data, leak resources,
|
|
12
|
+
or let attackers in. Style and pattern concerns belong to other reviewers
|
|
13
|
+
(`style-enforcer`, `pattern-guardian`); you focus on whether the code is
|
|
14
|
+
*correct and safe*.
|
|
15
|
+
|
|
16
|
+
## Your mission
|
|
17
|
+
|
|
18
|
+
Given a set of changed files (a diff), find genuine defects:
|
|
19
|
+
|
|
20
|
+
1. **Logic errors** — wrong conditions, off-by-one, inverted booleans,
|
|
21
|
+
unreachable branches, operator precedence mistakes, assumptions that don't
|
|
22
|
+
hold (e.g. "this can't be null"), mutation of shared state, stale closures,
|
|
23
|
+
swapped arguments.
|
|
24
|
+
2. **Edge cases** — empty input, zero, negative, max, missing keys, first/last
|
|
25
|
+
element, concurrent callers, retries, partial failure, encoding/Unicode,
|
|
26
|
+
timezones, locale.
|
|
27
|
+
3. **Security** — unvalidated input, injection (SQL / command / XML / path),
|
|
28
|
+
path traversal, insecure defaults, secrets committed or logged, authorization
|
|
29
|
+
checks skipped, unsafe deserialization, weak randomness, TOCTOU.
|
|
30
|
+
4. **Concurrency & resources** — races, deadlocks, missing locks, leaked
|
|
31
|
+
handles / connections / goroutines, blocking calls on hot paths, unbounded
|
|
32
|
+
growth, forgetting to close / await / release.
|
|
33
|
+
5. **Correctness vs intent** — does the change actually do what the surrounding
|
|
34
|
+
code and the task say it should? Watch for copy-paste that silently changed
|
|
35
|
+
behavior, or a "fix" that breaks an adjacent path.
|
|
36
|
+
6. **Red flags** — leftover debug code, `console.log` / `print` left in,
|
|
37
|
+
TODO/FIXME that ships a known-broken path, commented-out code hiding a real
|
|
38
|
+
fix, swallowed errors (`catch {}`), assertions that can't fail.
|
|
39
|
+
|
|
40
|
+
## How to work
|
|
41
|
+
|
|
42
|
+
1. Get the change scope via git:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git --no-pager diff --staged
|
|
46
|
+
git --no-pager diff
|
|
47
|
+
# if the tree is clean, review the branch: git --no-pager diff main...HEAD
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
2. Read the changed files in full — a defect often spans the edit boundary, so
|
|
51
|
+
the surrounding function matters as much as the diff hunk.
|
|
52
|
+
3. For each suspicion, read enough context to confirm it is real. Do not flag
|
|
53
|
+
hypotheticals you haven't verified against the code.
|
|
54
|
+
4. If the project has tests, you may run the relevant ones to confirm a defect
|
|
55
|
+
reproduces (or to check a fix), but prefer reporting findings with evidence.
|
|
56
|
+
|
|
57
|
+
## Output
|
|
58
|
+
|
|
59
|
+
Report only genuine, actionable defects against the changed code. For each:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
## Bug: [short title]
|
|
63
|
+
**Where:** path/to/file.ext:line
|
|
64
|
+
**Severity:** Blocking | Should-fix | Note
|
|
65
|
+
**Evidence:** the code path / input that triggers it
|
|
66
|
+
**Impact:** what actually breaks
|
|
67
|
+
**Fix:** the concrete correction (do not implement it)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
If the changed code is correct, say exactly: "No correctness issues — changes
|
|
71
|
+
look sound." If you found only minor notes, list them under **Note**.
|
|
72
|
+
|
|
73
|
+
## Hard rules
|
|
74
|
+
|
|
75
|
+
- **Investigation only. Never use `edit` or `create`. Never modify files.**
|
|
76
|
+
- Every finding must be a real defect you verified against the code, with a file
|
|
77
|
+
and line. No style nits, no "consider using X" preferences — those belong to
|
|
78
|
+
other reviewers.
|
|
79
|
+
- High bar, high signal. A wrong or speculative report is worse than silence.
|
|
80
|
+
- All file paths in your report must be absolute.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-review
|
|
3
|
+
description: >
|
|
4
|
+
Standalone correctness review of the current changes. Delegates to the
|
|
5
|
+
code-reviewer agent for bugs, logic errors, security, and resource/concurrency
|
|
6
|
+
issues, then drives the blocking findings to resolution. Use directly (instead
|
|
7
|
+
of the broader peer-review pass) when you want a focused correctness audit —
|
|
8
|
+
e.g. after a batch of edits, before a commit, or when the user asks for a
|
|
9
|
+
code review.
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Code Review
|
|
13
|
+
|
|
14
|
+
A focused, correctness-first audit of what you just changed — independent of
|
|
15
|
+
style and pattern concerns (those live in `style-enforcer` / `pattern-guardian`
|
|
16
|
+
and the broader `peer-review` pass).
|
|
17
|
+
|
|
18
|
+
## When to use
|
|
19
|
+
|
|
20
|
+
- After a non-trivial batch of edits and before you declare it done.
|
|
21
|
+
- Before committing or opening a PR.
|
|
22
|
+
- When the user explicitly asks for a code review or "check my changes".
|
|
23
|
+
- As a lighter-weight alternative to the full peer-review pass when you only
|
|
24
|
+
care about correctness.
|
|
25
|
+
|
|
26
|
+
## Steps
|
|
27
|
+
|
|
28
|
+
1. **Scope the change.** Get exactly what changed:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git --no-pager diff --staged
|
|
32
|
+
git --no-pager diff
|
|
33
|
+
# if the tree is clean, review the branch: git --no-pager diff main...HEAD
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If there is nothing to review, say so and stop.
|
|
37
|
+
|
|
38
|
+
2. **Run the code-reviewer pass.** Delegate to the **code-reviewer** agent,
|
|
39
|
+
giving it the diff scope and the paths that changed. The agent is
|
|
40
|
+
investigation-only: it returns `Blocking` / `Should-fix` / `Note` findings
|
|
41
|
+
with absolute file paths and line numbers, and never edits.
|
|
42
|
+
|
|
43
|
+
If the `code-reviewer` agent is not installed in this project (or cannot be
|
|
44
|
+
invoked in the current environment), perform the pass yourself inline: read
|
|
45
|
+
the diff in full, and for each changed file check for logic errors, unsafe
|
|
46
|
+
edge cases, security issues, and concurrency/resource leaks, reporting the
|
|
47
|
+
same `Blocking` / `Should-fix` / `Note` findings.
|
|
48
|
+
|
|
49
|
+
3. **Triage.** Drop duplicates and anything non-actionable. Group by severity:
|
|
50
|
+
**Blocking**, **Should-fix**, **Note**.
|
|
51
|
+
|
|
52
|
+
4. **Act, don't just report.** For every **Blocking** and **Should-fix** item:
|
|
53
|
+
fix it now (you may edit here — the agent may not), or state precisely why
|
|
54
|
+
it does not apply. Do not produce a list of issues you then leave
|
|
55
|
+
unaddressed.
|
|
56
|
+
|
|
57
|
+
5. **Confirm.** Re-run the code-reviewer pass after non-trivial fixes, until no
|
|
58
|
+
blocking items remain.
|
|
59
|
+
|
|
60
|
+
## Output
|
|
61
|
+
|
|
62
|
+
A short list grouped by **Blocking / Should-fix / Note**, and for each the
|
|
63
|
+
action you took. If the review found nothing, say "Code review clean — no
|
|
64
|
+
blocking issues."
|
|
65
|
+
|
|
66
|
+
> For the broader review (consistency + style + correctness together), use the
|
|
67
|
+
> **peer-review** skill instead.
|
|
@@ -3,7 +3,7 @@ name: peer-review
|
|
|
3
3
|
description: >
|
|
4
4
|
Run a continuous-peer-review pass over the current changes to prevent
|
|
5
5
|
fragmentation and drift before completion. Orchestrates the pattern-guardian,
|
|
6
|
-
style-enforcer, and
|
|
6
|
+
style-enforcer, and code-reviewer agents, then consolidates only the
|
|
7
7
|
blocking items. Use after a batch of edits and before declaring a non-trivial
|
|
8
8
|
change done.
|
|
9
9
|
---
|
|
@@ -20,34 +20,40 @@ whenever the user asks for a review of the current changes.
|
|
|
20
20
|
|
|
21
21
|
## Steps
|
|
22
22
|
|
|
23
|
-
1. **Scope the change.** Determine exactly what changed:
|
|
23
|
+
1. **Scope the change.** Determine exactly what changed:
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
```bash
|
|
26
|
+
git --no-pager diff --staged
|
|
27
|
+
git --no-pager diff
|
|
28
|
+
# if the tree is clean, review the branch: git --no-pager diff main...HEAD
|
|
29
|
+
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
If there is nothing to review, say so and stop.
|
|
32
32
|
|
|
33
|
-
2. **Run the specialists in parallel.** Delegate each as a subagent, giving
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
2. **Run the specialists in parallel.** Delegate each as a subagent, giving
|
|
34
|
+
each the diff scope and the relevant file paths:
|
|
35
|
+
- **pattern-guardian** — duplication, re-invented helpers, divergent
|
|
36
|
+
conventions, a second way to do a thing, unjustified new dependencies.
|
|
37
|
+
- **style-enforcer** — adherence to the project style guide / lint config /
|
|
38
|
+
local conventions on the changed files.
|
|
39
|
+
- **code-reviewer** — general correctness: bugs, logic errors, security,
|
|
40
|
+
resource/concurrency issues. High bar, high signal only.
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
If the `code-reviewer` agent is not installed in this project (or cannot be
|
|
43
|
+
invoked in the current environment), perform that correctness pass yourself
|
|
44
|
+
inline: read the diff in full, and for each changed file check for logic
|
|
45
|
+
errors, unsafe edge cases, security issues, and concurrency/resource leaks,
|
|
46
|
+
reporting the same `Blocking` / `Should-fix` / `Note` findings.
|
|
44
47
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
issues you then leave unaddressed.
|
|
48
|
+
3. **Consolidate.** Merge their findings. Drop duplicates and anything
|
|
49
|
+
non-actionable. Group by severity: **Blocking**, **Should-fix**, **Note**.
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
4. **Act, don't summarize.** For every Blocking and Should-fix item: fix it
|
|
52
|
+
now, or state precisely why it does not apply. Do not produce a report of
|
|
53
|
+
issues you then leave unaddressed.
|
|
54
|
+
|
|
55
|
+
5. **Confirm.** Re-run the relevant specialist if you made non-trivial fixes,
|
|
56
|
+
until no blocking items remain.
|
|
51
57
|
|
|
52
58
|
## Output
|
|
53
59
|
|