@ankurhalder/codebase-snapshot 4.0.5 → 4.0.6

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
@@ -2730,21 +2730,28 @@ function isBinaryExtension(filePath) {
2730
2730
  return BINARY_EXTENSIONS.has(ext);
2731
2731
  }
2732
2732
  function isBinaryBuffer(buffer) {
2733
- const checkLength = Math.min(buffer.length, 8192);
2734
- for (let index = 0; index < checkLength; index++) {
2733
+ for (let index = 0; index < buffer.length; index++) {
2735
2734
  if (buffer[index] === 0) return true;
2736
2735
  }
2737
2736
  return false;
2738
2737
  }
2738
+ var BINARY_SCAN_BYTES = 8 * 1024 * 1024;
2739
+ var CHUNK = 64 * 1024;
2739
2740
  function isBinaryFile(absolutePath) {
2740
2741
  if (isBinaryExtension(absolutePath)) return true;
2741
2742
  let fd;
2742
2743
  try {
2743
2744
  fd = fs5.openSync(absolutePath, "r");
2744
- const buffer = Buffer.alloc(8192);
2745
- const bytesRead = fs5.readSync(fd, buffer, 0, 8192, 0);
2746
- if (bytesRead === 0) return false;
2747
- return isBinaryBuffer(buffer.subarray(0, bytesRead));
2745
+ const buffer = Buffer.alloc(CHUNK);
2746
+ let position = 0;
2747
+ while (position < BINARY_SCAN_BYTES) {
2748
+ const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
2749
+ const bytesRead = fs5.readSync(fd, buffer, 0, wanted, position);
2750
+ if (bytesRead === 0) return false;
2751
+ if (isBinaryBuffer(buffer.subarray(0, bytesRead))) return true;
2752
+ position += bytesRead;
2753
+ }
2754
+ return false;
2748
2755
  } catch {
2749
2756
  return false;
2750
2757
  } finally {
@@ -5498,7 +5505,7 @@ function validateSnapshot(configInput) {
5498
5505
 
5499
5506
  // src/index.ts
5500
5507
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5501
- var GENERATOR_VERSION = "4.0.5";
5508
+ var GENERATOR_VERSION = "4.0.6";
5502
5509
  var SCHEMA_VERSION = "3.0.0";
5503
5510
  function sha256Hex2(input) {
5504
5511
  return crypto3.createHash("sha256").update(input).digest("hex");
@@ -6265,8 +6272,8 @@ function generateSnapshot(configInput, options) {
6265
6272
  const lineCount = countLines(rawContent);
6266
6273
  totalLines += lineCount;
6267
6274
  totalSizeBytes += stats.size;
6268
- const layer2 = classifyLayer(relativePath, config.layers);
6269
- const kind = classifyKind(relativePath, config.kinds);
6275
+ const layer2 = maskPathText(classifyLayer(relativePath, config.layers), config.secretRules);
6276
+ const kind = maskPathText(classifyKind(relativePath, config.kinds), config.secretRules);
6270
6277
  const language = detectLanguage(relativePath);
6271
6278
  bump(layerCounts, layer2);
6272
6279
  bump(kindCounts, kind);
@@ -6376,7 +6383,12 @@ function generateSnapshot(configInput, options) {
6376
6383
  include: [...config.include].map(maskName),
6377
6384
  preset: config.preset,
6378
6385
  layersMode: config.layersMode,
6379
- budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6386
+ budgets: {
6387
+ default: config.budgets.default,
6388
+ byLayer: Object.fromEntries(
6389
+ Object.entries(config.budgets.byLayer).map(([name, bytes]) => [maskName(name), bytes])
6390
+ )
6391
+ },
6380
6392
  excludePatterns: [...config.excludePatterns].map(maskName),
6381
6393
  layers: config.layers.map((layer2) => maskName(layer2.name)),
6382
6394
  kinds: config.kinds.map((kind) => maskName(kind.kind))
@@ -4077,21 +4077,28 @@ function isBinaryExtension(filePath) {
4077
4077
  return BINARY_EXTENSIONS.has(ext);
4078
4078
  }
4079
4079
  function isBinaryBuffer(buffer) {
4080
- const checkLength = Math.min(buffer.length, 8192);
4081
- for (let index = 0; index < checkLength; index++) {
4080
+ for (let index = 0; index < buffer.length; index++) {
4082
4081
  if (buffer[index] === 0) return true;
4083
4082
  }
4084
4083
  return false;
4085
4084
  }
4085
+ var BINARY_SCAN_BYTES = 8 * 1024 * 1024;
4086
+ var CHUNK = 64 * 1024;
4086
4087
  function isBinaryFile(absolutePath) {
4087
4088
  if (isBinaryExtension(absolutePath)) return true;
4088
4089
  let fd;
4089
4090
  try {
4090
4091
  fd = fs9.openSync(absolutePath, "r");
4091
- const buffer = Buffer.alloc(8192);
4092
- const bytesRead = fs9.readSync(fd, buffer, 0, 8192, 0);
4093
- if (bytesRead === 0) return false;
4094
- return isBinaryBuffer(buffer.subarray(0, bytesRead));
4092
+ const buffer = Buffer.alloc(CHUNK);
4093
+ let position = 0;
4094
+ while (position < BINARY_SCAN_BYTES) {
4095
+ const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
4096
+ const bytesRead = fs9.readSync(fd, buffer, 0, wanted, position);
4097
+ if (bytesRead === 0) return false;
4098
+ if (isBinaryBuffer(buffer.subarray(0, bytesRead))) return true;
4099
+ position += bytesRead;
4100
+ }
4101
+ return false;
4095
4102
  } catch {
4096
4103
  return false;
4097
4104
  } finally {
@@ -5461,7 +5468,7 @@ async function runInit(options) {
5461
5468
 
5462
5469
  // src/index.ts
5463
5470
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5464
- var GENERATOR_VERSION = "4.0.5";
5471
+ var GENERATOR_VERSION = "4.0.6";
5465
5472
  var SCHEMA_VERSION = "3.0.0";
5466
5473
  function sha256Hex2(input) {
5467
5474
  return crypto.createHash("sha256").update(input).digest("hex");
@@ -6228,8 +6235,8 @@ function generateSnapshot(configInput, options) {
6228
6235
  const lineCount = countLines(rawContent);
6229
6236
  totalLines += lineCount;
6230
6237
  totalSizeBytes += stats.size;
6231
- const layer2 = classifyLayer(relativePath, config.layers);
6232
- const kind = classifyKind(relativePath, config.kinds);
6238
+ const layer2 = maskPathText(classifyLayer(relativePath, config.layers), config.secretRules);
6239
+ const kind = maskPathText(classifyKind(relativePath, config.kinds), config.secretRules);
6233
6240
  const language = detectLanguage(relativePath);
6234
6241
  bump(layerCounts, layer2);
6235
6242
  bump(kindCounts, kind);
@@ -6339,7 +6346,12 @@ function generateSnapshot(configInput, options) {
6339
6346
  include: [...config.include].map(maskName),
6340
6347
  preset: config.preset,
6341
6348
  layersMode: config.layersMode,
6342
- budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6349
+ budgets: {
6350
+ default: config.budgets.default,
6351
+ byLayer: Object.fromEntries(
6352
+ Object.entries(config.budgets.byLayer).map(([name, bytes]) => [maskName(name), bytes])
6353
+ )
6354
+ },
6343
6355
  excludePatterns: [...config.excludePatterns].map(maskName),
6344
6356
  layers: config.layers.map((layer2) => maskName(layer2.name)),
6345
6357
  kinds: config.kinds.map((kind) => maskName(kind.kind))
@@ -6522,5 +6534,5 @@ async function generateSnapshotAsync(configInput, options) {
6522
6534
  }
6523
6535
 
6524
6536
  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 };
6525
- //# sourceMappingURL=chunk-PCNDUNKT.js.map
6526
- //# sourceMappingURL=chunk-PCNDUNKT.js.map
6537
+ //# sourceMappingURL=chunk-GAY7W5MK.js.map
6538
+ //# sourceMappingURL=chunk-GAY7W5MK.js.map
package/dist/cli.cjs CHANGED
@@ -2738,21 +2738,28 @@ function isBinaryExtension(filePath) {
2738
2738
  return BINARY_EXTENSIONS.has(ext);
2739
2739
  }
2740
2740
  function isBinaryBuffer(buffer) {
2741
- const checkLength = Math.min(buffer.length, 8192);
2742
- for (let index = 0; index < checkLength; index++) {
2741
+ for (let index = 0; index < buffer.length; index++) {
2743
2742
  if (buffer[index] === 0) return true;
2744
2743
  }
2745
2744
  return false;
2746
2745
  }
2746
+ var BINARY_SCAN_BYTES = 8 * 1024 * 1024;
2747
+ var CHUNK = 64 * 1024;
2747
2748
  function isBinaryFile(absolutePath) {
2748
2749
  if (isBinaryExtension(absolutePath)) return true;
2749
2750
  let fd;
2750
2751
  try {
2751
2752
  fd = fs9__namespace.openSync(absolutePath, "r");
2752
- const buffer = Buffer.alloc(8192);
2753
- const bytesRead = fs9__namespace.readSync(fd, buffer, 0, 8192, 0);
2754
- if (bytesRead === 0) return false;
2755
- return isBinaryBuffer(buffer.subarray(0, bytesRead));
2753
+ const buffer = Buffer.alloc(CHUNK);
2754
+ let position = 0;
2755
+ while (position < BINARY_SCAN_BYTES) {
2756
+ const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
2757
+ const bytesRead = fs9__namespace.readSync(fd, buffer, 0, wanted, position);
2758
+ if (bytesRead === 0) return false;
2759
+ if (isBinaryBuffer(buffer.subarray(0, bytesRead))) return true;
2760
+ position += bytesRead;
2761
+ }
2762
+ return false;
2756
2763
  } catch {
2757
2764
  return false;
2758
2765
  } finally {
@@ -5477,7 +5484,7 @@ function validateSnapshot(configInput) {
5477
5484
 
5478
5485
  // src/index.ts
5479
5486
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5480
- var GENERATOR_VERSION = "4.0.5";
5487
+ var GENERATOR_VERSION = "4.0.6";
5481
5488
  var SCHEMA_VERSION = "3.0.0";
5482
5489
  function sha256Hex2(input) {
5483
5490
  return crypto__namespace.createHash("sha256").update(input).digest("hex");
@@ -6244,8 +6251,8 @@ function generateSnapshot(configInput, options) {
6244
6251
  const lineCount = countLines(rawContent);
6245
6252
  totalLines += lineCount;
6246
6253
  totalSizeBytes += stats.size;
6247
- const layer2 = classifyLayer(relativePath, config.layers);
6248
- const kind = classifyKind(relativePath, config.kinds);
6254
+ const layer2 = maskPathText(classifyLayer(relativePath, config.layers), config.secretRules);
6255
+ const kind = maskPathText(classifyKind(relativePath, config.kinds), config.secretRules);
6249
6256
  const language = detectLanguage(relativePath);
6250
6257
  bump(layerCounts, layer2);
6251
6258
  bump(kindCounts, kind);
@@ -6355,7 +6362,12 @@ function generateSnapshot(configInput, options) {
6355
6362
  include: [...config.include].map(maskName),
6356
6363
  preset: config.preset,
6357
6364
  layersMode: config.layersMode,
6358
- budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6365
+ budgets: {
6366
+ default: config.budgets.default,
6367
+ byLayer: Object.fromEntries(
6368
+ Object.entries(config.budgets.byLayer).map(([name, bytes]) => [maskName(name), bytes])
6369
+ )
6370
+ },
6359
6371
  excludePatterns: [...config.excludePatterns].map(maskName),
6360
6372
  layers: config.layers.map((layer2) => maskName(layer2.name)),
6361
6373
  kinds: config.kinds.map((kind) => maskName(kind.kind))
package/dist/cli.js CHANGED
@@ -1,4 +1,4 @@
1
- import { loadConfigFileDetailed, resolveConfig, validateSnapshot, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, GENERATOR_VERSION, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, PromptCancelled, MIN_MAX_PART_BYTES, SCHEMA_VERSION, PRESETS, parseByteSize, renderExplainText } from './chunk-PCNDUNKT.js';
1
+ import { loadConfigFileDetailed, resolveConfig, validateSnapshot, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, GENERATOR_VERSION, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, PromptCancelled, MIN_MAX_PART_BYTES, SCHEMA_VERSION, PRESETS, parseByteSize, renderExplainText } from './chunk-GAY7W5MK.js';
2
2
  import * as fs from 'fs';
3
3
  import * as path2 from 'path';
4
4
  import { parseArgs } from 'util';
package/dist/index.cjs CHANGED
@@ -4106,21 +4106,28 @@ function isBinaryExtension(filePath) {
4106
4106
  return BINARY_EXTENSIONS.has(ext);
4107
4107
  }
4108
4108
  function isBinaryBuffer(buffer) {
4109
- const checkLength = Math.min(buffer.length, 8192);
4110
- for (let index = 0; index < checkLength; index++) {
4109
+ for (let index = 0; index < buffer.length; index++) {
4111
4110
  if (buffer[index] === 0) return true;
4112
4111
  }
4113
4112
  return false;
4114
4113
  }
4114
+ var BINARY_SCAN_BYTES = 8 * 1024 * 1024;
4115
+ var CHUNK = 64 * 1024;
4115
4116
  function isBinaryFile(absolutePath) {
4116
4117
  if (isBinaryExtension(absolutePath)) return true;
4117
4118
  let fd;
4118
4119
  try {
4119
4120
  fd = fs9__namespace.openSync(absolutePath, "r");
4120
- const buffer = Buffer.alloc(8192);
4121
- const bytesRead = fs9__namespace.readSync(fd, buffer, 0, 8192, 0);
4122
- if (bytesRead === 0) return false;
4123
- return isBinaryBuffer(buffer.subarray(0, bytesRead));
4121
+ const buffer = Buffer.alloc(CHUNK);
4122
+ let position = 0;
4123
+ while (position < BINARY_SCAN_BYTES) {
4124
+ const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
4125
+ const bytesRead = fs9__namespace.readSync(fd, buffer, 0, wanted, position);
4126
+ if (bytesRead === 0) return false;
4127
+ if (isBinaryBuffer(buffer.subarray(0, bytesRead))) return true;
4128
+ position += bytesRead;
4129
+ }
4130
+ return false;
4124
4131
  } catch {
4125
4132
  return false;
4126
4133
  } finally {
@@ -5490,7 +5497,7 @@ async function runInit(options) {
5490
5497
 
5491
5498
  // src/index.ts
5492
5499
  var GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
5493
- var GENERATOR_VERSION = "4.0.5";
5500
+ var GENERATOR_VERSION = "4.0.6";
5494
5501
  var SCHEMA_VERSION = "3.0.0";
5495
5502
  function sha256Hex2(input) {
5496
5503
  return crypto__namespace.createHash("sha256").update(input).digest("hex");
@@ -6257,8 +6264,8 @@ function generateSnapshot(configInput, options) {
6257
6264
  const lineCount = countLines(rawContent);
6258
6265
  totalLines += lineCount;
6259
6266
  totalSizeBytes += stats.size;
6260
- const layer2 = classifyLayer(relativePath, config.layers);
6261
- const kind = classifyKind(relativePath, config.kinds);
6267
+ const layer2 = maskPathText(classifyLayer(relativePath, config.layers), config.secretRules);
6268
+ const kind = maskPathText(classifyKind(relativePath, config.kinds), config.secretRules);
6262
6269
  const language = detectLanguage(relativePath);
6263
6270
  bump(layerCounts, layer2);
6264
6271
  bump(kindCounts, kind);
@@ -6368,7 +6375,12 @@ function generateSnapshot(configInput, options) {
6368
6375
  include: [...config.include].map(maskName),
6369
6376
  preset: config.preset,
6370
6377
  layersMode: config.layersMode,
6371
- budgets: { default: config.budgets.default, byLayer: { ...config.budgets.byLayer } },
6378
+ budgets: {
6379
+ default: config.budgets.default,
6380
+ byLayer: Object.fromEntries(
6381
+ Object.entries(config.budgets.byLayer).map(([name, bytes]) => [maskName(name), bytes])
6382
+ )
6383
+ },
6372
6384
  excludePatterns: [...config.excludePatterns].map(maskName),
6373
6385
  layers: config.layers.map((layer2) => maskName(layer2.name)),
6374
6386
  kinds: config.kinds.map((kind) => maskName(kind.kind))
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.5";
498
+ declare const GENERATOR_VERSION = "4.0.6";
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.5";
498
+ declare const GENERATOR_VERSION = "4.0.6";
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-PCNDUNKT.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-GAY7W5MK.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.5",
3
+ "version": "4.0.6",
4
4
  "description": "Production-grade LLM codebase snapshot generator, auditor, and AST partitioner",
5
5
  "keywords": [
6
6
  "codebase",