feat: remove the generative-mcpapps skill detection block

The skill status/install section is gone, together with its client probe, the host /better-display/skill-status route, the skill scanning implementation, the bundled skills/generative-mcpapps pack, its copy strings and tests. Reader still renders mcp-app fences the model emits; it just no longer detects or guides installing that skill.

Version 0.4.4.
This commit is contained in:
QQ 2026-11-12 22:40:35 +08:00
parent 3168c2a341
commit eeac9d7e2a
25 changed files with 29 additions and 1544 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## 0.4.4 — 2026-11-12
- 删除设置里的 `generative-mcpapps` 技能检测/安装块(对用户无用):同时移除客户端探测、宿主 `/better-display/skill-status` 路由、技能扫描实现、随包 `skills/generative-mcpapps` 技能包,以及对应的文案与测试。阅读页仍会渲染模型自己写出的 `mcp-app` 代码块,只是不再检测/引导安装该技能。
## 0.4.3 — 2026-11-12
- 修复设置项标题在「Better Display / Better Chat」之间来回变的问题:合并后的插件此前复用了独立 dsh-better-display 的设置节 id(`better-display`)与 locale 命名空间(`better-display`),两个插件同时安装时后注册的会覆盖前者,标题随加载顺序翻转。现在改用独立的 `better-chat` 节 id 与 locale 命名空间,互不覆盖。

View File

@ -36,8 +36,8 @@ tools and approvals remain.
- ````mcp-app` code blocks in the final answer render as interactive cards inside
`<iframe sandbox="allow-scripts allow-forms">`.
- **Better Chat** settings: preview deliverables in the right sidebar, frosted
glass (off by default), auto-fold the process (on by default), approval-card
shortcuts, and detect whether the `generative-mcpapps` skill is installed.
glass (off by default), auto-fold the process (on by default), and approval-card
shortcuts.
- Upstream design notes, extension points and runbooks live in [`docs/`](docs/).
## Feature 2: Enter approves, Esc rejects on approval cards (v0.1.0; hints in v0.4.1, customization in v0.4.2)

View File

@ -30,7 +30,7 @@ dsh plugin --profile desktop add git+https://git.qyhhh.top/DeepsSeekHarness/dsh-
皮肤不会把阅读页当成仅检视视图。
- 最终回答里的 ````mcp-app` 代码块会挂成交互卡片(`<iframe sandbox="allow-scripts allow-forms">`)。
- 设置里的 **Better Chat**:产物右侧预览、半透明毛玻璃(默认关)、过程自动折叠
(默认开)、审批卡快捷键,并检测 `generative-mcpapps` 技能是否已装进宿主技能目录。
(默认开)、审批卡快捷键。
- 上游的设计说明、扩展点文档与开发 runbook 一并保留在 [`docs/`](docs/)。
## 功能二:审批卡片的回车批准 / Esc 拒绝(v0.1.0,v0.4.1 加提示,v0.4.2 快捷键可配置)
@ -88,7 +88,7 @@ pnpm test # vitest
## 目录
```text
src/host.ts 宿主入口(reveal / skill-status / metrics 路由)
src/host.ts 宿主入口(reveal / metrics 路由)
src/client/index.tsx 合并后的客户端入口
src/client/reader-plugin.tsx 阅读视图入口(原 dsh-better-display client)
src/client/chat/ 审批键盘、权限 UI、商店更新

View File

@ -1,11 +1,11 @@
openapi: 3.0.3
info:
title: dsh-better-display
version: 0.3.9
title: dsh-better-chat
version: 0.4.4
description: >
Exact routes registered by apply() in src/dsh-better-display.ts.
Exact routes registered by apply() in src/host.ts.
POST /better-display/reveal is createRevealHandler in src/reveal.ts.
GET /better-display/skill-status returns toPublicSkillStatus.
GET /better-display/metrics returns metricsPayload().
The host webServer mounts these paths. The handlers do not read an
Authorization header or any other credential.
servers:
@ -68,38 +68,6 @@ paths:
$ref: '#/components/schemas/ErrorBody'
'405':
description: req.method was not POST. Empty body. Content-Type is not set.
/better-display/skill-status:
get:
operationId: getGenerativeMcpappsSkillStatus
summary: Public generative-mcpapps install status
description: >
Any method other than GET returns 405 with an empty body and no
Content-Type. The optional cwd query selects which project roots are
scanned. The JSON body is toPublicSkillStatus, which always replaces
roots with the two conventional relative paths and drops packPath
and any host home absolute path.
parameters:
- in: query
name: cwd
required: false
schema:
type: string
description: Project directory passed to scanGenerativeMcpappsStatus. Omitted when the settings probe has no session cwd.
responses:
'200':
description: Public skill status. This body has no ok field.
content:
application/json:
schema:
$ref: '#/components/schemas/PublicSkillStatus'
'405':
description: req.method was not GET. Empty body. Content-Type is not set.
'500':
description: scanGenerativeMcpappsStatus threw. error is String(err).
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBody'
components:
schemas:
ErrorBody:
@ -112,36 +80,3 @@ components:
enum: [false]
error:
type: string
PublicSkillRoot:
type: object
required: [source, path]
additionalProperties: false
properties:
source:
type: string
enum: [conventional]
path:
type: string
enum: ['.dsh/skills', '.agents/skills']
PublicSkillStatus:
type: object
required: [name, installed, via, roots]
additionalProperties: false
properties:
name:
type: string
enum: [generative-mcpapps]
installed:
type: boolean
via:
type: string
nullable: true
enum: ['skills.list', 'skill-root', null]
description: skills.list when the host skills registry lists the skill, skill-root when a scanned root has it, otherwise null.
roots:
type: array
minItems: 2
maxItems: 2
items:
$ref: '#/components/schemas/PublicSkillRoot'
description: Always .dsh/skills then .agents/skills, source conventional. Not the scanned absolute roots.

View File

@ -52891,16 +52891,7 @@ ${trimmed}
shortcutReset: "Restore defaults",
shortcutErrorKey: "Allow actions must use Enter; reject must use Esc.",
shortcutErrorModifier: "Always allow needs at least one modifier key.",
shortcutErrorConflict: "That combination is already used by another action.",
skillTitle: "generative-mcpapps skill",
skillInstalled: "Installed",
skillMissing: "Not detected",
skillPurpose: "This install is for model auto-selection of MCP Apps. Reader already renders mcp-app fences when the model emits them.",
skillPluginNote: "Shipping the pack inside this plugin repository does not install it into the harness skill catalog.",
skillInstall: "Copy the whole generative-mcpapps folder (including references and examples) into .dsh/skills or .agents/skills — in your home or the project, you choose — then Re-check. There is no one-click install that works on every host.",
skillRecheck: "Re-check",
skillChecking: "Checking…",
skillUnavailable: "Could not query the host skill catalog. Copy into .dsh/skills or .agents/skills (home or project), then Re-check."
shortcutErrorConflict: "That combination is already used by another action."
};
const zh = {
nav: "Better Chat",
@ -52924,16 +52915,7 @@ ${trimmed}
shortcutReset: "恢复默认",
shortcutErrorKey: "允许类动作只能用 Enter,拒绝只能用 Esc。",
shortcutErrorModifier: "「始终允许」至少需要一个修饰键(Ctrl/Shift/Alt)。",
shortcutErrorConflict: "这个组合键已经被另一个动作占用。",
skillTitle: "generative-mcpapps 技能",
skillInstalled: "已安装",
skillMissing: "未检测到",
skillPurpose: "这项安装是为了让模型自动选用 MCP Apps。阅读页在模型写出 mcp-app 代码块时已经会渲染,不依赖该技能是否装进宿主。",
skillPluginNote: "技能包只出现在本插件仓库里,并不等于当前 Agent 已经加载它。",
skillInstall: "把完整的 generative-mcpapps 文件夹(含 references 与 examples)复制到 .dsh/skills 或 .agents/skills(家目录或项目目录,由你选),然后重新检测。没有在所有宿主上都可用的一键安装。",
skillRecheck: "重新检测",
skillChecking: "正在检测…",
skillUnavailable: "无法查询宿主技能目录。请复制到 .dsh/skills 或 .agents/skills(家目录或项目),再重新检测。"
shortcutErrorConflict: "这个组合键已经被另一个动作占用。"
};
function settingsLanguage(tag) {
return (tag ?? "").toLowerCase().startsWith("zh") ? "zh" : "en";
@ -52941,86 +52923,8 @@ ${trimmed}
function settingsCopyFor(tag) {
return settingsLanguage(tag) === "zh" ? zh : en;
}
// src/skill-status.ts
/** Shared generative-mcpapps identity. Plugin-tree presence is not installation. */
const GENERATIVE_MCPAPPS_SKILL = "generative-mcpapps";
/** Conventional relative roots only. Never expand $HOME or dump host `root.path`. */
const CONVENTIONAL_SKILL_ROOTS = [".dsh/skills", ".agents/skills"];
/** Copy source relative to the plugin / checkout, not an absolute pack path. */
const SKILL_PACK_RELATIVE = `skills/${GENERATIVE_MCPAPPS_SKILL}`;
function skillNameMatches(name) {
return typeof name === "string" && name === "generative-mcpapps";
}
function skillListIncludes(entries) {
return Array.isArray(entries) && entries.some((entry) => skillNameMatches(entry?.name));
}
function skillsFromListResult(result) {
if (Array.isArray(result)) return result;
if (result === null || typeof result !== "object") return [];
const record = result;
if (record.ok === false) return [];
if (Array.isArray(record.skills)) return record.skills;
if (record.value && typeof record.value === "object") {
const value = record.value;
if (Array.isArray(value.skills)) return value.skills;
if (Array.isArray(record.value)) return record.value;
}
return [];
}
function publicSkillRoots() {
return CONVENTIONAL_SKILL_ROOTS.map((path) => ({
source: "conventional",
path
}));
}
/**
* Strip host home / pack absolutes before anything user-facing (HTTP or Settings).
* Detection still uses the raw scan; this is the public face.
*/
function toPublicSkillStatus(status) {
return {
name: status.name,
installed: status.installed,
via: status.via,
roots: publicSkillRoots()
};
}
// src/client/skill-status.ts
async function detectGenerativeMcpappsSkill(probe) {
let host;
if (probe.fetchHostStatus) try {
host = await probe.fetchHostStatus();
} catch {
host = void 0;
}
let remoteHit = false;
if (probe.listRemoteSkills) try {
remoteHit = skillListIncludes(await probe.listRemoteSkills());
} catch {
remoteHit = false;
}
const installed = Boolean(host?.installed || remoteHit);
const via = remoteHit ? "skills.list" : host?.via ?? null;
const publicHost = host === void 0 ? void 0 : toPublicSkillStatus(host);
return {
name: GENERATIVE_MCPAPPS_SKILL,
installed,
via,
roots: publicHost?.roots ?? publicSkillRoots(),
hostReached: host !== void 0
};
}
/** mkdir/cp using conventional relative roots only. Host paths are ignored. */
function shortestInstallCommand(_status) {
const dest = CONVENTIONAL_SKILL_ROOTS[0];
return `mkdir -p ${dest} && cp -R ${SKILL_PACK_RELATIVE} ${dest}/`;
}
function firstSessionId(list) {
if (list?.ids && list.ids.length > 0) return list.ids[0];
return (list?.byId ? Object.keys(list.byId) : [])[0];
}
// \0dshx-css-module:src/client/SettingsSection.module.css.mjs
const css = ".TSdzRq_section{flex-direction:column;gap:28px;width:100%;max-width:720px;display:flex}.TSdzRq_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.TSdzRq_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:24px;display:flex}.TSdzRq_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.TSdzRq_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.TSdzRq_switch{background:var(--dsw-alias-bg-module-platform);cursor:pointer;border:none;border-radius:12px;flex:none;width:40px;height:24px;padding:0;position:relative}.TSdzRq_switch:after{content:\"\";background:var(--dsw-alias-label-primary);border-radius:50%;width:18px;height:18px;transition:transform .16s;position:absolute;top:3px;left:3px}.TSdzRq_switch[data-on]:after{transform:translate(16px)}.TSdzRq_switch[data-on]{background:var(--dsw-alias-state-business-primary)}.TSdzRq_block{flex-direction:column;gap:10px;display:flex}.TSdzRq_status{color:var(--dsw-alias-label-secondary);align-items:center;gap:8px;font-size:13px;line-height:20px;display:inline-flex}.TSdzRq_badge{background:var(--dsw-alias-bg-module-platform);height:22px;color:var(--dsw-alias-label-secondary);border-radius:11px;align-items:center;padding:0 8px;font-size:12px;display:inline-flex}.TSdzRq_badge[data-ok]{color:#059669;background:#10b98124}.TSdzRq_pre{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;white-space:pre-wrap;border-radius:8px;margin:0;padding:10px 12px;font-size:12px;line-height:18px}.TSdzRq_roots{color:var(--dsw-alias-label-tertiary);margin:0;padding-left:18px;font-size:12px;line-height:18px}.TSdzRq_actions{gap:8px;display:flex}.TSdzRq_button{border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);height:32px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border-radius:8px;padding:0 12px;font-size:13px}.TSdzRq_button:hover{background:var(--dsw-alias-interactive-bg-hover)}.TSdzRq_button:disabled{opacity:.6;cursor:default}.TSdzRq_segment{background:var(--dsw-alias-bg-module-platform);border-radius:10px;gap:2px;width:100%;margin-top:8px;padding:2px;display:flex}.TSdzRq_segmentStop{min-width:0;height:32px;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:8px;flex:1 1 0;padding:0 8px;font-size:12px;line-height:18px}.TSdzRq_segmentStop[data-on]{background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);box-shadow:0 0 0 .5px var(--dsw-alias-border-l2)}.TSdzRq_slider{width:100%;accent-color:var(--dsw-alias-state-business-primary);margin:10px 0 0}.TSdzRq_keyActions{flex:none;align-items:center;gap:8px;display:flex}.TSdzRq_keyButton{border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);min-width:96px;height:32px;color:var(--dsw-alias-label-primary);font-family:var(--ds-font-family-code,ui-monospace, SFMono-Regular, Consolas, monospace);cursor:pointer;border-radius:8px;padding:0 12px;font-size:12px;line-height:20px}.TSdzRq_keyButton:hover{border-color:var(--dsw-alias-border-l3)}.TSdzRq_keyButton[data-recording]{border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-bg-module-platform)}.TSdzRq_error{color:var(--dsw-alias-state-error-primary,#d1483c);margin:0;font-size:12px;line-height:18px}";
const css = ".TSdzRq_section{flex-direction:column;gap:28px;width:100%;max-width:720px;display:flex}.TSdzRq_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.TSdzRq_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:24px;display:flex}.TSdzRq_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.TSdzRq_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.TSdzRq_switch{background:var(--dsw-alias-bg-module-platform);cursor:pointer;border:none;border-radius:12px;flex:none;width:40px;height:24px;padding:0;position:relative}.TSdzRq_switch:after{content:\"\";background:var(--dsw-alias-label-primary);border-radius:50%;width:18px;height:18px;transition:transform .16s;position:absolute;top:3px;left:3px}.TSdzRq_switch[data-on]:after{transform:translate(16px)}.TSdzRq_switch[data-on]{background:var(--dsw-alias-state-business-primary)}.TSdzRq_block{flex-direction:column;gap:10px;display:flex}.TSdzRq_actions{gap:8px;display:flex}.TSdzRq_button{border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-module-platform);height:32px;color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;border-radius:8px;padding:0 12px;font-size:13px}.TSdzRq_button:hover{background:var(--dsw-alias-interactive-bg-hover)}.TSdzRq_button:disabled{opacity:.6;cursor:default}.TSdzRq_segment{background:var(--dsw-alias-bg-module-platform);border-radius:10px;gap:2px;width:100%;margin-top:8px;padding:2px;display:flex}.TSdzRq_segmentStop{min-width:0;height:32px;color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:8px;flex:1 1 0;padding:0 8px;font-size:12px;line-height:18px}.TSdzRq_segmentStop[data-on]{background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);box-shadow:0 0 0 .5px var(--dsw-alias-border-l2)}.TSdzRq_slider{width:100%;accent-color:var(--dsw-alias-state-business-primary);margin:10px 0 0}.TSdzRq_keyActions{flex:none;align-items:center;gap:8px;display:flex}.TSdzRq_keyButton{border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base);min-width:96px;height:32px;color:var(--dsw-alias-label-primary);font-family:var(--ds-font-family-code,ui-monospace, SFMono-Regular, Consolas, monospace);cursor:pointer;border-radius:8px;padding:0 12px;font-size:12px;line-height:20px}.TSdzRq_keyButton:hover{border-color:var(--dsw-alias-border-l3)}.TSdzRq_keyButton[data-recording]{border-color:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-bg-module-platform)}.TSdzRq_error{color:var(--dsw-alias-state-error-primary,#d1483c);margin:0;font-size:12px;line-height:18px}";
const tagId = "dsh-better-chat/SettingsSection.module.css";
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
const tag = document.createElement("style");
@ -53031,22 +52935,18 @@ ${trimmed}
}
var SettingsSection_module_css_default = {
"actions": "TSdzRq_actions",
"badge": "TSdzRq_badge",
"block": "TSdzRq_block",
"button": "TSdzRq_button",
"desc": "TSdzRq_desc",
"error": "TSdzRq_error",
"keyActions": "TSdzRq_keyActions",
"keyButton": "TSdzRq_keyButton",
"pre": "TSdzRq_pre",
"roots": "TSdzRq_roots",
"row": "TSdzRq_row",
"rowText": "TSdzRq_rowText",
"section": "TSdzRq_section",
"segment": "TSdzRq_segment",
"segmentStop": "TSdzRq_segmentStop",
"slider": "TSdzRq_slider",
"status": "TSdzRq_status",
"switch": "TSdzRq_switch",
"title": "TSdzRq_title"
};
@ -53068,27 +52968,6 @@ ${trimmed}
props.prefs.actions.setDeliverableOpenMode(value);
};
const on = mode === "sidebar";
const [skill, setSkill] = (0, react.useState)();
const [checking, setChecking] = (0, react.useState)(false);
const recheck = (0, react.useCallback)(async () => {
setChecking(true);
try {
setSkill(await detectGenerativeMcpappsSkill(props.checkSkill));
} catch {
setSkill({
name: "generative-mcpapps",
installed: false,
via: null,
roots: [],
hostReached: false
});
} finally {
setChecking(false);
}
}, [props.checkSkill]);
(0, react.useEffect)(() => {
recheck();
}, [recheck]);
const chat = props.chat;
const chatSnap = (0, react.useSyncExternalStore)(chat?.subscribe ?? (() => () => {}), () => chat?.getSnapshot() ?? { bindings: void 0 }, () => ({ bindings: void 0 }));
const bindings = normalizeBindings(chatSnap);
@ -53301,60 +53180,7 @@ ${trimmed}
})
})
]
}) : null,
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
className: SettingsSection_module_css_default.block,
"data-better-display-skill": skill?.installed ? "installed" : "missing",
children: [
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className: SettingsSection_module_css_default.title,
children: text(props, copy, "skillTitle")
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className: SettingsSection_module_css_default.status,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
className: SettingsSection_module_css_default.badge,
"data-ok": skill?.installed || void 0,
children: skill?.installed ? text(props, copy, "skillInstalled") : text(props, copy, "skillMissing")
})
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
className: SettingsSection_module_css_default.desc,
children: text(props, copy, "skillPurpose")
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
className: SettingsSection_module_css_default.desc,
children: text(props, copy, "skillPluginNote")
}),
skill && !skill.installed ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
className: SettingsSection_module_css_default.desc,
children: skill.hostReached ? text(props, copy, "skillInstall") : text(props, copy, "skillUnavailable")
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
className: SettingsSection_module_css_default.pre,
children: shortestInstallCommand()
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
className: SettingsSection_module_css_default.roots,
"data-better-display-skill-roots": true,
children: CONVENTIONAL_SKILL_ROOTS.map((root) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: root }, root))
})
] }) : null,
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
className: SettingsSection_module_css_default.actions,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
type: "button",
className: SettingsSection_module_css_default.button,
disabled: checking,
onClick: () => {
recheck();
},
children: checking ? text(props, copy, "skillChecking") : text(props, copy, "skillRecheck")
})
})
]
})
}) : null
]
});
}
@ -53363,26 +53189,6 @@ ${trimmed}
const snap = (ctx.get?.("locale") ?? ctx.locale)?.getSnapshot?.();
return snap?.locale ?? snap?.language ?? (typeof document !== "undefined" ? document.documentElement.lang : void 0) ?? (typeof navigator !== "undefined" ? navigator.language : void 0);
}
function createSkillProbe(ctx) {
return {
fetchHostStatus: async () => {
const snap = ctx.sessions?.list?.getSnapshot?.();
const id = firstSessionId(snap);
const cwd = id && snap?.byId ? snap.byId[id]?.cwd : void 0;
const url = cwd ? `/better-display/skill-status?cwd=${encodeURIComponent(cwd)}` : "/better-display/skill-status";
const res = await fetch(url);
if (!res.ok) return void 0;
return await res.json();
},
listRemoteSkills: async () => {
const skills = ctx.remote?.skills ?? ctx.get?.("remote.skills") ?? (ctx.get?.("remote"))?.skills;
const sessions = ctx.sessions;
const sessionId = firstSessionId(sessions?.list?.getSnapshot?.());
if (!skills?.list || !sessionId) return void 0;
return skillsFromListResult(await skills.list({ sessionId }));
}
};
}
/**
* Own locale namespace and settings-section id. The merged plugin used to reuse
* dsh-better-display's `better-display` id; while the standalone display plugin
@ -53397,13 +53203,11 @@ ${trimmed}
zh,
en
}), "dsh-better-chat: settings copy");
const checkSkill = createSkillProbe(ctx);
const injected = () => ({
prefs,
chat,
copy: settingsCopyFor(languageTag(ctx)),
languageTag: languageTag(ctx),
checkSkill
languageTag: languageTag(ctx)
});
ctx.slots.inject("settings.section", () => ctx.slots.register({
name: "settings.section",

File diff suppressed because one or more lines are too long

View File

@ -1,10 +1,8 @@
import { existsSync, readFileSync } from "node:fs";
import { dirname, isAbsolute, join, posix, resolve, win32 } from "node:path";
import { dirname, posix, resolve, win32 } from "node:path";
import { fileURLToPath } from "node:url";
import { randomUUID } from "node:crypto";
import { spawn } from "node:child_process";
import { access, readdir } from "node:fs/promises";
import { homedir } from "node:os";
// src/flags.ts
const defaultFlags = { readerEnabled: true };
function locateFlags(start = dirname(fileURLToPath(import.meta.url))) {
@ -144,13 +142,8 @@ function requestIdOf(req) {
}
// src/metrics.ts
const ROUTE_REVEAL = "/better-display/reveal";
const ROUTE_SKILL_STATUS = "/better-display/skill-status";
const ROUTE_METRICS = "/better-display/metrics";
const ROUTE_HITS = [
ROUTE_REVEAL,
ROUTE_SKILL_STATUS,
ROUTE_METRICS
];
const ROUTE_HITS = [ROUTE_REVEAL, ROUTE_METRICS];
const hits = new Map(ROUTE_HITS.map((route) => [route, 0]));
const timings = new Map(ROUTE_HITS.map((route) => [route, {
count: 0,
@ -322,156 +315,6 @@ function createRevealHandler({ roots, reveal = revealPath }) {
});
};
}
// src/skill-status.ts
/** Shared generative-mcpapps identity. Plugin-tree presence is not installation. */
const GENERATIVE_MCPAPPS_SKILL = "generative-mcpapps";
/** Conventional relative roots only. Never expand $HOME or dump host `root.path`. */
const CONVENTIONAL_SKILL_ROOTS = [".dsh/skills", ".agents/skills"];
function skillNameMatches(name) {
return typeof name === "string" && name === "generative-mcpapps";
}
function skillListIncludes(entries) {
return Array.isArray(entries) && entries.some((entry) => skillNameMatches(entry?.name));
}
/** Directory bundle `name/SKILL.md` or flat `name.md` at a scanned root. */
function skillRootEntryMatches(entryName) {
return entryName === "generative-mcpapps" || entryName === `generative-mcpapps.md`;
}
function skillsFromListResult(result) {
if (Array.isArray(result)) return result;
if (result === null || typeof result !== "object") return [];
const record = result;
if (record.ok === false) return [];
if (Array.isArray(record.skills)) return record.skills;
if (record.value && typeof record.value === "object") {
const value = record.value;
if (Array.isArray(value.skills)) return value.skills;
if (Array.isArray(record.value)) return record.value;
}
return [];
}
function publicSkillRoots() {
return CONVENTIONAL_SKILL_ROOTS.map((path) => ({
source: "conventional",
path
}));
}
/**
* Strip host home / pack absolutes before anything user-facing (HTTP or Settings).
* Detection still uses the raw scan; this is the public face.
*/
function toPublicSkillStatus(status) {
return {
name: status.name,
installed: status.installed,
via: status.via,
roots: publicSkillRoots()
};
}
// src/skill-roots.ts
function expandHomePath(path, home = homedir()) {
if (path === "~") return home;
if (path.startsWith("~/") || path.startsWith("~\\")) return join(home, path.slice(2));
return path;
}
/** `$DSH_HOME` or `~/.dsh`, matching official `resolveDshHome`. */
function resolveDshHome(env = process.env, home = homedir()) {
const fromEnv = env.DSH_HOME;
const selected = fromEnv !== void 0 && fromEnv.trim().length > 0 ? fromEnv : join(home, ".dsh");
return resolve(expandHomePath(selected, home));
}
/** `$DSH_AGENTS_HOME` or `~/.agents`. */
function resolveAgentsHome(env = process.env, home = homedir()) {
const fromEnv = env.DSH_AGENTS_HOME;
const selected = fromEnv !== void 0 && fromEnv.trim().length > 0 ? fromEnv : join(home, ".agents");
return resolve(expandHomePath(selected, home));
}
function userSkillRoots(env = process.env, home = homedir()) {
return [{
source: "user-dsh",
path: join(resolveDshHome(env, home), "skills")
}, {
source: "user-agents",
path: join(resolveAgentsHome(env, home), "skills")
}];
}
function projectSkillRoots(projectRoot) {
return [{
source: "project-dsh",
path: join(projectRoot, ".dsh", "skills")
}, {
source: "project-agents",
path: join(projectRoot, ".agents", "skills")
}];
}
async function findProjectRoot(cwd) {
let current = resolve(cwd);
while (true) {
if (existsSync(join(current, ".git"))) return current;
const parent = dirname(current);
if (parent === current) return resolve(cwd);
current = parent;
}
}
async function rootHasGenerativeMcpapps(rootPath) {
let entries;
try {
entries = await readdir(rootPath, { withFileTypes: true });
} catch {
return false;
}
for (const entry of entries) {
if (entry.name === ".system") continue;
if (!skillRootEntryMatches(entry.name)) continue;
if (entry.isDirectory()) try {
await access(join(rootPath, entry.name, "SKILL.md"));
return true;
} catch {
continue;
}
if (entry.isFile()) return true;
}
return false;
}
/** Resolve the plugin-shipped pack. This path is never treated as a skill root. */
function pluginSkillPackPath(moduleUrl = import.meta.url) {
const here = dirname(fileURLToPath(moduleUrl));
return [
join(here, "../skills", GENERATIVE_MCPAPPS_SKILL),
join(here, "../../skills", GENERATIVE_MCPAPPS_SKILL),
join(here, "skills", GENERATIVE_MCPAPPS_SKILL)
].find((path) => existsSync(join(path, "SKILL.md")));
}
async function scanGenerativeMcpappsStatus(options = {}) {
const roots = [...userSkillRoots(options.env ?? process.env, options.home ?? homedir())];
const cwd = typeof options.cwd === "string" && options.cwd.trim().length > 0 ? isAbsolute(options.cwd) ? options.cwd : resolve(options.cwd) : void 0;
if (cwd !== void 0) roots.unshift(...projectSkillRoots(await findProjectRoot(cwd)));
const inspected = [];
let rootHit = false;
for (const root of roots) {
const present = await rootHasGenerativeMcpapps(root.path);
inspected.push({
...root,
present
});
if (present) rootHit = true;
}
let via = null;
let listHit = false;
if (options.listSkills) try {
listHit = skillListIncludes(await options.listSkills());
if (listHit) via = "skills.list";
} catch {}
if (!listHit && rootHit) via = "skill-root";
const packPath = options.packPath ?? pluginSkillPackPath();
return {
name: GENERATIVE_MCPAPPS_SKILL,
installed: listHit || rootHit,
via,
roots: inspected,
...packPath !== void 0 ? { packPath } : {}
};
}
// src/host.ts
const name = "dsh-better-chat";
const inject = ["webServer"];
@ -481,11 +324,6 @@ function writeJson(res, status, body) {
res.statusCode = status;
res.end(JSON.stringify(body));
}
function skillLister(ctx) {
const skills = ctx.get?.("skills");
if (typeof skills?.list !== "function") return void 0;
return async () => skillsFromListResult(await skills.list({}));
}
function beginRequest(req, res, route) {
const requestId = requestIdOf(req);
res.setHeader("X-Request-ID", requestId);
@ -520,33 +358,6 @@ function apply(ctx, options) {
reveal(req, res);
}
});
const disposeSkill = ctx.webServer.register({
kind: "exact",
path: ROUTE_SKILL_STATUS,
handler: async (req, res) => {
const requestId = beginRequest(req, res, ROUTE_SKILL_STATUS);
if (req.method !== "GET") {
res.statusCode = 405;
res.end();
return;
}
try {
writeJson(res, 200, toPublicSkillStatus(await scanGenerativeMcpappsStatus({
cwd: new URL(req.url ?? "", "http://127.0.0.1").searchParams.get("cwd") ?? void 0,
listSkills: skillLister(ctx)
})));
} catch (err) {
log.error("skill-status failed", {
requestId,
error: err instanceof Error ? err.message : String(err)
});
writeJson(res, 500, {
ok: false,
error: String(err)
});
}
}
});
const disposeMetrics = ctx.webServer.register({
kind: "exact",
path: ROUTE_METRICS,
@ -562,9 +373,8 @@ function apply(ctx, options) {
});
return () => {
disposeReveal();
disposeSkill();
disposeMetrics();
};
}, "dsh-better-chat: reveal, skill-status, and metrics routes");
}, "dsh-better-chat: reveal and metrics routes");
}
export { apply, inject, name };

View File

@ -1,6 +1,6 @@
{
"name": "dsh-better-chat",
"version": "0.4.3",
"version": "0.4.4",
"description": "DSH 聊天增强插件:审批回车批准 / Esc 拒绝、权限 UI、插件商店更新,以及 reading view(合并自 dsh-better-display)",
"type": "module",
"license": "MIT",
@ -81,7 +81,6 @@
"src",
"tests",
"docs",
"skills",
"cordis.patch.yml",
"flags.json",
"README.md",

View File

@ -1,47 +0,0 @@
---
name: generative-mcpapps
description: "Render interactive HTML/JS widgets, product UI mockups, and clickable prototypes inside the chat (MCP Apps / SEP-1865). Use whenever the user asks to see, preview, compare, or interact with a design (mockup, prototype, 画出来看看): data visualizations, calculators, stateful forms, config wizards, or any UI richer than plain Markdown."
---
# Generative MCP Apps
Create self-contained interactive HTML/JS widgets, UI mockups, and clickable prototypes in chat. This is an Agent Skill with YAML metadata and Markdown instructions; it has no Gemini-specific syntax or model requirement.
## Select the delivery surface
- In DSH with Better Display enabled, emit an `mcp-app` fenced code block. The reading view renders it in an iframe with `sandbox="allow-scripts allow-forms"`.
- In another harness, use only its available, documented UI tool and actual input schema. The Better Display fence and message aliases below are not a universal MCP Apps transport.
- If no inline renderer is available, save a standalone HTML artifact and explain how to open it. Do not claim that a plain code block was rendered.
The harness must discover this skill before automatic selection can work. Keep the whole `generative-mcpapps/` folder together, including references and examples, in a skill directory supported by that harness. Merely placing it inside a plugin repository does not prove that the current agent has loaded it.
## Build the widget
1. Choose local interaction (tabs, filters, calculations) or an explicit submission back to chat. For Better Display, submission fills the composer; the user still sends the message. It does not execute tools or commands automatically.
2. Inline critical CSS and JavaScript. Use semantic theme variables with readable fallbacks, a transparent body, and layouts that fit widths from 320px to 1200px. Avoid `100vh` and `min-h-screen`: Better Display measures content height and clamps it to 60–2400px.
3. Read [HTML boilerplate and theme tokens](references/html_boilerplate.md) when assembling a card. Read [Better Display host messages](references/sep1865_protocol.md) only when using host communication. The latter documents this plugin's implementation, not a full MCP Apps specification.
4. For a selectable local-state example, inspect [interactive_quiz.html](examples/interactive_quiz.html). Adapt its content and controls to the user's request.
## Deliver in Better Display
Output the complete HTML document directly in the answer:
````markdown
```mcp-app title="交互原型"
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>交互原型</title>
</head>
<body>
<!-- Include the widget's inline styles, content, and script here. -->
</body>
</html>
```
````
## Verify the result
Check the complete document, narrow-width layout, readable theme contrast, and the requested interaction. For a submission widget, verify that the chosen data reaches the chat composer; distinguish that from a sent message or completed agent action. A local-only widget needs no host submission. Report only the rendering and interaction actually observed in the available harness.

View File

@ -1,153 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>双盲方案盲选评测器</title>
<style>
:root {
--app-bg: var(--background, #ffffff);
--card-bg: var(--card, #f8fafc);
--border-color: var(--border, #e2e8f0);
--text-main: var(--foreground, #0f172a);
--text-muted: var(--muted-foreground, #64748b);
--primary-color: var(--primary, #2563eb);
--primary-text: var(--primary-foreground, #ffffff);
--hover-bg: rgba(148, 163, 184, 0.12);
}
@media (prefers-color-scheme: dark) {
:root {
--app-bg: var(--background, #0f172a);
--card-bg: var(--card, #1e293b);
--border-color: var(--border, #334155);
--text-main: var(--foreground, #f8fafc);
--text-muted: var(--muted-foreground, #94a3b8);
}
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: transparent;
color: var(--text-main);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
padding: 12px;
}
.quiz-card {
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 16px;
max-width: 680px;
margin: 0 auto;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
border-bottom: 1px solid var(--border-color);
padding-bottom: 8px;
}
.title { font-size: 15px; font-weight: 600; }
.badge {
font-size: 11px;
padding: 2px 8px;
border-radius: 9999px;
background: var(--hover-bg);
color: var(--text-muted);
}
.prompt {
font-size: 13px;
color: var(--text-muted);
margin-bottom: 14px;
line-height: 1.4;
}
.options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.option-btn {
text-align: left;
background: transparent;
border: 1px solid var(--border-color);
border-radius: 8px;
padding: 10px 14px;
color: var(--text-main);
font-size: 13px;
cursor: pointer;
line-height: 1.4;
transition: all 0.15s ease;
}
.option-btn:hover { background: var(--hover-bg); }
.option-btn.selected {
border-color: var(--primary-color);
background: var(--hover-bg);
font-weight: 500;
}
.footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 10px;
}
.submit-btn {
background: var(--primary-color);
color: var(--primary-text);
border: none;
border-radius: 6px;
padding: 7px 16px;
font-size: 13px;
cursor: pointer;
}
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
</style>
</head>
<body>
<div class="quiz-card">
<div class="header">
<span class="title">⚡ 架构方案盲选评测</span>
<span class="badge" id="step-indicator">第 1/2 题</span>
</div>
<p class="prompt" id="question-text">
【场景】:订单超时自动关单,选 Redis 过期监听还是延迟消息队列?
</p>
<div class="options" id="options-container">
<button class="option-btn" onclick="selectOption('A')">A: 选 Redis 监听,轻量便捷无需额外运维</button>
<button class="option-btn" onclick="selectOption('B')">B: 坚决选延迟消息队列,Redis 监听会静默丢事件</button>
</div>
<div class="footer">
<span style="font-size: 12px; color: var(--text-muted);" id="status-text">请选择最符合你直觉的方案</span>
<button class="submit-btn" id="submit-btn" disabled onclick="submitChoice()">确认选择并提交</button>
</div>
</div>
<script>
let currentSelection = null;
function selectOption(key) {
currentSelection = key;
document.querySelectorAll('.option-btn').forEach((btn, idx) => {
btn.classList.toggle('selected', (idx === 0 && key === 'A') || (idx === 1 && key === 'B'));
});
document.getElementById('submit-btn').disabled = false;
}
function submitChoice() {
if (!currentSelection) return;
document.getElementById('status-text').innerText = "已发送到聊天输入框,请确认并发送。";
document.getElementById('submit-btn').disabled = true;
// 通过 Better Display 适配器将选择填入聊天输入框
window.parent.postMessage({
jsonrpc: "2.0",
id: "eval-" + Date.now(),
method: "ui/submit",
params: {
task: "architecture_quiz_completed",
choice: currentSelection,
desc: currentSelection === 'A' ? 'Redis 监听' : '延迟消息队列'
}
}, "*");
}
</script>
</body>
</html>

View File

@ -1,122 +0,0 @@
# HTML Boilerplate & Theme Tokens Reference
This document provides self-contained HTML/CSS templates optimized for MCP Apps iframes across dark and light modes.
---
## 1. Universal Theme Tokens Mapping
Host applications inject different CSS variables into iframes. Use this resilient CSS custom properties cascade to guarantee proper contrast regardless of the host:
```css
:root {
/* Surface & Background */
--app-bg: var(--background, #ffffff);
--card-bg: var(--card, #f8fafc);
--border-color: var(--border, #e2e8f0);
/* Typography */
--text-main: var(--foreground, #0f172a);
--text-muted: var(--muted-foreground, #64748b);
/* Accents & States */
--primary-color: var(--primary, #2563eb);
--primary-text: var(--primary-foreground, #ffffff);
--hover-bg: rgba(148, 163, 184, 0.12);
}
@media (prefers-color-scheme: dark) {
:root {
--app-bg: var(--background, #0f172a);
--card-bg: var(--card, #1e293b);
--border-color: var(--border, #334155);
--text-main: var(--foreground, #f8fafc);
--text-muted: var(--muted-foreground, #94a3b8);
}
}
```
---
## 2. Standard Responsive Card Template
```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
/* Insert Theme Tokens here */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: transparent;
color: var(--text-main);
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
padding: 12px;
}
.mcp-card {
background: var(--card-bg);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 16px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
max-width: 720px;
margin: 0 auto;
}
.mcp-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.mcp-title {
font-size: 15px;
font-weight: 600;
color: var(--text-main);
}
.mcp-badge {
font-size: 11px;
padding: 2px 8px;
border-radius: 9999px;
background: var(--hover-bg);
color: var(--text-muted);
}
.btn-primary {
background: var(--primary-color);
color: var(--primary-text);
border: none;
border-radius: 6px;
padding: 8px 14px;
font-size: 13px;
font-weight: 500;
cursor: pointer;
transition: opacity 0.15s ease;
}
.btn-primary:hover { opacity: 0.9; }
</style>
</head>
<body>
<div class="mcp-card">
<div class="mcp-header">
<h3 class="mcp-title" id="widget-title">交互组件标题</h3>
<span class="mcp-badge" id="widget-badge">Interactive</span>
</div>
<div id="widget-content">
<!-- 动态正文内容 -->
</div>
</div>
<script>
function notifyHost(action, payload) {
window.parent.postMessage({
jsonrpc: "2.0",
id: "action-" + Date.now(),
method: "ui/submit",
params: { action, payload }
}, "*");
}
</script>
</body>
</html>
```

View File

@ -1,54 +0,0 @@
# Better Display host messages
This documents the adapter in `src/client/McpAppFrame.tsx`, not the full SEP-1865 specification. Use these messages for Better Display's `mcp-app` iframe. Other hosts require their own documented transport and capabilities.
## Initialization and theme
The iframe can send `ui/initialize` with a JSON-RPC request ID. Better Display responds with `result.protocolVersion` and `result.hostContext`, including `theme`, `locale`, and `styles.variables`.
For compatibility, Better Display also sends an initial `ui/initialize` notification with those theme fields in `params`. Later theme changes arrive as `ui/notifications/host-context-changed`. The plugin injects a theme and height helper into HTML documents.
When handling parent messages, verify the source:
```javascript
window.addEventListener("message", (event) => {
if (event.source !== window.parent) return;
const msg = event.data;
if (!msg || msg.jsonrpc !== "2.0") return;
const context = msg.result?.hostContext || msg.params;
if (context?.theme) {
document.documentElement.dataset.theme = context.theme;
}
});
```
The sandbox has an opaque origin, so messages to the parent use `"*"`. The host checks that incoming messages originate from this iframe's content window.
## Submit a choice to the composer
```javascript
window.parent.postMessage({
jsonrpc: "2.0",
id: "choice-" + Date.now(),
method: "ui/submit",
params: { task: "quiz_completed", choice: "B", desc: "Selected option B" }
}, "*");
```
The host displays a receipt and fills the chat composer with a prompt derived from the parameters. The user must send it. `ui/update-model-context` is handled as the same composer action in this adapter; do not assume a silent model-context update. These submit handlers do not send a JSON-RPC success response, so do not wait indefinitely for one.
There is no `tools/call` handler in this adapter. Use submission for a requested follow-up instead of claiming that a click executed a tool.
## Readiness and sizing
`ui/ready` and `ui/notifications/initialized` mark the iframe ready. The injected ResizeObserver normally handles height automatically. A widget may also send:
```javascript
window.parent.postMessage({
jsonrpc: "2.0",
method: "ui/resize",
params: { height: document.body.scrollHeight }
}, "*");
```
The host accepts positive finite heights and clamps them to 60–2400px. No `ui/updateState` handler is provided by this adapter.

View File

@ -75,51 +75,6 @@
gap: 10px;
}
.status {
display: inline-flex;
align-items: center;
gap: 8px;
font-size: 13px;
line-height: 20px;
color: var(--dsw-alias-label-secondary);
}
.badge {
display: inline-flex;
align-items: center;
height: 22px;
padding: 0 8px;
border-radius: 11px;
background: var(--dsw-alias-bg-module-platform);
color: var(--dsw-alias-label-secondary);
font-size: 12px;
}
.badge[data-ok] {
background: rgba(16, 185, 129, 0.14);
color: #059669;
}
.pre {
margin: 0;
padding: 10px 12px;
border-radius: 8px;
background: var(--dsw-alias-bg-module-platform);
color: var(--dsw-alias-label-secondary);
font-size: 12px;
line-height: 18px;
overflow-wrap: anywhere;
white-space: pre-wrap;
}
.roots {
margin: 0;
padding-left: 18px;
color: var(--dsw-alias-label-tertiary);
font-size: 12px;
line-height: 18px;
}
.actions {
display: flex;
gap: 8px;

View File

@ -11,7 +11,6 @@ import {
import type { ChatPrefs } from './chat/bindings-store.js';
import { deliverableOpenModeOf, type DeliverableOpenMode } from './open-file.js';
import { settingsCopyFor, type SettingsCopy, type SettingsCopyKey } from './settings-copy.js';
import { CONVENTIONAL_SKILL_ROOTS, detectGenerativeMcpappsSkill, shortestInstallCommand, type SkillStatusProbe, type SkillStatusSnapshot } from './skill-status.js';
import css from './SettingsSection.module.css';
export interface ReaderPrefsSnapshot {
@ -38,7 +37,6 @@ export interface BetterDisplaySettingsInjected {
chat?: ChatPrefs;
copy?: SettingsCopy;
languageTag?: string;
checkSkill: SkillStatusProbe;
}
type SettingsProps = BetterDisplaySettingsInjected & {
@ -73,27 +71,6 @@ export function SettingsSection(props: SettingsProps) {
props.prefs.actions.setDeliverableOpenMode(value);
};
const on = mode === 'sidebar';
const [skill, setSkill] = useState<SkillStatusSnapshot | undefined>();
const [checking, setChecking] = useState(false);
const recheck = useCallback(async () => {
setChecking(true);
try {
setSkill(await detectGenerativeMcpappsSkill(props.checkSkill));
} catch {
setSkill({
name: 'generative-mcpapps',
installed: false,
via: null,
roots: [],
hostReached: false,
});
} finally {
setChecking(false);
}
}, [props.checkSkill]);
useEffect(() => { void recheck(); }, [recheck]);
// 审批快捷键:读插件配置(dsh.better-chat.v1),保存后派发事件让卡片提示立即重建。
const chat = props.chat;
@ -257,33 +234,6 @@ export function SettingsSection(props: SettingsProps) {
</div>
</section>
) : null}
<section className={css.block} data-better-display-skill={skill?.installed ? 'installed' : 'missing'}>
<div className={css.title}>{text(props, copy, 'skillTitle')}</div>
<div className={css.status}>
<span className={css.badge} data-ok={skill?.installed || undefined}>
{skill?.installed ? text(props, copy, 'skillInstalled') : text(props, copy, 'skillMissing')}
</span>
</div>
<p className={css.desc}>{text(props, copy, 'skillPurpose')}</p>
<p className={css.desc}>{text(props, copy, 'skillPluginNote')}</p>
{skill && !skill.installed ? (
<>
<p className={css.desc}>{skill.hostReached ? text(props, copy, 'skillInstall') : text(props, copy, 'skillUnavailable')}</p>
<pre className={css.pre}>{shortestInstallCommand()}</pre>
<ul className={css.roots} data-better-display-skill-roots>
{CONVENTIONAL_SKILL_ROOTS.map(root => (
<li key={root}>{root}</li>
))}
</ul>
</>
) : null}
<div className={css.actions}>
<button type="button" className={css.button} disabled={checking} onClick={() => { void recheck(); }}>
{checking ? text(props, copy, 'skillChecking') : text(props, copy, 'skillRecheck')}
</button>
</div>
</section>
</div>
);
}

View File

@ -20,16 +20,7 @@ export type SettingsCopyKey =
| 'shortcutReset'
| 'shortcutErrorKey'
| 'shortcutErrorModifier'
| 'shortcutErrorConflict'
| 'skillTitle'
| 'skillInstalled'
| 'skillMissing'
| 'skillPurpose'
| 'skillPluginNote'
| 'skillInstall'
| 'skillRecheck'
| 'skillChecking'
| 'skillUnavailable';
| 'shortcutErrorConflict';
export type SettingsCopy = Record<SettingsCopyKey, string>;
@ -56,15 +47,6 @@ export const en: SettingsCopy = {
shortcutErrorKey: 'Allow actions must use Enter; reject must use Esc.',
shortcutErrorModifier: 'Always allow needs at least one modifier key.',
shortcutErrorConflict: 'That combination is already used by another action.',
skillTitle: 'generative-mcpapps skill',
skillInstalled: 'Installed',
skillMissing: 'Not detected',
skillPurpose: 'This install is for model auto-selection of MCP Apps. Reader already renders mcp-app fences when the model emits them.',
skillPluginNote: 'Shipping the pack inside this plugin repository does not install it into the harness skill catalog.',
skillInstall: 'Copy the whole generative-mcpapps folder (including references and examples) into .dsh/skills or .agents/skills — in your home or the project, you choose — then Re-check. There is no one-click install that works on every host.',
skillRecheck: 'Re-check',
skillChecking: 'Checking…',
skillUnavailable: 'Could not query the host skill catalog. Copy into .dsh/skills or .agents/skills (home or project), then Re-check.',
};
export const zh: SettingsCopy = {
@ -90,15 +72,6 @@ export const zh: SettingsCopy = {
shortcutErrorKey: '允许类动作只能用 Enter,拒绝只能用 Esc。',
shortcutErrorModifier: '「始终允许」至少需要一个修饰键(Ctrl/Shift/Alt)。',
shortcutErrorConflict: '这个组合键已经被另一个动作占用。',
skillTitle: 'generative-mcpapps 技能',
skillInstalled: '已安装',
skillMissing: '未检测到',
skillPurpose: '这项安装是为了让模型自动选用 MCP Apps。阅读页在模型写出 mcp-app 代码块时已经会渲染,不依赖该技能是否装进宿主。',
skillPluginNote: '技能包只出现在本插件仓库里,并不等于当前 Agent 已经加载它。',
skillInstall: '把完整的 generative-mcpapps 文件夹(含 references 与 examples)复制到 .dsh/skills 或 .agents/skills(家目录或项目目录,由你选),然后重新检测。没有在所有宿主上都可用的一键安装。',
skillRecheck: '重新检测',
skillChecking: '正在检测…',
skillUnavailable: '无法查询宿主技能目录。请复制到 .dsh/skills 或 .agents/skills(家目录或项目),再重新检测。',
};
export function settingsLanguage(tag: string | undefined): 'zh' | 'en' {

View File

@ -2,8 +2,6 @@ import type { Context } from '@deepseek-ai/cordis';
import type {} from './settings-slots.js';
import { settingsCopyFor, zh, en } from './settings-copy.js';
import { SettingsSection, type BetterDisplaySettingsInjected, type OpenPrefs } from './SettingsSection.js';
import { firstSessionId, skillsFromListResult, type SkillStatusProbe } from './skill-status.js';
import type { HostSkillStatus } from '../skill-status.js';
import type { ChatPrefs } from './chat/bindings-store.js';
interface LocaleFace {
@ -12,10 +10,6 @@ interface LocaleFace {
getSnapshot?: () => { locale?: string; language?: string };
}
interface RemoteSkillsFace {
list?: (arg: { sessionId: string }, signal?: AbortSignal) => Promise<unknown>;
}
function languageTag(ctx: Context): string | undefined {
const locale = (ctx.get?.('locale') ?? (ctx as unknown as { locale?: LocaleFace }).locale) as LocaleFace | undefined;
const snap = locale?.getSnapshot?.();
@ -24,33 +18,6 @@ function languageTag(ctx: Context): string | undefined {
?? (typeof navigator !== 'undefined' ? navigator.language : undefined);
}
function createSkillProbe(ctx: Context): SkillStatusProbe {
return {
fetchHostStatus: async () => {
const sessions = ctx.sessions as { list?: { getSnapshot?: () => { byId?: Record<string, { cwd?: string }> } } } | undefined;
const snap = sessions?.list?.getSnapshot?.();
const id = firstSessionId(snap);
const cwd = id && snap?.byId ? snap.byId[id]?.cwd : undefined;
const url = cwd
? `/better-display/skill-status?cwd=${encodeURIComponent(cwd)}`
: '/better-display/skill-status';
const res = await fetch(url);
if (!res.ok) return undefined;
return await res.json() as HostSkillStatus;
},
listRemoteSkills: async () => {
const remote = ctx.remote as unknown as { skills?: RemoteSkillsFace } | undefined;
const skills = remote?.skills
?? (ctx.get?.('remote.skills') as RemoteSkillsFace | undefined)
?? ((ctx.get?.('remote') as { skills?: RemoteSkillsFace } | undefined)?.skills);
const sessions = ctx.sessions as { list?: { getSnapshot?: () => { ids?: string[]; byId?: Record<string, unknown> } } } | undefined;
const sessionId = firstSessionId(sessions?.list?.getSnapshot?.());
if (!skills?.list || !sessionId) return undefined;
return skillsFromListResult(await skills.list({ sessionId }));
},
};
}
/**
* Own locale namespace and settings-section id. The merged plugin used to reuse
* dsh-better-display's `better-display` id; while the standalone display plugin
@ -65,13 +32,11 @@ export function installBetterDisplaySettings(ctx: Context, prefs: OpenPrefs, cha
if (locale?.register) {
ctx.effect(() => locale.register!(SETTINGS_LOCALE_NS, { zh, en }), 'dsh-better-chat: settings copy');
}
const checkSkill = createSkillProbe(ctx);
const injected = (): BetterDisplaySettingsInjected => ({
prefs,
chat,
copy: settingsCopyFor(languageTag(ctx)),
languageTag: languageTag(ctx),
checkSkill,
});
ctx.slots.inject('settings.section', () => ctx.slots.register({
name: 'settings.section',

View File

@ -1,78 +0,0 @@
import {
CONVENTIONAL_SKILL_ROOTS,
GENERATIVE_MCPAPPS_SKILL,
SKILL_PACK_RELATIVE,
publicSkillRoots,
skillListIncludes,
skillsFromListResult,
toPublicSkillStatus,
type HostSkillStatus,
} from '../skill-status.js';
export {
CONVENTIONAL_SKILL_ROOTS,
GENERATIVE_MCPAPPS_SKILL,
SKILL_PACK_RELATIVE,
publicSkillRoots,
skillListIncludes,
skillsFromListResult,
toPublicSkillStatus,
};
export type { HostSkillStatus };
export interface SkillStatusSnapshot {
readonly name: typeof GENERATIVE_MCPAPPS_SKILL;
readonly installed: boolean;
readonly via: 'skills.list' | 'skill-root' | null;
readonly roots: HostSkillStatus['roots'];
readonly packPath?: string;
readonly hostReached: boolean;
}
export interface SkillStatusProbe {
listRemoteSkills?: () => Promise<readonly { readonly name?: string }[] | undefined>;
fetchHostStatus?: () => Promise<HostSkillStatus | undefined>;
}
export async function detectGenerativeMcpappsSkill(probe: SkillStatusProbe): Promise<SkillStatusSnapshot> {
let host: HostSkillStatus | undefined;
if (probe.fetchHostStatus) {
try {
host = await probe.fetchHostStatus();
} catch {
host = undefined;
}
}
let remoteHit = false;
if (probe.listRemoteSkills) {
try {
remoteHit = skillListIncludes(await probe.listRemoteSkills());
} catch {
remoteHit = false;
}
}
const installed = Boolean(host?.installed || remoteHit);
const via = remoteHit ? 'skills.list' : (host?.via ?? null);
const publicHost = host === undefined ? undefined : toPublicSkillStatus(host);
return {
name: GENERATIVE_MCPAPPS_SKILL,
installed,
via,
roots: publicHost?.roots ?? publicSkillRoots(),
hostReached: host !== undefined,
};
}
/** mkdir/cp using conventional relative roots only. Host paths are ignored. */
export function shortestInstallCommand(_status?: Pick<SkillStatusSnapshot, 'packPath' | 'roots'>): string {
const dest = CONVENTIONAL_SKILL_ROOTS[0];
return `mkdir -p ${dest} && cp -R ${SKILL_PACK_RELATIVE} ${dest}/`;
}
export function firstSessionId(list: { ids?: readonly string[]; byId?: Record<string, unknown> } | undefined): string | undefined {
if (list?.ids && list.ids.length > 0) return list.ids[0];
const keys = list?.byId ? Object.keys(list.byId) : [];
return keys[0];
}

View File

@ -2,10 +2,8 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
import type { Context } from '@deepseek-ai/cordis';
import { loadFlags, type Flags } from './flags.js';
import { createLogger, requestIdOf } from './log.js';
import { metricsPayload, recordRouteDuration, recordRouteHit, ROUTE_METRICS, ROUTE_REVEAL, ROUTE_SKILL_STATUS } from './metrics.js';
import { metricsPayload, recordRouteDuration, recordRouteHit, ROUTE_METRICS, ROUTE_REVEAL } from './metrics.js';
import { createRevealHandler, revealRoots } from './reveal.js';
import { scanGenerativeMcpappsStatus } from './skill-roots.js';
import { skillsFromListResult, toPublicSkillStatus } from './skill-status.js';
declare module '@deepseek-ai/cordis' {
interface Context {
@ -30,12 +28,6 @@ function writeJson(res: ServerResponse, status: number, body: unknown): void {
res.end(JSON.stringify(body));
}
function skillLister(ctx: Context): (() => Promise<readonly { readonly name?: string }[] | undefined>) | undefined {
const skills = ctx.get?.('skills') as { list?: (options?: object) => Promise<unknown> } | undefined;
if (typeof skills?.list !== 'function') return undefined;
return async () => skillsFromListResult(await skills.list!({}));
}
function beginRequest(req: IncomingMessage, res: ServerResponse, route: string): string {
const requestId = requestIdOf(req);
res.setHeader('X-Request-ID', requestId);
@ -73,33 +65,6 @@ export function apply(ctx: Context, options?: { readonly flags?: Flags }): void
reveal(req, res);
},
});
const disposeSkill = ctx.webServer!.register({
kind: 'exact',
path: ROUTE_SKILL_STATUS,
handler: async (req, res) => {
const requestId = beginRequest(req, res, ROUTE_SKILL_STATUS);
if (req.method !== 'GET') {
res.statusCode = 405;
res.end();
return;
}
try {
const url = new URL(req.url ?? '', 'http://127.0.0.1');
const cwd = url.searchParams.get('cwd') ?? undefined;
const status = await scanGenerativeMcpappsStatus({
cwd,
listSkills: skillLister(ctx),
});
writeJson(res, 200, toPublicSkillStatus(status));
} catch (err) {
log.error('skill-status failed', {
requestId,
error: err instanceof Error ? err.message : String(err),
});
writeJson(res, 500, { ok: false, error: String(err) });
}
},
});
const disposeMetrics = ctx.webServer!.register({
kind: 'exact',
path: ROUTE_METRICS,
@ -115,9 +80,8 @@ export function apply(ctx: Context, options?: { readonly flags?: Flags }): void
});
return () => {
disposeReveal();
disposeSkill();
disposeMetrics();
};
}, 'dsh-better-chat: reveal, skill-status, and metrics routes');
}, 'dsh-better-chat: reveal and metrics routes');
}
}

View File

@ -1,8 +1,7 @@
export const ROUTE_REVEAL = '/better-display/reveal';
export const ROUTE_SKILL_STATUS = '/better-display/skill-status';
export const ROUTE_METRICS = '/better-display/metrics';
export const ROUTE_HITS = [ROUTE_REVEAL, ROUTE_SKILL_STATUS, ROUTE_METRICS] as const;
export const ROUTE_HITS = [ROUTE_REVEAL, ROUTE_METRICS] as const;
export interface RouteTiming {
count: number;

View File

@ -1,138 +0,0 @@
import { access, readdir } from 'node:fs/promises';
import { existsSync } from 'node:fs';
import { homedir } from 'node:os';
import { dirname, isAbsolute, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
GENERATIVE_MCPAPPS_SKILL,
skillListIncludes,
skillRootEntryMatches,
type HostSkillStatus,
type SkillRootInfo,
} from './skill-status.js';
export function expandHomePath(path: string, home = homedir()): string {
if (path === '~') return home;
if (path.startsWith('~/') || path.startsWith('~\\')) return join(home, path.slice(2));
return path;
}
/** `$DSH_HOME` or `~/.dsh`, matching official `resolveDshHome`. */
export function resolveDshHome(env: Record<string, string | undefined> = process.env, home = homedir()): string {
const fromEnv = env.DSH_HOME;
const selected = fromEnv !== undefined && fromEnv.trim().length > 0 ? fromEnv : join(home, '.dsh');
return resolve(expandHomePath(selected, home));
}
/** `$DSH_AGENTS_HOME` or `~/.agents`. */
export function resolveAgentsHome(env: Record<string, string | undefined> = process.env, home = homedir()): string {
const fromEnv = env.DSH_AGENTS_HOME;
const selected = fromEnv !== undefined && fromEnv.trim().length > 0 ? fromEnv : join(home, '.agents');
return resolve(expandHomePath(selected, home));
}
export function userSkillRoots(
env: Record<string, string | undefined> = process.env,
home = homedir(),
): readonly SkillRootInfo[] {
return [
{ source: 'user-dsh', path: join(resolveDshHome(env, home), 'skills') },
{ source: 'user-agents', path: join(resolveAgentsHome(env, home), 'skills') },
];
}
export function projectSkillRoots(projectRoot: string): readonly SkillRootInfo[] {
return [
{ source: 'project-dsh', path: join(projectRoot, '.dsh', 'skills') },
{ source: 'project-agents', path: join(projectRoot, '.agents', 'skills') },
];
}
export async function findProjectRoot(cwd: string): Promise<string> {
let current = resolve(cwd);
while (true) {
if (existsSync(join(current, '.git'))) return current;
const parent = dirname(current);
if (parent === current) return resolve(cwd);
current = parent;
}
}
export async function rootHasGenerativeMcpapps(rootPath: string): Promise<boolean> {
let entries;
try {
entries = await readdir(rootPath, { withFileTypes: true });
} catch {
return false;
}
for (const entry of entries) {
if (entry.name === '.system') continue;
if (!skillRootEntryMatches(entry.name)) continue;
if (entry.isDirectory()) {
try {
await access(join(rootPath, entry.name, 'SKILL.md'));
return true;
} catch {
continue;
}
}
if (entry.isFile()) return true;
}
return false;
}
/** Resolve the plugin-shipped pack. This path is never treated as a skill root. */
export function pluginSkillPackPath(moduleUrl = import.meta.url): string | undefined {
const here = dirname(fileURLToPath(moduleUrl));
const candidates = [
join(here, '../skills', GENERATIVE_MCPAPPS_SKILL),
join(here, '../../skills', GENERATIVE_MCPAPPS_SKILL),
join(here, 'skills', GENERATIVE_MCPAPPS_SKILL),
];
return candidates.find(path => existsSync(join(path, 'SKILL.md')));
}
export async function scanGenerativeMcpappsStatus(options: {
cwd?: string;
env?: Record<string, string | undefined>;
home?: string;
packPath?: string;
listSkills?: () => Promise<readonly { readonly name?: string }[] | undefined>;
} = {}): Promise<HostSkillStatus> {
const env = options.env ?? process.env;
const home = options.home ?? homedir();
const roots: SkillRootInfo[] = [...userSkillRoots(env, home)];
const cwd = typeof options.cwd === 'string' && options.cwd.trim().length > 0
? (isAbsolute(options.cwd) ? options.cwd : resolve(options.cwd))
: undefined;
if (cwd !== undefined) roots.unshift(...projectSkillRoots(await findProjectRoot(cwd)));
const inspected: SkillRootInfo[] = [];
let rootHit = false;
for (const root of roots) {
const present = await rootHasGenerativeMcpapps(root.path);
inspected.push({ ...root, present });
if (present) rootHit = true;
}
let via: HostSkillStatus['via'] = null;
let listHit = false;
if (options.listSkills) {
try {
listHit = skillListIncludes(await options.listSkills());
if (listHit) via = 'skills.list';
} catch {
// Registry/RPC absence falls back to the scanned roots.
}
}
if (!listHit && rootHit) via = 'skill-root';
const packPath = options.packPath ?? pluginSkillPackPath();
return {
name: GENERATIVE_MCPAPPS_SKILL,
installed: listHit || rootHit,
via,
roots: inspected,
...packPath !== undefined ? { packPath } : {},
};
}

View File

@ -1,81 +0,0 @@
/** Shared generative-mcpapps identity. Plugin-tree presence is not installation. */
export const GENERATIVE_MCPAPPS_SKILL = 'generative-mcpapps';
/** Conventional relative roots only. Never expand $HOME or dump host `root.path`. */
export const CONVENTIONAL_SKILL_ROOTS = ['.dsh/skills', '.agents/skills'] as const;
/** Copy source relative to the plugin / checkout, not an absolute pack path. */
export const SKILL_PACK_RELATIVE = `skills/${GENERATIVE_MCPAPPS_SKILL}`;
export type SkillRootSource =
| 'project-dsh'
| 'project-agents'
| 'user-dsh'
| 'user-agents'
| 'custom'
| 'bundled'
| (string & {});
export interface SkillRootInfo {
readonly source: SkillRootSource;
readonly path: string;
readonly present?: boolean;
}
export interface HostSkillStatus {
readonly name: typeof GENERATIVE_MCPAPPS_SKILL;
readonly installed: boolean;
readonly via: 'skills.list' | 'skill-root' | null;
readonly roots: readonly SkillRootInfo[];
/** Plugin-shipped pack path for copy guidance. Not a harness skill root. */
readonly packPath?: string;
}
export function skillNameMatches(name: unknown): boolean {
return typeof name === 'string' && name === GENERATIVE_MCPAPPS_SKILL;
}
export function skillListIncludes(entries: readonly { readonly name?: string }[] | undefined): boolean {
return Array.isArray(entries) && entries.some(entry => skillNameMatches(entry?.name));
}
/** Directory bundle `name/SKILL.md` or flat `name.md` at a scanned root. */
export function skillRootEntryMatches(entryName: string): boolean {
return entryName === GENERATIVE_MCPAPPS_SKILL || entryName === `${GENERATIVE_MCPAPPS_SKILL}.md`;
}
export function skillsFromListResult(result: unknown): { name?: string }[] {
if (Array.isArray(result)) return result;
if (result === null || typeof result !== 'object') return [];
const record = result as {
ok?: boolean;
value?: { skills?: unknown } | unknown;
skills?: unknown;
};
if (record.ok === false) return [];
if (Array.isArray(record.skills)) return record.skills as { name?: string }[];
if (record.value && typeof record.value === 'object') {
const value = record.value as { skills?: unknown };
if (Array.isArray(value.skills)) return value.skills as { name?: string }[];
if (Array.isArray(record.value)) return record.value as { name?: string }[];
}
return [];
}
export function publicSkillRoots(): readonly SkillRootInfo[] {
return CONVENTIONAL_SKILL_ROOTS.map(path => ({ source: 'conventional', path }));
}
/**
* Strip host home / pack absolutes before anything user-facing (HTTP or Settings).
* Detection still uses the raw scan; this is the public face.
*/
export function toPublicSkillStatus(status: HostSkillStatus): HostSkillStatus {
return {
name: status.name,
installed: status.installed,
via: status.via,
roots: publicSkillRoots(),
};
}

View File

@ -18,7 +18,7 @@ test('logger redacts authorization headers, tokens, and secret-looking query val
'x-request-id': 'req-1',
accept: 'application/json',
},
url: `/better-display/skill-status?cwd=/work&token=${SECRET}&api_key=${SECRET}&password=${SECRET}`,
url: `/better-display/reveal?cwd=/work&token=${SECRET}&api_key=${SECRET}&password=${SECRET}`,
token: SECRET,
access_token: SECRET,
});

View File

@ -3,7 +3,7 @@ import { IncomingMessage, ServerResponse } from 'node:http';
import { Socket } from 'node:net';
import { test } from 'vitest';
import { apply } from '../src/host.js';
import { metricsPayload, recordRouteDuration, recordRouteHit, ROUTE_METRICS, ROUTE_REVEAL, ROUTE_SKILL_STATUS } from '../src/metrics.js';
import { metricsPayload, recordRouteDuration, recordRouteHit, ROUTE_METRICS, ROUTE_REVEAL } from '../src/metrics.js';
test('route hit counter increments', () => {
const before = metricsPayload();
@ -29,7 +29,7 @@ test('GET /better-display/metrics returns the incremented route counter', () =>
},
effect(run: () => void) { run(); },
} as never, { flags: { readerEnabled: true } });
assert.deepEqual(routes.map(route => route.path).sort(), [ROUTE_METRICS, ROUTE_REVEAL, ROUTE_SKILL_STATUS].sort());
assert.deepEqual(routes.map(route => route.path).sort(), [ROUTE_METRICS, ROUTE_REVEAL].sort());
const metrics = routes.find(route => route.path === ROUTE_METRICS);
assert.ok(metrics);
const before = metricsPayload().counters.dsh_better_display_route_hits_total[ROUTE_METRICS] ?? 0;

View File

@ -1,63 +0,0 @@
import { test } from 'vitest';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { en, zh } from '../src/client/settings-copy.ts';
import { CONVENTIONAL_SKILL_ROOTS, GENERATIVE_MCPAPPS_SKILL } from '../src/skill-status.ts';
import { shortestInstallCommand } from '../src/client/skill-status.ts';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
/** User-facing surfaces must never print home/profile absolutes. */
const LEAKED_ABSOLUTE_PATH = /\/Users\/|[A-Za-z]:\\|(?:^|[\s"'`])\/home\/|\$HOME\b|\$DSH_HOME\b|~\//;
function installGuidanceSurface(): string {
return [
...Object.values(en),
...Object.values(zh),
shortestInstallCommand({
packPath: '/Users/cola/plugin/skills/generative-mcpapps',
roots: [
{ source: 'user-dsh', path: '/Users/cola/.dsh/skills' },
{ source: 'user-agents', path: 'C:\\Users\\cola\\.agents\\skills' },
],
}),
...CONVENTIONAL_SKILL_ROOTS,
].join('\n');
}
test('install guidance names only relative skill roots', () => {
const surface = installGuidanceSurface();
assert.match(surface, /\.dsh\/skills/);
assert.match(surface, /\.agents\/skills/);
assert.match(surface, new RegExp(GENERATIVE_MCPAPPS_SKILL));
assert.doesNotMatch(surface, LEAKED_ABSOLUTE_PATH);
assert.doesNotMatch(surface, /\/Users\//);
assert.doesNotMatch(surface, /C:\\/);
});
test('Settings dictionaries mention conventional roots and the skill folder', () => {
for (const copy of [en, zh]) {
const blob = `${copy.skillInstall}\n${copy.skillUnavailable}`;
assert.match(blob, /\.dsh\/skills/);
assert.match(blob, /\.agents\/skills/);
assert.match(blob, /generative-mcpapps/);
assert.doesNotMatch(blob, LEAKED_ABSOLUTE_PATH);
}
});
test('committed Settings UI copy and command stay relative', () => {
const client = readFileSync(resolve(root, 'lib/client.js'), 'utf8');
const section = readFileSync(resolve(root, 'src/client/SettingsSection.tsx'), 'utf8');
assert.match(section, /CONVENTIONAL_SKILL_ROOTS/);
assert.doesNotMatch(section, /root\.path/);
assert.doesNotMatch(section, /shortestInstallCommand\(skill\)/);
assert.match(client, /\.dsh\/skills/);
assert.match(client, /\.agents\/skills/);
assert.doesNotMatch(client, /mkdir -p "\$DSH_HOME\/skills"/);
assert.doesNotMatch(client, /status\.packPath \?\?/);
assert.doesNotMatch(client, /root\.source, ": ", root\.path/);
assert.doesNotMatch(client, /\/Users\//);
assert.doesNotMatch(client, /C:\\\\/);
});

View File

@ -1,137 +0,0 @@
import { test } from 'vitest';
import assert from 'node:assert/strict';
import { mkdir, mkdtemp, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import {
CONVENTIONAL_SKILL_ROOTS,
GENERATIVE_MCPAPPS_SKILL,
SKILL_PACK_RELATIVE,
skillListIncludes,
skillNameMatches,
skillRootEntryMatches,
skillsFromListResult,
toPublicSkillStatus,
} from '../src/skill-status.ts';
import {
projectSkillRoots,
rootHasGenerativeMcpapps,
scanGenerativeMcpappsStatus,
userSkillRoots,
} from '../src/skill-roots.ts';
import { detectGenerativeMcpappsSkill, firstSessionId, shortestInstallCommand } from '../src/client/skill-status.ts';
test('only the kebab-case skill name counts as installed', () => {
assert.equal(skillNameMatches(GENERATIVE_MCPAPPS_SKILL), true);
assert.equal(skillNameMatches('other'), false);
assert.equal(skillRootEntryMatches('generative-mcpapps'), true);
assert.equal(skillRootEntryMatches('generative-mcpapps.md'), true);
assert.equal(skillRootEntryMatches('skills'), false);
assert.equal(skillListIncludes([{ name: 'generative-mcpapps' }]), true);
assert.equal(skillListIncludes(skillsFromListResult({ ok: true, value: { skills: [{ name: 'generative-mcpapps' }] } })), true);
});
test('plugin-tree skills/ is not a harness skill root', () => {
const roots = [
...projectSkillRoots('/plugin/dsh-better-chat'),
...userSkillRoots({ DSH_HOME: '/home/me/.dsh', DSH_AGENTS_HOME: '/home/me/.agents' }, '/home/me'),
];
// Paths are OS-native (path.join), so assert on their normalized tails.
const paths = roots.map(root => root.path.replaceAll('\\', '/'));
assert.ok(paths[0]?.endsWith('/plugin/dsh-better-chat/.dsh/skills'), paths[0]);
assert.ok(paths[1]?.endsWith('/plugin/dsh-better-chat/.agents/skills'), paths[1]);
assert.ok(paths[2]?.endsWith('/home/me/.dsh/skills'), paths[2]);
assert.ok(paths[3]?.endsWith('/home/me/.agents/skills'), paths[3]);
assert.equal(roots.some(root => root.path.replaceAll('\\', '/').endsWith('/dsh-better-chat/skills')), false);
});
test('a real user skill root with the pack is installed; the plugin pack path is not', async () => {
const emptyHome = await mkdtemp(join(tmpdir(), 'dsh-bd-empty-'));
const skillHome = await mkdtemp(join(tmpdir(), 'dsh-bd-skill-'));
const userRoot = join(skillHome, '.dsh', 'skills', 'generative-mcpapps');
await mkdir(userRoot, { recursive: true });
await writeFile(join(userRoot, 'SKILL.md'), '---\nname: generative-mcpapps\ndescription: x\n---\n');
const missing = await scanGenerativeMcpappsStatus({
home: emptyHome,
env: {},
packPath: '/plugin/dsh-better-display/skills/generative-mcpapps',
});
const found = await scanGenerativeMcpappsStatus({
home: skillHome,
env: { DSH_HOME: join(skillHome, '.dsh') },
packPath: '/plugin/dsh-better-display/skills/generative-mcpapps',
});
assert.equal(await rootHasGenerativeMcpapps('/plugin/dsh-better-display/skills'), false);
assert.equal(missing.installed, false);
assert.equal(found.installed, true);
assert.equal(found.via, 'skill-root');
assert.equal(found.packPath, '/plugin/dsh-better-display/skills/generative-mcpapps');
});
test('client detect snapshot never carries host packPath or home roots', async () => {
const status = await detectGenerativeMcpappsSkill({
fetchHostStatus: async () => ({
name: 'generative-mcpapps',
installed: false,
via: null,
packPath: '/Users/cola/plugin/skills/generative-mcpapps',
roots: [{ source: 'user-dsh', path: '/Users/cola/.dsh/skills', present: false }],
}),
});
assert.equal(status.packPath, undefined);
assert.deepEqual(status.roots.map(root => root.path), [...CONVENTIONAL_SKILL_ROOTS]);
assert.equal(status.roots.some(root => /\/Users\/|[A-Za-z]:\\/.test(root.path)), false);
});
test('skills/list wins when the registry can see the skill', async () => {
const status = await detectGenerativeMcpappsSkill({
fetchHostStatus: async () => ({
name: 'generative-mcpapps',
installed: false,
via: null,
roots: [{ source: 'user-dsh', path: '/tmp/.dsh/skills', present: false }],
}),
listRemoteSkills: async () => [{ name: 'generative-mcpapps' }],
});
assert.equal(status.installed, true);
assert.equal(status.via, 'skills.list');
});
test('public skill status strips packPath and host home absolutes', () => {
const published = toPublicSkillStatus({
name: 'generative-mcpapps',
installed: false,
via: null,
packPath: '/Users/cola/.dsh/plugins/skills/generative-mcpapps',
roots: [
{ source: 'user-dsh', path: '/Users/cola/.dsh/skills', present: false },
{ source: 'user-agents', path: 'C:\\Users\\cola\\.agents\\skills', present: false },
],
});
assert.equal(published.packPath, undefined);
assert.deepEqual(published.roots.map(root => root.path), [...CONVENTIONAL_SKILL_ROOTS]);
assert.equal(published.roots.some(root => /\/Users\/|[A-Za-z]:\\/.test(root.path)), false);
});
test('install command uses conventional relative roots only', () => {
const command = shortestInstallCommand({
packPath: '/opt/plugin/skills/generative-mcpapps',
roots: [{ source: 'user-dsh', path: '/home/me/.dsh/skills' }],
});
assert.match(command, /mkdir -p \.dsh\/skills/);
assert.match(command, new RegExp(`cp -R ${SKILL_PACK_RELATIVE.replace('/', '\\/')}`));
assert.match(command, /generative-mcpapps/);
assert.doesNotMatch(command, /\/Users\//);
assert.doesNotMatch(command, /[A-Za-z]:\\/);
assert.doesNotMatch(command, /\/home\//);
assert.doesNotMatch(command, /\$HOME|\$DSH_HOME/);
assert.doesNotMatch(command, /\/opt\//);
});
test('firstSessionId reads ids or byId keys', () => {
assert.equal(firstSessionId({ ids: ['a', 'b'] }), 'a');
assert.equal(firstSessionId({ byId: { z: {} } }), 'z');
assert.equal(firstSessionId(undefined), undefined);
});