codebase-snapshot 0.14.0 → 0.15.0
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 +95 -0
- package/README.md +1 -1
- package/SECURITY.md +2 -2
- package/dist/bin.js +84 -8
- package/dist/{chunk-7WSZUMT6.js → chunk-4OHQULCV.js} +1 -1
- package/dist/{chunk-2YNQ42B3.js → chunk-KHHUC6UT.js} +78 -8
- package/dist/cli.cjs +84 -8
- package/dist/cli.d.cts +11 -1
- package/dist/cli.d.ts +11 -1
- package/dist/cli.js +9 -3
- package/dist/index.cjs +78 -8
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/mcp.cjs +78 -8
- package/dist/mcp.js +2 -2
- package/dist/{types-CbD8yQRZ.d.cts → types-5G2Q6tWP.d.cts} +4 -0
- package/dist/{types-CbD8yQRZ.d.ts → types-5G2Q6tWP.d.ts} +4 -0
- package/docs/benchmarks.md +54 -9
- package/docs/cli.md +6 -4
- package/docs/deploy.md +2 -2
- package/docs/mcp.md +4 -4
- package/docs/tools.md +3 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -30,6 +30,101 @@ deprecated with an explanatory message instead. `latest` has pointed at 0.9.0 si
|
|
|
30
30
|
|
|
31
31
|
---
|
|
32
32
|
|
|
33
|
+
## 0.15.0
|
|
34
|
+
|
|
35
|
+
**Parity, measured on someone else's repositories.**
|
|
36
|
+
|
|
37
|
+
0.15.x was the parity phase, and the honest test of parity is not a feature list — it is running the
|
|
38
|
+
same repositories through both tools and publishing what happened.
|
|
39
|
+
|
|
40
|
+
- **Ten public repositories, three tools, one command** (`scripts/benchmark-suite.mjs`): is-odd,
|
|
41
|
+
chalk, co, minimatch, luxon, requests, click, express, zod and github-readme-stats, cloned shallow
|
|
42
|
+
and packed by this tool, repomix 1.19.0 and gitingest. Nine of ten land within about plus or minus
|
|
43
|
+
30% of repomix's own token count. The tenth, minimatch, is a policy difference: five 20–25 MB
|
|
44
|
+
benchmark fixtures are emitted by repomix (64.8M tokens) and bounded-previewed by us (319,879).
|
|
45
|
+
The page says which is which instead of celebrating a ratio.
|
|
46
|
+
- **`--only` and `--ignore`** narrow a single run without editing a configuration: `--only` replaces
|
|
47
|
+
the allow-list, `--ignore` adds to the deny-list, and both enter the config digest so `validate`
|
|
48
|
+
and `explain` compare like with like. An ignored path is recorded in `skipped[]`, never dropped.
|
|
49
|
+
- **gitingest runs in the harness** now, with `PYTHONIOENCODING=utf-8` for the child process;
|
|
50
|
+
without it, gitingest aborts on Windows while printing its tree and the comparison silently
|
|
51
|
+
degrades to two tools.
|
|
52
|
+
|
|
53
|
+
### What parity means here
|
|
54
|
+
|
|
55
|
+
Feature-for-feature, the floor is covered: diffs, logs, a token tree, single-file packs in three
|
|
56
|
+
formats, comment stripping, blank-line stripping, and structural parsers for seven non-TypeScript
|
|
57
|
+
languages. What is different is deliberate and stated: a selection (slice, budget, delta) that neither
|
|
58
|
+
competitor produces, an audit that verifies the manifest instead of trusting it, and a token estimate
|
|
59
|
+
that is documented as an estimate.
|
|
60
|
+
|
|
61
|
+
### How it was verified
|
|
62
|
+
|
|
63
|
+
Full `npm run verify`: 1328 tests, 1320 pass, 0 fail, 8 host skips; 29 site pages with no link or
|
|
64
|
+
metadata problems; a 52-file tarball whose lockfile agrees with `package.json`. The ten-repository
|
|
65
|
+
run is reproducible with one command and reports its own skips.
|
|
66
|
+
## 0.14.6
|
|
67
|
+
|
|
68
|
+
**Per-run narrowing: `--only` and `--ignore`.**
|
|
69
|
+
|
|
70
|
+
- Both tools this is measured against let one run narrow the files without editing a config. This
|
|
71
|
+
tool did not: `--include`/`--exclude` only wrote settings into a config during `init`/`setup`.
|
|
72
|
+
- `--only <globs>` **replaces** the include allow-list for the run; `--ignore <globs>` **adds to** the
|
|
73
|
+
exclude list. The directions differ on purpose — a narrower allow-list is a statement about the
|
|
74
|
+
whole run, while "also ignore this" is naturally cumulative with what the config already denies.
|
|
75
|
+
- Both enter the config digest, so `validate` and `explain` accept them and need them to compare like
|
|
76
|
+
with like; an ignored path is recorded in `skipped[]`, not dropped.
|
|
77
|
+
|
|
78
|
+
Verified: an ignored file disappears from `files[]` and appears in `skipped[]`; `validate` with the
|
|
79
|
+
same flag passes and without it reports drift; `explain --ignore` answers "excluded".
|
|
80
|
+
## 0.14.5
|
|
81
|
+
|
|
82
|
+
**Ten public repositories, three tools, one run.**
|
|
83
|
+
|
|
84
|
+
- `scripts/benchmark-suite.mjs` shallow-clones a list of repositories, packs each with this tool,
|
|
85
|
+
repomix and gitingest, and prints one table (or `--json`). A repository it cannot clone is a skip
|
|
86
|
+
with the reason, never a missing row.
|
|
87
|
+
- `docs/benchmarks.md` carries the run: ten repositories from `jonschlinkert/is-odd` (5,450 tokens)
|
|
88
|
+
to `colinhacks/zod` (1.76M). Nine of ten land within about plus or minus 30% of repomix's own
|
|
89
|
+
token count — expected for two estimators.
|
|
90
|
+
- The tenth is the interesting one: `isaacs/minimatch` holds five 20–25 MB benchmark fixtures.
|
|
91
|
+
repomix emits them (64.8M tokens); our large-file rule emits a bounded preview and records the
|
|
92
|
+
omission, so the pack is 319,879 tokens. The page says exactly that instead of celebrating a ratio
|
|
93
|
+
that a policy difference produced.
|
|
94
|
+
|
|
95
|
+
Verified: the suite runs end to end, and a test pins that an uncloneable input becomes a skip with
|
|
96
|
+
its reason.
|
|
97
|
+
## 0.14.4
|
|
98
|
+
|
|
99
|
+
- The goal log records the 0.14.2-0.14.3 round. `ROADMAP.md` marks item 27 (`--remove-empty-lines`)
|
|
100
|
+
and item 33 (call-site evidence) as shipped, and item 36 as measured three ways on this repository
|
|
101
|
+
with ten public repositories still to run.
|
|
102
|
+
## 0.14.3
|
|
103
|
+
|
|
104
|
+
- **`snapshot_symbol` reports call sites.** The definition says what a symbol is; the call sites say
|
|
105
|
+
who depends on it. Unless `references: false`, the tool scans the parts (never the working tree) for
|
|
106
|
+
the name, bounded by `MAX_SEARCH_BYTES` and `maxReferences` (default 20), and returns path, line and
|
|
107
|
+
the line text — marking the definition line itself.
|
|
108
|
+
- Case-sensitive matching on purpose: a case-insensitive scan of a common word is noise. Import lines
|
|
109
|
+
count as sites, which is why a rename sees them.
|
|
110
|
+
|
|
111
|
+
Verified: a call in `src/auth.ts` is reported with its line, the import line is included, and
|
|
112
|
+
`references: false` skips the scan.
|
|
113
|
+
## 0.14.2
|
|
114
|
+
|
|
115
|
+
- **The comparison harness runs gitingest, and now does.** `--gitingest` reported "not available" here
|
|
116
|
+
because gitingest aborts on Windows with `charmap codec can't encode` while printing its tree; the
|
|
117
|
+
harness sets `PYTHONIOENCODING=utf-8` for that child process and it completes.
|
|
118
|
+
- `docs/benchmarks.md` carries the three-way table from a real run: our full pack 336 files /
|
|
119
|
+
1,060,727 estimated tokens, repomix 335 / 888,168, gitingest 3.12 MB of digest with no token count.
|
|
120
|
+
The caveats say which numbers are comparable (bytes) and which are not (tokenizers).
|
|
121
|
+
|
|
122
|
+
## 0.14.1
|
|
123
|
+
|
|
124
|
+
- The goal log records the second published milestone: 0.14.0 tagged, released on GitHub and
|
|
125
|
+
published to npm (the registry reports `latest = 0.14.0`), after the same few-minute processing
|
|
126
|
+
window that 0.13.0 had. `ROADMAP.md` marks it published.
|
|
127
|
+
|
|
33
128
|
## 0.14.0
|
|
34
129
|
|
|
35
130
|
**The audit now proves the manifest, instead of trusting it.**
|
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.
|
|
213
|
+
npx -y codebase-snapshot@0.15.0 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
|
package/SECURITY.md
CHANGED
|
@@ -6,11 +6,11 @@ Only the latest published release receives security fixes.
|
|
|
6
6
|
|
|
7
7
|
| Version | Supported |
|
|
8
8
|
| :--- | :--- |
|
|
9
|
-
| <!--@majorMinor-->0.
|
|
9
|
+
| <!--@majorMinor-->0.15<!--/@majorMinor-->.x | ✅ |
|
|
10
10
|
| anything older | ❌ |
|
|
11
11
|
|
|
12
12
|
The number line restarted at 0.9.0 when the package moved to the unscoped `codebase-snapshot` name,
|
|
13
|
-
so <!--@majorMinor-->0.
|
|
13
|
+
so <!--@majorMinor-->0.15<!--/@majorMinor-->.x is newer than 4.4.1, not older. That is explained in full in the
|
|
14
14
|
[changelog](CHANGELOG.md#a-note-on-version-numbers).
|
|
15
15
|
|
|
16
16
|
## Reporting a vulnerability
|
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.
|
|
2194
|
+
var GENERATOR_VERSION = "0.15.0";
|
|
2195
2195
|
var SCHEMA_VERSION = "3.0.0";
|
|
2196
2196
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2197
2197
|
function isOurGeneratorName(name) {
|
|
@@ -4352,7 +4352,12 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
|
|
|
4352
4352
|
logCount: resolveLogCount(
|
|
4353
4353
|
cliOptions?.logCount ?? cliOptions?.includeLogs ?? userConfig?.logCount
|
|
4354
4354
|
),
|
|
4355
|
-
|
|
4355
|
+
// `--only` replaces the allow-list for this run; `--ignore` adds to the deny-list. The two
|
|
4356
|
+
// directions are different on purpose: a narrower allow-list is a statement about the whole
|
|
4357
|
+
// run, while "also ignore this" is naturally cumulative with what the config already excludes.
|
|
4358
|
+
include: resolveInclude(
|
|
4359
|
+
cliOptions?.only ?? userConfig?.include
|
|
4360
|
+
),
|
|
4356
4361
|
preset: preset.presetName,
|
|
4357
4362
|
presetExclude,
|
|
4358
4363
|
artifacts,
|
|
@@ -4363,9 +4368,12 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
|
|
|
4363
4368
|
kinds,
|
|
4364
4369
|
// `exclude` is the flag spelling of the same setting; writing it in a config used to
|
|
4365
4370
|
// be ignored without a word.
|
|
4366
|
-
excludePatterns:
|
|
4367
|
-
|
|
4368
|
-
|
|
4371
|
+
excludePatterns: [
|
|
4372
|
+
...resolveExcludePatterns(
|
|
4373
|
+
userConfig?.excludePatterns ?? userConfig?.exclude
|
|
4374
|
+
),
|
|
4375
|
+
...resolveExcludePatterns(cliOptions?.ignore)
|
|
4376
|
+
],
|
|
4369
4377
|
secretRules,
|
|
4370
4378
|
// Extra property rather than a `ResolvedSnapshotConfig` field: the resolved
|
|
4371
4379
|
// shape is owned elsewhere, and every scan reads it through the registry in
|
|
@@ -13872,6 +13880,11 @@ var symbolTool = {
|
|
|
13872
13880
|
name: { type: "string", description: "Symbol name, case-insensitive." },
|
|
13873
13881
|
lines: { type: "integer", description: "Window size around the definition (default 40).", minimum: 5 },
|
|
13874
13882
|
maxFiles: { type: "integer", description: "Cap on files searched (default 5).", minimum: 1 },
|
|
13883
|
+
references: {
|
|
13884
|
+
type: "boolean",
|
|
13885
|
+
description: "Also report call sites: other files whose body mentions the name (default true)."
|
|
13886
|
+
},
|
|
13887
|
+
maxReferences: { type: "integer", description: "Cap on reported call sites (default 20).", minimum: 1 },
|
|
13875
13888
|
root: ROOT_PROPERTY,
|
|
13876
13889
|
outDir: OUT_DIR_PROPERTY
|
|
13877
13890
|
},
|
|
@@ -13882,7 +13895,8 @@ var symbolTool = {
|
|
|
13882
13895
|
type: "object",
|
|
13883
13896
|
properties: {
|
|
13884
13897
|
found: { type: "integer" },
|
|
13885
|
-
matches: { type: "array", items: { type: "object" } }
|
|
13898
|
+
matches: { type: "array", items: { type: "object" } },
|
|
13899
|
+
references: { type: "array", items: { type: "object" } }
|
|
13886
13900
|
}
|
|
13887
13901
|
},
|
|
13888
13902
|
annotations: READ_ONLY,
|
|
@@ -13935,8 +13949,44 @@ var symbolTool = {
|
|
|
13935
13949
|
structured: { found: 0, matches: [] }
|
|
13936
13950
|
};
|
|
13937
13951
|
}
|
|
13938
|
-
const
|
|
13939
|
-
|
|
13952
|
+
const callSites = [];
|
|
13953
|
+
if (args.references !== false) {
|
|
13954
|
+
const limit = Math.max(1, typeof args.maxReferences === "number" ? args.maxReferences : 20);
|
|
13955
|
+
const definitionKeys = new Set(matches.map((match) => match.path + ":" + match.line));
|
|
13956
|
+
const word = new RegExp("\\b" + name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "\\b");
|
|
13957
|
+
const parts = /* @__PURE__ */ new Map();
|
|
13958
|
+
let scanned = 0;
|
|
13959
|
+
for (const file of read.manifest.files) {
|
|
13960
|
+
if (callSites.length >= limit) break;
|
|
13961
|
+
const partPath = partPathFor(workspace, file.part);
|
|
13962
|
+
if (partPath === null) continue;
|
|
13963
|
+
let partText = parts.get(partPath);
|
|
13964
|
+
if (partText === void 0) {
|
|
13965
|
+
try {
|
|
13966
|
+
partText = fs18.readFileSync(partPath, "utf8");
|
|
13967
|
+
} catch {
|
|
13968
|
+
continue;
|
|
13969
|
+
}
|
|
13970
|
+
parts.set(partPath, partText);
|
|
13971
|
+
}
|
|
13972
|
+
if (scanned > MAX_SEARCH_BYTES) break;
|
|
13973
|
+
scanned += Buffer.byteLength(partText, "utf8");
|
|
13974
|
+
const section = findSection(parsePartSections(partText), file.relativePath);
|
|
13975
|
+
if (section === null) continue;
|
|
13976
|
+
const bodyLines = section.body.split("\n");
|
|
13977
|
+
for (let index = 0; index < bodyLines.length && callSites.length < limit; index += 1) {
|
|
13978
|
+
if (!word.test(bodyLines[index])) continue;
|
|
13979
|
+
callSites.push({
|
|
13980
|
+
path: file.relativePath,
|
|
13981
|
+
line: index + 1,
|
|
13982
|
+
text: bodyLines[index].trim().slice(0, 200),
|
|
13983
|
+
definition: definitionKeys.has(file.relativePath + ":" + (index + 1))
|
|
13984
|
+
});
|
|
13985
|
+
}
|
|
13986
|
+
}
|
|
13987
|
+
}
|
|
13988
|
+
const text2 = matches.map((match) => "### " + match.path + " (" + match.part + ", line " + match.line + ")\n" + match.text).join("\n\n") + (args.references === false ? "" : "\n\n" + (callSites.length === 0 ? "No call site was found in the snapshot." : "Call sites (" + callSites.length + "):\n" + callSites.map((site) => " " + site.path + ":" + site.line + " " + site.text).join("\n")));
|
|
13989
|
+
return { text: text2, structured: { found: matches.length, matches, references: callSites } };
|
|
13940
13990
|
}
|
|
13941
13991
|
};
|
|
13942
13992
|
var contextTool = {
|
|
@@ -15240,6 +15290,8 @@ var VALIDATE_OPTIONS = [
|
|
|
15240
15290
|
"sarif",
|
|
15241
15291
|
"strip-comments",
|
|
15242
15292
|
"remove-empty-lines",
|
|
15293
|
+
"only",
|
|
15294
|
+
"ignore",
|
|
15243
15295
|
"pack",
|
|
15244
15296
|
// The opt-in reports change the artifact selection the manifest records, so validate must accept
|
|
15245
15297
|
// them to compare like with like: without the flags it reports the selection as drift.
|
|
@@ -15275,6 +15327,8 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
15275
15327
|
generate: [
|
|
15276
15328
|
"strip-comments",
|
|
15277
15329
|
"remove-empty-lines",
|
|
15330
|
+
"only",
|
|
15331
|
+
"ignore",
|
|
15278
15332
|
"workspace",
|
|
15279
15333
|
"budget-tokens",
|
|
15280
15334
|
"sign",
|
|
@@ -15355,6 +15409,10 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
15355
15409
|
// Removed rather than implemented, because a flag that parses and does nothing is the defect
|
|
15356
15410
|
// this table exists to prevent.
|
|
15357
15411
|
"large-file-bytes",
|
|
15412
|
+
// `--only` and `--ignore` change which files are scanned, so they change what `explain` can say
|
|
15413
|
+
// about a path; without them the answer for an ignored file is "included: true".
|
|
15414
|
+
"only",
|
|
15415
|
+
"ignore",
|
|
15358
15416
|
"include-sensitive-files",
|
|
15359
15417
|
"no-config",
|
|
15360
15418
|
"discovery",
|
|
@@ -15896,6 +15954,18 @@ function buildAgentContract() {
|
|
|
15896
15954
|
appliesTo: optionAppliesTo("allow-origin"),
|
|
15897
15955
|
summary: "mcp --http: comma-separated extra CORS origins. Loopback origins are always allowed."
|
|
15898
15956
|
},
|
|
15957
|
+
{
|
|
15958
|
+
flag: "--only",
|
|
15959
|
+
type: "string",
|
|
15960
|
+
summary: "Comma-separated globs to include: overrides the config include list for this run.",
|
|
15961
|
+
appliesTo: optionAppliesTo("only")
|
|
15962
|
+
},
|
|
15963
|
+
{
|
|
15964
|
+
flag: "--ignore",
|
|
15965
|
+
type: "string",
|
|
15966
|
+
summary: "Comma-separated globs to exclude, added to the config exclude list for this run.",
|
|
15967
|
+
appliesTo: optionAppliesTo("ignore")
|
|
15968
|
+
},
|
|
15899
15969
|
{
|
|
15900
15970
|
flag: "--remove-empty-lines",
|
|
15901
15971
|
type: "boolean",
|
|
@@ -20930,6 +21000,8 @@ var CLI_OPTIONS = {
|
|
|
20930
21000
|
workspace: { type: "string" },
|
|
20931
21001
|
"strip-comments": { type: "boolean" },
|
|
20932
21002
|
"remove-empty-lines": { type: "boolean" },
|
|
21003
|
+
only: { type: "string" },
|
|
21004
|
+
ignore: { type: "string" },
|
|
20933
21005
|
"all-members": { type: "boolean" },
|
|
20934
21006
|
help: { type: "boolean", short: "h" },
|
|
20935
21007
|
version: { type: "boolean", short: "v" }
|
|
@@ -21378,6 +21450,8 @@ function parseCliArgs(argv) {
|
|
|
21378
21450
|
workspace: values.workspace === void 0 ? void 0 : String(values.workspace),
|
|
21379
21451
|
stripComments: values["strip-comments"] === true ? true : void 0,
|
|
21380
21452
|
removeEmptyLines: values["remove-empty-lines"] === true ? true : void 0,
|
|
21453
|
+
only: values.only === void 0 ? void 0 : String(values.only).split(",").map((item) => item.trim()).filter(Boolean),
|
|
21454
|
+
ignore: values.ignore === void 0 ? void 0 : String(values.ignore).split(",").map((item) => item.trim()).filter(Boolean),
|
|
21381
21455
|
allMembers: values["all-members"] === true ? true : void 0,
|
|
21382
21456
|
budgetTokens: values["budget-tokens"] === void 0 ? void 0 : parsePositiveInteger(values["budget-tokens"], "budget-tokens", 500),
|
|
21383
21457
|
delta: values.delta === void 0 ? void 0 : String(values.delta),
|
|
@@ -22079,6 +22153,8 @@ ${USAGE}
|
|
|
22079
22153
|
...invocation.tokenTree === true ? { tokenTree: true } : {},
|
|
22080
22154
|
...invocation.stripComments === true ? { stripComments: true } : {},
|
|
22081
22155
|
...invocation.removeEmptyLines === true ? { removeEmptyLines: true } : {},
|
|
22156
|
+
...invocation.only === void 0 ? {} : { only: invocation.only },
|
|
22157
|
+
...invocation.ignore === void 0 ? {} : { ignore: invocation.ignore },
|
|
22082
22158
|
...invocation.pack === void 0 ? {} : { pack: invocation.pack },
|
|
22083
22159
|
brief: invocation.brief,
|
|
22084
22160
|
promptTask: invocation.promptTask,
|
|
@@ -3994,7 +3994,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
3994
3994
|
|
|
3995
3995
|
// src/version.ts
|
|
3996
3996
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
3997
|
-
var GENERATOR_VERSION = "0.
|
|
3997
|
+
var GENERATOR_VERSION = "0.15.0";
|
|
3998
3998
|
var SCHEMA_VERSION = "3.0.0";
|
|
3999
3999
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
4000
4000
|
function isOurGeneratorName(name) {
|
|
@@ -5888,7 +5888,12 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
|
|
|
5888
5888
|
logCount: resolveLogCount(
|
|
5889
5889
|
cliOptions?.logCount ?? cliOptions?.includeLogs ?? userConfig?.logCount
|
|
5890
5890
|
),
|
|
5891
|
-
|
|
5891
|
+
// `--only` replaces the allow-list for this run; `--ignore` adds to the deny-list. The two
|
|
5892
|
+
// directions are different on purpose: a narrower allow-list is a statement about the whole
|
|
5893
|
+
// run, while "also ignore this" is naturally cumulative with what the config already excludes.
|
|
5894
|
+
include: resolveInclude(
|
|
5895
|
+
cliOptions?.only ?? userConfig?.include
|
|
5896
|
+
),
|
|
5892
5897
|
preset: preset.presetName,
|
|
5893
5898
|
presetExclude,
|
|
5894
5899
|
artifacts,
|
|
@@ -5899,9 +5904,12 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
|
|
|
5899
5904
|
kinds,
|
|
5900
5905
|
// `exclude` is the flag spelling of the same setting; writing it in a config used to
|
|
5901
5906
|
// be ignored without a word.
|
|
5902
|
-
excludePatterns:
|
|
5903
|
-
|
|
5904
|
-
|
|
5907
|
+
excludePatterns: [
|
|
5908
|
+
...resolveExcludePatterns(
|
|
5909
|
+
userConfig?.excludePatterns ?? userConfig?.exclude
|
|
5910
|
+
),
|
|
5911
|
+
...resolveExcludePatterns(cliOptions?.ignore)
|
|
5912
|
+
],
|
|
5905
5913
|
secretRules,
|
|
5906
5914
|
// Extra property rather than a `ResolvedSnapshotConfig` field: the resolved
|
|
5907
5915
|
// shape is owned elsewhere, and every scan reads it through the registry in
|
|
@@ -12262,6 +12270,11 @@ var symbolTool = {
|
|
|
12262
12270
|
name: { type: "string", description: "Symbol name, case-insensitive." },
|
|
12263
12271
|
lines: { type: "integer", description: "Window size around the definition (default 40).", minimum: 5 },
|
|
12264
12272
|
maxFiles: { type: "integer", description: "Cap on files searched (default 5).", minimum: 1 },
|
|
12273
|
+
references: {
|
|
12274
|
+
type: "boolean",
|
|
12275
|
+
description: "Also report call sites: other files whose body mentions the name (default true)."
|
|
12276
|
+
},
|
|
12277
|
+
maxReferences: { type: "integer", description: "Cap on reported call sites (default 20).", minimum: 1 },
|
|
12265
12278
|
root: ROOT_PROPERTY,
|
|
12266
12279
|
outDir: OUT_DIR_PROPERTY
|
|
12267
12280
|
},
|
|
@@ -12272,7 +12285,8 @@ var symbolTool = {
|
|
|
12272
12285
|
type: "object",
|
|
12273
12286
|
properties: {
|
|
12274
12287
|
found: { type: "integer" },
|
|
12275
|
-
matches: { type: "array", items: { type: "object" } }
|
|
12288
|
+
matches: { type: "array", items: { type: "object" } },
|
|
12289
|
+
references: { type: "array", items: { type: "object" } }
|
|
12276
12290
|
}
|
|
12277
12291
|
},
|
|
12278
12292
|
annotations: READ_ONLY,
|
|
@@ -12325,8 +12339,44 @@ var symbolTool = {
|
|
|
12325
12339
|
structured: { found: 0, matches: [] }
|
|
12326
12340
|
};
|
|
12327
12341
|
}
|
|
12328
|
-
const
|
|
12329
|
-
|
|
12342
|
+
const callSites = [];
|
|
12343
|
+
if (args.references !== false) {
|
|
12344
|
+
const limit = Math.max(1, typeof args.maxReferences === "number" ? args.maxReferences : 20);
|
|
12345
|
+
const definitionKeys = new Set(matches.map((match) => match.path + ":" + match.line));
|
|
12346
|
+
const word = new RegExp("\\b" + name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "\\b");
|
|
12347
|
+
const parts = /* @__PURE__ */ new Map();
|
|
12348
|
+
let scanned = 0;
|
|
12349
|
+
for (const file of read.manifest.files) {
|
|
12350
|
+
if (callSites.length >= limit) break;
|
|
12351
|
+
const partPath = partPathFor(workspace, file.part);
|
|
12352
|
+
if (partPath === null) continue;
|
|
12353
|
+
let partText = parts.get(partPath);
|
|
12354
|
+
if (partText === void 0) {
|
|
12355
|
+
try {
|
|
12356
|
+
partText = fs24.readFileSync(partPath, "utf8");
|
|
12357
|
+
} catch {
|
|
12358
|
+
continue;
|
|
12359
|
+
}
|
|
12360
|
+
parts.set(partPath, partText);
|
|
12361
|
+
}
|
|
12362
|
+
if (scanned > MAX_SEARCH_BYTES) break;
|
|
12363
|
+
scanned += Buffer.byteLength(partText, "utf8");
|
|
12364
|
+
const section = findSection(parsePartSections(partText), file.relativePath);
|
|
12365
|
+
if (section === null) continue;
|
|
12366
|
+
const bodyLines = section.body.split("\n");
|
|
12367
|
+
for (let index = 0; index < bodyLines.length && callSites.length < limit; index += 1) {
|
|
12368
|
+
if (!word.test(bodyLines[index])) continue;
|
|
12369
|
+
callSites.push({
|
|
12370
|
+
path: file.relativePath,
|
|
12371
|
+
line: index + 1,
|
|
12372
|
+
text: bodyLines[index].trim().slice(0, 200),
|
|
12373
|
+
definition: definitionKeys.has(file.relativePath + ":" + (index + 1))
|
|
12374
|
+
});
|
|
12375
|
+
}
|
|
12376
|
+
}
|
|
12377
|
+
}
|
|
12378
|
+
const text2 = matches.map((match) => "### " + match.path + " (" + match.part + ", line " + match.line + ")\n" + match.text).join("\n\n") + (args.references === false ? "" : "\n\n" + (callSites.length === 0 ? "No call site was found in the snapshot." : "Call sites (" + callSites.length + "):\n" + callSites.map((site) => " " + site.path + ":" + site.line + " " + site.text).join("\n")));
|
|
12379
|
+
return { text: text2, structured: { found: matches.length, matches, references: callSites } };
|
|
12330
12380
|
}
|
|
12331
12381
|
};
|
|
12332
12382
|
var contextTool = {
|
|
@@ -13630,6 +13680,8 @@ var VALIDATE_OPTIONS = [
|
|
|
13630
13680
|
"sarif",
|
|
13631
13681
|
"strip-comments",
|
|
13632
13682
|
"remove-empty-lines",
|
|
13683
|
+
"only",
|
|
13684
|
+
"ignore",
|
|
13633
13685
|
"pack",
|
|
13634
13686
|
// The opt-in reports change the artifact selection the manifest records, so validate must accept
|
|
13635
13687
|
// them to compare like with like: without the flags it reports the selection as drift.
|
|
@@ -13665,6 +13717,8 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
13665
13717
|
generate: [
|
|
13666
13718
|
"strip-comments",
|
|
13667
13719
|
"remove-empty-lines",
|
|
13720
|
+
"only",
|
|
13721
|
+
"ignore",
|
|
13668
13722
|
"workspace",
|
|
13669
13723
|
"budget-tokens",
|
|
13670
13724
|
"sign",
|
|
@@ -13745,6 +13799,10 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
13745
13799
|
// Removed rather than implemented, because a flag that parses and does nothing is the defect
|
|
13746
13800
|
// this table exists to prevent.
|
|
13747
13801
|
"large-file-bytes",
|
|
13802
|
+
// `--only` and `--ignore` change which files are scanned, so they change what `explain` can say
|
|
13803
|
+
// about a path; without them the answer for an ignored file is "included: true".
|
|
13804
|
+
"only",
|
|
13805
|
+
"ignore",
|
|
13748
13806
|
"include-sensitive-files",
|
|
13749
13807
|
"no-config",
|
|
13750
13808
|
"discovery",
|
|
@@ -14286,6 +14344,18 @@ function buildAgentContract() {
|
|
|
14286
14344
|
appliesTo: optionAppliesTo("allow-origin"),
|
|
14287
14345
|
summary: "mcp --http: comma-separated extra CORS origins. Loopback origins are always allowed."
|
|
14288
14346
|
},
|
|
14347
|
+
{
|
|
14348
|
+
flag: "--only",
|
|
14349
|
+
type: "string",
|
|
14350
|
+
summary: "Comma-separated globs to include: overrides the config include list for this run.",
|
|
14351
|
+
appliesTo: optionAppliesTo("only")
|
|
14352
|
+
},
|
|
14353
|
+
{
|
|
14354
|
+
flag: "--ignore",
|
|
14355
|
+
type: "string",
|
|
14356
|
+
summary: "Comma-separated globs to exclude, added to the config exclude list for this run.",
|
|
14357
|
+
appliesTo: optionAppliesTo("ignore")
|
|
14358
|
+
},
|
|
14289
14359
|
{
|
|
14290
14360
|
flag: "--remove-empty-lines",
|
|
14291
14361
|
type: "boolean",
|
package/dist/cli.cjs
CHANGED
|
@@ -2221,7 +2221,7 @@ function applySpansKeepingQuotes(line, spans) {
|
|
|
2221
2221
|
|
|
2222
2222
|
// src/version.ts
|
|
2223
2223
|
var GENERATOR_NAME = "codebase-snapshot";
|
|
2224
|
-
var GENERATOR_VERSION = "0.
|
|
2224
|
+
var GENERATOR_VERSION = "0.15.0";
|
|
2225
2225
|
var SCHEMA_VERSION = "3.0.0";
|
|
2226
2226
|
var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
|
|
2227
2227
|
function isOurGeneratorName(name) {
|
|
@@ -4367,7 +4367,12 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
|
|
|
4367
4367
|
logCount: resolveLogCount(
|
|
4368
4368
|
cliOptions?.logCount ?? cliOptions?.includeLogs ?? userConfig?.logCount
|
|
4369
4369
|
),
|
|
4370
|
-
|
|
4370
|
+
// `--only` replaces the allow-list for this run; `--ignore` adds to the deny-list. The two
|
|
4371
|
+
// directions are different on purpose: a narrower allow-list is a statement about the whole
|
|
4372
|
+
// run, while "also ignore this" is naturally cumulative with what the config already excludes.
|
|
4373
|
+
include: resolveInclude(
|
|
4374
|
+
cliOptions?.only ?? userConfig?.include
|
|
4375
|
+
),
|
|
4371
4376
|
preset: preset.presetName,
|
|
4372
4377
|
presetExclude,
|
|
4373
4378
|
artifacts,
|
|
@@ -4378,9 +4383,12 @@ function resolveConfig(userConfig, cliOptions, baseDir) {
|
|
|
4378
4383
|
kinds,
|
|
4379
4384
|
// `exclude` is the flag spelling of the same setting; writing it in a config used to
|
|
4380
4385
|
// be ignored without a word.
|
|
4381
|
-
excludePatterns:
|
|
4382
|
-
|
|
4383
|
-
|
|
4386
|
+
excludePatterns: [
|
|
4387
|
+
...resolveExcludePatterns(
|
|
4388
|
+
userConfig?.excludePatterns ?? userConfig?.exclude
|
|
4389
|
+
),
|
|
4390
|
+
...resolveExcludePatterns(cliOptions?.ignore)
|
|
4391
|
+
],
|
|
4384
4392
|
secretRules,
|
|
4385
4393
|
// Extra property rather than a `ResolvedSnapshotConfig` field: the resolved
|
|
4386
4394
|
// shape is owned elsewhere, and every scan reads it through the registry in
|
|
@@ -13762,6 +13770,11 @@ var symbolTool = {
|
|
|
13762
13770
|
name: { type: "string", description: "Symbol name, case-insensitive." },
|
|
13763
13771
|
lines: { type: "integer", description: "Window size around the definition (default 40).", minimum: 5 },
|
|
13764
13772
|
maxFiles: { type: "integer", description: "Cap on files searched (default 5).", minimum: 1 },
|
|
13773
|
+
references: {
|
|
13774
|
+
type: "boolean",
|
|
13775
|
+
description: "Also report call sites: other files whose body mentions the name (default true)."
|
|
13776
|
+
},
|
|
13777
|
+
maxReferences: { type: "integer", description: "Cap on reported call sites (default 20).", minimum: 1 },
|
|
13765
13778
|
root: ROOT_PROPERTY,
|
|
13766
13779
|
outDir: OUT_DIR_PROPERTY
|
|
13767
13780
|
},
|
|
@@ -13772,7 +13785,8 @@ var symbolTool = {
|
|
|
13772
13785
|
type: "object",
|
|
13773
13786
|
properties: {
|
|
13774
13787
|
found: { type: "integer" },
|
|
13775
|
-
matches: { type: "array", items: { type: "object" } }
|
|
13788
|
+
matches: { type: "array", items: { type: "object" } },
|
|
13789
|
+
references: { type: "array", items: { type: "object" } }
|
|
13776
13790
|
}
|
|
13777
13791
|
},
|
|
13778
13792
|
annotations: READ_ONLY,
|
|
@@ -13825,8 +13839,44 @@ var symbolTool = {
|
|
|
13825
13839
|
structured: { found: 0, matches: [] }
|
|
13826
13840
|
};
|
|
13827
13841
|
}
|
|
13828
|
-
const
|
|
13829
|
-
|
|
13842
|
+
const callSites = [];
|
|
13843
|
+
if (args.references !== false) {
|
|
13844
|
+
const limit = Math.max(1, typeof args.maxReferences === "number" ? args.maxReferences : 20);
|
|
13845
|
+
const definitionKeys = new Set(matches.map((match) => match.path + ":" + match.line));
|
|
13846
|
+
const word = new RegExp("\\b" + name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "\\b");
|
|
13847
|
+
const parts = /* @__PURE__ */ new Map();
|
|
13848
|
+
let scanned = 0;
|
|
13849
|
+
for (const file of read.manifest.files) {
|
|
13850
|
+
if (callSites.length >= limit) break;
|
|
13851
|
+
const partPath = partPathFor(workspace, file.part);
|
|
13852
|
+
if (partPath === null) continue;
|
|
13853
|
+
let partText = parts.get(partPath);
|
|
13854
|
+
if (partText === void 0) {
|
|
13855
|
+
try {
|
|
13856
|
+
partText = fs24__namespace.readFileSync(partPath, "utf8");
|
|
13857
|
+
} catch {
|
|
13858
|
+
continue;
|
|
13859
|
+
}
|
|
13860
|
+
parts.set(partPath, partText);
|
|
13861
|
+
}
|
|
13862
|
+
if (scanned > MAX_SEARCH_BYTES) break;
|
|
13863
|
+
scanned += Buffer.byteLength(partText, "utf8");
|
|
13864
|
+
const section = findSection(parsePartSections(partText), file.relativePath);
|
|
13865
|
+
if (section === null) continue;
|
|
13866
|
+
const bodyLines = section.body.split("\n");
|
|
13867
|
+
for (let index = 0; index < bodyLines.length && callSites.length < limit; index += 1) {
|
|
13868
|
+
if (!word.test(bodyLines[index])) continue;
|
|
13869
|
+
callSites.push({
|
|
13870
|
+
path: file.relativePath,
|
|
13871
|
+
line: index + 1,
|
|
13872
|
+
text: bodyLines[index].trim().slice(0, 200),
|
|
13873
|
+
definition: definitionKeys.has(file.relativePath + ":" + (index + 1))
|
|
13874
|
+
});
|
|
13875
|
+
}
|
|
13876
|
+
}
|
|
13877
|
+
}
|
|
13878
|
+
const text2 = matches.map((match) => "### " + match.path + " (" + match.part + ", line " + match.line + ")\n" + match.text).join("\n\n") + (args.references === false ? "" : "\n\n" + (callSites.length === 0 ? "No call site was found in the snapshot." : "Call sites (" + callSites.length + "):\n" + callSites.map((site) => " " + site.path + ":" + site.line + " " + site.text).join("\n")));
|
|
13879
|
+
return { text: text2, structured: { found: matches.length, matches, references: callSites } };
|
|
13830
13880
|
}
|
|
13831
13881
|
};
|
|
13832
13882
|
var contextTool = {
|
|
@@ -15130,6 +15180,8 @@ var VALIDATE_OPTIONS = [
|
|
|
15130
15180
|
"sarif",
|
|
15131
15181
|
"strip-comments",
|
|
15132
15182
|
"remove-empty-lines",
|
|
15183
|
+
"only",
|
|
15184
|
+
"ignore",
|
|
15133
15185
|
"pack",
|
|
15134
15186
|
// The opt-in reports change the artifact selection the manifest records, so validate must accept
|
|
15135
15187
|
// them to compare like with like: without the flags it reports the selection as drift.
|
|
@@ -15165,6 +15217,8 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
15165
15217
|
generate: [
|
|
15166
15218
|
"strip-comments",
|
|
15167
15219
|
"remove-empty-lines",
|
|
15220
|
+
"only",
|
|
15221
|
+
"ignore",
|
|
15168
15222
|
"workspace",
|
|
15169
15223
|
"budget-tokens",
|
|
15170
15224
|
"sign",
|
|
@@ -15245,6 +15299,10 @@ var COMMAND_OPTION_SCOPE = {
|
|
|
15245
15299
|
// Removed rather than implemented, because a flag that parses and does nothing is the defect
|
|
15246
15300
|
// this table exists to prevent.
|
|
15247
15301
|
"large-file-bytes",
|
|
15302
|
+
// `--only` and `--ignore` change which files are scanned, so they change what `explain` can say
|
|
15303
|
+
// about a path; without them the answer for an ignored file is "included: true".
|
|
15304
|
+
"only",
|
|
15305
|
+
"ignore",
|
|
15248
15306
|
"include-sensitive-files",
|
|
15249
15307
|
"no-config",
|
|
15250
15308
|
"discovery",
|
|
@@ -15786,6 +15844,18 @@ function buildAgentContract() {
|
|
|
15786
15844
|
appliesTo: optionAppliesTo("allow-origin"),
|
|
15787
15845
|
summary: "mcp --http: comma-separated extra CORS origins. Loopback origins are always allowed."
|
|
15788
15846
|
},
|
|
15847
|
+
{
|
|
15848
|
+
flag: "--only",
|
|
15849
|
+
type: "string",
|
|
15850
|
+
summary: "Comma-separated globs to include: overrides the config include list for this run.",
|
|
15851
|
+
appliesTo: optionAppliesTo("only")
|
|
15852
|
+
},
|
|
15853
|
+
{
|
|
15854
|
+
flag: "--ignore",
|
|
15855
|
+
type: "string",
|
|
15856
|
+
summary: "Comma-separated globs to exclude, added to the config exclude list for this run.",
|
|
15857
|
+
appliesTo: optionAppliesTo("ignore")
|
|
15858
|
+
},
|
|
15789
15859
|
{
|
|
15790
15860
|
flag: "--remove-empty-lines",
|
|
15791
15861
|
type: "boolean",
|
|
@@ -20791,6 +20861,8 @@ var CLI_OPTIONS = {
|
|
|
20791
20861
|
workspace: { type: "string" },
|
|
20792
20862
|
"strip-comments": { type: "boolean" },
|
|
20793
20863
|
"remove-empty-lines": { type: "boolean" },
|
|
20864
|
+
only: { type: "string" },
|
|
20865
|
+
ignore: { type: "string" },
|
|
20794
20866
|
"all-members": { type: "boolean" },
|
|
20795
20867
|
help: { type: "boolean", short: "h" },
|
|
20796
20868
|
version: { type: "boolean", short: "v" }
|
|
@@ -21239,6 +21311,8 @@ function parseCliArgs(argv) {
|
|
|
21239
21311
|
workspace: values.workspace === void 0 ? void 0 : String(values.workspace),
|
|
21240
21312
|
stripComments: values["strip-comments"] === true ? true : void 0,
|
|
21241
21313
|
removeEmptyLines: values["remove-empty-lines"] === true ? true : void 0,
|
|
21314
|
+
only: values.only === void 0 ? void 0 : String(values.only).split(",").map((item) => item.trim()).filter(Boolean),
|
|
21315
|
+
ignore: values.ignore === void 0 ? void 0 : String(values.ignore).split(",").map((item) => item.trim()).filter(Boolean),
|
|
21242
21316
|
allMembers: values["all-members"] === true ? true : void 0,
|
|
21243
21317
|
budgetTokens: values["budget-tokens"] === void 0 ? void 0 : parsePositiveInteger(values["budget-tokens"], "budget-tokens", 500),
|
|
21244
21318
|
delta: values.delta === void 0 ? void 0 : String(values.delta),
|
|
@@ -21940,6 +22014,8 @@ ${USAGE}
|
|
|
21940
22014
|
...invocation.tokenTree === true ? { tokenTree: true } : {},
|
|
21941
22015
|
...invocation.stripComments === true ? { stripComments: true } : {},
|
|
21942
22016
|
...invocation.removeEmptyLines === true ? { removeEmptyLines: true } : {},
|
|
22017
|
+
...invocation.only === void 0 ? {} : { only: invocation.only },
|
|
22018
|
+
...invocation.ignore === void 0 ? {} : { ignore: invocation.ignore },
|
|
21943
22019
|
...invocation.pack === void 0 ? {} : { pack: invocation.pack },
|
|
21944
22020
|
brief: invocation.brief,
|
|
21945
22021
|
promptTask: invocation.promptTask,
|