@aipanel/dsh-plugin 1.2.19 → 1.2.21
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 +77 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -552,6 +552,15 @@ async function runProjectDiagnostics(workspace) {
|
|
|
552
552
|
};
|
|
553
553
|
return { eslintOutput, tscOutput: mergedTsc };
|
|
554
554
|
}
|
|
555
|
+
function formatDiagnosticsSections(title, eslintOutput, tscOutput) {
|
|
556
|
+
const parts = [];
|
|
557
|
+
parts.push("## ESLint\n\n" + (eslintOutput.text || "\u6CA1\u6709\u53D1\u73B0\u95EE\u9898"));
|
|
558
|
+
const tscLines = tscOutput.rawOutput.trim();
|
|
559
|
+
parts.push("## vue-tsc\n\n" + (tscLines || "\u6CA1\u6709\u53D1\u73B0\u7C7B\u578B\u9519\u8BEF"));
|
|
560
|
+
return `${title}
|
|
561
|
+
|
|
562
|
+
` + parts.join("\n\n");
|
|
563
|
+
}
|
|
555
564
|
|
|
556
565
|
// ../../core/es/common/utils.mjs
|
|
557
566
|
var NODE_MENTION_RE = /@节点\[(n[0-9a-z]+)\]/g;
|
|
@@ -800,10 +809,54 @@ function buildNodeContext(e) {
|
|
|
800
809
|
const loc = e.line ? e.column ? `:${e.line}:${e.column}` : `:${e.line}` : "";
|
|
801
810
|
if (e.filePath) lines.push(`\u6E90\u7801\u6587\u4EF6\u8DEF\u5F84\uFF1A${e.filePath}${loc}`);
|
|
802
811
|
if (e.description) lines.push(`DOM \u5143\u7D20\u9009\u62E9\u5668\uFF1A${e.description}`);
|
|
803
|
-
if (e.innerText)
|
|
812
|
+
if (e.innerText) {
|
|
813
|
+
const text = e.innerText.slice(0, 20).replace(/\r?\n/g, "\\n");
|
|
814
|
+
lines.push(`DOM \u5143\u7D20\u5185\u90E8\u6587\u672C\uFF1A${text}`);
|
|
815
|
+
}
|
|
804
816
|
if (e.previewPageUrl) lines.push(`\u7528\u6237\u9009\u4E2D\u8282\u70B9\u65F6\u7684\u9875\u9762 URL\uFF1A${e.previewPageUrl}`);
|
|
805
817
|
return lines.join("\n");
|
|
806
818
|
}
|
|
819
|
+
function buildPluginMessage(text) {
|
|
820
|
+
return {
|
|
821
|
+
role: "user",
|
|
822
|
+
id: randomUUID(),
|
|
823
|
+
content: [{ type: "text", text }],
|
|
824
|
+
source: { kind: "plugin", plugin: name }
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
function registerPtcEdit(targets, rootKey, exec2, result, decision, cwd) {
|
|
828
|
+
if (!MUTATING_TOOLS.has(exec2.name)) return;
|
|
829
|
+
if (result.isError) return;
|
|
830
|
+
if (decision.kind !== "accept") return;
|
|
831
|
+
const rawArgs = exec2.arguments;
|
|
832
|
+
const filePath = typeof rawArgs?.file_path === "string" ? rawArgs.file_path : rawArgs?.filePath;
|
|
833
|
+
if (typeof filePath !== "string" || !filePath) return;
|
|
834
|
+
if (!isJsFile(filePath)) return;
|
|
835
|
+
let files = targets.get(rootKey);
|
|
836
|
+
if (!files) {
|
|
837
|
+
files = /* @__PURE__ */ new Set();
|
|
838
|
+
targets.set(rootKey, files);
|
|
839
|
+
}
|
|
840
|
+
files.add(path2.resolve(cwd, filePath));
|
|
841
|
+
}
|
|
842
|
+
async function collectPtcDiagnostics(files, cwd) {
|
|
843
|
+
const blocks = [];
|
|
844
|
+
for (const file of files) {
|
|
845
|
+
const { eslintOutput, tscOutput } = await runAllChecks(file, cwd).catch(
|
|
846
|
+
() => ({
|
|
847
|
+
eslintOutput: {},
|
|
848
|
+
tscOutput: { rawOutput: "", exitCode: 0 }
|
|
849
|
+
})
|
|
850
|
+
);
|
|
851
|
+
if (!eslintOutput.text && !tscOutput.rawOutput.trim()) continue;
|
|
852
|
+
blocks.push(
|
|
853
|
+
formatDiagnosticsSections(`### ${path2.relative(cwd, file)}`, eslintOutput, tscOutput)
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
return blocks.length > 0 ? `\u81EA\u52A8\u8BCA\u65AD\uFF08PTC \u6279\u91CF\u7F16\u8F91\u540E\uFF09\uFF1A
|
|
857
|
+
|
|
858
|
+
${blocks.join("\n\n")}` : "";
|
|
859
|
+
}
|
|
807
860
|
function toDiagnosticEntries(items) {
|
|
808
861
|
return items.map((d) => ({
|
|
809
862
|
file: d.file ?? "",
|
|
@@ -981,12 +1034,31 @@ function apply(ctx, config = {}) {
|
|
|
981
1034
|
}
|
|
982
1035
|
};
|
|
983
1036
|
tools.register(diagnosticsTool);
|
|
1037
|
+
const pendingPtcEdits = /* @__PURE__ */ new Map();
|
|
984
1038
|
ctx.on(
|
|
985
1039
|
"tools/post-execute",
|
|
986
1040
|
async (exec2, result, next) => {
|
|
987
1041
|
const decision = await next();
|
|
988
1042
|
if (!autoDiagnose) return decision;
|
|
989
|
-
if (exec2.parent !== void 0)
|
|
1043
|
+
if (exec2.parent !== void 0) {
|
|
1044
|
+
registerPtcEdit(pendingPtcEdits, String(exec2.rootCallId), exec2, result, decision, cwd);
|
|
1045
|
+
return decision;
|
|
1046
|
+
}
|
|
1047
|
+
const rootKey = String(exec2.rootCallId);
|
|
1048
|
+
const ptcTargets = pendingPtcEdits.get(rootKey);
|
|
1049
|
+
if (ptcTargets !== void 0) {
|
|
1050
|
+
pendingPtcEdits.delete(rootKey);
|
|
1051
|
+
if (decision.kind !== "accept") return decision;
|
|
1052
|
+
const ptcDiagText = await collectPtcDiagnostics(ptcTargets, cwd);
|
|
1053
|
+
if (!ptcDiagText) return decision;
|
|
1054
|
+
return {
|
|
1055
|
+
...decision,
|
|
1056
|
+
additionalContexts: [
|
|
1057
|
+
...decision.additionalContexts ?? [],
|
|
1058
|
+
buildPluginMessage(ptcDiagText)
|
|
1059
|
+
]
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
990
1062
|
if (!MUTATING_TOOLS.has(exec2.name)) return decision;
|
|
991
1063
|
if (result.isError) return decision;
|
|
992
1064
|
if (decision.kind !== "accept") return decision;
|
|
@@ -1048,19 +1120,11 @@ ${diagText}` }]
|
|
|
1048
1120
|
const injected = [...ids].map((id) => byId.get(id)).filter((el) => el !== void 0);
|
|
1049
1121
|
if (injected.length === 0) return decision;
|
|
1050
1122
|
const contextText = injected.map(buildNodeContext).join("\n\n---\n\n");
|
|
1051
|
-
const contextMessage =
|
|
1052
|
-
|
|
1053
|
-
id: randomUUID(),
|
|
1054
|
-
content: [
|
|
1055
|
-
{
|
|
1056
|
-
type: "text",
|
|
1057
|
-
text: `\u4EE5\u4E0B\u662F\u7528\u6237\u5F15\u7528\u8282\u70B9\u7684\u5B8C\u6574\u4E0A\u4E0B\u6587\uFF08\u8282\u70B9 ID \u4E0E\u6D88\u606F\u4E2D\u7684 @\u8282\u70B9[id] \u6807\u8BB0\u5BF9\u5E94\uFF09\uFF1A
|
|
1123
|
+
const contextMessage = buildPluginMessage(
|
|
1124
|
+
`\u4EE5\u4E0B\u662F\u7528\u6237\u5F15\u7528\u8282\u70B9\u7684\u5B8C\u6574\u4E0A\u4E0B\u6587\uFF08\u8282\u70B9 ID \u4E0E\u6D88\u606F\u4E2D\u7684 @\u8282\u70B9[id] \u6807\u8BB0\u5BF9\u5E94\uFF09\uFF1A
|
|
1058
1125
|
|
|
1059
1126
|
${contextText}`
|
|
1060
|
-
|
|
1061
|
-
],
|
|
1062
|
-
source: { kind: "plugin", plugin: name }
|
|
1063
|
-
};
|
|
1127
|
+
);
|
|
1064
1128
|
try {
|
|
1065
1129
|
await fetch(contextBase, { method: "DELETE", signal });
|
|
1066
1130
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aipanel/dsh-plugin",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AIPanel for DeepSeek Harness (dsh):注入审查工具 run_diagnostics、编辑后自动诊断。",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@deepseek-ai/dsh-user-questions": "^0.1.5-rc.1",
|
|
26
26
|
"@deepseek-ai/dsh-util-values": "^0.1.5-rc.1",
|
|
27
27
|
"esbuild": "^0.25.0",
|
|
28
|
-
"@aipanel/core": "1.2.
|
|
28
|
+
"@aipanel/core": "1.2.21"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "esbuild src/index.ts --bundle --outfile=dist/index.js --platform=node --format=esm --target=node18 --external:@deepseek-ai/* --external:node:* --external:vue-tsc",
|