@ankurhalder/codebase-snapshot 4.0.1 → 4.0.3

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/dist/bin.js CHANGED
@@ -1334,12 +1334,8 @@ function isSensitivePath(relativePath) {
1334
1334
  }
1335
1335
  return matchesSensitiveList(posixPath, base);
1336
1336
  }
1337
- var activeSecretRules = null;
1338
- function setActiveSecretRules(rules) {
1339
- activeSecretRules = rules === null ? null : [...rules];
1340
- }
1341
1337
  function pathScanRules(extraRules) {
1342
- const fallback = extraRules ?? activeSecretRules ?? [];
1338
+ const fallback = extraRules ?? [];
1343
1339
  return [...DEFAULT_SECRET_PATTERNS, ...fallback];
1344
1340
  }
1345
1341
  function findSecretInPath(relativePath, extraRules) {
@@ -1379,7 +1375,12 @@ function findSecretInPath(relativePath, extraRules) {
1379
1375
  function maskSkipPaths(records, extraRules) {
1380
1376
  return records.map((record) => {
1381
1377
  const hit = findSecretInPath(record.path, extraRules);
1382
- return hit ? { ...record, path: hit.masked } : record;
1378
+ const detail = record.detail ? findSecretInPath(record.detail, extraRules) : null;
1379
+ return {
1380
+ ...record,
1381
+ path: hit ? hit.masked : record.path,
1382
+ ...detail ? { detail: detail.masked } : {}
1383
+ };
1383
1384
  });
1384
1385
  }
1385
1386
  function globToRegExp(glob) {
@@ -2520,7 +2521,6 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
2520
2521
  ...aliasedRules ?? []
2521
2522
  ]);
2522
2523
  const secretRules = disableDefaultPatterns ? compiledCustomRules : [...compileSecretRules(DEFAULT_SECRET_PATTERNS), ...compiledCustomRules];
2523
- setActiveSecretRules(secretRules);
2524
2524
  const cliMonolith = cliOptions?.includeMonolith;
2525
2525
  const includeMonolith = cliMonolith ?? strictBoolean(userConfig?.includeMonolith, false, "`includeMonolith`");
2526
2526
  const artifacts = resolveArtifacts(
@@ -5228,6 +5228,9 @@ function validateSnapshot(configInput) {
5228
5228
  });
5229
5229
  }
5230
5230
  }
5231
+ const maskValue = (value) => findSecretInPath(value, config.secretRules)?.masked ?? value;
5232
+ const currentExcludes = config.excludePatterns.map(maskValue);
5233
+ const currentInclude = config.include.map(maskValue);
5231
5234
  const recorded = manifest.config;
5232
5235
  if (recorded && typeof recorded === "object") {
5233
5236
  if (recorded.maxPartBytes !== config.maxPartBytes) {
@@ -5256,15 +5259,15 @@ function validateSnapshot(configInput) {
5256
5259
  );
5257
5260
  }
5258
5261
  const recordedExcludes = Array.isArray(recorded.excludePatterns) ? recorded.excludePatterns : [];
5259
- if (recordedExcludes.join("\0") !== config.excludePatterns.join("\0")) {
5262
+ if (recordedExcludes.join("\0") !== currentExcludes.join("\0")) {
5260
5263
  drift.configMismatches.push(
5261
- `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${config.excludePatterns.join(", ")}]`
5264
+ `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${currentExcludes.join(", ")}]`
5262
5265
  );
5263
5266
  }
5264
5267
  const recordedInclude = Array.isArray(recorded.include) ? recorded.include : [];
5265
- if (recordedInclude.join("\0") !== config.include.join("\0")) {
5268
+ if (recordedInclude.join("\0") !== currentInclude.join("\0")) {
5266
5269
  drift.configMismatches.push(
5267
- `include: manifest [${recordedInclude.join(", ")}] vs current [${config.include.join(", ")}]`
5270
+ `include: manifest [${recordedInclude.join(", ")}] vs current [${currentInclude.join(", ")}]`
5268
5271
  );
5269
5272
  }
5270
5273
  if (recorded?.artifacts && typeof recorded.artifacts === "object") {
@@ -5444,7 +5447,7 @@ function validateSnapshot(configInput) {
5444
5447
 
5445
5448
  // src/index.ts
5446
5449
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5447
- var GENERATOR_VERSION = "4.0.1";
5450
+ var GENERATOR_VERSION = "4.0.3";
5448
5451
  var SCHEMA_VERSION = "3.0.0";
5449
5452
  function sha256Hex2(input) {
5450
5453
  return crypto3.createHash("sha256").update(input).digest("hex");
@@ -6285,6 +6288,7 @@ function generateSnapshot(configInput, options) {
6285
6288
  const truncatedPreviewCount = files.filter((file) => file.isPreviewTruncated).length;
6286
6289
  const validationErrors = verifyInMemory(files, parts, maxEffectiveBudget);
6287
6290
  const totalContentBytes = files.reduce((total, file) => total + file.includedBytes, 0);
6291
+ const maskName = (value) => maskPathText(value, config.secretRules);
6288
6292
  const manifest = {
6289
6293
  schemaVersion: SCHEMA_VERSION,
6290
6294
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6305,13 +6309,13 @@ function generateSnapshot(configInput, options) {
6305
6309
  includeMonolith: config.includeMonolith,
6306
6310
  includeSensitiveFiles: config.includeSensitiveFiles,
6307
6311
  artifacts: { ...config.artifacts },
6308
- include: [...config.include],
6312
+ include: [...config.include].map(maskName),
6309
6313
  preset: config.preset,
6310
6314
  layersMode: config.layersMode,
6311
6315
  budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6312
- excludePatterns: [...config.excludePatterns],
6313
- layers: config.layers.map((layer2) => layer2.name),
6314
- kinds: config.kinds.map((kind) => kind.kind)
6316
+ excludePatterns: [...config.excludePatterns].map(maskName),
6317
+ layers: config.layers.map((layer2) => maskName(layer2.name)),
6318
+ kinds: config.kinds.map((kind) => maskName(kind.kind))
6315
6319
  },
6316
6320
  counts: {
6317
6321
  totalFiles: files.length,
@@ -6967,8 +6971,8 @@ function buildAgentContract() {
6967
6971
  "snapshot.config.mjs",
6968
6972
  "snapshot.config.cjs",
6969
6973
  "snapshot.config.json",
6970
- ".snapshotrc",
6971
6974
  ".snapshotrc.json",
6975
+ ".snapshotrc",
6972
6976
  'package.json \u2192 "snapshot" key'
6973
6977
  ],
6974
6978
  settings: [
@@ -7909,6 +7913,8 @@ async function runWatchLoop(invocation, resolved) {
7909
7913
  (segment) => segment === outName || segment === tmpName || segment.startsWith(`${outName}.backup-`) || VCS_SEGMENTS.has(segment)
7910
7914
  );
7911
7915
  let running = false;
7916
+ let quietUntil = 0;
7917
+ const QUIET_MS = 1500;
7912
7918
  const regenerate = async () => {
7913
7919
  if (running) return;
7914
7920
  running = true;
@@ -7946,6 +7952,7 @@ async function runWatchLoop(invocation, resolved) {
7946
7952
  } catch (err) {
7947
7953
  warn(`\u274C ${err.message}`);
7948
7954
  } finally {
7955
+ quietUntil = performance.now() + QUIET_MS;
7949
7956
  running = false;
7950
7957
  }
7951
7958
  };
@@ -7953,6 +7960,7 @@ async function runWatchLoop(invocation, resolved) {
7953
7960
  void regenerate();
7954
7961
  let timer = null;
7955
7962
  const watcher = fs11.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
7963
+ if (performance.now() < quietUntil) return;
7956
7964
  if (filename) {
7957
7965
  const changed = path12.resolve(resolved.cwd, filename.toString());
7958
7966
  if (isGenerated(changed)) return;
@@ -2188,12 +2188,8 @@ function isSensitivePath(relativePath) {
2188
2188
  }
2189
2189
  return matchesSensitiveList(posixPath, base);
2190
2190
  }
2191
- var activeSecretRules = null;
2192
- function setActiveSecretRules(rules) {
2193
- activeSecretRules = rules === null ? null : [...rules];
2194
- }
2195
2191
  function pathScanRules(extraRules) {
2196
- const fallback = extraRules ?? activeSecretRules ?? [];
2192
+ const fallback = extraRules ?? [];
2197
2193
  return [...DEFAULT_SECRET_PATTERNS, ...fallback];
2198
2194
  }
2199
2195
  function findSecretInPath(relativePath, extraRules) {
@@ -2233,7 +2229,12 @@ function findSecretInPath(relativePath, extraRules) {
2233
2229
  function maskSkipPaths(records, extraRules) {
2234
2230
  return records.map((record) => {
2235
2231
  const hit = findSecretInPath(record.path, extraRules);
2236
- return hit ? { ...record, path: hit.masked } : record;
2232
+ const detail = record.detail ? findSecretInPath(record.detail, extraRules) : null;
2233
+ return {
2234
+ ...record,
2235
+ path: hit ? hit.masked : record.path,
2236
+ ...detail ? { detail: detail.masked } : {}
2237
+ };
2237
2238
  });
2238
2239
  }
2239
2240
  function globToRegExp(glob) {
@@ -2923,6 +2924,9 @@ async function loadConfigFileDetailed(cwd) {
2923
2924
  }
2924
2925
  async function loadConfigFile(cwd) {
2925
2926
  const loaded = await loadConfigFileDetailed(cwd);
2927
+ if (loaded.errors.length > 0) {
2928
+ throw new Error(`The config file could not be read: ${loaded.errors.join("; ")}`);
2929
+ }
2926
2930
  return loaded.config;
2927
2931
  }
2928
2932
  var MIN_MAX_PART_BYTES = 4096;
@@ -3244,7 +3248,6 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
3244
3248
  ...aliasedRules ?? []
3245
3249
  ]);
3246
3250
  const secretRules = disableDefaultPatterns ? compiledCustomRules : [...compileSecretRules(DEFAULT_SECRET_PATTERNS), ...compiledCustomRules];
3247
- setActiveSecretRules(secretRules);
3248
3251
  const cliMonolith = cliOptions?.includeMonolith;
3249
3252
  const includeMonolith = cliMonolith ?? strictBoolean(userConfig?.includeMonolith, false, "`includeMonolith`");
3250
3253
  const artifacts = resolveArtifacts(
@@ -4273,6 +4276,9 @@ function validateSnapshot(configInput) {
4273
4276
  });
4274
4277
  }
4275
4278
  }
4279
+ const maskValue = (value) => findSecretInPath(value, config.secretRules)?.masked ?? value;
4280
+ const currentExcludes = config.excludePatterns.map(maskValue);
4281
+ const currentInclude = config.include.map(maskValue);
4276
4282
  const recorded = manifest.config;
4277
4283
  if (recorded && typeof recorded === "object") {
4278
4284
  if (recorded.maxPartBytes !== config.maxPartBytes) {
@@ -4301,15 +4307,15 @@ function validateSnapshot(configInput) {
4301
4307
  );
4302
4308
  }
4303
4309
  const recordedExcludes = Array.isArray(recorded.excludePatterns) ? recorded.excludePatterns : [];
4304
- if (recordedExcludes.join("\0") !== config.excludePatterns.join("\0")) {
4310
+ if (recordedExcludes.join("\0") !== currentExcludes.join("\0")) {
4305
4311
  drift.configMismatches.push(
4306
- `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${config.excludePatterns.join(", ")}]`
4312
+ `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${currentExcludes.join(", ")}]`
4307
4313
  );
4308
4314
  }
4309
4315
  const recordedInclude = Array.isArray(recorded.include) ? recorded.include : [];
4310
- if (recordedInclude.join("\0") !== config.include.join("\0")) {
4316
+ if (recordedInclude.join("\0") !== currentInclude.join("\0")) {
4311
4317
  drift.configMismatches.push(
4312
- `include: manifest [${recordedInclude.join(", ")}] vs current [${config.include.join(", ")}]`
4318
+ `include: manifest [${recordedInclude.join(", ")}] vs current [${currentInclude.join(", ")}]`
4313
4319
  );
4314
4320
  }
4315
4321
  if (recorded?.artifacts && typeof recorded.artifacts === "object") {
@@ -5404,7 +5410,7 @@ async function runInit(options) {
5404
5410
 
5405
5411
  // src/index.ts
5406
5412
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5407
- var GENERATOR_VERSION = "4.0.1";
5413
+ var GENERATOR_VERSION = "4.0.3";
5408
5414
  var SCHEMA_VERSION = "3.0.0";
5409
5415
  function sha256Hex2(input) {
5410
5416
  return crypto.createHash("sha256").update(input).digest("hex");
@@ -6245,6 +6251,7 @@ function generateSnapshot(configInput, options) {
6245
6251
  const truncatedPreviewCount = files.filter((file) => file.isPreviewTruncated).length;
6246
6252
  const validationErrors = verifyInMemory(files, parts, maxEffectiveBudget);
6247
6253
  const totalContentBytes = files.reduce((total, file) => total + file.includedBytes, 0);
6254
+ const maskName = (value) => maskPathText(value, config.secretRules);
6248
6255
  const manifest = {
6249
6256
  schemaVersion: SCHEMA_VERSION,
6250
6257
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6265,13 +6272,13 @@ function generateSnapshot(configInput, options) {
6265
6272
  includeMonolith: config.includeMonolith,
6266
6273
  includeSensitiveFiles: config.includeSensitiveFiles,
6267
6274
  artifacts: { ...config.artifacts },
6268
- include: [...config.include],
6275
+ include: [...config.include].map(maskName),
6269
6276
  preset: config.preset,
6270
6277
  layersMode: config.layersMode,
6271
6278
  budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6272
- excludePatterns: [...config.excludePatterns],
6273
- layers: config.layers.map((layer2) => layer2.name),
6274
- kinds: config.kinds.map((kind) => kind.kind)
6279
+ excludePatterns: [...config.excludePatterns].map(maskName),
6280
+ layers: config.layers.map((layer2) => maskName(layer2.name)),
6281
+ kinds: config.kinds.map((kind) => maskName(kind.kind))
6275
6282
  },
6276
6283
  counts: {
6277
6284
  totalFiles: files.length,
@@ -6451,5 +6458,5 @@ async function generateSnapshotAsync(configInput, options) {
6451
6458
  }
6452
6459
 
6453
6460
  export { ARTIFACT_NAMES, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, GENERATOR_NAME, GENERATOR_VERSION, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, PRESETS, PromptCancelled, SCHEMA_VERSION, anchorForPath, assertReplaceable, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, fenceForText, generateProjectTree, generateSnapshot, generateSnapshotAsync, getPreset, globToRegExp, isBinaryBuffer, isBinaryExtension, isBinaryFile, isInteractive, isResolvedConfig, isSensitivePath, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, profileForPath, renderConfig, renderDiffText, renderExplainText, renderMinimalConfig, renumberParts, resolveConfig, resolveSafeOutputDirs, runInit, scanAndRedactSecrets, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, truncatePreview, truncateToBytes, unknownPresetMessage, validateSnapshot };
6454
- //# sourceMappingURL=chunk-RGIMMEAW.js.map
6455
- //# sourceMappingURL=chunk-RGIMMEAW.js.map
6461
+ //# sourceMappingURL=chunk-L7QBLC4C.js.map
6462
+ //# sourceMappingURL=chunk-L7QBLC4C.js.map
package/dist/cli.cjs CHANGED
@@ -1356,12 +1356,8 @@ function isSensitivePath(relativePath) {
1356
1356
  }
1357
1357
  return matchesSensitiveList(posixPath, base);
1358
1358
  }
1359
- var activeSecretRules = null;
1360
- function setActiveSecretRules(rules) {
1361
- activeSecretRules = rules === null ? null : [...rules];
1362
- }
1363
1359
  function pathScanRules(extraRules) {
1364
- const fallback = extraRules ?? activeSecretRules ?? [];
1360
+ const fallback = extraRules ?? [];
1365
1361
  return [...DEFAULT_SECRET_PATTERNS, ...fallback];
1366
1362
  }
1367
1363
  function findSecretInPath(relativePath, extraRules) {
@@ -1401,7 +1397,12 @@ function findSecretInPath(relativePath, extraRules) {
1401
1397
  function maskSkipPaths(records, extraRules) {
1402
1398
  return records.map((record) => {
1403
1399
  const hit = findSecretInPath(record.path, extraRules);
1404
- return hit ? { ...record, path: hit.masked } : record;
1400
+ const detail = record.detail ? findSecretInPath(record.detail, extraRules) : null;
1401
+ return {
1402
+ ...record,
1403
+ path: hit ? hit.masked : record.path,
1404
+ ...detail ? { detail: detail.masked } : {}
1405
+ };
1405
1406
  });
1406
1407
  }
1407
1408
  function globToRegExp(glob) {
@@ -2533,7 +2534,6 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
2533
2534
  ...aliasedRules ?? []
2534
2535
  ]);
2535
2536
  const secretRules = disableDefaultPatterns ? compiledCustomRules : [...compileSecretRules(DEFAULT_SECRET_PATTERNS), ...compiledCustomRules];
2536
- setActiveSecretRules(secretRules);
2537
2537
  const cliMonolith = cliOptions?.includeMonolith;
2538
2538
  const includeMonolith = cliMonolith ?? strictBoolean(userConfig?.includeMonolith, false, "`includeMonolith`");
2539
2539
  const artifacts = resolveArtifacts(
@@ -5208,6 +5208,9 @@ function validateSnapshot(configInput) {
5208
5208
  });
5209
5209
  }
5210
5210
  }
5211
+ const maskValue = (value) => findSecretInPath(value, config.secretRules)?.masked ?? value;
5212
+ const currentExcludes = config.excludePatterns.map(maskValue);
5213
+ const currentInclude = config.include.map(maskValue);
5211
5214
  const recorded = manifest.config;
5212
5215
  if (recorded && typeof recorded === "object") {
5213
5216
  if (recorded.maxPartBytes !== config.maxPartBytes) {
@@ -5236,15 +5239,15 @@ function validateSnapshot(configInput) {
5236
5239
  );
5237
5240
  }
5238
5241
  const recordedExcludes = Array.isArray(recorded.excludePatterns) ? recorded.excludePatterns : [];
5239
- if (recordedExcludes.join("\0") !== config.excludePatterns.join("\0")) {
5242
+ if (recordedExcludes.join("\0") !== currentExcludes.join("\0")) {
5240
5243
  drift.configMismatches.push(
5241
- `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${config.excludePatterns.join(", ")}]`
5244
+ `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${currentExcludes.join(", ")}]`
5242
5245
  );
5243
5246
  }
5244
5247
  const recordedInclude = Array.isArray(recorded.include) ? recorded.include : [];
5245
- if (recordedInclude.join("\0") !== config.include.join("\0")) {
5248
+ if (recordedInclude.join("\0") !== currentInclude.join("\0")) {
5246
5249
  drift.configMismatches.push(
5247
- `include: manifest [${recordedInclude.join(", ")}] vs current [${config.include.join(", ")}]`
5250
+ `include: manifest [${recordedInclude.join(", ")}] vs current [${currentInclude.join(", ")}]`
5248
5251
  );
5249
5252
  }
5250
5253
  if (recorded?.artifacts && typeof recorded.artifacts === "object") {
@@ -5424,7 +5427,7 @@ function validateSnapshot(configInput) {
5424
5427
 
5425
5428
  // src/index.ts
5426
5429
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5427
- var GENERATOR_VERSION = "4.0.1";
5430
+ var GENERATOR_VERSION = "4.0.3";
5428
5431
  var SCHEMA_VERSION = "3.0.0";
5429
5432
  function sha256Hex2(input) {
5430
5433
  return crypto__namespace.createHash("sha256").update(input).digest("hex");
@@ -6265,6 +6268,7 @@ function generateSnapshot(configInput, options) {
6265
6268
  const truncatedPreviewCount = files.filter((file) => file.isPreviewTruncated).length;
6266
6269
  const validationErrors = verifyInMemory(files, parts, maxEffectiveBudget);
6267
6270
  const totalContentBytes = files.reduce((total, file) => total + file.includedBytes, 0);
6271
+ const maskName = (value) => maskPathText(value, config.secretRules);
6268
6272
  const manifest = {
6269
6273
  schemaVersion: SCHEMA_VERSION,
6270
6274
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6285,13 +6289,13 @@ function generateSnapshot(configInput, options) {
6285
6289
  includeMonolith: config.includeMonolith,
6286
6290
  includeSensitiveFiles: config.includeSensitiveFiles,
6287
6291
  artifacts: { ...config.artifacts },
6288
- include: [...config.include],
6292
+ include: [...config.include].map(maskName),
6289
6293
  preset: config.preset,
6290
6294
  layersMode: config.layersMode,
6291
6295
  budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6292
- excludePatterns: [...config.excludePatterns],
6293
- layers: config.layers.map((layer2) => layer2.name),
6294
- kinds: config.kinds.map((kind) => kind.kind)
6296
+ excludePatterns: [...config.excludePatterns].map(maskName),
6297
+ layers: config.layers.map((layer2) => maskName(layer2.name)),
6298
+ kinds: config.kinds.map((kind) => maskName(kind.kind))
6295
6299
  },
6296
6300
  counts: {
6297
6301
  totalFiles: files.length,
@@ -6947,8 +6951,8 @@ function buildAgentContract() {
6947
6951
  "snapshot.config.mjs",
6948
6952
  "snapshot.config.cjs",
6949
6953
  "snapshot.config.json",
6950
- ".snapshotrc",
6951
6954
  ".snapshotrc.json",
6955
+ ".snapshotrc",
6952
6956
  'package.json \u2192 "snapshot" key'
6953
6957
  ],
6954
6958
  settings: [
@@ -7897,6 +7901,8 @@ async function runWatchLoop(invocation, resolved) {
7897
7901
  (segment) => segment === outName || segment === tmpName || segment.startsWith(`${outName}.backup-`) || VCS_SEGMENTS.has(segment)
7898
7902
  );
7899
7903
  let running = false;
7904
+ let quietUntil = 0;
7905
+ const QUIET_MS = 1500;
7900
7906
  const regenerate = async () => {
7901
7907
  if (running) return;
7902
7908
  running = true;
@@ -7934,6 +7940,7 @@ async function runWatchLoop(invocation, resolved) {
7934
7940
  } catch (err) {
7935
7941
  warn(`\u274C ${err.message}`);
7936
7942
  } finally {
7943
+ quietUntil = performance.now() + QUIET_MS;
7937
7944
  running = false;
7938
7945
  }
7939
7946
  };
@@ -7941,6 +7948,7 @@ async function runWatchLoop(invocation, resolved) {
7941
7948
  void regenerate();
7942
7949
  let timer = null;
7943
7950
  const watcher = fs9__namespace.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
7951
+ if (performance.now() < quietUntil) return;
7944
7952
  if (filename) {
7945
7953
  const changed = path10__namespace.resolve(resolved.cwd, filename.toString());
7946
7954
  if (isGenerated(changed)) return;
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { parseByteSize, GENERATOR_VERSION, ARTIFACT_NAMES, getPreset, unknownPresetMessage, MIN_MAX_PART_BYTES, loadConfigFileDetailed, resolveConfig, validateSnapshot, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, GENERATOR_NAME, runInit, PromptCancelled, SCHEMA_VERSION, PRESETS, renderExplainText } from './chunk-RGIMMEAW.js';
1
+ import { parseByteSize, GENERATOR_VERSION, ARTIFACT_NAMES, getPreset, unknownPresetMessage, MIN_MAX_PART_BYTES, loadConfigFileDetailed, resolveConfig, validateSnapshot, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, GENERATOR_NAME, runInit, PromptCancelled, SCHEMA_VERSION, PRESETS, renderExplainText } from './chunk-L7QBLC4C.js';
2
2
  import * as fs from 'fs';
3
3
  import * as path2 from 'path';
4
4
  import { parseArgs } from 'util';
@@ -483,8 +483,8 @@ function buildAgentContract() {
483
483
  "snapshot.config.mjs",
484
484
  "snapshot.config.cjs",
485
485
  "snapshot.config.json",
486
- ".snapshotrc",
487
486
  ".snapshotrc.json",
487
+ ".snapshotrc",
488
488
  'package.json \u2192 "snapshot" key'
489
489
  ],
490
490
  settings: [
@@ -1433,6 +1433,8 @@ async function runWatchLoop(invocation, resolved) {
1433
1433
  (segment) => segment === outName || segment === tmpName || segment.startsWith(`${outName}.backup-`) || VCS_SEGMENTS.has(segment)
1434
1434
  );
1435
1435
  let running = false;
1436
+ let quietUntil = 0;
1437
+ const QUIET_MS = 1500;
1436
1438
  const regenerate = async () => {
1437
1439
  if (running) return;
1438
1440
  running = true;
@@ -1470,6 +1472,7 @@ async function runWatchLoop(invocation, resolved) {
1470
1472
  } catch (err) {
1471
1473
  warn(`\u274C ${err.message}`);
1472
1474
  } finally {
1475
+ quietUntil = performance.now() + QUIET_MS;
1473
1476
  running = false;
1474
1477
  }
1475
1478
  };
@@ -1477,6 +1480,7 @@ async function runWatchLoop(invocation, resolved) {
1477
1480
  void regenerate();
1478
1481
  let timer = null;
1479
1482
  const watcher = fs.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
1483
+ if (performance.now() < quietUntil) return;
1480
1484
  if (filename) {
1481
1485
  const changed = path2.resolve(resolved.cwd, filename.toString());
1482
1486
  if (isGenerated(changed)) return;
package/dist/index.cjs CHANGED
@@ -2218,12 +2218,8 @@ function isSensitivePath(relativePath) {
2218
2218
  }
2219
2219
  return matchesSensitiveList(posixPath, base);
2220
2220
  }
2221
- var activeSecretRules = null;
2222
- function setActiveSecretRules(rules) {
2223
- activeSecretRules = rules === null ? null : [...rules];
2224
- }
2225
2221
  function pathScanRules(extraRules) {
2226
- const fallback = extraRules ?? activeSecretRules ?? [];
2222
+ const fallback = extraRules ?? [];
2227
2223
  return [...DEFAULT_SECRET_PATTERNS, ...fallback];
2228
2224
  }
2229
2225
  function findSecretInPath(relativePath, extraRules) {
@@ -2263,7 +2259,12 @@ function findSecretInPath(relativePath, extraRules) {
2263
2259
  function maskSkipPaths(records, extraRules) {
2264
2260
  return records.map((record) => {
2265
2261
  const hit = findSecretInPath(record.path, extraRules);
2266
- return hit ? { ...record, path: hit.masked } : record;
2262
+ const detail = record.detail ? findSecretInPath(record.detail, extraRules) : null;
2263
+ return {
2264
+ ...record,
2265
+ path: hit ? hit.masked : record.path,
2266
+ ...detail ? { detail: detail.masked } : {}
2267
+ };
2267
2268
  });
2268
2269
  }
2269
2270
  function globToRegExp(glob) {
@@ -2953,6 +2954,9 @@ async function loadConfigFileDetailed(cwd) {
2953
2954
  }
2954
2955
  async function loadConfigFile(cwd) {
2955
2956
  const loaded = await loadConfigFileDetailed(cwd);
2957
+ if (loaded.errors.length > 0) {
2958
+ throw new Error(`The config file could not be read: ${loaded.errors.join("; ")}`);
2959
+ }
2956
2960
  return loaded.config;
2957
2961
  }
2958
2962
  var MIN_MAX_PART_BYTES = 4096;
@@ -3274,7 +3278,6 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
3274
3278
  ...aliasedRules ?? []
3275
3279
  ]);
3276
3280
  const secretRules = disableDefaultPatterns ? compiledCustomRules : [...compileSecretRules(DEFAULT_SECRET_PATTERNS), ...compiledCustomRules];
3277
- setActiveSecretRules(secretRules);
3278
3281
  const cliMonolith = cliOptions?.includeMonolith;
3279
3282
  const includeMonolith = cliMonolith ?? strictBoolean(userConfig?.includeMonolith, false, "`includeMonolith`");
3280
3283
  const artifacts = resolveArtifacts(
@@ -4303,6 +4306,9 @@ function validateSnapshot(configInput) {
4303
4306
  });
4304
4307
  }
4305
4308
  }
4309
+ const maskValue = (value) => findSecretInPath(value, config.secretRules)?.masked ?? value;
4310
+ const currentExcludes = config.excludePatterns.map(maskValue);
4311
+ const currentInclude = config.include.map(maskValue);
4306
4312
  const recorded = manifest.config;
4307
4313
  if (recorded && typeof recorded === "object") {
4308
4314
  if (recorded.maxPartBytes !== config.maxPartBytes) {
@@ -4331,15 +4337,15 @@ function validateSnapshot(configInput) {
4331
4337
  );
4332
4338
  }
4333
4339
  const recordedExcludes = Array.isArray(recorded.excludePatterns) ? recorded.excludePatterns : [];
4334
- if (recordedExcludes.join("\0") !== config.excludePatterns.join("\0")) {
4340
+ if (recordedExcludes.join("\0") !== currentExcludes.join("\0")) {
4335
4341
  drift.configMismatches.push(
4336
- `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${config.excludePatterns.join(", ")}]`
4342
+ `excludePatterns: manifest [${recordedExcludes.join(", ")}] vs current [${currentExcludes.join(", ")}]`
4337
4343
  );
4338
4344
  }
4339
4345
  const recordedInclude = Array.isArray(recorded.include) ? recorded.include : [];
4340
- if (recordedInclude.join("\0") !== config.include.join("\0")) {
4346
+ if (recordedInclude.join("\0") !== currentInclude.join("\0")) {
4341
4347
  drift.configMismatches.push(
4342
- `include: manifest [${recordedInclude.join(", ")}] vs current [${config.include.join(", ")}]`
4348
+ `include: manifest [${recordedInclude.join(", ")}] vs current [${currentInclude.join(", ")}]`
4343
4349
  );
4344
4350
  }
4345
4351
  if (recorded?.artifacts && typeof recorded.artifacts === "object") {
@@ -5434,7 +5440,7 @@ async function runInit(options) {
5434
5440
 
5435
5441
  // src/index.ts
5436
5442
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5437
- var GENERATOR_VERSION = "4.0.1";
5443
+ var GENERATOR_VERSION = "4.0.3";
5438
5444
  var SCHEMA_VERSION = "3.0.0";
5439
5445
  function sha256Hex2(input) {
5440
5446
  return crypto__namespace.createHash("sha256").update(input).digest("hex");
@@ -6275,6 +6281,7 @@ function generateSnapshot(configInput, options) {
6275
6281
  const truncatedPreviewCount = files.filter((file) => file.isPreviewTruncated).length;
6276
6282
  const validationErrors = verifyInMemory(files, parts, maxEffectiveBudget);
6277
6283
  const totalContentBytes = files.reduce((total, file) => total + file.includedBytes, 0);
6284
+ const maskName = (value) => maskPathText(value, config.secretRules);
6278
6285
  const manifest = {
6279
6286
  schemaVersion: SCHEMA_VERSION,
6280
6287
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -6295,13 +6302,13 @@ function generateSnapshot(configInput, options) {
6295
6302
  includeMonolith: config.includeMonolith,
6296
6303
  includeSensitiveFiles: config.includeSensitiveFiles,
6297
6304
  artifacts: { ...config.artifacts },
6298
- include: [...config.include],
6305
+ include: [...config.include].map(maskName),
6299
6306
  preset: config.preset,
6300
6307
  layersMode: config.layersMode,
6301
6308
  budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6302
- excludePatterns: [...config.excludePatterns],
6303
- layers: config.layers.map((layer2) => layer2.name),
6304
- kinds: config.kinds.map((kind) => kind.kind)
6309
+ excludePatterns: [...config.excludePatterns].map(maskName),
6310
+ layers: config.layers.map((layer2) => maskName(layer2.name)),
6311
+ kinds: config.kinds.map((kind) => maskName(kind.kind))
6305
6312
  },
6306
6313
  counts: {
6307
6314
  totalFiles: files.length,
package/dist/index.d.cts CHANGED
@@ -495,7 +495,7 @@ declare function matchesExclude(relativePath: string, pattern: string): boolean;
495
495
  declare function collectFiles(cwd: string, options?: CollectOptions): CollectResult;
496
496
 
497
497
  declare const GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
498
- declare const GENERATOR_VERSION = "4.0.1";
498
+ declare const GENERATOR_VERSION = "4.0.3";
499
499
  declare const SCHEMA_VERSION = "3.0.0";
500
500
  interface GenerateOptions {
501
501
  /** Compute the full manifest but write nothing to disk. */
package/dist/index.d.ts CHANGED
@@ -495,7 +495,7 @@ declare function matchesExclude(relativePath: string, pattern: string): boolean;
495
495
  declare function collectFiles(cwd: string, options?: CollectOptions): CollectResult;
496
496
 
497
497
  declare const GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
498
- declare const GENERATOR_VERSION = "4.0.1";
498
+ declare const GENERATOR_VERSION = "4.0.3";
499
499
  declare const SCHEMA_VERSION = "3.0.0";
500
500
  interface GenerateOptions {
501
501
  /** Compute the full manifest but write nothing to disk. */
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ARTIFACT_NAMES, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, GENERATOR_NAME, GENERATOR_VERSION, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, PRESETS, PromptCancelled, SCHEMA_VERSION, anchorForPath, assertReplaceable, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, fenceForText, generateProjectTree, generateSnapshot, generateSnapshotAsync, getPreset, globToRegExp, isBinaryBuffer, isBinaryExtension, isBinaryFile, isInteractive, isResolvedConfig, isSensitivePath, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, profileForPath, renderConfig, renderDiffText, renderExplainText, renderMinimalConfig, renumberParts, resolveConfig, resolveSafeOutputDirs, runInit, scanAndRedactSecrets, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, truncatePreview, truncateToBytes, validateSnapshot } from './chunk-RGIMMEAW.js';
1
+ export { ARTIFACT_NAMES, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, GENERATOR_NAME, GENERATOR_VERSION, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, PRESETS, PromptCancelled, SCHEMA_VERSION, anchorForPath, assertReplaceable, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, fenceForText, generateProjectTree, generateSnapshot, generateSnapshotAsync, getPreset, globToRegExp, isBinaryBuffer, isBinaryExtension, isBinaryFile, isInteractive, isResolvedConfig, isSensitivePath, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, profileForPath, renderConfig, renderDiffText, renderExplainText, renderMinimalConfig, renumberParts, resolveConfig, resolveSafeOutputDirs, runInit, scanAndRedactSecrets, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, truncatePreview, truncateToBytes, validateSnapshot } from './chunk-L7QBLC4C.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ankurhalder/codebase-snapshot",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Production-grade LLM codebase snapshot generator, auditor, and AST partitioner",
5
5
  "keywords": [
6
6
  "codebase",