@remylagerweij/vue-doctor 2.0.4 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/baseline-BgcqUbRB.js +70 -0
- package/dist/{baseline-t03hOZec.js → baseline-zPvaJyGF.js} +1 -1
- package/dist/cli.js +192 -23
- package/dist/diagnose-9mGhh_uH.js +2 -0
- package/dist/{diagnose-C4vCT7pO.js → diagnose-B3lL2Qo2.js} +1193 -78
- package/dist/{discover-project-JCgCRT9u.js → discover-project-B1uzc9aU.js} +116 -9
- package/dist/discover-project-Cj2k7pUX.js +2 -0
- package/dist/index.js +1842 -7361
- package/dist/{baseline-B4hYcahD.js → rule-ids-BrYqJT7o.js} +2594 -546
- package/dist/rule-options-DKLnjGap.js +8897 -0
- package/dist/rule-options-dyUSlzk0.js +44 -0
- package/dist/{rules-_h5qMfCs.js → rules-CkC009c7.js} +3 -3
- package/dist/{server-CPJOEUHq.js → server-KeUQYFzs.js} +4 -4
- package/dist/validate-rule-options-0hIH4ndj.js +23 -0
- package/dist/validate-rule-options-CntwdX24.js +24 -0
- package/dist/vue-doctor-plugin.d.ts +4 -0
- package/dist/vue-doctor-plugin.js +2511 -463
- package/package.json +8 -6
- package/dist/diagnose-DzDOUndE.js +0 -2
- package/dist/discover-project-D_BLbCCW.js +0 -2
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { r as ruleIdOf } from "./rule-ids-BrYqJT7o.js";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
// src/core/baseline.ts
|
|
5
|
+
const DEFAULT_BASELINE_FILENAME = ".vue-doctor-baseline.json";
|
|
6
|
+
const BASELINE_VERSION = 1;
|
|
7
|
+
/** Thrown for a missing or malformed baseline file. The CLI maps it to exit code 2. */
|
|
8
|
+
var BaselineError = class extends Error {
|
|
9
|
+
constructor(filePath, reason) {
|
|
10
|
+
super(`Cannot use baseline ${filePath}: ${reason}`);
|
|
11
|
+
this.name = "BaselineError";
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const ruleKey = ruleIdOf;
|
|
15
|
+
const createBaseline = (diagnostics) => ({
|
|
16
|
+
version: BASELINE_VERSION,
|
|
17
|
+
tool: "vue-doctor",
|
|
18
|
+
findings: diagnostics.filter((diagnostic) => diagnostic.fingerprint).map((diagnostic) => ({
|
|
19
|
+
fingerprint: diagnostic.fingerprint,
|
|
20
|
+
rule: ruleKey(diagnostic),
|
|
21
|
+
file: diagnostic.filePath
|
|
22
|
+
})).sort((left, right) => left.file.localeCompare(right.file) || left.rule.localeCompare(right.rule) || left.fingerprint.localeCompare(right.fingerprint))
|
|
23
|
+
});
|
|
24
|
+
const writeBaseline = (filePath, baseline) => {
|
|
25
|
+
fs.writeFileSync(filePath, `${JSON.stringify(baseline, null, 2)}\n`);
|
|
26
|
+
};
|
|
27
|
+
const isBaselineFile = (value) => {
|
|
28
|
+
if (!value || typeof value !== "object") return false;
|
|
29
|
+
const candidate = value;
|
|
30
|
+
return candidate.version === BASELINE_VERSION && Array.isArray(candidate.findings) && candidate.findings.every((entry) => typeof entry?.fingerprint === "string");
|
|
31
|
+
};
|
|
32
|
+
const readBaseline = (filePath) => {
|
|
33
|
+
let content;
|
|
34
|
+
try {
|
|
35
|
+
content = fs.readFileSync(filePath, "utf-8");
|
|
36
|
+
} catch {
|
|
37
|
+
throw new BaselineError(filePath, "the file does not exist (create it with `vue-doctor baseline`)");
|
|
38
|
+
}
|
|
39
|
+
let parsed;
|
|
40
|
+
try {
|
|
41
|
+
parsed = JSON.parse(content);
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new BaselineError(filePath, `invalid JSON (${error instanceof Error ? error.message : String(error)})`);
|
|
44
|
+
}
|
|
45
|
+
if (!isBaselineFile(parsed)) throw new BaselineError(filePath, `expected a version ${BASELINE_VERSION} baseline written by \`vue-doctor baseline\``);
|
|
46
|
+
return new Set(parsed.findings.map((entry) => entry.fingerprint));
|
|
47
|
+
};
|
|
48
|
+
/** Marks findings present in the baseline as `status: "baseline"` and every other finding as `"new"`. */
|
|
49
|
+
const applyBaseline = (diagnostics, baselineFingerprints, baselinePath, isDiffMode) => {
|
|
50
|
+
const seen = /* @__PURE__ */ new Set();
|
|
51
|
+
const marked = diagnostics.map((diagnostic) => {
|
|
52
|
+
const isKnown = diagnostic.fingerprint !== void 0 && baselineFingerprints.has(diagnostic.fingerprint);
|
|
53
|
+
if (isKnown) seen.add(diagnostic.fingerprint);
|
|
54
|
+
return {
|
|
55
|
+
...diagnostic,
|
|
56
|
+
status: isKnown ? "baseline" : "new"
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
const matched = marked.filter((diagnostic) => diagnostic.status === "baseline").length;
|
|
60
|
+
return {
|
|
61
|
+
diagnostics: marked,
|
|
62
|
+
summary: {
|
|
63
|
+
path: baselinePath,
|
|
64
|
+
matched,
|
|
65
|
+
new: marked.length - matched,
|
|
66
|
+
fixed: isDiffMode ? null : baselineFingerprints.size - seen.size
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export { readBaseline as a, createBaseline as i, DEFAULT_BASELINE_FILENAME as n, writeBaseline as o, applyBaseline as r, BaselineError as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { i as createBaseline, o as writeBaseline } from "./baseline-
|
|
2
|
+
export { i as createBaseline, o as writeBaseline } from "./baseline-BgcqUbRB.js";
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as logger, c as getToolVersions, d as loadConfig, i as configureLogger, l as mapWithConcurrency, n as diagnose, o as output, r as createKnipSession, s as highlighter, t as NoVueDependencyError, u as createPrivateTempDirectory } from "./diagnose-
|
|
3
|
-
import {
|
|
2
|
+
import { a as logger, c as getToolVersions, d as loadConfig, i as configureLogger, l as mapWithConcurrency, n as diagnose, o as output, r as createKnipSession, s as highlighter, t as NoVueDependencyError, u as createPrivateTempDirectory } from "./diagnose-B3lL2Qo2.js";
|
|
3
|
+
import { f as getCanonicalRuleId, m as getRuleMeta, o as PLUGIN_NAME, r as ruleIdOf, s as RULE_REGISTRY } from "./rule-ids-BrYqJT7o.js";
|
|
4
|
+
import { i as createBaseline, n as DEFAULT_BASELINE_FILENAME, o as writeBaseline } from "./baseline-BgcqUbRB.js";
|
|
4
5
|
import { n as isMonorepoRoot } from "./find-monorepo-root-VE6uVqvK.js";
|
|
5
|
-
import {
|
|
6
|
-
import { a as filterSourceFiles, c as EXIT_CODES, d as evaluateGate, l as FAIL_ON_VALUES, n as registerExplainCommand, o as getDiffInfo, r as registerRulesCommand, s as docsUrl, u as GATE_SCOPE_VALUES } from "./rules-
|
|
6
|
+
import { a as getRootPackage, b as VERSION$1, g as MILLISECONDS_PER_SECOND, i as formatFrameworkName, n as discoverProject, r as discoverVueSubprojects, u as listWorkspacePackages } from "./discover-project-B1uzc9aU.js";
|
|
7
|
+
import { a as filterSourceFiles, c as EXIT_CODES, d as evaluateGate, l as FAIL_ON_VALUES, n as registerExplainCommand, o as getDiffInfo, r as registerRulesCommand, s as docsUrl, u as GATE_SCOPE_VALUES } from "./rules-CkC009c7.js";
|
|
7
8
|
import { n as REPORT_SCHEMA_URL, t as REPORT_FORMAT } from "./constants-Cav5tPU4.js";
|
|
8
9
|
import fs from "node:fs";
|
|
9
10
|
import path from "node:path";
|
|
@@ -159,6 +160,11 @@ const maskSecrets = (text) => {
|
|
|
159
160
|
masked = masked.replace(GENERIC_TOKEN_PATTERN, (candidate) => looksRandom(candidate) ? MASK : candidate);
|
|
160
161
|
return masked;
|
|
161
162
|
};
|
|
163
|
+
// src/report/agent-prompt.ts
|
|
164
|
+
const sanitizeUntrustedPromptText = (value) => {
|
|
165
|
+
const sanitized = (value ?? "").replace(/[\r\n\t]+/g, " ").replace(/[`*_#[\]{}<>|]/g, " ").replace(/\b(system|assistant|user)\s*:/gi, "$1;");
|
|
166
|
+
return maskSecrets(sanitized);
|
|
167
|
+
};
|
|
162
168
|
const PACKAGE_NAME = "@remylagerweij/vue-doctor";
|
|
163
169
|
const CONSTRAINTS = "Change only what is needed to fix it, keep the behaviour otherwise identical, do not suppress or disable the rule, do not add dependencies, and update a test only if one already covers this code.";
|
|
164
170
|
/** Dead-code findings come from knip, not from a registered rule, so they carry their own title and guidance. */
|
|
@@ -270,6 +276,52 @@ const buildGroupPrompt = (findings, options = {}) => {
|
|
|
270
276
|
lines.push(`Guidance: ${maskSecrets(guidance)}`, `Docs: ${first.docsUrl}`, `Constraints: ${CONSTRAINTS}`, `Verify: run \`${verifyCommand(first.ruleId, options.projectRoot ?? ".")}\` and confirm ${first.ruleId} is no longer reported.`);
|
|
271
277
|
return lines.join("\n");
|
|
272
278
|
};
|
|
279
|
+
/**
|
|
280
|
+
* A single prompt for multiple Vue Doctor findings across one or several rules: groups them
|
|
281
|
+
* by rule, lists locations, guidance, constraints and a verification command.
|
|
282
|
+
*/
|
|
283
|
+
const buildCombinedAgentPrompt = (findings, options = {}) => {
|
|
284
|
+
if (findings.length === 0) return "";
|
|
285
|
+
if (findings.length === 1) return buildAgentPrompt(findings[0], options);
|
|
286
|
+
const byRule = /* @__PURE__ */ new Map();
|
|
287
|
+
for (const finding of findings) {
|
|
288
|
+
const list = byRule.get(finding.ruleId) ?? [];
|
|
289
|
+
list.push(finding);
|
|
290
|
+
byRule.set(finding.ruleId, list);
|
|
291
|
+
}
|
|
292
|
+
if (byRule.size === 1) return buildGroupPrompt(findings, options);
|
|
293
|
+
const sortedRules = [...byRule.entries()].sort(([leftId, leftList], [rightId, rightList]) => {
|
|
294
|
+
const leftHasError = leftList.some((f) => f.severity === "error");
|
|
295
|
+
const rightHasError = rightList.some((f) => f.severity === "error");
|
|
296
|
+
return Number(rightHasError) - Number(leftHasError) || rightList.length - leftList.length || compareText$1(leftId, rightId);
|
|
297
|
+
});
|
|
298
|
+
const lines = [
|
|
299
|
+
"You are fixing Vue Doctor findings in this repository.",
|
|
300
|
+
`Remaining findings: ${findings.length}`,
|
|
301
|
+
""
|
|
302
|
+
];
|
|
303
|
+
const maxLocations = Math.max(1, options.maxLocations ?? 10);
|
|
304
|
+
for (const [ruleId, ruleFindings] of sortedRules) {
|
|
305
|
+
const [first] = ruleFindings;
|
|
306
|
+
const meta = findRuleMeta(ruleId);
|
|
307
|
+
const { title, guidance } = describeRule(ruleId, meta, first);
|
|
308
|
+
const sorted = [...ruleFindings].sort(compareLocations);
|
|
309
|
+
const shown = sorted.slice(0, maxLocations);
|
|
310
|
+
const hidden = sorted.length - shown.length;
|
|
311
|
+
const sharedMessage = sorted.every((f) => f.message === first.message);
|
|
312
|
+
lines.push(ruleLine(ruleId, title, first, meta));
|
|
313
|
+
if (sharedMessage) lines.push(`Problem: ${sanitizeUntrustedPromptText(first.message)}`);
|
|
314
|
+
lines.push("Locations:");
|
|
315
|
+
for (const finding of shown) lines.push(`- ${formatLocation(finding)}${sharedMessage ? "" : `: ${sanitizeUntrustedPromptText(finding.message)}`}`);
|
|
316
|
+
if (hidden > 0) lines.push(`- and ${hidden} more`);
|
|
317
|
+
lines.push(`Guidance: ${maskSecrets(guidance)}`);
|
|
318
|
+
if (first.docsUrl) lines.push(`Docs: ${first.docsUrl}`);
|
|
319
|
+
lines.push("");
|
|
320
|
+
}
|
|
321
|
+
const projectRoot = options.projectRoot ?? ".";
|
|
322
|
+
lines.push(`Constraints: ${CONSTRAINTS}`, `Verify: run \`npx ${PACKAGE_NAME} ${quoteArgument(projectRoot)} --diff --format json\` and confirm the findings are no longer reported.`);
|
|
323
|
+
return lines.join("\n");
|
|
324
|
+
};
|
|
273
325
|
// src/report/build-report.ts
|
|
274
326
|
/** Context lines shown before and after the finding in `codeFrame`. */
|
|
275
327
|
const CODE_FRAME_CONTEXT_LINES = 2;
|
|
@@ -1814,8 +1866,8 @@ const createBatchProgressReporter = async (options) => {
|
|
|
1814
1866
|
// src/scan.ts
|
|
1815
1867
|
const printProjectDetection = (projectInfo, isDiffMode, includePaths) => {
|
|
1816
1868
|
const lines = [];
|
|
1817
|
-
const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.0
|
|
1818
|
-
lines.push(createFramedLine(`Vue Doctor v2.0
|
|
1869
|
+
const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.1.0")}`;
|
|
1870
|
+
lines.push(createFramedLine(`Vue Doctor v2.1.0`, title));
|
|
1819
1871
|
const vueVersionDisplay = projectInfo.vueVersion ? `Vue ${projectInfo.vueVersion}` : "Vue";
|
|
1820
1872
|
const frameworkDisplay = formatFrameworkName(projectInfo.framework);
|
|
1821
1873
|
const projectLine = `${projectInfo.projectName} · ${frameworkDisplay} · ${vueVersionDisplay}`;
|
|
@@ -2160,6 +2212,31 @@ var GitHubClient = class {
|
|
|
2160
2212
|
};
|
|
2161
2213
|
// src/ci/feedback.ts
|
|
2162
2214
|
const SCOPE_MARKER_PREFIX = "<!-- vue-doctor:scope:";
|
|
2215
|
+
const findingIdentity = (f) => f.fingerprint ? f.fingerprint : `${f.file}:${f.line}:${f.ruleId}`;
|
|
2216
|
+
const extractTrackedFindings = (body) => {
|
|
2217
|
+
const match = body.match(/<!-- vue-doctor:tracked:([a-zA-Z0-9+/=]+) -->/);
|
|
2218
|
+
if (match) try {
|
|
2219
|
+
const json = Buffer.from(match[1], "base64").toString("utf8");
|
|
2220
|
+
return JSON.parse(json);
|
|
2221
|
+
} catch {}
|
|
2222
|
+
const findings = [];
|
|
2223
|
+
const fixedRegex = /- ~~(?:\S+\s+)?\*\*([A-Z]+)\*\*\s+`([^`]+)`:\s*(.*?)\s*\(`([^`]+)`\)~~/g;
|
|
2224
|
+
let m;
|
|
2225
|
+
while ((m = fixedRegex.exec(body)) !== null) {
|
|
2226
|
+
const [, sev, loc, msg, rule] = m;
|
|
2227
|
+
const [file, lineStr] = loc.split(":");
|
|
2228
|
+
findings.push({
|
|
2229
|
+
id: `${file}:${lineStr || "1"}:${rule}`,
|
|
2230
|
+
ruleId: rule,
|
|
2231
|
+
file,
|
|
2232
|
+
line: parseInt(lineStr || "1", 10),
|
|
2233
|
+
message: msg,
|
|
2234
|
+
severity: sev.toLowerCase() === "error" ? "error" : "warning",
|
|
2235
|
+
fixed: true
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
return findings;
|
|
2239
|
+
};
|
|
2163
2240
|
const normalizeScope = (prefix = "") => prefix.split("/").filter((part) => part !== "" && part !== ".").join("/");
|
|
2164
2241
|
const scopeMarker = (scope) => `${SCOPE_MARKER_PREFIX}${sanitizeMarkerScope(scope)} -->`;
|
|
2165
2242
|
/** The scanned directory a review comment belongs to; comments without a scope marker belong to the repository root. */
|
|
@@ -2231,26 +2308,118 @@ const groupFindings = (findings, grouping, agentPrompt, scope = "") => {
|
|
|
2231
2308
|
return commentGroups;
|
|
2232
2309
|
};
|
|
2233
2310
|
/**
|
|
2234
|
-
*
|
|
2311
|
+
* Formats a single unified PR comment containing the score summary, all active findings
|
|
2312
|
+
* grouped together, fixed earlier findings (crossed through), and a single combined AI agent prompt.
|
|
2235
2313
|
*/
|
|
2236
|
-
const
|
|
2237
|
-
|
|
2238
|
-
const scope = normalizeScope(
|
|
2314
|
+
const renderStickyComment = (report, options, previousTracked = []) => {
|
|
2315
|
+
const prefix = options.sourceRootPrefix ?? "";
|
|
2316
|
+
const scope = normalizeScope(prefix);
|
|
2239
2317
|
const summaryMarkdown = renderMarkdownSummary(report, {
|
|
2240
2318
|
stickyMarker: true,
|
|
2241
2319
|
collapseFindings: true,
|
|
2242
2320
|
scope
|
|
2243
|
-
});
|
|
2321
|
+
}).trimEnd();
|
|
2322
|
+
const currentFindings = report.projects.flatMap((p) => p.findings.map((finding) => ({
|
|
2323
|
+
...finding,
|
|
2324
|
+
file: toRepoPath(prefix, p.root, finding.file)
|
|
2325
|
+
})));
|
|
2326
|
+
const currentKeySet = new Set(currentFindings.map(findingIdentity));
|
|
2327
|
+
const activeFindings = currentFindings;
|
|
2328
|
+
const fixedFindings = [];
|
|
2329
|
+
const seenFixedIds = /* @__PURE__ */ new Set();
|
|
2330
|
+
for (const prev of previousTracked) if (!currentKeySet.has(prev.id) && !seenFixedIds.has(prev.id)) {
|
|
2331
|
+
fixedFindings.push({
|
|
2332
|
+
...prev,
|
|
2333
|
+
fixed: true
|
|
2334
|
+
});
|
|
2335
|
+
seenFixedIds.add(prev.id);
|
|
2336
|
+
}
|
|
2337
|
+
fixedFindings.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.ruleId.localeCompare(b.ruleId));
|
|
2338
|
+
const sections = [summaryMarkdown];
|
|
2339
|
+
if (activeFindings.length > 0) {
|
|
2340
|
+
sections.push("");
|
|
2341
|
+
const heading = fixedFindings.length > 0 ? `### 📋 Remaining issues (${activeFindings.length})` : `### 📋 Issues (${activeFindings.length})`;
|
|
2342
|
+
sections.push(heading, "");
|
|
2343
|
+
const groups = groupFindings(activeFindings, options.grouping ?? "rule-per-file", false, "");
|
|
2344
|
+
const maxComments = options.maxComments ?? 30;
|
|
2345
|
+
const shownGroups = groups.slice(0, maxComments);
|
|
2346
|
+
for (const group of shownGroups) {
|
|
2347
|
+
const cleaned = group.body.replace(/^<!-- vue-doctor:finding:[^\n]+\n/m, "").replace(/^### 🩺/m, "#### 🩺").trimEnd();
|
|
2348
|
+
sections.push(cleaned);
|
|
2349
|
+
sections.push("");
|
|
2350
|
+
}
|
|
2351
|
+
if (groups.length > shownGroups.length) {
|
|
2352
|
+
const omitted = groups.length - shownGroups.length;
|
|
2353
|
+
sections.push(`_… and ${omitted} more issue groups not shown._`, "");
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
if (fixedFindings.length > 0) {
|
|
2357
|
+
sections.push("");
|
|
2358
|
+
sections.push(`### ✅ Fixed earlier findings (${fixedFindings.length})`, "");
|
|
2359
|
+
const maxComments = options.maxComments ?? 30;
|
|
2360
|
+
const shownFixed = fixedFindings.slice(0, maxComments);
|
|
2361
|
+
for (const fixed of shownFixed) {
|
|
2362
|
+
const icon = fixed.severity === "error" ? "🔴" : "⚠️";
|
|
2363
|
+
const loc = fixed.line > 0 ? `${fixed.file}:${fixed.line}` : fixed.file;
|
|
2364
|
+
sections.push(`- ~~${icon} **${fixed.severity.toUpperCase()}** ${markdownCode(loc)}: ${escapeMarkdown(fixed.message)} (${markdownCode(fixed.ruleId)})~~`);
|
|
2365
|
+
}
|
|
2366
|
+
if (fixedFindings.length > shownFixed.length) {
|
|
2367
|
+
const omitted = fixedFindings.length - shownFixed.length;
|
|
2368
|
+
sections.push(`_… and ${omitted} more fixed findings not shown._`);
|
|
2369
|
+
}
|
|
2370
|
+
sections.push("");
|
|
2371
|
+
}
|
|
2372
|
+
if (options.agentPrompt !== false && activeFindings.length > 0) {
|
|
2373
|
+
const promptText = buildCombinedAgentPrompt(activeFindings, { projectRoot: options.sourceRootPrefix || "." });
|
|
2374
|
+
if (promptText) sections.push("", "<details>", "<summary>🤖 Fix remaining issues with an AI agent</summary>", "", markdownFence(promptText, "text"), "", "</details>", "");
|
|
2375
|
+
}
|
|
2376
|
+
const newTracked = [...activeFindings.map((f) => ({
|
|
2377
|
+
id: findingIdentity(f),
|
|
2378
|
+
ruleId: f.ruleId,
|
|
2379
|
+
file: f.file,
|
|
2380
|
+
line: f.line,
|
|
2381
|
+
message: f.message,
|
|
2382
|
+
severity: f.severity,
|
|
2383
|
+
help: f.help,
|
|
2384
|
+
docsUrl: f.docsUrl,
|
|
2385
|
+
category: f.category,
|
|
2386
|
+
codeFrame: f.codeFrame,
|
|
2387
|
+
fixed: false
|
|
2388
|
+
})), ...fixedFindings.map((f) => ({
|
|
2389
|
+
id: f.id,
|
|
2390
|
+
ruleId: f.ruleId,
|
|
2391
|
+
file: f.file,
|
|
2392
|
+
line: f.line,
|
|
2393
|
+
message: f.message,
|
|
2394
|
+
severity: f.severity,
|
|
2395
|
+
help: f.help,
|
|
2396
|
+
docsUrl: f.docsUrl,
|
|
2397
|
+
category: f.category,
|
|
2398
|
+
codeFrame: f.codeFrame,
|
|
2399
|
+
fixed: true
|
|
2400
|
+
}))];
|
|
2401
|
+
const trackedBase64 = Buffer.from(JSON.stringify(newTracked)).toString("base64");
|
|
2402
|
+
sections.push(`<!-- vue-doctor:tracked:${trackedBase64} -->`);
|
|
2403
|
+
return `${sections.join("\n").replace(/\n+$/, "")}\n`;
|
|
2404
|
+
};
|
|
2405
|
+
/**
|
|
2406
|
+
* Handles the single sticky PR comment containing summary, grouped issues, fixed earlier findings, and agent prompt.
|
|
2407
|
+
*/
|
|
2408
|
+
const postStickySummary = async (client, options, report) => {
|
|
2409
|
+
if (!options.pullNumber) return;
|
|
2410
|
+
const scope = normalizeScope(options.sourceRootPrefix);
|
|
2244
2411
|
const marker = summaryMarker(scope);
|
|
2245
2412
|
const existing = (await client.listIssueComments(options.owner, options.repo, options.pullNumber)).find((c) => c.body?.includes(marker));
|
|
2413
|
+
const previousTracked = existing?.body ? extractTrackedFindings(existing.body) : [];
|
|
2414
|
+
const commentMarkdown = renderStickyComment(report, options, previousTracked);
|
|
2246
2415
|
if (existing) {
|
|
2247
|
-
if (existing.body !==
|
|
2416
|
+
if (existing.body !== commentMarkdown) {
|
|
2248
2417
|
logger.log(`Updating sticky summary comment #${existing.id}...`);
|
|
2249
|
-
await client.updateIssueComment(options.owner, options.repo, existing.id,
|
|
2418
|
+
await client.updateIssueComment(options.owner, options.repo, existing.id, commentMarkdown);
|
|
2250
2419
|
} else logger.log(`Sticky summary comment #${existing.id} is up to date.`);
|
|
2251
2420
|
} else {
|
|
2252
2421
|
logger.log("Posting new sticky summary comment...");
|
|
2253
|
-
await client.createIssueComment(options.owner, options.repo, options.pullNumber,
|
|
2422
|
+
await client.createIssueComment(options.owner, options.repo, options.pullNumber, commentMarkdown);
|
|
2254
2423
|
}
|
|
2255
2424
|
};
|
|
2256
2425
|
/**
|
|
@@ -2626,8 +2795,8 @@ const registerCiCommand = (program) => {
|
|
|
2626
2795
|
baseScore: deltaInfo.baseScore ?? void 0,
|
|
2627
2796
|
sourceRootPrefix
|
|
2628
2797
|
};
|
|
2629
|
-
if (feedbackModes.includes("summary") && feedbackOpts.pullNumber) await postStickySummary(client, feedbackOpts, report);
|
|
2630
|
-
if (feedbackModes.includes("
|
|
2798
|
+
if ((feedbackModes.includes("summary") || feedbackModes.includes("findings") || feedbackModes.includes("comment")) && feedbackOpts.pullNumber) await postStickySummary(client, feedbackOpts, report);
|
|
2799
|
+
if (feedbackModes.includes("review-comments") && feedbackOpts.pullNumber) await postReviewComments(client, feedbackOpts, report);
|
|
2631
2800
|
await postCommitStatus(client, feedbackOpts, report, gateOutcome.exitCode === EXIT_CODES.ok);
|
|
2632
2801
|
}
|
|
2633
2802
|
process.exitCode = gateOutcome.exitCode;
|
|
@@ -2665,8 +2834,8 @@ const registerCiCommand = (program) => {
|
|
|
2665
2834
|
pullNumber: prNumber && !Number.isNaN(prNumber) ? prNumber : void 0,
|
|
2666
2835
|
commitSha
|
|
2667
2836
|
};
|
|
2668
|
-
if (feedbackModes.includes("summary") && feedbackOpts.pullNumber) await postStickySummary(client, feedbackOpts, report);
|
|
2669
|
-
if (feedbackModes.includes("
|
|
2837
|
+
if ((feedbackModes.includes("summary") || feedbackModes.includes("findings") || feedbackModes.includes("comment")) && feedbackOpts.pullNumber) await postStickySummary(client, feedbackOpts, report);
|
|
2838
|
+
if (feedbackModes.includes("review-comments") && feedbackOpts.pullNumber) await postReviewComments(client, feedbackOpts, report);
|
|
2670
2839
|
await postCommitStatus(client, feedbackOpts, report, report.summary.errors === 0);
|
|
2671
2840
|
} catch (error) {
|
|
2672
2841
|
handleError(error);
|
|
@@ -2956,7 +3125,7 @@ const registerInitCommand = (program) => {
|
|
|
2956
3125
|
const projectDir = path.resolve(directoryArg);
|
|
2957
3126
|
const isInteractive = Boolean(process.stdin.isTTY) && !options.yes;
|
|
2958
3127
|
const clack = isInteractive ? await import("@clack/prompts") : null;
|
|
2959
|
-
const { discoverProject, formatFrameworkName } = await import("./discover-project-
|
|
3128
|
+
const { discoverProject, formatFrameworkName } = await import("./discover-project-Cj2k7pUX.js");
|
|
2960
3129
|
const { isMonorepoRoot } = await import("./find-monorepo-root-Cqb6bdkf.js");
|
|
2961
3130
|
const projectInfo = discoverProject(projectDir);
|
|
2962
3131
|
if (isInteractive && clack) {
|
|
@@ -3143,8 +3312,8 @@ const registerInitCommand = (program) => {
|
|
|
3143
3312
|
if (spinner) spinner.start("Scanning project to record baseline snapshot...");
|
|
3144
3313
|
else logger.log("Scanning project to record baseline snapshot...");
|
|
3145
3314
|
try {
|
|
3146
|
-
const { diagnose } = await import("./diagnose-
|
|
3147
|
-
const { createBaseline, writeBaseline } = await import("./baseline-
|
|
3315
|
+
const { diagnose } = await import("./diagnose-9mGhh_uH.js");
|
|
3316
|
+
const { createBaseline, writeBaseline } = await import("./baseline-zPvaJyGF.js");
|
|
3148
3317
|
const baselineData = createBaseline((await diagnose(projectDir, { baseline: null })).diagnostics);
|
|
3149
3318
|
writeBaseline(path.join(projectDir, baselineFileName), baselineData);
|
|
3150
3319
|
const countMsg = `${baselineData.findings.length} finding${baselineData.findings.length === 1 ? "" : "s"}`;
|
|
@@ -3162,12 +3331,12 @@ const registerInitCommand = (program) => {
|
|
|
3162
3331
|
// src/commands/mcp.ts
|
|
3163
3332
|
const registerMcpCommand = (program) => {
|
|
3164
3333
|
program.command("mcp").description("Start Model Context Protocol (MCP) server over stdio for AI agents").action(async () => {
|
|
3165
|
-
const { McpServer } = await import("./server-
|
|
3334
|
+
const { McpServer } = await import("./server-KeUQYFzs.js");
|
|
3166
3335
|
new McpServer().startStdio();
|
|
3167
3336
|
});
|
|
3168
3337
|
};
|
|
3169
3338
|
// src/program.ts
|
|
3170
|
-
const VERSION = "2.0
|
|
3339
|
+
const VERSION = "2.1.0";
|
|
3171
3340
|
const parseScore = (value) => {
|
|
3172
3341
|
const score = Number(value);
|
|
3173
3342
|
if (!Number.isInteger(score) || score < 0 || score > 100) throw new InvalidArgumentError("Expected an integer between 0 and 100.");
|