@aipanel/provider-deepseek 1.2.0-beta.0 → 1.2.0-beta.2
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/dsh-plugin/dist/index.js +110 -0
- package/package.json +6 -3
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// dsh-plugin/src/index.ts
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
defineTool
|
|
5
|
+
} from "@deepseek-ai/dsh-tools";
|
|
6
|
+
import { createUserMessage } from "@deepseek-ai/dsh-llm";
|
|
7
|
+
var name = "aipanel";
|
|
8
|
+
var inject = ["tools", "subprocess"];
|
|
9
|
+
var JS_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
10
|
+
".js",
|
|
11
|
+
".jsx",
|
|
12
|
+
".ts",
|
|
13
|
+
".tsx",
|
|
14
|
+
".mjs",
|
|
15
|
+
".cjs",
|
|
16
|
+
".mts",
|
|
17
|
+
".cts",
|
|
18
|
+
".vue"
|
|
19
|
+
]);
|
|
20
|
+
var MUTATING_TOOLS = /* @__PURE__ */ new Set(["write", "edit", "apply_patch"]);
|
|
21
|
+
var STDOUT_MAX_BYTES = 2e5;
|
|
22
|
+
var STDOUT_SPILL_MAX_BYTES = 2e6;
|
|
23
|
+
var STDERR_MAX_BYTES = 1e5;
|
|
24
|
+
var GRACE_MS = 3e4;
|
|
25
|
+
function apply(ctx, config = {}) {
|
|
26
|
+
const cwd = config.cwd ?? process.cwd();
|
|
27
|
+
const autoDiagnose = config.autoDiagnose ?? true;
|
|
28
|
+
const tools = ctx.tools;
|
|
29
|
+
const subprocess = ctx.subprocess;
|
|
30
|
+
async function collectOutput(argv, signal) {
|
|
31
|
+
try {
|
|
32
|
+
const exe = await subprocess.resolveExecutable("npx", void 0, signal);
|
|
33
|
+
const proc = subprocess.spawn({
|
|
34
|
+
argv: [exe, ...argv],
|
|
35
|
+
cwd,
|
|
36
|
+
stdio: {
|
|
37
|
+
stdin: "ignore",
|
|
38
|
+
stdout: { maxBytes: STDOUT_MAX_BYTES, spill: { maxBytes: STDOUT_SPILL_MAX_BYTES } },
|
|
39
|
+
stderr: { maxBytes: STDERR_MAX_BYTES }
|
|
40
|
+
},
|
|
41
|
+
graceMs: GRACE_MS,
|
|
42
|
+
signal
|
|
43
|
+
});
|
|
44
|
+
await proc.done;
|
|
45
|
+
return { text: proc.collected.stdout?.readFrom(0)?.text ?? "" };
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return { text: "", error: String(e) };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function runDiagnostics(filePath, signal) {
|
|
51
|
+
const parts = [];
|
|
52
|
+
const tsc = await collectOutput(["tsc", "--noEmit", "--pretty", "false"], signal);
|
|
53
|
+
if (tsc.error) parts.push("## tsc\n\n(diagnostics skipped: " + tsc.error + ")");
|
|
54
|
+
else if (tsc.text.trim()) parts.push("## tsc\n\n" + tsc.text.trim());
|
|
55
|
+
const eslint = await collectOutput(["eslint", filePath, "--format", "compact"], signal);
|
|
56
|
+
if (eslint.text.trim()) parts.push("## eslint\n\n" + eslint.text.trim());
|
|
57
|
+
return parts.join("\n\n");
|
|
58
|
+
}
|
|
59
|
+
tools.register(
|
|
60
|
+
defineTool({
|
|
61
|
+
name: "run_diagnostics",
|
|
62
|
+
description: "Run ESLint and TypeScript type checks on filePath and report problems. Use after editing code to verify no lint/type errors before proceeding.",
|
|
63
|
+
parameters: {
|
|
64
|
+
filePath: {
|
|
65
|
+
type: "string",
|
|
66
|
+
required: true,
|
|
67
|
+
description: "Absolute or cwd-relative file path to diagnose"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
output: {
|
|
71
|
+
schema: { type: "string" },
|
|
72
|
+
render: (_args, value) => [{ type: "text", text: value }]
|
|
73
|
+
},
|
|
74
|
+
async execute(args, exec) {
|
|
75
|
+
return runDiagnostics(path.resolve(cwd, args.filePath), exec.signal).catch(
|
|
76
|
+
(e) => "diagnostics failed: " + String(e)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
ctx.on(
|
|
82
|
+
"tools/post-execute",
|
|
83
|
+
async (exec, result, next) => {
|
|
84
|
+
const decision = await next();
|
|
85
|
+
if (!autoDiagnose) return decision;
|
|
86
|
+
if (!MUTATING_TOOLS.has(exec.name)) return decision;
|
|
87
|
+
if (result.isError) return decision;
|
|
88
|
+
if (decision.kind !== "accept") return decision;
|
|
89
|
+
const filePath = exec.arguments?.filePath;
|
|
90
|
+
if (typeof filePath !== "string" || !filePath) return decision;
|
|
91
|
+
if (!JS_EXTENSIONS.has(path.extname(filePath))) return decision;
|
|
92
|
+
const diag = await runDiagnostics(path.resolve(cwd, filePath), exec.signal).catch(
|
|
93
|
+
() => "diagnostics unavailable"
|
|
94
|
+
);
|
|
95
|
+
const message = createUserMessage({
|
|
96
|
+
content: [
|
|
97
|
+
{ type: "text", text: `Auto diagnostics after ${exec.name} (${filePath}):
|
|
98
|
+
${diag}` }
|
|
99
|
+
],
|
|
100
|
+
source: { kind: "plugin", plugin: name }
|
|
101
|
+
});
|
|
102
|
+
return { kind: "accept", additionalContexts: [message] };
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
apply,
|
|
108
|
+
inject,
|
|
109
|
+
name
|
|
110
|
+
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aipanel/provider-deepseek",
|
|
3
|
-
"version": "1.2.0-beta.
|
|
3
|
+
"version": "1.2.0-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.js",
|
|
7
7
|
"types": "es/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"es",
|
|
10
|
-
"lib"
|
|
10
|
+
"lib",
|
|
11
|
+
"dsh-plugin/dist"
|
|
11
12
|
],
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
@@ -21,8 +22,10 @@
|
|
|
21
22
|
"registry": "https://registry.npmjs.org/"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
25
|
+
"@deepseek-ai/dsh-llm": "^0.1.1-rc.2",
|
|
26
|
+
"@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
|
|
24
27
|
"execa": "^9.6.1",
|
|
25
|
-
"@aipanel/core": "1.2.0-beta.
|
|
28
|
+
"@aipanel/core": "1.2.0-beta.2"
|
|
26
29
|
},
|
|
27
30
|
"devDependencies": {
|
|
28
31
|
"esbuild": "^0.25.0"
|