@yagyeshvyas/vibeguard 1.13.0 → 1.13.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 (103) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +18 -2
  3. package/bin/cli.js +2753 -2753
  4. package/ci/vibeguard.yml +42 -42
  5. package/package.json +1 -1
  6. package/scripts/counts.js +93 -93
  7. package/scripts/postinstall.js +26 -26
  8. package/src/auto.js +427 -427
  9. package/src/daemon.js +343 -343
  10. package/src/dashboard.js +278 -278
  11. package/src/engine.js +297 -297
  12. package/src/hook.js +151 -151
  13. package/src/install.js +298 -298
  14. package/src/integrity.json +1 -1
  15. package/src/plugin.js +182 -182
  16. package/src/privacy-audit.js +272 -272
  17. package/src/repl.js +150 -150
  18. package/src/report.js +331 -331
  19. package/src/rules-pack.js +3068 -3068
  20. package/src/rules.js +1822 -1822
  21. package/src/sbom.js +193 -193
  22. package/src/scanner.js +1032 -1032
  23. package/src/shell-guard.js +302 -302
  24. package/src/slopsquat.js +144 -144
  25. package/src/trace.js +220 -220
  26. package/src/.vibeguard/cache/file-hashes.json +0 -60
  27. package/src/.vibeguard/latest-snapshot.json +0 -36
  28. package/src/.vibeguard/mcp-pins.json +0 -1
  29. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +0 -428
  30. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +0 -344
  31. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +0 -279
  32. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +0 -297
  33. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +0 -151
  34. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +0 -299
  35. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +0 -65
  36. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +0 -2051
  37. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +0 -168
  38. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +0 -362
  39. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +0 -150
  40. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +0 -1611
  41. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +0 -164
  42. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +0 -292
  43. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +0 -144
  44. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +0 -220
  45. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +0 -428
  46. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +0 -344
  47. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +0 -297
  48. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +0 -299
  49. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +0 -37
  50. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +0 -2055
  51. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +0 -168
  52. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +0 -362
  53. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +0 -220
  54. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +0 -428
  55. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +0 -344
  56. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +0 -279
  57. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +0 -297
  58. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +0 -151
  59. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +0 -299
  60. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +0 -65
  61. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +0 -2055
  62. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +0 -168
  63. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +0 -362
  64. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +0 -150
  65. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +0 -1611
  66. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +0 -164
  67. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +0 -292
  68. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +0 -144
  69. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +0 -220
  70. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +0 -428
  71. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +0 -344
  72. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +0 -279
  73. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +0 -297
  74. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +0 -151
  75. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +0 -299
  76. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +0 -65
  77. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +0 -2054
  78. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +0 -168
  79. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +0 -362
  80. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +0 -150
  81. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +0 -1611
  82. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +0 -164
  83. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +0 -292
  84. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +0 -144
  85. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +0 -220
  86. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +0 -428
  87. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +0 -344
  88. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +0 -297
  89. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +0 -299
  90. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +0 -37
  91. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +0 -2055
  92. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +0 -168
  93. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +0 -362
  94. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +0 -220
  95. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +0 -428
  96. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +0 -344
  97. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +0 -297
  98. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +0 -33
  99. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +0 -2055
  100. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +0 -1611
  101. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +0 -292
  102. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +0 -220
  103. package/src/.vibeguard-baseline.json +0 -5226
package/src/install.js CHANGED
@@ -1,298 +1,298 @@
1
- 'use strict';
2
-
3
- /*
4
- * One-command installer: `vibeguard install`.
5
- *
6
- * Detects which AI coding clients are present and wires the VibeGuard MCP server
7
- * into each. It only WRITES config for clients whose config format/location is
8
- * known and stable; for anything else it prints a ready-to-paste block so you can
9
- * add it by hand (we don't write to guessed paths).
10
- *
11
- * Default server command is `npx -y @yagyeshvyas/vibeguard mcp` (works once published).
12
- * Use --local to point at this checkout's absolute mcp-server.js for dev.
13
- */
14
-
15
- const fs = require('fs');
16
- const os = require('os');
17
- const path = require('path');
18
-
19
- const HOME = os.homedir();
20
-
21
- function serverSpec(local) {
22
- if (local) {
23
- return { command: process.execPath, args: [path.resolve(__dirname, 'mcp-server.js')] };
24
- }
25
- // Pin the package+version: an unpinned `npx -y vibeguard` can resolve an
26
- // unrelated/older package and makes the MCP config non-reproducible.
27
- return { command: 'npx', args: ['-y', `@yagyeshvyas/vibeguard@${require('../package.json').version}`, 'mcp'] };
28
- }
29
-
30
- function exists(p) {
31
- try {
32
- return fs.existsSync(p);
33
- } catch {
34
- return false;
35
- }
36
- }
37
-
38
- function backup(file) {
39
- try {
40
- if (exists(file)) fs.copyFileSync(file, file + '.vibeguard-bak');
41
- } catch {
42
- /* best effort */
43
- }
44
- }
45
-
46
- function readJson(file) {
47
- try {
48
- return JSON.parse(fs.readFileSync(file, 'utf8'));
49
- } catch {
50
- return {};
51
- }
52
- }
53
-
54
- function ensureDir(file) {
55
- fs.mkdirSync(path.dirname(file), { recursive: true });
56
- }
57
-
58
- // Merge a server entry into a JSON config using the given top-level key
59
- // ("mcpServers" for most, "servers" for VS Code).
60
- function writeJsonMcp(file, key, spec, name) {
61
- ensureDir(file);
62
- backup(file);
63
- const cfg = readJson(file);
64
- if (!cfg[key] || typeof cfg[key] !== 'object') cfg[key] = {};
65
- cfg[key][name] = { command: spec.command, args: spec.args };
66
- fs.writeFileSync(file, JSON.stringify(cfg, null, 2) + '\n');
67
- return file;
68
- }
69
-
70
- // -------- Per-client handlers ----------------------------------------------
71
- // Each returns { client, status: 'installed'|'skipped'|'manual'|'error', detail }.
72
-
73
- function installClaudeCode(spec) {
74
- // Write the project-scoped .mcp.json (Claude Code's documented config file) in
75
- // the current directory. No shelling out, no global side effects — this repo
76
- // gets the server, and we also print the global `claude mcp add` command.
77
- const file = path.join(process.cwd(), '.mcp.json');
78
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
79
- return {
80
- client: 'Claude Code',
81
- status: 'installed',
82
- detail: `${file} (project). Global: claude mcp add -s user vibeguard -- ${[spec.command, ...spec.args].join(' ')}`,
83
- };
84
- }
85
-
86
- function installCursor(spec) {
87
- const dir = path.join(HOME, '.cursor');
88
- if (!exists(dir)) return { client: 'Cursor', status: 'skipped', detail: 'not detected (~/.cursor missing)' };
89
- const file = path.join(dir, 'mcp.json');
90
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
91
- return { client: 'Cursor', status: 'installed', detail: file };
92
- }
93
-
94
- function installWindsurf(spec) {
95
- const dir = path.join(HOME, '.codeium', 'windsurf');
96
- if (!exists(path.join(HOME, '.codeium')))
97
- return { client: 'Windsurf', status: 'skipped', detail: 'not detected (~/.codeium missing)' };
98
- const file = path.join(dir, 'mcp_config.json');
99
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
100
- return { client: 'Windsurf', status: 'installed', detail: file };
101
- }
102
-
103
- function installCodex(spec) {
104
- const dir = path.join(HOME, '.codex');
105
- if (!exists(dir)) return { client: 'Codex CLI', status: 'skipped', detail: 'not detected (~/.codex missing)' };
106
- const file = path.join(dir, 'config.toml');
107
- let content = '';
108
- try {
109
- content = fs.readFileSync(file, 'utf8');
110
- } catch {
111
- content = '';
112
- }
113
- if (/\[mcp_servers\.vibeguard\]/.test(content)) {
114
- return { client: 'Codex CLI', status: 'installed', detail: 'already present in ' + file };
115
- }
116
- backup(file);
117
- const argsToml = spec.args.map((a) => JSON.stringify(a)).join(', ');
118
- const block =
119
- `\n[mcp_servers.vibeguard]\n` +
120
- `command = ${JSON.stringify(spec.command)}\n` +
121
- `args = [${argsToml}]\n`;
122
- ensureDir(file);
123
- fs.writeFileSync(file, (content && !content.endsWith('\n') ? content + '\n' : content) + block);
124
- return { client: 'Codex CLI', status: 'installed', detail: file };
125
- }
126
-
127
- function installVSCode(spec) {
128
- // VS Code (Copilot agent) reads workspace .vscode/mcp.json with a "servers" key.
129
- const file = path.join(process.cwd(), '.vscode', 'mcp.json');
130
- // Only write if a .vscode folder exists here (i.e. this is a VS Code project).
131
- if (!exists(path.join(process.cwd(), '.vscode'))) {
132
- return { client: 'VS Code', status: 'skipped', detail: 'no ./.vscode in this project' };
133
- }
134
- writeJsonMcp(file, 'servers', spec, 'vibeguard');
135
- return { client: 'VS Code', status: 'installed', detail: file };
136
- }
137
-
138
- function installAntigravity(spec) {
139
- // Google Antigravity uses ~/.antigravity/config.json with mcpServers key
140
- const dir = path.join(HOME, '.antigravity');
141
- if (!exists(dir)) return { client: 'Antigravity', status: 'skipped', detail: 'not detected (~/.antigravity missing)' };
142
- const file = path.join(dir, 'config.json');
143
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
144
- return { client: 'Antigravity', status: 'installed', detail: file };
145
- }
146
-
147
- function installContinue(spec) {
148
- // Continue.dev uses ~/.continue/config.json with mcpServers key
149
- const dir = path.join(HOME, '.continue');
150
- if (!exists(dir)) return { client: 'Continue', status: 'skipped', detail: 'not detected (~/.continue missing)' };
151
- const file = path.join(dir, 'config.json');
152
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
153
- return { client: 'Continue', status: 'installed', detail: file };
154
- }
155
-
156
- function installCline(spec) {
157
- // Cline (VS Code extension) uses cline_mcp_settings.json in VS Code user dir
158
- const dir = path.join(HOME, '.vscode', 'extensions');
159
- if (!exists(path.join(HOME, '.vscode')) && !exists(path.join(HOME, 'AppData', 'Roaming', 'Code')))
160
- return { client: 'Cline', status: 'skipped', detail: 'not detected (VS Code not found)' };
161
- // Cline stores MCP config in the VS Code userData directory
162
- const userDataDir = process.platform === 'win32'
163
- ? path.join(HOME, 'AppData', 'Roaming', 'Code', 'User')
164
- : path.join(HOME, '.vscode', 'User');
165
- if (!exists(userDataDir)) return { client: 'Cline', status: 'skipped', detail: 'VS Code User dir not found' };
166
- const file = path.join(userDataDir, 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
167
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
168
- return { client: 'Cline', status: 'installed', detail: file };
169
- }
170
-
171
- function installAider(spec) {
172
- // Aider uses ~/.aider.conf.yml — MCP via command launch
173
- const file = path.join(HOME, '.aider.conf.yml');
174
- if (!exists(file)) return { client: 'Aider', status: 'manual', detail: 'add --mcp to your aider launch or ~/.aider.conf.yml' };
175
- let content = '';
176
- try { content = fs.readFileSync(file, 'utf8'); } catch {}
177
- if (/vibeguard/.test(content)) return { client: 'Aider', status: 'installed', detail: 'already present' };
178
- backup(file);
179
- const block = `\n# VibeGuard MCP server\nmcp-command: ${spec.command}\nmcp-args: ${spec.args.join(' ')}\n`;
180
- fs.writeFileSync(file, content + block);
181
- return { client: 'Aider', status: 'installed', detail: file };
182
- }
183
-
184
- function installGeminiCLI(spec) {
185
- // Google Gemini CLI uses ~/.gemini/config.json with mcpServers key
186
- const dir = path.join(HOME, '.gemini');
187
- if (!exists(dir)) return { client: 'Gemini CLI', status: 'skipped', detail: 'not detected (~/.gemini missing)' };
188
- const file = path.join(dir, 'config.json');
189
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
190
- return { client: 'Gemini CLI', status: 'installed', detail: file };
191
- }
192
-
193
- function installRooCode(spec) {
194
- // Roo Code (VS Code extension) uses roo_cline_mcp_settings.json
195
- const userDataDir = process.platform === 'win32'
196
- ? path.join(HOME, 'AppData', 'Roaming', 'Code', 'User')
197
- : path.join(HOME, '.vscode', 'User');
198
- if (!exists(userDataDir)) return { client: 'Roo Code', status: 'skipped', detail: 'VS Code User dir not found' };
199
- const file = path.join(userDataDir, 'globalStorage', 'rooveterinaryinc.roo-cline', 'settings', 'roo_cline_mcp_settings.json');
200
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
201
- return { client: 'Roo Code', status: 'installed', detail: file };
202
- }
203
-
204
- function installOpenHands(spec) {
205
- // OpenHands uses ~/.openhands/config.toml similar to Codex
206
- const dir = path.join(HOME, '.openhands');
207
- if (!exists(dir)) return { client: 'OpenHands', status: 'skipped', detail: 'not detected (~/.openhands missing)' };
208
- const file = path.join(dir, 'config.toml');
209
- let content = '';
210
- try { content = fs.readFileSync(file, 'utf8'); } catch {}
211
- if (/\[mcp_servers\.vibeguard\]/.test(content)) return { client: 'OpenHands', status: 'installed', detail: 'already present' };
212
- backup(file);
213
- const argsToml = spec.args.map((a) => JSON.stringify(a)).join(', ');
214
- const block = `\n[mcp_servers.vibeguard]\ncommand = ${JSON.stringify(spec.command)}\nargs = [${argsToml}]\n`;
215
- ensureDir(file);
216
- fs.writeFileSync(file, (content && !content.endsWith('\n') ? content + '\n' : content) + block);
217
- return { client: 'OpenHands', status: 'installed', detail: file };
218
- }
219
-
220
- function installCopilotCLI(spec) {
221
- // GitHub Copilot CLI uses ~/.copilot/config.json with mcpServers key
222
- const dir = path.join(HOME, '.copilot');
223
- if (!exists(dir)) return { client: 'Copilot CLI', status: 'skipped', detail: 'not detected (~/.copilot missing)' };
224
- const file = path.join(dir, 'config.json');
225
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
226
- return { client: 'Copilot CLI', status: 'installed', detail: file };
227
- }
228
-
229
- function installAmazonQ(spec) {
230
- // Amazon Q Developer CLI uses ~/.aws/amazonq/config.json
231
- const dir = path.join(HOME, '.aws', 'amazonq');
232
- if (!exists(dir)) return { client: 'Amazon Q', status: 'skipped', detail: 'not detected (~/.aws/amazonq missing)' };
233
- const file = path.join(dir, 'config.json');
234
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
235
- return { client: 'Amazon Q', status: 'installed', detail: file };
236
- }
237
-
238
- function installCody(spec) {
239
- // Sourcegraph Cody uses ~/.config/cody/config.json
240
- const dir = process.platform === 'win32'
241
- ? path.join(HOME, 'AppData', 'Roaming', 'Sourcegraph', 'Cody')
242
- : path.join(HOME, '.config', 'cody');
243
- if (!exists(dir)) return { client: 'Sourcegraph Cody', status: 'skipped', detail: 'not detected (cody config dir missing)' };
244
- const file = path.join(dir, 'config.json');
245
- writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
246
- return { client: 'Sourcegraph Cody', status: 'installed', detail: file };
247
- }
248
-
249
- function installHermes(spec) {
250
- // Hermes Agent (Nous Research) reads MCP servers from $HERMES_HOME/config.yaml
251
- // (default ~/.hermes/config.yaml) under `mcp_servers:`. We never hand-edit the
252
- // YAML (a bad write can break the live gateway); we detect it and emit the
253
- // exact, safe commands using Hermes' own config CLI instead.
254
- const hermesHome = process.env.HERMES_HOME || path.join(HOME, '.hermes');
255
- const cfg = path.join(hermesHome, 'config.yaml');
256
- if (!exists(cfg)) {
257
- return { client: 'Hermes Agent', status: 'skipped', detail: `not detected (${cfg} missing)` };
258
- }
259
- const argsStr = spec.args.map((a) => JSON.stringify(a)).join(', ');
260
- return {
261
- client: 'Hermes Agent',
262
- status: 'instructions',
263
- detail: `${cfg} — add under \`mcp_servers:\`, or run:\n hermes config set mcp_servers.vibeguard.command ${spec.command}\n hermes config set mcp_servers.vibeguard.args '[${argsStr}]'\n hermes config set mcp_servers.vibeguard.timeout 120`,
264
- };
265
- }
266
-
267
- function pasteBlock(spec) {
268
- return JSON.stringify(
269
- { mcpServers: { vibeguard: { command: spec.command, args: spec.args } } },
270
- null,
271
- 2
272
- );
273
- }
274
-
275
- function install(opts = {}) {
276
- const spec = serverSpec(opts.local);
277
- const results = [
278
- installClaudeCode(spec),
279
- installCursor(spec),
280
- installWindsurf(spec),
281
- installCodex(spec),
282
- installAntigravity(spec),
283
- installContinue(spec),
284
- installCline(spec),
285
- installAider(spec),
286
- installGeminiCLI(spec),
287
- installRooCode(spec),
288
- installOpenHands(spec),
289
- installVSCode(spec),
290
- installCopilotCLI(spec),
291
- installAmazonQ(spec),
292
- installCody(spec),
293
- installHermes(spec),
294
- ];
295
- return { spec, results, paste: pasteBlock(spec) };
296
- }
297
-
298
- module.exports = { install, serverSpec, pasteBlock, writeJsonMcp };
1
+ 'use strict';
2
+
3
+ /*
4
+ * One-command installer: `vibeguard install`.
5
+ *
6
+ * Detects which AI coding clients are present and wires the VibeGuard MCP server
7
+ * into each. It only WRITES config for clients whose config format/location is
8
+ * known and stable; for anything else it prints a ready-to-paste block so you can
9
+ * add it by hand (we don't write to guessed paths).
10
+ *
11
+ * Default server command is `npx -y @yagyeshvyas/vibeguard mcp` (works once published).
12
+ * Use --local to point at this checkout's absolute mcp-server.js for dev.
13
+ */
14
+
15
+ const fs = require('fs');
16
+ const os = require('os');
17
+ const path = require('path');
18
+
19
+ const HOME = os.homedir();
20
+
21
+ function serverSpec(local) {
22
+ if (local) {
23
+ return { command: process.execPath, args: [path.resolve(__dirname, 'mcp-server.js')] };
24
+ }
25
+ // Pin the package+version: an unpinned `npx -y vibeguard` can resolve an
26
+ // unrelated/older package and makes the MCP config non-reproducible.
27
+ return { command: 'npx', args: ['-y', `@yagyeshvyas/vibeguard@${require('../package.json').version}`, 'mcp'] };
28
+ }
29
+
30
+ function exists(p) {
31
+ try {
32
+ return fs.existsSync(p);
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+
38
+ function backup(file) {
39
+ try {
40
+ if (exists(file)) fs.copyFileSync(file, file + '.vibeguard-bak');
41
+ } catch {
42
+ /* best effort */
43
+ }
44
+ }
45
+
46
+ function readJson(file) {
47
+ try {
48
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
49
+ } catch {
50
+ return {};
51
+ }
52
+ }
53
+
54
+ function ensureDir(file) {
55
+ fs.mkdirSync(path.dirname(file), { recursive: true });
56
+ }
57
+
58
+ // Merge a server entry into a JSON config using the given top-level key
59
+ // ("mcpServers" for most, "servers" for VS Code).
60
+ function writeJsonMcp(file, key, spec, name) {
61
+ ensureDir(file);
62
+ backup(file);
63
+ const cfg = readJson(file);
64
+ if (!cfg[key] || typeof cfg[key] !== 'object') cfg[key] = {};
65
+ cfg[key][name] = { command: spec.command, args: spec.args };
66
+ fs.writeFileSync(file, JSON.stringify(cfg, null, 2) + '\n');
67
+ return file;
68
+ }
69
+
70
+ // -------- Per-client handlers ----------------------------------------------
71
+ // Each returns { client, status: 'installed'|'skipped'|'manual'|'error', detail }.
72
+
73
+ function installClaudeCode(spec) {
74
+ // Write the project-scoped .mcp.json (Claude Code's documented config file) in
75
+ // the current directory. No shelling out, no global side effects — this repo
76
+ // gets the server, and we also print the global `claude mcp add` command.
77
+ const file = path.join(process.cwd(), '.mcp.json');
78
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
79
+ return {
80
+ client: 'Claude Code',
81
+ status: 'installed',
82
+ detail: `${file} (project). Global: claude mcp add -s user vibeguard -- ${[spec.command, ...spec.args].join(' ')}`,
83
+ };
84
+ }
85
+
86
+ function installCursor(spec) {
87
+ const dir = path.join(HOME, '.cursor');
88
+ if (!exists(dir)) return { client: 'Cursor', status: 'skipped', detail: 'not detected (~/.cursor missing)' };
89
+ const file = path.join(dir, 'mcp.json');
90
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
91
+ return { client: 'Cursor', status: 'installed', detail: file };
92
+ }
93
+
94
+ function installWindsurf(spec) {
95
+ const dir = path.join(HOME, '.codeium', 'windsurf');
96
+ if (!exists(path.join(HOME, '.codeium')))
97
+ return { client: 'Windsurf', status: 'skipped', detail: 'not detected (~/.codeium missing)' };
98
+ const file = path.join(dir, 'mcp_config.json');
99
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
100
+ return { client: 'Windsurf', status: 'installed', detail: file };
101
+ }
102
+
103
+ function installCodex(spec) {
104
+ const dir = path.join(HOME, '.codex');
105
+ if (!exists(dir)) return { client: 'Codex CLI', status: 'skipped', detail: 'not detected (~/.codex missing)' };
106
+ const file = path.join(dir, 'config.toml');
107
+ let content = '';
108
+ try {
109
+ content = fs.readFileSync(file, 'utf8');
110
+ } catch {
111
+ content = '';
112
+ }
113
+ if (/\[mcp_servers\.vibeguard\]/.test(content)) {
114
+ return { client: 'Codex CLI', status: 'installed', detail: 'already present in ' + file };
115
+ }
116
+ backup(file);
117
+ const argsToml = spec.args.map((a) => JSON.stringify(a)).join(', ');
118
+ const block =
119
+ `\n[mcp_servers.vibeguard]\n` +
120
+ `command = ${JSON.stringify(spec.command)}\n` +
121
+ `args = [${argsToml}]\n`;
122
+ ensureDir(file);
123
+ fs.writeFileSync(file, (content && !content.endsWith('\n') ? content + '\n' : content) + block);
124
+ return { client: 'Codex CLI', status: 'installed', detail: file };
125
+ }
126
+
127
+ function installVSCode(spec) {
128
+ // VS Code (Copilot agent) reads workspace .vscode/mcp.json with a "servers" key.
129
+ const file = path.join(process.cwd(), '.vscode', 'mcp.json');
130
+ // Only write if a .vscode folder exists here (i.e. this is a VS Code project).
131
+ if (!exists(path.join(process.cwd(), '.vscode'))) {
132
+ return { client: 'VS Code', status: 'skipped', detail: 'no ./.vscode in this project' };
133
+ }
134
+ writeJsonMcp(file, 'servers', spec, 'vibeguard');
135
+ return { client: 'VS Code', status: 'installed', detail: file };
136
+ }
137
+
138
+ function installAntigravity(spec) {
139
+ // Google Antigravity uses ~/.antigravity/config.json with mcpServers key
140
+ const dir = path.join(HOME, '.antigravity');
141
+ if (!exists(dir)) return { client: 'Antigravity', status: 'skipped', detail: 'not detected (~/.antigravity missing)' };
142
+ const file = path.join(dir, 'config.json');
143
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
144
+ return { client: 'Antigravity', status: 'installed', detail: file };
145
+ }
146
+
147
+ function installContinue(spec) {
148
+ // Continue.dev uses ~/.continue/config.json with mcpServers key
149
+ const dir = path.join(HOME, '.continue');
150
+ if (!exists(dir)) return { client: 'Continue', status: 'skipped', detail: 'not detected (~/.continue missing)' };
151
+ const file = path.join(dir, 'config.json');
152
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
153
+ return { client: 'Continue', status: 'installed', detail: file };
154
+ }
155
+
156
+ function installCline(spec) {
157
+ // Cline (VS Code extension) uses cline_mcp_settings.json in VS Code user dir
158
+ const dir = path.join(HOME, '.vscode', 'extensions');
159
+ if (!exists(path.join(HOME, '.vscode')) && !exists(path.join(HOME, 'AppData', 'Roaming', 'Code')))
160
+ return { client: 'Cline', status: 'skipped', detail: 'not detected (VS Code not found)' };
161
+ // Cline stores MCP config in the VS Code userData directory
162
+ const userDataDir = process.platform === 'win32'
163
+ ? path.join(HOME, 'AppData', 'Roaming', 'Code', 'User')
164
+ : path.join(HOME, '.vscode', 'User');
165
+ if (!exists(userDataDir)) return { client: 'Cline', status: 'skipped', detail: 'VS Code User dir not found' };
166
+ const file = path.join(userDataDir, 'globalStorage', 'saoudrizwan.claude-dev', 'settings', 'cline_mcp_settings.json');
167
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
168
+ return { client: 'Cline', status: 'installed', detail: file };
169
+ }
170
+
171
+ function installAider(spec) {
172
+ // Aider uses ~/.aider.conf.yml — MCP via command launch
173
+ const file = path.join(HOME, '.aider.conf.yml');
174
+ if (!exists(file)) return { client: 'Aider', status: 'manual', detail: 'add --mcp to your aider launch or ~/.aider.conf.yml' };
175
+ let content = '';
176
+ try { content = fs.readFileSync(file, 'utf8'); } catch {}
177
+ if (/vibeguard/.test(content)) return { client: 'Aider', status: 'installed', detail: 'already present' };
178
+ backup(file);
179
+ const block = `\n# VibeGuard MCP server\nmcp-command: ${spec.command}\nmcp-args: ${spec.args.join(' ')}\n`;
180
+ fs.writeFileSync(file, content + block);
181
+ return { client: 'Aider', status: 'installed', detail: file };
182
+ }
183
+
184
+ function installGeminiCLI(spec) {
185
+ // Google Gemini CLI uses ~/.gemini/config.json with mcpServers key
186
+ const dir = path.join(HOME, '.gemini');
187
+ if (!exists(dir)) return { client: 'Gemini CLI', status: 'skipped', detail: 'not detected (~/.gemini missing)' };
188
+ const file = path.join(dir, 'config.json');
189
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
190
+ return { client: 'Gemini CLI', status: 'installed', detail: file };
191
+ }
192
+
193
+ function installRooCode(spec) {
194
+ // Roo Code (VS Code extension) uses roo_cline_mcp_settings.json
195
+ const userDataDir = process.platform === 'win32'
196
+ ? path.join(HOME, 'AppData', 'Roaming', 'Code', 'User')
197
+ : path.join(HOME, '.vscode', 'User');
198
+ if (!exists(userDataDir)) return { client: 'Roo Code', status: 'skipped', detail: 'VS Code User dir not found' };
199
+ const file = path.join(userDataDir, 'globalStorage', 'rooveterinaryinc.roo-cline', 'settings', 'roo_cline_mcp_settings.json');
200
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
201
+ return { client: 'Roo Code', status: 'installed', detail: file };
202
+ }
203
+
204
+ function installOpenHands(spec) {
205
+ // OpenHands uses ~/.openhands/config.toml similar to Codex
206
+ const dir = path.join(HOME, '.openhands');
207
+ if (!exists(dir)) return { client: 'OpenHands', status: 'skipped', detail: 'not detected (~/.openhands missing)' };
208
+ const file = path.join(dir, 'config.toml');
209
+ let content = '';
210
+ try { content = fs.readFileSync(file, 'utf8'); } catch {}
211
+ if (/\[mcp_servers\.vibeguard\]/.test(content)) return { client: 'OpenHands', status: 'installed', detail: 'already present' };
212
+ backup(file);
213
+ const argsToml = spec.args.map((a) => JSON.stringify(a)).join(', ');
214
+ const block = `\n[mcp_servers.vibeguard]\ncommand = ${JSON.stringify(spec.command)}\nargs = [${argsToml}]\n`;
215
+ ensureDir(file);
216
+ fs.writeFileSync(file, (content && !content.endsWith('\n') ? content + '\n' : content) + block);
217
+ return { client: 'OpenHands', status: 'installed', detail: file };
218
+ }
219
+
220
+ function installCopilotCLI(spec) {
221
+ // GitHub Copilot CLI uses ~/.copilot/config.json with mcpServers key
222
+ const dir = path.join(HOME, '.copilot');
223
+ if (!exists(dir)) return { client: 'Copilot CLI', status: 'skipped', detail: 'not detected (~/.copilot missing)' };
224
+ const file = path.join(dir, 'config.json');
225
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
226
+ return { client: 'Copilot CLI', status: 'installed', detail: file };
227
+ }
228
+
229
+ function installAmazonQ(spec) {
230
+ // Amazon Q Developer CLI uses ~/.aws/amazonq/config.json
231
+ const dir = path.join(HOME, '.aws', 'amazonq');
232
+ if (!exists(dir)) return { client: 'Amazon Q', status: 'skipped', detail: 'not detected (~/.aws/amazonq missing)' };
233
+ const file = path.join(dir, 'config.json');
234
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
235
+ return { client: 'Amazon Q', status: 'installed', detail: file };
236
+ }
237
+
238
+ function installCody(spec) {
239
+ // Sourcegraph Cody uses ~/.config/cody/config.json
240
+ const dir = process.platform === 'win32'
241
+ ? path.join(HOME, 'AppData', 'Roaming', 'Sourcegraph', 'Cody')
242
+ : path.join(HOME, '.config', 'cody');
243
+ if (!exists(dir)) return { client: 'Sourcegraph Cody', status: 'skipped', detail: 'not detected (cody config dir missing)' };
244
+ const file = path.join(dir, 'config.json');
245
+ writeJsonMcp(file, 'mcpServers', spec, 'vibeguard');
246
+ return { client: 'Sourcegraph Cody', status: 'installed', detail: file };
247
+ }
248
+
249
+ function installHermes(spec) {
250
+ // Hermes Agent (Nous Research) reads MCP servers from $HERMES_HOME/config.yaml
251
+ // (default ~/.hermes/config.yaml) under `mcp_servers:`. We never hand-edit the
252
+ // YAML (a bad write can break the live gateway); we detect it and emit the
253
+ // exact, safe commands using Hermes' own config CLI instead.
254
+ const hermesHome = process.env.HERMES_HOME || path.join(HOME, '.hermes');
255
+ const cfg = path.join(hermesHome, 'config.yaml');
256
+ if (!exists(cfg)) {
257
+ return { client: 'Hermes Agent', status: 'skipped', detail: `not detected (${cfg} missing)` };
258
+ }
259
+ const argsStr = spec.args.map((a) => JSON.stringify(a)).join(', ');
260
+ return {
261
+ client: 'Hermes Agent',
262
+ status: 'instructions',
263
+ detail: `${cfg} — add under \`mcp_servers:\`, or run:\n hermes config set mcp_servers.vibeguard.command ${spec.command}\n hermes config set mcp_servers.vibeguard.args '[${argsStr}]'\n hermes config set mcp_servers.vibeguard.timeout 120`,
264
+ };
265
+ }
266
+
267
+ function pasteBlock(spec) {
268
+ return JSON.stringify(
269
+ { mcpServers: { vibeguard: { command: spec.command, args: spec.args } } },
270
+ null,
271
+ 2
272
+ );
273
+ }
274
+
275
+ function install(opts = {}) {
276
+ const spec = serverSpec(opts.local);
277
+ const results = [
278
+ installClaudeCode(spec),
279
+ installCursor(spec),
280
+ installWindsurf(spec),
281
+ installCodex(spec),
282
+ installAntigravity(spec),
283
+ installContinue(spec),
284
+ installCline(spec),
285
+ installAider(spec),
286
+ installGeminiCLI(spec),
287
+ installRooCode(spec),
288
+ installOpenHands(spec),
289
+ installVSCode(spec),
290
+ installCopilotCLI(spec),
291
+ installAmazonQ(spec),
292
+ installCody(spec),
293
+ installHermes(spec),
294
+ ];
295
+ return { spec, results, paste: pasteBlock(spec) };
296
+ }
297
+
298
+ module.exports = { install, serverSpec, pasteBlock, writeJsonMcp };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "tool": "vibeguard",
3
- "generatedAt": "2026-11-22T19:55:42.417Z",
3
+ "generatedAt": "2026-11-22T20:37:46.905Z",
4
4
  "algo": "sha256",
5
5
  "hashes": {
6
6
  "action-guard.js": "764f02ee6d4a1dc95939642f120ac7c233f66aee2794dd71efa15f5690fc43b0",