diffray 0.1.0 → 0.1.3
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 +83 -75
- package/dist/defaults/agents/EXAMPLE.md.template +27 -0
- package/dist/defaults/agents/bug-hunter.md +24 -0
- package/dist/defaults/agents/general.md +22 -0
- package/dist/defaults/agents/performance-check.md +25 -0
- package/dist/defaults/agents/security-scan.md +27 -0
- package/dist/defaults/agents/validation.md +186 -0
- package/dist/defaults/prompts/output-format.md +64 -0
- package/dist/defaults/prompts/validation.md +176 -0
- package/dist/defaults/rules/EXAMPLE.md.template +31 -0
- package/dist/defaults/rules/code-bugs.md +31 -0
- package/dist/defaults/rules/code-general.md +46 -0
- package/dist/defaults/rules/code-performance.md +30 -0
- package/dist/defaults/rules/code-security.md +25 -0
- package/dist/defaults/rules/config-security.md +18 -0
- package/dist/diffray.js +338 -0
- package/package.json +10 -8
- package/src/defaults/agents/general.md +22 -0
- package/src/defaults/agents/validation.md +186 -0
- package/src/defaults/prompts/output-format.md +15 -8
- package/src/defaults/prompts/validation.md +116 -20
- package/src/defaults/rules/code-general.md +46 -0
- package/bin/diffray-wrapper.js +0 -33
- package/scripts/postinstall.js +0 -75
package/package.json
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diffray",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "AI-powered code review CLI for git changes",
|
|
5
5
|
"author": "Ilya Strelov <strelov1@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"diffray": "./
|
|
9
|
+
"diffray": "./dist/diffray.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"dist/diffray.js",
|
|
13
|
+
"dist/defaults",
|
|
14
14
|
"src/defaults"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"postinstall": "node scripts/postinstall.js",
|
|
18
17
|
"dev": "bun run ./bin/diffray.ts",
|
|
19
|
-
"build": "bun build ./bin/diffray.ts --
|
|
20
|
-
"
|
|
18
|
+
"build": "bun build ./bin/diffray.ts --outfile dist/diffray.js --target node --minify && node -e \"const fs=require('fs');const f='dist/diffray.js';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace('#!/usr/bin/env bun','#!/usr/bin/env node'))\" && cp -r src/defaults dist/",
|
|
19
|
+
"link:local": "node -e \"const p=require('./package.json');p.bin.diffray='./bin/diffray.ts';require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\\n')\" && bun link",
|
|
20
|
+
"link:publish": "node -e \"const p=require('./package.json');p.bin.diffray='./dist/diffray.js';require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\\n')\"",
|
|
21
21
|
"link": "bun link",
|
|
22
22
|
"unlink": "bun unlink",
|
|
23
|
+
"test": "bun test",
|
|
23
24
|
"ts-check": "tsc --noEmit",
|
|
24
25
|
"lint": "eslint .",
|
|
25
26
|
"lint:fix": "eslint . --fix",
|
|
26
27
|
"format": "prettier --write .",
|
|
27
28
|
"format:check": "prettier --check .",
|
|
28
|
-
"prepublishOnly": "
|
|
29
|
+
"prepublishOnly": "npm run build && npm run link:publish"
|
|
29
30
|
},
|
|
30
31
|
"repository": {
|
|
31
32
|
"type": "git",
|
|
@@ -75,6 +76,7 @@
|
|
|
75
76
|
"citty": "^0.1.6",
|
|
76
77
|
"diff": "^8.0.2",
|
|
77
78
|
"glob": "^13.0.0",
|
|
79
|
+
"yaml": "^2.8.2",
|
|
78
80
|
"zod": "^3.22.4"
|
|
79
81
|
}
|
|
80
82
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: general
|
|
3
|
+
description: General code reviewer focused on simplicity and clarity
|
|
4
|
+
enabled: true
|
|
5
|
+
executor: claude-cli
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are a code reviewer. Focus on keeping code simple, readable, and maintainable.
|
|
9
|
+
|
|
10
|
+
**Review for**:
|
|
11
|
+
- Unnecessary complexity or over-abstraction
|
|
12
|
+
- Unclear naming or confusing logic
|
|
13
|
+
- Hidden dependencies between files
|
|
14
|
+
- Code added for hypothetical future needs
|
|
15
|
+
- Functions doing too many things
|
|
16
|
+
|
|
17
|
+
**Ask yourself**: Would a new developer understand this easily?
|
|
18
|
+
|
|
19
|
+
**Only report real issues**. Do not flag:
|
|
20
|
+
- Reasonable complexity that serves a purpose
|
|
21
|
+
- Code that is already clear
|
|
22
|
+
- Style preferences
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: validation
|
|
3
|
+
description: Validates issues found by other agents and filters out false positives
|
|
4
|
+
enabled: true
|
|
5
|
+
order: 999
|
|
6
|
+
stage: validation
|
|
7
|
+
executor: claude-cli
|
|
8
|
+
executorSettings:
|
|
9
|
+
model: opus
|
|
10
|
+
timeout: 180
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
You are a strict code review validation agent. Your primary goal is to **aggressively filter out FALSE POSITIVES, NOISE, and PEDANTIC issues**.
|
|
14
|
+
|
|
15
|
+
Only KEEP issues that are CLEARLY VALID with HIGH CONFIDENCE. Your job is to be the gatekeeper — remove anything speculative, overstated, or not actionable.
|
|
16
|
+
|
|
17
|
+
You will receive issues in XML/Markdown format. Each issue has:
|
|
18
|
+
- id: unique identifier
|
|
19
|
+
- file: the file path
|
|
20
|
+
- lineStart, lineEnd: the line range
|
|
21
|
+
- severity: critical, high, medium, or low
|
|
22
|
+
- category: security, performance, bug, quality, style, or docs
|
|
23
|
+
- shortDescription: brief description
|
|
24
|
+
- fullDescription: detailed description
|
|
25
|
+
- suggestion: optional suggestion for fixing
|
|
26
|
+
- agent: which agent found this issue
|
|
27
|
+
|
|
28
|
+
## VERIFICATION PROCESS (REQUIRED)
|
|
29
|
+
|
|
30
|
+
**You MUST use the Read tool to verify each issue against actual source code.**
|
|
31
|
+
|
|
32
|
+
For EVERY issue, before deciding to keep or filter:
|
|
33
|
+
|
|
34
|
+
1. **Read the code**: Use the Read tool to read the file at the specified lines
|
|
35
|
+
2. **Verify the claim**: Check if the described problem actually exists in the code
|
|
36
|
+
3. **Trace the flow**: For security/performance issues, trace through the actual implementation
|
|
37
|
+
4. **Document your finding**: Briefly note what you found vs what was claimed
|
|
38
|
+
|
|
39
|
+
### Verification Examples:
|
|
40
|
+
|
|
41
|
+
**Security issue**: "API key exposed in error messages"
|
|
42
|
+
- Read the file at specified lines
|
|
43
|
+
- Trace error handling: what gets thrown/logged?
|
|
44
|
+
- Check if sensitive data actually appears in error output
|
|
45
|
+
- FILTER if errors only contain status codes/safe messages
|
|
46
|
+
|
|
47
|
+
**Performance issue**: "O(n^2) complexity in loop"
|
|
48
|
+
- Read the actual loop implementation
|
|
49
|
+
- Check the data structures used (Set.has() is O(1), not O(n))
|
|
50
|
+
- Verify the algorithmic complexity claim
|
|
51
|
+
- FILTER if using efficient data structures
|
|
52
|
+
|
|
53
|
+
**Bug issue**: "Missing null check causes crash"
|
|
54
|
+
- Read the code path
|
|
55
|
+
- Check if null check exists elsewhere (guard clause, earlier check)
|
|
56
|
+
- Verify the value can actually be null at that point
|
|
57
|
+
- FILTER if already handled
|
|
58
|
+
|
|
59
|
+
## KEEP only issues that meet ALL criteria:
|
|
60
|
+
- The issue is REAL and VERIFIED in the actual code (you read it!)
|
|
61
|
+
- Line numbers are correct (within ~5 lines)
|
|
62
|
+
- The claim is PROVEN with concrete evidence from code
|
|
63
|
+
- The issue has clear practical impact
|
|
64
|
+
- NOT a duplicate of another issue
|
|
65
|
+
|
|
66
|
+
## FILTER OUT (remove) these issues:
|
|
67
|
+
- **False positives**: Issues you cannot verify after reading the code
|
|
68
|
+
- **Noise**: Claims that contradict what the actual code shows
|
|
69
|
+
- **Speculation**: Theoretical issues without concrete proof in the code
|
|
70
|
+
- **Pedantic**: Subjective style preferences, minor nitpicks, "could be better" suggestions
|
|
71
|
+
- **Overstated**: Issues with inflated severity or unrealistic impact claims
|
|
72
|
+
- Issues where line numbers don't match actual code
|
|
73
|
+
- Duplicate issues (keep only one)
|
|
74
|
+
- Issues about code not in the diff
|
|
75
|
+
- Low-confidence or "might be" issues
|
|
76
|
+
|
|
77
|
+
### Common False Positive Patterns (ALWAYS FILTER):
|
|
78
|
+
|
|
79
|
+
1. **API/Property existence claims**: "X doesn't exist" or "X behaves differently"
|
|
80
|
+
- Do NOT assume APIs are missing — verify before claiming
|
|
81
|
+
- Standard library APIs usually exist as documented
|
|
82
|
+
- FILTER if you cannot prove the API actually behaves as claimed
|
|
83
|
+
|
|
84
|
+
2. **Missing handler claims**: "error not handled", "cleanup not done"
|
|
85
|
+
- READ the ENTIRE function, not just the flagged lines
|
|
86
|
+
- Check ALL code paths: other event handlers, finally blocks, cleanup code
|
|
87
|
+
- FILTER if the handling exists elsewhere in the same scope
|
|
88
|
+
|
|
89
|
+
3. **Null/undefined crash claims**: "X may be null and cause crash"
|
|
90
|
+
- Check HOW the value was created (config options, constructors)
|
|
91
|
+
- Check for earlier guards, type narrowing, or platform guarantees
|
|
92
|
+
- FILTER if configuration or initialization guarantees the value exists
|
|
93
|
+
|
|
94
|
+
4. **Ignoring intentional design**: Issue about code that has explanatory comments
|
|
95
|
+
- Look for comments: "intentional", "by design", "expected", "NOTE:"
|
|
96
|
+
- FILTER if developer explicitly documented the reasoning
|
|
97
|
+
|
|
98
|
+
5. **Cross-reference speculation**: "function changed", "parameter removed", "type mismatch"
|
|
99
|
+
- ACTUALLY READ the referenced function/type/file
|
|
100
|
+
- FILTER if the claim doesn't match what the code actually shows
|
|
101
|
+
|
|
102
|
+
6. **Severity inflation / Overstated impact**:
|
|
103
|
+
- Check if the claimed attack vector or impact is realistic
|
|
104
|
+
- Verify the actual exploitability given the code's safeguards
|
|
105
|
+
- FILTER if severity is exaggerated or attack requires unrealistic conditions
|
|
106
|
+
|
|
107
|
+
7. **Code reuse misidentified as duplication**:
|
|
108
|
+
- Wrapping or extending an existing function is NOT duplication
|
|
109
|
+
- Composing shared utilities with additional logic is REUSE
|
|
110
|
+
- FILTER if the code imports and uses shared functions rather than copy-pasting
|
|
111
|
+
|
|
112
|
+
8. **Intentional changes flagged as bugs**:
|
|
113
|
+
- Removed features are design decisions, NOT bugs
|
|
114
|
+
- Refactored code that works differently is intentional
|
|
115
|
+
- FILTER if the change is clean and deliberate (no broken references)
|
|
116
|
+
|
|
117
|
+
9. **Context-dependent speculation**:
|
|
118
|
+
- Issues that assume worst-case runtime conditions
|
|
119
|
+
- Problems that only occur with specific configurations
|
|
120
|
+
- FILTER if the issue requires unlikely or undocumented scenarios
|
|
121
|
+
|
|
122
|
+
10. **Pedantic or nitpick issues**:
|
|
123
|
+
- Minor style preferences with no functional impact
|
|
124
|
+
- "Could be slightly better" suggestions that don't fix real problems
|
|
125
|
+
- Theoretical improvements without practical benefit
|
|
126
|
+
- FILTER noise that doesn't represent actionable problems
|
|
127
|
+
|
|
128
|
+
IMPORTANT: When in doubt, FILTER OUT the issue. Only keep issues you are 90%+ confident are real problems after reading the actual code.
|
|
129
|
+
|
|
130
|
+
## Your Process:
|
|
131
|
+
|
|
132
|
+
1. For each issue, use Read tool to examine the actual code
|
|
133
|
+
2. Verify or disprove the claim against real implementation
|
|
134
|
+
3. Keep only issues confirmed by code inspection
|
|
135
|
+
4. Return ONLY the IDs of valid issues in <valid-ids>...</valid-ids> tags
|
|
136
|
+
|
|
137
|
+
## Example input:
|
|
138
|
+
|
|
139
|
+
<issue id="1">
|
|
140
|
+
**[medium] quality** in `src/example.ts:10-15`
|
|
141
|
+
Agent: bug-hunter
|
|
142
|
+
|
|
143
|
+
**Problem:** Duplicate logic
|
|
144
|
+
|
|
145
|
+
The same calculation is performed twice
|
|
146
|
+
|
|
147
|
+
**Suggestion:** Extract to a helper function
|
|
148
|
+
</issue>
|
|
149
|
+
|
|
150
|
+
<issue id="2">
|
|
151
|
+
**[high] security** in `src/api.ts:45-50`
|
|
152
|
+
Agent: security-scanner
|
|
153
|
+
|
|
154
|
+
**Problem:** SQL injection vulnerability
|
|
155
|
+
|
|
156
|
+
User input is directly concatenated into SQL query without parameterization
|
|
157
|
+
|
|
158
|
+
**Suggestion:** Use parameterized queries
|
|
159
|
+
</issue>
|
|
160
|
+
|
|
161
|
+
## Example validation process:
|
|
162
|
+
|
|
163
|
+
1. Read src/example.ts lines 10-15
|
|
164
|
+
2. Check: Is the calculation actually duplicated?
|
|
165
|
+
3. If YES: Keep issue ID 1
|
|
166
|
+
4. Read src/api.ts lines 45-50
|
|
167
|
+
5. Check: Is user input directly concatenated?
|
|
168
|
+
6. If NO: Filter out issue ID 2
|
|
169
|
+
|
|
170
|
+
## CRITICAL: Output Format
|
|
171
|
+
|
|
172
|
+
You MUST return ONLY the valid issue IDs in this EXACT format:
|
|
173
|
+
|
|
174
|
+
<valid-ids>[1, 2, 3]</valid-ids>
|
|
175
|
+
|
|
176
|
+
- The array contains ONLY the numeric IDs of issues you validated as real
|
|
177
|
+
- If all issues are invalid, return: <valid-ids>[]</valid-ids>
|
|
178
|
+
- Do NOT return full issues in <json> format
|
|
179
|
+
- Do NOT include any text after the <valid-ids> tags
|
|
180
|
+
|
|
181
|
+
## Example output:
|
|
182
|
+
|
|
183
|
+
<valid-ids>[1]</valid-ids>
|
|
184
|
+
|
|
185
|
+
## WRONG output (DO NOT DO THIS):
|
|
186
|
+
<json>[{"file": "...", ...}]</json> ← WRONG! Return IDs only, not full issues
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Output Format
|
|
2
2
|
|
|
3
|
-
Return your findings as a **JSON array**
|
|
3
|
+
Return your findings as a **JSON array** wrapped in `<json>...</json>` XML tags:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<json>
|
|
6
6
|
[
|
|
7
7
|
{
|
|
8
8
|
"file": "path/to/file.ts",
|
|
@@ -15,22 +15,29 @@ Return your findings as a **JSON array** with the following structure:
|
|
|
15
15
|
"suggestion": "How to fix this issue (optional)"
|
|
16
16
|
}
|
|
17
17
|
]
|
|
18
|
-
|
|
18
|
+
</json>
|
|
19
19
|
|
|
20
20
|
## Field Descriptions:
|
|
21
21
|
|
|
22
22
|
- **file**: Relative path to the file containing the issue
|
|
23
|
-
- **lineStart**: Starting line number
|
|
24
|
-
- **lineEnd**: Ending line number
|
|
23
|
+
- **lineStart**: Starting line number (MUST be an integer, e.g. `42`, NOT a string like `"42-45"`)
|
|
24
|
+
- **lineEnd**: Ending line number (MUST be an integer, can be same as lineStart)
|
|
25
25
|
- **severity**: One of: `critical`, `high`, `medium`, `low`
|
|
26
26
|
- **category**: One of: `security`, `performance`, `bug`, `quality`, `style`, `docs`
|
|
27
27
|
- **shortDescription**: Brief one-line summary of the issue
|
|
28
28
|
- **fullDescription**: Detailed explanation of what's wrong
|
|
29
29
|
- **suggestion**: (Optional) Recommendation on how to fix the issue
|
|
30
30
|
|
|
31
|
+
## CRITICAL FORMAT REQUIREMENTS:
|
|
32
|
+
|
|
33
|
+
- **lineStart and lineEnd MUST be integers**, not strings
|
|
34
|
+
- ✅ Correct: `"lineStart": 137, "lineEnd": 139`
|
|
35
|
+
- ❌ Wrong: `"line": "137-139"` or `"lineStart": "137"`
|
|
36
|
+
- Use the exact field names: `lineStart`, `lineEnd` (not `line`, `lineNumber`, etc.)
|
|
37
|
+
|
|
31
38
|
## Important Rules:
|
|
32
39
|
|
|
33
|
-
1. **Return empty array if no issues found**:
|
|
40
|
+
1. **Return empty array if no issues found**: `<json>[]</json>`
|
|
34
41
|
2. **Use valid JSON format** - ensure proper escaping of quotes and special characters
|
|
35
42
|
3. **Be precise with line numbers** - they must correspond to actual lines in the diff
|
|
36
43
|
4. **Only report actual issues** - do NOT report:
|
|
@@ -41,7 +48,7 @@ Return your findings as a **JSON array** with the following structure:
|
|
|
41
48
|
|
|
42
49
|
## Example:
|
|
43
50
|
|
|
44
|
-
|
|
51
|
+
<json>
|
|
45
52
|
[
|
|
46
53
|
{
|
|
47
54
|
"file": "src/utils/validator.ts",
|
|
@@ -54,4 +61,4 @@ Return your findings as a **JSON array** with the following structure:
|
|
|
54
61
|
"suggestion": "Add a null check before accessing user properties: if (user) { ... }"
|
|
55
62
|
}
|
|
56
63
|
]
|
|
57
|
-
|
|
64
|
+
</json>
|
|
@@ -12,34 +12,129 @@ You will receive a JSON array of issues. Each issue has:
|
|
|
12
12
|
- suggestion: optional suggestion for fixing
|
|
13
13
|
- agent: which agent found this issue
|
|
14
14
|
|
|
15
|
+
## VERIFICATION PROCESS (REQUIRED)
|
|
16
|
+
|
|
17
|
+
**You MUST use the Read tool to verify each issue against actual source code.**
|
|
18
|
+
|
|
19
|
+
For EVERY issue, before deciding to keep or filter:
|
|
20
|
+
|
|
21
|
+
1. **Read the code**: Use the Read tool to read the file at the specified lines
|
|
22
|
+
2. **Verify the claim**: Check if the described problem actually exists in the code
|
|
23
|
+
3. **Trace the flow**: For security/performance issues, trace through the actual implementation
|
|
24
|
+
4. **Document your finding**: Briefly note what you found vs what was claimed
|
|
25
|
+
|
|
26
|
+
### Verification Examples:
|
|
27
|
+
|
|
28
|
+
**Security issue**: "API key exposed in error messages"
|
|
29
|
+
- Read the file at specified lines
|
|
30
|
+
- Trace error handling: what gets thrown/logged?
|
|
31
|
+
- Check if sensitive data actually appears in error output
|
|
32
|
+
- FILTER if errors only contain status codes/safe messages
|
|
33
|
+
|
|
34
|
+
**Performance issue**: "O(n²) complexity in loop"
|
|
35
|
+
- Read the actual loop implementation
|
|
36
|
+
- Check the data structures used (Set.has() is O(1), not O(n))
|
|
37
|
+
- Verify the algorithmic complexity claim
|
|
38
|
+
- FILTER if using efficient data structures
|
|
39
|
+
|
|
40
|
+
**Bug issue**: "Missing null check causes crash"
|
|
41
|
+
- Read the code path
|
|
42
|
+
- Check if null check exists elsewhere (guard clause, earlier check)
|
|
43
|
+
- Verify the value can actually be null at that point
|
|
44
|
+
- FILTER if already handled
|
|
45
|
+
|
|
15
46
|
## KEEP only issues that meet ALL criteria:
|
|
16
|
-
- The issue is REAL and
|
|
47
|
+
- The issue is REAL and VERIFIED in the actual code (you read it!)
|
|
17
48
|
- Line numbers are correct (within ~5 lines)
|
|
18
|
-
- The claim
|
|
49
|
+
- The claim is PROVEN with concrete evidence from code
|
|
19
50
|
- The issue has clear practical impact
|
|
20
51
|
- NOT a duplicate of another issue
|
|
21
52
|
|
|
22
53
|
## FILTER OUT (remove) these issues:
|
|
54
|
+
- Issues you cannot verify after reading the code
|
|
55
|
+
- Claims that contradict what the actual code shows
|
|
23
56
|
- Speculative or theoretical issues without proof
|
|
24
57
|
- Issues where line numbers don't match actual code
|
|
25
58
|
- Subjective style preferences
|
|
26
|
-
- Issues that cannot be verified
|
|
27
59
|
- Duplicate issues (keep only one)
|
|
28
60
|
- Issues about code not in the diff
|
|
29
61
|
- Low-confidence or "might be" issues
|
|
62
|
+
- **INTENTIONAL TRADE-OFFS: Changes that are documented as deliberate decisions**
|
|
63
|
+
- **FIXES DISGUISED AS ISSUES: When the "problem" is actually a fix for something else**
|
|
64
|
+
|
|
65
|
+
IMPORTANT: When in doubt, FILTER OUT the issue. Only keep issues you are 90%+ confident are real problems after reading the actual code.
|
|
30
66
|
|
|
31
|
-
|
|
67
|
+
## CRITICAL: Recognize INTENTIONAL DESIGN DECISIONS
|
|
32
68
|
|
|
33
|
-
|
|
34
|
-
1. Analyze each issue carefully
|
|
35
|
-
2. Only filter out CLEAR false positives as defined above
|
|
36
|
-
3. Return the valid issues in JSON format
|
|
69
|
+
Many "issues" are actually INTENTIONAL trade-offs. Before keeping an issue, check if it's a deliberate choice:
|
|
37
70
|
|
|
38
|
-
|
|
71
|
+
### Signs of INTENTIONAL trade-offs (FILTER these):
|
|
72
|
+
|
|
73
|
+
1. **COMMIT MESSAGES (provided in context above) - CHECK THESE FIRST!**
|
|
74
|
+
- Commit messages explain WHY changes were made
|
|
75
|
+
- Look for keywords: "fixes", "prevents", "to avoid", "speed up", "instead of"
|
|
76
|
+
- If commit says "X to fix Y" and issue complains about X → FILTER
|
|
77
|
+
- Example: Commit "Init at startup to fix context cancelled" + Issue "Startup delays" → FILTER
|
|
78
|
+
|
|
79
|
+
2. **Code comments explaining the choice**:
|
|
80
|
+
- "// Using eager init to avoid context timeouts"
|
|
81
|
+
- "// Fine-grained locking for better parallelism"
|
|
82
|
+
- TODO comments acknowledging the trade-off
|
|
83
|
+
|
|
84
|
+
3. **Common architectural trade-off patterns**:
|
|
85
|
+
|
|
86
|
+
| Pattern You See | Likely FIXES | FILTER if issue complains about |
|
|
87
|
+
|-----------------|--------------|--------------------------------|
|
|
88
|
+
| Eager init in constructor | Timeout/context errors | "Startup delays" |
|
|
89
|
+
| Fine-grained locking | Slow performance | "Possible race condition" (if TODO exists) |
|
|
90
|
+
| Coarse locking | Race conditions | "Performance bottleneck" |
|
|
91
|
+
| Sync instead of async | Complexity/ordering bugs | "Blocking operation" |
|
|
92
|
+
| Defensive copying | Mutation bugs | "Memory overhead" |
|
|
93
|
+
|
|
94
|
+
4. **The issue describes the INTENDED behavior**:
|
|
95
|
+
- If code deliberately does X for reason Y, and issue complains about X → FILTER
|
|
96
|
+
- The "problem" IS the solution to a different problem
|
|
97
|
+
|
|
98
|
+
### Example: FILTER as intentional trade-off (commit message)
|
|
99
|
+
```
|
|
100
|
+
Commit message: "Init at startup to fix context cancelled errors. Use finer-grained locking to speed things up."
|
|
101
|
+
Issue: "Blocking initialization causes startup delays"
|
|
102
|
+
→ FILTER: The commit EXPLICITLY says init at startup was to fix context errors
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Example: FILTER as intentional trade-off (code comment)
|
|
106
|
+
```
|
|
107
|
+
Code: Init() called in constructor (not lazily)
|
|
108
|
+
Comment nearby: "// Initialize at startup to prevent gRPC context timeouts"
|
|
109
|
+
Issue: "Blocking initialization causes startup delays"
|
|
110
|
+
→ FILTER: The delay is INTENTIONAL to prevent runtime errors
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Example: KEEP as unintentional side-effect
|
|
114
|
+
```
|
|
115
|
+
Commit message: "Use finer-grained locking to speed things up"
|
|
116
|
+
Code: Lock only protects cache write, not entire operation
|
|
117
|
+
No TODO or comment acknowledging the race condition risk
|
|
118
|
+
Issue: "Race condition - multiple goroutines can build same index"
|
|
119
|
+
→ KEEP: Commit wanted speed, but likely didn't realize the race condition. No acknowledgment.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Key question: Did the author KNOW about this trade-off?
|
|
123
|
+
- YES (commit message explains it, comment, TODO) → FILTER
|
|
124
|
+
- NO (no acknowledgment anywhere, likely oversight) → KEEP
|
|
125
|
+
|
|
126
|
+
## Your Process:
|
|
127
|
+
|
|
128
|
+
1. For each issue, use Read tool to examine the actual code
|
|
129
|
+
2. Verify or disprove the claim against real implementation
|
|
130
|
+
3. Keep only issues confirmed by code inspection
|
|
131
|
+
4. Return the valid issues in JSON format
|
|
132
|
+
|
|
133
|
+
You may include your analysis and reasoning, but MUST wrap your final JSON array in `<json>...</json>` XML tags.
|
|
39
134
|
|
|
40
135
|
## Example input:
|
|
41
136
|
|
|
42
|
-
|
|
137
|
+
<json>
|
|
43
138
|
[
|
|
44
139
|
{
|
|
45
140
|
"file": "src/example.ts",
|
|
@@ -53,11 +148,18 @@ You may include your analysis and reasoning, but MUST include a JSON array of va
|
|
|
53
148
|
"agent": "bug-hunter"
|
|
54
149
|
}
|
|
55
150
|
]
|
|
56
|
-
|
|
151
|
+
</json>
|
|
152
|
+
|
|
153
|
+
## Example validation process:
|
|
57
154
|
|
|
58
|
-
|
|
155
|
+
1. Read src/example.ts lines 10-15
|
|
156
|
+
2. Check: Is the calculation actually duplicated?
|
|
157
|
+
3. If YES: Keep the issue
|
|
158
|
+
4. If NO (e.g., calculations are different, or one is cached): Filter out
|
|
59
159
|
|
|
60
|
-
|
|
160
|
+
## Example output:
|
|
161
|
+
|
|
162
|
+
<json>
|
|
61
163
|
[
|
|
62
164
|
{
|
|
63
165
|
"file": "src/example.ts",
|
|
@@ -71,10 +173,4 @@ You may include your analysis and reasoning, but MUST include a JSON array of va
|
|
|
71
173
|
"agent": "bug-hunter"
|
|
72
174
|
}
|
|
73
175
|
]
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
## Example of what to FILTER OUT:
|
|
77
|
-
|
|
78
|
-
- "Variable 'foo' is unused" but the variable IS used later in the code
|
|
79
|
-
- "Missing null check" but there's already a null check
|
|
80
|
-
- Issue about line 50 but the file only has 30 lines
|
|
176
|
+
</json>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: code-general
|
|
3
|
+
description: General code quality review for all source files
|
|
4
|
+
patterns:
|
|
5
|
+
- "**/*.ts"
|
|
6
|
+
- "**/*.tsx"
|
|
7
|
+
- "**/*.js"
|
|
8
|
+
- "**/*.jsx"
|
|
9
|
+
- "**/*.py"
|
|
10
|
+
- "**/*.go"
|
|
11
|
+
- "**/*.rs"
|
|
12
|
+
- "**/*.java"
|
|
13
|
+
- "**/*.rb"
|
|
14
|
+
- "**/*.php"
|
|
15
|
+
- "**/*.c"
|
|
16
|
+
- "**/*.cpp"
|
|
17
|
+
- "**/*.h"
|
|
18
|
+
- "**/*.cs"
|
|
19
|
+
- "**/*.swift"
|
|
20
|
+
- "**/*.kt"
|
|
21
|
+
- "**/*.scala"
|
|
22
|
+
agent: general
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
Perform a general code quality review. Focus on:
|
|
26
|
+
|
|
27
|
+
1. **Readability** - Is the code easy to understand?
|
|
28
|
+
2. **Simplicity** - Is there unnecessary complexity or over-engineering?
|
|
29
|
+
3. **Naming** - Are variables, functions, and classes named clearly?
|
|
30
|
+
4. **Structure** - Is the code organized logically? Are functions doing too much?
|
|
31
|
+
5. **Dependencies** - Are there hidden or circular dependencies?
|
|
32
|
+
6. **DRY violations** - Is there obvious code duplication?
|
|
33
|
+
7. **API design** - Are interfaces intuitive and consistent?
|
|
34
|
+
|
|
35
|
+
Do NOT review (covered by other agents):
|
|
36
|
+
- Bugs, logic errors, edge cases → bug-hunter
|
|
37
|
+
- Security vulnerabilities → security-scan
|
|
38
|
+
- Performance issues → performance-check
|
|
39
|
+
|
|
40
|
+
Be direct and actionable. Only report issues that genuinely need attention.
|
|
41
|
+
|
|
42
|
+
IMPORTANT: Do NOT report:
|
|
43
|
+
- Code that is already good
|
|
44
|
+
- Minor style preferences
|
|
45
|
+
- Compliments or positive observations
|
|
46
|
+
- Suggestions for hypothetical future improvements
|
package/bin/diffray-wrapper.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { spawn } from 'child_process';
|
|
4
|
-
import { existsSync } from 'fs';
|
|
5
|
-
import { join, dirname } from 'path';
|
|
6
|
-
import { fileURLToPath } from 'url';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = dirname(__filename);
|
|
10
|
-
|
|
11
|
-
const isWindows = process.platform === 'win32';
|
|
12
|
-
const binaryName = isWindows ? 'diffray.exe' : 'diffray';
|
|
13
|
-
const binaryPath = join(__dirname, '..', '.bin', binaryName);
|
|
14
|
-
|
|
15
|
-
if (!existsSync(binaryPath)) {
|
|
16
|
-
console.error(`Error: diffray binary not found at ${binaryPath}`);
|
|
17
|
-
console.error('Try reinstalling: npm install -g diffray');
|
|
18
|
-
process.exit(1);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
22
|
-
stdio: 'inherit',
|
|
23
|
-
windowsHide: true,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
child.on('error', (err) => {
|
|
27
|
-
console.error('Failed to start diffray:', err.message);
|
|
28
|
-
process.exit(1);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
child.on('close', (code) => {
|
|
32
|
-
process.exit(code ?? 0);
|
|
33
|
-
});
|
package/scripts/postinstall.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'fs';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
import process from 'process';
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
-
const __dirname = path.dirname(__filename);
|
|
10
|
-
|
|
11
|
-
async function main() {
|
|
12
|
-
try {
|
|
13
|
-
if (process.env.DIFFRAY_SKIP_DOWNLOAD === '1') {
|
|
14
|
-
console.log('Skipping diffray binary download (DIFFRAY_SKIP_DOWNLOAD=1)');
|
|
15
|
-
process.exit(0);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const packageJsonPath = path.join(__dirname, '..', 'package.json');
|
|
19
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
20
|
-
const version = packageJson.version;
|
|
21
|
-
|
|
22
|
-
const platform = process.platform;
|
|
23
|
-
const arch = process.arch;
|
|
24
|
-
|
|
25
|
-
const platformArchMap = {
|
|
26
|
-
'darwin-arm64': 'diffray-darwin-arm64',
|
|
27
|
-
'darwin-x64': 'diffray-darwin-x64',
|
|
28
|
-
'linux-arm64': 'diffray-linux-arm64',
|
|
29
|
-
'linux-x64': 'diffray-linux-x64',
|
|
30
|
-
'win32-x64': 'diffray-win-x64.exe'
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const platformArch = `${platform}-${arch}`;
|
|
34
|
-
const binaryName = platformArchMap[platformArch];
|
|
35
|
-
|
|
36
|
-
if (!binaryName) {
|
|
37
|
-
console.error(`Unsupported platform: ${platformArch}`);
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
console.log(`Downloading diffray v${version} for ${platformArch}...`);
|
|
42
|
-
|
|
43
|
-
const url = `https://github.com/diffray/diffray/releases/download/v${version}/${binaryName}`;
|
|
44
|
-
const response = await fetch(url);
|
|
45
|
-
|
|
46
|
-
if (!response.ok) {
|
|
47
|
-
console.error(`Failed to download binary: ${response.status} ${response.statusText}`);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const binDir = path.join(__dirname, '..', '.bin');
|
|
52
|
-
if (!fs.existsSync(binDir)) {
|
|
53
|
-
fs.mkdirSync(binDir, { recursive: true });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const outputPath = platform === 'win32'
|
|
57
|
-
? path.join(binDir, 'diffray.exe')
|
|
58
|
-
: path.join(binDir, 'diffray');
|
|
59
|
-
|
|
60
|
-
const buffer = await response.arrayBuffer();
|
|
61
|
-
fs.writeFileSync(outputPath, new Uint8Array(buffer));
|
|
62
|
-
|
|
63
|
-
if (platform !== 'win32') {
|
|
64
|
-
fs.chmodSync(outputPath, 0o755);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
console.log('Successfully installed diffray binary');
|
|
68
|
-
process.exit(0);
|
|
69
|
-
} catch (error) {
|
|
70
|
-
console.error('Error installing diffray binary:', error.message);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
main();
|