ctxtop 0.0.0-stage → 4.0.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.
- package/.antigravity-plugin/plugin.json +36 -0
- package/.claude-plugin/plugin.json +18 -0
- package/CHECKSUMS.sha256 +149 -0
- package/LICENSE +27 -0
- package/README.md +330 -3
- package/SECURITY.md +22 -0
- package/agents/ah-flash-scout.md +25 -0
- package/assets/advanced_view_loaded_420px.png +0 -0
- package/assets/hero-demo.svg +188 -0
- package/assets/logo.svg +19 -0
- package/assets/simple_view_lean_420px.png +0 -0
- package/assets/simple_view_loaded_420px.png +0 -0
- package/assets/social-preview.svg +72 -0
- package/assets/zone_c_step3_shield_full.png +0 -0
- package/bin/ah-statusline.mjs +145 -0
- package/bin/cli.mjs +3 -0
- package/bin/ctxtop.mjs +1474 -0
- package/commands/cost-radar.md +11 -0
- package/commands/evolve.md +10 -0
- package/commands/handoff.md +10 -0
- package/commands/horizon.md +10 -0
- package/commands/inspect.md +10 -0
- package/commands/precheck.md +10 -0
- package/config/default_flightcheck.json +114 -0
- package/config/modelCatalog.json +620 -0
- package/config/platformQuirks.json +19 -0
- package/hooks/handlers/compact-lifecycle.mjs +262 -0
- package/hooks/handlers/hookIo.mjs +255 -0
- package/hooks/handlers/hookIpcClient.mjs +83 -0
- package/hooks/handlers/post-tool-use.mjs +265 -0
- package/hooks/handlers/pre-model-switch.mjs +249 -0
- package/hooks/handlers/pre-tool-use.mjs +365 -0
- package/hooks/handlers/stop-gate.mjs +240 -0
- package/hooks/handlers/user-prompt-submit.mjs +143 -0
- package/hooks/hooks.json +81 -0
- package/hooks/post_invocation.mjs +13 -0
- package/hooks/post_tool_use.mjs +17 -0
- package/hooks/pre_invocation.mjs +14 -0
- package/hooks/pre_tool_use.mjs +97 -0
- package/hooks/register.js +687 -0
- package/hooks/session_start.mjs +14 -0
- package/hooks/stop.mjs +13 -0
- package/hooks.json +56 -0
- package/package.json +103 -4
- package/packages/antigravity/package.json +14 -0
- package/packages/antigravity/src/index.mjs +1 -0
- package/packages/claude-code/package.json +14 -0
- package/packages/claude-code/src/index.mjs +2 -0
- package/packages/core/package.json +14 -0
- package/packages/core/src/index.mjs +1 -0
- package/packages/engine-node/package.json +14 -0
- package/packages/engine-node/src/index.mjs +1 -0
- package/packages/mcp/package.json +17 -0
- package/packages/mcp/src/server.mjs +396 -0
- package/packages/pro/LICENSE-COMMERCIAL.md +19 -0
- package/packages/pro/README-SIGNING.md +30 -0
- package/packages/pro/package.json +16 -0
- package/packages/pro/src/index.mjs +3 -0
- package/packages/pro/src/team_finops_pack.mjs +241 -0
- package/packages/pro/workers/polar_webhook_worker.mjs +215 -0
- package/plugin.json +36 -0
- package/rules/AGENTS.md +10 -0
- package/sidecars/horizon-daemon/ipcServer.mjs +24 -0
- package/sidecars/horizon-daemon/server.mjs +2002 -0
- package/sidecars/horizon-daemon/sidecar.json +19 -0
- package/skills/cost-radar/SKILL.md +21 -0
- package/skills/evolve/SKILL.md +21 -0
- package/skills/handoff/SKILL.md +42 -0
- package/skills/horizon/SKILL.md +17 -0
- package/skills/inspect/SKILL.md +18 -0
- package/skills/precheck/SKILL.md +44 -0
- package/src/adapters/antigravity/index.mjs +79 -0
- package/src/adapters/claude-code/index.mjs +155 -0
- package/src/cli/cost_radar.mjs +70 -0
- package/src/cli/doctor.mjs +351 -0
- package/src/cli/horizon_hud.mjs +686 -0
- package/src/cli/init.mjs +425 -0
- package/src/cli/postmortem.mjs +515 -0
- package/src/coach/cacheGravityRouter.mjs +12 -0
- package/src/config/modelCatalog.json +620 -0
- package/src/config/platformQuirks.json +19 -0
- package/src/core/action_queue.mjs +264 -0
- package/src/core/ag_bridge.mjs +346 -0
- package/src/core/atomic_io.mjs +124 -0
- package/src/core/baseline.mjs +607 -0
- package/src/core/blindspot_sensors.mjs +399 -0
- package/src/core/classifier.mjs +1757 -0
- package/src/core/coach/circuit_breakers.mjs +650 -0
- package/src/core/coach/contradiction_auditor.mjs +239 -0
- package/src/core/coach/effort_advisor.mjs +143 -0
- package/src/core/coach/handoff_hydrator.mjs +483 -0
- package/src/core/coach/progressive_checkpointer.mjs +551 -0
- package/src/core/coach/prompt_decomposer_coach.mjs +141 -0
- package/src/core/coach/reflector_queue.mjs +505 -0
- package/src/core/coach/saved_quota_ledger.mjs +615 -0
- package/src/core/coach/subagent_ipi_sanitizer.mjs +200 -0
- package/src/core/coach/subagent_phantom_auditor.mjs +261 -0
- package/src/core/coach/task_quota_router.mjs +955 -0
- package/src/core/coach/turn_zero_gate.mjs +574 -0
- package/src/core/compaction_coach.mjs +1126 -0
- package/src/core/config.mjs +214 -0
- package/src/core/constants.mjs +1800 -0
- package/src/core/detectors_det01_to_16.mjs +1474 -0
- package/src/core/episodic_memory.mjs +135 -0
- package/src/core/fts5_output_compressor.mjs +359 -0
- package/src/core/git_ledger.mjs +189 -0
- package/src/core/handoff_audit.mjs +558 -0
- package/src/core/history.mjs +221 -0
- package/src/core/hook_diagnostics.mjs +158 -0
- package/src/core/horizon_classifier.mjs +326 -0
- package/src/core/horizon_config.mjs +802 -0
- package/src/core/host_watchdog.mjs +200 -0
- package/src/core/layer5_hygiene.mjs +966 -0
- package/src/core/log_resolver.mjs +231 -0
- package/src/core/mcp_auditor.mjs +138 -0
- package/src/core/micro_skills_store.mjs +91 -0
- package/src/core/offenders.mjs +161 -0
- package/src/core/parser.mjs +1996 -0
- package/src/core/path_canonicalizer.mjs +73 -0
- package/src/core/paths.mjs +310 -0
- package/src/core/prefix_cache_shield.mjs +386 -0
- package/src/core/pro_license.mjs +385 -0
- package/src/core/prompt_rubric.mjs +518 -0
- package/src/core/pruner.mjs +433 -0
- package/src/core/quota.mjs +1860 -0
- package/src/core/rsi_instinct_engine.mjs +1197 -0
- package/src/core/sanitizer.mjs +121 -0
- package/src/core/session_forensics.mjs +303 -0
- package/src/core/session_timeline.mjs +358 -0
- package/src/core/settings.mjs +99 -0
- package/src/core/shared/detectors.mjs +1342 -0
- package/src/core/shared/fnv1a64.mjs +85 -0
- package/src/core/shared/handoff_schema.mjs +123 -0
- package/src/core/shared/index.mjs +5 -0
- package/src/core/shared/ipi_sanitizer.mjs +165 -0
- package/src/core/shared/micro_skills.mjs +1 -0
- package/src/core/shared/plugin_validator.mjs +202 -0
- package/src/core/shared/prompt_hygiene_governor.mjs +1 -0
- package/src/core/sidecar_store.mjs +302 -0
- package/src/core/sprint_metrics.mjs +366 -0
- package/src/core/sqlite_client.mjs +283 -0
- package/src/core/storage_doctor.mjs +358 -0
- package/src/core/subagents.mjs +609 -0
- package/src/core/swarm_topology.mjs +360 -0
- package/src/core/task_quota_router.mjs +1656 -0
- package/src/core/telemetry/cache_ttl_watchdog.mjs +284 -0
- package/src/core/telemetry/scope_lock_registry.mjs +578 -0
- package/src/core/telemetry/shadow_file_detector.mjs +291 -0
- package/src/core/telemetry/trajectory_watcher.mjs +259 -0
- package/src/core/timeline_svg.mjs +236 -0
- package/src/core/tool_surgeon.mjs +305 -0
- package/src/core/trajectory_stitcher.mjs +645 -0
- package/src/core/u_shaped_optimizer.mjs +789 -0
- package/src/core/wal_hygiene.mjs +233 -0
- package/src/core-isomorphic/catalog/detectorCatalog.mjs +558 -0
- package/src/core-isomorphic/catalog/index.mjs +1 -0
- package/src/core-isomorphic/coach/cacheGravityRouter.mjs +720 -0
- package/src/core-isomorphic/coach/microSkills.mjs +1 -0
- package/src/core-isomorphic/coach/promptHygieneGovernor.mjs +1 -0
- package/src/core-isomorphic/coach/repoCalibration.mjs +254 -0
- package/src/core-isomorphic/coach/savedQuotaLedger.mjs +527 -0
- package/src/core-isomorphic/coach/stateBatonHydrator.mjs +810 -0
- package/src/core-isomorphic/coach/ttlWatchdog.mjs +457 -0
- package/src/core-isomorphic/config/anthropicModelCatalog.json +203 -0
- package/src/core-isomorphic/config/catalogLoader.mjs +768 -0
- package/src/core-isomorphic/config/horizonConfig.mjs +1009 -0
- package/src/core-isomorphic/control/callTree.mjs +338 -0
- package/src/core-isomorphic/control/coachLatches.mjs +126 -0
- package/src/core-isomorphic/control/controlStateMachine.mjs +205 -0
- package/src/core-isomorphic/control/index.mjs +49 -0
- package/src/core-isomorphic/control/swarmWorktree.mjs +109 -0
- package/src/core-isomorphic/control/toolSuspension.mjs +197 -0
- package/src/core-isomorphic/diagnostics/drift_guard.mjs +382 -0
- package/src/core-isomorphic/diagnostics/index.mjs +9 -0
- package/src/core-isomorphic/diagnostics/micro_skills.mjs +471 -0
- package/src/core-isomorphic/diagnostics/prompt_hygiene_governor.mjs +622 -0
- package/src/core-isomorphic/economics/billingBlocks.mjs +251 -0
- package/src/core-isomorphic/economics/cacheGravity.mjs +351 -0
- package/src/core-isomorphic/economics/cliffBreaker.mjs +170 -0
- package/src/core-isomorphic/economics/driftLatency.mjs +319 -0
- package/src/core-isomorphic/economics/dualTtl.mjs +198 -0
- package/src/core-isomorphic/economics/index.mjs +47 -0
- package/src/core-isomorphic/economics/retentionRadar.mjs +348 -0
- package/src/core-isomorphic/guards/circuitBreakers.mjs +1202 -0
- package/src/core-isomorphic/guards/det01_03_shell_secret.mjs +1035 -0
- package/src/core-isomorphic/guards/det04_12_thrash_rot.mjs +480 -0
- package/src/core-isomorphic/guards/det13_20_mcp_scope.mjs +603 -0
- package/src/core-isomorphic/guards/losslessPostSanitizer.mjs +301 -0
- package/src/core-isomorphic/index.js +26 -0
- package/src/core-isomorphic/telemetry/otelExporter.mjs +187 -0
- package/src/core-isomorphic/telemetry/scopeLockRegistry.mjs +522 -0
- package/src/core-isomorphic/telemetry/sprintMetrics.mjs +327 -0
- package/src/core-isomorphic/telemetry/swarmTopology.mjs +152 -0
- package/src/core-isomorphic/telemetry/telemetryBridge.mjs +1132 -0
- package/src/core-isomorphic/ui/brailleSparkline.mjs +142 -0
- package/src/core-isomorphic/ui/costRadarSvg.mjs +276 -0
- package/src/core-isomorphic/ui/horizonGrid.mjs +475 -0
- package/src/core-isomorphic/ui/horizonPanelHtml.mjs +1181 -0
- package/src/core-isomorphic/ui/modViews.mjs +1478 -0
- package/src/core-isomorphic/ui/pdfReceiptGenerator.mjs +329 -0
- package/src/core-isomorphic/ustf/index.mjs +7 -0
- package/src/core-isomorphic/ustf/normalizer.mjs +512 -0
- package/src/core-isomorphic/ustf/schema.mjs +186 -0
- package/src/core-isomorphic/utils/runtime.mjs +962 -0
- package/src/demo/synthetic_states.mjs +661 -0
- package/src/diagnostics/bugReportGenerator.mjs +253 -0
- package/src/diagnostics/doctorEngine.mjs +203 -0
- package/src/engine-node/db/index.mjs +58 -0
- package/src/engine-node/db/jsonl_fallback.mjs +184 -0
- package/src/engine-node/db/probe.mjs +110 -0
- package/src/engine-node/db/sqlite_wrapper.mjs +122 -0
- package/src/engine-node/index.mjs +9 -0
- package/src/engine-node/ipc/client.mjs +447 -0
- package/src/engine-node/ipc/index.mjs +22 -0
- package/src/engine-node/ipc/protocol.mjs +177 -0
- package/src/engine-node/ipc/server.mjs +445 -0
- package/src/engine-node/offloader/index.mjs +6 -0
- package/src/engine-node/offloader/tool_offloader.mjs +241 -0
- package/src/engine-node/sensors/blindspots.mjs +369 -0
- package/src/engine-node/sensors/git_merge_tree.mjs +223 -0
- package/src/engine-node/sensors/index.mjs +7 -0
- package/src/hooks/portfolio_runtime.mjs +858 -0
- package/src/hooks/post_invocation.mjs +419 -0
- package/src/hooks/pre_invocation.mjs +1015 -0
- package/src/hooks/session_start.mjs +161 -0
- package/src/shims/agy_cli_compressor.mjs +705 -0
- package/src/shims/agy_git_guard.mjs +749 -0
- package/src/shims/ah_log_query.mjs +39 -0
- package/src/ui/costRadarSvg.mjs +6 -0
- package/src/ui/horizonGrid.mjs +1 -0
- package/src/ui/horizonPanelHtml.mjs +1 -0
- package/src/ui/horizon_panel.css +167 -0
- package/src/ui/horizon_panel.js +212 -0
- package/src/ui/modViews.mjs +1 -0
- package/src/utils/nodeIo.mjs +59 -0
- package/src/utils/runtime.mjs +1 -0
- package/src/webview/advanced_view.html +1808 -0
- package/src/webview/horizon_panel.html +11389 -0
- package/src/webview/registry.mjs +80 -0
- package/src/webview/simple_view.html +1370 -0
|
@@ -0,0 +1,966 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { canonicalizePath } from './paths.mjs';
|
|
4
|
+
import { atomicWriteFileSync } from './atomic_io.mjs';
|
|
5
|
+
import { PrefixCacheShield, isWarmCacheState } from './prefix_cache_shield.mjs';
|
|
6
|
+
|
|
7
|
+
export function buildTrustedPluginHookCommand(hookFileName) {
|
|
8
|
+
const safeHook = path.posix.basename(String(hookFileName || ''));
|
|
9
|
+
return `node --no-warnings -e "import('node:fs').then(fs=>import('node:os').then(os=>import('node:path').then(p=>{const f1=p.join(os.homedir(),'.gemini/config/plugins/agy-horizon-flightcheck/src/hooks/${safeHook}');const f2=p.join(os.homedir(),'.gemini/config/plugins/agy-horizon/src/hooks/${safeHook}');const target=fs.existsSync(f1)?f1:(fs.existsSync(f2)?f2:'');if(target)import(process.platform==='win32'?'file:///'+target.replace(/\\\\/g,'/'):target);})));"`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Epoch-Aware File Re-Read Classifier, Fail-Open CLI Output Dampener,
|
|
14
|
+
* and Positional Rule Promotion.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const CORTEX_STEP_TYPE_CHECKPOINT = 23;
|
|
18
|
+
export const MEMORY_MD_TRUNCATION_THRESHOLD_LINES = 200;
|
|
19
|
+
export const SWARM_TOOL_MATCHER = 'invoke_subagent|define_subagent|send_message|manage_subagents';
|
|
20
|
+
export const FULL_TOOL_HOOK_MATCHER =
|
|
21
|
+
'run_command|edit_file|write_file|write_to_file|replace_file_content|multi_replace_file_content|read_file|view_file|grep_search|find_by_name|list_dir|invoke_subagent|define_subagent|send_message|manage_subagents|swarm';
|
|
22
|
+
export const LEAN_PRE_TOOL_HOOK_MATCHER =
|
|
23
|
+
'run_command|edit_file|write_file|write_to_file|replace_file_content|multi_replace_file_content|read_file|view_file|invoke_subagent|define_subagent|send_message|manage_subagents|swarm';
|
|
24
|
+
export const LEAN_POST_TOOL_HOOK_MATCHER =
|
|
25
|
+
'run_command|edit_file|write_file|write_to_file|replace_file_content|multi_replace_file_content|invoke_subagent|define_subagent|send_message|manage_subagents|swarm';
|
|
26
|
+
export const ULTRA_LEAN_PRE_TOOL_HOOK_MATCHER = LEAN_POST_TOOL_HOOK_MATCHER;
|
|
27
|
+
export const CLI_DAMPENER_MATCHER = 'run_command|execute_bash|bash|Bash|PowerShell';
|
|
28
|
+
export const FLAT_LIFECYCLE_EVENTS = Object.freeze(['SessionStart', 'PreInvocation', 'PostInvocation', 'Stop']);
|
|
29
|
+
|
|
30
|
+
const READ_TOOLS = new Set([
|
|
31
|
+
'view_file',
|
|
32
|
+
'read_file',
|
|
33
|
+
'view_file_outline',
|
|
34
|
+
'view_code_item',
|
|
35
|
+
'read',
|
|
36
|
+
'read_file_v2'
|
|
37
|
+
]);
|
|
38
|
+
|
|
39
|
+
const EDIT_TOOLS = new Set([
|
|
40
|
+
'replace_file_content',
|
|
41
|
+
'multi_replace_file_content',
|
|
42
|
+
'write_to_file',
|
|
43
|
+
'write_file',
|
|
44
|
+
'edit_file',
|
|
45
|
+
'edit',
|
|
46
|
+
'multiedit',
|
|
47
|
+
'multi_edit',
|
|
48
|
+
'write',
|
|
49
|
+
'notebookedit',
|
|
50
|
+
'edit_file_v2'
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Determines whether a parsed step or stepEvent represents a Cortex compaction checkpoint
|
|
55
|
+
* (`CORTEX_STEP_TYPE_CHECKPOINT = 23`).
|
|
56
|
+
*/
|
|
57
|
+
export function isCompactionCheckpointStep(step) {
|
|
58
|
+
if (!step || typeof step !== 'object') return false;
|
|
59
|
+
// If the step is a tool call/result reading or discussing files, it is NOT a compaction checkpoint
|
|
60
|
+
const t = String(step.type || '').toUpperCase();
|
|
61
|
+
if (t === 'TOOL_CALL' || t === 'TOOL_RESULT' || t === 'TOOL_OUTPUT') return false;
|
|
62
|
+
if (Array.isArray(step.toolCalls) && step.toolCalls.length > 0 && !step.content) return false;
|
|
63
|
+
const st = step.step_type ?? step.stepType;
|
|
64
|
+
return (
|
|
65
|
+
t === 'CHECKPOINT' ||
|
|
66
|
+
t === 'CORTEX_STEP_TYPE_CHECKPOINT' ||
|
|
67
|
+
Number(st) === CORTEX_STEP_TYPE_CHECKPOINT ||
|
|
68
|
+
st === 'CORTEX_STEP_TYPE_CHECKPOINT'
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Smart File Re-Read Classifier.
|
|
74
|
+
*
|
|
75
|
+
* Inspects transcript steps between consecutive `view_file` / `read_file` calls for the same file path.
|
|
76
|
+
* Does NOT classify a repeat read as waste if:
|
|
77
|
+
* 1. A compaction step (`CORTEX_STEP_TYPE_CHECKPOINT = 23`) occurred between reads (in-memory buffer was wiped).
|
|
78
|
+
* 2. An edit tool (`replace_file_content`, `write_to_file`, `edit_file`, `write_file`) was invoked on that file between reads.
|
|
79
|
+
* 3. A build/test tool (`run_command`) executed between reads.
|
|
80
|
+
*
|
|
81
|
+
* Only classifies as waste if the file was read multiple times in an unmodified state
|
|
82
|
+
* within the same continuous context epoch.
|
|
83
|
+
*/
|
|
84
|
+
export function evaluateSmartFileReReads(steps = []) {
|
|
85
|
+
const stepMeta = [];
|
|
86
|
+
const readsByPath = new Map(); // canonicalPath -> Array<{ idx, rawPath, callOrder }>
|
|
87
|
+
const latestTouchByPath = new Map();
|
|
88
|
+
|
|
89
|
+
for (let idx = 0; idx < steps.length; idx++) {
|
|
90
|
+
const step = steps[idx] || {};
|
|
91
|
+
const isCheckpoint = isCompactionCheckpointStep(step);
|
|
92
|
+
let hasRunCommand = false;
|
|
93
|
+
const editedCanonPaths = new Set();
|
|
94
|
+
const readEntries = [];
|
|
95
|
+
|
|
96
|
+
const calls = Array.isArray(step.toolCalls)
|
|
97
|
+
? step.toolCalls
|
|
98
|
+
: (Array.isArray(step.tool_calls) ? step.tool_calls : []);
|
|
99
|
+
|
|
100
|
+
if (calls.length > 0) {
|
|
101
|
+
for (let cIdx = 0; cIdx < calls.length; cIdx++) {
|
|
102
|
+
const call = calls[cIdx] || {};
|
|
103
|
+
const name = String(call.name || call.tool || '').toLowerCase();
|
|
104
|
+
const args = call.args || call.parameters || call.Arguments || call.input || {};
|
|
105
|
+
const targetFile = args.Path || args.path || args.file_path || args.target_file || args.notebook_path || args.Target || args.target || args.TargetFile || args.AbsolutePath || args.uri;
|
|
106
|
+
|
|
107
|
+
if (name === 'run_command' || name === 'bash' || name === 'run_terminal_cmd') {
|
|
108
|
+
hasRunCommand = true;
|
|
109
|
+
}
|
|
110
|
+
if (targetFile && typeof targetFile === 'string') {
|
|
111
|
+
const normalizedTarget = targetFile.replace(/\\/g, '/');
|
|
112
|
+
if (/\.system_generated(\/|$)|(^|\/)steps\/\d+\/output\.txt$/i.test(normalizedTarget)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const canon = canonicalizePath(targetFile);
|
|
116
|
+
latestTouchByPath.set(canon, idx);
|
|
117
|
+
if (READ_TOOLS.has(name)) {
|
|
118
|
+
const startLine = Number(args.StartLine ?? args.start_line ?? args.startLine ?? args.offset);
|
|
119
|
+
const endLine = Number(args.EndLine ?? args.end_line ?? args.endLine ?? args.limit);
|
|
120
|
+
const hasLineRange = Number.isInteger(startLine) && startLine > 0;
|
|
121
|
+
const readObj = {
|
|
122
|
+
canon,
|
|
123
|
+
rawPath: targetFile,
|
|
124
|
+
callOrder: cIdx,
|
|
125
|
+
startLine: hasLineRange ? startLine : null,
|
|
126
|
+
endLine: Number.isInteger(endLine) && endLine > 0 ? endLine : null,
|
|
127
|
+
hasLineRange
|
|
128
|
+
};
|
|
129
|
+
readEntries.push(readObj);
|
|
130
|
+
if (!readsByPath.has(canon)) readsByPath.set(canon, []);
|
|
131
|
+
readsByPath.get(canon).push({ idx, ...readObj });
|
|
132
|
+
} else if (EDIT_TOOLS.has(name)) {
|
|
133
|
+
editedCanonPaths.add(canon);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
} else if (step.toolName || step.type === 'COMMAND') {
|
|
138
|
+
const name = String(step.toolName || '').toLowerCase();
|
|
139
|
+
if (name === 'run_command' || name === 'bash' || name === 'run_terminal_cmd' || step.type === 'COMMAND') {
|
|
140
|
+
hasRunCommand = true;
|
|
141
|
+
}
|
|
142
|
+
if (step.targetPath && typeof step.targetPath === 'string') {
|
|
143
|
+
const canon = canonicalizePath(step.targetPath);
|
|
144
|
+
latestTouchByPath.set(canon, idx);
|
|
145
|
+
if (READ_TOOLS.has(name)) {
|
|
146
|
+
readEntries.push({ canon, rawPath: step.targetPath, callOrder: 0 });
|
|
147
|
+
if (!readsByPath.has(canon)) readsByPath.set(canon, []);
|
|
148
|
+
readsByPath.get(canon).push({ idx, rawPath: step.targetPath, callOrder: 0 });
|
|
149
|
+
} else if (EDIT_TOOLS.has(name)) {
|
|
150
|
+
editedCanonPaths.add(canon);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
stepMeta.push({
|
|
156
|
+
idx,
|
|
157
|
+
isCheckpoint,
|
|
158
|
+
hasRunCommand,
|
|
159
|
+
editedCanonPaths,
|
|
160
|
+
readEntries
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const wasteTargetByStep = new Map(); // stepIdx -> rawPath
|
|
165
|
+
const wasteCanonPaths = new Set();
|
|
166
|
+
const exemptedReReads = [];
|
|
167
|
+
|
|
168
|
+
for (const [canon, readList] of readsByPath.entries()) {
|
|
169
|
+
if (readList.length < 2) continue;
|
|
170
|
+
|
|
171
|
+
for (let j = 0; j < readList.length - 1; j++) {
|
|
172
|
+
const first = readList[j];
|
|
173
|
+
const second = readList[j + 1];
|
|
174
|
+
|
|
175
|
+
let hasCheckpointBetween = false;
|
|
176
|
+
let hasFileEditBetween = false;
|
|
177
|
+
let hasRunCommandBetween = false;
|
|
178
|
+
|
|
179
|
+
for (let k = first.idx + 1; k < second.idx; k++) {
|
|
180
|
+
const m = stepMeta[k];
|
|
181
|
+
if (!m) continue;
|
|
182
|
+
if (m.isCheckpoint) hasCheckpointBetween = true;
|
|
183
|
+
if (m.editedCanonPaths.has(canon)) hasFileEditBetween = true;
|
|
184
|
+
if (m.hasRunCommand) hasRunCommandBetween = true;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Also check if the same turn had an edit or run_command between the two reads
|
|
188
|
+
if (first.idx === second.idx) {
|
|
189
|
+
const m = stepMeta[first.idx];
|
|
190
|
+
if (m?.editedCanonPaths.has(canon)) hasFileEditBetween = true;
|
|
191
|
+
if (m?.hasRunCommand) hasRunCommandBetween = true;
|
|
192
|
+
} else {
|
|
193
|
+
const mFirst = stepMeta[first.idx];
|
|
194
|
+
const mSecond = stepMeta[second.idx];
|
|
195
|
+
if (mFirst?.editedCanonPaths.has(canon) || mSecond?.editedCanonPaths.has(canon)) {
|
|
196
|
+
hasFileEditBetween = true;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const areDisjointRanges = Boolean(
|
|
201
|
+
first.hasLineRange && second.hasLineRange &&
|
|
202
|
+
(first.startLine !== second.startLine || first.endLine !== second.endLine)
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const exemptionReason = hasCheckpointBetween
|
|
206
|
+
? 'CHECKPOINT'
|
|
207
|
+
: (hasFileEditBetween
|
|
208
|
+
? 'FILE_EDIT'
|
|
209
|
+
: (hasRunCommandBetween
|
|
210
|
+
? 'RUN_COMMAND'
|
|
211
|
+
: (areDisjointRanges ? 'DISJOINT_LINE_RANGE' : null)));
|
|
212
|
+
|
|
213
|
+
if (exemptionReason) {
|
|
214
|
+
exemptedReReads.push({
|
|
215
|
+
path: second.rawPath || first.rawPath,
|
|
216
|
+
canonicalPath: canon,
|
|
217
|
+
firstStepIndex: first.idx,
|
|
218
|
+
secondStepIndex: second.idx,
|
|
219
|
+
reason: exemptionReason
|
|
220
|
+
});
|
|
221
|
+
} else {
|
|
222
|
+
wasteTargetByStep.set(first.idx, first.rawPath);
|
|
223
|
+
wasteCanonPaths.add(canon);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
wasteTargetByStep,
|
|
230
|
+
wasteCanonPaths,
|
|
231
|
+
exemptedReReads,
|
|
232
|
+
latestTouchByPath,
|
|
233
|
+
readsByPath
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Wraps a noisy CLI command in a fail-open stdout dampener (`head -n 100` + log redirect)
|
|
239
|
+
* to prevent accidental 20k+ token single-turn bloat.
|
|
240
|
+
*/
|
|
241
|
+
export function wrapNoisyCommandWithDampener(commandLine, {
|
|
242
|
+
maxLines = 100,
|
|
243
|
+
logFile = '.agents/tmp/cli_stdout.log',
|
|
244
|
+
platform = process.platform
|
|
245
|
+
} = {}) {
|
|
246
|
+
const cleanCmd = String(commandLine || '').trim();
|
|
247
|
+
if (!cleanCmd) return '';
|
|
248
|
+
const limit = Math.max(10, Number(maxLines) || 100);
|
|
249
|
+
if (
|
|
250
|
+
cleanCmd.includes('head -n') ||
|
|
251
|
+
cleanCmd.includes('Select-Object -First') ||
|
|
252
|
+
cleanCmd.includes('Tee-Object') ||
|
|
253
|
+
cleanCmd.includes(logFile)
|
|
254
|
+
) {
|
|
255
|
+
return cleanCmd;
|
|
256
|
+
}
|
|
257
|
+
if (platform === 'win32') {
|
|
258
|
+
return `& { ${cleanCmd} } *>&1 | Tee-Object -FilePath "${logFile}" | Select-Object -First ${limit}; $LASTEXITCODE = 0`;
|
|
259
|
+
}
|
|
260
|
+
return `(${cleanCmd}) 2>&1 | tee "${logFile}" | head -n ${limit} || true`;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Registers a fail-open PreToolUse CLI command dampening hook in `.agents/hooks.json`.
|
|
265
|
+
* Wraps noisy commands in PowerShell `Tee-Object | Select-Object -First` on Windows or POSIX `tee | head -n`.
|
|
266
|
+
*/
|
|
267
|
+
export function registerCliDampeningHook(workspacePath, {
|
|
268
|
+
command = '',
|
|
269
|
+
maxLines = 100,
|
|
270
|
+
logFile = '.agents/tmp/cli_stdout.log',
|
|
271
|
+
platform = process.platform,
|
|
272
|
+
writeToDisk = true
|
|
273
|
+
} = {}) {
|
|
274
|
+
const wsRoot = workspacePath || process.cwd();
|
|
275
|
+
const hooksJsonPath = path.join(wsRoot, '.agents', 'hooks.json');
|
|
276
|
+
const limit = Math.max(10, Number(maxLines) || 100);
|
|
277
|
+
const isWin = platform === 'win32';
|
|
278
|
+
|
|
279
|
+
let existing = {};
|
|
280
|
+
if (fs.existsSync(hooksJsonPath)) {
|
|
281
|
+
try {
|
|
282
|
+
existing = JSON.parse(fs.readFileSync(hooksJsonPath, 'utf8'));
|
|
283
|
+
} catch {
|
|
284
|
+
existing = {};
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (!existing || typeof existing !== 'object' || Array.isArray(existing)) {
|
|
288
|
+
existing = {};
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const preToolList = Array.isArray(existing.PreToolUse)
|
|
292
|
+
? [...existing.PreToolUse]
|
|
293
|
+
: (Array.isArray(existing.hooks?.PreToolUse) ? [...existing.hooks.PreToolUse] : []);
|
|
294
|
+
|
|
295
|
+
const wrappedExample = wrapNoisyCommandWithDampener(command || 'npm test', {
|
|
296
|
+
maxLines: limit,
|
|
297
|
+
logFile,
|
|
298
|
+
platform
|
|
299
|
+
});
|
|
300
|
+
const inlineGuardScript = [
|
|
301
|
+
`let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>{`,
|
|
302
|
+
`try{const j=JSON.parse(d||'{}');const cmd=String(j.tool_input?.CommandLine||j.tool_input?.command||j.CommandLine||'');`,
|
|
303
|
+
`if(cmd&&cmd.length>0&&!cmd.includes('head -n')&&!cmd.includes('Select-Object')){`,
|
|
304
|
+
`process.stdout.write(JSON.stringify({systemMessage:'[CLI Output Dampener] Pipe large command output through head -n ${limit} (or Select-Object -First ${limit} on PowerShell) or redirect to ${logFile} to prevent >20k single-turn context bloat.'}));`,
|
|
305
|
+
`}}catch{}process.exit(0);});`
|
|
306
|
+
].join('');
|
|
307
|
+
const wrappedCommandTemplate = isWin
|
|
308
|
+
? `& { <command> } *>&1 | Tee-Object -FilePath "${logFile}" | Select-Object -First ${limit}; $LASTEXITCODE = 0`
|
|
309
|
+
: `(<command>) 2>&1 | tee "${logFile}" | head -n ${limit} || true`;
|
|
310
|
+
const hookEntry = {
|
|
311
|
+
id: 'horizon-cli-dampener',
|
|
312
|
+
event: 'PreToolUse',
|
|
313
|
+
matcher: CLI_DAMPENER_MATCHER,
|
|
314
|
+
failOpen: true,
|
|
315
|
+
maxLines: limit,
|
|
316
|
+
logFile,
|
|
317
|
+
platform,
|
|
318
|
+
wrapperStrategy: isWin
|
|
319
|
+
? `Tee-Object -FilePath "${logFile}" | Select-Object -First ${limit}`
|
|
320
|
+
: `tee "${logFile}" | head -n ${limit}`,
|
|
321
|
+
targetCommandPattern: String(command || '*').slice(0, 160),
|
|
322
|
+
command: `node -e "${inlineGuardScript.replace(/"/g, '\\"')}"`,
|
|
323
|
+
wrappedCommandTemplate,
|
|
324
|
+
description: `Fail-open PreToolUse wrapper: caps noisy CLI stdout via ${isWin ? 'Select-Object -First' : 'head -n'} ${limit} or pipes full output to ${logFile} to prevent 20k+ single-turn bloat.`,
|
|
325
|
+
updatedAt: new Date().toISOString()
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const existingIdx = preToolList.findIndex(
|
|
329
|
+
h => h && (h.id === 'horizon-cli-dampener' || h.matcher === 'run_command' || h.matcher === CLI_DAMPENER_MATCHER)
|
|
330
|
+
);
|
|
331
|
+
if (existingIdx >= 0) {
|
|
332
|
+
preToolList[existingIdx] = { ...preToolList[existingIdx], ...hookEntry };
|
|
333
|
+
} else {
|
|
334
|
+
preToolList.push(hookEntry);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const swarmPreIdx = preToolList.findIndex(h => h && (h.id === 'horizon-swarm-pre-tool' || h.matcher === SWARM_TOOL_MATCHER));
|
|
338
|
+
const swarmPreEntry = {
|
|
339
|
+
id: 'horizon-swarm-pre-tool',
|
|
340
|
+
event: 'PreToolUse',
|
|
341
|
+
matcher: SWARM_TOOL_MATCHER,
|
|
342
|
+
type: 'command',
|
|
343
|
+
command: buildTrustedPluginHookCommand('pre_invocation.mjs'),
|
|
344
|
+
timeout: 5
|
|
345
|
+
};
|
|
346
|
+
if (swarmPreIdx >= 0) {
|
|
347
|
+
preToolList[swarmPreIdx] = { ...preToolList[swarmPreIdx], ...swarmPreEntry };
|
|
348
|
+
} else {
|
|
349
|
+
preToolList.push(swarmPreEntry);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const postToolList = Array.isArray(existing.PostToolUse)
|
|
353
|
+
? [...existing.PostToolUse]
|
|
354
|
+
: (Array.isArray(existing.hooks?.PostToolUse) ? [...existing.hooks.PostToolUse] : []);
|
|
355
|
+
const swarmPostIdx = postToolList.findIndex(h => h && (h.id === 'horizon-swarm-post-tool' || h.matcher === SWARM_TOOL_MATCHER));
|
|
356
|
+
const swarmPostEntry = {
|
|
357
|
+
id: 'horizon-swarm-post-tool',
|
|
358
|
+
event: 'PostToolUse',
|
|
359
|
+
matcher: SWARM_TOOL_MATCHER,
|
|
360
|
+
type: 'command',
|
|
361
|
+
command: buildTrustedPluginHookCommand('post_invocation.mjs'),
|
|
362
|
+
timeout: 5
|
|
363
|
+
};
|
|
364
|
+
if (swarmPostIdx >= 0) {
|
|
365
|
+
postToolList[swarmPostIdx] = { ...postToolList[swarmPostIdx], ...swarmPostEntry };
|
|
366
|
+
} else {
|
|
367
|
+
postToolList.push(swarmPostEntry);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const nextHooksConfig = {
|
|
371
|
+
...existing,
|
|
372
|
+
PreToolUse: preToolList,
|
|
373
|
+
PostToolUse: postToolList,
|
|
374
|
+
hooks: {
|
|
375
|
+
...(existing.hooks && typeof existing.hooks === 'object' ? existing.hooks : {}),
|
|
376
|
+
PreToolUse: preToolList,
|
|
377
|
+
PostToolUse: postToolList
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
let written = false;
|
|
382
|
+
if (writeToDisk) {
|
|
383
|
+
try {
|
|
384
|
+
atomicWriteFileSync(hooksJsonPath, JSON.stringify(nextHooksConfig, null, 2) + '\n', { encoding: 'utf8' });
|
|
385
|
+
written = true;
|
|
386
|
+
} catch (err) {
|
|
387
|
+
return {
|
|
388
|
+
success: false,
|
|
389
|
+
error: String(err?.message || err),
|
|
390
|
+
hooksPath: hooksJsonPath
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return {
|
|
396
|
+
success: true,
|
|
397
|
+
written,
|
|
398
|
+
hooksPath: hooksJsonPath,
|
|
399
|
+
hookEntry,
|
|
400
|
+
wrappedExample,
|
|
401
|
+
hooksConfig: nextHooksConfig
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Computes a line insertion index strictly within the top 30% (Primacy zone)
|
|
407
|
+
* or bottom 30% (Recency zone) of a document, avoiding the 30%-70% Low-Attention Trough.
|
|
408
|
+
*/
|
|
409
|
+
export function computeAttentionZoneInsertionIndex(lines = [], zone = 'primacy') {
|
|
410
|
+
const total = Array.isArray(lines) ? lines.length : Number(lines) || 0;
|
|
411
|
+
const normalizedZone = String(zone || 'primacy').toLowerCase() === 'recency' ? 'recency' : 'primacy';
|
|
412
|
+
|
|
413
|
+
if (total <= 3) {
|
|
414
|
+
return normalizedZone === 'primacy' ? (total <= 2 ? 0 : 1) : total;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
if (normalizedZone === 'primacy') {
|
|
418
|
+
const maxPrimacyLine = Math.max(1, Math.floor(total * 0.25));
|
|
419
|
+
// Prefer inserting right after the first markdown heading or blank line within the top 25%
|
|
420
|
+
if (Array.isArray(lines)) {
|
|
421
|
+
for (let i = 0; i <= maxPrimacyLine; i++) {
|
|
422
|
+
if (/^#\s+/.test(lines[i])) {
|
|
423
|
+
return Math.min(maxPrimacyLine, i + 1);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return Math.min(maxPrimacyLine, Math.max(1, Math.floor(total * 0.15)));
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
// Recency zone: strictly within bottom 30% (>= ceil(total * 0.75))
|
|
431
|
+
const minRecencyLine = Math.ceil(total * 0.75);
|
|
432
|
+
return Math.max(minRecencyLine, total);
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Audits workspace rule files (`AGENTS.md`, `.agents/CONTEXT.md`, `MEMORY.md`) against
|
|
437
|
+
* Antigravity's 200-line `MEMORY.md` truncation threshold.
|
|
438
|
+
*/
|
|
439
|
+
export function auditRuleFileAttentionAndLineLimit(workspacePath, {
|
|
440
|
+
maxLines = MEMORY_MD_TRUNCATION_THRESHOLD_LINES
|
|
441
|
+
} = {}) {
|
|
442
|
+
const wsRoot = workspacePath || process.cwd();
|
|
443
|
+
const candidates = [
|
|
444
|
+
{ label: '.agents/CONTEXT.md', path: path.join(wsRoot, '.agents', 'CONTEXT.md') },
|
|
445
|
+
{ label: 'AGENTS.md', path: path.join(wsRoot, 'AGENTS.md') },
|
|
446
|
+
{ label: 'MEMORY.md', path: path.join(wsRoot, 'MEMORY.md') }
|
|
447
|
+
];
|
|
448
|
+
|
|
449
|
+
const files = [];
|
|
450
|
+
let maxFileLines = 0;
|
|
451
|
+
let primaryTargetPath = path.join(wsRoot, 'AGENTS.md');
|
|
452
|
+
|
|
453
|
+
for (const c of candidates) {
|
|
454
|
+
if (fs.existsSync(c.path)) {
|
|
455
|
+
try {
|
|
456
|
+
const text = fs.readFileSync(c.path, 'utf8');
|
|
457
|
+
const lineCount = text.split(/\r?\n/).length;
|
|
458
|
+
if (lineCount > maxFileLines) maxFileLines = lineCount;
|
|
459
|
+
if (c.label === '.agents/CONTEXT.md' || c.label === 'AGENTS.md') {
|
|
460
|
+
primaryTargetPath = c.path;
|
|
461
|
+
}
|
|
462
|
+
files.push({
|
|
463
|
+
label: c.label,
|
|
464
|
+
path: c.path,
|
|
465
|
+
lineCount,
|
|
466
|
+
exceedsLimit: lineCount > maxLines,
|
|
467
|
+
nearLimit: lineCount >= Math.round(maxLines * 0.85)
|
|
468
|
+
});
|
|
469
|
+
} catch {}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const exceeds200LineThreshold = files.some(f => f.exceedsLimit);
|
|
474
|
+
const near200LineThreshold = files.some(f => f.nearLimit);
|
|
475
|
+
const truncationWarning = exceeds200LineThreshold
|
|
476
|
+
? `Rule file (${maxFileLines} lines) exceeds Antigravity's ${maxLines}-line MEMORY.md truncation threshold. Insert critical rules in the Primacy zone (top 30%) or offload domain rules to .agents/skills/.`
|
|
477
|
+
: (near200LineThreshold
|
|
478
|
+
? `Rule file (${maxFileLines}/${maxLines} lines) is approaching Antigravity's ${maxLines}-line MEMORY.md truncation threshold.`
|
|
479
|
+
: '');
|
|
480
|
+
|
|
481
|
+
return {
|
|
482
|
+
thresholdLines: maxLines,
|
|
483
|
+
maxFileLines,
|
|
484
|
+
primaryTargetPath,
|
|
485
|
+
exceeds200LineThreshold,
|
|
486
|
+
near200LineThreshold,
|
|
487
|
+
truncationWarning,
|
|
488
|
+
files
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Promotes an Unlogged User Correction into `.agents/CONTEXT.md` or `AGENTS.md`
|
|
494
|
+
* strictly within the top 30% (Primacy zone) or bottom 30% (Recency zone),
|
|
495
|
+
* and checks total line count against Antigravity's 200-line `MEMORY.md` truncation threshold.
|
|
496
|
+
*/
|
|
497
|
+
export function promoteRuleWithAttentionZone(targetFileOrWorkspace, ruleText, {
|
|
498
|
+
zone = 'primacy',
|
|
499
|
+
targetFileName = null,
|
|
500
|
+
maxLines = MEMORY_MD_TRUNCATION_THRESHOLD_LINES,
|
|
501
|
+
writeToDisk = true,
|
|
502
|
+
session = null,
|
|
503
|
+
cacheState = null,
|
|
504
|
+
cacheWarm = false,
|
|
505
|
+
cachedTokens = 0,
|
|
506
|
+
cacheTtlSeconds = 0,
|
|
507
|
+
forceColdBust = false,
|
|
508
|
+
prefixCacheShield = null,
|
|
509
|
+
homeDir = undefined
|
|
510
|
+
} = {}) {
|
|
511
|
+
const cleanRule = String(ruleText || '').replace(/<\/?USER_REQUEST>/gi, '').trim();
|
|
512
|
+
if (!cleanRule) {
|
|
513
|
+
return { success: false, error: 'Rule text cannot be empty' };
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
let resolvedPath = targetFileOrWorkspace || path.join(process.cwd(), 'AGENTS.md');
|
|
517
|
+
try {
|
|
518
|
+
if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isDirectory()) {
|
|
519
|
+
const contextMd = path.join(resolvedPath, '.agents', 'CONTEXT.md');
|
|
520
|
+
const agentsMd = path.join(resolvedPath, 'AGENTS.md');
|
|
521
|
+
if (targetFileName) {
|
|
522
|
+
resolvedPath = path.join(resolvedPath, targetFileName);
|
|
523
|
+
} else if (fs.existsSync(contextMd)) {
|
|
524
|
+
resolvedPath = contextMd;
|
|
525
|
+
} else {
|
|
526
|
+
resolvedPath = agentsMd;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
} catch {}
|
|
530
|
+
|
|
531
|
+
let existingContent = '';
|
|
532
|
+
if (fs.existsSync(resolvedPath)) {
|
|
533
|
+
try {
|
|
534
|
+
existingContent = fs.readFileSync(resolvedPath, 'utf8');
|
|
535
|
+
} catch {}
|
|
536
|
+
} else {
|
|
537
|
+
existingContent = [
|
|
538
|
+
'# Project Context & Agent Rules',
|
|
539
|
+
'',
|
|
540
|
+
'## Primacy Directives (Top 30% High-Attention Zone)',
|
|
541
|
+
'',
|
|
542
|
+
'## Architecture & Workflow Notes',
|
|
543
|
+
'- Maintain strict module boundaries.',
|
|
544
|
+
'- Keep tests deterministic and isolated.',
|
|
545
|
+
'- Validate inputs at system boundaries.',
|
|
546
|
+
'- Avoid unnecessary dependencies.',
|
|
547
|
+
'- Preserve existing comments and documentation.',
|
|
548
|
+
'',
|
|
549
|
+
'## Recency Directives (Bottom 30% High-Attention Zone)'
|
|
550
|
+
].join('\n');
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
const lines = existingContent.split(/\r?\n/);
|
|
554
|
+
const totalLinesBefore = lines.length;
|
|
555
|
+
const requestedZone = String(zone || 'primacy').toLowerCase() === 'recency' ? 'recency' : 'primacy';
|
|
556
|
+
|
|
557
|
+
// If the file already exceeds the 200-line MEMORY.md truncation threshold and recency was requested,
|
|
558
|
+
// warn that lines past 200 risk truncation!
|
|
559
|
+
const formattedBullet = cleanRule.startsWith('-') || cleanRule.startsWith('*')
|
|
560
|
+
? cleanRule
|
|
561
|
+
: `- **User Constraint**: ${cleanRule}`;
|
|
562
|
+
|
|
563
|
+
const insertIdx = computeAttentionZoneInsertionIndex(lines, requestedZone);
|
|
564
|
+
const updatedLines = [
|
|
565
|
+
...lines.slice(0, insertIdx),
|
|
566
|
+
formattedBullet,
|
|
567
|
+
...lines.slice(insertIdx)
|
|
568
|
+
];
|
|
569
|
+
|
|
570
|
+
const totalLinesAfter = updatedLines.length;
|
|
571
|
+
const normalizedPosition = totalLinesAfter > 1
|
|
572
|
+
? parseFloat((insertIdx / totalLinesAfter).toFixed(3))
|
|
573
|
+
: (requestedZone === 'primacy' ? 0.0 : 1.0);
|
|
574
|
+
|
|
575
|
+
const inPrimacyZone = normalizedPosition <= 0.30;
|
|
576
|
+
const inRecencyZone = normalizedPosition >= 0.70;
|
|
577
|
+
const exceeds200LineThreshold = totalLinesAfter > maxLines;
|
|
578
|
+
const near200LineThreshold = totalLinesAfter >= Math.round(maxLines * 0.85);
|
|
579
|
+
|
|
580
|
+
const truncationWarning = exceeds200LineThreshold
|
|
581
|
+
? `Total length (${totalLinesAfter} lines) exceeds Antigravity's ${maxLines}-line MEMORY.md truncation threshold. Lines past ${maxLines} may be truncated; keep critical rules in the Primacy zone (top 30%).`
|
|
582
|
+
: (near200LineThreshold
|
|
583
|
+
? `Total length (${totalLinesAfter}/${maxLines} lines) is approaching Antigravity's ${maxLines}-line MEMORY.md truncation threshold.`
|
|
584
|
+
: '');
|
|
585
|
+
|
|
586
|
+
const updatedContent = updatedLines.join('\n');
|
|
587
|
+
const resolvedSession = session || {
|
|
588
|
+
cacheState,
|
|
589
|
+
cacheWarm,
|
|
590
|
+
cachedTokens,
|
|
591
|
+
cacheTtlSeconds,
|
|
592
|
+
forceColdBust
|
|
593
|
+
};
|
|
594
|
+
const isWarmLocked = writeToDisk && !forceColdBust && isWarmCacheState(resolvedSession);
|
|
595
|
+
if (isWarmLocked) {
|
|
596
|
+
const shield = prefixCacheShield || new PrefixCacheShield({ homeDir });
|
|
597
|
+
const shieldResult = shield.stageOrApplyDelta(
|
|
598
|
+
{
|
|
599
|
+
targetPath: resolvedPath,
|
|
600
|
+
operation: 'REPLACE',
|
|
601
|
+
newContent: updatedContent,
|
|
602
|
+
ruleText: formattedBullet,
|
|
603
|
+
source: 'layer5-hygiene-promote'
|
|
604
|
+
},
|
|
605
|
+
resolvedSession
|
|
606
|
+
);
|
|
607
|
+
return {
|
|
608
|
+
success: true,
|
|
609
|
+
written: false,
|
|
610
|
+
staged: true,
|
|
611
|
+
deferred: true,
|
|
612
|
+
reason: 'CACHE_WARM_FENCE',
|
|
613
|
+
shieldResult,
|
|
614
|
+
targetPath: resolvedPath,
|
|
615
|
+
zoneUsed: requestedZone,
|
|
616
|
+
insertedAtLine: insertIdx + 1,
|
|
617
|
+
totalLinesBefore,
|
|
618
|
+
totalLinesAfter,
|
|
619
|
+
normalizedPosition,
|
|
620
|
+
inPrimacyZone,
|
|
621
|
+
inRecencyZone,
|
|
622
|
+
exceeds200LineThreshold,
|
|
623
|
+
near200LineThreshold,
|
|
624
|
+
truncationWarning,
|
|
625
|
+
formattedRule: formattedBullet,
|
|
626
|
+
content: updatedContent
|
|
627
|
+
};
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
let written = false;
|
|
631
|
+
if (writeToDisk) {
|
|
632
|
+
try {
|
|
633
|
+
atomicWriteFileSync(resolvedPath, updatedContent, { encoding: 'utf8' });
|
|
634
|
+
written = true;
|
|
635
|
+
} catch (err) {
|
|
636
|
+
return {
|
|
637
|
+
success: false,
|
|
638
|
+
error: String(err?.message || err),
|
|
639
|
+
targetPath: resolvedPath
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
return {
|
|
645
|
+
success: true,
|
|
646
|
+
written,
|
|
647
|
+
staged: false,
|
|
648
|
+
deferred: false,
|
|
649
|
+
targetPath: resolvedPath,
|
|
650
|
+
zoneUsed: requestedZone,
|
|
651
|
+
insertedAtLine: insertIdx + 1,
|
|
652
|
+
totalLinesBefore,
|
|
653
|
+
totalLinesAfter,
|
|
654
|
+
normalizedPosition,
|
|
655
|
+
inPrimacyZone,
|
|
656
|
+
inRecencyZone,
|
|
657
|
+
exceeds200LineThreshold,
|
|
658
|
+
near200LineThreshold,
|
|
659
|
+
truncationWarning,
|
|
660
|
+
formattedRule: formattedBullet,
|
|
661
|
+
content: updatedContent
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Updates `.antigravityignore` safely behind `PrefixCacheShield` when prompt cache is warm.
|
|
667
|
+
*/
|
|
668
|
+
export function updateAntigravityIgnore(workspaceOrIgnorePath, patterns = [], {
|
|
669
|
+
writeToDisk = true,
|
|
670
|
+
session = null,
|
|
671
|
+
cacheState = null,
|
|
672
|
+
cacheWarm = false,
|
|
673
|
+
cachedTokens = 0,
|
|
674
|
+
cacheTtlSeconds = 0,
|
|
675
|
+
forceColdBust = false,
|
|
676
|
+
prefixCacheShield = null,
|
|
677
|
+
homeDir = undefined
|
|
678
|
+
} = {}) {
|
|
679
|
+
const baseStr = String(workspaceOrIgnorePath || process.cwd());
|
|
680
|
+
const ignorePath = baseStr.endsWith('.antigravityignore')
|
|
681
|
+
? path.resolve(baseStr)
|
|
682
|
+
: path.join(path.resolve(baseStr), '.antigravityignore');
|
|
683
|
+
const existing = fs.existsSync(ignorePath) ? fs.readFileSync(ignorePath, 'utf8') : '';
|
|
684
|
+
const lines = existing ? existing.split(/\r?\n/) : [];
|
|
685
|
+
const existingSet = new Set(lines.map((l) => l.trim()).filter(Boolean));
|
|
686
|
+
const list = Array.isArray(patterns) ? patterns : [patterns];
|
|
687
|
+
const added = [];
|
|
688
|
+
for (const pat of list) {
|
|
689
|
+
const clean = String(pat || '').trim();
|
|
690
|
+
if (clean && !existingSet.has(clean)) {
|
|
691
|
+
lines.push(clean);
|
|
692
|
+
existingSet.add(clean);
|
|
693
|
+
added.push(clean);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
const updatedContent = lines.filter((l, idx) => idx < lines.length - 1 || l !== '').join('\n') + '\n';
|
|
697
|
+
const resolvedSession = session || {
|
|
698
|
+
cacheState,
|
|
699
|
+
cacheWarm,
|
|
700
|
+
cachedTokens,
|
|
701
|
+
cacheTtlSeconds,
|
|
702
|
+
forceColdBust
|
|
703
|
+
};
|
|
704
|
+
if (writeToDisk && !forceColdBust && isWarmCacheState(resolvedSession)) {
|
|
705
|
+
const shield = prefixCacheShield || new PrefixCacheShield({ homeDir });
|
|
706
|
+
const shieldResult = shield.stageOrApplyDelta(
|
|
707
|
+
{
|
|
708
|
+
targetPath: ignorePath,
|
|
709
|
+
operation: 'REPLACE',
|
|
710
|
+
newContent: updatedContent,
|
|
711
|
+
source: 'layer5-antigravityignore'
|
|
712
|
+
},
|
|
713
|
+
resolvedSession
|
|
714
|
+
);
|
|
715
|
+
return {
|
|
716
|
+
success: true,
|
|
717
|
+
written: false,
|
|
718
|
+
staged: true,
|
|
719
|
+
deferred: true,
|
|
720
|
+
reason: 'CACHE_WARM_FENCE',
|
|
721
|
+
targetPath: ignorePath,
|
|
722
|
+
addedPatterns: added,
|
|
723
|
+
shieldResult,
|
|
724
|
+
content: updatedContent
|
|
725
|
+
};
|
|
726
|
+
}
|
|
727
|
+
let written = false;
|
|
728
|
+
if (writeToDisk) {
|
|
729
|
+
atomicWriteFileSync(ignorePath, updatedContent, { encoding: 'utf8' });
|
|
730
|
+
written = true;
|
|
731
|
+
}
|
|
732
|
+
return {
|
|
733
|
+
success: true,
|
|
734
|
+
written,
|
|
735
|
+
staged: false,
|
|
736
|
+
deferred: false,
|
|
737
|
+
targetPath: ignorePath,
|
|
738
|
+
addedPatterns: added,
|
|
739
|
+
content: updatedContent
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Quantifies the exact "Context Re-Read Tax" whenever an unmodified file inspected before
|
|
745
|
+
* a `compact_boundary` / `CORTEX_STEP_TYPE_CHECKPOINT` / `prompt-suggestion-compact` is re-read after compaction.
|
|
746
|
+
*/
|
|
747
|
+
export function evaluatePostCompactionReReadTax(rawSteps = []) {
|
|
748
|
+
const list = Array.isArray(rawSteps) ? rawSteps : [];
|
|
749
|
+
let compactionSeen = false;
|
|
750
|
+
let compactionStepIndex = null;
|
|
751
|
+
const preCompactionReads = new Map(); // canonPath -> { rawPath, stepIndex, tokens }
|
|
752
|
+
const editedSincePreRead = new Set();
|
|
753
|
+
const postCompactionReReads = [];
|
|
754
|
+
let totalReReadTaxTokens = 0;
|
|
755
|
+
|
|
756
|
+
for (let i = 0; i < list.length; i++) {
|
|
757
|
+
const s = list[i] || {};
|
|
758
|
+
const typeStr = String(s.type || s.subtype || '').toLowerCase();
|
|
759
|
+
const isBoundary = Boolean(
|
|
760
|
+
isCompactionCheckpointStep(s) ||
|
|
761
|
+
typeStr.includes('compact') ||
|
|
762
|
+
s.compactMetadata ||
|
|
763
|
+
(typeStr === 'user_input' || typeStr === 'system_message' || typeStr === 'checkpoint'
|
|
764
|
+
? String(s.content || '').includes('<CONTEXT_SUMMARY>')
|
|
765
|
+
: false)
|
|
766
|
+
);
|
|
767
|
+
|
|
768
|
+
if (isBoundary) {
|
|
769
|
+
compactionSeen = true;
|
|
770
|
+
compactionStepIndex = s.stepIndex ?? i;
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
const calls = Array.isArray(s.toolCalls)
|
|
775
|
+
? s.toolCalls
|
|
776
|
+
: (Array.isArray(s.tool_calls) ? s.tool_calls : []);
|
|
777
|
+
|
|
778
|
+
for (const c of calls) {
|
|
779
|
+
const name = String(c.name || c.tool || '').toLowerCase();
|
|
780
|
+
const args = c.args || c.parameters || c.Arguments || {};
|
|
781
|
+
const fp = args.Path || args.path || args.TargetFile || args.AbsolutePath;
|
|
782
|
+
if (!fp || typeof fp !== 'string') continue;
|
|
783
|
+
const canon = canonicalizePath(fp);
|
|
784
|
+
|
|
785
|
+
if (EDIT_TOOLS.has(name)) {
|
|
786
|
+
editedSincePreRead.add(canon);
|
|
787
|
+
} else if (READ_TOOLS.has(name)) {
|
|
788
|
+
const tok = Number(s.outputTokens ?? s.output_tokens ?? Math.max(500, Math.ceil(String(s.content || '').length / 4)));
|
|
789
|
+
if (!compactionSeen) {
|
|
790
|
+
preCompactionReads.set(canon, { rawPath: fp, stepIndex: s.stepIndex ?? i, tokens: tok });
|
|
791
|
+
editedSincePreRead.delete(canon);
|
|
792
|
+
} else if (preCompactionReads.has(canon) && !editedSincePreRead.has(canon)) {
|
|
793
|
+
const prev = preCompactionReads.get(canon);
|
|
794
|
+
totalReReadTaxTokens += tok;
|
|
795
|
+
postCompactionReReads.push({
|
|
796
|
+
path: fp,
|
|
797
|
+
canonicalPath: canon,
|
|
798
|
+
preCompactionStepIndex: prev.stepIndex,
|
|
799
|
+
compactionStepIndex,
|
|
800
|
+
postCompactionStepIndex: s.stepIndex ?? i,
|
|
801
|
+
wastedTokens: tok
|
|
802
|
+
});
|
|
803
|
+
preCompactionReads.delete(canon);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
return {
|
|
810
|
+
compactionDetected: compactionSeen,
|
|
811
|
+
compactionStepIndex,
|
|
812
|
+
reReadCount: postCompactionReReads.length,
|
|
813
|
+
totalReReadTaxTokens,
|
|
814
|
+
reReads: postCompactionReReads
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Analyzes per-turn ratios of reasoning tokens (`thinkingTokens`) and `thinkingDurationMs`
|
|
820
|
+
* to classify `unused_effort`, `loop_tax`, `housekeeping`, and `thrashing`.
|
|
821
|
+
*/
|
|
822
|
+
export function detectEffortThrashing(steps = []) {
|
|
823
|
+
const list = Array.isArray(steps) ? steps : [];
|
|
824
|
+
const flaggedTurns = [];
|
|
825
|
+
let totalWastedThinkingTokens = 0;
|
|
826
|
+
let consecutiveHighSimple = 0;
|
|
827
|
+
|
|
828
|
+
for (let i = 0; i < list.length; i++) {
|
|
829
|
+
const s = list[i] || {};
|
|
830
|
+
const thinkingTokens = Number(s.thinkingTokens ?? s.thinking_tokens ?? s.usage?.thinking_tokens ?? 0);
|
|
831
|
+
const outputTokens = Number(s.outputTokens ?? s.output_tokens ?? s.usage?.output_tokens ?? Math.ceil(String(s.content || '').length / 4));
|
|
832
|
+
const thinkingDurationMs = Number(s.thinkingDurationMs ?? s.thinking_duration_ms ?? 0);
|
|
833
|
+
const calls = Array.isArray(s.toolCalls)
|
|
834
|
+
? s.toolCalls
|
|
835
|
+
: (Array.isArray(s.tool_calls) ? s.tool_calls : []);
|
|
836
|
+
const toolNames = calls.map(c => String(c.name || c.tool || '').toLowerCase());
|
|
837
|
+
|
|
838
|
+
if (thinkingTokens <= 0 && thinkingDurationMs <= 0) continue;
|
|
839
|
+
|
|
840
|
+
const isError = Boolean(s.status === 'ERROR' || (typeof s.exitCode === 'number' && s.exitCode !== 0));
|
|
841
|
+
const isHousekeepingOnly = toolNames.length > 0 && toolNames.every(n => /todowrite|list_dir|find_by_name|glob/i.test(n));
|
|
842
|
+
|
|
843
|
+
let classification = null;
|
|
844
|
+
if (isError && thinkingTokens >= 2000) {
|
|
845
|
+
classification = 'loop_tax';
|
|
846
|
+
} else if (isHousekeepingOnly && thinkingTokens >= 1500) {
|
|
847
|
+
classification = 'housekeeping';
|
|
848
|
+
} else if (thinkingTokens >= 3000 && outputTokens > 0 && (thinkingTokens / Math.max(1, outputTokens)) >= 6) {
|
|
849
|
+
consecutiveHighSimple += 1;
|
|
850
|
+
classification = consecutiveHighSimple >= 2 ? 'thrashing' : 'unused_effort';
|
|
851
|
+
} else {
|
|
852
|
+
consecutiveHighSimple = 0;
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
if (classification) {
|
|
856
|
+
totalWastedThinkingTokens += thinkingTokens;
|
|
857
|
+
flaggedTurns.push({
|
|
858
|
+
stepIndex: s.stepIndex ?? i,
|
|
859
|
+
classification,
|
|
860
|
+
thinkingTokens,
|
|
861
|
+
outputTokens,
|
|
862
|
+
thinkingDurationMs
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
return {
|
|
868
|
+
thrashingDetected: flaggedTurns.some(t => t.classification === 'thrashing' || t.classification === 'loop_tax'),
|
|
869
|
+
totalWastedThinkingTokens,
|
|
870
|
+
flaggedTurns
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Validates that an Antigravity `hooks.json` / `.agents/hooks.json` configuration obeys:
|
|
876
|
+
* 1. `SessionStart`, `PreInvocation`, `PostInvocation`, and `Stop` MUST be flat handler arrays
|
|
877
|
+
* with NO `matcher` wrapper object or `matcher` property.
|
|
878
|
+
* 2. `PreToolUse` and `PostToolUse` capture swarm coordination and lifecycle tools:
|
|
879
|
+
* `"invoke_subagent|define_subagent|send_message|manage_subagents"`.
|
|
880
|
+
*/
|
|
881
|
+
export function validateAntigravityHooksSchema(hooksConfig) {
|
|
882
|
+
const errors = [];
|
|
883
|
+
if (!hooksConfig || typeof hooksConfig !== 'object' || Array.isArray(hooksConfig)) {
|
|
884
|
+
return { valid: false, errors: ['hooksConfig must be a non-null JSON object'] };
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
const scopes = [hooksConfig];
|
|
888
|
+
if (hooksConfig.hooks && typeof hooksConfig.hooks === 'object' && !Array.isArray(hooksConfig.hooks)) {
|
|
889
|
+
scopes.push(hooksConfig.hooks);
|
|
890
|
+
}
|
|
891
|
+
for (const [key, val] of Object.entries(hooksConfig)) {
|
|
892
|
+
if (
|
|
893
|
+
val &&
|
|
894
|
+
typeof val === 'object' &&
|
|
895
|
+
!Array.isArray(val) &&
|
|
896
|
+
key !== 'hooks' &&
|
|
897
|
+
!FLAT_LIFECYCLE_EVENTS.includes(key) &&
|
|
898
|
+
key !== 'PreToolUse' &&
|
|
899
|
+
key !== 'PostToolUse'
|
|
900
|
+
) {
|
|
901
|
+
scopes.push(val);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
let hasSwarmPreToolMatcher = false;
|
|
906
|
+
let hasSwarmPostToolMatcher = false;
|
|
907
|
+
|
|
908
|
+
for (const scope of scopes) {
|
|
909
|
+
for (const evt of FLAT_LIFECYCLE_EVENTS) {
|
|
910
|
+
if (!(evt in scope)) continue;
|
|
911
|
+
const arr = scope[evt];
|
|
912
|
+
if (!Array.isArray(arr)) {
|
|
913
|
+
errors.push(`${evt} must be a flat array of handlers (found ${typeof arr})`);
|
|
914
|
+
continue;
|
|
915
|
+
}
|
|
916
|
+
for (let i = 0; i < arr.length; i++) {
|
|
917
|
+
const entry = arr[i];
|
|
918
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
919
|
+
errors.push(`${evt}[${i}] must be a handler object`);
|
|
920
|
+
continue;
|
|
921
|
+
}
|
|
922
|
+
if ('matcher' in entry || 'hooks' in entry) {
|
|
923
|
+
errors.push(`${evt}[${i}] must be a flat handler entry with NO matcher wrapper object`);
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
for (const toolEvt of ['PreToolUse', 'PostToolUse']) {
|
|
929
|
+
if (!(toolEvt in scope)) continue;
|
|
930
|
+
const arr = scope[toolEvt];
|
|
931
|
+
if (!Array.isArray(arr)) {
|
|
932
|
+
errors.push(`${toolEvt} must be an array of tool matcher handlers`);
|
|
933
|
+
continue;
|
|
934
|
+
}
|
|
935
|
+
for (let i = 0; i < arr.length; i++) {
|
|
936
|
+
const entry = arr[i];
|
|
937
|
+
if (!entry || typeof entry !== 'object') continue;
|
|
938
|
+
if ('hooks' in entry) {
|
|
939
|
+
if (!Array.isArray(entry.hooks) || entry.hooks.length === 0) {
|
|
940
|
+
errors.push(`${toolEvt}[${i}].hooks must be a non-empty array of command handlers`);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
const m = String(entry.matcher || '');
|
|
944
|
+
if (
|
|
945
|
+
m.includes('invoke_subagent') &&
|
|
946
|
+
m.includes('define_subagent') &&
|
|
947
|
+
m.includes('send_message') &&
|
|
948
|
+
m.includes('manage_subagents')
|
|
949
|
+
) {
|
|
950
|
+
if (toolEvt === 'PreToolUse') hasSwarmPreToolMatcher = true;
|
|
951
|
+
if (toolEvt === 'PostToolUse') hasSwarmPostToolMatcher = true;
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
return {
|
|
958
|
+
valid: errors.length === 0,
|
|
959
|
+
hasSwarmPreToolMatcher,
|
|
960
|
+
hasSwarmPostToolMatcher,
|
|
961
|
+
swarmToolMatcher: SWARM_TOOL_MATCHER,
|
|
962
|
+
errors
|
|
963
|
+
};
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
|