@ankurhalder/codebase-snapshot 2.0.0 → 2.1.1

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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { J as JsonSummary, M as MarkdownSummary, S as SourceSummary, R as ResolvedSnapshotConfig, a as SnapshotConfig, B as ByteSize, C as CliOptions, F as FileEntry, P as PartMetadata, L as LayerRule, K as KindRule, b as SecretRule, c as SecretFinding, V as ValidationResult, d as Manifest, e as SkipRecord } from './types-S-5eRuRc.cjs';
2
- export { A as ArtifactSelection, f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as ValidationDrift } from './types-S-5eRuRc.cjs';
1
+ import { J as JsonSummary, M as MarkdownSummary, S as SourceSummary, R as ResolvedSnapshotConfig, a as SnapshotConfig, B as ByteSize, C as CliOptions, F as FileEntry, P as PartMetadata, L as LayerRule, K as KindRule, b as SecretRule, c as SecretFinding, V as ValidationResult, d as Manifest, A as ArtifactSelection, e as SkipRecord } from './types-CJqkePM4.cjs';
2
+ export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as SummaryQuality, r as ValidationDrift } from './types-CJqkePM4.cjs';
3
3
 
4
4
  /**
5
5
  * Strips `//` and block comments the way JSONC does, without touching anything
@@ -59,6 +59,16 @@ interface ConfigLoadResult {
59
59
  file: string | null;
60
60
  /** Why a candidate config file was ignored. Never silently discarded. */
61
61
  warnings: string[];
62
+ /**
63
+ * Config files that exist but could not be read.
64
+ *
65
+ * These are fatal: a config that fails to parse used to be skipped in favour of
66
+ * the defaults, which meant a typo silently produced a snapshot with none of the
67
+ * developer's settings applied. A config that is merely unsupported on this Node
68
+ * version (a `.ts` file below Node 22.6) stays a warning — nothing is wrong with
69
+ * the file, and the message already says what to do.
70
+ */
71
+ errors: string[];
62
72
  }
63
73
  /** True when this Node can `import()` a `.ts` file natively (type stripping). */
64
74
  declare function supportsTypeScriptImports(): boolean;
@@ -164,11 +174,58 @@ declare function truncateToBytes(content: string, maxBytes: number): {
164
174
  };
165
175
  declare function truncatePreview(content: string, headLines: number, tailLines: number): PreviewResult;
166
176
 
167
- declare function detectPreset(cwd: string): {
177
+ /**
178
+ * Everything preset detection is allowed to look at.
179
+ *
180
+ * Built once per run: the previous implementation re-read `package.json` inside
181
+ * every detector, which was both slow and incapable of seeing anything outside
182
+ * the JavaScript ecosystem.
183
+ */
184
+ interface PresetContext {
185
+ cwd: string;
186
+ /** Top-level file names, e.g. `next.config.ts`. */
187
+ files: ReadonlySet<string>;
188
+ /** Top-level directory names. */
189
+ dirs: ReadonlySet<string>;
190
+ /** `dependencies` + `devDependencies` + `peerDependencies` names. */
191
+ dependencies: ReadonlySet<string>;
192
+ /** Small snapshots of well-known manifests, for keyword detection. */
193
+ manifests: Readonly<Record<string, string>>;
194
+ }
195
+
196
+ interface PresetDefinition {
197
+ readonly name: string;
198
+ /** Higher wins. Framework presets outrank repository shapes. */
199
+ readonly priority: number;
200
+ detect(context: PresetContext): boolean;
201
+ readonly layers: LayerRule[];
202
+ readonly kinds: KindRule[];
203
+ /** Ecosystem-specific ignores, merged with the user's `excludePatterns`. */
204
+ readonly exclude?: string[];
205
+ /** Advice for the setup wizard. Never applied automatically. */
206
+ readonly recommendedBudget?: ByteSize;
207
+ }
208
+ interface DetectedPreset {
168
209
  presetName: string;
169
210
  layers: LayerRule[];
170
211
  kinds: KindRule[];
171
- };
212
+ /** Ecosystem ignores the scanner should apply in addition to the user's. */
213
+ exclude: string[];
214
+ recommendedBudget: ByteSize | null;
215
+ }
216
+ /**
217
+ * Every preset, ordered by priority.
218
+ *
219
+ * Ordering is the whole detection model: the first definition whose `detect`
220
+ * returns true wins, so the list is sorted once at module load rather than being
221
+ * hand-maintained in the right order.
222
+ */
223
+ declare const PRESETS: readonly PresetDefinition[];
224
+ /** Every preset name, in priority order — used by the CLI and the wizard. */
225
+ declare function listPresetNames(): string[];
226
+ declare function getPreset(name: string): PresetDefinition | undefined;
227
+ /** Detects the preset for `cwd`, reading the repository once. */
228
+ declare function detectPreset(cwd: string, forced?: string): DetectedPreset;
172
229
 
173
230
  declare function isBinaryExtension(filePath: string): boolean;
174
231
  declare function isBinaryBuffer(buffer: Buffer): boolean;
@@ -284,6 +341,117 @@ declare function loadManifest(target: string): Manifest;
284
341
  /** Renders a diff for a terminal. */
285
342
  declare function renderDiffText(diff: ManifestDiff): string;
286
343
 
344
+ interface PromptIO {
345
+ input: NodeJS.ReadStream;
346
+ output: NodeJS.WriteStream;
347
+ }
348
+ /** Thrown when the developer presses Ctrl+C or Ctrl+D mid-prompt. */
349
+ declare class PromptCancelled extends Error {
350
+ constructor();
351
+ }
352
+ /** Both ends must be a TTY before anything interactive is attempted. */
353
+ declare function isInteractive(io: PromptIO): boolean;
354
+
355
+ interface InitOptions {
356
+ cwd: string;
357
+ /** Force a preset instead of detecting one. */
358
+ preset?: string;
359
+ maxPartBytes?: ByteSize;
360
+ include?: string[];
361
+ exclude?: string[];
362
+ skipArtifacts?: string[];
363
+ onlyArtifacts?: string[];
364
+ includeSensitiveFiles?: boolean;
365
+ /** Accept every default without prompting. */
366
+ yes?: boolean;
367
+ /** Write only the settings that differ from the defaults. */
368
+ minimal?: boolean;
369
+ /** Overwrite an existing config. */
370
+ force?: boolean;
371
+ /** Render the config without writing anything. */
372
+ dryRun?: boolean;
373
+ outDir?: string;
374
+ io?: PromptIO;
375
+ }
376
+ interface InitResult {
377
+ configPath: string;
378
+ configText: string;
379
+ written: boolean;
380
+ preset: string;
381
+ scripts: string[];
382
+ gitignoreEntries: string[];
383
+ /** Human-readable notes about anything that was skipped or could not be done. */
384
+ notes: string[];
385
+ }
386
+ /**
387
+ * Runs the interactive setup, or writes a config from flags.
388
+ *
389
+ * Interactive only when both ends are a TTY and `--yes` was not passed; every
390
+ * other path uses the flag values and the detected preset, and prints what it
391
+ * decided rather than prompting.
392
+ */
393
+ declare function runInit(options: InitOptions): Promise<InitResult>;
394
+
395
+ /** What the wizard decided, after prompts or flags. */
396
+ interface WizardAnswers {
397
+ preset: string;
398
+ maxPartBytes: ByteSize;
399
+ largeFileBytes: ByteSize;
400
+ include: string[];
401
+ excludePatterns: string[];
402
+ artifacts: Required<ArtifactSelection>;
403
+ includeSensitiveFiles: boolean;
404
+ outDir: string;
405
+ }
406
+ declare const DEFAULT_ANSWERS: WizardAnswers;
407
+ /**
408
+ * Renders the full, self-documenting config.
409
+ *
410
+ * Every setting appears at its current value, commented and grouped, because
411
+ * most developers never open the documentation — a file that lists only their
412
+ * changes cannot tell them what else exists. Deleting any line is safe: the
413
+ * defaults are real.
414
+ */
415
+ declare function renderConfig(answers: WizardAnswers): string;
416
+ /**
417
+ * The terse variant: only what differs from the defaults.
418
+ *
419
+ * `--minimal` exists for people who prefer a short file and will read the docs.
420
+ */
421
+ declare function renderMinimalConfig(answers: WizardAnswers): string;
422
+
423
+ interface HeuristicResult {
424
+ summary: SourceSummary;
425
+ /**
426
+ * `ast` only when a real parser produced this (TypeScript, and the script
427
+ * block of a Vue/Svelte/Astro component). Everything else is `heuristic`, and
428
+ * the manifest says so — a line-scan is not a parse.
429
+ */
430
+ quality: "ast" | "heuristic";
431
+ }
432
+ interface LanguageProfile {
433
+ readonly id: string;
434
+ readonly extensions: readonly string[];
435
+ summarize(path: string, content: string): HeuristicResult;
436
+ }
437
+
438
+ /**
439
+ * Every heuristic profile, in no particular order — lookup is by extension.
440
+ *
441
+ * Adding a language is one file exporting a `LanguageProfile` plus one line
442
+ * here; nothing else in the pipeline changes.
443
+ */
444
+ declare const LANGUAGE_PROFILES: readonly LanguageProfile[];
445
+ /** The profile that owns `path`, or `null` when no profile claims it. */
446
+ declare function profileForPath(path: string): LanguageProfile | null;
447
+ /**
448
+ * Summarizes `path` with whichever profile claims it.
449
+ *
450
+ * Returns `null` for files no profile handles — those still enter the snapshot,
451
+ * they just carry no structural summary.
452
+ */
453
+ declare function summarizeWithProfile(path: string, content: string): HeuristicResult | null;
454
+
287
455
  interface CollectOptions {
288
456
  /**
289
457
  * When non-empty, only files matching at least one pattern are candidates.
@@ -329,7 +497,7 @@ declare function matchesExclude(relativePath: string, pattern: string): boolean;
329
497
  declare function collectFiles(cwd: string, options?: CollectOptions): CollectResult;
330
498
 
331
499
  declare const GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
332
- declare const GENERATOR_VERSION = "2.0.0";
500
+ declare const GENERATOR_VERSION = "2.1.1";
333
501
  declare const SCHEMA_VERSION = "3.0.0";
334
502
  interface GenerateOptions {
335
503
  /** Compute the full manifest but write nothing to disk. */
@@ -350,6 +518,15 @@ declare function resolveSafeOutputDirs(config: {
350
518
  outDir: string;
351
519
  tmpDir: string;
352
520
  };
521
+ /**
522
+ * Refuses to replace a directory that this generator did not write.
523
+ *
524
+ * `swapIntoPlace` renames the previous output aside and deletes it, and the
525
+ * scratch directory is deleted outright before every run. Path checks alone
526
+ * cannot make that safe: `outDir: "src"` is a plausible typo, and it used to
527
+ * delete the developer's entire source tree and exit 0.
528
+ */
529
+ declare function assertReplaceable(target: string, label: "outDir" | "tmpDir"): void;
353
530
  /**
354
531
  * Generates the snapshot.
355
532
  *
@@ -361,4 +538,4 @@ declare function generateSnapshot(configInput?: SnapshotConfig | ResolvedSnapsho
361
538
  /** Promise-returning wrapper for consumers that prefer an async call site. */
362
539
  declare function generateSnapshotAsync(configInput?: SnapshotConfig | ResolvedSnapshotConfig | null, options?: GenerateOptions): Promise<Manifest>;
363
540
 
364
- export { ARTIFACT_NAMES, ByteSize, CliOptions, DEFAULT_SECRET_PATTERNS, type ExplainResult, FileEntry, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, JsonSummary, KindRule, LayerRule, MIN_MAX_PART_BYTES, Manifest, type ManifestDiff, MarkdownSummary, PartMetadata, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, ValidationResult, anchorForPath, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, generateProjectTree, generateSnapshot, generateSnapshotAsync, globToRegExp, isBinaryBuffer, isBinaryExtension, isBinaryFile, isResolvedConfig, isSensitivePath, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, renderDiffText, renderExplainText, renumberParts, resolveConfig, resolveSafeOutputDirs, scanAndRedactSecrets, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, supportsTypeScriptImports, truncatePreview, truncateToBytes, validateSnapshot };
541
+ export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CliOptions, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, type ExplainResult, FileEntry, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, type HeuristicResult, type InitOptions, type InitResult, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, Manifest, type ManifestDiff, MarkdownSummary, PRESETS, PartMetadata, PromptCancelled, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, ValidationResult, type WizardAnswers, anchorForPath, assertReplaceable, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, 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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { J as JsonSummary, M as MarkdownSummary, S as SourceSummary, R as ResolvedSnapshotConfig, a as SnapshotConfig, B as ByteSize, C as CliOptions, F as FileEntry, P as PartMetadata, L as LayerRule, K as KindRule, b as SecretRule, c as SecretFinding, V as ValidationResult, d as Manifest, e as SkipRecord } from './types-S-5eRuRc.js';
2
- export { A as ArtifactSelection, f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as ValidationDrift } from './types-S-5eRuRc.js';
1
+ import { J as JsonSummary, M as MarkdownSummary, S as SourceSummary, R as ResolvedSnapshotConfig, a as SnapshotConfig, B as ByteSize, C as CliOptions, F as FileEntry, P as PartMetadata, L as LayerRule, K as KindRule, b as SecretRule, c as SecretFinding, V as ValidationResult, d as Manifest, A as ArtifactSelection, e as SkipRecord } from './types-CJqkePM4.js';
2
+ export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as SummaryQuality, r as ValidationDrift } from './types-CJqkePM4.js';
3
3
 
4
4
  /**
5
5
  * Strips `//` and block comments the way JSONC does, without touching anything
@@ -59,6 +59,16 @@ interface ConfigLoadResult {
59
59
  file: string | null;
60
60
  /** Why a candidate config file was ignored. Never silently discarded. */
61
61
  warnings: string[];
62
+ /**
63
+ * Config files that exist but could not be read.
64
+ *
65
+ * These are fatal: a config that fails to parse used to be skipped in favour of
66
+ * the defaults, which meant a typo silently produced a snapshot with none of the
67
+ * developer's settings applied. A config that is merely unsupported on this Node
68
+ * version (a `.ts` file below Node 22.6) stays a warning — nothing is wrong with
69
+ * the file, and the message already says what to do.
70
+ */
71
+ errors: string[];
62
72
  }
63
73
  /** True when this Node can `import()` a `.ts` file natively (type stripping). */
64
74
  declare function supportsTypeScriptImports(): boolean;
@@ -164,11 +174,58 @@ declare function truncateToBytes(content: string, maxBytes: number): {
164
174
  };
165
175
  declare function truncatePreview(content: string, headLines: number, tailLines: number): PreviewResult;
166
176
 
167
- declare function detectPreset(cwd: string): {
177
+ /**
178
+ * Everything preset detection is allowed to look at.
179
+ *
180
+ * Built once per run: the previous implementation re-read `package.json` inside
181
+ * every detector, which was both slow and incapable of seeing anything outside
182
+ * the JavaScript ecosystem.
183
+ */
184
+ interface PresetContext {
185
+ cwd: string;
186
+ /** Top-level file names, e.g. `next.config.ts`. */
187
+ files: ReadonlySet<string>;
188
+ /** Top-level directory names. */
189
+ dirs: ReadonlySet<string>;
190
+ /** `dependencies` + `devDependencies` + `peerDependencies` names. */
191
+ dependencies: ReadonlySet<string>;
192
+ /** Small snapshots of well-known manifests, for keyword detection. */
193
+ manifests: Readonly<Record<string, string>>;
194
+ }
195
+
196
+ interface PresetDefinition {
197
+ readonly name: string;
198
+ /** Higher wins. Framework presets outrank repository shapes. */
199
+ readonly priority: number;
200
+ detect(context: PresetContext): boolean;
201
+ readonly layers: LayerRule[];
202
+ readonly kinds: KindRule[];
203
+ /** Ecosystem-specific ignores, merged with the user's `excludePatterns`. */
204
+ readonly exclude?: string[];
205
+ /** Advice for the setup wizard. Never applied automatically. */
206
+ readonly recommendedBudget?: ByteSize;
207
+ }
208
+ interface DetectedPreset {
168
209
  presetName: string;
169
210
  layers: LayerRule[];
170
211
  kinds: KindRule[];
171
- };
212
+ /** Ecosystem ignores the scanner should apply in addition to the user's. */
213
+ exclude: string[];
214
+ recommendedBudget: ByteSize | null;
215
+ }
216
+ /**
217
+ * Every preset, ordered by priority.
218
+ *
219
+ * Ordering is the whole detection model: the first definition whose `detect`
220
+ * returns true wins, so the list is sorted once at module load rather than being
221
+ * hand-maintained in the right order.
222
+ */
223
+ declare const PRESETS: readonly PresetDefinition[];
224
+ /** Every preset name, in priority order — used by the CLI and the wizard. */
225
+ declare function listPresetNames(): string[];
226
+ declare function getPreset(name: string): PresetDefinition | undefined;
227
+ /** Detects the preset for `cwd`, reading the repository once. */
228
+ declare function detectPreset(cwd: string, forced?: string): DetectedPreset;
172
229
 
173
230
  declare function isBinaryExtension(filePath: string): boolean;
174
231
  declare function isBinaryBuffer(buffer: Buffer): boolean;
@@ -284,6 +341,117 @@ declare function loadManifest(target: string): Manifest;
284
341
  /** Renders a diff for a terminal. */
285
342
  declare function renderDiffText(diff: ManifestDiff): string;
286
343
 
344
+ interface PromptIO {
345
+ input: NodeJS.ReadStream;
346
+ output: NodeJS.WriteStream;
347
+ }
348
+ /** Thrown when the developer presses Ctrl+C or Ctrl+D mid-prompt. */
349
+ declare class PromptCancelled extends Error {
350
+ constructor();
351
+ }
352
+ /** Both ends must be a TTY before anything interactive is attempted. */
353
+ declare function isInteractive(io: PromptIO): boolean;
354
+
355
+ interface InitOptions {
356
+ cwd: string;
357
+ /** Force a preset instead of detecting one. */
358
+ preset?: string;
359
+ maxPartBytes?: ByteSize;
360
+ include?: string[];
361
+ exclude?: string[];
362
+ skipArtifacts?: string[];
363
+ onlyArtifacts?: string[];
364
+ includeSensitiveFiles?: boolean;
365
+ /** Accept every default without prompting. */
366
+ yes?: boolean;
367
+ /** Write only the settings that differ from the defaults. */
368
+ minimal?: boolean;
369
+ /** Overwrite an existing config. */
370
+ force?: boolean;
371
+ /** Render the config without writing anything. */
372
+ dryRun?: boolean;
373
+ outDir?: string;
374
+ io?: PromptIO;
375
+ }
376
+ interface InitResult {
377
+ configPath: string;
378
+ configText: string;
379
+ written: boolean;
380
+ preset: string;
381
+ scripts: string[];
382
+ gitignoreEntries: string[];
383
+ /** Human-readable notes about anything that was skipped or could not be done. */
384
+ notes: string[];
385
+ }
386
+ /**
387
+ * Runs the interactive setup, or writes a config from flags.
388
+ *
389
+ * Interactive only when both ends are a TTY and `--yes` was not passed; every
390
+ * other path uses the flag values and the detected preset, and prints what it
391
+ * decided rather than prompting.
392
+ */
393
+ declare function runInit(options: InitOptions): Promise<InitResult>;
394
+
395
+ /** What the wizard decided, after prompts or flags. */
396
+ interface WizardAnswers {
397
+ preset: string;
398
+ maxPartBytes: ByteSize;
399
+ largeFileBytes: ByteSize;
400
+ include: string[];
401
+ excludePatterns: string[];
402
+ artifacts: Required<ArtifactSelection>;
403
+ includeSensitiveFiles: boolean;
404
+ outDir: string;
405
+ }
406
+ declare const DEFAULT_ANSWERS: WizardAnswers;
407
+ /**
408
+ * Renders the full, self-documenting config.
409
+ *
410
+ * Every setting appears at its current value, commented and grouped, because
411
+ * most developers never open the documentation — a file that lists only their
412
+ * changes cannot tell them what else exists. Deleting any line is safe: the
413
+ * defaults are real.
414
+ */
415
+ declare function renderConfig(answers: WizardAnswers): string;
416
+ /**
417
+ * The terse variant: only what differs from the defaults.
418
+ *
419
+ * `--minimal` exists for people who prefer a short file and will read the docs.
420
+ */
421
+ declare function renderMinimalConfig(answers: WizardAnswers): string;
422
+
423
+ interface HeuristicResult {
424
+ summary: SourceSummary;
425
+ /**
426
+ * `ast` only when a real parser produced this (TypeScript, and the script
427
+ * block of a Vue/Svelte/Astro component). Everything else is `heuristic`, and
428
+ * the manifest says so — a line-scan is not a parse.
429
+ */
430
+ quality: "ast" | "heuristic";
431
+ }
432
+ interface LanguageProfile {
433
+ readonly id: string;
434
+ readonly extensions: readonly string[];
435
+ summarize(path: string, content: string): HeuristicResult;
436
+ }
437
+
438
+ /**
439
+ * Every heuristic profile, in no particular order — lookup is by extension.
440
+ *
441
+ * Adding a language is one file exporting a `LanguageProfile` plus one line
442
+ * here; nothing else in the pipeline changes.
443
+ */
444
+ declare const LANGUAGE_PROFILES: readonly LanguageProfile[];
445
+ /** The profile that owns `path`, or `null` when no profile claims it. */
446
+ declare function profileForPath(path: string): LanguageProfile | null;
447
+ /**
448
+ * Summarizes `path` with whichever profile claims it.
449
+ *
450
+ * Returns `null` for files no profile handles — those still enter the snapshot,
451
+ * they just carry no structural summary.
452
+ */
453
+ declare function summarizeWithProfile(path: string, content: string): HeuristicResult | null;
454
+
287
455
  interface CollectOptions {
288
456
  /**
289
457
  * When non-empty, only files matching at least one pattern are candidates.
@@ -329,7 +497,7 @@ declare function matchesExclude(relativePath: string, pattern: string): boolean;
329
497
  declare function collectFiles(cwd: string, options?: CollectOptions): CollectResult;
330
498
 
331
499
  declare const GENERATOR_NAME = "@ankurhalder/codebase-snapshot";
332
- declare const GENERATOR_VERSION = "2.0.0";
500
+ declare const GENERATOR_VERSION = "2.1.1";
333
501
  declare const SCHEMA_VERSION = "3.0.0";
334
502
  interface GenerateOptions {
335
503
  /** Compute the full manifest but write nothing to disk. */
@@ -350,6 +518,15 @@ declare function resolveSafeOutputDirs(config: {
350
518
  outDir: string;
351
519
  tmpDir: string;
352
520
  };
521
+ /**
522
+ * Refuses to replace a directory that this generator did not write.
523
+ *
524
+ * `swapIntoPlace` renames the previous output aside and deletes it, and the
525
+ * scratch directory is deleted outright before every run. Path checks alone
526
+ * cannot make that safe: `outDir: "src"` is a plausible typo, and it used to
527
+ * delete the developer's entire source tree and exit 0.
528
+ */
529
+ declare function assertReplaceable(target: string, label: "outDir" | "tmpDir"): void;
353
530
  /**
354
531
  * Generates the snapshot.
355
532
  *
@@ -361,4 +538,4 @@ declare function generateSnapshot(configInput?: SnapshotConfig | ResolvedSnapsho
361
538
  /** Promise-returning wrapper for consumers that prefer an async call site. */
362
539
  declare function generateSnapshotAsync(configInput?: SnapshotConfig | ResolvedSnapshotConfig | null, options?: GenerateOptions): Promise<Manifest>;
363
540
 
364
- export { ARTIFACT_NAMES, ByteSize, CliOptions, DEFAULT_SECRET_PATTERNS, type ExplainResult, FileEntry, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, JsonSummary, KindRule, LayerRule, MIN_MAX_PART_BYTES, Manifest, type ManifestDiff, MarkdownSummary, PartMetadata, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, ValidationResult, anchorForPath, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, generateProjectTree, generateSnapshot, generateSnapshotAsync, globToRegExp, isBinaryBuffer, isBinaryExtension, isBinaryFile, isResolvedConfig, isSensitivePath, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, renderDiffText, renderExplainText, renumberParts, resolveConfig, resolveSafeOutputDirs, scanAndRedactSecrets, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, supportsTypeScriptImports, truncatePreview, truncateToBytes, validateSnapshot };
541
+ export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CliOptions, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, type ExplainResult, FileEntry, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, type HeuristicResult, type InitOptions, type InitResult, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, Manifest, type ManifestDiff, MarkdownSummary, PRESETS, PartMetadata, PromptCancelled, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, ValidationResult, type WizardAnswers, anchorForPath, assertReplaceable, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, 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 };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { ARTIFACT_NAMES, DEFAULT_SECRET_PATTERNS, GENERATOR_NAME, GENERATOR_VERSION, MIN_MAX_PART_BYTES, SCHEMA_VERSION, anchorForPath, assertUsableConfigInput, collectFiles, compareManifests, countLines, defineConfig, detectLanguage, detectPreset, explainPath, fenceForContent, generateProjectTree, generateSnapshot, generateSnapshotAsync, globToRegExp, isBinaryBuffer, isBinaryExtension, isBinaryFile, isResolvedConfig, isSensitivePath, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, renderDiffText, renderExplainText, renumberParts, resolveConfig, resolveSafeOutputDirs, scanAndRedactSecrets, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, supportsTypeScriptImports, truncatePreview, truncateToBytes, validateSnapshot } from './chunk-RGDVLQTT.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, 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-SUOJL5EX.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -34,6 +34,16 @@ interface MarkdownSummary {
34
34
  headings: string[];
35
35
  frontmatterKeys: string[];
36
36
  }
37
+ /**
38
+ * How a summary was produced.
39
+ *
40
+ * `ast` — a real parser (TypeScript compiler; the script block of a
41
+ * Vue/Svelte/Astro component).
42
+ * `structural` — a real grammar for a data format (JSON, Markdown).
43
+ * `heuristic` — line patterns. Useful, but not a parse, and never presented
44
+ * as one.
45
+ */
46
+ type SummaryQuality = "ast" | "structural" | "heuristic";
37
47
  type SkipReason = "asset" | "binary" | "read-error" | "not-file" | "sensitive-file" | "symlink" | "default-ignore" | "excluded";
38
48
  interface SkipRecord {
39
49
  path: string;
@@ -64,6 +74,8 @@ interface FileEntry {
64
74
  /** UTF-8 bytes of file content actually emitted into the snapshot. */
65
75
  includedBytes: number;
66
76
  summary?: SourceSummary | JsonSummary | MarkdownSummary;
77
+ /** How the summary was produced. Absent when there is no summary. */
78
+ summaryQuality?: SummaryQuality;
67
79
  /** True when the summary alone was too large for the part budget and was dropped. */
68
80
  summaryOmitted?: boolean;
69
81
  /** Emitted body after redaction/truncation. Never serialized into the manifest. */
@@ -169,6 +181,7 @@ interface ManifestConfigSnapshot {
169
181
  includeSensitiveFiles: boolean;
170
182
  artifacts: ResolvedArtifacts;
171
183
  include: string[];
184
+ preset: string;
172
185
  layersMode: "merge" | "replace";
173
186
  budgets: ResolvedBudgets;
174
187
  excludePatterns: string[];
@@ -286,6 +299,8 @@ interface SnapshotConfig {
286
299
  includeSensitiveFiles?: boolean;
287
300
  /** Allow-list of globs. When non-empty, only matching files are included. */
288
301
  include?: string[];
302
+ /** Force a preset by name instead of auto-detecting one. */
303
+ preset?: string;
289
304
  /** Switch individual snapshot artifacts off. Everything is on by default. */
290
305
  artifacts?: ArtifactSelection;
291
306
  /**
@@ -319,6 +334,10 @@ interface ResolvedSnapshotConfig {
319
334
  includeSensitiveFiles: boolean;
320
335
  /** Empty means "no allow-list"; every discovered file is a candidate. */
321
336
  include: string[];
337
+ /** The preset that was resolved (detected or forced). */
338
+ preset: string;
339
+ /** Ecosystem ignores contributed by the preset, merged with `excludePatterns`. */
340
+ presetExclude: string[];
322
341
  artifacts: ResolvedArtifacts;
323
342
  layersMode: "merge" | "replace";
324
343
  budgets: ResolvedBudgets;
@@ -369,4 +388,4 @@ interface ValidationResult {
369
388
  warnings: string[];
370
389
  }
371
390
 
372
- export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PartMetadata as P, ResolvedSnapshotConfig as R, SourceSummary as S, ValidationResult as V, SnapshotConfig as a, SecretRule as b, SecretFinding as c, Manifest as d, SkipRecord as e, BudgetConfig as f, ManifestArtifact as g, ManifestConfigSnapshot as h, ManifestIndexes as i, ManifestTotals as j, Mode as k, PartFileEntry as l, ResolvedArtifacts as m, ResolvedBudgets as n, SecretRuleInput as o, SkipReason as p, ValidationDrift as q };
391
+ export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PartMetadata as P, ResolvedSnapshotConfig as R, SourceSummary as S, ValidationResult as V, SnapshotConfig as a, SecretRule as b, SecretFinding as c, Manifest as d, SkipRecord as e, BudgetConfig as f, ManifestArtifact as g, ManifestConfigSnapshot as h, ManifestIndexes as i, ManifestTotals as j, Mode as k, PartFileEntry as l, ResolvedArtifacts as m, ResolvedBudgets as n, SecretRuleInput as o, SkipReason as p, SummaryQuality as q, ValidationDrift as r };
@@ -34,6 +34,16 @@ interface MarkdownSummary {
34
34
  headings: string[];
35
35
  frontmatterKeys: string[];
36
36
  }
37
+ /**
38
+ * How a summary was produced.
39
+ *
40
+ * `ast` — a real parser (TypeScript compiler; the script block of a
41
+ * Vue/Svelte/Astro component).
42
+ * `structural` — a real grammar for a data format (JSON, Markdown).
43
+ * `heuristic` — line patterns. Useful, but not a parse, and never presented
44
+ * as one.
45
+ */
46
+ type SummaryQuality = "ast" | "structural" | "heuristic";
37
47
  type SkipReason = "asset" | "binary" | "read-error" | "not-file" | "sensitive-file" | "symlink" | "default-ignore" | "excluded";
38
48
  interface SkipRecord {
39
49
  path: string;
@@ -64,6 +74,8 @@ interface FileEntry {
64
74
  /** UTF-8 bytes of file content actually emitted into the snapshot. */
65
75
  includedBytes: number;
66
76
  summary?: SourceSummary | JsonSummary | MarkdownSummary;
77
+ /** How the summary was produced. Absent when there is no summary. */
78
+ summaryQuality?: SummaryQuality;
67
79
  /** True when the summary alone was too large for the part budget and was dropped. */
68
80
  summaryOmitted?: boolean;
69
81
  /** Emitted body after redaction/truncation. Never serialized into the manifest. */
@@ -169,6 +181,7 @@ interface ManifestConfigSnapshot {
169
181
  includeSensitiveFiles: boolean;
170
182
  artifacts: ResolvedArtifacts;
171
183
  include: string[];
184
+ preset: string;
172
185
  layersMode: "merge" | "replace";
173
186
  budgets: ResolvedBudgets;
174
187
  excludePatterns: string[];
@@ -286,6 +299,8 @@ interface SnapshotConfig {
286
299
  includeSensitiveFiles?: boolean;
287
300
  /** Allow-list of globs. When non-empty, only matching files are included. */
288
301
  include?: string[];
302
+ /** Force a preset by name instead of auto-detecting one. */
303
+ preset?: string;
289
304
  /** Switch individual snapshot artifacts off. Everything is on by default. */
290
305
  artifacts?: ArtifactSelection;
291
306
  /**
@@ -319,6 +334,10 @@ interface ResolvedSnapshotConfig {
319
334
  includeSensitiveFiles: boolean;
320
335
  /** Empty means "no allow-list"; every discovered file is a candidate. */
321
336
  include: string[];
337
+ /** The preset that was resolved (detected or forced). */
338
+ preset: string;
339
+ /** Ecosystem ignores contributed by the preset, merged with `excludePatterns`. */
340
+ presetExclude: string[];
322
341
  artifacts: ResolvedArtifacts;
323
342
  layersMode: "merge" | "replace";
324
343
  budgets: ResolvedBudgets;
@@ -369,4 +388,4 @@ interface ValidationResult {
369
388
  warnings: string[];
370
389
  }
371
390
 
372
- export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PartMetadata as P, ResolvedSnapshotConfig as R, SourceSummary as S, ValidationResult as V, SnapshotConfig as a, SecretRule as b, SecretFinding as c, Manifest as d, SkipRecord as e, BudgetConfig as f, ManifestArtifact as g, ManifestConfigSnapshot as h, ManifestIndexes as i, ManifestTotals as j, Mode as k, PartFileEntry as l, ResolvedArtifacts as m, ResolvedBudgets as n, SecretRuleInput as o, SkipReason as p, ValidationDrift as q };
391
+ export type { ArtifactSelection as A, ByteSize as B, CliOptions as C, FileEntry as F, HooksConfig as H, InclusionMode as I, JsonSummary as J, KindRule as K, LayerRule as L, MarkdownSummary as M, OutputFormat as O, PartMetadata as P, ResolvedSnapshotConfig as R, SourceSummary as S, ValidationResult as V, SnapshotConfig as a, SecretRule as b, SecretFinding as c, Manifest as d, SkipRecord as e, BudgetConfig as f, ManifestArtifact as g, ManifestConfigSnapshot as h, ManifestIndexes as i, ManifestTotals as j, Mode as k, PartFileEntry as l, ResolvedArtifacts as m, ResolvedBudgets as n, SecretRuleInput as o, SkipReason as p, SummaryQuality as q, ValidationDrift as r };