@vibe-agent-toolkit/cli 0.1.41-rc.6 → 0.1.41-rc.8
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/README.md +4 -3
- package/dist/bin/vat +25 -2
- package/dist/bin/vat.js +25 -2
- package/dist/bin/vat.js.map +1 -1
- package/dist/bin.js +12 -1
- 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/hierarchical-output.d.ts +6 -2
- package/dist/commands/audit/hierarchical-output.d.ts.map +1 -1
- package/dist/commands/audit/hierarchical-output.js +93 -50
- package/dist/commands/audit/hierarchical-output.js.map +1 -1
- package/dist/commands/audit-settings.d.ts +35 -0
- package/dist/commands/audit-settings.d.ts.map +1 -1
- package/dist/commands/audit-settings.js +121 -51
- package/dist/commands/audit-settings.js.map +1 -1
- package/dist/commands/audit.d.ts +97 -2
- package/dist/commands/audit.d.ts.map +1 -1
- package/dist/commands/audit.js +505 -231
- 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 +126 -32
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/claude/marketplace/license-utils.d.ts +39 -2
- package/dist/commands/claude/marketplace/license-utils.d.ts.map +1 -1
- package/dist/commands/claude/marketplace/license-utils.js +114 -68
- package/dist/commands/claude/marketplace/license-utils.js.map +1 -1
- package/dist/commands/claude/marketplace/publish.js +5 -4
- package/dist/commands/claude/marketplace/publish.js.map +1 -1
- package/dist/commands/claude/marketplace/validate.d.ts +97 -0
- package/dist/commands/claude/marketplace/validate.d.ts.map +1 -1
- package/dist/commands/claude/marketplace/validate.js +157 -49
- package/dist/commands/claude/marketplace/validate.js.map +1 -1
- package/dist/commands/claude/org/skills.d.ts +11 -3
- package/dist/commands/claude/org/skills.d.ts.map +1 -1
- package/dist/commands/claude/org/skills.js +70 -20
- package/dist/commands/claude/org/skills.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 +116 -0
- package/dist/commands/claude/plugin/build.d.ts.map +1 -1
- package/dist/commands/claude/plugin/build.js +173 -40
- package/dist/commands/claude/plugin/build.js.map +1 -1
- package/dist/commands/claude/plugin/marketplace-json.d.ts +36 -0
- package/dist/commands/claude/plugin/marketplace-json.d.ts.map +1 -0
- package/dist/commands/claude/plugin/marketplace-json.js +34 -0
- package/dist/commands/claude/plugin/marketplace-json.js.map +1 -0
- package/dist/commands/claude/plugin/plugin-json-merge.d.ts +30 -1
- package/dist/commands/claude/plugin/plugin-json-merge.d.ts.map +1 -1
- package/dist/commands/claude/plugin/plugin-json-merge.js +107 -14
- package/dist/commands/claude/plugin/plugin-json-merge.js.map +1 -1
- package/dist/commands/claude/plugin/tree-copy.d.ts.map +1 -1
- package/dist/commands/claude/plugin/tree-copy.js +0 -1
- 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 +55 -48
- package/dist/commands/corpus/runner.js.map +1 -1
- package/dist/commands/doctor.d.ts +57 -8
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +142 -67
- 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 +240 -11
- package/dist/commands/phase-utils.d.ts.map +1 -1
- package/dist/commands/phase-utils.js +352 -15
- package/dist/commands/phase-utils.js.map +1 -1
- 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 +38 -13
- 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 +121 -68
- package/dist/commands/resources/validate.js.map +1 -1
- package/dist/commands/skill/review.d.ts.map +1 -1
- package/dist/commands/skill/review.js +40 -23
- 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 +140 -0
- package/dist/commands/skills/build.d.ts.map +1 -1
- package/dist/commands/skills/build.js +348 -94
- 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 +17 -0
- package/dist/commands/skills/package.d.ts.map +1 -1
- package/dist/commands/skills/package.js +72 -43
- 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 +9 -1
- package/dist/commands/skills/skill-discovery.js.map +1 -1
- package/dist/commands/skills/validate-command.d.ts.map +1 -1
- package/dist/commands/skills/validate-command.js +22 -6
- package/dist/commands/skills/validate-command.js.map +1 -1
- package/dist/commands/skills/validate.d.ts +79 -0
- package/dist/commands/skills/validate.d.ts.map +1 -1
- package/dist/commands/skills/validate.js +268 -79
- 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 +79 -66
- package/dist/commands/validate.js.map +1 -1
- package/dist/commands/verify.d.ts +38 -1
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +247 -84
- 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/config-loader.d.ts.map +1 -1
- package/dist/utils/config-loader.js +0 -2
- package/dist/utils/config-loader.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-anchor.d.ts +26 -0
- package/dist/utils/issue-anchor.d.ts.map +1 -0
- package/dist/utils/issue-anchor.js +39 -0
- package/dist/utils/issue-anchor.js.map +1 -0
- package/dist/utils/issue-rendering.d.ts +149 -0
- package/dist/utils/issue-rendering.d.ts.map +1 -0
- package/dist/utils/issue-rendering.js +229 -0
- package/dist/utils/issue-rendering.js.map +1 -0
- package/dist/utils/output.d.ts +80 -9
- package/dist/utils/output.d.ts.map +1 -1
- package/dist/utils/output.js +138 -23
- package/dist/utils/output.js.map +1 -1
- package/dist/utils/project-root-policy.d.ts +2 -2
- package/dist/utils/project-root-policy.js +2 -2
- 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/validate-help-files.d.ts +3 -2
- package/dist/utils/validate-help-files.d.ts.map +1 -1
- package/dist/utils/validate-help-files.js +48 -5
- package/dist/utils/validate-help-files.js.map +1 -1
- package/dist/utils/verdict-helpers.d.ts +14 -5
- package/dist/utils/verdict-helpers.d.ts.map +1 -1
- package/dist/utils/verdict-helpers.js +19 -16
- package/dist/utils/verdict-helpers.js.map +1 -1
- package/docs/audit.md +40 -14
- package/docs/doctor.md +46 -10
- package/docs/index.md +1 -1
- package/docs/rag.md +9 -4
- package/docs/resources.md +54 -22
- package/docs/skills.md +11 -7
- package/package.json +12 -12
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rendering for SETS of `ValidationIssue`s — the severity label, the set's
|
|
3
|
+
* heading, and the per-issue block.
|
|
4
|
+
*
|
|
5
|
+
* `issue-anchor.ts` answers "where is this issue?"; this module answers "what
|
|
6
|
+
* severity is it, and what is in this set?". Both exist because the answer has
|
|
7
|
+
* to be spelled identically by every command: two renderers that each invent
|
|
8
|
+
* their own severity prefix is exactly how `info` findings came to be printed
|
|
9
|
+
* as `[WARNING]` in `vat skills build` AND `vat claude plugin build`, and how a
|
|
10
|
+
* mixed set came to be labelled "post-build error(s)" wholesale.
|
|
11
|
+
*
|
|
12
|
+
* The failure mode these helpers exist to prevent is directional: every
|
|
13
|
+
* hand-rolled severity collapse in this codebase mapped the case it could not
|
|
14
|
+
* represent onto the REASSURING one (info ⇒ "warning", warnings ⇒ "all
|
|
15
|
+
* passed"). That is why none of it was ever reported — it produces silence, not
|
|
16
|
+
* a false alarm.
|
|
17
|
+
*/
|
|
18
|
+
import { countBySeverity, } from '@vibe-agent-toolkit/agent-schema';
|
|
19
|
+
import { formatIssueAnchor } from './issue-anchor.js';
|
|
20
|
+
/**
|
|
21
|
+
* Uppercase label for a resolved severity.
|
|
22
|
+
*
|
|
23
|
+
* A total map, not an `=== 'error' ? … : …` ternary: the ternary is what
|
|
24
|
+
* rendered every non-error severity — `info` included — as `WARNING`.
|
|
25
|
+
*/
|
|
26
|
+
const SEVERITY_LABELS = {
|
|
27
|
+
error: 'ERROR',
|
|
28
|
+
warning: 'WARNING',
|
|
29
|
+
info: 'INFO',
|
|
30
|
+
ignore: 'IGNORED',
|
|
31
|
+
};
|
|
32
|
+
/** Render an issue's own severity as itself. */
|
|
33
|
+
export function severityLabel(severity) {
|
|
34
|
+
return SEVERITY_LABELS[severity];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The severity distribution in prose: `1 error, 2 warnings, 3 info`.
|
|
38
|
+
*
|
|
39
|
+
* Zero buckets are omitted so the phrase names only what is present. An
|
|
40
|
+
* all-zero set returns `no findings` rather than an empty string, because an
|
|
41
|
+
* empty string silently disappears into whatever sentence embeds it.
|
|
42
|
+
*/
|
|
43
|
+
export function formatSeverityBreakdown(counts) {
|
|
44
|
+
const parts = [];
|
|
45
|
+
if (counts.errors > 0) {
|
|
46
|
+
parts.push(`${counts.errors} error${counts.errors === 1 ? '' : 's'}`);
|
|
47
|
+
}
|
|
48
|
+
if (counts.warnings > 0) {
|
|
49
|
+
parts.push(`${counts.warnings} warning${counts.warnings === 1 ? '' : 's'}`);
|
|
50
|
+
}
|
|
51
|
+
if (counts.info > 0) {
|
|
52
|
+
parts.push(`${counts.info} info`);
|
|
53
|
+
}
|
|
54
|
+
return parts.length === 0 ? 'no findings' : parts.join(', ');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Heading for a set of issues: `3 post-build issues (1 error, 2 info)`.
|
|
58
|
+
*
|
|
59
|
+
* The breakdown is not decoration — it is the only part of the heading that
|
|
60
|
+
* cannot be wrong about a mixed set. `noun` qualifies the set ("post-build"),
|
|
61
|
+
* and is omitted entirely when empty.
|
|
62
|
+
*/
|
|
63
|
+
export function formatIssueSetHeading(issues, noun) {
|
|
64
|
+
const qualifier = noun === undefined || noun === '' ? '' : `${noun} `;
|
|
65
|
+
const total = issues.length;
|
|
66
|
+
const breakdown = formatSeverityBreakdown(countBySeverity(issues));
|
|
67
|
+
return `${total} ${qualifier}issue${total === 1 ? '' : 's'} (${breakdown})`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Render one issue as its own lines, each prefixed with `indent`.
|
|
71
|
+
*
|
|
72
|
+
* Returns an array rather than writing, so a caller can pick its own stream and
|
|
73
|
+
* a unit test can assert over every line without capturing output.
|
|
74
|
+
*/
|
|
75
|
+
export function formatIssueLines(issue, indent = '') {
|
|
76
|
+
const lines = [
|
|
77
|
+
`${indent}[${severityLabel(issue.severity)}] [${String(issue.code)}] ${String(issue.message)}`,
|
|
78
|
+
];
|
|
79
|
+
const anchor = formatIssueAnchor(issue);
|
|
80
|
+
if (anchor !== undefined) {
|
|
81
|
+
lines.push(`${indent} Location: ${anchor}`);
|
|
82
|
+
}
|
|
83
|
+
if (issue.fix) {
|
|
84
|
+
lines.push(`${indent} Fix: ${String(issue.fix)}`);
|
|
85
|
+
}
|
|
86
|
+
return lines;
|
|
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
|
+
}
|
|
111
|
+
/** Identity of an issue for de-duplication across the two post-build channels. */
|
|
112
|
+
function issueIdentity(issue) {
|
|
113
|
+
return [
|
|
114
|
+
issue.code,
|
|
115
|
+
issue.severity,
|
|
116
|
+
issue.location ?? '',
|
|
117
|
+
issue.line === undefined ? '' : String(issue.line),
|
|
118
|
+
issue.field ?? '',
|
|
119
|
+
issue.message,
|
|
120
|
+
].join('\0');
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Every post-build finding a `PackageSkillResult` carries, from BOTH channels.
|
|
124
|
+
*
|
|
125
|
+
* `hasErrors` is the OR of two independent sets — the packager's own framework
|
|
126
|
+
* run (`postBuildIssues`: link exclusions, unreferenced files, broken packaged
|
|
127
|
+
* links) and the full validation of the built tree (`postBuildValidation`). A
|
|
128
|
+
* renderer that walks only `postBuildIssues` therefore prints NOTHING for a
|
|
129
|
+
* build that failed purely on `postBuildValidation`: the user is told the build
|
|
130
|
+
* failed and shown no reason. Reading both is the whole point of this helper.
|
|
131
|
+
*
|
|
132
|
+
* `postBuildValidation.allErrors` is the full emitted set including `info`
|
|
133
|
+
* (see its doc comment — the name lies), so info findings survive here.
|
|
134
|
+
*/
|
|
135
|
+
export function collectPostBuildIssues(result) {
|
|
136
|
+
const seen = new Set();
|
|
137
|
+
const merged = [];
|
|
138
|
+
for (const issue of [
|
|
139
|
+
...(result.postBuildIssues ?? []),
|
|
140
|
+
...(result.postBuildValidation?.allErrors ?? []),
|
|
141
|
+
]) {
|
|
142
|
+
const identity = issueIdentity(issue);
|
|
143
|
+
if (seen.has(identity))
|
|
144
|
+
continue;
|
|
145
|
+
seen.add(identity);
|
|
146
|
+
merged.push(issue);
|
|
147
|
+
}
|
|
148
|
+
return merged;
|
|
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
|
+
/** Sum severity counts across lanes (per-skill → per-plugin → per-run). */
|
|
222
|
+
export function sumSeverityCounts(counts) {
|
|
223
|
+
return counts.reduce((acc, c) => ({
|
|
224
|
+
errors: acc.errors + c.errors,
|
|
225
|
+
warnings: acc.warnings + c.warnings,
|
|
226
|
+
info: acc.info + c.info,
|
|
227
|
+
}), { errors: 0, warnings: 0, info: 0 });
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=issue-rendering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-rendering.js","sourceRoot":"","sources":["../../src/utils/issue-rendering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,eAAe,GAGhB,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC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K,QAAQ,IAAI,CAAC,OAAO,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,CAAC,CAClF,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAAC,MAAiC;IACjE,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM;QAC7B,QAAQ,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"}
|
package/dist/utils/output.d.ts
CHANGED
|
@@ -3,18 +3,89 @@
|
|
|
3
3
|
* YAML output on stdout, logs on stderr
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
* Write
|
|
7
|
-
*
|
|
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.
|
|
8
24
|
*/
|
|
9
|
-
export declare function
|
|
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
|
+
}
|
|
10
39
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
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.
|
|
13
57
|
*/
|
|
14
|
-
export declare function
|
|
58
|
+
export declare function writeAllSync(write: SyncWriter, buffer: Buffer, options?: WriteAllSyncOptions): void;
|
|
59
|
+
/**
|
|
60
|
+
* Write a single YAML document to stdout, opened with `---`.
|
|
61
|
+
*
|
|
62
|
+
* There is deliberately NO trailing marker. `---` OPENS a document in YAML; the
|
|
63
|
+
* end-of-document marker is `...`. Emitting `---` at the end therefore opened a
|
|
64
|
+
* second, empty document, so every command's stdout was a two-document stream and
|
|
65
|
+
* a plain `YAML.parse()` threw `Source contains multiple documents` — on output
|
|
66
|
+
* this CLI documents as "YAML summary → stdout (for programmatic parsing)".
|
|
67
|
+
*
|
|
68
|
+
* The repo's own test helper had already been written around it: `executeCli…`
|
|
69
|
+
* calls `parseAllDocuments(...)` and takes `docs[0]`, with a comment saying "to
|
|
70
|
+
* handle document markers". That workaround is what kept the defect invisible —
|
|
71
|
+
* every consumer that did the obvious thing instead got an exception.
|
|
72
|
+
*
|
|
73
|
+
* Dropping the trailer also makes this agree with the seven hand-rolled emit
|
|
74
|
+
* sites elsewhere in the CLI, none of which ever wrote one.
|
|
75
|
+
*
|
|
76
|
+
* @param data - Data to serialize as YAML
|
|
77
|
+
*/
|
|
78
|
+
export declare function writeYamlOutput(data: unknown): void;
|
|
15
79
|
/**
|
|
16
|
-
* Write test-format
|
|
17
|
-
*
|
|
80
|
+
* Write a test-format finding to stderr.
|
|
81
|
+
*
|
|
82
|
+
* Format: `file:line:column: severity: message` — the GCC/ESLint-compact
|
|
83
|
+
* convention, which every editor and CI log scraper already parses.
|
|
84
|
+
*
|
|
85
|
+
* The severity is not decoration. Only `error` findings fail the run, so a
|
|
86
|
+
* reader who cannot see the severity cannot tell which lines of a long report
|
|
87
|
+
* they have to act on. Omitting it made an info-severity note byte-identical in
|
|
88
|
+
* shape to a build-breaking error.
|
|
18
89
|
*/
|
|
19
|
-
export declare function writeTestFormatError(file: string, line: number, column: number, message: string): void;
|
|
90
|
+
export declare function writeTestFormatError(file: string, line: number, column: number, severity: string, message: string): void;
|
|
20
91
|
//# sourceMappingURL=output.d.ts.map
|
|
@@ -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,39 +2,154 @@
|
|
|
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';
|
|
6
7
|
/**
|
|
7
|
-
* Write
|
|
8
|
-
*
|
|
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.
|
|
9
26
|
*/
|
|
10
|
-
export function
|
|
11
|
-
|
|
12
|
-
process.stdout.write(yaml.stringify(data, {
|
|
13
|
-
indent: 2,
|
|
14
|
-
lineWidth: 120,
|
|
15
|
-
aliasDuplicateObjects: false,
|
|
16
|
-
}));
|
|
17
|
-
process.stdout.write('---\n');
|
|
27
|
+
export function writeStdoutSync(content) {
|
|
28
|
+
writeAllSync((buffer, offset, length) => writeSync(1, buffer, offset, length), Buffer.from(content, 'utf8'));
|
|
18
29
|
}
|
|
19
30
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
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.
|
|
22
39
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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;
|
|
27
95
|
}
|
|
28
|
-
|
|
29
|
-
|
|
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);
|
|
30
107
|
}
|
|
31
|
-
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Write a single YAML document to stdout, opened with `---`.
|
|
112
|
+
*
|
|
113
|
+
* There is deliberately NO trailing marker. `---` OPENS a document in YAML; the
|
|
114
|
+
* end-of-document marker is `...`. Emitting `---` at the end therefore opened a
|
|
115
|
+
* second, empty document, so every command's stdout was a two-document stream and
|
|
116
|
+
* a plain `YAML.parse()` threw `Source contains multiple documents` — on output
|
|
117
|
+
* this CLI documents as "YAML summary → stdout (for programmatic parsing)".
|
|
118
|
+
*
|
|
119
|
+
* The repo's own test helper had already been written around it: `executeCli…`
|
|
120
|
+
* calls `parseAllDocuments(...)` and takes `docs[0]`, with a comment saying "to
|
|
121
|
+
* handle document markers". That workaround is what kept the defect invisible —
|
|
122
|
+
* every consumer that did the obvious thing instead got an exception.
|
|
123
|
+
*
|
|
124
|
+
* Dropping the trailer also makes this agree with the seven hand-rolled emit
|
|
125
|
+
* sites elsewhere in the CLI, none of which ever wrote one.
|
|
126
|
+
*
|
|
127
|
+
* @param data - Data to serialize as YAML
|
|
128
|
+
*/
|
|
129
|
+
export function writeYamlOutput(data) {
|
|
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, {
|
|
136
|
+
indent: 2,
|
|
137
|
+
lineWidth: 120,
|
|
138
|
+
aliasDuplicateObjects: false,
|
|
139
|
+
})}`);
|
|
32
140
|
}
|
|
33
141
|
/**
|
|
34
|
-
* Write test-format
|
|
35
|
-
*
|
|
142
|
+
* Write a test-format finding to stderr.
|
|
143
|
+
*
|
|
144
|
+
* Format: `file:line:column: severity: message` — the GCC/ESLint-compact
|
|
145
|
+
* convention, which every editor and CI log scraper already parses.
|
|
146
|
+
*
|
|
147
|
+
* The severity is not decoration. Only `error` findings fail the run, so a
|
|
148
|
+
* reader who cannot see the severity cannot tell which lines of a long report
|
|
149
|
+
* they have to act on. Omitting it made an info-severity note byte-identical in
|
|
150
|
+
* shape to a build-breaking error.
|
|
36
151
|
*/
|
|
37
|
-
export function writeTestFormatError(file, line, column, message) {
|
|
38
|
-
process.stderr.write(`${file}:${line}:${column}: ${message}\n`);
|
|
152
|
+
export function writeTestFormatError(file, line, column, severity, message) {
|
|
153
|
+
process.stderr.write(`${file}:${line}:${column}: ${severity}: ${message}\n`);
|
|
39
154
|
}
|
|
40
155
|
//# sourceMappingURL=output.js.map
|
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,MA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
*
|
|
4
|
+
* Root discovery belongs at the CLI boundary, not inside libraries. Each command
|
|
5
|
+
* picks exactly one of these to fulfill its declared policy:
|
|
6
6
|
*
|
|
7
7
|
* - `required` → {@link requireProjectRoot} — fails fast with a clear message.
|
|
8
8
|
* - `loud-cwd` → {@link projectRootOrLoudCwd} — falls back to cwd with a stderr warning.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI-boundary policy helpers for projectRoot resolution.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Root discovery belongs at the CLI boundary, not inside libraries. Each command
|
|
5
|
+
* picks exactly one of these to fulfill its declared policy:
|
|
6
6
|
*
|
|
7
7
|
* - `required` → {@link requireProjectRoot} — fails fast with a clear message.
|
|
8
8
|
* - `loud-cwd` → {@link projectRootOrLoudCwd} — falls back to cwd with a stderr warning.
|
|
@@ -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"}
|