@swestash/agent-lens 0.5.3 → 0.5.4

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Agent Lens
2
2
 
3
- > Passively collect, browse, and analyze your Claude Code CLI session traces — **100% local**.
3
+ > Passively collect, search, and audit your Claude Code CLI session traces — **100% local**.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@swestash/agent-lens)](https://www.npmjs.com/package/@swestash/agent-lens)
6
6
  ![Node](https://img.shields.io/badge/node-%E2%89%A524-brightgreen)
@@ -9,8 +9,9 @@
9
9
 
10
10
  Claude Code records rich per-session telemetry under `~/.claude/`, but prunes it on a rolling
11
11
  **30-day window**. Agent Lens continuously copies that data out before it's lost, normalizes it into
12
- a queryable SQLite store, and gives you a browsable transcript viewer plus analytics dashboards —
13
- **without a single byte leaving your machine**.
12
+ a queryable SQLite store, and gives you three things over it — a searchable transcript browser,
13
+ usage/cost dashboards, and a deterministic, no-AI **audit of what the agent actually did on your
14
+ machine** — **without a single byte leaving your machine**.
14
15
 
15
16
  ## Install
16
17
 
@@ -2319,7 +2319,7 @@ function classify(db, dirty) {
2319
2319
 
2320
2320
  // ../ingest/dist/detect.js
2321
2321
  import { createHash } from "crypto";
2322
- var DETECTOR_VERSION = 6;
2322
+ var DETECTOR_VERSION = 7;
2323
2323
  function evidence(s, max = 200) {
2324
2324
  const one = s.replace(/\s+/g, " ").trim();
2325
2325
  return one.length > max ? one.slice(0, max - 1) + "\u2026" : one;
@@ -2341,6 +2341,8 @@ var SECRET_VALUE_PATTERNS = [
2341
2341
  { re: /\bsk-[A-Za-z0-9]{20,}\b/, label: "api-secret-key" }
2342
2342
  ];
2343
2343
  var isBash = (t) => t === "Bash";
2344
+ var SQL_DESTRUCTIVE = /\b(DROP\s+(TABLE|DATABASE|SCHEMA)|TRUNCATE(\s+TABLE)?)\b/i;
2345
+ var SQL_CLIENT = /\b(psql|pgcli|mysql|mysqladmin|mariadb|sqlite3?|sqlcmd|usql|mongo|mongosh|clickhouse-client|cockroach|snowsql|bq)\b/i;
2344
2346
  var stripComments = (c) => c.replace(/(^|\s)#[^\n]*/g, "$1");
2345
2347
  var neutralizeEcho = (c) => c.replace(/((?:^|[;&|\n(])\s*)(?:echo|printf)\b(?:"(?:[^"\\]|\\.)*"|'[^']*'|[^;&|\n])*/gi, "$1echo");
2346
2348
  var blankHeredoc = (c) => c.replace(/<<-?\s*(['"]?)(\w+)\1[\s\S]*?\n\s*\2\b/g, "<<HEREDOC");
@@ -2418,14 +2420,22 @@ var RULES = [
2418
2420
  tools: ["Bash"],
2419
2421
  baseSeverity: "high",
2420
2422
  test(ctx) {
2421
- const c = ctx.commandBare;
2422
- if (!c)
2423
+ if (!ctx.commandBare)
2424
+ return null;
2425
+ const c = ctx.commandBare.replace(/\bgit\s+rm\b/gi, "gitrm");
2426
+ const rmSeg = c.match(/\brm\b[^|;&\n]*/i)?.[0];
2427
+ if (!rmSeg)
2423
2428
  return null;
2424
- const rf = /\brm\s+[^|;&\n]*(-[a-z]*r[a-z]*f|-[a-z]*f[a-z]*r|--recursive[^|;&\n]*--force|--force[^|;&\n]*--recursive)/i;
2425
- if (!rf.test(c))
2429
+ const combined = /(?:^|\s)-(?=[a-zA-Z]*[rR])(?=[a-zA-Z]*f)[a-zA-Z]+(?=\s|$)/.test(rmSeg);
2430
+ const recursive = /(?:^|\s)(?:-[a-zA-Z]*[rR][a-zA-Z]*|--recursive)(?=\s|$)/.test(rmSeg);
2431
+ const force = /(?:^|\s)(?:-[a-zA-Z]*f[a-zA-Z]*|--force)(?=\s|$)/.test(rmSeg);
2432
+ if (!combined && !(recursive && force))
2426
2433
  return null;
2427
2434
  const dangerousTarget = HOME_OR_ROOT_TARGET.test(c) || /\s\/(?:\s|$)/.test(c) || /\brm\b[^|;&\n]*\*/.test(c);
2428
- return { evidence: evidence(ctx.command), severity: dangerousTarget ? "critical" : "high", mods: { dangerous_target: dangerousTarget } };
2435
+ const targets = rmSeg.split(/\s+/).slice(1).filter((a) => a && !a.startsWith("-"));
2436
+ const tempOnly = targets.length > 0 && targets.every((t) => TEMP_PATH.test(t));
2437
+ const severity = dangerousTarget ? "critical" : tempOnly ? "low" : "high";
2438
+ return { evidence: evidence(ctx.command), severity, mods: { dangerous_target: dangerousTarget, temp_target: tempOnly } };
2429
2439
  }
2430
2440
  },
2431
2441
  {
@@ -2468,10 +2478,12 @@ var RULES = [
2468
2478
  baseSeverity: "high",
2469
2479
  test(ctx) {
2470
2480
  const query = typeof ctx.input?.query === "string" ? ctx.input.query : null;
2471
- const hay = ctx.commandCode ?? query;
2472
- if (!hay || !/\b(DROP\s+(TABLE|DATABASE|SCHEMA)|TRUNCATE(\s+TABLE)?)\b/i.test(hay))
2473
- return null;
2474
- return { evidence: evidence(ctx.command ?? query) };
2481
+ if (query && SQL_DESTRUCTIVE.test(query))
2482
+ return { evidence: evidence(ctx.command ?? query) };
2483
+ const code = ctx.commandCode;
2484
+ if (code && SQL_CLIENT.test(code) && SQL_DESTRUCTIVE.test(code))
2485
+ return { evidence: evidence(ctx.command) };
2486
+ return null;
2475
2487
  }
2476
2488
  },
2477
2489
  {