@neuralaxis/vibedoctor 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/README.md +298 -115
  2. package/dist/adapters/biome.js +135 -21
  3. package/dist/adapters/dpdp.d.ts +6 -0
  4. package/dist/adapters/dpdp.js +34 -0
  5. package/dist/adapters/index.d.ts +1 -0
  6. package/dist/adapters/index.js +3 -1
  7. package/dist/adapters/osvScanner.js +136 -17
  8. package/dist/adapters/presidio.js +6 -2
  9. package/dist/adapters/privacyDetector.d.ts +24 -1
  10. package/dist/adapters/privacyDetector.js +86 -2
  11. package/dist/adapters/shared.d.ts +6 -0
  12. package/dist/agentPack/templates/skills.js +159 -53
  13. package/dist/cli/commands/dpdp.d.ts +35 -0
  14. package/dist/cli/commands/dpdp.js +103 -0
  15. package/dist/cli/commands/init.js +105 -50
  16. package/dist/cli/commands/privacyReview.js +3 -4
  17. package/dist/cli/commands/scan.js +4 -1
  18. package/dist/cli/commands/setup.d.ts +13 -17
  19. package/dist/cli/commands/setup.js +138 -200
  20. package/dist/cli/index.js +84 -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 +57 -0
  24. package/dist/core/config.js +194 -7
  25. package/dist/core/credentialHeuristics.d.ts +28 -0
  26. package/dist/core/credentialHeuristics.js +179 -0
  27. package/dist/core/engine.d.ts +21 -0
  28. package/dist/core/engine.js +484 -84
  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 +63 -5
  35. package/dist/core/findingNormalizer.d.ts +33 -0
  36. package/dist/core/findingNormalizer.js +171 -0
  37. package/dist/core/projectDetector.d.ts +13 -0
  38. package/dist/core/projectDetector.js +100 -15
  39. package/dist/core/relevance.d.ts +87 -0
  40. package/dist/core/relevance.js +367 -0
  41. package/dist/core/scanPlanner.d.ts +12 -0
  42. package/dist/core/scanPlanner.js +61 -29
  43. package/dist/core/semverLite.d.ts +27 -0
  44. package/dist/core/semverLite.js +163 -0
  45. package/dist/core/suppressions.d.ts +96 -0
  46. package/dist/core/suppressions.js +302 -0
  47. package/dist/core/toolRegistry.d.ts +58 -0
  48. package/dist/core/toolRegistry.js +247 -0
  49. package/dist/core/toolRunner.d.ts +23 -2
  50. package/dist/core/toolRunner.js +61 -93
  51. package/dist/core/toolVerification.d.ts +87 -0
  52. package/dist/core/toolVerification.js +370 -0
  53. package/dist/dpdp/artifacts.d.ts +11 -0
  54. package/dist/dpdp/artifacts.js +120 -0
  55. package/dist/dpdp/catalogue.d.ts +14 -0
  56. package/dist/dpdp/catalogue.js +661 -0
  57. package/dist/dpdp/collectors/confidence.d.ts +9 -0
  58. package/dist/dpdp/collectors/confidence.js +25 -0
  59. package/dist/dpdp/collectors/dependencies.d.ts +7 -0
  60. package/dist/dpdp/collectors/dependencies.js +63 -0
  61. package/dist/dpdp/collectors/index.d.ts +24 -0
  62. package/dist/dpdp/collectors/index.js +71 -0
  63. package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
  64. package/dist/dpdp/collectors/lifecycle.js +202 -0
  65. package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
  66. package/dist/dpdp/collectors/optionalScanners.js +437 -0
  67. package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
  68. package/dist/dpdp/collectors/privacyBridge.js +152 -0
  69. package/dist/dpdp/collectors/safeguards.d.ts +5 -0
  70. package/dist/dpdp/collectors/safeguards.js +186 -0
  71. package/dist/dpdp/collectors/schema.d.ts +6 -0
  72. package/dist/dpdp/collectors/schema.js +122 -0
  73. package/dist/dpdp/collectors/shared.d.ts +10 -0
  74. package/dist/dpdp/collectors/shared.js +43 -0
  75. package/dist/dpdp/context.d.ts +28 -0
  76. package/dist/dpdp/context.js +195 -0
  77. package/dist/dpdp/dataMap.d.ts +7 -0
  78. package/dist/dpdp/dataMap.js +339 -0
  79. package/dist/dpdp/evaluators.d.ts +20 -0
  80. package/dist/dpdp/evaluators.js +522 -0
  81. package/dist/dpdp/evidence.d.ts +11 -0
  82. package/dist/dpdp/evidence.js +123 -0
  83. package/dist/dpdp/findings.d.ts +44 -0
  84. package/dist/dpdp/findings.js +286 -0
  85. package/dist/dpdp/gates.d.ts +14 -0
  86. package/dist/dpdp/gates.js +47 -0
  87. package/dist/dpdp/index.d.ts +16 -0
  88. package/dist/dpdp/index.js +32 -0
  89. package/dist/dpdp/legalSources.d.ts +10 -0
  90. package/dist/dpdp/legalSources.js +104 -0
  91. package/dist/dpdp/paths.d.ts +25 -0
  92. package/dist/dpdp/paths.js +85 -0
  93. package/dist/dpdp/report.d.ts +6 -0
  94. package/dist/dpdp/report.js +222 -0
  95. package/dist/dpdp/reviewQueue.d.ts +3 -0
  96. package/dist/dpdp/reviewQueue.js +88 -0
  97. package/dist/dpdp/scan.d.ts +26 -0
  98. package/dist/dpdp/scan.js +310 -0
  99. package/dist/dpdp/scoring.d.ts +41 -0
  100. package/dist/dpdp/scoring.js +237 -0
  101. package/dist/dpdp/types.d.ts +312 -0
  102. package/dist/dpdp/types.js +86 -0
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.js +1 -0
  105. package/dist/mcp/tools/dpdp.d.ts +11 -0
  106. package/dist/mcp/tools/dpdp.js +151 -0
  107. package/dist/mcp/tools/index.js +3 -1
  108. package/dist/reporters/html.js +57 -13
  109. package/dist/reporters/json.js +12 -1
  110. package/dist/reporters/markdown.js +46 -4
  111. package/dist/reporters/sarif.js +54 -5
  112. package/package.json +4 -1
@@ -0,0 +1,370 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isVerificationBlocking = isVerificationBlocking;
7
+ exports.probeRuntime = probeRuntime;
8
+ exports.probeRuntimes = probeRuntimes;
9
+ exports.probeRuntimesFor = probeRuntimesFor;
10
+ exports.verifyTool = verifyTool;
11
+ exports.verifyTools = verifyTools;
12
+ exports.summarizeVerification = summarizeVerification;
13
+ exports.formatVersionForDisplay = formatVersionForDisplay;
14
+ const node_fs_1 = require("node:fs");
15
+ const node_path_1 = __importDefault(require("node:path"));
16
+ const executable_1 = require("./executable");
17
+ const semverLite_1 = require("./semverLite");
18
+ const toolRegistry_1 = require("./toolRegistry");
19
+ const toolRunner_1 = require("./toolRunner");
20
+ function isVerificationBlocking(verification) {
21
+ return verification.state === "not_found" || verification.state === "broken" || verification.state === "incompatible_runtime";
22
+ }
23
+ const DEFAULT_VERSION_PATTERN = /\b(\d+\.\d+(?:\.\d+)?(?:[-+][0-9A-Za-z.-]+)?)\b/;
24
+ function extractVersion(output, pattern) {
25
+ const match = (pattern ?? DEFAULT_VERSION_PATTERN).exec(output);
26
+ return match?.[1] ?? match?.[0];
27
+ }
28
+ // Generous, because some tools are genuinely slow to start: reporting a working
29
+ // tool as broken because it took 31 seconds to print its version would be worse
30
+ // than waiting.
31
+ const PROBE_TIMEOUT_MS = 90_000;
32
+ /** Candidate interpreter command names, in the order the scanner would find them. */
33
+ const RUNTIME_COMMANDS = {
34
+ node: ["node"],
35
+ python: ["python", "python3", "py"]
36
+ };
37
+ /**
38
+ * Locates a language runtime once per process. `python` being absent is the
39
+ * reason a whole family of installs silently fails, so it is reported as a
40
+ * first-class fact rather than inferred from a tool-level error message.
41
+ */
42
+ async function probeRuntime(engine, cwd) {
43
+ if (engine === "node") {
44
+ // We are running on Node, so the version that matters is this process's.
45
+ const resolved = (0, executable_1.resolveExecutable)("node", cwd);
46
+ return {
47
+ engine,
48
+ available: true,
49
+ command: "node",
50
+ resolvedPath: resolved?.path ?? process.execPath,
51
+ version: process.versions.node,
52
+ detail: `Node ${process.versions.node} at ${resolved?.path ?? process.execPath}`
53
+ };
54
+ }
55
+ for (const command of RUNTIME_COMMANDS[engine]) {
56
+ const resolved = (0, executable_1.resolveExecutable)(command, cwd);
57
+ if (!resolved) {
58
+ continue;
59
+ }
60
+ const result = await (0, toolRunner_1.runCommand)({ cmd: command, args: ["--version"], cwd, timeoutMs: PROBE_TIMEOUT_MS });
61
+ if (result.status !== "ok") {
62
+ continue;
63
+ }
64
+ const version = extractVersion(`${result.stdout}\n${result.stderr}`, undefined);
65
+ return {
66
+ engine,
67
+ available: true,
68
+ command,
69
+ resolvedPath: resolved.path,
70
+ version,
71
+ detail: `${command} ${version ?? "(unknown version)"} at ${resolved.path}`
72
+ };
73
+ }
74
+ return {
75
+ engine,
76
+ available: false,
77
+ detail: `No ${engine} interpreter found on PATH (tried ${RUNTIME_COMMANDS[engine].join(", ")}).`
78
+ };
79
+ }
80
+ async function probeRuntimes(cwd, engines) {
81
+ const unique = Array.from(new Set(engines));
82
+ const probes = await Promise.all(unique.map(async (engine) => [engine, await probeRuntime(engine, cwd)]));
83
+ return Object.fromEntries(probes);
84
+ }
85
+ /**
86
+ * Probes only the runtimes that a tool present on this machine actually needs.
87
+ *
88
+ * Probing every runtime a registry entry mentions meant spawning a Python
89
+ * interpreter on repositories with no Python tooling installed, on every scan.
90
+ */
91
+ async function probeRuntimesFor(entries, cwd, depth = "execute") {
92
+ const engines = new Set();
93
+ for (const entry of entries) {
94
+ if (entry.moduleProbe && depth === "execute") {
95
+ engines.add(entry.moduleProbe.runtime);
96
+ continue;
97
+ }
98
+ if (!entry.runtime || !entry.executable) {
99
+ continue;
100
+ }
101
+ // Node compatibility is free — this process is the runtime — so it is always
102
+ // worth knowing. Other runtimes cost a spawn, so only ask when the tool that
103
+ // needs one is actually installed.
104
+ if (entry.runtime === "node" || (0, executable_1.resolveExecutable)(entry.executable, cwd)) {
105
+ engines.add(entry.runtime);
106
+ }
107
+ }
108
+ return probeRuntimes(cwd, Array.from(engines));
109
+ }
110
+ async function checkRuntimeCompatibility(root, entry, probes) {
111
+ if (!entry.runtime) {
112
+ return undefined;
113
+ }
114
+ const probe = probes[entry.runtime];
115
+ const { range, source } = entry.ecosystem === "npm" ? await (0, toolRegistry_1.readDeclaredNodeRequirement)(root, entry.packageName) : {};
116
+ if (!probe?.available) {
117
+ return {
118
+ engine: entry.runtime,
119
+ requirement: range,
120
+ requirementSource: source,
121
+ compatible: false
122
+ };
123
+ }
124
+ const version = (0, semverLite_1.parseVersion)(probe.version);
125
+ const satisfied = version ? (0, semverLite_1.satisfiesRange)(version, range) : undefined;
126
+ return {
127
+ engine: entry.runtime,
128
+ version: probe.version,
129
+ requirement: range,
130
+ requirementSource: source,
131
+ compatible: satisfied ?? "unknown"
132
+ };
133
+ }
134
+ function runtimeRemediation(entry, runtime) {
135
+ const needed = (0, semverLite_1.minimumSatisfying)(runtime.requirement);
136
+ const target = needed ? `${runtime.engine} >= ${needed}` : `a newer ${runtime.engine}`;
137
+ return [
138
+ `${entry.id} declares ${runtime.requirement ?? "a newer runtime"}${runtime.requirementSource ? ` (${runtime.requirementSource})` : ""}`,
139
+ `but the active runtime is ${runtime.engine} ${runtime.version ?? "unknown"}.`,
140
+ `Either upgrade to ${target}, run VibeDoctor under a compatible runtime, or set`,
141
+ `runtime.deferred_tools: [${entry.id}] in vibedoctor.yml to defer it deliberately.`
142
+ ].join(" ");
143
+ }
144
+ async function verifyTool(entry, options) {
145
+ const { root, runtimes } = options;
146
+ const depth = options.depth ?? "execute";
147
+ if (entry.ecosystem === "built-in") {
148
+ return {
149
+ id: entry.id,
150
+ state: "verified",
151
+ reason: "Built-in check; no external executable required.",
152
+ version: "built-in"
153
+ };
154
+ }
155
+ const runtime = await checkRuntimeCompatibility(root, entry, runtimes);
156
+ // A tool driven as a module of another runtime (Presidio) has no binary to
157
+ // find; import the module through the interpreter the scanner would use.
158
+ if (entry.moduleProbe) {
159
+ const probe = runtimes[entry.moduleProbe.runtime];
160
+ if (!probe?.available) {
161
+ return {
162
+ id: entry.id,
163
+ state: depth === "resolve" ? "unverifiable" : "not_found",
164
+ reason: depth === "resolve"
165
+ ? `${entry.id} runs as a ${entry.moduleProbe.runtime} module; whether it is importable is determined when it runs.`
166
+ : `${entry.moduleProbe.runtime} interpreter is not available, so ${entry.id} cannot run.`,
167
+ remediation: `Install ${entry.moduleProbe.runtime} and make it available on PATH, then rerun setup.`,
168
+ runtime
169
+ };
170
+ }
171
+ if (depth === "resolve") {
172
+ // Importing the module is expensive enough to matter on every scan, and
173
+ // the adapter reports the same fact when it actually runs.
174
+ return {
175
+ id: entry.id,
176
+ state: "unverifiable",
177
+ interpreterPath: probe.resolvedPath,
178
+ reason: `${entry.id} runs as a ${entry.moduleProbe.runtime} module; its availability is confirmed when the scan invokes it.`,
179
+ runtime
180
+ };
181
+ }
182
+ const args = ["-c", `import ${entry.moduleProbe.module} as m; print(getattr(m, "__version__", "installed"))`];
183
+ const result = await (0, toolRunner_1.runCommand)({ cmd: probe.command, args, cwd: root, timeoutMs: PROBE_TIMEOUT_MS });
184
+ const probeCommand = [probe.command, ...args].join(" ");
185
+ if (result.status !== "ok") {
186
+ return {
187
+ id: entry.id,
188
+ state: result.status === "skipped" ? "not_found" : "broken",
189
+ interpreterPath: probe.resolvedPath,
190
+ probeCommand,
191
+ reason: `${entry.moduleProbe.module} could not be imported by ${probe.resolvedPath ?? probe.command}.`,
192
+ remediation: (0, toolRegistry_1.installHintFor)(entry),
193
+ runtime
194
+ };
195
+ }
196
+ return {
197
+ id: entry.id,
198
+ state: "verified",
199
+ interpreterPath: probe.resolvedPath,
200
+ version: result.stdout.trim() || "installed",
201
+ probeCommand,
202
+ reason: `Imported ${entry.moduleProbe.module} using ${probe.resolvedPath ?? probe.command}.`,
203
+ runtime
204
+ };
205
+ }
206
+ if (!entry.executable) {
207
+ return {
208
+ id: entry.id,
209
+ state: "unverifiable",
210
+ reason: `${entry.id} declares no executable or module probe, so its availability cannot be confirmed.`,
211
+ remediation: "Add a probe to the tool registry so setup can verify this tool.",
212
+ runtime
213
+ };
214
+ }
215
+ const resolved = (0, executable_1.resolveExecutable)(entry.executable, root);
216
+ if (!resolved) {
217
+ const searched = (0, executable_1.describeSearchPaths)(root);
218
+ return {
219
+ id: entry.id,
220
+ state: "not_found",
221
+ reason: `${entry.executable} was not found in any of the ${searched.length} directories on the scanner's PATH.`,
222
+ remediation: (0, toolRegistry_1.installHintFor)(entry),
223
+ runtime
224
+ };
225
+ }
226
+ // Runtime incompatibility is reported before the probe, because a tool that
227
+ // cannot start under this runtime is not "broken" — it is mismatched, and the
228
+ // remediation is completely different.
229
+ if (runtime && runtime.compatible === false) {
230
+ return {
231
+ id: entry.id,
232
+ state: "incompatible_runtime",
233
+ resolvedPath: resolved.path,
234
+ reason: runtime.requirement
235
+ ? `${entry.id} requires ${runtime.engine} ${runtime.requirement} but ${runtime.engine} ${runtime.version ?? "unknown"} is active.`
236
+ : `${entry.id} needs a ${runtime.engine} runtime that is not available.`,
237
+ remediation: runtimeRemediation(entry, runtime),
238
+ runtime
239
+ };
240
+ }
241
+ if (depth === "resolve") {
242
+ return {
243
+ id: entry.id,
244
+ state: "verified",
245
+ resolvedPath: resolved.path,
246
+ reason: `Resolved to ${resolved.path}; the scan invokes this executable directly.`,
247
+ runtime
248
+ };
249
+ }
250
+ const probeArgs = entry.probeArgs ?? ["--version"];
251
+ const result = await (0, toolRunner_1.runCommand)({ cmd: entry.executable, args: probeArgs, cwd: root, timeoutMs: PROBE_TIMEOUT_MS });
252
+ const probeCommand = [entry.executable, ...probeArgs].join(" ");
253
+ const output = `${result.stdout}\n${result.stderr}`;
254
+ if (result.status !== "ok") {
255
+ // A tool present on PATH that cannot answer its own version probe is
256
+ // installed-but-unusable; saying "installed" here is what misled users.
257
+ const unsupportedRuntime = /requires node|unsupported engine|SyntaxError|Unexpected token/i.test(output);
258
+ return {
259
+ id: entry.id,
260
+ state: unsupportedRuntime ? "incompatible_runtime" : "broken",
261
+ resolvedPath: resolved.path,
262
+ probeCommand,
263
+ reason: unsupportedRuntime
264
+ ? `${entry.id} is installed at ${resolved.path} but failed to start under the active runtime.`
265
+ : `${entry.id} is installed at ${resolved.path} but \`${probeCommand}\` exited ${result.exitCode ?? "abnormally"}.`,
266
+ remediation: unsupportedRuntime && runtime ? runtimeRemediation(entry, runtime) : (0, toolRegistry_1.installHintFor)(entry),
267
+ runtime
268
+ };
269
+ }
270
+ return {
271
+ id: entry.id,
272
+ state: "verified",
273
+ resolvedPath: resolved.path,
274
+ version: extractVersion(output, entry.versionPattern),
275
+ probeCommand,
276
+ reason: `Ran \`${probeCommand}\` successfully at ${resolved.path}.`,
277
+ runtime
278
+ };
279
+ }
280
+ const VERIFICATION_CACHE_FILE = ".vibedoctor/tool-verification.json";
281
+ /**
282
+ * Identity of the file that answered the probe. A tool's version output cannot
283
+ * change unless the file does, so this is safe to cache against — and some tools
284
+ * are slow enough to matter: Semgrep takes the better part of a minute just to
285
+ * report its own version.
286
+ */
287
+ function fingerprintFile(filePath) {
288
+ if (!filePath) {
289
+ return undefined;
290
+ }
291
+ try {
292
+ const stats = (0, node_fs_1.statSync)(filePath);
293
+ return `${filePath}:${stats.size}:${Math.round(stats.mtimeMs)}`;
294
+ }
295
+ catch {
296
+ return undefined;
297
+ }
298
+ }
299
+ async function loadVerificationCache(root) {
300
+ try {
301
+ const parsed = JSON.parse(await node_fs_1.promises.readFile(node_path_1.default.join(root, VERIFICATION_CACHE_FILE), "utf8"));
302
+ if (parsed.version !== 1 || !Array.isArray(parsed.entries)) {
303
+ return new Map();
304
+ }
305
+ return new Map(parsed.entries.map((entry) => [entry.id, entry]));
306
+ }
307
+ catch {
308
+ return new Map();
309
+ }
310
+ }
311
+ async function saveVerificationCache(root, entries) {
312
+ try {
313
+ const target = node_path_1.default.join(root, VERIFICATION_CACHE_FILE);
314
+ await node_fs_1.promises.mkdir(node_path_1.default.dirname(target), { recursive: true });
315
+ await node_fs_1.promises.writeFile(target, `${JSON.stringify({ version: 1, entries }, null, 2)}\n`, "utf8");
316
+ }
317
+ catch {
318
+ // A cache that cannot be written only costs time on the next run.
319
+ }
320
+ }
321
+ async function verifyTools(entries, root, depth = "execute") {
322
+ const runtimes = await probeRuntimesFor(entries, root, depth);
323
+ if (depth === "resolve") {
324
+ // Resolution is a filesystem lookup; caching it would only add staleness.
325
+ return Promise.all(entries.map((entry) => verifyTool(entry, { root, runtimes, depth })));
326
+ }
327
+ const cache = await loadVerificationCache(root);
328
+ const results = await Promise.all(entries.map(async (entry) => {
329
+ const cached = cache.get(entry.id);
330
+ if (cached && entry.executable) {
331
+ const current = fingerprintFile((0, executable_1.resolveExecutable)(entry.executable, root)?.path);
332
+ if (current && current === cached.fingerprint) {
333
+ const { fingerprint: _fingerprint, checkedAt: _checkedAt, ...verification } = cached;
334
+ return { verification, cacheEntry: cached };
335
+ }
336
+ }
337
+ const verification = await verifyTool(entry, { root, runtimes, depth });
338
+ const fingerprint = fingerprintFile(verification.resolvedPath);
339
+ return {
340
+ verification,
341
+ // Only a result tied to a specific file can be invalidated reliably, so
342
+ // only those are cached.
343
+ cacheEntry: fingerprint && verification.state === "verified"
344
+ ? { ...verification, fingerprint, checkedAt: new Date().toISOString() }
345
+ : undefined
346
+ };
347
+ }));
348
+ await saveVerificationCache(root, results.map((result) => result.cacheEntry).filter((entry) => Boolean(entry)));
349
+ return results.map((result) => result.verification);
350
+ }
351
+ function summarizeVerification(verification) {
352
+ const where = verification.resolvedPath ?? verification.interpreterPath;
353
+ const version = verification.version ? ` ${verification.version}` : "";
354
+ switch (verification.state) {
355
+ case "verified":
356
+ return `${verification.id}${version} — verified${where ? ` at ${where}` : ""}`;
357
+ case "not_found":
358
+ return `${verification.id} — NOT FOUND: ${verification.reason}`;
359
+ case "broken":
360
+ return `${verification.id} — BROKEN: ${verification.reason}`;
361
+ case "incompatible_runtime":
362
+ return `${verification.id} — RUNTIME MISMATCH: ${verification.reason}`;
363
+ case "unverifiable":
364
+ return `${verification.id} — UNVERIFIED: ${verification.reason}`;
365
+ }
366
+ }
367
+ function formatVersionForDisplay(value) {
368
+ const parsed = (0, semverLite_1.parseVersion)(value);
369
+ return parsed ? (0, semverLite_1.formatVersion)(parsed) : (value ?? "unknown");
370
+ }
@@ -0,0 +1,11 @@
1
+ import type { DpdpScanResult } from "./types";
2
+ export declare const DPDP_ARTIFACT_DIR = ".vibedoctor/dpdp";
3
+ export declare const DPDP_READINESS_REPORT = "readiness-report.json";
4
+ export declare function writeDpdpArtifacts(root: string, result: DpdpScanResult): Promise<string[]>;
5
+ export declare function serializeDpdpReport(result: DpdpScanResult): Record<string, unknown>;
6
+ export declare function readDpdpArtifact<T>(root: string, name: string): Promise<T | undefined>;
7
+ /**
8
+ * Load a previously written DPDP scan result from artifacts without re-scanning.
9
+ * Requires readiness-report.json (and preferably evidence-ledger.json).
10
+ */
11
+ export declare function loadCachedDpdpScanResult(root: string): Promise<DpdpScanResult | undefined>;
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DPDP_READINESS_REPORT = exports.DPDP_ARTIFACT_DIR = void 0;
7
+ exports.writeDpdpArtifacts = writeDpdpArtifacts;
8
+ exports.serializeDpdpReport = serializeDpdpReport;
9
+ exports.readDpdpArtifact = readDpdpArtifact;
10
+ exports.loadCachedDpdpScanResult = loadCachedDpdpScanResult;
11
+ const node_fs_1 = require("node:fs");
12
+ const node_path_1 = __importDefault(require("node:path"));
13
+ const paths_1 = require("../core/paths");
14
+ const reviewQueue_1 = require("./reviewQueue");
15
+ const report_1 = require("./report");
16
+ exports.DPDP_ARTIFACT_DIR = ".vibedoctor/dpdp";
17
+ exports.DPDP_READINESS_REPORT = "readiness-report.json";
18
+ async function writeDpdpArtifacts(root, result) {
19
+ const dir = node_path_1.default.join(root, exports.DPDP_ARTIFACT_DIR);
20
+ await (0, paths_1.ensureDir)(dir);
21
+ const files = [
22
+ { name: "data-map.json", content: `${JSON.stringify(result.dataMap, null, 2)}\n` },
23
+ { name: "control-matrix.json", content: `${JSON.stringify(result.controlMatrix, null, 2)}\n` },
24
+ { name: "evidence-ledger.json", content: `${JSON.stringify(result.evidenceLedger, null, 2)}\n` },
25
+ { name: "review-queue.md", content: (0, reviewQueue_1.renderReviewQueueMarkdown)(result.reviewQueue) },
26
+ { name: "agent-handoff.md", content: (0, report_1.renderAgentHandoff)(result) },
27
+ { name: "readiness-report.json", content: `${JSON.stringify(serializeDpdpReport(result), null, 2)}\n` },
28
+ { name: "readiness-report.md", content: (0, report_1.renderDpdpMarkdownReport)(result) },
29
+ { name: "readiness-report.html", content: (0, report_1.renderDpdpHtmlReport)(result) }
30
+ ];
31
+ const written = [];
32
+ for (const file of files) {
33
+ const absolute = node_path_1.default.join(dir, file.name);
34
+ await node_fs_1.promises.writeFile(absolute, file.content, "utf8");
35
+ written.push(node_path_1.default.join(exports.DPDP_ARTIFACT_DIR, file.name).replaceAll("\\", "/"));
36
+ }
37
+ return written;
38
+ }
39
+ function serializeDpdpReport(result) {
40
+ return {
41
+ version: result.version,
42
+ generatedAt: result.generatedAt,
43
+ disclaimer: result.disclaimer,
44
+ mode: result.mode,
45
+ legalSourceVersion: result.legalSourceVersion,
46
+ scores: result.scores,
47
+ summary: result.scores.statusCounts,
48
+ dataMap: result.dataMap,
49
+ controlMatrix: result.controlMatrix,
50
+ reviewQueue: result.reviewQueue,
51
+ fixNext: result.fixNext,
52
+ capabilities: result.capabilities,
53
+ findings: result.findings,
54
+ context: result.context,
55
+ baselineApplied: result.baselineApplied
56
+ };
57
+ }
58
+ async function readDpdpArtifact(root, name) {
59
+ const absolute = node_path_1.default.join(root, exports.DPDP_ARTIFACT_DIR, name);
60
+ try {
61
+ return JSON.parse(await node_fs_1.promises.readFile(absolute, "utf8"));
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ /**
68
+ * Load a previously written DPDP scan result from artifacts without re-scanning.
69
+ * Requires readiness-report.json (and preferably evidence-ledger.json).
70
+ */
71
+ async function loadCachedDpdpScanResult(root) {
72
+ const report = await readDpdpArtifact(root, exports.DPDP_READINESS_REPORT);
73
+ if (!report?.scores || !report?.controlMatrix) {
74
+ return undefined;
75
+ }
76
+ const evidenceLedger = (await readDpdpArtifact(root, "evidence-ledger.json")) ??
77
+ {
78
+ version: 1,
79
+ generatedAt: String(report.generatedAt ?? ""),
80
+ disclaimer: String(report.disclaimer ?? ""),
81
+ evidence: [],
82
+ declared: []
83
+ };
84
+ const dataMapRaw = (await readDpdpArtifact(root, "data-map.json")) ??
85
+ report.dataMap;
86
+ if (!dataMapRaw) {
87
+ return undefined;
88
+ }
89
+ const dataMap = {
90
+ ...dataMapRaw,
91
+ graph: dataMapRaw.graph ?? { nodes: [], edges: [] }
92
+ };
93
+ return {
94
+ version: 1,
95
+ generatedAt: String(report.generatedAt ?? ""),
96
+ root,
97
+ mode: report.mode ?? "full",
98
+ disclaimer: String(report.disclaimer ?? ""),
99
+ scores: report.scores,
100
+ dataMap,
101
+ controlMatrix: report.controlMatrix,
102
+ evidenceLedger,
103
+ reviewQueue: report.reviewQueue ?? [],
104
+ fixNext: report.fixNext ??
105
+ [],
106
+ capabilities: report.capabilities ?? [],
107
+ findings: report.findings ?? [],
108
+ legalSourceVersion: String(report.legalSourceVersion ?? ""),
109
+ context: report.context ?? {
110
+ version: 1,
111
+ organization: {
112
+ processesPersonalData: "unknown",
113
+ isSignificantDataFiduciary: "unknown",
114
+ processesChildrenData: "unknown",
115
+ hasCrossBorderTransfer: "unknown"
116
+ }
117
+ },
118
+ baselineApplied: Boolean(report.baselineApplied)
119
+ };
120
+ }
@@ -0,0 +1,14 @@
1
+ import type { ControlDefinition, VerificationClass } from "./types";
2
+ /**
3
+ * Machine-readable DPDP obligation catalogue for technical readiness assessment.
4
+ * Every control has verification class, legal reference, and evaluator linkage where deterministic.
5
+ */
6
+ export declare const DPDP_CONTROLS: ControlDefinition[];
7
+ export declare function getControlById(id: string): ControlDefinition | undefined;
8
+ export declare function controlsByDomain(): Record<string, ControlDefinition[]>;
9
+ export declare function controlsForVerificationClass(vc: VerificationClass): ControlDefinition[];
10
+ export declare const DPDP_CATALOGUE_META: {
11
+ version: string;
12
+ controlCount: number;
13
+ disclaimer: string;
14
+ };