Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(skillhub): associate market copies by registry slug
xd-bobo1b52f5eaf824
diff --git a/apps/desktop/src/main/skillhub/__tests__/scanner.test.ts b/apps/desktop/src/main/skillhub/__tests__/scanner.test.tsindex fc482bf6e1..83ee2f8413 100644--- a/apps/desktop/src/main/skillhub/__tests__/scanner.test.ts+++ b/apps/desktop/src/main/skillhub/__tests__/scanner.test.ts@@ -22,6 +22,7 @@ import {writeSkillFile,} from '../scanner';import type { Maker } from '@cindy/maker-core';+import { registryService, type StoredInstall } from '../registry';const tempRoots: string[] = [];@@ -80,6 +81,34 @@ function createSymlinkedSkill() {}describe('scanAllSkills', () => {+ it('projects the registry slug joined by physical path without replacing native directory names', async () => {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'skillhub-registry-slug-'));+ tempRoots.push(root);+ const paths = [path.join(root, '.agents', 'skills', 'Foo'), path.join(root, '.claude', 'skills', 'foo')];+ for (const skillPath of paths) {+ fs.mkdirSync(skillPath, { recursive: true });+ fs.writeFileSync(path.join(skillPath, 'SKILL.md'), '---\nname: fixture\n---\nFixture');+ }+ const entry = { catalogScope: 'market', version: '1.0.0' } as StoredInstall;+ vi.mocked(registryService.listAllInstalls).mockResolvedValueOnce([+ { skillName: 'foo', installPath: paths[0], entry },+ { skillName: 'different-skill', installPath: paths[1], entry },+ ]);+ const maker = { listCustomizations: vi.fn(async () => ({ errors: [], items: paths.map((absolutePath) => ({+ engine: 'claude-code', kind: 'skill', scope: 'user', name: 'fixture', absolutePath,+ mdPath: path.join(absolutePath, 'SKILL.md'), files: [],+ })) })) } as unknown as Maker;+ const result = await scanAllSkills({}, maker);+ expect(result.skills).toHaveLength(2);+ for (const [index, skillPath] of paths.entries()) {+ const physical = fs.realpathSync(skillPath);+ expect(result.skills.find((skill) => skill.absolutePath === physical)).toMatchObject({+ name: path.basename(physical), registryEntry: entry,+ registrySkillName: index === 0 ? 'foo' : 'different-skill',+ });+ }+ });+it('projects plugin ownership and prevents standalone uninstall for snapshot links', async () => {const root = fs.mkdtempSync(path.join(os.tmpdir(), 'skillhub-plugin-source-'));tempRoots.push(root);diff --git a/apps/desktop/src/main/skillhub/scanner.ts b/apps/desktop/src/main/skillhub/scanner.tsindex b162d23bd0..a64e382fb9 100644--- a/apps/desktop/src/main/skillhub/scanner.ts+++ b/apps/desktop/src/main/skillhub/scanner.ts@@ -109,6 +109,8 @@ export interface Skill {* 仅 kind=skill 才会填;command/agent 始终 null。*/registryEntry: StoredInstall | null;+ /** Original market slug from the registry joined by physical path. */+ registrySkillName?: string;}export type SourceStatus =@@ -356,15 +358,15 @@ export async function scanAllSkills(log.warn('registry list failed, fallback to empty:', err);registryEntries = [];}- const registryByPath = new Map<string, StoredInstall>();+ const registryByPath = new Map<string, (typeof registryEntries)[number]>();const registryLiveKeys = new Map<string, string>();for (const r of registryEntries) {const installPathKey = path.normalize(r.installPath);- registryByPath.set(installPathKey, r.entry);+ registryByPath.set(installPathKey, r);registryLiveKeys.set(installPathKey, installPathKey);try {const realInstallPathKey = path.normalize(fs.realpathSync(r.installPath));- registryByPath.set(realInstallPathKey, r.entry);+ registryByPath.set(realInstallPathKey, r);registryLiveKeys.set(installPathKey, realInstallPathKey);} catch {// If the path no longer exists, keep the original key so orphan cleanup@@ -383,7 +385,9 @@ export async function scanAllSkills(const normPath = path.normalize(resolved);// path 是物理唯一标识;允许 registry skillName 和 scanner directory name 不一致// (历史数据或 frontmatter name 与目录名不同步时会出现)- s.registryEntry = registryByPath.get(normPath) ?? null;+ const registered = registryByPath.get(normPath);+ s.registryEntry = registered?.entry ?? null;+ s.registrySkillName = registered?.skillName;liveRealPaths.add(normPath);}diff --git a/apps/desktop/src/renderer/features/skillhub/components/MarketLocalSkills.tsx b/apps/desktop/src/renderer/features/skillhub/components/MarketLocalSkills.tsxindex 203d2c8646..8c3e9d0639 100644--- a/apps/desktop/src/renderer/features/skillhub/components/MarketLocalSkills.tsx+++ b/apps/desktop/src/renderer/features/skillhub/components/MarketLocalSkills.tsx@@ -15,14 +15,14 @@ export function MarketLocalSkills({ skill }: {const { t } = useTranslation();const { skills } = useSkillhub();const [selectedId, setSelectedId] = useState<string | null>(null);- // The directory keeps its native casing even when its registry slug does not.- const marketName = skill.name.toLowerCase();const copies = skills.filter((local) => {- const localName = local.name.toLowerCase();- if (local.kind !== 'skill' || localName !== marketName) return false;+ // Use the physically joined registry identity; casing alone cannot prove+ // ownership on case-sensitive volumes. Old scans keep exact-name matching.+ const localName = local.registryEntry ? local.registrySkillName ?? local.name : local.name;+ if (local.kind !== 'skill' || localName !== skill.name) return false;return local.registryEntry? skillhubCatalogKey(localName, local.registryEntry.catalogScope)- === skillhubCatalogKey(marketName, skill.catalogScope)+ === skillhubCatalogKey(skill.name, skill.catalogScope): skill.isMine;});if (copies.length === 0) return null;diff --git a/apps/desktop/src/renderer/features/skillhub/components/__tests__/MarketLocalSkills.test.tsx b/apps/desktop/src/renderer/features/skillhub/components/__tests__/MarketLocalSkills.test.tsxindex db6443fc9c..7308a73078 100644--- a/apps/desktop/src/renderer/features/skillhub/components/__tests__/MarketLocalSkills.test.tsx+++ b/apps/desktop/src/renderer/features/skillhub/components/__tests__/MarketLocalSkills.test.tsx@@ -88,7 +88,7 @@ describe('market Skill details', () => {describe('market installed location matching', () => {it.each(['market', 'team'] as const)('manages a case-variant local directory in the %s catalog', async (catalogScope) => {- const copy = { ...local, name: 'Gws-Calendar', absolutePath: '/fixture/.agents/skills/Gws-Calendar',+ const copy = { ...local, name: 'Gws-Calendar', registrySkillName: market.name, absolutePath: '/fixture/.agents/skills/Gws-Calendar',registryEntry: { ...local.registryEntry!, catalogScope } };mocks.skills = [copy];render(<MarketLocalSkills skill={{ ...market, catalogScope }} />);@@ -142,17 +142,29 @@ describe('market installed location matching', () => {it('does not manage same-name copies from another catalog or unregistered third-party copies', () => {mocks.skills = [- { ...local, name: 'Gws-Calendar', registryEntry: { ...local.registryEntry!, catalogScope: 'team' } },+ { ...local, name: 'Gws-Calendar', registrySkillName: market.name, registryEntry: { ...local.registryEntry!, catalogScope: 'team' } },{ ...local, name: 'Gws-Calendar', absolutePath: '/untracked', registryEntry: null },- { ...local, name: 'Gws-Calendar', absolutePath: '/native', registryEntry: { ...local.registryEntry!, catalogScope: undefined } },+ { ...local, name: 'Gws-Calendar', registrySkillName: market.name, absolutePath: '/native', registryEntry: { ...local.registryEntry!, catalogScope: undefined } },];render(<MarketLocalSkills skill={market} />);expect(screen.queryByRole('switch')).toBeNull();});it('includes an owned unregistered copy and keeps package-owned copies toggleable', () => {- mocks.skills = [{ ...local, name: 'Gws-Calendar', registryEntry: null, canUninstall: false }];+ mocks.skills = [{ ...local, registryEntry: null, canUninstall: false }];render(<MarketLocalSkills skill={{ ...market, isMine: true }} />);expect(screen.getByRole('switch')).toBeTruthy();});++ it('keeps unrelated case-sensitive copies separate even on an owned market page', () => {+ mocks.skills = [+ { ...local, name: 'Gws-Calendar', registryEntry: null },+ { ...local, name: 'Gws-Calendar', registrySkillName: 'other-market-skill' },+ { ...local, name: market.name, registrySkillName: 'other-market-skill' },+ { ...local, name: 'Gws-Calendar' }, // Old scan without registry slug: exact match only.+ ];+ render(<MarketLocalSkills skill={{ ...market, isMine: true }} />);+ expect(screen.queryByRole('switch')).toBeNull();+ expect(screen.queryByRole('button', { name: 'skillhub.management.moreLabel' })).toBeNull();+ });});diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.tsindex 73fb8f203b..a7cb1fd538 100644--- a/apps/desktop/src/renderer/vite-env.d.ts+++ b/apps/desktop/src/renderer/vite-env.d.ts@@ -6684,6 +6684,8 @@ interface SkillhubSkill {* Only set for kind=skill; command/agent always null.*/registryEntry: StoredInstall | null;+ /** Original market slug from the registry joined by physical path. */+ registrySkillName?: string;}type SkillhubSourceStatus =diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex 784d7d3656..7d78b00abc 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -52,6 +52,9 @@同源多副本按范围和最近项目匹配;旧路径无法唯一消歧时不任意选择副本。SkillHub项目目录包含置顶任务和已创建但尚未发消息的项目任务,不沿用侧栏的展示排除规则;仍只扫描本地目录,并由 Main 的项目目录白名单复核。+ 扫描结果可选携带按物理路径关联的 `registrySkillName`,市场详情按此原始注册 slug+ 与 catalog scope 匹配;保留实际目录名用于本地展示。未注册或旧扫描缺少该字段时,+ 只按精确名称匹配,不用大小写折叠推断两个目录属于同一市场技能。源目录形状不能单独证明归属:同一分组必须有直接、非符号链接的发现入口,才可按独立实体卸载;检查覆盖入口、发现根及引擎配置目录各级,拒绝其中的符号链接,保留发现布局以上的已跟踪项目别名兼容。外部入口移除及清理重试保留源文件和按物理身份共享的