@aipanel/dsh-plugin 1.2.25 → 1.2.27
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/index.js +74 -82
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -288,7 +288,7 @@ var PerformanceTimer = class {
|
|
|
288
288
|
// ../../core/es/node/diagnostics.mjs
|
|
289
289
|
import fs from "node:fs";
|
|
290
290
|
import path from "node:path";
|
|
291
|
-
import {
|
|
291
|
+
import { execa } from "execa";
|
|
292
292
|
import { createRequire } from "node:module";
|
|
293
293
|
var log2 = createNodeLogger("Diagnostics");
|
|
294
294
|
var JS_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -475,41 +475,35 @@ function parseOxlintOutput(stdout, cwd) {
|
|
|
475
475
|
async function runOxlintFiles(pattern, cwd, warnLimit) {
|
|
476
476
|
const bin = resolveOxlintBin(cwd);
|
|
477
477
|
if (!bin) return {};
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
engines: ["oxlint"]
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
);
|
|
512
|
-
});
|
|
478
|
+
const result = await execa(
|
|
479
|
+
"node",
|
|
480
|
+
[bin, "--format=json", "--ignore-pattern", "node_modules", pattern],
|
|
481
|
+
{ cwd, timeout: 6e4, maxBuffer: 50 * 1024 * 1024, reject: false }
|
|
482
|
+
);
|
|
483
|
+
if (result.timedOut || result.isTerminated || result.isMaxBuffer) {
|
|
484
|
+
log2.warn("oxlint timed out", { pattern });
|
|
485
|
+
return {
|
|
486
|
+
text: "[oxlint] \u8FD0\u884C\u5931\u8D25\uFF1A\u68C0\u67E5\u8D85\u65F6\uFF0C\u8BF7\u5C1D\u8BD5\u7F29\u5C0F\u68C0\u67E5\u8303\u56F4\u3002",
|
|
487
|
+
diagnostics: [],
|
|
488
|
+
engines: ["oxlint"]
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
try {
|
|
492
|
+
const messages = parseOxlintOutput(result.stdout, cwd);
|
|
493
|
+
log2.debug("oxlint lint", {
|
|
494
|
+
pattern,
|
|
495
|
+
messageCount: messages.length,
|
|
496
|
+
stderr: result.stderr || void 0
|
|
497
|
+
});
|
|
498
|
+
return formatLintMessages(messages, { label: "oxlint", source: "oxlint" }, warnLimit);
|
|
499
|
+
} catch (e) {
|
|
500
|
+
log2.warn("oxlint failed", { pattern, error: e.message });
|
|
501
|
+
return {
|
|
502
|
+
text: `[oxlint] \u8FD0\u884C\u5931\u8D25\uFF1A${e.message}`,
|
|
503
|
+
diagnostics: [],
|
|
504
|
+
engines: ["oxlint"]
|
|
505
|
+
};
|
|
506
|
+
}
|
|
513
507
|
}
|
|
514
508
|
var _vueTscBin;
|
|
515
509
|
function resolveVueTscBin() {
|
|
@@ -650,45 +644,43 @@ async function runTypeCheck(filePath, cwd) {
|
|
|
650
644
|
}
|
|
651
645
|
const timeout = filePath ? 6e4 : 12e4;
|
|
652
646
|
const maxBuffer = filePath ? 10 * 1024 * 1024 : 50 * 1024 * 1024;
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (keep) filtered.push(line);
|
|
679
|
-
}
|
|
680
|
-
rawOutput = filtered.join("\n");
|
|
681
|
-
}
|
|
682
|
-
log2.debug("type-check finished", {
|
|
683
|
-
engine: engine.source,
|
|
684
|
-
filePath: filePath || "(all)",
|
|
685
|
-
exitCode,
|
|
686
|
-
outputLength: rawOutput.length
|
|
687
|
-
});
|
|
688
|
-
resolve({ rawOutput, exitCode, diagnostics, source: engine.source });
|
|
647
|
+
const result = await execa("node", [engine.bin, "--build", "--noEmit", "--pretty", "false"], {
|
|
648
|
+
cwd: projectDir,
|
|
649
|
+
timeout,
|
|
650
|
+
maxBuffer,
|
|
651
|
+
reject: false
|
|
652
|
+
});
|
|
653
|
+
let rawOutput = result.stdout + result.stderr;
|
|
654
|
+
const killed = result.timedOut || result.isTerminated || result.isMaxBuffer;
|
|
655
|
+
const exitCode = typeof result.exitCode === "number" ? result.exitCode : killed ? 1 : 0;
|
|
656
|
+
if (killed && !rawOutput) {
|
|
657
|
+
rawOutput = `${engine.source} \u68C0\u67E5\u8D85\u65F6\uFF0C\u8BF7\u5C1D\u8BD5\u7F29\u5C0F\u68C0\u67E5\u8303\u56F4\u6216\u4F18\u5316\u9879\u76EE\u914D\u7F6E\u3002`;
|
|
658
|
+
}
|
|
659
|
+
const diagnostics = parseTscDiags(rawOutput, filePath, projectDir, engine.source);
|
|
660
|
+
if (filePath) {
|
|
661
|
+
const resolved = path.resolve(filePath);
|
|
662
|
+
const errorLinePat = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:/;
|
|
663
|
+
const lines = rawOutput.split("\n");
|
|
664
|
+
const filtered = [];
|
|
665
|
+
let keep = false;
|
|
666
|
+
for (const line of lines) {
|
|
667
|
+
const m = errorLinePat.exec(line);
|
|
668
|
+
if (m) {
|
|
669
|
+
keep = path.resolve(projectDir, m[1]) === resolved;
|
|
670
|
+
} else if (!/^\s/.test(line)) {
|
|
671
|
+
keep = false;
|
|
689
672
|
}
|
|
690
|
-
|
|
673
|
+
if (keep) filtered.push(line);
|
|
674
|
+
}
|
|
675
|
+
rawOutput = filtered.join("\n");
|
|
676
|
+
}
|
|
677
|
+
log2.debug("type-check finished", {
|
|
678
|
+
engine: engine.source,
|
|
679
|
+
filePath: filePath || "(all)",
|
|
680
|
+
exitCode,
|
|
681
|
+
outputLength: rawOutput.length
|
|
691
682
|
});
|
|
683
|
+
return { rawOutput, exitCode, diagnostics, source: engine.source };
|
|
692
684
|
}
|
|
693
685
|
async function runAllChecks(pattern, cwd) {
|
|
694
686
|
log2.debug("runAllChecks", { pattern, cwd });
|
|
@@ -987,11 +979,11 @@ function buildPluginMessage(text) {
|
|
|
987
979
|
source: { kind: "plugin", plugin: name }
|
|
988
980
|
};
|
|
989
981
|
}
|
|
990
|
-
function registerPtcEdit(targets, rootKey,
|
|
991
|
-
if (!MUTATING_TOOLS.has(
|
|
982
|
+
function registerPtcEdit(targets, rootKey, exec, result, decision, cwd) {
|
|
983
|
+
if (!MUTATING_TOOLS.has(exec.name)) return;
|
|
992
984
|
if (result.isError) return;
|
|
993
985
|
if (decision.kind !== "accept") return;
|
|
994
|
-
const rawArgs =
|
|
986
|
+
const rawArgs = exec.arguments;
|
|
995
987
|
const filePath = typeof rawArgs?.file_path === "string" ? rawArgs.file_path : rawArgs?.filePath;
|
|
996
988
|
if (typeof filePath !== "string" || !filePath) return;
|
|
997
989
|
if (!isJsFile(filePath)) return;
|
|
@@ -1200,14 +1192,14 @@ function apply(ctx, config = {}) {
|
|
|
1200
1192
|
const pendingPtcEdits = /* @__PURE__ */ new Map();
|
|
1201
1193
|
ctx.on(
|
|
1202
1194
|
"tools/post-execute",
|
|
1203
|
-
async (
|
|
1195
|
+
async (exec, result, next) => {
|
|
1204
1196
|
const decision = await next();
|
|
1205
1197
|
if (!autoDiagnose) return decision;
|
|
1206
|
-
if (
|
|
1207
|
-
registerPtcEdit(pendingPtcEdits, String(
|
|
1198
|
+
if (exec.parent !== void 0) {
|
|
1199
|
+
registerPtcEdit(pendingPtcEdits, String(exec.rootCallId), exec, result, decision, cwd);
|
|
1208
1200
|
return decision;
|
|
1209
1201
|
}
|
|
1210
|
-
const rootKey = String(
|
|
1202
|
+
const rootKey = String(exec.rootCallId);
|
|
1211
1203
|
const ptcTargets = pendingPtcEdits.get(rootKey);
|
|
1212
1204
|
if (ptcTargets !== void 0) {
|
|
1213
1205
|
pendingPtcEdits.delete(rootKey);
|
|
@@ -1222,10 +1214,10 @@ function apply(ctx, config = {}) {
|
|
|
1222
1214
|
]
|
|
1223
1215
|
};
|
|
1224
1216
|
}
|
|
1225
|
-
if (!MUTATING_TOOLS.has(
|
|
1217
|
+
if (!MUTATING_TOOLS.has(exec.name)) return decision;
|
|
1226
1218
|
if (result.isError) return decision;
|
|
1227
1219
|
if (decision.kind !== "accept") return decision;
|
|
1228
|
-
const rawArgs =
|
|
1220
|
+
const rawArgs = exec.arguments;
|
|
1229
1221
|
const filePath = typeof rawArgs?.file_path === "string" ? rawArgs.file_path : rawArgs?.filePath;
|
|
1230
1222
|
if (typeof filePath !== "string" || !filePath) return decision;
|
|
1231
1223
|
if (!isJsFile(filePath)) return decision;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aipanel/dsh-plugin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.27",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AIPanel for DeepSeek Harness (dsh):注入审查工具 run_diagnostics、编辑后自动诊断。",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
"registry": "https://registry.npmjs.org/"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"execa": "^9.6.1",
|
|
15
16
|
"vue-tsc": "^3.3.9"
|
|
16
17
|
},
|
|
17
18
|
"devDependencies": {
|
|
18
|
-
"@aipanel/core": "1.2.
|
|
19
|
+
"@aipanel/core": "1.2.27",
|
|
19
20
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
20
21
|
"@deepseek-ai/dsh-agent": "^0.1.6-alpha.2",
|
|
21
22
|
"@deepseek-ai/dsh-llm": "^0.1.6-alpha.2",
|
|
@@ -29,7 +30,7 @@
|
|
|
29
30
|
"esbuild": "^0.25.0"
|
|
30
31
|
},
|
|
31
32
|
"scripts": {
|
|
32
|
-
"build": "esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm --target=node18 --external:@deepseek-ai/* --external:node:* --external:vue-tsc",
|
|
33
|
+
"build": "esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm --target=node18 --external:@deepseek-ai/* --external:node:* --external:vue-tsc --external:execa",
|
|
33
34
|
"typecheck": "tsc -p tsconfig.json"
|
|
34
35
|
}
|
|
35
36
|
}
|