diffray 0.1.2 → 0.2.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.
Files changed (34) hide show
  1. package/README.md +866 -250
  2. package/dist/defaults/agents/api-design.md +31 -0
  3. package/dist/defaults/agents/bug-hunter.md +0 -1
  4. package/dist/defaults/agents/consistency-check.md +27 -0
  5. package/dist/defaults/agents/data-privacy.md +30 -0
  6. package/dist/defaults/agents/database.md +30 -0
  7. package/dist/defaults/agents/general.md +0 -1
  8. package/dist/defaults/agents/i18n.md +29 -0
  9. package/dist/defaults/agents/observability.md +30 -0
  10. package/dist/defaults/agents/performance-check.md +0 -1
  11. package/dist/defaults/agents/security-scan.md +0 -1
  12. package/dist/defaults/agents/validation.md +0 -1
  13. package/dist/defaults/prompts/INDEX.md +178 -0
  14. package/dist/defaults/prompts/README.md +173 -0
  15. package/dist/defaults/prompts/SUMMARY.md +276 -0
  16. package/dist/defaults/prompts/USAGE.md +277 -0
  17. package/dist/defaults/prompts/api-design.md +119 -0
  18. package/dist/defaults/prompts/data-privacy.md +144 -0
  19. package/dist/defaults/prompts/database.md +105 -0
  20. package/dist/defaults/prompts/i18n.md +89 -0
  21. package/dist/defaults/prompts/observability.md +142 -0
  22. package/dist/defaults/rules/code-consistency.md +74 -0
  23. package/dist/defaults/rules/code-general.md +46 -0
  24. package/dist/diffray.cjs +347 -0
  25. package/package.json +29 -13
  26. package/src/defaults/agents/bug-hunter.md +0 -1
  27. package/src/defaults/agents/consistency-check.md +27 -0
  28. package/src/defaults/agents/general.md +0 -1
  29. package/src/defaults/agents/performance-check.md +0 -1
  30. package/src/defaults/agents/security-scan.md +0 -1
  31. package/src/defaults/agents/validation.md +0 -1
  32. package/src/defaults/rules/code-consistency.md +74 -0
  33. package/src/defaults/rules/code-general.md +46 -0
  34. package/dist/diffray.js +0 -337
package/package.json CHANGED
@@ -1,32 +1,34 @@
1
1
  {
2
2
  "name": "diffray",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
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": "./dist/diffray.js"
9
+ "diffray": "./dist/diffray.cjs"
10
10
  },
11
11
  "files": [
12
- "dist/diffray.js",
12
+ "dist/diffray.cjs",
13
13
  "dist/defaults",
14
14
  "src/defaults"
15
15
  ],
16
16
  "scripts": {
17
- "dev": "bun run ./bin/diffray.ts",
18
- "build": "bun build ./bin/diffray.ts --outfile dist/diffray.js --target node --minify && 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
- "link": "bun link",
22
- "unlink": "bun unlink",
23
- "test": "bun test",
17
+ "dev": "npx tsx ./bin/diffray.ts",
18
+ "build": "node build.mjs && 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')\" && npm link",
20
+ "link:publish": "node -e \"const p=require('./package.json');p.bin.diffray='./dist/diffray.cjs';require('fs').writeFileSync('package.json',JSON.stringify(p,null,2)+'\\n')\"",
21
+ "link": "npm link",
22
+ "unlink": "npm unlink",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
24
25
  "ts-check": "tsc --noEmit",
25
26
  "lint": "eslint .",
26
27
  "lint:fix": "eslint . --fix",
27
28
  "format": "prettier --write .",
28
29
  "format:check": "prettier --check .",
29
- "prepublishOnly": "npm run build && npm run link:publish"
30
+ "prepublishOnly": "npm run build && npm run link:publish",
31
+ "prepare": "husky"
30
32
  },
31
33
  "repository": {
32
34
  "type": "git",
@@ -61,13 +63,27 @@
61
63
  ],
62
64
  "devDependencies": {
63
65
  "@eslint/js": "^9.39.2",
64
- "@types/bun": "latest",
66
+ "@types/node": "^22.15.21",
65
67
  "@typescript-eslint/eslint-plugin": "^8.52.0",
66
68
  "@typescript-eslint/parser": "^8.52.0",
69
+ "esbuild": "^0.25.0",
67
70
  "eslint": "^9.39.2",
68
71
  "eslint-config-prettier": "^10.1.8",
69
72
  "eslint-plugin-prettier": "^5.5.4",
70
- "prettier": "^3.7.4"
73
+ "husky": "^9.1.0",
74
+ "lint-staged": "^15.5.0",
75
+ "prettier": "^3.7.4",
76
+ "tsx": "^4.19.0",
77
+ "vitest": "^3.1.0"
78
+ },
79
+ "lint-staged": {
80
+ "*.{ts,tsx,js,jsx}": [
81
+ "eslint --fix",
82
+ "prettier --write"
83
+ ],
84
+ "*.{json,md,yml,yaml}": [
85
+ "prettier --write"
86
+ ]
71
87
  },
72
88
  "peerDependencies": {
73
89
  "typescript": "^5"
@@ -2,7 +2,6 @@
2
2
  name: bug-hunter
3
3
  description: Detects bugs, logic errors and runtime issues
4
4
  enabled: true
5
- executor: claude-cli
6
5
  ---
7
6
 
8
7
  You are a bug detection specialist focused on identifying logic errors and runtime issues that will cause code to fail or behave incorrectly.
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: consistency-check
3
+ description: Detects inconsistencies in code style, patterns, and conventions
4
+ enabled: true
5
+ ---
6
+
7
+ You are a code consistency specialist focused on detecting inconsistencies within the codebase that make code harder to read and maintain.
8
+
9
+ **Your Mission**: Ensure code follows consistent patterns and conventions across the project. Find places where new code deviates from established patterns.
10
+
11
+ **Focus Areas**:
12
+ - **Naming Inconsistencies**: Same concept named differently (e.g., `userId` vs `user_id`, `getData` vs `fetchData`)
13
+ - **Pattern Deviations**: New code using different patterns than existing code (e.g., callbacks vs promises, different error handling)
14
+ - **API Inconsistencies**: Similar functions with different signatures, inconsistent return types
15
+ - **Import Style**: Mixed import styles (default vs named, relative vs absolute paths)
16
+ - **Error Handling**: Inconsistent error handling patterns (try/catch vs .catch, custom vs standard errors)
17
+ - **Formatting Variations**: Inconsistent formatting not caught by linters (object shorthand usage, arrow vs regular functions)
18
+ - **Documentation Style**: Inconsistent markdown formatting, heading hierarchy, link formats, code block annotations
19
+ - **Config/JSON/YAML Style**: Inconsistent key naming (camelCase vs snake_case), value formats, structure patterns
20
+
21
+ **Instructions**:
22
+ - Compare new code against established patterns in the codebase
23
+ - ONLY report inconsistencies that harm readability or maintainability
24
+ - Point out what the established pattern is and how the new code deviates
25
+ - Do NOT report on personal style preferences
26
+ - Ignore intentional deviations with clear purpose
27
+ - Be specific about which pattern should be followed
@@ -2,7 +2,6 @@
2
2
  name: general
3
3
  description: General code reviewer focused on simplicity and clarity
4
4
  enabled: true
5
- executor: claude-cli
6
5
  ---
7
6
 
8
7
  You are a code reviewer. Focus on keeping code simple, readable, and maintainable.
@@ -2,7 +2,6 @@
2
2
  name: performance-check
3
3
  description: Checks for performance issues
4
4
  enabled: true
5
- executor: claude-cli
6
5
  ---
7
6
 
8
7
  You are a performance optimization expert specializing in identifying bottlenecks, scalability issues, and optimization opportunities.
@@ -2,7 +2,6 @@
2
2
  name: security-scan
3
3
  description: Scans for security vulnerabilities
4
4
  enabled: true
5
- executor: claude-cli
6
5
  ---
7
6
 
8
7
  You are a senior security engineer performing focused security audits of code changes.
@@ -4,7 +4,6 @@ description: Validates issues found by other agents and filters out false positi
4
4
  enabled: true
5
5
  order: 999
6
6
  stage: validation
7
- executor: claude-cli
8
7
  executorSettings:
9
8
  model: opus
10
9
  timeout: 180
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: code-consistency
3
+ description: Consistency check 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
+ - "**/*.c"
16
+ - "**/*.cpp"
17
+ - "**/*.h"
18
+ - "**/*.cs"
19
+ - "**/*.swift"
20
+ - "**/*.kt"
21
+ - "**/*.scala"
22
+ - "**/*.md"
23
+ - "**/*.json"
24
+ - "**/*.yaml"
25
+ - "**/*.yml"
26
+ agent: consistency-check
27
+ ---
28
+
29
+ Review code changes for inconsistencies with existing codebase patterns:
30
+
31
+ 1. **Naming conventions** - Does new code follow established naming patterns?
32
+ - Variable/function naming style (camelCase, snake_case, etc.)
33
+ - Similar concepts should use similar names
34
+
35
+ 2. **Code patterns** - Does new code use same patterns as existing code?
36
+ - Async handling (async/await vs callbacks vs promises)
37
+ - Error handling approach
38
+ - Data fetching patterns
39
+ - State management patterns
40
+
41
+ 3. **API design** - Are new APIs consistent with existing ones?
42
+ - Parameter ordering and naming
43
+ - Return value structure
44
+ - Error response format
45
+
46
+ 4. **Import/export style** - Consistent module organization?
47
+ - Import ordering and grouping
48
+ - Default vs named exports
49
+
50
+ 5. **Type definitions** - Consistent type patterns?
51
+ - Interface vs type usage
52
+ - Optional vs nullable patterns
53
+
54
+ 6. **Documentation consistency** (for .md files)
55
+ - Heading styles and hierarchy
56
+ - Link formats and references
57
+ - Code block language annotations
58
+ - Section ordering and structure
59
+
60
+ 7. **Config/JSON/YAML consistency** (for config files)
61
+ - Key naming conventions (camelCase vs snake_case vs kebab-case)
62
+ - Value formats (strings vs numbers, quotes usage)
63
+ - Structure patterns (nesting depth, array vs object)
64
+ - Comment styles (where applicable)
65
+
66
+ IMPORTANT: Only report inconsistencies that:
67
+ - Make the codebase harder to navigate
68
+ - Could lead to confusion or bugs
69
+ - Violate clearly established patterns
70
+
71
+ Do NOT report:
72
+ - Style preferences without established pattern
73
+ - Intentional deviations with clear purpose
74
+ - Minor variations that don't impact readability
@@ -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