@neuralaxis/vibedoctor 0.1.1 → 0.1.3

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 (75) hide show
  1. package/README.md +219 -290
  2. package/dist/adapters/biome.d.ts +1 -1
  3. package/dist/adapters/biome.js +7 -4
  4. package/dist/adapters/coveragePy.js +3 -0
  5. package/dist/adapters/customDeadChain.d.ts +2 -1
  6. package/dist/adapters/customDeadChain.js +100 -8
  7. package/dist/adapters/customLeftovers.js +33 -10
  8. package/dist/adapters/deptry.js +21 -2
  9. package/dist/adapters/index.d.ts +3 -0
  10. package/dist/adapters/index.js +7 -1
  11. package/dist/adapters/jscpd.d.ts +1 -0
  12. package/dist/adapters/jscpd.js +10 -1
  13. package/dist/adapters/knip.js +29 -4
  14. package/dist/adapters/lizard.d.ts +1 -1
  15. package/dist/adapters/lizard.js +51 -2
  16. package/dist/adapters/osvScanner.js +14 -2
  17. package/dist/adapters/presidio.d.ts +2 -0
  18. package/dist/adapters/presidio.js +158 -0
  19. package/dist/adapters/privacyDetector.d.ts +10 -0
  20. package/dist/adapters/privacyDetector.js +600 -0
  21. package/dist/adapters/ruff.d.ts +1 -1
  22. package/dist/adapters/ruff.js +4 -1
  23. package/dist/adapters/semgrep.d.ts +1 -1
  24. package/dist/adapters/semgrep.js +17 -3
  25. package/dist/adapters/shared.d.ts +1 -0
  26. package/dist/adapters/shared.js +22 -0
  27. package/dist/adapters/telemetryDetector.d.ts +2 -0
  28. package/dist/adapters/telemetryDetector.js +118 -0
  29. package/dist/adapters/tsc.js +43 -18
  30. package/dist/adapters/vulture.d.ts +1 -1
  31. package/dist/adapters/vulture.js +25 -6
  32. package/dist/agentPack/generateAgentPack.d.ts +7 -0
  33. package/dist/agentPack/generateAgentPack.js +89 -1
  34. package/dist/agentPack/templates/index.js +21 -15
  35. package/dist/agentPack/templates/skills.js +57 -4
  36. package/dist/cli/commands/agent.d.ts +5 -0
  37. package/dist/cli/commands/agent.js +10 -0
  38. package/dist/cli/commands/agentPlan.js +9 -1
  39. package/dist/cli/commands/init.js +50 -17
  40. package/dist/cli/commands/privacyReview.d.ts +9 -0
  41. package/dist/cli/commands/privacyReview.js +304 -0
  42. package/dist/cli/commands/scan.d.ts +1 -1
  43. package/dist/cli/commands/scan.js +31 -1
  44. package/dist/cli/commands/setup.js +16 -1
  45. package/dist/cli/commands/tool.d.ts +4 -0
  46. package/dist/cli/commands/tool.js +11 -0
  47. package/dist/cli/index.js +36 -0
  48. package/dist/core/config.d.ts +29 -0
  49. package/dist/core/config.js +142 -5
  50. package/dist/core/engine.d.ts +35 -1
  51. package/dist/core/engine.js +204 -36
  52. package/dist/core/finding.d.ts +16 -2
  53. package/dist/core/finding.js +5 -0
  54. package/dist/core/paths.js +5 -0
  55. package/dist/core/privacyReview.d.ts +51 -0
  56. package/dist/core/privacyReview.js +94 -0
  57. package/dist/core/projectDetector.d.ts +1 -1
  58. package/dist/core/projectDetector.js +34 -12
  59. package/dist/core/scanPlanner.js +4 -0
  60. package/dist/core/scoring.js +6 -0
  61. package/dist/core/toolRunner.d.ts +1 -0
  62. package/dist/core/toolRunner.js +73 -11
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.js +5 -0
  65. package/dist/mcp/tools/shared.d.ts +1 -1
  66. package/dist/mcp/tools/shared.js +8 -1
  67. package/dist/reporters/agent.js +8 -0
  68. package/dist/reporters/html.js +12 -8
  69. package/dist/reporters/json.js +5 -5
  70. package/dist/reporters/markdown.js +15 -1
  71. package/dist/reporters/sarif.js +6 -0
  72. package/dist/reporters/terminal.js +1 -5
  73. package/dist/rules/severityMap.d.ts +1 -0
  74. package/dist/rules/severityMap.js +1 -0
  75. package/package.json +6 -2
@@ -1,2 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.adapterTargets = adapterTargets;
4
+ const paths_1 = require("../core/paths");
5
+ const MAX_TARGET_ARGS_LENGTH = 6_000;
6
+ function getTopLevelTargets(targets) {
7
+ const topLevels = new Set();
8
+ for (const target of targets) {
9
+ const parts = target.split("/");
10
+ if (parts.length > 0 && parts[0]) {
11
+ topLevels.add(parts[0]);
12
+ }
13
+ }
14
+ const result = Array.from(topLevels).sort();
15
+ return result.length > 0 ? result : ["."];
16
+ }
17
+ function adapterTargets(ctx, extensionPattern) {
18
+ const targets = (0, paths_1.filterPaths)(ctx.project.projectFiles, ctx.config.paths.include, ctx.config.paths.exclude).filter((file) => extensionPattern.test(file));
19
+ if (targets.length === 0) {
20
+ return ["."];
21
+ }
22
+ const totalLength = targets.reduce((sum, target) => sum + target.length + 1, 0);
23
+ return totalLength > MAX_TARGET_ARGS_LENGTH ? getTopLevelTargets(targets) : targets;
24
+ }
@@ -0,0 +1,2 @@
1
+ import type { ToolAdapter } from "./shared";
2
+ export declare const telemetryDetectorAdapter: ToolAdapter;
@@ -0,0 +1,118 @@
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.telemetryDetectorAdapter = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const paths_1 = require("../core/paths");
9
+ exports.telemetryDetectorAdapter = {
10
+ id: "telemetry-detector",
11
+ category: "privacy",
12
+ async detect(_project, config) {
13
+ return config.checks.privacy.enabled && config.checks.privacy.detectTelemetryOptOut;
14
+ },
15
+ async runStandalone(ctx) {
16
+ const findings = [];
17
+ const packageFiles = ctx.project.projectFiles.filter((f) => node_path_1.default.basename(f) === "package.json");
18
+ let hasTelemetryFramework = false;
19
+ let targetPackageJson = "package.json";
20
+ for (const file of packageFiles) {
21
+ const content = await (0, paths_1.readTextIfExists)(node_path_1.default.join(ctx.root, file));
22
+ if (!content) {
23
+ continue;
24
+ }
25
+ try {
26
+ const pkg = JSON.parse(content);
27
+ const deps = {
28
+ ...(pkg.dependencies ?? {}),
29
+ ...(pkg.devDependencies ?? {})
30
+ };
31
+ if ("next" in deps || "gatsby" in deps || "gatsby-cli" in deps) {
32
+ hasTelemetryFramework = true;
33
+ targetPackageJson = file;
34
+ break;
35
+ }
36
+ }
37
+ catch {
38
+ // Ignore malformed package.json files
39
+ }
40
+ }
41
+ if (!hasTelemetryFramework) {
42
+ return { findings };
43
+ }
44
+ // Check if .env or .env.local disables telemetry
45
+ const envFiles = [".env", ".env.local", ".env.development", ".env.production"];
46
+ let isOptedOut = false;
47
+ for (const envFile of envFiles) {
48
+ const content = await (0, paths_1.readTextIfExists)(node_path_1.default.join(ctx.root, envFile));
49
+ if (!content) {
50
+ continue;
51
+ }
52
+ const hasNextDisabled = /^\s*NEXT_TELEMETRY_DISABLED\s*=\s*1\s*$/m.test(content);
53
+ const hasDoNotTrack = /^\s*DO_NOT_TRACK\s*=\s*1\s*$/m.test(content);
54
+ // If either environment variable disables it in any .env file, we consider it configured
55
+ if (hasNextDisabled || hasDoNotTrack) {
56
+ isOptedOut = true;
57
+ break;
58
+ }
59
+ }
60
+ // Also check current process env as a fallback
61
+ if (process.env.NEXT_TELEMETRY_DISABLED === "1" || process.env.DO_NOT_TRACK === "1") {
62
+ isOptedOut = true;
63
+ }
64
+ if (!isOptedOut) {
65
+ findings.push({
66
+ id: `privacy:telemetry:opt-out`,
67
+ source: "telemetry-detector",
68
+ category: "privacy",
69
+ severity: "low",
70
+ confidence: "high",
71
+ title: "Telemetry enabled in project dependencies",
72
+ message: "Next.js or Gatsby is installed, but telemetry opt-out variables are not configured in your .env files.",
73
+ file: targetPackageJson,
74
+ isNew: true,
75
+ isAutofixable: true,
76
+ safeToAutofix: true,
77
+ agentInstruction: "Add 'NEXT_TELEMETRY_DISABLED=1' and 'DO_NOT_TRACK=1' to your root .env file.",
78
+ tags: ["privacy", "telemetry", "opt-out"],
79
+ evidence: {
80
+ detector: "telemetry-detector",
81
+ reasons: ["Telemetry-heavy package detected in package.json", "No opt-out configuration found in .env files"]
82
+ },
83
+ scoreImpact: 5
84
+ });
85
+ }
86
+ return { findings };
87
+ },
88
+ buildFixCommand(ctx) {
89
+ const escapedRoot = ctx.root.replace(/\\/g, "\\\\");
90
+ const script = [
91
+ "const fs = require('node:fs');",
92
+ "const path = require('node:path');",
93
+ `const envPath = path.join('${escapedRoot}', '.env');`,
94
+ "let content = '';",
95
+ "if (fs.existsSync(envPath)) {",
96
+ " content = fs.readFileSync(envPath, 'utf8');",
97
+ "}",
98
+ "const varsToAdd = [];",
99
+ "if (!content.includes('NEXT_TELEMETRY_DISABLED=')) {",
100
+ " varsToAdd.push('NEXT_TELEMETRY_DISABLED=1');",
101
+ "}",
102
+ "if (!content.includes('DO_NOT_TRACK=')) {",
103
+ " varsToAdd.push('DO_NOT_TRACK=1');",
104
+ "}",
105
+ "if (varsToAdd.length > 0) {",
106
+ " const prefix = content && !content.endsWith('\\n') ? '\\n' : '';",
107
+ " fs.appendFileSync(envPath, prefix + varsToAdd.join('\\n') + '\\n', 'utf8');",
108
+ " console.log('Successfully enabled telemetry opt-out in .env');",
109
+ "}"
110
+ ].join(" ");
111
+ return {
112
+ cmd: "node",
113
+ args: ["-e", script],
114
+ cwd: ctx.root
115
+ };
116
+ },
117
+ installHint: "Built-in telemetry opt-out detector. No external install needed."
118
+ };
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.tscAdapter = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
4
8
  const finding_1 = require("../core/finding");
5
9
  const TSC_PATTERN = /^(?<file>.+?)\((?<line>\d+),(?<column>\d+)\): error (?<code>TS\d+): (?<message>.+)$/gm;
6
10
  function parseTsc(stdout, stderr) {
@@ -20,6 +24,12 @@ function mapSeverity(code) {
20
24
  }
21
25
  return "medium";
22
26
  }
27
+ function findTsconfigPath(projectFiles) {
28
+ if (projectFiles.includes("tsconfig.json")) {
29
+ return "tsconfig.json";
30
+ }
31
+ return projectFiles.find((f) => f.endsWith("/tsconfig.json"));
32
+ }
23
33
  exports.tscAdapter = {
24
34
  id: "tsc",
25
35
  category: "correctness",
@@ -27,31 +37,46 @@ exports.tscAdapter = {
27
37
  return project.languages.includes("typescript");
28
38
  },
29
39
  buildScanCommand(ctx) {
40
+ const tsconfig = findTsconfigPath(ctx.project.projectFiles);
41
+ const cwd = tsconfig && node_path_1.default.dirname(tsconfig) !== "." ? node_path_1.default.join(ctx.root, node_path_1.default.dirname(tsconfig)) : ctx.root;
30
42
  return {
31
43
  cmd: "tsc",
32
44
  args: ["--noEmit", "--pretty", "false"],
33
- cwd: ctx.root,
45
+ cwd,
34
46
  timeoutMs: 90_000
35
47
  };
36
48
  },
37
49
  parseResult(result, ctx) {
38
- return parseTsc(result.stdout, result.stderr).map((item) => ({
39
- id: `tsc:${item.file}:${item.line}:${item.code}`,
40
- source: "tsc",
41
- category: "correctness",
42
- severity: mapSeverity(item.code),
43
- confidence: "high",
44
- title: item.code,
45
- message: item.message,
46
- file: (0, finding_1.normalizeFilePath)(item.file, ctx.root),
47
- startLine: Number(item.line),
48
- isNew: true,
49
- isAutofixable: false,
50
- safeToAutofix: false,
51
- agentInstruction: "Fix the type error without changing public behavior unless required.",
52
- tags: ["typescript", "types"],
53
- scoreImpact: 0
54
- }));
50
+ const output = `${result.stdout}\n${result.stderr}`;
51
+ const parsed = parseTsc(result.stdout, result.stderr);
52
+ // With no tsconfig, tsc prints CLI help and can exit successfully. That
53
+ // does not represent a completed type check.
54
+ if (/Syntax:\s*tsc|TS2304.*--help|Version \d+/i.test(output) && parsed.length === 0) {
55
+ result.status = "skipped";
56
+ return [];
57
+ }
58
+ const tsconfig = findTsconfigPath(ctx.project.projectFiles);
59
+ const prefix = tsconfig && node_path_1.default.dirname(tsconfig) !== "." ? node_path_1.default.dirname(tsconfig) : "";
60
+ return parsed.map((item) => {
61
+ const fullPath = prefix ? node_path_1.default.join(prefix, item.file) : item.file;
62
+ return {
63
+ id: `tsc:${fullPath}:${item.line}:${item.code}`,
64
+ source: "tsc",
65
+ category: "correctness",
66
+ severity: mapSeverity(item.code),
67
+ confidence: "high",
68
+ title: item.code,
69
+ message: item.message,
70
+ file: (0, finding_1.normalizeFilePath)(fullPath, ctx.root),
71
+ startLine: Number(item.line),
72
+ isNew: true,
73
+ isAutofixable: false,
74
+ safeToAutofix: false,
75
+ agentInstruction: "Fix the type error without changing public behavior unless required.",
76
+ tags: ["typescript", "types"],
77
+ scoreImpact: 0
78
+ };
79
+ });
55
80
  },
56
81
  installHint: "Install TypeScript with: npm install -D typescript"
57
82
  };
@@ -1,2 +1,2 @@
1
- import type { ToolAdapter } from "./shared";
1
+ import { type ToolAdapter } from "./shared";
2
2
  export declare const vultureAdapter: ToolAdapter;
@@ -2,9 +2,24 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.vultureAdapter = void 0;
4
4
  const finding_1 = require("../core/finding");
5
+ const shared_1 = require("./shared");
6
+ const VULTURE_PATTERN = /^(?<file>.+?):(?<line>\d+):\s*unused\s+(?<type>[\w\s]+)\s+'(?<name>[^']+)'(?:\s*\((?<confidence>\d+)%\s*confidence\))?/gm;
5
7
  function parseVulture(stdout) {
6
- const trimmed = stdout.trim();
7
- return trimmed ? JSON.parse(trimmed) : [];
8
+ const items = [];
9
+ const matches = stdout.matchAll(VULTURE_PATTERN);
10
+ for (const match of matches) {
11
+ if (!match.groups) {
12
+ continue;
13
+ }
14
+ items.push({
15
+ filename: match.groups.file,
16
+ first_lineno: Number(match.groups.line),
17
+ name: match.groups.name,
18
+ type: match.groups.type.trim(),
19
+ confidence: match.groups.confidence ? Number(match.groups.confidence) : 60
20
+ });
21
+ }
22
+ return items;
8
23
  }
9
24
  function isPackageInitializer(file) {
10
25
  return file.replaceAll("\\", "/").endsWith("/__init__.py") || file === "__init__.py";
@@ -16,15 +31,19 @@ exports.vultureAdapter = {
16
31
  return project.languages.includes("python");
17
32
  },
18
33
  buildScanCommand(ctx) {
34
+ const targets = (0, shared_1.adapterTargets)(ctx, /\.py$/i);
35
+ const excludePatterns = ctx.config.paths.exclude.length > 0 ? ctx.config.paths.exclude.join(",") : undefined;
36
+ const excludeArgs = excludePatterns ? ["--exclude", excludePatterns] : [];
19
37
  return {
20
38
  cmd: "vulture",
21
- args: [".", "--json"],
39
+ args: [...targets, ...excludeArgs],
22
40
  cwd: ctx.root,
23
41
  timeoutMs: 60_000
24
42
  };
25
43
  },
26
44
  parseResult(result, ctx) {
27
- return parseVulture(result.stdout).map((item) => {
45
+ const text = `${result.stdout}\n${result.stderr}`;
46
+ return parseVulture(text).map((item) => {
28
47
  const packageInitializer = isPackageInitializer(item.filename);
29
48
  return {
30
49
  id: `vulture:${item.filename}:${item.first_lineno}:${item.name}`,
@@ -33,9 +52,9 @@ exports.vultureAdapter = {
33
52
  severity: "low",
34
53
  confidence: packageInitializer
35
54
  ? "low"
36
- : (item.confidence ?? 60) >= 90
55
+ : item.confidence >= 90
37
56
  ? "high"
38
- : (item.confidence ?? 60) >= 70
57
+ : item.confidence >= 70
39
58
  ? "medium"
40
59
  : "low",
41
60
  title: packageInitializer ? `Review package initializer ${item.type}` : `Unused ${item.type}`,
@@ -1,5 +1,7 @@
1
1
  export declare const AGENT_TARGETS: readonly ["codex", "copilot", "claude", "cursor"];
2
+ export declare const AGENT_PLUGIN_TARGETS: readonly ["codex", "claude"];
2
3
  export type AgentTarget = (typeof AGENT_TARGETS)[number];
4
+ export type AgentPluginTarget = (typeof AGENT_PLUGIN_TARGETS)[number];
3
5
  export type AgentPackManifest = {
4
6
  version: number;
5
7
  generatedBy: string;
@@ -29,6 +31,11 @@ export type AgentPackDoctorResult = {
29
31
  };
30
32
  export declare function loadAgentPackManifest(root: string): Promise<AgentPackManifest | undefined>;
31
33
  export declare function parseAgentTargets(value: string | undefined, defaultTargets?: AgentTarget[]): AgentTarget[];
34
+ export declare function parseAgentPluginTargets(value: string | undefined, defaultTargets?: AgentPluginTarget[]): AgentPluginTarget[];
35
+ export declare function generateAgentPluginBundle(root: string, options: {
36
+ targets: AgentPluginTarget[];
37
+ force?: boolean;
38
+ }): Promise<AgentPackApplyResult>;
32
39
  export declare function generateCanonicalAgentPack(root: string, options: {
33
40
  targets: AgentTarget[];
34
41
  force?: boolean;
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AGENT_TARGETS = void 0;
6
+ exports.AGENT_PLUGIN_TARGETS = exports.AGENT_TARGETS = void 0;
7
7
  exports.loadAgentPackManifest = loadAgentPackManifest;
8
8
  exports.parseAgentTargets = parseAgentTargets;
9
+ exports.parseAgentPluginTargets = parseAgentPluginTargets;
10
+ exports.generateAgentPluginBundle = generateAgentPluginBundle;
9
11
  exports.generateCanonicalAgentPack = generateCanonicalAgentPack;
10
12
  exports.syncAgentPack = syncAgentPack;
11
13
  exports.initAgentPack = initAgentPack;
@@ -17,6 +19,8 @@ const paths_1 = require("../core/paths");
17
19
  const policy_1 = require("./policy");
18
20
  const templates_1 = require("./templates");
19
21
  exports.AGENT_TARGETS = ["codex", "copilot", "claude", "cursor"];
22
+ exports.AGENT_PLUGIN_TARGETS = ["codex", "claude"];
23
+ const VIBEDOCTOR_PLUGIN_VERSION = "0.1.1";
20
24
  function toAbsolutePath(root, relativePath) {
21
25
  return node_path_1.default.join(root, ...relativePath.split("/"));
22
26
  }
@@ -26,6 +30,9 @@ function normalizeRelativePath(relativePath) {
26
30
  function uniqueTargets(targets) {
27
31
  return Array.from(new Set(targets));
28
32
  }
33
+ function uniquePluginTargets(targets) {
34
+ return Array.from(new Set(targets));
35
+ }
29
36
  function mergeApplyResults(...results) {
30
37
  return {
31
38
  created: Array.from(new Set(results.flatMap((result) => result.created))),
@@ -98,6 +105,50 @@ function buildManifest(targets) {
98
105
  function renderManifest(targets) {
99
106
  return `${JSON.stringify(buildManifest(targets), null, 2)}\n`;
100
107
  }
108
+ function renderCodexPluginManifest() {
109
+ return `${JSON.stringify({
110
+ name: "vibedoctor",
111
+ version: VIBEDOCTOR_PLUGIN_VERSION,
112
+ description: "Code-health, privacy review, and repair skills for VibeDoctor.",
113
+ author: {
114
+ name: "neuralaxis",
115
+ url: "https://github.com/neural-axis"
116
+ },
117
+ homepage: "https://github.com/neural-axis/VibeDoctor#readme",
118
+ repository: "https://github.com/neural-axis/VibeDoctor",
119
+ license: "GPL-3.0-or-later",
120
+ keywords: ["code-health", "static-analysis", "privacy-review", "agent-tools"],
121
+ skills: "./skills/",
122
+ interface: {
123
+ displayName: "VibeDoctor",
124
+ shortDescription: "Code-health skills for coding agents",
125
+ longDescription: "Run VibeDoctor scans, review Privacy Review findings, plan safe fixes, and diagnose CI or pull request health from reusable agent skills.",
126
+ developerName: "neuralaxis",
127
+ category: "Developer Tools",
128
+ capabilities: ["Read", "Write"],
129
+ websiteURL: "https://github.com/neural-axis/VibeDoctor",
130
+ defaultPrompt: [
131
+ "Use VibeDoctor to scan this repository.",
132
+ "Use VibeDoctor to review privacy findings.",
133
+ "Use VibeDoctor to repair this CI failure."
134
+ ],
135
+ brandColor: "#2563EB"
136
+ }
137
+ }, null, 2)}\n`;
138
+ }
139
+ function renderClaudePluginManifest() {
140
+ return `${JSON.stringify({
141
+ name: "vibedoctor",
142
+ description: "Code-health, privacy review, and repair skills for VibeDoctor.",
143
+ version: VIBEDOCTOR_PLUGIN_VERSION,
144
+ author: {
145
+ name: "neuralaxis"
146
+ },
147
+ homepage: "https://github.com/neural-axis/VibeDoctor#readme",
148
+ repository: "https://github.com/neural-axis/VibeDoctor",
149
+ license: "GPL-3.0-or-later"
150
+ }, null, 2)}\n`;
151
+ }
101
152
  async function loadAgentPackManifest(root) {
102
153
  const manifestPath = toAbsolutePath(root, ".vibedoctor/agent-pack.json");
103
154
  if (!(await (0, paths_1.pathExists)(manifestPath))) {
@@ -133,6 +184,43 @@ function parseAgentTargets(value, defaultTargets = ["codex"]) {
133
184
  }
134
185
  return uniqueTargets(parts);
135
186
  }
187
+ function parseAgentPluginTargets(value, defaultTargets = [...exports.AGENT_PLUGIN_TARGETS]) {
188
+ if (!value) {
189
+ return uniquePluginTargets(defaultTargets);
190
+ }
191
+ const parts = value
192
+ .split(",")
193
+ .map((item) => item.trim().toLowerCase())
194
+ .filter(Boolean);
195
+ if (parts.includes("all")) {
196
+ return [...exports.AGENT_PLUGIN_TARGETS];
197
+ }
198
+ const invalid = parts.filter((target) => !exports.AGENT_PLUGIN_TARGETS.includes(target));
199
+ if (invalid.length > 0) {
200
+ throw new Error(`Unsupported agent plugin target(s): ${invalid.join(", ")}`);
201
+ }
202
+ return uniquePluginTargets(parts);
203
+ }
204
+ async function generateAgentPluginBundle(root, options) {
205
+ const targets = uniquePluginTargets(options.targets);
206
+ const files = templates_1.AGENT_SKILLS.map((skill) => ({
207
+ path: `plugins/vibedoctor/skills/${skill.name}/SKILL.md`,
208
+ content: skill.content
209
+ }));
210
+ if (targets.includes("codex")) {
211
+ files.push({
212
+ path: "plugins/vibedoctor/.codex-plugin/plugin.json",
213
+ content: renderCodexPluginManifest()
214
+ });
215
+ }
216
+ if (targets.includes("claude")) {
217
+ files.push({
218
+ path: "plugins/vibedoctor/.claude-plugin/plugin.json",
219
+ content: renderClaudePluginManifest()
220
+ });
221
+ }
222
+ return writeManagedFiles(root, files, { force: options.force });
223
+ }
136
224
  async function generateCanonicalAgentPack(root, options) {
137
225
  const files = [
138
226
  { path: "AGENTS.md", content: (0, templates_1.renderAgentsMd)() },
@@ -18,8 +18,10 @@ Use VibeDoctor as the source of truth for code-health checks.
18
18
 
19
19
  Before major edits:
20
20
  \`\`\`bash
21
- vibedoctor scan --changed --report json
22
- \`\`\`
21
+ vibedoctor scan --changed --report json
22
+ \`\`\`
23
+
24
+ Read \`completeness.status\` before editing. If it is \`partial\` or \`invalid\`, run the report's \`recoveryActions\` first. Never compare a partial score with a complete score or assume a timed-out tool passed.
23
25
 
24
26
  After edits:
25
27
  \`\`\`bash
@@ -38,20 +40,22 @@ Always fix in this order:
38
40
  1. security blockers
39
41
  2. failing tests
40
42
  3. type errors
41
- 4. dependency vulnerabilities
42
- 5. high-confidence dead code
43
- 6. leftovers and legacy baggage
44
- 7. refactor-readiness items
45
- 8. efficiency suggestions
43
+ 4. dependency vulnerabilities
44
+ 5. Privacy Review findings with regulated identifiers or sensitive attributes
45
+ 6. high-confidence dead code
46
+ 7. leftovers and legacy baggage
47
+ 8. refactor-readiness items
48
+ 9. efficiency suggestions
46
49
 
47
50
  ## Safety rules
48
51
 
49
52
  - Do not delete dead code unless VibeDoctor marks it high confidence and you independently verify no active references.
50
53
  - Do not remove backward compatibility code unless the user explicitly approves or the path is proven unused.
51
- - Do not refactor large files without tests.
52
- - Do not change public APIs during cleanup unless the task explicitly asks.
53
- - Do not lower test, lint, security, or coverage thresholds.
54
- - Do not silence VibeDoctor findings without explaining why.
54
+ - Do not refactor large files without tests.
55
+ - Do not change public APIs during cleanup unless the task explicitly asks.
56
+ - Do not lower test, lint, security, or coverage thresholds.
57
+ - Do not send raw personal data to an AI service unless repository config and the user explicitly allow it.
58
+ - Do not silence VibeDoctor findings without explaining why.
55
59
  - Respect .vibedoctor/agent-policy.yml when it exists.
56
60
 
57
61
  ## Verification
@@ -61,8 +65,9 @@ After each meaningful change, run the smallest relevant verification command.
61
65
  At the end, report:
62
66
 
63
67
  \`\`\`text
64
- Health score:
65
- Commands run:
68
+ Health score:
69
+ Scan completeness:
70
+ Commands run:
66
71
  Files changed:
67
72
  Remaining blockers:
68
73
  Suggested next step:
@@ -82,7 +87,7 @@ Prefer:
82
87
  - \`vibedoctor fix --safe\` for safe cleanup
83
88
  - \`vibedoctor agent-plan --format markdown\` when planning multiple fixes
84
89
 
85
- Do not delete dead code, remove compatibility paths, or refactor large files unless VibeDoctor evidence and tests support it.
90
+ Do not delete dead code, remove compatibility paths, refactor large files, or send raw personal data to AI unless VibeDoctor evidence, repository policy, and user approval support it.
86
91
  `;
87
92
  }
88
93
  function renderCopilotInstructions() {
@@ -107,7 +112,8 @@ For pull requests, summarize:
107
112
  - tests run
108
113
  - remaining VibeDoctor findings
109
114
 
110
- Do not remove dead code, legacy fallbacks, compatibility shims, or large blocks of comments unless VibeDoctor marks them as high-confidence cleanup candidates and references are verified.
115
+ Do not remove dead code, legacy fallbacks, compatibility shims, or large blocks of comments unless VibeDoctor marks them as high-confidence cleanup candidates and references are verified.
116
+ Do not send raw personal data to external AI review unless the user explicitly approves and repository policy allows it.
111
117
  `;
112
118
  }
113
119
  function renderCursorMcpConfig() {
@@ -60,9 +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. Prioritize 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:
66
71
  - security blockers
67
72
  - correctness blockers
68
73
  - failing tests
@@ -79,7 +84,8 @@ Give only:
79
84
  - blockers
80
85
  - safest next command
81
86
  - top 3 fixes
82
- - whether work is safe to continue
87
+ - whether work is safe to continue
88
+ - scan completeness and any missing tool coverage
83
89
 
84
90
  Do not paste the full JSON unless the user asks.
85
91
  `),
@@ -118,6 +124,53 @@ Report:
118
124
  - files changed
119
125
  - remaining blockers
120
126
  - verification result
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
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
121
174
  `),
122
175
  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.", `
123
176
  # VibeDoctor Dead Code Cleanup
@@ -13,6 +13,11 @@ export declare function runAgentSyncCommand(root: string, options: {
13
13
  targets?: string;
14
14
  force?: boolean;
15
15
  }): Promise<string>;
16
+ export declare function runAgentPluginCommand(root: string, options: {
17
+ target?: string;
18
+ targets?: string;
19
+ force?: boolean;
20
+ }): Promise<string>;
16
21
  export declare function runAgentDoctorCommand(root: string, options: {
17
22
  target?: string;
18
23
  targets?: string;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runAgentInitCommand = runAgentInitCommand;
4
4
  exports.runAgentPackCommand = runAgentPackCommand;
5
5
  exports.runAgentSyncCommand = runAgentSyncCommand;
6
+ exports.runAgentPluginCommand = runAgentPluginCommand;
6
7
  exports.runAgentDoctorCommand = runAgentDoctorCommand;
7
8
  const generateAgentPack_1 = require("../../agentPack/generateAgentPack");
8
9
  function formatFileSection(title, files) {
@@ -28,6 +29,10 @@ function resolveTargets(options, defaultTargets = ["codex"]) {
28
29
  const merged = options.target ? options.target : options.targets;
29
30
  return (0, generateAgentPack_1.parseAgentTargets)(merged, defaultTargets);
30
31
  }
32
+ function resolvePluginTargets(options, defaultTargets = ["codex", "claude"]) {
33
+ const merged = options.target ? options.target : options.targets;
34
+ return (0, generateAgentPack_1.parseAgentPluginTargets)(merged, defaultTargets);
35
+ }
31
36
  async function runAgentInitCommand(root, options) {
32
37
  const targets = resolveTargets(options);
33
38
  const result = await (0, generateAgentPack_1.initAgentPack)(root, { targets, force: options.force });
@@ -45,6 +50,11 @@ async function runAgentSyncCommand(root, options) {
45
50
  const result = await (0, generateAgentPack_1.syncAgentPack)(root, { targets, force: options.force });
46
51
  return formatApplyResult("VibeDoctor Agent Pack synced ✅", result);
47
52
  }
53
+ async function runAgentPluginCommand(root, options) {
54
+ const targets = resolvePluginTargets(options);
55
+ const result = await (0, generateAgentPack_1.generateAgentPluginBundle)(root, { targets, force: options.force });
56
+ return formatApplyResult("VibeDoctor Agent Plugin bundle generated ✅", result);
57
+ }
48
58
  async function runAgentDoctorCommand(root, options) {
49
59
  const manifest = await (0, generateAgentPack_1.loadAgentPackManifest)(root);
50
60
  const targets = resolveTargets(options, manifest?.targets ?? ["codex"]);
@@ -7,6 +7,14 @@ const agent_1 = require("../../reporters/agent");
7
7
  async function runAgentPlanCommand(root, format = "markdown", target = undefined) {
8
8
  const scan = await (0, engine_1.runScan)(root, "default");
9
9
  const { policy } = await (0, policy_1.loadAgentPolicy)(root);
10
- const plan = (0, engine_1.createAgentPlan)({ findings: scan.findings, score: scan.score, skippedTools: scan.skippedTools, testCommands: scan.testCommands }, { policy, target: target ?? "generic" });
10
+ const plan = (0, engine_1.createAgentPlan)({
11
+ findings: scan.findings,
12
+ score: scan.score,
13
+ skippedTools: scan.skippedTools,
14
+ toolStatuses: scan.toolStatuses,
15
+ completeness: scan.completeness,
16
+ recoveryActions: scan.recoveryActions,
17
+ testCommands: scan.testCommands
18
+ }, { policy, target: target ?? "generic" });
11
19
  return format === "json" ? `${(0, agent_1.renderAgentJson)(plan)}\n` : (0, agent_1.renderAgentMarkdown)(plan);
12
20
  }