diffray 0.1.0

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 ADDED
@@ -0,0 +1,395 @@
1
+ # ⚡ diffray
2
+
3
+ **Code Review Pipeline** - Git diffs → Agents → Results
4
+
5
+ ## What is an Agent?
6
+
7
+ **Agent is an abstraction** - it can be either:
8
+
9
+ - **LLM Agent** - API call to Claude, GPT, or other LLMs
10
+ - **CLI Agent** - Execution of CLI tools like `claude`, `auggie`, etc.
11
+
12
+ This allows you to combine different review approaches in one pipeline!
13
+
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ Git Changes → Pipeline → LLM Agent (Claude API) → Result 1
19
+ → CLI Agent (claude code) → Result 2
20
+ → CLI Agent (auggie) → Result 3
21
+ → LLM Agent (GPT-4) → Result 4
22
+ ```
23
+
24
+ ## Key Features
25
+
26
+ - **Pipeline-based** - Process diffs through multiple stages
27
+ - **Stage System** - Organized execution: Load Rules → Match → Execute → Aggregate
28
+ - **Rule Matching** - Run different agents on different file types using glob patterns
29
+ - **Flexible Agents** - Mix LLM APIs and CLI tools in one pipeline
30
+ - **Markdown Agents** - Define agents using simple Markdown files
31
+ - **Parallel Execution** - All agents run simultaneously within their stage
32
+ - **Live Spinners** - Visual feedback for each agent (no external dependencies)
33
+ - **Configurable** - Enable/disable agents, rules, and stages
34
+ - **Global** - Works in any git repository
35
+ - **Lightweight** - Minimal dependencies
36
+
37
+ ## Installation
38
+
39
+ ### From source
40
+
41
+ ```bash
42
+ # Clone and install
43
+ git clone <your-repo>
44
+ cd diffray
45
+ bun install
46
+
47
+ # Link globally
48
+ bun link
49
+ ```
50
+
51
+ Now you can use `diffray` anywhere!
52
+
53
+ ## Usage
54
+
55
+ ### Run Pipeline
56
+
57
+ ```bash
58
+ # Run code review pipeline
59
+ diffray
60
+
61
+ # Output:
62
+ # ⚡ diffray - AI Code Review
63
+ #
64
+ # ■ Analyzing changes...
65
+ # ◇ 8 files: 7 modified, 1 added
66
+ # 624 changes: +612 -12
67
+ # ◉ Loading agents...
68
+ # ✓ Loaded 2 agent(s)
69
+ #
70
+ # ↻ Running 2 agent(s) in parallel...
71
+ # ✓ Custom Code Review (101ms)
72
+ # ✓ Security Scanner (101ms)
73
+ #
74
+ # ✓ Pipeline completed successfully in 102ms
75
+ # ■ 2/2 agents succeeded
76
+
77
+ # Verbose mode (shows file details and prompts)
78
+ diffray --verbose
79
+
80
+ # JSON output (machine-readable)
81
+ diffray --json
82
+
83
+ # Filter by severity (show only critical)
84
+ diffray --severity=critical
85
+
86
+ # Filter by multiple severities (critical and high)
87
+ diffray --severity=critical,high
88
+
89
+ # Combine options
90
+ diffray --json --severity=critical
91
+
92
+ # Output includes:
93
+ # ~ README.md: +141 -5
94
+ # ~ src/cli.ts: +107 -3
95
+ # + src/config.test.ts: +52 -0
96
+ # ...
97
+ ```
98
+
99
+ ### Manage Agents
100
+
101
+ ```bash
102
+ # List all agents
103
+ diffray agents list
104
+
105
+ # Show agent details
106
+ diffray agents show bug-hunter
107
+
108
+ # Sync agents from MD files to cache
109
+ diffray agents sync
110
+ ```
111
+
112
+ **Creating Custom Agents:**
113
+
114
+ Agents are defined using Markdown files! See [Agent Configuration Guide](./docs/AGENTS.md) for details.
115
+
116
+ To create a custom agent, create a new `.md` file in `src/defaults/agents/` with the following structure:
117
+ - Frontmatter with ID, Order, Enabled, and Executor fields
118
+ - Description section
119
+ - System Prompt section
120
+
121
+ After creating or modifying agents, run `diffray agents sync` to reload them.
122
+
123
+ ### Manage Executors
124
+
125
+ ```bash
126
+ # List all executors
127
+ diffray executors list
128
+
129
+ # Show executor details
130
+ diffray executors show claude-cli
131
+
132
+ # Enable/disable executors
133
+ diffray executors enable cerebras-api
134
+ diffray executors disable claude-cli
135
+ ```
136
+
137
+ ### Manage Rules
138
+
139
+ Rules allow you to run different agents on different file types using glob patterns. Rules are defined in Markdown files in `src/defaults/rules/`.
140
+
141
+ ```bash
142
+ # List all rules
143
+ diffray rules list
144
+
145
+ # Show rule details
146
+ diffray rules show code-bugs
147
+
148
+ # Test rule matching against specific files
149
+ diffray rules test code-bugs src/cli.ts src/agents.ts README.md
150
+ # Output:
151
+ # ✓ Matched 2 file(s):
152
+ # ● src/cli.ts
153
+ # ● src/agents.ts
154
+ # Not matched 1 file(s):
155
+ # ○ README.md
156
+
157
+ # Sync rules from MD files to cache
158
+ diffray rules sync
159
+ ```
160
+
161
+ **Creating Custom Rules:**
162
+
163
+ Create a new `.md` file in `src/defaults/rules/` with frontmatter:
164
+
165
+ ```markdown
166
+ ---
167
+ id: "my-rule"
168
+ name: "My Custom Rule"
169
+ description: "Description of what this rule does"
170
+ patterns: ["**/*.ts", "**/*.tsx"]
171
+ agent: "bug-hunter"
172
+ ---
173
+
174
+ Additional instructions for the agent when this rule matches.
175
+ ```
176
+
177
+ **Default Rules:**
178
+ - `code-bugs`: Run bug-hunter on code files `**/*.{ts,tsx,js,jsx,py,go,rs,java,rb,php}`
179
+ - `code-security`: Run security-scan on code files `**/*.{ts,tsx,js,jsx,py,go,rs,java,rb,php}`
180
+ - `config-security`: Run security-scan on config files `**/*.{json,yaml,yml,toml}`
181
+
182
+ ### Configuration
183
+
184
+ diffray stores configuration in `~/.diffray/config.json`. This file caches agents, executors, rules, and settings.
185
+
186
+ ```bash
187
+ # Initialize configuration file
188
+ diffray config init
189
+
190
+ # Show current configuration
191
+ diffray config show
192
+
193
+ # Edit configuration in your $EDITOR
194
+ diffray config edit
195
+
196
+ # Reset to defaults
197
+ diffray config reset
198
+ ```
199
+
200
+ #### Configuration Structure
201
+
202
+ The configuration file has the following structure:
203
+
204
+ ```json
205
+ {
206
+ "excludePatterns": ["*.lock", "*.min.js", "dist/*", "node_modules/**"],
207
+ "output": {
208
+ "colorize": true,
209
+ "verbose": false,
210
+ "format": "terminal"
211
+ },
212
+ "executors": [...],
213
+ "agents": [...],
214
+ "rules": [...],
215
+ "stages": [...]
216
+ }
217
+ ```
218
+
219
+ **Key Sections:**
220
+
221
+ - `excludePatterns`: File patterns to exclude from review (array of glob patterns)
222
+ - `output.colorize`: Enable colored output (boolean, default: `true`)
223
+ - `output.verbose`: Show verbose output (boolean, default: `false`)
224
+ - `output.format`: Output format - `terminal`, `markdown`, or `json` (default: `terminal`)
225
+ - `executors`: Cached executor configurations (managed via `diffray executors` commands)
226
+ - `agents`: Cached agent configurations (synced from Markdown files via `diffray agents sync`)
227
+ - `rules`: Cached rule configurations (synced from MD files via `diffray rules sync`)
228
+ - `stages`: Pipeline stage configurations with enabled/disabled status
229
+
230
+ ### Executors Configuration
231
+
232
+ Executors define **how** to run Agents. diffray supports multiple executor types:
233
+
234
+ - **CLI Executors** - Run CLI tools like `claude`, `auggie`, etc.
235
+ - **LLM API Executors** - Call LLM APIs directly (Claude, GPT, etc.)
236
+
237
+ Executors are configured in `~/.diffray/config.json`.
238
+
239
+ #### Executor Configuration
240
+
241
+ Executors can be configured in `~/.diffray/config.json`:
242
+
243
+ ```json
244
+ {
245
+ "executors": [
246
+ {
247
+ "name": "claude-cli",
248
+ "enabled": true,
249
+ "model": "opus",
250
+ "timeout": 180
251
+ },
252
+ {
253
+ "name": "cerebras-api",
254
+ "enabled": true,
255
+ "model": "llama-3.1-8b",
256
+ "temperature": 0.5,
257
+ "maxTokens": 4096
258
+ }
259
+ ]
260
+ }
261
+ ```
262
+
263
+ #### Executor Options
264
+
265
+ **CLI Executors (claude-cli):**
266
+ - `enabled` - Enable/disable executor
267
+ - `model` - Model to use (default: `sonnet`)
268
+ - `timeout` - Timeout in seconds (default: 120)
269
+
270
+ **API Executors (cerebras-api):**
271
+ - `enabled` - Enable/disable executor
272
+ - `model` - Model to use (default: `llama-3.3-70b`)
273
+ - `temperature` - Temperature (default: 0.7)
274
+ - `maxTokens` - Max tokens (default: 8192)
275
+
276
+ #### Linking Agents to Executors
277
+
278
+ Agents reference executors via the `executor` field in their Markdown configuration:
279
+
280
+ ```markdown
281
+ ---
282
+ ID: bug-hunter
283
+ Executor: claude-cli
284
+ ---
285
+ ```
286
+
287
+ ## Agent Configuration
288
+
289
+ Agents are configured using **Markdown files** in `src/defaults/agents/`. See the [Agent Configuration Guide](./docs/AGENTS.md) for complete documentation.
290
+
291
+ ### Agent Markdown Format
292
+
293
+ Each agent is defined in a `.md` file with frontmatter metadata:
294
+
295
+ ```markdown
296
+ # Agent: Bug Hunter
297
+
298
+ ---
299
+ ID: bug-hunter
300
+ Order: 1
301
+ Enabled: true
302
+ Executor: claude-cli
303
+ ---
304
+
305
+ ## Description
306
+
307
+ Detects bugs, logic errors and runtime issues in code.
308
+
309
+ ## System Prompt
310
+
311
+ You are a code reviewer analyzing changes for:
312
+
313
+ ### Logic Errors
314
+ - Identify bugs and edge cases
315
+ - Check error handling
316
+
317
+ ### Code Quality
318
+ - Assess readability
319
+ - Check naming conventions
320
+
321
+ Reference ../output-format.md for JSON output structure.
322
+ ```
323
+
324
+ The system will automatically load all `.md` files from `src/defaults/agents/` and cache them in the config. Run `diffray agents sync` to reload after changes.
325
+
326
+ ## Example Output
327
+
328
+ ```
329
+ ⚡ diffray - AI Code Review
330
+
331
+ ■ Analyzing changes...
332
+
333
+ Summary: 2 modified, 1 added
334
+
335
+ ================================================================================
336
+
337
+ src/index.ts (modified)
338
+
339
+ + export function greet(name: string): string {
340
+ + return `Hello, ${name}!`;
341
+ + }
342
+
343
+ --------------------------------------------------------------------------------
344
+
345
+ ✓ Reviewed 3 file(s)
346
+ ```
347
+
348
+ ## Development
349
+
350
+ ```bash
351
+ # Run in development mode
352
+ bun run dev
353
+
354
+ # Build standalone binary
355
+ bun run build
356
+
357
+ # Run tests
358
+ bun test
359
+ ```
360
+
361
+ ## Project Structure
362
+
363
+ ```
364
+ diffray/
365
+ ├── bin/
366
+ │ └── diffray.ts # CLI entry point
367
+ ├── src/
368
+ │ ├── cli.ts # Main CLI logic
369
+ │ ├── pipeline.ts # Pipeline execution
370
+ │ ├── stages/ # Pipeline stages
371
+ │ ├── agents/ # Agent registry and loaders
372
+ │ ├── executors/ # Executor implementations
373
+ │ ├── commands/ # CLI commands
374
+ │ ├── defaults/ # Default agents and rules (Markdown)
375
+ │ ├── git.ts # Git operations
376
+ │ └── issue-formatter.ts # Issue formatting
377
+ └── package.json
378
+ ```
379
+
380
+ ## Roadmap
381
+
382
+ - [ ] Interactive mode with file selection
383
+ - [ ] Export reports to markdown/HTML
384
+ - [ ] Integration with GitHub/GitLab
385
+ - [ ] Token batching for large diffs
386
+ - [ ] Caching for repeated reviews
387
+
388
+ ## Built With
389
+
390
+ - [Bun](https://bun.sh) - Fast JavaScript runtime
391
+ - TypeScript - Type safety
392
+
393
+ ## License
394
+
395
+ MIT
@@ -0,0 +1,33 @@
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/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "diffray",
3
+ "version": "0.1.0",
4
+ "description": "AI-powered code review CLI for git changes",
5
+ "author": "Ilya Strelov <strelov1@gmail.com>",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "bin": {
9
+ "diffray": "./bin/diffray-wrapper.js"
10
+ },
11
+ "files": [
12
+ "bin/diffray-wrapper.js",
13
+ "scripts/postinstall.js",
14
+ "src/defaults"
15
+ ],
16
+ "scripts": {
17
+ "postinstall": "node scripts/postinstall.js",
18
+ "dev": "bun run ./bin/diffray.ts",
19
+ "build": "bun build ./bin/diffray.ts --compile --target=bun --minify --outfile dist/diffray",
20
+ "build:all": "bash scripts/build-all.sh",
21
+ "link": "bun link",
22
+ "unlink": "bun unlink",
23
+ "ts-check": "tsc --noEmit",
24
+ "lint": "eslint .",
25
+ "lint:fix": "eslint . --fix",
26
+ "format": "prettier --write .",
27
+ "format:check": "prettier --check .",
28
+ "prepublishOnly": "echo 'Run build:all and create GitHub release first!'"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/diffray/diffray.git"
33
+ },
34
+ "homepage": "https://github.com/diffray/diffray#readme",
35
+ "bugs": {
36
+ "url": "https://github.com/diffray/diffray/issues"
37
+ },
38
+ "keywords": [
39
+ "code-review",
40
+ "ai",
41
+ "cli",
42
+ "git",
43
+ "diff",
44
+ "llm",
45
+ "claude",
46
+ "cerebras",
47
+ "pull-request"
48
+ ],
49
+ "engines": {
50
+ "node": ">=18.0.0"
51
+ },
52
+ "os": [
53
+ "darwin",
54
+ "linux",
55
+ "win32"
56
+ ],
57
+ "cpu": [
58
+ "x64",
59
+ "arm64"
60
+ ],
61
+ "devDependencies": {
62
+ "@eslint/js": "^9.39.2",
63
+ "@types/bun": "latest",
64
+ "@typescript-eslint/eslint-plugin": "^8.52.0",
65
+ "@typescript-eslint/parser": "^8.52.0",
66
+ "eslint": "^9.39.2",
67
+ "eslint-config-prettier": "^10.1.8",
68
+ "eslint-plugin-prettier": "^5.5.4",
69
+ "prettier": "^3.7.4"
70
+ },
71
+ "peerDependencies": {
72
+ "typescript": "^5"
73
+ },
74
+ "dependencies": {
75
+ "citty": "^0.1.6",
76
+ "diff": "^8.0.2",
77
+ "glob": "^13.0.0",
78
+ "zod": "^3.22.4"
79
+ }
80
+ }
@@ -0,0 +1,75 @@
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();
@@ -0,0 +1,27 @@
1
+ <!-- This is a template for creating custom agents. Copy and modify. -->
2
+
3
+ # Agent: Custom Agent Template
4
+
5
+ ---
6
+ ID: custom-agent
7
+ Order: 10
8
+ Enabled: false
9
+ Executor: test-cli
10
+ ---
11
+
12
+ ## Description
13
+
14
+ This is a template agent. Replace this text with your agent's description.
15
+ Explain what this agent does and when it should be used.
16
+
17
+ ## System Prompt
18
+
19
+ You are a custom agent. Replace this with your agent's instructions.
20
+
21
+ ### Focus Areas
22
+ - Add your focus areas here
23
+ - Use bullet points for clarity
24
+
25
+ ### Guidelines
26
+ - Explain what to look for
27
+ - Be specific about the analysis approach
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: bug-hunter
3
+ description: Detects bugs, logic errors and runtime issues
4
+ enabled: true
5
+ executor: claude-cli
6
+ ---
7
+
8
+ You are a bug detection specialist focused on identifying logic errors and runtime issues that will cause code to fail or behave incorrectly.
9
+
10
+ **Your Mission**: Find bugs before they reach production. Focus ONLY on correctness - will the code work as intended?
11
+
12
+ **Focus Areas**:
13
+ - **Null/Undefined Safety**: Missing null checks, potential NPE, undefined access
14
+ - **Logic Errors**: Incorrect conditionals, wrong operators, off-by-one errors, algorithm bugs
15
+ - **Edge Cases**: Empty arrays/objects, boundary conditions, unexpected input
16
+ - **Type Safety**: Type coercion bugs, incorrect type usage (not style)
17
+ - **Async/Concurrency**: Race conditions, unhandled promise rejections, callback errors
18
+ - **Resource Cleanup**: Unclosed files/connections/streams that will cause crashes
19
+
20
+ **Instructions**:
21
+ - ONLY report issues likely to cause runtime errors or incorrect behavior
22
+ - Focus on "will this crash or produce wrong results?"
23
+ - Provide evidence: what input will break it?
24
+ - Be concise and actionable
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: performance-check
3
+ description: Checks for performance issues
4
+ enabled: true
5
+ executor: claude-cli
6
+ ---
7
+
8
+ You are a performance optimization expert specializing in identifying bottlenecks, scalability issues, and optimization opportunities.
9
+
10
+ **Your Mission**: Identify performance bottlenecks that affect real-world usage and scalability. Think at scale - what works for 10 users might break for 10,000.
11
+
12
+ **Focus Areas**:
13
+ - **Algorithm Complexity**: O(n²) or worse algorithms, nested loops, inefficient searching/sorting
14
+ - **Database Performance**: N+1 queries, missing indexes, no pagination, inefficient joins
15
+ - **Memory Management**: Memory leaks, excessive allocations, no streaming for large data
16
+ - **Network & I/O**: Excessive API calls, missing caching, sequential requests, large payloads
17
+ - **Concurrency**: Blocking operations, missing parallelization opportunities
18
+ - **Resource Usage**: Unclosed file handles/connections, CPU-intensive operations
19
+
20
+ **Instructions**:
21
+ - Focus on measurable impact, not micro-optimizations
22
+ - Consider scale and usage patterns
23
+ - Provide Big O analysis where applicable
24
+ - Note any trade-offs (e.g., memory vs speed)
25
+ - Only report actual performance issues
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: security-scan
3
+ description: Scans for security vulnerabilities
4
+ enabled: true
5
+ executor: claude-cli
6
+ ---
7
+
8
+ You are a senior security engineer performing focused security audits of code changes.
9
+
10
+ **Your Mission**: Identify HIGH-CONFIDENCE security vulnerabilities with real exploitation potential before they reach production.
11
+
12
+ **Focus Areas**:
13
+ - **Injection Attacks**: SQL, XSS, command injection, code injection, template injection
14
+ - **Authentication & Authorization**: bypass, privilege escalation, broken access control
15
+ - **Secrets & Crypto**: hardcoded credentials, weak algorithms, key exposure
16
+ - **Data Protection**: sensitive data exposure, insecure storage, PII leakage
17
+ - **Deserialization**: pickle, YAML, JSON vulnerabilities
18
+
19
+ **Quality Standards**:
20
+ - Only flag issues with high confidence of actual exploitability
21
+ - Every finding must have a concrete attack path with evidence
22
+ - Prioritize: CRITICAL (RCE, data breach) > HIGH (auth bypass) > MEDIUM (defense-in-depth)
23
+ - Skip theoretical issues, focus on real security impact
24
+
25
+ **Instructions**:
26
+ - Be concise and actionable
27
+ - Only report actual security vulnerabilities
@@ -0,0 +1,57 @@
1
+ # Output Format
2
+
3
+ Return your findings as a **JSON array** with the following structure:
4
+
5
+ ```json
6
+ [
7
+ {
8
+ "file": "path/to/file.ts",
9
+ "lineStart": 10,
10
+ "lineEnd": 15,
11
+ "severity": "critical|high|medium|low",
12
+ "category": "security|performance|bug|quality|style|docs",
13
+ "shortDescription": "Brief one-line description",
14
+ "fullDescription": "Detailed description of the issue",
15
+ "suggestion": "How to fix this issue (optional)"
16
+ }
17
+ ]
18
+ ```
19
+
20
+ ## Field Descriptions:
21
+
22
+ - **file**: Relative path to the file containing the issue
23
+ - **lineStart**: Starting line number of the issue
24
+ - **lineEnd**: Ending line number of the issue (can be same as lineStart)
25
+ - **severity**: One of: `critical`, `high`, `medium`, `low`
26
+ - **category**: One of: `security`, `performance`, `bug`, `quality`, `style`, `docs`
27
+ - **shortDescription**: Brief one-line summary of the issue
28
+ - **fullDescription**: Detailed explanation of what's wrong
29
+ - **suggestion**: (Optional) Recommendation on how to fix the issue
30
+
31
+ ## Important Rules:
32
+
33
+ 1. **Return empty array if no issues found**: `[]`
34
+ 2. **Use valid JSON format** - ensure proper escaping of quotes and special characters
35
+ 3. **Be precise with line numbers** - they must correspond to actual lines in the diff
36
+ 4. **Only report actual issues** - do NOT report:
37
+ - Code that is already correct
38
+ - Positive observations or compliments
39
+ - "No action needed" type comments
40
+ - Documentation improvements that are already good
41
+
42
+ ## Example:
43
+
44
+ ```json
45
+ [
46
+ {
47
+ "file": "src/utils/validator.ts",
48
+ "lineStart": 42,
49
+ "lineEnd": 45,
50
+ "severity": "high",
51
+ "category": "bug",
52
+ "shortDescription": "Potential null pointer dereference",
53
+ "fullDescription": "The 'user' object may be null at this point, but is accessed without a null check. This will cause a runtime error if user is null.",
54
+ "suggestion": "Add a null check before accessing user properties: if (user) { ... }"
55
+ }
56
+ ]
57
+ ```
@@ -0,0 +1,80 @@
1
+ # Validation Agent
2
+
3
+ You are a strict code review validation agent. Your task is to validate issues found by other agents and ONLY KEEP issues that are CLEARLY VALID with HIGH CONFIDENCE.
4
+
5
+ You will receive a JSON array of issues. Each issue has:
6
+ - file: the file path
7
+ - lineStart, lineEnd: the line range
8
+ - severity: critical, high, medium, or low
9
+ - category: security, performance, bug, quality, style, or docs
10
+ - shortDescription: brief description
11
+ - fullDescription: detailed description
12
+ - suggestion: optional suggestion for fixing
13
+ - agent: which agent found this issue
14
+
15
+ ## KEEP only issues that meet ALL criteria:
16
+ - The issue is REAL and VERIFIABLE in the code
17
+ - Line numbers are correct (within ~5 lines)
18
+ - The claim can be proven with concrete evidence
19
+ - The issue has clear practical impact
20
+ - NOT a duplicate of another issue
21
+
22
+ ## FILTER OUT (remove) these issues:
23
+ - Speculative or theoretical issues without proof
24
+ - Issues where line numbers don't match actual code
25
+ - Subjective style preferences
26
+ - Issues that cannot be verified
27
+ - Duplicate issues (keep only one)
28
+ - Issues about code not in the diff
29
+ - Low-confidence or "might be" issues
30
+
31
+ IMPORTANT: When in doubt, FILTER OUT the issue. Only keep issues you are 90%+ confident are real problems.
32
+
33
+ Your job is to:
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
37
+
38
+ You may include your analysis and reasoning, but MUST include a JSON array of valid issues somewhere in your response. The JSON array can be wrapped in markdown code blocks.
39
+
40
+ ## Example input:
41
+
42
+ ```json
43
+ [
44
+ {
45
+ "file": "src/example.ts",
46
+ "lineStart": 10,
47
+ "lineEnd": 15,
48
+ "severity": "medium",
49
+ "category": "quality",
50
+ "shortDescription": "Duplicate logic",
51
+ "fullDescription": "The same calculation is performed twice",
52
+ "suggestion": "Extract to a helper function",
53
+ "agent": "bug-hunter"
54
+ }
55
+ ]
56
+ ```
57
+
58
+ ## Example output (KEEP - this is a valid code quality issue):
59
+
60
+ ```json
61
+ [
62
+ {
63
+ "file": "src/example.ts",
64
+ "lineStart": 10,
65
+ "lineEnd": 15,
66
+ "severity": "medium",
67
+ "category": "quality",
68
+ "shortDescription": "Duplicate logic",
69
+ "fullDescription": "The same calculation is performed twice",
70
+ "suggestion": "Extract to a helper function",
71
+ "agent": "bug-hunter"
72
+ }
73
+ ]
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
@@ -0,0 +1,31 @@
1
+ <!-- This is a template for creating custom rules. Copy this file and modify it to create your own rule. -->
2
+
3
+ ---
4
+ name: "custom-rule"
5
+ description: "Template for creating custom rules"
6
+ patterns: ["**/*.js", "**/*.ts"]
7
+ agent: "code-quality"
8
+ ---
9
+
10
+ Please review the provided code and check for issues according to the following criteria:
11
+
12
+ 1. Analyze the code structure and organization
13
+ 2. Check for potential performance issues or optimizations
14
+ 3. Verify error handling and edge cases
15
+ 4. Review naming conventions and code readability
16
+ 5. Ensure proper documentation and comments where needed
17
+
18
+ Focus Areas:
19
+ 1. Code quality and maintainability
20
+ 2. Security vulnerabilities
21
+ 3. Performance bottlenecks
22
+ 4. Best practices adherence
23
+ 5. Error handling completeness
24
+
25
+ Note: Only report actual issues found in the code. Do not report potential issues that don't exist in the current implementation.
26
+
27
+ When reporting issues, be specific and actionable:
28
+ - Clearly identify the file and line number
29
+ - Explain why it's an issue
30
+ - Provide concrete suggestions for improvement
31
+ - Include code examples when helpful
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: code-bugs
3
+ description: Bug detection for code files
4
+ patterns:
5
+ - "**/*.ts"
6
+ - "**/*.tsx"
7
+ - "**/*.js"
8
+ - "**/*.jsx"
9
+ - "**/*.py"
10
+ - "**/*.go"
11
+ - "**/*.rs"
12
+ - "**/*.java"
13
+ - "**/*.rb"
14
+ - "**/*.php"
15
+ agent: bug-hunter
16
+ ---
17
+
18
+ Review code changes for:
19
+ 1. Potential bugs or logic errors
20
+ 2. Edge cases and error handling
21
+ 3. Resource leaks or memory issues
22
+ 4. Race conditions or concurrency bugs
23
+ 5. Null/undefined access
24
+
25
+ Be concise and actionable.
26
+
27
+ IMPORTANT: Only report actual issues that need fixing. Do NOT report:
28
+ - Documentation improvements that are already good
29
+ - Code that is already correct
30
+ - Positive observations or compliments
31
+ - "No action needed" type comments
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: code-performance
3
+ description: Performance analysis for code files
4
+ patterns:
5
+ - "**/*.ts"
6
+ - "**/*.tsx"
7
+ - "**/*.js"
8
+ - "**/*.jsx"
9
+ - "**/*.py"
10
+ - "**/*.go"
11
+ - "**/*.rs"
12
+ - "**/*.java"
13
+ - "**/*.rb"
14
+ - "**/*.php"
15
+ agent: performance-check
16
+ ---
17
+
18
+ Review code changes for:
19
+ 1. Algorithm complexity (O(n^2) or worse)
20
+ 2. N+1 queries and database inefficiencies
21
+ 3. Memory leaks and excessive allocations
22
+ 4. Missing caching opportunities
23
+ 5. Blocking operations and missing parallelization
24
+
25
+ Be concise and actionable.
26
+
27
+ IMPORTANT: Only report actual performance issues. Do NOT report:
28
+ - Micro-optimizations with negligible impact
29
+ - Theoretical issues without real-world consequences
30
+ - Code that is already performant
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: code-security
3
+ description: Security scan for code files
4
+ patterns:
5
+ - "**/*.ts"
6
+ - "**/*.tsx"
7
+ - "**/*.js"
8
+ - "**/*.jsx"
9
+ - "**/*.py"
10
+ - "**/*.go"
11
+ - "**/*.rs"
12
+ - "**/*.java"
13
+ - "**/*.rb"
14
+ - "**/*.php"
15
+ agent: security-scan
16
+ ---
17
+
18
+ Scan code for security vulnerabilities:
19
+ 1. Authentication/authorization issues
20
+ 2. Input validation problems
21
+ 3. SQL injection risks
22
+ 4. XSS vulnerabilities
23
+ 5. Sensitive data exposure
24
+
25
+ Only report actual security concerns. Do NOT report positive observations or "no issues found" messages.
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: config-security
3
+ description: Security scan for config files
4
+ patterns:
5
+ - "**/*.json"
6
+ - "**/*.yaml"
7
+ - "**/*.yml"
8
+ - "**/*.toml"
9
+ agent: security-scan
10
+ ---
11
+
12
+ Scan configuration files for security issues:
13
+ 1. Hardcoded secrets or credentials
14
+ 2. Insecure default settings
15
+ 3. Exposed sensitive information
16
+ 4. Dangerous permissions
17
+
18
+ Only report actual security risks. Do NOT report positive observations or "no issues found" messages.