@vibe-agent-toolkit/cli 0.1.41-rc.7 → 0.1.41
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 +24 -1
- package/dist/bin/vat.js +24 -1
- package/dist/bin/vat.js.map +1 -1
- package/dist/bin.js +23 -2
- package/dist/bin.js.map +1 -1
- package/dist/commands/agent/list.d.ts +11 -0
- package/dist/commands/agent/list.d.ts.map +1 -1
- package/dist/commands/agent/list.js +30 -11
- package/dist/commands/agent/list.js.map +1 -1
- package/dist/commands/audit/distributed-tree.d.ts +172 -0
- package/dist/commands/audit/distributed-tree.d.ts.map +1 -0
- package/dist/commands/audit/distributed-tree.js +319 -0
- package/dist/commands/audit/distributed-tree.js.map +1 -0
- package/dist/commands/audit.d.ts +69 -1
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +525 -174
- package/dist/commands/audit.js.map +1 -1
- package/dist/commands/build.d.ts +14 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +103 -26
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/claude/marketplace/git-publish.d.ts.map +1 -1
- package/dist/commands/claude/marketplace/git-publish.js +21 -3
- package/dist/commands/claude/marketplace/git-publish.js.map +1 -1
- package/dist/commands/claude/marketplace/validate.d.ts +125 -0
- package/dist/commands/claude/marketplace/validate.d.ts.map +1 -1
- package/dist/commands/claude/marketplace/validate.js +251 -44
- package/dist/commands/claude/marketplace/validate.js.map +1 -1
- package/dist/commands/claude/org/stubs.d.ts +9 -1
- package/dist/commands/claude/org/stubs.d.ts.map +1 -1
- package/dist/commands/claude/org/stubs.js +11 -3
- package/dist/commands/claude/org/stubs.js.map +1 -1
- package/dist/commands/claude/plugin/build.d.ts +34 -4
- package/dist/commands/claude/plugin/build.d.ts.map +1 -1
- package/dist/commands/claude/plugin/build.js +187 -16
- package/dist/commands/claude/plugin/build.js.map +1 -1
- package/dist/commands/claude/plugin/plugin-files.d.ts.map +1 -1
- package/dist/commands/claude/plugin/plugin-files.js +6 -2
- package/dist/commands/claude/plugin/plugin-files.js.map +1 -1
- package/dist/commands/claude/plugin/plugin-json-merge.d.ts.map +1 -1
- package/dist/commands/claude/plugin/plugin-json-merge.js +15 -0
- package/dist/commands/claude/plugin/plugin-json-merge.js.map +1 -1
- package/dist/commands/claude/plugin/tree-copy.d.ts +40 -0
- package/dist/commands/claude/plugin/tree-copy.d.ts.map +1 -1
- package/dist/commands/claude/plugin/tree-copy.js +100 -4
- package/dist/commands/claude/plugin/tree-copy.js.map +1 -1
- package/dist/commands/corpus/report.d.ts +22 -4
- package/dist/commands/corpus/report.d.ts.map +1 -1
- package/dist/commands/corpus/report.js +1 -0
- package/dist/commands/corpus/report.js.map +1 -1
- package/dist/commands/corpus/runner.d.ts +16 -1
- package/dist/commands/corpus/runner.d.ts.map +1 -1
- package/dist/commands/corpus/runner.js +40 -22
- package/dist/commands/corpus/runner.js.map +1 -1
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/inventory.d.ts +2 -0
- package/dist/commands/inventory.d.ts.map +1 -1
- package/dist/commands/inventory.js +45 -4
- package/dist/commands/inventory.js.map +1 -1
- package/dist/commands/phase-utils.d.ts +183 -14
- package/dist/commands/phase-utils.d.ts.map +1 -1
- package/dist/commands/phase-utils.js +294 -29
- package/dist/commands/phase-utils.js.map +1 -1
- package/dist/commands/positional-args.d.ts +36 -0
- package/dist/commands/positional-args.d.ts.map +1 -0
- package/dist/commands/positional-args.js +52 -0
- package/dist/commands/positional-args.js.map +1 -0
- package/dist/commands/rag/query-command.d.ts +40 -0
- package/dist/commands/rag/query-command.d.ts.map +1 -1
- package/dist/commands/rag/query-command.js +47 -20
- package/dist/commands/rag/query-command.js.map +1 -1
- package/dist/commands/resources/index.d.ts.map +1 -1
- package/dist/commands/resources/index.js +27 -9
- package/dist/commands/resources/index.js.map +1 -1
- package/dist/commands/resources/scan.d.ts +37 -0
- package/dist/commands/resources/scan.d.ts.map +1 -1
- package/dist/commands/resources/scan.js +47 -32
- package/dist/commands/resources/scan.js.map +1 -1
- package/dist/commands/resources/validate.d.ts +136 -1
- package/dist/commands/resources/validate.d.ts.map +1 -1
- package/dist/commands/resources/validate.js +105 -66
- 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 +5 -0
- package/dist/commands/skill/review-checklist.js.map +1 -1
- package/dist/commands/skill/review.d.ts.map +1 -1
- package/dist/commands/skill/review.js +7 -3
- package/dist/commands/skill/review.js.map +1 -1
- package/dist/commands/skill/test/run.d.ts +1 -1
- package/dist/commands/skill/test/run.d.ts.map +1 -1
- package/dist/commands/skill/test/run.js +8 -6
- package/dist/commands/skill/test/run.js.map +1 -1
- package/dist/commands/skills/build.d.ts +349 -11
- package/dist/commands/skills/build.d.ts.map +1 -1
- package/dist/commands/skills/build.js +901 -97
- package/dist/commands/skills/build.js.map +1 -1
- package/dist/commands/skills/command-helpers.d.ts +6 -10
- package/dist/commands/skills/command-helpers.d.ts.map +1 -1
- package/dist/commands/skills/command-helpers.js +6 -22
- package/dist/commands/skills/command-helpers.js.map +1 -1
- package/dist/commands/skills/list.d.ts +18 -0
- package/dist/commands/skills/list.d.ts.map +1 -1
- package/dist/commands/skills/list.js +41 -15
- package/dist/commands/skills/list.js.map +1 -1
- package/dist/commands/skills/package.d.ts +15 -0
- package/dist/commands/skills/package.d.ts.map +1 -1
- package/dist/commands/skills/package.js +30 -20
- package/dist/commands/skills/package.js.map +1 -1
- package/dist/commands/skills/scope-guard.d.ts +64 -0
- package/dist/commands/skills/scope-guard.d.ts.map +1 -0
- package/dist/commands/skills/scope-guard.js +86 -0
- package/dist/commands/skills/scope-guard.js.map +1 -0
- package/dist/commands/skills/validate-command.d.ts.map +1 -1
- package/dist/commands/skills/validate-command.js +41 -7
- package/dist/commands/skills/validate-command.js.map +1 -1
- package/dist/commands/skills/validate.d.ts +44 -3
- package/dist/commands/skills/validate.d.ts.map +1 -1
- package/dist/commands/skills/validate.js +217 -53
- package/dist/commands/skills/validate.js.map +1 -1
- package/dist/commands/validate.d.ts +18 -0
- package/dist/commands/validate.d.ts.map +1 -1
- package/dist/commands/validate.js +89 -68
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/verify.d.ts +113 -6
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +440 -123
- package/dist/commands/verify.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/skill-resolution/index.d.ts +1 -1
- package/dist/skill-resolution/index.d.ts.map +1 -1
- package/dist/skill-resolution/index.js +1 -1
- package/dist/skill-resolution/index.js.map +1 -1
- package/dist/skill-resolution/packaging-config.d.ts +15 -2
- package/dist/skill-resolution/packaging-config.d.ts.map +1 -1
- package/dist/skill-resolution/packaging-config.js +39 -2
- package/dist/skill-resolution/packaging-config.js.map +1 -1
- package/dist/utils/command-error.d.ts +34 -1
- package/dist/utils/command-error.d.ts.map +1 -1
- package/dist/utils/command-error.js +32 -1
- package/dist/utils/command-error.js.map +1 -1
- package/dist/utils/help-loader.d.ts +6 -2
- package/dist/utils/help-loader.d.ts.map +1 -1
- package/dist/utils/help-loader.js +9 -16
- package/dist/utils/help-loader.js.map +1 -1
- package/dist/utils/issue-rendering.d.ts +130 -0
- package/dist/utils/issue-rendering.d.ts.map +1 -1
- package/dist/utils/issue-rendering.js +147 -0
- package/dist/utils/issue-rendering.js.map +1 -1
- package/dist/utils/issue-severity.d.ts +51 -0
- package/dist/utils/issue-severity.d.ts.map +1 -0
- package/dist/utils/issue-severity.js +63 -0
- package/dist/utils/issue-severity.js.map +1 -0
- package/dist/utils/output.d.ts +54 -5
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +111 -17
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/relativize-paths.d.ts +45 -0
- package/dist/utils/relativize-paths.d.ts.map +1 -0
- package/dist/utils/relativize-paths.js +67 -0
- package/dist/utils/relativize-paths.js.map +1 -0
- package/dist/utils/resource-loader.d.ts +21 -2
- package/dist/utils/resource-loader.d.ts.map +1 -1
- package/dist/utils/resource-loader.js +85 -11
- package/dist/utils/resource-loader.js.map +1 -1
- package/dist/utils/skill-packaging-config.d.ts +22 -1
- package/dist/utils/skill-packaging-config.d.ts.map +1 -1
- package/dist/utils/skill-packaging-config.js +26 -0
- package/dist/utils/skill-packaging-config.js.map +1 -1
- package/dist/utils/verdict-helpers.d.ts +4 -3
- package/dist/utils/verdict-helpers.d.ts.map +1 -1
- package/dist/utils/verdict-helpers.js +6 -13
- package/dist/utils/verdict-helpers.js.map +1 -1
- package/dist/version.d.ts +22 -2
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +31 -2
- package/dist/version.js.map +1 -1
- package/docs/index.md +12 -0
- package/docs/rag.md +9 -4
- package/docs/resources.md +30 -14
- package/docs/skills.md +25 -7
- package/package.json +12 -12
|
@@ -85,6 +85,29 @@ export function formatIssueLines(issue, indent = '') {
|
|
|
85
85
|
}
|
|
86
86
|
return lines;
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Render the run-level findings section — findings that belong to the whole
|
|
90
|
+
* invocation rather than to any one skill (ALLOW_UNUSED is the only producer).
|
|
91
|
+
*
|
|
92
|
+
* Shared by `vat skills validate` and `vat skills build` so the two commands
|
|
93
|
+
* name the same concept the same way. Attributing these to a skill is the
|
|
94
|
+
* misreading the heading exists to prevent: `validation.allow` is declared once
|
|
95
|
+
* for the package, so an entry that matched nothing is a fact about the run.
|
|
96
|
+
*
|
|
97
|
+
* Returns `[]` for an empty set; callers own their surrounding blank lines.
|
|
98
|
+
*/
|
|
99
|
+
export function formatRunIssueLines(runIssues) {
|
|
100
|
+
if (runIssues.length === 0)
|
|
101
|
+
return [];
|
|
102
|
+
const lines = [
|
|
103
|
+
'Run-level (project config, not any one skill):',
|
|
104
|
+
` ${formatIssueSetHeading(runIssues)}:`,
|
|
105
|
+
];
|
|
106
|
+
for (const issue of runIssues) {
|
|
107
|
+
lines.push(...formatIssueLines(issue, ' '));
|
|
108
|
+
}
|
|
109
|
+
return lines;
|
|
110
|
+
}
|
|
88
111
|
/** Identity of an issue for de-duplication across the two post-build channels. */
|
|
89
112
|
function issueIdentity(issue) {
|
|
90
113
|
return [
|
|
@@ -124,6 +147,130 @@ export function collectPostBuildIssues(result) {
|
|
|
124
147
|
}
|
|
125
148
|
return merged;
|
|
126
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Project a set of issues onto its counts: severity buckets plus a per-code tally.
|
|
152
|
+
*
|
|
153
|
+
* Severity counting delegates to `countBySeverity` — there must be exactly one
|
|
154
|
+
* severity collapse in this codebase (see this module's header). That delegation
|
|
155
|
+
* carries its rule with it: `ignore` findings land in NO severity bucket, because
|
|
156
|
+
* the adopter's `validation.allow` config silenced them.
|
|
157
|
+
*
|
|
158
|
+
* They do still appear in `codes`, because they were emitted — a code the adopter
|
|
159
|
+
* allow-listed would otherwise be invisible in every summary, which is the one
|
|
160
|
+
* place a reviewer would look to notice an allow-list that has quietly grown.
|
|
161
|
+
*
|
|
162
|
+
* `codes` is ordered descending by count, ties broken by code name ascending.
|
|
163
|
+
* Insertion order is the YAML serialization order, so the ordering is the feature:
|
|
164
|
+
* the first row names the dominant finding without the reader tallying anything.
|
|
165
|
+
*/
|
|
166
|
+
export function summarizeFindings(issues) {
|
|
167
|
+
const counts = countBySeverity(issues);
|
|
168
|
+
const tally = new Map();
|
|
169
|
+
for (const issue of issues) {
|
|
170
|
+
const code = String(issue.code);
|
|
171
|
+
tally.set(code, (tally.get(code) ?? 0) + 1);
|
|
172
|
+
}
|
|
173
|
+
// `Object.fromEntries` over a sorted array, rather than keyed assignment into a
|
|
174
|
+
// record: it preserves the sort as insertion order without a dynamic index write.
|
|
175
|
+
const codes = Object.fromEntries([...tally.entries()].sort(([codeA, countA], [codeB, countB]) => countB - countA || codeA.localeCompare(codeB)));
|
|
176
|
+
return {
|
|
177
|
+
...(counts.errors > 0 ? { errors: counts.errors } : {}),
|
|
178
|
+
...(counts.warnings > 0 ? { warnings: counts.warnings } : {}),
|
|
179
|
+
...(counts.info > 0 ? { info: counts.info } : {}),
|
|
180
|
+
codes,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* The findings a human-facing report renders IN FULL at a given verbosity.
|
|
185
|
+
*
|
|
186
|
+
* One policy, spelled once, because the three verbs that report findings —
|
|
187
|
+
* `vat skills validate`, `vat skills build`, `vat audit` — each grew their own
|
|
188
|
+
* answer and landed on three different ones: validate collapsed every severity
|
|
189
|
+
* into a per-skill count line, while build and audit printed every occurrence.
|
|
190
|
+
* On a 90-skill adopter that read as 804 lines against 6,552 and 26,480, for
|
|
191
|
+
* the same corpus.
|
|
192
|
+
*
|
|
193
|
+
* The rule is asymmetric on purpose, and the asymmetry is the whole point:
|
|
194
|
+
*
|
|
195
|
+
* - **`error` is always rendered in full**, at every verbosity. An error is what
|
|
196
|
+
* failed the run, there are few of them, and every one is actionable. Collapsing
|
|
197
|
+
* an error into a count means the reader must re-run with a flag to learn what
|
|
198
|
+
* broke — which is strictly worse than the verbosity it was meant to fix. This
|
|
199
|
+
* is the direction the module header warns about: a collapse that hides the
|
|
200
|
+
* thing you needed produces silence, not a false alarm.
|
|
201
|
+
* - **`warning` and `info` collapse into the caller's summary line** unless
|
|
202
|
+
* `verbose`. These are the high-cardinality findings (one adopter skill carries
|
|
203
|
+
* 348 `LINK_DROPPED_BY_DEPTH` warnings alone), and a count plus a per-code tally
|
|
204
|
+
* answers "what is going on here?" without the reader scrolling past 348 near-
|
|
205
|
+
* identical blocks.
|
|
206
|
+
* - **`ignore` never renders**, at any verbosity: the adopter's `validation.allow`
|
|
207
|
+
* config silenced it deliberately. It stays visible in `summarizeFindings`'
|
|
208
|
+
* `codes` tally, which is where a quietly-growing allow-list is noticed.
|
|
209
|
+
*
|
|
210
|
+
* This decides only WHICH findings are rendered, never HOW. Each lane keeps its
|
|
211
|
+
* own heading and summary line — those legitimately differ — so this can be shared
|
|
212
|
+
* without forcing one layout onto three commands.
|
|
213
|
+
*
|
|
214
|
+
* The machine-readable document is NOT filtered by this. `vat audit`'s YAML and
|
|
215
|
+
* `vat skills build`'s `issueCounts` carry every finding at every verbosity;
|
|
216
|
+
* anything else would silently break consumers that parse them.
|
|
217
|
+
*/
|
|
218
|
+
export function issuesToRenderAtVerbosity(issues, verbose) {
|
|
219
|
+
return issues.filter((issue) => issue.severity !== 'ignore' && (verbose || issue.severity === 'error'));
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* How many findings `--verbose` would render that this verbosity does not.
|
|
223
|
+
*
|
|
224
|
+
* Derived from {@link issuesToRenderAtVerbosity} rather than re-stating its rule,
|
|
225
|
+
* so the number a report quotes can never contradict the policy that produced it.
|
|
226
|
+
* Allow-suppressed findings are in neither set, so they are correctly not counted
|
|
227
|
+
* as "hidden by verbosity" — they were hidden by the adopter's own config.
|
|
228
|
+
*/
|
|
229
|
+
export function countCollapsedFindings(issues, verbose) {
|
|
230
|
+
return (issuesToRenderAtVerbosity(issues, true).length
|
|
231
|
+
- issuesToRenderAtVerbosity(issues, verbose).length);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* The one sentence that tells a reader findings exist that they cannot see.
|
|
235
|
+
*
|
|
236
|
+
* A collapsed block is otherwise a heading with nothing beneath it — the
|
|
237
|
+
* reassuring silence this module's header warns about. `vat audit` has printed
|
|
238
|
+
* this line all along and `vat skills build` did not; one helper rather than a
|
|
239
|
+
* second phrasing of the same idea, because two wordings for one concept is how
|
|
240
|
+
* the severity collapse came to be spelled five different ways.
|
|
241
|
+
*
|
|
242
|
+
* `report` names the verb whose YAML the reader should open ("audit", "build").
|
|
243
|
+
* That clause is only honest for a command that publishes full `issues:` arrays;
|
|
244
|
+
* do not pass a report name for a verb that publishes counts alone.
|
|
245
|
+
*
|
|
246
|
+
* Returns `undefined` when nothing was collapsed, so callers print nothing rather
|
|
247
|
+
* than a "0 findings not shown" line.
|
|
248
|
+
*/
|
|
249
|
+
export function formatCollapsedFindingsHint(collapsed, report) {
|
|
250
|
+
if (collapsed <= 0)
|
|
251
|
+
return undefined;
|
|
252
|
+
return (`\n${collapsed} warning/info finding(s) not shown — re-run with --verbose, `
|
|
253
|
+
+ `or read this ${report}'s YAML report on stdout, which lists every finding.`);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* How many files LINK TRAVERSAL put in a bundle, in prose: `1 file`, `11 files`.
|
|
257
|
+
*
|
|
258
|
+
* Deliberately not called the bundle's file count, which is what it reads like and
|
|
259
|
+
* is not: `files.dependencies` carries only what the link-graph walk discovered, so
|
|
260
|
+
* every file `files:` copied in — each glob match, plus any explicit entry the walk
|
|
261
|
+
* had not already bundled — is absent from the total. A bundle holding SKILL.md, one
|
|
262
|
+
* linked doc and one declared artifact prints `2 files`. That undercount is issue
|
|
263
|
+
* #177 and is deliberately NOT patched here; this wording is only the part that can
|
|
264
|
+
* be made true today, so nobody reads the number as an inventory of the output.
|
|
265
|
+
*
|
|
266
|
+
* The `+ 1` is the bundle's root `SKILL.md`, which `files.dependencies` does not
|
|
267
|
+
* list — spelled once here rather than at each progress line, so the two build
|
|
268
|
+
* lanes cannot come to disagree about whether the root document counts.
|
|
269
|
+
*/
|
|
270
|
+
export function formatPackagedFileCount(result) {
|
|
271
|
+
const total = result.files.dependencies.length + 1;
|
|
272
|
+
return `${total} file${total === 1 ? '' : 's'}`;
|
|
273
|
+
}
|
|
127
274
|
/** Sum severity counts across lanes (per-skill → per-plugin → per-run). */
|
|
128
275
|
export function sumSeverityCounts(counts) {
|
|
129
276
|
return counts.reduce((acc, c) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-rendering.js","sourceRoot":"","sources":["../../src/utils/issue-rendering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;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AAQ,EAAE,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ;QACnC,IAAI,EAAE,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI;KACxB,CAAC,EACF,EAAE,MAAM,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE place a `validation.severity` override is applied to already-materialized
|
|
3
|
+
* findings.
|
|
4
|
+
*
|
|
5
|
+
* Every lane that reports findings has to answer the same question — "the adopter
|
|
6
|
+
* configured this code, so what severity does this issue actually carry?" — and the
|
|
7
|
+
* lanes answered it differently for as long as each owned its own copy. Measured on
|
|
8
|
+
* one PR, across a 3-lane × 7-cell matrix driven end to end:
|
|
9
|
+
*
|
|
10
|
+
* - `vat verify`'s packaged-content phase resolved properly, both directions.
|
|
11
|
+
* - `vat audit` computed the merged override map correctly and then consulted it
|
|
12
|
+
* for exactly one value (`!== 'ignore'`), so `ignore` worked and `error` /
|
|
13
|
+
* `warning` / `info` were silent no-ops. An adopter promoting a code to `error`
|
|
14
|
+
* saw `severity: warning`, `errors: 0`, `status: warning`.
|
|
15
|
+
* - `vat verify`'s marketplace phase never met a resolver at all.
|
|
16
|
+
*
|
|
17
|
+
* That is not three bugs, it is one missing module. Anything that re-severities
|
|
18
|
+
* findings imports this; nobody writes a fourth copy. Same rule as
|
|
19
|
+
* `resolveAssetReference` and `resolveSkillReference` in CLAUDE.md.
|
|
20
|
+
*/
|
|
21
|
+
import { type ValidationIssue } from '@vibe-agent-toolkit/agent-schema';
|
|
22
|
+
/** A `validation.severity` map as it appears in config, or nothing. */
|
|
23
|
+
export interface SeverityOverrides {
|
|
24
|
+
severity?: Record<string, string> | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Re-severity findings against a `validation.severity` map, dropping the codes
|
|
28
|
+
* resolved to `ignore`.
|
|
29
|
+
*
|
|
30
|
+
* **Resolution, not just suppression.** Dropping `ignore` codes is the half that is
|
|
31
|
+
* easy to write and the half that looks finished: the documented opt-out starts
|
|
32
|
+
* working, so the escape hatch appears fixed. The promote direction is the half that
|
|
33
|
+
* gets forgotten, and it is the one an adopter reaches for when they want a code to
|
|
34
|
+
* fail their build. A filter that only knows how to delete answers "can I silence
|
|
35
|
+
* this?" and silently ignores "can I enforce this?".
|
|
36
|
+
*
|
|
37
|
+
* Note what each consumer does with the result. Status is re-derived from the
|
|
38
|
+
* returned severities by every caller, so a promotion moves the reported status.
|
|
39
|
+
* Whether it also moves the process exit code is the CALLER's contract, not this
|
|
40
|
+
* function's — `vat verify` derives its exit code from severity, while `vat audit`
|
|
41
|
+
* is advisory and its exit code is tracked separately. Do not "fix" that here.
|
|
42
|
+
*
|
|
43
|
+
* An un-overridden code short-circuits rather than round-tripping through
|
|
44
|
+
* {@link resolveSeverity}. Two reasons, and the second is load-bearing: the answer
|
|
45
|
+
* would be the registry default, which is already the severity the issue carries
|
|
46
|
+
* (`materializeIssue` built it from that same registry); and `resolveSeverity`
|
|
47
|
+
* indexes `CODE_REGISTRY` unguarded, so handing it a non-registry code would throw
|
|
48
|
+
* rather than pass the issue through.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveIssueSeverity(issues: readonly ValidationIssue[], validation: SeverityOverrides | undefined): ValidationIssue[];
|
|
51
|
+
//# sourceMappingURL=issue-severity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-severity.d.ts","sourceRoot":"","sources":["../../src/utils/issue-severity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAmC,KAAK,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAEzG,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CAC/C;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,eAAe,EAAE,EAClC,UAAU,EAAE,iBAAiB,GAAG,SAAS,GACxC,eAAe,EAAE,CAenB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ONE place a `validation.severity` override is applied to already-materialized
|
|
3
|
+
* findings.
|
|
4
|
+
*
|
|
5
|
+
* Every lane that reports findings has to answer the same question — "the adopter
|
|
6
|
+
* configured this code, so what severity does this issue actually carry?" — and the
|
|
7
|
+
* lanes answered it differently for as long as each owned its own copy. Measured on
|
|
8
|
+
* one PR, across a 3-lane × 7-cell matrix driven end to end:
|
|
9
|
+
*
|
|
10
|
+
* - `vat verify`'s packaged-content phase resolved properly, both directions.
|
|
11
|
+
* - `vat audit` computed the merged override map correctly and then consulted it
|
|
12
|
+
* for exactly one value (`!== 'ignore'`), so `ignore` worked and `error` /
|
|
13
|
+
* `warning` / `info` were silent no-ops. An adopter promoting a code to `error`
|
|
14
|
+
* saw `severity: warning`, `errors: 0`, `status: warning`.
|
|
15
|
+
* - `vat verify`'s marketplace phase never met a resolver at all.
|
|
16
|
+
*
|
|
17
|
+
* That is not three bugs, it is one missing module. Anything that re-severities
|
|
18
|
+
* findings imports this; nobody writes a fourth copy. Same rule as
|
|
19
|
+
* `resolveAssetReference` and `resolveSkillReference` in CLAUDE.md.
|
|
20
|
+
*/
|
|
21
|
+
import { resolveSeverity } from '@vibe-agent-toolkit/agent-schema';
|
|
22
|
+
/**
|
|
23
|
+
* Re-severity findings against a `validation.severity` map, dropping the codes
|
|
24
|
+
* resolved to `ignore`.
|
|
25
|
+
*
|
|
26
|
+
* **Resolution, not just suppression.** Dropping `ignore` codes is the half that is
|
|
27
|
+
* easy to write and the half that looks finished: the documented opt-out starts
|
|
28
|
+
* working, so the escape hatch appears fixed. The promote direction is the half that
|
|
29
|
+
* gets forgotten, and it is the one an adopter reaches for when they want a code to
|
|
30
|
+
* fail their build. A filter that only knows how to delete answers "can I silence
|
|
31
|
+
* this?" and silently ignores "can I enforce this?".
|
|
32
|
+
*
|
|
33
|
+
* Note what each consumer does with the result. Status is re-derived from the
|
|
34
|
+
* returned severities by every caller, so a promotion moves the reported status.
|
|
35
|
+
* Whether it also moves the process exit code is the CALLER's contract, not this
|
|
36
|
+
* function's — `vat verify` derives its exit code from severity, while `vat audit`
|
|
37
|
+
* is advisory and its exit code is tracked separately. Do not "fix" that here.
|
|
38
|
+
*
|
|
39
|
+
* An un-overridden code short-circuits rather than round-tripping through
|
|
40
|
+
* {@link resolveSeverity}. Two reasons, and the second is load-bearing: the answer
|
|
41
|
+
* would be the registry default, which is already the severity the issue carries
|
|
42
|
+
* (`materializeIssue` built it from that same registry); and `resolveSeverity`
|
|
43
|
+
* indexes `CODE_REGISTRY` unguarded, so handing it a non-registry code would throw
|
|
44
|
+
* rather than pass the issue through.
|
|
45
|
+
*/
|
|
46
|
+
export function resolveIssueSeverity(issues, validation) {
|
|
47
|
+
const overrides = validation?.severity;
|
|
48
|
+
if (overrides === undefined)
|
|
49
|
+
return [...issues];
|
|
50
|
+
const resolved = [];
|
|
51
|
+
for (const issue of issues) {
|
|
52
|
+
if (!(issue.code in overrides)) {
|
|
53
|
+
resolved.push(issue);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const severity = resolveSeverity(issue.code, { severity: overrides });
|
|
57
|
+
if (severity === 'ignore')
|
|
58
|
+
continue;
|
|
59
|
+
resolved.push(severity === issue.severity ? issue : { ...issue, severity });
|
|
60
|
+
}
|
|
61
|
+
return resolved;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=issue-severity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-severity.js","sourceRoot":"","sources":["../../src/utils/issue-severity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAkB,eAAe,EAAwB,MAAM,kCAAkC,CAAC;AAOzG;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAkC,EAClC,UAAyC;IAEzC,MAAM,SAAS,GAAG,UAAU,EAAE,QAAQ,CAAC;IACvC,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;IAEhD,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC;YAC/B,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,SAAS;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,IAAiB,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC;QACnF,IAAI,QAAQ,KAAK,QAAQ;YAAE,SAAS;QACpC,QAAQ,CAAC,IAAI,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/utils/output.d.ts
CHANGED
|
@@ -2,6 +2,60 @@
|
|
|
2
2
|
* Output utilities for structured data
|
|
3
3
|
* YAML output on stdout, logs on stderr
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Write `content` to stdout SYNCHRONOUSLY, in a loop until every byte is handed
|
|
7
|
+
* over.
|
|
8
|
+
*
|
|
9
|
+
* `process.stdout.write` is asynchronous whenever stdout is a PIPE, and every
|
|
10
|
+
* command in this CLI calls `process.exit()` the moment it has written its
|
|
11
|
+
* summary. `process.exit` does not drain a pending write, so everything past the
|
|
12
|
+
* first pipe buffer (64 KB on Linux/macOS) was silently discarded — with exit
|
|
13
|
+
* code 0, so nothing signalled the loss. An interactive TTY is unbuffered and
|
|
14
|
+
* looked perfect, which is why this survived: it only bites the piped consumer
|
|
15
|
+
* this CLI's own docs recommend (`vat command | jq .status`).
|
|
16
|
+
*
|
|
17
|
+
* `writeSync` cannot return before the bytes reach the pipe, so `process.exit`
|
|
18
|
+
* has nothing left to lose. The loop is required because a single `writeSync`
|
|
19
|
+
* may accept fewer bytes than offered.
|
|
20
|
+
*
|
|
21
|
+
* This is the same fix `help-loader.ts` applied to `--help --verbose`; it lives
|
|
22
|
+
* here so both callers share one implementation rather than two copies of a
|
|
23
|
+
* subtle loop.
|
|
24
|
+
*/
|
|
25
|
+
export declare function writeStdoutSync(content: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* A synchronous write primitive: `(buffer, offset, length) => bytesWritten`.
|
|
28
|
+
*
|
|
29
|
+
* Matches `fs.writeSync`'s shape so the real one drops straight in, while a test
|
|
30
|
+
* can supply one that returns short counts or throws EAGAIN on demand.
|
|
31
|
+
*/
|
|
32
|
+
export type SyncWriter = (buffer: Buffer, offset: number, length: number) => number;
|
|
33
|
+
export interface WriteAllSyncOptions {
|
|
34
|
+
/** Override {@link MAX_CONSECUTIVE_EAGAIN_RETRIES}. Tests use a tiny budget. */
|
|
35
|
+
maxConsecutiveRetries?: number;
|
|
36
|
+
/** Override the backoff. Tests pass a no-op to drive the bound instantly. */
|
|
37
|
+
waitBetweenRetries?: (consecutiveRetries: number) => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Drive `write` until every byte of `buffer` has been accepted.
|
|
41
|
+
*
|
|
42
|
+
* Split out from {@link writeStdoutSync} because the things that make this loop
|
|
43
|
+
* necessary — a short write, and an EAGAIN retry on a momentarily-full
|
|
44
|
+
* non-blocking pipe — are both hard to provoke on a real fd and trivial to state
|
|
45
|
+
* against an injected writer. The fd-1 wiring stays a one-liner above, so the
|
|
46
|
+
* only part with branching logic is the part that can be unit tested.
|
|
47
|
+
*
|
|
48
|
+
* The EAGAIN retry is BOUNDED. A reader that stops draining without closing the
|
|
49
|
+
* pipe (`vat … | consumer-that-wanders-off`) leaves it permanently full, so
|
|
50
|
+
* every retry raises EAGAIN forever; an unbounded loop turns that into a hang
|
|
51
|
+
* with no output and no error — strictly worse than the truncation this replaced.
|
|
52
|
+
* Exhausting the budget throws, so the failure is visible and the exit code is
|
|
53
|
+
* non-zero, rather than the bytes quietly going missing.
|
|
54
|
+
*
|
|
55
|
+
* @throws the underlying error for any failure other than EAGAIN; an `Error`
|
|
56
|
+
* naming the unwritten remainder when the retry budget is exhausted.
|
|
57
|
+
*/
|
|
58
|
+
export declare function writeAllSync(write: SyncWriter, buffer: Buffer, options?: WriteAllSyncOptions): void;
|
|
5
59
|
/**
|
|
6
60
|
* Write a single YAML document to stdout, opened with `---`.
|
|
7
61
|
*
|
|
@@ -22,11 +76,6 @@
|
|
|
22
76
|
* @param data - Data to serialize as YAML
|
|
23
77
|
*/
|
|
24
78
|
export declare function writeYamlOutput(data: unknown): void;
|
|
25
|
-
/**
|
|
26
|
-
* Flush stdout before writing to stderr
|
|
27
|
-
* Prevents output corruption when streams are merged
|
|
28
|
-
*/
|
|
29
|
-
export declare function flushStdout(): Promise<void>;
|
|
30
79
|
/**
|
|
31
80
|
* Write a test-format finding to stderr.
|
|
32
81
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAKrD;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;AAoCpF,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,6EAA6E;IAC7E,kBAAkB,CAAC,EAAE,CAAC,kBAAkB,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,mBAAwB,GAChC,IAAI,CA+BN;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAWnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,IAAI,CAEN"}
|
package/dist/utils/output.js
CHANGED
|
@@ -2,7 +2,111 @@
|
|
|
2
2
|
* Output utilities for structured data
|
|
3
3
|
* YAML output on stdout, logs on stderr
|
|
4
4
|
*/
|
|
5
|
+
import { writeSync } from 'node:fs';
|
|
5
6
|
import * as yaml from 'yaml';
|
|
7
|
+
/**
|
|
8
|
+
* Write `content` to stdout SYNCHRONOUSLY, in a loop until every byte is handed
|
|
9
|
+
* over.
|
|
10
|
+
*
|
|
11
|
+
* `process.stdout.write` is asynchronous whenever stdout is a PIPE, and every
|
|
12
|
+
* command in this CLI calls `process.exit()` the moment it has written its
|
|
13
|
+
* summary. `process.exit` does not drain a pending write, so everything past the
|
|
14
|
+
* first pipe buffer (64 KB on Linux/macOS) was silently discarded — with exit
|
|
15
|
+
* code 0, so nothing signalled the loss. An interactive TTY is unbuffered and
|
|
16
|
+
* looked perfect, which is why this survived: it only bites the piped consumer
|
|
17
|
+
* this CLI's own docs recommend (`vat command | jq .status`).
|
|
18
|
+
*
|
|
19
|
+
* `writeSync` cannot return before the bytes reach the pipe, so `process.exit`
|
|
20
|
+
* has nothing left to lose. The loop is required because a single `writeSync`
|
|
21
|
+
* may accept fewer bytes than offered.
|
|
22
|
+
*
|
|
23
|
+
* This is the same fix `help-loader.ts` applied to `--help --verbose`; it lives
|
|
24
|
+
* here so both callers share one implementation rather than two copies of a
|
|
25
|
+
* subtle loop.
|
|
26
|
+
*/
|
|
27
|
+
export function writeStdoutSync(content) {
|
|
28
|
+
writeAllSync((buffer, offset, length) => writeSync(1, buffer, offset, length), Buffer.from(content, 'utf8'));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* How many CONSECUTIVE EAGAIN retries — retries during which the writer accepted
|
|
32
|
+
* zero bytes — are tolerated before the write is declared stalled.
|
|
33
|
+
*
|
|
34
|
+
* Consecutive, not cumulative: a large payload to a slow reader legitimately
|
|
35
|
+
* EAGAINs thousands of times in total, and every one of those is followed by
|
|
36
|
+
* progress. What is never legitimate is the pipe staying full while the process
|
|
37
|
+
* on the other end takes nothing at all. Combined with the wait below, the
|
|
38
|
+
* budget is roughly ten seconds of a completely stalled reader.
|
|
39
|
+
*/
|
|
40
|
+
const MAX_CONSECUTIVE_EAGAIN_RETRIES = 10_000;
|
|
41
|
+
/** Consecutive retries to spin on before sleeping between attempts. */
|
|
42
|
+
const EAGAIN_SPIN_RETRIES = 16;
|
|
43
|
+
/**
|
|
44
|
+
* Sleep synchronously. Required because this whole path exists to run to
|
|
45
|
+
* completion before `process.exit`, so it cannot yield to the event loop; a
|
|
46
|
+
* timer would never fire. `Atomics.wait` on a never-notified buffer is the one
|
|
47
|
+
* primitive that blocks the thread without burning CPU.
|
|
48
|
+
*/
|
|
49
|
+
function sleepSync(ms) {
|
|
50
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Spin for the first few retries — a draining pipe frees space in microseconds,
|
|
54
|
+
* and paying a millisecond for that would be absurd — then back off to a real
|
|
55
|
+
* sleep so a genuinely stalled reader is waited out rather than spun on.
|
|
56
|
+
*/
|
|
57
|
+
function defaultWaitBetweenRetries(consecutiveRetries) {
|
|
58
|
+
if (consecutiveRetries > EAGAIN_SPIN_RETRIES)
|
|
59
|
+
sleepSync(1);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Drive `write` until every byte of `buffer` has been accepted.
|
|
63
|
+
*
|
|
64
|
+
* Split out from {@link writeStdoutSync} because the things that make this loop
|
|
65
|
+
* necessary — a short write, and an EAGAIN retry on a momentarily-full
|
|
66
|
+
* non-blocking pipe — are both hard to provoke on a real fd and trivial to state
|
|
67
|
+
* against an injected writer. The fd-1 wiring stays a one-liner above, so the
|
|
68
|
+
* only part with branching logic is the part that can be unit tested.
|
|
69
|
+
*
|
|
70
|
+
* The EAGAIN retry is BOUNDED. A reader that stops draining without closing the
|
|
71
|
+
* pipe (`vat … | consumer-that-wanders-off`) leaves it permanently full, so
|
|
72
|
+
* every retry raises EAGAIN forever; an unbounded loop turns that into a hang
|
|
73
|
+
* with no output and no error — strictly worse than the truncation this replaced.
|
|
74
|
+
* Exhausting the budget throws, so the failure is visible and the exit code is
|
|
75
|
+
* non-zero, rather than the bytes quietly going missing.
|
|
76
|
+
*
|
|
77
|
+
* @throws the underlying error for any failure other than EAGAIN; an `Error`
|
|
78
|
+
* naming the unwritten remainder when the retry budget is exhausted.
|
|
79
|
+
*/
|
|
80
|
+
export function writeAllSync(write, buffer, options = {}) {
|
|
81
|
+
const maxRetries = options.maxConsecutiveRetries ?? MAX_CONSECUTIVE_EAGAIN_RETRIES;
|
|
82
|
+
const wait = options.waitBetweenRetries ?? defaultWaitBetweenRetries;
|
|
83
|
+
let written = 0;
|
|
84
|
+
let consecutiveRetries = 0;
|
|
85
|
+
while (written < buffer.length) {
|
|
86
|
+
try {
|
|
87
|
+
const n = write(buffer, written, buffer.length - written);
|
|
88
|
+
// A writer that reports no progress would spin forever. Treat it as a
|
|
89
|
+
// failure rather than hang the CLI.
|
|
90
|
+
if (n <= 0) {
|
|
91
|
+
throw new Error(`Refusing to loop forever: writer accepted ${n} bytes of ${buffer.length - written} remaining`);
|
|
92
|
+
}
|
|
93
|
+
written += n;
|
|
94
|
+
consecutiveRetries = 0;
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
// A non-blocking pipe whose buffer is momentarily full raises EAGAIN; a
|
|
98
|
+
// reader that is draining will free space, so retry. Anything else is a
|
|
99
|
+
// genuine write failure.
|
|
100
|
+
if (error.code !== 'EAGAIN')
|
|
101
|
+
throw error;
|
|
102
|
+
consecutiveRetries++;
|
|
103
|
+
if (consecutiveRetries > maxRetries) {
|
|
104
|
+
throw new Error(`Write stalled: ${maxRetries} consecutive EAGAIN retries with no progress after ${written} of ${buffer.length} bytes. The reader is not draining the pipe.`);
|
|
105
|
+
}
|
|
106
|
+
wait(consecutiveRetries);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
6
110
|
/**
|
|
7
111
|
* Write a single YAML document to stdout, opened with `---`.
|
|
8
112
|
*
|
|
@@ -23,26 +127,16 @@ import * as yaml from 'yaml';
|
|
|
23
127
|
* @param data - Data to serialize as YAML
|
|
24
128
|
*/
|
|
25
129
|
export function writeYamlOutput(data) {
|
|
26
|
-
|
|
27
|
-
|
|
130
|
+
// Deliberately the ordinary stream write, NOT writeStdoutSync: this summary
|
|
131
|
+
// follows human-readable progress output written via console.log, and a
|
|
132
|
+
// synchronous fd-1 write would jump ahead of anything still buffered there.
|
|
133
|
+
// Completeness is guaranteed instead by makeStdioBlocking() at startup, which
|
|
134
|
+
// makes BOTH channels synchronous and keeps them in order.
|
|
135
|
+
process.stdout.write(`---\n${yaml.stringify(data, {
|
|
28
136
|
indent: 2,
|
|
29
137
|
lineWidth: 120,
|
|
30
138
|
aliasDuplicateObjects: false,
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Flush stdout before writing to stderr
|
|
35
|
-
* Prevents output corruption when streams are merged
|
|
36
|
-
*/
|
|
37
|
-
export async function flushStdout() {
|
|
38
|
-
return new Promise((resolve) => {
|
|
39
|
-
if (process.stdout.writableNeedDrain) {
|
|
40
|
-
process.stdout.once('drain', resolve);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
resolve();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
139
|
+
})}`);
|
|
46
140
|
}
|
|
47
141
|
/**
|
|
48
142
|
* Write a test-format finding to stderr.
|
package/dist/utils/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,YAAY,CACV,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAChE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAC7B,CAAC;AACJ,CAAC;AAUD;;;;;;;;;GASG;AACH,MAAM,8BAA8B,GAAG,MAAM,CAAC;AAE9C,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B;;;;;GAKG;AACH,SAAS,SAAS,CAAC,EAAU;IAC3B,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,iBAAiB,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MAAM,CAAC,MAAM,8CAA8C,CAC5J,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,eAAe,CAAC,IAAa;IAC3C,4EAA4E;IAC5E,wEAAwE;IACxE,4EAA4E;IAC5E,8EAA8E;IAC9E,2DAA2D;IAC3D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAChD,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,GAAG;QACd,qBAAqB,EAAE,KAAK;KAC7B,CAAC,EAAE,CAAC,CAAC;AACR,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,IAAY,EACZ,IAAY,EACZ,MAAc,EACd,QAAgB,EAChB,OAAe;IAEf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,MAAM,KAAK,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-basing report `path` values onto the run's single stated root.
|
|
3
|
+
*
|
|
4
|
+
* A report states its coordinate system ONCE — `root:` — and every `path`
|
|
5
|
+
* beneath it is relative to that. Producers keep absolute paths internally on
|
|
6
|
+
* purpose: an absolute path is the identity every internal map keys on (compat
|
|
7
|
+
* results, visited-path de-duplication, registry caches), and unlike a
|
|
8
|
+
* `location` it is trivially recoverable, since an absolute path plus a known
|
|
9
|
+
* root yields the relative form. Re-basing therefore happens once, at the
|
|
10
|
+
* document boundary, and this module is that one place.
|
|
11
|
+
*
|
|
12
|
+
* Deliberately NOT a deep walk over every `path`-named property: re-basing is
|
|
13
|
+
* not idempotent (`relative(root, someRelativeValue)` resolves the value
|
|
14
|
+
* against the process cwd and produces nonsense), so a helper that guesses
|
|
15
|
+
* which values are absolute would silently corrupt an already-relative one.
|
|
16
|
+
* The caller names the nested carriers it owns instead.
|
|
17
|
+
*/
|
|
18
|
+
/** The minimum shape this module re-bases: anything carrying a `path`. */
|
|
19
|
+
export interface PathEntry {
|
|
20
|
+
path: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Re-base one absolute path onto `root`, as a forward-slashed relative path.
|
|
24
|
+
*
|
|
25
|
+
* Pointing a report AT a single resource makes that resource the root, which
|
|
26
|
+
* relativizes to the empty string. That is spelled `.` — the POSIX name for
|
|
27
|
+
* "the root itself" — so no consumer has to special-case a blank value, and
|
|
28
|
+
* `join(root, path)` still resolves.
|
|
29
|
+
*/
|
|
30
|
+
export declare function relativizePath(absolutePath: string, root: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Re-base the `path` of every entry — and of every entry inside the nested
|
|
33
|
+
* carriers named by `nestedKeys`, at any depth — onto `root`.
|
|
34
|
+
*
|
|
35
|
+
* Returns new objects; the input is never mutated.
|
|
36
|
+
*
|
|
37
|
+
* @param entries - Report entries carrying absolute `path` values.
|
|
38
|
+
* @param root - The single root the document states.
|
|
39
|
+
* @param nestedKeys - Names of array-valued properties whose elements also
|
|
40
|
+
* carry an absolute `path` (audit passes `['linkedFiles']`). Omitting a
|
|
41
|
+
* carrier leaves its paths absolute, which is how a document ends up in two
|
|
42
|
+
* coordinate systems — so a producer that adds a carrier must name it here.
|
|
43
|
+
*/
|
|
44
|
+
export declare function relativizePathEntries<T extends PathEntry>(entries: readonly T[], root: string, nestedKeys?: readonly string[]): T[];
|
|
45
|
+
//# sourceMappingURL=relativize-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relativize-paths.d.ts","sourceRoot":"","sources":["../../src/utils/relativize-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,0EAA0E;AAC1E,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzE;AA+BD;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,SAAS,EACvD,OAAO,EAAE,SAAS,CAAC,EAAE,EACrB,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,SAAS,MAAM,EAAO,GACjC,CAAC,EAAE,CAEL"}
|