@vibe-agent-toolkit/cli 0.2.0-rc.2 → 0.2.0-rc.4
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/bin/vat +68 -16
- package/dist/bin/vat.js +68 -16
- package/dist/bin/vat.js.map +1 -1
- package/dist/bin.js +157 -37
- package/dist/bin.js.map +1 -1
- package/dist/command-loaders.d.ts +44 -0
- package/dist/command-loaders.d.ts.map +1 -0
- package/dist/command-loaders.js +58 -0
- package/dist/command-loaders.js.map +1 -0
- package/dist/commands/agent/index.js +1 -1
- package/dist/commands/agent/install.d.ts.map +1 -1
- package/dist/commands/agent/install.js +46 -5
- package/dist/commands/agent/install.js.map +1 -1
- package/dist/commands/audit/distributed-tree.d.ts +2 -2
- package/dist/commands/audit/distributed-tree.d.ts.map +1 -1
- package/dist/commands/audit/distributed-tree.js +2 -1
- package/dist/commands/audit/distributed-tree.js.map +1 -1
- package/dist/commands/audit/git-url-clone.d.ts +1 -1
- package/dist/commands/audit/git-url-clone.d.ts.map +1 -1
- package/dist/commands/audit/git-url-clone.js.map +1 -1
- package/dist/commands/audit/hierarchical-output.d.ts +1 -1
- package/dist/commands/audit/hierarchical-output.d.ts.map +1 -1
- package/dist/commands/audit/hierarchical-output.js +1 -1
- package/dist/commands/audit/hierarchical-output.js.map +1 -1
- package/dist/commands/audit.d.ts +22 -1
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +224 -24
- package/dist/commands/audit.js.map +1 -1
- package/dist/commands/build.d.ts +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +15 -12
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cache/cache-control.d.ts +82 -0
- package/dist/commands/cache/cache-control.d.ts.map +1 -0
- package/dist/commands/cache/cache-control.js +86 -0
- package/dist/commands/cache/cache-control.js.map +1 -0
- 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 +68 -3
- package/dist/commands/cache/clear.js.map +1 -1
- package/dist/commands/cache/index.d.ts +13 -63
- package/dist/commands/cache/index.d.ts.map +1 -1
- package/dist/commands/cache/index.js +38 -79
- package/dist/commands/cache/index.js.map +1 -1
- package/dist/commands/claude/budget.d.ts +157 -0
- package/dist/commands/claude/budget.d.ts.map +1 -0
- package/dist/commands/claude/budget.js +412 -0
- package/dist/commands/claude/budget.js.map +1 -0
- package/dist/commands/claude/context.d.ts +340 -0
- package/dist/commands/claude/context.d.ts.map +1 -0
- package/dist/commands/claude/context.js +1079 -0
- package/dist/commands/claude/context.js.map +1 -0
- package/dist/commands/claude/index.d.ts +13 -0
- package/dist/commands/claude/index.d.ts.map +1 -1
- package/dist/commands/claude/index.js +24 -2
- 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 +18 -19
- package/dist/commands/claude/marketplace/git-publish.js.map +1 -1
- package/dist/commands/claude/marketplace/validate.d.ts +19 -1
- package/dist/commands/claude/marketplace/validate.d.ts.map +1 -1
- package/dist/commands/claude/marketplace/validate.js +41 -21
- package/dist/commands/claude/marketplace/validate.js.map +1 -1
- package/dist/commands/claude/plugin/build.d.ts +18 -2
- package/dist/commands/claude/plugin/build.d.ts.map +1 -1
- package/dist/commands/claude/plugin/build.js +55 -18
- package/dist/commands/claude/plugin/build.js.map +1 -1
- package/dist/commands/claude/plugin/helpers.d.ts.map +1 -1
- package/dist/commands/claude/plugin/helpers.js +2 -1
- package/dist/commands/claude/plugin/helpers.js.map +1 -1
- package/dist/commands/claude/plugin/install.d.ts.map +1 -1
- package/dist/commands/claude/plugin/install.js +24 -3
- package/dist/commands/claude/plugin/install.js.map +1 -1
- package/dist/commands/claude/plugin/tree-copy.d.ts.map +1 -1
- package/dist/commands/claude/plugin/tree-copy.js +2 -1
- package/dist/commands/claude/plugin/tree-copy.js.map +1 -1
- package/dist/commands/consistency-check.d.ts.map +1 -1
- package/dist/commands/consistency-check.js +4 -3
- package/dist/commands/consistency-check.js.map +1 -1
- package/dist/commands/corpus/report.d.ts +1 -1
- package/dist/commands/corpus/report.d.ts.map +1 -1
- package/dist/commands/corpus/runner.d.ts.map +1 -1
- package/dist/commands/corpus/runner.js +3 -2
- package/dist/commands/corpus/runner.js.map +1 -1
- package/dist/commands/corpus/scan.d.ts.map +1 -1
- package/dist/commands/corpus/scan.js +18 -8
- package/dist/commands/corpus/scan.js.map +1 -1
- package/dist/commands/doctor.d.ts +36 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +99 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/inventory.d.ts +13 -1
- package/dist/commands/inventory.d.ts.map +1 -1
- package/dist/commands/inventory.js +118 -13
- package/dist/commands/inventory.js.map +1 -1
- package/dist/commands/mcp/collections.d.ts +1 -1
- package/dist/commands/mcp/collections.d.ts.map +1 -1
- package/dist/commands/phase-utils.d.ts +155 -104
- package/dist/commands/phase-utils.d.ts.map +1 -1
- package/dist/commands/phase-utils.js +109 -155
- package/dist/commands/phase-utils.js.map +1 -1
- package/dist/commands/rag/index-command.d.ts +39 -0
- package/dist/commands/rag/index-command.d.ts.map +1 -1
- package/dist/commands/rag/index-command.js +28 -2
- package/dist/commands/rag/index-command.js.map +1 -1
- package/dist/commands/rag/index.d.ts.map +1 -1
- package/dist/commands/rag/index.js +21 -10
- package/dist/commands/rag/index.js.map +1 -1
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +10 -2
- package/dist/commands/resources/index.js.map +1 -1
- package/dist/commands/resources/scan.d.ts +24 -0
- package/dist/commands/resources/scan.d.ts.map +1 -1
- package/dist/commands/resources/scan.js +19 -6
- package/dist/commands/resources/scan.js.map +1 -1
- package/dist/commands/resources/validate.d.ts +12 -1
- package/dist/commands/resources/validate.d.ts.map +1 -1
- package/dist/commands/resources/validate.js +102 -51
- package/dist/commands/resources/validate.js.map +1 -1
- package/dist/commands/skill/review-checklist.d.ts.map +1 -1
- package/dist/commands/skill/review-checklist.js +1 -0
- package/dist/commands/skill/review-checklist.js.map +1 -1
- package/dist/commands/skill/review.js +2 -2
- package/dist/commands/skill/review.js.map +1 -1
- package/dist/commands/skill/test/configure.d.ts +19 -0
- package/dist/commands/skill/test/configure.d.ts.map +1 -1
- package/dist/commands/skill/test/configure.js +18 -3
- package/dist/commands/skill/test/configure.js.map +1 -1
- package/dist/commands/skill/test/run.d.ts +51 -4
- package/dist/commands/skill/test/run.d.ts.map +1 -1
- package/dist/commands/skill/test/run.js +123 -12
- package/dist/commands/skill/test/run.js.map +1 -1
- package/dist/commands/skills/build.d.ts +11 -1
- package/dist/commands/skills/build.d.ts.map +1 -1
- package/dist/commands/skills/build.js +154 -61
- package/dist/commands/skills/build.js.map +1 -1
- package/dist/commands/skills/package.d.ts +1 -1
- package/dist/commands/skills/package.d.ts.map +1 -1
- package/dist/commands/skills/package.js.map +1 -1
- package/dist/commands/skills/skill-discovery.d.ts.map +1 -1
- package/dist/commands/skills/skill-discovery.js +2 -1
- package/dist/commands/skills/skill-discovery.js.map +1 -1
- package/dist/commands/skills/validate.d.ts +79 -2
- package/dist/commands/skills/validate.d.ts.map +1 -1
- package/dist/commands/skills/validate.js +101 -48
- package/dist/commands/skills/validate.js.map +1 -1
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +26 -16
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/verify.d.ts +11 -10
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +49 -38
- package/dist/commands/verify.js.map +1 -1
- package/dist/utils/command-error.d.ts +33 -2
- package/dist/utils/command-error.d.ts.map +1 -1
- package/dist/utils/command-error.js +34 -10
- package/dist/utils/command-error.js.map +1 -1
- package/dist/utils/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js +7 -1
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/context-budget-issues.d.ts +108 -0
- package/dist/utils/context-budget-issues.d.ts.map +1 -0
- package/dist/utils/context-budget-issues.js +280 -0
- package/dist/utils/context-budget-issues.js.map +1 -0
- package/dist/utils/corpus-target.d.ts +48 -0
- package/dist/utils/corpus-target.d.ts.map +1 -0
- package/dist/utils/corpus-target.js +61 -0
- package/dist/utils/corpus-target.js.map +1 -0
- package/dist/utils/issue-anchor.d.ts +2 -2
- package/dist/utils/issue-anchor.d.ts.map +1 -1
- package/dist/utils/issue-anchor.js +1 -1
- package/dist/utils/issue-rendering.d.ts +1 -1
- package/dist/utils/issue-rendering.d.ts.map +1 -1
- package/dist/utils/issue-rendering.js +1 -1
- package/dist/utils/issue-rendering.js.map +1 -1
- package/dist/utils/issue-severity.d.ts +1 -1
- package/dist/utils/issue-severity.d.ts.map +1 -1
- package/dist/utils/issue-severity.js +1 -1
- package/dist/utils/issue-severity.js.map +1 -1
- package/dist/utils/optional-backend.d.ts +77 -0
- package/dist/utils/optional-backend.d.ts.map +1 -0
- package/dist/utils/optional-backend.js +115 -0
- package/dist/utils/optional-backend.js.map +1 -0
- package/dist/utils/output.d.ts +17 -0
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +19 -0
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/population-wiring.d.ts +100 -0
- package/dist/utils/population-wiring.d.ts.map +1 -0
- package/dist/utils/population-wiring.js +98 -0
- package/dist/utils/population-wiring.js.map +1 -0
- package/dist/utils/projection-store.d.ts +188 -0
- package/dist/utils/projection-store.d.ts.map +1 -0
- package/dist/utils/projection-store.js +257 -0
- package/dist/utils/projection-store.js.map +1 -0
- package/dist/utils/resource-loader.d.ts +128 -2
- package/dist/utils/resource-loader.d.ts.map +1 -1
- package/dist/utils/resource-loader.js +234 -7
- package/dist/utils/resource-loader.js.map +1 -1
- package/dist/utils/verdict-helpers.d.ts +1 -1
- package/dist/utils/verdict-helpers.d.ts.map +1 -1
- package/dist/utils/verdict-helpers.js +1 -1
- package/dist/utils/verdict-helpers.js.map +1 -1
- package/docs/agent.md +2 -2
- package/docs/mcp.md +2 -2
- package/docs/resources.md +8 -1
- package/package.json +15 -12
- package/dist/commands/resources/command-helpers.d.ts +0 -5
- package/dist/commands/resources/command-helpers.d.ts.map +0 -1
- package/dist/commands/resources/command-helpers.js +0 -6
- package/dist/commands/resources/command-helpers.js.map +0 -1
package/dist/commands/build.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { existsSync } from 'node:fs';
|
|
9
9
|
import { readdir } from 'node:fs/promises';
|
|
10
|
-
import { calculateValidationStatus, countBySeverity, } from '@vibe-agent-toolkit/agent-schema';
|
|
11
10
|
import { checkBrokenPackagedLinks } from '@vibe-agent-toolkit/agent-skills';
|
|
11
|
+
import { calculateValidationStatus, countBySeverity, } from '@vibe-agent-toolkit/schema';
|
|
12
12
|
import { safePath } from '@vibe-agent-toolkit/utils';
|
|
13
13
|
import { Command } from 'commander';
|
|
14
14
|
import { handleCommandError } from '../utils/command-error.js';
|
|
@@ -16,8 +16,10 @@ import { loadConfig } from '../utils/config-loader.js';
|
|
|
16
16
|
import { sumSeverityCounts } from '../utils/issue-rendering.js';
|
|
17
17
|
import { writeYamlOutput } from '../utils/output.js';
|
|
18
18
|
import { requireProjectRoot } from '../utils/project-root-policy.js';
|
|
19
|
+
import { runClaudePluginBuildPhase } from './claude/plugin/build.js';
|
|
19
20
|
import { aggregatePhaseIssueCounts, aggregatePhaseStatus, applyPhaseSelection, createPhaseContext, decidePhaseSelection, exitCodeForPhases, runPhase, SYSTEM_ERROR, worseOf, } from './phase-utils.js';
|
|
20
21
|
import { rejectPositionalArguments } from './positional-args.js';
|
|
22
|
+
import { runSkillsBuildPhase } from './skills/build.js';
|
|
21
23
|
export function createBuildTopLevelCommand() {
|
|
22
24
|
const command = new Command('build');
|
|
23
25
|
command
|
|
@@ -65,9 +67,8 @@ Exit Codes:
|
|
|
65
67
|
0 - All phases completed successfully (warnings do not fail a build)
|
|
66
68
|
1 - Build error, or '--only' named a phase that is unrecognized or unconfigured
|
|
67
69
|
2 - System error (this command's own, a usage error such as a positional
|
|
68
|
-
argument, or propagated from a phase that could not run: exited 2,
|
|
69
|
-
|
|
70
|
-
parsed)
|
|
70
|
+
argument, or propagated from a phase that could not run: it exited 2, or
|
|
71
|
+
reported 'system-error' for itself)
|
|
71
72
|
|
|
72
73
|
Requirements:
|
|
73
74
|
projectRoot: required (errors if no vibe-agent-toolkit.config.yaml or .git/ ancestor)
|
|
@@ -188,15 +189,14 @@ const BUILD_VOCABULARY = {
|
|
|
188
189
|
*/
|
|
189
190
|
export function selectBuildPhases(only, hasClaudeMarketplaces, verbose = false) {
|
|
190
191
|
const phases = [];
|
|
191
|
-
//
|
|
192
|
-
//
|
|
193
|
-
//
|
|
194
|
-
const verboseArgs = verbose ? ['--verbose'] : [];
|
|
192
|
+
// A flag not forwarded here is a flag the composite command silently cannot
|
|
193
|
+
// express: `vat build` would always get the collapsed report with no way to
|
|
194
|
+
// ask for the full one.
|
|
195
195
|
if (!only || only === 'skills') {
|
|
196
|
-
phases.push({ name: 'skills',
|
|
196
|
+
phases.push({ name: 'skills', run: () => runSkillsBuildPhase(undefined, { verbose }) });
|
|
197
197
|
}
|
|
198
198
|
if ((!only || only === 'claude') && hasClaudeMarketplaces) {
|
|
199
|
-
phases.push({ name: 'claude',
|
|
199
|
+
phases.push({ name: 'claude', run: () => runClaudePluginBuildPhase({ verbose }) });
|
|
200
200
|
}
|
|
201
201
|
return decidePhaseSelection(only, phases, BUILD_VOCABULARY);
|
|
202
202
|
}
|
|
@@ -209,7 +209,7 @@ async function buildTopLevelCommand(options, command) {
|
|
|
209
209
|
const cwd = process.cwd();
|
|
210
210
|
// Spec §7: `vat build` requires a projectRoot.
|
|
211
211
|
requireProjectRoot(cwd, 'vat build');
|
|
212
|
-
const { logger, startTime
|
|
212
|
+
const { logger, startTime } = createPhaseContext(options.debug);
|
|
213
213
|
try {
|
|
214
214
|
// Inside the try, deliberately: this used to throw from outside it, so an
|
|
215
215
|
// unroutable `--only` produced a raw stack trace and zero bytes of stdout.
|
|
@@ -223,7 +223,10 @@ async function buildTopLevelCommand(options, command) {
|
|
|
223
223
|
let shippedLinkIssues = [];
|
|
224
224
|
for (const phase of phases) {
|
|
225
225
|
logger.info(`\n▶ Phase: ${phase.name}`);
|
|
226
|
-
|
|
226
|
+
// Awaited in the loop, deliberately, and here it is a DEPENDENCY rather
|
|
227
|
+
// than a presentation choice: `claude` packages what `skills` just wrote
|
|
228
|
+
// into dist/, so overlapping the two would read a half-built tree.
|
|
229
|
+
const result = await runPhase(phase);
|
|
227
230
|
phaseResults.push(result);
|
|
228
231
|
// Only a real failure stops the build. A `warning` phase must NOT abort:
|
|
229
232
|
// warnings are non-blocking everywhere else in VAT, and phase status only
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EACL,yBAAyB,EACzB,eAAe,GAEhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CA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AK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;YACxE,QAAQ,EAAE,GAAG,QAAQ,IAAI;SAC1B,CAAC,CAAC;QAEH,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The root-level `--no-cache` control surface, kept apart from the `cache`
|
|
3
|
+
* command itself.
|
|
4
|
+
*
|
|
5
|
+
* `bin.ts` must call {@link registerCacheControl} on every single invocation,
|
|
6
|
+
* before parsing. Co-locating it with `createCacheCommand` in `index.ts` meant
|
|
7
|
+
* that unavoidable call dragged in `./clear.js` and, behind it, the whole
|
|
8
|
+
* resources package — measured at ~1.2s of module load on Windows, paid even by
|
|
9
|
+
* `vat --version`. This module imports nothing but commander, so the always-on
|
|
10
|
+
* path stays cheap — keep it that way: any import added here is paid by every
|
|
11
|
+
* `vat` invocation, and `index.ts` deliberately does not re-export it, so
|
|
12
|
+
* reaching these functions through the command group cannot happen by accident.
|
|
13
|
+
*/
|
|
14
|
+
import type { Command } from 'commander';
|
|
15
|
+
/**
|
|
16
|
+
* Root options this module reads. Commander represents `--no-cache` as the
|
|
17
|
+
* POSITIVE key `cache` — `true` by default, `false` only when the negated flag
|
|
18
|
+
* is passed. It NEVER produces `noCache`; reading that key is the exact bug that
|
|
19
|
+
* made three flags in this package silent no-ops (see
|
|
20
|
+
* `test/commands/commander-option-keys.test.ts`).
|
|
21
|
+
*/
|
|
22
|
+
export interface CacheControlOptions {
|
|
23
|
+
cache?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Register the root-level `--no-cache` flag and the hook that gives it effect.
|
|
27
|
+
*
|
|
28
|
+
* ## Why this sets an environment variable instead of plumbing a flag
|
|
29
|
+
*
|
|
30
|
+
* ⚠️ The ORIGINAL reason has expired, and saying so is the point of this note.
|
|
31
|
+
* It was that `vat validate` / `vat verify` / `vat build` enumerated nothing in
|
|
32
|
+
* their own process — each `spawnSync`ed the vat binary once per phase, so a
|
|
33
|
+
* flag parsed in the parent never reached the process doing the parsing, while
|
|
34
|
+
* `process.env` crossed the boundary for free. Phases run in this process now,
|
|
35
|
+
* so that argument no longer holds.
|
|
36
|
+
*
|
|
37
|
+
* What still holds is narrower but sufficient: the flag has to reach code that
|
|
38
|
+
* no CLI option is threaded through. `ParseCache` is constructed deep inside
|
|
39
|
+
* `@vibe-agent-toolkit/resources`, by callers several layers below any command,
|
|
40
|
+
* and `bin.ts` leans on the same mechanism for `VAT_CONTEXT` /
|
|
41
|
+
* `VAT_CONTEXT_PATH`. Plumbing a `noCache` parameter down every one of those
|
|
42
|
+
* call chains is the alternative, and it is a real one — this is now a choice
|
|
43
|
+
* rather than a necessity, so treat it as revisitable rather than as settled.
|
|
44
|
+
*
|
|
45
|
+
* `VAT_CACHE=0` is read by `ParseCache` (packages/resources/src/parse-cache.ts)
|
|
46
|
+
* per construction, never at module load, so setting it from a `preAction` hook
|
|
47
|
+
* — after Commander has parsed, before any command body runs — is observed by
|
|
48
|
+
* every phase, all of which now start after that hook has run.
|
|
49
|
+
*
|
|
50
|
+
* ## The collision with `vat resources validate --no-cache`
|
|
51
|
+
*
|
|
52
|
+
* This root program does NOT use `enablePositionalOptions()`, so Commander scans
|
|
53
|
+
* the WHOLE argv for root options, including everything after the subcommand
|
|
54
|
+
* name. That is the same mechanism that let a root `-v` shadow the subcommands'
|
|
55
|
+
* own `-v, --verbose` (see the incident recorded in `bin.ts`). Measured against
|
|
56
|
+
* commander 12: `vat resources validate docs --no-cache` leaves the ROOT with
|
|
57
|
+
* `cache: false` and the SUBCOMMAND with `cache: true` — the subcommand's
|
|
58
|
+
* identically-named flag is swallowed before it ever sees it, which would have
|
|
59
|
+
* silently re-enabled the external-URL cache the flag exists to bypass.
|
|
60
|
+
*
|
|
61
|
+
* Rather than break a shipped flag, the hook hands the value back down to
|
|
62
|
+
* whichever action command declares a `cache` option of its own. `--no-cache` is
|
|
63
|
+
* a superset — every cache off — so the handoff is a strengthening, never a
|
|
64
|
+
* reversal.
|
|
65
|
+
*
|
|
66
|
+
* @param program - The root program to register the flag and hook on
|
|
67
|
+
*/
|
|
68
|
+
export declare function registerCacheControl(program: Command): void;
|
|
69
|
+
/**
|
|
70
|
+
* Apply the root `--no-cache` decision: export it to child processes, and hand
|
|
71
|
+
* it down to an action command that declares its own `cache` option.
|
|
72
|
+
*
|
|
73
|
+
* Exported so a test can drive it from real parsed options rather than from a
|
|
74
|
+
* hand-built bag. Deliberately does nothing when the flag was not passed — a
|
|
75
|
+
* toggle that writes `VAT_CACHE=1` by default would be indistinguishable from
|
|
76
|
+
* one that is always on.
|
|
77
|
+
*
|
|
78
|
+
* @param rootOptions - Options bag from the ROOT program
|
|
79
|
+
* @param actionCommand - The command whose action is about to run
|
|
80
|
+
*/
|
|
81
|
+
export declare function applyCacheControl(rootOptions: CacheControlOptions, actionCommand: Command): void;
|
|
82
|
+
//# sourceMappingURL=cache-control.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-control.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/cache-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAM3D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,mBAAmB,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAWhG"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The root-level `--no-cache` control surface, kept apart from the `cache`
|
|
3
|
+
* command itself.
|
|
4
|
+
*
|
|
5
|
+
* `bin.ts` must call {@link registerCacheControl} on every single invocation,
|
|
6
|
+
* before parsing. Co-locating it with `createCacheCommand` in `index.ts` meant
|
|
7
|
+
* that unavoidable call dragged in `./clear.js` and, behind it, the whole
|
|
8
|
+
* resources package — measured at ~1.2s of module load on Windows, paid even by
|
|
9
|
+
* `vat --version`. This module imports nothing but commander, so the always-on
|
|
10
|
+
* path stays cheap — keep it that way: any import added here is paid by every
|
|
11
|
+
* `vat` invocation, and `index.ts` deliberately does not re-export it, so
|
|
12
|
+
* reaching these functions through the command group cannot happen by accident.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Register the root-level `--no-cache` flag and the hook that gives it effect.
|
|
16
|
+
*
|
|
17
|
+
* ## Why this sets an environment variable instead of plumbing a flag
|
|
18
|
+
*
|
|
19
|
+
* ⚠️ The ORIGINAL reason has expired, and saying so is the point of this note.
|
|
20
|
+
* It was that `vat validate` / `vat verify` / `vat build` enumerated nothing in
|
|
21
|
+
* their own process — each `spawnSync`ed the vat binary once per phase, so a
|
|
22
|
+
* flag parsed in the parent never reached the process doing the parsing, while
|
|
23
|
+
* `process.env` crossed the boundary for free. Phases run in this process now,
|
|
24
|
+
* so that argument no longer holds.
|
|
25
|
+
*
|
|
26
|
+
* What still holds is narrower but sufficient: the flag has to reach code that
|
|
27
|
+
* no CLI option is threaded through. `ParseCache` is constructed deep inside
|
|
28
|
+
* `@vibe-agent-toolkit/resources`, by callers several layers below any command,
|
|
29
|
+
* and `bin.ts` leans on the same mechanism for `VAT_CONTEXT` /
|
|
30
|
+
* `VAT_CONTEXT_PATH`. Plumbing a `noCache` parameter down every one of those
|
|
31
|
+
* call chains is the alternative, and it is a real one — this is now a choice
|
|
32
|
+
* rather than a necessity, so treat it as revisitable rather than as settled.
|
|
33
|
+
*
|
|
34
|
+
* `VAT_CACHE=0` is read by `ParseCache` (packages/resources/src/parse-cache.ts)
|
|
35
|
+
* per construction, never at module load, so setting it from a `preAction` hook
|
|
36
|
+
* — after Commander has parsed, before any command body runs — is observed by
|
|
37
|
+
* every phase, all of which now start after that hook has run.
|
|
38
|
+
*
|
|
39
|
+
* ## The collision with `vat resources validate --no-cache`
|
|
40
|
+
*
|
|
41
|
+
* This root program does NOT use `enablePositionalOptions()`, so Commander scans
|
|
42
|
+
* the WHOLE argv for root options, including everything after the subcommand
|
|
43
|
+
* name. That is the same mechanism that let a root `-v` shadow the subcommands'
|
|
44
|
+
* own `-v, --verbose` (see the incident recorded in `bin.ts`). Measured against
|
|
45
|
+
* commander 12: `vat resources validate docs --no-cache` leaves the ROOT with
|
|
46
|
+
* `cache: false` and the SUBCOMMAND with `cache: true` — the subcommand's
|
|
47
|
+
* identically-named flag is swallowed before it ever sees it, which would have
|
|
48
|
+
* silently re-enabled the external-URL cache the flag exists to bypass.
|
|
49
|
+
*
|
|
50
|
+
* Rather than break a shipped flag, the hook hands the value back down to
|
|
51
|
+
* whichever action command declares a `cache` option of its own. `--no-cache` is
|
|
52
|
+
* a superset — every cache off — so the handoff is a strengthening, never a
|
|
53
|
+
* reversal.
|
|
54
|
+
*
|
|
55
|
+
* @param program - The root program to register the flag and hook on
|
|
56
|
+
*/
|
|
57
|
+
export function registerCacheControl(program) {
|
|
58
|
+
program.option('--no-cache', "Disable VAT's disk caches for this run (every phase included)");
|
|
59
|
+
program.hook('preAction', (_thisCommand, actionCommand) => {
|
|
60
|
+
applyCacheControl(program.opts(), actionCommand);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Apply the root `--no-cache` decision: export it to child processes, and hand
|
|
65
|
+
* it down to an action command that declares its own `cache` option.
|
|
66
|
+
*
|
|
67
|
+
* Exported so a test can drive it from real parsed options rather than from a
|
|
68
|
+
* hand-built bag. Deliberately does nothing when the flag was not passed — a
|
|
69
|
+
* toggle that writes `VAT_CACHE=1` by default would be indistinguishable from
|
|
70
|
+
* one that is always on.
|
|
71
|
+
*
|
|
72
|
+
* @param rootOptions - Options bag from the ROOT program
|
|
73
|
+
* @param actionCommand - The command whose action is about to run
|
|
74
|
+
*/
|
|
75
|
+
export function applyCacheControl(rootOptions, actionCommand) {
|
|
76
|
+
if (rootOptions.cache !== false)
|
|
77
|
+
return;
|
|
78
|
+
process.env['VAT_CACHE'] = '0';
|
|
79
|
+
// `attributeName()`, not `name()`: for `--no-cache` the latter returns
|
|
80
|
+
// 'no-cache', so a check written against it never matches and the handoff
|
|
81
|
+
// above becomes a no-op that looks like it works.
|
|
82
|
+
if (actionCommand.options.some((option) => option.attributeName() === 'cache')) {
|
|
83
|
+
actionCommand.setOptionValue('cache', false);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=cache-control.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-control.js","sourceRoot":"","sources":["../../../src/commands/cache/cache-control.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,+DAA+D,CAAC,CAAC;IAE9F,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,EAAE;QACxD,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAuB,EAAE,aAAa,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAgC,EAAE,aAAsB;IACxF,IAAI,WAAW,CAAC,KAAK,KAAK,KAAK;QAAE,OAAO;IAExC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC;IAE/B,uEAAuE;IACvE,0EAA0E;IAC1E,kDAAkD;IAClD,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,OAAO,CAAC,EAAE,CAAC;QAC/E,aAAa,CAAC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;AACH,CAAC"}
|
|
@@ -13,13 +13,27 @@
|
|
|
13
13
|
export interface CacheClearOptions {
|
|
14
14
|
debug?: boolean;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* What a clear did, as published on stdout.
|
|
18
|
+
*
|
|
19
|
+
* `partial` is not a failure mode bolted on — it is the *common* outcome when
|
|
20
|
+
* something else on the machine is writing to the shared tree, and it has to be
|
|
21
|
+
* reportable. A recursive delete that gives up part-way has already removed most
|
|
22
|
+
* of the cache; surfacing that as a bare thrown error told the operator only
|
|
23
|
+
* that the command failed, while leaving them to guess how much of their cache
|
|
24
|
+
* still existed. An honest count of what went and what stayed is the whole
|
|
25
|
+
* point of a report.
|
|
26
|
+
*/
|
|
17
27
|
export interface CacheClearReport {
|
|
18
|
-
status: 'success';
|
|
28
|
+
status: 'success' | 'partial';
|
|
19
29
|
cacheDir: string;
|
|
20
30
|
existed: boolean;
|
|
21
|
-
/** Top-level entries that
|
|
31
|
+
/** Top-level entries that are gone, sorted. Empty when nothing was there. */
|
|
22
32
|
removed: string[];
|
|
33
|
+
/** Top-level entries that survived a partial clear, sorted. Absent on success. */
|
|
34
|
+
remaining?: string[];
|
|
35
|
+
/** Why the delete stopped short. Absent on success. */
|
|
36
|
+
reason?: string;
|
|
23
37
|
entriesRemoved: number;
|
|
24
38
|
bytesRemoved: number;
|
|
25
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/clear.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED
|
|
1
|
+
{"version":3,"file":"clear.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/clear.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAeH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,uDAAuD;IACvD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AA4BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAcrC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAwBrF;AA+CD;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBtF"}
|
|
@@ -20,6 +20,24 @@ import { writeYamlOutput } from '../../utils/output.js';
|
|
|
20
20
|
/** The one name the shared cache root is allowed to have. See {@link vatCacheRoot}. */
|
|
21
21
|
const VAT_CACHE_DIR_NAME = '.vat-cache';
|
|
22
22
|
const EMPTY_USAGE = { entries: 0, bytes: 0 };
|
|
23
|
+
/**
|
|
24
|
+
* Retry budget for the recursive delete.
|
|
25
|
+
*
|
|
26
|
+
* Not defensive padding — observed. `<tmpdir>/.vat-cache` is shared by every VAT
|
|
27
|
+
* on the machine: other worktrees, other sessions, and any adopter running an
|
|
28
|
+
* *installed* vat all write into it under their own namespace. A `vat cache
|
|
29
|
+
* clear` issued while one of them is mid-run walks a tree that is growing
|
|
30
|
+
* underneath it and `rmdir` fails `ENOTEMPTY` on a shard that gained a file
|
|
31
|
+
* between the listing and the removal. Reproduced twice against a concurrent
|
|
32
|
+
* `vat verify`; the same command succeeded immediately once that run finished.
|
|
33
|
+
*
|
|
34
|
+
* Node retries exactly this error class (`EBUSY`, `EMFILE`, `ENFILE`,
|
|
35
|
+
* `ENOTEMPTY`, `EPERM`) with a linear backoff, which clears a short overlap.
|
|
36
|
+
* It cannot win against a writer that keeps going for the whole window — that
|
|
37
|
+
* case still surfaces as an error, which is correct: "some of your cache is
|
|
38
|
+
* gone and something is still writing" must not be reported as success.
|
|
39
|
+
*/
|
|
40
|
+
const RM_RETRY = { maxRetries: 5, retryDelay: 100 };
|
|
23
41
|
/**
|
|
24
42
|
* The shared cache root, `<tmpdir>/.vat-cache`.
|
|
25
43
|
*
|
|
@@ -80,16 +98,59 @@ export async function clearCacheDirectory(cacheDir) {
|
|
|
80
98
|
return { status: 'success', cacheDir, existed: false, removed: [], entriesRemoved: 0, bytesRemoved: 0 };
|
|
81
99
|
}
|
|
82
100
|
const usage = await measureEntries(cacheDir, entries);
|
|
83
|
-
|
|
101
|
+
const names = entries.map((entry) => entry.name);
|
|
102
|
+
try {
|
|
103
|
+
await fs.rm(cacheDir, { recursive: true, force: true, ...RM_RETRY });
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
return partialReport(cacheDir, names, usage, error);
|
|
107
|
+
}
|
|
84
108
|
return {
|
|
85
109
|
status: 'success',
|
|
86
110
|
cacheDir,
|
|
87
111
|
existed: true,
|
|
88
|
-
removed:
|
|
112
|
+
removed: sorted(names),
|
|
89
113
|
entriesRemoved: usage.entries,
|
|
90
114
|
bytesRemoved: usage.bytes,
|
|
91
115
|
};
|
|
92
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Describe a delete that stopped part-way, by re-reading the tree.
|
|
119
|
+
*
|
|
120
|
+
* The survivors are read back off disk rather than inferred from the error,
|
|
121
|
+
* because the error names one path and says nothing about the other ninety-nine
|
|
122
|
+
* percent. Re-measuring what remains and subtracting is the only way the counts
|
|
123
|
+
* describe what actually happened rather than what was attempted.
|
|
124
|
+
*
|
|
125
|
+
* A concurrent writer can make the remainder *larger* than the original
|
|
126
|
+
* measurement, so the subtraction is floored at zero: reporting a negative
|
|
127
|
+
* number of removed bytes would be worse than reporting none.
|
|
128
|
+
*
|
|
129
|
+
* @param cacheDir - The tree that was being removed
|
|
130
|
+
* @param names - Top-level entry names as they were before the delete
|
|
131
|
+
* @param before - Usage measured before the delete
|
|
132
|
+
* @param error - Whatever `fs.rm` threw
|
|
133
|
+
* @returns A report naming what went, what stayed, and why
|
|
134
|
+
*/
|
|
135
|
+
async function partialReport(cacheDir, names, before, error) {
|
|
136
|
+
const survivors = (await readdirOrNull(cacheDir)) ?? [];
|
|
137
|
+
const remaining = new Set(survivors.map((entry) => entry.name));
|
|
138
|
+
const after = await measureEntries(cacheDir, survivors);
|
|
139
|
+
return {
|
|
140
|
+
status: 'partial',
|
|
141
|
+
cacheDir,
|
|
142
|
+
existed: true,
|
|
143
|
+
removed: sorted(names.filter((name) => !remaining.has(name))),
|
|
144
|
+
remaining: sorted([...remaining]),
|
|
145
|
+
reason: error instanceof Error ? error.message : String(error),
|
|
146
|
+
entriesRemoved: Math.max(0, before.entries - after.entries),
|
|
147
|
+
bytesRemoved: Math.max(0, before.bytes - after.bytes),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
/** Stable ordering for the reported entry lists. */
|
|
151
|
+
function sorted(names) {
|
|
152
|
+
return [...names].sort((left, right) => left.localeCompare(right));
|
|
153
|
+
}
|
|
93
154
|
/**
|
|
94
155
|
* Command entry point: clear the real cache root and publish the report.
|
|
95
156
|
*
|
|
@@ -102,7 +163,11 @@ export async function cacheClearCommand(options = {}) {
|
|
|
102
163
|
const report = await clearCacheDirectory(vatCacheRoot());
|
|
103
164
|
logger.debug(`Cleared ${String(report.entriesRemoved)} cache entries from ${report.cacheDir}`);
|
|
104
165
|
writeYamlOutput(report);
|
|
105
|
-
|
|
166
|
+
// A partial clear publishes its report and *then* fails. Exiting through
|
|
167
|
+
// `handleCommandError` instead would suppress the report entirely, which is
|
|
168
|
+
// the defect this branch exists to fix: the operator most needs to know how
|
|
169
|
+
// much of the cache survived precisely when the command did not finish.
|
|
170
|
+
process.exit(report.status === 'partial' ? 1 : 0);
|
|
106
171
|
}
|
|
107
172
|
catch (error) {
|
|
108
173
|
handleCommandError(error, logger, startTime, 'CacheClear');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../src/commands/cache/clear.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAe,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,uFAAuF;AACvF,MAAM,kBAAkB,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"clear.js","sourceRoot":"","sources":["../../../src/commands/cache/clear.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAe,QA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,CAAC;IAC/F,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,EAChG,WAAW,CACZ,CAAC;AACJ,CAAC;AAED,iFAAiF;AACjF,KAAK,UAAU,WAAW,CAAC,GAAW;IACpC,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC;AAED;;;;;;;GAOG;AACH,KAAK,UAAU,MAAM,CAAC,MAAc;IAClC,IAAI,CAAC;QACH,mHAAmH;QACnH,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,IAAI,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
|
@@ -1,68 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Cache command group
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* clear` decides whether the caches *survive*.
|
|
2
|
+
* Cache command group.
|
|
3
|
+
*
|
|
4
|
+
* The paired `--no-cache` control surface lives in `./cache-control.js`:
|
|
5
|
+
* `--no-cache` decides whether this run *writes* to the caches, `vat cache
|
|
6
|
+
* clear` decides whether the caches *survive*. They are separate modules only
|
|
7
|
+
* because `bin.ts` registers the flag on every invocation and must not pay for
|
|
8
|
+
* this command's imports to do it.
|
|
9
|
+
*
|
|
10
|
+
* ⛔ Do NOT re-export `cache-control.js` from here for convenience. Importing it
|
|
11
|
+
* through this module pulls `./clear.js` and the whole resources package behind
|
|
12
|
+
* it — the exact ~1.2s that splitting the file removed — so a re-export leaves
|
|
13
|
+
* the expensive path one identical-looking import away, with nothing pinning
|
|
14
|
+
* the cheap one. Import from `./cache-control.js` directly.
|
|
7
15
|
*/
|
|
8
16
|
import { Command } from 'commander';
|
|
9
|
-
/**
|
|
10
|
-
* Root options this module reads. Commander represents `--no-cache` as the
|
|
11
|
-
* POSITIVE key `cache` — `true` by default, `false` only when the negated flag
|
|
12
|
-
* is passed. It NEVER produces `noCache`; reading that key is the exact bug that
|
|
13
|
-
* made three flags in this package silent no-ops (see
|
|
14
|
-
* `test/commands/commander-option-keys.test.ts`).
|
|
15
|
-
*/
|
|
16
|
-
export interface CacheControlOptions {
|
|
17
|
-
cache?: boolean;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Register the root-level `--no-cache` flag and the hook that gives it effect.
|
|
21
|
-
*
|
|
22
|
-
* ## Why this sets an environment variable instead of plumbing a flag
|
|
23
|
-
*
|
|
24
|
-
* `vat validate`, `vat verify` and `vat build` enumerate nothing in their own
|
|
25
|
-
* process: each `spawnSync`s the vat binary once per phase, and the child is
|
|
26
|
-
* what parses the corpus. A flag parsed in the parent therefore never reaches
|
|
27
|
-
* the process whose caching it is supposed to control, whereas `process.env` is
|
|
28
|
-
* inherited by every child for free. `bin.ts` already leans on exactly that for
|
|
29
|
-
* `VAT_CONTEXT` / `VAT_CONTEXT_PATH`.
|
|
30
|
-
*
|
|
31
|
-
* `VAT_CACHE=0` is read by `ParseCache` (packages/resources/src/parse-cache.ts)
|
|
32
|
-
* per construction, never at module load, so setting it from a `preAction` hook
|
|
33
|
-
* — after Commander has parsed, before any command body runs — is observed.
|
|
34
|
-
*
|
|
35
|
-
* ## The collision with `vat resources validate --no-cache`
|
|
36
|
-
*
|
|
37
|
-
* This root program does NOT use `enablePositionalOptions()`, so Commander scans
|
|
38
|
-
* the WHOLE argv for root options, including everything after the subcommand
|
|
39
|
-
* name. That is the same mechanism that let a root `-v` shadow the subcommands'
|
|
40
|
-
* own `-v, --verbose` (see the incident recorded in `bin.ts`). Measured against
|
|
41
|
-
* commander 12: `vat resources validate docs --no-cache` leaves the ROOT with
|
|
42
|
-
* `cache: false` and the SUBCOMMAND with `cache: true` — the subcommand's
|
|
43
|
-
* identically-named flag is swallowed before it ever sees it, which would have
|
|
44
|
-
* silently re-enabled the external-URL cache the flag exists to bypass.
|
|
45
|
-
*
|
|
46
|
-
* Rather than break a shipped flag, the hook hands the value back down to
|
|
47
|
-
* whichever action command declares a `cache` option of its own. `--no-cache` is
|
|
48
|
-
* a superset — every cache off — so the handoff is a strengthening, never a
|
|
49
|
-
* reversal.
|
|
50
|
-
*
|
|
51
|
-
* @param program - The root program to register the flag and hook on
|
|
52
|
-
*/
|
|
53
|
-
export declare function registerCacheControl(program: Command): void;
|
|
54
|
-
/**
|
|
55
|
-
* Apply the root `--no-cache` decision: export it to child processes, and hand
|
|
56
|
-
* it down to an action command that declares its own `cache` option.
|
|
57
|
-
*
|
|
58
|
-
* Exported so a test can drive it from real parsed options rather than from a
|
|
59
|
-
* hand-built bag. Deliberately does nothing when the flag was not passed — a
|
|
60
|
-
* toggle that writes `VAT_CACHE=1` by default would be indistinguishable from
|
|
61
|
-
* one that is always on.
|
|
62
|
-
*
|
|
63
|
-
* @param rootOptions - Options bag from the ROOT program
|
|
64
|
-
* @param actionCommand - The command whose action is about to run
|
|
65
|
-
*/
|
|
66
|
-
export declare function applyCacheControl(rootOptions: CacheControlOptions, actionCommand: Command): void;
|
|
67
17
|
export declare function createCacheCommand(): Command;
|
|
68
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/cache/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,kBAAkB,IAAI,OAAO,CA2E5C"}
|