ctxtop 4.0.0 → 4.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 (89) hide show
  1. package/.antigravity-plugin/plugin.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHECKSUMS.sha256 +59 -42
  4. package/README.md +351 -330
  5. package/bin/ah-statusline.mjs +30 -0
  6. package/bin/ctxtop.mjs +330 -5
  7. package/config/default_flightcheck.json +19 -0
  8. package/config/modelCatalog.json +165 -0
  9. package/hooks/handlers/compact-lifecycle.mjs +323 -8
  10. package/hooks/handlers/config-change.mjs +402 -0
  11. package/hooks/handlers/hookIo.mjs +56 -0
  12. package/hooks/handlers/post-model-switch.mjs +111 -0
  13. package/hooks/handlers/post-tool-use.mjs +117 -16
  14. package/hooks/handlers/pre-model-switch.mjs +823 -24
  15. package/hooks/handlers/pre-tool-use.mjs +271 -4
  16. package/hooks/handlers/stop-gate.mjs +297 -11
  17. package/hooks/handlers/user-prompt-submit.mjs +224 -0
  18. package/hooks/hooks.json +50 -0
  19. package/hooks/post_tool_use.mjs +8 -0
  20. package/hooks/register.js +48 -9
  21. package/hooks/session_start.mjs +11 -1
  22. package/hooks/stop.mjs +11 -1
  23. package/package.json +11 -4
  24. package/packages/antigravity/package.json +1 -1
  25. package/packages/claude-code/package.json +1 -1
  26. package/packages/core/package.json +1 -1
  27. package/packages/engine-node/package.json +1 -1
  28. package/packages/mcp/package.json +1 -1
  29. package/packages/mcp/src/server.mjs +1 -1
  30. package/packages/pro/package.json +1 -1
  31. package/plugin.json +1 -1
  32. package/sidecars/horizon-daemon/server.mjs +38 -2
  33. package/skills/handoff/SKILL.md +8 -0
  34. package/src/adapters/antigravity/index.mjs +31 -1
  35. package/src/adapters/claude-code/index.mjs +40 -1
  36. package/src/cli/horizon_hud.mjs +254 -52
  37. package/src/config/modelCatalog.json +84 -0
  38. package/src/core/bucket_b_runtime.mjs +1200 -0
  39. package/src/core/constants.mjs +191 -4
  40. package/src/core/detectors_det01_to_16.mjs +54 -5
  41. package/src/core/doc_indexer.mjs +338 -0
  42. package/src/core/layer5_hygiene.mjs +118 -0
  43. package/src/core/parser.mjs +2 -1
  44. package/src/core/paths.mjs +3 -2
  45. package/src/core/rsl_clash_auditor.mjs +423 -0
  46. package/src/core/rsl_distiller.mjs +372 -0
  47. package/src/core/rsl_ledger.mjs +969 -0
  48. package/src/core/rsl_triage.mjs +909 -0
  49. package/src/core/session_auditor.mjs +658 -0
  50. package/src/core/shield_manager.mjs +1417 -0
  51. package/src/core/task_quota_router.mjs +1 -1
  52. package/src/core-isomorphic/coach/cacheGravityRouter.mjs +874 -47
  53. package/src/core-isomorphic/coach/resumeToolsetAuditor.mjs +321 -0
  54. package/src/core-isomorphic/coach/smartCompactAdvisor.mjs +305 -0
  55. package/src/core-isomorphic/coach/ttlWatchdog.mjs +13 -6
  56. package/src/core-isomorphic/config/anthropicModelCatalog.json +404 -1
  57. package/src/core-isomorphic/config/catalogLoader.mjs +546 -46
  58. package/src/core-isomorphic/config/horizonConfig.mjs +47 -1
  59. package/src/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +266 -0
  60. package/src/core-isomorphic/economics/cacheGravity.mjs +18 -0
  61. package/src/core-isomorphic/economics/cliffBreaker.mjs +98 -12
  62. package/src/core-isomorphic/economics/driftLatency.mjs +114 -0
  63. package/src/core-isomorphic/guards/bucketBAlphaBeta.mjs +860 -0
  64. package/src/core-isomorphic/guards/bucketBGamma.mjs +442 -0
  65. package/src/core-isomorphic/guards/bucketBHeuristics.mjs +37 -0
  66. package/src/core-isomorphic/guards/circuitBreakers.mjs +191 -191
  67. package/src/core-isomorphic/guards/det01_03_shell_secret.mjs +154 -5
  68. package/src/core-isomorphic/guards/det04_12_thrash_rot.mjs +103 -11
  69. package/src/core-isomorphic/guards/det13_20_mcp_scope.mjs +311 -1
  70. package/src/core-isomorphic/guards/docIndexCore.mjs +446 -0
  71. package/src/core-isomorphic/guards/losslessPostSanitizer.mjs +16 -0
  72. package/src/core-isomorphic/guards/slopsquatGate.mjs +551 -0
  73. package/src/core-isomorphic/index.js +1 -0
  74. package/src/core-isomorphic/telemetry/telemetryBridge.mjs +36 -12
  75. package/src/core-isomorphic/ui/horizonPanelHtml.mjs +293 -237
  76. package/src/core-isomorphic/ui/modViews.mjs +35 -9
  77. package/src/diagnostics/claudeHookCapabilities.mjs +396 -0
  78. package/src/diagnostics/doctorEngine.mjs +95 -3
  79. package/src/engine-node/db/probe.mjs +234 -2
  80. package/src/engine-node/index.mjs +3 -0
  81. package/src/engine-node/sensors/blindspots.mjs +13 -6
  82. package/src/hooks/antigravity_rsl_hook.mjs +250 -0
  83. package/src/hooks/claude_rsl_hook.mjs +288 -0
  84. package/src/hooks/post_invocation.mjs +196 -4
  85. package/src/hooks/pre_invocation.mjs +732 -22
  86. package/src/hooks/session_start.mjs +39 -1
  87. package/src/utils/modelSwitchTelemetry.mjs +308 -0
  88. package/src/utils/sessionCalibration.mjs +657 -0
  89. package/src/webview/horizon_panel.html +1325 -317
@@ -41,7 +41,7 @@ export const SURFACE_TAGS = Object.freeze({
41
41
  });
42
42
 
43
43
  export const PREFIX_LOCK_WARNING_TEXT =
44
- 'Active warm cache (>50k tokens). Changing reasoning effort or switching models rewrites the system prefix and triggers a 100% uncached KV cache rebuild.';
44
+ 'Active warm cache (>50k tokens). Switching models (within or across families) triggers a full uncached cache rebuild; on Claude, changing reasoning effort also re-bills cached chat history (Gemini thinking-level changes keep the cache).';
45
45
 
46
46
  export const CORTEX_CLAMPED_CEILING_LABEL =
47
47
  '256k Host Cap (1M model)';
@@ -496,6 +496,76 @@ export const MODEL_REGISTRY = Object.freeze({
496
496
  deprecated_after: null,
497
497
  rate_schedules: buildAnthropicSchedule({ input: 10.00, output: 50.00, write5m: 12.50, write1h: 20.00, cachedRead: 0.25 })
498
498
  }),
499
+ 'claude-fable-5': Object.freeze({
500
+ id: 'claude-fable-5',
501
+ aliases: Object.freeze(['fable-5']),
502
+ family: 'fable',
503
+ label: 'Claude Fable 5',
504
+ supported_efforts: Object.freeze(['low', 'medium', 'high']),
505
+ caching_mode: 'explicit_and_implicit',
506
+ supports_explicit_cache: true,
507
+ antigravity_min_tier: 'ultra',
508
+ shared_pool_ceiling: 1000000,
509
+ max_output_tokens: null,
510
+ deprecated_after: null,
511
+ rate_schedules: buildAnthropicSchedule({ input: 10.00, output: 50.00, write5m: 12.50, write1h: 20.00, cachedRead: 1.00 })
512
+ }),
513
+ 'claude-opus-5': Object.freeze({
514
+ id: 'claude-opus-5',
515
+ aliases: Object.freeze(['opus-5']),
516
+ family: 'opus',
517
+ label: 'Claude Opus 5',
518
+ supported_efforts: Object.freeze(['low', 'medium', 'high']),
519
+ caching_mode: 'explicit_and_implicit',
520
+ supports_explicit_cache: true,
521
+ antigravity_min_tier: 'pro',
522
+ shared_pool_ceiling: 1000000,
523
+ max_output_tokens: null,
524
+ deprecated_after: null,
525
+ rate_schedules: buildAnthropicSchedule({ input: 5.00, output: 25.00, write5m: 6.25, write1h: 10.00, cachedRead: 0.50 })
526
+ }),
527
+ 'claude-sonnet-5': Object.freeze({
528
+ id: 'claude-sonnet-5',
529
+ aliases: Object.freeze(['sonnet-5']),
530
+ family: 'sonnet',
531
+ label: 'Claude Sonnet 5',
532
+ supported_efforts: Object.freeze(['low', 'medium', 'high']),
533
+ caching_mode: 'explicit_and_implicit',
534
+ supports_explicit_cache: true,
535
+ antigravity_min_tier: 'pro',
536
+ shared_pool_ceiling: 1000000,
537
+ max_output_tokens: null,
538
+ deprecated_after: null,
539
+ rate_schedules: buildAnthropicSchedule({ input: 2.00, output: 10.00, write5m: 2.50, write1h: 4.00, cachedRead: 0.20 })
540
+ }),
541
+ 'claude-opus-4-8': Object.freeze({
542
+ id: 'claude-opus-4-8',
543
+ aliases: Object.freeze(['claude-opus-4.8', 'opus-4-8', 'opus-4.8']),
544
+ family: 'opus',
545
+ label: 'Claude Opus 4.8',
546
+ supported_efforts: Object.freeze(['low', 'medium', 'high']),
547
+ caching_mode: 'explicit_and_implicit',
548
+ supports_explicit_cache: true,
549
+ antigravity_min_tier: 'pro',
550
+ shared_pool_ceiling: 1000000,
551
+ max_output_tokens: null,
552
+ deprecated_after: null,
553
+ rate_schedules: buildAnthropicSchedule({ input: 5.00, output: 25.00, write5m: 6.25, write1h: 10.00, cachedRead: 0.50 })
554
+ }),
555
+ 'claude-opus-4-7': Object.freeze({
556
+ id: 'claude-opus-4-7',
557
+ aliases: Object.freeze(['claude-opus-4.7', 'opus-4-7', 'opus-4.7']),
558
+ family: 'opus',
559
+ label: 'Claude Opus 4.7',
560
+ supported_efforts: Object.freeze(['low', 'medium', 'high']),
561
+ caching_mode: 'explicit_and_implicit',
562
+ supports_explicit_cache: true,
563
+ antigravity_min_tier: 'pro',
564
+ shared_pool_ceiling: 1000000,
565
+ max_output_tokens: null,
566
+ deprecated_after: null,
567
+ rate_schedules: buildAnthropicSchedule({ input: 5.00, output: 25.00, write5m: 6.25, write1h: 10.00, cachedRead: 0.50 })
568
+ }),
499
569
  'claude-sonnet-4-6': Object.freeze({
500
570
  id: 'claude-sonnet-4-6',
501
571
  aliases: Object.freeze(['claude-sonnet-4.6', 'sonnet-4-6', 'sonnet-4.6']),
@@ -598,6 +668,88 @@ export const MODEL_REGISTRY = Object.freeze({
598
668
  })
599
669
  })
600
670
  ])
671
+ }),
672
+ 'gemini-3.1-pro': Object.freeze({
673
+ id: 'gemini-3.1-pro',
674
+ aliases: Object.freeze(['gemini-3.1-pro-preview', 'gemini-3-1-pro', 'gemini-3-1-pro-preview']),
675
+ family: 'gemini-pro',
676
+ label: 'Gemini 3.1 Pro',
677
+ supported_efforts: Object.freeze(['low', 'medium', 'high']),
678
+ caching_mode: 'explicit_and_implicit',
679
+ supports_explicit_cache: true,
680
+ antigravity_min_tier: 'pro',
681
+ shared_pool_ceiling: 1000000,
682
+ max_output_tokens: null,
683
+ deprecated_after: null,
684
+ prompt_cliff_tokens: 200000,
685
+ rate_schedules: Object.freeze([
686
+ Object.freeze({
687
+ effective_from_utc: null,
688
+ effective_until_utc: null,
689
+ standard: Object.freeze({
690
+ input_per_1m: 1.25,
691
+ output_per_1m: 10.00,
692
+ write_5m_per_1m: 1.25,
693
+ write_1h_per_1m: 1.25,
694
+ cached_read_per_1m: 0.125
695
+ }),
696
+ cliff_over_200k: Object.freeze({
697
+ input_per_1m: 2.50,
698
+ output_per_1m: 15.00,
699
+ write_5m_per_1m: 2.50,
700
+ write_1h_per_1m: 2.50,
701
+ cached_read_per_1m: 0.25
702
+ }),
703
+ priority: Object.freeze({
704
+ input_per_1m: 1.25,
705
+ output_per_1m: 10.00,
706
+ write_5m_per_1m: 1.25,
707
+ write_1h_per_1m: 1.25,
708
+ cached_read_per_1m: 0.125
709
+ })
710
+ })
711
+ ])
712
+ }),
713
+ 'gemini-2.5-pro': Object.freeze({
714
+ id: 'gemini-2.5-pro',
715
+ aliases: Object.freeze(['gemini-2.5-pro-preview', 'gemini-2-5-pro', 'gemini-2.5-pro-1m']),
716
+ family: 'gemini-pro',
717
+ label: 'Gemini 2.5 Pro',
718
+ supported_efforts: Object.freeze(['low', 'medium', 'high']),
719
+ caching_mode: 'explicit_and_implicit',
720
+ supports_explicit_cache: true,
721
+ antigravity_min_tier: 'pro',
722
+ shared_pool_ceiling: 1000000,
723
+ max_output_tokens: null,
724
+ deprecated_after: null,
725
+ prompt_cliff_tokens: 200000,
726
+ rate_schedules: Object.freeze([
727
+ Object.freeze({
728
+ effective_from_utc: null,
729
+ effective_until_utc: null,
730
+ standard: Object.freeze({
731
+ input_per_1m: 1.25,
732
+ output_per_1m: 10.00,
733
+ write_5m_per_1m: 1.25,
734
+ write_1h_per_1m: 1.25,
735
+ cached_read_per_1m: 0.125
736
+ }),
737
+ cliff_over_200k: Object.freeze({
738
+ input_per_1m: 2.50,
739
+ output_per_1m: 15.00,
740
+ write_5m_per_1m: 2.50,
741
+ write_1h_per_1m: 2.50,
742
+ cached_read_per_1m: 0.25
743
+ }),
744
+ priority: Object.freeze({
745
+ input_per_1m: 1.25,
746
+ output_per_1m: 10.00,
747
+ write_5m_per_1m: 1.25,
748
+ write_1h_per_1m: 1.25,
749
+ cached_read_per_1m: 0.125
750
+ })
751
+ })
752
+ ])
601
753
  })
602
754
  });
603
755
 
@@ -618,16 +770,25 @@ export const MODEL_PRICING_PER_MILLION = {
618
770
  'claude-fable-5.2': 8.00,
619
771
  'claude-fable-5-1': 10.00,
620
772
  'claude-fable-5.1': 10.00,
773
+ 'claude-fable-5': 10.00,
774
+ 'claude-opus-5': 5.00,
775
+ 'claude-sonnet-5': 2.00,
776
+ 'claude-opus-4-8': 5.00,
777
+ 'claude-opus-4.8': 5.00,
778
+ 'claude-opus-4-7': 5.00,
779
+ 'claude-opus-4.7': 5.00,
621
780
  'claude-opus-4-6': 5.00,
622
781
  'claude-opus-4.6': 5.00,
623
782
  'claude-opus-4-6-thinking': 5.00,
624
783
  'claude-opus-4-5': 5.00,
625
784
  'claude-opus-4.5': 5.00,
626
785
  'claude-opus-4-1': 15.00,
786
+ 'claude-opus-4-0': 15.00,
627
787
  'claude-sonnet-4-6': 3.00,
628
788
  'claude-sonnet-4.6': 3.00,
629
789
  'claude-sonnet-4-5': 3.00,
630
790
  'claude-sonnet-4.5': 3.00,
791
+ 'claude-sonnet-4-0': 3.00,
631
792
  'claude-haiku-4-5': 1.00,
632
793
  'claude-haiku-4.5': 1.00,
633
794
  'claude-3-5-sonnet': 3.00,
@@ -677,16 +838,25 @@ export const MODEL_CEILINGS = Object.freeze({
677
838
  'claude-fable-5.2': 1000000,
678
839
  'claude-fable-5-1': 1000000,
679
840
  'claude-fable-5.1': 1000000,
841
+ 'claude-fable-5': 1000000,
842
+ 'claude-opus-5': 1000000,
843
+ 'claude-sonnet-5': 1000000,
844
+ 'claude-opus-4-8': 1000000,
845
+ 'claude-opus-4.8': 1000000,
846
+ 'claude-opus-4-7': 1000000,
847
+ 'claude-opus-4.7': 1000000,
680
848
  'claude-opus-4-6': 200000,
681
849
  'claude-opus-4.6': 200000,
682
850
  'claude-opus-4-6-thinking': 200000,
683
851
  'claude-opus-4-5': 200000,
684
852
  'claude-opus-4.5': 200000,
685
853
  'claude-opus-4-1': 200000,
854
+ 'claude-opus-4-0': 200000,
686
855
  'claude-sonnet-4-6': 200000,
687
856
  'claude-sonnet-4.6': 200000,
688
857
  'claude-sonnet-4-5': 200000,
689
858
  'claude-sonnet-4.5': 200000,
859
+ 'claude-sonnet-4-0': 200000,
690
860
  'claude-haiku-4-5': 200000,
691
861
  'claude-haiku-4.5': 200000,
692
862
  'claude-3-5-sonnet': 200000,
@@ -715,6 +885,9 @@ export const MODEL_CEILINGS = Object.freeze({
715
885
  'gpt-oss-120b': 128000,
716
886
  'gemini-1.5-pro-1m': 1000000,
717
887
  'gemini-2.5-pro-1m': 1000000,
888
+ 'gemini-2.5-pro-preview': 1000000,
889
+ 'gemini-3.1-pro': 1000000,
890
+ 'gemini-3.1-pro-preview': 1000000,
718
891
  'default': 256000
719
892
  });
720
893
 
@@ -1159,18 +1332,20 @@ export function resolveModelRates(modelId = 'gemini-4-carbon', eventTimestampUtc
1159
1332
  desc.rate_schedules[desc.rate_schedules.length - 1];
1160
1333
 
1161
1334
  const promptEnvelope = extractPromptEnvelopeTokens(effectiveCtx);
1335
+ const cliffSchedule = matchedSched.cliff_over_200k || matchedSched.cliff_over_100k || null;
1336
+ const cliffWindowName = matchedSched.cliff_over_200k ? 'cliff_over_200k' : 'cliff_over_100k';
1162
1337
  const cliffTriggered = Boolean(
1163
1338
  desc.prompt_cliff_tokens &&
1164
1339
  promptEnvelope > desc.prompt_cliff_tokens &&
1165
- matchedSched.cliff_over_100k
1340
+ cliffSchedule
1166
1341
  );
1167
1342
  const rates = cliffTriggered
1168
- ? matchedSched.cliff_over_100k
1343
+ ? cliffSchedule
1169
1344
  : (matchedSched[tierKey] || matchedSched.standard);
1170
1345
 
1171
1346
  let windowName = 'standard';
1172
1347
  if (cliffTriggered) {
1173
- windowName = 'cliff_over_100k';
1348
+ windowName = cliffWindowName;
1174
1349
  } else if (matchedSched.window) {
1175
1350
  windowName = matchedSched.window;
1176
1351
  } else if (desc.rate_schedules.length > 1) {
@@ -1798,3 +1973,15 @@ export function resolveEffortProfile(turnMetadata) {
1798
1973
 
1799
1974
  return { ...EFFORT_PROFILES.STANDARD };
1800
1975
  }
1976
+
1977
+ export const RSL_CONSTANTS = Object.freeze({
1978
+ MAX_RULE_FILE_BYTES: 24_000,
1979
+ AGGREGATE_RULE_TOKEN_BUDGET: 20_000,
1980
+ CLAUDE_MEMORY_MAX_LINES: 200,
1981
+ CLAUDE_MEMORY_MAX_BYTES: 25_000,
1982
+ INITIAL_IMPORTANCE: 2,
1983
+ PROMOTE_HOOK_IMPORTANCE: 5,
1984
+ REPEAT_VIOLATION_THRESHOLD: 2,
1985
+ CONTRASTIVE_WINDOW_STEPS: 4,
1986
+ MAX_DIGEST_CHARS: 10_000
1987
+ });
@@ -610,8 +610,9 @@ export function tokenizeShellCommandSegments(cmdStr = '') {
610
610
  return segments;
611
611
  }
612
612
 
613
- export function isDestructiveOrBypassShellCommand(cmdStr = '', depth = 0) {
613
+ export function isDestructiveOrBypassShellCommand(cmdStr = '', depth = 0, options = {}) {
614
614
  if (!cmdStr || depth > 2) return false;
615
+ const userExplicitTestIntent = Boolean(options?.userExplicitTestIntent);
615
616
  const segments = tokenizeShellCommandSegments(cmdStr);
616
617
 
617
618
  for (const rawTokens of segments) {
@@ -696,16 +697,49 @@ export function isDestructiveOrBypassShellCommand(cmdStr = '', depth = 0) {
696
697
  if (subTokens.some(t => !t.quoted && (t.value === '--force' || /^-[a-zA-Z]*f[a-zA-Z]*$/.test(t.value)))) {
697
698
  return true;
698
699
  }
700
+ } else if (sub === 'checkout') {
701
+ const isBranchCreate = subTokens.some(t => !t.quoted && (t.value === '-b' || t.value === '-B' || t.value === '--orphan'));
702
+ if (!isBranchCreate) {
703
+ const isDiscard = subTokens.some(
704
+ t => !t.quoted && (t.value === '--' || t.value === '.' || t.value === '-f' || t.value === '--force')
705
+ );
706
+ if (isDiscard) return true;
707
+ }
708
+ } else if (sub === 'restore') {
709
+ const stagedOnly =
710
+ subTokens.some(t => !t.quoted && (t.value === '--staged' || t.value === '-S')) &&
711
+ !subTokens.some(t => !t.quoted && (t.value === '--worktree' || t.value === '-W'));
712
+ if (!stagedOnly && subTokens.some(t => t.value !== '--help' && t.value !== '-h')) {
713
+ return true;
714
+ }
715
+ } else if (sub === 'fsck' || sub === 'cat-file' || sub === 'reflog') {
716
+ return true;
717
+ } else if (
718
+ sub === 'log' &&
719
+ subTokens.some(t => !t.quoted && t.value === '--all') &&
720
+ subTokens.some(t => !t.quoted && (t.value === '-p' || t.value === '--patch'))
721
+ ) {
722
+ return true;
699
723
  }
700
724
  }
701
725
  continue;
702
726
  }
703
727
 
704
- if (exeBase === 'rm') {
728
+ if (exeBase === 'rm' || exeBase === 'unlink') {
705
729
  let hasRec = false;
706
730
  let hasForce = false;
707
731
  for (const t of argTokens) {
708
732
  if (/\.gemini[\\/]antigravity[\\/]brain/i.test(t.value)) return true;
733
+ if (
734
+ !userExplicitTestIntent &&
735
+ !t.value.startsWith('-') &&
736
+ isTestFilePath(t.value) &&
737
+ !/^(?:\/tmp\/|\/var\/folders\/)/i.test(t.value) &&
738
+ !/(?:^|[\\/])(?:tmp|temp|\.claude[\\/]cache|\.agents[\\/]tmp)[\\/]/i.test(t.value) &&
739
+ !/appdata[\\/]local[\\/]temp[\\/]/i.test(t.value)
740
+ ) {
741
+ return true;
742
+ }
709
743
  if (!t.quoted && t.value.startsWith('-')) {
710
744
  if (t.value === '--recursive') hasRec = true;
711
745
  else if (t.value === '--force') hasForce = true;
@@ -719,11 +753,21 @@ export function isDestructiveOrBypassShellCommand(cmdStr = '', depth = 0) {
719
753
  continue;
720
754
  }
721
755
 
722
- if (['del', 'erase', 'remove-item', 'ri', 'rd', 'rmdir', 'unlink'].includes(exeBase)) {
756
+ if (['del', 'erase', 'remove-item', 'ri', 'rd', 'rmdir'].includes(exeBase)) {
723
757
  let hasRec = false;
724
758
  let hasForce = false;
725
759
  for (const t of argTokens) {
726
760
  if (/\.gemini[\\/]antigravity[\\/]brain/i.test(t.value)) return true;
761
+ if (
762
+ !userExplicitTestIntent &&
763
+ !t.value.startsWith('-') &&
764
+ !t.value.startsWith('/') &&
765
+ isTestFilePath(t.value) &&
766
+ !/(?:^|[\\/])(?:tmp|temp|\.claude[\\/]cache|\.agents[\\/]tmp)[\\/]/i.test(t.value) &&
767
+ !/appdata[\\/]local[\\/]temp[\\/]/i.test(t.value)
768
+ ) {
769
+ return true;
770
+ }
727
771
  if (!t.quoted) {
728
772
  if (/^-recurse$/i.test(t.value)) hasRec = true;
729
773
  if (/^-force$/i.test(t.value)) hasForce = true;
@@ -739,8 +783,13 @@ export function isDestructiveOrBypassShellCommand(cmdStr = '', depth = 0) {
739
783
  }
740
784
 
741
785
  export function evaluateDet08DestructiveShell(stepsOrCmd = [], _context = {}) {
786
+ const shellOpts = {
787
+ userExplicitTestIntent: Boolean(
788
+ _context?.userExplicitTestIntent || _context?.userAuthorizedTestDeletion
789
+ )
790
+ };
742
791
  if (typeof stepsOrCmd === 'string') {
743
- const blocked = isDestructiveOrBypassShellCommand(stepsOrCmd);
792
+ const blocked = isDestructiveOrBypassShellCommand(stepsOrCmd, 0, shellOpts);
744
793
  return {
745
794
  id: 'DET-08',
746
795
  detectorId: 'DET-08',
@@ -767,7 +816,7 @@ export function evaluateDet08DestructiveShell(stepsOrCmd = [], _context = {}) {
767
816
  const args = call.args || call.arguments || call.input || {};
768
817
  const cmdStr = String(args.CommandLine || args.command || args.cmd || call.command || step.command || '').trim();
769
818
  const targetPath = String(args.Path || args.path || args.TargetFile || args.AbsolutePath || call.targetPath || '').trim();
770
- if (cmdStr && isDestructiveOrBypassShellCommand(cmdStr)) {
819
+ if (cmdStr && isDestructiveOrBypassShellCommand(cmdStr, 0, shellOpts)) {
771
820
  return {
772
821
  id: 'DET-08',
773
822
  detectorId: 'DET-08',