@vibe-agent-toolkit/cli 0.2.0-rc.8 → 0.2.0-rc.9
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/dist/commands/audit/provenance.d.ts.map +1 -1
- package/dist/commands/audit/provenance.js +4 -3
- package/dist/commands/audit/provenance.js.map +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +2 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cache/clear.d.ts +17 -3
- package/dist/commands/cache/clear.d.ts.map +1 -1
- package/dist/commands/cache/clear.js +17 -3
- package/dist/commands/cache/clear.js.map +1 -1
- package/dist/commands/cache/index.d.ts.map +1 -1
- package/dist/commands/cache/index.js +19 -10
- package/dist/commands/cache/index.js.map +1 -1
- package/dist/commands/claude/context.d.ts +2 -2
- package/dist/commands/claude/context.js +4 -4
- package/dist/commands/claude/context.js.map +1 -1
- package/dist/commands/claude/index.d.ts +12 -11
- package/dist/commands/claude/index.d.ts.map +1 -1
- package/dist/commands/claude/index.js +14 -16
- package/dist/commands/claude/index.js.map +1 -1
- package/dist/commands/claude/marketplace/git-publish.d.ts.map +1 -1
- package/dist/commands/claude/marketplace/git-publish.js +19 -10
- package/dist/commands/claude/marketplace/git-publish.js.map +1 -1
- package/dist/commands/claude/marketplace/validate.js +2 -2
- package/dist/commands/claude/marketplace/validate.js.map +1 -1
- package/dist/commands/claude/org/skills.js +8 -8
- package/dist/commands/claude/org/skills.js.map +1 -1
- package/dist/commands/claude/plugin/build.d.ts.map +1 -1
- package/dist/commands/claude/plugin/build.js +11 -21
- package/dist/commands/claude/plugin/build.js.map +1 -1
- package/dist/commands/claude/plugin/plugin-files.js +3 -3
- package/dist/commands/claude/plugin/plugin-files.js.map +1 -1
- package/dist/commands/consistency-check.d.ts +11 -5
- package/dist/commands/consistency-check.d.ts.map +1 -1
- package/dist/commands/consistency-check.js +113 -78
- package/dist/commands/consistency-check.js.map +1 -1
- package/dist/commands/resources/check-progress.d.ts +6 -0
- package/dist/commands/resources/check-progress.d.ts.map +1 -1
- package/dist/commands/resources/check-progress.js +10 -2
- package/dist/commands/resources/check-progress.js.map +1 -1
- package/dist/commands/resources/check.d.ts +182 -203
- package/dist/commands/resources/check.d.ts.map +1 -1
- package/dist/commands/resources/check.js +272 -248
- package/dist/commands/resources/check.js.map +1 -1
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +140 -23
- package/dist/commands/resources/index.js.map +1 -1
- package/dist/commands/resources/query.d.ts +2 -2
- package/dist/commands/resources/query.d.ts.map +1 -1
- package/dist/commands/resources/query.js +20 -10
- package/dist/commands/resources/query.js.map +1 -1
- package/dist/commands/skill/test/run.js +3 -3
- package/dist/commands/skill/test/run.js.map +1 -1
- package/dist/commands/skills/build.d.ts +34 -21
- package/dist/commands/skills/build.d.ts.map +1 -1
- package/dist/commands/skills/build.js +99 -50
- package/dist/commands/skills/build.js.map +1 -1
- package/dist/commands/skills/skill-discovery.d.ts +15 -13
- package/dist/commands/skills/skill-discovery.d.ts.map +1 -1
- package/dist/commands/skills/skill-discovery.js +23 -4
- package/dist/commands/skills/skill-discovery.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +31 -8
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/verify.d.ts +10 -4
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +92 -65
- package/dist/commands/verify.js.map +1 -1
- package/dist/report-schemas.d.ts.map +1 -1
- package/dist/report-schemas.js +0 -2
- package/dist/report-schemas.js.map +1 -1
- package/dist/skill-resolution/classify.js +2 -2
- package/dist/skill-resolution/classify.js.map +1 -1
- package/dist/skill-resolution/resolve-skill-reference.d.ts.map +1 -1
- package/dist/skill-resolution/resolve-skill-reference.js +48 -52
- package/dist/skill-resolution/resolve-skill-reference.js.map +1 -1
- package/dist/utils/claude-context-lens.d.ts +34 -0
- package/dist/utils/claude-context-lens.d.ts.map +1 -0
- package/dist/utils/claude-context-lens.js +39 -0
- package/dist/utils/claude-context-lens.js.map +1 -0
- package/dist/utils/projection-lenses.d.ts +98 -0
- package/dist/utils/projection-lenses.d.ts.map +1 -0
- package/dist/utils/projection-lenses.js +203 -0
- package/dist/utils/projection-lenses.js.map +1 -0
- package/dist/utils/projection-query.d.ts +38 -14
- package/dist/utils/projection-query.d.ts.map +1 -1
- package/dist/utils/projection-query.js +78 -17
- package/dist/utils/projection-query.js.map +1 -1
- package/dist/utils/projection-store.d.ts +61 -42
- package/dist/utils/projection-store.d.ts.map +1 -1
- package/dist/utils/projection-store.js +155 -59
- package/dist/utils/projection-store.js.map +1 -1
- package/dist/utils/relation-limits.d.ts +50 -0
- package/dist/utils/relation-limits.d.ts.map +1 -0
- package/dist/utils/relation-limits.js +50 -0
- package/dist/utils/relation-limits.js.map +1 -0
- package/dist/utils/skill-discovery.d.ts.map +1 -1
- package/dist/utils/skill-discovery.js +2 -1
- package/dist/utils/skill-discovery.js.map +1 -1
- package/dist/utils/skill-packaging-config.d.ts +38 -3
- package/dist/utils/skill-packaging-config.d.ts.map +1 -1
- package/dist/utils/skill-packaging-config.js +28 -3
- package/dist/utils/skill-packaging-config.js.map +1 -1
- package/package.json +16 -16
- package/schemas/resources-check.json +43 -0
- package/dist/commands/claude/budget.d.ts +0 -269
- package/dist/commands/claude/budget.d.ts.map +0 -1
- package/dist/commands/claude/budget.js +0 -507
- package/dist/commands/claude/budget.js.map +0 -1
- package/dist/utils/context-budget-issues.d.ts +0 -108
- package/dist/utils/context-budget-issues.d.ts.map +0 -1
- package/dist/utils/context-budget-issues.js +0 -280
- package/dist/utils/context-budget-issues.js.map +0 -1
- package/schemas/claude-budget.json +0 -197
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `vat claude budget [paths...]` — is the always-loaded context at a working
|
|
3
|
-
* location over its budget?
|
|
4
|
-
*
|
|
5
|
-
* ## Why this is a command and not a check inside `vat resources validate`
|
|
6
|
-
*
|
|
7
|
-
* It used to be one: default-on, with a `--no-context-budget` opt-out. That is
|
|
8
|
-
* gone, in both directions — `vat resources validate` has no knowledge of the
|
|
9
|
-
* budget at all any more, not a flag, not a default. The ruling behind the move
|
|
10
|
-
* is short: *a validation run must not emit findings nobody asked for.* An
|
|
11
|
-
* `info` finding attached to a lane people run for link and anchor errors is a
|
|
12
|
-
* finding they scroll past, and a check people scroll past is a check they
|
|
13
|
-
* eventually silence.
|
|
14
|
-
*
|
|
15
|
-
* ## The sibling split: `context` QUERIES, `budget` CHECKS
|
|
16
|
-
*
|
|
17
|
-
* `vat claude context` answers a question and
|
|
18
|
-
* never gates — totals, admissions, the declared limits, no verdict, always
|
|
19
|
-
* exit 0. This command is the other half of that pair: it applies a THRESHOLD,
|
|
20
|
-
* produces findings with severities an adopter can configure, and lets an
|
|
21
|
-
* adopter who promotes the code to `error` fail their build with it. Two verbs
|
|
22
|
-
* because they are two acts, and folding a verdict into the query would make
|
|
23
|
-
* the query's number a number people learn to stop reading.
|
|
24
|
-
*
|
|
25
|
-
* ## Everything below is orchestration — deliberately
|
|
26
|
-
*
|
|
27
|
-
* Which directories exist, what each pays, and whether that is over budget are
|
|
28
|
-
* all decided in `@vibe-agent-toolkit/resources` (`buildClaudeContextPopulation`
|
|
29
|
-
* and `sweepAlwaysLoadedBudgets`); the wording and grouping of the findings in
|
|
30
|
-
* `utils/context-budget-issues.ts`; severity resolution in the two shared
|
|
31
|
-
* filters every other lane runs. This module populates one tree, calls them in
|
|
32
|
-
* order, and renders. It decides nothing about context loading of its own,
|
|
33
|
-
* which is the CLI-stays-dumb rule applied to the lane where the temptation is
|
|
34
|
-
* strongest.
|
|
35
|
-
*
|
|
36
|
-
* ⛔ The threshold is never re-spelled here. It is a MEASURED quantity that
|
|
37
|
-
* lives beside the detector (`DEFAULT_ALWAYS_LOADED_CONTEXT_TOKENS`), and a
|
|
38
|
-
* literal in this package would be a second source of truth that nothing
|
|
39
|
-
* compares.
|
|
40
|
-
*
|
|
41
|
-
* ## The stated bounds ride ONCE on the REPORT, in every format
|
|
42
|
-
*
|
|
43
|
-
* The sibling query publishes 23 stated limits; this command applies a threshold
|
|
44
|
-
* to the same measurement, so it publishes {@link ALWAYS_LOADED_BUDGET_LIMITS}
|
|
45
|
-
* and {@link CLAUDE_CONTEXT_BOUNDS_STATEMENT} beside its verdict — the half that
|
|
46
|
-
* GATES is the half whose bounds a reader most needs. Both are imported, never
|
|
47
|
-
* restated: the sentence is domain content owned beside the list it frames.
|
|
48
|
-
*
|
|
49
|
-
* ⛔ They belong to the REPORT, never to a finding. A per-finding copy is the
|
|
50
|
-
* defect this lane already shipped once on the query side, and it is invisible to
|
|
51
|
-
* any assertion that checks presence rather than counting occurrences.
|
|
52
|
-
*/
|
|
53
|
-
import { ALWAYS_LOADED_BUDGET_LIMITS, buildClaudeContextPopulation, CLAUDE_CONTEXT_BOUNDS_STATEMENT, DEFAULT_ALWAYS_LOADED_CONTEXT_TOKENS, sweepAlwaysLoadedBudgets, } from '@vibe-agent-toolkit/resources';
|
|
54
|
-
import { applyAllowFilter, buildReport as buildEnvelope, exitCodeForSeverityCounts, reportSchema, toFindings, } from '@vibe-agent-toolkit/schema';
|
|
55
|
-
import { findProjectRoot } from '@vibe-agent-toolkit/utils';
|
|
56
|
-
import { Command, Option } from 'commander';
|
|
57
|
-
import { z } from 'zod';
|
|
58
|
-
import { handleReportCommandError } from '../../utils/command-error.js';
|
|
59
|
-
import { loadConfig } from '../../utils/config-loader.js';
|
|
60
|
-
import { contextBudgetIssues, scopeSweepToPaths } from '../../utils/context-budget-issues.js';
|
|
61
|
-
import { targetPathWithin } from '../../utils/corpus-target.js';
|
|
62
|
-
import { resolveIssueSeverity } from '../../utils/issue-severity.js';
|
|
63
|
-
import { createLogger } from '../../utils/logger.js';
|
|
64
|
-
import { writeJsonOutput, writeStdoutSync, writeYamlOutput } from '../../utils/output.js';
|
|
65
|
-
import { populationWiring } from '../../utils/population-wiring.js';
|
|
66
|
-
import { withPopulationCache } from '../../utils/projection-store.js';
|
|
67
|
-
import { runIntegrityFinding } from '../../utils/run-integrity.js';
|
|
68
|
-
import { gitTrackerForProjectRoot } from '../audit/distributed-tree.js';
|
|
69
|
-
/** How this command names itself in a refusal. */
|
|
70
|
-
const COMMAND_NAME = 'vat claude budget';
|
|
71
|
-
/** Soft wrap width for the printed limit statements. */
|
|
72
|
-
const WRAP_COLUMNS = 96;
|
|
73
|
-
/** How the corpus root itself is named to a reader — it has no path of its own. */
|
|
74
|
-
const CORPUS_ROOT_LABEL = '<corpus root>';
|
|
75
|
-
/** A signed bound on the measurement method, as `@vibe-agent-toolkit/resources` states it. */
|
|
76
|
-
const StatedLimitSchema = z.object({
|
|
77
|
-
id: z.string(),
|
|
78
|
-
direction: z.enum(['over-report', 'under-report', 'scope', 'assumption']),
|
|
79
|
-
statement: z.string(),
|
|
80
|
-
}).strict();
|
|
81
|
-
/**
|
|
82
|
-
* What one run reports beyond its findings.
|
|
83
|
-
*
|
|
84
|
-
* The sweep counters describe the WHOLE tree, not the scope: a scope narrows
|
|
85
|
-
* what is reported, never what was measured. The envelope's `examined` is the
|
|
86
|
-
* working-location count for the same reason — "9 chains checked, none over
|
|
87
|
-
* budget" and "nothing was checked" are different answers and must not render
|
|
88
|
-
* identically.
|
|
89
|
-
*/
|
|
90
|
-
export const BudgetDataSchema = z.object({
|
|
91
|
-
root: z.string(),
|
|
92
|
-
/** The budget every chain was measured against, in tokens. */
|
|
93
|
-
threshold: z.number().int().nonnegative(),
|
|
94
|
-
/** The root-relative directories asked about. `''` is the whole tree. */
|
|
95
|
-
scope: z.array(z.string()),
|
|
96
|
-
/** Requested paths that named no working location — see `scopeSweepToPaths`. */
|
|
97
|
-
unmatchedScope: z.array(z.string()),
|
|
98
|
-
/** Distinct instruction chains among the working locations — the queries the sweep really issued. */
|
|
99
|
-
distinctChains: z.number().int().nonnegative(),
|
|
100
|
-
/** Locations whose representative the projection never realized. Counted, never zeroed. */
|
|
101
|
-
skippedUnknownLocations: z.number().int().nonnegative(),
|
|
102
|
-
/**
|
|
103
|
-
* What this verdict does not settle, in either direction. Stated ONCE.
|
|
104
|
-
*
|
|
105
|
-
* ⛔ On the report beside `threshold`, never on a finding. These bound the
|
|
106
|
-
* MEASUREMENT METHOD, not any one chain — a finding carrying its own copy
|
|
107
|
-
* reads as though that chain had caveats of its own, and repeated across a
|
|
108
|
-
* sweep it is pure byte-identical duplication.
|
|
109
|
-
*/
|
|
110
|
-
boundsStatement: z.string(),
|
|
111
|
-
/** The signed over/under-report bounds on the method. Stated ONCE. */
|
|
112
|
-
limits: z.array(StatedLimitSchema),
|
|
113
|
-
}).strict();
|
|
114
|
-
/** The document this command publishes. */
|
|
115
|
-
export const BUDGET_REPORT_SCHEMA = reportSchema(BudgetDataSchema);
|
|
116
|
-
/**
|
|
117
|
-
* Create the `vat claude budget [paths...]` command.
|
|
118
|
-
*
|
|
119
|
-
* @returns The configured Commander command
|
|
120
|
-
*/
|
|
121
|
-
export function createBudgetCommand() {
|
|
122
|
-
const command = new Command('budget');
|
|
123
|
-
command
|
|
124
|
-
.description('Check whether the always-loaded context at a working location exceeds its budget')
|
|
125
|
-
.argument('[paths...]', 'Directories to check, with everything beneath them (default: the whole tree)')
|
|
126
|
-
.addOption(new Option('--format <format>', 'Output format: text (default), yaml, or json').choices([
|
|
127
|
-
'text',
|
|
128
|
-
'yaml',
|
|
129
|
-
'json',
|
|
130
|
-
]).default('text'))
|
|
131
|
-
.option('--debug', 'Verbose logging to stderr')
|
|
132
|
-
.action(claudeBudgetCommand)
|
|
133
|
-
.addHelpText('after', `
|
|
134
|
-
Description:
|
|
135
|
-
Reports ALWAYS_LOADED_CONTEXT_BUDGET for each instruction chain whose
|
|
136
|
-
always-loaded context exceeds the budget. The measured chain is the
|
|
137
|
-
repo-root CLAUDE.md, every CLAUDE.md on the path down to the working
|
|
138
|
-
location, one level of @ imports from each, and any unscoped rules file in
|
|
139
|
-
the root .claude/rules/. An AGENTS.md is measured only where a CLAUDE.md
|
|
140
|
-
imports it (@AGENTS.md) — Claude Code does not load it by name, so a repo
|
|
141
|
-
standardised on AGENTS.md alone has nothing here to measure. Path-scoped
|
|
142
|
-
rules (a paths: list) are excluded: they load when the agent touches a
|
|
143
|
-
matching file, not at launch.
|
|
144
|
-
|
|
145
|
-
ONE finding per chain, not per directory: directories loading the same files
|
|
146
|
-
share a finding, which names how many working locations pay it. Naming paths
|
|
147
|
-
narrows WHICH chains are reported; the payer count stays the whole tree's,
|
|
148
|
-
because that is the number that was measured.
|
|
149
|
-
|
|
150
|
-
This is the CHECK. 'vat claude context' is the QUERY — same lane, no
|
|
151
|
-
threshold and no verdict.
|
|
152
|
-
|
|
153
|
-
Configuration (vibe-agent-toolkit.config.yaml):
|
|
154
|
-
resources.validation.thresholds.alwaysLoadedContextTokens moves the budget
|
|
155
|
-
(default ${String(DEFAULT_ALWAYS_LOADED_CONTEXT_TOKENS)}). resources.validation.severity.ALWAYS_LOADED_CONTEXT_BUDGET
|
|
156
|
-
silences it (ignore) or promotes it to warning/error. A project with no
|
|
157
|
-
config file is checked at the same default budget.
|
|
158
|
-
|
|
159
|
-
Output:
|
|
160
|
-
- threshold: the budget every chain was measured against
|
|
161
|
-
- scope/unmatchedScope: what was asked about, and what matched nothing.
|
|
162
|
-
A path that matched nothing was NOT checked, so it is
|
|
163
|
-
reported as a RESOURCE_CHECK_BROKEN error rather than
|
|
164
|
-
passing quietly -- and that code is not configurable
|
|
165
|
-
- status/summary: ok, findings, or error; plus the count per severity
|
|
166
|
-
- examined: working locations evaluated across the WHOLE tree,
|
|
167
|
-
so an empty findings list is legible
|
|
168
|
-
- findings: one per over-budget chain, ascending by directory
|
|
169
|
-
- data.distinctChains, data.skippedUnknownLocations: whole-tree facts
|
|
170
|
-
- data.limits/boundsStatement: what this verdict does not settle, signed
|
|
171
|
-
over-report or under-report. On the REPORT, never on a
|
|
172
|
-
finding — they bound the method, not any one chain, so
|
|
173
|
-
they are stated exactly once however many chains flag
|
|
174
|
-
|
|
175
|
-
Text to stdout by default; --format yaml|json for a program. Diagnostics
|
|
176
|
-
and blob-stage refusals go to stderr.
|
|
177
|
-
|
|
178
|
-
Exit Codes:
|
|
179
|
-
0 - Reported (findings at the default info severity do not gate)
|
|
180
|
-
1 - A finding resolved to error severity via config, or a requested path
|
|
181
|
-
matched no working location so nothing was checked there
|
|
182
|
-
2 - System error (a path outside the corpus root, unreadable tree)
|
|
183
|
-
|
|
184
|
-
Example:
|
|
185
|
-
$ vat claude budget packages/cli # is it over budget where I work?
|
|
186
|
-
`);
|
|
187
|
-
return command;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Action handler for `vat claude budget [paths...]`.
|
|
191
|
-
*
|
|
192
|
-
* @param pathArgs - Directories to check; empty means the whole tree
|
|
193
|
-
* @param options - The command's flags
|
|
194
|
-
*/
|
|
195
|
-
export async function claudeBudgetCommand(pathArgs, options) {
|
|
196
|
-
const logger = createLogger(options.debug === true ? { debug: true } : {});
|
|
197
|
-
const startTime = Date.now();
|
|
198
|
-
try {
|
|
199
|
-
const root = findProjectRoot(process.cwd()) ?? process.cwd();
|
|
200
|
-
// 🔑 Every argument is resolved BEFORE the population. A path outside the
|
|
201
|
-
// corpus is a usage error, and finding it afterwards would charge the caller
|
|
202
|
-
// a full population — minutes on a cold cache — to be told they mistyped.
|
|
203
|
-
const scope = scopeWithin(root, pathArgs);
|
|
204
|
-
const config = loadConfig(root);
|
|
205
|
-
const validation = config?.resources?.validation;
|
|
206
|
-
const threshold = validation?.thresholds?.alwaysLoadedContextTokens
|
|
207
|
-
?? DEFAULT_ALWAYS_LOADED_CONTEXT_TOKENS;
|
|
208
|
-
const sweep = await sweepBudgets(root, threshold, logger);
|
|
209
|
-
const scoped = scopeSweepToPaths(sweep, scope);
|
|
210
|
-
// The same two shared mechanisms every other lane uses, in the same order:
|
|
211
|
-
// `validation.allow` suppresses by path glob, then `validation.severity`
|
|
212
|
-
// resolves — BOTH directions, so an adopter promoting this code to `error`
|
|
213
|
-
// gets an error, which is the case that gets forgotten.
|
|
214
|
-
const findings = resolveIssueSeverity(applyAllowFilter(contextBudgetIssues(scoped.sweep), validation ?? {}).emitted, validation);
|
|
215
|
-
warnUnmatched(scoped.unmatchedScope, logger);
|
|
216
|
-
const report = { ...buildReport({ root, threshold, scope, sweep, scoped, findings }), durationMs: Date.now() - startTime };
|
|
217
|
-
emit(report, options.format ?? 'text');
|
|
218
|
-
// `error` gates, and it is reachable two ways: an adopter promoted
|
|
219
|
-
// ALWAYS_LOADED_CONTEXT_BUDGET, or the run checked nothing — see
|
|
220
|
-
// {@link nothingCheckedFindings}. At the code's `info` default the first
|
|
221
|
-
// never fires, so the budget cannot fail a build unless an adopter asked it
|
|
222
|
-
// to; the second is not a severity anybody may configure away.
|
|
223
|
-
process.exit(exitCodeForSeverityCounts(report.summary));
|
|
224
|
-
}
|
|
225
|
-
catch (error) {
|
|
226
|
-
handleReportCommandError(error, logger, startTime, 'claude budget', options.format);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Assemble the report from the run's parts.
|
|
231
|
-
*
|
|
232
|
-
* ⛔ The counters come from the UNSCOPED sweep. They answer "what was measured",
|
|
233
|
-
* and a scope changes only what is reported — sourcing them from the narrowed
|
|
234
|
-
* view would let `vat claude budget docs` claim the tree has one chain.
|
|
235
|
-
*
|
|
236
|
-
* ⛔ This is the ONE place the stated bounds enter the machine-readable output,
|
|
237
|
-
* and keeping it a single assignment is what makes "stated once" structural
|
|
238
|
-
* rather than a habit: there is no per-finding site left where a copy could be
|
|
239
|
-
* reintroduced. They are attached unconditionally — a run that flagged nothing
|
|
240
|
-
* used the same method, and a reader acting on "within budget" needs them most.
|
|
241
|
-
*
|
|
242
|
-
* ⛔ Exported so it can be TESTED. What has to be pinned is a COUNT — that the
|
|
243
|
-
* block appears exactly once across a MULTI-finding report — and a presence
|
|
244
|
-
* check passes identically with a copy per finding.
|
|
245
|
-
*
|
|
246
|
-
* ⛔ The run-integrity refusal is DERIVED here from `scoped.unmatchedScope`
|
|
247
|
-
* rather than assembled by the caller, which is what makes "a run that checked
|
|
248
|
-
* nothing never reports success" unrepresentable instead of merely observed:
|
|
249
|
-
* there is no pipeline step left in which a later edit could drop it. See
|
|
250
|
-
* {@link nothingCheckedFindings}.
|
|
251
|
-
*
|
|
252
|
-
* @param input - The run's parts
|
|
253
|
-
* @returns The report, ready to serialize
|
|
254
|
-
*/
|
|
255
|
-
export function buildReport(input) {
|
|
256
|
-
const { root, threshold, scope, sweep, scoped, findings } = input;
|
|
257
|
-
// The run-integrity report LEADS: every budget finding beneath it is noise
|
|
258
|
-
// until the operator knows part of what they asked about was never measured.
|
|
259
|
-
const reported = [...nothingCheckedFindings(scoped.unmatchedScope), ...findings];
|
|
260
|
-
return buildEnvelope({
|
|
261
|
-
examined: sweep.evaluatedDirectories,
|
|
262
|
-
findings: toFindings(reported),
|
|
263
|
-
data: {
|
|
264
|
-
root,
|
|
265
|
-
threshold,
|
|
266
|
-
scope: [...scope],
|
|
267
|
-
unmatchedScope: [...scoped.unmatchedScope],
|
|
268
|
-
distinctChains: sweep.queriedDirectories,
|
|
269
|
-
skippedUnknownLocations: sweep.skippedUnknownLocations,
|
|
270
|
-
boundsStatement: CLAUDE_CONTEXT_BOUNDS_STATEMENT,
|
|
271
|
-
limits: [...ALWAYS_LOADED_BUDGET_LIMITS],
|
|
272
|
-
},
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Resolve the requested scope, defaulting to the whole tree.
|
|
277
|
-
*
|
|
278
|
-
* ⚠️ No arguments means the WHOLE TREE, not the current directory — the
|
|
279
|
-
* opposite of `vat claude context`'s default, and deliberately so. This is a
|
|
280
|
-
* check: the useful bare invocation is "tell me about everything", the way a
|
|
281
|
-
* linter run from a subdirectory still lints the project. Naming a directory is
|
|
282
|
-
* how a caller asks the narrower question.
|
|
283
|
-
*
|
|
284
|
-
* @param root - The discovered project root
|
|
285
|
-
* @param pathArgs - The path arguments, possibly empty
|
|
286
|
-
* @returns Root-relative directories; `['']` for the whole tree
|
|
287
|
-
*/
|
|
288
|
-
function scopeWithin(root, pathArgs) {
|
|
289
|
-
if (pathArgs.length === 0)
|
|
290
|
-
return [''];
|
|
291
|
-
return pathArgs.map((pathArg) => targetPathWithin(root, pathArg, COMMAND_NAME));
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Say so, loudly, when a requested path named no working location.
|
|
295
|
-
*
|
|
296
|
-
* ⛔ `warn` (stderr), never `debug`. The human half of
|
|
297
|
-
* {@link nothingCheckedFindings} — the same fact, on the channel a person reads,
|
|
298
|
-
* ahead of the report rather than inside it.
|
|
299
|
-
*
|
|
300
|
-
* @param unmatched - The requested paths that matched nothing
|
|
301
|
-
* @param logger - Where the warning goes
|
|
302
|
-
*/
|
|
303
|
-
function warnUnmatched(unmatched, logger) {
|
|
304
|
-
if (unmatched.length === 0)
|
|
305
|
-
return;
|
|
306
|
-
logger.warn(`Warning: no working location matched ${unmatched.join(', ')} — nothing was checked there.`
|
|
307
|
-
+ ' This is NOT a report that those paths are within budget.');
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* The refusal for a run whose requested paths named no working location.
|
|
311
|
-
*
|
|
312
|
-
* 🔑 **A gate that checked nothing must never answer `success`.** This shipped:
|
|
313
|
-
* `vat claude budget no/such/dir` reported `status: success` on exit 0, because
|
|
314
|
-
* an unmatched scope measures zero chains and zero findings serializes
|
|
315
|
-
* identically to "everything you asked about is within budget". The command
|
|
316
|
-
* already knew — it warned on stderr that nothing had been checked — and then
|
|
317
|
-
* published a document saying the opposite. Only the document gates a build, so
|
|
318
|
-
* the two channels disagreed on the half that matters.
|
|
319
|
-
*
|
|
320
|
-
* 🪤 {@link warnUnmatched} still says the same thing on stderr, and that is not
|
|
321
|
-
* the duplication this file bans elsewhere: stderr is the human channel and
|
|
322
|
-
* stdout is the parsed document, so the two are one statement per audience. What
|
|
323
|
-
* was wrong was never that the warning existed — it was that the DOCUMENT
|
|
324
|
-
* contradicted it, and the exit code was computed from the document.
|
|
325
|
-
*
|
|
326
|
-
* ⛔ Not repeated a THIRD time inside the text rendering, though. That shares a
|
|
327
|
-
* channel with the finding, which {@link renderReportText} already prints.
|
|
328
|
-
*
|
|
329
|
-
* The precedent is `vat resources check`'s `emptyCorpusFinding`, and this
|
|
330
|
-
* follows it through the shared {@link runIntegrityFinding} rather than
|
|
331
|
-
* inventing a third convention — `RESOURCE_CHECK_BROKEN` at `error`, derived in
|
|
332
|
-
* {@link buildReport} rather than assembled in the handler, so it bypasses
|
|
333
|
-
* `applyAllowFilter` and `resolveIssueSeverity` by construction and no report
|
|
334
|
-
* carrying an unmatched path can be built with a clean status. The reasoning
|
|
335
|
-
* behind each of those lives with the mechanism, in `run-integrity.ts`.
|
|
336
|
-
*
|
|
337
|
-
* ⛔ ONE finding however many paths went unmatched. The claim is about the RUN,
|
|
338
|
-
* and one per argument is the per-finding duplication this report is built to
|
|
339
|
-
* make impossible. It is not routed through `nothingCheckedFinding` because the
|
|
340
|
-
* denominator here is not a count but a list of names the message must carry.
|
|
341
|
-
*
|
|
342
|
-
* @param unmatched - The requested paths that matched no working location
|
|
343
|
-
* @returns The finding, or nothing when everything asked about was checked
|
|
344
|
-
*/
|
|
345
|
-
function nothingCheckedFindings(unmatched) {
|
|
346
|
-
if (unmatched.length === 0)
|
|
347
|
-
return [];
|
|
348
|
-
const named = unmatched.map((path) => (path === '' ? CORPUS_ROOT_LABEL : path)).join(', ');
|
|
349
|
-
return [runIntegrityFinding(`No working location matched ${named}, so nothing was checked there and this`
|
|
350
|
-
+ ' report is NOT a statement that those paths are within budget.'
|
|
351
|
-
+ ' A working location is any non-ignored directory holding an enumerated file,'
|
|
352
|
-
+ ' so a path matching none is usually a typo, a directory that is empty, or one'
|
|
353
|
-
+ ' `.gitignore` declines — and the whole corpus root matching none means the'
|
|
354
|
-
+ ' enumeration came back empty, which a broad ignore pattern or a shallow or'
|
|
355
|
-
+ ' sparse checkout produces.'
|
|
356
|
-
+ ' `vat resources scan` over the same path lists what an enumeration finds.')];
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Populate the Claude-context lane for one tree and sweep every location.
|
|
360
|
-
*
|
|
361
|
-
* ⚠️ Roots at the discovered project root and NOWHERE else, whatever paths were
|
|
362
|
-
* named. A budget is a property of a position in the directory tree, and rooting
|
|
363
|
-
* a population at a subdirectory would compute one against a corpus whose
|
|
364
|
-
* ancestors are missing — a confidently wrong number.
|
|
365
|
-
*
|
|
366
|
-
* @param root - The absolute corpus root; the ONLY tree populated
|
|
367
|
-
* @param threshold - The always-loaded token budget
|
|
368
|
-
* @param logger - Where blob-stage refusals go. **stderr**, never stdout: this
|
|
369
|
-
* command's stdout is the document a caller parses
|
|
370
|
-
* @returns Every working location's budget
|
|
371
|
-
*/
|
|
372
|
-
async function sweepBudgets(root, threshold, logger) {
|
|
373
|
-
const projection = await withPopulationCache({ root }, async (cache) => {
|
|
374
|
-
const gitTracker = await gitTrackerForProjectRoot(root);
|
|
375
|
-
return buildClaudeContextPopulation({ root, ...populationWiring(logger, gitTracker, cache, root) });
|
|
376
|
-
});
|
|
377
|
-
return sweepAlwaysLoadedBudgets(projection, threshold);
|
|
378
|
-
}
|
|
379
|
-
/**
|
|
380
|
-
* Write the report in the requested format.
|
|
381
|
-
*
|
|
382
|
-
* @param report - The report
|
|
383
|
-
* @param format - The selected format
|
|
384
|
-
*/
|
|
385
|
-
function emit(report, format) {
|
|
386
|
-
if (format === 'json') {
|
|
387
|
-
writeJsonOutput(report);
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
if (format === 'yaml') {
|
|
391
|
-
writeYamlOutput(report);
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
writeStdoutSync(renderReportText(report));
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Render the report for a person.
|
|
398
|
-
*
|
|
399
|
-
* ⛔ Exported so the "stated once" property can be pinned in TEXT as well as in
|
|
400
|
-
* json. The two renderings are separate code paths and this lane has already
|
|
401
|
-
* shipped a defect where they disagreed while each looked right alone.
|
|
402
|
-
*
|
|
403
|
-
* @param report - The report
|
|
404
|
-
* @returns The text rendering, newline-terminated
|
|
405
|
-
*/
|
|
406
|
-
export function renderReportText(report) {
|
|
407
|
-
const lines = [
|
|
408
|
-
`Always-loaded context budget at ${report.data.root}`,
|
|
409
|
-
` budget ${count(report.data.threshold)} tokens`
|
|
410
|
-
+ ` · ${count(report.examined)} working locations`
|
|
411
|
-
+ ` · ${count(report.data.distinctChains)} distinct chains`
|
|
412
|
-
+ ` · ${count(report.data.skippedUnknownLocations)} unrealized`,
|
|
413
|
-
'',
|
|
414
|
-
...findingLines(report.findings),
|
|
415
|
-
...limitLines(report.data),
|
|
416
|
-
];
|
|
417
|
-
return `${lines.join('\n')}\n`;
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* The stated bounds, printed once at the foot of the report.
|
|
421
|
-
*
|
|
422
|
-
* ⛔ Never omitted, and never per finding. A clean report is subject to exactly
|
|
423
|
-
* the same signed bounds as a flagged one — more so, since "within budget" is the
|
|
424
|
-
* verdict a reader is most likely to act on without reading further.
|
|
425
|
-
*
|
|
426
|
-
* The sibling `vat claude context` prints a section of the same shape from its
|
|
427
|
-
* own list. They are deliberately NOT sharing a renderer: two commands, two
|
|
428
|
-
* report types, and the query additionally prints the modelled-behaviour
|
|
429
|
-
* citations that no bound of this verdict rests on.
|
|
430
|
-
*
|
|
431
|
-
* @param data - The report's data, carrying the bounds
|
|
432
|
-
* @returns The section's lines
|
|
433
|
-
*/
|
|
434
|
-
function limitLines(data) {
|
|
435
|
-
const lines = ['What this verdict does not settle', ...wrapped(data.boundsStatement, ' '), ''];
|
|
436
|
-
for (const limit of data.limits) {
|
|
437
|
-
lines.push(` ${limit.direction}: ${limit.id}`);
|
|
438
|
-
lines.push(...wrapped(limit.statement, ' '));
|
|
439
|
-
}
|
|
440
|
-
return lines;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Soft-wrap a statement under a fixed indent.
|
|
444
|
-
*
|
|
445
|
-
* The statements run to several sentences and are the part of this output a
|
|
446
|
-
* reader has to actually read; unwrapped they arrive as one 500-column line that
|
|
447
|
-
* a terminal breaks mid-word. A word longer than the width overflows its own line
|
|
448
|
-
* rather than being split — no character of a statement is ever dropped.
|
|
449
|
-
*
|
|
450
|
-
* @param text - The statement
|
|
451
|
-
* @param indent - Leading whitespace for every produced line
|
|
452
|
-
* @returns One or more indented lines
|
|
453
|
-
*/
|
|
454
|
-
function wrapped(text, indent) {
|
|
455
|
-
const width = Math.max(WRAP_COLUMNS - indent.length, 24);
|
|
456
|
-
const lines = [];
|
|
457
|
-
let pending = '';
|
|
458
|
-
for (const word of text.split(' ')) {
|
|
459
|
-
const candidate = pending === '' ? word : `${pending} ${word}`;
|
|
460
|
-
if (pending !== '' && candidate.length > width) {
|
|
461
|
-
lines.push(indent + pending);
|
|
462
|
-
pending = word;
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
pending = candidate;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
if (pending !== '')
|
|
469
|
-
lines.push(indent + pending);
|
|
470
|
-
return lines;
|
|
471
|
-
}
|
|
472
|
-
/**
|
|
473
|
-
* The findings, or the sentence that says there were none.
|
|
474
|
-
*
|
|
475
|
-
* ⛔ The empty case is a SENTENCE, not blank output. A command that prints
|
|
476
|
-
* nothing is indistinguishable from one that failed to run.
|
|
477
|
-
*
|
|
478
|
-
* @param findings - The reported findings
|
|
479
|
-
* @returns The lines, blank-terminated
|
|
480
|
-
*/
|
|
481
|
-
function findingLines(findings) {
|
|
482
|
-
if (findings.length === 0)
|
|
483
|
-
return ['Every instruction chain checked is within budget.', ''];
|
|
484
|
-
const lines = [];
|
|
485
|
-
for (const finding of findings) {
|
|
486
|
-
lines.push(`${finding.severity} ${finding.code} at ${finding.location ?? CORPUS_ROOT_LABEL}`);
|
|
487
|
-
lines.push(` ${finding.message}`);
|
|
488
|
-
if (finding.fix !== undefined)
|
|
489
|
-
lines.push(` Fix: ${finding.fix}`);
|
|
490
|
-
lines.push('');
|
|
491
|
-
}
|
|
492
|
-
return lines;
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* A count as a reader reads it.
|
|
496
|
-
*
|
|
497
|
-
* Pinned to `en-US` rather than left to the host locale, so the same run renders
|
|
498
|
-
* byte-identically on two developers' machines — the same rule the findings
|
|
499
|
-
* themselves follow in `utils/context-budget-issues.ts`.
|
|
500
|
-
*
|
|
501
|
-
* @param value - The number
|
|
502
|
-
* @returns Its thousands-separated form
|
|
503
|
-
*/
|
|
504
|
-
function count(value) {
|
|
505
|
-
return value.toLocaleString('en-US');
|
|
506
|
-
}
|
|
507
|
-
//# sourceMappingURL=budget.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../../../src/commands/claude/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,+BAA+B,EAC/B,oCAAoC,EACpC,wBAAwB,GAEzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,WAAW,IAAI,aAAa,EAC5B,yBAAyB,EAGzB,YAAY,EACZ,UAAU,GAEX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EA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f,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,QAA4B;IAChD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,mDAAmD,EAAE,EAAE,CAAC,CAAC;IAC5F,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,OAAO,OAAO,CAAC,QAAQ,IAAI,iBAAiB,EAAE,CAAC,CAAC;QAC9F,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QACnC,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,UAAU,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACnE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,KAAK,CAAC,KAAa;IAC1B,OAAO,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The always-loaded context budget sweep, rendered as validation findings.
|
|
3
|
-
*
|
|
4
|
-
* Pure: no I/O, no config, no severity resolution, no exit code. It takes the
|
|
5
|
-
* {@link BudgetSweep} `@vibe-agent-toolkit/resources` produced and answers
|
|
6
|
-
* "which of these does a reader need to be told about, and in what words". The
|
|
7
|
-
* command that calls it stays a thin orchestrator, and this file is where the
|
|
8
|
-
* decision worth testing lives.
|
|
9
|
-
*
|
|
10
|
-
* ## ONE issue per REPRESENTATIVE, never one per working location
|
|
11
|
-
*
|
|
12
|
-
* A sweep reports every working location, and locations sharing an instruction
|
|
13
|
-
* chain share one budget — that is the whole point of the collapse. Re-measured
|
|
14
|
-
* on VAT's own tree, after the context population began declining the
|
|
15
|
-
* gitignored half: **366 of 589 directories** pay the single chain
|
|
16
|
-
* `['CLAUDE.md']`, so emitting per location would print 366 byte-identical
|
|
17
|
-
* findings, all blaming one file, the moment the root `CLAUDE.md` crossed the
|
|
18
|
-
* budget. (It read *"553 of 819"* against the wider population; the ratio barely
|
|
19
|
-
* moved, and the argument does not turn on it.) There are **9** distinct chains
|
|
20
|
-
* on this tree either way, so per-representative emission caps the output at 9
|
|
21
|
-
* findings at any threshold.
|
|
22
|
-
*
|
|
23
|
-
* That is not a formatting preference. A check that emits 366 findings for one
|
|
24
|
-
* cause is a check an adopter silences with
|
|
25
|
-
* `severity.ALWAYS_LOADED_CONTEXT_BUDGET: ignore` rather than fixes — and a
|
|
26
|
-
* silenced check reports nothing forever, which is strictly worse than the
|
|
27
|
-
* finding it was trying to deliver.
|
|
28
|
-
*
|
|
29
|
-
* ## What the message may and may not claim
|
|
30
|
-
*
|
|
31
|
-
* ⛔ Never "the total cost". A global `~/.claude/CLAUDE.md` and the enabled skill
|
|
32
|
-
* index are real always-loaded cost that this TREE-ONLY projection cannot see, so
|
|
33
|
-
* even a budget reporting zero exclusions is a floor — see the module doc of
|
|
34
|
-
* `packages/resources/src/projection/claude-context-budget.ts`, which states the
|
|
35
|
-
* bound precisely and which this wording must not contradict. The messages here
|
|
36
|
-
* therefore say "estimated at", and the narrower, checkable claim carried by
|
|
37
|
-
* {@link AlwaysLoadedBudget.lowerBound} — that rows VAT *did* see were left out
|
|
38
|
-
* of the sum — is appended as its own sentence with the three counts behind it.
|
|
39
|
-
*
|
|
40
|
-
* 🔑 `excludedRuleRows` is deliberately NOT one of those counts. What it counts is
|
|
41
|
-
* PATH-SCOPED rules — the ones carrying a `paths:` list — and those are excluded
|
|
42
|
-
* by DESIGN: they are `selected`, not `always`, so their absence from the sum is a
|
|
43
|
-
* decision rather than a gap in what we know, and only ignorance makes a sum a
|
|
44
|
-
* lower bound.
|
|
45
|
-
*
|
|
46
|
-
* ⛔ Not "rules files" as a class. An UNSCOPED rule in the root `.claude/rules/`
|
|
47
|
-
* is classed `always` and IS charged into the budget — nothing gates it on a path,
|
|
48
|
-
* so it loads at launch exactly as a CLAUDE.md does. The blanket reading was true
|
|
49
|
-
* while every rule was excluded and became a false statement about a check that
|
|
50
|
-
* gates the moment the root-rule admission started qualifying. It matters here
|
|
51
|
-
* because the largest contributor a message names may now be a rules file, which
|
|
52
|
-
* is why the registry `fix` points at the named contributors rather than at a file
|
|
53
|
-
* type.
|
|
54
|
-
*/
|
|
55
|
-
import type { BudgetSweep } from '@vibe-agent-toolkit/resources';
|
|
56
|
-
import { type ValidationIssue } from '@vibe-agent-toolkit/schema';
|
|
57
|
-
/** A sweep narrowed to the paths a caller asked about, and what did not match. */
|
|
58
|
-
export interface ScopedSweep {
|
|
59
|
-
/**
|
|
60
|
-
* The narrowed sweep.
|
|
61
|
-
*
|
|
62
|
-
* ⚠️ It retains EVERY location of every selected chain, not only the ones
|
|
63
|
-
* inside the scope — see {@link scopeSweepToPaths} for why that is the whole
|
|
64
|
-
* point rather than an oversight.
|
|
65
|
-
*/
|
|
66
|
-
readonly sweep: BudgetSweep;
|
|
67
|
-
/**
|
|
68
|
-
* Requested paths that named no working location in this sweep.
|
|
69
|
-
*
|
|
70
|
-
* ⛔ Reported rather than dropped. A scope that matched nothing produces zero
|
|
71
|
-
* findings, which is byte-identical to "everything you asked about is within
|
|
72
|
-
* budget" — the one confusion this field exists to prevent.
|
|
73
|
-
*/
|
|
74
|
-
readonly unmatchedScope: readonly string[];
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Narrow a sweep to the instruction chains the requested paths inherit.
|
|
78
|
-
*
|
|
79
|
-
* ## The retention rule, which is the whole design
|
|
80
|
-
*
|
|
81
|
-
* A scope selects CHAINS, never payers. Every location paying a selected chain
|
|
82
|
-
* is retained even when it sits outside the scope, because the finding's message
|
|
83
|
-
* says how many working locations pay it — and that number is a fact about the
|
|
84
|
-
* TREE. Retaining only the in-scope payers would make `vat claude budget
|
|
85
|
-
* docs/guides` report *"1 working location pays it"* for a chain 366 directories
|
|
86
|
-
* pay: a confidently wrong number, which costs more than no number.
|
|
87
|
-
*
|
|
88
|
-
* ## Matching is on SEGMENT boundaries
|
|
89
|
-
*
|
|
90
|
-
* `'packages/cli-x'.startsWith('packages/cli')` is true, so a bare prefix test
|
|
91
|
-
* hands a sibling directory its neighbour's scope. The same trap
|
|
92
|
-
* `representativeFor` in `claude-context-budget-sweep.ts` exists to avoid, one
|
|
93
|
-
* layer down.
|
|
94
|
-
*
|
|
95
|
-
* @param sweep - Every working location's budget, from `sweepAlwaysLoadedBudgets`
|
|
96
|
-
* @param scope - Root-relative directories to report for. `''` is the corpus
|
|
97
|
-
* root and selects the whole tree; an empty list selects nothing
|
|
98
|
-
* @returns The narrowed sweep and the requested paths that matched no location
|
|
99
|
-
*/
|
|
100
|
-
export declare function scopeSweepToPaths(sweep: BudgetSweep, scope: readonly string[]): ScopedSweep;
|
|
101
|
-
/**
|
|
102
|
-
* One finding per over-budget instruction chain, ordered for a clean diff.
|
|
103
|
-
*
|
|
104
|
-
* @param sweep - Every working location's budget, from `sweepAlwaysLoadedBudgets`
|
|
105
|
-
* @returns The issues, ascending by representative directory (code point)
|
|
106
|
-
*/
|
|
107
|
-
export declare function contextBudgetIssues(sweep: BudgetSweep): ValidationIssue[];
|
|
108
|
-
//# sourceMappingURL=context-budget-issues.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-budget-issues.d.ts","sourceRoot":"","sources":["../../src/utils/context-budget-issues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAuB,KAAK,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAYvF,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,CAoB3F;AA4BD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,EAAE,CAKzE"}
|