codebase-snapshot 0.10.1 → 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/CHANGELOG.md +70 -0
- package/README.md +1 -1
- package/dist/bin.js +595 -396
- package/dist/{chunk-7DAW2LFZ.js → chunk-5AV7OR3J.js} +371 -176
- package/dist/{chunk-WDJ3O3R4.js → chunk-5EYBTBFY.js} +24 -28
- package/dist/cli.cjs +595 -396
- package/dist/cli.d.cts +11 -9
- package/dist/cli.d.ts +11 -9
- package/dist/cli.js +14 -6
- package/dist/{generate-worker-D_mUjgXw.d.cts → generate-worker-BK4uJx7Z.d.cts} +17 -8
- package/dist/{generate-worker-D_mUjgXw.d.ts → generate-worker-BK4uJx7Z.d.ts} +17 -8
- package/dist/index.cjs +347 -169
- package/dist/index.d.cts +68 -23
- package/dist/index.d.ts +68 -23
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +453 -2694
- package/dist/mcp.d.cts +1 -1
- package/dist/mcp.d.ts +1 -1
- package/dist/mcp.js +2 -2
- package/dist/{types-Z471HW65.d.cts → types-BoWneA7n.d.cts} +35 -4
- package/dist/{types-Z471HW65.d.ts → types-BoWneA7n.d.ts} +35 -4
- package/docs/cli.md +29 -8
- package/docs/codebase-token-budget.md +12 -9
- package/docs/configuration.md +18 -2
- package/docs/how-to-context-budget.md +1 -1
- package/docs/mcp.md +3 -3
- package/docs/output.md +8 -5
- package/docs/stale-context-is-your-bug.md +8 -4
- package/docs/vs-code2prompt.md +1 -1
- package/docs/vs-gitingest.md +1 -1
- package/docs/vs-repomix.md +1 -1
- package/package.json +1 -1
package/dist/cli.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { O as OutputFormat, D as DiscoveryMode, R as ResolvedSnapshotConfig } from './types-
|
|
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-
|
|
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-
|
|
2
|
-
export { buildAgentContract } from './chunk-
|
|
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,
|
|
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';
|
|
@@ -642,7 +642,9 @@ async function runInitCommand(invocation) {
|
|
|
642
642
|
}
|
|
643
643
|
function generatorOrigin(cwd) {
|
|
644
644
|
try {
|
|
645
|
-
const pkg = JSON.parse(
|
|
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(
|
|
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
|
|
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
|
|
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 };
|