@aipanel/dsh-plugin 1.3.6 → 1.3.8

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 +23 -3
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -113,6 +113,9 @@ function checkRunsInPhase(check, phase) {
113
113
  const run = check.run ?? "both";
114
114
  return run === "both" || run === phase;
115
115
  }
116
+ function checkRunsOnTarget(check, kind) {
117
+ return check.targets === void 0 || check.targets.includes(kind);
118
+ }
116
119
  var FORMATS = [
117
120
  "text",
118
121
  "tsc",
@@ -122,6 +125,7 @@ var FORMATS = [
122
125
  "aipanel-json"
123
126
  ];
124
127
  var RUNS = ["edit", "manual", "both"];
128
+ var TARGET_KINDS = ["edited", "file", "project"];
125
129
  function normalizeExtensions(raw) {
126
130
  if (!Array.isArray(raw)) return void 0;
127
131
  const extensions = raw.filter((item) => typeof item === "string" && item.trim() !== "").map((item) => {
@@ -130,6 +134,13 @@ function normalizeExtensions(raw) {
130
134
  });
131
135
  return extensions.length > 0 ? [...new Set(extensions)] : void 0;
132
136
  }
137
+ function normalizeTargets(raw) {
138
+ if (!Array.isArray(raw)) return void 0;
139
+ const targets = raw.filter(
140
+ (item) => TARGET_KINDS.includes(item)
141
+ );
142
+ return targets.length > 0 ? [...new Set(targets)] : void 0;
143
+ }
133
144
  function normalizeArgs(raw) {
134
145
  if (!Array.isArray(raw)) return void 0;
135
146
  const args = raw.filter((item) => typeof item === "string");
@@ -140,6 +151,7 @@ function normalizeCheck(raw) {
140
151
  const value = raw;
141
152
  const run = RUNS.includes(value.run) ? value.run : void 0;
142
153
  const extensions = normalizeExtensions(value.extensions);
154
+ const targets = normalizeTargets(value.targets);
143
155
  const cwd = typeof value.cwd === "string" && value.cwd ? { cwd: value.cwd } : {};
144
156
  const timeout = typeof value.timeoutMs === "number" && Number.isFinite(value.timeoutMs) && value.timeoutMs > 0 ? { timeoutMs: Math.floor(value.timeoutMs) } : {};
145
157
  const format = FORMATS.includes(value.format) ? { format: value.format } : {};
@@ -148,6 +160,7 @@ function normalizeCheck(raw) {
148
160
  return {
149
161
  builtin: "typecheck",
150
162
  ...run ? { run } : {},
163
+ ...targets ? { targets } : {},
151
164
  ...extensions ? { extensions } : {}
152
165
  };
153
166
  }
@@ -159,6 +172,7 @@ function normalizeCheck(raw) {
159
172
  ...presetArgs ? { args: presetArgs } : {},
160
173
  ...presetProjectArgs ? { projectArgs: presetProjectArgs } : {},
161
174
  ...extensions ? { extensions } : {},
175
+ ...targets ? { targets } : {},
162
176
  ...run ? { run } : {},
163
177
  ...format,
164
178
  ...cwd,
@@ -180,6 +194,7 @@ function normalizeCheck(raw) {
180
194
  ...args ? { args } : {},
181
195
  ...projectArgs ? { projectArgs } : {},
182
196
  ...extensions ? { extensions } : {},
197
+ ...targets ? { targets } : {},
183
198
  ...cwd,
184
199
  ...run ? { run } : {},
185
200
  ...format,
@@ -1246,8 +1261,11 @@ async function runCommandCheck(check, target, phase, severity, optional = false)
1246
1261
  if (failure) return { text: failure, diagnostics: [] };
1247
1262
  const raw = rawCommandOutput(outcome);
1248
1263
  try {
1249
- if (check.adapter) return await runAdapterModule(check, outcome, cwd, fileSet);
1250
- return adaptBuiltinFormat(check.format ?? "text", check, raw, cwd, severity);
1264
+ const produced2 = check.adapter ? await runAdapterModule(check, outcome, cwd, fileSet) : adaptBuiltinFormat(check.format ?? "text", check, raw, cwd, severity);
1265
+ if (phase === "edit" && outcome.exitCode === 0 && produced2.diagnostics.length === 0) {
1266
+ return { ...produced2, text: void 0, notes: void 0 };
1267
+ }
1268
+ return produced2;
1251
1269
  } catch (error) {
1252
1270
  const reason = error instanceof Error ? error.message : String(error);
1253
1271
  const excerpt = raw.replace(/\s+/g, " ").trim().slice(0, 200);
@@ -1347,7 +1365,9 @@ async function runTypecheckCheck(check, target, phase, severity) {
1347
1365
  ];
1348
1366
  }
1349
1367
  async function runDiagnostics(target, policy, phase) {
1350
- const checks = policy.checks.filter((check) => checkRunsInPhase(check, phase));
1368
+ const checks = policy.checks.filter(
1369
+ (check) => checkRunsInPhase(check, phase) && checkRunsOnTarget(check, target.kind)
1370
+ );
1351
1371
  log2.debug("runDiagnostics", { phase, target: target.kind, checks: checks.length });
1352
1372
  const results = await Promise.all(
1353
1373
  checks.map((check) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipanel/dsh-plugin",
3
- "version": "1.3.6",
3
+ "version": "1.3.8",
4
4
  "type": "module",
5
5
  "description": "AIPanel for DeepSeek Harness (dsh):注入审查工具 run_diagnostics、编辑后自动诊断。",
6
6
  "main": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "vue-tsc": "^3.3.9"
17
17
  },
18
18
  "devDependencies": {
19
- "@aipanel/core": "1.3.6",
19
+ "@aipanel/core": "1.3.8",
20
20
  "@deepseek-ai/cordis": "~4.0.4",
21
21
  "@deepseek-ai/dsh-agent": "^0.1.7-alpha.2",
22
22
  "@deepseek-ai/dsh-llm": "^0.1.7-alpha.2",