@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.
Files changed (2) hide show
  1. package/dist/index.js +74 -82
  2. 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 { exec } from "node:child_process";
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
- return new Promise((resolve) => {
479
- exec(
480
- // ESLint 默认行为对齐:忽略 node_modules(oxlint 默认不排除)
481
- `node "${bin}" --format=json --ignore-pattern node_modules "${pattern}"`,
482
- { cwd, timeout: 6e4, maxBuffer: 50 * 1024 * 1024 },
483
- (error, stdout, stderr) => {
484
- const killed = error?.killed;
485
- if (killed) {
486
- log2.warn("oxlint timed out", { pattern });
487
- resolve({
488
- text: "[oxlint] \u8FD0\u884C\u5931\u8D25\uFF1A\u68C0\u67E5\u8D85\u65F6\uFF0C\u8BF7\u5C1D\u8BD5\u7F29\u5C0F\u68C0\u67E5\u8303\u56F4\u3002",
489
- diagnostics: [],
490
- engines: ["oxlint"]
491
- });
492
- return;
493
- }
494
- try {
495
- const messages = parseOxlintOutput(stdout, cwd);
496
- log2.debug("oxlint lint", {
497
- pattern,
498
- messageCount: messages.length,
499
- stderr: stderr || void 0
500
- });
501
- resolve(formatLintMessages(messages, { label: "oxlint", source: "oxlint" }, warnLimit));
502
- } catch (e) {
503
- log2.warn("oxlint failed", { pattern, error: e.message });
504
- resolve({
505
- text: `[oxlint] \u8FD0\u884C\u5931\u8D25\uFF1A${e.message}`,
506
- diagnostics: [],
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
- return new Promise((resolve) => {
654
- exec(
655
- `node "${engine.bin}" --build --noEmit --pretty false`,
656
- { cwd: projectDir, timeout, maxBuffer },
657
- (error, stdout, stderr) => {
658
- let rawOutput = stdout + stderr;
659
- const killed = error?.killed;
660
- const exitCode = typeof error?.code === "number" ? error.code : killed ? 1 : 0;
661
- if (killed && !rawOutput) {
662
- 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`;
663
- }
664
- const diagnostics = parseTscDiags(rawOutput, filePath, projectDir, engine.source);
665
- if (filePath) {
666
- const resolved = path.resolve(filePath);
667
- const errorLinePat = /^(.+?)\((\d+),(\d+)\):\s+(error|warning)\s+TS\d+:/;
668
- const lines = rawOutput.split("\n");
669
- const filtered = [];
670
- let keep = false;
671
- for (const line of lines) {
672
- const m = errorLinePat.exec(line);
673
- if (m) {
674
- keep = path.resolve(projectDir, m[1]) === resolved;
675
- } else if (!/^\s/.test(line)) {
676
- keep = false;
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, exec2, result, decision, cwd) {
991
- if (!MUTATING_TOOLS.has(exec2.name)) return;
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 = exec2.arguments;
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 (exec2, result, next) => {
1195
+ async (exec, result, next) => {
1204
1196
  const decision = await next();
1205
1197
  if (!autoDiagnose) return decision;
1206
- if (exec2.parent !== void 0) {
1207
- registerPtcEdit(pendingPtcEdits, String(exec2.rootCallId), exec2, result, decision, cwd);
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(exec2.rootCallId);
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(exec2.name)) return decision;
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 = exec2.arguments;
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.25",
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.25",
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
  }