@aaronshaf/ger 1.2.11 → 2.0.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/.ast-grep/rules/no-as-casting.yml +13 -0
- package/.claude-plugin/plugin.json +22 -0
- package/.github/workflows/ci-simple.yml +53 -0
- package/.github/workflows/ci.yml +171 -0
- package/.github/workflows/claude-code-review.yml +83 -0
- package/.github/workflows/claude.yml +50 -0
- package/.github/workflows/dependency-update.yml +84 -0
- package/.github/workflows/release.yml +166 -0
- package/.github/workflows/security-scan.yml +113 -0
- package/.github/workflows/security.yml +96 -0
- package/.husky/pre-commit +16 -0
- package/.husky/pre-push +25 -0
- package/.lintstagedrc.json +6 -0
- package/.tool-versions +1 -0
- package/CLAUDE.md +105 -0
- package/DEVELOPMENT.md +361 -0
- package/EXAMPLES.md +457 -0
- package/README.md +831 -16
- package/bin/ger +3 -18
- package/biome.json +36 -0
- package/bun.lock +678 -0
- package/bunfig.toml +8 -0
- package/docs/adr/0001-use-effect-for-side-effects.md +65 -0
- package/docs/adr/0002-use-bun-runtime.md +64 -0
- package/docs/adr/0003-store-credentials-in-home-directory.md +75 -0
- package/docs/adr/0004-use-commander-for-cli.md +76 -0
- package/docs/adr/0005-use-effect-schema-for-validation.md +93 -0
- package/docs/adr/0006-use-msw-for-api-mocking.md +89 -0
- package/docs/adr/0007-git-hooks-for-quality.md +94 -0
- package/docs/adr/0008-no-as-typecasting.md +83 -0
- package/docs/adr/0009-file-size-limits.md +82 -0
- package/docs/adr/0010-llm-friendly-xml-output.md +93 -0
- package/docs/adr/0011-ai-tool-strategy-pattern.md +102 -0
- package/docs/adr/0012-build-status-message-parsing.md +94 -0
- package/docs/adr/0013-git-subprocess-integration.md +98 -0
- package/docs/adr/0014-group-management-support.md +95 -0
- package/docs/adr/0015-batch-comment-processing.md +111 -0
- package/docs/adr/0016-flexible-change-identifiers.md +94 -0
- package/docs/adr/0017-git-worktree-support.md +102 -0
- package/docs/adr/0018-auto-install-commit-hook.md +103 -0
- package/docs/adr/0019-sdk-package-exports.md +95 -0
- package/docs/adr/0020-code-coverage-enforcement.md +105 -0
- package/docs/adr/0021-typescript-isolated-declarations.md +83 -0
- package/docs/adr/0022-biome-oxlint-tooling.md +124 -0
- package/docs/adr/README.md +30 -0
- package/docs/prd/README.md +12 -0
- package/docs/prd/architecture.md +325 -0
- package/docs/prd/commands.md +425 -0
- package/docs/prd/data-model.md +349 -0
- package/docs/prd/overview.md +124 -0
- package/index.ts +219 -0
- package/oxlint.json +24 -0
- package/package.json +82 -15
- package/scripts/check-coverage.ts +69 -0
- package/scripts/check-file-size.ts +38 -0
- package/scripts/fix-test-mocks.ts +55 -0
- package/skills/gerrit-workflow/SKILL.md +247 -0
- package/skills/gerrit-workflow/examples.md +572 -0
- package/skills/gerrit-workflow/reference.md +728 -0
- package/src/api/gerrit.ts +696 -0
- package/src/cli/commands/abandon.ts +65 -0
- package/src/cli/commands/add-reviewer.ts +156 -0
- package/src/cli/commands/build-status.ts +282 -0
- package/src/cli/commands/checkout.ts +422 -0
- package/src/cli/commands/comment.ts +460 -0
- package/src/cli/commands/comments.ts +85 -0
- package/src/cli/commands/diff.ts +71 -0
- package/src/cli/commands/extract-url.ts +266 -0
- package/src/cli/commands/groups-members.ts +104 -0
- package/src/cli/commands/groups-show.ts +169 -0
- package/src/cli/commands/groups.ts +137 -0
- package/src/cli/commands/incoming.ts +226 -0
- package/src/cli/commands/init.ts +164 -0
- package/src/cli/commands/mine.ts +115 -0
- package/src/cli/commands/open.ts +57 -0
- package/src/cli/commands/projects.ts +68 -0
- package/src/cli/commands/push.ts +430 -0
- package/src/cli/commands/rebase.ts +52 -0
- package/src/cli/commands/remove-reviewer.ts +123 -0
- package/src/cli/commands/restore.ts +50 -0
- package/src/cli/commands/review.ts +486 -0
- package/src/cli/commands/search.ts +162 -0
- package/src/cli/commands/setup.ts +286 -0
- package/src/cli/commands/show.ts +491 -0
- package/src/cli/commands/status.ts +35 -0
- package/src/cli/commands/submit.ts +108 -0
- package/src/cli/commands/vote.ts +119 -0
- package/src/cli/commands/workspace.ts +200 -0
- package/src/cli/index.ts +53 -0
- package/src/cli/register-commands.ts +659 -0
- package/src/cli/register-group-commands.ts +88 -0
- package/src/cli/register-reviewer-commands.ts +97 -0
- package/src/prompts/default-review.md +86 -0
- package/src/prompts/system-inline-review.md +135 -0
- package/src/prompts/system-overall-review.md +206 -0
- package/src/schemas/config.test.ts +245 -0
- package/src/schemas/config.ts +84 -0
- package/src/schemas/gerrit.ts +681 -0
- package/src/services/commit-hook.ts +314 -0
- package/src/services/config.test.ts +150 -0
- package/src/services/config.ts +250 -0
- package/src/services/git-worktree.ts +342 -0
- package/src/services/review-strategy.ts +292 -0
- package/src/test-utils/mock-generator.ts +138 -0
- package/src/utils/change-id.test.ts +98 -0
- package/src/utils/change-id.ts +63 -0
- package/src/utils/comment-formatters.ts +153 -0
- package/src/utils/diff-context.ts +103 -0
- package/src/utils/diff-formatters.ts +141 -0
- package/src/utils/formatters.ts +85 -0
- package/src/utils/git-commit.test.ts +277 -0
- package/src/utils/git-commit.ts +122 -0
- package/src/utils/index.ts +55 -0
- package/src/utils/message-filters.ts +26 -0
- package/src/utils/review-formatters.ts +89 -0
- package/src/utils/review-prompt-builder.ts +110 -0
- package/src/utils/shell-safety.ts +117 -0
- package/src/utils/status-indicators.ts +100 -0
- package/src/utils/url-parser.test.ts +271 -0
- package/src/utils/url-parser.ts +118 -0
- package/tests/abandon.test.ts +230 -0
- package/tests/add-reviewer.test.ts +579 -0
- package/tests/build-status-watch.test.ts +344 -0
- package/tests/build-status.test.ts +789 -0
- package/tests/change-id-formats.test.ts +268 -0
- package/tests/checkout/integration.test.ts +653 -0
- package/tests/checkout/parse-input.test.ts +55 -0
- package/tests/checkout/validation.test.ts +178 -0
- package/tests/comment-batch-advanced.test.ts +431 -0
- package/tests/comment-gerrit-api-compliance.test.ts +414 -0
- package/tests/comment.test.ts +708 -0
- package/tests/comments.test.ts +323 -0
- package/tests/config-service-simple.test.ts +100 -0
- package/tests/diff.test.ts +419 -0
- package/tests/extract-url.test.ts +517 -0
- package/tests/groups-members.test.ts +256 -0
- package/tests/groups-show.test.ts +323 -0
- package/tests/groups.test.ts +334 -0
- package/tests/helpers/build-status-test-setup.ts +83 -0
- package/tests/helpers/config-mock.ts +27 -0
- package/tests/incoming.test.ts +357 -0
- package/tests/init.test.ts +70 -0
- package/tests/integration/commit-hook.test.ts +246 -0
- package/tests/interactive-incoming.test.ts +173 -0
- package/tests/mine.test.ts +285 -0
- package/tests/mocks/msw-handlers.ts +80 -0
- package/tests/open.test.ts +233 -0
- package/tests/projects.test.ts +259 -0
- package/tests/rebase.test.ts +271 -0
- package/tests/remove-reviewer.test.ts +357 -0
- package/tests/restore.test.ts +237 -0
- package/tests/review.test.ts +135 -0
- package/tests/search.test.ts +712 -0
- package/tests/setup.test.ts +63 -0
- package/tests/show-auto-detect.test.ts +324 -0
- package/tests/show.test.ts +813 -0
- package/tests/status.test.ts +145 -0
- package/tests/submit.test.ts +316 -0
- package/tests/unit/commands/push.test.ts +194 -0
- package/tests/unit/git-branch-detection.test.ts +82 -0
- package/tests/unit/git-worktree.test.ts +55 -0
- package/tests/unit/patterns/push-patterns.test.ts +148 -0
- package/tests/unit/schemas/gerrit.test.ts +85 -0
- package/tests/unit/services/commit-hook.test.ts +132 -0
- package/tests/unit/services/review-strategy.test.ts +349 -0
- package/tests/unit/test-utils/mock-generator.test.ts +154 -0
- package/tests/unit/utils/comment-formatters.test.ts +415 -0
- package/tests/unit/utils/diff-context.test.ts +171 -0
- package/tests/unit/utils/diff-formatters.test.ts +165 -0
- package/tests/unit/utils/formatters.test.ts +411 -0
- package/tests/unit/utils/message-filters.test.ts +227 -0
- package/tests/unit/utils/shell-safety.test.ts +230 -0
- package/tests/unit/utils/status-indicators.test.ts +137 -0
- package/tests/vote.test.ts +317 -0
- package/tests/workspace.test.ts +295 -0
- package/tsconfig.json +36 -5
- package/src/commands/branch.ts +0 -196
- package/src/ger.ts +0 -22
- package/src/types.d.ts +0 -35
- package/src/utils.ts +0 -130
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Command } from 'commander'
|
|
2
|
+
import { Effect } from 'effect'
|
|
3
|
+
import { GerritApiServiceLive } from '@/api/gerrit'
|
|
4
|
+
import { ConfigServiceLive } from '@/services/config'
|
|
5
|
+
import { groupsCommand } from './commands/groups'
|
|
6
|
+
import { groupsShowCommand } from './commands/groups-show'
|
|
7
|
+
import { groupsMembersCommand } from './commands/groups-members'
|
|
8
|
+
|
|
9
|
+
// Helper function to execute Effect with standard error handling
|
|
10
|
+
async function executeEffect<E>(
|
|
11
|
+
effect: Effect.Effect<void, E, never>,
|
|
12
|
+
options: { xml?: boolean },
|
|
13
|
+
resultTag: string,
|
|
14
|
+
): Promise<void> {
|
|
15
|
+
try {
|
|
16
|
+
await Effect.runPromise(effect)
|
|
17
|
+
} catch (error) {
|
|
18
|
+
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
19
|
+
if (options.xml) {
|
|
20
|
+
console.log(`<?xml version="1.0" encoding="UTF-8"?>`)
|
|
21
|
+
console.log(`<${resultTag}>`)
|
|
22
|
+
console.log(` <status>error</status>`)
|
|
23
|
+
console.log(` <error><![CDATA[${errorMessage}]]></error>`)
|
|
24
|
+
console.log(`</${resultTag}>`)
|
|
25
|
+
} else {
|
|
26
|
+
console.error('✗ Error:', errorMessage)
|
|
27
|
+
}
|
|
28
|
+
process.exit(1)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Register all group-related commands (groups, groups-show, groups-members)
|
|
34
|
+
*/
|
|
35
|
+
export function registerGroupCommands(program: Command): void {
|
|
36
|
+
// groups command
|
|
37
|
+
program
|
|
38
|
+
.command('groups')
|
|
39
|
+
.description('List Gerrit groups')
|
|
40
|
+
.option('--pattern <regex>', 'Filter groups by name pattern')
|
|
41
|
+
.option('--owned', 'Show only groups owned by you')
|
|
42
|
+
.option('--project <name>', 'Show groups for specific project')
|
|
43
|
+
.option('--user <account>', 'Show groups a user belongs to')
|
|
44
|
+
.option('--limit <n>', 'Maximum number of results (default: 25)')
|
|
45
|
+
.option('--xml', 'XML output for LLM consumption')
|
|
46
|
+
.action(async (options) => {
|
|
47
|
+
await executeEffect(
|
|
48
|
+
groupsCommand(options).pipe(
|
|
49
|
+
Effect.provide(GerritApiServiceLive),
|
|
50
|
+
Effect.provide(ConfigServiceLive),
|
|
51
|
+
),
|
|
52
|
+
options,
|
|
53
|
+
'groups_result',
|
|
54
|
+
)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// groups-show command
|
|
58
|
+
program
|
|
59
|
+
.command('groups-show <group-id>')
|
|
60
|
+
.description('Show detailed information about a Gerrit group')
|
|
61
|
+
.option('--xml', 'XML output for LLM consumption')
|
|
62
|
+
.action(async (groupId, options) => {
|
|
63
|
+
await executeEffect(
|
|
64
|
+
groupsShowCommand(groupId, options).pipe(
|
|
65
|
+
Effect.provide(GerritApiServiceLive),
|
|
66
|
+
Effect.provide(ConfigServiceLive),
|
|
67
|
+
),
|
|
68
|
+
options,
|
|
69
|
+
'group_detail_result',
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
// groups-members command
|
|
74
|
+
program
|
|
75
|
+
.command('groups-members <group-id>')
|
|
76
|
+
.description('List all members of a Gerrit group')
|
|
77
|
+
.option('--xml', 'XML output for LLM consumption')
|
|
78
|
+
.action(async (groupId, options) => {
|
|
79
|
+
await executeEffect(
|
|
80
|
+
groupsMembersCommand(groupId, options).pipe(
|
|
81
|
+
Effect.provide(GerritApiServiceLive),
|
|
82
|
+
Effect.provide(ConfigServiceLive),
|
|
83
|
+
),
|
|
84
|
+
options,
|
|
85
|
+
'group_members_result',
|
|
86
|
+
)
|
|
87
|
+
})
|
|
88
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Command } from 'commander'
|
|
2
|
+
import { Effect } from 'effect'
|
|
3
|
+
import { GerritApiServiceLive } from '@/api/gerrit'
|
|
4
|
+
import { ConfigServiceLive } from '@/services/config'
|
|
5
|
+
import { addReviewerCommand } from './commands/add-reviewer'
|
|
6
|
+
import { removeReviewerCommand } from './commands/remove-reviewer'
|
|
7
|
+
|
|
8
|
+
// Helper function to execute Effect with standard error handling
|
|
9
|
+
async function executeEffect<E>(
|
|
10
|
+
effect: Effect.Effect<void, E, never>,
|
|
11
|
+
options: { xml?: boolean },
|
|
12
|
+
resultTag: string,
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
try {
|
|
15
|
+
await Effect.runPromise(effect)
|
|
16
|
+
} catch (error) {
|
|
17
|
+
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
18
|
+
if (options.xml) {
|
|
19
|
+
console.log(`<?xml version="1.0" encoding="UTF-8"?>`)
|
|
20
|
+
console.log(`<${resultTag}>`)
|
|
21
|
+
console.log(` <status>error</status>`)
|
|
22
|
+
console.log(` <error><![CDATA[${errorMessage}]]></error>`)
|
|
23
|
+
console.log(`</${resultTag}>`)
|
|
24
|
+
} else {
|
|
25
|
+
console.error('✗ Error:', errorMessage)
|
|
26
|
+
}
|
|
27
|
+
process.exit(1)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Register all reviewer-related commands (add-reviewer, remove-reviewer)
|
|
33
|
+
*/
|
|
34
|
+
export function registerReviewerCommands(program: Command): void {
|
|
35
|
+
// add-reviewer command
|
|
36
|
+
program
|
|
37
|
+
.command('add-reviewer <reviewers...>')
|
|
38
|
+
.description('Add reviewers or groups to a change')
|
|
39
|
+
.option('-c, --change <change-id>', 'Change ID (required until auto-detection is implemented)')
|
|
40
|
+
.option('--cc', 'Add as CC instead of reviewer')
|
|
41
|
+
.option('--group', 'Add as group instead of individual reviewer')
|
|
42
|
+
.option(
|
|
43
|
+
'--notify <level>',
|
|
44
|
+
'Notification level: none, owner, owner_reviewers, all (default: all)',
|
|
45
|
+
)
|
|
46
|
+
.option('--xml', 'XML output for LLM consumption')
|
|
47
|
+
.addHelpText(
|
|
48
|
+
'after',
|
|
49
|
+
`
|
|
50
|
+
Examples:
|
|
51
|
+
$ ger add-reviewer user@example.com -c 12345 # Add a reviewer
|
|
52
|
+
$ ger add-reviewer user1@example.com user2@example.com -c 12345 # Multiple
|
|
53
|
+
$ ger add-reviewer --cc user@example.com -c 12345 # Add as CC
|
|
54
|
+
$ ger add-reviewer --group project-reviewers -c 12345 # Add a group
|
|
55
|
+
$ ger add-reviewer --group admins --cc -c 12345 # Add group as CC
|
|
56
|
+
$ ger add-reviewer --notify none user@example.com -c 12345 # No email`,
|
|
57
|
+
)
|
|
58
|
+
.action(async (reviewers, options) => {
|
|
59
|
+
await executeEffect(
|
|
60
|
+
addReviewerCommand(reviewers, options).pipe(
|
|
61
|
+
Effect.provide(GerritApiServiceLive),
|
|
62
|
+
Effect.provide(ConfigServiceLive),
|
|
63
|
+
),
|
|
64
|
+
options,
|
|
65
|
+
'add_reviewer_result',
|
|
66
|
+
)
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
// remove-reviewer command
|
|
70
|
+
program
|
|
71
|
+
.command('remove-reviewer <reviewers...>')
|
|
72
|
+
.description('Remove reviewers from a change')
|
|
73
|
+
.option('-c, --change <change-id>', 'Change ID (required until auto-detection is implemented)')
|
|
74
|
+
.option(
|
|
75
|
+
'--notify <level>',
|
|
76
|
+
'Notification level: none, owner, owner_reviewers, all (default: all)',
|
|
77
|
+
)
|
|
78
|
+
.option('--xml', 'XML output for LLM consumption')
|
|
79
|
+
.addHelpText(
|
|
80
|
+
'after',
|
|
81
|
+
`
|
|
82
|
+
Examples:
|
|
83
|
+
$ ger remove-reviewer user@example.com -c 12345 # Remove a reviewer
|
|
84
|
+
$ ger remove-reviewer user1@example.com user2@example.com -c 12345 # Multiple
|
|
85
|
+
$ ger remove-reviewer --notify none user@example.com -c 12345 # No email`,
|
|
86
|
+
)
|
|
87
|
+
.action(async (reviewers, options) => {
|
|
88
|
+
await executeEffect(
|
|
89
|
+
removeReviewerCommand(reviewers, options).pipe(
|
|
90
|
+
Effect.provide(GerritApiServiceLive),
|
|
91
|
+
Effect.provide(ConfigServiceLive),
|
|
92
|
+
),
|
|
93
|
+
options,
|
|
94
|
+
'remove_reviewer_result',
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Engineering Code Review - Signal Over Noise
|
|
2
|
+
|
|
3
|
+
You are conducting a technical code review for experienced engineers. **PRIORITY: Find actual problems, not generate busy work.**
|
|
4
|
+
|
|
5
|
+
## Core Principles
|
|
6
|
+
|
|
7
|
+
**SIGNAL > NOISE**: Only comment on issues that materially impact correctness, security, performance, or maintainability. Silence is better than noise.
|
|
8
|
+
|
|
9
|
+
**NO PRAISE NEEDED**: Don't compliment good code. Engineers expect competent code by default.
|
|
10
|
+
|
|
11
|
+
**EMPTY RESPONSES ARE VALID**: Small changes without issues should result in empty inline comments. The overall review can simply note "No significant issues found."
|
|
12
|
+
|
|
13
|
+
**FOCUS ON REAL PROBLEMS**:
|
|
14
|
+
- Bugs that will cause runtime failures
|
|
15
|
+
- Security vulnerabilities
|
|
16
|
+
- Performance bottlenecks
|
|
17
|
+
- Architectural mistakes
|
|
18
|
+
- Missing error handling
|
|
19
|
+
|
|
20
|
+
**ASSUME COMPETENCE**: The author is an experienced engineer who made intentional decisions. Question only when you see genuine problems.
|
|
21
|
+
|
|
22
|
+
## Review Categories (Priority Order)
|
|
23
|
+
|
|
24
|
+
### 1. CRITICAL ISSUES (Must Fix)
|
|
25
|
+
- **Correctness**: Logic errors, race conditions, data corruption risks
|
|
26
|
+
- **Security**: Authentication bypasses, injection vulnerabilities, data exposure
|
|
27
|
+
- **Data Loss**: Operations that could destroy or corrupt user data
|
|
28
|
+
- **Breaking Changes**: Incompatible API/schema changes without migration
|
|
29
|
+
- **Production Impact**: Issues that would cause outages or severe degradation
|
|
30
|
+
|
|
31
|
+
### 2. SIGNIFICANT CONCERNS (Should Fix)
|
|
32
|
+
- **Performance**: Memory leaks, N+1 queries, inefficient algorithms
|
|
33
|
+
- **Error Handling**: Missing error cases, silent failures, poor recovery
|
|
34
|
+
- **Resource Management**: Unclosed connections, file handles, cleanup issues
|
|
35
|
+
- **Type Safety**: Unsafe casts, missing validation, schema mismatches
|
|
36
|
+
- **Concurrency**: Deadlock risks, thread safety issues, synchronization problems
|
|
37
|
+
|
|
38
|
+
### 3. CODE QUALITY (Consider Fixing)
|
|
39
|
+
- **Architecture**: Design pattern violations, coupling issues, abstraction leaks
|
|
40
|
+
- **Maintainability**: Complex logic without justification, unclear naming
|
|
41
|
+
- **Testing**: Missing test coverage for critical paths, brittle test design
|
|
42
|
+
- **Documentation**: Misleading comments, missing API documentation
|
|
43
|
+
- **Best Practices**: Framework misuse, anti-patterns, deprecated APIs
|
|
44
|
+
|
|
45
|
+
### 4. MINOR IMPROVEMENTS (Optional)
|
|
46
|
+
- **Consistency**: Deviations from established patterns without reason
|
|
47
|
+
- **Efficiency**: Minor optimization opportunities
|
|
48
|
+
- **Clarity**: Code that works but could be more readable
|
|
49
|
+
- **Future-Proofing**: Anticipating likely future requirements
|
|
50
|
+
|
|
51
|
+
## What NOT to Review (Common Time Wasters)
|
|
52
|
+
|
|
53
|
+
- **Code style/formatting**: Handled by automated tools
|
|
54
|
+
- **Personal preferences**: Different != wrong
|
|
55
|
+
- **Compliments**: "Looks good!" wastes everyone's time
|
|
56
|
+
- **Nitpicks**: Minor wording, variable names, spacing
|
|
57
|
+
- **Micro-optimizations**: Unless there's a proven performance problem
|
|
58
|
+
- **Already working code**: If it works and isn't broken, don't fix it
|
|
59
|
+
- **Suggestions for "better" approaches**: Only if current approach has concrete problems
|
|
60
|
+
|
|
61
|
+
## Before Commenting, Ask Yourself
|
|
62
|
+
|
|
63
|
+
1. **Will this cause a runtime failure?** → Critical issue, comment required
|
|
64
|
+
2. **Will this create a security vulnerability?** → Critical issue, comment required
|
|
65
|
+
3. **Will this significantly harm performance?** → Important issue, comment required
|
|
66
|
+
4. **Will this make the code unmaintainable?** → Consider commenting
|
|
67
|
+
5. **Is this just a different way to solve the same problem?** → Skip it
|
|
68
|
+
|
|
69
|
+
## Output Guidelines
|
|
70
|
+
|
|
71
|
+
**INLINE COMMENTS**: Only for specific line-level issues. Empty array is perfectly valid.
|
|
72
|
+
- Start with "🤖 "
|
|
73
|
+
- Be direct: "This will cause X bug" not "Consider maybe perhaps changing this"
|
|
74
|
+
- Provide specific fixes when possible
|
|
75
|
+
|
|
76
|
+
**OVERALL REVIEW**: Required even if no inline comments.
|
|
77
|
+
- For clean code: "No significant issues found. Change is ready."
|
|
78
|
+
- For problematic code: Focus on the most important issues only
|
|
79
|
+
- Skip the pleasantries, get to the point
|
|
80
|
+
|
|
81
|
+
## Success Metrics
|
|
82
|
+
|
|
83
|
+
- **Good review**: Finds 1-3 real issues that would cause problems
|
|
84
|
+
- **Great review**: Catches a critical bug before production
|
|
85
|
+
- **Bad review**: 10+ nitpicky comments about style preferences
|
|
86
|
+
- **Terrible review**: "Great job! LGTM!" with zero value added
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
## IMMEDIATE TASK: ANALYZE CODE AND GENERATE INLINE COMMENTS
|
|
2
|
+
|
|
3
|
+
**YOU MUST ANALYZE THE PROVIDED CODE CHANGES RIGHT NOW AND GENERATE INLINE COMMENTS.**
|
|
4
|
+
|
|
5
|
+
**CRITICAL OUTPUT REQUIREMENT:**
|
|
6
|
+
- YOUR ENTIRE OUTPUT MUST BE WRAPPED IN <response></response> TAGS
|
|
7
|
+
- NEVER USE BACKTICKS ANYWHERE IN YOUR RESPONSE - they cause shell execution errors
|
|
8
|
+
- Output ONLY a JSON array wrapped in response tags
|
|
9
|
+
- **EMPTY ARRAY IS PERFECTLY VALID** for clean code without issues
|
|
10
|
+
- No other text before or after the tags
|
|
11
|
+
|
|
12
|
+
**GERRIT FORMATTING RULES FOR YOUR MESSAGE CONTENT:**
|
|
13
|
+
- Each message starts with "🤖 " (robot emoji and space)
|
|
14
|
+
- Use CAPS for emphasis, NOT markdown bold or italic
|
|
15
|
+
- Reference code using quotes: 'variable' or "function()"
|
|
16
|
+
- NO backticks (`) in your message text
|
|
17
|
+
- Keep explanations clear and concise
|
|
18
|
+
|
|
19
|
+
**START YOUR ANALYSIS NOW. DO NOT ASK QUESTIONS. DO NOT WAIT FOR MORE INPUT.**
|
|
20
|
+
|
|
21
|
+
## JSON Structure for Inline Comments
|
|
22
|
+
|
|
23
|
+
The JSON array must contain inline comment objects with these fields:
|
|
24
|
+
|
|
25
|
+
### Required Fields
|
|
26
|
+
- "file": **Complete file path** as shown in the diff (e.g., "app/controllers/users_controller.rb", not just "users_controller.rb")
|
|
27
|
+
- "message": Your comment text (MUST start with "🤖 ")
|
|
28
|
+
|
|
29
|
+
### Line Specification (MUST use one approach)
|
|
30
|
+
- "line": For single-line comments (integer line number - REQUIRED for single line comments)
|
|
31
|
+
- "range": For multi-line comments (object with):
|
|
32
|
+
- "start_line": First line of the issue (integer)
|
|
33
|
+
- "end_line": Last line of the issue (integer)
|
|
34
|
+
- "start_character": Optional column start (integer)
|
|
35
|
+
- "end_character": Optional column end (integer)
|
|
36
|
+
|
|
37
|
+
**CRITICAL LINE NUMBER RULES:**
|
|
38
|
+
1. **ALWAYS use final file line numbers, NEVER diff line numbers**
|
|
39
|
+
2. Line numbers must match the NEW version of the file after all changes
|
|
40
|
+
3. Use `git show HEAD:path/to/file` or examine the final file to get correct line numbers
|
|
41
|
+
4. If you see "+50" in a diff, the actual line number is NOT 50 - check the final file
|
|
42
|
+
5. Every comment MUST have either "line" OR "range". Comments without valid line numbers will be rejected.
|
|
43
|
+
|
|
44
|
+
### Optional Fields
|
|
45
|
+
- "side": "REVISION" (new code, default) or "PARENT" (original code)
|
|
46
|
+
|
|
47
|
+
**VERIFICATION STEP**: Before adding any comment, verify the line number by checking the final file content to ensure your line number points to the exact code you're commenting on.
|
|
48
|
+
|
|
49
|
+
## Comment Quality Guidelines
|
|
50
|
+
|
|
51
|
+
1. **Be Specific**: Reference exact variables, functions, or patterns
|
|
52
|
+
2. **Explain Impact**: What could go wrong and why it matters
|
|
53
|
+
3. **Suggest Fixes**: Provide actionable corrections when possible
|
|
54
|
+
4. **Group Logically**: Use range for related lines, separate comments for distinct issues
|
|
55
|
+
5. **Prioritize**: Comment on significant issues, not style preferences
|
|
56
|
+
|
|
57
|
+
## Example Output Formats
|
|
58
|
+
|
|
59
|
+
### Example 1: Mixed Single and Multi-line Comments
|
|
60
|
+
<response>
|
|
61
|
+
[
|
|
62
|
+
{"file": "app/controllers/auth/validator.rb", "line": 45, "message": "🤖 Missing validation for email format - accepts invalid emails like 'user@'. Use a proper email regex or validation library."},
|
|
63
|
+
{"file": "app/controllers/auth/validator.rb", "line": 67, "message": "🤖 Password strength check allows common passwords. Consider checking against a common password list."},
|
|
64
|
+
{"file": "lib/database/connection.rb", "range": {"start_line": 23, "end_line": 35}, "message": "🤖 Database connection retry logic has exponential backoff but no maximum retry limit. This could retry indefinitely on persistent failures. Add a max retry count."},
|
|
65
|
+
{"file": "app/controllers/api/users_controller.rb", "line": 89, "message": "🤖 SQL injection vulnerability: Query uses string concatenation with userId. Use parameterized queries with ActiveRecord methods.", "side": "REVISION"}
|
|
66
|
+
]
|
|
67
|
+
</response>
|
|
68
|
+
|
|
69
|
+
### Example 2: Critical Security Issues
|
|
70
|
+
<response>
|
|
71
|
+
[
|
|
72
|
+
{"file": "app/middleware/authentication_middleware.rb", "line": 34, "message": "🤖 Authentication bypass: Debug header check allows skipping auth. This MUST be removed before production."},
|
|
73
|
+
{"file": "lib/utils/crypto_helper.rb", "range": {"start_line": 12, "end_line": 18}, "message": "🤖 Weak encryption: MD5 is cryptographically broken. Use bcrypt for password hashing."},
|
|
74
|
+
{"file": "app/controllers/api/files_controller.rb", "line": 156, "message": "🤖 Path traversal vulnerability: User input directly used in file path without sanitization. An attacker could access files outside intended directory using '../'."}
|
|
75
|
+
]
|
|
76
|
+
</response>
|
|
77
|
+
|
|
78
|
+
## Priority Guidelines for Inline Comments
|
|
79
|
+
|
|
80
|
+
### ALWAYS Comment On (Real Problems Only)
|
|
81
|
+
- **Bugs**: Logic errors, null pointer risks, incorrect algorithms
|
|
82
|
+
- **Security**: Injection vulnerabilities, auth bypasses, data leaks
|
|
83
|
+
- **Crashes**: Unhandled exceptions, resource exhaustion, infinite loops
|
|
84
|
+
- **Data loss**: Operations that corrupt or lose user data
|
|
85
|
+
|
|
86
|
+
### SOMETIMES Comment On (If Significant)
|
|
87
|
+
- **Performance**: N+1 queries, memory leaks, algorithmic complexity issues
|
|
88
|
+
- **Error handling**: Missing try/catch for operations that commonly fail
|
|
89
|
+
- **Type safety**: Dangerous casts, missing validation for external input
|
|
90
|
+
|
|
91
|
+
### NEVER Comment On (Time Wasters)
|
|
92
|
+
- **Style/formatting**: Let automated tools handle this
|
|
93
|
+
- **Working code**: If it functions correctly, leave it alone
|
|
94
|
+
- **Personal preferences**: "I would have done this differently"
|
|
95
|
+
- **Nitpicks**: Variable names, spacing, minor wording
|
|
96
|
+
- **Compliments**: Don't waste time praising obvious competence
|
|
97
|
+
|
|
98
|
+
## GIT REPOSITORY ACCESS
|
|
99
|
+
|
|
100
|
+
You are running in a git repository with full access to:
|
|
101
|
+
- git diff, git show, git log for understanding changes and context
|
|
102
|
+
- git blame for code ownership and history
|
|
103
|
+
- All project files for architectural understanding
|
|
104
|
+
- Use these commands to provide comprehensive, accurate reviews
|
|
105
|
+
|
|
106
|
+
## FINAL TASK INSTRUCTION
|
|
107
|
+
|
|
108
|
+
**ANALYZE THE CODE CHANGES NOW AND OUTPUT YOUR INLINE COMMENTS IMMEDIATELY.**
|
|
109
|
+
|
|
110
|
+
Your output format must be:
|
|
111
|
+
```
|
|
112
|
+
<response>
|
|
113
|
+
[]
|
|
114
|
+
</response>
|
|
115
|
+
```
|
|
116
|
+
(Empty array for clean code - this is GOOD!)
|
|
117
|
+
|
|
118
|
+
OR:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
<response>
|
|
122
|
+
[{"file": "auth.js", "line": 42, "message": "🤖 SQL injection vulnerability: query uses string concatenation"}]
|
|
123
|
+
</response>
|
|
124
|
+
```
|
|
125
|
+
(Only comment on real problems)
|
|
126
|
+
|
|
127
|
+
**CRITICAL REQUIREMENTS**:
|
|
128
|
+
- Every message must start with "🤖 "
|
|
129
|
+
- Never use backticks in your response
|
|
130
|
+
- Empty arrays are encouraged for clean code
|
|
131
|
+
- Focus on bugs, security, crashes - ignore style preferences
|
|
132
|
+
- Use git commands to understand context before commenting
|
|
133
|
+
- NO TEXT OUTSIDE THE <response></response> TAGS
|
|
134
|
+
|
|
135
|
+
**DO YOUR ANALYSIS NOW. STOP ASKING QUESTIONS. GENERATE THE REVIEW.**
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
## Review Structure and Formatting
|
|
2
|
+
|
|
3
|
+
### Section Headers (Use Only What's Relevant)
|
|
4
|
+
|
|
5
|
+
Use CAPS for section headers. Include ONLY sections where you have substantive content:
|
|
6
|
+
|
|
7
|
+
- OVERALL ASSESSMENT - High-level verdict and summary
|
|
8
|
+
- CRITICAL ISSUES - Must be fixed before merge
|
|
9
|
+
- SIGNIFICANT CONCERNS - Should be addressed
|
|
10
|
+
- CODE QUALITY - Improvements for maintainability
|
|
11
|
+
- SECURITY ASSESSMENT - Security-specific findings
|
|
12
|
+
- PERFORMANCE ANALYSIS - Performance implications
|
|
13
|
+
- TEST COVERAGE - Testing observations
|
|
14
|
+
- ARCHITECTURE NOTES - Design and pattern feedback
|
|
15
|
+
- RECOMMENDATIONS - Actionable suggestions
|
|
16
|
+
|
|
17
|
+
### Gerrit Formatting Requirements
|
|
18
|
+
|
|
19
|
+
Gerrit uses a LIMITED markdown subset. Follow these rules EXACTLY:
|
|
20
|
+
|
|
21
|
+
- NO markdown bold (**text**) or italic (*text*) - use CAPS for emphasis
|
|
22
|
+
- NO headers with # or ## - use CAPS section titles
|
|
23
|
+
- NO backticks (`) for code - use quotes 'code' or "code" for inline
|
|
24
|
+
- Code blocks: Start EACH line with exactly 4 spaces, add blank lines before and after
|
|
25
|
+
- Bullet points: Use * or - at line start
|
|
26
|
+
- Block quotes: Start line with >
|
|
27
|
+
- Reference files as path/to/file.ext:123 (with line numbers)
|
|
28
|
+
- Always add blank lines between sections for readability
|
|
29
|
+
- Keep code blocks simple and well-spaced
|
|
30
|
+
|
|
31
|
+
**CRITICAL GERRIT FORMATTING RULES:**
|
|
32
|
+
|
|
33
|
+
1. NEVER start regular text lines with spaces - this creates unintended code blocks!
|
|
34
|
+
2. Only use 4 leading spaces when showing actual code examples
|
|
35
|
+
3. Regular text should start at column 1 (no indentation)
|
|
36
|
+
4. When explaining something after a bullet point, don't indent - start a new line
|
|
37
|
+
5. Use blank lines to separate sections and improve readability
|
|
38
|
+
|
|
39
|
+
WRONG (creates code blocks):
|
|
40
|
+
* Issue with authentication
|
|
41
|
+
This explanation will become a code block due to leading spaces
|
|
42
|
+
|
|
43
|
+
CORRECT:
|
|
44
|
+
* Issue with authentication
|
|
45
|
+
This explanation stays as regular text
|
|
46
|
+
|
|
47
|
+
### Content Guidelines
|
|
48
|
+
|
|
49
|
+
1. Start with the most important findings
|
|
50
|
+
2. Group related issues together
|
|
51
|
+
3. Be specific with file paths and line numbers
|
|
52
|
+
4. Explain the "why" behind each issue
|
|
53
|
+
5. Provide actionable fixes or alternatives
|
|
54
|
+
6. Use concrete examples when helpful
|
|
55
|
+
|
|
56
|
+
## CRITICAL OUTPUT REQUIREMENT
|
|
57
|
+
|
|
58
|
+
**YOUR ENTIRE OUTPUT MUST BE WRAPPED IN <response></response> TAGS.**
|
|
59
|
+
|
|
60
|
+
**IMMEDIATE TASK**: Analyze the code changes provided below and write a comprehensive engineering review.
|
|
61
|
+
|
|
62
|
+
Start with "🤖 [Your Tool Name] ([Your Model])" then provide a **CONCISE** engineering assessment. Examples:
|
|
63
|
+
- If you are Claude Sonnet 4: "🤖 Claude (Sonnet 4)"
|
|
64
|
+
- If you are Gemini: "🤖 Gemini (1.5 Pro)" or "🤖 Gemini (1.5 Flash)"
|
|
65
|
+
- For clean code: "No significant issues found. Change is ready for merge."
|
|
66
|
+
- For problematic code: Focus only on critical/important issues, skip minor concerns
|
|
67
|
+
|
|
68
|
+
**YOU MUST ANALYZE THE PROVIDED CODE CHANGES AND WRITE A REVIEW NOW.**
|
|
69
|
+
|
|
70
|
+
## Example Output Format
|
|
71
|
+
|
|
72
|
+
<response>
|
|
73
|
+
🤖 Claude (Sonnet 4)
|
|
74
|
+
|
|
75
|
+
OVERALL ASSESSMENT
|
|
76
|
+
|
|
77
|
+
This change successfully implements the new authentication flow with proper error handling and test coverage. However, there are critical security concerns and performance issues that need addressing before merge.
|
|
78
|
+
|
|
79
|
+
CRITICAL ISSUES
|
|
80
|
+
|
|
81
|
+
1. SQL Injection Vulnerability - src/api/users.ts:45
|
|
82
|
+
|
|
83
|
+
The query construction uses string concatenation with user input:
|
|
84
|
+
|
|
85
|
+
const query = "SELECT * FROM users WHERE id = " + userId
|
|
86
|
+
|
|
87
|
+
This allows SQL injection attacks. Use parameterized queries:
|
|
88
|
+
|
|
89
|
+
const query = "SELECT * FROM users WHERE id = $1"
|
|
90
|
+
const result = await db.query(query, [userId])
|
|
91
|
+
|
|
92
|
+
2. Authentication Bypass - src/middleware/auth.ts:78-82
|
|
93
|
+
|
|
94
|
+
The token validation can be bypassed when 'debug' header is present:
|
|
95
|
+
|
|
96
|
+
if (req.headers.debug) return next()
|
|
97
|
+
|
|
98
|
+
This MUST be removed from production code.
|
|
99
|
+
|
|
100
|
+
SIGNIFICANT CONCERNS
|
|
101
|
+
|
|
102
|
+
Resource Leak - src/services/cache.ts:156
|
|
103
|
+
|
|
104
|
+
The Redis connection is created but never closed on error:
|
|
105
|
+
|
|
106
|
+
* Connection opens on line 145
|
|
107
|
+
* Error path at line 156 doesn't call client.disconnect()
|
|
108
|
+
* This will exhaust connection pool over time
|
|
109
|
+
|
|
110
|
+
Add proper cleanup in a finally block:
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
await client.connect()
|
|
114
|
+
// ... operations
|
|
115
|
+
} finally {
|
|
116
|
+
await client.disconnect()
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
PERFORMANCE ANALYSIS
|
|
120
|
+
|
|
121
|
+
- N+1 Query Pattern in src/api/posts.ts:234-248
|
|
122
|
+
Loading comments for each post individually causes N+1 queries.
|
|
123
|
+
Consider using a single query with JOIN or batch loading.
|
|
124
|
+
|
|
125
|
+
- Unbounded Memory Usage in src/utils/processor.ts:89
|
|
126
|
+
Loading entire dataset into memory without pagination.
|
|
127
|
+
For large datasets, this will cause OOM errors.
|
|
128
|
+
|
|
129
|
+
TEST COVERAGE
|
|
130
|
+
|
|
131
|
+
- Missing error path tests for the new authentication flow
|
|
132
|
+
- No integration tests for the rate limiting middleware
|
|
133
|
+
- Edge cases around token expiry not covered
|
|
134
|
+
|
|
135
|
+
RECOMMENDATIONS
|
|
136
|
+
|
|
137
|
+
1. Add rate limiting to authentication endpoints
|
|
138
|
+
2. Implement request validation using a schema library
|
|
139
|
+
3. Add monitoring for the new cache layer
|
|
140
|
+
4. Consider adding database transaction support for multi-step operations
|
|
141
|
+
|
|
142
|
+
The security issues are blocking and must be fixed. The performance concerns should be addressed before this scales to production load.
|
|
143
|
+
</response>
|
|
144
|
+
|
|
145
|
+
## Review Tone and Approach
|
|
146
|
+
|
|
147
|
+
1. **Be Direct but Constructive**
|
|
148
|
+
- State issues clearly without hedging
|
|
149
|
+
- Explain impact and provide solutions
|
|
150
|
+
- Focus on the code, not the coder
|
|
151
|
+
|
|
152
|
+
2. **Prioritize Effectively**
|
|
153
|
+
- Lead with blocking issues
|
|
154
|
+
- Group related problems
|
|
155
|
+
- Don't bury critical findings
|
|
156
|
+
|
|
157
|
+
3. **Provide Value**
|
|
158
|
+
- Every comment should help improve the code
|
|
159
|
+
- Skip trivial issues unless they indicate patterns
|
|
160
|
+
- Include concrete fix suggestions
|
|
161
|
+
|
|
162
|
+
## GIT REPOSITORY ACCESS
|
|
163
|
+
|
|
164
|
+
You are running in a git repository with full access to:
|
|
165
|
+
- git diff, git show, git log for understanding changes and context
|
|
166
|
+
- git blame for code ownership and history
|
|
167
|
+
- All project files for architectural understanding
|
|
168
|
+
- Use these commands to explore the codebase and provide comprehensive reviews
|
|
169
|
+
|
|
170
|
+
## FINAL REMINDER
|
|
171
|
+
|
|
172
|
+
**CRITICAL: Your ENTIRE output must be wrapped in <response></response> tags.**
|
|
173
|
+
|
|
174
|
+
Example format:
|
|
175
|
+
```
|
|
176
|
+
<response>
|
|
177
|
+
🤖 Claude (Sonnet 4)
|
|
178
|
+
|
|
179
|
+
OVERALL ASSESSMENT
|
|
180
|
+
|
|
181
|
+
Your review content here...
|
|
182
|
+
</response>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
MANDATORY REQUIREMENTS:
|
|
186
|
+
- Start with "🤖 [Your Tool Name] ([Your Model])"
|
|
187
|
+
- Be CONCISE - engineers value brevity over verbosity
|
|
188
|
+
- For clean code, simply state "No significant issues found"
|
|
189
|
+
- Focus on material problems, skip style preferences and compliments
|
|
190
|
+
- Use Gerrit's limited markdown format - NO backticks, NO markdown bold/italic
|
|
191
|
+
- Use git commands to understand context before writing review
|
|
192
|
+
- NO TEXT OUTSIDE THE <response></response> TAGS
|
|
193
|
+
|
|
194
|
+
CRITICAL FORMATTING RULES:
|
|
195
|
+
- Add blank lines between sections and before/after code blocks
|
|
196
|
+
- Use exactly 4 spaces to start each line of code blocks
|
|
197
|
+
- Keep code blocks simple and readable
|
|
198
|
+
- Add proper spacing for readability
|
|
199
|
+
- NEVER indent regular text - start all non-code text at column 1
|
|
200
|
+
- Only code examples should have leading spaces (exactly 4)
|
|
201
|
+
|
|
202
|
+
## TASK SUMMARY
|
|
203
|
+
|
|
204
|
+
**ANALYZE THE CODE CHANGES PROVIDED ABOVE AND WRITE YOUR ENGINEERING REVIEW IMMEDIATELY.**
|
|
205
|
+
|
|
206
|
+
Do not ask for clarification. Do not wait for more input. Analyze the provided code changes, git history, and changed files, then write your review following the format requirements above.
|