codebase-snapshot 0.10.0 → 0.10.2

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/cli.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-Z471HW65.cjs';
1
+ import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-BoWneA7n.cjs';
2
2
 
3
3
  /**
4
4
  * The machine-readable description of this tool.
@@ -310,6 +310,16 @@ declare function parseByteOption(raw: string | undefined, optionName: string, mi
310
310
  * through to the writable `generate` command.
311
311
  */
312
312
  declare function parseCliArgs(argv: string[]): ParsedInvocation;
313
+ /**
314
+ * The environment a nested package-manager run gets: the caller's, minus npm's own config.
315
+ *
316
+ * Running `setup` through `npx`/`npm exec` puts the parent npm's resolved config into
317
+ * `npm_config_*` variables, and a child that inherits them is not the `npm install` a user would
318
+ * type — with an npm that supports an `allowScripts` switch, the child aborted with
319
+ * `EALLOWSCRIPTS: --allow-scripts is not allowed in project-scoped installs`. Stripping them makes
320
+ * the child read the project's own `.npmrc` and flags, which is the whole point of using the
321
+ * project's package manager.
322
+ */
313
323
  declare function cleanInstallEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
314
324
  /**
315
325
  * Runs one invocation, and mentions a newer release when there is one.
@@ -375,14 +385,6 @@ declare function isGeneratedWatchPath(candidate: string, paths: WatchPaths): boo
375
385
  * because Windows does not always name the path our own writes produced.
376
386
  */
377
387
  declare function decideWatchEvent(state: WatchState, event: WatchEvent, paths: WatchPaths): WatchDecision;
378
- /**
379
- * Re-generates on every change under `cwd`.
380
- *
381
- * Events inside the resolved output and temporary directories are ignored, so
382
- * writing a snapshot cannot feed the watcher. A source event that arrives while
383
- * a run is in flight sets a pending flag and gets exactly one follow-up run;
384
- * the settle window only suppresses unattributed events.
385
- */
386
388
  /**
387
389
  * The directories the watcher must ignore, derived from a resolved config.
388
390
  *
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-Z471HW65.js';
1
+ import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-BoWneA7n.js';
2
2
 
3
3
  /**
4
4
  * The machine-readable description of this tool.
@@ -310,6 +310,16 @@ declare function parseByteOption(raw: string | undefined, optionName: string, mi
310
310
  * through to the writable `generate` command.
311
311
  */
312
312
  declare function parseCliArgs(argv: string[]): ParsedInvocation;
313
+ /**
314
+ * The environment a nested package-manager run gets: the caller's, minus npm's own config.
315
+ *
316
+ * Running `setup` through `npx`/`npm exec` puts the parent npm's resolved config into
317
+ * `npm_config_*` variables, and a child that inherits them is not the `npm install` a user would
318
+ * type — with an npm that supports an `allowScripts` switch, the child aborted with
319
+ * `EALLOWSCRIPTS: --allow-scripts is not allowed in project-scoped installs`. Stripping them makes
320
+ * the child read the project's own `.npmrc` and flags, which is the whole point of using the
321
+ * project's package manager.
322
+ */
313
323
  declare function cleanInstallEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
314
324
  /**
315
325
  * Runs one invocation, and mentions a newer release when there is one.
@@ -375,14 +385,6 @@ declare function isGeneratedWatchPath(candidate: string, paths: WatchPaths): boo
375
385
  * because Windows does not always name the path our own writes produced.
376
386
  */
377
387
  declare function decideWatchEvent(state: WatchState, event: WatchEvent, paths: WatchPaths): WatchDecision;
378
- /**
379
- * Re-generates on every change under `cwd`.
380
- *
381
- * Events inside the resolved output and temporary directories are ignored, so
382
- * writing a snapshot cannot feed the watcher. A source event that arrives while
383
- * a run is in flight sets a pending flag and gets exactly one follow-up run;
384
- * the settle window only suppresses unattributed events.
385
- */
386
388
  /**
387
389
  * The directories the watcher must ignore, derived from a resolved config.
388
390
  *
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
- import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-4H7MSW64.js';
2
- export { buildAgentContract } from './chunk-4H7MSW64.js';
3
- import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, parseByteSize, stripJsonComments, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-EP7OCPUM.js';
1
+ import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-5EYBTBFY.js';
2
+ export { buildAgentContract } from './chunk-5EYBTBFY.js';
3
+ import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-5AV7OR3J.js';
4
4
  import { spawnSync } from 'child_process';
5
5
  import * as fs from 'fs';
6
6
  import * as path2 from 'path';
@@ -194,7 +194,7 @@ Options:
194
194
  --max-part-bytes <n> Maximum byte budget per markdown part (default: 307200).
195
195
  Accepts units: 120k, 1.5mb
196
196
  --max-part-tokens <n> Per-part budget in tokens; narrows --max-part-bytes
197
- --large-file-bytes <n> Threshold for head/tail truncation (default: 204800)
197
+ --large-file-bytes <n> Preview threshold (default: the part budget; never above it)
198
198
  --changed-since <ref> Only files changed since this git ref, plus untracked ones
199
199
  --staged Only files staged for the next commit
200
200
  --with-dependents With the two above: also include their importers
@@ -642,7 +642,9 @@ async function runInitCommand(invocation) {
642
642
  }
643
643
  function generatorOrigin(cwd) {
644
644
  try {
645
- const pkg = JSON.parse(fs.readFileSync(path2.join(cwd, "package.json"), "utf8"));
645
+ const pkg = JSON.parse(
646
+ stripJsonComments(fs.readFileSync(path2.join(cwd, "package.json"), "utf8"))
647
+ );
646
648
  const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
647
649
  if (typeof spec === "string") return `project dependency ${spec}`;
648
650
  } catch {
@@ -939,6 +941,8 @@ function runSkillCommand(invocation) {
939
941
  function renderValidateText(result) {
940
942
  if (result.valid) {
941
943
  info("\u2705 Snapshot is valid and up to date with disk.");
944
+ } else if (result.errors.length === 1 && result.errors[0].includes(" is not a snapshot manifest: ")) {
945
+ warn(`\u274C ${result.errors[0]}`);
942
946
  } else {
943
947
  warn("\u274C Snapshot validation failed:");
944
948
  for (const error of result.errors) warn(` - ${error}`);
@@ -1144,7 +1148,11 @@ ${USAGE}
1144
1148
  if (invocation.command === "diff") {
1145
1149
  try {
1146
1150
  const [beforePath, afterPath] = invocation.args;
1147
- const diff = compareManifests(loadManifest(beforePath), loadManifest(afterPath));
1151
+ const diff = compareManifests(
1152
+ loadManifest(beforePath),
1153
+ loadManifest(afterPath),
1154
+ resolved.secretRules
1155
+ );
1148
1156
  emit(invocation.format, diff, () => info(renderDiffText(diff)));
1149
1157
  return 0;
1150
1158
  } catch (err) {
@@ -1199,7 +1207,7 @@ ${USAGE}
1199
1207
  const reasons = skipBreakdown.length > shownReasons.length ? `${shownReasons.join(", ")}, +${skipBreakdown.length - shownReasons.length} more` : shownReasons.join(", ");
1200
1208
  const candidates = manifest.counts.totalFiles + manifest.counts.skippedCount;
1201
1209
  info(
1202
- manifest.counts.skippedCount === 0 ? ` - Tracked files: ${formatNumber(manifest.counts.totalFiles)}` : ` - Tracked files: ${formatNumber(manifest.counts.totalFiles)} included of ${formatNumber(candidates)} found \u2014 ${formatNumber(manifest.counts.skippedCount)} skipped (${reasons}); every one is listed in ${displayOutPath(resolved.cwd, resolved.outDir, "reports/audit.md")}`
1210
+ manifest.counts.skippedCount === 0 ? ` - Tracked files: ${formatNumber(manifest.counts.totalFiles)}` : ` - Tracked files: ${formatNumber(manifest.counts.totalFiles)} included of ${formatNumber(candidates)} paths found \u2014 ${formatNumber(manifest.counts.skippedCount)} skipped (${reasons}); every one is listed in ${displayOutPath(resolved.cwd, resolved.outDir, "reports/audit.md")}`
1203
1211
  );
1204
1212
  info(` - Total lines: ${formatNumber(manifest.counts.totalLines)}`);
1205
1213
  info(
@@ -28,7 +28,21 @@ interface GenerateSummary {
28
28
  filename: string;
29
29
  byteSize: number;
30
30
  }>;
31
+ totalSizeBytes: number;
31
32
  totalContentBytes: number;
33
+ preset: string;
34
+ layers: Record<string, number>;
35
+ /**
36
+ * The most common skip reasons, ranked.
37
+ *
38
+ * `snapshot_plan` prints these, and it now runs off-thread too — so the ranking is computed
39
+ * where the manifest is, and the whole `skipped[]` array (one record per path, thousands of
40
+ * them) does not cross the thread boundary to be counted here.
41
+ */
42
+ skipReasons: Array<{
43
+ reason: string;
44
+ count: number;
45
+ }>;
32
46
  warnings: string[];
33
47
  }
34
48
  type WorkerResults = {
@@ -38,13 +52,6 @@ type WorkerResults = {
38
52
  ok: false;
39
53
  message: string;
40
54
  };
41
- /**
42
- * The absolute path of the package entry this process is running from.
43
- *
44
- * `__dirname` exists in the CJS build and `import.meta.url` in the ESM one, and `typeof` on an
45
- * undeclared identifier does not throw — so this resolves correctly in both without a build-time
46
- * substitution.
47
- */
48
55
  /**
49
56
  * Where the worker finds this package's entry: the path, and the URL the worker imports.
50
57
  *
@@ -68,6 +75,8 @@ declare function workerEntry(directory: string, isCjs: boolean): {
68
75
  * as a tool failure naming the reason — never silently retried on the calling thread, because a
69
76
  * quiet fallback would hide exactly the condition this exists to avoid.
70
77
  */
71
- declare function generateInWorker(cwd: string, cliOptions: WorkspaceCliOptions): Promise<WorkerResults>;
78
+ declare function generateInWorker(cwd: string, cliOptions: WorkspaceCliOptions, options?: {
79
+ dryRun?: boolean;
80
+ }): Promise<WorkerResults>;
72
81
 
73
82
  export { type GenerateSummary as G, type WorkerResults as W, generateInWorker as g, workerEntry as w };
@@ -28,7 +28,21 @@ interface GenerateSummary {
28
28
  filename: string;
29
29
  byteSize: number;
30
30
  }>;
31
+ totalSizeBytes: number;
31
32
  totalContentBytes: number;
33
+ preset: string;
34
+ layers: Record<string, number>;
35
+ /**
36
+ * The most common skip reasons, ranked.
37
+ *
38
+ * `snapshot_plan` prints these, and it now runs off-thread too — so the ranking is computed
39
+ * where the manifest is, and the whole `skipped[]` array (one record per path, thousands of
40
+ * them) does not cross the thread boundary to be counted here.
41
+ */
42
+ skipReasons: Array<{
43
+ reason: string;
44
+ count: number;
45
+ }>;
32
46
  warnings: string[];
33
47
  }
34
48
  type WorkerResults = {
@@ -38,13 +52,6 @@ type WorkerResults = {
38
52
  ok: false;
39
53
  message: string;
40
54
  };
41
- /**
42
- * The absolute path of the package entry this process is running from.
43
- *
44
- * `__dirname` exists in the CJS build and `import.meta.url` in the ESM one, and `typeof` on an
45
- * undeclared identifier does not throw — so this resolves correctly in both without a build-time
46
- * substitution.
47
- */
48
55
  /**
49
56
  * Where the worker finds this package's entry: the path, and the URL the worker imports.
50
57
  *
@@ -68,6 +75,8 @@ declare function workerEntry(directory: string, isCjs: boolean): {
68
75
  * as a tool failure naming the reason — never silently retried on the calling thread, because a
69
76
  * quiet fallback would hide exactly the condition this exists to avoid.
70
77
  */
71
- declare function generateInWorker(cwd: string, cliOptions: WorkspaceCliOptions): Promise<WorkerResults>;
78
+ declare function generateInWorker(cwd: string, cliOptions: WorkspaceCliOptions, options?: {
79
+ dryRun?: boolean;
80
+ }): Promise<WorkerResults>;
72
81
 
73
82
  export { type GenerateSummary as G, type WorkerResults as W, generateInWorker as g, workerEntry as w };