codebase-snapshot 0.12.8 → 0.12.10
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 +22 -0
- package/README.md +2 -1
- package/dist/bin.js +77 -6
- package/dist/{chunk-K72C3YWN.js → chunk-GQ5MGSLC.js} +2 -2
- package/dist/{chunk-YN34P7LF.js → chunk-KJQZ2JOC.js} +69 -5
- package/dist/cli.cjs +297 -226
- package/dist/cli.js +31 -24
- package/dist/index.cjs +69 -5
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +4 -4
- package/dist/mcp.js +2 -2
- package/docs/brief.md +104 -0
- package/docs/cli.md +3 -3
- package/docs/configuration.md +3 -0
- package/docs/mcp.md +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-
|
|
2
|
-
export { buildAgentContract } from './chunk-
|
|
3
|
-
import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-
|
|
1
|
+
import { buildAgentContract, runStdioServer, COMMAND_OPTION_SCOPE, commandsForOption, SKILL_NAME, renderSkill, renderContractText } from './chunk-GQ5MGSLC.js';
|
|
2
|
+
export { buildAgentContract } from './chunk-GQ5MGSLC.js';
|
|
3
|
+
import { shouldCheck, checkForUpdate, GENERATOR_VERSION, cacheFilePath, formatUpdateNotice, installKind, loadConfigFileDetailed, resolveConfig, validateSnapshot, describeManifestShapeProblem, explainPath, compareManifests, loadManifest, renderDiffText, generateSnapshot, formatNumber, isDiscoveryMode, ARTIFACT_NAMES, getPreset, unknownPresetMessage, GENERATOR_NAME, runInit, installPreCommitHook, PromptCancelled, findConfigFile, planFirstRun, isEffectivelyEmpty, isInteractive, defaultIO, hasPriorSnapshot, DEFAULT_ANSWERS, firstRunMessage, stripJsonComments, parseByteSize, gitignorePath, appendGitignoreEntries, runWithStdoutCapture, escapeControls, MIN_MAX_PART_TOKENS, MIN_MAX_PART_BYTES, renderExplainText } from './chunk-KJQZ2JOC.js';
|
|
4
4
|
import { spawnSync } from 'child_process';
|
|
5
|
-
import * as
|
|
5
|
+
import * as fs2 from 'fs';
|
|
6
6
|
import * as path2 from 'path';
|
|
7
7
|
import { parseArgs } from 'util';
|
|
8
8
|
|
|
@@ -18,11 +18,11 @@ function targetPath(cwd, target) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
function assertWritableInsideRepository(cwd, filePath) {
|
|
21
|
-
const root =
|
|
21
|
+
const root = fs2.realpathSync(cwd);
|
|
22
22
|
const shown = path2.relative(root, filePath) || filePath;
|
|
23
23
|
let stat = null;
|
|
24
24
|
try {
|
|
25
|
-
stat =
|
|
25
|
+
stat = fs2.lstatSync(filePath);
|
|
26
26
|
} catch {
|
|
27
27
|
stat = null;
|
|
28
28
|
}
|
|
@@ -38,13 +38,13 @@ function assertWritableInsideRepository(cwd, filePath) {
|
|
|
38
38
|
}
|
|
39
39
|
let existing = filePath;
|
|
40
40
|
const missing = [];
|
|
41
|
-
while (!
|
|
41
|
+
while (!fs2.existsSync(existing)) {
|
|
42
42
|
missing.unshift(path2.basename(existing));
|
|
43
43
|
const parent = path2.dirname(existing);
|
|
44
44
|
if (parent === existing) break;
|
|
45
45
|
existing = parent;
|
|
46
46
|
}
|
|
47
|
-
const realAncestor =
|
|
47
|
+
const realAncestor = fs2.realpathSync(existing);
|
|
48
48
|
const resolved = missing.length === 0 ? realAncestor : path2.join(realAncestor, ...missing);
|
|
49
49
|
if (resolved !== root && !resolved.startsWith(`${root}${path2.sep}`)) {
|
|
50
50
|
throw new Error(
|
|
@@ -53,17 +53,17 @@ function assertWritableInsideRepository(cwd, filePath) {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
function writeIfChanged(target, filePath, content) {
|
|
56
|
-
const existing =
|
|
56
|
+
const existing = fs2.existsSync(filePath) ? fs2.readFileSync(filePath, "utf8") : null;
|
|
57
57
|
if (existing === content) return { target, path: filePath, action: "unchanged" };
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
fs2.mkdirSync(path2.dirname(filePath), { recursive: true });
|
|
59
|
+
fs2.writeFileSync(filePath, content, "utf8");
|
|
60
60
|
return { target, path: filePath, action: existing === null ? "created" : "updated" };
|
|
61
61
|
}
|
|
62
62
|
function legacyAgentsNote(cwd) {
|
|
63
63
|
const filePath = path2.join(cwd, "AGENTS.md");
|
|
64
64
|
try {
|
|
65
|
-
if (!
|
|
66
|
-
if (!
|
|
65
|
+
if (!fs2.existsSync(filePath)) return null;
|
|
66
|
+
if (!fs2.readFileSync(filePath, "utf8").includes(LEGACY_AGENTS_MARKER)) return null;
|
|
67
67
|
} catch {
|
|
68
68
|
return null;
|
|
69
69
|
}
|
|
@@ -75,7 +75,7 @@ function installSkill(cwd, target = "all") {
|
|
|
75
75
|
const notes = [];
|
|
76
76
|
const wanted = target === "all" ? ["claude", "cursor"] : [target];
|
|
77
77
|
for (const item of wanted) assertWritableInsideRepository(cwd, targetPath(cwd, item));
|
|
78
|
-
const createsSomething = wanted.some((item) => !
|
|
78
|
+
const createsSomething = wanted.some((item) => !fs2.existsSync(targetPath(cwd, item)));
|
|
79
79
|
if (createsSomething) {
|
|
80
80
|
assertWritableInsideRepository(cwd, path2.join(cwd, ".gitignore"));
|
|
81
81
|
}
|
|
@@ -367,10 +367,10 @@ function parseCliArgs(argv) {
|
|
|
367
367
|
}
|
|
368
368
|
if (values.cwd !== void 0) {
|
|
369
369
|
const target = String(values.cwd);
|
|
370
|
-
if (!
|
|
370
|
+
if (!fs2.existsSync(target)) {
|
|
371
371
|
throw new UsageError(`--cwd directory does not exist: ${target}`);
|
|
372
372
|
}
|
|
373
|
-
if (!
|
|
373
|
+
if (!fs2.statSync(target).isDirectory()) {
|
|
374
374
|
throw new UsageError(`--cwd is not a directory: ${target}`);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
@@ -614,7 +614,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
|
|
|
614
614
|
if (!hasScript) {
|
|
615
615
|
try {
|
|
616
616
|
const parsed = JSON.parse(
|
|
617
|
-
stripJsonComments(
|
|
617
|
+
stripJsonComments(fs2.readFileSync(path2.join(cwd, "package.json"), "utf8"))
|
|
618
618
|
);
|
|
619
619
|
hasScript = typeof parsed.scripts?.snapshot === "string";
|
|
620
620
|
} catch {
|
|
@@ -623,7 +623,7 @@ function nextStepHint(cwd, scriptsAddedNow) {
|
|
|
623
623
|
}
|
|
624
624
|
if (!hasScript) return `npx ${GENERATOR_NAME} generate`;
|
|
625
625
|
const bin = path2.join(cwd, "node_modules", ".bin", "codebase-snapshot");
|
|
626
|
-
const installed =
|
|
626
|
+
const installed = fs2.existsSync(bin) || fs2.existsSync(`${bin}.cmd`);
|
|
627
627
|
return installed ? "npm run snapshot" : "npm install && npm run snapshot";
|
|
628
628
|
}
|
|
629
629
|
function presetSummary(init) {
|
|
@@ -667,6 +667,13 @@ async function runInitCommand(invocation) {
|
|
|
667
667
|
if (result.gitignoreEntries.length > 0) {
|
|
668
668
|
info(` Added to .gitignore: ${result.gitignoreEntries.join(", ")}`);
|
|
669
669
|
}
|
|
670
|
+
if (result.briefWritten) {
|
|
671
|
+
info(
|
|
672
|
+
` Wrote ${path2.basename(result.briefPath)}: a scaffold for the half of PROMPT.md only you can write. Fill it in, then set brief: ${JSON.stringify(path2.basename(result.briefPath))} in the config to merge it.`
|
|
673
|
+
);
|
|
674
|
+
} else if (fs2.existsSync(result.briefPath)) {
|
|
675
|
+
info(` Kept ${path2.basename(result.briefPath)}: it already exists, and is never overwritten.`);
|
|
676
|
+
}
|
|
670
677
|
for (const note of result.notes) info(` \u26A0 ${note}`);
|
|
671
678
|
if (hook) for (const note of hook.notes) info(` ${note}`);
|
|
672
679
|
info("");
|
|
@@ -682,7 +689,7 @@ async function runInitCommand(invocation) {
|
|
|
682
689
|
function generatorOrigin(cwd) {
|
|
683
690
|
try {
|
|
684
691
|
const pkg = JSON.parse(
|
|
685
|
-
stripJsonComments(
|
|
692
|
+
stripJsonComments(fs2.readFileSync(path2.join(cwd, "package.json"), "utf8"))
|
|
686
693
|
);
|
|
687
694
|
const spec = pkg.dependencies?.["codebase-snapshot"] ?? pkg.devDependencies?.["codebase-snapshot"];
|
|
688
695
|
if (typeof spec === "string") return `project dependency ${spec}`;
|
|
@@ -693,7 +700,7 @@ function generatorOrigin(cwd) {
|
|
|
693
700
|
return "global or direct install";
|
|
694
701
|
}
|
|
695
702
|
function detectPackageManager(cwd) {
|
|
696
|
-
const has = (name) =>
|
|
703
|
+
const has = (name) => fs2.existsSync(path2.join(cwd, name));
|
|
697
704
|
if (has("bun.lockb") || has("bun.lock")) return { name: "bun", command: "bun", args: ["install"] };
|
|
698
705
|
if (has("pnpm-lock.yaml")) return { name: "pnpm", command: "pnpm", args: ["install"] };
|
|
699
706
|
if (has("yarn.lock")) return { name: "yarn", command: "yarn", args: ["install"] };
|
|
@@ -839,7 +846,7 @@ async function runSetupCommand(invocation, options = {}) {
|
|
|
839
846
|
info(` \u26A0 --preset ${invocation.preset} was not applied: the existing config is kept.`);
|
|
840
847
|
}
|
|
841
848
|
}
|
|
842
|
-
const hasManifest =
|
|
849
|
+
const hasManifest = fs2.existsSync(path2.join(invocation.cwd, "package.json"));
|
|
843
850
|
let install = null;
|
|
844
851
|
if (invocation.noInstall) {
|
|
845
852
|
if (invocation.format !== "json") info(" Skipped the install (--no-install)");
|
|
@@ -1156,12 +1163,12 @@ ${USAGE}
|
|
|
1156
1163
|
}
|
|
1157
1164
|
if (invocation.command === "report") {
|
|
1158
1165
|
const manifestPath = path2.resolve(resolved.cwd, resolved.outDir, "manifest.json");
|
|
1159
|
-
if (!
|
|
1166
|
+
if (!fs2.existsSync(manifestPath)) {
|
|
1160
1167
|
return fail(invocation.format, `Manifest not found at ${manifestPath}. Run generate first.`);
|
|
1161
1168
|
}
|
|
1162
1169
|
let manifest;
|
|
1163
1170
|
try {
|
|
1164
|
-
manifest = JSON.parse(
|
|
1171
|
+
manifest = JSON.parse(fs2.readFileSync(manifestPath, "utf8"));
|
|
1165
1172
|
} catch (err) {
|
|
1166
1173
|
return fail(invocation.format, `Could not read ${manifestPath}: ${err.message}`);
|
|
1167
1174
|
}
|
|
@@ -1492,7 +1499,7 @@ async function runWatchLoop(invocation, resolved, options) {
|
|
|
1492
1499
|
info("\u{1F440} Watching for changes. Press Ctrl+C to stop.");
|
|
1493
1500
|
let watcher;
|
|
1494
1501
|
try {
|
|
1495
|
-
watcher =
|
|
1502
|
+
watcher = fs2.watch(resolved.cwd, { recursive: true }, (_event, filename) => {
|
|
1496
1503
|
const decision = decideWatchEvent(
|
|
1497
1504
|
state,
|
|
1498
1505
|
{
|
package/dist/index.cjs
CHANGED
|
@@ -1762,7 +1762,7 @@ var RESERVED_SECTIONS = [
|
|
|
1762
1762
|
];
|
|
1763
1763
|
function parseOwnerBrief(filePath, text2) {
|
|
1764
1764
|
const problems = [];
|
|
1765
|
-
const source = text2.replace(/^\uFEFF/, "");
|
|
1765
|
+
const source = text2.replace(/^\uFEFF/, "").replace(/<!--[\s\S]*?-->/g, "");
|
|
1766
1766
|
const preamble = [];
|
|
1767
1767
|
const sections = [];
|
|
1768
1768
|
let current = null;
|
|
@@ -1816,7 +1816,7 @@ function parseOwnerBrief(filePath, text2) {
|
|
|
1816
1816
|
}
|
|
1817
1817
|
const ownerName = canonicalOwner.get(key);
|
|
1818
1818
|
if (ownerName !== void 0) {
|
|
1819
|
-
recognised[ownerName] = body;
|
|
1819
|
+
if (body.length > 0) recognised[ownerName] = body;
|
|
1820
1820
|
continue;
|
|
1821
1821
|
}
|
|
1822
1822
|
notes.push({ heading: section.heading, body });
|
|
@@ -4010,7 +4010,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
4010
4010
|
|
|
4011
4011
|
// src/version.ts
|
|
4012
4012
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
4013
|
-
var GENERATOR_VERSION = "0.12.
|
|
4013
|
+
var GENERATOR_VERSION = "0.12.10";
|
|
4014
4014
|
var SCHEMA_VERSION = "3.0.0";
|
|
4015
4015
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
4016
4016
|
function isOurGeneratorName(name) {
|
|
@@ -9800,6 +9800,56 @@ function gitignorePath(cwd, filePath) {
|
|
|
9800
9800
|
return path17__namespace.relative(cwd, filePath).split(path17__namespace.sep).join("/");
|
|
9801
9801
|
}
|
|
9802
9802
|
|
|
9803
|
+
// src/wizard/brief-template.ts
|
|
9804
|
+
var BRIEF_SCAFFOLD_FILE = "BRIEF.md";
|
|
9805
|
+
var BRIEF_SCAFFOLD = [
|
|
9806
|
+
"<!-- BRIEF.md \u2014 the half of PROMPT.md only you can write.",
|
|
9807
|
+
"",
|
|
9808
|
+
" `snapshot generate` writes the facts: which files are here, which were skipped and why,",
|
|
9809
|
+
" the system map, the history, the standard, the coverage. It cannot know what the software",
|
|
9810
|
+
" is for, what has already gone wrong, or which failures this team would recognise.",
|
|
9811
|
+
" That is judgement, so it lives here.",
|
|
9812
|
+
"",
|
|
9813
|
+
" Five headings are merged into PROMPT.md:",
|
|
9814
|
+
" ## Stakes what breaks if this is wrong, and who carries it",
|
|
9815
|
+
" ## The system how the pieces fit, in your words",
|
|
9816
|
+
" ## What came before the rounds you have already run, and what they cost",
|
|
9817
|
+
" ## The bar what a finding has to do to be believed here",
|
|
9818
|
+
" ## Calibration failures from your own history, one line each",
|
|
9819
|
+
"",
|
|
9820
|
+
" Any other `##` heading is kept under Owner notes. A measured heading (Coverage,",
|
|
9821
|
+
" This snapshot, ...) is refused, because prose must not overwrite a measurement.",
|
|
9822
|
+
" Leave a section empty and it is simply not rendered. The file is capped at 64 KiB.",
|
|
9823
|
+
" -->",
|
|
9824
|
+
"",
|
|
9825
|
+
"## Stakes",
|
|
9826
|
+
"",
|
|
9827
|
+
"<!-- What breaks if this is wrong? Who carries the consequence? One paragraph. -->",
|
|
9828
|
+
"",
|
|
9829
|
+
"## The system",
|
|
9830
|
+
"",
|
|
9831
|
+
"<!-- How the pieces fit: the boundaries, the protocol between them, the rule that holds it",
|
|
9832
|
+
" together. The generated brief adds the file counts, importers and entry points beside",
|
|
9833
|
+
' this, under "What the index records". -->',
|
|
9834
|
+
"",
|
|
9835
|
+
"## What came before",
|
|
9836
|
+
"",
|
|
9837
|
+
"<!-- The rounds already run: what was found, what was fixed, what keeps coming back. -->",
|
|
9838
|
+
"",
|
|
9839
|
+
"## The bar",
|
|
9840
|
+
"",
|
|
9841
|
+
"<!-- What a finding must do to be believed here: the lines, the state that reaches them, the",
|
|
9842
|
+
" test that would have caught it. Drop this section to keep the built-in standard. -->",
|
|
9843
|
+
"",
|
|
9844
|
+
"## Calibration",
|
|
9845
|
+
"",
|
|
9846
|
+
"<!-- Two or three real failures, one line each, in the shape you want them reported:",
|
|
9847
|
+
" - a grant signed for one recipe executing another recipe's deletions",
|
|
9848
|
+
" - a recipe that never worked, because its test supplied a number where the daemon sends a string",
|
|
9849
|
+
" -->",
|
|
9850
|
+
""
|
|
9851
|
+
].join("\n");
|
|
9852
|
+
|
|
9803
9853
|
// src/wizard/config-template.ts
|
|
9804
9854
|
var DEFAULT_ANSWERS = {
|
|
9805
9855
|
preset: "generic",
|
|
@@ -9954,7 +10004,8 @@ function renderConfig(answers) {
|
|
|
9954
10004
|
// adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
|
|
9955
10005
|
// maxParts: 10,
|
|
9956
10006
|
// The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
|
|
9957
|
-
//
|
|
10007
|
+
// Any other heading is kept as Owner notes; a measured heading is refused. Capped at 64 KiB.
|
|
10008
|
+
${answers.brief === void 0 ? '// brief: "docs/brief.md",' : `brief: ${JSON.stringify(answers.brief)},`}
|
|
9958
10009
|
// Which job the brief is written for: audit, review or explain.
|
|
9959
10010
|
// promptTask: "audit",
|
|
9960
10011
|
// afterGenerate: (manifest) => { /* write your own artifact */ }
|
|
@@ -10609,6 +10660,9 @@ async function runInit(options) {
|
|
|
10609
10660
|
artifacts: artifactAnswers(options),
|
|
10610
10661
|
includeSensitiveFiles: options.includeSensitiveFiles ?? DEFAULT_ANSWERS.includeSensitiveFiles,
|
|
10611
10662
|
outDir: options.outDir ?? DEFAULT_ANSWERS.outDir
|
|
10663
|
+
// The scaffold is written below but not wired in: a config that points at a file the user
|
|
10664
|
+
// may delete would turn "delete the template" into "generate now fails". They enable it
|
|
10665
|
+
// when they have something to say, and the scaffold says how.
|
|
10612
10666
|
};
|
|
10613
10667
|
const interactive = isInteractive(io) && options.yes !== true;
|
|
10614
10668
|
if (interactive) {
|
|
@@ -10836,7 +10890,9 @@ async function runInit(options) {
|
|
|
10836
10890
|
gitignoreEntries: [],
|
|
10837
10891
|
dependency: { name: GENERATOR_NAME, range: `^${GENERATOR_VERSION}`, added: false },
|
|
10838
10892
|
notes,
|
|
10839
|
-
outDir: answers.outDir
|
|
10893
|
+
outDir: answers.outDir,
|
|
10894
|
+
briefPath: path17__namespace.join(options.cwd, BRIEF_SCAFFOLD_FILE),
|
|
10895
|
+
briefWritten: false
|
|
10840
10896
|
};
|
|
10841
10897
|
}
|
|
10842
10898
|
if (present !== null && present !== preferredName && !options.force && !reused) {
|
|
@@ -10858,6 +10914,12 @@ async function runInit(options) {
|
|
|
10858
10914
|
throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
|
|
10859
10915
|
}
|
|
10860
10916
|
if (!reused) writeFileOrExplain(configPath, configText);
|
|
10917
|
+
const briefPath = path17__namespace.join(options.cwd, BRIEF_SCAFFOLD_FILE);
|
|
10918
|
+
let briefWritten = false;
|
|
10919
|
+
if (!fs16__namespace.existsSync(briefPath)) {
|
|
10920
|
+
writeFileOrExplain(briefPath, BRIEF_SCAFFOLD);
|
|
10921
|
+
briefWritten = true;
|
|
10922
|
+
}
|
|
10861
10923
|
const { scripts, dependency } = updatePackageJson(options.cwd, notes);
|
|
10862
10924
|
const ignore = appendGitignoreEntries(
|
|
10863
10925
|
options.cwd,
|
|
@@ -10876,6 +10938,8 @@ async function runInit(options) {
|
|
|
10876
10938
|
gitignoreEntries: ignore.added,
|
|
10877
10939
|
dependency,
|
|
10878
10940
|
notes,
|
|
10941
|
+
briefPath,
|
|
10942
|
+
briefWritten,
|
|
10879
10943
|
outDir: answers.outDir
|
|
10880
10944
|
};
|
|
10881
10945
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
|
|
|
548
548
|
* `package.json` carries the same version; `npm run verify` compares the two.
|
|
549
549
|
*/
|
|
550
550
|
declare const GENERATOR_NAME = "codebase-snapshot";
|
|
551
|
-
declare const GENERATOR_VERSION = "0.12.
|
|
551
|
+
declare const GENERATOR_VERSION = "0.12.10";
|
|
552
552
|
/**
|
|
553
553
|
* The manifest and ownership-marker schema this build writes and understands.
|
|
554
554
|
*
|
|
@@ -926,6 +926,10 @@ interface InitResult {
|
|
|
926
926
|
* project that chose a different directory.
|
|
927
927
|
*/
|
|
928
928
|
outDir: string;
|
|
929
|
+
/** The brief scaffold this run wrote, when it wrote one. */
|
|
930
|
+
briefPath: string;
|
|
931
|
+
/** False when the repository already had a BRIEF.md, which is never overwritten. */
|
|
932
|
+
briefWritten: boolean;
|
|
929
933
|
}
|
|
930
934
|
/**
|
|
931
935
|
* Runs the interactive setup, or writes a config from flags.
|
|
@@ -1030,6 +1034,8 @@ interface WizardAnswers {
|
|
|
1030
1034
|
artifacts: Required<ArtifactSelection>;
|
|
1031
1035
|
includeSensitiveFiles: boolean;
|
|
1032
1036
|
outDir: string;
|
|
1037
|
+
/** Path to the owner brief this config points at, when `init` wrote one. */
|
|
1038
|
+
brief?: string;
|
|
1033
1039
|
}
|
|
1034
1040
|
declare const DEFAULT_ANSWERS: WizardAnswers;
|
|
1035
1041
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -548,7 +548,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
|
|
|
548
548
|
* `package.json` carries the same version; `npm run verify` compares the two.
|
|
549
549
|
*/
|
|
550
550
|
declare const GENERATOR_NAME = "codebase-snapshot";
|
|
551
|
-
declare const GENERATOR_VERSION = "0.12.
|
|
551
|
+
declare const GENERATOR_VERSION = "0.12.10";
|
|
552
552
|
/**
|
|
553
553
|
* The manifest and ownership-marker schema this build writes and understands.
|
|
554
554
|
*
|
|
@@ -926,6 +926,10 @@ interface InitResult {
|
|
|
926
926
|
* project that chose a different directory.
|
|
927
927
|
*/
|
|
928
928
|
outDir: string;
|
|
929
|
+
/** The brief scaffold this run wrote, when it wrote one. */
|
|
930
|
+
briefPath: string;
|
|
931
|
+
/** False when the repository already had a BRIEF.md, which is never overwritten. */
|
|
932
|
+
briefWritten: boolean;
|
|
929
933
|
}
|
|
930
934
|
/**
|
|
931
935
|
* Runs the interactive setup, or writes a config from flags.
|
|
@@ -1030,6 +1034,8 @@ interface WizardAnswers {
|
|
|
1030
1034
|
artifacts: Required<ArtifactSelection>;
|
|
1031
1035
|
includeSensitiveFiles: boolean;
|
|
1032
1036
|
outDir: string;
|
|
1037
|
+
/** Path to the owner brief this config points at, when `init` wrote one. */
|
|
1038
|
+
brief?: string;
|
|
1033
1039
|
}
|
|
1034
1040
|
declare const DEFAULT_ANSWERS: WizardAnswers;
|
|
1035
1041
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-
|
|
1
|
+
export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, CONFIG_KEYS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, HOOK_MARKER, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, UP_TO_DATE_INTERVAL_MS, anchorForPath, appendGitignoreEntries, assertReplaceable, assertUsableConfigInput, buildImportResolver, bytesForTokens, cacheDirectory, cacheFilePath, checkForUpdate, classifyKind, classifyLayer, collectFiles, compareManifests, configDigest, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayPath, displayWidth, enforceBudget, estimateTokens, explainPath, fenceForContent, fenceForText, fetchLatestVersion, findSecretInPath, firstRunMessage, formatTokens, formatUpdateNotice, generateProjectTree, generateSarifReport, generateSnapshot, generateSnapshotAsync, getGitInfo, getPreset, gitignorePath, globToRegExp, hasPriorSnapshot, importsChangedFile, importsOfFile, importsOfText, installKind, installPreCommitHook, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, isSkeletonizable, isTsxFileName, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, lockPathFor, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveChangedScope, resolveConfig, resolveSafeOutputDirs, resolveSpecifier, runInit, scanAndRedactSecrets, shouldCheck, skeletonizeTypeScript, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, treeTruncationWarnings, truncatePreview, truncateToBytes, tsconfigPathsFor, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-KJQZ2JOC.js';
|
package/dist/mcp.cjs
CHANGED
|
@@ -298,7 +298,7 @@ var RESERVED_SECTIONS = [
|
|
|
298
298
|
];
|
|
299
299
|
function parseOwnerBrief(filePath, text) {
|
|
300
300
|
const problems = [];
|
|
301
|
-
const source = text.replace(/^\uFEFF/, "");
|
|
301
|
+
const source = text.replace(/^\uFEFF/, "").replace(/<!--[\s\S]*?-->/g, "");
|
|
302
302
|
const preamble = [];
|
|
303
303
|
const sections = [];
|
|
304
304
|
let current = null;
|
|
@@ -352,7 +352,7 @@ function parseOwnerBrief(filePath, text) {
|
|
|
352
352
|
}
|
|
353
353
|
const ownerName = canonicalOwner.get(key);
|
|
354
354
|
if (ownerName !== void 0) {
|
|
355
|
-
recognised[ownerName] = body;
|
|
355
|
+
if (body.length > 0) recognised[ownerName] = body;
|
|
356
356
|
continue;
|
|
357
357
|
}
|
|
358
358
|
notes.push({ heading: section.heading, body });
|
|
@@ -2546,7 +2546,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2546
2546
|
|
|
2547
2547
|
// src/version.ts
|
|
2548
2548
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2549
|
-
var GENERATOR_VERSION = "0.12.
|
|
2549
|
+
var GENERATOR_VERSION = "0.12.10";
|
|
2550
2550
|
var SCHEMA_VERSION = "3.0.0";
|
|
2551
2551
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2552
2552
|
function isOurGeneratorName(name) {
|
|
@@ -9217,7 +9217,7 @@ function buildAgentContract() {
|
|
|
9217
9217
|
{
|
|
9218
9218
|
name: "init",
|
|
9219
9219
|
aliases: [],
|
|
9220
|
-
summary: "Write a commented config file (snapshot.config.ts only when Node can strip types and the project is an ES module; snapshot.config.mjs otherwise), add the snapshot scripts and the devDependency,
|
|
9220
|
+
summary: "Write a commented config file (snapshot.config.ts only when Node can strip types and the project is an ES module; snapshot.config.mjs otherwise), add the snapshot scripts and the devDependency, ignore the snapshot directories, and write a BRIEF.md scaffold for the owner half of PROMPT.md. No agent file is written. Interactive, or --yes for CI.",
|
|
9221
9221
|
positionals: [],
|
|
9222
9222
|
exits: [0, 1, 2]
|
|
9223
9223
|
},
|
package/dist/mcp.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-
|
|
2
|
-
export { generateInWorker } from './chunk-
|
|
1
|
+
export { ERROR_CODES, LEGACY_PROTOCOL_VERSIONS, MAX_LINE_BYTES, METHOD, MODERN_PROTOCOL_VERSIONS, SERVER_INSTRUCTIONS, SUPPORTED_PROTOCOL_VERSIONS, buildPrompts, buildResourceProvider, buildTools, classifyRequest, coerceNumericStrings, createLineReader, createMcpServer, createServer, createSession, createWriter, findSection, inspectModernMeta, negotiateLegacyVersion, parsePartSections, runStdioServer, validateArguments, windowText } from './chunk-GQ5MGSLC.js';
|
|
2
|
+
export { generateInWorker } from './chunk-KJQZ2JOC.js';
|
package/docs/brief.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# The brief: the half only you can write
|
|
2
|
+
|
|
3
|
+
`PROMPT.md` is generated, and part of it cannot be. The manifest can prove which files are here,
|
|
4
|
+
which were skipped and why, what the system map is and what the standard requires. It cannot know
|
|
5
|
+
what the software is *for*, what has already gone wrong, or which failures this team would
|
|
6
|
+
recognise. That is judgement, so it is supplied as a file and merged into the brief.
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
# init writes BRIEF.md next to the config, with the five headings and guidance in comments
|
|
10
|
+
npx codebase-snapshot init --yes
|
|
11
|
+
|
|
12
|
+
# then enable it with one edit, or name your own file on the command line
|
|
13
|
+
npx codebase-snapshot generate --brief docs/brief.md
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
// snapshot.config.mjs
|
|
18
|
+
export default {
|
|
19
|
+
brief: "BRIEF.md", // relative to the project root; a missing file is an error
|
|
20
|
+
promptTask: "audit", // audit | review | explain
|
|
21
|
+
};
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## The five headings
|
|
25
|
+
|
|
26
|
+
| Heading | What happens |
|
|
27
|
+
| :--- | :--- |
|
|
28
|
+
| `## Stakes` | rendered as its own section, right after the job |
|
|
29
|
+
| `## The system` | replaces the generated narrative; the measured facts still follow under "What the index records" |
|
|
30
|
+
| `## What came before` | rendered above the generated commit ledger |
|
|
31
|
+
| `## The bar` | replaces the standard |
|
|
32
|
+
| `## Calibration` | replaces the example failures |
|
|
33
|
+
|
|
34
|
+
Any other `##` heading is kept, verbatim, under **Owner notes**. Nothing is dropped because the
|
|
35
|
+
merge did not recognise it — a brief is your text, and silently discarding a section is the one
|
|
36
|
+
thing this tool does not do.
|
|
37
|
+
|
|
38
|
+
Every owner section is marked in `PROMPT.md` as written by the project owner, so a reader can tell
|
|
39
|
+
an assertion from a measurement.
|
|
40
|
+
|
|
41
|
+
## A worked example
|
|
42
|
+
|
|
43
|
+
```markdown
|
|
44
|
+
<!-- BRIEF.md: fill in what you know; an empty section is simply not rendered -->
|
|
45
|
+
|
|
46
|
+
## Stakes
|
|
47
|
+
|
|
48
|
+
Runs live production for one owner. A wrong cleanup deletes their data, and the backup is taken by
|
|
49
|
+
the same process it is protecting.
|
|
50
|
+
|
|
51
|
+
## What came before
|
|
52
|
+
|
|
53
|
+
Four rounds, 23 defects. The recurring shapes: a guard at the route but not the timer, and an `ok`
|
|
54
|
+
flag that means only that the call returned.
|
|
55
|
+
|
|
56
|
+
## Calibration
|
|
57
|
+
|
|
58
|
+
- a grant signed for one recipe executing another recipe's deletions
|
|
59
|
+
- a recipe that never worked, because its test supplied a number where the daemon sends a string
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## What is refused, and why
|
|
63
|
+
|
|
64
|
+
Three things are errors rather than overrides, because each would make the document lie:
|
|
65
|
+
|
|
66
|
+
- **a measured heading.** `Coverage`, `This snapshot`, `Attaching this`, `The job`, `What you have`
|
|
67
|
+
and the rest are rendered from the manifest. Redefining one would let prose overwrite a
|
|
68
|
+
measurement.
|
|
69
|
+
- **a file that cannot be read.** A snapshot must not quietly ship without the half you wrote.
|
|
70
|
+
- **an edited brief after generating.** Its digest is recorded, so `validate` reports
|
|
71
|
+
`brief: docs/brief.md changed since this snapshot was generated`.
|
|
72
|
+
|
|
73
|
+
Two smaller ones: a heading defined twice is ambiguous and refused, and a file over 64 KiB is
|
|
74
|
+
refused with its size — past that it is a second codebase rather than instruction.
|
|
75
|
+
|
|
76
|
+
## How the file is parsed
|
|
77
|
+
|
|
78
|
+
| Input | Result |
|
|
79
|
+
| :--- | :--- |
|
|
80
|
+
| `## stakes`, `## STAKES` | the stakes section; headings match case-insensitively |
|
|
81
|
+
| `## Stakes:` | the stakes section; a trailing colon is a typo, not a different heading |
|
|
82
|
+
| `<!-- ... -->` | removed before parsing — the `init` scaffold is all comments and renders nothing |
|
|
83
|
+
| a section with no text | not rendered at all |
|
|
84
|
+
| a fenced block containing `## Coverage` | content, not a heading |
|
|
85
|
+
| CRLF, or a UTF-8 byte-order mark | read like the plain case |
|
|
86
|
+
| a control character | escaped, as everywhere else this tool reproduces text |
|
|
87
|
+
|
|
88
|
+
## The job changes, the standard does not
|
|
89
|
+
|
|
90
|
+
`promptTask` changes only the opening section:
|
|
91
|
+
|
|
92
|
+
- `audit` (the default) — find what is still wrong or will break;
|
|
93
|
+
- `review` — say what a change breaks, and what it claims but does not do;
|
|
94
|
+
- `explain` — explain how a subsystem works, and cite the lines.
|
|
95
|
+
|
|
96
|
+
The standard, the coverage duty and the answer shape are the same in all three. An unknown value
|
|
97
|
+
is a usage error, never a silent fall back to the default.
|
|
98
|
+
|
|
99
|
+
## Relationship to the rest of the snapshot
|
|
100
|
+
|
|
101
|
+
`brief` is instruction, not payload: changing it does not change the files that are copied, but it
|
|
102
|
+
does change the config digest, so a stale brief is flagged exactly like a stale snapshot. The
|
|
103
|
+
writer’s prose is masked like every other reproduced string, and the brief file itself is an
|
|
104
|
+
ordinary file in the repository — it may be snapshotted, or excluded with `excludePatterns`.
|
package/docs/cli.md
CHANGED
|
@@ -97,7 +97,7 @@ Exit `0` when the snapshot passes its own integrity check, `1` when it does not.
|
|
|
97
97
|
|
|
98
98
|
```
|
|
99
99
|
📸 Generating snapshot for: /path/to/repo
|
|
100
|
-
Branch: main | Part budget: 300 KB | Generator: 0.12.
|
|
100
|
+
Branch: main | Part budget: 300 KB | Generator: 0.12.10 (project dependency ^0.12.10)
|
|
101
101
|
|
|
102
102
|
✅ Snapshot generated in 0.14s:
|
|
103
103
|
- Tracked files: 121 included of 128 paths found — 7 skipped (default-ignore 5, binary 1, sensitive-file 1); every one is listed in snapshot/reports/audit.md
|
|
@@ -192,7 +192,7 @@ The whole first run in one command, with defaults and no prompts. This is the sa
|
|
|
192
192
|
🚀 Setup for: /path/to/repo
|
|
193
193
|
✅ Created snapshot.config.ts (preset: nextjs)
|
|
194
194
|
Added npm scripts: snapshot, snapshot:validate
|
|
195
|
-
Added devDependency: codebase-snapshot ^0.12.
|
|
195
|
+
Added devDependency: codebase-snapshot ^0.12.10
|
|
196
196
|
Added to .gitignore: /snapshot/, /snapshot.tmp/
|
|
197
197
|
⏳ Installing dependencies…
|
|
198
198
|
✅ Installed dependencies (npm install, 2.1s)
|
|
@@ -244,7 +244,7 @@ It also has three side effects on files you own, and it says so when it does the
|
|
|
244
244
|
```
|
|
245
245
|
✅ Created snapshot.config.ts (preset: node-lib)
|
|
246
246
|
Added npm scripts: snapshot, snapshot:validate
|
|
247
|
-
Added devDependency: codebase-snapshot ^0.12.
|
|
247
|
+
Added devDependency: codebase-snapshot ^0.12.10
|
|
248
248
|
Added to .gitignore: /snapshot/, /snapshot.tmp/
|
|
249
249
|
```
|
|
250
250
|
|
package/docs/configuration.md
CHANGED
|
@@ -297,6 +297,9 @@ case where the file count, not the byte count, is the binding constraint.
|
|
|
297
297
|
|
|
298
298
|
## The brief: what only you can write
|
|
299
299
|
|
|
300
|
+
[The brief](brief.md) documents the format in full: the merge, the refusals, and how the file is
|
|
301
|
+
parsed.
|
|
302
|
+
|
|
300
303
|
`PROMPT.md` is generated, and half of it cannot be: what the software is *for*, what has already
|
|
301
304
|
gone wrong, and which failures you would recognise. That is judgement, so it is supplied as a
|
|
302
305
|
file and merged at fixed slots.
|
package/docs/mcp.md
CHANGED
|
@@ -10,7 +10,7 @@ walk — that the client sees.
|
|
|
10
10
|
## Start it
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npx -y codebase-snapshot@0.12.
|
|
13
|
+
npx -y codebase-snapshot@0.12.10 mcp
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
The server serves the directory it was started in. `--cwd <path>` points it elsewhere, and that
|
|
@@ -25,7 +25,7 @@ Claude Desktop and Cursor:
|
|
|
25
25
|
"mcpServers": {
|
|
26
26
|
"codebase-snapshot": {
|
|
27
27
|
"command": "npx",
|
|
28
|
-
"args": ["-y", "codebase-snapshot@0.12.
|
|
28
|
+
"args": ["-y", "codebase-snapshot@0.12.10", "mcp", "--cwd", "/absolute/path/to/repo"]
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -34,7 +34,7 @@ Claude Desktop and Cursor:
|
|
|
34
34
|
Claude Code registers the same thing from a shell:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.12.
|
|
37
|
+
claude mcp add codebase-snapshot -- npx -y codebase-snapshot@0.12.10 mcp --cwd /absolute/path/to/repo
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
On Windows, wrap the command as `cmd /c npx` with the same arguments — `npx` is a `.cmd` shim
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codebase-snapshot",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.10",
|
|
4
4
|
"description": "Create a codebase snapshot an LLM can read: budgeted Markdown parts for Claude, ChatGPT and Cursor, a manifest of every included and skipped file, secret redaction, and validate, which fails when the snapshot drifts. Local CLI and MCP server.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codebase-snapshot",
|