@shomra/agent 0.3.8 → 0.3.9

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 (2) hide show
  1. package/package.json +1 -1
  2. package/shomra.mjs +17 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shomra/agent",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Shomra — adversarial assurance for AI agents, as a local-first CLI. Blocks dangerous tool-calls before they run, attacks your own guardrails to prove they hold, and gates AI artifacts in your editor and CI.",
5
5
  "type": "module",
6
6
  "bin": {
package/shomra.mjs CHANGED
@@ -226,6 +226,9 @@ const VALUE_FLAGS = new Set([
226
226
  'scenarios', 'objectives', 'turns', 'target', 'run', 'port', 'config', 'env',
227
227
  'command', 'base', 'repo', 'pr', 'token', 'sha', 'session', 'since', 'depth',
228
228
  'scope', 'writer', 'type', 'slug', 'framework', 'chunk-size', 'manifest',
229
+ // `--fail-on <critical|high|medium>` lets CI gate below the default
230
+ // (blocked-only) exit code — e.g. fail the build on a HIGH finding.
231
+ 'fail-on',
229
232
  ]);
230
233
  const KNOWN_FLAGS = new Set([...BOOLEAN_FLAGS, ...VALUE_FLAGS]);
231
234
 
@@ -1373,6 +1376,7 @@ async function cmdGateAll(flags, positional, { apiKey, url }) {
1373
1376
  if (flags.sarif) {
1374
1377
  console.log(JSON.stringify(toSarif(results), null, 2));
1375
1378
  if (blocked > 0 || strictOutage) process.exitCode = 1;
1379
+ else if (failOnHit(flags, blocked, flagged)) process.exitCode = 1;
1376
1380
  else if (flagged > 0 && flags.strict) process.exitCode = 2;
1377
1381
  return;
1378
1382
  }
@@ -1395,6 +1399,7 @@ async function cmdGateAll(flags, positional, { apiKey, url }) {
1395
1399
 
1396
1400
  // Set exitCode (not process.exit) so pending sockets drain cleanly on Windows.
1397
1401
  if (blocked > 0 || strictOutage) process.exitCode = 1;
1402
+ else if (failOnHit(flags, blocked, flagged)) process.exitCode = 1;
1398
1403
  else if (flagged > 0 && flags.strict) process.exitCode = 2;
1399
1404
  }
1400
1405
 
@@ -1498,9 +1503,21 @@ async function cmdCheck(flags, positional) {
1498
1503
  }
1499
1504
 
1500
1505
  if (blocked > 0 || strictOutage) process.exitCode = 1;
1506
+ else if (failOnHit(flags, blocked, flagged)) process.exitCode = 1;
1501
1507
  else if (flagged > 0 && flags.strict) process.exitCode = 2;
1502
1508
  }
1503
1509
 
1510
+ // `--fail-on <critical|high|medium>` — gate CI below the default (blocked-only).
1511
+ // blocked ⇒ a CRITICAL/BLOCK finding, flagged ⇒ a HIGH/FLAG one; the mapping is
1512
+ // the same severity→decision the guard uses. Default 'critical' preserves the
1513
+ // existing behavior (HIGH exits 0 unless --strict). An unrecognised value is
1514
+ // treated as 'critical' rather than silently gating on nothing.
1515
+ function failOnHit(flags, blocked, flagged) {
1516
+ const threshold = { critical: 3, high: 2, medium: 1 }[String(flags['fail-on'] || 'critical').toLowerCase()] ?? 3;
1517
+ const worst = blocked > 0 ? 3 : flagged > 0 ? 2 : 0;
1518
+ return worst > 0 && worst >= threshold;
1519
+ }
1520
+
1504
1521
  // ── shomra baseline: accept everything here, so only NEW findings fail ───────
1505
1522
  //
1506
1523
  // shomra baseline [dir] # write .shomra/baseline.json of current findings