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 CHANGED
@@ -26,6 +26,28 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
26
26
 
27
27
  ---
28
28
 
29
+ ## 0.12.10
30
+
31
+ - **The contract said `init` writes nothing else.** It writes `BRIEF.md` as of 0.12.9, and the
32
+ command summary still ended "Nothing else is written." It names the scaffold now and keeps the
33
+ part that is still true: no agent file is written.
34
+
35
+ Verified: 1 187 tests, 1 179 pass, 0 fail, 8 host skips; every gate clean at 0.12.10.
36
+ ## 0.12.9
37
+
38
+ - **`init` now writes `BRIEF.md`.** The scaffold holds the five headings with their guidance in
39
+ comments, and the config keeps `brief:` commented: an untouched scaffold renders no section, and
40
+ because nothing points at it, deleting the template cannot break `generate`. One edit enables it.
41
+ The summary line says which edit.
42
+ - **HTML comments are stripped before the brief is parsed.** The scaffold is nothing but comments;
43
+ without this, every comment would have been pasted into the model's instructions.
44
+ - **An empty recognised section is no longer rendered.** A heading someone has not filled in yet is
45
+ not an assertion, and it no longer produces a provenance line above nothing.
46
+ - New page: [docs/brief.md](docs/brief.md) — the merge, the refusals, the parse rules and a worked
47
+ example. Linked from the README table and the configuration page.
48
+
49
+ Verified: 1 187 tests, 1 179 pass, 0 fail, 8 host skips; lint 226 files; site 16 pages, 410 internal
50
+ links, 0 problems; every gate clean at 0.12.9.
29
51
  ## 0.12.8
30
52
 
31
53
  - **0.12.7 published its own test log.** A `Tee-Object` capture (`.t127.txt`) was in the working
package/README.md CHANGED
@@ -210,7 +210,7 @@ Everything an agent needs is available as data, and the tool can install its own
210
210
  ```bash
211
211
  npx codebase-snapshot describe --format json # contract: workflow, options, exit codes
212
212
  npx codebase-snapshot skill --install # into .claude/skills + .cursor/rules
213
- npx -y codebase-snapshot@0.12.8 mcp # or serve it over MCP
213
+ npx -y codebase-snapshot@0.12.10 mcp # or serve it over MCP
214
214
  ```
215
215
 
216
216
  An agent told only "use `npx codebase-snapshot`" can read the contract, follow its ordered
@@ -269,6 +269,7 @@ others.
269
269
  | [CLI reference](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/cli.md) | Commands, options, exit codes, examples |
270
270
  | [Configuration](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/configuration.md) | Every setting, all 25 presets, budgets, hooks, secrets |
271
271
  | [Snapshot output](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/output.md) | Directory layout and the full manifest schema |
272
+ | [The brief](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/brief.md) | The half of PROMPT.md only you can write, and what is refused |
272
273
  | [AI agents](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/agent.md) | The contract, the skill, what an agent should avoid |
273
274
  | [MCP server](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/mcp.md) | Eight tools, resources, both protocol eras |
274
275
  | [Troubleshooting](https://github.com/ankurhalder/codebase-snapshot/blob/main/docs/troubleshooting.md) | Every message and what to do about it |
package/dist/bin.js CHANGED
@@ -2191,7 +2191,7 @@ function applySpansKeepingQuotes(line, spans) {
2191
2191
 
2192
2192
  // src/version.ts
2193
2193
  var GENERATOR_NAME = "codebase-snapshot";
2194
- var GENERATOR_VERSION = "0.12.8";
2194
+ var GENERATOR_VERSION = "0.12.10";
2195
2195
  var SCHEMA_VERSION = "3.0.0";
2196
2196
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
2197
2197
  function isOurGeneratorName(name) {
@@ -3311,7 +3311,7 @@ var RESERVED_SECTIONS = [
3311
3311
  ];
3312
3312
  function parseOwnerBrief(filePath, text2) {
3313
3313
  const problems = [];
3314
- const source = text2.replace(/^\uFEFF/, "");
3314
+ const source = text2.replace(/^\uFEFF/, "").replace(/<!--[\s\S]*?-->/g, "");
3315
3315
  const preamble = [];
3316
3316
  const sections = [];
3317
3317
  let current = null;
@@ -3365,7 +3365,7 @@ function parseOwnerBrief(filePath, text2) {
3365
3365
  }
3366
3366
  const ownerName = canonicalOwner.get(key);
3367
3367
  if (ownerName !== void 0) {
3368
- recognised[ownerName] = body;
3368
+ if (body.length > 0) recognised[ownerName] = body;
3369
3369
  continue;
3370
3370
  }
3371
3371
  notes.push({ heading: section.heading, body });
@@ -8014,6 +8014,56 @@ function gitignorePath(cwd, filePath) {
8014
8014
  return path10.relative(cwd, filePath).split(path10.sep).join("/");
8015
8015
  }
8016
8016
 
8017
+ // src/wizard/brief-template.ts
8018
+ var BRIEF_SCAFFOLD_FILE = "BRIEF.md";
8019
+ var BRIEF_SCAFFOLD = [
8020
+ "<!-- BRIEF.md \u2014 the half of PROMPT.md only you can write.",
8021
+ "",
8022
+ " `snapshot generate` writes the facts: which files are here, which were skipped and why,",
8023
+ " the system map, the history, the standard, the coverage. It cannot know what the software",
8024
+ " is for, what has already gone wrong, or which failures this team would recognise.",
8025
+ " That is judgement, so it lives here.",
8026
+ "",
8027
+ " Five headings are merged into PROMPT.md:",
8028
+ " ## Stakes what breaks if this is wrong, and who carries it",
8029
+ " ## The system how the pieces fit, in your words",
8030
+ " ## What came before the rounds you have already run, and what they cost",
8031
+ " ## The bar what a finding has to do to be believed here",
8032
+ " ## Calibration failures from your own history, one line each",
8033
+ "",
8034
+ " Any other `##` heading is kept under Owner notes. A measured heading (Coverage,",
8035
+ " This snapshot, ...) is refused, because prose must not overwrite a measurement.",
8036
+ " Leave a section empty and it is simply not rendered. The file is capped at 64 KiB.",
8037
+ " -->",
8038
+ "",
8039
+ "## Stakes",
8040
+ "",
8041
+ "<!-- What breaks if this is wrong? Who carries the consequence? One paragraph. -->",
8042
+ "",
8043
+ "## The system",
8044
+ "",
8045
+ "<!-- How the pieces fit: the boundaries, the protocol between them, the rule that holds it",
8046
+ " together. The generated brief adds the file counts, importers and entry points beside",
8047
+ ' this, under "What the index records". -->',
8048
+ "",
8049
+ "## What came before",
8050
+ "",
8051
+ "<!-- The rounds already run: what was found, what was fixed, what keeps coming back. -->",
8052
+ "",
8053
+ "## The bar",
8054
+ "",
8055
+ "<!-- What a finding must do to be believed here: the lines, the state that reaches them, the",
8056
+ " test that would have caught it. Drop this section to keep the built-in standard. -->",
8057
+ "",
8058
+ "## Calibration",
8059
+ "",
8060
+ "<!-- Two or three real failures, one line each, in the shape you want them reported:",
8061
+ " - a grant signed for one recipe executing another recipe's deletions",
8062
+ " - a recipe that never worked, because its test supplied a number where the daemon sends a string",
8063
+ " -->",
8064
+ ""
8065
+ ].join("\n");
8066
+
8017
8067
  // src/wizard/config-template.ts
8018
8068
  var DEFAULT_ANSWERS = {
8019
8069
  preset: "generic",
@@ -8168,7 +8218,8 @@ function renderConfig(answers) {
8168
8218
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
8169
8219
  // maxParts: 10,
8170
8220
  // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
8171
- // brief: "docs/brief.md",
8221
+ // Any other heading is kept as Owner notes; a measured heading is refused. Capped at 64 KiB.
8222
+ ${answers.brief === void 0 ? '// brief: "docs/brief.md",' : `brief: ${JSON.stringify(answers.brief)},`}
8172
8223
  // Which job the brief is written for: audit, review or explain.
8173
8224
  // promptTask: "audit",
8174
8225
  // afterGenerate: (manifest) => { /* write your own artifact */ }
@@ -8826,6 +8877,9 @@ async function runInit(options) {
8826
8877
  artifacts: artifactAnswers(options),
8827
8878
  includeSensitiveFiles: options.includeSensitiveFiles ?? DEFAULT_ANSWERS.includeSensitiveFiles,
8828
8879
  outDir: options.outDir ?? DEFAULT_ANSWERS.outDir
8880
+ // The scaffold is written below but not wired in: a config that points at a file the user
8881
+ // may delete would turn "delete the template" into "generate now fails". They enable it
8882
+ // when they have something to say, and the scaffold says how.
8829
8883
  };
8830
8884
  const interactive = isInteractive(io) && options.yes !== true;
8831
8885
  if (interactive) {
@@ -9053,7 +9107,9 @@ async function runInit(options) {
9053
9107
  gitignoreEntries: [],
9054
9108
  dependency: { name: GENERATOR_NAME, range: `^${GENERATOR_VERSION}`, added: false },
9055
9109
  notes,
9056
- outDir: answers.outDir
9110
+ outDir: answers.outDir,
9111
+ briefPath: path11.join(options.cwd, BRIEF_SCAFFOLD_FILE),
9112
+ briefWritten: false
9057
9113
  };
9058
9114
  }
9059
9115
  if (present !== null && present !== preferredName && !options.force && !reused) {
@@ -9075,6 +9131,12 @@ async function runInit(options) {
9075
9131
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
9076
9132
  }
9077
9133
  if (!reused) writeFileOrExplain(configPath, configText);
9134
+ const briefPath = path11.join(options.cwd, BRIEF_SCAFFOLD_FILE);
9135
+ let briefWritten = false;
9136
+ if (!fs11.existsSync(briefPath)) {
9137
+ writeFileOrExplain(briefPath, BRIEF_SCAFFOLD);
9138
+ briefWritten = true;
9139
+ }
9078
9140
  const { scripts, dependency } = updatePackageJson(options.cwd, notes);
9079
9141
  const ignore = appendGitignoreEntries(
9080
9142
  options.cwd,
@@ -9093,6 +9155,8 @@ async function runInit(options) {
9093
9155
  gitignoreEntries: ignore.added,
9094
9156
  dependency,
9095
9157
  notes,
9158
+ briefPath,
9159
+ briefWritten,
9096
9160
  outDir: answers.outDir
9097
9161
  };
9098
9162
  }
@@ -14918,7 +14982,7 @@ function buildAgentContract() {
14918
14982
  {
14919
14983
  name: "init",
14920
14984
  aliases: [],
14921
- 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, and ignore the snapshot directories. Nothing else is written. Interactive, or --yes for CI.",
14985
+ 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.",
14922
14986
  positionals: [],
14923
14987
  exits: [0, 1, 2]
14924
14988
  },
@@ -17104,6 +17168,13 @@ async function runInitCommand(invocation) {
17104
17168
  if (result.gitignoreEntries.length > 0) {
17105
17169
  info(` Added to .gitignore: ${result.gitignoreEntries.join(", ")}`);
17106
17170
  }
17171
+ if (result.briefWritten) {
17172
+ info(
17173
+ ` Wrote ${path22.basename(result.briefPath)}: a scaffold for the half of PROMPT.md only you can write. Fill it in, then set brief: ${JSON.stringify(path22.basename(result.briefPath))} in the config to merge it.`
17174
+ );
17175
+ } else if (fs21.existsSync(result.briefPath)) {
17176
+ info(` Kept ${path22.basename(result.briefPath)}: it already exists, and is never overwritten.`);
17177
+ }
17107
17178
  for (const note of result.notes) info(` \u26A0 ${note}`);
17108
17179
  if (hook) for (const note of hook.notes) info(` ${note}`);
17109
17180
  info("");
@@ -1,4 +1,4 @@
1
- import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS, generateInWorker, validateSnapshot, buildImportResolver, resolveSpecifier, truncateToBytes, explainPath, renderExplainText, describeManifestShapeProblem, loadConfigFileDetailed, parseByteSize, resolveConfig } from './chunk-YN34P7LF.js';
1
+ import { GENERATOR_VERSION, anchorForPath, displayPath, MIN_MAX_PART_BYTES, SCHEMA_VERSION, GENERATOR_NAME, ARTIFACT_NAMES, PRESETS, generateInWorker, validateSnapshot, buildImportResolver, resolveSpecifier, truncateToBytes, explainPath, renderExplainText, describeManifestShapeProblem, loadConfigFileDetailed, parseByteSize, resolveConfig } from './chunk-KJQZ2JOC.js';
2
2
  import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
 
@@ -1814,7 +1814,7 @@ function buildAgentContract() {
1814
1814
  {
1815
1815
  name: "init",
1816
1816
  aliases: [],
1817
- 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, and ignore the snapshot directories. Nothing else is written. Interactive, or --yes for CI.",
1817
+ 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.",
1818
1818
  positionals: [],
1819
1819
  exits: [0, 1, 2]
1820
1820
  },
@@ -1745,7 +1745,7 @@ var RESERVED_SECTIONS = [
1745
1745
  ];
1746
1746
  function parseOwnerBrief(filePath, text2) {
1747
1747
  const problems = [];
1748
- const source = text2.replace(/^\uFEFF/, "");
1748
+ const source = text2.replace(/^\uFEFF/, "").replace(/<!--[\s\S]*?-->/g, "");
1749
1749
  const preamble = [];
1750
1750
  const sections = [];
1751
1751
  let current = null;
@@ -1799,7 +1799,7 @@ function parseOwnerBrief(filePath, text2) {
1799
1799
  }
1800
1800
  const ownerName = canonicalOwner.get(key);
1801
1801
  if (ownerName !== void 0) {
1802
- recognised[ownerName] = body;
1802
+ if (body.length > 0) recognised[ownerName] = body;
1803
1803
  continue;
1804
1804
  }
1805
1805
  notes.push({ heading: section.heading, body });
@@ -3993,7 +3993,7 @@ function applySpansKeepingQuotes(line, spans) {
3993
3993
 
3994
3994
  // src/version.ts
3995
3995
  var GENERATOR_NAME = "codebase-snapshot";
3996
- var GENERATOR_VERSION = "0.12.8";
3996
+ var GENERATOR_VERSION = "0.12.10";
3997
3997
  var SCHEMA_VERSION = "3.0.0";
3998
3998
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
3999
3999
  function isOurGeneratorName(name) {
@@ -9805,6 +9805,56 @@ function gitignorePath(cwd, filePath) {
9805
9805
  return path17.relative(cwd, filePath).split(path17.sep).join("/");
9806
9806
  }
9807
9807
 
9808
+ // src/wizard/brief-template.ts
9809
+ var BRIEF_SCAFFOLD_FILE = "BRIEF.md";
9810
+ var BRIEF_SCAFFOLD = [
9811
+ "<!-- BRIEF.md \u2014 the half of PROMPT.md only you can write.",
9812
+ "",
9813
+ " `snapshot generate` writes the facts: which files are here, which were skipped and why,",
9814
+ " the system map, the history, the standard, the coverage. It cannot know what the software",
9815
+ " is for, what has already gone wrong, or which failures this team would recognise.",
9816
+ " That is judgement, so it lives here.",
9817
+ "",
9818
+ " Five headings are merged into PROMPT.md:",
9819
+ " ## Stakes what breaks if this is wrong, and who carries it",
9820
+ " ## The system how the pieces fit, in your words",
9821
+ " ## What came before the rounds you have already run, and what they cost",
9822
+ " ## The bar what a finding has to do to be believed here",
9823
+ " ## Calibration failures from your own history, one line each",
9824
+ "",
9825
+ " Any other `##` heading is kept under Owner notes. A measured heading (Coverage,",
9826
+ " This snapshot, ...) is refused, because prose must not overwrite a measurement.",
9827
+ " Leave a section empty and it is simply not rendered. The file is capped at 64 KiB.",
9828
+ " -->",
9829
+ "",
9830
+ "## Stakes",
9831
+ "",
9832
+ "<!-- What breaks if this is wrong? Who carries the consequence? One paragraph. -->",
9833
+ "",
9834
+ "## The system",
9835
+ "",
9836
+ "<!-- How the pieces fit: the boundaries, the protocol between them, the rule that holds it",
9837
+ " together. The generated brief adds the file counts, importers and entry points beside",
9838
+ ' this, under "What the index records". -->',
9839
+ "",
9840
+ "## What came before",
9841
+ "",
9842
+ "<!-- The rounds already run: what was found, what was fixed, what keeps coming back. -->",
9843
+ "",
9844
+ "## The bar",
9845
+ "",
9846
+ "<!-- What a finding must do to be believed here: the lines, the state that reaches them, the",
9847
+ " test that would have caught it. Drop this section to keep the built-in standard. -->",
9848
+ "",
9849
+ "## Calibration",
9850
+ "",
9851
+ "<!-- Two or three real failures, one line each, in the shape you want them reported:",
9852
+ " - a grant signed for one recipe executing another recipe's deletions",
9853
+ " - a recipe that never worked, because its test supplied a number where the daemon sends a string",
9854
+ " -->",
9855
+ ""
9856
+ ].join("\n");
9857
+
9808
9858
  // src/wizard/config-template.ts
9809
9859
  var DEFAULT_ANSWERS = {
9810
9860
  preset: "generic",
@@ -9959,7 +10009,8 @@ function renderConfig(answers) {
9959
10009
  // adding a part as the code grows. The plan in PROMPT.md becomes a fixed-length attachment list.
9960
10010
  // maxParts: 10,
9961
10011
  // The owner-written half of PROMPT.md: Stakes, The system, What came before, The bar, Calibration.
9962
- // brief: "docs/brief.md",
10012
+ // Any other heading is kept as Owner notes; a measured heading is refused. Capped at 64 KiB.
10013
+ ${answers.brief === void 0 ? '// brief: "docs/brief.md",' : `brief: ${JSON.stringify(answers.brief)},`}
9963
10014
  // Which job the brief is written for: audit, review or explain.
9964
10015
  // promptTask: "audit",
9965
10016
  // afterGenerate: (manifest) => { /* write your own artifact */ }
@@ -10614,6 +10665,9 @@ async function runInit(options) {
10614
10665
  artifacts: artifactAnswers(options),
10615
10666
  includeSensitiveFiles: options.includeSensitiveFiles ?? DEFAULT_ANSWERS.includeSensitiveFiles,
10616
10667
  outDir: options.outDir ?? DEFAULT_ANSWERS.outDir
10668
+ // The scaffold is written below but not wired in: a config that points at a file the user
10669
+ // may delete would turn "delete the template" into "generate now fails". They enable it
10670
+ // when they have something to say, and the scaffold says how.
10617
10671
  };
10618
10672
  const interactive = isInteractive(io) && options.yes !== true;
10619
10673
  if (interactive) {
@@ -10841,7 +10895,9 @@ async function runInit(options) {
10841
10895
  gitignoreEntries: [],
10842
10896
  dependency: { name: GENERATOR_NAME, range: `^${GENERATOR_VERSION}`, added: false },
10843
10897
  notes,
10844
- outDir: answers.outDir
10898
+ outDir: answers.outDir,
10899
+ briefPath: path17.join(options.cwd, BRIEF_SCAFFOLD_FILE),
10900
+ briefWritten: false
10845
10901
  };
10846
10902
  }
10847
10903
  if (present !== null && present !== preferredName && !options.force && !reused) {
@@ -10863,6 +10919,12 @@ async function runInit(options) {
10863
10919
  throw new Error(`${configName} already exists. Re-run with --force to replace it.`);
10864
10920
  }
10865
10921
  if (!reused) writeFileOrExplain(configPath, configText);
10922
+ const briefPath = path17.join(options.cwd, BRIEF_SCAFFOLD_FILE);
10923
+ let briefWritten = false;
10924
+ if (!fs16.existsSync(briefPath)) {
10925
+ writeFileOrExplain(briefPath, BRIEF_SCAFFOLD);
10926
+ briefWritten = true;
10927
+ }
10866
10928
  const { scripts, dependency } = updatePackageJson(options.cwd, notes);
10867
10929
  const ignore = appendGitignoreEntries(
10868
10930
  options.cwd,
@@ -10881,6 +10943,8 @@ async function runInit(options) {
10881
10943
  gitignoreEntries: ignore.added,
10882
10944
  dependency,
10883
10945
  notes,
10946
+ briefPath,
10947
+ briefWritten,
10884
10948
  outDir: answers.outDir
10885
10949
  };
10886
10950
  }