codebase-snapshot 0.9.18 → 0.10.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/cli.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-KbJvBjmV.cjs';
1
+ import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-Z471HW65.cjs';
2
2
 
3
3
  /**
4
4
  * The machine-readable description of this tool.
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-KbJvBjmV.js';
1
+ import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-Z471HW65.js';
2
2
 
3
3
  /**
4
4
  * The machine-readable description of this tool.
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
- import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-XAW5GY6X.js';
2
- export { buildAgentContract } from './chunk-XAW5GY6X.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-ZXWAVHSZ.js';
1
+ import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-WDJ3O3R4.js';
2
+ export { buildAgentContract } from './chunk-WDJ3O3R4.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-7DAW2LFZ.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
@@ -640,6 +640,17 @@ async function runInitCommand(invocation) {
640
640
  return fail(invocation.format, err.message);
641
641
  }
642
642
  }
643
+ function generatorOrigin(cwd) {
644
+ try {
645
+ const pkg = JSON.parse(fs.readFileSync(path2.join(cwd, "package.json"), "utf8"));
646
+ const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
647
+ if (typeof spec === "string") return `project dependency ${spec}`;
648
+ } catch {
649
+ }
650
+ const entry = process.argv[1] ?? "";
651
+ if (entry.includes("_npx") || entry.includes(`${path2.sep}npx${path2.sep}`)) return "via npx";
652
+ return "global or direct install";
653
+ }
643
654
  function detectPackageManager(cwd) {
644
655
  const has = (name) => fs.existsSync(path2.join(cwd, name));
645
656
  if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
@@ -787,9 +798,14 @@ async function runSetupCommand(invocation, options = {}) {
787
798
  info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
788
799
  }
789
800
  }
801
+ const hasManifest = fs.existsSync(path2.join(invocation.cwd, "package.json"));
790
802
  let install = null;
791
803
  if (invocation.noInstall) {
792
804
  if (invocation.format !== "json") info(" Skipped the install (--no-install)");
805
+ } else if (!hasManifest) {
806
+ if (invocation.format !== "json") {
807
+ info(" Skipped the install: no package.json here, so there is no dependency to add.");
808
+ }
793
809
  } else {
794
810
  if (invocation.format !== "json") info("\u23F3 Installing dependencies\u2026");
795
811
  install = installDependencies(invocation.cwd);
@@ -1142,7 +1158,7 @@ ${USAGE}
1142
1158
  const started = performance.now();
1143
1159
  info(`\u{1F4F8} ${invocation.dryRun ? "Planning snapshot (dry run)" : "Generating snapshot"} for: ${resolved.cwd}`);
1144
1160
  info(
1145
- ` Branch: ${resolved.branch} | Part budget: ${(resolved.maxPartBytes / 1024).toFixed(0)} KB`
1161
+ ` Branch: ${resolved.branch} | Part budget: ${(resolved.maxPartBytes / 1024).toFixed(0)} KB | Generator: ${GENERATOR_VERSION} (${generatorOrigin(resolved.cwd)})`
1146
1162
  );
1147
1163
  try {
1148
1164
  const manifest = generateSnapshot(resolved, { dryRun: invocation.dryRun });
@@ -1160,12 +1176,31 @@ ${USAGE}
1160
1176
  ` - Redacted: ${manifest.totals.redactedLines} line(s) \u2014 a real run lists them in ` + displayOutPath(resolved.cwd, resolved.outDir, "reports/audit.md")
1161
1177
  );
1162
1178
  }
1179
+ const incomplete = manifest.incomplete ?? [];
1180
+ if (incomplete.length > 0) {
1181
+ const byReason = /* @__PURE__ */ new Map();
1182
+ for (const record of incomplete) {
1183
+ byReason.set(record.reason, (byReason.get(record.reason) ?? 0) + 1);
1184
+ }
1185
+ const detail = [...byReason.entries()].map(([reason, count]) => `${count} ${reason}`).join(", ");
1186
+ info(` - Incomplete: ${incomplete.length} file(s) \u2014 ${detail}; see manifest.json incomplete[]`);
1187
+ }
1163
1188
  info(` - Integrity: ${manifest.validation.status}`);
1164
1189
  for (const error of manifest.validation.errors.slice(0, 10)) info(` - ${error}`);
1165
1190
  } else {
1166
1191
  info(`
1167
1192
  \u2705 Snapshot generated in ${elapsed}s:`);
1168
- info(` - Tracked files: ${manifest.counts.totalFiles}`);
1193
+ const skipCounts = /* @__PURE__ */ new Map();
1194
+ for (const record of manifest.skipped) {
1195
+ skipCounts.set(record.reason, (skipCounts.get(record.reason) ?? 0) + 1);
1196
+ }
1197
+ const skipBreakdown = [...skipCounts.entries()].sort((left, right) => right[1] - left[1]).map(([reason, count]) => `${reason} ${formatNumber(count)}`);
1198
+ const shownReasons = skipBreakdown.slice(0, 3);
1199
+ const reasons = skipBreakdown.length > shownReasons.length ? `${shownReasons.join(", ")}, +${skipBreakdown.length - shownReasons.length} more` : shownReasons.join(", ");
1200
+ const candidates = manifest.counts.totalFiles + manifest.counts.skippedCount;
1201
+ 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")}`
1203
+ );
1169
1204
  info(` - Total lines: ${formatNumber(manifest.counts.totalLines)}`);
1170
1205
  info(
1171
1206
  ` - Total size: ${(manifest.counts.totalSizeBytes / (1024 * 1024)).toFixed(2)} MB`