@diff-review-system/drs 1.1.2 ā 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/.opencode/agent/describe/pr-describer.md +221 -0
- package/.opencode/agent/review/documentation.md +56 -0
- package/.opencode/agent/review/performance.md +32 -139
- package/.opencode/agent/review/quality.md +36 -113
- package/.opencode/agent/review/security.md +32 -97
- package/.opencode/agent/review/style.md +4 -0
- package/.opencode/agent/review/unified-reviewer.md +74 -0
- package/.opencode/opencode.jsonc +4 -29
- package/.opencode/tool/write_json_output.ts +24 -0
- package/README.md +48 -21
- package/dist/ci/runner.d.ts.map +1 -1
- package/dist/ci/runner.js +2 -0
- package/dist/ci/runner.js.map +1 -1
- package/dist/cli/describe-mr.d.ts +11 -0
- package/dist/cli/describe-mr.d.ts.map +1 -0
- package/dist/cli/describe-mr.js +104 -0
- package/dist/cli/describe-mr.js.map +1 -0
- package/dist/cli/describe-pr.d.ts +12 -0
- package/dist/cli/describe-pr.d.ts.map +1 -0
- package/dist/cli/describe-pr.js +105 -0
- package/dist/cli/describe-pr.js.map +1 -0
- package/dist/cli/index.js +220 -16
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +273 -145
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/post-comments.d.ts +15 -0
- package/dist/cli/post-comments.d.ts.map +1 -0
- package/dist/cli/post-comments.js +216 -0
- package/dist/cli/post-comments.js.map +1 -0
- package/dist/cli/review-local.d.ts +3 -0
- package/dist/cli/review-local.d.ts.map +1 -1
- package/dist/cli/review-local.js +44 -18
- package/dist/cli/review-local.js.map +1 -1
- package/dist/cli/review-mr.d.ts +6 -0
- package/dist/cli/review-mr.d.ts.map +1 -1
- package/dist/cli/review-mr.js +63 -7
- package/dist/cli/review-mr.js.map +1 -1
- package/dist/cli/review-pr.d.ts +6 -0
- package/dist/cli/review-pr.d.ts.map +1 -1
- package/dist/cli/review-pr.js +8 -1
- package/dist/cli/review-pr.js.map +1 -1
- package/dist/cli/show-changes.d.ts +15 -0
- package/dist/cli/show-changes.d.ts.map +1 -0
- package/dist/cli/show-changes.js +184 -0
- package/dist/cli/show-changes.js.map +1 -0
- package/dist/github/platform-adapter.d.ts.map +1 -1
- package/dist/github/platform-adapter.js +4 -2
- package/dist/github/platform-adapter.js.map +1 -1
- package/dist/gitlab/client.d.ts.map +1 -1
- package/dist/gitlab/client.js +1 -1
- package/dist/gitlab/client.js.map +1 -1
- package/dist/gitlab/platform-adapter.d.ts.map +1 -1
- package/dist/gitlab/platform-adapter.js +6 -5
- package/dist/gitlab/platform-adapter.js.map +1 -1
- package/dist/lib/change-summary.d.ts +8 -0
- package/dist/lib/change-summary.d.ts.map +1 -0
- package/dist/lib/change-summary.js +2 -0
- package/dist/lib/change-summary.js.map +1 -0
- package/dist/lib/comment-formatter.d.ts +3 -2
- package/dist/lib/comment-formatter.d.ts.map +1 -1
- package/dist/lib/comment-formatter.js +16 -2
- package/dist/lib/comment-formatter.js.map +1 -1
- package/dist/lib/comment-formatter.test.d.ts +2 -0
- package/dist/lib/comment-formatter.test.d.ts.map +1 -0
- package/dist/lib/comment-formatter.test.js +607 -0
- package/dist/lib/comment-formatter.test.js.map +1 -0
- package/dist/lib/comment-manager.test.d.ts +2 -0
- package/dist/lib/comment-manager.test.d.ts.map +1 -0
- package/dist/lib/comment-manager.test.js +618 -0
- package/dist/lib/comment-manager.test.js.map +1 -0
- package/dist/lib/comment-poster.d.ts +21 -0
- package/dist/lib/comment-poster.d.ts.map +1 -0
- package/dist/lib/comment-poster.js +96 -0
- package/dist/lib/comment-poster.js.map +1 -0
- package/dist/lib/comment-poster.test.d.ts +5 -0
- package/dist/lib/comment-poster.test.d.ts.map +1 -0
- package/dist/lib/comment-poster.test.js +215 -0
- package/dist/lib/comment-poster.test.js.map +1 -0
- package/dist/lib/config-model-overrides.test.js +71 -41
- package/dist/lib/config-model-overrides.test.js.map +1 -1
- package/dist/lib/config.d.ts +63 -7
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +116 -22
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/config.test.js +10 -2
- package/dist/lib/config.test.js.map +1 -1
- package/dist/lib/context-compression.d.ts +19 -0
- package/dist/lib/context-compression.d.ts.map +1 -0
- package/dist/lib/context-compression.js +170 -0
- package/dist/lib/context-compression.js.map +1 -0
- package/dist/lib/context-compression.test.d.ts +2 -0
- package/dist/lib/context-compression.test.d.ts.map +1 -0
- package/dist/lib/context-compression.test.js +33 -0
- package/dist/lib/context-compression.test.js.map +1 -0
- package/dist/lib/context-loader.d.ts.map +1 -1
- package/dist/lib/context-loader.js +8 -1
- package/dist/lib/context-loader.js.map +1 -1
- package/dist/lib/context-loader.test.d.ts +2 -0
- package/dist/lib/context-loader.test.d.ts.map +1 -0
- package/dist/lib/context-loader.test.js +207 -0
- package/dist/lib/context-loader.test.js.map +1 -0
- package/dist/lib/describe-core.d.ts +9 -0
- package/dist/lib/describe-core.d.ts.map +1 -0
- package/dist/lib/describe-core.js +71 -0
- package/dist/lib/describe-core.js.map +1 -0
- package/dist/lib/describe-core.test.d.ts +2 -0
- package/dist/lib/describe-core.test.d.ts.map +1 -0
- package/dist/lib/describe-core.test.js +208 -0
- package/dist/lib/describe-core.test.js.map +1 -0
- package/dist/lib/describe-output-path.test.d.ts +2 -0
- package/dist/lib/describe-output-path.test.d.ts.map +1 -0
- package/dist/lib/describe-output-path.test.js +51 -0
- package/dist/lib/describe-output-path.test.js.map +1 -0
- package/dist/lib/describe-parser.d.ts +3 -0
- package/dist/lib/describe-parser.d.ts.map +1 -0
- package/dist/lib/describe-parser.js +163 -0
- package/dist/lib/describe-parser.js.map +1 -0
- package/dist/lib/describe-parser.test.d.ts +2 -0
- package/dist/lib/describe-parser.test.d.ts.map +1 -0
- package/dist/lib/describe-parser.test.js +282 -0
- package/dist/lib/describe-parser.test.js.map +1 -0
- package/dist/lib/description-executor.d.ts +22 -0
- package/dist/lib/description-executor.d.ts.map +1 -0
- package/dist/lib/description-executor.js +72 -0
- package/dist/lib/description-executor.js.map +1 -0
- package/dist/lib/description-formatter.d.ts +37 -0
- package/dist/lib/description-formatter.d.ts.map +1 -0
- package/dist/lib/description-formatter.js +219 -0
- package/dist/lib/description-formatter.js.map +1 -0
- package/dist/lib/diff-parser.d.ts +11 -0
- package/dist/lib/diff-parser.d.ts.map +1 -1
- package/dist/lib/diff-parser.js +37 -0
- package/dist/lib/diff-parser.js.map +1 -1
- package/dist/lib/issue-parser.d.ts +1 -1
- package/dist/lib/issue-parser.d.ts.map +1 -1
- package/dist/lib/issue-parser.js +16 -14
- package/dist/lib/issue-parser.js.map +1 -1
- package/dist/lib/json-output-schema.d.ts +207 -0
- package/dist/lib/json-output-schema.d.ts.map +1 -0
- package/dist/lib/json-output-schema.js +124 -0
- package/dist/lib/json-output-schema.js.map +1 -0
- package/dist/lib/json-output-schema.test.d.ts +2 -0
- package/dist/lib/json-output-schema.test.d.ts.map +1 -0
- package/dist/lib/json-output-schema.test.js +92 -0
- package/dist/lib/json-output-schema.test.js.map +1 -0
- package/dist/lib/json-output.d.ts +43 -0
- package/dist/lib/json-output.d.ts.map +1 -0
- package/dist/lib/json-output.js +34 -0
- package/dist/lib/json-output.js.map +1 -0
- package/dist/lib/output-paths.d.ts +6 -0
- package/dist/lib/output-paths.d.ts.map +1 -0
- package/dist/lib/output-paths.js +5 -0
- package/dist/lib/output-paths.js.map +1 -0
- package/dist/lib/platform-client.d.ts +1 -1
- package/dist/lib/platform-client.d.ts.map +1 -1
- package/dist/lib/repository-validator.d.ts +52 -0
- package/dist/lib/repository-validator.d.ts.map +1 -0
- package/dist/lib/repository-validator.js +219 -0
- package/dist/lib/repository-validator.js.map +1 -0
- package/dist/lib/repository-validator.test.d.ts +5 -0
- package/dist/lib/repository-validator.test.d.ts.map +1 -0
- package/dist/lib/repository-validator.test.js +341 -0
- package/dist/lib/repository-validator.test.js.map +1 -0
- package/dist/lib/review-core.d.ts +66 -0
- package/dist/lib/review-core.d.ts.map +1 -0
- package/dist/lib/review-core.js +449 -0
- package/dist/lib/review-core.js.map +1 -0
- package/dist/lib/review-core.test.d.ts +2 -0
- package/dist/lib/review-core.test.d.ts.map +1 -0
- package/dist/lib/review-core.test.js +552 -0
- package/dist/lib/review-core.test.js.map +1 -0
- package/dist/lib/review-orchestrator.d.ts +27 -10
- package/dist/lib/review-orchestrator.d.ts.map +1 -1
- package/dist/lib/review-orchestrator.js +51 -110
- package/dist/lib/review-orchestrator.js.map +1 -1
- package/dist/lib/review-orchestrator.test.d.ts +2 -0
- package/dist/lib/review-orchestrator.test.d.ts.map +1 -0
- package/dist/lib/review-orchestrator.test.js +413 -0
- package/dist/lib/review-orchestrator.test.js.map +1 -0
- package/dist/lib/review-output-path.test.d.ts +2 -0
- package/dist/lib/review-output-path.test.d.ts.map +1 -0
- package/dist/lib/review-output-path.test.js +83 -0
- package/dist/lib/review-output-path.test.js.map +1 -0
- package/dist/lib/review-parser.d.ts +2 -0
- package/dist/lib/review-parser.d.ts.map +1 -0
- package/dist/lib/review-parser.js +100 -0
- package/dist/lib/review-parser.js.map +1 -0
- package/dist/lib/unified-review-executor.d.ts +21 -4
- package/dist/lib/unified-review-executor.d.ts.map +1 -1
- package/dist/lib/unified-review-executor.js +81 -151
- package/dist/lib/unified-review-executor.js.map +1 -1
- package/dist/lib/unified-review-executor.test.d.ts +5 -0
- package/dist/lib/unified-review-executor.test.d.ts.map +1 -0
- package/dist/lib/unified-review-executor.test.js +344 -0
- package/dist/lib/unified-review-executor.test.js.map +1 -0
- package/dist/lib/write-json-output.d.ts +13 -0
- package/dist/lib/write-json-output.d.ts.map +1 -0
- package/dist/lib/write-json-output.js +37 -0
- package/dist/lib/write-json-output.js.map +1 -0
- package/dist/opencode/agent-loader.d.ts +3 -4
- package/dist/opencode/agent-loader.d.ts.map +1 -1
- package/dist/opencode/agent-loader.js +48 -34
- package/dist/opencode/agent-loader.js.map +1 -1
- package/dist/opencode/agent-skill-overlay.d.ts +11 -0
- package/dist/opencode/agent-skill-overlay.d.ts.map +1 -0
- package/dist/opencode/agent-skill-overlay.js +164 -0
- package/dist/opencode/agent-skill-overlay.js.map +1 -0
- package/dist/opencode/client.d.ts +11 -3
- package/dist/opencode/client.d.ts.map +1 -1
- package/dist/opencode/client.js +237 -71
- package/dist/opencode/client.js.map +1 -1
- package/dist/opencode/client.test.d.ts +2 -0
- package/dist/opencode/client.test.d.ts.map +1 -0
- package/dist/opencode/client.test.js +317 -0
- package/dist/opencode/client.test.js.map +1 -0
- package/dist/opencode/opencode-paths.d.ts +2 -0
- package/dist/opencode/opencode-paths.d.ts.map +1 -0
- package/dist/opencode/opencode-paths.js +7 -0
- package/dist/opencode/opencode-paths.js.map +1 -0
- package/dist/opencode/skill-loader.d.ts +6 -0
- package/dist/opencode/skill-loader.d.ts.map +1 -0
- package/dist/opencode/skill-loader.js +36 -0
- package/dist/opencode/skill-loader.js.map +1 -0
- package/package.json +7 -7
- package/.opencode/agent/github-reviewer.md +0 -77
- package/.opencode/agent/gitlab-reviewer.md +0 -77
- package/.opencode/agent/local-reviewer.md +0 -63
|
@@ -8,111 +8,46 @@ tools:
|
|
|
8
8
|
Grep: true
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
You are
|
|
11
|
+
You are an elite security code reviewer with deep expertise in application security, threat modeling, and secure coding practices. Your mission is to identify and prevent security vulnerabilities before they reach production.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Security Vulnerability Assessment
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
- SQL injection
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
15
|
+
- Systematically scan for OWASP Top 10 vulnerabilities (injection flaws, broken authentication, sensitive data exposure, XXE, broken access control, security misconfiguration, XSS, insecure deserialization, using components with known vulnerabilities, insufficient logging)
|
|
16
|
+
- Identify potential SQL injection, NoSQL injection, and command injection vulnerabilities
|
|
17
|
+
- Check for cross-site scripting (XSS) vulnerabilities in any user-facing output
|
|
18
|
+
- Look for cross-site request forgery (CSRF) protection gaps
|
|
19
|
+
- Examine cryptographic implementations for weak algorithms or improper key management
|
|
20
|
+
- Identify potential race conditions and time-of-check-time-of-use (TOCTOU) vulnerabilities
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
- Broken authentication flows
|
|
24
|
-
- Missing authorization checks
|
|
25
|
-
- Insecure session management
|
|
26
|
-
- JWT vulnerabilities
|
|
27
|
-
- Privilege escalation
|
|
22
|
+
## Input Validation and Sanitization
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
24
|
+
- Verify all user inputs are properly validated against expected formats and ranges
|
|
25
|
+
- Ensure input sanitization occurs at appropriate boundaries (client-side validation is supplementary, never primary)
|
|
26
|
+
- Check for proper encoding when outputting user data
|
|
27
|
+
- Validate that file uploads have proper type checking, size limits, and content validation
|
|
28
|
+
- Ensure API parameters are validated for type, format, and business logic constraints
|
|
29
|
+
- Look for potential path traversal vulnerabilities in file operations
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
- Debug mode in production
|
|
38
|
-
- Default credentials
|
|
39
|
-
- Unnecessary services enabled
|
|
40
|
-
- Missing security headers
|
|
41
|
-
- Verbose error messages
|
|
31
|
+
## Authentication and Authorization Review
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
33
|
+
- Verify authentication mechanisms use secure, industry-standard approaches
|
|
34
|
+
- Check for proper session management (secure cookies, appropriate timeouts, session invalidation)
|
|
35
|
+
- Ensure passwords are properly hashed using modern algorithms (bcrypt, Argon2, PBKDF2)
|
|
36
|
+
- Validate that authorization checks occur at every protected resource access
|
|
37
|
+
- Look for privilege escalation opportunities
|
|
38
|
+
- Check for insecure direct object references (IDOR)
|
|
39
|
+
- Verify proper implementation of role-based or attribute-based access control
|
|
49
40
|
|
|
50
|
-
##
|
|
41
|
+
## Analysis Methodology
|
|
51
42
|
|
|
52
|
-
|
|
43
|
+
1. Identify the security context and attack surface of the code
|
|
44
|
+
2. Map data flows from untrusted sources to sensitive operations
|
|
45
|
+
3. Examine each security-critical operation for proper controls
|
|
46
|
+
4. Consider both common vulnerabilities and context-specific threats
|
|
47
|
+
5. Evaluate defense-in-depth measures
|
|
53
48
|
|
|
54
|
-
|
|
49
|
+
## Review Structure Guidance
|
|
55
50
|
|
|
56
|
-
|
|
57
|
-
{
|
|
58
|
-
"issues": [
|
|
59
|
-
{
|
|
60
|
-
"category": "SECURITY",
|
|
61
|
-
"severity": "CRITICAL" | "HIGH" | "MEDIUM" | "LOW",
|
|
62
|
-
"title": "Brief title of the vulnerability",
|
|
63
|
-
"file": "path/to/file.ts",
|
|
64
|
-
"line": 42,
|
|
65
|
-
"problem": "Clear explanation of the vulnerability and potential impact",
|
|
66
|
-
"solution": "Secure code example or fix description",
|
|
67
|
-
"references": ["https://owasp.org/...", "https://cwe.mitre.org/..."],
|
|
68
|
-
"agent": "security"
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
}
|
|
72
|
-
```
|
|
51
|
+
Provide findings in order of severity (Critical, High, Medium, Low, Informational). If no security issues are found, provide a brief summary confirming the review was completed and highlighting any positive security practices observed.
|
|
73
52
|
|
|
74
|
-
|
|
75
|
-
**Optional fields**: line (line number), references (array of URLs)
|
|
76
|
-
|
|
77
|
-
## Examples
|
|
78
|
-
|
|
79
|
-
### SQL Injection
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
// ā VULNERABLE
|
|
83
|
-
const query = `SELECT * FROM users WHERE id = ${userId}`
|
|
84
|
-
|
|
85
|
-
// ā
SECURE
|
|
86
|
-
const query = 'SELECT * FROM users WHERE id = ?'
|
|
87
|
-
const result = await db.query(query, [userId])
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### XSS Prevention
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
// ā VULNERABLE
|
|
94
|
-
element.innerHTML = userInput
|
|
95
|
-
|
|
96
|
-
// ā
SECURE
|
|
97
|
-
element.textContent = userInput
|
|
98
|
-
// or use a sanitization library
|
|
99
|
-
element.innerHTML = DOMPurify.sanitize(userInput)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Hardcoded Credentials
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
// ā VULNERABLE
|
|
106
|
-
const apiKey = "sk-1234567890abcdef"
|
|
107
|
-
|
|
108
|
-
// ā
SECURE
|
|
109
|
-
const apiKey = process.env.API_KEY
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
Focus on exploitable vulnerabilities. Prioritize issues that could lead to:
|
|
113
|
-
- Data breaches
|
|
114
|
-
- Unauthorized access
|
|
115
|
-
- Code execution
|
|
116
|
-
- Denial of service
|
|
117
|
-
|
|
118
|
-
Be precise with line numbers and provide actionable fixes.
|
|
53
|
+
Always consider the principle of least privilege, defense in depth, and fail securely. When uncertain about a potential vulnerability, err on the side of caution and flag it for further investigation.
|
|
@@ -29,6 +29,10 @@ You are a code style reviewer ensuring consistency and documentation quality.
|
|
|
29
29
|
- Outdated comments
|
|
30
30
|
- JSDoc/TSDoc completeness
|
|
31
31
|
- README updates needed
|
|
32
|
+
- New CLI flags or config options documented in README
|
|
33
|
+
- Command examples formatted consistently and kept up-to-date
|
|
34
|
+
- Markdown formatting issues (headings, code fences, lists, links)
|
|
35
|
+
- Consistent terminology for key concepts and feature names
|
|
32
36
|
|
|
33
37
|
### 4. Type Safety (TypeScript)
|
|
34
38
|
- Missing type annotations
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Unified review agent covering security, quality, style, performance, and documentation
|
|
3
|
+
color: "#6B46C1"
|
|
4
|
+
hidden: false
|
|
5
|
+
tools:
|
|
6
|
+
Read: true
|
|
7
|
+
Glob: true
|
|
8
|
+
Grep: true
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
You are a unified code review agent responsible for reviewing changes across **security**, **quality**, **style**, **performance**, and **documentation** in a single pass. Focus on issues introduced in the diff and keep feedback concise and actionable.
|
|
12
|
+
|
|
13
|
+
## Review Priorities
|
|
14
|
+
|
|
15
|
+
- **Security**: injection risks, auth/authorization flaws, secrets exposure, unsafe deserialization.
|
|
16
|
+
- **Quality**: correctness, error handling, edge cases, maintainability.
|
|
17
|
+
- **Performance**: inefficient loops, unnecessary I/O, excessive allocations.
|
|
18
|
+
- **Style**: naming, consistency, readability, TypeScript best practices.
|
|
19
|
+
- **Documentation**: missing or inaccurate comments, README/API doc drift.
|
|
20
|
+
|
|
21
|
+
## Output Requirements
|
|
22
|
+
|
|
23
|
+
- You MUST call the `write_json_output` tool with:
|
|
24
|
+
- `outputType`: `"review_output"`
|
|
25
|
+
- `payload`: the JSON object described below
|
|
26
|
+
- After calling the tool, return **only** the JSON pointer returned by the tool
|
|
27
|
+
(e.g. `{"outputType":"review_output","outputPath":".drs/review-output.json"}`)
|
|
28
|
+
- Do **not** return raw JSON directly.
|
|
29
|
+
- Do **not** include markdown, code fences, or extra text.
|
|
30
|
+
- Follow this exact schema:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"timestamp": "ISO-8601 timestamp or descriptive string",
|
|
35
|
+
"summary": {
|
|
36
|
+
"filesReviewed": 0,
|
|
37
|
+
"issuesFound": 0,
|
|
38
|
+
"bySeverity": {
|
|
39
|
+
"CRITICAL": 0,
|
|
40
|
+
"HIGH": 0,
|
|
41
|
+
"MEDIUM": 0,
|
|
42
|
+
"LOW": 0
|
|
43
|
+
},
|
|
44
|
+
"byCategory": {
|
|
45
|
+
"SECURITY": 0,
|
|
46
|
+
"QUALITY": 0,
|
|
47
|
+
"STYLE": 0,
|
|
48
|
+
"PERFORMANCE": 0,
|
|
49
|
+
"DOCUMENTATION": 0
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"issues": [
|
|
53
|
+
{
|
|
54
|
+
"category": "SECURITY" | "QUALITY" | "STYLE" | "PERFORMANCE" | "DOCUMENTATION",
|
|
55
|
+
"severity": "CRITICAL" | "HIGH" | "MEDIUM" | "LOW",
|
|
56
|
+
"title": "Brief title",
|
|
57
|
+
"file": "path/to/file.ts",
|
|
58
|
+
"line": 42,
|
|
59
|
+
"problem": "Description of the problem",
|
|
60
|
+
"solution": "Concrete fix or mitigation",
|
|
61
|
+
"references": ["https://link1", "https://link2"],
|
|
62
|
+
"agent": "unified"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
If there are no issues, set `issues` to `[]` and keep summary counts at `0`.
|
|
69
|
+
|
|
70
|
+
### Important Constraints
|
|
71
|
+
- **Only report issues on changed or added lines** (lines starting with `+` in the diff).
|
|
72
|
+
- Prioritize **additions over deletions**; deletions are context only.
|
|
73
|
+
- Be specific: include file names and line numbers when available.
|
|
74
|
+
- Keep severities calibrated (use HIGH/CRITICAL sparingly).
|
package/.opencode/opencode.jsonc
CHANGED
|
@@ -1,40 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://opencode.ai/config.json",
|
|
3
3
|
|
|
4
|
-
//
|
|
4
|
+
// Tools available to DRS review agents
|
|
5
|
+
// Note: Agent model configuration is done via .drs/drs.config.yaml
|
|
5
6
|
"tools": {
|
|
6
|
-
"gitlab-api": true,
|
|
7
|
-
"github-api": true,
|
|
8
|
-
"Bash": true,
|
|
9
7
|
"Read": true,
|
|
10
8
|
"Glob": true,
|
|
11
9
|
"Grep": true,
|
|
10
|
+
"Bash": true,
|
|
11
|
+
"write_json_output": true,
|
|
12
12
|
"Write": false,
|
|
13
13
|
"Edit": false
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
// Agent model configuration
|
|
17
|
-
"agent": {
|
|
18
|
-
"gitlab-reviewer": {
|
|
19
|
-
"model": "opencode/glm-4.7-free"
|
|
20
|
-
},
|
|
21
|
-
"github-reviewer": {
|
|
22
|
-
"model": "opencode/glm-4.7-free"
|
|
23
|
-
},
|
|
24
|
-
"local-reviewer": {
|
|
25
|
-
"model": "opencode/glm-4.7-free"
|
|
26
|
-
},
|
|
27
|
-
"review/security": {
|
|
28
|
-
"model": "opencode/glm-4.7-free"
|
|
29
|
-
},
|
|
30
|
-
"review/quality": {
|
|
31
|
-
"model": "opencode/glm-4.7-free"
|
|
32
|
-
},
|
|
33
|
-
"review/style": {
|
|
34
|
-
"model": "opencode/glm-4.7-free"
|
|
35
|
-
},
|
|
36
|
-
"review/performance": {
|
|
37
|
-
"model": "opencode/glm-4.7-free"
|
|
38
|
-
}
|
|
39
14
|
}
|
|
40
15
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { tool } from '@opencode-ai/plugin';
|
|
2
|
+
import { writeJsonOutput } from '../../src/lib/write-json-output.js';
|
|
3
|
+
|
|
4
|
+
export default tool({
|
|
5
|
+
description: 'Write validated JSON output for DRS agents.',
|
|
6
|
+
args: {
|
|
7
|
+
outputType: tool.schema
|
|
8
|
+
.enum(['describe_output', 'review_output'])
|
|
9
|
+
.describe('The DRS output type to validate and write'),
|
|
10
|
+
payload: tool.schema.any().describe('JSON value or JSON string to write'),
|
|
11
|
+
pretty: tool.schema.boolean().optional().describe('Pretty-print JSON output'),
|
|
12
|
+
indent: tool.schema
|
|
13
|
+
.number()
|
|
14
|
+
.int()
|
|
15
|
+
.min(2)
|
|
16
|
+
.max(8)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('Indent size when pretty-printing'),
|
|
19
|
+
},
|
|
20
|
+
async execute({ outputType, payload, pretty, indent }) {
|
|
21
|
+
const pointer = await writeJsonOutput({ outputType, payload, pretty, indent });
|
|
22
|
+
return JSON.stringify(pointer);
|
|
23
|
+
},
|
|
24
|
+
});
|
package/README.md
CHANGED
|
@@ -7,9 +7,12 @@ Enterprise-grade automated code review for Merge Requests and Pull Requests, pow
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Comprehensive Analysis**: Advanced code review using Claude's latest models
|
|
10
|
-
- **Specialized Review Domains**: Security, quality, style, and
|
|
10
|
+
- **Specialized Review Domains**: Security, quality, style, performance, and documentation analysis
|
|
11
11
|
- **Multi-Platform Support**: Native integration with GitLab and GitHub
|
|
12
|
-
- **Flexible Deployment**: CI/CD pipelines
|
|
12
|
+
- **Flexible Deployment**: CI/CD pipelines or local CLI
|
|
13
|
+
- **Review Modes**: Multi-agent deep review, single-pass unified review, and hybrid escalation
|
|
14
|
+
- **Unified Reviewer**: One-pass JSON output with severity-tagged findings across domains
|
|
15
|
+
- **PR/MR Descriptions**: Optional auto-generated descriptions and labels for pull requests
|
|
13
16
|
- **Highly Customizable**: Configure review agents with project-specific rules
|
|
14
17
|
- **Deep Integration**: Full API support for both GitLab and GitHub platforms
|
|
15
18
|
|
|
@@ -81,11 +84,41 @@ drs review-local
|
|
|
81
84
|
# Review specific GitLab MR
|
|
82
85
|
drs review-mr --project my-org/my-repo --mr 123 --post-comments
|
|
83
86
|
|
|
87
|
+
# Review GitLab MR and auto-generate a description (optionally post it)
|
|
88
|
+
drs review-mr --project my-org/my-repo --mr 123 --describe
|
|
89
|
+
drs review-mr --project my-org/my-repo --mr 123 --describe --post-description
|
|
90
|
+
|
|
84
91
|
# Review GitLab MR and generate code quality report
|
|
85
92
|
drs review-mr --project my-org/my-repo --mr 123 --code-quality-report gl-code-quality-report.json
|
|
86
93
|
|
|
87
94
|
# Review specific GitHub PR
|
|
88
95
|
drs review-pr --owner octocat --repo hello-world --pr 456 --post-comments
|
|
96
|
+
|
|
97
|
+
# Review GitHub PR and auto-generate a description (optionally post it)
|
|
98
|
+
drs review-pr --owner octocat --repo hello-world --pr 456 --describe
|
|
99
|
+
drs review-pr --owner octocat --repo hello-world --pr 456 --describe --post-description
|
|
100
|
+
|
|
101
|
+
# Override base branch used for diff hints
|
|
102
|
+
drs review-pr --owner octocat --repo hello-world --pr 456 --base-branch release/2026-01
|
|
103
|
+
|
|
104
|
+
# Generate review JSON first, then post comments after manual review
|
|
105
|
+
drs review-pr --owner octocat --repo hello-world --pr 456 -o review.json
|
|
106
|
+
drs post-comments --input review.json --owner octocat --repo hello-world --pr 456
|
|
107
|
+
|
|
108
|
+
# Show the diff context passed to agents
|
|
109
|
+
drs show-changes --owner octocat --repo hello-world --pr 456
|
|
110
|
+
|
|
111
|
+
# Show diff context for a single file
|
|
112
|
+
drs show-changes --owner octocat --repo hello-world --pr 456 --file src/app.ts
|
|
113
|
+
|
|
114
|
+
# Show diff context using a specific base branch
|
|
115
|
+
drs show-changes --owner octocat --repo hello-world --pr 456 --base-branch release/2026-01
|
|
116
|
+
|
|
117
|
+
# Generate PR/MR descriptions on demand
|
|
118
|
+
drs describe-pr --owner octocat --repo hello-world --pr 456
|
|
119
|
+
drs describe-pr --owner octocat --repo hello-world --pr 456 --post-description
|
|
120
|
+
drs describe-mr --project my-org/my-repo --mr 123
|
|
121
|
+
drs describe-mr --project my-org/my-repo --mr 123 --post-description
|
|
89
122
|
```
|
|
90
123
|
|
|
91
124
|
### Mode 2: GitLab CI/CD
|
|
@@ -141,20 +174,6 @@ DRS includes a **secure, pre-configured workflow** at `.github/workflows/pr-revi
|
|
|
141
174
|
- Maintainer workflow
|
|
142
175
|
- Attack prevention strategies
|
|
143
176
|
|
|
144
|
-
### Mode 4: Webhook Server
|
|
145
|
-
|
|
146
|
-
Deploy as a standalone service:
|
|
147
|
-
|
|
148
|
-
```bash
|
|
149
|
-
# Using Docker Compose
|
|
150
|
-
cd examples
|
|
151
|
-
docker-compose up -d
|
|
152
|
-
|
|
153
|
-
# Configure webhooks:
|
|
154
|
-
# GitLab: http://your-server:8080/webhook/gitlab (Merge request events, Comments)
|
|
155
|
-
# GitHub: http://your-server:8080/webhook/github (Pull request events)
|
|
156
|
-
```
|
|
157
|
-
|
|
158
177
|
## GitLab Code Quality Reports
|
|
159
178
|
|
|
160
179
|
DRS can generate GitLab-compatible code quality reports that integrate seamlessly with GitLab CI/CD. This provides an alternative (or complement) to inline MR comments.
|
|
@@ -294,9 +313,6 @@ DRS uses OpenCode SDK with markdown-based agent definitions:
|
|
|
294
313
|
```
|
|
295
314
|
.opencode/
|
|
296
315
|
āāā agent/
|
|
297
|
-
ā āāā gitlab-reviewer.md # GitLab MR orchestrator
|
|
298
|
-
ā āāā github-reviewer.md # GitHub PR orchestrator
|
|
299
|
-
ā āāā local-reviewer.md # Local diff reviewer
|
|
300
316
|
ā āāā review/
|
|
301
317
|
ā āāā security.md # Security specialist
|
|
302
318
|
ā āāā quality.md # Code quality expert
|
|
@@ -313,8 +329,8 @@ Create custom agents in your project:
|
|
|
313
329
|
|
|
314
330
|
```bash
|
|
315
331
|
# Create custom security agent
|
|
316
|
-
mkdir -p .drs/agents
|
|
317
|
-
cat > .drs/agents/security.md << 'EOF'
|
|
332
|
+
mkdir -p .drs/agents/security
|
|
333
|
+
cat > .drs/agents/security/agent.md << 'EOF'
|
|
318
334
|
---
|
|
319
335
|
description: Custom security reviewer
|
|
320
336
|
model: opencode/claude-sonnet-4-5
|
|
@@ -339,8 +355,19 @@ review:
|
|
|
339
355
|
ignorePatterns:
|
|
340
356
|
- "*.test.ts"
|
|
341
357
|
- "*.md"
|
|
358
|
+
describe:
|
|
359
|
+
enabled: true
|
|
360
|
+
postDescription: false
|
|
361
|
+
|
|
362
|
+
describe:
|
|
363
|
+
model: opencode/glm-4.7-free
|
|
342
364
|
```
|
|
343
365
|
|
|
366
|
+
Notes:
|
|
367
|
+
- `review.describe` controls auto-description when running `review-mr` or `review-pr`.
|
|
368
|
+
- CLI flags override config: `--describe` / `--skip-describe` and `--post-description` / `--skip-post-description`.
|
|
369
|
+
- `describe.model` is used by `describe-mr`/`describe-pr` and by review-driven descriptions.
|
|
370
|
+
|
|
344
371
|
## Review Domains
|
|
345
372
|
|
|
346
373
|
### Security Analysis
|
package/dist/ci/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/ci/runner.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAgBnD;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/ci/runner.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,aAAa,CAgBnD;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CA4DjD;AAED;;GAEG;AACH,wBAAgB,IAAI,IAAI,OAAO,CAE9B"}
|
package/dist/ci/runner.js
CHANGED
|
@@ -62,6 +62,8 @@ export async function runCIReview() {
|
|
|
62
62
|
projectId: env.projectId,
|
|
63
63
|
mrIid: env.mrIid,
|
|
64
64
|
postComments: true, // Always post comments in CI
|
|
65
|
+
describe: config.review.describe?.enabled ?? false,
|
|
66
|
+
postDescription: config.review.describe?.postDescription ?? false,
|
|
65
67
|
});
|
|
66
68
|
console.log(chalk.green.bold('\nā Review complete\n'));
|
|
67
69
|
}
|
package/dist/ci/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/ci/runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAW/C;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,sBAAsB;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,EAAE,CAAC;QACrC,OAAO;YACL,QAAQ,EAAE,QAAQ;YAClB,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;YACpC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB;gBACrC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,EAAE,CAAC;gBAChD,CAAC,CAAC,SAAS;YACb,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mCAAmC;YAC7D,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,mCAAmC;YAC7D,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;SACrC,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC,CAAC;IAEnE,qBAAqB;IACrB,MAAM,GAAG,GAAG,mBAAmB,EAAE,CAAC;IAElC,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CA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O,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAChD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI;IAClB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;AACnF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type DRSConfig } from '../lib/config.js';
|
|
2
|
+
export interface DescribeMROptions {
|
|
3
|
+
projectId: string;
|
|
4
|
+
mrIid: number;
|
|
5
|
+
postDescription?: boolean;
|
|
6
|
+
outputPath?: string;
|
|
7
|
+
jsonOutput?: boolean;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function describeMR(config: DRSConfig, options: DescribeMROptions): Promise<void>;
|
|
11
|
+
//# sourceMappingURL=describe-mr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-mr.d.ts","sourceRoot":"","sources":["../../src/cli/describe-mr.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAe7E,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,iBA4H7E"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { getDescriberModelOverride } from '../lib/config.js';
|
|
3
|
+
import { createGitLabClient } from '../gitlab/client.js';
|
|
4
|
+
import { GitLabPlatformAdapter } from '../gitlab/platform-adapter.js';
|
|
5
|
+
import { createOpencodeClientInstance } from '../opencode/client.js';
|
|
6
|
+
import { buildDescribeInstructions } from '../lib/describe-core.js';
|
|
7
|
+
import { loadGlobalContext } from '../lib/context-loader.js';
|
|
8
|
+
import { displayDescription, normalizeDescription, postDescription, } from '../lib/description-formatter.js';
|
|
9
|
+
import { compressFilesWithDiffs, formatCompressionSummary } from '../lib/context-compression.js';
|
|
10
|
+
import { parseDescribeOutput } from '../lib/describe-parser.js';
|
|
11
|
+
export async function describeMR(config, options) {
|
|
12
|
+
console.log(chalk.bold.blue('\nš Generating MR Description\n'));
|
|
13
|
+
// Initialize GitLab client
|
|
14
|
+
const gitlabClient = createGitLabClient();
|
|
15
|
+
const platformAdapter = new GitLabPlatformAdapter(gitlabClient);
|
|
16
|
+
// Fetch MR files
|
|
17
|
+
console.log(chalk.dim(`Fetching MR !${options.mrIid} from project ${options.projectId}...`));
|
|
18
|
+
const files = await platformAdapter.getChangedFiles(options.projectId, options.mrIid);
|
|
19
|
+
console.log(chalk.dim(`Found ${files.length} changed files\n`));
|
|
20
|
+
// Build context for the describer agent
|
|
21
|
+
const label = `MR !${options.mrIid}`;
|
|
22
|
+
const filesWithDiffs = files.map((file) => ({
|
|
23
|
+
filename: file.filename,
|
|
24
|
+
patch: file.patch,
|
|
25
|
+
}));
|
|
26
|
+
const compression = compressFilesWithDiffs(filesWithDiffs, config.contextCompression);
|
|
27
|
+
const compressionSummary = formatCompressionSummary(compression);
|
|
28
|
+
if (compressionSummary) {
|
|
29
|
+
console.log(chalk.yellow('ā Diff content trimmed to fit token budget.\n'));
|
|
30
|
+
}
|
|
31
|
+
const includeProjectContext = config.describe?.includeProjectContext ?? true;
|
|
32
|
+
const projectContext = includeProjectContext ? loadGlobalContext() : null;
|
|
33
|
+
const instructions = buildDescribeInstructions(label, compression.files, compressionSummary, projectContext ?? undefined);
|
|
34
|
+
if (options.debug) {
|
|
35
|
+
console.log(chalk.yellow('\n=== Agent Instructions ==='));
|
|
36
|
+
console.log(instructions);
|
|
37
|
+
console.log(chalk.yellow('=== End Instructions ===\n'));
|
|
38
|
+
}
|
|
39
|
+
// Initialize OpenCode client with model overrides
|
|
40
|
+
const modelOverrides = getDescriberModelOverride(config);
|
|
41
|
+
const opencode = await createOpencodeClientInstance({
|
|
42
|
+
baseUrl: config.opencode.serverUrl ?? undefined,
|
|
43
|
+
directory: process.cwd(),
|
|
44
|
+
modelOverrides,
|
|
45
|
+
provider: config.opencode.provider,
|
|
46
|
+
debug: options.debug,
|
|
47
|
+
});
|
|
48
|
+
try {
|
|
49
|
+
console.log(chalk.dim('Running MR describer agent...\n'));
|
|
50
|
+
// Run the describer agent
|
|
51
|
+
const session = await opencode.createSession({
|
|
52
|
+
agent: 'describe/pr-describer',
|
|
53
|
+
message: instructions,
|
|
54
|
+
});
|
|
55
|
+
// Collect all assistant messages from the session
|
|
56
|
+
let fullResponse = '';
|
|
57
|
+
for await (const message of opencode.streamMessages(session.id)) {
|
|
58
|
+
if (message.role === 'assistant') {
|
|
59
|
+
fullResponse += message.content;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Parse the JSON output from the agent
|
|
63
|
+
let description;
|
|
64
|
+
try {
|
|
65
|
+
description = await parseDescribeOutput(process.cwd(), options.debug, fullResponse);
|
|
66
|
+
}
|
|
67
|
+
catch (parseError) {
|
|
68
|
+
console.error(chalk.red('Failed to parse agent output as JSON'));
|
|
69
|
+
console.log(chalk.dim('Agent output:'), fullResponse);
|
|
70
|
+
const reason = parseError instanceof Error ? `: ${parseError.message}` : '';
|
|
71
|
+
throw new Error(`Agent did not return valid JSON output${reason}`);
|
|
72
|
+
}
|
|
73
|
+
let normalizedDescription;
|
|
74
|
+
try {
|
|
75
|
+
normalizedDescription = normalizeDescription(description);
|
|
76
|
+
}
|
|
77
|
+
catch (validationError) {
|
|
78
|
+
console.error(chalk.red('Agent output did not match expected description schema'));
|
|
79
|
+
console.log(chalk.dim('Agent output:'), fullResponse);
|
|
80
|
+
throw validationError;
|
|
81
|
+
}
|
|
82
|
+
// Display the description
|
|
83
|
+
displayDescription(normalizedDescription, 'MR');
|
|
84
|
+
// Save to JSON file if requested
|
|
85
|
+
if (options.outputPath) {
|
|
86
|
+
const fs = await import('fs/promises');
|
|
87
|
+
await fs.writeFile(options.outputPath, JSON.stringify(normalizedDescription, null, 2), 'utf-8');
|
|
88
|
+
console.log(chalk.green(`\nā Description saved to ${options.outputPath}`));
|
|
89
|
+
}
|
|
90
|
+
// Output JSON if requested
|
|
91
|
+
if (options.jsonOutput) {
|
|
92
|
+
console.log('\n' + JSON.stringify(normalizedDescription, null, 2));
|
|
93
|
+
}
|
|
94
|
+
// Post description to MR if requested
|
|
95
|
+
if (options.postDescription) {
|
|
96
|
+
await postDescription(platformAdapter, options.projectId, options.mrIid, normalizedDescription, 'MR');
|
|
97
|
+
}
|
|
98
|
+
console.log(chalk.green('\nā MR description generated successfully\n'));
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
await opencode.shutdown();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=describe-mr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-mr.js","sourceRoot":"","sources":["../../src/cli/describe-mr.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAkB,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB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4
|
+
repo: string;
|
|
5
|
+
prNumber: number;
|
|
6
|
+
postDescription?: boolean;
|
|
7
|
+
outputPath?: string;
|
|
8
|
+
jsonOutput?: boolean;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function describePR(config: DRSConfig, options: DescribePROptions): Promise<void>;
|
|
12
|
+
//# sourceMappingURL=describe-pr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe-pr.d.ts","sourceRoot":"","sources":["../../src/cli/describe-pr.ts"],"names":[],"mappings":"AACA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAe7E,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,iBA+H7E"}
|