@neuralaxis/vibedoctor 0.2.0 → 0.2.2

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.
Files changed (80) hide show
  1. package/README.md +135 -23
  2. package/dist/adapters/biome.js +136 -21
  3. package/dist/adapters/flowDoctor.d.ts +7 -0
  4. package/dist/adapters/flowDoctor.js +195 -0
  5. package/dist/adapters/gitleaks.js +4 -2
  6. package/dist/adapters/index.d.ts +1 -0
  7. package/dist/adapters/index.js +3 -1
  8. package/dist/adapters/osvScanner.js +140 -19
  9. package/dist/adapters/presidio.js +3 -1
  10. package/dist/adapters/ruff.js +7 -3
  11. package/dist/adapters/shared.d.ts +4 -0
  12. package/dist/cli/commands/init.js +112 -50
  13. package/dist/cli/commands/privacyReview.js +3 -4
  14. package/dist/cli/commands/scan.d.ts +6 -0
  15. package/dist/cli/commands/scan.js +16 -2
  16. package/dist/cli/commands/setup.d.ts +13 -17
  17. package/dist/cli/commands/setup.js +138 -200
  18. package/dist/cli/index.js +4 -4
  19. package/dist/core/agentDiagnosis.d.ts +39 -0
  20. package/dist/core/agentDiagnosis.js +96 -0
  21. package/dist/core/capability.d.ts +92 -0
  22. package/dist/core/capability.js +122 -0
  23. package/dist/core/config.d.ts +47 -0
  24. package/dist/core/config.js +134 -3
  25. package/dist/core/credentialHeuristics.d.ts +28 -0
  26. package/dist/core/credentialHeuristics.js +179 -0
  27. package/dist/core/engine.d.ts +29 -1
  28. package/dist/core/engine.js +510 -126
  29. package/dist/core/executable.d.ts +18 -0
  30. package/dist/core/executable.js +137 -0
  31. package/dist/core/fileRole.d.ts +24 -0
  32. package/dist/core/fileRole.js +125 -0
  33. package/dist/core/finding.d.ts +125 -1
  34. package/dist/core/finding.js +70 -8
  35. package/dist/core/findingCorrelator.d.ts +19 -0
  36. package/dist/core/findingCorrelator.js +112 -0
  37. package/dist/core/findingNormalizer.d.ts +33 -0
  38. package/dist/core/findingNormalizer.js +172 -0
  39. package/dist/core/managedTools.d.ts +25 -0
  40. package/dist/core/managedTools.js +186 -0
  41. package/dist/core/projectDetector.d.ts +13 -0
  42. package/dist/core/projectDetector.js +100 -15
  43. package/dist/core/relevance.d.ts +87 -0
  44. package/dist/core/relevance.js +367 -0
  45. package/dist/core/repoGraph.d.ts +62 -0
  46. package/dist/core/repoGraph.js +408 -0
  47. package/dist/core/riskRanker.d.ts +6 -0
  48. package/dist/core/riskRanker.js +127 -0
  49. package/dist/core/scanContext.d.ts +26 -0
  50. package/dist/core/scanContext.js +44 -0
  51. package/dist/core/scanPlanner.d.ts +13 -0
  52. package/dist/core/scanPlanner.js +66 -38
  53. package/dist/core/semverLite.d.ts +27 -0
  54. package/dist/core/semverLite.js +163 -0
  55. package/dist/core/suppressions.d.ts +96 -0
  56. package/dist/core/suppressions.js +302 -0
  57. package/dist/core/toolRegistry.d.ts +58 -0
  58. package/dist/core/toolRegistry.js +254 -0
  59. package/dist/core/toolRunner.d.ts +27 -2
  60. package/dist/core/toolRunner.js +79 -93
  61. package/dist/core/toolRuntime.d.ts +40 -0
  62. package/dist/core/toolRuntime.js +417 -0
  63. package/dist/core/toolVerification.d.ts +89 -0
  64. package/dist/core/toolVerification.js +425 -0
  65. package/dist/dpdp/collectors/optionalScanners.js +120 -30
  66. package/dist/dpdp/findings.d.ts +33 -3
  67. package/dist/dpdp/findings.js +191 -4
  68. package/dist/dpdp/scan.js +2 -2
  69. package/dist/dpdp/scoring.d.ts +14 -4
  70. package/dist/dpdp/scoring.js +34 -8
  71. package/dist/dpdp/types.d.ts +19 -1
  72. package/dist/index.d.ts +5 -0
  73. package/dist/index.js +5 -0
  74. package/dist/reporters/agent.d.ts +1 -1
  75. package/dist/reporters/agent.js +7 -0
  76. package/dist/reporters/html.js +57 -13
  77. package/dist/reporters/json.js +7 -1
  78. package/dist/reporters/markdown.js +46 -4
  79. package/dist/reporters/sarif.js +54 -5
  80. package/package.json +80 -80
@@ -4,6 +4,7 @@ exports.GAP_CONTROL_EVALUATORS = exports.POSITIVE_CONTROL_EVALUATORS = void 0;
4
4
  exports.isPositiveControl = isPositiveControl;
5
5
  exports.isGapControl = isGapControl;
6
6
  exports.countStatuses = countStatuses;
7
+ exports.hasSupportingCoverage = hasSupportingCoverage;
7
8
  exports.posturePointsForControl = posturePointsForControl;
8
9
  exports.computeTechnicalPostureScore = computeTechnicalPostureScore;
9
10
  exports.computeEvidenceCompleteness = computeEvidenceCompleteness;
@@ -117,8 +118,22 @@ function countStatuses(controls) {
117
118
  counts.unresolved = counts.violated + counts.partial + counts.needsContext + counts.error;
118
119
  return counts;
119
120
  }
121
+ /**
122
+ * Whether the scanners a control depends on actually ran.
123
+ *
124
+ * "Nothing bad was found" and "nothing looked" produce the same control status,
125
+ * and a gap detector's silence was credited at 0.85 either way. That let a
126
+ * posture score climb because a scanner was missing, which is exactly backwards.
127
+ */
128
+ function hasSupportingCoverage(capabilities) {
129
+ const optional = capabilities.filter((capability) => capability.id === "presidio" || capability.id === "semgrep");
130
+ if (optional.length === 0) {
131
+ return true;
132
+ }
133
+ return optional.some((capability) => capability.status === "available");
134
+ }
120
135
  /** Points contributed by one control status toward technical posture (0–1). */
121
- function posturePointsForControl(control) {
136
+ function posturePointsForControl(control, coverageComplete = true) {
122
137
  switch (control.status) {
123
138
  case "VERIFIED":
124
139
  return 1;
@@ -137,10 +152,12 @@ function posturePointsForControl(control) {
137
152
  return 0.25;
138
153
  }
139
154
  if (isGapControl(control)) {
140
- return 0.85;
155
+ // Silence only earns credit when something was actually looking. Without
156
+ // the supporting scanners it is an unknown, scored like NEEDS_CONTEXT.
157
+ return coverageComplete ? 0.85 : 0.4;
141
158
  }
142
159
  // Inventory, processors, cross-border, SDF, etc. — neutral-good silence
143
- return 0.7;
160
+ return coverageComplete ? 0.7 : 0.4;
144
161
  default:
145
162
  return 0.5;
146
163
  }
@@ -152,8 +169,10 @@ function posturePointsForControl(control) {
152
169
  * Scoring table:
153
170
  * - VERIFIED 1.0 · PARTIAL 0.5 · VIOLATED 0.0 · ERROR 0.15 · NEEDS_CONTEXT 0.4
154
171
  * - NOT_OBSERVED: 0.25 (positive control), 0.85 (gap detector), 0.7 (other)
172
+ * - When supporting scanners did not run, unobserved controls score 0.4 instead,
173
+ * because their silence carries no information.
155
174
  */
156
- function computeTechnicalPostureScore(controls) {
175
+ function computeTechnicalPostureScore(controls, capabilities = []) {
157
176
  const observable = controls.filter((control) => control.applicable &&
158
177
  control.status !== "NOT_APPLICABLE" &&
159
178
  control.status !== "SKIPPED" &&
@@ -161,9 +180,10 @@ function computeTechnicalPostureScore(controls) {
161
180
  if (observable.length === 0) {
162
181
  return 100;
163
182
  }
183
+ const coverageComplete = hasSupportingCoverage(capabilities);
164
184
  let points = 0;
165
185
  for (const control of observable) {
166
- points += posturePointsForControl(control);
186
+ points += posturePointsForControl(control, coverageComplete);
167
187
  }
168
188
  return Math.max(0, Math.min(100, Math.round((points / observable.length) * 100)));
169
189
  }
@@ -196,14 +216,20 @@ function openRiskBySeverity(controls) {
196
216
  }
197
217
  return counts;
198
218
  }
199
- function buildDpdpScores(controls) {
219
+ function buildDpdpScores(controls, capabilities = []) {
220
+ const coverageComplete = hasSupportingCoverage(capabilities);
221
+ const missing = capabilities
222
+ .filter((capability) => capability.status !== "available")
223
+ .map((capability) => capability.id);
200
224
  return {
201
- technicalPostureScore: computeTechnicalPostureScore(controls),
225
+ technicalPostureScore: computeTechnicalPostureScore(controls, capabilities),
202
226
  evidenceCompletenessPercent: computeEvidenceCompleteness(controls),
203
227
  openRiskBySeverity: openRiskBySeverity(controls),
204
228
  statusCounts: countStatuses(controls),
205
229
  labels: {
206
- technicalPosture: "DPDP technical posture (not legal compliance)",
230
+ technicalPosture: coverageComplete
231
+ ? "DPDP technical posture (not legal compliance)"
232
+ : `DPDP technical posture — reduced coverage, ${missing.join(" and ")} did not run (not legal compliance)`,
207
233
  evidenceCompleteness: "Evidence completeness (technical observability)",
208
234
  openRisk: "Open technical risk counts by severity"
209
235
  }
@@ -230,7 +230,12 @@ export type DpdpScores = {
230
230
  openRiskBySeverity: Record<Severity, number>;
231
231
  statusCounts: ControlStatusCounts;
232
232
  labels: {
233
- technicalPosture: "DPDP technical posture (not legal compliance)";
233
+ /**
234
+ * Names the figure and, when supporting scanners did not run, says so in the
235
+ * label itself — a posture number quoted without its coverage caveat is the
236
+ * thing that overstates the evidence.
237
+ */
238
+ technicalPosture: string;
234
239
  evidenceCompleteness: "Evidence completeness (technical observability)";
235
240
  openRisk: "Open technical risk counts by severity";
236
241
  };
@@ -249,6 +254,19 @@ export type DpdpCapabilityStatus = {
249
254
  id: string;
250
255
  status: "available" | "skipped" | "error";
251
256
  message?: string;
257
+ /**
258
+ * Which decision produced this status. "Skipped" previously covered opting
259
+ * out, having nothing in scope, and not being installed — three situations with
260
+ * nothing in common, so a user could not tell whether a scanner they had
261
+ * installed was actually contributing evidence.
262
+ */
263
+ cause?: "opted_out" | "disabled" | "quick_mode" | "nothing_in_scope" | "not_installed" | "not_applicable" | "failed" | "timed_out" | "ran";
264
+ /** What to change to make this capability available. */
265
+ remediation?: string;
266
+ /** Absolute path or interpreter that answered, when the capability did run. */
267
+ resolvedVia?: string;
268
+ /** How many signals this capability contributed to the evidence ledger. */
269
+ signalsContributed?: number;
252
270
  };
253
271
  export type DpdpScanResult = {
254
272
  version: 1;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,15 @@
1
1
  export * from "./agentPack/generateAgentPack";
2
2
  export * from "./agentPack/policy";
3
3
  export { AGENT_SKILLS, DEFAULT_SKILL_NAMES, type SkillTemplate } from "./agentPack/templates";
4
+ export * from "./core/agentDiagnosis";
4
5
  export * from "./core/config";
5
6
  export * from "./core/engine";
6
7
  export * from "./core/finding";
8
+ export * from "./core/findingCorrelator";
7
9
  export * from "./core/privacyReview";
8
10
  export * from "./core/projectDetector";
11
+ export * from "./core/scanContext";
12
+ export * from "./core/scanPlanner";
13
+ export * from "./core/toolRuntime";
9
14
  export * from "./mcp/server";
10
15
  export * from "./dpdp";
package/dist/index.js CHANGED
@@ -20,10 +20,15 @@ __exportStar(require("./agentPack/policy"), exports);
20
20
  var templates_1 = require("./agentPack/templates");
21
21
  Object.defineProperty(exports, "AGENT_SKILLS", { enumerable: true, get: function () { return templates_1.AGENT_SKILLS; } });
22
22
  Object.defineProperty(exports, "DEFAULT_SKILL_NAMES", { enumerable: true, get: function () { return templates_1.DEFAULT_SKILL_NAMES; } });
23
+ __exportStar(require("./core/agentDiagnosis"), exports);
23
24
  __exportStar(require("./core/config"), exports);
24
25
  __exportStar(require("./core/engine"), exports);
25
26
  __exportStar(require("./core/finding"), exports);
27
+ __exportStar(require("./core/findingCorrelator"), exports);
26
28
  __exportStar(require("./core/privacyReview"), exports);
27
29
  __exportStar(require("./core/projectDetector"), exports);
30
+ __exportStar(require("./core/scanContext"), exports);
31
+ __exportStar(require("./core/scanPlanner"), exports);
32
+ __exportStar(require("./core/toolRuntime"), exports);
28
33
  __exportStar(require("./mcp/server"), exports);
29
34
  __exportStar(require("./dpdp"), exports);
@@ -1,3 +1,3 @@
1
1
  import type { AgentPlan, ScanOutput } from "../core/engine";
2
2
  export declare function renderAgentMarkdown(input: Pick<ScanOutput, "agentPlan"> | AgentPlan): string;
3
- export declare function renderAgentJson(input: Pick<ScanOutput, "agentPlan"> | AgentPlan): string;
3
+ export declare function renderAgentJson(input: Pick<ScanOutput, "agentPlan"> | AgentPlan | ScanOutput): string;
@@ -2,9 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderAgentMarkdown = renderAgentMarkdown;
4
4
  exports.renderAgentJson = renderAgentJson;
5
+ const agentDiagnosis_1 = require("../core/agentDiagnosis");
5
6
  function getPlan(input) {
6
7
  return "agentPlan" in input ? input.agentPlan : input;
7
8
  }
9
+ function isScanOutput(input) {
10
+ return "findings" in input && "completeness" in input && "score" in input;
11
+ }
8
12
  function renderAgentMarkdown(input) {
9
13
  const plan = getPlan(input);
10
14
  const lines = ["# VibeDoctor Agent Plan", "", `Goal: ${plan.goal}.`, "", `Target: ${plan.target}`, "", "## Workflow", ""];
@@ -52,5 +56,8 @@ function renderAgentMarkdown(input) {
52
56
  return `${lines.join("\n")}\n`;
53
57
  }
54
58
  function renderAgentJson(input) {
59
+ if (isScanOutput(input)) {
60
+ return JSON.stringify(input.diagnosis ?? (0, agentDiagnosis_1.buildAgentDiagnosis)(input), null, 2);
61
+ }
55
62
  return JSON.stringify(getPlan(input), null, 2);
56
63
  }
@@ -1,6 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderHtmlReport = renderHtmlReport;
4
+ const capability_1 = require("../core/capability");
5
+ const relevance_1 = require("../core/relevance");
6
+ const suppressions_1 = require("../core/suppressions");
7
+ function formatDuration(durationMs) {
8
+ if (durationMs === undefined) {
9
+ return "";
10
+ }
11
+ return durationMs >= 1000 ? `${(durationMs / 1000).toFixed(1)}s` : `${durationMs}ms`;
12
+ }
13
+ function formatLocation(finding) {
14
+ if (!finding.file) {
15
+ return "";
16
+ }
17
+ const line = finding.startLine ? `:${finding.startLine}` : "";
18
+ const column = finding.startLine && finding.startColumn ? `:${finding.startColumn}` : "";
19
+ return `${finding.file}${line}${column}`;
20
+ }
4
21
  function renderHtmlReport(scan) {
5
22
  const severityColor = (sev) => {
6
23
  if (sev === "critical")
@@ -15,7 +32,7 @@ function renderHtmlReport(scan) {
15
32
  if (!items.length)
16
33
  return "";
17
34
  const lis = items
18
- .map((f) => `<li style="margin-bottom:8px"><strong style="color:${severityColor(f.severity)}">${escapeHtml(f.title)}</strong> <span style="color:#6b7280">(${f.severity}, ${f.confidence})</span>${f.file ? ` <code>${escapeHtml(f.file)}${f.startLine ? ":" + f.startLine : ""}</code>` : ""}<br><span>${escapeHtml(f.message)}</span></li>`)
35
+ .map((f) => `<li style="margin-bottom:8px"><strong style="color:${severityColor(f.severity)}">${escapeHtml(f.title)}</strong> <span style="color:#6b7280">(${f.severity}, ${f.confidence})</span>${f.file ? ` <code>${escapeHtml(formatLocation(f))}</code>` : ""}<br><span>${escapeHtml(f.message)}</span></li>`)
19
36
  .join("");
20
37
  return `<h3>${title} (${items.length})</h3><ul style="padding-left:20px">${lis}</ul>`;
21
38
  };
@@ -28,6 +45,27 @@ function renderHtmlReport(scan) {
28
45
  return `<h3>${label}</h3><ul>${lis}</ul>`;
29
46
  };
30
47
  const errored = scan.toolStatuses.filter((t) => t.status === "error" || t.status === "timeout");
48
+ const capabilitySection = () => {
49
+ if (!scan.capabilityMatrix.tools.length)
50
+ return "";
51
+ const rows = scan.capabilityMatrix.tools
52
+ .map((tool) => `<tr><td><strong>${escapeHtml(tool.id)}</strong></td><td>${escapeHtml((0, capability_1.capabilityStateLabel)(tool.state))}</td><td>${tool.findingsSurfaced}/${tool.findingsReported}</td><td>${escapeHtml(formatDuration(tool.durationMs))}</td><td>${escapeHtml(tool.reason)}</td></tr>`)
53
+ .join("");
54
+ const remediations = scan.capabilityMatrix.tools.filter((tool) => tool.remediation && (0, capability_1.isCoverageGap)(tool));
55
+ const restore = remediations.length
56
+ ? `<h4>To restore coverage</h4><ul>${remediations
57
+ .map((tool) => `<li><strong>${escapeHtml(tool.id)}</strong> — ${escapeHtml(tool.remediation)}</li>`)
58
+ .join("")}</ul>`
59
+ : "";
60
+ return `<div class="section"><h3>Tool coverage</h3><table><thead><tr><th>Tool</th><th>State</th><th>Findings shown/reported</th><th>Time</th><th>Detail</th></tr></thead><tbody>${rows}</tbody></table>${restore}</div>`;
61
+ };
62
+ const lineSection = (title, sectionLines) => {
63
+ if (!sectionLines.length)
64
+ return "";
65
+ return `<div class="section"><h3>${escapeHtml(title)}</h3><ul>${sectionLines
66
+ .map((line) => `<li>${escapeHtml(line.replace(/^- /, ""))}</li>`)
67
+ .join("")}</ul></div>`;
68
+ };
31
69
  return `<!doctype html>
32
70
  <html>
33
71
  <head>
@@ -43,37 +81,43 @@ function renderHtmlReport(scan) {
43
81
  ul { margin: 8px 0; }
44
82
  .section { margin-top: 24px; }
45
83
  .meta { color: #6b7280; font-size: 0.85em; }
84
+ table { border-collapse: collapse; width: 100%; font-size: 0.9em; }
85
+ th, td { border-bottom: 1px solid #e5e7eb; padding: 6px 8px; text-align: left; vertical-align: top; }
86
+ th { color: #374151; font-weight: 600; }
46
87
  </style>
47
88
  </head>
48
89
  <body>
49
90
  <h1>VibeDoctor Health Report</h1>
50
91
  <div class="meta">Root: <code>${escapeHtml(scan.root)}</code> &middot; Mode: ${scan.mode} &middot; Generated for agents &amp; humans</div>
51
92
 
52
- <div class="score">Health: ${scan.score.overall}/100 — ${scan.completeness.status.toUpperCase()} ${scan.score.overall >= 85 ? "✅" : "⚠️"}</div>
53
- <div class="meta">Scan coverage: ${scan.completeness.completed}/${scan.completeness.planned} checks completed.${scan.completeness.comparable ? "" : " This score is not comparable to a complete scan."}</div>
93
+ <div class="score">Health: ${scan.score.overall}/100 — ${scan.completeness.status.toUpperCase()} ${scan.score.overall >= 85 ? "✅" : "⚠️"}</div>
94
+ <div class="meta">Scan coverage: ${scan.completeness.completed}/${scan.completeness.planned} checks completed.${scan.completeness.comparable ? "" : " This score is not comparable to a complete scan."}</div>
54
95
 
55
96
  <div class="summary">
56
- <span class="pill">Blockers: ${scan.blockers.length}</span>
57
- <span class="pill">Fix next: ${scan.fixNext.length}</span>
58
- <span class="pill">Privacy Review: ${scan.privacyFindings.length}</span>
59
- <span class="pill">Leftovers: ${scan.leftovers.length}</span>
97
+ <span class="pill">Blockers: ${scan.blockers.length}</span>
98
+ <span class="pill">Fix next: ${scan.fixNext.length}</span>
99
+ <span class="pill">Privacy Review: ${scan.privacyFindings.length}</span>
100
+ <span class="pill">Leftovers: ${scan.leftovers.length}</span>
60
101
  <span class="pill">Dead chains: ${scan.deadCodeCandidates.length}</span>
61
102
  <span class="pill">Refactor: ${scan.refactorCandidates.length}</span>
62
103
  </div>
63
104
 
64
105
  <div class="section">
65
- ${renderFindingList(scan.blockers, "BLOCKERS")}
66
- ${renderFindingList(scan.fixNext, "FIX NEXT")}
67
- ${renderFindingList(scan.privacyFindings.slice(0, 10), "PRIVACY REVIEW FINDINGS")}
68
- ${renderFindingList(scan.leftovers, "LEFTOVERS")}
106
+ ${renderFindingList(scan.blockers, "BLOCKERS")}
107
+ ${renderFindingList(scan.fixNext, "FIX NEXT")}
108
+ ${renderFindingList(scan.privacyFindings.slice(0, 10), "PRIVACY REVIEW FINDINGS")}
109
+ ${renderFindingList(scan.leftovers, "LEFTOVERS")}
69
110
  ${renderFindingList(scan.deadCodeCandidates, "DEAD CHAINS")}
70
111
  ${renderFindingList(scan.refactorCandidates, "REFACTOR CANDIDATES")}
71
112
  </div>
72
113
 
73
114
  ${toolList(scan.toolStatuses.filter(t => t.status !== "ok"), "Tool Statuses (non-ok)")}
74
115
  ${toolList(scan.skippedTools, "Skipped Tools")}
75
- ${errored.length ? toolList(errored, "Errored / Timed Out Tools") : ""}
76
- ${scan.recoveryActions.length ? `<h3>Recover before editing</h3><ul>${scan.recoveryActions.map(action => `<li><code>${escapeHtml(action.command)}</code> — ${escapeHtml(action.successCondition)}</li>`).join("")}</ul>` : ""}
116
+ ${errored.length ? toolList(errored, "Errored / Timed Out Tools") : ""}
117
+ ${capabilitySection()}
118
+ ${lineSection("Report filtering", (0, relevance_1.renderRelevanceLines)(scan.relevance))}
119
+ ${lineSection("Acknowledged", (0, suppressions_1.renderSuppressionLines)(scan.suppressions))}
120
+ ${scan.recoveryActions.length ? `<h3>Recover before editing</h3><ul>${scan.recoveryActions.map(action => `<li><code>${escapeHtml(action.command)}</code> — ${escapeHtml(action.successCondition)}</li>`).join("")}</ul>` : ""}
77
121
 
78
122
  <p class="meta" style="margin-top:32px">Run <code>vibedoctor agent-plan</code> for guided repair. Full JSON/HTML/Markdown/SARIF available via --report.</p>
79
123
  </body>
@@ -15,9 +15,15 @@ function renderJsonReport(scan) {
15
15
  privacyReview: scan.privacyReview,
16
16
  toolStatuses: scan.toolStatuses,
17
17
  skippedTools: scan.skippedTools,
18
+ capabilityMatrix: scan.capabilityMatrix,
19
+ relevance: scan.relevance,
20
+ suppressions: scan.suppressions,
21
+ suppressedFindings: scan.suppressedFindings,
22
+ verifications: scan.verifications,
18
23
  agentPlan: scan.agentPlan,
19
24
  notes: {
20
- dpdp: "DPDP findings are technical readiness signals integrated into privacy findings. See .vibedoctor/dpdp/ for the control matrix and data map. Not legal compliance."
25
+ dpdp: "DPDP findings are technical readiness signals integrated into privacy findings. See .vibedoctor/dpdp/ for the control matrix and data map. Not legal compliance.",
26
+ coverage: "capabilityMatrix is authoritative for what actually ran: toolStatuses and skippedTools are views of it. relevance explains any difference between findings a tool reported and findings shown here, so a short report is never a clean one."
21
27
  }
22
28
  }, null, 2) + "\n";
23
29
  }
@@ -1,6 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderMarkdownReport = renderMarkdownReport;
4
+ const capability_1 = require("../core/capability");
5
+ const relevance_1 = require("../core/relevance");
6
+ const suppressions_1 = require("../core/suppressions");
7
+ function formatDuration(durationMs) {
8
+ if (durationMs === undefined) {
9
+ return "";
10
+ }
11
+ return durationMs >= 1000 ? `${(durationMs / 1000).toFixed(1)}s` : `${durationMs}ms`;
12
+ }
13
+ /** Cell content has to be escaped or a `|` in a tool's reason breaks the table. */
14
+ function escapeTableCell(value) {
15
+ return value.replaceAll("|", "\\|").replaceAll("\n", " ");
16
+ }
17
+ function formatLocation(finding) {
18
+ if (!finding.file) {
19
+ return "";
20
+ }
21
+ const line = finding.startLine ? `:${finding.startLine}` : "";
22
+ const column = finding.startLine && finding.startColumn ? `:${finding.startColumn}` : "";
23
+ return ` — \`${finding.file}${line}${column}\``;
24
+ }
4
25
  function renderMarkdownReport(scan) {
5
26
  const plan = scan.agentPlan;
6
27
  const lines = [
@@ -23,24 +44,45 @@ function renderMarkdownReport(scan) {
23
44
  lines.push("- None");
24
45
  }
25
46
  else {
26
- scan.blockers.forEach((finding) => lines.push(`- ${finding.title}${finding.file ? ` — \`${finding.file}\`` : ""}: ${finding.message}`));
47
+ scan.blockers.forEach((finding) => lines.push(`- ${finding.title}${formatLocation(finding)}: ${finding.message}`));
27
48
  }
28
49
  lines.push("", "## Fix next");
29
- scan.fixNext.forEach((finding) => lines.push(`- ${finding.title}${finding.file ? ` — \`${finding.file}\`` : ""}`));
50
+ scan.fixNext.forEach((finding) => lines.push(`- ${finding.title}${formatLocation(finding)}`));
30
51
  if (scan.privacyFindings.length > 0) {
31
52
  lines.push("", "## Privacy Review findings");
32
53
  scan.privacyFindings
33
54
  .slice(0, 10)
34
- .forEach((finding) => lines.push(`- ${finding.title}${finding.file ? ` — \`${finding.file}${finding.startLine ? `:${finding.startLine}` : ""}\`` : ""}: ${finding.evidence?.maskedValue ?? finding.evidence?.entityType ?? finding.message}`));
55
+ .forEach((finding) => lines.push(`- ${finding.title}${formatLocation(finding)}: ${finding.evidence?.maskedValue ?? finding.evidence?.entityType ?? finding.message}`));
35
56
  }
36
57
  if (scan.deadCodeCandidates.length > 0) {
37
58
  lines.push("", "## Dead chains and dead code");
38
- scan.deadCodeCandidates.slice(0, 5).forEach((finding) => lines.push(`- ${finding.title}${finding.file ? ` — \`${finding.file}\`` : ""}: ${finding.message}`));
59
+ scan.deadCodeCandidates.slice(0, 5).forEach((finding) => lines.push(`- ${finding.title}${formatLocation(finding)}: ${finding.message}`));
39
60
  }
40
61
  if (scan.skippedTools.length > 0) {
41
62
  lines.push("", "## Skipped tools");
42
63
  scan.skippedTools.forEach((tool) => lines.push(`- ${tool.id}${tool.installHint ? ` — ${tool.installHint}` : ""}`));
43
64
  }
65
+ if (scan.capabilityMatrix.tools.length > 0) {
66
+ lines.push("", "## Tool coverage");
67
+ lines.push("| Tool | State | Findings shown/reported | Time | Detail |");
68
+ lines.push("| --- | --- | --- | --- | --- |");
69
+ scan.capabilityMatrix.tools.forEach((tool) => lines.push(`| ${escapeTableCell(tool.id)} | ${(0, capability_1.capabilityStateLabel)(tool.state)} | ${tool.findingsSurfaced}/${tool.findingsReported} | ${formatDuration(tool.durationMs)} | ${escapeTableCell(tool.reason)} |`));
70
+ const remediations = scan.capabilityMatrix.tools.filter((tool) => tool.remediation && (0, capability_1.isCoverageGap)(tool));
71
+ if (remediations.length > 0) {
72
+ lines.push("", "### To restore coverage");
73
+ remediations.forEach((tool) => lines.push(`- ${tool.id}: ${tool.remediation}`));
74
+ }
75
+ }
76
+ const relevanceLines = (0, relevance_1.renderRelevanceLines)(scan.relevance);
77
+ if (relevanceLines.length > 0) {
78
+ lines.push("", "## Report filtering");
79
+ relevanceLines.forEach((line) => lines.push(line));
80
+ }
81
+ const suppressionLines = (0, suppressions_1.renderSuppressionLines)(scan.suppressions);
82
+ if (suppressionLines.length > 0) {
83
+ lines.push("", "## Acknowledged");
84
+ suppressionLines.forEach((line) => lines.push(line));
85
+ }
44
86
  lines.push("", "## Agent tasks");
45
87
  plan.tasks.forEach((task) => lines.push(`- ${task.title}`));
46
88
  return `${lines.join("\n")}\n`;
@@ -1,9 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderSarif = renderSarif;
4
+ const capability_1 = require("../core/capability");
5
+ // SARIF forbids a region that carries columns without a line, so positions are
6
+ // emitted together or not at all.
7
+ function buildRegion(finding) {
8
+ if (finding.startLine === undefined) {
9
+ return undefined;
10
+ }
11
+ return {
12
+ startLine: finding.startLine,
13
+ endLine: finding.endLine,
14
+ startColumn: finding.startColumn,
15
+ endColumn: finding.endColumn
16
+ };
17
+ }
4
18
  function renderSarif(scan) {
19
+ const gaps = scan.capabilityMatrix.tools.filter(capability_1.isCoverageGap);
5
20
  return JSON.stringify({
6
21
  version: "2.1.0",
22
+ $schema: "https://json.schemastore.org/sarif-2.1.0.json",
7
23
  runs: [
8
24
  {
9
25
  tool: {
@@ -11,6 +27,22 @@ function renderSarif(scan) {
11
27
  name: "VibeDoctor"
12
28
  }
13
29
  },
30
+ invocations: [
31
+ {
32
+ executionSuccessful: scan.completeness.status !== "invalid",
33
+ // Every tool that did not fully cover the repository is reported
34
+ // here, so a consumer never reads an incomplete scan as a clean one.
35
+ toolExecutionNotifications: gaps.map((tool) => ({
36
+ level: tool.trust === "absent" ? "error" : "warning",
37
+ message: {
38
+ text: `${tool.id} (${(0, capability_1.capabilityStateLabel)(tool.state)}): ${tool.reason}${tool.remediation ? ` ${tool.remediation}` : ""}`
39
+ },
40
+ descriptor: {
41
+ id: `vibedoctor.coverage.${tool.id}`
42
+ }
43
+ }))
44
+ }
45
+ ],
14
46
  results: scan.findings.map((finding) => ({
15
47
  ruleId: finding.id,
16
48
  level: finding.severity === "critical" || finding.severity === "high" ? "error" : "warning",
@@ -21,8 +53,22 @@ function renderSarif(scan) {
21
53
  category: finding.category,
22
54
  confidence: finding.confidence,
23
55
  entityType: finding.evidence?.entityType,
24
- sensitivity: finding.evidence?.sensitivity
56
+ sensitivity: finding.evidence?.sensitivity,
57
+ evidenceGrade: finding.evidenceGrade,
58
+ fileRole: finding.fileRole,
59
+ baselineState: finding.baselineState,
60
+ priority: finding.priority,
61
+ package: finding.package
25
62
  },
63
+ suppressions: finding.suppression
64
+ ? [
65
+ {
66
+ kind: "external",
67
+ status: finding.suppression.expired ? "rejected" : "accepted",
68
+ justification: `${finding.suppression.ruleId} (${finding.suppression.classification}): ${finding.suppression.reason}`
69
+ }
70
+ ]
71
+ : undefined,
26
72
  locations: finding.file
27
73
  ? [
28
74
  {
@@ -30,14 +76,17 @@ function renderSarif(scan) {
30
76
  artifactLocation: {
31
77
  uri: finding.file
32
78
  },
33
- region: {
34
- startLine: finding.startLine
35
- }
79
+ region: buildRegion(finding)
36
80
  }
37
81
  }
38
82
  ]
39
83
  : undefined
40
- }))
84
+ })),
85
+ properties: {
86
+ capabilityMatrix: scan.capabilityMatrix,
87
+ relevance: scan.relevance,
88
+ suppressions: scan.suppressions
89
+ }
41
90
  }
42
91
  ]
43
92
  }, null, 2);