@yagyeshvyas/vibeguard 1.12.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 (113) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +34 -17
  3. package/bin/cli.js +2753 -2753
  4. package/bin/cmd-mcp-firewall.js +1 -0
  5. package/bin/cmd-platform.js +3 -0
  6. package/ci/vibeguard.yml +42 -42
  7. package/package.json +2 -2
  8. package/scripts/counts.js +93 -93
  9. package/scripts/postinstall.js +26 -26
  10. package/src/auto.js +427 -427
  11. package/src/daemon.js +343 -343
  12. package/src/dashboard.js +278 -278
  13. package/src/engine.js +297 -297
  14. package/src/hook.js +151 -151
  15. package/src/install.js +298 -298
  16. package/src/integrity.js +1 -0
  17. package/src/integrity.json +9 -6
  18. package/src/mcp-firewall.js +11 -0
  19. package/src/platform/approval-service.js +124 -0
  20. package/src/platform/approval.js +16 -0
  21. package/src/platform/oauth-server.js +89 -0
  22. package/src/platform/os-sandbox.js +52 -1
  23. package/src/platform/runtime-monitor.js +69 -0
  24. package/src/platform/sandbox-manager.js +5 -0
  25. package/src/plugin.js +182 -182
  26. package/src/privacy-audit.js +272 -272
  27. package/src/repl.js +150 -150
  28. package/src/report.js +331 -331
  29. package/src/rules-pack.js +3068 -3068
  30. package/src/rules.js +1822 -1822
  31. package/src/sbom.js +193 -193
  32. package/src/scanner.js +1032 -1032
  33. package/src/shell-guard.js +302 -302
  34. package/src/slopsquat.js +144 -144
  35. package/src/trace.js +220 -220
  36. package/src/.vibeguard/cache/file-hashes.json +0 -60
  37. package/src/.vibeguard/latest-snapshot.json +0 -36
  38. package/src/.vibeguard/mcp-pins.json +0 -1
  39. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/auto.js +0 -428
  40. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/daemon.js +0 -344
  41. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/dashboard.js +0 -279
  42. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/engine.js +0 -297
  43. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/hook.js +0 -151
  44. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/install.js +0 -299
  45. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/manifest.json +0 -65
  46. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/mcp-server.js +0 -2051
  47. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/plugin.js +0 -168
  48. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/pre-deploy.js +0 -362
  49. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/repl.js +0 -150
  50. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/rules.js +0 -1611
  51. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/sbom.js +0 -164
  52. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/shell-guard.js +0 -292
  53. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/slopsquat.js +0 -144
  54. package/src/.vibeguard/snapshots/2026-08-05T16-23-50-635Z/trace.js +0 -220
  55. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/auto.js +0 -428
  56. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/daemon.js +0 -344
  57. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/engine.js +0 -297
  58. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/install.js +0 -299
  59. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/manifest.json +0 -37
  60. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/mcp-server.js +0 -2055
  61. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/plugin.js +0 -168
  62. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/pre-deploy.js +0 -362
  63. package/src/.vibeguard/snapshots/2026-08-05T16-26-26-074Z/trace.js +0 -220
  64. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/auto.js +0 -428
  65. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/daemon.js +0 -344
  66. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/dashboard.js +0 -279
  67. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/engine.js +0 -297
  68. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/hook.js +0 -151
  69. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/install.js +0 -299
  70. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/manifest.json +0 -65
  71. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/mcp-server.js +0 -2055
  72. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/plugin.js +0 -168
  73. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/pre-deploy.js +0 -362
  74. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/repl.js +0 -150
  75. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/rules.js +0 -1611
  76. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/sbom.js +0 -164
  77. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/shell-guard.js +0 -292
  78. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/slopsquat.js +0 -144
  79. package/src/.vibeguard/snapshots/2026-08-05T16-35-06-272Z/trace.js +0 -220
  80. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/auto.js +0 -428
  81. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/daemon.js +0 -344
  82. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/dashboard.js +0 -279
  83. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/engine.js +0 -297
  84. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/hook.js +0 -151
  85. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/install.js +0 -299
  86. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/manifest.json +0 -65
  87. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/mcp-server.js +0 -2054
  88. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/plugin.js +0 -168
  89. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/pre-deploy.js +0 -362
  90. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/repl.js +0 -150
  91. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/rules.js +0 -1611
  92. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/sbom.js +0 -164
  93. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/shell-guard.js +0 -292
  94. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/slopsquat.js +0 -144
  95. package/src/.vibeguard/snapshots/2026-08-05T18-08-40-613Z/trace.js +0 -220
  96. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/auto.js +0 -428
  97. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/daemon.js +0 -344
  98. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/engine.js +0 -297
  99. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/install.js +0 -299
  100. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/manifest.json +0 -37
  101. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/mcp-server.js +0 -2055
  102. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/plugin.js +0 -168
  103. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/pre-deploy.js +0 -362
  104. package/src/.vibeguard/snapshots/2026-08-05T18-11-32-644Z/trace.js +0 -220
  105. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js +0 -428
  106. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js +0 -344
  107. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js +0 -297
  108. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/manifest.json +0 -33
  109. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js +0 -2055
  110. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js +0 -1611
  111. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js +0 -292
  112. package/src/.vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js +0 -220
  113. package/src/.vibeguard-baseline.json +0 -5226
package/src/trace.js CHANGED
@@ -1,220 +1,220 @@
1
- 'use strict';
2
-
3
- /*
4
- * Prompt tracing — link findings back to the AI prompt that generated them.
5
- *
6
- * Reads Cursor (.cursor/), Claude Code, and Windsurf session history files.
7
- * Scans for security-relevant behavior patterns in AI agent transcripts.
8
- *
9
- * Two capabilities:
10
- * 1. Trace a finding back to the AI prompt that likely generated the code
11
- * 2. Behavior analysis: detect blind approvals, high delegation, risky patterns
12
- */
13
-
14
- const fs = require('fs');
15
- const path = require('path');
16
-
17
- const SESSION_DIRS = [
18
- '.cursor',
19
- '.cursor/projects',
20
- '.windsurf',
21
- '.claude',
22
- '.continue',
23
- ];
24
-
25
- function findSessionFiles(root) {
26
- const files = [];
27
- for (const dir of SESSION_DIRS) {
28
- const absDir = path.join(root, dir);
29
- if (!fs.existsSync(absDir)) continue;
30
- try {
31
- walkAndCollect(absDir, files, /\.(?:json|jsonl|md|txt)$/i);
32
- } catch {}
33
- }
34
- return files;
35
- }
36
-
37
- function walkAndCollect(dir, out, extRe) {
38
- let entries;
39
- try {
40
- entries = fs.readdirSync(dir, { withFileTypes: true });
41
- } catch { return; }
42
- for (const e of entries) {
43
- const full = path.join(dir, e.name);
44
- if (e.isDirectory()) walkAndCollect(full, out, extRe);
45
- else if (e.isFile() && extRe.test(e.name)) out.push(full);
46
- }
47
- }
48
-
49
- function parseSession(filepath) {
50
- const content = fs.readFileSync(filepath, 'utf8');
51
- const messages = [];
52
-
53
- // Try JSONL format (one JSON object per line)
54
- if (filepath.endsWith('.jsonl')) {
55
- for (const line of content.split('\n')) {
56
- try {
57
- const obj = JSON.parse(line);
58
- if (obj.role || obj.type || obj.message) messages.push(obj);
59
- } catch {}
60
- }
61
- }
62
-
63
- // Try JSON array
64
- if (messages.length === 0 && filepath.endsWith('.json')) {
65
- try {
66
- const arr = JSON.parse(content);
67
- if (Array.isArray(arr)) messages.push(...arr);
68
- else messages.push(arr);
69
- } catch {}
70
- }
71
-
72
- // Try markdown/text (split by user/assistant markers)
73
- if (messages.length === 0) {
74
- const parts = content.split(/^(?:User|Human|Assistant|AI|>>>)[:\s]/m);
75
- parts.forEach((p, i) => {
76
- if (p.trim()) messages.push({ role: i % 2 === 0 ? 'user' : 'assistant', content: p.trim() });
77
- });
78
- }
79
-
80
- return { file: filepath, messages };
81
- }
82
-
83
- const RISKY_BEHAVIORS = [
84
- {
85
- id: 'behavior.blind-approval',
86
- re: /(?:yes|ok|sure|go ahead|do it|approve|sounds good|perfect|great)\s*[!.?\s]*$/i,
87
- risk: 'medium',
88
- desc: 'Blind approval of AI suggestion without review',
89
- },
90
- {
91
- id: 'behavior.high-delegation',
92
- re: /(?:do\s+(?:all|everything|the\s+whole)|build\s+(?:the\s+entire|all)|write\s+(?:all|every|the\s+complete)|implement\s+(?:all|everything|the\s+entire))/i,
93
- risk: 'medium',
94
- desc: 'High delegation — asking AI to do everything at once reduces review quality',
95
- },
96
- {
97
- id: 'behavior.skip-tests',
98
- re: /(?:skip|don'?t\s+need|no\s+need\s+for)\s+(?:tests?|testing|validation)/i,
99
- risk: 'high',
100
- desc: 'Requesting code without tests',
101
- },
102
- {
103
- id: 'behavior.skip-auth',
104
- re: /(?:skip|don'?t\s+(?:need|worry\s+about)|no\s+need\s+for)\s+(?:auth|authentication|authorization|security)/i,
105
- risk: 'high',
106
- desc: 'Explicitly requesting to skip authentication/security',
107
- },
108
- {
109
- id: 'behavior.hardcode-secrets',
110
- re: /(?:just\s+)?(?:hardcode|hard-code|put\s+(?:the\s+)?(?:password|secret|token|key|api\s+key)\s+(?:directly\s+)?(?:in|here))/i,
111
- risk: 'high',
112
- desc: 'Asking AI to hardcode secrets',
113
- },
114
- {
115
- id: 'behavior.disable-security',
116
- re: /(?:disable|turn\s+off|remove|skip|bypass)\s+(?:security|validation|sanitization|escaping|CORS|helmet|CSRF)/i,
117
- risk: 'high',
118
- desc: 'Asking AI to disable security features',
119
- },
120
- {
121
- id: 'behavior.trust-input',
122
- re: /(?:trust\s+the\s+(?:user|client|input)|user\s+input\s+is\s+(?:safe|trusted|fine)|don'?t\s+validate)/i,
123
- risk: 'high',
124
- desc: 'Expressing trust in user/client input without validation',
125
- },
126
- {
127
- id: 'behavior.excessive-iter',
128
- re: /(?:again|redo|try\s+again|different\s+approach|start\s+over)/i,
129
- risk: 'low',
130
- desc: 'Excessive iteration on AI output — possible degradation of review quality',
131
- threshold: 10,
132
- },
133
- ];
134
-
135
- function analyzeBehavior(messages) {
136
- const behaviors = [];
137
- let userMessages = 0;
138
- let approvals = 0;
139
- let iterations = 0;
140
-
141
- for (const msg of messages) {
142
- const role = msg.role || msg.type || '';
143
- const content = msg.content || msg.message || msg.text || '';
144
- if (typeof content !== 'string') continue;
145
- if (!/user|human/i.test(role)) continue;
146
- userMessages++;
147
-
148
- for (const b of RISKY_BEHAVIORS) {
149
- if (b.re.test(content)) {
150
- if (b.id === 'behavior.blind-approval') approvals++;
151
- if (b.id === 'behavior.excessive-iter') iterations++;
152
- if (b.id === 'behavior.excessive-iter' && iterations < (b.threshold || 10)) continue;
153
- behaviors.push({
154
- id: b.id,
155
- risk: b.risk,
156
- message: b.desc,
157
- snippet: content.slice(0, 200),
158
- });
159
- }
160
- }
161
- }
162
-
163
- const delegationRatio = userMessages > 0 ? approvals / userMessages : 0;
164
- const risk = delegationRatio > 0.6 ? 'high' : delegationRatio > 0.3 ? 'medium' : 'low';
165
-
166
- return {
167
- totalUserMessages: userMessages,
168
- approvals,
169
- iterations,
170
- delegationRatio: Math.round(delegationRatio * 100) / 100,
171
- risk,
172
- behaviors,
173
- recommendation:
174
- risk === 'high'
175
- ? 'High blind-approval ratio — review AI suggestions more carefully before accepting'
176
- : risk === 'medium'
177
- ? 'Moderate delegation — ensure each AI suggestion is reviewed'
178
- : 'Good review discipline — keep validating AI output',
179
- };
180
- }
181
-
182
- function traceFindingsToPrompts(findings, sessions) {
183
- const traces = [];
184
- for (const f of findings) {
185
- const matching = [];
186
- for (const session of sessions) {
187
- for (const msg of session.messages) {
188
- const content = msg.content || msg.message || '';
189
- if (typeof content !== 'string') continue;
190
- const snippet = f.snippet || '';
191
- if (snippet && content.includes(snippet.slice(0, 30))) {
192
- matching.push({ file: session.file, role: msg.role, snippet: content.slice(0, 200) });
193
- }
194
- const titleWords = (f.title || '').split(/\s+/).filter((w) => w.length > 4);
195
- if (titleWords.length > 0 && titleWords.every((w) => content.toLowerCase().includes(w.toLowerCase()))) {
196
- matching.push({ file: session.file, role: msg.role, snippet: content.slice(0, 200) });
197
- }
198
- }
199
- }
200
- if (matching.length > 0) {
201
- traces.push({ finding: f.ruleId, file: f.file, line: f.line, matches: matching });
202
- }
203
- }
204
- return traces;
205
- }
206
-
207
- function trace(root, findings) {
208
- const sessionFiles = findSessionFiles(root);
209
- if (sessionFiles.length === 0) {
210
- return { sessions: 0, behavior: null, traces: [] };
211
- }
212
-
213
- const sessions = sessionFiles.map(parseSession);
214
- const behavior = analyzeBehavior(sessions.flatMap((s) => s.messages));
215
- const traces = traceFindingsToPrompts(findings, sessions);
216
-
217
- return { sessions: sessions.length, behavior, traces };
218
- }
219
-
220
- module.exports = { trace, analyzeBehavior, findSessionFiles, parseSession, RISKY_BEHAVIORS };
1
+ 'use strict';
2
+
3
+ /*
4
+ * Prompt tracing — link findings back to the AI prompt that generated them.
5
+ *
6
+ * Reads Cursor (.cursor/), Claude Code, and Windsurf session history files.
7
+ * Scans for security-relevant behavior patterns in AI agent transcripts.
8
+ *
9
+ * Two capabilities:
10
+ * 1. Trace a finding back to the AI prompt that likely generated the code
11
+ * 2. Behavior analysis: detect blind approvals, high delegation, risky patterns
12
+ */
13
+
14
+ const fs = require('fs');
15
+ const path = require('path');
16
+
17
+ const SESSION_DIRS = [
18
+ '.cursor',
19
+ '.cursor/projects',
20
+ '.windsurf',
21
+ '.claude',
22
+ '.continue',
23
+ ];
24
+
25
+ function findSessionFiles(root) {
26
+ const files = [];
27
+ for (const dir of SESSION_DIRS) {
28
+ const absDir = path.join(root, dir);
29
+ if (!fs.existsSync(absDir)) continue;
30
+ try {
31
+ walkAndCollect(absDir, files, /\.(?:json|jsonl|md|txt)$/i);
32
+ } catch {}
33
+ }
34
+ return files;
35
+ }
36
+
37
+ function walkAndCollect(dir, out, extRe) {
38
+ let entries;
39
+ try {
40
+ entries = fs.readdirSync(dir, { withFileTypes: true });
41
+ } catch { return; }
42
+ for (const e of entries) {
43
+ const full = path.join(dir, e.name);
44
+ if (e.isDirectory()) walkAndCollect(full, out, extRe);
45
+ else if (e.isFile() && extRe.test(e.name)) out.push(full);
46
+ }
47
+ }
48
+
49
+ function parseSession(filepath) {
50
+ const content = fs.readFileSync(filepath, 'utf8');
51
+ const messages = [];
52
+
53
+ // Try JSONL format (one JSON object per line)
54
+ if (filepath.endsWith('.jsonl')) {
55
+ for (const line of content.split('\n')) {
56
+ try {
57
+ const obj = JSON.parse(line);
58
+ if (obj.role || obj.type || obj.message) messages.push(obj);
59
+ } catch {}
60
+ }
61
+ }
62
+
63
+ // Try JSON array
64
+ if (messages.length === 0 && filepath.endsWith('.json')) {
65
+ try {
66
+ const arr = JSON.parse(content);
67
+ if (Array.isArray(arr)) messages.push(...arr);
68
+ else messages.push(arr);
69
+ } catch {}
70
+ }
71
+
72
+ // Try markdown/text (split by user/assistant markers)
73
+ if (messages.length === 0) {
74
+ const parts = content.split(/^(?:User|Human|Assistant|AI|>>>)[:\s]/m);
75
+ parts.forEach((p, i) => {
76
+ if (p.trim()) messages.push({ role: i % 2 === 0 ? 'user' : 'assistant', content: p.trim() });
77
+ });
78
+ }
79
+
80
+ return { file: filepath, messages };
81
+ }
82
+
83
+ const RISKY_BEHAVIORS = [
84
+ {
85
+ id: 'behavior.blind-approval',
86
+ re: /(?:yes|ok|sure|go ahead|do it|approve|sounds good|perfect|great)\s*[!.?\s]*$/i,
87
+ risk: 'medium',
88
+ desc: 'Blind approval of AI suggestion without review',
89
+ },
90
+ {
91
+ id: 'behavior.high-delegation',
92
+ re: /(?:do\s+(?:all|everything|the\s+whole)|build\s+(?:the\s+entire|all)|write\s+(?:all|every|the\s+complete)|implement\s+(?:all|everything|the\s+entire))/i,
93
+ risk: 'medium',
94
+ desc: 'High delegation — asking AI to do everything at once reduces review quality',
95
+ },
96
+ {
97
+ id: 'behavior.skip-tests',
98
+ re: /(?:skip|don'?t\s+need|no\s+need\s+for)\s+(?:tests?|testing|validation)/i,
99
+ risk: 'high',
100
+ desc: 'Requesting code without tests',
101
+ },
102
+ {
103
+ id: 'behavior.skip-auth',
104
+ re: /(?:skip|don'?t\s+(?:need|worry\s+about)|no\s+need\s+for)\s+(?:auth|authentication|authorization|security)/i,
105
+ risk: 'high',
106
+ desc: 'Explicitly requesting to skip authentication/security',
107
+ },
108
+ {
109
+ id: 'behavior.hardcode-secrets',
110
+ re: /(?:just\s+)?(?:hardcode|hard-code|put\s+(?:the\s+)?(?:password|secret|token|key|api\s+key)\s+(?:directly\s+)?(?:in|here))/i,
111
+ risk: 'high',
112
+ desc: 'Asking AI to hardcode secrets',
113
+ },
114
+ {
115
+ id: 'behavior.disable-security',
116
+ re: /(?:disable|turn\s+off|remove|skip|bypass)\s+(?:security|validation|sanitization|escaping|CORS|helmet|CSRF)/i,
117
+ risk: 'high',
118
+ desc: 'Asking AI to disable security features',
119
+ },
120
+ {
121
+ id: 'behavior.trust-input',
122
+ re: /(?:trust\s+the\s+(?:user|client|input)|user\s+input\s+is\s+(?:safe|trusted|fine)|don'?t\s+validate)/i,
123
+ risk: 'high',
124
+ desc: 'Expressing trust in user/client input without validation',
125
+ },
126
+ {
127
+ id: 'behavior.excessive-iter',
128
+ re: /(?:again|redo|try\s+again|different\s+approach|start\s+over)/i,
129
+ risk: 'low',
130
+ desc: 'Excessive iteration on AI output — possible degradation of review quality',
131
+ threshold: 10,
132
+ },
133
+ ];
134
+
135
+ function analyzeBehavior(messages) {
136
+ const behaviors = [];
137
+ let userMessages = 0;
138
+ let approvals = 0;
139
+ let iterations = 0;
140
+
141
+ for (const msg of messages) {
142
+ const role = msg.role || msg.type || '';
143
+ const content = msg.content || msg.message || msg.text || '';
144
+ if (typeof content !== 'string') continue;
145
+ if (!/user|human/i.test(role)) continue;
146
+ userMessages++;
147
+
148
+ for (const b of RISKY_BEHAVIORS) {
149
+ if (b.re.test(content)) {
150
+ if (b.id === 'behavior.blind-approval') approvals++;
151
+ if (b.id === 'behavior.excessive-iter') iterations++;
152
+ if (b.id === 'behavior.excessive-iter' && iterations < (b.threshold || 10)) continue;
153
+ behaviors.push({
154
+ id: b.id,
155
+ risk: b.risk,
156
+ message: b.desc,
157
+ snippet: content.slice(0, 200),
158
+ });
159
+ }
160
+ }
161
+ }
162
+
163
+ const delegationRatio = userMessages > 0 ? approvals / userMessages : 0;
164
+ const risk = delegationRatio > 0.6 ? 'high' : delegationRatio > 0.3 ? 'medium' : 'low';
165
+
166
+ return {
167
+ totalUserMessages: userMessages,
168
+ approvals,
169
+ iterations,
170
+ delegationRatio: Math.round(delegationRatio * 100) / 100,
171
+ risk,
172
+ behaviors,
173
+ recommendation:
174
+ risk === 'high'
175
+ ? 'High blind-approval ratio — review AI suggestions more carefully before accepting'
176
+ : risk === 'medium'
177
+ ? 'Moderate delegation — ensure each AI suggestion is reviewed'
178
+ : 'Good review discipline — keep validating AI output',
179
+ };
180
+ }
181
+
182
+ function traceFindingsToPrompts(findings, sessions) {
183
+ const traces = [];
184
+ for (const f of findings) {
185
+ const matching = [];
186
+ for (const session of sessions) {
187
+ for (const msg of session.messages) {
188
+ const content = msg.content || msg.message || '';
189
+ if (typeof content !== 'string') continue;
190
+ const snippet = f.snippet || '';
191
+ if (snippet && content.includes(snippet.slice(0, 30))) {
192
+ matching.push({ file: session.file, role: msg.role, snippet: content.slice(0, 200) });
193
+ }
194
+ const titleWords = (f.title || '').split(/\s+/).filter((w) => w.length > 4);
195
+ if (titleWords.length > 0 && titleWords.every((w) => content.toLowerCase().includes(w.toLowerCase()))) {
196
+ matching.push({ file: session.file, role: msg.role, snippet: content.slice(0, 200) });
197
+ }
198
+ }
199
+ }
200
+ if (matching.length > 0) {
201
+ traces.push({ finding: f.ruleId, file: f.file, line: f.line, matches: matching });
202
+ }
203
+ }
204
+ return traces;
205
+ }
206
+
207
+ function trace(root, findings) {
208
+ const sessionFiles = findSessionFiles(root);
209
+ if (sessionFiles.length === 0) {
210
+ return { sessions: 0, behavior: null, traces: [] };
211
+ }
212
+
213
+ const sessions = sessionFiles.map(parseSession);
214
+ const behavior = analyzeBehavior(sessions.flatMap((s) => s.messages));
215
+ const traces = traceFindingsToPrompts(findings, sessions);
216
+
217
+ return { sessions: sessions.length, behavior, traces };
218
+ }
219
+
220
+ module.exports = { trace, analyzeBehavior, findSessionFiles, parseSession, RISKY_BEHAVIORS };
@@ -1,60 +0,0 @@
1
- {
2
- "src\\action-guard.js": "5b6bc868643909c8ba4edee717590b9896488eb0720636ed58a87a98e1f2d7ac",
3
- "src\\agent-scan.js": "018813166eb1e370bf452efaa92020cd4baea0a20f3826fed3f95ded312aa5c7",
4
- "src\\ai-guard.js": "9dd2c524dd704bbba69aacf7076e76ac966c6e0c773ee4b04ed7c8fb889db006",
5
- "src\\ast.js": "18f09f9c082c6a9364f705aa6a1c759923aa14694f192631fc28a817c09cb0f2",
6
- "src\\audit-trail.js": "4a85a1742f0285866ff476ed6a1bb71adc23544c64a01b9132f2af83e42df1d2",
7
- "src\\auto.js": "d9e2da6d17da445268190b0c22b23e34466b88340eefeed3e115835df4865e94",
8
- "src\\autofix.js": "4bde4737edffe427e6d3aaf81d965ea011bc3833c4148c4a22ee1f12703bbfe3",
9
- "src\\badge.js": "d1b15b89c9c465ad200cbf8ec4375c7a57c973c0e61ff6180dd375c13b730e79",
10
- "src\\behavior.js": "32cacd372634db14514acce2152c5fbfd06dcff1688e1a4dc818b630af30ea08",
11
- "src\\compliance.js": "5c2bd2382e863fdfd919e122882e7200eb8cd337554c5c08e94ae4989143ea1d",
12
- "src\\crosstaint.js": "e73373b6539bb13bae852eebca525bef96ec7a81748f13d2b23c9168bd4e85d5",
13
- "src\\cve-intel.js": "2e483a12cb4277696e39ac45df41b9ef6690a7ff4710d0896d0a9a53a300bec6",
14
- "src\\daemon-run.js": "ed9c886cceef3b0e5d247811b1fc4e234627262b7e462bb6d3de1726e67cee7e",
15
- "src\\daemon.js": "ba8b04a18eb90b15c7638cebf1d64ccff56bb50f6578388cf84d586e13085333",
16
- "src\\dashboard.js": "306341fef715ce4798af7261a5c88de0294ad6133f1164f64143c759e9eea672",
17
- "src\\deps.js": "d402879b7cdc59a0893f468c7fd13c1565c30c2fe605302c62b7dd4a5cb3fd4d",
18
- "src\\doctor.js": "af1b2f1b71333c6784b7300d9014116bdeb1d2dfcf53f8492655ebb6942d3a44",
19
- "src\\engine.js": "df64dffbecbfd03b95212921968b27c8172a43ac5ec7cb24caf407a7c7c9e727",
20
- "src\\external.js": "46bfe70cc5d8fce56b52e548bf355316ccb3de1d7b09bca7fac56365c547ac98",
21
- "src\\firewall.js": "61b31a2a55d63503c6bdcf888394b7a713678ea0e0b656e0d2179c91f66444a9",
22
- "src\\guard.js": "b01088b9c200b9675f2ad42a22a6f404ebf4aabc1301b3e1319d0d8115749af2",
23
- "src\\history.js": "5f23bd1f4114680bb619bae5a085b72c8d6c8515caae8b385f5be518e19a2db7",
24
- "src\\hook.js": "e839314e11036cfb0d9fd7550e956dec68aaf1fc3c6f05c71e2c6c41b353c701",
25
- "src\\install.js": "713201e1e34ecf7227cf1dd9bcb700555784b3efea8638d3673525473a00c1ac",
26
- "src\\integrity.js": "4e1aeeedef92481400172b99d4b759e8198a2889874860f7efd26e1a373c20ed",
27
- "src\\integrity.json": "c2dd7b37b741b2f14c85dcd70b21e0a57718b21eae187274a725a82b11d81fda",
28
- "src\\interceptor.js": "0a137e2b8a50398973e93913cf6feb22c9ac6d70b0f0d075a46a28f1a804827a",
29
- "src\\mcp-audit.js": "8f38b2738ffedc23f61601a1c03d3cbaac8a38fb19390a898ffe32b30bf8ffc4",
30
- "src\\mcp-server.js": "0ac8078c950bf33abe085a7d55310493ba7e6b707431a1e981ecf80bdb0f0b86",
31
- "src\\net-audit.js": "92155c86c59bbcd9bc2817f9615182c33b44ac267a52ba12c1249213e9f01cd4",
32
- "src\\pii.js": "51ea76de52b2c15d2cb34ab8125a5f67f725d1e7de43a4cef39136e25b276025",
33
- "src\\plugin.js": "9545e2c6966def8797b7424ec485e6650f369418e65a5dfe029b9e433f458937",
34
- "src\\policy-gen.js": "00674efc8a8bb5e9dc244b9232337253378958aa23f09f9075b29c4a3a0021dd",
35
- "src\\pre-deploy.js": "b3c20ba753b9d45f4f538bf76c07e0ac342eb410b86481401aa29129188a3c24",
36
- "src\\presets.js": "93a154e7afacba4303d7864f949331d0d99539ea685465d1625a350b8a6dd133",
37
- "src\\privacy-audit.js": "c58be96bd0cd1b7ee2d9c80224e804f05548b4978509310892886bd3af5fb256",
38
- "src\\proxy.js": "2f4d73fa8280a44841ae38a5930252d3d5b34d75c369c79b40bf679f4eac6da6",
39
- "src\\repl.js": "93fe101bfd6fa4dff6048299bab53394daa5c4cf37498ef734b58332df070983",
40
- "src\\report.js": "5bd90f42aa649d24a1bf352407fbbbdb64ba1133295d75003445083ad1f8f12a",
41
- "src\\rules-pack.js": "4000f23bb6e03458f2f70cdcdb1c04ac43f1b6afdcd24354b7e257acdeb4b953",
42
- "src\\rules.js": "a1f9387f844c2b5eb9eed2505a07c6966b349d32e7eae516261d6fd6ba884c38",
43
- "src\\sandbox.js": "958d6a65f0a0801564d1ab073d0842b84cfb5ed9a1a260397a7db606c9afee12",
44
- "src\\sbom.js": "7899f87e404e9dd108bd517103231014d169cca5f9d96eeaa0e7bc1929a042e2",
45
- "src\\scanner.js": "a68643ce2439043345a659549476194f06fd2c1ad4ca9dbc2a72d08552658c76",
46
- "src\\secure-prompt.js": "a4d8203ad2292e57b29f75a700f2837f12ba6c9067fd4d5f6731e55203e184b2",
47
- "src\\shell-guard.js": "f16a0bd72d7e99feaae69bb20886ed2569d137bdc65240a6eacdfcf214831d9d",
48
- "src\\shell-hook.sh": "78d1c958b5ade7fcb44c35e9bf5c104f255c0780105743b9c8d41b87dc50212b",
49
- "src\\slopsquat.js": "a0333c3ff25809166a5826fa128a642216e157ce1e6174b3b25c3f9583535f79",
50
- "src\\supply-firewall.js": "357dd9e156c0b97ba9b2966d1f7920351b007dcbbd85ddacbe7e6f5ae1e19844",
51
- "src\\suppress.js": "3c34ebbdabb0338fe3bf00d399aaa9ab04fb796067fe33a4a4b52884eb5c4fda",
52
- "src\\taint-ast.js": "80de0594102c40095509e2eb5d79eba4568566b456b6cd7134fcf69fdc83e7ef",
53
- "src\\taint-py.js": "a2956aa190c94de7f12e449f06bc3107b96aea19728210788d43eb4198786d4f",
54
- "src\\taint.js": "958decf89c32993e2c9a057ef7be9bbe592e7525fd0daa5fc5a278dcafe957af",
55
- "src\\trace.js": "f8eabeb328f1f1754af2e3d8f9ce9173cb1b02446ee33eb216abb9c88190fe6e",
56
- "src\\urlscan.js": "493a83a447a592c0d910350404d93a50f9987b4c3346ff35c63de832ccfa8f7a",
57
- "src\\vault.js": "bd325fc67cb318825ccefa59fdee22e922abea385d9084f8177b1b0a79d027eb",
58
- "src\\verify.js": "4e031db183842eed3fd5148b41fc445032406c13e8866108de2d957e9c8920ba",
59
- "src\\verifykeys.js": "abfd3dca195ed7da582fd443ac72adb519bd38b3c0016b40df5b7204ce717429"
60
- }
@@ -1,36 +0,0 @@
1
- {
2
- "dir": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z",
3
- "manifest": {
4
- "stamp": "2026-08-05T18-16-47-635Z",
5
- "files": [
6
- {
7
- "file": "rules.js",
8
- "backup": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z/rules.js"
9
- },
10
- {
11
- "file": "auto.js",
12
- "backup": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z/auto.js"
13
- },
14
- {
15
- "file": "daemon.js",
16
- "backup": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z/daemon.js"
17
- },
18
- {
19
- "file": "engine.js",
20
- "backup": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z/engine.js"
21
- },
22
- {
23
- "file": "mcp-server.js",
24
- "backup": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z/mcp-server.js"
25
- },
26
- {
27
- "file": "shell-guard.js",
28
- "backup": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z/shell-guard.js"
29
- },
30
- {
31
- "file": "trace.js",
32
- "backup": ".vibeguard/snapshots/2026-08-05T18-16-47-635Z/trace.js"
33
- }
34
- ]
35
- }
36
- }
@@ -1 +0,0 @@
1
- {}