@swestash/agent-lens 0.9.3 → 0.9.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.
@@ -2424,7 +2424,7 @@ function parseStored(json, where) {
2424
2424
  }
2425
2425
 
2426
2426
  // ../ingest/dist/classify.js
2427
- var CLASSIFIER_VERSION = 2;
2427
+ var CLASSIFIER_VERSION = 3;
2428
2428
  var CATEGORIES = ["bugfix", "refactor", "docs", "ops", "review", "feature", "chore"];
2429
2429
  var BANDS = [
2430
2430
  { max: 22, band: "trivial" },
@@ -2467,14 +2467,23 @@ function band(score) {
2467
2467
  return "xl";
2468
2468
  }
2469
2469
  var clamp01 = (x) => x < 0 ? 0 : x > 1 ? 1 : x;
2470
+ var WORD_RE = /* @__PURE__ */ new Map();
2471
+ function wordRe(phrase) {
2472
+ let re = WORD_RE.get(phrase);
2473
+ if (!re) {
2474
+ const escaped = phrase.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2475
+ re = new RegExp(`\\b${escaped}\\b`, "g");
2476
+ WORD_RE.set(phrase, re);
2477
+ }
2478
+ return re;
2479
+ }
2470
2480
  function hits(text, words) {
2471
2481
  let n = 0;
2472
2482
  for (const w of words) {
2473
- let i = text.indexOf(w);
2474
- while (i !== -1) {
2483
+ const re = wordRe(w);
2484
+ re.lastIndex = 0;
2485
+ while (re.exec(text) !== null)
2475
2486
  n++;
2476
- i = text.indexOf(w, i + w.length);
2477
- }
2478
2487
  }
2479
2488
  return n;
2480
2489
  }
@@ -2496,9 +2505,9 @@ function scoreCategories(s, text, files) {
2496
2505
  scores.bugfix += hits(t, ["bug", "fix", "broken", "crash", "regression", "traceback", "stack trace", "failing", "error", "exception", "not working"]) * 1;
2497
2506
  scores.refactor += hits(t, ["refactor", "clean up", "cleanup", "rename", "extract", "simplify", "dead code", "tidy", "reorganize", "restructure"]) * 1;
2498
2507
  scores.docs += hits(t, ["readme", "document", "documentation", "changelog", "docstring", "comment", "write docs", "usage guide"]) * 1;
2499
- scores.ops += hits(t, ["deploy", "docker", "pipeline", "ci/cd", "ci ", "systemd", "infra", "kubernetes", "terraform", "release", "rollback", "container"]) * 1;
2508
+ scores.ops += hits(t, ["deploy", "docker", "pipeline", "ci/cd", "ci", "systemd", "infra", "kubernetes", "terraform", "release", "rollback", "container"]) * 1;
2500
2509
  scores.review += hits(t, ["review", "audit", "inspect", "look over", "feedback on"]) * 1;
2501
- scores.feature += hits(t, ["add ", "implement", "build ", "create ", "feature", "support for", "new feature"]) * 0.8;
2510
+ scores.feature += hits(t, ["add", "implement", "build", "create", "feature", "support for", "new feature"]) * 0.8;
2502
2511
  const docFiles = s.loc.files > 0 ? countMatch(files, DOC_EXT) : 0;
2503
2512
  const opsFiles = s.loc.files > 0 ? countMatch(files, OPS_FILE) : 0;
2504
2513
  if (s.loc.files > 0) {
@@ -4325,6 +4334,16 @@ function orderBy(columns, sort, fallback, dir) {
4325
4334
  const col = sort !== void 0 && Object.hasOwn(columns, sort) ? columns[sort] : columns[fallback];
4326
4335
  return `${col} ${dir === "asc" ? "ASC" : "DESC"}`;
4327
4336
  }
4337
+ function pageLimit(raw, fallback, max) {
4338
+ const n = Math.floor(Number(raw));
4339
+ if (!Number.isFinite(n) || n < 1)
4340
+ return Math.min(fallback, max);
4341
+ return Math.min(n, max);
4342
+ }
4343
+ function pageOffset(raw) {
4344
+ const n = Math.floor(Number(raw));
4345
+ return Number.isFinite(n) && n > 0 ? n : 0;
4346
+ }
4328
4347
  function pushGrouped(map, key, value) {
4329
4348
  const list = map.get(key);
4330
4349
  if (list)
@@ -5071,7 +5090,11 @@ function renderSessionExport(db, id, level) {
5071
5090
  }));
5072
5091
  const { markdown } = exportMarkdown({ id: s.id, title: s.title, source: s.source_id, project: s.project_path, model: null, started_at: s.started_at, ended_at: s.ended_at }, events, { level });
5073
5092
  const suffix = level === "off" ? "" : ".redacted";
5074
- return { markdown, filename: `session-${id.slice(0, 8)}${suffix}.md` };
5093
+ return { markdown, filename: `session-${filenameSafe(id.slice(0, 8))}${suffix}.md` };
5094
+ }
5095
+ function filenameSafe(s) {
5096
+ const cleaned = s.replace(/[^A-Za-z0-9._-]/g, "_");
5097
+ return cleaned === "" ? "session" : cleaned;
5075
5098
  }
5076
5099
 
5077
5100
  // ../server/dist/dashboard.js
@@ -5568,8 +5591,8 @@ async function createApp(db, opts = {}) {
5568
5591
  errorType: q.error_type ? q.error_type.split(",").filter(Boolean) : void 0,
5569
5592
  sort: ["started", "title", "turns", "tokens", "cost", "duration", "errors", "security"].find((s) => s === q.sort),
5570
5593
  dir: q.dir === "asc" ? "asc" : q.dir === "desc" ? "desc" : void 0,
5571
- limit: Math.min(Number(q.limit) || 50, 200),
5572
- offset: Number(q.offset) || 0
5594
+ limit: pageLimit(q.limit, 50, 200),
5595
+ offset: pageOffset(q.offset)
5573
5596
  });
5574
5597
  });
5575
5598
  app.get("/api/sessions/:id", async (req, reply) => {
@@ -5604,8 +5627,8 @@ async function createApp(db, opts = {}) {
5604
5627
  ...findingFilters(q),
5605
5628
  sort: ["severity", "session", "rule", "category", "time"].find((s) => s === q.sort),
5606
5629
  dir: q.dir === "asc" ? "asc" : q.dir === "desc" ? "desc" : void 0,
5607
- limit: Math.min(Number(q.limit) || 50, 5e3),
5608
- offset: Number(q.offset) || 0
5630
+ limit: pageLimit(q.limit, 50, 5e3),
5631
+ offset: pageOffset(q.offset)
5609
5632
  });
5610
5633
  });
5611
5634
  app.get("/api/security/mutes", async () => triageDb ? listMutes(triageDb) : []);
@@ -5678,8 +5701,8 @@ async function createApp(db, opts = {}) {
5678
5701
  project: q.project,
5679
5702
  sort,
5680
5703
  dir: q.dir === "asc" ? "asc" : "desc",
5681
- limit: Math.min(Number(q.limit) || 50, 200),
5682
- offset: Number(q.offset) || 0
5704
+ limit: pageLimit(q.limit, 50, 200),
5705
+ offset: pageOffset(q.offset)
5683
5706
  });
5684
5707
  });
5685
5708
  app.get("/api/file", async (req, reply) => {