codebase-snapshot 0.21.0 → 0.22.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.
@@ -1,4 +1,4 @@
1
- import { c as SnapshotConfig, f as Manifest } from './types-D5XYzksd.cjs';
1
+ import { d as SnapshotConfig, M as Manifest } from './types-DQXKiaXk.cjs';
2
2
 
3
3
  /** The options `resolveConfig` was called with, as the CLI would have passed them. */
4
4
  interface WorkspaceCliOptions {
@@ -1,4 +1,4 @@
1
- import { c as SnapshotConfig, f as Manifest } from './types-D5XYzksd.js';
1
+ import { d as SnapshotConfig, M as Manifest } from './types-DQXKiaXk.js';
2
2
 
3
3
  /** The options `resolveConfig` was called with, as the CLI would have passed them. */
4
4
  interface WorkspaceCliOptions {
package/dist/index.cjs CHANGED
@@ -4525,7 +4525,7 @@ function verifySnapshotSignature(snapshotDir) {
4525
4525
 
4526
4526
  // src/version.ts
4527
4527
  var GENERATOR_NAME = "codebase-snapshot";
4528
- var GENERATOR_VERSION = "0.21.0";
4528
+ var GENERATOR_VERSION = "0.22.0";
4529
4529
  var SCHEMA_VERSION = "3.0.0";
4530
4530
  var LEGACY_GENERATOR_NAMES = ["@ankurhalder/codebase-snapshot"];
4531
4531
  function isOurGeneratorName(name) {
@@ -16329,6 +16329,25 @@ var COMMAND_OPTION_SCOPE = {
16329
16329
  "help",
16330
16330
  "version"
16331
16331
  ],
16332
+ guard: [
16333
+ "hook",
16334
+ "changed",
16335
+ "max-chars",
16336
+ "diff",
16337
+ "paths",
16338
+ "depth",
16339
+ "max-results",
16340
+ "no-cache",
16341
+ "no-live",
16342
+ "cwd",
16343
+ "out-dir",
16344
+ "no-config",
16345
+ "format",
16346
+ "mode",
16347
+ "no-update-check",
16348
+ "help",
16349
+ "version"
16350
+ ],
16332
16351
  brief: [
16333
16352
  "diff",
16334
16353
  "paths",
@@ -16481,6 +16500,7 @@ var COMMAND_ORDER = [
16481
16500
  "health",
16482
16501
  "report",
16483
16502
  "impact",
16503
+ "guard",
16484
16504
  "brief",
16485
16505
  "explain",
16486
16506
  "update",
@@ -16634,6 +16654,13 @@ function buildAgentContract() {
16634
16654
  positionals: [],
16635
16655
  exits: [0, 1, 2]
16636
16656
  },
16657
+ {
16658
+ name: "guard",
16659
+ aliases: [],
16660
+ summary: "Check whether a change is complete: untouched consumers, candidate tests, affected routes, and a trust stamp, in one small report. With --hook <claude|copilot|codex|raw>, read one hook payload from stdin and emit the host-shaped additionalContext, or an empty object when there is nothing to say. Defaults to the working tree against HEAD.",
16661
+ positionals: [],
16662
+ exits: [0, 1, 2]
16663
+ },
16637
16664
  {
16638
16665
  name: "brief",
16639
16666
  aliases: [],
@@ -16795,6 +16822,27 @@ function buildAgentContract() {
16795
16822
  appliesTo: optionAppliesTo("include-cycles"),
16796
16823
  summary: "impact only: include import cycles in the impacted subgraph."
16797
16824
  },
16825
+ {
16826
+ flag: "--hook",
16827
+ type: "string",
16828
+ default: "unset",
16829
+ appliesTo: optionAppliesTo("hook"),
16830
+ summary: "guard only: read one hook payload from stdin and shape the response for claude, copilot, codex, or raw. Fail-open: an error returns an empty object and a stderr note."
16831
+ },
16832
+ {
16833
+ flag: "--changed",
16834
+ type: "boolean",
16835
+ default: false,
16836
+ appliesTo: optionAppliesTo("changed"),
16837
+ summary: "guard only: check the working tree against HEAD. This is the default when --hook is not given."
16838
+ },
16839
+ {
16840
+ flag: "--max-chars",
16841
+ type: "number",
16842
+ default: 1200,
16843
+ appliesTo: optionAppliesTo("max-chars"),
16844
+ summary: "guard only: cap on the model-facing hook text (minimum 200, maximum 10000)."
16845
+ },
16798
16846
  {
16799
16847
  flag: "--copy",
16800
16848
  type: "boolean",
package/dist/index.d.cts CHANGED
@@ -1,8 +1,184 @@
1
1
  import * as node_crypto from 'node:crypto';
2
- import { S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, M as MarkdownSummary, b as SourceSummary, c as SnapshotConfig, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, B as ByteSize, C as CliOptions, d as PartMetadata, F as FileEntry, T as TextEncoding, e as SecretFinding, V as ValidationResult, f as Manifest, E as EdgeProvenance, g as TrustEnvelope, A as ArtifactSelection } from './types-D5XYzksd.cjs';
3
- export { h as BudgetConfig, i as CoverageStatus, j as DeclarationSpan, k as FreshnessStatus, H as HooksConfig, I as ImportBinding, l as InclusionMode, m as IncompleteFile, n as IndexSourceKind, o as ManifestArtifact, p as ManifestConfigSnapshot, q as ManifestIndexes, r as ManifestTotals, s as Mode, O as OutputFormat, t as OwnerBrief, u as PartFileEntry, P as PromptTask, v as ReExportBinding, w as ResolvedArtifacts, x as ResolvedBudgets, y as SecretRuleInput, z as SkipReason, G as SummaryQuality, N as TruncationReason, Q as ValidationDrift } from './types-D5XYzksd.cjs';
2
+ import { E as EdgeProvenance, M as Manifest, T as TrustEnvelope, S as SecretRule, D as DiscoveryMode, a as SkipRecord, J as JsonSummary, b as MarkdownSummary, c as SourceSummary, d as SnapshotConfig, K as KindRule, L as LayerRule, R as ResolvedSnapshotConfig, B as ByteSize, C as CliOptions, e as PartMetadata, F as FileEntry, f as TextEncoding, g as SecretFinding, V as ValidationResult, A as ArtifactSelection } from './types-DQXKiaXk.cjs';
3
+ export { h as BudgetConfig, i as CoverageStatus, j as DeclarationSpan, k as FreshnessStatus, H as HooksConfig, I as ImportBinding, l as InclusionMode, m as IncompleteFile, n as IndexSourceKind, o as ManifestArtifact, p as ManifestConfigSnapshot, q as ManifestIndexes, r as ManifestTotals, s as Mode, O as OutputFormat, t as OwnerBrief, u as PartFileEntry, P as PromptTask, v as ReExportBinding, w as ResolvedArtifacts, x as ResolvedBudgets, y as SecretRuleInput, z as SkipReason, G as SummaryQuality, N as TruncationReason, Q as ValidationDrift } from './types-DQXKiaXk.cjs';
4
4
  import ts from 'typescript';
5
- export { w as workerEntry } from './generate-worker-D56JeXwx.cjs';
5
+ export { w as workerEntry } from './generate-worker-BUNhTXkj.cjs';
6
+
7
+ declare const DEFAULT_MAX_PROGRAM_FILES = 2500;
8
+ type PrecisionMode = "ts-semantic" | "syntactic-fallback";
9
+ interface TsProgramFile {
10
+ relativePath: string;
11
+ content?: string;
12
+ }
13
+ interface ScopedProgramOptions {
14
+ root: string;
15
+ files: readonly TsProgramFile[];
16
+ maxProgramFiles?: number;
17
+ timeoutMs?: number;
18
+ }
19
+ interface ScopedProgram {
20
+ root: string;
21
+ program: ts.Program | null;
22
+ checker: ts.TypeChecker | null;
23
+ fileCount: number;
24
+ precisionMode: PrecisionMode;
25
+ coverage: "complete" | "partial";
26
+ reasons: string[];
27
+ deadline: number;
28
+ }
29
+ interface SymbolReference {
30
+ path: string;
31
+ line: number;
32
+ column: number;
33
+ name: string;
34
+ isDefinition: boolean;
35
+ confidence: "ts-semantic";
36
+ }
37
+ interface SymbolReferencesOptions extends ScopedProgramOptions {
38
+ symbolName: string;
39
+ targetPath?: string;
40
+ maxResults?: number;
41
+ }
42
+ interface SymbolReferencesResult {
43
+ symbol: string;
44
+ targetPath?: string;
45
+ precisionMode: PrecisionMode;
46
+ coverage: "complete" | "partial";
47
+ truncated: boolean;
48
+ reasons: string[];
49
+ references: SymbolReference[];
50
+ }
51
+ interface PreciseCallersOptions extends ScopedProgramOptions {
52
+ changedFiles: readonly string[];
53
+ changedSymbols: Readonly<Record<string, readonly string[]>>;
54
+ }
55
+ interface PreciseCallersResult {
56
+ precisionMode: PrecisionMode;
57
+ coverage: "complete" | "partial";
58
+ reasons: string[];
59
+ callers: Array<{
60
+ path: string;
61
+ symbol: string;
62
+ references: SymbolReference[];
63
+ }>;
64
+ }
65
+ interface SymbolQueryTarget {
66
+ symbolName: string;
67
+ targetPath?: string;
68
+ }
69
+ interface MultiSymbolReferencesOptions extends ScopedProgramOptions {
70
+ targets: readonly SymbolQueryTarget[];
71
+ maxResults?: number;
72
+ }
73
+ interface MultiSymbolReferencesResult {
74
+ precisionMode: PrecisionMode;
75
+ coverage: "complete" | "partial";
76
+ truncated: boolean;
77
+ reasons: string[];
78
+ results: Array<{
79
+ symbol: string;
80
+ targetPath?: string;
81
+ references: SymbolReference[];
82
+ }>;
83
+ }
84
+ declare function createScopedProgram(options: ScopedProgramOptions): ScopedProgram;
85
+ declare function findMultipleSymbolReferences(options: MultiSymbolReferencesOptions): MultiSymbolReferencesResult;
86
+ declare function findSymbolReferences(options: SymbolReferencesOptions): SymbolReferencesResult;
87
+ declare function resolvePreciseChangedCallers(options: PreciseCallersOptions): PreciseCallersResult;
88
+
89
+ type ImpactBaseKind = "diff" | "paths";
90
+ type ImpactLevel = "direct-symbol" | "file-import" | "type-only" | "reexport" | "namespace-or-cjs";
91
+ interface ImpactBase {
92
+ kind: ImpactBaseKind;
93
+ value: string;
94
+ }
95
+ interface ImpactChangeRequest {
96
+ diff?: string;
97
+ paths?: readonly string[];
98
+ }
99
+ interface ImpactChanges {
100
+ base: ImpactBase;
101
+ paths: string[];
102
+ detail: string;
103
+ }
104
+ interface ImpactChangedFile {
105
+ path: string;
106
+ inSnapshot: boolean;
107
+ deleted: boolean;
108
+ reason?: string;
109
+ }
110
+ interface ImpactAffectedFile {
111
+ path: string;
112
+ distance: number;
113
+ via: string;
114
+ specifier: string;
115
+ confidence?: EdgeProvenance;
116
+ impactKind?: ImpactLevel;
117
+ matchedSymbols?: string[];
118
+ }
119
+ interface ImpactTestFile {
120
+ path: string;
121
+ covers: string[];
122
+ reason: "imports-changed" | "imports-affected";
123
+ }
124
+ interface ImpactUnresolvedImport {
125
+ path: string;
126
+ specifier: string;
127
+ }
128
+ interface ImpactRoute {
129
+ path: string;
130
+ methods: string[];
131
+ }
132
+ interface ImpactReport {
133
+ schemaVersion: 1;
134
+ base: ImpactBase;
135
+ snapshot: {
136
+ manifest: string;
137
+ fingerprint: string;
138
+ generatedAt: string;
139
+ git: {
140
+ commit: string;
141
+ isDirty: boolean;
142
+ };
143
+ };
144
+ changed: ImpactChangedFile[];
145
+ affected: ImpactAffectedFile[];
146
+ tests: ImpactTestFile[];
147
+ unresolved: ImpactUnresolvedImport[];
148
+ routesAffected?: ImpactRoute[];
149
+ prunedByBarrel?: number;
150
+ cycles?: string[][];
151
+ imports?: Record<string, string[]>;
152
+ precise?: {
153
+ references: SymbolReference[];
154
+ coverage: "complete" | "partial";
155
+ reasons: string[];
156
+ };
157
+ trust: TrustEnvelope;
158
+ truncated: boolean;
159
+ limits: {
160
+ depth: number;
161
+ maxResults: number;
162
+ affected: number;
163
+ };
164
+ warnings: string[];
165
+ }
166
+ interface ImpactInput {
167
+ manifest: Manifest;
168
+ cwd: string;
169
+ changes: ImpactChanges;
170
+ manifestPath?: string;
171
+ depth?: number;
172
+ maxResults?: number;
173
+ symbols?: readonly string[];
174
+ changedLines?: ReadonlyMap<string, Array<[number, number]>>;
175
+ includeImports?: boolean;
176
+ includeCycles?: boolean;
177
+ trust?: TrustEnvelope;
178
+ }
179
+ declare function resolveImpactChanges(cwd: string, request: ImpactChangeRequest): ImpactChanges;
180
+ declare function computeImpact(input: ImpactInput): ImpactReport;
181
+ declare function renderImpactText(report: ImpactReport): string;
6
182
 
7
183
  interface GitInfo {
8
184
  branch: string;
@@ -566,7 +742,7 @@ declare function validateSnapshot(configInput: ResolvedSnapshotConfig | Snapshot
566
742
  * `package.json` carries the same version; `npm run verify` compares the two.
567
743
  */
568
744
  declare const GENERATOR_NAME = "codebase-snapshot";
569
- declare const GENERATOR_VERSION = "0.21.0";
745
+ declare const GENERATOR_VERSION = "0.22.0";
570
746
  /**
571
747
  * The manifest and ownership-marker schema this build writes and understands.
572
748
  *
@@ -1000,182 +1176,6 @@ declare function loadManifest(target: string): Manifest;
1000
1176
  /** Renders a diff for a terminal. */
1001
1177
  declare function renderDiffText(diff: ManifestDiff): string;
1002
1178
 
1003
- declare const DEFAULT_MAX_PROGRAM_FILES = 2500;
1004
- type PrecisionMode = "ts-semantic" | "syntactic-fallback";
1005
- interface TsProgramFile {
1006
- relativePath: string;
1007
- content?: string;
1008
- }
1009
- interface ScopedProgramOptions {
1010
- root: string;
1011
- files: readonly TsProgramFile[];
1012
- maxProgramFiles?: number;
1013
- timeoutMs?: number;
1014
- }
1015
- interface ScopedProgram {
1016
- root: string;
1017
- program: ts.Program | null;
1018
- checker: ts.TypeChecker | null;
1019
- fileCount: number;
1020
- precisionMode: PrecisionMode;
1021
- coverage: "complete" | "partial";
1022
- reasons: string[];
1023
- deadline: number;
1024
- }
1025
- interface SymbolReference {
1026
- path: string;
1027
- line: number;
1028
- column: number;
1029
- name: string;
1030
- isDefinition: boolean;
1031
- confidence: "ts-semantic";
1032
- }
1033
- interface SymbolReferencesOptions extends ScopedProgramOptions {
1034
- symbolName: string;
1035
- targetPath?: string;
1036
- maxResults?: number;
1037
- }
1038
- interface SymbolReferencesResult {
1039
- symbol: string;
1040
- targetPath?: string;
1041
- precisionMode: PrecisionMode;
1042
- coverage: "complete" | "partial";
1043
- truncated: boolean;
1044
- reasons: string[];
1045
- references: SymbolReference[];
1046
- }
1047
- interface PreciseCallersOptions extends ScopedProgramOptions {
1048
- changedFiles: readonly string[];
1049
- changedSymbols: Readonly<Record<string, readonly string[]>>;
1050
- }
1051
- interface PreciseCallersResult {
1052
- precisionMode: PrecisionMode;
1053
- coverage: "complete" | "partial";
1054
- reasons: string[];
1055
- callers: Array<{
1056
- path: string;
1057
- symbol: string;
1058
- references: SymbolReference[];
1059
- }>;
1060
- }
1061
- interface SymbolQueryTarget {
1062
- symbolName: string;
1063
- targetPath?: string;
1064
- }
1065
- interface MultiSymbolReferencesOptions extends ScopedProgramOptions {
1066
- targets: readonly SymbolQueryTarget[];
1067
- maxResults?: number;
1068
- }
1069
- interface MultiSymbolReferencesResult {
1070
- precisionMode: PrecisionMode;
1071
- coverage: "complete" | "partial";
1072
- truncated: boolean;
1073
- reasons: string[];
1074
- results: Array<{
1075
- symbol: string;
1076
- targetPath?: string;
1077
- references: SymbolReference[];
1078
- }>;
1079
- }
1080
- declare function createScopedProgram(options: ScopedProgramOptions): ScopedProgram;
1081
- declare function findMultipleSymbolReferences(options: MultiSymbolReferencesOptions): MultiSymbolReferencesResult;
1082
- declare function findSymbolReferences(options: SymbolReferencesOptions): SymbolReferencesResult;
1083
- declare function resolvePreciseChangedCallers(options: PreciseCallersOptions): PreciseCallersResult;
1084
-
1085
- type ImpactBaseKind = "diff" | "paths";
1086
- type ImpactLevel = "direct-symbol" | "file-import" | "type-only" | "reexport" | "namespace-or-cjs";
1087
- interface ImpactBase {
1088
- kind: ImpactBaseKind;
1089
- value: string;
1090
- }
1091
- interface ImpactChangeRequest {
1092
- diff?: string;
1093
- paths?: readonly string[];
1094
- }
1095
- interface ImpactChanges {
1096
- base: ImpactBase;
1097
- paths: string[];
1098
- detail: string;
1099
- }
1100
- interface ImpactChangedFile {
1101
- path: string;
1102
- inSnapshot: boolean;
1103
- deleted: boolean;
1104
- reason?: string;
1105
- }
1106
- interface ImpactAffectedFile {
1107
- path: string;
1108
- distance: number;
1109
- via: string;
1110
- specifier: string;
1111
- confidence?: EdgeProvenance;
1112
- impactKind?: ImpactLevel;
1113
- matchedSymbols?: string[];
1114
- }
1115
- interface ImpactTestFile {
1116
- path: string;
1117
- covers: string[];
1118
- reason: "imports-changed" | "imports-affected";
1119
- }
1120
- interface ImpactUnresolvedImport {
1121
- path: string;
1122
- specifier: string;
1123
- }
1124
- interface ImpactRoute {
1125
- path: string;
1126
- methods: string[];
1127
- }
1128
- interface ImpactReport {
1129
- schemaVersion: 1;
1130
- base: ImpactBase;
1131
- snapshot: {
1132
- manifest: string;
1133
- fingerprint: string;
1134
- generatedAt: string;
1135
- git: {
1136
- commit: string;
1137
- isDirty: boolean;
1138
- };
1139
- };
1140
- changed: ImpactChangedFile[];
1141
- affected: ImpactAffectedFile[];
1142
- tests: ImpactTestFile[];
1143
- unresolved: ImpactUnresolvedImport[];
1144
- routesAffected?: ImpactRoute[];
1145
- prunedByBarrel?: number;
1146
- cycles?: string[][];
1147
- imports?: Record<string, string[]>;
1148
- precise?: {
1149
- references: SymbolReference[];
1150
- coverage: "complete" | "partial";
1151
- reasons: string[];
1152
- };
1153
- trust: TrustEnvelope;
1154
- truncated: boolean;
1155
- limits: {
1156
- depth: number;
1157
- maxResults: number;
1158
- affected: number;
1159
- };
1160
- warnings: string[];
1161
- }
1162
- interface ImpactInput {
1163
- manifest: Manifest;
1164
- cwd: string;
1165
- changes: ImpactChanges;
1166
- manifestPath?: string;
1167
- depth?: number;
1168
- maxResults?: number;
1169
- symbols?: readonly string[];
1170
- changedLines?: ReadonlyMap<string, Array<[number, number]>>;
1171
- includeImports?: boolean;
1172
- includeCycles?: boolean;
1173
- trust?: TrustEnvelope;
1174
- }
1175
- declare function resolveImpactChanges(cwd: string, request: ImpactChangeRequest): ImpactChanges;
1176
- declare function computeImpact(input: ImpactInput): ImpactReport;
1177
- declare function renderImpactText(report: ImpactReport): string;
1178
-
1179
1179
  interface GitignoreUpdate {
1180
1180
  /** The entries this call appended, in the order written. */
1181
1181
  added: string[];