From 0ff37eaafe9048572c9a99bb0eedad42a41a0538 Mon Sep 17 00:00:00 2001 From: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> Date: Thu, 29 Oct 2026 14:16:47 +0800 Subject: [PATCH] fix(dsh): clarify installed skill cards and metadata Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com> --- .../installed-update-check-design.md | 7 +- plugins/dsh/README.en.md | 2 +- plugins/dsh/README.md | 2 +- plugins/dsh/bun.lock | 1 + plugins/dsh/package.json | 1 + plugins/dsh/src/client/installed-skills.tsx | 54 ++++++++--- plugins/dsh/src/client/installed-styles.tsx | 22 +++-- .../dsh/src/client/native-control-styles.tsx | 4 + plugins/dsh/src/client/ui.tsx | 8 ++ plugins/dsh/src/host/index.ts | 6 +- .../dsh/src/host/installed-presentation.ts | 89 +++++++++++++++++++ plugins/dsh/src/host/types.ts | 2 + .../dsh/test/installed-presentation.test.ts | 54 +++++++++++ plugins/dsh/test/installed-references.test.ts | 28 ++++-- .../installed-update-context-probe.mjs | 2 +- .../installed-update-overview-probe.mjs | 12 +-- .../dsh/test/skill-primary-actions.test.tsx | 30 ++++++- 17 files changed, 286 insertions(+), 38 deletions(-) create mode 100644 plugins/dsh/src/host/installed-presentation.ts create mode 100644 plugins/dsh/test/installed-presentation.test.ts diff --git a/openspec/changes/add-dsh-native-plugin/installed-update-check-design.md b/openspec/changes/add-dsh-native-plugin/installed-update-check-design.md index 6c5c34bed..0f788acbb 100644 --- a/openspec/changes/add-dsh-native-plugin/installed-update-check-design.md +++ b/openspec/changes/add-dsh-native-plugin/installed-update-check-design.md @@ -4,7 +4,7 @@ 用户主动检查当前来源、当前工作区可见的受管理安装。无进入页面自动扫描、后台轮询、批量执行、自动覆盖或新增Registry/SaaS协议。日常仍按技能聚合;实际检查/更新以精确itemKey为单位。 ## 交互 -已安装页提供检查更新与进度n/m;结果渐进呈现,不逐项弹通知,不阻断浏览。汇总可更新技能数与检查失败项,支持全部/可更新/检查失败筛选和失败重试,关键词可叠加。已最新无卡片冗余文字;可更新显示目标版本摘要或多位置有更新,查看更新进入现有详情右侧,保持使用技能主动作。位置结果独立:同技能只计一个可更新技能,但不同位置版本与确认分开。blocked显示需处理,不算可执行更新;unavailable/错误算检查失败,不伪报已最新。 +已安装页提供检查更新与进度n/m;结果渐进呈现,不逐项弹通知,不阻断浏览。汇总可更新技能数与检查失败项,支持全部/可更新/检查失败筛选和失败重试,关键词可叠加。已最新无卡片冗余文字;卡片右上角最多展示两个状态标签:安装状态仅在已停用或待核验时展示;更新标签按检查失败、需处理、可更新优先级展示一项,单位置可更新保留目标版本,多位置统一显示“可更新”,其余细节进入详情查看。正常已安装不重复标记。卡片头部组合头像、名称、命名空间与右侧状态;无状态时不预留独立标签行。保持紧凑间距和同排按钮对齐,窄屏下状态与长名称不能重叠。点击卡片(支持键盘)进入现有详情右侧,移除重复的管理安装、详情与查看更新按钮;仅可用技能保留使用技能主动作,点击使用不触发详情跳转。返回列表恢复焦点、滚动和有效筛选。位置结果独立:同技能只计一个可更新技能,但不同位置版本与确认分开。blocked显示需处理,不算可执行更新;unavailable/错误算检查失败,不伪报已最新。 ## 技术边界 统一检查使用DSH私有只读检查轮次;保留原单项checkUpdate和精确位置prepareUpgrade事务,不另造批量写入API。客户端有界并发只读检查;重入禁用,取消/离开/切来源/会话/工作区时中止在途并丢弃迟到结果。结果仅适用于同一来源会话及同一安装引用。库存变更、更新/卸载/启停导致旧itemKey失效时清除对应结果。详情返回保留仍有效结果与筛选;详情更新执行始终重新核验,不把检查结果当授权。错误/空库存/不完整库存明确表达,不能全局显示全部已最新。 @@ -21,3 +21,8 @@ 轮次引用只由Host生成并绑定真实会话/工作区/来源/文件服务/运行时,客户端不提供路径。数量、生命周期和并发有界,结束、取消、过期和销毁释放资源;单个位置等待取消不误杀同技能其他位置共享请求。旧轮次结果不得流入新上下文,检查快照不能作为写入授权。 性能验收覆盖10/100/500处安装,分别记录库存读取、目标核验、远端请求次数和耗时;以读取次数和工作量接近线性为主要回归断言,不使用机器相关固定耗时阈值。真实DSH验证新私有协议、渐进结果、取消和原逐项更新确认。 + +## 已安装卡片的信息与展示来源 +已安装卡片沿用浏览卡片的头像/标题/命名空间、内容、底部操作层次,保留真实简介和已安装版本。安装位置版本不同时展示多版本摘要,不把最新市场版本冒充本地版本。只保留使用技能主操作与整卡详情入口;最多两个状态标签,可更新使用柔和蓝色、已停用中性灰、失败/需处理琥珀色,明暗主题均可读且不只靠颜色表达。窄卡状态自然换行,不挤掉标题。无摘要时展示简短缺省,不编造用途。 + +列表展示信息从可信受管理安装位置的 SKILL.md 或 SKILL.md.disabled 读取,返回可选 displayName/summary。固定文件、普通文件、有界读取、拒绝符号链接和异常路径;YAML解析仅抽取有界字符串,不执行标签或内容。失败仅省略展示字段,不改变安装状态、完整性判定或来源。展示字段不进入安装引用、授权和更新快照。只在列表读取,保持一次库存读取,无逐卡网络详情请求、全目录摘要哈希或影响检查更新的快照热路径;会话、来源、根目录变化仍在返回前核验。 diff --git a/plugins/dsh/README.en.md b/plugins/dsh/README.en.md index 84d0b326c..f079f89c9 100644 --- a/plugins/dsh/README.en.md +++ b/plugins/dsh/README.en.md @@ -138,7 +138,7 @@ Each visibility setting accepts `auto`, `show` or `hide`. Auto detects actual an - Browse supports search, server sorting, real labels and explicit **Load more**, normally 12 results per page. A first-page 404/405 can fall back to bounded legacy search, with an explicit pagination/sorting limitation. A failed label filter never silently returns unfiltered results. - Details show fixed-version documentation and optional tabs. Select a downloadable version before confirming installation. Existing-target protection remains; skill downgrades are not supported. -- Installed skills are grouped by identity and support keyword filtering. Open “管理安装” for independent location rows and precise confirmed operations; missing directories retain stale-record cleanup. +- Installed skills are grouped by identity and support keyword filtering. Click an installed card to open details; usable skills retain only the use action. Cards show locally installed names, summaries and actual installed versions, marking differing copies as multiple versions. Up to two semantic badges show disabled/unverified installation and update status (blue for updates, gray for disabled, amber for warnings), without a redundant installed label. Details provide independent location rows and precise confirmed operations; missing directories retain stale-record cleanup. - `astron_skillhub_search` only searches. Result cards provide a detail action; the drawer offers explicit installation confirmation. - An explicit request to install a uniquely selected result does not require opening the drawer first. `astron_skillhub_install` verifies the search-time version and content snapshot. It accepts a `selectionRef` or a full coordinate, exclusively, and a `user`/`project` scope. Expired or ambiguous references are rejected without switching to current latest. diff --git a/plugins/dsh/README.md b/plugins/dsh/README.md index f6130313f..2bdc52d90 100644 --- a/plugins/dsh/README.md +++ b/plugins/dsh/README.md @@ -138,7 +138,7 @@ Loader entry ID 为 `astron-skillhub`;`skillhub` 是 Host/Remote 服务名。 - **浏览技能**:搜索、服务端排序、真实标签筛选、点击加载更多。新目录接口每批 12 项;旧来源首批 404/405 可回退受限搜索,明确提示不支持分页和排序。选中标签失败不会退回未过滤结果。 - **技能详情**:查看文档、版本和可选模块;可“查看此版本”后确认安装指定的可下载版本。已有其他版本时保留覆盖保护,不执行降级。 -- **已安装**:按技能聚合并支持关键词过滤。默认提供使用与管理安装;详情右侧按位置显示版本、状态和操作,升级、启停与卸载均只影响确认的位置。目录缺失时仍可清理失效记录。 +- **已安装**:按技能聚合并支持关键词过滤。点击卡片进入详情,可用技能仅保留“使用技能”按钮;展示本地技能文件中的名称、摘要与实际安装版本;不同位置版本不同时明确标注多个版本。右上角最多显示安装异常/停用与更新状态两个标签(可更新为浅蓝、停用为灰、异常为琥珀色),正常已安装不重复标记。详情右侧按位置显示版本、状态和操作,升级、启停与卸载均只影响确认的位置。目录缺失时仍可清理失效记录。 - **对话搜索**:`astron_skillhub_search` 只搜索,不安装或执行技能。结果提供明确详情动作;详情抽屉可确认安装。 - **对话安装**:用户明确要求安装唯一搜索结果时,不必先打开详情。`astron_skillhub_install` 核验搜索时的精确版本和快照;接受 `selectionRef` 或完整坐标,二者互斥,范围为 `user`/`project`。过期或歧义引用拒绝执行,不改装当前 latest。 diff --git a/plugins/dsh/bun.lock b/plugins/dsh/bun.lock index 6873c341b..b17ddab0f 100644 --- a/plugins/dsh/bun.lock +++ b/plugins/dsh/bun.lock @@ -16,6 +16,7 @@ "class-variance-authority": "0.7.1", "react-markdown": "10.1.0", "rehype-sanitize": "6.0.0", + "yaml": "2.9.1", "zod": "4.4.3", }, "devDependencies": { diff --git a/plugins/dsh/package.json b/plugins/dsh/package.json index 98b6ada22..885eea412 100644 --- a/plugins/dsh/package.json +++ b/plugins/dsh/package.json @@ -100,6 +100,7 @@ "class-variance-authority": "0.7.1", "react-markdown": "10.1.0", "rehype-sanitize": "6.0.0", + "yaml": "2.9.1", "zod": "4.4.3" }, "devDependencies": { diff --git a/plugins/dsh/src/client/installed-skills.tsx b/plugins/dsh/src/client/installed-skills.tsx index 420ed12b7..6d50de3b8 100644 --- a/plugins/dsh/src/client/installed-skills.tsx +++ b/plugins/dsh/src/client/installed-skills.tsx @@ -14,7 +14,7 @@ import { DetailContent } from './detail-content.js'; import { RemovalHistory, type RemovalServices } from './removal-control.js'; import { InstalledStyles } from './installed-styles.js'; import type { InstalledNavigation } from './installed-navigation.js'; -import { Button, Card, CardHeader, CardContent, CardFooter } from './ui.js'; +import { Badge, Button, Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from './ui.js'; import { SkillAvatar } from './skill-card.js'; export interface InstalledServices extends UpgradeServices, RemovalServices { @@ -30,6 +30,23 @@ export interface InstalledServices extends UpgradeServices, RemovalServices { checkUpdate(sourceRevision: string, itemKey: string, signal: AbortSignal): Promise>; } type Item = InstalledSkillList['items'][number]; +export function installedCardBadges(items: Item[], results: Record, verified: boolean) { + const badges: { label: string; tone: 'neutral' | 'warning' | 'info' }[] = []; + const summary = verified ? skillInstallationSummary(items) : '安装待核验'; + if (summary !== '已安装') badges.push({ label: summary, tone: summary === '已停用' ? 'neutral' : 'warning' }); + if (items.some(item => updateFailed(results[item.itemKey]))) badges.push({ label: '检查失败', tone: 'warning' }); + else if (items.some(item => results[item.itemKey]?.state === 'blocked')) badges.push({ label: '更新需处理', tone: 'warning' }); + else if (items.some(item => results[item.itemKey]?.state === 'upgradable')) { + const result = results[items[0]!.itemKey]; + badges.push({ label: items.length > 1 ? '可更新' : `可更新至 ${result && 'candidateVersion' in result ? result.candidateVersion ?? '新版本' : '新版本'}`, tone: 'info' }); + } + return badges; +} +export function installedCardVersions(items: Item[]) { + const versions = [...new Set(items.map(item => item.version))]; + return { label: versions.length === 1 ? `v${versions[0]}` : `多个版本 · ${versions.map(version => `v${version}`).join(' / ')}`, + title: items.map(item => `${item.scope === 'user' ? '所有项目' : '仅此项目'} · v${item.version}`).join(';') }; +} const noContext = { getSnapshot: () => 0, subscribe: () => () => {} }; export function InstalledSkills({ services, sourceRevision, source, remote, modes, scrollContainer, navigation, onInstall }: { services: InstalledServices; sourceRevision: string; source: string; remote: TypertRemoteNamespaceMap['skillhub']; modes: SkillHubConfig['detailTabs']; @@ -44,6 +61,7 @@ export function InstalledSkills({ services, sourceRevision, source, remote, mode const heading = useRef(null); const refreshButton = useRef(null); const trigger = useRef(null); + const triggerKey = useRef(null); const listScroll = useRef(navigation.listScroll); useLayoutEffect(() => { Object.assign(navigation, { scope: 'all', keyword, selected, intent: 'detail', listScroll: listScroll.current }); }); useLayoutEffect(() => { @@ -69,7 +87,7 @@ export function InstalledSkills({ services, sourceRevision, source, remote, mode const verified = !!query.data && !query.isError && query.data.complete && !query.data.unavailable.length; const records = (identity: Item) => query.data?.items.filter(item => item.namespace === identity.namespace && item.slug === identity.slug) ?? [identity]; const actions = (items: Item[], label?: string) => { const identity = items[0]; if (identity) { listScroll.current = scrollContainer.current?.scrollTop ?? 0; setSelected(identity); } } : undefined} label={label} summaryVisible={!label} />; + select={services.management?.selectSkillUse} useSkill={services.skillUse} label={label} summaryVisible={!label} />; const [results, setResults] = useState>({}); const [filter, setFilter] = useState('all'); @@ -153,7 +171,7 @@ export function InstalledSkills({ services, sourceRevision, source, remote, mode ; const term = keyword.trim().toLocaleLowerCase(); - const groups = allGroups.filter(items => filter === 'all' || items.some(item => filter === 'updates' ? results[item.itemKey]?.state === 'upgradable' : updateFailed(results[item.itemKey]))).filter(items => !term || items.some(item => `@${item.namespace}/${item.slug} ${item.version}`.toLocaleLowerCase().includes(term))); + const groups = allGroups.filter(items => filter === 'all' || items.some(item => filter === 'updates' ? results[item.itemKey]?.state === 'upgradable' : updateFailed(results[item.itemKey]))).filter(items => !term || items.some(item => `@${item.namespace}/${item.slug} ${item.displayName ?? ''} ${item.version}`.toLocaleLowerCase().includes(term))); return