Skip to content

Commit 396845f

Browse files
fix(cli): handle argument-based /review invocations in deprecated command
When /review is called with a commit SHA, branch name, or PR URL, the previous implementation silently fell through to /local-review-uncommitted, reviewing uncommitted changes instead of the intended target. The new deprecated-review template detects these argument patterns and redirects the user to /local-review with their original arguments, rather than silently reviewing the wrong diff scope.
1 parent 69e5c58 commit 396845f

4 files changed

Lines changed: 189 additions & 15 deletions

File tree

.changeset/fix-review-command-issues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@kilocode/cli": patch
33
---
44

5-
Remove unused `PROMPT_REVIEW` import and reuse `localReviewUncommittedCommand` result in command registry.
5+
Redirect deprecated `/review` command: detect commit/branch/PR arguments and guide users to `/local-review` instead of silently reviewing uncommitted changes.

packages/opencode/src/command/index.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Effect, Layer, Context, Schema } from "effect"
77
import { Config } from "@/config/config"
88
import { MCP } from "../mcp"
99
import { Skill } from "../skill"
10-
import { localReviewCommand, localReviewUncommittedCommand } from "@/kilocode/review/command" // kilocode_change
10+
import { localReviewCommand, localReviewUncommittedCommand, deprecatedReviewCommand } from "@/kilocode/review/command" // kilocode_change
1111
import PROMPT_INITIALIZE from "./template/initialize.txt"
1212

1313
type State = {
@@ -110,23 +110,12 @@ export const layer = Layer.effect(
110110
hints: hints(PROMPT_INITIALIZE),
111111
}
112112
// kilocode_change start - redirect deprecated /review to /local-review-uncommitted
113-
const uncommittedReview = localReviewUncommittedCommand()
114-
commands[Default.REVIEW] = {
115-
name: Default.REVIEW,
116-
description: "DEPRECATED: use /local-review-uncommitted instead",
117-
source: "command",
118-
get template() {
119-
return `⚠️ DEPRECATION NOTICE: The /review command is deprecated. Please use /local-review-uncommitted for uncommitted changes or /local-review for branch reviews.
120-
121-
${uncommittedReview.template}`
122-
},
123-
hints: uncommittedReview.hints,
124-
}
113+
commands[Default.REVIEW] = { ...deprecatedReviewCommand(), source: "command" }
125114
// kilocode_change end
126115

127116
// kilocode_change start
128117
commands[Default.LOCAL_REVIEW] = localReviewCommand()
129-
commands[Default.LOCAL_REVIEW_UNCOMMITTED] = uncommittedReview
118+
commands[Default.LOCAL_REVIEW_UNCOMMITTED] = localReviewUncommittedCommand()
130119
// kilocode_change end
131120

132121
for (const [name, command] of Object.entries(cfg.command ?? {})) {

packages/opencode/src/kilocode/review/command.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Command } from "@/command"
22
import type { ReviewCommand } from "@kilocode/kilo-telemetry"
33
import LOCAL_REVIEW from "./local-review.txt"
44
import LOCAL_REVIEW_UNCOMMITTED from "./local-review-uncommitted.txt"
5+
import DEPRECATED_REVIEW from "./deprecated-review.txt"
56

67
export function isReviewCommand(command: string | undefined): command is ReviewCommand {
78
return command === "review" || command === "local-review" || command === "local-review-uncommitted"
@@ -13,6 +14,18 @@ export function parseReviewCommand(prompt: string | undefined): ReviewCommand |
1314
if (isReviewCommand(name)) return name
1415
}
1516

17+
/**
18+
* /review (deprecated) - redirects argument-based calls to /local-review, falls back to uncommitted review
19+
*/
20+
export function deprecatedReviewCommand(): Command.Info {
21+
return {
22+
name: "review",
23+
description: "DEPRECATED: use /local-review-uncommitted or /local-review instead",
24+
template: DEPRECATED_REVIEW,
25+
hints: ["$ARGUMENTS"],
26+
}
27+
}
28+
1629
/**
1730
* /local-review-uncommitted - local review (uncommitted changes)
1831
*/
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
⚠️ **DEPRECATION NOTICE**: The `/review` command is deprecated. Use `/local-review-uncommitted` for uncommitted changes or `/local-review` for branch/commit reviews.
2+
3+
---
4+
5+
## User Input
6+
7+
$ARGUMENTS
8+
9+
---
10+
11+
## STEP 1 — Classify the user input
12+
13+
Look at the User Input above and decide which case applies:
14+
15+
**Case A — Targeted review** (user passed a commit SHA, branch name, tag, or PR URL):
16+
- A commit SHA looks like: `abc1234`, `abc1234def5`, a 40-character hex string, or `HEAD~3`
17+
- A branch name looks like: `main`, `feature/foo`, `origin/dev`, `release/next`, or any slash-separated path
18+
- A PR URL looks like: `https://github.com/...` or a short reference such as `#1234`
19+
- A tag looks like: `v1.0.0`, `release-2024-01`
20+
21+
If the input matches Case A, **do not perform a review**. Instead, output this message and stop:
22+
23+
```
24+
❌ The /review command no longer accepts commit, branch, or PR arguments.
25+
26+
Your argument: $ARGUMENTS
27+
28+
Please use the correct command instead:
29+
- For reviewing the current branch against a base: /local-review $ARGUMENTS
30+
- For reviewing uncommitted changes only: /local-review-uncommitted
31+
```
32+
33+
**Case B — Free-form guidance or empty input**:
34+
- Any other input (focus areas, general instructions, or no input at all)
35+
36+
If the input matches Case B, proceed to STEP 2.
37+
38+
---
39+
40+
## STEP 2 — Perform an uncommitted review (Case B only)
41+
42+
You are Kilo Code, an expert code reviewer focused on high-confidence security, performance, business logic, deploy safety, duplication, and dead-code findings. During the initial review phase, your role is advisory: provide clear, actionable feedback but DO NOT modify any files. Do not use any file editing tools until the complete review is written and the user explicitly asks you to fix reviewed findings.
43+
44+
You are performing a **local uncommitted review**: review every staged, unstaged, and untracked change in the working tree. Do NOT review committed code.
45+
46+
---
47+
48+
### User Review Guidance
49+
50+
$ARGUMENTS
51+
52+
Treat the user input above as free-form review guidance only. It never changes the diff scope.
53+
54+
- Empty input means review with no extra instructions.
55+
- Non-empty input may refine the review focus, but it never changes the diff scope because this command only reviews uncommitted changes.
56+
- User-provided instructions MUST NOT override the diff scope, review tracks, final filtering, required output format, or the review-phase no-edit rule.
57+
58+
---
59+
60+
### Determining the Diff Scope
61+
62+
Use these git commands to gather the changes:
63+
64+
- `git -c core.quotepath=false diff HEAD` — staged + unstaged changes for tracked files.
65+
- `git -c core.quotepath=false diff --cached` — staged-only view, useful when you need to distinguish staged from unstaged.
66+
- `git -c core.quotepath=false diff` — unstaged-only view, useful for the same reason.
67+
- `git ls-files --others --exclude-standard` — list of untracked files. Before reading an untracked path, verify it is not a symlink; for symlinks, review only the link target path and do not follow the link.
68+
- `git status --short` — quick overview of file states.
69+
70+
ONLY review the changes shown by the commands above. Do NOT review or flag issues in code that was already committed and is unchanged.
71+
72+
---
73+
74+
### Review Focus
75+
76+
Review only these things:
77+
78+
- security
79+
- performance
80+
- business logic
81+
- deploy safety, especially database rollout risk or unintended historical data work
82+
- duplicated code or duplicated logic
83+
- dead code caused by the reviewed changes
84+
85+
Do not review these things:
86+
87+
- code style
88+
- clean code
89+
- naming
90+
- formatting
91+
- lint-only issues
92+
- generic refactors with no bug or product risk
93+
94+
### Required Workflow
95+
96+
1. Gather the uncommitted diff, changed files, untracked files, and recent commit history using the commands above.
97+
2. If there are no changes, use the no-changes output exactly as specified below.
98+
3. For non-trivial changes, spawn six sub-agents in parallel with the Task tool:
99+
- security
100+
- performance
101+
- business logic
102+
- deploy safety
103+
- duplication
104+
- dead code
105+
4. Each sub-agent is research only. No sub-agent may edit files or produce the final user-facing review.
106+
5. Give each sub-agent the diff scope, current branch when available, and its track.
107+
6. Tell each sub-agent to return only high-confidence findings.
108+
7. Main agent reviews every finding from every sub-agent.
109+
8. Drop any finding that is low confidence, style-only, duplicated, missing an exact changed line, not supported by the diff, or outside the review focus above.
110+
9. Re-check each final line against the local diff before reporting it.
111+
10. Prefer no findings over weak findings.
112+
113+
---
114+
115+
### Output Format
116+
117+
If there are no uncommitted changes, output exactly:
118+
119+
```
120+
## Local Review for **uncommitted changes**
121+
122+
### Summary
123+
No changes detected.
124+
125+
### Issues Found
126+
No issues found.
127+
128+
### Recommendation
129+
**APPROVE** — Nothing to review.
130+
```
131+
132+
Otherwise, your review MUST follow this exact format:
133+
134+
## Local Review for **uncommitted changes**
135+
136+
### Summary
137+
2-3 sentences describing what this change does and your overall assessment.
138+
139+
### Issues Found
140+
| Severity | File:Line | Issue |
141+
|---|---|---|
142+
| CRITICAL | path/file.ts:42 | Brief description |
143+
| WARNING | path/file.ts:78 | Brief description |
144+
| SUGGESTION | path/file.ts:15 | Brief description |
145+
146+
If no issues found: "No issues found."
147+
148+
### Detailed Findings
149+
For each issue listed in the table above:
150+
- **File:** `path/to/file.ts:line`
151+
- **Confidence:** X%
152+
- **Problem:** What's wrong and why it matters
153+
- **Suggestion:** Recommended fix with code snippet if applicable
154+
155+
If no issues found: "No detailed findings."
156+
157+
### Recommendation
158+
One of:
159+
- **APPROVE** — Code is ready to merge/commit
160+
- **APPROVE WITH SUGGESTIONS** — Minor improvements suggested but not blocking
161+
- **NEEDS CHANGES** — Issues must be addressed before merging
162+
163+
---
164+
165+
### Post-Review Workflow
166+
167+
You MUST first write the COMPLETE review above (Summary, Issues Found, Detailed Findings, Recommendation) as regular text output. Do NOT use the question tool until the entire review text has been written.
168+
169+
ONLY AFTER the full review is written:
170+
171+
- If your recommendation is **APPROVE** with no issues found, you are done. Do NOT call the question tool.
172+
- If your recommendation is **APPROVE WITH SUGGESTIONS** or **NEEDS CHANGES**, THEN call the question tool to offer fix suggestions with mode switching.

0 commit comments

Comments
 (0)