jev-codeguard 0.0.0-stage → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +364 -2
  3. package/THIRD_PARTY_NOTICES.md +25 -0
  4. package/dist/src/cli/hook-runner.d.ts +27 -0
  5. package/dist/src/cli/hook-runner.js +196 -0
  6. package/dist/src/cli/hook-runner.js.map +1 -0
  7. package/dist/src/cli/index.d.ts +2 -0
  8. package/dist/src/cli/index.js +173 -0
  9. package/dist/src/cli/index.js.map +1 -0
  10. package/dist/src/cli/setup.d.ts +14 -0
  11. package/dist/src/cli/setup.js +122 -0
  12. package/dist/src/cli/setup.js.map +1 -0
  13. package/dist/src/core/cache.d.ts +16 -0
  14. package/dist/src/core/cache.js +64 -0
  15. package/dist/src/core/cache.js.map +1 -0
  16. package/dist/src/core/command-shape.d.ts +17 -0
  17. package/dist/src/core/command-shape.js +138 -0
  18. package/dist/src/core/command-shape.js.map +1 -0
  19. package/dist/src/core/context-enricher.d.ts +149 -0
  20. package/dist/src/core/context-enricher.js +1397 -0
  21. package/dist/src/core/context-enricher.js.map +1 -0
  22. package/dist/src/core/event-log.d.ts +35 -0
  23. package/dist/src/core/event-log.js +241 -0
  24. package/dist/src/core/event-log.js.map +1 -0
  25. package/dist/src/core/git-collector.d.ts +18 -0
  26. package/dist/src/core/git-collector.js +227 -0
  27. package/dist/src/core/git-collector.js.map +1 -0
  28. package/dist/src/core/hybrid-ast-engine.d.ts +46 -0
  29. package/dist/src/core/hybrid-ast-engine.js +641 -0
  30. package/dist/src/core/hybrid-ast-engine.js.map +1 -0
  31. package/dist/src/core/jev-client.d.ts +50 -0
  32. package/dist/src/core/jev-client.js +262 -0
  33. package/dist/src/core/jev-client.js.map +1 -0
  34. package/dist/src/core/policy-config.d.ts +96 -0
  35. package/dist/src/core/policy-config.js +60 -0
  36. package/dist/src/core/policy-config.js.map +1 -0
  37. package/dist/src/core/policy-engine.d.ts +65 -0
  38. package/dist/src/core/policy-engine.js +344 -0
  39. package/dist/src/core/policy-engine.js.map +1 -0
  40. package/dist/src/core/presets.d.ts +18 -0
  41. package/dist/src/core/presets.js +180 -0
  42. package/dist/src/core/presets.js.map +1 -0
  43. package/dist/src/core/skill-auditor.d.ts +56 -0
  44. package/dist/src/core/skill-auditor.js +435 -0
  45. package/dist/src/core/skill-auditor.js.map +1 -0
  46. package/dist/src/core/telemetry.d.ts +30 -0
  47. package/dist/src/core/telemetry.js +55 -0
  48. package/dist/src/core/telemetry.js.map +1 -0
  49. package/dist/src/core/types.d.ts +89 -0
  50. package/dist/src/core/types.js +2 -0
  51. package/dist/src/core/types.js.map +1 -0
  52. package/dist/src/dashboard/server.d.ts +9 -0
  53. package/dist/src/dashboard/server.js +2425 -0
  54. package/dist/src/dashboard/server.js.map +1 -0
  55. package/dist/src/mcp/server.d.ts +137 -0
  56. package/dist/src/mcp/server.js +875 -0
  57. package/dist/src/mcp/server.js.map +1 -0
  58. package/package.json +75 -4
  59. package/skills/jev-system-one/SKILL.md +54 -0
  60. package/skills/vendor/codebase-design/DEEPENING.md +37 -0
  61. package/skills/vendor/codebase-design/DESIGN-IT-TWICE.md +44 -0
  62. package/skills/vendor/codebase-design/LICENSE +21 -0
  63. package/skills/vendor/codebase-design/SKILL.md +114 -0
  64. package/skills/vendor/gsap-performance/LICENSE +21 -0
  65. package/skills/vendor/gsap-performance/SKILL.md +79 -0
  66. package/skills/vendor/manifest.json +122 -0
  67. package/skills/vendor/security-best-practices/LICENSE.txt +201 -0
  68. package/skills/vendor/security-best-practices/SKILL.md +86 -0
  69. package/skills/vendor/security-best-practices/references/golang-general-backend-security.md +826 -0
  70. package/skills/vendor/security-best-practices/references/javascript-express-web-server-security.md +1158 -0
  71. package/skills/vendor/security-best-practices/references/javascript-general-web-frontend-security.md +747 -0
  72. package/skills/vendor/security-best-practices/references/javascript-jquery-web-frontend-security.md +678 -0
  73. package/skills/vendor/security-best-practices/references/javascript-typescript-nextjs-web-server-security.md +1144 -0
  74. package/skills/vendor/security-best-practices/references/javascript-typescript-react-web-frontend-security.md +990 -0
  75. package/skills/vendor/security-best-practices/references/javascript-typescript-vue-web-frontend-security.md +791 -0
  76. package/skills/vendor/security-best-practices/references/python-django-web-server-security.md +882 -0
  77. package/skills/vendor/security-best-practices/references/python-fastapi-web-server-security.md +1036 -0
  78. package/skills/vendor/security-best-practices/references/python-flask-web-server-security.md +705 -0
@@ -0,0 +1,344 @@
1
+ import { isAutopilotEnabled, JEV_POLICY } from "./policy-config.js";
2
+ function getNoul(answers, key, fallback = 0) {
3
+ const ans = answers[key];
4
+ if (ans && ans.type === "noul" && typeof ans.noul === "number") {
5
+ return ans.noul;
6
+ }
7
+ return fallback;
8
+ }
9
+ function getScore(answers, key, fallback = 1) {
10
+ const ans = answers[key];
11
+ if (ans && ans.type === "score" && typeof ans.score === "number") {
12
+ if (ans.probabilities && "0" in ans.probabilities && !("5" in ans.probabilities)) {
13
+ let weighted = 0;
14
+ for (const [k, p] of Object.entries(ans.probabilities)) {
15
+ const idx = Number(k);
16
+ if (Number.isFinite(idx) && typeof p === "number") {
17
+ weighted += (idx + 1) * p;
18
+ }
19
+ }
20
+ return Number(Math.max(1, Math.min(5, weighted)).toFixed(2));
21
+ }
22
+ return ans.score;
23
+ }
24
+ return fallback;
25
+ }
26
+ function getChoice(answers, key, fallback = "") {
27
+ const ans = answers[key];
28
+ if (ans && ans.type === "choice" && typeof ans.selected === "string") {
29
+ return ans.selected;
30
+ }
31
+ return fallback;
32
+ }
33
+ const p2 = (value) => value.toFixed(2);
34
+ function commandGateSummary(verdict, pSafe, pDestructive, blastRadius) {
35
+ return `[Jev Command Gate: ${verdict}] P(safe)=${p2(pSafe)} | P(destructive)=${p2(pDestructive)} | BlastRadius=${blastRadius.toFixed(1)}/5`;
36
+ }
37
+ /** Explains which ALLOW condition an ASK_USER command missed, using the same thresholds. */
38
+ function describeAllowGap(t, pSafe, pDestructive, pSecretRisk, blastRadius, recommended) {
39
+ const gaps = [];
40
+ if (blastRadius <= t.lowBlastMax) {
41
+ if (pSafe < t.lowBlastSafeMin)
42
+ gaps.push(`P(safe)=${p2(pSafe)} < ${t.lowBlastSafeMin}`);
43
+ if (pDestructive > t.lowBlastRiskMax)
44
+ gaps.push(`P(destructive)=${p2(pDestructive)} > ${t.lowBlastRiskMax}`);
45
+ if (pSecretRisk > t.lowBlastRiskMax)
46
+ gaps.push(`P(secret)=${p2(pSecretRisk)} > ${t.lowBlastRiskMax}`);
47
+ return `low-blast action (blast ${blastRadius.toFixed(2)}/5) not auto-allowed: ${gaps.join(", ") || "standard band not met"}`;
48
+ }
49
+ if (blastRadius > t.allowBlastMax)
50
+ gaps.push(`blast ${blastRadius.toFixed(2)}/5 > ${t.allowBlastMax}`);
51
+ if (pSafe < t.allowSafeMin)
52
+ gaps.push(`P(safe)=${p2(pSafe)} < ${t.allowSafeMin}`);
53
+ if (pDestructive > t.allowDestructiveMax)
54
+ gaps.push(`P(destructive)=${p2(pDestructive)} > ${t.allowDestructiveMax}`);
55
+ if (pSecretRisk >= t.allowSecretRiskBelow)
56
+ gaps.push(`P(secret)=${p2(pSecretRisk)} >= ${t.allowSecretRiskBelow}`);
57
+ if (gaps.length === 0) {
58
+ gaps.push(`model vote "${recommended}" (not allow_silently) and P(safe)=${p2(pSafe)} < ${t.strongAllowSafeMin} needed without that vote`);
59
+ }
60
+ return `blast ${blastRadius.toFixed(2)}/5 action not auto-allowed: ${gaps.join(", ")}`;
61
+ }
62
+ export function evaluateCommandGate(answers, overrides = {}) {
63
+ const t = { ...JEV_POLICY.commandGate, ...overrides };
64
+ const pSafe = getNoul(answers, "is_safe_to_execute", 0.5);
65
+ const pDestructive = getNoul(answers, "is_destructive_or_irreversible", 0);
66
+ const pSecretRisk = getNoul(answers, "exposes_secrets_or_network_risk", 0);
67
+ const blastRadius = getScore(answers, "blast_radius", 2);
68
+ const recommended = getChoice(answers, "recommended_decision", "ask_user_confirmation");
69
+ const metrics = { pSafe, pDestructive, pSecretRisk, blastRadius, recommended };
70
+ const confidence = Number(Math.max(pSafe, pDestructive, pSecretRisk).toFixed(3));
71
+ // Every BLOCK trigger pushes its own reason, so a BLOCK is never reason-less.
72
+ const blockReasons = [];
73
+ const remediation = [];
74
+ if (pDestructive >= t.blockDestructiveMin) {
75
+ blockReasons.push(`High probability of destructive/irreversible impact: P(destructive)=${p2(pDestructive)} >= ${t.blockDestructiveMin}`);
76
+ remediation.push("Use a non-destructive alternative (e.g., dry-run flag, targeted file path, or git stash instead of hard reset/clean).");
77
+ }
78
+ if (pSecretRisk >= t.blockSecretRiskMin) {
79
+ blockReasons.push(`Elevated secret exposure or network risk: P(secret_or_net_risk)=${p2(pSecretRisk)} >= ${t.blockSecretRiskMin}`);
80
+ remediation.push("Remove any credentials/tokens from command arguments and avoid piping remote scripts directly to a shell.");
81
+ }
82
+ const concreteRisk = Math.max(pDestructive, pSecretRisk);
83
+ if (pSafe < t.blockUnsafeSafeMax && concreteRisk > t.blockUnsafeRiskMin) {
84
+ blockReasons.push(`Low calibrated safety with concrete risk: P(safe)=${p2(pSafe)} < ${t.blockUnsafeSafeMax} and max(P(destructive), P(secret))=${p2(concreteRisk)} > ${t.blockUnsafeRiskMin}`);
85
+ }
86
+ if (recommended === "block_immediately" && pDestructive >= t.blockModelVoteDestructiveMin) {
87
+ blockReasons.push(`Model recommends block_immediately with P(destructive)=${p2(pDestructive)} >= ${t.blockModelVoteDestructiveMin}`);
88
+ }
89
+ if (blockReasons.length > 0) {
90
+ if (remediation.length === 0) {
91
+ remediation.push("Narrow the scope of the command or ask the user explicitly before running destructive operations.");
92
+ }
93
+ return {
94
+ verdict: "BLOCK",
95
+ confidence,
96
+ summary: commandGateSummary("BLOCK", pSafe, pDestructive, blastRadius),
97
+ reasons: blockReasons,
98
+ remediation,
99
+ metrics
100
+ };
101
+ }
102
+ const standardBand = pSafe >= t.allowSafeMin &&
103
+ pDestructive <= t.allowDestructiveMax &&
104
+ pSecretRisk < t.allowSecretRiskBelow &&
105
+ blastRadius <= t.allowBlastMax;
106
+ const strongEvidence = pSafe >= t.strongAllowSafeMin &&
107
+ pDestructive <= t.strongAllowRiskMax &&
108
+ pSecretRisk <= t.strongAllowRiskMax;
109
+ const lowBlastBand = blastRadius <= t.lowBlastMax &&
110
+ pSafe >= t.lowBlastSafeMin &&
111
+ pDestructive <= t.lowBlastRiskMax &&
112
+ pSecretRisk <= t.lowBlastRiskMax;
113
+ let allowBand = null;
114
+ if (standardBand && recommended === "allow_silently")
115
+ allowBand = "standard band + allow_silently vote";
116
+ else if (standardBand && strongEvidence)
117
+ allowBand = "strong-evidence band";
118
+ else if (lowBlastBand)
119
+ allowBand = "low-blast band";
120
+ if (allowBand) {
121
+ return {
122
+ verdict: "ALLOW",
123
+ confidence,
124
+ summary: commandGateSummary("ALLOW", pSafe, pDestructive, blastRadius),
125
+ reasons: [
126
+ `Calibrated safety check passed (${allowBand}): P(safe)=${p2(pSafe)}, P(destructive)=${p2(pDestructive)}, P(secret)=${p2(pSecretRisk)}, blast_radius=${blastRadius.toFixed(2)}`
127
+ ],
128
+ remediation: [],
129
+ metrics
130
+ };
131
+ }
132
+ return {
133
+ verdict: "ASK_USER",
134
+ confidence,
135
+ summary: commandGateSummary("ASK_USER", pSafe, pDestructive, blastRadius),
136
+ reasons: [
137
+ `Human confirmation advised — ${describeAllowGap(t, pSafe, pDestructive, pSecretRisk, blastRadius, recommended)}.`
138
+ ],
139
+ remediation: ["Request user confirmation before executing this action."],
140
+ metrics
141
+ };
142
+ }
143
+ /**
144
+ * Decision for a guard request whose `exact_command` is not a literal command line.
145
+ * Scoring prose is meaningless (agents described "read-only" intent instead of the
146
+ * command they then ran), so the gate refuses to auto-allow it.
147
+ */
148
+ export function buildUnverifiableCommandDecision(signals) {
149
+ return {
150
+ verdict: "ASK_USER",
151
+ confidence: 0,
152
+ summary: "[Jev Command Gate: ASK_USER] exact_command is not a literal command line",
153
+ reasons: [
154
+ `exact_command looks like a prose description, not the command that will run (signals: ${signals.join(", ") || "unknown"}).`
155
+ ],
156
+ remediation: [
157
+ "Re-call jev_guard_action with exact_command set to the verbatim command line you will execute (program + arguments); put the explanation in context.",
158
+ "If the action cannot be expressed as one literal command, ask the user to confirm it."
159
+ ],
160
+ metrics: { commandShape: "prose", signals: signals.join(",") }
161
+ };
162
+ }
163
+ export function evaluateDiffGate(answers, overrides = {}, options = {}) {
164
+ const t = { ...JEV_POLICY.diffGate, ...overrides };
165
+ const pFulfillsSpec = getNoul(answers, "fulfills_spec", 0.5);
166
+ const pBugRisk = getNoul(answers, "introduces_bug_or_regression", 0);
167
+ const pSecurityRisk = getNoul(answers, "has_security_risk", 0);
168
+ const pMissingTests = getNoul(answers, "missing_tests_or_edge_cases", 0);
169
+ const codeQuality = getScore(answers, "code_quality", 3);
170
+ const nextAction = getChoice(answers, "next_action", "ready_to_commit");
171
+ // Only concrete security/regression risk blocks. Spec mismatch and missing tests are
172
+ // warnings: 62% of real verify calls used to BLOCK on spec alone, agents then rewrote
173
+ // the spec until it passed or ignored the gate.
174
+ const blockers = [];
175
+ const warnings = [];
176
+ const remediation = [];
177
+ if (pSecurityRisk >= t.blockSecurityRiskMin) {
178
+ blockers.push(`[BLOCKER] Security risk in added code: P(security_risk)=${p2(pSecurityRisk)} >= ${t.blockSecurityRiskMin}`);
179
+ remediation.push("Run `jev_audit_code` on the changed files to pinpoint the exact security vector and apply the local skill remediation.");
180
+ }
181
+ if (pBugRisk >= t.blockBugRiskMin) {
182
+ blockers.push(`[BLOCKER] Bug or regression risk is elevated: P(bug_risk)=${p2(pBugRisk)} >= ${t.blockBugRiskMin}`);
183
+ remediation.push("Inspect changed logic for unhandled edge cases, broken imports, or regressions.");
184
+ }
185
+ const isCleanDocsCheckpoint = Boolean(options.isDocsOnlyDiff) &&
186
+ pBugRisk < t.docsCheckpointRiskBelow &&
187
+ pSecurityRisk < t.docsCheckpointRiskBelow &&
188
+ (codeQuality >= t.docsCheckpointQualityMin ||
189
+ (pBugRisk <= t.docsCheckpointNegligibleRisk && pSecurityRisk <= t.docsCheckpointNegligibleRisk));
190
+ if (!isCleanDocsCheckpoint && pFulfillsSpec < t.minSpecMatch) {
191
+ warnings.push(`[WARNING] Spec alignment uncertain: P(fulfills_spec)=${p2(pFulfillsSpec)} < ${t.minSpecMatch}`);
192
+ remediation.push("Compare the diff with the user's original request (not a paraphrase of the diff). If a requirement looks unmet or the diff mixes in other uncommitted work, tell the user which parts are uncertain and confirm scope; do not rewrite the spec just to pass the gate.");
193
+ }
194
+ if (!isCleanDocsCheckpoint && (pMissingTests >= t.missingTestsWarnMin || nextAction === "add_tests")) {
195
+ warnings.push(`[WARNING] Test coverage likely missing: P(missing_tests)=${p2(pMissingTests)}${nextAction === "add_tests" ? " (model next_action=add_tests)" : ""}`);
196
+ remediation.push("Add unit or integration tests covering the modified code paths.");
197
+ }
198
+ const verdict = blockers.length > 0 ? "BLOCK" : warnings.length > 0 ? "ASK_USER" : "ALLOW";
199
+ const reasons = [...blockers, ...warnings];
200
+ if (reasons.length === 0) {
201
+ reasons.push(`Diff verified cleanly: P(fulfills_spec)=${p2(pFulfillsSpec)}, P(bug)=${p2(pBugRisk)}, quality=${codeQuality.toFixed(1)}/5`);
202
+ }
203
+ return {
204
+ verdict,
205
+ confidence: Number(pFulfillsSpec.toFixed(3)),
206
+ summary: `[Jev Diff Gate: ${verdict}] P(spec)=${p2(pFulfillsSpec)} | P(bug)=${p2(pBugRisk)} | P(sec)=${p2(pSecurityRisk)} | Quality=${codeQuality.toFixed(1)}/5 | Next=${nextAction}`,
207
+ reasons,
208
+ remediation,
209
+ metrics: {
210
+ pFulfillsSpec,
211
+ pBugRisk,
212
+ pSecurityRisk,
213
+ pMissingTests,
214
+ codeQuality,
215
+ nextAction
216
+ }
217
+ };
218
+ }
219
+ export function extractContextPruneResults(candidates, answers, threshold = 0.60) {
220
+ const results = [];
221
+ const bounded = candidates.slice(0, 100);
222
+ for (let i = 0; i < bounded.length; i += 1) {
223
+ const prob = getNoul(answers, `item_${i}`, 0);
224
+ if (prob >= threshold) {
225
+ results.push({
226
+ item: bounded[i],
227
+ probability: prob
228
+ });
229
+ }
230
+ }
231
+ results.sort((a, b) => b.probability - a.probability);
232
+ return results;
233
+ }
234
+ function normalizeWorkspacePath(value) {
235
+ return value.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
236
+ }
237
+ /**
238
+ * Finds the newest guard escalation that an autopilot decision must not override.
239
+ * "Related" means the same workspace (path or name) inside the window. In the real
240
+ * logs every autopilot call made within 15 minutes of a guard ASK_USER in the same
241
+ * workspace was the agent asking whether it could skip that confirmation. When the
242
+ * workspace cannot be identified (IDE host directory), any escalation in the window
243
+ * counts — failing towards asking the human.
244
+ */
245
+ export function findBlockingGuardEscalation(escalations, target) {
246
+ const now = (target.now ?? new Date()).getTime();
247
+ const windowMs = target.windowMs ?? JEV_POLICY.autopilot.guardEscalationWindowMs;
248
+ const targetPath = target.workspacePath ? normalizeWorkspacePath(target.workspacePath) : "";
249
+ const targetName = target.workspaceName.trim().toLowerCase();
250
+ let newest;
251
+ let newestTime = -Infinity;
252
+ for (const esc of escalations) {
253
+ if (esc.verdict !== "ASK_USER" && esc.verdict !== "BLOCK")
254
+ continue;
255
+ const at = Date.parse(esc.timestamp);
256
+ if (!Number.isFinite(at))
257
+ continue;
258
+ const age = now - at;
259
+ if (age < 0 || age > windowMs)
260
+ continue;
261
+ const samePath = targetPath.length > 0 &&
262
+ typeof esc.workspacePath === "string" &&
263
+ normalizeWorkspacePath(esc.workspacePath) === targetPath;
264
+ const sameName = targetName.length > 0 && esc.workspace.trim().toLowerCase() === targetName;
265
+ if (!(target.workspaceIsUnknown || samePath || sameName))
266
+ continue;
267
+ if (at > newestTime) {
268
+ newest = esc;
269
+ newestTime = at;
270
+ }
271
+ }
272
+ return newest;
273
+ }
274
+ function describeGuardEscalation(esc, now) {
275
+ const ageMs = now.getTime() - Date.parse(esc.timestamp);
276
+ const ageMin = Number.isFinite(ageMs) ? Math.max(0, Math.round(ageMs / 60000)) : 0;
277
+ const command = esc.command.length > 160 ? `${esc.command.slice(0, 157)}...` : esc.command;
278
+ return `jev_guard_action returned ${esc.verdict} for \`${command}\` in workspace ${esc.workspace} ${ageMin} min ago`;
279
+ }
280
+ function recommendationClause(selectedOption, selectedProbability) {
281
+ return selectedOption
282
+ ? `recommend "${selectedOption}" as the first option (P=${p2(selectedProbability)})`
283
+ : "Jev returned no recommended option";
284
+ }
285
+ export function evaluateAutopilotProxy(answers, overrides = {}, gate = { enabled: isAutopilotEnabled() }) {
286
+ const t = { ...JEV_POLICY.autopilot, ...overrides };
287
+ const choiceAns = answers.selected_option;
288
+ const selectedOption = choiceAns && choiceAns.type === "choice" ? choiceAns.selected : "";
289
+ const allProbabilities = choiceAns && choiceAns.type === "choice" ? choiceAns.probabilities : {};
290
+ const selectedProbability = selectedOption && typeof allProbabilities[selectedOption] === "number"
291
+ ? allProbabilities[selectedOption]
292
+ : 0;
293
+ const isReversible = getNoul(answers, "is_reversible_technical_choice", 0.5);
294
+ const requiresHuman = getNoul(answers, "requires_private_business_or_human_taste", 0.5);
295
+ const alignmentScore = getScore(answers, "alignment_strength", 3);
296
+ const base = {
297
+ selectedOption,
298
+ selectedProbability,
299
+ allProbabilities,
300
+ isReversible,
301
+ requiresHuman,
302
+ alignmentScore
303
+ };
304
+ const recommendation = recommendationClause(selectedOption, selectedProbability);
305
+ const esc = gate.guardEscalation;
306
+ const guardNote = esc ? describeGuardEscalation(esc, gate.now ?? new Date()) : "";
307
+ if (!gate.enabled) {
308
+ return {
309
+ ...base,
310
+ mode: "ASK_HUMAN",
311
+ escalationReason: "autopilot_disabled",
312
+ ...(esc ? { guardEscalation: esc } : {}),
313
+ agentDirective: `[JEV AUTOPILOT OFF]: Autopilot is disabled (set JEV_AUTOPILOT=1 to enable). Ask the user and ${recommendation}.${guardNote ? ` Also confirm: ${guardNote}.` : ""}`
314
+ };
315
+ }
316
+ if (esc) {
317
+ return {
318
+ ...base,
319
+ mode: "ASK_HUMAN",
320
+ escalationReason: "recent_guard_escalation",
321
+ guardEscalation: esc,
322
+ agentDirective: `[JEV ESCALATE TO HUMAN]: ${guardNote}. Autopilot cannot replace that confirmation; ask the user explicitly and ${recommendation}.`
323
+ };
324
+ }
325
+ const canAutopilot = selectedOption.length > 0 &&
326
+ selectedProbability >= t.minChoiceProbability &&
327
+ isReversible >= t.minReversibleProbability &&
328
+ requiresHuman < t.requiresHumanBelow &&
329
+ (alignmentScore >= t.minAlignmentScore || selectedProbability >= t.strongChoiceProbability);
330
+ if (canAutopilot) {
331
+ return {
332
+ ...base,
333
+ mode: "AUTOPILOT_PROCEED",
334
+ agentDirective: `[JEV AUTOPILOT]: Option "${selectedOption}" clears the autopilot bar for a reversible technical choice (P=${p2(selectedProbability)}, reversible=${p2(isReversible)}, alignment=${alignmentScore.toFixed(1)}/5). You may proceed with it; state the choice in one line and ask the user if new risk, cost, or scope appears.`
335
+ };
336
+ }
337
+ return {
338
+ ...base,
339
+ mode: "ASK_HUMAN",
340
+ escalationReason: "insufficient_confidence",
341
+ agentDirective: `[JEV ESCALATE TO HUMAN]: This decision requires human input (P(requires_human)=${p2(requiresHuman)}, top_choice="${selectedOption}" at P=${p2(selectedProbability)}). Ask the user and ${recommendation}.`
342
+ };
343
+ }
344
+ //# sourceMappingURL=policy-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"policy-engine.js","sourceRoot":"","sources":["../../../src/core/policy-engine.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kBAAkB,EAClB,UAAU,EAIX,MAAM,oBAAoB,CAAC;AAE5B,SAAS,OAAO,CAAC,OAAkC,EAAE,GAAW,EAAE,QAAQ,GAAG,CAAC;IAC5E,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC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mB;YACzB,cAAc,EAAE,4BAA4B,cAAc,mEAAmE,EAAE,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,CAAC,YAAY,CAAC,eAAe,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,kHAAkH;SAC/U,CAAC;IACJ,CAAC;IAED,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,WAAW;QACjB,gBAAgB,EAAE,yBAAyB;QAC3C,cAAc,EAAE,kFAAkF,EAAE,CAAC,aAAa,CAAC,iBAAiB,cAAc,UAAU,EAAE,CAAC,mBAAmB,CAAC,uBAAuB,cAAc,GAAG;KAC5N,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { JevQuestion } from "./types.js";
2
+ export interface ContextCandidate {
3
+ id: string;
4
+ summary?: string;
5
+ content?: string;
6
+ }
7
+ export declare function buildCommandGuardQuestions(): Record<string, JevQuestion>;
8
+ export declare function buildDiffVerificationQuestions(): Record<string, JevQuestion>;
9
+ export declare function buildContextPruneQuestions(task: string, candidates: ContextCandidate[]): Record<string, JevQuestion>;
10
+ export declare function buildBatchClassifyQuestions(items: string[], criteria: Record<string, string>, instructions: string): Record<string, JevQuestion>;
11
+ export declare function buildTaskRouteQuestions(): Record<string, JevQuestion>;
12
+ export declare const DEFAULT_DEVELOPER_PROFILE: {
13
+ architecture: string;
14
+ security: string;
15
+ frontend: string;
16
+ workflow: string;
17
+ };
18
+ export declare function buildAutopilotProxyQuestions(options: Record<string, string>): Record<string, JevQuestion>;
@@ -0,0 +1,180 @@
1
+ export function buildCommandGuardQuestions() {
2
+ return {
3
+ is_safe_to_execute: {
4
+ type: "noul",
5
+ instructions: "Is this command or file operation safe to execute automatically in a developer workspace without risking data loss, system corruption, or credential exposure?"
6
+ },
7
+ is_destructive_or_irreversible: {
8
+ type: "noul",
9
+ instructions: "Could this action permanently delete untracked work, drop database tables, force-push git history, or modify critical system files irreversibly?"
10
+ },
11
+ exposes_secrets_or_network_risk: {
12
+ type: "noul",
13
+ instructions: "Does this action exfiltrate data, expose secrets/API keys/env vars, download untrusted remote scripts (curl|sh), or open unauthorized network listeners?"
14
+ },
15
+ blast_radius: {
16
+ type: "score",
17
+ instructions: "Rate the potential blast radius of this action from 1 (read-only or isolated local file) to 5 (production infrastructure, git history rewrite, or system-wide impact).",
18
+ criteria: [
19
+ "1: Read-only inspection or harmless local test run",
20
+ "2: Isolated edit or standard build/test command within project workspace",
21
+ "3: Multi-file refactor, dependency installation, or local git commit",
22
+ "4: Destructive file deletion, git reset/clean, or external API mutation",
23
+ "5: Irreversible force push, production DB mutation, secret exposure, or OS-level change"
24
+ ]
25
+ },
26
+ recommended_decision: {
27
+ type: "choice",
28
+ instructions: "What gate enforcement action should the coding agent firewall take?",
29
+ criteria: {
30
+ allow_silently: "Safe routine development command or edit; allow immediately without interrupting the user",
31
+ ask_user_confirmation: "Moderate blast radius or ambiguous side effects; ask the human developer to confirm first",
32
+ block_immediately: "High risk, destructive, or security violation; block execution and require a safer approach"
33
+ }
34
+ }
35
+ };
36
+ }
37
+ export function buildDiffVerificationQuestions() {
38
+ return {
39
+ fulfills_spec: {
40
+ type: "noul",
41
+ instructions: "Do the changes shown in the git diff (whether production code, tests, or documentation/handoff/review Markdown when the specification explicitly states this step is a documentation, planning, or review checkpoint) fulfill the requested scope of this step?"
42
+ },
43
+ introduces_bug_or_regression: {
44
+ type: "noul",
45
+ instructions: "Does the newly added (+) production code in the git diff introduce a real logic bug, broken import, or regression (ignoring defensive error handling and passing unit tests)?"
46
+ },
47
+ has_security_risk: {
48
+ type: "noul",
49
+ instructions: "Does the newly added (+) production code in the git diff introduce a new, unmitigated security vulnerability (ignoring security patches, removed (-) lines, and test payloads in *.test.ts files)?"
50
+ },
51
+ missing_tests_or_edge_cases: {
52
+ type: "noul",
53
+ instructions: "Are automated tests completely missing despite the changes requiring new test coverage (note: check test_output and *.test.ts in changed_files)?"
54
+ },
55
+ code_quality: {
56
+ type: "score",
57
+ instructions: "Rate the overall code quality, modularity, and maintainability of the diff from 1 (poor/hacky) to 5 (clean, well-typed, production-grade).",
58
+ criteria: [
59
+ "1: Broken, messy, or violates core project conventions",
60
+ "2: Fragile implementation with obvious technical debt",
61
+ "3: Acceptable working code with minor rough edges",
62
+ "4: Clean, well-structured, and properly typed code",
63
+ "5: Exemplary deep-module architecture with thorough test coverage"
64
+ ]
65
+ },
66
+ next_action: {
67
+ type: "choice",
68
+ instructions: "What should the coding agent do next before marking the task complete?",
69
+ criteria: {
70
+ ready_to_commit: "All requirements met, tests covered, and no material bugs or security risks",
71
+ fix_bugs: "Fix logic errors, regressions, or incomplete spec requirements in the code",
72
+ add_tests: "Write or update automated tests covering the changed behavior and edge cases",
73
+ address_security: "Fix security vulnerabilities or input validation gaps before proceeding",
74
+ clarify_requirements: "Stop and ask the user to clarify ambiguous or conflicting requirements"
75
+ }
76
+ }
77
+ };
78
+ }
79
+ export function buildContextPruneQuestions(task, candidates) {
80
+ const questions = {};
81
+ const bounded = candidates.slice(0, 100);
82
+ for (let i = 0; i < bounded.length; i += 1) {
83
+ const item = bounded[i];
84
+ const label = item.summary
85
+ ? `${item.id} (${item.summary.slice(0, 180)})`
86
+ : item.id;
87
+ questions[`item_${i}`] = {
88
+ type: "noul",
89
+ instructions: `Is candidate [${label}] directly relevant and necessary in the context window to complete the task: "${task.slice(0, 300)}"?`
90
+ };
91
+ }
92
+ return questions;
93
+ }
94
+ export function buildBatchClassifyQuestions(items, criteria, instructions) {
95
+ const questions = {};
96
+ const bounded = items.slice(0, 100);
97
+ for (let i = 0; i < bounded.length; i += 1) {
98
+ questions[`item_${i}`] = {
99
+ type: "choice",
100
+ instructions: `${instructions} (Item #${i}: "${bounded[i].slice(0, 250)}")`,
101
+ criteria
102
+ };
103
+ }
104
+ return questions;
105
+ }
106
+ export function buildTaskRouteQuestions() {
107
+ return {
108
+ execution_strategy: {
109
+ type: "choice",
110
+ instructions: "Which engineering workflow strategy best fits this coding task?",
111
+ criteria: {
112
+ direct_edit: "Small, clear, well-scoped change that can be implemented directly in 1-2 files",
113
+ tdd_red_green: "Feature or bugfix with testable logic where writing failing tests first prevents regressions",
114
+ parallel_subagents: "Task with 2+ independent subsystems or files that can be delegated in parallel",
115
+ brainstorm_spec_first: "Ambiguous, creative, or multi-component feature that needs a design spec and user alignment first",
116
+ deep_bug_diagnosis: "Complex bug, race condition, or regression requiring root-cause reproduction before changing code"
117
+ }
118
+ },
119
+ recommended_model_tier: {
120
+ type: "choice",
121
+ instructions: "What LLM compute tier is optimal for executing this task cost-effectively?",
122
+ criteria: {
123
+ fast_lightweight: "Routine boilerplate, formatting, simple file lookup, or straightforward wiring (Flash / Haiku tier)",
124
+ balanced_coding: "Standard feature implementation, component creation, or unit test authoring (Sonnet / Pro tier)",
125
+ deep_reasoning_flagship: "Complex system architecture, subtle security audit, concurrency debugging, or multi-module redesign (Opus / Argon High tier)"
126
+ }
127
+ },
128
+ requires_security_review: {
129
+ type: "noul",
130
+ instructions: "Does this task touch authentication, authorization, untrusted user input, database queries, file uploads, shell execution, secrets, or network APIs?"
131
+ },
132
+ requires_ui_ux_design_system: {
133
+ type: "noul",
134
+ instructions: "Does this task involve frontend UI components, layouts, styling, or web animations (GSAP/CSS)?"
135
+ },
136
+ ambiguity_needs_user_question: {
137
+ type: "noul",
138
+ instructions: "Are the requirements underspecified such that the agent should ask a clarifying question before writing code?"
139
+ },
140
+ complexity_score: {
141
+ type: "score",
142
+ instructions: "Rate the technical complexity of the task from 1 (trivial) to 5 (highly complex architectural change)."
143
+ }
144
+ };
145
+ }
146
+ export const DEFAULT_DEVELOPER_PROFILE = {
147
+ architecture: "Prefer deep modules with small clean interfaces, TypeScript/Node.js or Python best practices, DRY, YAGNI, and deterministic tests.",
148
+ security: "Security-first by default: runtime input validation (Zod/Pydantic), parameterized queries, least privilege, no secret leaks.",
149
+ frontend: "High-craft UI/UX (Impeccable/Taste/UI-UX-Pro-Max), 60fps GPU-accelerated GSAP animations (transform x/y/scale, useGSAP, quickTo).",
150
+ workflow: "Autonomous execution preferred for reversible technical/engineering choices; only interrupt the human for irreversible actions, external credentials/billing, or genuine product ambiguity."
151
+ };
152
+ export function buildAutopilotProxyQuestions(options) {
153
+ return {
154
+ selected_option: {
155
+ type: "choice",
156
+ instructions: "Acting as the senior developer's calibrated digital twin, select the single best option that maximizes engineering quality, security, and maintainability for this project.",
157
+ criteria: options
158
+ },
159
+ is_reversible_technical_choice: {
160
+ type: "noul",
161
+ instructions: "Is this a technical, architectural, or implementation decision that can be safely decided autonomously and reversed via git if needed (as opposed to an irreversible destructive action)?"
162
+ },
163
+ requires_private_business_or_human_taste: {
164
+ type: "noul",
165
+ instructions: "Does answering this question genuinely require private business logic, billing/paid API approval, personal credentials, or subjective product goals that cannot be inferred from engineering best practices and the workspace context?"
166
+ },
167
+ alignment_strength: {
168
+ type: "score",
169
+ instructions: "How strongly and unambiguously does the winning option outperform the alternatives according to the developer profile and software engineering standards?",
170
+ criteria: [
171
+ "1: Complete tie / pure guess",
172
+ "2: Slight preference but high ambiguity",
173
+ "3: Moderate engineering advantage",
174
+ "4: Clear technical winner",
175
+ "5: Overwhelmingly superior standard practice"
176
+ ]
177
+ }
178
+ };
179
+ }
180
+ //# sourceMappingURL=presets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"presets.js","sourceRoot":"","sources":["../../../src/core/presets.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,0BAA0B;IACxC,OAAO;QACL,kBAAkB,EAAE;YAClB,IAAI,EAAE,MAAM;YACZ,YAAY,EACV,gKAAgK;SACnK;QACD,8BAA8B,EAAE;YAC9B,IAAI,EAAE,MAAM;YACZ,YAAY,EACV,kJAAkJ;SACrJ;QACD,+BAA+B,EAAE;YAC/B,IAAI,EAAE,MAAM;YACZ,YAAY,EACV,0JAA0J;SAC7J;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,OAAO;YACb,YAAY,EACV,wKAAwK;YAC1K,QAAQ,EAAE;gBACR,oDAAoD;gBACpD,0EAA0E;gBAC1E,sEAAsE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,EAAE;gBACR,8BAA8B;gBAC9B,yCAAyC;gBACzC,mCAAmC;gBACnC,2BAA2B;gBAC3B,8CAA8C;aAC/C;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { JevClient } from "./jev-client.js";
2
+ import type { CodeStack, GateVerdict, JevQuestion, SkillAuditResult, SkillRemediationExcerpt } from "./types.js";
3
+ export interface VectorMetadata {
4
+ key: string;
5
+ title: string;
6
+ instructions: string;
7
+ searchKeywords: string[];
8
+ fallbackGuidance: string;
9
+ }
10
+ export declare const SECURITY_AUDIT_VECTORS: VectorMetadata[];
11
+ export declare const ARCHITECTURE_VECTOR_KEY = "shallow_module_or_arch_flaw";
12
+ export declare const GSAP_ANIMATION_VECTOR: VectorMetadata;
13
+ /**
14
+ * Third-party remediation skills shipped inside this package (skills/vendor/), vendored
15
+ * verbatim at pinned commits by scripts/vendor-skills.mjs. See THIRD_PARTY_NOTICES.md.
16
+ * Resolved from this module's location (dist/src/core/), never from process.cwd().
17
+ */
18
+ export declare const BUNDLED_SKILLS_DIR: string;
19
+ export declare function resolveSkillsDir(customDir?: string): string;
20
+ export declare function detectCodeStack(codeOrDiff: string, filePath?: string): CodeStack;
21
+ export declare function stackIncludesAnimation(stack: CodeStack): boolean;
22
+ export declare function buildSkillAuditQuestions(stack: CodeStack, includeAnimation?: boolean): Record<string, JevQuestion>;
23
+ export declare function extractSkillRemediation(skillsDir: string, stack: CodeStack, violatedVectors: Array<{
24
+ vector: string;
25
+ probability: number;
26
+ }>, bundledDir?: string): SkillRemediationExcerpt[];
27
+ export interface AuditCodeInput {
28
+ code: string;
29
+ filePath?: string;
30
+ stack?: CodeStack;
31
+ skillsDir?: string;
32
+ violationThreshold?: number;
33
+ projectContext?: unknown;
34
+ fileHeaderContext?: Record<string, string>;
35
+ }
36
+ type ScoredVector = {
37
+ vector: string;
38
+ probability: number;
39
+ };
40
+ /**
41
+ * Builds the audit explanation from the verdict that was actually reached, so a BLOCK
42
+ * can never be described as "all checks passed" and GSAP is only mentioned when the
43
+ * animation vector was really evaluated.
44
+ */
45
+ export declare function buildAuditSummary(input: {
46
+ verdict: GateVerdict;
47
+ securityScore: number;
48
+ threshold: number;
49
+ includeAnimation: boolean;
50
+ modelChoice: string;
51
+ securityVectors: ScoredVector[];
52
+ advisoryVectors: ScoredVector[];
53
+ lowScoreReview: boolean;
54
+ }): string;
55
+ export declare function auditCodeWithSkills(client: JevClient, input: AuditCodeInput): Promise<SkillAuditResult>;
56
+ export {};