@neuralaxis/vibedoctor 0.1.3 → 0.2.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.
Files changed (78) hide show
  1. package/README.md +213 -116
  2. package/dist/adapters/dpdp.d.ts +6 -0
  3. package/dist/adapters/dpdp.js +34 -0
  4. package/dist/adapters/index.d.ts +1 -0
  5. package/dist/adapters/index.js +3 -1
  6. package/dist/adapters/presidio.js +3 -1
  7. package/dist/adapters/privacyDetector.d.ts +24 -1
  8. package/dist/adapters/privacyDetector.js +86 -2
  9. package/dist/adapters/shared.d.ts +6 -0
  10. package/dist/agentPack/templates/skills.js +159 -53
  11. package/dist/cli/commands/dpdp.d.ts +35 -0
  12. package/dist/cli/commands/dpdp.js +103 -0
  13. package/dist/cli/commands/scan.js +4 -1
  14. package/dist/cli/commands/setup.js +1 -1
  15. package/dist/cli/index.js +84 -0
  16. package/dist/core/config.d.ts +21 -0
  17. package/dist/core/config.js +89 -4
  18. package/dist/core/engine.js +22 -3
  19. package/dist/core/finding.d.ts +1 -1
  20. package/dist/core/finding.js +1 -0
  21. package/dist/core/scanPlanner.js +10 -2
  22. package/dist/dpdp/artifacts.d.ts +11 -0
  23. package/dist/dpdp/artifacts.js +120 -0
  24. package/dist/dpdp/catalogue.d.ts +14 -0
  25. package/dist/dpdp/catalogue.js +661 -0
  26. package/dist/dpdp/collectors/confidence.d.ts +9 -0
  27. package/dist/dpdp/collectors/confidence.js +25 -0
  28. package/dist/dpdp/collectors/dependencies.d.ts +7 -0
  29. package/dist/dpdp/collectors/dependencies.js +63 -0
  30. package/dist/dpdp/collectors/index.d.ts +24 -0
  31. package/dist/dpdp/collectors/index.js +71 -0
  32. package/dist/dpdp/collectors/lifecycle.d.ts +2 -0
  33. package/dist/dpdp/collectors/lifecycle.js +202 -0
  34. package/dist/dpdp/collectors/optionalScanners.d.ts +14 -0
  35. package/dist/dpdp/collectors/optionalScanners.js +347 -0
  36. package/dist/dpdp/collectors/privacyBridge.d.ts +13 -0
  37. package/dist/dpdp/collectors/privacyBridge.js +152 -0
  38. package/dist/dpdp/collectors/safeguards.d.ts +5 -0
  39. package/dist/dpdp/collectors/safeguards.js +186 -0
  40. package/dist/dpdp/collectors/schema.d.ts +6 -0
  41. package/dist/dpdp/collectors/schema.js +122 -0
  42. package/dist/dpdp/collectors/shared.d.ts +10 -0
  43. package/dist/dpdp/collectors/shared.js +43 -0
  44. package/dist/dpdp/context.d.ts +28 -0
  45. package/dist/dpdp/context.js +195 -0
  46. package/dist/dpdp/dataMap.d.ts +7 -0
  47. package/dist/dpdp/dataMap.js +339 -0
  48. package/dist/dpdp/evaluators.d.ts +20 -0
  49. package/dist/dpdp/evaluators.js +522 -0
  50. package/dist/dpdp/evidence.d.ts +11 -0
  51. package/dist/dpdp/evidence.js +123 -0
  52. package/dist/dpdp/findings.d.ts +14 -0
  53. package/dist/dpdp/findings.js +99 -0
  54. package/dist/dpdp/gates.d.ts +14 -0
  55. package/dist/dpdp/gates.js +47 -0
  56. package/dist/dpdp/index.d.ts +16 -0
  57. package/dist/dpdp/index.js +32 -0
  58. package/dist/dpdp/legalSources.d.ts +10 -0
  59. package/dist/dpdp/legalSources.js +104 -0
  60. package/dist/dpdp/paths.d.ts +25 -0
  61. package/dist/dpdp/paths.js +85 -0
  62. package/dist/dpdp/report.d.ts +6 -0
  63. package/dist/dpdp/report.js +222 -0
  64. package/dist/dpdp/reviewQueue.d.ts +3 -0
  65. package/dist/dpdp/reviewQueue.js +88 -0
  66. package/dist/dpdp/scan.d.ts +26 -0
  67. package/dist/dpdp/scan.js +310 -0
  68. package/dist/dpdp/scoring.d.ts +31 -0
  69. package/dist/dpdp/scoring.js +211 -0
  70. package/dist/dpdp/types.d.ts +294 -0
  71. package/dist/dpdp/types.js +86 -0
  72. package/dist/index.d.ts +1 -0
  73. package/dist/index.js +1 -0
  74. package/dist/mcp/tools/dpdp.d.ts +11 -0
  75. package/dist/mcp/tools/dpdp.js +151 -0
  76. package/dist/mcp/tools/index.js +3 -1
  77. package/dist/reporters/json.js +6 -1
  78. package/package.json +4 -1
@@ -8,6 +8,8 @@ exports.confidenceFromScore = confidenceFromScore;
8
8
  exports.passesLuhn = passesLuhn;
9
9
  exports.isValidAadhaar = isValidAadhaar;
10
10
  exports.maskPiiValue = maskPiiValue;
11
+ exports.clearPrivacyFindingsCache = clearPrivacyFindingsCache;
12
+ exports.getPrivacyFindingsCacheStats = getPrivacyFindingsCacheStats;
11
13
  exports.detectPiiFindings = detectPiiFindings;
12
14
  exports.normalizeExternalFile = normalizeExternalFile;
13
15
  const node_fs_1 = require("node:fs");
@@ -459,9 +461,64 @@ async function readCandidate(root, file, maxFileBytes) {
459
461
  function passesConfidenceThreshold(finding, minimum) {
460
462
  return CONFIDENCE_RANK[finding.confidence] >= CONFIDENCE_RANK[minimum];
461
463
  }
462
- async function detectPiiFindings(ctx) {
464
+ /** Process-lifetime cache: privacy adapter + DPDP collectors often scan the same tree once per run. */
465
+ const privacyFindingsCache = new Map();
466
+ let privacyCacheHits = 0;
467
+ let privacyCacheMisses = 0;
468
+ function clearPrivacyFindingsCache() {
469
+ privacyFindingsCache.clear();
470
+ privacyCacheHits = 0;
471
+ privacyCacheMisses = 0;
472
+ }
473
+ function getPrivacyFindingsCacheStats() {
474
+ return {
475
+ size: privacyFindingsCache.size,
476
+ hits: privacyCacheHits,
477
+ misses: privacyCacheMisses
478
+ };
479
+ }
480
+ function privacyConfigFingerprint(ctx) {
481
+ const privacy = ctx.config.checks.privacy;
482
+ return JSON.stringify({
483
+ minConfidenceToReport: privacy.minConfidenceToReport,
484
+ maskExamples: privacy.maskExamples,
485
+ maxFileBytes: privacy.maxFileBytes,
486
+ detectUnsanitizedLogs: privacy.detectUnsanitizedLogs,
487
+ detectApiOverfetching: privacy.detectApiOverfetching,
488
+ detectMissingRetention: privacy.detectMissingRetention
489
+ });
490
+ }
491
+ function resolvePrivacyCandidates(ctx, options) {
492
+ if (options.fileAllowlist !== undefined) {
493
+ return options.fileAllowlist.filter(isTextCandidate).map((file) => file.replaceAll("\\", "/")).sort();
494
+ }
495
+ return (0, paths_1.filterPaths)(ctx.project.projectFiles, options.include ?? ctx.config.paths.include, options.exclude ?? ctx.config.paths.exclude)
496
+ .filter(isTextCandidate)
497
+ .map((file) => file.replaceAll("\\", "/"))
498
+ .sort();
499
+ }
500
+ async function buildPrivacyFindingsCacheKey(ctx, options, candidates) {
501
+ const fileVersions = [];
502
+ for (const candidate of candidates) {
503
+ const stat = await node_fs_1.promises.stat(node_path_1.default.join(ctx.root, candidate)).catch(() => undefined);
504
+ fileVersions.push(`${candidate}:${stat?.size ?? -1}:${stat?.mtimeMs ?? -1}`);
505
+ }
506
+ return [
507
+ ctx.root,
508
+ privacyConfigFingerprint(ctx),
509
+ fileVersions.join("\n"),
510
+ JSON.stringify({
511
+ include: options.include ?? null,
512
+ exclude: options.exclude ?? null,
513
+ allowlist: options.fileAllowlist !== undefined
514
+ })
515
+ ].join("::");
516
+ }
517
+ function cloneFindings(findings) {
518
+ return structuredClone(findings);
519
+ }
520
+ async function detectPiiFindingsUncached(ctx, candidates) {
463
521
  const privacyCfg = ctx.config.checks.privacy;
464
- const candidates = (0, paths_1.filterPaths)(ctx.project.projectFiles, ctx.config.paths.include, ctx.config.paths.exclude).filter(isTextCandidate);
465
522
  const findings = [];
466
523
  for (const file of candidates) {
467
524
  const content = await readCandidate(ctx.root, file, privacyCfg.maxFileBytes);
@@ -583,6 +640,33 @@ async function detectPiiFindings(ctx) {
583
640
  }
584
641
  return findings.filter((finding) => passesConfidenceThreshold(finding, privacyCfg.minConfidenceToReport));
585
642
  }
643
+ /**
644
+ * Deterministic privacy scan with process-lifetime cache.
645
+ * Concurrent callers with the same key share one in-flight computation (dedupes privacy + DPDP double walks).
646
+ */
647
+ async function detectPiiFindings(ctx, options = {}) {
648
+ const candidates = resolvePrivacyCandidates(ctx, options);
649
+ if (options.skipCache) {
650
+ return detectPiiFindingsUncached(ctx, candidates);
651
+ }
652
+ const key = await buildPrivacyFindingsCacheKey(ctx, options, candidates);
653
+ const existing = privacyFindingsCache.get(key);
654
+ if (existing) {
655
+ privacyCacheHits += 1;
656
+ return cloneFindings(await existing);
657
+ }
658
+ privacyCacheMisses += 1;
659
+ const pending = detectPiiFindingsUncached(ctx, candidates);
660
+ privacyFindingsCache.set(key, pending);
661
+ try {
662
+ const findings = await pending;
663
+ return cloneFindings(findings);
664
+ }
665
+ catch (error) {
666
+ privacyFindingsCache.delete(key);
667
+ throw error;
668
+ }
669
+ }
586
670
  exports.privacyDetectorAdapter = {
587
671
  id: "privacy-detector",
588
672
  category: "privacy",
@@ -7,6 +7,12 @@ export type ToolAdapterContext = {
7
7
  project: ProjectContext;
8
8
  config: VibeDoctorConfig;
9
9
  scanMode: "default" | "changed" | "quick" | "full";
10
+ /** Results already produced by the scan engine, available to dependent adapters for reuse. */
11
+ sharedToolResults?: Record<string, SharedToolExecution>;
12
+ };
13
+ export type SharedToolExecution = {
14
+ findings: Finding[];
15
+ status?: ToolResult;
10
16
  };
11
17
  export type ToolAdapter = {
12
18
  id: string;
@@ -60,14 +60,14 @@ vibedoctor scan --changed --report json
60
60
  vibedoctor scan --full --report json
61
61
  \`\`\`
62
62
 
63
- 3. Read \`.vibedoctor/report.json\`.
64
-
65
- 4. Check \`completeness.status\` before changing code:
66
- - \`complete\`: the score is comparable and findings can be prioritized.
67
- - \`partial\` or \`invalid\`: run every command in \`recoveryActions\` first.
68
- - If recovery fails, disclose the missing coverage and request human review before risky edits.
69
-
70
- 5. Prioritize validated findings in this order:
63
+ 3. Read \`.vibedoctor/report.json\`.
64
+
65
+ 4. Check \`completeness.status\` before changing code:
66
+ - \`complete\`: the score is comparable and findings can be prioritized.
67
+ - \`partial\` or \`invalid\`: run every command in \`recoveryActions\` first.
68
+ - If recovery fails, disclose the missing coverage and request human review before risky edits.
69
+
70
+ 5. Prioritize validated findings in this order:
71
71
  - security blockers
72
72
  - correctness blockers
73
73
  - failing tests
@@ -84,8 +84,8 @@ Give only:
84
84
  - blockers
85
85
  - safest next command
86
86
  - top 3 fixes
87
- - whether work is safe to continue
88
- - scan completeness and any missing tool coverage
87
+ - whether work is safe to continue
88
+ - scan completeness and any missing tool coverage
89
89
 
90
90
  Do not paste the full JSON unless the user asks.
91
91
  `),
@@ -125,52 +125,158 @@ Report:
125
125
  - remaining blockers
126
126
  - verification result
127
127
  `),
128
- createSkill("vibedoctor-privacy-review", "Review VibeDoctor Privacy Review findings with masked evidence, deterministic scan output, and optional API-key adjudication. Use when asked to find PII, review personal data exposure, inspect shift-report data risk, or validate Privacy Review findings.", `
129
- # VibeDoctor Privacy Review
130
-
131
- Use this skill for personal-data and PII discovery findings.
132
-
133
- ## Default workflow
134
-
135
- 1. Run the deterministic privacy scan:
136
-
137
- \`\`\`bash
138
- vibedoctor scan --category privacy --report json
139
- \`\`\`
140
-
141
- 2. Read \`.vibedoctor/report.json\`, focusing on \`privacyFindings\`.
142
-
143
- 3. Group findings into:
144
- - confirmed regulated identifiers
145
- - likely personal data
146
- - combination-risk fields
147
- - false positives or needs human review
148
-
149
- 4. Use masked evidence only. Do not request raw values unless the user explicitly asks and the repository policy allows it.
150
-
151
- ## Optional API-key review
152
-
153
- Only run this command when \`checks.privacy.ai.enabled\` is true and the required env vars are configured:
154
-
155
- \`\`\`bash
156
- vibedoctor privacy-review --refresh --format markdown
157
- \`\`\`
158
-
159
- ## Review rules
128
+ createSkill("vibedoctor-privacy-review", "Review VibeDoctor Privacy Review findings with masked evidence, deterministic scan output, and optional API-key adjudication. Use when asked to find PII, review personal data exposure, inspect shift-report data risk, or validate Privacy Review findings.", `
129
+ # VibeDoctor Privacy Review
130
+
131
+ Use this skill for personal-data and PII discovery findings.
132
+
133
+ ## Default workflow
134
+
135
+ 1. Run the deterministic privacy scan:
136
+
137
+ \`\`\`bash
138
+ vibedoctor scan --category privacy --report json
139
+ \`\`\`
140
+
141
+ 2. Read \`.vibedoctor/report.json\`, focusing on \`privacyFindings\`.
142
+
143
+ 3. Group findings into:
144
+ - confirmed regulated identifiers
145
+ - likely personal data
146
+ - combination-risk fields
147
+ - false positives or needs human review
148
+
149
+ 4. Use masked evidence only. Do not request raw values unless the user explicitly asks and the repository policy allows it.
150
+
151
+ ## Optional API-key review
152
+
153
+ Only run this command when \`checks.privacy.ai.enabled\` is true and the required env vars are configured:
154
+
155
+ \`\`\`bash
156
+ vibedoctor privacy-review --refresh --format markdown
157
+ \`\`\`
158
+
159
+ ## Review rules
160
+
161
+ - Keep secrets separate from PII; Gitleaks findings are handled by the security workflow.
162
+ - Treat medium-confidence Privacy Review findings as review candidates, not automatic truth.
163
+ - For regulated identifiers or sensitive attributes, recommend removal, anonymization, or controlled test fixtures.
164
+ - For combination risk, explain which fields create the re-identification risk together.
165
+
166
+ ## Output
167
+
168
+ Return:
169
+ - confirmed PII findings
170
+ - likely false positives
171
+ - evidence used
172
+ - recommended action
173
+ - whether API-key review was used
174
+ `),
175
+ createSkill("vibedoctor-dpdp-readiness-review", "Run DPDP technical readiness review using deterministic VibeDoctor DPDP artifacts. Use when asked about DPDP, India data protection technical controls, personal-data maps, consent/erasure gaps, processor signals, or engineering risk against DPDP — never for legal certification.", `
176
+ # VibeDoctor DPDP Readiness Review
177
+
178
+ This skill supports **DPDP technical readiness / engineering-risk assessment**.
179
+ It is **not** legal advice and **not** a compliance certification.
180
+
181
+ ## Hard rules
182
+
183
+ 1. Consume deterministic artifacts; do not implement a competing compliance engine.
184
+ 2. Never independently mark DETERMINISTIC controls as passed if the control matrix says otherwise.
185
+ 3. Never invent evidence.
186
+ 4. Never claim legal certification.
187
+ 5. Never calculate a separate legal compliance percentage or score.
188
+ 6. Declared evidence is not deterministic verification.
189
+ 7. Preserve provenance and uncertainty in every answer.
190
+ 8. After code changes, re-run deterministic verification.
191
+ 9. Treat the bundled legal-source manifest as a versioned offline baseline, not proof that the law is current.
160
192
 
161
- - Keep secrets separate from PII; Gitleaks findings are handled by the security workflow.
162
- - Treat medium-confidence Privacy Review findings as review candidates, not automatic truth.
163
- - For regulated identifiers or sensitive attributes, recommend removal, anonymization, or controlled test fixtures.
164
- - For combination risk, explain which fields create the re-identification risk together.
193
+ ## Legal-source freshness gate
165
194
 
166
- ## Output
195
+ Perform this gate whenever the answer interprets a control against DPDP law, rules, commencement, or enforcement status.
167
196
 
168
- Return:
169
- - confirmed PII findings
170
- - likely false positives
171
- - evidence used
172
- - recommended action
173
- - whether API-key review was used
197
+ 1. Read \`legalSourceVersion\` and the legal citations in the control matrix or report.
198
+ 2. Use current web research to find the latest official primary sources. Check, as applicable:
199
+ - the Digital Personal Data Protection Act and later amendments
200
+ - final Rules and later amendments or corrigenda
201
+ - commencement and enforcement notifications
202
+ - Data Protection Board or other notifications only when relevant to the controls under review
203
+ 3. Prefer official Government of India sources, including \`meity.gov.in\`, \`indiacode.nic.in\`, and \`egazette.nic.in\`. Search results, blogs, news, and law-firm summaries may help discovery but are not authority.
204
+ 4. For each official source used, record its title, URL, Act/Gazette/notification identifier, publication date, effective date or phased schedule, and the date checked. Use exact citations; do not reproduce long passages.
205
+ 5. Compare the current official sources with the bundled manifest and its \`legalSourceVersion\`.
206
+ 6. If an official source is newer or materially different, label the result \`LEGAL_SOURCE_DRIFT\`. Identify affected control IDs and citations, keep the deterministic technical statuses unchanged, and recommend updating the versioned catalogue plus qualified legal review.
207
+ 7. If live research is unavailable, official pages cannot be reached, or currency cannot be established, label the result \`CURRENT_LEGAL_SOURCES_NOT_VERIFIED\`. You may use the bundled manifest as an offline baseline, but do not claim the legal position is current.
208
+ 8. Never silently use live research to change deterministic findings, scores, or control statuses. Present current-law observations separately from technical scan results.
209
+
210
+ ## Default workflow
211
+
212
+ 1. Run or refresh the deterministic scan:
213
+
214
+ \`\`\`bash
215
+ vibedoctor dpdp scan --full
216
+ \`\`\`
217
+
218
+ 2. Read these artifacts (source of truth):
219
+ - \`.vibedoctor/dpdp/data-map.json\`
220
+ - \`.vibedoctor/dpdp/control-matrix.json\`
221
+ - \`.vibedoctor/dpdp/evidence-ledger.json\`
222
+ - \`.vibedoctor/dpdp/review-queue.md\`
223
+ - \`.vibedoctor/dpdp/agent-handoff.md\` (or run \`vibedoctor dpdp handoff\`)
224
+
225
+ 3. Do **not** re-ask questions already answered by deterministic evidence.
226
+
227
+ 4. Group unresolved questions by audience from the review queue:
228
+ - developer
229
+ - security
230
+ - product
231
+ - legal
232
+ - operations
233
+ - founder
234
+
235
+ 5. Ask the **minimum** number of questions needed.
236
+
237
+ 6. Review any supplied policies and \`.vibedoctor/dpdp/evidence.yml\` declarations.
238
+ Compare declared policy against implementation signals in the data map.
239
+
240
+ 7. Produce remediation grouped into:
241
+ - code
242
+ - configuration
243
+ - documentation
244
+ - organisational work
245
+
246
+ 8. After code/config changes:
247
+
248
+ \`\`\`bash
249
+ vibedoctor dpdp verify
250
+ \`\`\`
251
+
252
+ ## Output format
253
+
254
+ \`\`\`text
255
+ DPDP technical posture (not legal compliance):
256
+ Legal-source freshness: verified as of <date> | LEGAL_SOURCE_DRIFT | CURRENT_LEGAL_SOURCES_NOT_VERIFIED
257
+ Official sources checked:
258
+ Bundled-manifest drift:
259
+ Evidence completeness:
260
+ Personal-data categories:
261
+ Stores / external recipients:
262
+ Verified technical risks (violations):
263
+ Partial controls:
264
+ Human-review items (by audience):
265
+ Skipped capabilities:
266
+ Fix-next (code/config first):
267
+ Questions still needed:
268
+ What was not verified:
269
+ \`\`\`
270
+
271
+ ## Scoring language
272
+
273
+ Only cite scores from the deterministic report:
274
+ - technical posture score
275
+ - evidence completeness percentage
276
+ - open-risk counts by severity
277
+ - status counts
278
+
279
+ Label them as **technical readiness**, never as legal compliance.
174
280
  `),
175
281
  createSkill("vibedoctor-dead-code-cleanup", "Review and clean high-confidence dead code chains, unused exports, unused files, unused dependencies, commented-out code, legacy fallbacks, and AI-created leftovers found by VibeDoctor. Use when asked to remove dead code, clean leftovers, reduce legacy baggage, or simplify AI-generated code.", `
176
282
  # VibeDoctor Dead Code Cleanup
@@ -0,0 +1,35 @@
1
+ import type { ControlMatrix, DpdpScanMode, DpdpScanResult, PersonalDataMap } from "../../dpdp/types";
2
+ export type DpdpCommandResult = {
3
+ output: string;
4
+ exitCode: number;
5
+ };
6
+ export declare function runDpdpInitCommand(root: string): Promise<DpdpCommandResult>;
7
+ export declare function runDpdpScanCommand(root: string, options?: {
8
+ full?: boolean;
9
+ changed?: boolean;
10
+ report?: "terminal" | "json" | "html" | "markdown";
11
+ }): Promise<DpdpCommandResult>;
12
+ export declare function runDpdpMapCommand(root: string, options?: {
13
+ refresh?: boolean;
14
+ }): Promise<DpdpCommandResult>;
15
+ export declare function runDpdpReviewQueueCommand(root: string, options?: {
16
+ refresh?: boolean;
17
+ }): Promise<DpdpCommandResult>;
18
+ export declare function runDpdpReportCommand(root: string, options?: {
19
+ json?: boolean;
20
+ html?: boolean;
21
+ markdown?: boolean;
22
+ refresh?: boolean;
23
+ }): Promise<DpdpCommandResult>;
24
+ export declare function runDpdpHandoffCommand(root: string, options?: {
25
+ refresh?: boolean;
26
+ }): Promise<DpdpCommandResult>;
27
+ export declare function runDpdpVerifyCommand(root: string): Promise<DpdpCommandResult>;
28
+ export declare function runDpdpExplainCommand(root: string, id: string, options?: {
29
+ refresh?: boolean;
30
+ }): Promise<DpdpCommandResult>;
31
+ export declare function readCachedDataMap(root: string): Promise<PersonalDataMap | undefined>;
32
+ export declare function readCachedControlMatrix(root: string): Promise<ControlMatrix | undefined>;
33
+ export declare function ensureDpdpArtifactsExist(root: string): Promise<boolean>;
34
+ /** @deprecated Prefer loadOrScanDpdp from dpdp/scan — kept for internal callers. */
35
+ export declare function loadOrScan(root: string, mode: DpdpScanMode, refresh?: boolean): Promise<DpdpScanResult>;
@@ -0,0 +1,103 @@
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.runDpdpInitCommand = runDpdpInitCommand;
7
+ exports.runDpdpScanCommand = runDpdpScanCommand;
8
+ exports.runDpdpMapCommand = runDpdpMapCommand;
9
+ exports.runDpdpReviewQueueCommand = runDpdpReviewQueueCommand;
10
+ exports.runDpdpReportCommand = runDpdpReportCommand;
11
+ exports.runDpdpHandoffCommand = runDpdpHandoffCommand;
12
+ exports.runDpdpVerifyCommand = runDpdpVerifyCommand;
13
+ exports.runDpdpExplainCommand = runDpdpExplainCommand;
14
+ exports.readCachedDataMap = readCachedDataMap;
15
+ exports.readCachedControlMatrix = readCachedControlMatrix;
16
+ exports.ensureDpdpArtifactsExist = ensureDpdpArtifactsExist;
17
+ exports.loadOrScan = loadOrScan;
18
+ const node_fs_1 = require("node:fs");
19
+ const node_path_1 = __importDefault(require("node:path"));
20
+ const shared_1 = require("./shared");
21
+ const scan_1 = require("../../dpdp/scan");
22
+ const report_1 = require("../../dpdp/report");
23
+ const reviewQueue_1 = require("../../dpdp/reviewQueue");
24
+ const artifacts_1 = require("../../dpdp/artifacts");
25
+ const paths_1 = require("../../core/paths");
26
+ async function runDpdpInitCommand(root) {
27
+ const written = await (0, scan_1.initDpdpWorkspace)(root);
28
+ return {
29
+ output: `DPDP workspace ready.\n${written.map((item) => `- ${item}`).join("\n")}\n\nThis module provides DPDP technical readiness assessment, not legal certification.\n`,
30
+ exitCode: 0
31
+ };
32
+ }
33
+ async function runDpdpScanCommand(root, options = {}) {
34
+ const mode = options.changed ? "changed" : options.full ? "full" : "full";
35
+ const result = await (0, scan_1.runDpdpScan)(root, mode);
36
+ const { config } = await (0, shared_1.getConfig)(root);
37
+ const exitCode = (0, scan_1.determineDpdpExitCode)(result, config);
38
+ switch (options.report) {
39
+ case "json":
40
+ return { output: (0, report_1.renderDpdpJsonReport)(result), exitCode };
41
+ case "html":
42
+ return { output: (0, report_1.renderDpdpHtmlReport)(result), exitCode };
43
+ case "markdown":
44
+ return { output: (0, report_1.renderDpdpMarkdownReport)(result), exitCode };
45
+ default:
46
+ return { output: (0, report_1.renderDpdpTerminalReport)(result), exitCode };
47
+ }
48
+ }
49
+ async function runDpdpMapCommand(root, options = {}) {
50
+ const result = await (0, scan_1.loadOrScanDpdp)(root, "full", options.refresh === true);
51
+ return {
52
+ output: `${JSON.stringify(result.dataMap, null, 2)}\n`,
53
+ exitCode: 0
54
+ };
55
+ }
56
+ async function runDpdpReviewQueueCommand(root, options = {}) {
57
+ const result = await (0, scan_1.loadOrScanDpdp)(root, "full", options.refresh === true);
58
+ return {
59
+ output: (0, reviewQueue_1.renderReviewQueueMarkdown)(result.reviewQueue),
60
+ exitCode: 0
61
+ };
62
+ }
63
+ async function runDpdpReportCommand(root, options = {}) {
64
+ const result = await (0, scan_1.loadOrScanDpdp)(root, "full", options.refresh === true);
65
+ if (options.html) {
66
+ return { output: (0, report_1.renderDpdpHtmlReport)(result), exitCode: 0 };
67
+ }
68
+ if (options.markdown) {
69
+ return { output: (0, report_1.renderDpdpMarkdownReport)(result), exitCode: 0 };
70
+ }
71
+ return { output: (0, report_1.renderDpdpJsonReport)(result), exitCode: 0 };
72
+ }
73
+ async function runDpdpHandoffCommand(root, options = {}) {
74
+ const result = await (0, scan_1.loadOrScanDpdp)(root, "full", options.refresh === true);
75
+ const handoffPath = node_path_1.default.join(root, artifacts_1.DPDP_ARTIFACT_DIR, "agent-handoff.md");
76
+ const content = (0, report_1.renderAgentHandoff)(result);
77
+ await node_fs_1.promises.mkdir(node_path_1.default.dirname(handoffPath), { recursive: true });
78
+ await node_fs_1.promises.writeFile(handoffPath, content, "utf8");
79
+ return { output: content, exitCode: 0 };
80
+ }
81
+ async function runDpdpVerifyCommand(root) {
82
+ return runDpdpScanCommand(root, { changed: true, report: "terminal" });
83
+ }
84
+ async function runDpdpExplainCommand(root, id, options = {}) {
85
+ const explained = await (0, scan_1.explainDpdpTarget)(root, id, { refresh: options.refresh === true });
86
+ return {
87
+ output: `${JSON.stringify(explained, null, 2)}\n`,
88
+ exitCode: explained.type === "unknown" ? 1 : 0
89
+ };
90
+ }
91
+ async function readCachedDataMap(root) {
92
+ return (0, artifacts_1.readDpdpArtifact)(root, "data-map.json");
93
+ }
94
+ async function readCachedControlMatrix(root) {
95
+ return (0, artifacts_1.readDpdpArtifact)(root, "control-matrix.json");
96
+ }
97
+ async function ensureDpdpArtifactsExist(root) {
98
+ return (0, paths_1.pathExists)(node_path_1.default.join(root, artifacts_1.DPDP_ARTIFACT_DIR, "control-matrix.json"));
99
+ }
100
+ /** @deprecated Prefer loadOrScanDpdp from dpdp/scan — kept for internal callers. */
101
+ async function loadOrScan(root, mode, refresh = false) {
102
+ return (0, scan_1.loadOrScanDpdp)(root, mode, refresh);
103
+ }
@@ -10,6 +10,7 @@ const json_1 = require("../../reporters/json");
10
10
  const html_1 = require("../../reporters/html");
11
11
  const agent_1 = require("../../reporters/agent");
12
12
  const shared_1 = require("./shared");
13
+ const gates_1 = require("../../dpdp/gates");
13
14
  function shouldCountForFailure(isNew, config) {
14
15
  return config.baseline.failOnlyOnNewIssues ? isNew : true;
15
16
  }
@@ -58,13 +59,15 @@ function determineExitCode(scan, config) {
58
59
  isHighConfidence(finding) &&
59
60
  !isReviewedFalsePositive(finding) &&
60
61
  finding.evidence?.sensitivity === "high");
62
+ const dpdpFailure = (0, gates_1.evaluateDpdpFailureGate)(scan.findings.map(gates_1.findingToGateCandidate).filter((item) => item !== undefined), config);
61
63
  return secretFailure ||
62
64
  dependencyFailure ||
63
65
  missingDependencyFailure ||
64
66
  typeFailure ||
65
67
  testFailure ||
66
68
  regulatedIdentifierFailure ||
67
- sensitiveAttributeFailure
69
+ sensitiveAttributeFailure ||
70
+ dpdpFailure
68
71
  ? 1
69
72
  : 0;
70
73
  }
@@ -165,7 +165,7 @@ const recommendedTools = [
165
165
  id: "presidio",
166
166
  ecosystem: "manual",
167
167
  priority: "recommended",
168
- reason: "Optional external scanner for Privacy Review when checks.privacy.presidio.enabled is true.",
168
+ reason: "External PII analyzer used by privacy + DPDP scans by default (skipped gracefully if missing). The normal privacy and DPDP opt-outs are independent.",
169
169
  installHint: "Install in the project Python environment with: python -m pip install presidio-analyzer"
170
170
  }
171
171
  ];
package/dist/cli/index.js CHANGED
@@ -15,6 +15,7 @@ const fix_1 = require("./commands/fix");
15
15
  const init_1 = require("./commands/init");
16
16
  const server_1 = require("../mcp/server");
17
17
  const privacyReview_1 = require("./commands/privacyReview");
18
+ const dpdp_1 = require("./commands/dpdp");
18
19
  const report_1 = require("./commands/report");
19
20
  const scan_1 = require("./commands/scan");
20
21
  const setup_1 = require("./commands/setup");
@@ -201,6 +202,89 @@ async function main() {
201
202
  process.stdout.write(result.output);
202
203
  process.exit(result.exitCode);
203
204
  });
205
+ const dpdp = program
206
+ .command("dpdp")
207
+ .description("DPDP technical readiness assessment (not legal certification)");
208
+ dpdp
209
+ .command("init")
210
+ .description("Create optional DPDP context and declared-evidence scaffolding")
211
+ .action(async () => {
212
+ const result = await (0, dpdp_1.runDpdpInitCommand)(process.cwd());
213
+ process.stdout.write(result.output);
214
+ process.exit(result.exitCode);
215
+ });
216
+ dpdp
217
+ .command("scan")
218
+ .description("Run deterministic DPDP technical readiness scan")
219
+ .option("--full", "Full repository scan (default)", true)
220
+ .option("--changed", "Collect evidence only from git changed files (falls back to full scope if no delta); control matrix remains full catalogue")
221
+ .option("--report <format>", "terminal|json|html|markdown", "terminal")
222
+ .action(async (options) => {
223
+ const result = await (0, dpdp_1.runDpdpScanCommand)(process.cwd(), {
224
+ full: !options.changed,
225
+ changed: Boolean(options.changed),
226
+ report: options.report
227
+ });
228
+ process.stdout.write(result.output);
229
+ process.exit(result.exitCode);
230
+ });
231
+ dpdp
232
+ .command("map")
233
+ .description("Print the personal-data processing map JSON (uses cached artifacts unless --refresh)")
234
+ .option("--refresh", "Force a new scan before printing", false)
235
+ .action(async (options) => {
236
+ const result = await (0, dpdp_1.runDpdpMapCommand)(process.cwd(), { refresh: Boolean(options.refresh) });
237
+ process.stdout.write(result.output);
238
+ process.exit(result.exitCode);
239
+ });
240
+ dpdp
241
+ .command("review-queue")
242
+ .description("Print human-review questions grouped by audience (uses cached artifacts unless --refresh)")
243
+ .option("--refresh", "Force a new scan before printing", false)
244
+ .action(async (options) => {
245
+ const result = await (0, dpdp_1.runDpdpReviewQueueCommand)(process.cwd(), { refresh: Boolean(options.refresh) });
246
+ process.stdout.write(result.output);
247
+ process.exit(result.exitCode);
248
+ });
249
+ dpdp
250
+ .command("report")
251
+ .description("Emit DPDP readiness report (uses cached artifacts unless --refresh)")
252
+ .option("--json", "JSON report")
253
+ .option("--html", "HTML report")
254
+ .option("--markdown", "Markdown report")
255
+ .option("--refresh", "Force a new scan before reporting", false)
256
+ .action(async (options) => {
257
+ const result = await (0, dpdp_1.runDpdpReportCommand)(process.cwd(), options);
258
+ process.stdout.write(result.output);
259
+ process.exit(result.exitCode);
260
+ });
261
+ dpdp
262
+ .command("handoff")
263
+ .description("Generate agent handoff markdown from deterministic artifacts (cached unless --refresh)")
264
+ .option("--refresh", "Force a new scan before generating handoff", false)
265
+ .action(async (options) => {
266
+ const result = await (0, dpdp_1.runDpdpHandoffCommand)(process.cwd(), { refresh: Boolean(options.refresh) });
267
+ process.stdout.write(result.output);
268
+ process.exit(result.exitCode);
269
+ });
270
+ dpdp
271
+ .command("verify")
272
+ .description("Re-run DPDP collection on changed files for post-fix verification (same scope as scan --changed; falls back to full if no git delta)")
273
+ .action(async () => {
274
+ const result = await (0, dpdp_1.runDpdpVerifyCommand)(process.cwd());
275
+ process.stdout.write(result.output);
276
+ process.exit(result.exitCode);
277
+ });
278
+ dpdp
279
+ .command("explain")
280
+ .description("Explain a DPDP control or finding id (uses cached artifacts unless --refresh)")
281
+ .argument("<control-or-finding-id>")
282
+ .option("--refresh", "Force a new scan before explaining", false)
283
+ .action(async (id, options) => {
284
+ const result = await (0, dpdp_1.runDpdpExplainCommand)(process.cwd(), id, { refresh: Boolean(options.refresh) });
285
+ process.stdout.write(result.output);
286
+ process.exit(result.exitCode);
287
+ });
204
288
  program
205
289
  .command("mcp")
206
290
  .description("Start the VibeDoctor MCP server over stdio")
@@ -84,6 +84,27 @@ export type VibeDoctorConfig = {
84
84
  enabled: boolean;
85
85
  };
86
86
  };
87
+ dpdp: {
88
+ enabled: boolean;
89
+ include: string[];
90
+ exclude: string[];
91
+ minConfidenceToReport: "low" | "medium" | "high";
92
+ maskExamples: boolean;
93
+ usePresidio: boolean;
94
+ useSemgrep: boolean;
95
+ legalSourceVersion: string;
96
+ contextFile: string;
97
+ evidenceFile: string;
98
+ failOnSeverity: Array<"info" | "low" | "medium" | "high" | "critical">;
99
+ failOnViolatedControls: string[];
100
+ failOnlyOnNew: boolean;
101
+ organization: {
102
+ processesPersonalData: "true" | "false" | "unknown";
103
+ isSignificantDataFiduciary: "true" | "false" | "unknown";
104
+ processesChildrenData: "true" | "false" | "unknown";
105
+ hasCrossBorderTransfer: "true" | "false" | "unknown";
106
+ };
107
+ };
87
108
  };
88
109
  output: {
89
110
  terminal: boolean;