codebase-snapshot 0.9.5 → 0.9.7
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 +80 -0
- package/README.md +4 -1
- package/dist/bin.js +471 -205
- package/dist/{chunk-4AHHSNGG.js → chunk-DPK6ZTOG.js} +33 -7
- package/dist/{chunk-B336MMNC.js → chunk-QABL7NRC.js} +445 -224
- package/dist/cli.cjs +574 -312
- package/dist/cli.d.cts +7 -1
- package/dist/cli.d.ts +7 -1
- package/dist/cli.js +16 -2
- package/dist/index.cjs +453 -217
- package/dist/index.d.cts +68 -2
- package/dist/index.d.ts +68 -2
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +31 -4
- package/dist/mcp.d.cts +14 -1
- package/dist/mcp.d.ts +14 -1
- package/dist/mcp.js +2 -2
- package/docs/cli.md +19 -2
- package/docs/mcp.md +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
var crypto = require('crypto');
|
|
4
4
|
var async_hooks = require('async_hooks');
|
|
5
|
-
var
|
|
5
|
+
var fs12 = require('fs');
|
|
6
6
|
var os = require('os');
|
|
7
|
-
var
|
|
7
|
+
var path13 = require('path');
|
|
8
8
|
var ts = require('typescript');
|
|
9
9
|
var module$1 = require('module');
|
|
10
10
|
var url = require('url');
|
|
11
11
|
var childProcess = require('child_process');
|
|
12
|
+
var https = require('https');
|
|
12
13
|
var readline = require('readline');
|
|
13
14
|
|
|
14
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -32,11 +33,12 @@ function _interopNamespace(e) {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
var crypto__namespace = /*#__PURE__*/_interopNamespace(crypto);
|
|
35
|
-
var
|
|
36
|
+
var fs12__namespace = /*#__PURE__*/_interopNamespace(fs12);
|
|
36
37
|
var os__namespace = /*#__PURE__*/_interopNamespace(os);
|
|
37
|
-
var
|
|
38
|
+
var path13__namespace = /*#__PURE__*/_interopNamespace(path13);
|
|
38
39
|
var ts__default = /*#__PURE__*/_interopDefault(ts);
|
|
39
40
|
var childProcess__namespace = /*#__PURE__*/_interopNamespace(childProcess);
|
|
41
|
+
var https__namespace = /*#__PURE__*/_interopNamespace(https);
|
|
40
42
|
var readline__namespace = /*#__PURE__*/_interopNamespace(readline);
|
|
41
43
|
|
|
42
44
|
// src/index.ts
|
|
@@ -263,9 +265,9 @@ var JAVA_METHOD = /^\s+(?:public|private|protected)\s+(?:static\s+)?(?:final\s+)
|
|
|
263
265
|
var jvmProfile = {
|
|
264
266
|
id: "jvm",
|
|
265
267
|
extensions: [".java", ".kt", ".kts", ".scala"],
|
|
266
|
-
summarize(
|
|
268
|
+
summarize(path14, content) {
|
|
267
269
|
const summary = emptySummary();
|
|
268
|
-
const lower =
|
|
270
|
+
const lower = path14.toLowerCase();
|
|
269
271
|
const isJava = lower.endsWith(".java");
|
|
270
272
|
const isKotlin = lower.endsWith(".kt") || lower.endsWith(".kts");
|
|
271
273
|
eachLine(content, (line) => {
|
|
@@ -718,16 +720,16 @@ function summarizeTypeScriptSource(relativePath, content) {
|
|
|
718
720
|
// src/ast/profiles/sfc.ts
|
|
719
721
|
var SCRIPT_BLOCK = /<script[^>]*>([\s\S]*?)<\/script>/gi;
|
|
720
722
|
var ASTRO_FRONTMATTER = /^\uFEFF?---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?=\r?\n|$)/;
|
|
721
|
-
function componentName(
|
|
722
|
-
const base =
|
|
723
|
+
function componentName(path14) {
|
|
724
|
+
const base = path14.split("/").pop() ?? path14;
|
|
723
725
|
return base.replace(/\.[^.]+$/, "");
|
|
724
726
|
}
|
|
725
727
|
var sfcProfile = {
|
|
726
728
|
id: "sfc",
|
|
727
729
|
extensions: [".vue", ".svelte", ".astro"],
|
|
728
|
-
summarize(
|
|
730
|
+
summarize(path14, content) {
|
|
729
731
|
let script = "";
|
|
730
|
-
if (
|
|
732
|
+
if (path14.toLowerCase().endsWith(".astro")) {
|
|
731
733
|
const frontmatter = ASTRO_FRONTMATTER.exec(content);
|
|
732
734
|
if (frontmatter) script += `${frontmatter[1]}
|
|
733
735
|
`;
|
|
@@ -736,7 +738,7 @@ var sfcProfile = {
|
|
|
736
738
|
script += `${match[1]}
|
|
737
739
|
`;
|
|
738
740
|
}
|
|
739
|
-
const name = componentName(
|
|
741
|
+
const name = componentName(path14);
|
|
740
742
|
if (!script.trim()) {
|
|
741
743
|
const summary2 = emptySummary();
|
|
742
744
|
if (name) {
|
|
@@ -770,15 +772,15 @@ for (const profile of LANGUAGE_PROFILES) {
|
|
|
770
772
|
BY_EXTENSION.set(extension.toLowerCase(), profile);
|
|
771
773
|
}
|
|
772
774
|
}
|
|
773
|
-
function profileForPath(
|
|
774
|
-
const lower =
|
|
775
|
+
function profileForPath(path14) {
|
|
776
|
+
const lower = path14.toLowerCase();
|
|
775
777
|
const dot = lower.lastIndexOf(".");
|
|
776
778
|
if (dot === -1) return null;
|
|
777
779
|
return BY_EXTENSION.get(lower.slice(dot)) ?? null;
|
|
778
780
|
}
|
|
779
|
-
function summarizeWithProfile(
|
|
780
|
-
const profile = profileForPath(
|
|
781
|
-
return profile ? profile.summarize(
|
|
781
|
+
function summarizeWithProfile(path14, content) {
|
|
782
|
+
const profile = profileForPath(path14);
|
|
783
|
+
return profile ? profile.summarize(path14, content) : null;
|
|
782
784
|
}
|
|
783
785
|
|
|
784
786
|
// src/ast/structured.ts
|
|
@@ -949,15 +951,15 @@ var SKIPPED_WALK_DIRS = /* @__PURE__ */ new Set([
|
|
|
949
951
|
]);
|
|
950
952
|
function readSmallFile(fullPath) {
|
|
951
953
|
try {
|
|
952
|
-
const stats =
|
|
954
|
+
const stats = fs12__namespace.statSync(fullPath);
|
|
953
955
|
if (!stats.isFile() || stats.size > MANIFEST_MAX_BYTES) return null;
|
|
954
|
-
return
|
|
956
|
+
return fs12__namespace.readFileSync(fullPath, "utf8");
|
|
955
957
|
} catch {
|
|
956
958
|
return null;
|
|
957
959
|
}
|
|
958
960
|
}
|
|
959
961
|
function readManifest(cwd, name) {
|
|
960
|
-
return readSmallFile(
|
|
962
|
+
return readSmallFile(path13__namespace.join(cwd, name));
|
|
961
963
|
}
|
|
962
964
|
function dependenciesFromPackageJson(raw) {
|
|
963
965
|
const names = /* @__PURE__ */ new Set();
|
|
@@ -1017,7 +1019,7 @@ function pnpmWorkspacePatterns(raw) {
|
|
|
1017
1019
|
function childDirectories(cwd, parent) {
|
|
1018
1020
|
let entries;
|
|
1019
1021
|
try {
|
|
1020
|
-
entries =
|
|
1022
|
+
entries = fs12__namespace.readdirSync(path13__namespace.join(cwd, parent), { withFileTypes: true });
|
|
1021
1023
|
} catch {
|
|
1022
1024
|
return [];
|
|
1023
1025
|
}
|
|
@@ -1053,12 +1055,12 @@ function scanWorkspacePackages(cwd, patterns) {
|
|
|
1053
1055
|
const files = /* @__PURE__ */ new Set();
|
|
1054
1056
|
const dependencies = /* @__PURE__ */ new Set();
|
|
1055
1057
|
for (const relative7 of workspacePackageDirs(cwd, patterns)) {
|
|
1056
|
-
const full =
|
|
1058
|
+
const full = path13__namespace.join(cwd, relative7);
|
|
1057
1059
|
try {
|
|
1058
|
-
for (const entry of
|
|
1060
|
+
for (const entry of fs12__namespace.readdirSync(full, { withFileTypes: true })) files.add(entry.name);
|
|
1059
1061
|
} catch {
|
|
1060
1062
|
}
|
|
1061
|
-
const raw = readSmallFile(
|
|
1063
|
+
const raw = readSmallFile(path13__namespace.join(full, "package.json"));
|
|
1062
1064
|
if (raw !== null) {
|
|
1063
1065
|
for (const name of dependenciesFromPackageJson(raw)) dependencies.add(name);
|
|
1064
1066
|
}
|
|
@@ -1075,7 +1077,7 @@ function countMarkdownFiles(cwd) {
|
|
|
1075
1077
|
directoriesSeen += 1;
|
|
1076
1078
|
let entries;
|
|
1077
1079
|
try {
|
|
1078
|
-
entries =
|
|
1080
|
+
entries = fs12__namespace.readdirSync(current.dir, { withFileTypes: true });
|
|
1079
1081
|
} catch {
|
|
1080
1082
|
continue;
|
|
1081
1083
|
}
|
|
@@ -1086,7 +1088,7 @@ function countMarkdownFiles(cwd) {
|
|
|
1086
1088
|
}
|
|
1087
1089
|
if (!entry.isDirectory() || current.depth >= 2) continue;
|
|
1088
1090
|
if (entry.name.startsWith(".") || SKIPPED_WALK_DIRS.has(entry.name)) continue;
|
|
1089
|
-
queue.push({ dir:
|
|
1091
|
+
queue.push({ dir: path13__namespace.join(current.dir, entry.name), depth: current.depth + 1 });
|
|
1090
1092
|
}
|
|
1091
1093
|
}
|
|
1092
1094
|
return count;
|
|
@@ -1095,7 +1097,7 @@ function buildPresetContext(cwd) {
|
|
|
1095
1097
|
const files = /* @__PURE__ */ new Set();
|
|
1096
1098
|
const dirs = /* @__PURE__ */ new Set();
|
|
1097
1099
|
try {
|
|
1098
|
-
for (const entry of
|
|
1100
|
+
for (const entry of fs12__namespace.readdirSync(cwd, { withFileTypes: true })) {
|
|
1099
1101
|
if (entry.isDirectory()) dirs.add(entry.name);
|
|
1100
1102
|
else if (entry.isFile()) files.add(entry.name);
|
|
1101
1103
|
}
|
|
@@ -1112,7 +1114,7 @@ function buildPresetContext(cwd) {
|
|
|
1112
1114
|
const isWorkspace = files.has("pnpm-workspace.yaml") || files.has("nx.json") || files.has("turbo.json") || files.has("lerna.json") || packageJson !== void 0 && packageJson.includes('"workspaces"') || declaredWorkspaces.length > 0;
|
|
1113
1115
|
let workspace = { files: /* @__PURE__ */ new Set(), dependencies: /* @__PURE__ */ new Set() };
|
|
1114
1116
|
if (isWorkspace) {
|
|
1115
|
-
const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(
|
|
1117
|
+
const pnpmRaw = files.has("pnpm-workspace.yaml") ? readSmallFile(path13__namespace.join(cwd, "pnpm-workspace.yaml")) : null;
|
|
1116
1118
|
const declared = pnpmRaw === null ? [] : pnpmWorkspacePatterns(pnpmRaw);
|
|
1117
1119
|
const patterns = declared.length > 0 ? declared : declaredWorkspaces.length > 0 ? declaredWorkspaces : DEFAULT_WORKSPACE_PATTERNS;
|
|
1118
1120
|
workspace = scanWorkspacePackages(cwd, patterns);
|
|
@@ -2387,14 +2389,14 @@ var PRESET_IGNORES = new Set(
|
|
|
2387
2389
|
);
|
|
2388
2390
|
function readLinkTarget(linkPath, fallback) {
|
|
2389
2391
|
try {
|
|
2390
|
-
return
|
|
2392
|
+
return fs12__namespace.readlinkSync(linkPath);
|
|
2391
2393
|
} catch {
|
|
2392
2394
|
return fallback;
|
|
2393
2395
|
}
|
|
2394
2396
|
}
|
|
2395
2397
|
function isInside(root, candidate) {
|
|
2396
|
-
const relative7 =
|
|
2397
|
-
return relative7 === "" || !relative7.startsWith(`..${
|
|
2398
|
+
const relative7 = path13__namespace.relative(root, candidate);
|
|
2399
|
+
return relative7 === "" || !relative7.startsWith(`..${path13__namespace.sep}`) && relative7 !== ".." && !path13__namespace.isAbsolute(relative7);
|
|
2398
2400
|
}
|
|
2399
2401
|
function getGitInfo(cwd, fallbackBranch = "main") {
|
|
2400
2402
|
try {
|
|
@@ -2599,10 +2601,10 @@ function trimUnescapedTrailingSpaces(line) {
|
|
|
2599
2601
|
return line.slice(0, end);
|
|
2600
2602
|
}
|
|
2601
2603
|
function readGitignoreRules(dir) {
|
|
2602
|
-
const gitignorePath =
|
|
2604
|
+
const gitignorePath = path13__namespace.join(dir, ".gitignore");
|
|
2603
2605
|
let raw;
|
|
2604
2606
|
try {
|
|
2605
|
-
raw =
|
|
2607
|
+
raw = fs12__namespace.readFileSync(gitignorePath, "utf8");
|
|
2606
2608
|
} catch {
|
|
2607
2609
|
return [];
|
|
2608
2610
|
}
|
|
@@ -2729,7 +2731,7 @@ function isToolOwnedDirName(name) {
|
|
|
2729
2731
|
}
|
|
2730
2732
|
function hasSnapshotMarker(target) {
|
|
2731
2733
|
try {
|
|
2732
|
-
return
|
|
2734
|
+
return fs12__namespace.statSync(target).isDirectory() && fs12__namespace.existsSync(path13__namespace.join(target, ".codebase-snapshot"));
|
|
2733
2735
|
} catch {
|
|
2734
2736
|
return false;
|
|
2735
2737
|
}
|
|
@@ -2743,7 +2745,7 @@ function makeToolOwnedDecider(cwd, toolOwnedPaths) {
|
|
|
2743
2745
|
const prefix = parts.slice(0, depth).join("/");
|
|
2744
2746
|
let hasMarker = markers.get(prefix);
|
|
2745
2747
|
if (hasMarker === void 0) {
|
|
2746
|
-
hasMarker =
|
|
2748
|
+
hasMarker = fs12__namespace.existsSync(path13__namespace.join(cwd, prefix, ".codebase-snapshot"));
|
|
2747
2749
|
markers.set(prefix, hasMarker);
|
|
2748
2750
|
}
|
|
2749
2751
|
if (hasMarker) return true;
|
|
@@ -2758,7 +2760,7 @@ function makeLinkProbe() {
|
|
|
2758
2760
|
let known = cache.get(absolutePath);
|
|
2759
2761
|
if (known === void 0) {
|
|
2760
2762
|
try {
|
|
2761
|
-
known =
|
|
2763
|
+
known = fs12__namespace.lstatSync(absolutePath).isSymbolicLink();
|
|
2762
2764
|
} catch {
|
|
2763
2765
|
known = false;
|
|
2764
2766
|
}
|
|
@@ -2771,7 +2773,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
|
|
|
2771
2773
|
const isLink = makeLinkProbe();
|
|
2772
2774
|
let rootReal = cwd;
|
|
2773
2775
|
try {
|
|
2774
|
-
rootReal =
|
|
2776
|
+
rootReal = fs12__namespace.realpathSync(cwd);
|
|
2775
2777
|
} catch {
|
|
2776
2778
|
}
|
|
2777
2779
|
const reported = /* @__PURE__ */ new Set();
|
|
@@ -2781,7 +2783,7 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
|
|
|
2781
2783
|
let linkedDir = null;
|
|
2782
2784
|
for (let depth = 1; depth <= parts.length; depth += 1) {
|
|
2783
2785
|
const prefix = parts.slice(0, depth).join("/");
|
|
2784
|
-
if (isLink(
|
|
2786
|
+
if (isLink(path13__namespace.join(cwd, prefix))) {
|
|
2785
2787
|
linkedDir = prefix;
|
|
2786
2788
|
break;
|
|
2787
2789
|
}
|
|
@@ -2792,10 +2794,10 @@ function dropLinkedDirectories(cwd, candidates, skipped) {
|
|
|
2792
2794
|
}
|
|
2793
2795
|
if (reported.has(linkedDir)) continue;
|
|
2794
2796
|
reported.add(linkedDir);
|
|
2795
|
-
const absolute =
|
|
2797
|
+
const absolute = path13__namespace.join(cwd, linkedDir);
|
|
2796
2798
|
let targetReal = absolute;
|
|
2797
2799
|
try {
|
|
2798
|
-
targetReal =
|
|
2800
|
+
targetReal = fs12__namespace.realpathSync(absolute);
|
|
2799
2801
|
} catch {
|
|
2800
2802
|
}
|
|
2801
2803
|
const target = readLinkTarget(absolute, targetReal);
|
|
@@ -2872,7 +2874,7 @@ function collectFiles(cwd, options = {}) {
|
|
|
2872
2874
|
"Discovery mode is `git`, but git could not list this directory's files. Run inside a working repository, or pass --discovery walk (or auto) to scan the tree directly."
|
|
2873
2875
|
);
|
|
2874
2876
|
}
|
|
2875
|
-
if (
|
|
2877
|
+
if (fs12__namespace.existsSync(path13__namespace.join(cwd, ".git"))) {
|
|
2876
2878
|
throw new Error(
|
|
2877
2879
|
"This directory is a git repository, but git could not list its files. A plain walk honours .gitignore files, but git also applies .git/info/exclude and your global excludes file, includes files that are tracked although a .gitignore now matches them, and treats a submodule as a single entry. Fix the repository (git status should work), run outside git, or pass --discovery walk to accept those differences."
|
|
2878
2880
|
);
|
|
@@ -2931,7 +2933,7 @@ function collectFiles(cwd, options = {}) {
|
|
|
2931
2933
|
}
|
|
2932
2934
|
function rootRealFor(root) {
|
|
2933
2935
|
try {
|
|
2934
|
-
return
|
|
2936
|
+
return fs12__namespace.realpathSync(root);
|
|
2935
2937
|
} catch {
|
|
2936
2938
|
return root;
|
|
2937
2939
|
}
|
|
@@ -2939,18 +2941,18 @@ function rootRealFor(root) {
|
|
|
2939
2941
|
function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PURE__ */ new Set(), parentGitignoreLayers = []) {
|
|
2940
2942
|
const results = { files: [], skipped: [] };
|
|
2941
2943
|
const stack = [];
|
|
2942
|
-
const relativeToBase = (target) =>
|
|
2944
|
+
const relativeToBase = (target) => path13__namespace.relative(baseDir, target).replace(/\\/g, "/") || ".";
|
|
2943
2945
|
const enter = (current, layers) => {
|
|
2944
2946
|
if (visited.has(current)) return false;
|
|
2945
2947
|
visited.add(current);
|
|
2946
2948
|
const localRules = readGitignoreRules(current);
|
|
2947
2949
|
const gitignoreLayers = localRules.length === 0 ? layers : [
|
|
2948
2950
|
...layers,
|
|
2949
|
-
{ prefix:
|
|
2951
|
+
{ prefix: path13__namespace.relative(baseDir, current).replace(/\\/g, "/"), rules: localRules }
|
|
2950
2952
|
];
|
|
2951
2953
|
let entries;
|
|
2952
2954
|
try {
|
|
2953
|
-
entries =
|
|
2955
|
+
entries = fs12__namespace.readdirSync(current, { withFileTypes: true });
|
|
2954
2956
|
} catch {
|
|
2955
2957
|
results.skipped.push({
|
|
2956
2958
|
path: relativeToBase(current),
|
|
@@ -2972,8 +2974,8 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
|
|
|
2972
2974
|
}
|
|
2973
2975
|
const entry = frame.entries[frame.index];
|
|
2974
2976
|
frame.index += 1;
|
|
2975
|
-
const fullPath =
|
|
2976
|
-
const relPath =
|
|
2977
|
+
const fullPath = path13__namespace.join(frame.dir, entry.name);
|
|
2978
|
+
const relPath = path13__namespace.relative(baseDir, fullPath).replace(/\\/g, "/");
|
|
2977
2979
|
if (isToolOwnedDirName(entry.name) && reservedPaths.has(relPath)) continue;
|
|
2978
2980
|
if (DEFAULT_IGNORED_DIRS.includes(entry.name)) {
|
|
2979
2981
|
results.skipped.push({
|
|
@@ -3006,14 +3008,14 @@ function walkDirectory(dir, baseDir, rootReal, visited, reservedPaths = /* @__PU
|
|
|
3006
3008
|
if (entry.isSymbolicLink()) {
|
|
3007
3009
|
let targetReal;
|
|
3008
3010
|
try {
|
|
3009
|
-
targetReal =
|
|
3011
|
+
targetReal = fs12__namespace.realpathSync(fullPath);
|
|
3010
3012
|
} catch {
|
|
3011
3013
|
results.skipped.push({ path: relPath, reason: "read-error", detail: "broken symlink" });
|
|
3012
3014
|
continue;
|
|
3013
3015
|
}
|
|
3014
3016
|
let stats;
|
|
3015
3017
|
try {
|
|
3016
|
-
stats =
|
|
3018
|
+
stats = fs12__namespace.statSync(fullPath);
|
|
3017
3019
|
} catch {
|
|
3018
3020
|
results.skipped.push({ path: relPath, reason: "read-error", detail: "unreadable symlink" });
|
|
3019
3021
|
continue;
|
|
@@ -3311,11 +3313,11 @@ async function loadConfigFileDetailed(cwd) {
|
|
|
3311
3313
|
const warnings = [];
|
|
3312
3314
|
const errors = [];
|
|
3313
3315
|
for (const filename of CONFIG_FILENAMES) {
|
|
3314
|
-
const fullPath =
|
|
3315
|
-
if (!
|
|
3316
|
+
const fullPath = path13__namespace.join(cwd, filename);
|
|
3317
|
+
if (!fs12__namespace.existsSync(fullPath)) continue;
|
|
3316
3318
|
if (filename.endsWith(".json") || filename === ".snapshotrc") {
|
|
3317
3319
|
try {
|
|
3318
|
-
const config = parseJsonish(
|
|
3320
|
+
const config = parseJsonish(fs12__namespace.readFileSync(fullPath, "utf8"), fullPath);
|
|
3319
3321
|
if (config === null || typeof config !== "object" || Array.isArray(config)) {
|
|
3320
3322
|
throw new Error(
|
|
3321
3323
|
`${fullPath} does not hold a configuration object (received ${describeValue2(config)}).`
|
|
@@ -3349,10 +3351,10 @@ async function loadConfigFileDetailed(cwd) {
|
|
|
3349
3351
|
continue;
|
|
3350
3352
|
}
|
|
3351
3353
|
}
|
|
3352
|
-
const pkgJsonPath =
|
|
3353
|
-
if (
|
|
3354
|
+
const pkgJsonPath = path13__namespace.join(cwd, "package.json");
|
|
3355
|
+
if (fs12__namespace.existsSync(pkgJsonPath)) {
|
|
3354
3356
|
try {
|
|
3355
|
-
const parsed = parseJsonish(
|
|
3357
|
+
const parsed = parseJsonish(fs12__namespace.readFileSync(pkgJsonPath, "utf8"), pkgJsonPath);
|
|
3356
3358
|
const snapshotKey = parsed.snapshot;
|
|
3357
3359
|
if (snapshotKey && typeof snapshotKey === "object" && !Array.isArray(snapshotKey)) {
|
|
3358
3360
|
return { config: snapshotKey, file: pkgJsonPath, warnings, errors };
|
|
@@ -3375,7 +3377,7 @@ async function loadConfigFile(cwd) {
|
|
|
3375
3377
|
const loaded = await loadConfigFileDetailed(cwd);
|
|
3376
3378
|
if (loaded.config && loaded.file && typeof loaded.config === "object") {
|
|
3377
3379
|
Object.defineProperty(loaded.config, CONFIG_DIR_SYMBOL, {
|
|
3378
|
-
value:
|
|
3380
|
+
value: path13__namespace.dirname(loaded.file),
|
|
3379
3381
|
enumerable: false,
|
|
3380
3382
|
configurable: true
|
|
3381
3383
|
});
|
|
@@ -3534,9 +3536,9 @@ function resolveKindRules(value) {
|
|
|
3534
3536
|
function outputExcludePatterns(cwd, outDir, tmpDir) {
|
|
3535
3537
|
const patterns = [];
|
|
3536
3538
|
for (const dir of [outDir, tmpDir]) {
|
|
3537
|
-
const absolute =
|
|
3538
|
-
const relative7 =
|
|
3539
|
-
if (!relative7 || relative7 === ".." || relative7.startsWith(`..${
|
|
3539
|
+
const absolute = path13__namespace.resolve(cwd, dir);
|
|
3540
|
+
const relative7 = path13__namespace.relative(cwd, absolute);
|
|
3541
|
+
if (!relative7 || relative7 === ".." || relative7.startsWith(`..${path13__namespace.sep}`) || path13__namespace.isAbsolute(relative7)) {
|
|
3540
3542
|
continue;
|
|
3541
3543
|
}
|
|
3542
3544
|
patterns.push(`${relative7.replace(/\\/g, "/")}/**`);
|
|
@@ -3655,11 +3657,11 @@ function resolveCandidateCwd(userConfig, cliOptions, baseDir) {
|
|
|
3655
3657
|
);
|
|
3656
3658
|
}
|
|
3657
3659
|
const candidate = cliOptions?.cwd || userConfig?.cwd || baseDir || process.cwd();
|
|
3658
|
-
const resolved =
|
|
3659
|
-
if (!
|
|
3660
|
+
const resolved = path13__namespace.resolve(candidate);
|
|
3661
|
+
if (!fs12__namespace.existsSync(resolved)) {
|
|
3660
3662
|
throw new Error(`Working directory does not exist: ${resolved}`);
|
|
3661
3663
|
}
|
|
3662
|
-
if (!
|
|
3664
|
+
if (!fs12__namespace.statSync(resolved).isDirectory()) {
|
|
3663
3665
|
throw new Error(`Working directory is not a directory: ${resolved}`);
|
|
3664
3666
|
}
|
|
3665
3667
|
return resolved;
|
|
@@ -4683,7 +4685,7 @@ var BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
4683
4685
|
".so"
|
|
4684
4686
|
]);
|
|
4685
4687
|
function isBinaryExtension(filePath) {
|
|
4686
|
-
const ext =
|
|
4688
|
+
const ext = path13__namespace.extname(filePath).toLowerCase();
|
|
4687
4689
|
return BINARY_EXTENSIONS.has(ext);
|
|
4688
4690
|
}
|
|
4689
4691
|
function isBinaryBuffer(buffer) {
|
|
@@ -4853,13 +4855,13 @@ function isBinaryFile(absolutePath) {
|
|
|
4853
4855
|
if (isBinaryExtension(absolutePath)) return true;
|
|
4854
4856
|
let fd;
|
|
4855
4857
|
try {
|
|
4856
|
-
fd =
|
|
4858
|
+
fd = fs12__namespace.openSync(absolutePath, "r");
|
|
4857
4859
|
const buffer = Buffer.alloc(CHUNK);
|
|
4858
4860
|
let sample;
|
|
4859
4861
|
let position = 0;
|
|
4860
4862
|
while (position < BINARY_SCAN_BYTES) {
|
|
4861
4863
|
const wanted = Math.min(CHUNK, BINARY_SCAN_BYTES - position);
|
|
4862
|
-
const bytesRead =
|
|
4864
|
+
const bytesRead = fs12__namespace.readSync(fd, buffer, 0, wanted, position);
|
|
4863
4865
|
if (bytesRead === 0) return false;
|
|
4864
4866
|
const chunk = buffer.subarray(0, bytesRead);
|
|
4865
4867
|
if (sample === void 0) {
|
|
@@ -4877,7 +4879,7 @@ function isBinaryFile(absolutePath) {
|
|
|
4877
4879
|
} finally {
|
|
4878
4880
|
if (fd !== void 0) {
|
|
4879
4881
|
try {
|
|
4880
|
-
|
|
4882
|
+
fs12__namespace.closeSync(fd);
|
|
4881
4883
|
} catch {
|
|
4882
4884
|
}
|
|
4883
4885
|
}
|
|
@@ -4937,10 +4939,10 @@ var LANGUAGE_BY_BASENAME = {
|
|
|
4937
4939
|
};
|
|
4938
4940
|
function detectLanguage(filePath) {
|
|
4939
4941
|
const normalized = filePath.replace(/\\/g, "/");
|
|
4940
|
-
const base =
|
|
4942
|
+
const base = path13__namespace.posix.basename(normalized);
|
|
4941
4943
|
if (LANGUAGE_BY_BASENAME[base]) return LANGUAGE_BY_BASENAME[base];
|
|
4942
4944
|
if (base === ".env" || base.startsWith(".env.")) return "dotenv";
|
|
4943
|
-
const ext =
|
|
4945
|
+
const ext = path13__namespace.posix.extname(base).toLowerCase();
|
|
4944
4946
|
return LANGUAGE_BY_EXTENSION[ext] ?? "text";
|
|
4945
4947
|
}
|
|
4946
4948
|
function maskedPath(value, secretRules) {
|
|
@@ -4948,33 +4950,33 @@ function maskedPath(value, secretRules) {
|
|
|
4948
4950
|
}
|
|
4949
4951
|
function confineToDirectory(directory, filename) {
|
|
4950
4952
|
if (filename.includes("\0")) return null;
|
|
4951
|
-
if (
|
|
4952
|
-
const base =
|
|
4953
|
-
const resolved =
|
|
4953
|
+
if (path13__namespace.isAbsolute(filename)) return null;
|
|
4954
|
+
const base = path13__namespace.resolve(directory);
|
|
4955
|
+
const resolved = path13__namespace.resolve(base, filename);
|
|
4954
4956
|
const caseInsensitive = process.platform === "win32" || process.platform === "darwin";
|
|
4955
|
-
const prefix = caseInsensitive ? `${base}${
|
|
4957
|
+
const prefix = caseInsensitive ? `${base}${path13__namespace.sep}`.toLowerCase() : `${base}${path13__namespace.sep}`;
|
|
4956
4958
|
const candidate = caseInsensitive ? resolved.toLowerCase() : resolved;
|
|
4957
4959
|
return candidate.startsWith(prefix) ? resolved : null;
|
|
4958
4960
|
}
|
|
4959
4961
|
function findStagingDirectory(config) {
|
|
4960
|
-
const tmpDir =
|
|
4962
|
+
const tmpDir = path13__namespace.resolve(config.cwd, config.tmpDir);
|
|
4961
4963
|
let entries;
|
|
4962
4964
|
try {
|
|
4963
|
-
entries =
|
|
4965
|
+
entries = fs12__namespace.readdirSync(tmpDir);
|
|
4964
4966
|
} catch {
|
|
4965
4967
|
return null;
|
|
4966
4968
|
}
|
|
4967
4969
|
const runs = entries.filter((name) => name.startsWith("run-")).sort();
|
|
4968
4970
|
const newest = runs[runs.length - 1];
|
|
4969
|
-
return newest ?
|
|
4971
|
+
return newest ? path13__namespace.join(tmpDir, newest) : null;
|
|
4970
4972
|
}
|
|
4971
4973
|
function describeMissingManifest(config, manifestPath) {
|
|
4972
|
-
const outDir =
|
|
4973
|
-
const markerPath =
|
|
4974
|
+
const outDir = path13__namespace.resolve(config.cwd, config.outDir);
|
|
4975
|
+
const markerPath = path13__namespace.join(outDir, ".codebase-snapshot");
|
|
4974
4976
|
let marker2 = null;
|
|
4975
4977
|
try {
|
|
4976
|
-
if (
|
|
4977
|
-
const parsed = JSON.parse(
|
|
4978
|
+
if (fs12__namespace.existsSync(markerPath)) {
|
|
4979
|
+
const parsed = JSON.parse(fs12__namespace.readFileSync(markerPath, "utf8"));
|
|
4978
4980
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
4979
4981
|
marker2 = parsed;
|
|
4980
4982
|
}
|
|
@@ -5010,14 +5012,14 @@ function sha256Hex(buffer) {
|
|
|
5010
5012
|
}
|
|
5011
5013
|
var VERIFY_SNIFF_MAX_BYTES = 8 * 1024 * 1024;
|
|
5012
5014
|
function wouldNowBeIncluded(cwd, relativePath, reason) {
|
|
5013
|
-
const absolutePath =
|
|
5015
|
+
const absolutePath = path13__namespace.join(cwd, relativePath);
|
|
5014
5016
|
try {
|
|
5015
|
-
const stats =
|
|
5017
|
+
const stats = fs12__namespace.statSync(absolutePath);
|
|
5016
5018
|
if (!stats.isFile()) return false;
|
|
5017
5019
|
if (isBinaryFile(absolutePath)) return false;
|
|
5018
5020
|
if (reason !== "binary") return true;
|
|
5019
5021
|
if (stats.size > VERIFY_SNIFF_MAX_BYTES) return false;
|
|
5020
|
-
return !decodeText(
|
|
5022
|
+
return !decodeText(fs12__namespace.readFileSync(absolutePath)).binary;
|
|
5021
5023
|
} catch {
|
|
5022
5024
|
return false;
|
|
5023
5025
|
}
|
|
@@ -5075,8 +5077,8 @@ function describeManifestShapeProblem(value) {
|
|
|
5075
5077
|
function validateSnapshot(configInput) {
|
|
5076
5078
|
assertUsableConfigInput(configInput);
|
|
5077
5079
|
const config = isResolvedConfig(configInput) ? normalizeResolvedConfig(configInput) : resolveConfig(configInput);
|
|
5078
|
-
const manifestPath =
|
|
5079
|
-
if (!
|
|
5080
|
+
const manifestPath = path13__namespace.resolve(config.cwd, config.outDir, "manifest.json");
|
|
5081
|
+
if (!fs12__namespace.existsSync(manifestPath)) {
|
|
5080
5082
|
return {
|
|
5081
5083
|
valid: false,
|
|
5082
5084
|
manifestPresent: false,
|
|
@@ -5087,7 +5089,7 @@ function validateSnapshot(configInput) {
|
|
|
5087
5089
|
}
|
|
5088
5090
|
let manifest;
|
|
5089
5091
|
try {
|
|
5090
|
-
manifest = JSON.parse(
|
|
5092
|
+
manifest = JSON.parse(fs12__namespace.readFileSync(manifestPath, "utf8"));
|
|
5091
5093
|
} catch (err) {
|
|
5092
5094
|
return {
|
|
5093
5095
|
valid: false,
|
|
@@ -5109,7 +5111,7 @@ function validateSnapshot(configInput) {
|
|
|
5109
5111
|
}
|
|
5110
5112
|
const drift = emptyDrift();
|
|
5111
5113
|
const warnings = [];
|
|
5112
|
-
const snapshotDir =
|
|
5114
|
+
const snapshotDir = path13__namespace.resolve(config.cwd, config.outDir);
|
|
5113
5115
|
const manifestFileMap = /* @__PURE__ */ new Map();
|
|
5114
5116
|
for (const file of manifest.files) {
|
|
5115
5117
|
if (file && typeof file.relativePath === "string") {
|
|
@@ -5143,7 +5145,7 @@ function validateSnapshot(configInput) {
|
|
|
5143
5145
|
}
|
|
5144
5146
|
let diskHash;
|
|
5145
5147
|
try {
|
|
5146
|
-
diskHash = sha256Hex(
|
|
5148
|
+
diskHash = sha256Hex(fs12__namespace.readFileSync(path13__namespace.join(config.cwd, diskFile)));
|
|
5147
5149
|
} catch (err) {
|
|
5148
5150
|
if (err.code === "ENOENT") {
|
|
5149
5151
|
drift.missingOnDisk.push(diskFile);
|
|
@@ -5167,7 +5169,7 @@ function validateSnapshot(configInput) {
|
|
|
5167
5169
|
}
|
|
5168
5170
|
let statFailure = null;
|
|
5169
5171
|
try {
|
|
5170
|
-
|
|
5172
|
+
fs12__namespace.statSync(confined);
|
|
5171
5173
|
} catch (err) {
|
|
5172
5174
|
statFailure = err;
|
|
5173
5175
|
}
|
|
@@ -5187,7 +5189,7 @@ function validateSnapshot(configInput) {
|
|
|
5187
5189
|
...Object.values(config.budgets.byLayer)
|
|
5188
5190
|
);
|
|
5189
5191
|
const partNames = /* @__PURE__ */ new Set();
|
|
5190
|
-
const partsDir =
|
|
5192
|
+
const partsDir = path13__namespace.join(snapshotDir, "parts");
|
|
5191
5193
|
for (const part of manifest.parts) {
|
|
5192
5194
|
if (!part || typeof part.filename !== "string") continue;
|
|
5193
5195
|
partNames.add(part.filename);
|
|
@@ -5202,7 +5204,7 @@ function validateSnapshot(configInput) {
|
|
|
5202
5204
|
}
|
|
5203
5205
|
let buffer;
|
|
5204
5206
|
try {
|
|
5205
|
-
buffer =
|
|
5207
|
+
buffer = fs12__namespace.readFileSync(partPath);
|
|
5206
5208
|
} catch {
|
|
5207
5209
|
drift.partIssues.push({ part: part.filename, issue: "missing from snapshot/parts" });
|
|
5208
5210
|
continue;
|
|
@@ -5416,9 +5418,9 @@ function validateSnapshot(configInput) {
|
|
|
5416
5418
|
["full-codebase.md", manifest.artifacts?.fullMarkdown]
|
|
5417
5419
|
]) {
|
|
5418
5420
|
if (!artifact) continue;
|
|
5419
|
-
const artifactPath =
|
|
5421
|
+
const artifactPath = path13__namespace.join(snapshotDir, key);
|
|
5420
5422
|
try {
|
|
5421
|
-
const buffer =
|
|
5423
|
+
const buffer = fs12__namespace.readFileSync(artifactPath);
|
|
5422
5424
|
if (sha256Hex(buffer) !== artifact.sha256 || buffer.length !== artifact.byteSize) {
|
|
5423
5425
|
drift.partIssues.push({ part: key, issue: "artifact does not match its recorded digest" });
|
|
5424
5426
|
}
|
|
@@ -5488,12 +5490,168 @@ function validateSnapshot(configInput) {
|
|
|
5488
5490
|
|
|
5489
5491
|
// src/version.ts
|
|
5490
5492
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
5491
|
-
var GENERATOR_VERSION = "0.9.
|
|
5493
|
+
var GENERATOR_VERSION = "0.9.7";
|
|
5492
5494
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
5493
5495
|
function isOurGeneratorName(name) {
|
|
5494
5496
|
if (typeof name !== "string") return false;
|
|
5495
5497
|
return name === GENERATOR_NAME || LEGACY_GENERATOR_NAMES.includes(name);
|
|
5496
5498
|
}
|
|
5499
|
+
var PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
|
|
5500
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
5501
|
+
var FAILURE_INTERVAL_MS = 60 * 60 * 1e3;
|
|
5502
|
+
var REQUEST_TIMEOUT_MS = 1200;
|
|
5503
|
+
function versionParts(value) {
|
|
5504
|
+
const core = value.trim().replace(/^v/i, "").split("-")[0];
|
|
5505
|
+
return core.split(".").map((part) => {
|
|
5506
|
+
const parsed = Number(part);
|
|
5507
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
5508
|
+
});
|
|
5509
|
+
}
|
|
5510
|
+
function isNewer(candidate, current) {
|
|
5511
|
+
const left = versionParts(candidate);
|
|
5512
|
+
const right = versionParts(current);
|
|
5513
|
+
const length = Math.max(left.length, right.length);
|
|
5514
|
+
for (let index = 0; index < length; index += 1) {
|
|
5515
|
+
const a = left[index] ?? 0;
|
|
5516
|
+
const b = right[index] ?? 0;
|
|
5517
|
+
if (a !== b) return a > b;
|
|
5518
|
+
}
|
|
5519
|
+
return false;
|
|
5520
|
+
}
|
|
5521
|
+
function cacheDirectory(env = process.env, platform = process.platform) {
|
|
5522
|
+
if (platform === "win32") {
|
|
5523
|
+
const base2 = env.LOCALAPPDATA ?? path13__namespace.join(os__namespace.homedir(), "AppData", "Local");
|
|
5524
|
+
return path13__namespace.join(base2, "codebase-snapshot");
|
|
5525
|
+
}
|
|
5526
|
+
if (platform === "darwin") {
|
|
5527
|
+
return path13__namespace.join(os__namespace.homedir(), "Library", "Caches", "codebase-snapshot");
|
|
5528
|
+
}
|
|
5529
|
+
const base = env.XDG_CACHE_HOME ?? path13__namespace.join(os__namespace.homedir(), ".cache");
|
|
5530
|
+
return path13__namespace.join(base, "codebase-snapshot");
|
|
5531
|
+
}
|
|
5532
|
+
function cacheFilePath(env = process.env) {
|
|
5533
|
+
return path13__namespace.join(cacheDirectory(env), "update-check.json");
|
|
5534
|
+
}
|
|
5535
|
+
function shouldCheck(argv, env) {
|
|
5536
|
+
const disabled = ["1", "true", "yes"].includes(
|
|
5537
|
+
String(env.CODEBASE_SNAPSHOT_NO_UPDATE_CHECK ?? "").toLowerCase()
|
|
5538
|
+
);
|
|
5539
|
+
if (disabled) return false;
|
|
5540
|
+
if (env.CI !== void 0 && env.CI !== "" && env.CI !== "false" && env.CI !== "0") return false;
|
|
5541
|
+
const args = argv.map((argument) => argument.toLowerCase());
|
|
5542
|
+
if (args.includes("--no-update-check")) return false;
|
|
5543
|
+
for (const skip of ["mcp", "describe", "skill", "--version", "-v", "--help", "-h"]) {
|
|
5544
|
+
if (args.includes(skip)) return false;
|
|
5545
|
+
}
|
|
5546
|
+
if (args.some((argument) => argument.includes("json"))) return false;
|
|
5547
|
+
return true;
|
|
5548
|
+
}
|
|
5549
|
+
function readCache(file) {
|
|
5550
|
+
let raw;
|
|
5551
|
+
try {
|
|
5552
|
+
raw = fs12__namespace.readFileSync(file, "utf8");
|
|
5553
|
+
} catch {
|
|
5554
|
+
return null;
|
|
5555
|
+
}
|
|
5556
|
+
try {
|
|
5557
|
+
const parsed = JSON.parse(raw);
|
|
5558
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
5559
|
+
const candidate = parsed;
|
|
5560
|
+
if (typeof candidate.checkedAt !== "number") return null;
|
|
5561
|
+
const latest = typeof candidate.latest === "string" ? candidate.latest : null;
|
|
5562
|
+
return { checkedAt: candidate.checkedAt, latest };
|
|
5563
|
+
} catch {
|
|
5564
|
+
return null;
|
|
5565
|
+
}
|
|
5566
|
+
}
|
|
5567
|
+
function writeCache(file, entry) {
|
|
5568
|
+
try {
|
|
5569
|
+
fs12__namespace.mkdirSync(path13__namespace.dirname(file), { recursive: true });
|
|
5570
|
+
fs12__namespace.writeFileSync(file, `${JSON.stringify(entry)}
|
|
5571
|
+
`, "utf8");
|
|
5572
|
+
} catch {
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
function fetchLatestVersion(url = PACKAGE_LATEST_URL, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
5576
|
+
return new Promise((resolve5) => {
|
|
5577
|
+
let settled = false;
|
|
5578
|
+
const finish = (value) => {
|
|
5579
|
+
if (settled) return;
|
|
5580
|
+
settled = true;
|
|
5581
|
+
resolve5(value);
|
|
5582
|
+
};
|
|
5583
|
+
const request = https__namespace.get(
|
|
5584
|
+
url,
|
|
5585
|
+
{
|
|
5586
|
+
headers: {
|
|
5587
|
+
accept: "application/json",
|
|
5588
|
+
"user-agent": "codebase-snapshot (update check)"
|
|
5589
|
+
}
|
|
5590
|
+
},
|
|
5591
|
+
(response) => {
|
|
5592
|
+
if (response.statusCode !== 200) {
|
|
5593
|
+
response.resume();
|
|
5594
|
+
finish(null);
|
|
5595
|
+
return;
|
|
5596
|
+
}
|
|
5597
|
+
let body = "";
|
|
5598
|
+
response.setEncoding("utf8");
|
|
5599
|
+
response.on("data", (chunk) => {
|
|
5600
|
+
body += chunk;
|
|
5601
|
+
if (body.length > 64 * 1024) {
|
|
5602
|
+
request.destroy();
|
|
5603
|
+
finish(null);
|
|
5604
|
+
}
|
|
5605
|
+
});
|
|
5606
|
+
response.on("end", () => {
|
|
5607
|
+
try {
|
|
5608
|
+
const parsed = JSON.parse(body);
|
|
5609
|
+
finish(typeof parsed.version === "string" ? parsed.version : null);
|
|
5610
|
+
} catch {
|
|
5611
|
+
finish(null);
|
|
5612
|
+
}
|
|
5613
|
+
});
|
|
5614
|
+
}
|
|
5615
|
+
);
|
|
5616
|
+
request.on("error", () => finish(null));
|
|
5617
|
+
request.setTimeout(timeoutMs, () => {
|
|
5618
|
+
request.destroy();
|
|
5619
|
+
finish(null);
|
|
5620
|
+
});
|
|
5621
|
+
});
|
|
5622
|
+
}
|
|
5623
|
+
async function checkForUpdate(options) {
|
|
5624
|
+
if (options.enabled === false) return null;
|
|
5625
|
+
const now = options.now ?? (() => Date.now());
|
|
5626
|
+
const fetchLatest = options.fetchLatest ?? fetchLatestVersion;
|
|
5627
|
+
let latest = null;
|
|
5628
|
+
try {
|
|
5629
|
+
const cached = readCache(options.cacheFile);
|
|
5630
|
+
let needsFetch = cached === null;
|
|
5631
|
+
if (cached) {
|
|
5632
|
+
const age = now() - cached.checkedAt;
|
|
5633
|
+
if (cached.latest === null) {
|
|
5634
|
+
needsFetch = age >= FAILURE_INTERVAL_MS;
|
|
5635
|
+
} else {
|
|
5636
|
+
latest = cached.latest;
|
|
5637
|
+
needsFetch = age >= CHECK_INTERVAL_MS;
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5640
|
+
if (needsFetch) {
|
|
5641
|
+
const fetched = await fetchLatest(PACKAGE_LATEST_URL, REQUEST_TIMEOUT_MS);
|
|
5642
|
+
writeCache(options.cacheFile, { checkedAt: now(), latest: fetched });
|
|
5643
|
+
latest = fetched;
|
|
5644
|
+
}
|
|
5645
|
+
} catch {
|
|
5646
|
+
return null;
|
|
5647
|
+
}
|
|
5648
|
+
if (!latest) return null;
|
|
5649
|
+
return isNewer(latest, options.current) ? { current: options.current, latest } : null;
|
|
5650
|
+
}
|
|
5651
|
+
function formatUpdateNotice(notice) {
|
|
5652
|
+
return `\u2191 codebase-snapshot ${notice.latest} is available \u2014 you have ${notice.current}.
|
|
5653
|
+
npm install -g codebase-snapshot`;
|
|
5654
|
+
}
|
|
5497
5655
|
function describeMatcher(matcher) {
|
|
5498
5656
|
if (typeof matcher === "string") return matcher;
|
|
5499
5657
|
if (matcher instanceof RegExp) return String(matcher);
|
|
@@ -5503,10 +5661,10 @@ function describeMatcher(matcher) {
|
|
|
5503
5661
|
return String(matcher);
|
|
5504
5662
|
}
|
|
5505
5663
|
function normalizeTarget(cwd, target) {
|
|
5506
|
-
const absolute =
|
|
5507
|
-
const relative7 =
|
|
5508
|
-
if (relative7.startsWith("..") ||
|
|
5509
|
-
return relative7.split(
|
|
5664
|
+
const absolute = path13__namespace.resolve(cwd, target);
|
|
5665
|
+
const relative7 = path13__namespace.relative(cwd, absolute);
|
|
5666
|
+
if (relative7.startsWith("..") || path13__namespace.isAbsolute(relative7)) return target;
|
|
5667
|
+
return relative7.split(path13__namespace.sep).join("/");
|
|
5510
5668
|
}
|
|
5511
5669
|
function findRuleMatch(rules, relativePath) {
|
|
5512
5670
|
return rules.find(
|
|
@@ -5525,20 +5683,20 @@ function findRecordedAncestor(skipped, relative7, maskedPath2) {
|
|
|
5525
5683
|
return nearest;
|
|
5526
5684
|
}
|
|
5527
5685
|
function readManifest2(config) {
|
|
5528
|
-
const manifestPath =
|
|
5686
|
+
const manifestPath = path13__namespace.resolve(config.cwd, config.outDir, "manifest.json");
|
|
5529
5687
|
try {
|
|
5530
|
-
return JSON.parse(
|
|
5688
|
+
return JSON.parse(fs12__namespace.readFileSync(manifestPath, "utf8"));
|
|
5531
5689
|
} catch {
|
|
5532
5690
|
return null;
|
|
5533
5691
|
}
|
|
5534
5692
|
}
|
|
5535
5693
|
function explainPath(config, target) {
|
|
5536
5694
|
const relative7 = normalizeTarget(config.cwd, target);
|
|
5537
|
-
const absolute =
|
|
5695
|
+
const absolute = path13__namespace.join(config.cwd, relative7);
|
|
5538
5696
|
const maskedPath2 = findSecretInPath(relative7, config.secretRules)?.masked ?? relative7;
|
|
5539
5697
|
const result = {
|
|
5540
5698
|
path: maskedPath2,
|
|
5541
|
-
exists:
|
|
5699
|
+
exists: fs12__namespace.existsSync(absolute),
|
|
5542
5700
|
included: false
|
|
5543
5701
|
};
|
|
5544
5702
|
const collection = collectFiles(config.cwd, {
|
|
@@ -5549,7 +5707,7 @@ function explainPath(config, target) {
|
|
|
5549
5707
|
// Same exclusion `generate` applies, so `explain` never says "not-discovered" about a file
|
|
5550
5708
|
// that is only missing because the walker dropped the tool's own output directory.
|
|
5551
5709
|
toolOwnedPaths: [config.outDir, config.tmpDir].map(
|
|
5552
|
-
(directory) =>
|
|
5710
|
+
(directory) => path13__namespace.relative(config.cwd, path13__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
|
|
5553
5711
|
).filter((relative8) => relative8.length > 0 && !relative8.startsWith(".."))
|
|
5554
5712
|
});
|
|
5555
5713
|
if (!collection.files.includes(relative7)) {
|
|
@@ -5588,8 +5746,8 @@ function explainPath(config, target) {
|
|
|
5588
5746
|
if (layerRule) result.layerMatch = describeMatcher(layerRule.match);
|
|
5589
5747
|
const kindRule = findRuleMatch(config.kinds, relative7);
|
|
5590
5748
|
if (kindRule) result.kindMatch = describeMatcher(kindRule.match);
|
|
5591
|
-
if (
|
|
5592
|
-
const buffer =
|
|
5749
|
+
if (fs12__namespace.existsSync(absolute) && fs12__namespace.statSync(absolute).isFile()) {
|
|
5750
|
+
const buffer = fs12__namespace.readFileSync(absolute);
|
|
5593
5751
|
const decoded = decodeText(buffer);
|
|
5594
5752
|
if (decoded.binary) {
|
|
5595
5753
|
result.included = false;
|
|
@@ -5837,14 +5995,14 @@ function compareManifests(before, after) {
|
|
|
5837
5995
|
function loadManifest(target) {
|
|
5838
5996
|
let isDirectory;
|
|
5839
5997
|
try {
|
|
5840
|
-
isDirectory =
|
|
5998
|
+
isDirectory = fs12__namespace.statSync(target).isDirectory();
|
|
5841
5999
|
} catch {
|
|
5842
6000
|
throw new Error(`No snapshot found at ${target}: the path does not exist.`);
|
|
5843
6001
|
}
|
|
5844
|
-
const manifestPath = isDirectory ?
|
|
6002
|
+
const manifestPath = isDirectory ? path13__namespace.join(target, "manifest.json") : target;
|
|
5845
6003
|
let raw;
|
|
5846
6004
|
try {
|
|
5847
|
-
raw =
|
|
6005
|
+
raw = fs12__namespace.readFileSync(manifestPath, "utf8");
|
|
5848
6006
|
} catch {
|
|
5849
6007
|
throw new Error(`Could not read a manifest at ${manifestPath}.`);
|
|
5850
6008
|
}
|
|
@@ -5901,15 +6059,15 @@ function renderDiffText(diff) {
|
|
|
5901
6059
|
function appendGitignoreEntries(cwd, entries) {
|
|
5902
6060
|
const wanted = [...new Set(entries)].filter((entry) => entry.trim().length > 0);
|
|
5903
6061
|
if (wanted.length === 0) return { added: [], note: null };
|
|
5904
|
-
const ignorePath =
|
|
6062
|
+
const ignorePath = path13__namespace.join(cwd, ".gitignore");
|
|
5905
6063
|
const manual = `Add ${wanted.map((entry) => `"${entry}"`).join(" and ")} to your .gitignore yourself.`;
|
|
5906
6064
|
let existing = "";
|
|
5907
6065
|
try {
|
|
5908
|
-
if (
|
|
5909
|
-
if (
|
|
6066
|
+
if (fs12__namespace.existsSync(ignorePath)) {
|
|
6067
|
+
if (fs12__namespace.statSync(ignorePath).isDirectory()) {
|
|
5910
6068
|
return { added: [], note: `${ignorePath} is a directory, so it was not updated. ${manual}` };
|
|
5911
6069
|
}
|
|
5912
|
-
existing =
|
|
6070
|
+
existing = fs12__namespace.readFileSync(ignorePath, "utf8");
|
|
5913
6071
|
}
|
|
5914
6072
|
} catch (err) {
|
|
5915
6073
|
return {
|
|
@@ -5922,7 +6080,7 @@ function appendGitignoreEntries(cwd, entries) {
|
|
|
5922
6080
|
if (added.length === 0) return { added: [], note: null };
|
|
5923
6081
|
const prefix = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
|
|
5924
6082
|
try {
|
|
5925
|
-
|
|
6083
|
+
fs12__namespace.writeFileSync(ignorePath, `${existing}${prefix}${added.join("\n")}
|
|
5926
6084
|
`, "utf8");
|
|
5927
6085
|
} catch (err) {
|
|
5928
6086
|
return { added: [], note: `${err.message}. ${manual}` };
|
|
@@ -6083,6 +6241,57 @@ function toggleIndex(selected, index) {
|
|
|
6083
6241
|
else next.add(index);
|
|
6084
6242
|
return next;
|
|
6085
6243
|
}
|
|
6244
|
+
function isWideCodePoint(code) {
|
|
6245
|
+
return code >= 4352 && code <= 4447 || // Hangul Jamo
|
|
6246
|
+
code >= 11904 && code <= 12350 || // CJK radicals, Kangxi, CJK symbols
|
|
6247
|
+
code >= 12353 && code <= 13311 || // kana through CJK compatibility
|
|
6248
|
+
code >= 13312 && code <= 19903 || // CJK extension A
|
|
6249
|
+
code >= 19968 && code <= 40959 || // CJK unified ideographs
|
|
6250
|
+
code >= 40960 && code <= 42191 || // Yi
|
|
6251
|
+
code >= 44032 && code <= 55203 || // Hangul syllables
|
|
6252
|
+
code >= 63744 && code <= 64255 || // CJK compatibility ideographs
|
|
6253
|
+
code >= 65072 && code <= 65135 || // CJK compatibility forms
|
|
6254
|
+
code >= 65280 && code <= 65376 || // fullwidth forms
|
|
6255
|
+
code >= 65504 && code <= 65510 || code >= 127744 && code <= 129535 || // emoji and pictographs
|
|
6256
|
+
code >= 131072 && code <= 262141;
|
|
6257
|
+
}
|
|
6258
|
+
var ANSI_PATTERN = /\u001b\[[0-9;?]*[A-Za-z]/g;
|
|
6259
|
+
function displayWidth(line) {
|
|
6260
|
+
let width = 0;
|
|
6261
|
+
for (const character of line.replace(ANSI_PATTERN, "")) {
|
|
6262
|
+
width += isWideCodePoint(character.codePointAt(0) ?? 0) ? 2 : 1;
|
|
6263
|
+
}
|
|
6264
|
+
return width;
|
|
6265
|
+
}
|
|
6266
|
+
function wrapOneLine(line, limit) {
|
|
6267
|
+
if (displayWidth(line) <= limit) return [line];
|
|
6268
|
+
const indent = /^[ \t]*/.exec(line)?.[0] ?? "";
|
|
6269
|
+
const continuation = `${indent} `;
|
|
6270
|
+
const rows = [];
|
|
6271
|
+
let prefix = indent;
|
|
6272
|
+
let rest = line.slice(indent.length).trimEnd();
|
|
6273
|
+
while (rest.length > 0) {
|
|
6274
|
+
const room = limit - displayWidth(prefix);
|
|
6275
|
+
if (room <= 0 || displayWidth(rest) <= room) {
|
|
6276
|
+
rows.push(prefix + rest);
|
|
6277
|
+
break;
|
|
6278
|
+
}
|
|
6279
|
+
let cut = room;
|
|
6280
|
+
const space = rest.slice(0, room).lastIndexOf(" ");
|
|
6281
|
+
if (space > 0) cut = space;
|
|
6282
|
+
const taken = rest.slice(0, cut).trimEnd();
|
|
6283
|
+
rows.push(`${prefix}${taken.length > 0 ? taken : rest.slice(0, cut)}`);
|
|
6284
|
+
rest = rest.slice(cut).trimStart();
|
|
6285
|
+
prefix = continuation;
|
|
6286
|
+
}
|
|
6287
|
+
return rows;
|
|
6288
|
+
}
|
|
6289
|
+
function wrapLines(text2, limit) {
|
|
6290
|
+
const width = Math.max(8, Math.floor(limit));
|
|
6291
|
+
const rows = [];
|
|
6292
|
+
for (const line of text2.split("\n")) rows.push(...wrapOneLine(line, width));
|
|
6293
|
+
return rows;
|
|
6294
|
+
}
|
|
6086
6295
|
function marker(active) {
|
|
6087
6296
|
return active ? "\u276F" : " ";
|
|
6088
6297
|
}
|
|
@@ -6160,14 +6369,27 @@ var Frame = class {
|
|
|
6160
6369
|
drawn = 0;
|
|
6161
6370
|
draw(text2) {
|
|
6162
6371
|
this.erase();
|
|
6163
|
-
this.
|
|
6372
|
+
const rows = wrapLines(text2, this.width());
|
|
6373
|
+
this.output.write(`${rows.join("\n")}
|
|
6164
6374
|
`);
|
|
6165
|
-
this.drawn =
|
|
6375
|
+
this.drawn = rows.length;
|
|
6166
6376
|
}
|
|
6167
6377
|
erase() {
|
|
6168
6378
|
if (this.drawn > 0) this.output.write(`\x1B[${this.drawn}A\x1B[0J`);
|
|
6169
6379
|
this.drawn = 0;
|
|
6170
6380
|
}
|
|
6381
|
+
/**
|
|
6382
|
+
* The usable width, in cells.
|
|
6383
|
+
*
|
|
6384
|
+
* Two cells of slack: an ambiguous-width glyph (`◆`, `❯`, `←`) renders two cells in some fonts
|
|
6385
|
+
* and one in others, and a row that lands exactly on the last column is the one case a terminal
|
|
6386
|
+
* may or may not wrap. Below that, a line cannot reach the edge to begin with.
|
|
6387
|
+
*/
|
|
6388
|
+
width() {
|
|
6389
|
+
const columns = this.output.columns;
|
|
6390
|
+
if (typeof columns !== "number" || !Number.isFinite(columns) || columns <= 0) return 80;
|
|
6391
|
+
return Math.max(8, Math.floor(columns) - 2);
|
|
6392
|
+
}
|
|
6171
6393
|
};
|
|
6172
6394
|
function isCancel(key) {
|
|
6173
6395
|
return key.ctrl === true && key.name === "c" || key.ctrl === true && key.name === "d";
|
|
@@ -6349,10 +6571,10 @@ var CONFIG_CANDIDATES = [
|
|
|
6349
6571
|
];
|
|
6350
6572
|
function chooseConfigFileName(cwd) {
|
|
6351
6573
|
if (!supportsTypeScriptImports()) return "snapshot.config.mjs";
|
|
6352
|
-
const pkgPath =
|
|
6353
|
-
if (!
|
|
6574
|
+
const pkgPath = path13__namespace.join(cwd, "package.json");
|
|
6575
|
+
if (!fs12__namespace.existsSync(pkgPath)) return "snapshot.config.mjs";
|
|
6354
6576
|
try {
|
|
6355
|
-
const parsed = JSON.parse(
|
|
6577
|
+
const parsed = JSON.parse(fs12__namespace.readFileSync(pkgPath, "utf8"));
|
|
6356
6578
|
return parsed.type === "module" ? "snapshot.config.ts" : "snapshot.config.mjs";
|
|
6357
6579
|
} catch {
|
|
6358
6580
|
return "snapshot.config.mjs";
|
|
@@ -6366,7 +6588,7 @@ var SIZE_CHOICES = [
|
|
|
6366
6588
|
];
|
|
6367
6589
|
function packageJsonHasConfig(cwd) {
|
|
6368
6590
|
try {
|
|
6369
|
-
const parsed = JSON.parse(
|
|
6591
|
+
const parsed = JSON.parse(fs12__namespace.readFileSync(path13__namespace.join(cwd, "package.json"), "utf8"));
|
|
6370
6592
|
return typeof parsed.snapshot === "object" && parsed.snapshot !== null && !Array.isArray(parsed.snapshot);
|
|
6371
6593
|
} catch {
|
|
6372
6594
|
return false;
|
|
@@ -6387,7 +6609,7 @@ function artifactAnswers(options) {
|
|
|
6387
6609
|
}
|
|
6388
6610
|
function topLevelDirs(cwd) {
|
|
6389
6611
|
try {
|
|
6390
|
-
return
|
|
6612
|
+
return fs12__namespace.readdirSync(cwd, { withFileTypes: true }).filter((entry) => entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules").map((entry) => entry.name).sort();
|
|
6391
6613
|
} catch {
|
|
6392
6614
|
return [];
|
|
6393
6615
|
}
|
|
@@ -6400,7 +6622,7 @@ function describeJsonValue(value) {
|
|
|
6400
6622
|
}
|
|
6401
6623
|
function writeFileOrExplain(target, content) {
|
|
6402
6624
|
try {
|
|
6403
|
-
|
|
6625
|
+
fs12__namespace.writeFileSync(target, content, "utf8");
|
|
6404
6626
|
} catch (err) {
|
|
6405
6627
|
const code = err.code;
|
|
6406
6628
|
const reason = code === "EACCES" || code === "EPERM" || code === "EROFS" ? `permission denied (${code})` : code === "EISDIR" ? "it is a directory" : `${err.message}`;
|
|
@@ -6411,7 +6633,7 @@ function canWriteModuleConfig(name, cwd) {
|
|
|
6411
6633
|
if (name.endsWith(".mjs") || name.endsWith(".ts")) return true;
|
|
6412
6634
|
if (!name.endsWith(".js")) return false;
|
|
6413
6635
|
try {
|
|
6414
|
-
const parsed = JSON.parse(
|
|
6636
|
+
const parsed = JSON.parse(fs12__namespace.readFileSync(path13__namespace.join(cwd, "package.json"), "utf8"));
|
|
6415
6637
|
return parsed.type === "module";
|
|
6416
6638
|
} catch {
|
|
6417
6639
|
return false;
|
|
@@ -6446,19 +6668,19 @@ function serializePackageJson(raw, value) {
|
|
|
6446
6668
|
return `${text2}${raw.endsWith("\n") ? crlf ? "\r\n" : "\n" : ""}`;
|
|
6447
6669
|
}
|
|
6448
6670
|
function updatePackageJson(cwd, notes) {
|
|
6449
|
-
const packagePath =
|
|
6671
|
+
const packagePath = path13__namespace.join(cwd, "package.json");
|
|
6450
6672
|
const unchanged = {
|
|
6451
6673
|
scripts: [],
|
|
6452
6674
|
dependency: { name: GENERATOR_NAME, range: null, added: false }
|
|
6453
6675
|
};
|
|
6454
|
-
if (!
|
|
6676
|
+
if (!fs12__namespace.existsSync(packagePath)) {
|
|
6455
6677
|
notes.push("No package.json found, so npm scripts and the devDependency were not added.");
|
|
6456
6678
|
return unchanged;
|
|
6457
6679
|
}
|
|
6458
6680
|
let raw;
|
|
6459
6681
|
let parsed;
|
|
6460
6682
|
try {
|
|
6461
|
-
raw =
|
|
6683
|
+
raw = fs12__namespace.readFileSync(packagePath, "utf8");
|
|
6462
6684
|
parsed = JSON.parse(raw);
|
|
6463
6685
|
} catch {
|
|
6464
6686
|
notes.push("Could not parse package.json; npm scripts and the devDependency were not added.");
|
|
@@ -6750,7 +6972,7 @@ async function runInit(options) {
|
|
|
6750
6972
|
const configText = renderConfig(answers);
|
|
6751
6973
|
const preferredName = chooseConfigFileName(options.cwd);
|
|
6752
6974
|
const presentConfigs = CONFIG_CANDIDATES.filter(
|
|
6753
|
-
(name) =>
|
|
6975
|
+
(name) => fs12__namespace.existsSync(path13__namespace.join(options.cwd, name))
|
|
6754
6976
|
);
|
|
6755
6977
|
const present = presentConfigs[0] ?? null;
|
|
6756
6978
|
if (presentConfigs.length > 1) {
|
|
@@ -6759,7 +6981,7 @@ async function runInit(options) {
|
|
|
6759
6981
|
);
|
|
6760
6982
|
}
|
|
6761
6983
|
const configName = present !== null && options.force ? present : preferredName;
|
|
6762
|
-
const configPath =
|
|
6984
|
+
const configPath = path13__namespace.join(options.cwd, configName);
|
|
6763
6985
|
const reused = present !== null && options.force !== true && options.reuseConfig === true;
|
|
6764
6986
|
if (reused) notes.push(`Kept the existing ${present} instead of writing a new one.`);
|
|
6765
6987
|
if (options.dryRun) {
|
|
@@ -6792,7 +7014,7 @@ async function runInit(options) {
|
|
|
6792
7014
|
'package.json already defines a "snapshot" config. Remove that key, or re-run with --force to write a config file that takes precedence over it.'
|
|
6793
7015
|
);
|
|
6794
7016
|
}
|
|
6795
|
-
if (
|
|
7017
|
+
if (fs12__namespace.existsSync(configPath) && !options.force && !reused) {
|
|
6796
7018
|
throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
|
|
6797
7019
|
}
|
|
6798
7020
|
if (!reused) writeFileOrExplain(configPath, configText);
|
|
@@ -6814,9 +7036,9 @@ async function runInit(options) {
|
|
|
6814
7036
|
};
|
|
6815
7037
|
}
|
|
6816
7038
|
function describeTarget(cwd) {
|
|
6817
|
-
const relative7 =
|
|
7039
|
+
const relative7 = path13__namespace.relative(process.cwd(), cwd);
|
|
6818
7040
|
if (relative7 === "") return "this directory";
|
|
6819
|
-
if (relative7.startsWith("..") ||
|
|
7041
|
+
if (relative7.startsWith("..") || path13__namespace.isAbsolute(relative7)) return cwd;
|
|
6820
7042
|
return relative7;
|
|
6821
7043
|
}
|
|
6822
7044
|
function firstRunMessage(reason, cwd) {
|
|
@@ -6840,7 +7062,7 @@ function planFirstRun(facts) {
|
|
|
6840
7062
|
var NOT_CONTENT = /* @__PURE__ */ new Set([".git", ".hg", ".svn", ".bzr", ".DS_Store", "Thumbs.db"]);
|
|
6841
7063
|
function isEffectivelyEmpty(cwd) {
|
|
6842
7064
|
try {
|
|
6843
|
-
return
|
|
7065
|
+
return fs12__namespace.readdirSync(cwd).every((entry) => NOT_CONTENT.has(entry));
|
|
6844
7066
|
} catch {
|
|
6845
7067
|
return false;
|
|
6846
7068
|
}
|
|
@@ -6848,7 +7070,7 @@ function isEffectivelyEmpty(cwd) {
|
|
|
6848
7070
|
function hasPriorSnapshot(cwd, outDir) {
|
|
6849
7071
|
let parsed;
|
|
6850
7072
|
try {
|
|
6851
|
-
parsed = JSON.parse(
|
|
7073
|
+
parsed = JSON.parse(fs12__namespace.readFileSync(path13__namespace.join(cwd, outDir, ".codebase-snapshot"), "utf8"));
|
|
6852
7074
|
} catch {
|
|
6853
7075
|
return false;
|
|
6854
7076
|
}
|
|
@@ -6936,13 +7158,13 @@ function buildImportResolver(files) {
|
|
|
6936
7158
|
const relativePath = file.relativePath;
|
|
6937
7159
|
remember(byPath, relativePath, relativePath);
|
|
6938
7160
|
remember(byPathFolded, relativePath.toLowerCase(), relativePath);
|
|
6939
|
-
const extension =
|
|
7161
|
+
const extension = path13__namespace.posix.extname(relativePath);
|
|
6940
7162
|
if (!SOURCE_EXTENSIONS.has(extension)) continue;
|
|
6941
7163
|
const stem = relativePath.slice(0, -extension.length);
|
|
6942
7164
|
remember(byStem, stem, relativePath);
|
|
6943
7165
|
remember(byStemFolded, stem.toLowerCase(), relativePath);
|
|
6944
|
-
if (
|
|
6945
|
-
const directory =
|
|
7166
|
+
if (path13__namespace.posix.basename(stem) === "index") {
|
|
7167
|
+
const directory = path13__namespace.posix.dirname(stem);
|
|
6946
7168
|
remember(byStem, directory, relativePath);
|
|
6947
7169
|
remember(byStemFolded, directory.toLowerCase(), relativePath);
|
|
6948
7170
|
}
|
|
@@ -6951,8 +7173,8 @@ function buildImportResolver(files) {
|
|
|
6951
7173
|
}
|
|
6952
7174
|
function resolveSpecifier(fromFile, specifier, resolver) {
|
|
6953
7175
|
if (!RELATIVE_SPECIFIER.test(specifier)) return null;
|
|
6954
|
-
const joined =
|
|
6955
|
-
|
|
7176
|
+
const joined = path13__namespace.posix.normalize(
|
|
7177
|
+
path13__namespace.posix.join(path13__namespace.posix.dirname(fromFile), specifier)
|
|
6956
7178
|
);
|
|
6957
7179
|
const exact = (key) => resolver.byPath.get(key) ?? resolver.byPathFolded.get(key.toLowerCase()) ?? null;
|
|
6958
7180
|
const direct = exact(joined);
|
|
@@ -7045,11 +7267,11 @@ function verifyInMemory(files, parts, maxPartBytes) {
|
|
|
7045
7267
|
return errors;
|
|
7046
7268
|
}
|
|
7047
7269
|
function resolveSafeOutputDirs(config) {
|
|
7048
|
-
const cwd =
|
|
7049
|
-
const outDir =
|
|
7050
|
-
const tmpDir =
|
|
7051
|
-
const root =
|
|
7052
|
-
const contains = (parent, child) => child === parent || child.startsWith(`${parent}${
|
|
7270
|
+
const cwd = path13__namespace.resolve(config.cwd);
|
|
7271
|
+
const outDir = path13__namespace.resolve(cwd, config.outDir);
|
|
7272
|
+
const tmpDir = path13__namespace.resolve(cwd, config.tmpDir);
|
|
7273
|
+
const root = path13__namespace.parse(cwd).root;
|
|
7274
|
+
const contains = (parent, child) => child === parent || child.startsWith(`${parent}${path13__namespace.sep}`);
|
|
7053
7275
|
const reject = (reason) => {
|
|
7054
7276
|
throw new Error(
|
|
7055
7277
|
`Refusing to generate: ${reason}. outDir=${outDir} tmpDir=${tmpDir} cwd=${cwd}`
|
|
@@ -7105,14 +7327,14 @@ function listEntries(dir) {
|
|
|
7105
7327
|
const walk = (absolute, prefix) => {
|
|
7106
7328
|
let children;
|
|
7107
7329
|
try {
|
|
7108
|
-
children =
|
|
7330
|
+
children = fs12__namespace.readdirSync(absolute, { withFileTypes: true });
|
|
7109
7331
|
} catch {
|
|
7110
7332
|
return;
|
|
7111
7333
|
}
|
|
7112
7334
|
for (const child of children) {
|
|
7113
7335
|
const relative7 = prefix === "" ? child.name : `${prefix}/${child.name}`;
|
|
7114
7336
|
entries.push(relative7);
|
|
7115
|
-
if (child.isDirectory()) walk(
|
|
7337
|
+
if (child.isDirectory()) walk(path13__namespace.join(absolute, child.name), relative7);
|
|
7116
7338
|
}
|
|
7117
7339
|
};
|
|
7118
7340
|
walk(dir, "");
|
|
@@ -7129,28 +7351,28 @@ function markerPayload(dir, state, id, createdAt) {
|
|
|
7129
7351
|
pid: process.pid,
|
|
7130
7352
|
entries: listEntries(dir)
|
|
7131
7353
|
};
|
|
7132
|
-
const manifestPath =
|
|
7133
|
-
if (
|
|
7134
|
-
marker2.manifestSha256 = sha256Hex2(
|
|
7354
|
+
const manifestPath = path13__namespace.join(dir, "manifest.json");
|
|
7355
|
+
if (fs12__namespace.existsSync(manifestPath)) {
|
|
7356
|
+
marker2.manifestSha256 = sha256Hex2(fs12__namespace.readFileSync(manifestPath));
|
|
7135
7357
|
}
|
|
7136
7358
|
return marker2;
|
|
7137
7359
|
}
|
|
7138
7360
|
function writeOwnershipMarker(dir, marker2) {
|
|
7139
|
-
|
|
7140
|
-
|
|
7361
|
+
fs12__namespace.writeFileSync(
|
|
7362
|
+
path13__namespace.join(dir, OWNERSHIP_MARKER),
|
|
7141
7363
|
`${JSON.stringify(marker2, null, 2)}
|
|
7142
7364
|
`,
|
|
7143
7365
|
"utf8"
|
|
7144
7366
|
);
|
|
7145
7367
|
}
|
|
7146
7368
|
function readOwnershipMarker(dir) {
|
|
7147
|
-
const markerPath =
|
|
7148
|
-
if (!
|
|
7369
|
+
const markerPath = path13__namespace.join(dir, OWNERSHIP_MARKER);
|
|
7370
|
+
if (!fs12__namespace.existsSync(markerPath)) {
|
|
7149
7371
|
return { marker: null, problem: "it holds no .codebase-snapshot marker" };
|
|
7150
7372
|
}
|
|
7151
7373
|
let raw;
|
|
7152
7374
|
try {
|
|
7153
|
-
raw =
|
|
7375
|
+
raw = fs12__namespace.readFileSync(markerPath, "utf8");
|
|
7154
7376
|
} catch {
|
|
7155
7377
|
return { marker: null, problem: "its .codebase-snapshot marker could not be read" };
|
|
7156
7378
|
}
|
|
@@ -7218,11 +7440,11 @@ function assessSnapshotDirectory(dir) {
|
|
|
7218
7440
|
marker: marker2
|
|
7219
7441
|
};
|
|
7220
7442
|
}
|
|
7221
|
-
const manifestPath =
|
|
7222
|
-
if (
|
|
7443
|
+
const manifestPath = path13__namespace.join(dir, "manifest.json");
|
|
7444
|
+
if (fs12__namespace.existsSync(manifestPath)) {
|
|
7223
7445
|
let raw;
|
|
7224
7446
|
try {
|
|
7225
|
-
raw =
|
|
7447
|
+
raw = fs12__namespace.readFileSync(manifestPath, "utf8");
|
|
7226
7448
|
} catch {
|
|
7227
7449
|
return {
|
|
7228
7450
|
owned: false,
|
|
@@ -7304,13 +7526,13 @@ function containsNoFiles(dir) {
|
|
|
7304
7526
|
const current = pending.pop();
|
|
7305
7527
|
let entries;
|
|
7306
7528
|
try {
|
|
7307
|
-
entries =
|
|
7529
|
+
entries = fs12__namespace.readdirSync(current, { withFileTypes: true });
|
|
7308
7530
|
} catch {
|
|
7309
7531
|
return false;
|
|
7310
7532
|
}
|
|
7311
7533
|
for (const entry of entries) {
|
|
7312
7534
|
if (entry.isDirectory()) {
|
|
7313
|
-
pending.push(
|
|
7535
|
+
pending.push(path13__namespace.join(current, entry.name));
|
|
7314
7536
|
} else if (!IGNORABLE_ENTRIES.has(entry.name)) {
|
|
7315
7537
|
return false;
|
|
7316
7538
|
}
|
|
@@ -7319,13 +7541,13 @@ function containsNoFiles(dir) {
|
|
|
7319
7541
|
return true;
|
|
7320
7542
|
}
|
|
7321
7543
|
function assertReplaceable(target, label, secretRules) {
|
|
7322
|
-
if (!
|
|
7323
|
-
if (!
|
|
7544
|
+
if (!fs12__namespace.existsSync(target)) return;
|
|
7545
|
+
if (!fs12__namespace.statSync(target).isDirectory()) {
|
|
7324
7546
|
throw new Error(
|
|
7325
7547
|
`Refusing to write into ${label} ${target}: it exists but is not a directory.`
|
|
7326
7548
|
);
|
|
7327
7549
|
}
|
|
7328
|
-
const entries =
|
|
7550
|
+
const entries = fs12__namespace.readdirSync(target);
|
|
7329
7551
|
if (entries.length === 0) return;
|
|
7330
7552
|
if (entries.every((name) => IGNORABLE_ENTRIES.has(name))) return;
|
|
7331
7553
|
if (containsNoFiles(target)) return;
|
|
@@ -7345,18 +7567,18 @@ function assertReplaceable(target, label, secretRules) {
|
|
|
7345
7567
|
);
|
|
7346
7568
|
}
|
|
7347
7569
|
function assertStagingRootUsable(tmpDir, secretRules) {
|
|
7348
|
-
if (!
|
|
7349
|
-
if (!
|
|
7570
|
+
if (!fs12__namespace.existsSync(tmpDir)) return;
|
|
7571
|
+
if (!fs12__namespace.statSync(tmpDir).isDirectory()) {
|
|
7350
7572
|
throw new Error(`Refusing to write into tmpDir ${tmpDir}: it exists but is not a directory.`);
|
|
7351
7573
|
}
|
|
7352
|
-
const entries =
|
|
7574
|
+
const entries = fs12__namespace.readdirSync(tmpDir);
|
|
7353
7575
|
if (entries.length === 0) return;
|
|
7354
7576
|
const foreign = entries.filter((name) => {
|
|
7355
|
-
const full =
|
|
7577
|
+
const full = path13__namespace.join(tmpDir, name);
|
|
7356
7578
|
if (!name.startsWith(RUN_DIR_PREFIX)) return true;
|
|
7357
7579
|
let stats;
|
|
7358
7580
|
try {
|
|
7359
|
-
stats =
|
|
7581
|
+
stats = fs12__namespace.statSync(full);
|
|
7360
7582
|
} catch {
|
|
7361
7583
|
return true;
|
|
7362
7584
|
}
|
|
@@ -7364,7 +7586,7 @@ function assertStagingRootUsable(tmpDir, secretRules) {
|
|
|
7364
7586
|
const { marker: marker2 } = readOwnershipMarker(full);
|
|
7365
7587
|
if (marker2) return false;
|
|
7366
7588
|
try {
|
|
7367
|
-
return
|
|
7589
|
+
return fs12__namespace.readdirSync(full).length > 0;
|
|
7368
7590
|
} catch {
|
|
7369
7591
|
return true;
|
|
7370
7592
|
}
|
|
@@ -7379,13 +7601,13 @@ function assertStagingRootUsable(tmpDir, secretRules) {
|
|
|
7379
7601
|
function cleanStaleRunDirs(tmpDir) {
|
|
7380
7602
|
let entries;
|
|
7381
7603
|
try {
|
|
7382
|
-
entries =
|
|
7604
|
+
entries = fs12__namespace.readdirSync(tmpDir);
|
|
7383
7605
|
} catch {
|
|
7384
7606
|
return;
|
|
7385
7607
|
}
|
|
7386
7608
|
for (const name of entries) {
|
|
7387
7609
|
if (!name.startsWith(RUN_DIR_PREFIX)) continue;
|
|
7388
|
-
const full =
|
|
7610
|
+
const full = path13__namespace.join(tmpDir, name);
|
|
7389
7611
|
const { marker: marker2 } = readOwnershipMarker(full);
|
|
7390
7612
|
if (marker2) {
|
|
7391
7613
|
const created = Date.parse(marker2.createdAt);
|
|
@@ -7393,33 +7615,33 @@ function cleanStaleRunDirs(tmpDir) {
|
|
|
7393
7615
|
const abandoned = typeof marker2.pid === "number" && !isProcessAlive(marker2.pid);
|
|
7394
7616
|
if (aged || abandoned) {
|
|
7395
7617
|
try {
|
|
7396
|
-
|
|
7618
|
+
fs12__namespace.rmSync(full, { recursive: true, force: true });
|
|
7397
7619
|
} catch {
|
|
7398
7620
|
}
|
|
7399
7621
|
}
|
|
7400
7622
|
continue;
|
|
7401
7623
|
}
|
|
7402
7624
|
try {
|
|
7403
|
-
if (
|
|
7625
|
+
if (fs12__namespace.readdirSync(full).length === 0) fs12__namespace.rmSync(full, { recursive: true, force: true });
|
|
7404
7626
|
} catch {
|
|
7405
7627
|
}
|
|
7406
7628
|
}
|
|
7407
7629
|
}
|
|
7408
7630
|
function removeIfEmpty(dir) {
|
|
7409
7631
|
try {
|
|
7410
|
-
if (
|
|
7632
|
+
if (fs12__namespace.readdirSync(dir).length === 0) fs12__namespace.rmSync(dir, { recursive: true, force: true });
|
|
7411
7633
|
} catch {
|
|
7412
7634
|
}
|
|
7413
7635
|
}
|
|
7414
7636
|
function ensureParentDirectory(target, label) {
|
|
7415
|
-
const parent =
|
|
7416
|
-
if (
|
|
7637
|
+
const parent = path13__namespace.dirname(target);
|
|
7638
|
+
if (fs12__namespace.existsSync(parent) && !fs12__namespace.statSync(parent).isDirectory()) {
|
|
7417
7639
|
throw new Error(
|
|
7418
7640
|
`Refusing to create ${label} ${target}: ${parent} exists but is not a directory.`
|
|
7419
7641
|
);
|
|
7420
7642
|
}
|
|
7421
7643
|
try {
|
|
7422
|
-
|
|
7644
|
+
fs12__namespace.mkdirSync(parent, { recursive: true });
|
|
7423
7645
|
} catch (err) {
|
|
7424
7646
|
throw new Error(
|
|
7425
7647
|
`Refusing to create ${label} ${target}: its parent ${parent} could not be created (${err.message}).`
|
|
@@ -7428,7 +7650,7 @@ function ensureParentDirectory(target, label) {
|
|
|
7428
7650
|
}
|
|
7429
7651
|
function acquireRunLock(stagingRoot) {
|
|
7430
7652
|
const key = lockKeyFor(stagingRoot);
|
|
7431
|
-
const lockPath =
|
|
7653
|
+
const lockPath = path13__namespace.join(os__namespace.tmpdir(), `codebase-snapshot-${key}.lock`);
|
|
7432
7654
|
const payload = `${JSON.stringify({
|
|
7433
7655
|
pid: process.pid,
|
|
7434
7656
|
stagingRoot,
|
|
@@ -7437,22 +7659,22 @@ function acquireRunLock(stagingRoot) {
|
|
|
7437
7659
|
`;
|
|
7438
7660
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
7439
7661
|
try {
|
|
7440
|
-
const handle =
|
|
7662
|
+
const handle = fs12__namespace.openSync(lockPath, "wx");
|
|
7441
7663
|
try {
|
|
7442
|
-
|
|
7664
|
+
fs12__namespace.writeSync(handle, payload);
|
|
7443
7665
|
} finally {
|
|
7444
|
-
|
|
7666
|
+
fs12__namespace.closeSync(handle);
|
|
7445
7667
|
}
|
|
7446
7668
|
return () => {
|
|
7447
7669
|
try {
|
|
7448
|
-
|
|
7670
|
+
fs12__namespace.rmSync(lockPath, { force: true });
|
|
7449
7671
|
} catch {
|
|
7450
7672
|
}
|
|
7451
7673
|
};
|
|
7452
7674
|
} catch (err) {
|
|
7453
7675
|
if (err.code !== "EEXIST") throw err;
|
|
7454
7676
|
if (attempt === 0 && lockOwnerIsGone(lockPath)) {
|
|
7455
|
-
|
|
7677
|
+
fs12__namespace.rmSync(lockPath, { force: true });
|
|
7456
7678
|
continue;
|
|
7457
7679
|
}
|
|
7458
7680
|
throw new Error(
|
|
@@ -7465,7 +7687,7 @@ function acquireRunLock(stagingRoot) {
|
|
|
7465
7687
|
function lockKeyFor(stagingRoot) {
|
|
7466
7688
|
let key = stagingRoot;
|
|
7467
7689
|
try {
|
|
7468
|
-
key =
|
|
7690
|
+
key = fs12__namespace.realpathSync(stagingRoot);
|
|
7469
7691
|
} catch {
|
|
7470
7692
|
}
|
|
7471
7693
|
if (process.platform === "win32" || process.platform === "darwin") key = key.toLowerCase();
|
|
@@ -7474,7 +7696,7 @@ function lockKeyFor(stagingRoot) {
|
|
|
7474
7696
|
function lockOwnerIsGone(lockPath) {
|
|
7475
7697
|
let raw;
|
|
7476
7698
|
try {
|
|
7477
|
-
raw =
|
|
7699
|
+
raw = fs12__namespace.readFileSync(lockPath, "utf8");
|
|
7478
7700
|
} catch {
|
|
7479
7701
|
return false;
|
|
7480
7702
|
}
|
|
@@ -7494,12 +7716,12 @@ function lockOwnerIsGone(lockPath) {
|
|
|
7494
7716
|
}
|
|
7495
7717
|
function writeManifestAtomically(manifestPath, manifest) {
|
|
7496
7718
|
const tempPath = `${manifestPath}.${process.pid}.tmp`;
|
|
7497
|
-
|
|
7719
|
+
fs12__namespace.writeFileSync(tempPath, JSON.stringify(manifest, null, 2), "utf8");
|
|
7498
7720
|
try {
|
|
7499
|
-
|
|
7721
|
+
fs12__namespace.renameSync(tempPath, manifestPath);
|
|
7500
7722
|
} catch (err) {
|
|
7501
7723
|
try {
|
|
7502
|
-
|
|
7724
|
+
fs12__namespace.rmSync(tempPath, { force: true });
|
|
7503
7725
|
} catch {
|
|
7504
7726
|
}
|
|
7505
7727
|
throw err;
|
|
@@ -7522,31 +7744,31 @@ function swapIntoPlace(stagingDir, outDir) {
|
|
|
7522
7744
|
}
|
|
7523
7745
|
function swapOnce(stagingDir, outDir) {
|
|
7524
7746
|
const backupDir = `${outDir}.backup-${process.pid}-${Date.now()}`;
|
|
7525
|
-
const hadPrevious =
|
|
7526
|
-
if (hadPrevious)
|
|
7747
|
+
const hadPrevious = fs12__namespace.existsSync(outDir);
|
|
7748
|
+
if (hadPrevious) fs12__namespace.renameSync(outDir, backupDir);
|
|
7527
7749
|
try {
|
|
7528
7750
|
try {
|
|
7529
|
-
|
|
7751
|
+
fs12__namespace.renameSync(stagingDir, outDir);
|
|
7530
7752
|
} catch (err) {
|
|
7531
7753
|
if (err.code !== "EXDEV") throw err;
|
|
7532
7754
|
const partialDir = `${outDir}.partial-${process.pid}-${Date.now()}`;
|
|
7533
7755
|
try {
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7756
|
+
fs12__namespace.cpSync(stagingDir, partialDir, { recursive: true });
|
|
7757
|
+
fs12__namespace.renameSync(partialDir, outDir);
|
|
7758
|
+
fs12__namespace.rmSync(stagingDir, { recursive: true, force: true });
|
|
7537
7759
|
} catch (copyErr) {
|
|
7538
7760
|
try {
|
|
7539
|
-
|
|
7761
|
+
fs12__namespace.rmSync(partialDir, { recursive: true, force: true });
|
|
7540
7762
|
} catch {
|
|
7541
7763
|
}
|
|
7542
7764
|
throw copyErr;
|
|
7543
7765
|
}
|
|
7544
7766
|
}
|
|
7545
|
-
if (hadPrevious)
|
|
7767
|
+
if (hadPrevious) fs12__namespace.rmSync(backupDir, { recursive: true, force: true });
|
|
7546
7768
|
} catch (err) {
|
|
7547
|
-
if (hadPrevious &&
|
|
7548
|
-
if (
|
|
7549
|
-
|
|
7769
|
+
if (hadPrevious && fs12__namespace.existsSync(backupDir)) {
|
|
7770
|
+
if (fs12__namespace.existsSync(outDir)) fs12__namespace.rmSync(outDir, { recursive: true, force: true });
|
|
7771
|
+
fs12__namespace.renameSync(backupDir, outDir);
|
|
7550
7772
|
}
|
|
7551
7773
|
throw err;
|
|
7552
7774
|
}
|
|
@@ -7641,7 +7863,7 @@ function generateSnapshot(configInput, options) {
|
|
|
7641
7863
|
// first run cannot have marked them yet, so the name alone keeps a run from recording its own
|
|
7642
7864
|
// output — but only at these exact paths, not at every directory that shares the name.
|
|
7643
7865
|
toolOwnedPaths: [config.outDir, config.tmpDir].map(
|
|
7644
|
-
(directory) =>
|
|
7866
|
+
(directory) => path13__namespace.relative(config.cwd, path13__namespace.resolve(config.cwd, directory)).replace(/\\/g, "/")
|
|
7645
7867
|
).filter((relative7) => relative7.length > 0 && !relative7.startsWith(".."))
|
|
7646
7868
|
});
|
|
7647
7869
|
const files = [];
|
|
@@ -7662,12 +7884,12 @@ function generateSnapshot(configInput, options) {
|
|
|
7662
7884
|
let totalSizeBytes = 0;
|
|
7663
7885
|
let largeFileCount = 0;
|
|
7664
7886
|
for (const relativePath of collection.files) {
|
|
7665
|
-
const absolutePath =
|
|
7887
|
+
const absolutePath = path13__namespace.join(config.cwd, relativePath);
|
|
7666
7888
|
let stats;
|
|
7667
7889
|
try {
|
|
7668
|
-
stats =
|
|
7890
|
+
stats = fs12__namespace.statSync(absolutePath);
|
|
7669
7891
|
if (!stats.isFile()) {
|
|
7670
|
-
const nestedRepository = stats.isDirectory() &&
|
|
7892
|
+
const nestedRepository = stats.isDirectory() && fs12__namespace.existsSync(path13__namespace.join(absolutePath, ".git"));
|
|
7671
7893
|
skipped.push(
|
|
7672
7894
|
nestedRepository ? {
|
|
7673
7895
|
path: relativePath,
|
|
@@ -7687,7 +7909,7 @@ function generateSnapshot(configInput, options) {
|
|
|
7687
7909
|
}
|
|
7688
7910
|
let buffer;
|
|
7689
7911
|
try {
|
|
7690
|
-
buffer =
|
|
7912
|
+
buffer = fs12__namespace.readFileSync(absolutePath);
|
|
7691
7913
|
} catch {
|
|
7692
7914
|
skipped.push({ path: relativePath, reason: "read-error" });
|
|
7693
7915
|
continue;
|
|
@@ -8017,12 +8239,12 @@ function generateSnapshot(configInput, options) {
|
|
|
8017
8239
|
let stagingDir = null;
|
|
8018
8240
|
try {
|
|
8019
8241
|
ensureParentDirectory(outDir, "outDir");
|
|
8020
|
-
|
|
8242
|
+
fs12__namespace.mkdirSync(tmpDir, { recursive: true });
|
|
8021
8243
|
cleanStaleRunDirs(tmpDir);
|
|
8022
8244
|
const snapshotId = crypto__namespace.randomUUID();
|
|
8023
8245
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8024
|
-
stagingDir =
|
|
8025
|
-
|
|
8246
|
+
stagingDir = path13__namespace.join(tmpDir, `${RUN_DIR_PREFIX}${process.pid}-${snapshotId.slice(0, 8)}`);
|
|
8247
|
+
fs12__namespace.mkdirSync(stagingDir);
|
|
8026
8248
|
writeOwnershipMarker(stagingDir, {
|
|
8027
8249
|
generator: GENERATOR_NAME,
|
|
8028
8250
|
version: GENERATOR_VERSION,
|
|
@@ -8032,41 +8254,41 @@ function generateSnapshot(configInput, options) {
|
|
|
8032
8254
|
id: snapshotId,
|
|
8033
8255
|
pid: process.pid
|
|
8034
8256
|
});
|
|
8035
|
-
const partsDir =
|
|
8036
|
-
const reportsDir =
|
|
8037
|
-
if (artifacts.parts)
|
|
8257
|
+
const partsDir = path13__namespace.join(stagingDir, "parts");
|
|
8258
|
+
const reportsDir = path13__namespace.join(stagingDir, "reports");
|
|
8259
|
+
if (artifacts.parts) fs12__namespace.mkdirSync(partsDir, { recursive: true });
|
|
8038
8260
|
if (artifacts.navigation || artifacts.projectTree || artifacts.audit) {
|
|
8039
|
-
|
|
8261
|
+
fs12__namespace.mkdirSync(reportsDir, { recursive: true });
|
|
8040
8262
|
}
|
|
8041
8263
|
if (artifacts.parts) {
|
|
8042
8264
|
for (const part of parts) {
|
|
8043
|
-
|
|
8265
|
+
fs12__namespace.writeFileSync(path13__namespace.join(partsDir, part.filename), part.markdown, "utf8");
|
|
8044
8266
|
}
|
|
8045
8267
|
}
|
|
8046
8268
|
if (projectTree !== null) {
|
|
8047
|
-
|
|
8269
|
+
fs12__namespace.writeFileSync(path13__namespace.join(reportsDir, "project-tree.md"), projectTree, "utf8");
|
|
8048
8270
|
}
|
|
8049
8271
|
if (artifacts.navigation) {
|
|
8050
|
-
|
|
8272
|
+
fs12__namespace.writeFileSync(path13__namespace.join(reportsDir, "navigation.md"), generateNavigation(manifest), "utf8");
|
|
8051
8273
|
}
|
|
8052
8274
|
if (artifacts.audit) {
|
|
8053
|
-
|
|
8054
|
-
|
|
8275
|
+
fs12__namespace.writeFileSync(
|
|
8276
|
+
path13__namespace.join(reportsDir, "audit.md"),
|
|
8055
8277
|
generateAuditReport(manifest, secretFindings, config.secretRules),
|
|
8056
8278
|
"utf8"
|
|
8057
8279
|
);
|
|
8058
8280
|
}
|
|
8059
8281
|
if (artifacts.readme) {
|
|
8060
|
-
|
|
8282
|
+
fs12__namespace.writeFileSync(path13__namespace.join(stagingDir, "README.md"), generateReadme(manifest, artifacts), "utf8");
|
|
8061
8283
|
}
|
|
8062
8284
|
if (artifacts.manifest) {
|
|
8063
|
-
|
|
8285
|
+
fs12__namespace.writeFileSync(path13__namespace.join(stagingDir, "manifest.json"), JSON.stringify(manifest, null, 2), "utf8");
|
|
8064
8286
|
}
|
|
8065
8287
|
if (monolithJson !== null) {
|
|
8066
|
-
|
|
8288
|
+
fs12__namespace.writeFileSync(path13__namespace.join(stagingDir, "full-codebase.json"), monolithJson, "utf8");
|
|
8067
8289
|
}
|
|
8068
8290
|
if (monolithMarkdown !== null) {
|
|
8069
|
-
|
|
8291
|
+
fs12__namespace.writeFileSync(path13__namespace.join(stagingDir, "full-codebase.md"), monolithMarkdown, "utf8");
|
|
8070
8292
|
}
|
|
8071
8293
|
writeOwnershipMarker(stagingDir, markerPayload(stagingDir, "complete", snapshotId, createdAt));
|
|
8072
8294
|
swapIntoPlace(stagingDir, outDir);
|
|
@@ -8075,7 +8297,7 @@ function generateSnapshot(configInput, options) {
|
|
|
8075
8297
|
const pendingHook = runAfterGenerate(config, manifest);
|
|
8076
8298
|
const shipHookState = () => {
|
|
8077
8299
|
if (artifacts.manifest && manifest.warnings.length !== warningsBeforeHook) {
|
|
8078
|
-
writeManifestAtomically(
|
|
8300
|
+
writeManifestAtomically(path13__namespace.join(outDir, "manifest.json"), manifest);
|
|
8079
8301
|
}
|
|
8080
8302
|
writeOwnershipMarker(outDir, markerPayload(outDir, "complete", snapshotId, createdAt));
|
|
8081
8303
|
};
|
|
@@ -8098,7 +8320,7 @@ function generateSnapshot(configInput, options) {
|
|
|
8098
8320
|
} catch (err) {
|
|
8099
8321
|
if (stagingDir !== null) {
|
|
8100
8322
|
try {
|
|
8101
|
-
|
|
8323
|
+
fs12__namespace.rmSync(stagingDir, { recursive: true, force: true });
|
|
8102
8324
|
} catch {
|
|
8103
8325
|
}
|
|
8104
8326
|
}
|
|
@@ -8113,18 +8335,26 @@ async function generateSnapshotAsync(configInput, options) {
|
|
|
8113
8335
|
}
|
|
8114
8336
|
|
|
8115
8337
|
exports.ARTIFACT_NAMES = ARTIFACT_NAMES;
|
|
8338
|
+
exports.CHECK_INTERVAL_MS = CHECK_INTERVAL_MS;
|
|
8116
8339
|
exports.DEFAULT_ANSWERS = DEFAULT_ANSWERS;
|
|
8117
8340
|
exports.DEFAULT_SECRET_PATTERNS = DEFAULT_SECRET_PATTERNS;
|
|
8341
|
+
exports.FAILURE_INTERVAL_MS = FAILURE_INTERVAL_MS;
|
|
8118
8342
|
exports.GENERATOR_NAME = GENERATOR_NAME;
|
|
8119
8343
|
exports.GENERATOR_VERSION = GENERATOR_VERSION;
|
|
8120
8344
|
exports.LANGUAGE_PROFILES = LANGUAGE_PROFILES;
|
|
8121
8345
|
exports.MIN_MAX_PART_BYTES = MIN_MAX_PART_BYTES;
|
|
8346
|
+
exports.PACKAGE_LATEST_URL = PACKAGE_LATEST_URL;
|
|
8122
8347
|
exports.PRESETS = PRESETS;
|
|
8348
|
+
exports.PromptBack = PromptBack;
|
|
8123
8349
|
exports.PromptCancelled = PromptCancelled;
|
|
8350
|
+
exports.REQUEST_TIMEOUT_MS = REQUEST_TIMEOUT_MS;
|
|
8124
8351
|
exports.SCHEMA_VERSION = SCHEMA_VERSION;
|
|
8125
8352
|
exports.anchorForPath = anchorForPath;
|
|
8126
8353
|
exports.assertReplaceable = assertReplaceable;
|
|
8127
8354
|
exports.assertUsableConfigInput = assertUsableConfigInput;
|
|
8355
|
+
exports.cacheDirectory = cacheDirectory;
|
|
8356
|
+
exports.cacheFilePath = cacheFilePath;
|
|
8357
|
+
exports.checkForUpdate = checkForUpdate;
|
|
8128
8358
|
exports.collectFiles = collectFiles;
|
|
8129
8359
|
exports.compareManifests = compareManifests;
|
|
8130
8360
|
exports.countInvalidUtf8Bytes = countInvalidUtf8Bytes;
|
|
@@ -8133,10 +8363,13 @@ exports.decodeText = decodeText;
|
|
|
8133
8363
|
exports.defineConfig = defineConfig;
|
|
8134
8364
|
exports.detectLanguage = detectLanguage;
|
|
8135
8365
|
exports.detectPreset = detectPreset;
|
|
8366
|
+
exports.displayWidth = displayWidth;
|
|
8136
8367
|
exports.explainPath = explainPath;
|
|
8137
8368
|
exports.fenceForContent = fenceForContent;
|
|
8138
8369
|
exports.fenceForText = fenceForText;
|
|
8370
|
+
exports.fetchLatestVersion = fetchLatestVersion;
|
|
8139
8371
|
exports.firstRunMessage = firstRunMessage;
|
|
8372
|
+
exports.formatUpdateNotice = formatUpdateNotice;
|
|
8140
8373
|
exports.generateProjectTree = generateProjectTree;
|
|
8141
8374
|
exports.generateSnapshot = generateSnapshot;
|
|
8142
8375
|
exports.generateSnapshotAsync = generateSnapshotAsync;
|
|
@@ -8148,6 +8381,7 @@ exports.isBinaryExtension = isBinaryExtension;
|
|
|
8148
8381
|
exports.isBinaryFile = isBinaryFile;
|
|
8149
8382
|
exports.isEffectivelyEmpty = isEffectivelyEmpty;
|
|
8150
8383
|
exports.isInteractive = isInteractive;
|
|
8384
|
+
exports.isNewer = isNewer;
|
|
8151
8385
|
exports.isResolvedConfig = isResolvedConfig;
|
|
8152
8386
|
exports.isSensitivePath = isSensitivePath;
|
|
8153
8387
|
exports.listPresetNames = listPresetNames;
|
|
@@ -8170,6 +8404,7 @@ exports.resolveConfig = resolveConfig;
|
|
|
8170
8404
|
exports.resolveSafeOutputDirs = resolveSafeOutputDirs;
|
|
8171
8405
|
exports.runInit = runInit;
|
|
8172
8406
|
exports.scanAndRedactSecrets = scanAndRedactSecrets;
|
|
8407
|
+
exports.shouldCheck = shouldCheck;
|
|
8173
8408
|
exports.stripJsonComments = stripJsonComments;
|
|
8174
8409
|
exports.summarizeJson = summarizeJson;
|
|
8175
8410
|
exports.summarizeMarkdown = summarizeMarkdown;
|
|
@@ -8179,5 +8414,6 @@ exports.supportsTypeScriptImports = supportsTypeScriptImports;
|
|
|
8179
8414
|
exports.truncatePreview = truncatePreview;
|
|
8180
8415
|
exports.truncateToBytes = truncateToBytes;
|
|
8181
8416
|
exports.validateSnapshot = validateSnapshot;
|
|
8417
|
+
exports.wrapLines = wrapLines;
|
|
8182
8418
|
//# sourceMappingURL=index.cjs.map
|
|
8183
8419
|
//# sourceMappingURL=index.cjs.map
|