dsh-plugin-marketplace 0.2.5 → 0.2.6
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/client.js +9 -6
- package/index.js +10 -7
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -207,7 +207,10 @@ window.__ModuleLoader__.load({
|
|
|
207
207
|
var st = props.installState; // {status, message, pkg} from the settings scope
|
|
208
208
|
var active = st && st.pkg === installName;
|
|
209
209
|
var status = active ? st.status : "idle";
|
|
210
|
-
var explainState = props.explainState; // {status, text} from the settings scope
|
|
210
|
+
var explainState = props.explainState; // {status, text, repo} from the settings scope
|
|
211
|
+
// The settings field is namespace-global and persists across sessions,
|
|
212
|
+
// so only show it when it belongs to the plugin currently open.
|
|
213
|
+
var explainMine = !!explainState && explainState.repo === p.fullName;
|
|
211
214
|
var [confirming, setConfirming] = react.useState(false);
|
|
212
215
|
var statusNode = null;
|
|
213
216
|
if (status === "running") {
|
|
@@ -264,14 +267,14 @@ window.__ModuleLoader__.load({
|
|
|
264
267
|
h("div", { className: "__mp_translateRow" },
|
|
265
268
|
h("button", { type: "button", className: "__mp_translateBtn",
|
|
266
269
|
style: { marginTop: "8px", padding: "4px 10px", fontSize: "12px", cursor: "pointer", background: "var(--dsw-alias-bg-hover, #21262d)", color: "var(--dsw-alias-label-primary, #e6edf3)", border: "1px solid var(--dsw-alias-border, #30363d)", borderRadius: "6px" },
|
|
267
|
-
disabled:
|
|
270
|
+
disabled: explainMine && explainState.status === "running",
|
|
268
271
|
onClick: function () { props.onExplain(p.fullName, p.desc, props.readme || ""); }
|
|
269
272
|
}, props.t("aiExplain")),
|
|
270
273
|
h("div", { id: "__mp_translateOut", style: { fontSize: "12px", lineHeight: "1.6", color: "var(--dsw-alias-label-secondary, #8b949e)", whiteSpace: "pre-wrap", wordBreak: "break-word", marginTop: "8px", borderTop: "1px solid var(--dsw-alias-border, #21262d)", paddingTop: "8px" } },
|
|
271
|
-
props.explainError ? h("span", { style: { color: "var(--dsw-alias-state-danger-text, #f85149)" } }, props.explainError)
|
|
272
|
-
:
|
|
273
|
-
:
|
|
274
|
-
:
|
|
274
|
+
explainMine && props.explainError ? h("span", { style: { color: "var(--dsw-alias-state-danger-text, #f85149)" } }, props.explainError)
|
|
275
|
+
: explainMine && explainState.status === "running" ? props.t("aiExplaining")
|
|
276
|
+
: explainMine && explainState.status === "error" ? props.t("aiExplainErr").replace("{msg}", explainState.text || "unknown")
|
|
277
|
+
: explainMine && explainState.status === "ok" ? explainState.text
|
|
275
278
|
: ""
|
|
276
279
|
)
|
|
277
280
|
)
|
package/index.js
CHANGED
|
@@ -49,6 +49,8 @@ const Config = z.object({
|
|
|
49
49
|
aiExplainResult: z.object({
|
|
50
50
|
status: z.string().default("idle"), // idle | running | ok | error
|
|
51
51
|
text: z.string().default(""),
|
|
52
|
+
/** repo this result belongs to ("owner/name"); client gates display on it. */
|
|
53
|
+
repo: z.string().default(""),
|
|
52
54
|
ts: z.number().default(0),
|
|
53
55
|
}),
|
|
54
56
|
});
|
|
@@ -227,12 +229,12 @@ function apply(ctx, config) {
|
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
/** Write the AI-explain result report (and clear the consumed request). */
|
|
230
|
-
async function reportExplain(status, text) {
|
|
232
|
+
async function reportExplain(status, text, repo) {
|
|
231
233
|
const settings = ctx.get("settings");
|
|
232
234
|
if (!settings) return;
|
|
233
235
|
const ts = Date.now();
|
|
234
236
|
await settings.update(NS, {
|
|
235
|
-
aiExplainResult: { status, text, ts },
|
|
237
|
+
aiExplainResult: { status, text, repo: repo || "", ts },
|
|
236
238
|
aiExplain: { repo: "", desc: "", readme: "", ts: 0 },
|
|
237
239
|
}).catch((error) => {
|
|
238
240
|
ctx.logger.warn(`[plugin-marketplace] explain state write failed: ${String(error)}`);
|
|
@@ -245,14 +247,16 @@ function apply(ctx, config) {
|
|
|
245
247
|
* settings-backed message channel as the install flow.
|
|
246
248
|
*/
|
|
247
249
|
async function maybeRunExplain() {
|
|
250
|
+
let repo = "";
|
|
248
251
|
try {
|
|
249
252
|
const cfg = current();
|
|
250
253
|
const req = cfg?.aiExplain;
|
|
251
254
|
if (!req || !req.repo || req.ts === lastExplainTs || req.ts === 0) return;
|
|
252
255
|
lastExplainTs = req.ts;
|
|
256
|
+
repo = String(req.repo);
|
|
253
257
|
const llm = ctx.llm;
|
|
254
258
|
if (!llm) {
|
|
255
|
-
await reportExplain("error", "LLM service unavailable; configure a model in Settings → Models.");
|
|
259
|
+
await reportExplain("error", "LLM service unavailable; configure a model in Settings → Models.", repo);
|
|
256
260
|
return;
|
|
257
261
|
}
|
|
258
262
|
// Route through the deployment's default model when one is configured.
|
|
@@ -261,7 +265,6 @@ function apply(ctx, config) {
|
|
|
261
265
|
const defaults = ctx.agentDefaultModel?.currentSelection?.();
|
|
262
266
|
if (defaults?.provider && defaults?.model) route = defaults;
|
|
263
267
|
} catch { /* no default model service; fall back to the adapter default */ }
|
|
264
|
-
const repo = String(req.repo);
|
|
265
268
|
const desc = String(req.desc || "").trim();
|
|
266
269
|
const readme = String(req.readme || "").trim().slice(0, 1500);
|
|
267
270
|
const prompt =
|
|
@@ -269,7 +272,7 @@ function apply(ctx, config) {
|
|
|
269
272
|
(desc ? `简介:${desc}\n` : "") +
|
|
270
273
|
(readme ? `README 摘要:\n${readme}\n` : "") +
|
|
271
274
|
`\n请用简体中文、3~5 句话直接告诉我这个插件大概是干嘛的(核心用途、解决什么问题、适合谁)。不要复述仓库名,不要罗列安装步骤。`;
|
|
272
|
-
await reportExplain("running", "");
|
|
275
|
+
await reportExplain("running", "", repo);
|
|
273
276
|
ctx.logger.info(`[plugin-marketplace] explaining ${repo} (model=${route ? `${route.provider}/${route.model}` : "default"})…`);
|
|
274
277
|
const messages = [createUserMessage({
|
|
275
278
|
content: [{ type: "text", text: prompt }],
|
|
@@ -293,10 +296,10 @@ function apply(ctx, config) {
|
|
|
293
296
|
.join(" ")
|
|
294
297
|
.trim();
|
|
295
298
|
if (!text) throw new Error("model produced no text");
|
|
296
|
-
await reportExplain("ok", text);
|
|
299
|
+
await reportExplain("ok", text, repo);
|
|
297
300
|
} catch (error) {
|
|
298
301
|
ctx.logger.warn(`[plugin-marketplace] explain flow failed: ${String(error)}`);
|
|
299
|
-
await reportExplain("error", String(error instanceof Error ? error.message : error));
|
|
302
|
+
await reportExplain("error", String(error instanceof Error ? error.message : error), repo);
|
|
300
303
|
}
|
|
301
304
|
}
|
|
302
305
|
}
|