@diff-review-system/drs 4.0.0-rc.4 → 4.0.1
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/.pi/agents/describe/pr-describer.md +14 -0
- package/.pi/agents/review/unified-reviewer.md +31 -1
- package/.pi/agents/task/agents-md-updater.md +3 -1
- package/.pi/agents/task/review-issue-fixer.md +18 -1
- package/.pi/agents/visual/pr-explainer.md +205 -0
- package/.pi/workflows/github-pr-describe.yaml +10 -7
- package/.pi/workflows/github-pr-fix-review-issues-stacked.yaml +148 -0
- package/.pi/workflows/github-pr-post-comment.yaml +10 -10
- package/.pi/workflows/github-pr-review-post.yaml +19 -8
- package/.pi/workflows/github-pr-review.yaml +348 -7
- package/.pi/workflows/github-pr-show-changes.yaml +8 -8
- package/.pi/workflows/github-pr-update-agents-md-stacked.yaml +103 -0
- package/.pi/workflows/github-pr-visual-explain.yaml +35 -0
- package/.pi/workflows/gitlab-mr-describe.yaml +8 -5
- package/.pi/workflows/gitlab-mr-fix-review-issues-stacked.yaml +144 -0
- package/.pi/workflows/gitlab-mr-post-comment.yaml +8 -8
- package/.pi/workflows/gitlab-mr-review.yaml +348 -5
- package/.pi/workflows/gitlab-mr-show-changes.yaml +6 -6
- package/.pi/workflows/gitlab-mr-update-agents-md-stacked.yaml +100 -0
- package/.pi/workflows/gitlab-mr-visual-explain.yaml +33 -0
- package/.pi/workflows/local-fix-review-issues.yaml +82 -13
- package/.pi/workflows/local-review.yaml +9 -2
- package/.pi/workflows/local-update-agents-md.yaml +1 -1
- package/.pi/workflows/local-visual-explain.yaml +31 -0
- package/.pi/workflows/release-changelog-finalize.yaml +47 -0
- package/.pi/workflows/tag-changelog-update.yaml +4 -4
- package/README.md +91 -27
- package/dist/ci/runner.d.ts.map +1 -1
- package/dist/ci/runner.js +3 -1
- package/dist/ci/runner.js.map +1 -1
- package/dist/cli/index.js +48 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/run-agent.d.ts +2 -0
- package/dist/cli/run-agent.d.ts.map +1 -1
- package/dist/cli/run-agent.js +4 -0
- package/dist/cli/run-agent.js.map +1 -1
- package/dist/cli/workflow.d.ts +56 -2
- package/dist/cli/workflow.d.ts.map +1 -1
- package/dist/cli/workflow.js +2165 -85
- package/dist/cli/workflow.js.map +1 -1
- package/dist/github/client.d.ts +12 -0
- package/dist/github/client.d.ts.map +1 -1
- package/dist/github/client.js +27 -0
- package/dist/github/client.js.map +1 -1
- package/dist/github/platform-adapter.d.ts +6 -1
- package/dist/github/platform-adapter.d.ts.map +1 -1
- package/dist/github/platform-adapter.js +84 -8
- package/dist/github/platform-adapter.js.map +1 -1
- package/dist/gitlab/client.d.ts +11 -0
- package/dist/gitlab/client.d.ts.map +1 -1
- package/dist/gitlab/client.js +11 -0
- package/dist/gitlab/client.js.map +1 -1
- package/dist/gitlab/platform-adapter.d.ts +3 -1
- package/dist/gitlab/platform-adapter.d.ts.map +1 -1
- package/dist/gitlab/platform-adapter.js +32 -1
- package/dist/gitlab/platform-adapter.js.map +1 -1
- package/dist/lib/comment-formatter.d.ts +8 -0
- package/dist/lib/comment-formatter.d.ts.map +1 -1
- package/dist/lib/comment-formatter.js +12 -4
- package/dist/lib/comment-formatter.js.map +1 -1
- package/dist/lib/comment-poster.d.ts.map +1 -1
- package/dist/lib/comment-poster.js +28 -1
- package/dist/lib/comment-poster.js.map +1 -1
- package/dist/lib/config.d.ts +50 -11
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +163 -28
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/context-compression.d.ts +10 -0
- package/dist/lib/context-compression.d.ts.map +1 -1
- package/dist/lib/context-compression.js +101 -13
- package/dist/lib/context-compression.js.map +1 -1
- package/dist/lib/context-loader.d.ts +2 -1
- package/dist/lib/context-loader.d.ts.map +1 -1
- package/dist/lib/context-loader.js +70 -1
- package/dist/lib/context-loader.js.map +1 -1
- package/dist/lib/describe-core.d.ts.map +1 -1
- package/dist/lib/describe-core.js +3 -2
- package/dist/lib/describe-core.js.map +1 -1
- package/dist/lib/diff-lines.d.ts +9 -0
- package/dist/lib/diff-lines.d.ts.map +1 -1
- package/dist/lib/diff-lines.js +17 -9
- package/dist/lib/diff-lines.js.map +1 -1
- package/dist/lib/exit.js +4 -4
- package/dist/lib/exit.js.map +1 -1
- package/dist/lib/html-artifact.d.ts +14 -0
- package/dist/lib/html-artifact.d.ts.map +1 -0
- package/dist/lib/html-artifact.js +59 -0
- package/dist/lib/html-artifact.js.map +1 -0
- package/dist/lib/issue-parser.js +3 -3
- package/dist/lib/issue-parser.js.map +1 -1
- package/dist/lib/json-output-schema.d.ts +70 -0
- package/dist/lib/json-output-schema.d.ts.map +1 -1
- package/dist/lib/json-output-schema.js +40 -0
- package/dist/lib/json-output-schema.js.map +1 -1
- package/dist/lib/platform-client.d.ts +26 -0
- package/dist/lib/platform-client.d.ts.map +1 -1
- package/dist/lib/review-artifact.d.ts +69 -0
- package/dist/lib/review-artifact.d.ts.map +1 -0
- package/dist/lib/review-artifact.js +171 -0
- package/dist/lib/review-artifact.js.map +1 -0
- package/dist/lib/review-core.d.ts +6 -4
- package/dist/lib/review-core.d.ts.map +1 -1
- package/dist/lib/review-core.js +71 -151
- package/dist/lib/review-core.js.map +1 -1
- package/dist/lib/review-orchestrator.d.ts +23 -0
- package/dist/lib/review-orchestrator.d.ts.map +1 -1
- package/dist/lib/review-orchestrator.js +20 -13
- package/dist/lib/review-orchestrator.js.map +1 -1
- package/dist/lib/review-usage.d.ts +4 -0
- package/dist/lib/review-usage.d.ts.map +1 -1
- package/dist/lib/review-usage.js +25 -0
- package/dist/lib/review-usage.js.map +1 -1
- package/dist/lib/trace-collector.d.ts +105 -0
- package/dist/lib/trace-collector.d.ts.map +1 -0
- package/dist/lib/trace-collector.js +255 -0
- package/dist/lib/trace-collector.js.map +1 -0
- package/dist/lib/trace-html.d.ts +3 -0
- package/dist/lib/trace-html.d.ts.map +1 -0
- package/dist/lib/trace-html.js +349 -0
- package/dist/lib/trace-html.js.map +1 -0
- package/dist/lib/workflow-artifacts.d.ts +54 -0
- package/dist/lib/workflow-artifacts.d.ts.map +1 -0
- package/dist/lib/workflow-artifacts.js +150 -0
- package/dist/lib/workflow-artifacts.js.map +1 -0
- package/dist/pi/sdk.d.ts.map +1 -1
- package/dist/pi/sdk.js +570 -6
- package/dist/pi/sdk.js.map +1 -1
- package/dist/runtime/agent-loader.js +2 -2
- package/dist/runtime/client.d.ts +2 -0
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +11 -5
- package/dist/runtime/client.js.map +1 -1
- package/package.json +21 -15
- package/.pi/workflows/github-pr-describe-post.yaml +0 -24
- package/.pi/workflows/gitlab-mr-describe-post.yaml +0 -22
- package/.pi/workflows/gitlab-mr-review-code-quality.yaml +0 -31
- package/.pi/workflows/gitlab-mr-review-post-code-quality.yaml +0 -40
- package/.pi/workflows/gitlab-mr-review-post.yaml +0 -30
- package/.pi/workflows/local-staged-review.yaml +0 -17
- package/dist/cli/run-agent.test.d.ts +0 -2
- package/dist/cli/run-agent.test.d.ts.map +0 -1
- package/dist/cli/run-agent.test.js +0 -204
- package/dist/cli/run-agent.test.js.map +0 -1
- package/dist/cli/workflow.test.d.ts +0 -2
- package/dist/cli/workflow.test.d.ts.map +0 -1
- package/dist/cli/workflow.test.js +0 -1410
- package/dist/cli/workflow.test.js.map +0 -1
- package/dist/github/client.test.d.ts +0 -2
- package/dist/github/client.test.d.ts.map +0 -1
- package/dist/github/client.test.js +0 -206
- package/dist/github/client.test.js.map +0 -1
- package/dist/github/platform-adapter.test.d.ts +0 -2
- package/dist/github/platform-adapter.test.d.ts.map +0 -1
- package/dist/github/platform-adapter.test.js +0 -40
- package/dist/github/platform-adapter.test.js.map +0 -1
- package/dist/gitlab/diff-parser.test.d.ts +0 -2
- package/dist/gitlab/diff-parser.test.d.ts.map +0 -1
- package/dist/gitlab/diff-parser.test.js +0 -315
- package/dist/gitlab/diff-parser.test.js.map +0 -1
- package/dist/gitlab/platform-adapter.test.d.ts +0 -2
- package/dist/gitlab/platform-adapter.test.d.ts.map +0 -1
- package/dist/gitlab/platform-adapter.test.js +0 -21
- package/dist/gitlab/platform-adapter.test.js.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/index.test.js +0 -7
- package/dist/index.test.js.map +0 -1
- package/dist/lib/code-quality-report.test.d.ts +0 -2
- package/dist/lib/code-quality-report.test.d.ts.map +0 -1
- package/dist/lib/code-quality-report.test.js +0 -327
- package/dist/lib/code-quality-report.test.js.map +0 -1
- package/dist/lib/comment-formatter.test.d.ts +0 -2
- package/dist/lib/comment-formatter.test.d.ts.map +0 -1
- package/dist/lib/comment-formatter.test.js +0 -727
- package/dist/lib/comment-formatter.test.js.map +0 -1
- package/dist/lib/comment-manager.test.d.ts +0 -2
- package/dist/lib/comment-manager.test.d.ts.map +0 -1
- package/dist/lib/comment-manager.test.js +0 -680
- package/dist/lib/comment-manager.test.js.map +0 -1
- package/dist/lib/comment-poster.test.d.ts +0 -5
- package/dist/lib/comment-poster.test.d.ts.map +0 -1
- package/dist/lib/comment-poster.test.js +0 -255
- package/dist/lib/comment-poster.test.js.map +0 -1
- package/dist/lib/config-model-overrides.test.d.ts +0 -2
- package/dist/lib/config-model-overrides.test.d.ts.map +0 -1
- package/dist/lib/config-model-overrides.test.js +0 -218
- package/dist/lib/config-model-overrides.test.js.map +0 -1
- package/dist/lib/config.test.d.ts +0 -2
- package/dist/lib/config.test.d.ts.map +0 -1
- package/dist/lib/config.test.js +0 -353
- package/dist/lib/config.test.js.map +0 -1
- package/dist/lib/context-compression.test.d.ts +0 -2
- package/dist/lib/context-compression.test.d.ts.map +0 -1
- package/dist/lib/context-compression.test.js +0 -337
- package/dist/lib/context-compression.test.js.map +0 -1
- package/dist/lib/context-loader.test.d.ts +0 -2
- package/dist/lib/context-loader.test.d.ts.map +0 -1
- package/dist/lib/context-loader.test.js +0 -212
- package/dist/lib/context-loader.test.js.map +0 -1
- package/dist/lib/cursor-fix-link.test.d.ts +0 -2
- package/dist/lib/cursor-fix-link.test.d.ts.map +0 -1
- package/dist/lib/cursor-fix-link.test.js +0 -70
- package/dist/lib/cursor-fix-link.test.js.map +0 -1
- package/dist/lib/describe-core.test.d.ts +0 -2
- package/dist/lib/describe-core.test.d.ts.map +0 -1
- package/dist/lib/describe-core.test.js +0 -208
- package/dist/lib/describe-core.test.js.map +0 -1
- package/dist/lib/describe-output-path.test.d.ts +0 -2
- package/dist/lib/describe-output-path.test.d.ts.map +0 -1
- package/dist/lib/describe-output-path.test.js +0 -51
- package/dist/lib/describe-output-path.test.js.map +0 -1
- package/dist/lib/describe-parser.test.d.ts +0 -2
- package/dist/lib/describe-parser.test.d.ts.map +0 -1
- package/dist/lib/describe-parser.test.js +0 -282
- package/dist/lib/describe-parser.test.js.map +0 -1
- package/dist/lib/description-executor.test.d.ts +0 -2
- package/dist/lib/description-executor.test.d.ts.map +0 -1
- package/dist/lib/description-executor.test.js +0 -135
- package/dist/lib/description-executor.test.js.map +0 -1
- package/dist/lib/description-formatter.test.d.ts +0 -2
- package/dist/lib/description-formatter.test.d.ts.map +0 -1
- package/dist/lib/description-formatter.test.js +0 -57
- package/dist/lib/description-formatter.test.js.map +0 -1
- package/dist/lib/diff-lines.test.d.ts +0 -2
- package/dist/lib/diff-lines.test.d.ts.map +0 -1
- package/dist/lib/diff-lines.test.js +0 -13
- package/dist/lib/diff-lines.test.js.map +0 -1
- package/dist/lib/diff-parser.test.d.ts +0 -2
- package/dist/lib/diff-parser.test.d.ts.map +0 -1
- package/dist/lib/diff-parser.test.js +0 -335
- package/dist/lib/diff-parser.test.js.map +0 -1
- package/dist/lib/error-comment-poster.test.d.ts +0 -2
- package/dist/lib/error-comment-poster.test.d.ts.map +0 -1
- package/dist/lib/error-comment-poster.test.js +0 -128
- package/dist/lib/error-comment-poster.test.js.map +0 -1
- package/dist/lib/exit.test.d.ts +0 -2
- package/dist/lib/exit.test.d.ts.map +0 -1
- package/dist/lib/exit.test.js +0 -120
- package/dist/lib/exit.test.js.map +0 -1
- package/dist/lib/issue-parser.test.d.ts +0 -2
- package/dist/lib/issue-parser.test.d.ts.map +0 -1
- package/dist/lib/issue-parser.test.js +0 -281
- package/dist/lib/issue-parser.test.js.map +0 -1
- package/dist/lib/json-output-schema.test.d.ts +0 -2
- package/dist/lib/json-output-schema.test.d.ts.map +0 -1
- package/dist/lib/json-output-schema.test.js +0 -92
- package/dist/lib/json-output-schema.test.js.map +0 -1
- package/dist/lib/json-output.test.d.ts +0 -2
- package/dist/lib/json-output.test.d.ts.map +0 -1
- package/dist/lib/json-output.test.js +0 -141
- package/dist/lib/json-output.test.js.map +0 -1
- package/dist/lib/logger.test.d.ts +0 -2
- package/dist/lib/logger.test.d.ts.map +0 -1
- package/dist/lib/logger.test.js +0 -324
- package/dist/lib/logger.test.js.map +0 -1
- package/dist/lib/position-validator.test.d.ts +0 -2
- package/dist/lib/position-validator.test.d.ts.map +0 -1
- package/dist/lib/position-validator.test.js +0 -128
- package/dist/lib/position-validator.test.js.map +0 -1
- package/dist/lib/prompt-budget.test.d.ts +0 -2
- package/dist/lib/prompt-budget.test.d.ts.map +0 -1
- package/dist/lib/prompt-budget.test.js +0 -55
- package/dist/lib/prompt-budget.test.js.map +0 -1
- package/dist/lib/repository-validator.test.d.ts +0 -5
- package/dist/lib/repository-validator.test.d.ts.map +0 -1
- package/dist/lib/repository-validator.test.js +0 -341
- package/dist/lib/repository-validator.test.js.map +0 -1
- package/dist/lib/review-core.test.d.ts +0 -2
- package/dist/lib/review-core.test.d.ts.map +0 -1
- package/dist/lib/review-core.test.js +0 -614
- package/dist/lib/review-core.test.js.map +0 -1
- package/dist/lib/review-orchestrator.test.d.ts +0 -2
- package/dist/lib/review-orchestrator.test.d.ts.map +0 -1
- package/dist/lib/review-orchestrator.test.js +0 -552
- package/dist/lib/review-orchestrator.test.js.map +0 -1
- package/dist/lib/review-output-path.test.d.ts +0 -2
- package/dist/lib/review-output-path.test.d.ts.map +0 -1
- package/dist/lib/review-output-path.test.js +0 -83
- package/dist/lib/review-output-path.test.js.map +0 -1
- package/dist/lib/review-parser.test.d.ts +0 -2
- package/dist/lib/review-parser.test.d.ts.map +0 -1
- package/dist/lib/review-parser.test.js +0 -130
- package/dist/lib/review-parser.test.js.map +0 -1
- package/dist/lib/review-usage.test.d.ts +0 -2
- package/dist/lib/review-usage.test.d.ts.map +0 -1
- package/dist/lib/review-usage.test.js +0 -83
- package/dist/lib/review-usage.test.js.map +0 -1
- package/dist/lib/unified-review-executor.d.ts +0 -58
- package/dist/lib/unified-review-executor.d.ts.map +0 -1
- package/dist/lib/unified-review-executor.js +0 -201
- package/dist/lib/unified-review-executor.js.map +0 -1
- package/dist/lib/unified-review-executor.test.d.ts +0 -5
- package/dist/lib/unified-review-executor.test.d.ts.map +0 -1
- package/dist/lib/unified-review-executor.test.js +0 -472
- package/dist/lib/unified-review-executor.test.js.map +0 -1
- package/dist/lib/write-json-output.test.d.ts +0 -2
- package/dist/lib/write-json-output.test.d.ts.map +0 -1
- package/dist/lib/write-json-output.test.js +0 -259
- package/dist/lib/write-json-output.test.js.map +0 -1
- package/dist/pi/sdk.test.d.ts +0 -2
- package/dist/pi/sdk.test.d.ts.map +0 -1
- package/dist/pi/sdk.test.js +0 -488
- package/dist/pi/sdk.test.js.map +0 -1
- package/dist/runtime/agent-loader.test.d.ts +0 -2
- package/dist/runtime/agent-loader.test.d.ts.map +0 -1
- package/dist/runtime/agent-loader.test.js +0 -277
- package/dist/runtime/agent-loader.test.js.map +0 -1
- package/dist/runtime/client.test.d.ts +0 -2
- package/dist/runtime/client.test.d.ts.map +0 -1
- package/dist/runtime/client.test.js +0 -772
- package/dist/runtime/client.test.js.map +0 -1
- package/dist/runtime/path-config.test.d.ts +0 -2
- package/dist/runtime/path-config.test.d.ts.map +0 -1
- package/dist/runtime/path-config.test.js +0 -112
- package/dist/runtime/path-config.test.js.map +0 -1
|
@@ -1,727 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { formatIssueComment, formatSummaryComment, formatTerminalIssue, formatErrorComment, calculateSummary, } from './comment-formatter.js';
|
|
3
|
-
describe('comment-formatter', () => {
|
|
4
|
-
describe('formatIssueComment', () => {
|
|
5
|
-
it('should format issue with line number', () => {
|
|
6
|
-
const issue = {
|
|
7
|
-
category: 'SECURITY',
|
|
8
|
-
severity: 'CRITICAL',
|
|
9
|
-
title: 'SQL Injection',
|
|
10
|
-
file: 'src/db.ts',
|
|
11
|
-
line: 42,
|
|
12
|
-
problem: 'Unsafe query construction',
|
|
13
|
-
solution: 'Use parameterized queries',
|
|
14
|
-
agent: 'security',
|
|
15
|
-
};
|
|
16
|
-
const formatted = formatIssueComment(issue);
|
|
17
|
-
expect(formatted).toContain('🔒 SECURITY - SQL Injection');
|
|
18
|
-
expect(formatted).toContain('src/db.ts:42');
|
|
19
|
-
expect(formatted).toContain('🔴 CRITICAL');
|
|
20
|
-
expect(formatted).toContain('security');
|
|
21
|
-
expect(formatted).toContain('Unsafe query construction');
|
|
22
|
-
expect(formatted).toContain('Use parameterized queries');
|
|
23
|
-
});
|
|
24
|
-
it('should format issue without line number', () => {
|
|
25
|
-
const issue = {
|
|
26
|
-
category: 'QUALITY',
|
|
27
|
-
severity: 'MEDIUM',
|
|
28
|
-
title: 'Code complexity',
|
|
29
|
-
file: 'src/app.ts',
|
|
30
|
-
problem: 'Function is too complex',
|
|
31
|
-
solution: 'Refactor into smaller functions',
|
|
32
|
-
agent: 'quality',
|
|
33
|
-
};
|
|
34
|
-
const formatted = formatIssueComment(issue);
|
|
35
|
-
expect(formatted).toContain('📊 QUALITY - Code complexity');
|
|
36
|
-
expect(formatted).toContain('src/app.ts`');
|
|
37
|
-
expect(formatted).not.toContain('src/app.ts:'); // Should not have line number
|
|
38
|
-
expect(formatted).toContain('🟠 MEDIUM');
|
|
39
|
-
});
|
|
40
|
-
it('should format issue with references', () => {
|
|
41
|
-
const issue = {
|
|
42
|
-
category: 'SECURITY',
|
|
43
|
-
severity: 'HIGH',
|
|
44
|
-
title: 'XSS Vulnerability',
|
|
45
|
-
file: 'src/render.ts',
|
|
46
|
-
line: 10,
|
|
47
|
-
problem: 'Unescaped user input',
|
|
48
|
-
solution: 'Sanitize input before rendering',
|
|
49
|
-
references: ['https://owasp.org/www-community/attacks/xss/', 'CWE-79'],
|
|
50
|
-
agent: 'security',
|
|
51
|
-
};
|
|
52
|
-
const formatted = formatIssueComment(issue);
|
|
53
|
-
expect(formatted).toContain('### References');
|
|
54
|
-
expect(formatted).toContain('https://owasp.org/www-community/attacks/xss/');
|
|
55
|
-
expect(formatted).toContain('CWE-79');
|
|
56
|
-
});
|
|
57
|
-
it('should include fingerprint when provided', () => {
|
|
58
|
-
const issue = {
|
|
59
|
-
category: 'STYLE',
|
|
60
|
-
severity: 'LOW',
|
|
61
|
-
title: 'Missing semicolon',
|
|
62
|
-
file: 'src/utils.ts',
|
|
63
|
-
line: 5,
|
|
64
|
-
problem: 'Inconsistent style',
|
|
65
|
-
solution: 'Add semicolon',
|
|
66
|
-
agent: 'style',
|
|
67
|
-
};
|
|
68
|
-
const fingerprint = 'src/utils.ts:5:STYLE:Missing semicolon';
|
|
69
|
-
const formatted = formatIssueComment(issue, fingerprint);
|
|
70
|
-
expect(formatted).toContain(`<!-- issue-fp: ${fingerprint} -->`);
|
|
71
|
-
});
|
|
72
|
-
it('should include a Fix in Cursor link when enabled', () => {
|
|
73
|
-
const issue = {
|
|
74
|
-
category: 'QUALITY',
|
|
75
|
-
severity: 'HIGH',
|
|
76
|
-
title: 'Bug fix needed',
|
|
77
|
-
file: 'src/app.ts',
|
|
78
|
-
line: 7,
|
|
79
|
-
problem: 'Code is wrong',
|
|
80
|
-
solution: 'Fix the code',
|
|
81
|
-
agent: 'quality',
|
|
82
|
-
};
|
|
83
|
-
const formatted = formatIssueComment(issue, undefined, {
|
|
84
|
-
enabled: true,
|
|
85
|
-
workspace: 'drs',
|
|
86
|
-
});
|
|
87
|
-
expect(formatted).toContain('[Fix in Cursor](https://cursor.com/link/prompt?');
|
|
88
|
-
expect(formatted).toContain('workspace=drs');
|
|
89
|
-
});
|
|
90
|
-
it('should not include fingerprint when not provided', () => {
|
|
91
|
-
const issue = {
|
|
92
|
-
category: 'STYLE',
|
|
93
|
-
severity: 'LOW',
|
|
94
|
-
title: 'Missing semicolon',
|
|
95
|
-
file: 'src/utils.ts',
|
|
96
|
-
line: 5,
|
|
97
|
-
problem: 'Inconsistent style',
|
|
98
|
-
solution: 'Add semicolon',
|
|
99
|
-
agent: 'style',
|
|
100
|
-
};
|
|
101
|
-
const formatted = formatIssueComment(issue);
|
|
102
|
-
expect(formatted).not.toContain('<!-- issue-fp:');
|
|
103
|
-
});
|
|
104
|
-
it('should format PERFORMANCE category correctly', () => {
|
|
105
|
-
const issue = {
|
|
106
|
-
category: 'PERFORMANCE',
|
|
107
|
-
severity: 'HIGH',
|
|
108
|
-
title: 'Inefficient loop',
|
|
109
|
-
file: 'src/process.ts',
|
|
110
|
-
line: 20,
|
|
111
|
-
problem: 'N^2 complexity',
|
|
112
|
-
solution: 'Use hash map for O(n) lookup',
|
|
113
|
-
agent: 'performance',
|
|
114
|
-
};
|
|
115
|
-
const formatted = formatIssueComment(issue);
|
|
116
|
-
expect(formatted).toContain('⚡ PERFORMANCE - Inefficient loop');
|
|
117
|
-
});
|
|
118
|
-
it('should format DOCUMENTATION category correctly', () => {
|
|
119
|
-
const issue = {
|
|
120
|
-
category: 'DOCUMENTATION',
|
|
121
|
-
severity: 'LOW',
|
|
122
|
-
title: 'Missing JSDoc',
|
|
123
|
-
file: 'src/api.ts',
|
|
124
|
-
line: 15,
|
|
125
|
-
problem: 'Function lacks documentation',
|
|
126
|
-
solution: 'Add JSDoc comment',
|
|
127
|
-
agent: 'documentation',
|
|
128
|
-
};
|
|
129
|
-
const formatted = formatIssueComment(issue);
|
|
130
|
-
expect(formatted).toContain('📝 DOCUMENTATION - Missing JSDoc');
|
|
131
|
-
expect(formatted).toContain('⚪ LOW');
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
describe('formatSummaryComment', () => {
|
|
135
|
-
it('should format summary with no issues', () => {
|
|
136
|
-
const summary = {
|
|
137
|
-
filesReviewed: 5,
|
|
138
|
-
issuesFound: 0,
|
|
139
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
140
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
141
|
-
};
|
|
142
|
-
const formatted = formatSummaryComment(summary, []);
|
|
143
|
-
expect(formatted).toContain('📋 Code Review Analysis');
|
|
144
|
-
expect(formatted).toContain('Files Reviewed**: 5');
|
|
145
|
-
expect(formatted).toContain('Total Issues**: 0');
|
|
146
|
-
expect(formatted).toContain('✅ **No issues found!**');
|
|
147
|
-
expect(formatted).toContain('DRS');
|
|
148
|
-
});
|
|
149
|
-
it('should format summary with issues', () => {
|
|
150
|
-
const issues = [
|
|
151
|
-
{
|
|
152
|
-
category: 'SECURITY',
|
|
153
|
-
severity: 'CRITICAL',
|
|
154
|
-
title: 'SQL Injection',
|
|
155
|
-
file: 'src/db.ts',
|
|
156
|
-
line: 42,
|
|
157
|
-
problem: 'Problem',
|
|
158
|
-
solution: 'Solution',
|
|
159
|
-
agent: 'security',
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
category: 'QUALITY',
|
|
163
|
-
severity: 'HIGH',
|
|
164
|
-
title: 'Code smell',
|
|
165
|
-
file: 'src/app.ts',
|
|
166
|
-
line: 10,
|
|
167
|
-
problem: 'Problem',
|
|
168
|
-
solution: 'Solution',
|
|
169
|
-
agent: 'quality',
|
|
170
|
-
},
|
|
171
|
-
];
|
|
172
|
-
const summary = {
|
|
173
|
-
filesReviewed: 2,
|
|
174
|
-
issuesFound: 2,
|
|
175
|
-
bySeverity: { CRITICAL: 1, HIGH: 1, MEDIUM: 0, LOW: 0 },
|
|
176
|
-
byCategory: { SECURITY: 1, QUALITY: 1, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
177
|
-
};
|
|
178
|
-
const formatted = formatSummaryComment(summary, issues);
|
|
179
|
-
expect(formatted).toContain('Files Reviewed**: 2');
|
|
180
|
-
expect(formatted).toContain('Total Issues**: 2');
|
|
181
|
-
expect(formatted).toContain('Critical**: 1');
|
|
182
|
-
expect(formatted).toContain('High**: 1');
|
|
183
|
-
expect(formatted).toContain('Security**: 1');
|
|
184
|
-
expect(formatted).toContain('Quality**: 1');
|
|
185
|
-
expect(formatted).toContain('🔴 Critical Issues');
|
|
186
|
-
expect(formatted).toContain('🟡 High Priority Issues');
|
|
187
|
-
expect(formatted).toContain('SQL Injection');
|
|
188
|
-
expect(formatted).toContain('Code smell');
|
|
189
|
-
});
|
|
190
|
-
it('should include comment ID when provided', () => {
|
|
191
|
-
const summary = {
|
|
192
|
-
filesReviewed: 1,
|
|
193
|
-
issuesFound: 0,
|
|
194
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
195
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
196
|
-
};
|
|
197
|
-
const commentId = 'drs-review-summary';
|
|
198
|
-
const formatted = formatSummaryComment(summary, [], commentId);
|
|
199
|
-
expect(formatted).toContain(`<!-- drs-comment-id: ${commentId} -->`);
|
|
200
|
-
});
|
|
201
|
-
it('should include review metadata when provided', () => {
|
|
202
|
-
const summary = {
|
|
203
|
-
filesReviewed: 1,
|
|
204
|
-
issuesFound: 0,
|
|
205
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
206
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
207
|
-
};
|
|
208
|
-
const formatted = formatSummaryComment(summary, [], undefined, undefined, undefined, undefined, {
|
|
209
|
-
headSha: 'abcdef1234567890',
|
|
210
|
-
sourceBranch: 'feature/review-metadata',
|
|
211
|
-
targetBranch: 'main',
|
|
212
|
-
});
|
|
213
|
-
expect(formatted).toContain('<!-- drs-reviewed-head-sha: abcdef1234567890 -->');
|
|
214
|
-
expect(formatted).toContain('🔎 Review Context');
|
|
215
|
-
expect(formatted).toContain('Reviewed Commit**: `abcdef123456`');
|
|
216
|
-
expect(formatted).toContain('Branch**: `feature/review-metadata` -> `main`');
|
|
217
|
-
});
|
|
218
|
-
it('should sanitize review metadata before embedding it', () => {
|
|
219
|
-
const summary = {
|
|
220
|
-
filesReviewed: 1,
|
|
221
|
-
issuesFound: 0,
|
|
222
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
223
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
224
|
-
};
|
|
225
|
-
const formatted = formatSummaryComment(summary, [], undefined, undefined, undefined, undefined, {
|
|
226
|
-
headSha: 'abc-->def',
|
|
227
|
-
sourceBranch: 'feature/`branch`',
|
|
228
|
-
targetBranch: '`main`',
|
|
229
|
-
});
|
|
230
|
-
expect(formatted).not.toContain('abc-->def');
|
|
231
|
-
expect(formatted).toContain('<!-- drs-reviewed-head-sha: abc- ->def -->');
|
|
232
|
-
expect(formatted).toContain('Branch**: `` feature/`branch` `` -> `` `main` ``');
|
|
233
|
-
});
|
|
234
|
-
it('should include change summary when provided', () => {
|
|
235
|
-
const summary = {
|
|
236
|
-
filesReviewed: 1,
|
|
237
|
-
issuesFound: 0,
|
|
238
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
239
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
240
|
-
};
|
|
241
|
-
const changeSummary = {
|
|
242
|
-
description: 'Added authentication system',
|
|
243
|
-
type: 'feature',
|
|
244
|
-
complexity: 'high',
|
|
245
|
-
riskLevel: 'medium',
|
|
246
|
-
subsystems: ['auth', 'api'],
|
|
247
|
-
};
|
|
248
|
-
const formatted = formatSummaryComment(summary, [], undefined, changeSummary);
|
|
249
|
-
expect(formatted).toContain('🧭 Change Summary');
|
|
250
|
-
expect(formatted).toContain('Added authentication system');
|
|
251
|
-
expect(formatted).toContain('Type**: feature');
|
|
252
|
-
expect(formatted).toContain('Complexity**: high');
|
|
253
|
-
expect(formatted).toContain('Risk Level**: medium');
|
|
254
|
-
expect(formatted).toContain('Affected Subsystems**: auth, api');
|
|
255
|
-
});
|
|
256
|
-
it('should format medium priority issues', () => {
|
|
257
|
-
const issues = [
|
|
258
|
-
{
|
|
259
|
-
category: 'QUALITY',
|
|
260
|
-
severity: 'MEDIUM',
|
|
261
|
-
title: 'Medium issue',
|
|
262
|
-
file: 'file.ts',
|
|
263
|
-
line: 10,
|
|
264
|
-
problem: 'Problem',
|
|
265
|
-
solution: 'Solution',
|
|
266
|
-
agent: 'quality',
|
|
267
|
-
},
|
|
268
|
-
];
|
|
269
|
-
const summary = {
|
|
270
|
-
filesReviewed: 1,
|
|
271
|
-
issuesFound: 1,
|
|
272
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 1, LOW: 0 },
|
|
273
|
-
byCategory: { SECURITY: 0, QUALITY: 1, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
274
|
-
};
|
|
275
|
-
const formatted = formatSummaryComment(summary, issues);
|
|
276
|
-
expect(formatted).toContain('🟠 Medium Priority Issues');
|
|
277
|
-
expect(formatted).toContain('Medium issue');
|
|
278
|
-
});
|
|
279
|
-
it('should format low priority issues', () => {
|
|
280
|
-
const issues = [
|
|
281
|
-
{
|
|
282
|
-
category: 'STYLE',
|
|
283
|
-
severity: 'LOW',
|
|
284
|
-
title: 'Low issue',
|
|
285
|
-
file: 'file.ts',
|
|
286
|
-
line: 10,
|
|
287
|
-
problem: 'Problem',
|
|
288
|
-
solution: 'Solution',
|
|
289
|
-
agent: 'style',
|
|
290
|
-
},
|
|
291
|
-
];
|
|
292
|
-
const summary = {
|
|
293
|
-
filesReviewed: 1,
|
|
294
|
-
issuesFound: 1,
|
|
295
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 1 },
|
|
296
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 1, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
297
|
-
};
|
|
298
|
-
const formatted = formatSummaryComment(summary, issues);
|
|
299
|
-
expect(formatted).toContain('⚪ Low Priority Issues');
|
|
300
|
-
expect(formatted).toContain('Low issue');
|
|
301
|
-
});
|
|
302
|
-
it('should include references in issue details', () => {
|
|
303
|
-
const issues = [
|
|
304
|
-
{
|
|
305
|
-
category: 'SECURITY',
|
|
306
|
-
severity: 'CRITICAL',
|
|
307
|
-
title: 'Issue with refs',
|
|
308
|
-
file: 'file.ts',
|
|
309
|
-
line: 10,
|
|
310
|
-
problem: 'Problem',
|
|
311
|
-
solution: 'Solution',
|
|
312
|
-
references: ['https://example.com', 'CWE-123'],
|
|
313
|
-
agent: 'security',
|
|
314
|
-
},
|
|
315
|
-
];
|
|
316
|
-
const summary = {
|
|
317
|
-
filesReviewed: 1,
|
|
318
|
-
issuesFound: 1,
|
|
319
|
-
bySeverity: { CRITICAL: 1, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
320
|
-
byCategory: { SECURITY: 1, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
321
|
-
};
|
|
322
|
-
const formatted = formatSummaryComment(summary, issues);
|
|
323
|
-
expect(formatted).toContain('**References**: https://example.com, CWE-123');
|
|
324
|
-
});
|
|
325
|
-
it('should handle change summary without subsystems', () => {
|
|
326
|
-
const summary = {
|
|
327
|
-
filesReviewed: 1,
|
|
328
|
-
issuesFound: 0,
|
|
329
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
330
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
331
|
-
};
|
|
332
|
-
const changeSummary = {
|
|
333
|
-
description: 'Minor fix',
|
|
334
|
-
type: 'bugfix',
|
|
335
|
-
complexity: 'simple',
|
|
336
|
-
riskLevel: 'low',
|
|
337
|
-
subsystems: [],
|
|
338
|
-
};
|
|
339
|
-
const formatted = formatSummaryComment(summary, [], undefined, changeSummary);
|
|
340
|
-
expect(formatted).toContain('Minor fix');
|
|
341
|
-
expect(formatted).not.toContain('Affected Subsystems');
|
|
342
|
-
});
|
|
343
|
-
it('should include expandable usage block when usage data is provided', () => {
|
|
344
|
-
const summary = {
|
|
345
|
-
filesReviewed: 3,
|
|
346
|
-
issuesFound: 0,
|
|
347
|
-
bySeverity: { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 },
|
|
348
|
-
byCategory: { SECURITY: 0, QUALITY: 0, STYLE: 0, PERFORMANCE: 0, DOCUMENTATION: 0 },
|
|
349
|
-
};
|
|
350
|
-
const usage = {
|
|
351
|
-
total: {
|
|
352
|
-
input: 1234,
|
|
353
|
-
output: 234,
|
|
354
|
-
cacheRead: 500,
|
|
355
|
-
cacheWrite: 0,
|
|
356
|
-
totalTokens: 1968,
|
|
357
|
-
cost: 0.0423,
|
|
358
|
-
},
|
|
359
|
-
agents: [
|
|
360
|
-
{
|
|
361
|
-
agentType: 'unified-reviewer',
|
|
362
|
-
model: 'opencode/glm-5-free',
|
|
363
|
-
turns: 4,
|
|
364
|
-
success: true,
|
|
365
|
-
usage: {
|
|
366
|
-
input: 1234,
|
|
367
|
-
output: 234,
|
|
368
|
-
cacheRead: 500,
|
|
369
|
-
cacheWrite: 0,
|
|
370
|
-
totalTokens: 1968,
|
|
371
|
-
cost: 0.0423,
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
],
|
|
375
|
-
};
|
|
376
|
-
const formatted = formatSummaryComment(summary, [], undefined, undefined, usage);
|
|
377
|
-
expect(formatted).toContain('💰 Model Usage');
|
|
378
|
-
expect(formatted).toContain('<details>');
|
|
379
|
-
expect(formatted).toContain('View token and cost breakdown');
|
|
380
|
-
expect(formatted).toContain('| Agent | Model | Turns | Input | Output | Cache Read |');
|
|
381
|
-
expect(formatted).toContain('unified-reviewer');
|
|
382
|
-
expect(formatted).toContain('opencode/glm-5-free');
|
|
383
|
-
expect(formatted).toContain('$0.0423');
|
|
384
|
-
expect(formatted).toContain('</details>');
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
describe('formatTerminalIssue', () => {
|
|
388
|
-
it('should format issue for terminal output', () => {
|
|
389
|
-
const issue = {
|
|
390
|
-
category: 'SECURITY',
|
|
391
|
-
severity: 'CRITICAL',
|
|
392
|
-
title: 'Security Issue',
|
|
393
|
-
file: 'src/app.ts',
|
|
394
|
-
line: 10,
|
|
395
|
-
problem: 'This is a problem',
|
|
396
|
-
solution: 'This is a solution',
|
|
397
|
-
agent: 'security',
|
|
398
|
-
};
|
|
399
|
-
const formatted = formatTerminalIssue(issue);
|
|
400
|
-
expect(formatted).toContain('🔴 CRITICAL');
|
|
401
|
-
expect(formatted).toContain('🔒 SECURITY');
|
|
402
|
-
expect(formatted).toContain('Security Issue');
|
|
403
|
-
expect(formatted).toContain('📁 src/app.ts:10');
|
|
404
|
-
expect(formatted).toContain('This is a problem');
|
|
405
|
-
expect(formatted).toContain('✅ Fix: This is a solution');
|
|
406
|
-
expect(formatted).toContain('━━━'); // Border
|
|
407
|
-
});
|
|
408
|
-
it('should format issue without line number', () => {
|
|
409
|
-
const issue = {
|
|
410
|
-
category: 'QUALITY',
|
|
411
|
-
severity: 'MEDIUM',
|
|
412
|
-
title: 'Quality Issue',
|
|
413
|
-
file: 'src/utils.ts',
|
|
414
|
-
problem: 'Problem description',
|
|
415
|
-
solution: 'Solution description',
|
|
416
|
-
agent: 'quality',
|
|
417
|
-
};
|
|
418
|
-
const formatted = formatTerminalIssue(issue);
|
|
419
|
-
expect(formatted).toContain('📁 src/utils.ts');
|
|
420
|
-
expect(formatted).not.toContain('src/utils.ts:'); // Should not have line number
|
|
421
|
-
});
|
|
422
|
-
it('should format all severity levels correctly', () => {
|
|
423
|
-
const severities = [
|
|
424
|
-
{ severity: 'CRITICAL', emoji: '🔴' },
|
|
425
|
-
{ severity: 'HIGH', emoji: '🟡' },
|
|
426
|
-
{ severity: 'MEDIUM', emoji: '🟠' },
|
|
427
|
-
{ severity: 'LOW', emoji: '⚪' },
|
|
428
|
-
];
|
|
429
|
-
for (const { severity, emoji } of severities) {
|
|
430
|
-
const issue = {
|
|
431
|
-
category: 'SECURITY',
|
|
432
|
-
severity,
|
|
433
|
-
title: 'Test',
|
|
434
|
-
file: 'test.ts',
|
|
435
|
-
line: 1,
|
|
436
|
-
problem: 'Problem',
|
|
437
|
-
solution: 'Solution',
|
|
438
|
-
agent: 'test',
|
|
439
|
-
};
|
|
440
|
-
const formatted = formatTerminalIssue(issue);
|
|
441
|
-
expect(formatted).toContain(`${emoji} ${severity}`);
|
|
442
|
-
}
|
|
443
|
-
});
|
|
444
|
-
it('should format all categories correctly', () => {
|
|
445
|
-
const categories = [
|
|
446
|
-
{ category: 'SECURITY', emoji: '🔒' },
|
|
447
|
-
{ category: 'QUALITY', emoji: '📊' },
|
|
448
|
-
{ category: 'STYLE', emoji: '✨' },
|
|
449
|
-
{ category: 'PERFORMANCE', emoji: '⚡' },
|
|
450
|
-
{ category: 'DOCUMENTATION', emoji: '📝' },
|
|
451
|
-
];
|
|
452
|
-
for (const { category, emoji } of categories) {
|
|
453
|
-
const issue = {
|
|
454
|
-
category,
|
|
455
|
-
severity: 'MEDIUM',
|
|
456
|
-
title: 'Test',
|
|
457
|
-
file: 'test.ts',
|
|
458
|
-
line: 1,
|
|
459
|
-
problem: 'Problem',
|
|
460
|
-
solution: 'Solution',
|
|
461
|
-
agent: 'test',
|
|
462
|
-
};
|
|
463
|
-
const formatted = formatTerminalIssue(issue);
|
|
464
|
-
expect(formatted).toContain(`${emoji} ${category}`);
|
|
465
|
-
}
|
|
466
|
-
});
|
|
467
|
-
});
|
|
468
|
-
describe('calculateSummary', () => {
|
|
469
|
-
it('should calculate summary for empty issues', () => {
|
|
470
|
-
const summary = calculateSummary(5, []);
|
|
471
|
-
expect(summary.filesReviewed).toBe(5);
|
|
472
|
-
expect(summary.issuesFound).toBe(0);
|
|
473
|
-
expect(summary.bySeverity.CRITICAL).toBe(0);
|
|
474
|
-
expect(summary.bySeverity.HIGH).toBe(0);
|
|
475
|
-
expect(summary.bySeverity.MEDIUM).toBe(0);
|
|
476
|
-
expect(summary.bySeverity.LOW).toBe(0);
|
|
477
|
-
expect(summary.byCategory.SECURITY).toBe(0);
|
|
478
|
-
expect(summary.byCategory.QUALITY).toBe(0);
|
|
479
|
-
expect(summary.byCategory.STYLE).toBe(0);
|
|
480
|
-
expect(summary.byCategory.PERFORMANCE).toBe(0);
|
|
481
|
-
expect(summary.byCategory.DOCUMENTATION).toBe(0);
|
|
482
|
-
});
|
|
483
|
-
it('should calculate summary with mixed severity issues', () => {
|
|
484
|
-
const issues = [
|
|
485
|
-
{
|
|
486
|
-
category: 'SECURITY',
|
|
487
|
-
severity: 'CRITICAL',
|
|
488
|
-
title: 'Issue 1',
|
|
489
|
-
file: 'file.ts',
|
|
490
|
-
line: 1,
|
|
491
|
-
problem: 'Problem',
|
|
492
|
-
solution: 'Solution',
|
|
493
|
-
agent: 'security',
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
category: 'SECURITY',
|
|
497
|
-
severity: 'HIGH',
|
|
498
|
-
title: 'Issue 2',
|
|
499
|
-
file: 'file.ts',
|
|
500
|
-
line: 2,
|
|
501
|
-
problem: 'Problem',
|
|
502
|
-
solution: 'Solution',
|
|
503
|
-
agent: 'security',
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
category: 'QUALITY',
|
|
507
|
-
severity: 'MEDIUM',
|
|
508
|
-
title: 'Issue 3',
|
|
509
|
-
file: 'file.ts',
|
|
510
|
-
line: 3,
|
|
511
|
-
problem: 'Problem',
|
|
512
|
-
solution: 'Solution',
|
|
513
|
-
agent: 'quality',
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
category: 'STYLE',
|
|
517
|
-
severity: 'LOW',
|
|
518
|
-
title: 'Issue 4',
|
|
519
|
-
file: 'file.ts',
|
|
520
|
-
line: 4,
|
|
521
|
-
problem: 'Problem',
|
|
522
|
-
solution: 'Solution',
|
|
523
|
-
agent: 'style',
|
|
524
|
-
},
|
|
525
|
-
];
|
|
526
|
-
const summary = calculateSummary(3, issues);
|
|
527
|
-
expect(summary.filesReviewed).toBe(3);
|
|
528
|
-
expect(summary.issuesFound).toBe(4);
|
|
529
|
-
expect(summary.bySeverity.CRITICAL).toBe(1);
|
|
530
|
-
expect(summary.bySeverity.HIGH).toBe(1);
|
|
531
|
-
expect(summary.bySeverity.MEDIUM).toBe(1);
|
|
532
|
-
expect(summary.bySeverity.LOW).toBe(1);
|
|
533
|
-
expect(summary.byCategory.SECURITY).toBe(2);
|
|
534
|
-
expect(summary.byCategory.QUALITY).toBe(1);
|
|
535
|
-
expect(summary.byCategory.STYLE).toBe(1);
|
|
536
|
-
});
|
|
537
|
-
it('should calculate summary with multiple issues of same severity', () => {
|
|
538
|
-
const issues = [
|
|
539
|
-
{
|
|
540
|
-
category: 'SECURITY',
|
|
541
|
-
severity: 'CRITICAL',
|
|
542
|
-
title: 'Issue 1',
|
|
543
|
-
file: 'file.ts',
|
|
544
|
-
line: 1,
|
|
545
|
-
problem: 'Problem',
|
|
546
|
-
solution: 'Solution',
|
|
547
|
-
agent: 'security',
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
category: 'QUALITY',
|
|
551
|
-
severity: 'CRITICAL',
|
|
552
|
-
title: 'Issue 2',
|
|
553
|
-
file: 'file.ts',
|
|
554
|
-
line: 2,
|
|
555
|
-
problem: 'Problem',
|
|
556
|
-
solution: 'Solution',
|
|
557
|
-
agent: 'quality',
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
category: 'PERFORMANCE',
|
|
561
|
-
severity: 'CRITICAL',
|
|
562
|
-
title: 'Issue 3',
|
|
563
|
-
file: 'file.ts',
|
|
564
|
-
line: 3,
|
|
565
|
-
problem: 'Problem',
|
|
566
|
-
solution: 'Solution',
|
|
567
|
-
agent: 'performance',
|
|
568
|
-
},
|
|
569
|
-
];
|
|
570
|
-
const summary = calculateSummary(1, issues);
|
|
571
|
-
expect(summary.issuesFound).toBe(3);
|
|
572
|
-
expect(summary.bySeverity.CRITICAL).toBe(3);
|
|
573
|
-
expect(summary.byCategory.SECURITY).toBe(1);
|
|
574
|
-
expect(summary.byCategory.QUALITY).toBe(1);
|
|
575
|
-
expect(summary.byCategory.PERFORMANCE).toBe(1);
|
|
576
|
-
});
|
|
577
|
-
it('should calculate summary with multiple issues of same category', () => {
|
|
578
|
-
const issues = [
|
|
579
|
-
{
|
|
580
|
-
category: 'SECURITY',
|
|
581
|
-
severity: 'CRITICAL',
|
|
582
|
-
title: 'Issue 1',
|
|
583
|
-
file: 'file.ts',
|
|
584
|
-
line: 1,
|
|
585
|
-
problem: 'Problem',
|
|
586
|
-
solution: 'Solution',
|
|
587
|
-
agent: 'security',
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
category: 'SECURITY',
|
|
591
|
-
severity: 'HIGH',
|
|
592
|
-
title: 'Issue 2',
|
|
593
|
-
file: 'file.ts',
|
|
594
|
-
line: 2,
|
|
595
|
-
problem: 'Problem',
|
|
596
|
-
solution: 'Solution',
|
|
597
|
-
agent: 'security',
|
|
598
|
-
},
|
|
599
|
-
{
|
|
600
|
-
category: 'SECURITY',
|
|
601
|
-
severity: 'MEDIUM',
|
|
602
|
-
title: 'Issue 3',
|
|
603
|
-
file: 'file.ts',
|
|
604
|
-
line: 3,
|
|
605
|
-
problem: 'Problem',
|
|
606
|
-
solution: 'Solution',
|
|
607
|
-
agent: 'security',
|
|
608
|
-
},
|
|
609
|
-
];
|
|
610
|
-
const summary = calculateSummary(1, issues);
|
|
611
|
-
expect(summary.issuesFound).toBe(3);
|
|
612
|
-
expect(summary.byCategory.SECURITY).toBe(3);
|
|
613
|
-
expect(summary.bySeverity.CRITICAL).toBe(1);
|
|
614
|
-
expect(summary.bySeverity.HIGH).toBe(1);
|
|
615
|
-
expect(summary.bySeverity.MEDIUM).toBe(1);
|
|
616
|
-
});
|
|
617
|
-
it('should handle zero files reviewed', () => {
|
|
618
|
-
const issues = [
|
|
619
|
-
{
|
|
620
|
-
category: 'STYLE',
|
|
621
|
-
severity: 'LOW',
|
|
622
|
-
title: 'Issue',
|
|
623
|
-
file: 'file.ts',
|
|
624
|
-
line: 1,
|
|
625
|
-
problem: 'Problem',
|
|
626
|
-
solution: 'Solution',
|
|
627
|
-
agent: 'style',
|
|
628
|
-
},
|
|
629
|
-
];
|
|
630
|
-
const summary = calculateSummary(0, issues);
|
|
631
|
-
expect(summary.filesReviewed).toBe(0);
|
|
632
|
-
expect(summary.issuesFound).toBe(1);
|
|
633
|
-
});
|
|
634
|
-
it('should handle all categories and severities', () => {
|
|
635
|
-
const issues = [
|
|
636
|
-
{
|
|
637
|
-
category: 'SECURITY',
|
|
638
|
-
severity: 'CRITICAL',
|
|
639
|
-
title: '1',
|
|
640
|
-
file: 'f.ts',
|
|
641
|
-
line: 1,
|
|
642
|
-
problem: 'P',
|
|
643
|
-
solution: 'S',
|
|
644
|
-
agent: 'a',
|
|
645
|
-
},
|
|
646
|
-
{
|
|
647
|
-
category: 'QUALITY',
|
|
648
|
-
severity: 'HIGH',
|
|
649
|
-
title: '2',
|
|
650
|
-
file: 'f.ts',
|
|
651
|
-
line: 2,
|
|
652
|
-
problem: 'P',
|
|
653
|
-
solution: 'S',
|
|
654
|
-
agent: 'a',
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
category: 'STYLE',
|
|
658
|
-
severity: 'MEDIUM',
|
|
659
|
-
title: '3',
|
|
660
|
-
file: 'f.ts',
|
|
661
|
-
line: 3,
|
|
662
|
-
problem: 'P',
|
|
663
|
-
solution: 'S',
|
|
664
|
-
agent: 'a',
|
|
665
|
-
},
|
|
666
|
-
{
|
|
667
|
-
category: 'PERFORMANCE',
|
|
668
|
-
severity: 'LOW',
|
|
669
|
-
title: '4',
|
|
670
|
-
file: 'f.ts',
|
|
671
|
-
line: 4,
|
|
672
|
-
problem: 'P',
|
|
673
|
-
solution: 'S',
|
|
674
|
-
agent: 'a',
|
|
675
|
-
},
|
|
676
|
-
{
|
|
677
|
-
category: 'DOCUMENTATION',
|
|
678
|
-
severity: 'LOW',
|
|
679
|
-
title: '5',
|
|
680
|
-
file: 'f.ts',
|
|
681
|
-
line: 5,
|
|
682
|
-
problem: 'P',
|
|
683
|
-
solution: 'S',
|
|
684
|
-
agent: 'a',
|
|
685
|
-
},
|
|
686
|
-
];
|
|
687
|
-
const summary = calculateSummary(5, issues);
|
|
688
|
-
expect(summary.issuesFound).toBe(5);
|
|
689
|
-
expect(summary.byCategory.SECURITY).toBe(1);
|
|
690
|
-
expect(summary.byCategory.QUALITY).toBe(1);
|
|
691
|
-
expect(summary.byCategory.STYLE).toBe(1);
|
|
692
|
-
expect(summary.byCategory.PERFORMANCE).toBe(1);
|
|
693
|
-
expect(summary.byCategory.DOCUMENTATION).toBe(1);
|
|
694
|
-
expect(summary.bySeverity.CRITICAL).toBe(1);
|
|
695
|
-
expect(summary.bySeverity.HIGH).toBe(1);
|
|
696
|
-
expect(summary.bySeverity.MEDIUM).toBe(1);
|
|
697
|
-
expect(summary.bySeverity.LOW).toBe(2);
|
|
698
|
-
});
|
|
699
|
-
});
|
|
700
|
-
describe('formatErrorComment', () => {
|
|
701
|
-
it('should format error comment with standard message', () => {
|
|
702
|
-
const formatted = formatErrorComment();
|
|
703
|
-
expect(formatted).toContain(':warning: DRS Review Failed');
|
|
704
|
-
expect(formatted).toContain('automated code review encountered an error');
|
|
705
|
-
expect(formatted).toContain('check the CI/CD logs');
|
|
706
|
-
expect(formatted).toContain('automatically removed when the review succeeds');
|
|
707
|
-
expect(formatted).toContain('DRS');
|
|
708
|
-
});
|
|
709
|
-
it('should include comment ID when provided', () => {
|
|
710
|
-
const formatted = formatErrorComment('drs-error');
|
|
711
|
-
expect(formatted).toContain('<!-- drs-comment-id: drs-error -->');
|
|
712
|
-
});
|
|
713
|
-
it('should not include comment ID when not provided', () => {
|
|
714
|
-
const formatted = formatErrorComment();
|
|
715
|
-
expect(formatted).not.toContain('<!-- drs-comment-id:');
|
|
716
|
-
});
|
|
717
|
-
it('should not expose error details in comment', () => {
|
|
718
|
-
// Error details should not be in the comment - users should check CI/CD logs
|
|
719
|
-
const formatted = formatErrorComment('drs-error');
|
|
720
|
-
// Should contain the log directive
|
|
721
|
-
expect(formatted).toContain('Please check the CI/CD logs for error details');
|
|
722
|
-
// Should not have a code block for error messages
|
|
723
|
-
expect(formatted).not.toContain('```');
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
});
|
|
727
|
-
//# sourceMappingURL=comment-formatter.test.js.map
|