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,19 @@
|
|
|
1
|
+
# Highbeam Pro (`@ctxtop/pro`) — Commercial Source-Available License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gizzant (Highbeam). All rights reserved.
|
|
4
|
+
|
|
5
|
+
## 1. Scope of This License
|
|
6
|
+
This Commercial Source-Available License governs all files inside `packages/pro/**`, `src/core/pro_license.mjs`, and the commercial features unlocked by an Highbeam Pro (`CTXP1`) cryptographic license key (`AUTO_PILOT` active cache/model-switch locks, cross-harness `DET-20` lease enforcement, signed Corporate PDF 1.4 Expense Receipts, and the Team FinOps OTel/Grafana Pack).
|
|
7
|
+
|
|
8
|
+
All other components of this repository (`@ctxtop/core`, `@ctxtop/antigravity`, `@ctxtop/claude-code`, the 40-cell HUD, 5-minute TTL clock, `--roast`, and advisory `COACH` mode) remain licensed under the root **MIT License**.
|
|
9
|
+
|
|
10
|
+
## 2. Permitted Source Inspection & Local Trial
|
|
11
|
+
You are permitted to view, inspect, and audit the source code in `packages/pro/**` to verify security, privacy, and zero-network compliance, and to evaluate Pro features during a 14-day local trial (`npx ctxtop license trial`).
|
|
12
|
+
|
|
13
|
+
## 3. Commercial Restrictions
|
|
14
|
+
Without a valid, unexpired Highbeam Pro (`$15/mo`, `$149/yr`, or `$199` Lifetime) or Team (`$39/seat/mo` or `$299/yr` 5-seat starter) `CTXP1` Ed25519 license key issued to you or your organization, you may **NOT**:
|
|
15
|
+
1. Remove, patch, stub, or bypass `verifyProLicenseKey()`, `getProEntitlementStatus()`, or `requireProFeature()` checks in production builds or forks.
|
|
16
|
+
2. Redistribute, publish, or host modified packages that unlock `@ctxtop/pro` commercial features without a valid `CTXP1` cryptographic key.
|
|
17
|
+
3. Generate or share forged `CTXP1` license keys for third parties.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# `@ctxtop/pro` Production Ed25519 Key Rotation & Polar.sh Signing Runbook
|
|
2
|
+
|
|
3
|
+
## 1. Zero-Network Offline Architecture
|
|
4
|
+
`@ctxtop/pro` licenses use offline `CTXP1.<payloadB64Url>.<sigB64Url>` Ed25519 tokens verified locally via Node's built-in `node:crypto` module (`verifyProLicenseKey()` in `src/core/pro_license.mjs`). The client IDE/CLI makes **zero** outbound network calls.
|
|
5
|
+
|
|
6
|
+
## 2. Generate Production Keypair
|
|
7
|
+
Run an offline one-liner using `generateProKeyPair()` on a secure local workstation:
|
|
8
|
+
```bash
|
|
9
|
+
node -e "import('./src/core/pro_license.mjs').then(m => { const kp = m.generateProKeyPair(); console.log(kp.publicKeyPem); console.log(kp.privateKeyPem); })"
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 3. Bind Cloudflare Worker Secrets (Polar.sh Webhook)
|
|
13
|
+
Store the PKCS#8 private key and Polar.sh webhook HMAC secret in Cloudflare Worker encrypted secrets:
|
|
14
|
+
```bash
|
|
15
|
+
wrangler secret put CTXTOP_ED25519_PRIVATE_KEY_PEM
|
|
16
|
+
wrangler secret put CTXTOP_POLAR_WEBHOOK_SECRET
|
|
17
|
+
```
|
|
18
|
+
Never commit `CTXTOP_ED25519_PRIVATE_KEY_PEM` to Git or npm tarballs.
|
|
19
|
+
|
|
20
|
+
## 4. Embed or Override the SPKI Public Key
|
|
21
|
+
1. Update `DEFAULT_PRO_PUBLIC_KEY_PEM` in `src/core/pro_license.mjs` with the corresponding SPKI PEM public key before tagging a release.
|
|
22
|
+
2. Enterprise deployments or staged key-rotation tests can override the embedded public key via environment variable without modifying code:
|
|
23
|
+
```bash
|
|
24
|
+
export CTXTOP_ED25519_PUBLIC_KEY_PEM="$(cat prod-ed25519-pub.pem)"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 5. Key Rotation Checklist
|
|
28
|
+
1. Generate a new keypair and deploy `CTXTOP_ED25519_PRIVATE_KEY_PEM` to the signing worker only after shipping the matching `DEFAULT_PRO_PUBLIC_KEY_PEM` in `ctxtop`.
|
|
29
|
+
2. Verify signature round-trip locally using `signProLicensePayload()` -> `verifyProLicenseKey()`.
|
|
30
|
+
3. Confirm tampered and expired payloads return `INVALID_SIGNATURE` and `LICENSE_EXPIRED`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ctxtop/pro",
|
|
3
|
+
"version": "4.0.0",
|
|
4
|
+
"description": "Highbeam Pro — Offline Ed25519 License Verifier, Team FinOps Pack & Commercial Entitlements (Polar.sh)",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE-COMMERCIAL.md",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./src/index.mjs",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.mjs",
|
|
10
|
+
"./worker": "./workers/polar_webhook_worker.mjs",
|
|
11
|
+
"./team-finops": "./src/team_finops_pack.mjs"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file packages/pro/src/team_finops_pack.mjs
|
|
3
|
+
* Roadmap Item #8: Packaged "BYO-Grafana" Team Policy & OpenTelemetry Bundle ($299/yr for 5 Seats).
|
|
4
|
+
*
|
|
5
|
+
* Generates zero-backend Team FinOps artifacts fed by `src/core-isomorphic/telemetry/otelExporter.mjs`:
|
|
6
|
+
* 1. `grafana-dashboard.json` (Grafana v10+ dashboard)
|
|
7
|
+
* 2. `datadog-dashboard.json` (Datadog dashboard widget template)
|
|
8
|
+
* 3. `.attention-horizon.json` (Committed Team Governance lockfile)
|
|
9
|
+
* 4. `otel-collector-config.yaml` (Local OTel JSONL filelog -> Prometheus/OTLP pipeline)
|
|
10
|
+
* 5. `README-TEAM-FINOPS.md` (5-minute zero-SaaS deployment guide)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
import { requireProFeature } from '../../../src/core/pro_license.mjs';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Builds the 5 Team FinOps Pack file payloads in memory.
|
|
19
|
+
*
|
|
20
|
+
* @param {object} [options={}]
|
|
21
|
+
* @param {string} [options.orgName='Engineering Team']
|
|
22
|
+
* @param {number} [options.seats=5]
|
|
23
|
+
*/
|
|
24
|
+
export function buildTeamFinopsArtifacts(options = {}) {
|
|
25
|
+
const orgName = String(options.orgName || 'Engineering Team').trim();
|
|
26
|
+
const seats = Math.max(1, Number(options.seats || 5));
|
|
27
|
+
|
|
28
|
+
const grafanaDashboard = {
|
|
29
|
+
uid: 'ah-team-finops-v4',
|
|
30
|
+
title: `Highbeam — ${orgName} Context FinOps & KV-Cache ROI`,
|
|
31
|
+
tags: ['attention-horizon', 'claude-code', 'antigravity', 'finops', 'otel'],
|
|
32
|
+
timezone: 'browser',
|
|
33
|
+
schemaVersion: 39,
|
|
34
|
+
version: 1,
|
|
35
|
+
refresh: '30s',
|
|
36
|
+
panels: [
|
|
37
|
+
{
|
|
38
|
+
id: 1,
|
|
39
|
+
type: 'timeseries',
|
|
40
|
+
title: 'Actual LLM Spend vs. Verified Highbeam Savings (USD)',
|
|
41
|
+
gridPos: { h: 8, w: 12, x: 0, y: 0 },
|
|
42
|
+
targets: [
|
|
43
|
+
{
|
|
44
|
+
expr: 'sum by (vcs_repository_url_full, model) (claude_code_cost_usage)',
|
|
45
|
+
legendFormat: 'Actual Spend ({{model}})'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
expr: 'sum by (vcs_repository_url_full, model) (attention_horizon_saved_quota_usd)',
|
|
49
|
+
legendFormat: 'Verified Saved USD ({{model}})'
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: 2,
|
|
55
|
+
type: 'stat',
|
|
56
|
+
title: 'Team Prompt Cache Hit Ratio (%)',
|
|
57
|
+
gridPos: { h: 8, w: 6, x: 12, y: 0 },
|
|
58
|
+
targets: [
|
|
59
|
+
{
|
|
60
|
+
expr: '100 * sum(claude_code_token_usage{type="cacheRead"}) / clamp_min(sum(claude_code_token_usage{type=~"input|cacheRead|cacheCreation"}), 1)',
|
|
61
|
+
legendFormat: 'Cache Hit %'
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 3,
|
|
67
|
+
type: 'stat',
|
|
68
|
+
title: 'Total Circuit Breaker Interventions (DET-01..32)',
|
|
69
|
+
gridPos: { h: 8, w: 6, x: 18, y: 0 },
|
|
70
|
+
targets: [
|
|
71
|
+
{
|
|
72
|
+
expr: 'sum(attention_horizon_intervention_count)',
|
|
73
|
+
legendFormat: 'Guard Trips'
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 4,
|
|
79
|
+
type: 'table',
|
|
80
|
+
title: 'Negative Cache ROI & Cold-Rebuild Hotspots by Repository',
|
|
81
|
+
gridPos: { h: 8, w: 24, x: 0, y: 8 },
|
|
82
|
+
targets: [
|
|
83
|
+
{
|
|
84
|
+
expr: 'sum by (vcs_repository_url_full, vcs_ref_head_name, model) (claude_code_cost_usage{negative_cache_roi="true"})',
|
|
85
|
+
legendFormat: '{{vcs_repository_url_full}} ({{vcs_ref_head_name}})'
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const datadogDashboard = {
|
|
93
|
+
title: `Highbeam — ${orgName} Agent FinOps (${seats} Seats)`,
|
|
94
|
+
description: 'Zero-backend Claude Code & Google Antigravity KV-cache efficiency and DET-01..32 circuit breaker telemetry.',
|
|
95
|
+
layout_type: 'ordered',
|
|
96
|
+
widgets: [
|
|
97
|
+
{
|
|
98
|
+
definition: {
|
|
99
|
+
title: 'LLM Spend vs. Highbeam Saved USD',
|
|
100
|
+
type: 'timeseries',
|
|
101
|
+
requests: [
|
|
102
|
+
{ q: 'sum:claude_code.cost.usage{*} by {model,vcs.repository.url.full}', display_type: 'bars' },
|
|
103
|
+
{ q: 'sum:attention_horizon.saved_quota.usd{*} by {model,vcs.repository.url.full}', display_type: 'line' }
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
definition: {
|
|
109
|
+
title: 'Prompt Cache Read vs. Uncached Input Tokens',
|
|
110
|
+
type: 'timeseries',
|
|
111
|
+
requests: [
|
|
112
|
+
{ q: 'sum:claude_code.token.usage{type:cacheread} by {vcs.repository.url.full}', display_type: 'area' },
|
|
113
|
+
{ q: 'sum:claude_code.token.usage{type:input} by {vcs.repository.url.full}', display_type: 'line' }
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
definition: {
|
|
119
|
+
title: 'Active Circuit Breaker Interventions',
|
|
120
|
+
type: 'query_value',
|
|
121
|
+
requests: [{ q: 'sum:attention_horizon.intervention.count{*}', aggregator: 'sum' }]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const teamPolicyConfig = {
|
|
128
|
+
version: 1,
|
|
129
|
+
organization: orgName,
|
|
130
|
+
licensedSeats: seats,
|
|
131
|
+
flightMode: 'AUTO_PILOT',
|
|
132
|
+
detectorNamespace: 'canonical',
|
|
133
|
+
teamGovernance: {
|
|
134
|
+
enforceRing0Safety: true,
|
|
135
|
+
enforceCrossHarnessScopeLocks: true,
|
|
136
|
+
otelExportEnabled: true
|
|
137
|
+
},
|
|
138
|
+
detectors: {
|
|
139
|
+
'DET-01': 'block',
|
|
140
|
+
'DET-02': 'block',
|
|
141
|
+
'DET-04': 'block',
|
|
142
|
+
'DET-05': 'block',
|
|
143
|
+
'DET-08': 'block',
|
|
144
|
+
'DET-09': 'block',
|
|
145
|
+
'DET-19': 'block',
|
|
146
|
+
'DET-20': 'block'
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const otelCollectorYaml = [
|
|
151
|
+
'# Highbeam — Zero-Backend Team FinOps OpenTelemetry Collector Config',
|
|
152
|
+
'receivers:',
|
|
153
|
+
' filelog/attention_horizon:',
|
|
154
|
+
' include:',
|
|
155
|
+
' - ~/.attention-horizon/otel/metrics.jsonl',
|
|
156
|
+
' - ./.claude/telemetry/otel-metrics.jsonl',
|
|
157
|
+
' operators:',
|
|
158
|
+
' - type: json_parser',
|
|
159
|
+
'',
|
|
160
|
+
'processors:',
|
|
161
|
+
' batch:',
|
|
162
|
+
' timeout: 10s',
|
|
163
|
+
'',
|
|
164
|
+
'exporters:',
|
|
165
|
+
' prometheus:',
|
|
166
|
+
' endpoint: "127.0.0.1:9464"',
|
|
167
|
+
' otlphttp:',
|
|
168
|
+
' endpoint: "${OTEL_EXPORTER_OTLP_ENDPOINT:-http://localhost:4318}"',
|
|
169
|
+
'',
|
|
170
|
+
'service:',
|
|
171
|
+
' pipelines:',
|
|
172
|
+
' logs/attention_horizon:',
|
|
173
|
+
' receivers: [filelog/attention_horizon]',
|
|
174
|
+
' processors: [batch]',
|
|
175
|
+
' exporters: [prometheus, otlphttp]'
|
|
176
|
+
].join('\n') + '\n';
|
|
177
|
+
|
|
178
|
+
const readmeMarkdown = [
|
|
179
|
+
`# Highbeam Team FinOps Pack — ${orgName} (${seats} Seats)`,
|
|
180
|
+
'',
|
|
181
|
+
'Zero-backend team cost attribution, KV-cache warmth telemetry, and cross-harness (`Claude Code` + `Google Antigravity`) governance.',
|
|
182
|
+
'',
|
|
183
|
+
'## Included Files',
|
|
184
|
+
'1. **`.attention-horizon.json`**: Commit this policy file to your repository root to standardize `DET-01..32` circuit breakers and cross-harness `DET-20` file-scope locks across all developers.',
|
|
185
|
+
'2. **`grafana-dashboard.json`**: Import directly into Grafana (**Dashboards -> New -> Import**) to track actual LLM spend vs. Highbeam saved USD.',
|
|
186
|
+
'3. **`datadog-dashboard.json`**: Import into Datadog (**Dashboards -> New Dashboard -> Import Dashboard JSON**).',
|
|
187
|
+
'4. **`otel-collector-config.yaml`**: Point your local or CI OpenTelemetry Collector at `~/.attention-horizon/otel/metrics.jsonl` (`CLAUDE_CODE_ENABLE_TELEMETRY=1`).'
|
|
188
|
+
].join('\n') + '\n';
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
orgName,
|
|
192
|
+
seats,
|
|
193
|
+
files: {
|
|
194
|
+
'grafana-dashboard.json': JSON.stringify(grafanaDashboard, null, 2) + '\n',
|
|
195
|
+
'datadog-dashboard.json': JSON.stringify(datadogDashboard, null, 2) + '\n',
|
|
196
|
+
'.attention-horizon.json': JSON.stringify(teamPolicyConfig, null, 2) + '\n',
|
|
197
|
+
'otel-collector-config.yaml': otelCollectorYaml,
|
|
198
|
+
'README-TEAM-FINOPS.md': readmeMarkdown
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Writes the BYO-Grafana Team FinOps Pack to disk after checking Pro/Team entitlement.
|
|
205
|
+
*
|
|
206
|
+
* @param {object} [options={}]
|
|
207
|
+
* @returns {{ ok: boolean, outDir: string | null, filesWritten: string[], entitlement: object }}
|
|
208
|
+
*/
|
|
209
|
+
export function generateTeamFinopsPack(options = {}) {
|
|
210
|
+
const entitlement = requireProFeature('team_finops_pack', options);
|
|
211
|
+
if (!entitlement.allowed && !options.preview) {
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
outDir: null,
|
|
215
|
+
filesWritten: [],
|
|
216
|
+
entitlement
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const outDir = path.resolve(
|
|
221
|
+
options.outDir || path.join(options.cwd || process.cwd(), 'attention-horizon-team-pack')
|
|
222
|
+
);
|
|
223
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
224
|
+
|
|
225
|
+
const artifacts = buildTeamFinopsArtifacts(options);
|
|
226
|
+
const filesWritten = [];
|
|
227
|
+
for (const [fileName, content] of Object.entries(artifacts.files)) {
|
|
228
|
+
const fullPath = path.join(outDir, fileName);
|
|
229
|
+
fs.writeFileSync(fullPath, content, 'utf8');
|
|
230
|
+
filesWritten.push(fullPath);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return {
|
|
234
|
+
ok: true,
|
|
235
|
+
outDir,
|
|
236
|
+
orgName: artifacts.orgName,
|
|
237
|
+
seats: artifacts.seats,
|
|
238
|
+
filesWritten,
|
|
239
|
+
entitlement
|
|
240
|
+
};
|
|
241
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file packages/pro/workers/polar_webhook_worker.mjs
|
|
3
|
+
* Zero-dependency, stateless Polar.sh Webhook Handler for minting offline `CTXP1` Ed25519 Pro licenses.
|
|
4
|
+
*
|
|
5
|
+
* Compatible with Cloudflare Workers (`export default { fetch }`) and Node.js HTTP servers.
|
|
6
|
+
* Requires zero database and $0.00/mo fixed infrastructure cost.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import crypto from 'node:crypto';
|
|
10
|
+
import { signProLicensePayload } from '../../../src/core/pro_license.mjs';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Verifies a Standard Webhooks / Polar.sh HMAC-SHA256 signature (`v1,<base64Sig>`).
|
|
14
|
+
*
|
|
15
|
+
* @param {object} params
|
|
16
|
+
* @param {string} params.rawBody
|
|
17
|
+
* @param {string} params.webhookId
|
|
18
|
+
* @param {string} params.webhookTimestamp
|
|
19
|
+
* @param {string} params.webhookSignature
|
|
20
|
+
* @param {string} params.secret
|
|
21
|
+
* @param {number} [params.toleranceSeconds=300]
|
|
22
|
+
* @param {number} [params.nowMs=Date.now()]
|
|
23
|
+
* @returns {{ valid: boolean, reason: string | null }}
|
|
24
|
+
*/
|
|
25
|
+
export function verifyPolarWebhookSignature({
|
|
26
|
+
rawBody = '',
|
|
27
|
+
webhookId = '',
|
|
28
|
+
webhookTimestamp = '',
|
|
29
|
+
webhookSignature = '',
|
|
30
|
+
secret = '',
|
|
31
|
+
toleranceSeconds = 300,
|
|
32
|
+
nowMs = Date.now()
|
|
33
|
+
} = {}) {
|
|
34
|
+
if (!secret || !webhookId || !webhookTimestamp || !webhookSignature) {
|
|
35
|
+
return { valid: false, reason: 'MISSING_WEBHOOK_HEADERS_OR_SECRET' };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const tsSec = Number(webhookTimestamp);
|
|
39
|
+
if (!Number.isFinite(tsSec)) {
|
|
40
|
+
return { valid: false, reason: 'INVALID_TIMESTAMP' };
|
|
41
|
+
}
|
|
42
|
+
const ageSec = Math.abs(Math.floor(nowMs / 1000) - tsSec);
|
|
43
|
+
if (toleranceSeconds > 0 && ageSec > toleranceSeconds) {
|
|
44
|
+
return { valid: false, reason: 'TIMESTAMP_OUTSIDE_TOLERANCE' };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const cleanSecret = secret.startsWith('whsec_')
|
|
48
|
+
? Buffer.from(secret.slice(6), 'base64')
|
|
49
|
+
: Buffer.from(secret, 'utf8');
|
|
50
|
+
|
|
51
|
+
const signedContent = `${webhookId}.${webhookTimestamp}.${rawBody}`;
|
|
52
|
+
const expectedB64 = crypto
|
|
53
|
+
.createHmac('sha256', cleanSecret)
|
|
54
|
+
.update(signedContent, 'utf8')
|
|
55
|
+
.digest('base64');
|
|
56
|
+
|
|
57
|
+
const candidates = String(webhookSignature)
|
|
58
|
+
.split(/\s+/)
|
|
59
|
+
.map((part) => (part.startsWith('v1,') ? part.slice(3) : part))
|
|
60
|
+
.filter(Boolean);
|
|
61
|
+
|
|
62
|
+
const expectedBuf = Buffer.from(expectedB64, 'utf8');
|
|
63
|
+
for (const cand of candidates) {
|
|
64
|
+
const candBuf = Buffer.from(cand, 'utf8');
|
|
65
|
+
if (candBuf.length === expectedBuf.length && crypto.timingSafeEqual(candBuf, expectedBuf)) {
|
|
66
|
+
return { valid: true, reason: null };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return { valid: false, reason: 'INVALID_HMAC_SIGNATURE' };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Maps a Polar.sh order/subscription payload to an Highbeam Pro tier and seat count.
|
|
75
|
+
* @param {object} eventPayload
|
|
76
|
+
*/
|
|
77
|
+
export function mapPolarOrderToLicenseSpec(eventPayload = {}) {
|
|
78
|
+
const data = eventPayload.data || eventPayload;
|
|
79
|
+
const productName = String(
|
|
80
|
+
data.product?.name || data.product_name || data.price?.product_name || data.tier || 'pro'
|
|
81
|
+
).toLowerCase();
|
|
82
|
+
const amountCents = Number(data.amount || data.price_amount || 0);
|
|
83
|
+
const email =
|
|
84
|
+
data.customer?.email ||
|
|
85
|
+
data.user?.email ||
|
|
86
|
+
data.customer_email ||
|
|
87
|
+
data.email ||
|
|
88
|
+
'customer@polar.sh';
|
|
89
|
+
|
|
90
|
+
let tier = 'pro';
|
|
91
|
+
let seats = 1;
|
|
92
|
+
let expiresAt = null;
|
|
93
|
+
const issuedAt = new Date().toISOString();
|
|
94
|
+
|
|
95
|
+
if (productName.includes('team') || amountCents >= 25000) {
|
|
96
|
+
tier = 'team';
|
|
97
|
+
seats = Number(data.seats || 5);
|
|
98
|
+
expiresAt = new Date(Date.now() + 366 * 86400 * 1000).toISOString();
|
|
99
|
+
} else if (productName.includes('lifetime') || productName.includes('ltd') || (amountCents >= 10000 && amountCents < 25000)) {
|
|
100
|
+
tier = 'ltd';
|
|
101
|
+
seats = 1;
|
|
102
|
+
expiresAt = null;
|
|
103
|
+
} else if (productName.includes('annual') || productName.includes('year') || (amountCents >= 5000 && amountCents < 10000)) {
|
|
104
|
+
tier = 'pro';
|
|
105
|
+
seats = 1;
|
|
106
|
+
expiresAt = new Date(Date.now() + 366 * 86400 * 1000).toISOString();
|
|
107
|
+
} else {
|
|
108
|
+
tier = 'pro';
|
|
109
|
+
seats = 1;
|
|
110
|
+
expiresAt = new Date(Date.now() + 32 * 86400 * 1000).toISOString();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
tier,
|
|
115
|
+
seats,
|
|
116
|
+
email,
|
|
117
|
+
issuedAt,
|
|
118
|
+
expiresAt,
|
|
119
|
+
orderId: data.id || null,
|
|
120
|
+
source: 'polar.sh'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Processes a raw Polar.sh webhook HTTP request and signs an offline `CTXP1` Ed25519 license key.
|
|
126
|
+
*
|
|
127
|
+
* @param {object} reqInput
|
|
128
|
+
* @param {string} reqInput.rawBody
|
|
129
|
+
* @param {Record<string, string>} reqInput.headers
|
|
130
|
+
* @param {object} env
|
|
131
|
+
* @param {string} env.CTXTOP_POLAR_WEBHOOK_SECRET
|
|
132
|
+
* @param {string} env.CTXTOP_ED25519_PRIVATE_KEY_PEM
|
|
133
|
+
* @param {number} [reqInput.nowMs]
|
|
134
|
+
*/
|
|
135
|
+
export function handlePolarWebhookRequest(reqInput = {}, env = {}) {
|
|
136
|
+
const headers = reqInput.headers || {};
|
|
137
|
+
const getHeader = (name) =>
|
|
138
|
+
headers[name] || headers[name.toLowerCase()] || '';
|
|
139
|
+
|
|
140
|
+
const secret = env.CTXTOP_POLAR_WEBHOOK_SECRET || process.env.CTXTOP_POLAR_WEBHOOK_SECRET || '';
|
|
141
|
+
const privateKeyPem =
|
|
142
|
+
env.CTXTOP_ED25519_PRIVATE_KEY_PEM || process.env.CTXTOP_ED25519_PRIVATE_KEY_PEM || '';
|
|
143
|
+
|
|
144
|
+
const sigCheck = verifyPolarWebhookSignature({
|
|
145
|
+
rawBody: reqInput.rawBody || '',
|
|
146
|
+
webhookId: getHeader('webhook-id') || getHeader('svix-id'),
|
|
147
|
+
webhookTimestamp: getHeader('webhook-timestamp') || getHeader('svix-timestamp'),
|
|
148
|
+
webhookSignature: getHeader('webhook-signature') || getHeader('svix-signature'),
|
|
149
|
+
secret,
|
|
150
|
+
nowMs: reqInput.nowMs || Date.now()
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (!sigCheck.valid) {
|
|
154
|
+
return {
|
|
155
|
+
status: 401,
|
|
156
|
+
body: { ok: false, error: sigCheck.reason }
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
let parsed = null;
|
|
161
|
+
try {
|
|
162
|
+
parsed = JSON.parse(reqInput.rawBody || '{}');
|
|
163
|
+
} catch {
|
|
164
|
+
return {
|
|
165
|
+
status: 400,
|
|
166
|
+
body: { ok: false, error: 'INVALID_JSON_BODY' }
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const eventType = String(parsed.type || 'order.created');
|
|
171
|
+
if (!/^(order\.created|subscription\.active|subscription\.created|benefit_grant\.created)$/i.test(eventType)) {
|
|
172
|
+
return {
|
|
173
|
+
status: 200,
|
|
174
|
+
body: { ok: true, ignored: true, eventType }
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const spec = mapPolarOrderToLicenseSpec(parsed);
|
|
179
|
+
const licenseKey = signProLicensePayload(spec, privateKeyPem);
|
|
180
|
+
|
|
181
|
+
return {
|
|
182
|
+
status: 200,
|
|
183
|
+
body: {
|
|
184
|
+
ok: true,
|
|
185
|
+
eventType,
|
|
186
|
+
tier: spec.tier,
|
|
187
|
+
seats: spec.seats,
|
|
188
|
+
email: spec.email,
|
|
189
|
+
expiresAt: spec.expiresAt,
|
|
190
|
+
licenseKey,
|
|
191
|
+
activationCommand: `npx ctxtop license activate ${licenseKey}`
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export default {
|
|
197
|
+
async fetch(request, env) {
|
|
198
|
+
if (request.method !== 'POST') {
|
|
199
|
+
return new Response(JSON.stringify({ ok: false, error: 'METHOD_NOT_ALLOWED' }), {
|
|
200
|
+
status: 405,
|
|
201
|
+
headers: { 'content-type': 'application/json' }
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
const rawBody = await request.text();
|
|
205
|
+
const headersObj = {};
|
|
206
|
+
request.headers.forEach((v, k) => {
|
|
207
|
+
headersObj[k.toLowerCase()] = v;
|
|
208
|
+
});
|
|
209
|
+
const res = handlePolarWebhookRequest({ rawBody, headers: headersObj }, env);
|
|
210
|
+
return new Response(JSON.stringify(res.body), {
|
|
211
|
+
status: res.status,
|
|
212
|
+
headers: { 'content-type': 'application/json' }
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
package/plugin.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://antigravity.google/schemas/v1/plugin.json",
|
|
3
|
+
"name": "attention-horizon-antigravity",
|
|
4
|
+
"displayName": "Highbeam",
|
|
5
|
+
"version": "4.0.0",
|
|
6
|
+
"description": "40-cell chronological context telemetry HUD, KV-Cache Gravity effort router, and zero-token guardrails.",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Gizzant"
|
|
9
|
+
},
|
|
10
|
+
"icon": "./assets/logo.svg",
|
|
11
|
+
"hooks": "./hooks.json",
|
|
12
|
+
"rules": [
|
|
13
|
+
"./rules/AGENTS.md"
|
|
14
|
+
],
|
|
15
|
+
"skills": [
|
|
16
|
+
"./skills/horizon",
|
|
17
|
+
"./skills/precheck",
|
|
18
|
+
"./skills/handoff",
|
|
19
|
+
"./skills/cost-radar",
|
|
20
|
+
"./skills/inspect",
|
|
21
|
+
"./skills/evolve"
|
|
22
|
+
],
|
|
23
|
+
"agents": [
|
|
24
|
+
"./agents/ah-flash-scout.md"
|
|
25
|
+
],
|
|
26
|
+
"sidecars": [
|
|
27
|
+
"./sidecars/horizon-daemon"
|
|
28
|
+
],
|
|
29
|
+
"suggestedPrompts": [
|
|
30
|
+
"/horizon Inspect my 40-cell Highbeam and Wasted Tokens",
|
|
31
|
+
"/precheck Audit my next architecture refactor prompt and context hygiene",
|
|
32
|
+
"/handoff Audit and format State Baton before /compact or session handoff",
|
|
33
|
+
"/cost-radar Render my prefix-cache retention, thinking drift and swarm topology timeline",
|
|
34
|
+
"/evolve Audit static AGENTS.md token overhead and route skill deltas"
|
|
35
|
+
]
|
|
36
|
+
}
|
package/rules/AGENTS.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Highbeam Guidelines
|
|
2
|
+
|
|
3
|
+
The Highbeam plugin tracks active context memory health, preventing context bloat and Context Truncation Risk (Oldest Rules at Risk).
|
|
4
|
+
|
|
5
|
+
## Ground Rules:
|
|
6
|
+
1. **Context Truncation Guard**: When an `[Highbeam Alert]` warns of `amputationCrisis` (Context Truncation Risk), never perform unbounded file re-reads or verbose test loops. Save state to `task.md` (or run `/handoff`) and recommend `/clear` or `/compact`.
|
|
7
|
+
2. **Knowledge Bleed**: If injected knowledge items are flagged as foreign bleed from another workspace, verify relevance before adopting cross-project conventions.
|
|
8
|
+
4. **Router Ergonomics & Cooldown**: Router operates in `guard` (default) or `advisory` (warn-only) mode. Halts respect a 3-turn cooldown to avoid nag loops (Context Truncation Crisis exempt). Diagnostics can be verified anytime with `npx ctxtop doctor`.
|
|
9
|
+
5. **UI Invariants**: Provide a 1-click Copy `/compact` button (`#btnCompactPrimary`) alongside `#compactInstruction`, never show ignore button on active source files, and maintain 3-way mirror parity.
|
|
10
|
+
6. **Account & OAuth Seat Safety**: Never access `oauth_creds.json` or `gemini:antigravity` tokens, never spawn headless `gemini`/`agy` CLIs in tests with `oauth-personal`, and avoid unthrottled multi-step grep/read loops or parallel subagent fan-out (`1–2` consolidated tool calls per turn).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file sidecars/horizon-daemon/ipcServer.mjs
|
|
3
|
+
* Horizon Daemon Micro-IPC Socket Mount.
|
|
4
|
+
*
|
|
5
|
+
* Mounts warm MicroIpcServer on Win32 Named Pipes (\\.\pipe\ctxtop-<username>)
|
|
6
|
+
* and POSIX Unix Domain Sockets (~/.ctxtop/daemon.sock).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { MicroIpcServer } from '../../src/engine-node/ipc/server.mjs';
|
|
10
|
+
import { resolveIpcPath } from '../../src/engine-node/ipc/protocol.mjs';
|
|
11
|
+
|
|
12
|
+
export { MicroIpcServer, resolveIpcPath };
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates and starts a MicroIpcServer instance.
|
|
16
|
+
*
|
|
17
|
+
* @param {object} [options]
|
|
18
|
+
* @returns {Promise<MicroIpcServer>}
|
|
19
|
+
*/
|
|
20
|
+
export async function createAndStartIpcServer(options = {}) {
|
|
21
|
+
const server = new MicroIpcServer(options);
|
|
22
|
+
await server.listen();
|
|
23
|
+
return server;
|
|
24
|
+
}
|