hillclimb 0.8.11 → 0.8.13

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.
@@ -8298,6 +8298,12 @@ var patterns_local_default = {
8298
8298
  var DELIMITER_SUFFIX = /\(=\| =\|:\| :\)$/;
8299
8299
  var HAS_VALUE_MATCHER = /[[{+*]|\\[wdWDsS]/;
8300
8300
  var GREEDY_TAIL = /\.\+$|\.\*$/;
8301
+ var PREFIX_RUNS = {
8302
+ "[0-9a-z._-]+.rds.amazonaws.com": "[0-9a-z._-]+",
8303
+ "[\\w\\-]*sq0i[a-z]{2}-[0-9A-Za-z\\-_]{22,43}": "[\\w-]+",
8304
+ "[\\w\\-]*sq0c[a-z]{2}-[0-9A-Za-z\\-_]{40,50}": "[\\w-]+",
8305
+ "[0-9]+:AA[0-9A-Za-z\\-_]{33}": "[0-9]+"
8306
+ };
8301
8307
  var PLACEHOLDER_VALUE = /your[-_ ]|xxxxx|example|sample|dummy|placeholder|change[-_]?me|redacted|insert[-_ ]|fixme|1234567890|abcdefgh/i;
8302
8308
  var LEADING_TEMPLATE = /^[$%{<*#]/;
8303
8309
  var FILLER_RUN = /^(?:x+|\*+|-+|\.+)$/i;
@@ -8402,9 +8408,11 @@ function compilePatterns() {
8402
8408
  if (GREEDY_TAIL.test(p.regex)) continue;
8403
8409
  if (p.validator && !(p.validator in VALIDATORS)) continue;
8404
8410
  try {
8411
+ const prefixRun = PREFIX_RUNS[p.regex];
8405
8412
  patterns.push({
8406
8413
  name: p.name,
8407
- regex: new RegExp(p.regex, p.flags ? `g${p.flags}` : "g"),
8414
+ regex: new RegExp(p.regex, `g${prefixRun ? "y" : ""}${p.flags ?? ""}`),
8415
+ prefixRun: prefixRun ? new RegExp(prefixRun, `g${p.flags ?? ""}`) : void 0,
8408
8416
  groupCount: countCaptureGroups(p.regex),
8409
8417
  validate: p.validator ? VALIDATORS[p.validator] : void 0,
8410
8418
  context: p.context ? new RegExp(p.context, "i") : void 0,
@@ -8416,12 +8424,24 @@ function compilePatterns() {
8416
8424
  }
8417
8425
  return patterns;
8418
8426
  }
8419
- function applyPattern(content, regex, groupCount, validate) {
8427
+ function applyPattern(content, regex, groupCount, validate, prefixRun) {
8420
8428
  let count = 0;
8421
8429
  let result = "";
8422
8430
  let lastIndex = 0;
8423
8431
  regex.lastIndex = 0;
8424
- let match = regex.exec(content);
8432
+ const nextMatch = () => {
8433
+ if (!prefixRun) return regex.exec(content);
8434
+ prefixRun.lastIndex = regex.lastIndex;
8435
+ let run = prefixRun.exec(content);
8436
+ while (run !== null) {
8437
+ regex.lastIndex = run.index;
8438
+ const match2 = regex.exec(content);
8439
+ if (match2 !== null) return match2;
8440
+ run = prefixRun.exec(content);
8441
+ }
8442
+ return null;
8443
+ };
8444
+ let match = nextMatch();
8425
8445
  if (match === null) {
8426
8446
  return { value: content, count: 0 };
8427
8447
  }
@@ -8442,7 +8462,7 @@ function applyPattern(content, regex, groupCount, validate) {
8442
8462
  if (fullMatch.length === 0) {
8443
8463
  regex.lastIndex++;
8444
8464
  }
8445
- match = regex.exec(content);
8465
+ match = nextMatch();
8446
8466
  continue;
8447
8467
  }
8448
8468
  count++;
@@ -8458,7 +8478,7 @@ function applyPattern(content, regex, groupCount, validate) {
8458
8478
  if (fullMatch.length === 0) {
8459
8479
  regex.lastIndex++;
8460
8480
  }
8461
- match = regex.exec(content);
8481
+ match = nextMatch();
8462
8482
  }
8463
8483
  result += content.slice(lastIndex);
8464
8484
  return { value: result, count };
@@ -8483,13 +8503,21 @@ function redactString(value, patterns, owningKey = null) {
8483
8503
  const keyHit = owningKey !== null && p.context.test(owningKey);
8484
8504
  if (!keyHit && (p.keyOnlyContext || !p.context.test(result))) continue;
8485
8505
  }
8486
- const applied = applyPattern(result, p.regex, p.groupCount, p.validate);
8506
+ const applied = applyPattern(
8507
+ result,
8508
+ p.regex,
8509
+ p.groupCount,
8510
+ p.validate,
8511
+ p.prefixRun
8512
+ );
8487
8513
  result = applied.value;
8488
8514
  totalCount += applied.count;
8489
8515
  }
8490
8516
  return { value: result, count: totalCount };
8491
8517
  }
8492
8518
  var keyMaskCaches = /* @__PURE__ */ new WeakMap();
8519
+ var memoStringUnits = /* @__PURE__ */ new WeakMap();
8520
+ var MAX_MEMO_STRING_UNITS = 8 * 1024 * 1024;
8493
8521
  function contextMaskForKey(key, patterns) {
8494
8522
  let cache = keyMaskCaches.get(patterns);
8495
8523
  if (!cache) {
@@ -8502,16 +8530,24 @@ function contextMaskForKey(key, patterns) {
8502
8530
  for (let i = 0; i < patterns.length; i++) {
8503
8531
  if (patterns[i].context?.test(key)) mask += `${i},`;
8504
8532
  }
8505
- if (cache.size < 1e4) cache.set(key, mask);
8533
+ if (cache.size < 1e4 && key.length <= 256) cache.set(key, mask);
8506
8534
  return mask;
8507
8535
  }
8508
8536
  function memoizedRedact(value, patterns, memo, owningKey) {
8537
+ if (value.length > MAX_MEMO_STRING_UNITS) {
8538
+ return redactString(value, patterns, owningKey);
8539
+ }
8509
8540
  const mask = owningKey === null ? "" : contextMaskForKey(owningKey, patterns);
8510
8541
  const memoKey = mask === "" ? `v${value}` : `k${mask}\0${value}`;
8511
8542
  const cached = memo.get(memoKey);
8512
8543
  if (cached) return cached;
8513
8544
  const result = redactString(value, patterns, owningKey);
8514
- memo.set(memoKey, result);
8545
+ const retained = memoStringUnits.get(memo) ?? 0;
8546
+ const units = memoKey.length + result.value.length;
8547
+ if (memo.size < 2048 && retained + units <= MAX_MEMO_STRING_UNITS) {
8548
+ memo.set(memoKey, result);
8549
+ memoStringUnits.set(memo, retained + units);
8550
+ }
8515
8551
  return result;
8516
8552
  }
8517
8553
  function walkAndRedactAll(value, patterns, memo, owningKey = null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hillclimb",
3
- "version": "0.8.11",
3
+ "version": "0.8.13",
4
4
  "description": "Extract and export AI coding tool logs grouped by repo",
5
5
  "license": "MIT",
6
6
  "type": "module",