@clear-capabilities/agentic-security-scanner 0.121.0 → 0.122.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.122.0 — cache economics Phase B (depth-first, subagent offload, cost HUD)
4
+
5
+ Completes the cache-economics program (PRD `docs/CACHE_ECONOMICS_PRD.md`, F4–F6) on
6
+ top of the v0.121.0 measured foundation. All in `hooks/model-cost-advisor.js`,
7
+ `hooks/lib/transcript.js`, and `scanner/src/posture/cache-economics.js`.
8
+
9
+ - **F4 — depth-first routing.** A model switch is now chosen over a cache-safe effort
10
+ drop only when it saves *materially* more (`A.savings ≥ B.savings × (1 +
11
+ depthFirstMargin)`, default 0.25). Effort is the primary lever; switching is the
12
+ break-even-gated exception.
13
+ - **F5 — subagent offload.** For a simple one-off whose cheap-model switch is
14
+ cache-blocked (deep warm cache), the advisor suggests running it as a **Haiku
15
+ subagent** — full cheap-model savings without discarding the main session's cache.
16
+ Config `subagentAdvice` (default true).
17
+ - **F6 — cost HUD + cache budget.** `cache-statusline` CLI prints a one-line HUD
18
+ (`$ spent · % cached · $/turn`) for a Claude Code `statusLine` command and writes
19
+ `.agentic-security/cache-telemetry.json`; the `query_cache_telemetry` MCP tool gains
20
+ a `statusline` field. A soft `sessionBudgetUsd` biases the `costQualityTradeoff`
21
+ dial toward cheaper as real session spend (priced from the transcript) approaches it.
22
+
3
23
  ## 0.121.0 — prompt-cache economics (measured, cache-aware cost optimization)
4
24
 
5
25
  Cache-economics core (PRD `docs/CACHE_ECONOMICS_PRD.md`, features F1–F3). Turns
@@ -1642,6 +1642,25 @@ async function main() {
1642
1642
  else console.log(formatCacheReport(result));
1643
1643
  process.exit(0);
1644
1644
  }
1645
+ case 'cache-statusline': {
1646
+ // F6 — one-line cost HUD for a Claude Code statusLine command. Also writes
1647
+ // .agentic-security/cache-telemetry.json for other pollers. Always exits 0.
1648
+ const { analyzeTranscript, renderCacheStatusLine } = await import('../src/posture/cache-economics.js');
1649
+ const projectDir = path.resolve(args.flags.root || process.env.CLAUDE_PROJECT_DIR || process.cwd());
1650
+ const result = analyzeTranscript({ transcriptPath: args.flags.transcript, projectDir });
1651
+ if (result.ok) {
1652
+ try {
1653
+ const dir = path.join(projectDir, '.agentic-security');
1654
+ fs.mkdirSync(dir, { recursive: true });
1655
+ fs.writeFileSync(path.join(dir, 'cache-telemetry.json'),
1656
+ JSON.stringify({ updatedAt: new Date().toISOString(), metrics: result.metrics, leaks: result.leaks }, null, 2));
1657
+ } catch { /* best-effort */ }
1658
+ console.log(renderCacheStatusLine(result.metrics));
1659
+ } else {
1660
+ console.log('agentic-security: no session cost yet');
1661
+ }
1662
+ process.exit(0);
1663
+ }
1645
1664
  case 'mcp': {
1646
1665
  const { runStdio } = await import('../src/mcp/stdio.js');
1647
1666
  const root = args.flags.root || process.env.AGENTIC_SECURITY_MCP_ROOT || process.cwd();
package/dist/752.index.js CHANGED
@@ -7,7 +7,8 @@ export const modules = {
7
7
 
8
8
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9
9
  /* harmony export */ analyzeTranscript: () => (/* binding */ analyzeTranscript),
10
- /* harmony export */ formatCacheReport: () => (/* binding */ formatCacheReport)
10
+ /* harmony export */ formatCacheReport: () => (/* binding */ formatCacheReport),
11
+ /* harmony export */ renderCacheStatusLine: () => (/* binding */ renderCacheStatusLine)
11
12
  /* harmony export */ });
12
13
  /* unused harmony export _internal */
13
14
  /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3024);
@@ -218,6 +219,14 @@ const CAUSE_LABEL = {
218
219
  'prefix-change': 'prefix changed (system prompt / tools / context edit)',
219
220
  };
220
221
 
222
+ // F6 — one-line HUD for a Claude Code statusLine command (mirrors
223
+ // watch-mode.js renderStatusLine). Takes the metrics from computeCacheEconomics.
224
+ function renderCacheStatusLine(metrics) {
225
+ if (!metrics || !metrics.turns) return 'agentic-security: no session cost yet';
226
+ const hit = Math.round(metrics.cacheHitRatio * 100);
227
+ return `agentic-security: ${money(metrics.actualUsd)} · ${hit}% cached · ${money(metrics.costPerTurnUsd)}/turn`;
228
+ }
229
+
221
230
  function formatCacheReport(result) {
222
231
  if (!result.ok) {
223
232
  return result.reason === 'no-transcript'
package/dist/985.index.js CHANGED
@@ -1420,6 +1420,7 @@ const query_cache_telemetry = {
1420
1420
  metrics: result.metrics,
1421
1421
  leaks: result.leaks,
1422
1422
  report: (0,cache_economics.formatCacheReport)(result),
1423
+ statusline: (0,cache_economics.renderCacheStatusLine)(result.metrics),
1423
1424
  };
1424
1425
  },
1425
1426
  };
@@ -1947,7 +1948,8 @@ function runStdio({
1947
1948
 
1948
1949
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1949
1950
  /* harmony export */ analyzeTranscript: () => (/* binding */ analyzeTranscript),
1950
- /* harmony export */ formatCacheReport: () => (/* binding */ formatCacheReport)
1951
+ /* harmony export */ formatCacheReport: () => (/* binding */ formatCacheReport),
1952
+ /* harmony export */ renderCacheStatusLine: () => (/* binding */ renderCacheStatusLine)
1951
1953
  /* harmony export */ });
1952
1954
  /* unused harmony export _internal */
1953
1955
  /* harmony import */ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3024);
@@ -2158,6 +2160,14 @@ const CAUSE_LABEL = {
2158
2160
  'prefix-change': 'prefix changed (system prompt / tools / context edit)',
2159
2161
  };
2160
2162
 
2163
+ // F6 — one-line HUD for a Claude Code statusLine command (mirrors
2164
+ // watch-mode.js renderStatusLine). Takes the metrics from computeCacheEconomics.
2165
+ function renderCacheStatusLine(metrics) {
2166
+ if (!metrics || !metrics.turns) return 'agentic-security: no session cost yet';
2167
+ const hit = Math.round(metrics.cacheHitRatio * 100);
2168
+ return `agentic-security: ${money(metrics.actualUsd)} · ${hit}% cached · ${money(metrics.costPerTurnUsd)}/turn`;
2169
+ }
2170
+
2161
2171
  function formatCacheReport(result) {
2162
2172
  if (!result.ok) {
2163
2173
  return result.reason === 'no-transcript'