burnoff 1.2.0 → 1.3.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.
@@ -760,11 +760,10 @@ function scanClaudeTelemetrySummary({
760
760
  * Strictly read-only scan of `~/.claude/agents/*.md` and `<cwd>/.claude/agents/*.md`
761
761
  * to count custom subagent definitions and narrow frontmatter `tools:` allowlists.
762
762
  */
763
- export function scanClaudeCustomAgentSpecs({ homeDir = getHomeDir(), cwd = process.cwd() } = {}) {
764
- const dirs = [
765
- path.join(homeDir, '.claude', 'agents'),
766
- path.join(cwd, '.claude', 'agents')
767
- ];
763
+ export function scanClaudeCustomAgentSpecs({ homeDir = getHomeDir(), cwd = process.cwd(), repoOnly = false } = {}) {
764
+ const dirs = repoOnly
765
+ ? [path.join(cwd, '.claude', 'agents')]
766
+ : [path.join(homeDir, '.claude', 'agents'), path.join(cwd, '.claude', 'agents')];
768
767
  const seen = new Set();
769
768
  const agents = [];
770
769
  let narrowToolsAgents = 0;
@@ -1010,7 +1009,8 @@ export function scanMcpToolNameLengthViolations({
1010
1009
  workspacePath = process.cwd(),
1011
1010
  observedToolNames = [],
1012
1011
  manifestDirs = [],
1013
- maxLength = 64
1012
+ maxLength = 64,
1013
+ repoOnly = false
1014
1014
  } = {}) {
1015
1015
  const disabledServers = new Set();
1016
1016
  const violationsByFullName = new Map();
@@ -1059,7 +1059,9 @@ export function scanMcpToolNameLengthViolations({
1059
1059
  inspectServerMap(projMcp.parsed.mcpServers || projMcp.parsed.servers || projMcp.parsed, projMcp.path.replace(/\\/g, '/'));
1060
1060
  }
1061
1061
 
1062
- const claudeJson = parseJsoncReadOnly(path.join(homeDir, '.claude.json'));
1062
+ const claudeJson = repoOnly
1063
+ ? { parseOk: false, parsed: null }
1064
+ : parseJsoncReadOnly(path.join(homeDir, '.claude.json'));
1063
1065
  if (claudeJson.parseOk && claudeJson.parsed && typeof claudeJson.parsed === 'object') {
1064
1066
  inspectServerMap(claudeJson.parsed.mcpServers, '~/.claude.json');
1065
1067
  const projects = claudeJson.parsed.projects;
@@ -1158,7 +1160,7 @@ function collectDisabledClaudeMcpServers({ homeDir = getHomeDir(), workspacePath
1158
1160
  trackServerMap(projMcp.parsed.mcpServers || projMcp.parsed.servers || projMcp.parsed);
1159
1161
  }
1160
1162
 
1161
- const claudeJson = parseJsoncReadOnly(path.join(homeDir, '.claude.json'));
1163
+ const claudeJson = homeDir ? parseJsoncReadOnly(path.join(homeDir, '.claude.json')) : { parseOk: false, parsed: null };
1162
1164
  if (claudeJson.parseOk && claudeJson.parsed && typeof claudeJson.parsed === 'object') {
1163
1165
  trackServerMap(claudeJson.parsed.mcpServers);
1164
1166
  const projects = claudeJson.parsed.projects;
@@ -1197,9 +1199,10 @@ export function scanMcpListChangedCapabilities({
1197
1199
  manifestDirs = [],
1198
1200
  runtimeListChangedServers = [],
1199
1201
  maxObservedCachedPrefixTokens = null,
1200
- cachedPrefixThreshold = LIST_CHANGED_PREFIX_THRESHOLD
1202
+ cachedPrefixThreshold = LIST_CHANGED_PREFIX_THRESHOLD,
1203
+ repoOnly = false
1201
1204
  } = {}) {
1202
- const disabledServers = collectDisabledClaudeMcpServers({ homeDir, workspacePath });
1205
+ const disabledServers = collectDisabledClaudeMcpServers({ homeDir: repoOnly ? null : homeDir, workspacePath });
1203
1206
  const flaggedByServer = new Map();
1204
1207
 
1205
1208
  const recordFlagged = (serverName, reason, source) => {
@@ -1228,7 +1231,9 @@ export function scanMcpListChangedCapabilities({
1228
1231
  inspectConfigMap(projMcp.parsed.mcpServers || projMcp.parsed.servers || projMcp.parsed, projMcp.path);
1229
1232
  }
1230
1233
 
1231
- const claudeJson = parseJsoncReadOnly(path.join(homeDir, '.claude.json'));
1234
+ const claudeJson = repoOnly
1235
+ ? { parseOk: false, parsed: null }
1236
+ : parseJsoncReadOnly(path.join(homeDir, '.claude.json'));
1232
1237
  if (claudeJson.parseOk && claudeJson.parsed && typeof claudeJson.parsed === 'object') {
1233
1238
  inspectConfigMap(claudeJson.parsed.mcpServers, '~/.claude.json');
1234
1239
  const projects = claudeJson.parsed.projects;
@@ -2029,6 +2034,49 @@ export function auditVolatilePromptPrefix({
2029
2034
  };
2030
2035
  }
2031
2036
 
2037
+ function makeMissingJsoncStub(filePath = '') {
2038
+ return {
2039
+ path: filePath,
2040
+ exists: false,
2041
+ parseOk: false,
2042
+ parsed: null,
2043
+ strictJsonValid: false,
2044
+ strict_json_syntax_warning: null,
2045
+ error: null
2046
+ };
2047
+ }
2048
+
2049
+ function filterFilesWithinCwd(filePaths = [], cwd = process.cwd()) {
2050
+ const resolvedCwd = path.resolve(cwd);
2051
+ return (Array.isArray(filePaths) ? filePaths : []).filter((fp) => {
2052
+ if (!fp) return false;
2053
+ const rel = path.relative(resolvedCwd, path.resolve(fp));
2054
+ return rel !== '..' && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel);
2055
+ });
2056
+ }
2057
+
2058
+ function createEmptyClaudeTelemetryStub() {
2059
+ return {
2060
+ sessionsScanned: 0,
2061
+ bytesScanned: 0,
2062
+ scanTruncated: false,
2063
+ browserToolCalls7d: 0,
2064
+ artifactCalls7d: 0,
2065
+ mcpToolCalls7d: {},
2066
+ schemaTokensByServer: {},
2067
+ observedMcpToolNames: [],
2068
+ runtimeListChangedServers: [],
2069
+ maxCachedPrefixTokens: 0,
2070
+ subagentSpawns7d: 0,
2071
+ sidechainTurns7d: 0,
2072
+ observedMcpInstructionsDeltaChars: 0,
2073
+ observedModels: [],
2074
+ entrypoints: ['cli'],
2075
+ sdkCliSessions7d: 0,
2076
+ claudeCodeVersion: null
2077
+ };
2078
+ }
2079
+
2032
2080
  /**
2033
2081
  * Runs Turn-0 startup config, rules-count, and eager-only MCP audit for Claude Code.
2034
2082
  */
@@ -2042,16 +2090,21 @@ export function runClaudeStartupAudit({
2042
2090
  nowMs = Date.now(),
2043
2091
  manifestDirs = [],
2044
2092
  maxTelemetryFiles = DEFAULT_TELEMETRY_MAX_FILES,
2045
- maxTelemetryBytes = DEFAULT_TELEMETRY_MAX_BYTES
2093
+ maxTelemetryBytes = DEFAULT_TELEMETRY_MAX_BYTES,
2094
+ repoOnly = false,
2095
+ ci = false
2046
2096
  } = {}) {
2097
+ const isRepoOnly = Boolean(repoOnly || ci);
2047
2098
  const paths = resolveClaudeConfigPaths({ homeDir, cwd, platform: hostPlatform });
2048
- const telemetry = scanClaudeTelemetrySummary({
2049
- projectsDir: paths.projectsDir,
2050
- days,
2051
- nowMs,
2052
- maxFiles: maxTelemetryFiles,
2053
- maxTotalBytes: maxTelemetryBytes
2054
- });
2099
+ const telemetry = isRepoOnly
2100
+ ? createEmptyClaudeTelemetryStub()
2101
+ : scanClaudeTelemetrySummary({
2102
+ projectsDir: paths.projectsDir,
2103
+ days,
2104
+ nowMs,
2105
+ maxFiles: maxTelemetryFiles,
2106
+ maxTotalBytes: maxTelemetryBytes
2107
+ });
2055
2108
 
2056
2109
  const detectedClaudeVersion = claudeCodeVersion || telemetry.claudeCodeVersion || null;
2057
2110
  const observedEntrypoint =
@@ -2059,17 +2112,29 @@ export function runClaudeStartupAudit({
2059
2112
  ? 'sdk-ts'
2060
2113
  : telemetry.entrypoints[0] || 'cli';
2061
2114
 
2062
- const claudeJson = parseJsoncReadOnly(paths.claudeJson);
2063
- const userSettings = parseJsoncReadOnly(paths.userSettings);
2115
+ const claudeJson = isRepoOnly
2116
+ ? makeMissingJsoncStub(paths.claudeJson)
2117
+ : parseJsoncReadOnly(paths.claudeJson);
2118
+ const userSettings = isRepoOnly
2119
+ ? makeMissingJsoncStub(paths.userSettings)
2120
+ : parseJsoncReadOnly(paths.userSettings);
2064
2121
  const projectSettings = parseJsoncReadOnly(paths.projectSettings);
2065
2122
  const projectLocalSettings = parseJsoncReadOnly(paths.projectLocalSettings);
2066
2123
  const projectMcp = parseJsoncReadOnly(paths.projectMcpJson);
2067
- const settingsLayers = [
2068
- { doc: userSettings, label: '~/.claude/settings.json' },
2069
- { doc: projectSettings, label: '.claude/settings.json' },
2070
- { doc: projectLocalSettings, label: '.claude/settings.local.json' }
2071
- ];
2072
- const layers = [userSettings.parsed, projectSettings.parsed, projectLocalSettings.parsed].filter(Boolean);
2124
+ const settingsLayers = isRepoOnly
2125
+ ? [
2126
+ { doc: projectSettings, label: '.claude/settings.json' },
2127
+ { doc: projectLocalSettings, label: '.claude/settings.local.json' }
2128
+ ]
2129
+ : [
2130
+ { doc: userSettings, label: '~/.claude/settings.json' },
2131
+ { doc: projectSettings, label: '.claude/settings.json' },
2132
+ { doc: projectLocalSettings, label: '.claude/settings.local.json' }
2133
+ ];
2134
+ const layers = isRepoOnly
2135
+ ? [projectSettings.parsed, projectLocalSettings.parsed].filter(Boolean)
2136
+ : [userSettings.parsed, projectSettings.parsed, projectLocalSettings.parsed].filter(Boolean);
2137
+ const scopedRulesFiles = isRepoOnly ? filterFilesWithinCwd(paths.rulesFiles, paths.cwd) : paths.rulesFiles;
2073
2138
 
2074
2139
  const chromeOnDemandCmd = buildClaudeCliCommand(['--chrome'], { platform: hostPlatform });
2075
2140
  const artifactDisallowedCmd = buildClaudeCliCommand(['--disallowedTools', 'Artifact'], { platform: hostPlatform });
@@ -2167,19 +2232,24 @@ export function runClaudeStartupAudit({
2167
2232
  schemaTokensByServer: telemetry.schemaTokensByServer
2168
2233
  });
2169
2234
 
2170
- const rulesBucket = auditRulesFiles(paths.rulesFiles);
2171
- const strictJsonSyntax = collectStrictJsonLints([
2172
- { res: claudeJson },
2173
- { res: userSettings },
2174
- { res: projectSettings },
2175
- { res: projectLocalSettings },
2176
- { res: projectMcp }
2177
- ]);
2235
+ const rulesBucket = auditRulesFiles(scopedRulesFiles);
2236
+ const strictJsonSyntax = collectStrictJsonLints(
2237
+ isRepoOnly
2238
+ ? [{ res: projectSettings }, { res: projectLocalSettings }, { res: projectMcp }]
2239
+ : [
2240
+ { res: claudeJson },
2241
+ { res: userSettings },
2242
+ { res: projectSettings },
2243
+ { res: projectLocalSettings },
2244
+ { res: projectMcp }
2245
+ ]
2246
+ );
2178
2247
  const localSettingsSecrets = auditLocalSettingsSecrets(projectLocalSettings, paths.cwd);
2179
2248
  const mcpToolViolations = scanMcpToolNameLengthViolations({
2180
2249
  homeDir: paths.homeDir,
2181
2250
  workspacePath: paths.cwd,
2182
- observedToolNames: telemetry.observedMcpToolNames || []
2251
+ observedToolNames: telemetry.observedMcpToolNames || [],
2252
+ repoOnly: isRepoOnly
2183
2253
  });
2184
2254
  const mcpToolNameLength = {
2185
2255
  status: mcpToolViolations.violations.length > 0 ? 'warn' : 'pass',
@@ -2191,11 +2261,13 @@ export function runClaudeStartupAudit({
2191
2261
  workspacePath: paths.cwd,
2192
2262
  manifestDirs,
2193
2263
  runtimeListChangedServers: telemetry.runtimeListChangedServers,
2194
- maxObservedCachedPrefixTokens: telemetry.maxCachedPrefixTokens
2264
+ maxObservedCachedPrefixTokens: telemetry.maxCachedPrefixTokens,
2265
+ repoOnly: isRepoOnly
2195
2266
  });
2196
2267
  const customAgents = scanClaudeCustomAgentSpecs({
2197
2268
  homeDir: paths.homeDir,
2198
- cwd: paths.cwd
2269
+ cwd: paths.cwd,
2270
+ repoOnly: isRepoOnly
2199
2271
  });
2200
2272
  const subagentCount =
2201
2273
  telemetry.subagentSpawns7d ||
@@ -2220,7 +2292,7 @@ export function runClaudeStartupAudit({
2220
2292
  maxObservedPrefixTokens: telemetry.maxCachedPrefixTokens
2221
2293
  });
2222
2294
  const volatilePrefix = auditVolatilePromptPrefix({
2223
- ruleFilePaths: paths.rulesFiles,
2295
+ ruleFilePaths: scopedRulesFiles,
2224
2296
  settingsLayers,
2225
2297
  harness: 'claude-code'
2226
2298
  });
@@ -2567,32 +2639,47 @@ export function runAntigravityStartupAudit({
2567
2639
  homeDir = getHomeDir(),
2568
2640
  cwd = process.cwd(),
2569
2641
  hostPlatform = process.platform,
2570
- nowMs = Date.now()
2642
+ nowMs = Date.now(),
2643
+ repoOnly = false,
2644
+ ci = false
2571
2645
  } = {}) {
2646
+ const isRepoOnly = Boolean(repoOnly || ci);
2572
2647
  const paths = resolveAntigravityConfigPaths({ homeDir, cwd, platform: hostPlatform });
2573
2648
  const projectHooks = parseJsoncReadOnly(paths.projectHooksJson);
2574
- const userHooks = parseJsoncReadOnly(paths.userHooksJson);
2649
+ const userHooks = isRepoOnly
2650
+ ? makeMissingJsoncStub(paths.userHooksJson)
2651
+ : parseJsoncReadOnly(paths.userHooksJson);
2575
2652
  const projectMcp = parseJsoncReadOnly(paths.projectMcpJson);
2576
- const userMcp = parseJsoncReadOnly(paths.userMcpJson);
2577
-
2578
- const ruleFiles = [
2579
- ...paths.rulesFiles,
2580
- ...listMarkdownFilesInDir(paths.projectRulesDir),
2581
- ...listMarkdownFilesInDir(paths.globalRulesDir)
2582
- ];
2653
+ const userMcp = isRepoOnly
2654
+ ? makeMissingJsoncStub(paths.userMcpJson)
2655
+ : parseJsoncReadOnly(paths.userMcpJson);
2656
+
2657
+ const ruleFiles = isRepoOnly
2658
+ ? filterFilesWithinCwd([...paths.rulesFiles, ...listMarkdownFilesInDir(paths.projectRulesDir)], cwd)
2659
+ : [
2660
+ ...paths.rulesFiles,
2661
+ ...listMarkdownFilesInDir(paths.projectRulesDir),
2662
+ ...listMarkdownFilesInDir(paths.globalRulesDir)
2663
+ ];
2583
2664
  const rulesBucket = auditAntigravityRulesFiles(ruleFiles);
2584
- const strictJsonSyntax = collectStrictJsonLints([
2585
- { res: projectHooks },
2586
- { res: userHooks },
2587
- { res: projectMcp },
2588
- { res: userMcp }
2589
- ]);
2665
+ const strictJsonSyntax = collectStrictJsonLints(
2666
+ isRepoOnly
2667
+ ? [{ res: projectHooks }, { res: projectMcp }]
2668
+ : [
2669
+ { res: projectHooks },
2670
+ { res: userHooks },
2671
+ { res: projectMcp },
2672
+ { res: userMcp }
2673
+ ]
2674
+ );
2590
2675
  const volatilePrefix = auditVolatilePromptPrefix({
2591
2676
  ruleFilePaths: ruleFiles,
2592
- settingsLayers: [
2593
- { label: paths.projectHooksJson, doc: projectHooks },
2594
- { label: paths.userHooksJson, doc: userHooks }
2595
- ],
2677
+ settingsLayers: isRepoOnly
2678
+ ? [{ label: paths.projectHooksJson, doc: projectHooks }]
2679
+ : [
2680
+ { label: paths.projectHooksJson, doc: projectHooks },
2681
+ { label: paths.userHooksJson, doc: userHooks }
2682
+ ],
2596
2683
  harness: 'antigravity'
2597
2684
  });
2598
2685
 
@@ -2698,28 +2785,33 @@ export function formatAntigravityStartupAuditReport(report) {
2698
2785
  export function runStartupAudit(options = {}) {
2699
2786
  const cwd = path.resolve(options.cwd || process.cwd());
2700
2787
  const homeDir = options.homeDir || getHomeDir();
2788
+ const isRepoOnly = Boolean(options.repoOnly || options.ci);
2701
2789
  const rawClient = String(options.client || 'auto').trim().toLowerCase();
2702
2790
 
2703
2791
  let target = rawClient;
2704
2792
  if (rawClient === 'auto') {
2705
- const hasAg =
2706
- fs.existsSync(path.join(cwd, '.agents')) ||
2707
- fs.existsSync(path.join(cwd, 'GEMINI.md')) ||
2708
- fs.existsSync(path.join(homeDir, '.gemini', 'config', 'hooks.json'));
2709
- const hasClaude =
2710
- fs.existsSync(path.join(cwd, '.claude')) ||
2711
- fs.existsSync(path.join(homeDir, '.claude'));
2793
+ const hasAg = isRepoOnly
2794
+ ? fs.existsSync(path.join(cwd, '.agents')) || fs.existsSync(path.join(cwd, 'GEMINI.md'))
2795
+ : fs.existsSync(path.join(cwd, '.agents')) ||
2796
+ fs.existsSync(path.join(cwd, 'GEMINI.md')) ||
2797
+ fs.existsSync(path.join(homeDir, '.gemini', 'config', 'hooks.json'));
2798
+ const hasClaude = isRepoOnly
2799
+ ? fs.existsSync(path.join(cwd, '.claude')) ||
2800
+ fs.existsSync(path.join(cwd, 'CLAUDE.md')) ||
2801
+ fs.existsSync(path.join(cwd, '.mcp.json'))
2802
+ : fs.existsSync(path.join(cwd, '.claude')) || fs.existsSync(path.join(homeDir, '.claude'));
2712
2803
  if (hasAg && hasClaude) target = 'both';
2713
2804
  else if (hasAg) target = 'antigravity';
2714
2805
  else target = 'claude';
2715
2806
  }
2716
2807
 
2808
+ const forwardedOpts = { ...options, repoOnly: isRepoOnly };
2717
2809
  if (target === 'antigravity' || target === 'ag') {
2718
- return runAntigravityStartupAudit(options);
2810
+ return runAntigravityStartupAudit(forwardedOpts);
2719
2811
  }
2720
2812
  if (target === 'both') {
2721
- const claudeReport = runClaudeStartupAudit(options);
2722
- const agReport = runAntigravityStartupAudit(options);
2813
+ const claudeReport = runClaudeStartupAudit(forwardedOpts);
2814
+ const agReport = runAntigravityStartupAudit(forwardedOpts);
2723
2815
  const claudeLints = claudeReport.lints || [];
2724
2816
  const agLints = agReport.lints || [];
2725
2817
  return {
@@ -2789,6 +2881,87 @@ export function formatStartupAuditReport(report) {
2789
2881
  return formatClaudeStartupAuditReport(report);
2790
2882
  }
2791
2883
 
2884
+ function escapeGhAnnotationValue(text = '') {
2885
+ return String(text || '')
2886
+ .replace(/%/g, '%25')
2887
+ .replace(/\r/g, '%0D')
2888
+ .replace(/\n/g, '%0A');
2889
+ }
2890
+
2891
+ function toRepoRelativePath(filePath, cwd = process.cwd()) {
2892
+ const raw = String(filePath || '').trim();
2893
+ if (!raw) return '.';
2894
+ if (!path.isAbsolute(raw)) return raw.replace(/\\/g, '/');
2895
+ const resolvedCwd = path.resolve(cwd);
2896
+ const rel = path.relative(resolvedCwd, path.resolve(raw));
2897
+ if (rel && rel !== '..' && !rel.startsWith(`..${path.sep}`) && !path.isAbsolute(rel)) {
2898
+ return rel.replace(/\\/g, '/');
2899
+ }
2900
+ return raw.replace(/\\/g, '/');
2901
+ }
2902
+
2903
+ /**
2904
+ * Evaluates a `runStartupAudit({ ci: true })` report for CI pass/warn/fail exit codes
2905
+ * and formats GitHub Actions `::error` / `::warning` workflow annotations.
2906
+ */
2907
+ export function evaluateStartupAuditCi(report = {}, { strict = false, cwd = process.cwd() } = {}) {
2908
+ const lints = Array.isArray(report?.lints) ? report.lints : [];
2909
+ let errorCount = 0;
2910
+ let warnCount = 0;
2911
+ let infoCount = 0;
2912
+ const annotations = [];
2913
+
2914
+ for (const l of lints) {
2915
+ const sev = String(l?.severity || 'warn').toLowerCase();
2916
+ const rel = toRepoRelativePath(l?.file || '.', cwd);
2917
+ const ruleId = String(l?.ruleId || 'BO-CFG');
2918
+ const msg = escapeGhAnnotationValue(l?.message || ruleId);
2919
+ if (sev === 'error') {
2920
+ errorCount += 1;
2921
+ annotations.push(`::error file=${rel},title=${ruleId}::${msg}`);
2922
+ } else if (sev === 'info') {
2923
+ infoCount += 1;
2924
+ } else {
2925
+ warnCount += 1;
2926
+ annotations.push(`::warning file=${rel},title=${ruleId}::${msg}`);
2927
+ }
2928
+ }
2929
+
2930
+ for (const harnessKey of ['claudeCode', 'antigravity']) {
2931
+ const bucket = report?.rulesAudit?.byHarness?.[harnessKey];
2932
+ if (bucket && bucket.status === 'warn') {
2933
+ warnCount += 1;
2934
+ const firstFile = bucket.files?.[0]?.path || '.';
2935
+ const rel = toRepoRelativePath(firstFile, cwd);
2936
+ const adv = (bucket.advisories || []).join('; ') || 'Static Turn-0 rule threshold exceeded.';
2937
+ annotations.push(`::warning file=${rel},title=BO-RULE-01::${escapeGhAnnotationValue(adv)}`);
2938
+ }
2939
+ }
2940
+
2941
+ const issueCount = Number(report?.summary?.issueCount || 0);
2942
+ let verdict = 'PASS';
2943
+ let exitCode = 0;
2944
+ if (errorCount > 0 || (Boolean(strict) && (warnCount > 0 || issueCount > 0))) {
2945
+ verdict = 'FAIL';
2946
+ exitCode = 1;
2947
+ } else if (warnCount > 0 || issueCount > 0) {
2948
+ verdict = 'WARN';
2949
+ exitCode = 0;
2950
+ }
2951
+
2952
+ return {
2953
+ verdict,
2954
+ exitCode,
2955
+ strict: Boolean(strict),
2956
+ repoOnly: true,
2957
+ errorCount,
2958
+ warnCount,
2959
+ infoCount,
2960
+ issueCount,
2961
+ annotations
2962
+ };
2963
+ }
2964
+
2792
2965
  export default {
2793
2966
  CALIBRATION_MANIFEST,
2794
2967
  RULES_THRESHOLDS,
@@ -2820,5 +2993,6 @@ export default {
2820
2993
  runAntigravityStartupAudit,
2821
2994
  formatAntigravityStartupAuditReport,
2822
2995
  runStartupAudit,
2823
- formatStartupAuditReport
2996
+ formatStartupAuditReport,
2997
+ evaluateStartupAuditCi
2824
2998
  };
@@ -35,6 +35,10 @@ import {
35
35
  recordReadIntervalEntry,
36
36
  updateReadSnapStoreAtomicSync
37
37
  } from './read-clamp.mjs';
38
+ import {
39
+ consumeMatchingAskSnoozeAtomicSync,
40
+ matchesSnoozeEntry
41
+ } from './snooze.mjs';
38
42
 
39
43
  const READ_TOOL_REGEX = /^(?:Read|read_file|view_file)$/i;
40
44
  const EDIT_WRITE_OR_READ_REGEX = /^(?:Edit|Write|MultiEdit|NotebookEdit|Read|Grep|Glob|read_file|view_file|grep_search)$/i;
@@ -125,6 +129,70 @@ function evaluatePreToolUseCore(event = {}, options = {}) {
125
129
  canonical.agentId || event.ownerId || event.agentId || event.subagentId || sessionId
126
130
  );
127
131
 
132
+ // Resolves interactive `ask` verdicts against active session/workspace snoozes.
133
+ // Security invariant: NEVER invoke for `deny` / `exitCode: 2` verdicts.
134
+ const evaluateAskWithSnooze = (verdict, targetText = '') => {
135
+ const evalNowMs = options.nowMs ?? Date.now();
136
+ let match = null;
137
+ if (Array.isArray(options.snoozes)) {
138
+ const memHit = options.snoozes.find((entry) =>
139
+ matchesSnoozeEntry(entry, { detectorId: verdict.detectorId, target: targetText, nowMs: evalNowMs })
140
+ );
141
+ if (memHit) {
142
+ if (memHit.remaining !== null && memHit.remaining !== undefined) {
143
+ memHit.remaining = Math.max(0, Number(memHit.remaining) - 1);
144
+ }
145
+ match = { matched: true, source: 'memory', grant: memHit };
146
+ }
147
+ } else if (shouldPersistState) {
148
+ match = consumeMatchingAskSnoozeAtomicSync(
149
+ {
150
+ sessionId,
151
+ detectorId: verdict.detectorId,
152
+ target: targetText,
153
+ nowMs: evalNowMs
154
+ },
155
+ cwdOptions
156
+ );
157
+ }
158
+
159
+ if (match?.matched) {
160
+ return {
161
+ snoozed: true,
162
+ response: finalize({
163
+ exitCode: 0,
164
+ stdout: '',
165
+ stderr: '',
166
+ snoozed: true,
167
+ verdict: {
168
+ ...verdict,
169
+ decision: 'allow',
170
+ snoozed: true,
171
+ snoozeGrantId: match.grant?.id || null,
172
+ reason: `[Burnoff Snoozed ${verdict.detectorId}] Allowed via active ${match.source || 'session'} grant.`
173
+ }
174
+ })
175
+ };
176
+ }
177
+
178
+ const askOut = {
179
+ hookSpecificOutput: {
180
+ hookEventName: 'PreToolUse',
181
+ permissionDecision: 'ask',
182
+ permissionDecisionReason: verdict.reason
183
+ }
184
+ };
185
+ return {
186
+ snoozed: false,
187
+ response: finalize({
188
+ exitCode: 0,
189
+ stdout: JSON.stringify(askOut),
190
+ stderr: '',
191
+ verdict
192
+ })
193
+ };
194
+ };
195
+
128
196
  let advisoryNotice = null;
129
197
 
130
198
  // 1. DET-20: Concurrent file-scope locks & quota hard brakes
@@ -169,19 +237,7 @@ function evaluatePreToolUseCore(event = {}, options = {}) {
169
237
  });
170
238
  if (det01.triggered) {
171
239
  if (det01.decision === 'ask') {
172
- const askOut = {
173
- hookSpecificOutput: {
174
- hookEventName: 'PreToolUse',
175
- permissionDecision: 'ask',
176
- permissionDecisionReason: det01.reason
177
- }
178
- };
179
- return finalize({
180
- exitCode: 0,
181
- stdout: JSON.stringify(askOut),
182
- stderr: '',
183
- verdict: det01
184
- });
240
+ return evaluateAskWithSnooze(det01, command).response;
185
241
  }
186
242
  if (canRecordLedger) {
187
243
  recordSavingsReceipt(
@@ -221,19 +277,7 @@ function evaluatePreToolUseCore(event = {}, options = {}) {
221
277
  });
222
278
  if (det02.triggered) {
223
279
  if (det02.decision === 'ask') {
224
- const askOut = {
225
- hookSpecificOutput: {
226
- hookEventName: 'PreToolUse',
227
- permissionDecision: 'ask',
228
- permissionDecisionReason: det02.reason
229
- }
230
- };
231
- return finalize({
232
- exitCode: 0,
233
- stdout: JSON.stringify(askOut),
234
- stderr: '',
235
- verdict: det02
236
- });
280
+ return evaluateAskWithSnooze(det02, rawPath || command).response;
237
281
  }
238
282
  if (canRecordLedger) {
239
283
  recordSavingsReceipt(
@@ -267,19 +311,7 @@ function evaluatePreToolUseCore(event = {}, options = {}) {
267
311
  filePath: rawPath
268
312
  });
269
313
  if (det03.triggered && det03.decision === 'ask') {
270
- const askOut = {
271
- hookSpecificOutput: {
272
- hookEventName: 'PreToolUse',
273
- permissionDecision: 'ask',
274
- permissionDecisionReason: det03.reason
275
- }
276
- };
277
- return finalize({
278
- exitCode: 0,
279
- stdout: JSON.stringify(askOut),
280
- stderr: '',
281
- verdict: det03
282
- });
314
+ return evaluateAskWithSnooze(det03, rawPath).response;
283
315
  }
284
316
  }
285
317
 
@@ -301,6 +333,10 @@ function evaluatePreToolUseCore(event = {}, options = {}) {
301
333
  });
302
334
  if (det04.triggered) {
303
335
  if (det04.decision === 'ask') {
336
+ const evaluated = evaluateAskWithSnooze(det04, rawPath || command);
337
+ if (evaluated.snoozed) {
338
+ return evaluated.response;
339
+ }
304
340
  if (canRecordLedger) {
305
341
  recordSavingsReceipt(
306
342
  {
@@ -317,19 +353,7 @@ function evaluatePreToolUseCore(event = {}, options = {}) {
317
353
  cwdOptions
318
354
  );
319
355
  }
320
- const askOut = {
321
- hookSpecificOutput: {
322
- hookEventName: 'PreToolUse',
323
- permissionDecision: 'ask',
324
- permissionDecisionReason: det04.reason
325
- }
326
- };
327
- return finalize({
328
- exitCode: 0,
329
- stdout: JSON.stringify(askOut),
330
- stderr: '',
331
- verdict: det04
332
- });
356
+ return evaluated.response;
333
357
  }
334
358
  if (canRecordLedger) {
335
359
  recordSavingsReceipt(