analyze_commit
Identify behavioral change risks in .NET commits by analyzing the HEAD commit with adjustable sensitivity. Returns structured findings for targeted review.
Instructions
Run GauntletCI behavioral change risk analysis on the current HEAD commit in a .NET repository. Returns findings as structured text.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workingDirectory | Yes | Absolute path to the .NET repository root. | |
| sensitivity | No | Risk sensitivity filter. Default: balanced. | balanced |
Implementation Reference
- src/index.ts:156-175 (handler)The handler for the analyze_commit tool: runs GauntletCI in JSON mode, parses the output, and formats findings as text via formatFindingsAsText().
if (name === "analyze_commit") { const { output, exitCode } = runGauntletCI(workingDirectory, sensitivity, "json"); if (exitCode !== 0 && exitCode !== 1) { return { content: [{ type: "text", text: `GauntletCI error (exit ${exitCode}): ${output}` }], isError: true, }; } try { const result = JSON.parse(output) as AnalyzeResult; return { content: [{ type: "text", text: formatFindingsAsText(result) }] }; } catch { return { content: [{ type: "text", text: `Failed to parse output: ${output.slice(0, 300)}` }], isError: true, }; } } - src/index.ts:84-105 (registration)The tool registration in ListToolsRequestSchema: defines name='analyze_commit', description, and inputSchema (workingDirectory required, sensitivity optional).
tools: [ { name: "analyze_commit", description: "Run GauntletCI behavioral change risk analysis on the current HEAD commit in a .NET repository. Returns findings as structured text.", inputSchema: { type: "object", properties: { workingDirectory: { type: "string", description: "Absolute path to the .NET repository root.", }, sensitivity: { type: "string", enum: ["strict", "balanced", "permissive"], description: "Risk sensitivity filter. Default: balanced.", default: "balanced", }, }, required: ["workingDirectory"], }, }, - src/index.ts:54-76 (helper)Helper function formatFindingsAsText() that converts the AnalyzeResult into a human-readable text string.
export function formatFindingsAsText(result: AnalyzeResult): string { if (result.findings.length === 0) { return `No findings. ${result.rulesEvaluated} rules evaluated.${result.commitSha ? ` Commit: ${result.commitSha}` : ""}`; } const lines: string[] = [ `${result.findings.length} finding(s) from ${result.rulesEvaluated} rules.${result.commitSha ? ` Commit: ${result.commitSha}` : ""}`, "", ]; for (const f of result.findings) { const sev = SEVERITY_LABELS[Math.min(f.severity, 3)]; const loc = f.filePath ? ` [${f.filePath}${f.line ? `:${f.line}` : ""}]` : ""; lines.push(`[${sev}] ${f.ruleId} - ${f.ruleName}${loc}`); lines.push(` Summary: ${f.summary}`); if (f.evidence) lines.push(` Evidence: ${f.evidence}`); if (f.whyItMatters) lines.push(` Why it matters: ${f.whyItMatters}`); if (f.suggestedAction) lines.push(` Suggested action: ${f.suggestedAction}`); lines.push(""); } return lines.join("\n"); } - src/index.ts:33-52 (helper)Helper function runGauntletCI() that spawns the 'gauntletci analyze' CLI subprocess.
export function runGauntletCI( workingDir: string, sensitivity: string, outputFormat: "json" | "sarif" | "text" ): { output: string; exitCode: number } { const result = spawnSync( "gauntletci", ["analyze", "--output", outputFormat, "--no-banner", "--sensitivity", sensitivity, "--no-llm"], { cwd: workingDir, encoding: "utf8", shell: process.platform === "win32", } ); return { output: result.stdout ?? "", exitCode: result.status ?? -1, }; } - src/index.ts:12-30 (schema)Type definitions: Finding interface, AnalyzeResult interface, and SEVERITY_LABELS constant used by analyze_commit.
interface Finding { ruleId: string; ruleName: string; summary: string; evidence: string; whyItMatters: string; suggestedAction: string; severity: number; filePath?: string; line?: number; } interface AnalyzeResult { commitSha?: string; hasFindings: boolean; findings: Finding[]; rulesEvaluated: number; }