codebase-snapshot 0.9.14 → 0.9.15
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 +134 -0
- package/README.md +2 -2
- package/SECURITY.md +23 -5
- package/dist/bin.js +668 -280
- package/dist/{chunk-J4W74N4Y.js → chunk-AU2VNTUU.js} +650 -554
- package/dist/{chunk-DUZK5VL2.js → chunk-JL4VDGXL.js} +303 -48
- package/dist/cli.cjs +664 -276
- package/dist/cli.js +102 -65
- package/dist/index.cjs +303 -48
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +3678 -3354
- package/dist/mcp.d.cts +10 -0
- package/dist/mcp.d.ts +10 -0
- package/dist/mcp.js +2 -2
- package/docs/cli.md +74 -48
- package/docs/configuration.md +37 -12
- package/docs/install.md +4 -3
- package/docs/mcp.md +30 -6
- package/docs/output.md +38 -9
- package/docs/stale-context-is-your-bug.md +4 -3
- package/docs/troubleshooting.md +32 -8
- 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 -2
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, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS,
|
|
1
|
+
import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-AU2VNTUU.js';
|
|
2
|
+
export { buildAgentContract } from './chunk-AU2VNTUU.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-JL4VDGXL.js';
|
|
4
4
|
import { spawnSync } from 'child_process';
|
|
5
5
|
import * as fs from 'fs';
|
|
6
6
|
import * as path2 from 'path';
|
|
@@ -357,7 +357,24 @@ function parseCliArgs(argv) {
|
|
|
357
357
|
let args = [];
|
|
358
358
|
const explicitMode = values.mode ? String(values.mode) : void 0;
|
|
359
359
|
const firstPositional = positionals[0];
|
|
360
|
-
|
|
360
|
+
const modeCommand = explicitMode === void 0 ? void 0 : COMMAND_ALIASES.get(explicitMode);
|
|
361
|
+
if (explicitMode !== void 0 && modeCommand === void 0) {
|
|
362
|
+
throw new UsageError(
|
|
363
|
+
`Unknown --mode "${explicitMode}". Expected one of: ${Array.from(COMMAND_ALIASES.keys()).join(", ")}.`
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
if (modeCommand !== void 0) {
|
|
367
|
+
command = modeCommand;
|
|
368
|
+
if (firstPositional !== void 0) {
|
|
369
|
+
const named = COMMAND_ALIASES.get(firstPositional);
|
|
370
|
+
if (named !== void 0 && named !== modeCommand) {
|
|
371
|
+
throw new UsageError(
|
|
372
|
+
`--mode ${explicitMode} contradicts the command "${firstPositional}". Pass one or the other.`
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
args = named !== void 0 ? positionals.slice(1) : positionals;
|
|
376
|
+
}
|
|
377
|
+
} else if (firstPositional !== void 0) {
|
|
361
378
|
const resolved = COMMAND_ALIASES.get(firstPositional);
|
|
362
379
|
if (!resolved) {
|
|
363
380
|
throw new UsageError(
|
|
@@ -366,27 +383,6 @@ function parseCliArgs(argv) {
|
|
|
366
383
|
}
|
|
367
384
|
command = resolved;
|
|
368
385
|
args = positionals.slice(1);
|
|
369
|
-
} else if (explicitMode !== void 0) {
|
|
370
|
-
const resolved = COMMAND_ALIASES.get(explicitMode);
|
|
371
|
-
if (!resolved) {
|
|
372
|
-
throw new UsageError(
|
|
373
|
-
`Unknown --mode "${explicitMode}". Expected one of: ${Array.from(COMMAND_ALIASES.keys()).join(", ")}.`
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
command = resolved;
|
|
377
|
-
}
|
|
378
|
-
if (explicitMode !== void 0) {
|
|
379
|
-
const resolvedMode = COMMAND_ALIASES.get(explicitMode);
|
|
380
|
-
if (!resolvedMode) {
|
|
381
|
-
throw new UsageError(
|
|
382
|
-
`Unknown --mode "${explicitMode}". Expected one of: ${Array.from(COMMAND_ALIASES.keys()).join(", ")}.`
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
if (firstPositional !== void 0 && resolvedMode !== command) {
|
|
386
|
-
throw new UsageError(
|
|
387
|
-
`--mode ${explicitMode} contradicts the command "${firstPositional}". Pass one or the other.`
|
|
388
|
-
);
|
|
389
|
-
}
|
|
390
386
|
}
|
|
391
387
|
const expectedArgs = COMMAND_ARITY[command];
|
|
392
388
|
if (args.length !== expectedArgs) {
|
|
@@ -679,6 +675,16 @@ function installDependencies(cwd) {
|
|
|
679
675
|
}
|
|
680
676
|
return { manager: manager.name, command, ok: true, detail: seconds };
|
|
681
677
|
}
|
|
678
|
+
async function setupHookOutDir(invocation, init) {
|
|
679
|
+
if (!init.reused || invocation.outDir !== void 0) return init.outDir;
|
|
680
|
+
const loaded = await loadConfigFileDetailed(invocation.cwd);
|
|
681
|
+
if (loaded.errors.length > 0) {
|
|
682
|
+
throw new Error(
|
|
683
|
+
`The config file could not be read: ${loaded.errors.join("; ")}. Fix it, or delete it to use the defaults.`
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
return resolveConfig(loaded.config, {}, invocation.cwd).outDir;
|
|
687
|
+
}
|
|
682
688
|
async function captureStdout(fn) {
|
|
683
689
|
const { value, text } = await runWithStdoutCapture(fn);
|
|
684
690
|
return { code: value, text };
|
|
@@ -712,7 +718,13 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
712
718
|
reuseConfig: true,
|
|
713
719
|
dryRun: invocation.dryRun
|
|
714
720
|
});
|
|
715
|
-
const
|
|
721
|
+
const keptConfigPath = init.reused ? findConfigFile(invocation.cwd) ?? init.configPath : init.configPath;
|
|
722
|
+
const appliedPreset = init.reused ? null : init.preset;
|
|
723
|
+
if (init.reused && invocation.preset !== void 0) {
|
|
724
|
+
init.notes.push(
|
|
725
|
+
`--preset ${invocation.preset} was not applied: the existing config is kept. Edit its preset setting, or run \`init --force\` to write a new one.`
|
|
726
|
+
);
|
|
727
|
+
}
|
|
716
728
|
if (invocation.dryRun) {
|
|
717
729
|
const manager = invocation.noInstall ? null : detectPackageManager(invocation.cwd).name;
|
|
718
730
|
if (invocation.format === "json") {
|
|
@@ -720,9 +732,9 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
720
732
|
`${JSON.stringify(
|
|
721
733
|
{
|
|
722
734
|
dryRun: true,
|
|
723
|
-
configPath:
|
|
735
|
+
configPath: keptConfigPath,
|
|
724
736
|
configReused: init.reused,
|
|
725
|
-
preset:
|
|
737
|
+
preset: appliedPreset,
|
|
726
738
|
install: manager,
|
|
727
739
|
configText: init.configText
|
|
728
740
|
},
|
|
@@ -735,7 +747,7 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
735
747
|
}
|
|
736
748
|
info("\n\u{1F9EA} Dry run \u2014 setup would:");
|
|
737
749
|
info(
|
|
738
|
-
` 1. ${init.reused ? `keep ${path2.basename(
|
|
750
|
+
` 1. ${init.reused ? `keep ${path2.basename(keptConfigPath)}` : `write ${path2.basename(keptConfigPath)} (preset: ${appliedPreset})`}`
|
|
739
751
|
);
|
|
740
752
|
info(" 2. add the npm scripts, the devDependency and the .gitignore entries");
|
|
741
753
|
if (manager !== null) info(` 3. install with ${manager}`);
|
|
@@ -744,12 +756,13 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
744
756
|
info(init.configText);
|
|
745
757
|
return 0;
|
|
746
758
|
}
|
|
759
|
+
const hook = invocation.installHook === true ? installPreCommitHook(invocation.cwd, await setupHookOutDir(invocation, init)) : null;
|
|
747
760
|
if (invocation.format !== "json") {
|
|
748
761
|
if (!interactive) info(`\u{1F680} Setup for: ${invocation.cwd}`);
|
|
749
762
|
if (init.reused) {
|
|
750
|
-
info(`\u267B Keeping ${path2.basename(
|
|
763
|
+
info(`\u267B Keeping ${path2.basename(keptConfigPath)}`);
|
|
751
764
|
} else {
|
|
752
|
-
info(`\u2705 Created ${path2.basename(
|
|
765
|
+
info(`\u2705 Created ${path2.basename(keptConfigPath)} (${presetSummary(init)})`);
|
|
753
766
|
}
|
|
754
767
|
if (init.scripts.length > 0) info(` Added npm scripts: ${init.scripts.join(", ")}`);
|
|
755
768
|
if (init.dependency.added && init.dependency.range !== null) {
|
|
@@ -759,6 +772,9 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
759
772
|
info(` Added to .gitignore: ${init.gitignoreEntries.join(", ")}`);
|
|
760
773
|
}
|
|
761
774
|
if (hook) for (const note of hook.notes) info(` ${note}`);
|
|
775
|
+
if (init.reused && invocation.preset !== void 0) {
|
|
776
|
+
info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
|
|
777
|
+
}
|
|
762
778
|
}
|
|
763
779
|
let install = null;
|
|
764
780
|
if (invocation.noInstall) {
|
|
@@ -776,7 +792,9 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
776
792
|
if (invocation.includeSensitiveFiles === true) generateArgs.push("--include-sensitive-files");
|
|
777
793
|
const budget = invocation.maxPartBytesRaw ?? invocation.maxPartBytes;
|
|
778
794
|
if (budget !== void 0) generateArgs.push("--max-part-bytes", String(budget));
|
|
779
|
-
if ((invocation.
|
|
795
|
+
if ((invocation.onlyArtifacts ?? []).length > 0) {
|
|
796
|
+
generateArgs.push("--only-artifacts", (invocation.onlyArtifacts ?? []).join(","));
|
|
797
|
+
} else if ((invocation.skipArtifacts ?? []).length > 0) {
|
|
780
798
|
generateArgs.push("--skip-artifacts", (invocation.skipArtifacts ?? []).join(","));
|
|
781
799
|
}
|
|
782
800
|
if (invocation.includeMonolith === true) generateArgs.push("--include-monolith");
|
|
@@ -803,9 +821,9 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
803
821
|
parsed = null;
|
|
804
822
|
}
|
|
805
823
|
const setup = {
|
|
806
|
-
configPath:
|
|
824
|
+
configPath: keptConfigPath,
|
|
807
825
|
configReused: init.reused,
|
|
808
|
-
preset:
|
|
826
|
+
preset: appliedPreset,
|
|
809
827
|
scripts: init.scripts,
|
|
810
828
|
dependency: init.dependency,
|
|
811
829
|
gitignoreEntries: init.gitignoreEntries,
|
|
@@ -938,7 +956,19 @@ function requestsJsonFormat(argv) {
|
|
|
938
956
|
}
|
|
939
957
|
return format === "json";
|
|
940
958
|
}
|
|
959
|
+
var closedStdoutGuarded = false;
|
|
960
|
+
function guardClosedStdout() {
|
|
961
|
+
if (closedStdoutGuarded) return;
|
|
962
|
+
closedStdoutGuarded = true;
|
|
963
|
+
process.stdout.on("error", (error) => {
|
|
964
|
+
if (error.code === "EPIPE" || error.code === "ECONNRESET") {
|
|
965
|
+
process.exit(0);
|
|
966
|
+
}
|
|
967
|
+
throw error;
|
|
968
|
+
});
|
|
969
|
+
}
|
|
941
970
|
async function main(argv = process.argv.slice(2)) {
|
|
971
|
+
guardClosedStdout();
|
|
942
972
|
const pending = process.stdout.isTTY === true && shouldCheck(argv, process.env) ? checkForUpdate({ current: GENERATOR_VERSION, cacheFile: cacheFilePath() }) : null;
|
|
943
973
|
const code = await runCommand(argv);
|
|
944
974
|
if (pending) {
|
|
@@ -994,40 +1024,47 @@ ${USAGE}
|
|
|
994
1024
|
const skipConfig = invocation.noConfig || invocation.command === "diff";
|
|
995
1025
|
const loaded = skipConfig ? { config: null, warnings: [], errors: [], file: null } : await loadConfigFileDetailed(invocation.cwd);
|
|
996
1026
|
if (invocation.noConfig) info("\u2699 --no-config: using built-in defaults, config file ignored");
|
|
997
|
-
for (const warning of loaded.warnings) warn(`\u26A0 Config: ${warning}`);
|
|
998
1027
|
if (loaded.errors.length > 0) {
|
|
999
|
-
|
|
1000
|
-
|
|
1028
|
+
return fail(
|
|
1029
|
+
invocation.format,
|
|
1030
|
+
`The config file could not be read: ${loaded.errors.join("; ")}. Fix it, or delete it to use the defaults.`
|
|
1031
|
+
);
|
|
1001
1032
|
}
|
|
1033
|
+
for (const warning of loaded.warnings) warn(`\u26A0 Config: ${warning}`);
|
|
1002
1034
|
if (loaded.file) info(`\u2699 Using config ${path2.relative(process.cwd(), loaded.file) || loaded.file}`);
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1035
|
+
let resolved;
|
|
1036
|
+
try {
|
|
1037
|
+
resolved = resolveConfig(
|
|
1038
|
+
loaded.config,
|
|
1039
|
+
{
|
|
1040
|
+
mode: invocation.command,
|
|
1041
|
+
format: invocation.format,
|
|
1042
|
+
dryRun: invocation.dryRun,
|
|
1043
|
+
cwd: invocation.cwd,
|
|
1044
|
+
outDir: invocation.outDir,
|
|
1045
|
+
includeMonolith: invocation.includeMonolith,
|
|
1046
|
+
includeSensitiveFiles: invocation.includeSensitiveFiles,
|
|
1047
|
+
maxPartBytes: invocation.maxPartBytes,
|
|
1048
|
+
maxPartTokens: invocation.maxPartTokens,
|
|
1049
|
+
largeFileBytes: invocation.largeFileBytes,
|
|
1050
|
+
maxMonolithBytes: invocation.maxMonolithBytes,
|
|
1051
|
+
skipArtifacts: invocation.skipArtifacts,
|
|
1052
|
+
// `--only-artifacts` is forwarded as itself, not only as the derived suppression list:
|
|
1053
|
+
// suppression cannot switch an artifact *on*, so a config that had turned one of the
|
|
1054
|
+
// requested artifacts off left the run with nothing to write.
|
|
1055
|
+
onlyArtifacts: invocation.onlyArtifacts,
|
|
1056
|
+
discovery: invocation.discovery,
|
|
1057
|
+
changedSince: invocation.changedSince,
|
|
1058
|
+
staged: invocation.staged,
|
|
1059
|
+
withDependents: invocation.withDependents,
|
|
1060
|
+
skeleton: invocation.skeleton,
|
|
1061
|
+
sarif: invocation.sarif
|
|
1062
|
+
},
|
|
1063
|
+
invocation.cwd
|
|
1064
|
+
);
|
|
1065
|
+
} catch (err) {
|
|
1066
|
+
return fail(invocation.format, err.message);
|
|
1067
|
+
}
|
|
1031
1068
|
if (invocation.command === "validate") {
|
|
1032
1069
|
const result = validateSnapshot(resolved);
|
|
1033
1070
|
emit(invocation.format, result, () => renderValidateText(result));
|