codebase-snapshot 0.9.8 → 0.9.12
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 +536 -0
- package/README.md +3 -3
- package/dist/bin.js +5262 -3459
- package/dist/{chunk-C24OAT6T.js → chunk-3H45YMBG.js} +1867 -509
- package/dist/{chunk-RQKXZOD7.js → chunk-5OR3WVPW.js} +366 -84
- package/dist/cli.cjs +5264 -3481
- package/dist/cli.d.cts +282 -3
- package/dist/cli.d.ts +282 -3
- package/dist/cli.js +181 -39
- package/dist/generate-worker-D5Xgh27c.d.cts +57 -0
- package/dist/generate-worker-D5Xgh27c.d.ts +57 -0
- package/dist/index.cjs +1820 -506
- package/dist/index.d.cts +310 -5
- package/dist/index.d.ts +310 -5
- package/dist/index.js +1 -3
- package/dist/mcp.cjs +5670 -4877
- package/dist/mcp.d.cts +70 -2
- package/dist/mcp.d.ts +70 -2
- package/dist/mcp.js +2 -4
- package/dist/{types-Ca4PmkiQ.d.cts → types-CTewen3J.d.cts} +115 -2
- package/dist/{types-Ca4PmkiQ.d.ts → types-CTewen3J.d.ts} +115 -2
- package/docs/agent.md +1 -1
- package/docs/cli.md +27 -4
- package/docs/configuration.md +5 -0
- package/docs/how-to-feed-a-repo-to-claude.md +61 -0
- package/docs/mcp.md +23 -10
- package/docs/output.md +36 -4
- package/docs/stale-context-is-your-bug.md +13 -0
- package/docs/vs-repomix.md +1 -1
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions,
|
|
2
|
-
export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as SummaryQuality, r as ValidationDrift } from './types-
|
|
1
|
+
import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, c as SnapshotConfig, B as ByteSize, C as CliOptions, P as PartMetadata, F as FileEntry, T as TextEncoding, d as SecretFinding, V as ValidationResult, e as Manifest, A as ArtifactSelection } from './types-CTewen3J.js';
|
|
2
|
+
export { f as BudgetConfig, H as HooksConfig, I as InclusionMode, g as ManifestArtifact, h as ManifestConfigSnapshot, i as ManifestIndexes, j as ManifestTotals, k as Mode, O as OutputFormat, l as PartFileEntry, m as ResolvedArtifacts, n as ResolvedBudgets, o as SecretRuleInput, p as SkipReason, q as SummaryQuality, r as ValidationDrift } from './types-CTewen3J.js';
|
|
3
|
+
export { w as workerEntry } from './generate-worker-D5Xgh27c.js';
|
|
4
|
+
|
|
5
|
+
interface GitInfo {
|
|
6
|
+
branch: string;
|
|
7
|
+
commit: string;
|
|
8
|
+
isDirty: boolean;
|
|
9
|
+
}
|
|
3
10
|
|
|
4
11
|
interface CollectOptions {
|
|
5
12
|
/**
|
|
@@ -39,7 +46,23 @@ interface CollectResult {
|
|
|
39
46
|
files: string[];
|
|
40
47
|
skipped: SkipRecord[];
|
|
41
48
|
}
|
|
49
|
+
declare function getGitInfo(cwd: string, fallbackBranch?: string): GitInfo;
|
|
42
50
|
declare function isSensitivePath(relativePath: string): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Reports a secret-shaped value in a *path*.
|
|
53
|
+
*
|
|
54
|
+
* File names are emitted verbatim into `project-tree.md`, `navigation.md`,
|
|
55
|
+
* `manifest.files[].relativePath`, the `## Skipped` table of the audit and
|
|
56
|
+
* `skipped[].path`, so a token in a name leaks exactly like a token in a body —
|
|
57
|
+
* and content redaction never sees it.
|
|
58
|
+
*
|
|
59
|
+
* `extraRules` are the caller's custom patterns. A `valueGroup` rule is masked
|
|
60
|
+
* whole here: a path has no `key: value` context to anchor on.
|
|
61
|
+
*/
|
|
62
|
+
declare function findSecretInPath(relativePath: string, extraRules?: readonly SecretRule[]): {
|
|
63
|
+
rules: string[];
|
|
64
|
+
masked: string;
|
|
65
|
+
} | null;
|
|
43
66
|
/**
|
|
44
67
|
* Translates a glob (`**`, `*`, `?`, `{a,b}`, `[abc]`) into a RegExp. A pattern
|
|
45
68
|
* without a leading `/` matches at any depth, mirroring `.gitignore` semantics.
|
|
@@ -137,6 +160,16 @@ interface ConfigLoadResult {
|
|
|
137
160
|
}
|
|
138
161
|
/** True when this Node can `import()` a `.ts` file natively (type stripping). */
|
|
139
162
|
declare function supportsTypeScriptImports(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Every key a configuration file may carry.
|
|
165
|
+
*
|
|
166
|
+
* This is `SnapshotConfig` plus the spellings that are read through casts: `discovery`
|
|
167
|
+
* (validated separately), `exclude` (the flag spelling of `excludePatterns`) and
|
|
168
|
+
* `secretRules` (the library spelling of a rule list, accepted by `resolveConfig` and
|
|
169
|
+
* therefore needed here too — omitting it made a config file that used it fail with
|
|
170
|
+
* "unknown setting(s): secretRules" while the same key worked when passed in code).
|
|
171
|
+
*/
|
|
172
|
+
declare const CONFIG_KEYS: ReadonlySet<string>;
|
|
140
173
|
/**
|
|
141
174
|
* Loads the first usable config file from `cwd`.
|
|
142
175
|
*
|
|
@@ -148,6 +181,16 @@ declare function loadConfigFileDetailed(cwd: string): Promise<ConfigLoadResult>;
|
|
|
148
181
|
declare function loadConfigFile(cwd: string): Promise<SnapshotConfig | null>;
|
|
149
182
|
/** Smallest usable part budget: a part header plus one section must fit. */
|
|
150
183
|
declare const MIN_MAX_PART_BYTES = 4096;
|
|
184
|
+
/**
|
|
185
|
+
* The same floor expressed in the unit `--max-part-tokens` is written in.
|
|
186
|
+
*
|
|
187
|
+
* `bytesForTokens` multiplies by four, so 1024 tokens and 4096 bytes are the same budget. A
|
|
188
|
+
* smaller token budget used to be raised to the floor without a word: `--max-part-tokens 200`
|
|
189
|
+
* was accepted, reported as 1024 tokens, and the setting the user wrote never applied. Rule 1
|
|
190
|
+
* says an impossible budget is an error, so this is the number the CLI and the config both
|
|
191
|
+
* refuse to go below.
|
|
192
|
+
*/
|
|
193
|
+
declare const MIN_MAX_PART_TOKENS: number;
|
|
151
194
|
/** Every artifact this package can write, in the order it is written. */
|
|
152
195
|
declare const ARTIFACT_NAMES: readonly ["readme", "manifest", "parts", "navigation", "projectTree", "audit", "monolith"];
|
|
153
196
|
/**
|
|
@@ -173,8 +216,27 @@ declare function resolveConfig(userConfig: SnapshotConfig | null, cliOptions?: P
|
|
|
173
216
|
* `"src/app/**"` now means "exactly `src/app` or below": the previous
|
|
174
217
|
* implementation stripped `**` **and** the trailing slash, so the pattern also
|
|
175
218
|
* matched `src/apple/` and `src/application/`.
|
|
219
|
+
*
|
|
220
|
+
* Everything else is answered by {@link matchesExclude}, which is the one implementation of
|
|
221
|
+
* "does this pattern select this path": glob metacharacters (including `{a,b}` and `[abc]`,
|
|
222
|
+
* which used to be tested for `*`/`?` only and then silently compared as literal text) go
|
|
223
|
+
* through the glob translator, and a plain pattern means a whole **path segment** sequence
|
|
224
|
+
* rather than a substring. `match: "test"` used to select `src/contest/a.ts`, and a layer rule
|
|
225
|
+
* that matched nothing classified every file under it as `other`.
|
|
176
226
|
*/
|
|
177
227
|
declare function matchRule(filePath: string, matcher: string | RegExp | ((filePath: string) => boolean)): boolean;
|
|
228
|
+
declare function classifyLayer(filePath: string, layers: LayerRule[]): string;
|
|
229
|
+
declare function classifyKind(filePath: string, kinds: KindRule[]): string;
|
|
230
|
+
/**
|
|
231
|
+
* Digest of every setting that changes what a snapshot contains.
|
|
232
|
+
*
|
|
233
|
+
* Masked config values cannot be compared directly: two different secrets both
|
|
234
|
+
* mask to the same placeholder, and `validate` would then report "current" for a
|
|
235
|
+
* snapshot generated with different rules. A digest of the raw effective settings
|
|
236
|
+
* answers "is this snapshot still configured the same way" without ever printing
|
|
237
|
+
* a value.
|
|
238
|
+
*/
|
|
239
|
+
declare function configDigest(config: ResolvedSnapshotConfig): string;
|
|
178
240
|
|
|
179
241
|
declare function defineConfig(config: SnapshotConfig): SnapshotConfig;
|
|
180
242
|
|
|
@@ -194,6 +256,14 @@ interface PartitionedPart {
|
|
|
194
256
|
* large file produced a part 13.5x over the configured budget.
|
|
195
257
|
*/
|
|
196
258
|
declare function partitionFiles(files: FileEntry[], maxPartBytes: number, contentFingerprint?: string): PartitionedPart[];
|
|
259
|
+
/**
|
|
260
|
+
* Hard-clips any part that is still above `budget`, re-hashing what it wrote.
|
|
261
|
+
*
|
|
262
|
+
* Exported so the clip path can be tested at all: the partitioner splits oversized sections
|
|
263
|
+
* rather than clipping them, so no ordinary fixture reaches this branch, and the stale token
|
|
264
|
+
* count it used to leave behind was therefore invisible to every end-to-end test.
|
|
265
|
+
*/
|
|
266
|
+
declare function enforceBudget(parts: PartitionedPart[], budget: number): PartitionedPart[];
|
|
197
267
|
/**
|
|
198
268
|
* Re-numbers a set of parts as one sequence and rewrites their headers.
|
|
199
269
|
*
|
|
@@ -202,6 +272,22 @@ declare function partitionFiles(files: FileEntry[], maxPartBytes: number, conten
|
|
|
202
272
|
* contain duplicate filenames and every `Previous:`/`Next:` link would lie.
|
|
203
273
|
*/
|
|
204
274
|
declare function renumberParts(parts: PartitionedPart[], contentFingerprint?: string): PartitionedPart[];
|
|
275
|
+
/**
|
|
276
|
+
* Paths reach the `## Files` list, the `### FILE:` heading and the navigation
|
|
277
|
+
* index, so a control character in a name is rendered as `\uXXXX` instead of
|
|
278
|
+
* being emitted raw: a bidi override visually reorders the line, a C1 CSI drives
|
|
279
|
+
* the terminal, and a newline would break the line-oriented layout. Escaping
|
|
280
|
+
* also keeps the `## Files` fence safe (see {@link fenceForText}). Paths are
|
|
281
|
+
* legal UTF-8, so this is reachable with an ordinary `git mv`.
|
|
282
|
+
*/
|
|
283
|
+
/**
|
|
284
|
+
* The form of a path that is written into a part.
|
|
285
|
+
*
|
|
286
|
+
* Exported because the reader has to compare against it: a section heading holds this
|
|
287
|
+
* form, not the manifest's `relativePath`, and the two differ for any path with a
|
|
288
|
+
* control character or one longer than {@link DISPLAY_PATH_MAX}.
|
|
289
|
+
*/
|
|
290
|
+
declare const displayPath: (value: string) => string;
|
|
205
291
|
/**
|
|
206
292
|
* Chooses a fence longer than any backtick run in `content`, so a file that
|
|
207
293
|
* contains a fenced block cannot break out of its own code block.
|
|
@@ -422,7 +508,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
|
|
|
422
508
|
* `package.json` carries the same version; `npm run verify` compares the two.
|
|
423
509
|
*/
|
|
424
510
|
declare const GENERATOR_NAME = "codebase-snapshot";
|
|
425
|
-
declare const GENERATOR_VERSION = "0.9.
|
|
511
|
+
declare const GENERATOR_VERSION = "0.9.12";
|
|
426
512
|
|
|
427
513
|
/** The one endpoint this package will ever request. */
|
|
428
514
|
declare const PACKAGE_LATEST_URL = "https://registry.npmjs.org/codebase-snapshot/latest";
|
|
@@ -441,6 +527,22 @@ interface UpdateNotice {
|
|
|
441
527
|
current: string;
|
|
442
528
|
latest: string;
|
|
443
529
|
}
|
|
530
|
+
/** How the running copy of the tool was reached, which decides how to replace it. */
|
|
531
|
+
type InstallKind = "global" | "local" | "npx";
|
|
532
|
+
/**
|
|
533
|
+
* Classifies the script path Node is running.
|
|
534
|
+
*
|
|
535
|
+
* The notice used to tell everybody to run `npm install -g codebase-snapshot`, and that is wrong
|
|
536
|
+
* for two of the three ways people run this. A repository that added it as a devDependency —
|
|
537
|
+
* which is exactly what `setup` does — does not want a second global copy shadowing its pinned
|
|
538
|
+
* one, and an `npx` invocation is a cache entry that the next `@latest` run replaces by itself.
|
|
539
|
+
*
|
|
540
|
+
* The path is the evidence, because it is available without asking npm anything: `_npx` is npm's
|
|
541
|
+
* own cache directory name, and a local dependency lives under the project's `node_modules`.
|
|
542
|
+
*/
|
|
543
|
+
declare function installKind(scriptPath?: string, cwd?: string): InstallKind;
|
|
544
|
+
/** The command that replaces this copy with the published latest. */
|
|
545
|
+
declare function updateCommand(kind: InstallKind): string;
|
|
444
546
|
interface UpdateCheckOptions {
|
|
445
547
|
current: string;
|
|
446
548
|
/** Absolute path to the cache file. */
|
|
@@ -473,7 +575,7 @@ declare function fetchLatestVersion(url?: string, timeoutMs?: number): Promise<s
|
|
|
473
575
|
*/
|
|
474
576
|
declare function checkForUpdate(options: UpdateCheckOptions): Promise<UpdateNotice | null>;
|
|
475
577
|
/** The two lines a user sees, or an empty string when there is nothing to say. */
|
|
476
|
-
declare function formatUpdateNotice(notice: UpdateNotice): string;
|
|
578
|
+
declare function formatUpdateNotice(notice: UpdateNotice, kind: InstallKind): string;
|
|
477
579
|
|
|
478
580
|
declare const DEFAULT_SECRET_PATTERNS: SecretRule[];
|
|
479
581
|
|
|
@@ -635,10 +737,19 @@ interface InitOptions {
|
|
|
635
737
|
/** Force a preset instead of detecting one. */
|
|
636
738
|
preset?: string;
|
|
637
739
|
maxPartBytes?: ByteSize;
|
|
740
|
+
/** Ceiling in tokens; narrows `maxPartBytes` rather than replacing it. */
|
|
741
|
+
maxPartTokens?: number;
|
|
742
|
+
largeFileBytes?: ByteSize;
|
|
743
|
+
maxMonolithBytes?: ByteSize;
|
|
744
|
+
discovery?: DiscoveryMode;
|
|
745
|
+
skeleton?: boolean;
|
|
746
|
+
sarif?: boolean;
|
|
638
747
|
include?: string[];
|
|
639
748
|
exclude?: string[];
|
|
640
749
|
skipArtifacts?: string[];
|
|
641
750
|
onlyArtifacts?: string[];
|
|
751
|
+
/** Turn the monolith on without disabling anything else (`--include-monolith`). */
|
|
752
|
+
includeMonolith?: boolean;
|
|
642
753
|
includeSensitiveFiles?: boolean;
|
|
643
754
|
/** Accept every default without prompting. */
|
|
644
755
|
yes?: boolean;
|
|
@@ -682,6 +793,14 @@ interface InitResult {
|
|
|
682
793
|
dependency: InitDependency;
|
|
683
794
|
/** Human-readable notes about anything that was skipped or could not be done. */
|
|
684
795
|
notes: string[];
|
|
796
|
+
/**
|
|
797
|
+
* The output directory the written config names.
|
|
798
|
+
*
|
|
799
|
+
* Returned so the caller can bake it into the pre-commit hook: the hook is a shell script and
|
|
800
|
+
* cannot read the config, and hardcoding `snapshot` there made a gate that never ran for any
|
|
801
|
+
* project that chose a different directory.
|
|
802
|
+
*/
|
|
803
|
+
outDir: string;
|
|
685
804
|
}
|
|
686
805
|
/**
|
|
687
806
|
* Runs the interactive setup, or writes a config from flags.
|
|
@@ -775,7 +894,12 @@ interface WizardAnswers {
|
|
|
775
894
|
preset: string;
|
|
776
895
|
branch: string;
|
|
777
896
|
maxPartBytes: ByteSize;
|
|
897
|
+
maxPartTokens: number | null;
|
|
778
898
|
largeFileBytes: ByteSize;
|
|
899
|
+
maxMonolithBytes: ByteSize | null;
|
|
900
|
+
discovery: DiscoveryMode;
|
|
901
|
+
skeleton: boolean;
|
|
902
|
+
sarif: boolean;
|
|
779
903
|
include: string[];
|
|
780
904
|
excludePatterns: string[];
|
|
781
905
|
artifacts: Required<ArtifactSelection>;
|
|
@@ -837,6 +961,179 @@ declare function profileForPath(path: string): LanguageProfile | null;
|
|
|
837
961
|
*/
|
|
838
962
|
declare function summarizeWithProfile(path: string, content: string): HeuristicResult | null;
|
|
839
963
|
|
|
964
|
+
/**
|
|
965
|
+
* A deterministic token estimate for emitted text.
|
|
966
|
+
*
|
|
967
|
+
* Why a local estimate at all: the snapshot exists to be pasted into a model's context, and
|
|
968
|
+
* every budget in this tool is expressed in bytes. Bytes are the right unit for a filesystem
|
|
969
|
+
* and the wrong one for a context window — the arithmetic that converts them is in
|
|
970
|
+
* `docs/codebase-token-budget.md` and every reader has to repeat it by hand. A number in the
|
|
971
|
+
* manifest that says "this part is about 8,400 tokens" is the answer to the question an
|
|
972
|
+
* agent actually asks before reading it.
|
|
973
|
+
*
|
|
974
|
+
* Why not a real tokenizer: this package has exactly one runtime dependency (`typescript`)
|
|
975
|
+
* and that is a feature, not an oversight. A BPE vocabulary is a few megabytes of data that
|
|
976
|
+
* would have to ship, version and be kept current. This counts the structure that BPE
|
|
977
|
+
* tokenizers follow closely on source code:
|
|
978
|
+
*
|
|
979
|
+
* - a run of word characters costs `round(length / 6)`, minimum one, because common words in
|
|
980
|
+
* source (`export`, `const`, `return`, `value`) are a single token in every mainstream
|
|
981
|
+
* vocabulary and long identifiers are two or three;
|
|
982
|
+
* - every other non-space character costs one, because punctuation is almost always its own
|
|
983
|
+
* token (`=`, `(`, `,` and `)` are separate);
|
|
984
|
+
* - a *space* costs nothing, because BPE merges the leading space into the next token — the
|
|
985
|
+
* sequence `" const"` is one token, not two;
|
|
986
|
+
* - a newline costs one, which is what an indented block boundary actually is.
|
|
987
|
+
*
|
|
988
|
+
* It is an estimate and it says so. The constants were set against `cl100k_base` on this
|
|
989
|
+
* repository's own sources and land within about 10% either way; the method above is stated
|
|
990
|
+
* so a reader can judge the number rather than being asked to trust it.
|
|
991
|
+
*/
|
|
992
|
+
/**
|
|
993
|
+
* Estimates the token count of `text`.
|
|
994
|
+
*
|
|
995
|
+
* Deterministic: the same string always produces the same number, on every platform, with no
|
|
996
|
+
* vocabulary to load and no network. That is what makes it safe to record in a manifest and
|
|
997
|
+
* compare between runs.
|
|
998
|
+
*/
|
|
999
|
+
declare function estimateTokens(text: string): number;
|
|
1000
|
+
/**
|
|
1001
|
+
* Converts a token budget into the byte budget the partitioner understands.
|
|
1002
|
+
*
|
|
1003
|
+
* The partitioner is byte-bounded because bytes are what it measures and writes. A user who
|
|
1004
|
+
* thinks in tokens gets a byte ceiling that corresponds to their number, using the same
|
|
1005
|
+
* ratio the estimate is built on — and `maxPartBytes` still applies, so the smaller of the
|
|
1006
|
+
* two wins and the manifest records both.
|
|
1007
|
+
*/
|
|
1008
|
+
declare function bytesForTokens(tokens: number): number;
|
|
1009
|
+
/** Renders a token count for a header or a report: `8400` → `8,400`. */
|
|
1010
|
+
declare function formatTokens(count: number): string;
|
|
1011
|
+
|
|
1012
|
+
/** Marks a hook this tool wrote, so a re-run may replace it and a user can recognise it. */
|
|
1013
|
+
declare const HOOK_MARKER = "# codebase-snapshot: pre-commit snapshot check";
|
|
1014
|
+
interface HookInstallResult {
|
|
1015
|
+
/** Absolute path of the hook file, or `null` when there was nowhere to write it. */
|
|
1016
|
+
path: string | null;
|
|
1017
|
+
/** True when this call wrote (or rewrote) the hook. */
|
|
1018
|
+
written: boolean;
|
|
1019
|
+
/** Human-readable outcomes, always at least one. */
|
|
1020
|
+
notes: string[];
|
|
1021
|
+
}
|
|
1022
|
+
/**
|
|
1023
|
+
* Installs (or refreshes) the pre-commit hook.
|
|
1024
|
+
*
|
|
1025
|
+
* Idempotent: a hook carrying {@link HOOK_MARKER} is replaced with the current body, so an
|
|
1026
|
+
* upgrade of this package updates the check. Anyone else's hook is untouched.
|
|
1027
|
+
*/
|
|
1028
|
+
declare function installPreCommitHook(cwd: string, outDir?: string): HookInstallResult;
|
|
1029
|
+
|
|
1030
|
+
interface ChangedScopeRequest {
|
|
1031
|
+
/** A git ref to compare the working tree against (`main`, `HEAD~3`, a sha). */
|
|
1032
|
+
changedSince?: string;
|
|
1033
|
+
/** Only what is staged for the next commit. */
|
|
1034
|
+
staged?: boolean;
|
|
1035
|
+
}
|
|
1036
|
+
interface ChangedScope {
|
|
1037
|
+
/** Repository-relative paths, POSIX separators. */
|
|
1038
|
+
paths: ReadonlySet<string>;
|
|
1039
|
+
/** How the set was produced, for the manifest and the summary line. */
|
|
1040
|
+
detail: string;
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Resolves the request into a path set.
|
|
1044
|
+
*
|
|
1045
|
+
* `--changed-since <ref>` is the working tree against that ref — committed, staged and
|
|
1046
|
+
* unstaged changes all count, because all three are what a reviewer is looking at — plus
|
|
1047
|
+
* untracked files, which `git diff` never lists and which are exactly what a new feature
|
|
1048
|
+
* starts with. `--staged` is the index against `HEAD`. Both together are a union.
|
|
1049
|
+
*/
|
|
1050
|
+
declare function resolveChangedScope(cwd: string, request: ChangedScopeRequest): ChangedScope;
|
|
1051
|
+
|
|
1052
|
+
/**
|
|
1053
|
+
* One-pass lookup tables for relative-import resolution.
|
|
1054
|
+
*
|
|
1055
|
+
* `resolveSpecifier` used to fall back to scanning every known file for every
|
|
1056
|
+
* unresolved import — 100k files × 100k imports — and built a RegExp from the
|
|
1057
|
+
* candidate path, so a directory named `[unmatched` aborted the run and `[id]`
|
|
1058
|
+
* matched unrelated files. Both are gone: every candidate is a map lookup, and
|
|
1059
|
+
* no path is ever used as a pattern.
|
|
1060
|
+
*
|
|
1061
|
+
* Exported so a consumer can answer "what imports this file" from the snapshot's own
|
|
1062
|
+
* index using the same rules the generator used. `manifest.indexes.imports.byFile`
|
|
1063
|
+
* records the *raw* specifiers a file imports (`"./user.js"`), and a second
|
|
1064
|
+
* implementation of the resolution would eventually disagree with this one — leaving
|
|
1065
|
+
* two accounts of one graph.
|
|
1066
|
+
*/
|
|
1067
|
+
interface ImportResolver {
|
|
1068
|
+
byPath: Map<string, string>;
|
|
1069
|
+
byPathFolded: Map<string, string>;
|
|
1070
|
+
byStem: Map<string, string>;
|
|
1071
|
+
byStemFolded: Map<string, string>;
|
|
1072
|
+
}
|
|
1073
|
+
/** Anything that knows its own repository-relative path; `FileEntry` is the common case. */
|
|
1074
|
+
interface ImportCandidate {
|
|
1075
|
+
relativePath: string;
|
|
1076
|
+
}
|
|
1077
|
+
declare function buildImportResolver(files: readonly ImportCandidate[]): ImportResolver;
|
|
1078
|
+
/** Best-effort resolution of a relative import to an included file. */
|
|
1079
|
+
declare function resolveSpecifier(fromFile: string, specifier: string, resolver: ImportResolver): string | null;
|
|
1080
|
+
/**
|
|
1081
|
+
* True when `imports` — the specifiers one file imports — reach anything in `changedPaths`.
|
|
1082
|
+
*
|
|
1083
|
+
* One hop, and only one hop. The test is against the **changed set**, never against a set that
|
|
1084
|
+
* is being extended while it is tested: doing that walked the graph transitively, so a changed
|
|
1085
|
+
* `a.ts` pulled in `b.ts` (which imports it) and then `c.ts` (which imports `b.ts`), and whether
|
|
1086
|
+
* the two-hop file was included depended on whether its name happened to sort after `b.ts`. The
|
|
1087
|
+
* same repository produced different snapshots depending on file names.
|
|
1088
|
+
*/
|
|
1089
|
+
declare function importsChangedFile(importerPath: string, imports: readonly string[], changedPaths: ReadonlySet<string>, resolver: ImportResolver): boolean;
|
|
1090
|
+
|
|
1091
|
+
/** Import specifiers from text already decoded, or `[]` when the language has no importer. */
|
|
1092
|
+
declare function importsOfText(relativePath: string, text: string): string[];
|
|
1093
|
+
/**
|
|
1094
|
+
* Import specifiers of one file on disk.
|
|
1095
|
+
*
|
|
1096
|
+
* A file this cannot read, a binary file and a file the parser rejects all contribute `[]`, which
|
|
1097
|
+
* is what the generator saw for them too — so the answer stays consistent with the snapshot
|
|
1098
|
+
* rather than becoming a third opinion about it.
|
|
1099
|
+
*/
|
|
1100
|
+
declare function importsOfFile(relativePath: string, absolutePath: string): string[];
|
|
1101
|
+
|
|
1102
|
+
interface SkeletonResult {
|
|
1103
|
+
text: string;
|
|
1104
|
+
/** How many bodies were replaced; zero means the file had none and was left alone. */
|
|
1105
|
+
collapsed: number;
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Replaces the body of every function-like node, innermost-first, by text span.
|
|
1109
|
+
*
|
|
1110
|
+
* Spans are collected and then applied from the end of the file backwards so that an earlier
|
|
1111
|
+
* replacement never invalidates a later span's offsets.
|
|
1112
|
+
*/
|
|
1113
|
+
/**
|
|
1114
|
+
* True when a filename is TypeScript-with-JSX, in any letter case.
|
|
1115
|
+
*
|
|
1116
|
+
* One function for one question, because two spellings of it is exactly how `.TSX` came to be
|
|
1117
|
+
* eligible for a skeleton and then parsed as plain TypeScript, where JSX is a syntax error.
|
|
1118
|
+
* Exported so the decision itself can be tested: collapsing a body is span-based and produces the
|
|
1119
|
+
* same text under either script kind for simple files, so an output comparison cannot prove which
|
|
1120
|
+
* parser ran.
|
|
1121
|
+
*/
|
|
1122
|
+
declare function isTsxFileName(fileName: string): boolean;
|
|
1123
|
+
declare function skeletonizeTypeScript(source: string, fileName?: string): SkeletonResult;
|
|
1124
|
+
/** True for a path this module can compress. */
|
|
1125
|
+
declare function isSkeletonizable(filePath: string): boolean;
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Renders the findings as a SARIF log.
|
|
1129
|
+
*
|
|
1130
|
+
* Every result carries the file and line, a `level` of `note` — a redaction is the tool doing
|
|
1131
|
+
* its job, not a build failure — and the rule that matched. `partialFingerprints` gives Code
|
|
1132
|
+
* Scanning a stable identity for an alert across commits, built from the path, the rules and
|
|
1133
|
+
* the line, so re-running `generate` does not close and reopen every alert.
|
|
1134
|
+
*/
|
|
1135
|
+
declare function generateSarifReport(manifest: Manifest, findings: readonly SecretFinding[], rules: readonly SecretRule[], toolVersion: string): string;
|
|
1136
|
+
|
|
840
1137
|
declare const SCHEMA_VERSION = "3.0.0";
|
|
841
1138
|
|
|
842
1139
|
interface GenerateOptions {
|
|
@@ -868,6 +1165,14 @@ declare function resolveSafeOutputDirs(config: {
|
|
|
868
1165
|
* directory per run rather than a single snapshot.
|
|
869
1166
|
*/
|
|
870
1167
|
declare function assertReplaceable(target: string, label: "outDir" | "tmpDir", secretRules?: readonly SecretRule[]): void;
|
|
1168
|
+
/**
|
|
1169
|
+
* Where the run lock for a staging root lives.
|
|
1170
|
+
*
|
|
1171
|
+
* Exported because the lock is the one piece of state that can outlive a crashed run and
|
|
1172
|
+
* wedge the next one, and the error the user sees names this path — a diagnostic that
|
|
1173
|
+
* has to be transcribed from a hash by hand is not a diagnostic.
|
|
1174
|
+
*/
|
|
1175
|
+
declare function lockPathFor(stagingRoot: string): string;
|
|
871
1176
|
/**
|
|
872
1177
|
* Generates the snapshot.
|
|
873
1178
|
*
|
|
@@ -879,4 +1184,4 @@ declare function generateSnapshot(configInput?: SnapshotConfig | ResolvedSnapsho
|
|
|
879
1184
|
/** Promise-returning wrapper for consumers that prefer an async call site. */
|
|
880
1185
|
declare function generateSnapshotAsync(configInput?: SnapshotConfig | ResolvedSnapshotConfig | null, options?: GenerateOptions): Promise<Manifest>;
|
|
881
1186
|
|
|
882
|
-
export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CliOptions, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, type HeuristicResult, type InitDependency, type InitOptions, type InitResult, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, anchorForPath, assertReplaceable, assertUsableConfigInput, cacheDirectory, cacheFilePath, checkForUpdate, collectFiles, compareManifests, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayWidth, explainPath, fenceForContent, fenceForText, fetchLatestVersion, firstRunMessage, formatUpdateNotice, generateProjectTree, generateSnapshot, generateSnapshotAsync, getPreset, globToRegExp, hasPriorSnapshot, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveConfig, resolveSafeOutputDirs, runInit, scanAndRedactSecrets, shouldCheck, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, truncatePreview, truncateToBytes, validateSnapshot, wrapLines };
|
|
1187
|
+
export { ARTIFACT_NAMES, ArtifactSelection, ByteSize, CHECK_INTERVAL_MS, CONFIG_KEYS, type ChangedScope, type ChangedScopeRequest, CliOptions, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, DiscoveryMode, type ExplainResult, FAILURE_INTERVAL_MS, FileEntry, type FirstRunFacts, type FirstRunPlan, type FirstRunRefusal, GENERATOR_NAME, GENERATOR_VERSION, type GenerateOptions, HOOK_MARKER, type HeuristicResult, type HookInstallResult, type ImportCandidate, type ImportResolver, type InitDependency, type InitOptions, type InitResult, type InstallKind, JsonSummary, KindRule, LANGUAGE_PROFILES, type LanguageProfile, LayerRule, MIN_MAX_PART_BYTES, MIN_MAX_PART_TOKENS, Manifest, type ManifestDiff, MarkdownSummary, PACKAGE_LATEST_URL, PRESETS, PartMetadata, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, ResolvedSnapshotConfig, SCHEMA_VERSION, SecretFinding, SecretRule, SkipRecord, SnapshotConfig, SourceSummary, TextEncoding, type UpdateCheckOptions, type UpdateNotice, ValidationResult, type WizardAnswers, anchorForPath, 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, 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, truncatePreview, truncateToBytes, updateCommand, validateSnapshot, wrapLines };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
export { ARTIFACT_NAMES, CHECK_INTERVAL_MS, DEFAULT_ANSWERS, DEFAULT_SECRET_PATTERNS, FAILURE_INTERVAL_MS, GENERATOR_NAME, GENERATOR_VERSION, LANGUAGE_PROFILES, MIN_MAX_PART_BYTES, PACKAGE_LATEST_URL, PRESETS, PromptBack, PromptCancelled, REQUEST_TIMEOUT_MS, SCHEMA_VERSION, anchorForPath, assertReplaceable, assertUsableConfigInput, cacheDirectory, cacheFilePath, checkForUpdate, collectFiles, compareManifests, countInvalidUtf8Bytes, countLines, decodeText, defineConfig, detectLanguage, detectPreset, displayWidth, explainPath, fenceForContent, fenceForText, fetchLatestVersion, firstRunMessage, formatUpdateNotice, generateProjectTree, generateSnapshot, generateSnapshotAsync, getPreset, globToRegExp, hasPriorSnapshot, isBinaryBuffer, isBinaryExtension, isBinaryFile, isEffectivelyEmpty, isInteractive, isNewer, isResolvedConfig, isSensitivePath, listPresetNames, loadConfigFile, loadConfigFileDetailed, loadManifest, markResolvedConfig, matchRule, matchesExclude, normalizeResolvedConfig, parseByteSize, partitionFiles, planFirstRun, profileForPath, renderConfig, renderDiffText, renderExplainText, renumberParts, resolveConfig, resolveSafeOutputDirs, runInit, scanAndRedactSecrets, shouldCheck, stripJsonComments, summarizeJson, summarizeMarkdown, summarizeTypeScriptSource, summarizeWithProfile, supportsTypeScriptImports, truncatePreview, truncateToBytes, validateSnapshot, wrapLines } from './chunk-
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
3
|
-
//# sourceMappingURL=index.js.map
|
|
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, anchorForPath, 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, 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, truncatePreview, truncateToBytes, updateCommand, validateSnapshot, workerEntry, wrapLines } from './chunk-3H45YMBG.js';
|