agentic-sdlc-mcp 1.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/.env.example +20 -0
- package/README.md +335 -0
- package/dist/config.d.ts +22 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +39 -0
- package/dist/config.js.map +1 -0
- package/dist/github/client.d.ts +28 -0
- package/dist/github/client.d.ts.map +1 -0
- package/dist/github/client.js +90 -0
- package/dist/github/client.js.map +1 -0
- package/dist/github/context.d.ts +47 -0
- package/dist/github/context.d.ts.map +1 -0
- package/dist/github/context.js +123 -0
- package/dist/github/context.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +92 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/index.d.ts +9 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +315 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/tools/agent-handoff.d.ts +100 -0
- package/dist/tools/agent-handoff.d.ts.map +1 -0
- package/dist/tools/agent-handoff.js +196 -0
- package/dist/tools/agent-handoff.js.map +1 -0
- package/dist/tools/create-issue-set.d.ts +90 -0
- package/dist/tools/create-issue-set.d.ts.map +1 -0
- package/dist/tools/create-issue-set.js +142 -0
- package/dist/tools/create-issue-set.js.map +1 -0
- package/dist/tools/create-pr-summary.d.ts +60 -0
- package/dist/tools/create-pr-summary.d.ts.map +1 -0
- package/dist/tools/create-pr-summary.js +179 -0
- package/dist/tools/create-pr-summary.js.map +1 -0
- package/dist/tools/plan-from-context.d.ts +71 -0
- package/dist/tools/plan-from-context.d.ts.map +1 -0
- package/dist/tools/plan-from-context.js +201 -0
- package/dist/tools/plan-from-context.js.map +1 -0
- package/dist/tools/prepare-work-item.d.ts +90 -0
- package/dist/tools/prepare-work-item.d.ts.map +1 -0
- package/dist/tools/prepare-work-item.js +250 -0
- package/dist/tools/prepare-work-item.js.map +1 -0
- package/dist/tools/quality-gate-status.d.ts +175 -0
- package/dist/tools/quality-gate-status.d.ts.map +1 -0
- package/dist/tools/quality-gate-status.js +200 -0
- package/dist/tools/quality-gate-status.js.map +1 -0
- package/dist/tools/release-readiness.d.ts +55 -0
- package/dist/tools/release-readiness.d.ts.map +1 -0
- package/dist/tools/release-readiness.js +202 -0
- package/dist/tools/release-readiness.js.map +1 -0
- package/dist/tools/repo-context.d.ts +62 -0
- package/dist/tools/repo-context.d.ts.map +1 -0
- package/dist/tools/repo-context.js +183 -0
- package/dist/tools/repo-context.js.map +1 -0
- package/dist/tools/review-pr.d.ts +104 -0
- package/dist/tools/review-pr.d.ts.map +1 -0
- package/dist/tools/review-pr.js +378 -0
- package/dist/tools/review-pr.js.map +1 -0
- package/dist/tools/security-triage.d.ts +94 -0
- package/dist/tools/security-triage.d.ts.map +1 -0
- package/dist/tools/security-triage.js +228 -0
- package/dist/tools/security-triage.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool: review_pr_against_standard
|
|
3
|
+
*
|
|
4
|
+
* Core logic extracted as `generateFindings` and `handleReviewPr` for testing.
|
|
5
|
+
* security-focused mode inspects actual patch lines for suspicious patterns.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
import { resolveRepo, getOctokit, paginateAll, handleGitHubError } from "../github/client.js";
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Schema
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
export const ReviewPrInputSchema = z.object({
|
|
13
|
+
owner: z.string().optional().describe("GitHub owner. Falls back to GITHUB_OWNER."),
|
|
14
|
+
repo: z.string().optional().describe("GitHub repo. Falls back to GITHUB_REPO."),
|
|
15
|
+
pullNumber: z.number().int().positive().describe("The pull request number to review."),
|
|
16
|
+
standard: z
|
|
17
|
+
.enum(["basic", "strict", "security-focused"])
|
|
18
|
+
.default("basic")
|
|
19
|
+
.describe("Review standard: 'basic', 'strict', or 'security-focused'."),
|
|
20
|
+
});
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Output schema
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
export const ReviewPrOutputSchema = {
|
|
25
|
+
pullNumber: z.number().int(),
|
|
26
|
+
standard: z.string(),
|
|
27
|
+
conclusion: z.enum(["pass", "needs_changes", "risky_but_acceptable"]),
|
|
28
|
+
findings: z.array(z.object({
|
|
29
|
+
severity: z.enum(["critical", "high", "medium", "low", "info"]),
|
|
30
|
+
category: z.string(),
|
|
31
|
+
description: z.string(),
|
|
32
|
+
suggestion: z.string().optional(),
|
|
33
|
+
})),
|
|
34
|
+
missingTests: z.array(z.string()),
|
|
35
|
+
securityConcerns: z.array(z.string()),
|
|
36
|
+
docsImpact: z.string(),
|
|
37
|
+
releaseRisk: z.string(),
|
|
38
|
+
};
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Pure helpers (exported for testing)
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
const SEVERITY_ORDER = ["critical", "high", "medium", "low", "info"];
|
|
43
|
+
export function sortFindings(findings) {
|
|
44
|
+
return [...findings].sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity));
|
|
45
|
+
}
|
|
46
|
+
export function severityIcon(s) {
|
|
47
|
+
const icons = {
|
|
48
|
+
critical: "\u{1F534}",
|
|
49
|
+
high: "\u{1F7E0}",
|
|
50
|
+
medium: "\u{1F7E1}",
|
|
51
|
+
low: "\u{1F535}",
|
|
52
|
+
info: "⚪",
|
|
53
|
+
};
|
|
54
|
+
return icons[s] ?? "⚪";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Secret-like patterns to flag in added patch lines (conservative).
|
|
58
|
+
* Only matches lines that look like an assignment, not just the word.
|
|
59
|
+
*/
|
|
60
|
+
const SUSPICIOUS_PATTERNS = [
|
|
61
|
+
{ name: "hardcoded password assignment", pattern: /password\s*[:=]\s*['"`][^'"`\s]{6,}/i },
|
|
62
|
+
{ name: "hardcoded API key assignment", pattern: /api[_-]?key\s*[:=]\s*['"`][^'"`\s]{6,}/i },
|
|
63
|
+
{ name: "hardcoded secret assignment", pattern: /secret\s*[:=]\s*['"`][^'"`\s]{6,}/i },
|
|
64
|
+
{ name: "hardcoded token assignment", pattern: /token\s*[:=]\s*['"`][^'"`\s]{6,}/i },
|
|
65
|
+
{ name: "AWS access key ID pattern", pattern: /AKIA[0-9A-Z]{16}/ },
|
|
66
|
+
];
|
|
67
|
+
/** Check added lines in a patch for suspicious secret-like patterns. */
|
|
68
|
+
export function scanPatchForSecrets(filename, patch) {
|
|
69
|
+
if (!patch)
|
|
70
|
+
return [];
|
|
71
|
+
const findings = [];
|
|
72
|
+
const addedLines = patch.split("\n").filter((l) => l.startsWith("+") && !l.startsWith("+++"));
|
|
73
|
+
for (const line of addedLines) {
|
|
74
|
+
for (const { name, pattern } of SUSPICIOUS_PATTERNS) {
|
|
75
|
+
if (pattern.test(line)) {
|
|
76
|
+
findings.push({
|
|
77
|
+
severity: "high",
|
|
78
|
+
category: "Security",
|
|
79
|
+
description: `Possible ${name} in \`${filename}\` -- needs manual review.`,
|
|
80
|
+
suggestion: "If this is a real credential, rotate it immediately and use an environment variable instead.",
|
|
81
|
+
});
|
|
82
|
+
break; // one finding per line is enough
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return findings;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Classify PR files into categories.
|
|
90
|
+
*/
|
|
91
|
+
export function classifyFiles(files) {
|
|
92
|
+
const testFiles = files.filter((f) => f.filename.includes("/test") ||
|
|
93
|
+
f.filename.includes("/spec") ||
|
|
94
|
+
f.filename.includes("__tests__") ||
|
|
95
|
+
/\.(test|spec)\.[jt]sx?$/.test(f.filename));
|
|
96
|
+
const lockFiles = files.filter((f) => [
|
|
97
|
+
"package-lock.json",
|
|
98
|
+
"yarn.lock",
|
|
99
|
+
"pnpm-lock.yaml",
|
|
100
|
+
"Cargo.lock",
|
|
101
|
+
"requirements.txt",
|
|
102
|
+
"poetry.lock",
|
|
103
|
+
"Pipfile.lock",
|
|
104
|
+
"go.sum",
|
|
105
|
+
].includes(f.filename.split("/").pop() ?? ""));
|
|
106
|
+
const configFiles = files.filter((f) => f.filename.endsWith(".json") ||
|
|
107
|
+
f.filename.endsWith(".yml") ||
|
|
108
|
+
f.filename.endsWith(".yaml") ||
|
|
109
|
+
f.filename.endsWith(".toml") ||
|
|
110
|
+
/\.env(\.|$)/.test(f.filename));
|
|
111
|
+
const dotEnvFiles = files.filter((f) => /\.env(\.|$)/.test(f.filename));
|
|
112
|
+
const docFiles = files.filter((f) => f.filename.endsWith(".md") ||
|
|
113
|
+
f.filename.endsWith(".rst") ||
|
|
114
|
+
f.filename.startsWith("docs/"));
|
|
115
|
+
const distFiles = files.filter((f) => f.filename.startsWith("dist/") ||
|
|
116
|
+
f.filename.startsWith("build/") ||
|
|
117
|
+
f.filename.endsWith(".min.js") ||
|
|
118
|
+
f.filename.endsWith(".min.css"));
|
|
119
|
+
const snapshotOnlyTestFiles = testFiles.filter((f) => f.filename.includes("__snapshots__") || f.filename.endsWith(".snap"));
|
|
120
|
+
const srcFiles = files.filter((f) => !testFiles.includes(f) && !docFiles.includes(f) && !lockFiles.includes(f));
|
|
121
|
+
return {
|
|
122
|
+
testFiles,
|
|
123
|
+
configFiles,
|
|
124
|
+
docFiles,
|
|
125
|
+
lockFiles,
|
|
126
|
+
dotEnvFiles,
|
|
127
|
+
distFiles,
|
|
128
|
+
snapshotOnlyTestFiles,
|
|
129
|
+
srcFiles,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Generate findings for a PR. Pure function -- no I/O.
|
|
134
|
+
*/
|
|
135
|
+
export function generateFindings(pr, files, standard) {
|
|
136
|
+
const findings = [];
|
|
137
|
+
const { testFiles, configFiles, docFiles, lockFiles, dotEnvFiles, distFiles, snapshotOnlyTestFiles, srcFiles, } = classifyFiles(files);
|
|
138
|
+
const totalLines = files.reduce((s, f) => s + f.additions + f.deletions, 0);
|
|
139
|
+
const hasLogicTests = testFiles.length > 0 && testFiles.some((f) => !snapshotOnlyTestFiles.includes(f));
|
|
140
|
+
const hasAnyTests = testFiles.length > 0;
|
|
141
|
+
// --- Basic checks ---
|
|
142
|
+
if (!pr.body || pr.body.trim().length < 20) {
|
|
143
|
+
findings.push({
|
|
144
|
+
severity: "high",
|
|
145
|
+
category: "Documentation",
|
|
146
|
+
description: "PR has no meaningful description.",
|
|
147
|
+
suggestion: "Add a description explaining the WHY, not just WHAT changed.",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
if (!hasAnyTests) {
|
|
151
|
+
findings.push({
|
|
152
|
+
severity: "high",
|
|
153
|
+
category: "Testing",
|
|
154
|
+
description: "No test files detected in this PR.",
|
|
155
|
+
suggestion: "Add or update unit/integration tests for the changed code.",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else if (!hasLogicTests && snapshotOnlyTestFiles.length > 0) {
|
|
159
|
+
findings.push({
|
|
160
|
+
severity: "medium",
|
|
161
|
+
category: "Testing",
|
|
162
|
+
description: "Only snapshot test files changed -- no logic test changes detected.",
|
|
163
|
+
suggestion: "Ensure snapshot updates are intentional and logic tests cover the changed behaviour.",
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (pr.draft) {
|
|
167
|
+
findings.push({
|
|
168
|
+
severity: "info",
|
|
169
|
+
category: "Status",
|
|
170
|
+
description: "PR is still marked as a draft.",
|
|
171
|
+
suggestion: "Mark as ready for review when implementation is complete.",
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (pr.commits > 20) {
|
|
175
|
+
findings.push({
|
|
176
|
+
severity: "low",
|
|
177
|
+
category: "Hygiene",
|
|
178
|
+
description: `PR has ${pr.commits} commits -- consider squashing for cleaner history.`,
|
|
179
|
+
suggestion: "Use 'git rebase -i' to squash related commits.",
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
// --- Strict checks ---
|
|
183
|
+
if (standard === "strict" || standard === "security-focused") {
|
|
184
|
+
if (totalLines > 800) {
|
|
185
|
+
findings.push({
|
|
186
|
+
severity: "medium",
|
|
187
|
+
category: "Size",
|
|
188
|
+
description: `Large PR: ${totalLines} changed lines. Harder to review thoroughly.`,
|
|
189
|
+
suggestion: "Consider splitting into smaller, focused PRs.",
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (srcFiles.length > 5 && docFiles.length === 0) {
|
|
193
|
+
findings.push({
|
|
194
|
+
severity: "low",
|
|
195
|
+
category: "Documentation",
|
|
196
|
+
description: "No documentation files updated despite significant source changes.",
|
|
197
|
+
suggestion: "Update README or docs/ if any public API or behaviour changed.",
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// --- Security-focused checks ---
|
|
202
|
+
if (standard === "security-focused") {
|
|
203
|
+
if (dotEnvFiles.length > 0) {
|
|
204
|
+
findings.push({
|
|
205
|
+
severity: "critical",
|
|
206
|
+
category: "Security",
|
|
207
|
+
description: `.env file(s) modified: ${dotEnvFiles.map((f) => f.filename).join(", ")}`,
|
|
208
|
+
suggestion: "Verify NO real credentials are committed. " +
|
|
209
|
+
".env files should be in .gitignore. If secrets are present, rotate them immediately.",
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
if (lockFiles.length > 0) {
|
|
213
|
+
findings.push({
|
|
214
|
+
severity: "medium",
|
|
215
|
+
category: "Security",
|
|
216
|
+
description: `Dependency lockfile changed: ${lockFiles.map((f) => f.filename).join(", ")}`,
|
|
217
|
+
suggestion: "Run 'npm audit' / 'pip-audit' / 'cargo audit' to check for known vulnerabilities.",
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
const nonLockConfigFiles = configFiles.filter((f) => !lockFiles.includes(f) && !dotEnvFiles.includes(f));
|
|
221
|
+
if (nonLockConfigFiles.length > 0) {
|
|
222
|
+
findings.push({
|
|
223
|
+
severity: "low",
|
|
224
|
+
category: "Security",
|
|
225
|
+
description: `Config files changed: ${nonLockConfigFiles.map((f) => f.filename).join(", ")}`,
|
|
226
|
+
suggestion: "Verify no environment-specific values or secrets are hardcoded.",
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (distFiles.length > 0) {
|
|
230
|
+
findings.push({
|
|
231
|
+
severity: "medium",
|
|
232
|
+
category: "Security",
|
|
233
|
+
description: `Compiled/generated files included: ${distFiles.map((f) => f.filename).join(", ")}`,
|
|
234
|
+
suggestion: "Dist files in PRs are unusual -- confirm this is intentional. " +
|
|
235
|
+
"Generated files can hide malicious code and should usually be gitignored.",
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
// Scan patch content for secret-like patterns
|
|
239
|
+
for (const file of files) {
|
|
240
|
+
if (file.patch) {
|
|
241
|
+
const secretFindings = scanPatchForSecrets(file.filename, file.patch);
|
|
242
|
+
findings.push(...secretFindings);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return findings;
|
|
247
|
+
}
|
|
248
|
+
// ---------------------------------------------------------------------------
|
|
249
|
+
// Core handler (exported for testing)
|
|
250
|
+
// ---------------------------------------------------------------------------
|
|
251
|
+
export async function handleReviewPr(params, ref, octokit) {
|
|
252
|
+
const { data: pr } = await octokit.pulls.get({
|
|
253
|
+
owner: ref.owner,
|
|
254
|
+
repo: ref.repo,
|
|
255
|
+
pull_number: params.pullNumber,
|
|
256
|
+
});
|
|
257
|
+
const rawFiles = await paginateAll((page, perPage) => octokit.pulls
|
|
258
|
+
.listFiles({
|
|
259
|
+
owner: ref.owner,
|
|
260
|
+
repo: ref.repo,
|
|
261
|
+
pull_number: params.pullNumber,
|
|
262
|
+
per_page: perPage,
|
|
263
|
+
page,
|
|
264
|
+
})
|
|
265
|
+
.then((r) => r.data), 300);
|
|
266
|
+
const files = rawFiles.map((f) => ({
|
|
267
|
+
filename: f.filename,
|
|
268
|
+
status: f.status,
|
|
269
|
+
additions: f.additions,
|
|
270
|
+
deletions: f.deletions,
|
|
271
|
+
patch: f.patch,
|
|
272
|
+
}));
|
|
273
|
+
const prMeta = {
|
|
274
|
+
number: pr.number,
|
|
275
|
+
title: pr.title,
|
|
276
|
+
body: pr.body ?? null,
|
|
277
|
+
draft: pr.draft ?? false,
|
|
278
|
+
commits: pr.commits,
|
|
279
|
+
};
|
|
280
|
+
const rawFindings = generateFindings(prMeta, files, params.standard);
|
|
281
|
+
const sorted = sortFindings(rawFindings);
|
|
282
|
+
const hasTests = files.some((f) => f.filename.includes("/test") ||
|
|
283
|
+
f.filename.includes("/spec") ||
|
|
284
|
+
f.filename.includes("__tests__") ||
|
|
285
|
+
/\.(test|spec)\.[jt]sx?$/.test(f.filename));
|
|
286
|
+
const totalLines = files.reduce((s, f) => s + f.additions + f.deletions, 0);
|
|
287
|
+
const critical = sorted.filter((f) => f.severity === "critical");
|
|
288
|
+
const high = sorted.filter((f) => f.severity === "high");
|
|
289
|
+
const medium = sorted.filter((f) => f.severity === "medium");
|
|
290
|
+
const conclusion = critical.length > 0 || high.length > 0
|
|
291
|
+
? "needs_changes"
|
|
292
|
+
: medium.length > 0
|
|
293
|
+
? "risky_but_acceptable"
|
|
294
|
+
: "pass";
|
|
295
|
+
const conclusionLabel = conclusion === "pass"
|
|
296
|
+
? "PASS"
|
|
297
|
+
: conclusion === "needs_changes"
|
|
298
|
+
? "NEEDS CHANGES"
|
|
299
|
+
: "RISKY BUT ACCEPTABLE";
|
|
300
|
+
const structured = {
|
|
301
|
+
pullNumber: pr.number,
|
|
302
|
+
title: pr.title,
|
|
303
|
+
standard: params.standard,
|
|
304
|
+
conclusion,
|
|
305
|
+
findings: sorted,
|
|
306
|
+
hasTests,
|
|
307
|
+
totalChangedLines: totalLines,
|
|
308
|
+
};
|
|
309
|
+
const lines = [
|
|
310
|
+
`# PR Review: #${pr.number} -- ${pr.title}`,
|
|
311
|
+
"",
|
|
312
|
+
`**Standard:** ${params.standard}`,
|
|
313
|
+
`**Conclusion:** ${conclusionLabel}`,
|
|
314
|
+
`**Findings:** ${sorted.length} total (${critical.length} critical, ${high.length} high, ${medium.length} medium)`,
|
|
315
|
+
"",
|
|
316
|
+
"## Findings",
|
|
317
|
+
];
|
|
318
|
+
if (sorted.length === 0) {
|
|
319
|
+
lines.push("", "No findings -- looks good!");
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
for (const f of sorted) {
|
|
323
|
+
lines.push("", `### ${severityIcon(f.severity)} [${f.severity.toUpperCase()}] ${f.category}: ${f.description}`, f.suggestion ? `> Suggestion: ${f.suggestion}` : "");
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
lines.push("", "## Test Coverage", hasTests ? "Tests included." : "No test files detected in this PR.", "", "## Release Risk", conclusion === "pass"
|
|
327
|
+
? "Low risk -- safe to merge after review."
|
|
328
|
+
: conclusion === "risky_but_acceptable"
|
|
329
|
+
? "Moderate risk -- address medium findings before release."
|
|
330
|
+
: "High risk -- must fix critical/high findings before merging.", "", "## Conclusion", conclusionLabel);
|
|
331
|
+
return { text: lines.join("\n"), structured };
|
|
332
|
+
}
|
|
333
|
+
// ---------------------------------------------------------------------------
|
|
334
|
+
// Registration
|
|
335
|
+
// ---------------------------------------------------------------------------
|
|
336
|
+
export function registerReviewPrTool(server) {
|
|
337
|
+
server.registerTool("review_pr_against_standard", {
|
|
338
|
+
title: "Review PR Against SDLC Standard",
|
|
339
|
+
description: `Review a pull request against Agentic SDLC standards.
|
|
340
|
+
|
|
341
|
+
Standards:
|
|
342
|
+
- basic: Core checks (tests, description, draft status, commit count)
|
|
343
|
+
- strict: basic + large diff detection, missing docs
|
|
344
|
+
- security-focused: strict + patch scanning for secret patterns, .env files, lockfile changes, dist files
|
|
345
|
+
|
|
346
|
+
Args:
|
|
347
|
+
- owner, repo: Repository coordinates.
|
|
348
|
+
- pullNumber (number): The PR to review.
|
|
349
|
+
- standard: "basic" | "strict" | "security-focused". Default: "basic".
|
|
350
|
+
|
|
351
|
+
Returns: Sorted findings by severity, test coverage signal, release risk, and conclusion.`,
|
|
352
|
+
inputSchema: ReviewPrInputSchema,
|
|
353
|
+
outputSchema: ReviewPrOutputSchema,
|
|
354
|
+
annotations: {
|
|
355
|
+
readOnlyHint: true,
|
|
356
|
+
destructiveHint: false,
|
|
357
|
+
idempotentHint: true,
|
|
358
|
+
openWorldHint: true,
|
|
359
|
+
},
|
|
360
|
+
}, async (params) => {
|
|
361
|
+
try {
|
|
362
|
+
const ref = resolveRepo(params.owner, params.repo);
|
|
363
|
+
const octokit = getOctokit();
|
|
364
|
+
const { text, structured } = await handleReviewPr(params, ref, octokit);
|
|
365
|
+
return {
|
|
366
|
+
content: [{ type: "text", text }],
|
|
367
|
+
structuredContent: structured,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
return {
|
|
372
|
+
isError: true,
|
|
373
|
+
content: [{ type: "text", text: handleGitHubError(error) }],
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
//# sourceMappingURL=review-pr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review-pr.js","sourceRoot":"","sources":["../../src/tools/review-pr.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAI9F,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,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EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,EAAE,CAAC;aAC5D,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool: security_triage
|
|
3
|
+
*
|
|
4
|
+
* Handler extracted as `handleSecurityTriage` for unit testing.
|
|
5
|
+
* Uses paginateAll for all three alert endpoints.
|
|
6
|
+
*/
|
|
7
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import type { SecurityAlert, Severity, RepoRef } from "../types.js";
|
|
10
|
+
import type { Octokit } from "@octokit/rest";
|
|
11
|
+
export declare const SecurityTriageInputSchema: z.ZodObject<{
|
|
12
|
+
owner: z.ZodOptional<z.ZodString>;
|
|
13
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
14
|
+
includeCodeScanning: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
includeDependabot: z.ZodDefault<z.ZodBoolean>;
|
|
16
|
+
includeSecretScanning: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
includeCodeScanning: boolean;
|
|
19
|
+
includeDependabot: boolean;
|
|
20
|
+
includeSecretScanning: boolean;
|
|
21
|
+
owner?: string | undefined;
|
|
22
|
+
repo?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
owner?: string | undefined;
|
|
25
|
+
repo?: string | undefined;
|
|
26
|
+
includeCodeScanning?: boolean | undefined;
|
|
27
|
+
includeDependabot?: boolean | undefined;
|
|
28
|
+
includeSecretScanning?: boolean | undefined;
|
|
29
|
+
}>;
|
|
30
|
+
export type SecurityTriageInput = z.infer<typeof SecurityTriageInputSchema>;
|
|
31
|
+
export declare const SecurityTriageOutputSchema: {
|
|
32
|
+
repo: z.ZodString;
|
|
33
|
+
alerts: z.ZodArray<z.ZodObject<{
|
|
34
|
+
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
35
|
+
severity: z.ZodEnum<["critical", "high", "medium", "low", "info"]>;
|
|
36
|
+
summary: z.ZodString;
|
|
37
|
+
state: z.ZodString;
|
|
38
|
+
url: z.ZodNullable<z.ZodString>;
|
|
39
|
+
fixedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
+
dismissedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
state: string;
|
|
43
|
+
url: string | null;
|
|
44
|
+
summary: string;
|
|
45
|
+
severity: "critical" | "high" | "medium" | "low" | "info";
|
|
46
|
+
id: string | number;
|
|
47
|
+
fixedAt?: string | null | undefined;
|
|
48
|
+
dismissedAt?: string | null | undefined;
|
|
49
|
+
}, {
|
|
50
|
+
state: string;
|
|
51
|
+
url: string | null;
|
|
52
|
+
summary: string;
|
|
53
|
+
severity: "critical" | "high" | "medium" | "low" | "info";
|
|
54
|
+
id: string | number;
|
|
55
|
+
fixedAt?: string | null | undefined;
|
|
56
|
+
dismissedAt?: string | null | undefined;
|
|
57
|
+
}>, "many">;
|
|
58
|
+
errors: z.ZodArray<z.ZodString, "many">;
|
|
59
|
+
severityCounts: z.ZodObject<{
|
|
60
|
+
critical: z.ZodNumber;
|
|
61
|
+
high: z.ZodNumber;
|
|
62
|
+
medium: z.ZodNumber;
|
|
63
|
+
low: z.ZodNumber;
|
|
64
|
+
info: z.ZodNumber;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
critical: number;
|
|
67
|
+
high: number;
|
|
68
|
+
medium: number;
|
|
69
|
+
low: number;
|
|
70
|
+
info: number;
|
|
71
|
+
}, {
|
|
72
|
+
critical: number;
|
|
73
|
+
high: number;
|
|
74
|
+
medium: number;
|
|
75
|
+
low: number;
|
|
76
|
+
info: number;
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
79
|
+
export interface SecurityTriageResult {
|
|
80
|
+
repo: string;
|
|
81
|
+
alerts: SecurityAlert[];
|
|
82
|
+
errors: string[];
|
|
83
|
+
severityCounts: Record<Severity, number>;
|
|
84
|
+
}
|
|
85
|
+
export declare const SEVERITY_ORDER: Severity[];
|
|
86
|
+
export declare function severityIcon(s: Severity | string): string;
|
|
87
|
+
export declare function normalizeSeverity(raw: string | null | undefined): Severity;
|
|
88
|
+
export declare function computeSeverityCounts(alerts: SecurityAlert[]): Record<Severity, number>;
|
|
89
|
+
export declare function handleSecurityTriage(params: SecurityTriageInput, ref: RepoRef, octokit: Octokit): Promise<{
|
|
90
|
+
text: string;
|
|
91
|
+
structured: SecurityTriageResult;
|
|
92
|
+
}>;
|
|
93
|
+
export declare function registerSecurityTriageTool(server: McpServer): void;
|
|
94
|
+
//# sourceMappingURL=security-triage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"security-triage.d.ts","sourceRoot":"","sources":["../../src/tools/security-triage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAM7C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;EASpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAM5E,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqBtC,CAAC;AAMF,MAAM,WAAW,oBAAoB;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