Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(skillhub): retain skill state on rename and gate draft details
xd-bobo2564e7841e53
diff --git a/apps/desktop/help-knowledge/skills.md b/apps/desktop/help-knowledge/skills.mdindex 05f4d83b05..4927ea56c5 100644--- a/apps/desktop/help-knowledge/skills.md+++ b/apps/desktop/help-knowledge/skills.md@@ -31,6 +31,7 @@ Skills are reusable agent capabilities you package as a folder and load into you**Disabling or uninstalling a local skill (Desktop):**- Open a skill's detail page to use the switch in the top action bar. For a market skill installed in multiple locations, select the local copy from the location dropdown beside the switch. Turning it off keeps the files and removes the skill from new-task command previews. Active tasks retain the skill preference snapshot applied when their Agent started, including their command palette. New or restarted Claude Code, Codex, and Pi agents apply that choice; an already-running agent keeps its existing context.+- Renaming a local skill while publishing keeps its enabled or disabled setting. If renaming fails, Cindy restores the original folder and content.- The switch is local to this device and Cindy profile. It does not edit external CLI settings, sync to other devices, or override a native engine's own disabled state. Enable it again to let the engine discover it normally.- In the skill's details, use **… → Uninstall skill**. Confirm the location and shared-file impact. Standalone skills, including locally written skills without a market installation record, move to the system trash. Recovery is through the operating system's trash.- External source imports remove only their discovery links and keep the external source files. Package-owned or built-in skills must be removed through their owning package; their uninstall action is unavailable here. Skills provided by Cindy plugins are managed on the owning plugin's page, including when discovered through shared skill links.@@ -66,3 +67,5 @@ Skills are reusable agent capabilities you package as a folder and load into you- Project-scoped skills only show up in sessions whose working directory matches — useful for skills tied to a particular repo's conventions.- Editing files inside an installed skill folder takes effect on the next session start; you don't need to reinstall.- Uninstalling only removes your local copy. For your own published skills, use unpublish or manage visibility to change market availability.++In a new-task draft, the slash hover panel offers detail links for global skills. Project skill detail links are available after creating a task, when SkillHub can include that project in its scan.diff --git a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.tsindex e824f848e0..aed3825103 100644--- a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts+++ b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts@@ -144,7 +144,7 @@ export const HELP_KNOWLEDGE: HelpKnowledgeDoc[] = [id: "skills",title: "Skills (reusable agent capabilities)",summary: "Browse, install, disable, uninstall, publish, and update agent skills; installed skills appear as \"/\" slash commands and are shared across Claude Code and Codex.",- content: "Skills are reusable agent capabilities you package as a folder and load into your sessions. They're managed on the same page as Plugins — **Skills** and **Plugins** are two tabs of one management surface (the Skills tab is the in-app browser for finding, installing, publishing, and updating skills).\n\n**Skills work with both agents:**\n\n- Skills are **engine-shared** — the same installed skill is available to both Claude Code and Codex, so you install it once.\n\n**Where skills live on disk:**\n\n- Global (available to every session): the shared root `~/.agents/skills/<name>/`, which is cross-linked to `~/.claude/skills/` and `~/.codex/skills/` so every engine sees the same skills. On Windows that's under `C:\\Users\\<you>\\`.\n- Project-scoped (only inside one working directory): `<working-dir>/.agents/skills/<name>/` or `<working-dir>/.claude/skills/<name>/`.\n- Each skill is its own folder with a required `SKILL.md` at the root (the prompt / spec the agent reads). Sibling files and subfolders in that folder are also visible to the agent.\n\n**Importing a local skill:**\n\n- On the Skills page, use **Import skill** (top-right) to pick a `.zip` package or a standalone `SKILL.md` file.\n- A zip must contain a `SKILL.md` (at the package root, or inside a single top-level folder). The YAML frontmatter must include non-empty `name` and `description` fields; `name` must match `^[a-z0-9-]{1,200}$`.\n- You then choose where to install: global, a known project, or another directory. Cindy extracts metadata from the file automatically and lists the skill with that name and description.\n- Imported skills can be uninstalled from the detail page, and you can publish them to SkillHub later if you want.\n\n**Using an installed skill:**\n\n- Hover over a local skill in the `/` suggestions and choose **View skill details** in its information panel to open that exact skill. This does not insert or send the command. Pi package skills remain usable from `/`, but do not show this local detail shortcut; manage them through their package.\n\n- Type `/` in the composer to open the slash-command palette; your installed skills show up there alongside built-in and agent commands. Pick one to run it.\n\n**Disabling or uninstalling a local skill (Desktop):**\n\n- Open a skill's detail page to use the switch in the top action bar. For a market skill installed in multiple locations, select the local copy from the location dropdown beside the switch. Turning it off keeps the files and removes the skill from new-task command previews. Active tasks retain the skill preference snapshot applied when their Agent started, including their command palette. New or restarted Claude Code, Codex, and Pi agents apply that choice; an already-running agent keeps its existing context.\n- The switch is local to this device and Cindy profile. It does not edit external CLI settings, sync to other devices, or override a native engine's own disabled state. Enable it again to let the engine discover it normally.\n- In the skill's details, use **… → Uninstall skill**. Confirm the location and shared-file impact. Standalone skills, including locally written skills without a market installation record, move to the system trash. Recovery is through the operating system's trash.\n- External source imports remove only their discovery links and keep the external source files. Package-owned or built-in skills must be removed through their owning package; their uninstall action is unavailable here. Skills provided by Cindy plugins are managed on the owning plugin's page, including when discovered through shared skill links.\n- Offline removal of an automatically synced skill is remembered on this device, including after restart or sign-in. Automatic sync skips it until you explicitly install it again.\n- Uninstalling a shared copy affects external CLIs that use it. It does not unpublish a skill or delete other users' copies. If file removal fails, Cindy keeps the installation. If only metadata/link cleanup fails, the notice offers **Retry cleanup** until the current window is closed or reloaded. Retry before then; closing or reloading ends the retry receipt without restoring the removed files.\n\n**Publishing your own skill:**\n\n- Find the publish action on the Skills page and point it at the skill's local folder. It zips the folder and uploads it — reading your directory in place, without copying or moving anything.\n- On first publish, you set the skill's **visibility**: PUBLIC (anyone in the org) or DEPARTMENT_SCOPED (only the departments you choose).\n- The local registry records what you published, so the app knows it's \"yours\" for future updates.\n\n**Updating an already-published skill:**\n\n- On your own skill's detail page you'll see a **发布新版本** (Publish New Version) button.\n- Edit the local folder however you want and publish — the version is **auto-incremented server-side**, you don't pick a number.\n- **Old versions stay live alongside the new one.** Users who already installed an older version keep it until they choose to update.\n- The display name and description are sent on every republish, so editing those metadata fields just means doing a republish.\n\n**Managing an already-published skill:**\n\n- Change who can see or use your skill from the management menu — public, shared with selected teams / departments, or private to you.\n- **Unpublish** makes it private again and returns ownership to your personal scope; it does not remove copies other users already installed.\n- **Authorship is fixed.** Only the original author's account can publish new versions of a given skill (enforced server-side as `NOT_AUTHOR`).\n\n**Browsing and installing others' skills:**\n\n- The marketplace lets you install skills into your global skills directory. You can request a specific version on install; the local registry tracks which version you have.\n\n**Notes:**\n\n- A skill folder without a `SKILL.md` at its root won't be picked up (lowercase `skill.md` is also accepted).\n- Project-scoped skills only show up in sessions whose working directory matches — useful for skills tied to a particular repo's conventions.\n- Editing files inside an installed skill folder takes effect on the next session start; you don't need to reinstall.\n- Uninstalling only removes your local copy. For your own published skills, use unpublish or manage visibility to change market availability.",+ content: "Skills are reusable agent capabilities you package as a folder and load into your sessions. They're managed on the same page as Plugins — **Skills** and **Plugins** are two tabs of one management surface (the Skills tab is the in-app browser for finding, installing, publishing, and updating skills).\n\n**Skills work with both agents:**\n\n- Skills are **engine-shared** — the same installed skill is available to both Claude Code and Codex, so you install it once.\n\n**Where skills live on disk:**\n\n- Global (available to every session): the shared root `~/.agents/skills/<name>/`, which is cross-linked to `~/.claude/skills/` and `~/.codex/skills/` so every engine sees the same skills. On Windows that's under `C:\\Users\\<you>\\`.\n- Project-scoped (only inside one working directory): `<working-dir>/.agents/skills/<name>/` or `<working-dir>/.claude/skills/<name>/`.\n- Each skill is its own folder with a required `SKILL.md` at the root (the prompt / spec the agent reads). Sibling files and subfolders in that folder are also visible to the agent.\n\n**Importing a local skill:**\n\n- On the Skills page, use **Import skill** (top-right) to pick a `.zip` package or a standalone `SKILL.md` file.\n- A zip must contain a `SKILL.md` (at the package root, or inside a single top-level folder). The YAML frontmatter must include non-empty `name` and `description` fields; `name` must match `^[a-z0-9-]{1,200}$`.\n- You then choose where to install: global, a known project, or another directory. Cindy extracts metadata from the file automatically and lists the skill with that name and description.\n- Imported skills can be uninstalled from the detail page, and you can publish them to SkillHub later if you want.\n\n**Using an installed skill:**\n\n- Hover over a local skill in the `/` suggestions and choose **View skill details** in its information panel to open that exact skill. This does not insert or send the command. Pi package skills remain usable from `/`, but do not show this local detail shortcut; manage them through their package.\n\n- Type `/` in the composer to open the slash-command palette; your installed skills show up there alongside built-in and agent commands. Pick one to run it.\n\n**Disabling or uninstalling a local skill (Desktop):**\n\n- Open a skill's detail page to use the switch in the top action bar. For a market skill installed in multiple locations, select the local copy from the location dropdown beside the switch. Turning it off keeps the files and removes the skill from new-task command previews. Active tasks retain the skill preference snapshot applied when their Agent started, including their command palette. New or restarted Claude Code, Codex, and Pi agents apply that choice; an already-running agent keeps its existing context.\n- Renaming a local skill while publishing keeps its enabled or disabled setting. If renaming fails, Cindy restores the original folder and content.\n- The switch is local to this device and Cindy profile. It does not edit external CLI settings, sync to other devices, or override a native engine's own disabled state. Enable it again to let the engine discover it normally.\n- In the skill's details, use **… → Uninstall skill**. Confirm the location and shared-file impact. Standalone skills, including locally written skills without a market installation record, move to the system trash. Recovery is through the operating system's trash.\n- External source imports remove only their discovery links and keep the external source files. Package-owned or built-in skills must be removed through their owning package; their uninstall action is unavailable here. Skills provided by Cindy plugins are managed on the owning plugin's page, including when discovered through shared skill links.\n- Offline removal of an automatically synced skill is remembered on this device, including after restart or sign-in. Automatic sync skips it until you explicitly install it again.\n- Uninstalling a shared copy affects external CLIs that use it. It does not unpublish a skill or delete other users' copies. If file removal fails, Cindy keeps the installation. If only metadata/link cleanup fails, the notice offers **Retry cleanup** until the current window is closed or reloaded. Retry before then; closing or reloading ends the retry receipt without restoring the removed files.\n\n**Publishing your own skill:**\n\n- Find the publish action on the Skills page and point it at the skill's local folder. It zips the folder and uploads it — reading your directory in place, without copying or moving anything.\n- On first publish, you set the skill's **visibility**: PUBLIC (anyone in the org) or DEPARTMENT_SCOPED (only the departments you choose).\n- The local registry records what you published, so the app knows it's \"yours\" for future updates.\n\n**Updating an already-published skill:**\n\n- On your own skill's detail page you'll see a **发布新版本** (Publish New Version) button.\n- Edit the local folder however you want and publish — the version is **auto-incremented server-side**, you don't pick a number.\n- **Old versions stay live alongside the new one.** Users who already installed an older version keep it until they choose to update.\n- The display name and description are sent on every republish, so editing those metadata fields just means doing a republish.\n\n**Managing an already-published skill:**\n\n- Change who can see or use your skill from the management menu — public, shared with selected teams / departments, or private to you.\n- **Unpublish** makes it private again and returns ownership to your personal scope; it does not remove copies other users already installed.\n- **Authorship is fixed.** Only the original author's account can publish new versions of a given skill (enforced server-side as `NOT_AUTHOR`).\n\n**Browsing and installing others' skills:**\n\n- The marketplace lets you install skills into your global skills directory. You can request a specific version on install; the local registry tracks which version you have.\n\n**Notes:**\n\n- A skill folder without a `SKILL.md` at its root won't be picked up (lowercase `skill.md` is also accepted).\n- Project-scoped skills only show up in sessions whose working directory matches — useful for skills tied to a particular repo's conventions.\n- Editing files inside an installed skill folder takes effect on the next session start; you don't need to reinstall.\n- Uninstalling only removes your local copy. For your own published skills, use unpublish or manage visibility to change market availability.\n\nIn a new-task draft, the slash hover panel offers detail links for global skills. Project skill detail links are available after creating a task, when SkillHub can include that project in its scan.",},{id: "updates-and-about",diff --git a/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts b/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.tsindex 9312e1aea1..f2ef6114ae 100644--- a/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts+++ b/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts@@ -27,4 +27,43 @@ describe('Skill activation preferences', () => {await reloaded.setCindySkillEnabled(b, true);expect(reloaded.readDisabledSkillPaths()).toEqual([]);});+ it.each(['success', 'enabled-source', 'content-failure', 'preference-failure', 'owner-changed'])('migrates disabled state with a local rename (%s)', async (scenario) => {+ const { renameLocalSkill } = await import('../scanner');+ const { setCindySkillEnabled, readDisabledSkillPaths, skillActivationKey } = await import('../activationPreferences');+ const source = path.join(root, scenario, '.agents', 'skills', 'old-name');+ const destination = path.join(path.dirname(source), 'new-name');+ const content = '---\nname: old-name\n---\nOriginal content\n';+ fs.mkdirSync(source, { recursive: true });+ fs.writeFileSync(path.join(source, 'SKILL.md'), content);+ await setCindySkillEnabled(scenario === 'enabled-source' ? destination : source, false);+ const before = [...readDisabledSkillPaths()];+ const oldKey = skillActivationKey(source);+ const realRename = fs.renameSync;+ let injected = false;+ const spy = vi.spyOn(fs, 'renameSync').mockImplementation((from, to) => {+ if (!injected && ((scenario === 'content-failure' && String(to) === path.join(destination, 'SKILL.md'))+ || (scenario === 'preference-failure' && String(to).endsWith('activation-preferences.json')))) {+ injected = true;+ throw new Error('simulated write failure');+ }+ return realRename(from, to);+ });+ try {+ const result = await renameLocalSkill({ absolutePath: source, newName: 'new-name' }, () => scenario !== 'owner-changed');+ if (scenario === 'success' || scenario === 'enabled-source') {+ expect(result).toEqual({ success: true, newAbsolutePath: destination });+ expect(readDisabledSkillPaths()).not.toContain(oldKey);+ if (scenario === 'success') expect(readDisabledSkillPaths()).toContain(skillActivationKey(destination));+ else expect(readDisabledSkillPaths()).not.toContain(skillActivationKey(destination));+ expect(fs.readFileSync(path.join(destination, 'SKILL.md'), 'utf8')).toContain('name: new-name');+ } else {+ expect(injected).toBe(scenario !== 'owner-changed');+ expect(result.success).toBe(false);+ expect(fs.existsSync(destination)).toBe(false);+ expect(fs.readFileSync(path.join(source, 'SKILL.md'), 'utf8')).toBe(content);+ expect(readDisabledSkillPaths()).toEqual(before);+ }+ } finally { spy.mockRestore(); }+ });+});diff --git a/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts b/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.tsindex 3298fe5872..0e6edc8ca5 100644--- a/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts+++ b/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts@@ -199,7 +199,8 @@ describe('registerSkillhubIpc usage handlers', () => {] as const;for (const [channel, params, delegated] of calls) {await handlers.get(channel)?.({ sender }, params);- expect(delegated).toHaveBeenCalledWith(params);+ if (channel === 'skillhub:rename-local') expect(delegated).toHaveBeenCalledWith(params, expect.any(Function));+ else expect(delegated).toHaveBeenCalledWith(params);}const wrongSender = await handlers.get('skillhub:read-raw')?.(diff --git a/apps/desktop/src/main/skillhub/activationPreferences.ts b/apps/desktop/src/main/skillhub/activationPreferences.tsindex 0dbd67c796..90437affcb 100644--- a/apps/desktop/src/main/skillhub/activationPreferences.ts+++ b/apps/desktop/src/main/skillhub/activationPreferences.ts@@ -48,3 +48,19 @@ export async function setCindySkillEnabled(source: string, enabled: boolean, can};});}++/** Run the filesystem rename and preference migration under the same settings lock. */+export async function renameSkillWithActivation(+ source: string,+ destination: string,+ renameFiles: () => void,+): Promise<void> {+ await store.updateAtomic(({ value }) => {+ const oldKey = skillActivationKey(source);+ renameFiles();+ const newKey = skillActivationKey(destination);+ const disabledPaths = value.disabledPaths.filter((key) => key !== oldKey && key !== newKey);+ if (value.disabledPaths.includes(oldKey)) disabledPaths.push(newKey);+ return { disabledPaths: [...new Set(disabledPaths)].sort() };+ });+}diff --git a/apps/desktop/src/main/skillhub/installLock.ts b/apps/desktop/src/main/skillhub/installLock.tsindex a4ff86b122..be35ed5e6f 100644--- a/apps/desktop/src/main/skillhub/installLock.ts+++ b/apps/desktop/src/main/skillhub/installLock.ts@@ -22,7 +22,8 @@ export type SkillInstallLockOwner =| 'market-install'| 'market-uninstall'| 'learn-apply'- | 'local-import';+ | 'local-import'+ | 'local-rename';interface LockHolder {owner: SkillInstallLockOwner;diff --git a/apps/desktop/src/main/skillhub/registerIpc.ts b/apps/desktop/src/main/skillhub/registerIpc.tsindex abed8955ba..3b52d0b6e6 100644--- a/apps/desktop/src/main/skillhub/registerIpc.ts+++ b/apps/desktop/src/main/skillhub/registerIpc.ts@@ -473,7 +473,10 @@ export function registerSkillhubIpc(options: RegisterSkillhubIpcOptions): void {'skillhub:rename-local',async (event, params: { absolutePath: string; newName: string }) => {if (!await hasScannedSkillGrant(event, params.absolutePath)) return scanGrantDenied();- return renameLocalSkill(params);+ const ownerId = getCurrentDataOwnerId();+ const result = await renameLocalSkill(params, () => ownerId === getCurrentDataOwnerId() && !isAppSessionBoundaryPending());+ if (result.success) broadcastLocalChange();+ return result;},);diff --git a/apps/desktop/src/main/skillhub/scanner.ts b/apps/desktop/src/main/skillhub/scanner.tsindex fe2c8890e2..96a9dd700a 100644--- a/apps/desktop/src/main/skillhub/scanner.ts+++ b/apps/desktop/src/main/skillhub/scanner.ts@@ -1,4 +1,5 @@-import { isCindySkillEnabled } from './activationPreferences';+import { isCindySkillEnabled, renameSkillWithActivation } from './activationPreferences';+import { tryAcquireSkillInstallLock } from './installLock';import { inspectLocalSkillTarget, isPluginManagedSkillPath } from './localSkillTarget';/*** SkillHub Scanner — 商店层 (registry / market) 视图组装。@@ -16,7 +17,7 @@ import { inspectLocalSkillTarget, isPluginManagedSkillPath } from './localSkillT* Read-only for scan; write helpers gated by SKILL_PATH_WHITELIST.*/-import { createHash } from 'node:crypto';+import { createHash, randomUUID } from 'node:crypto';import fs from 'node:fs';import os from 'node:os';import path from 'node:path';@@ -811,7 +812,7 @@ export async function writeSkillFile(params: { filePath: string; content: stringexport async function renameLocalSkill(params: {absolutePath: string;newName: string;-}): Promise<{ success: true; newAbsolutePath: string } | { success: false; error: string }> {+}, canMutate: () => boolean = () => true): Promise<{ success: true; newAbsolutePath: string } | { success: false; error: string }> {const { absolutePath, newName } = params;if (!absolutePath || !path.isAbsolute(absolutePath)) {@@ -870,51 +871,61 @@ export async function renameLocalSkill(params: {return { success: false, error: 'SKILL.md 不存在,无法改名' };}- // ── Step 1: rename 目录- try {- fs.renameSync(absolutePath, newAbsolutePath);- } catch (err) {- return { success: false, error: `重命名目录失败: ${err instanceof Error ? err.message : String(err)}` };+ const releases: Array<() => void> = [];+ for (const name of [oldName, newName]) {+ const release = tryAcquireSkillInstallLock(name, 'local-rename');+ if (!release) {+ releases.forEach((unlock) => unlock());+ return { success: false, error: 'Skill is busy; retry after the current operation' };+ }+ releases.push(release);}-- // ── Step 2: 改写 SKILL.md frontmatter 的 name 字段const newSkillMd = path.join(newAbsolutePath, 'SKILL.md');+ const tmpPath = `${newSkillMd}.xdt-tmp`;+ const backupPath = `${newSkillMd}.xdt-rename-${randomUUID()}`;+ let renamed = false;+ let backedUp = false;try {- const raw = fs.readFileSync(newSkillMd, 'utf-8');- const parsed = matter(raw);- const data = (parsed.data && typeof parsed.data === 'object'- ? parsed.data- : {}) as Record<string, unknown>;- // 只在 frontmatter 真有 name 字段时才覆写,没有就插入- data.name = newName;- const next = matter.stringify(parsed.content, data);-- // Atomic tmp + rename 一致地写- const tmpPath = `${newSkillMd}.xdt-tmp`;- const fd = fs.openSync(tmpPath, 'w');- try {- fs.writeSync(fd, next);- fs.fsyncSync(fd);- } finally {- fs.closeSync(fd);- }- fs.renameSync(tmpPath, newSkillMd);+ await renameSkillWithActivation(absolutePath, newAbsolutePath, () => {+ if (!canMutate()) throw new Error('Skill mutation context changed');+ // Recheck after waiting for the preferences lock; never replace a new entity.+ const current = fs.lstatSync(absolutePath);+ if (current.dev !== stat.dev || current.ino !== stat.ino || fs.existsSync(newAbsolutePath)) {+ throw new Error('Skill changed; refresh and retry');+ }+ const currentMd = fs.lstatSync(oldSkillMd);+ if (currentMd.isSymbolicLink() || currentMd.dev !== skillMdStat.dev || currentMd.ino !== skillMdStat.ino) {+ throw new Error('Skill content changed; refresh and retry');+ }+ const parsed = matter(fs.readFileSync(oldSkillMd, 'utf-8'));+ const data = (parsed.data && typeof parsed.data === 'object' ? parsed.data : {}) as Record<string, unknown>;+ data.name = newName;+ const next = matter.stringify(parsed.content, data);+ fs.renameSync(absolutePath, newAbsolutePath);+ renamed = true;+ const fd = fs.openSync(tmpPath, 'w');+ try { fs.writeSync(fd, next); fs.fsyncSync(fd); }+ finally { fs.closeSync(fd); }+ fs.renameSync(newSkillMd, backupPath);+ backedUp = true;+ fs.renameSync(tmpPath, newSkillMd);+ });+ try { fs.unlinkSync(backupPath); } catch { /* A leftover backup must not roll back committed preferences. */ }+ return { success: true, newAbsolutePath };} catch (err) {- // 回滚:把目录改回去,避免本地处于"目录新名 + frontmatter 旧名"的半完成状态- try {- fs.renameSync(newAbsolutePath, absolutePath);- } catch {- // 回滚也失败 — 报双重失败,让调用方提示用户手动修- return {- success: false,- error: `改写 SKILL.md 失败且回滚也失败: ${err instanceof Error ? err.message : String(err)}`,- };+ if (renamed) {+ try {+ // Keep the original file until preferences commit, so even a full disk+ // can roll back with renames instead of writing the contents again.+ if (backedUp) fs.renameSync(backupPath, newSkillMd);+ try { fs.unlinkSync(tmpPath); } catch { /* No staging file after a completed switch. */ }+ fs.renameSync(newAbsolutePath, absolutePath);+ } catch (rollbackError) {+ return { success: false, error: `Skill rename and rollback failed: ${String(rollbackError)}` };+ }}- return {- success: false,- error: `改写 SKILL.md frontmatter 失败,已回滚目录: ${err instanceof Error ? err.message : String(err)}`,- };+ return { success: false, error: `Skill rename failed: ${String(err)}` };+ } finally {+ releases.forEach((unlock) => unlock());}-- return { success: true, newAbsolutePath };}diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsxindex b1b2b915cf..2d29f54618 100644--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx@@ -8952,8 +8952,10 @@ export function ChatInput({focusedIndex={slashFocus}onFocusedIndexChange={setSlashFocus}onSelect={(cmd) => insertSlashCommand(cmd)}+ allowProjectSkillDetails={!!sessionId}onOpenSkillDetails={!isRemoteSession && !deviceLinkDeviceId ? (cmd) => {if (cmd.kind !== 'agent-skill' || cmd.source !== 'skill' || !cmd.path || cmd.origin === 'package') return;+ if (!sessionId && cmd.scope !== 'global' && cmd.scope !== 'user') return;draftSaveSchedulerRef.current?.flush();navigate(buildLocalSkillPathRoute(cmd.path), { state: { resetHistory: true } });} : undefined}diff --git a/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx b/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsxindex 8e20b1d383..76bc1a5bdc 100644--- a/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx+++ b/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx@@ -50,6 +50,8 @@ interface SlashCommandPaletteProps {onClose: () => void;/** Opens the backing local Skill from the hover information panel. */onOpenSkillDetails?: (command: UnifiedCommand) => void;+ /** Draft projects are not yet in SkillHub's Main-owned project scan. */+ allowProjectSkillDetails?: boolean;/** Reports hover state for the portaled tooltip so ChatInput's blur guard treats it as part of the palette. */onTooltipHoverChange?: (hovered: boolean) => void;/** Panel max-height in px. Defaults to 400 (chat view); NewMaker passes a smaller value so the popover doesn't cover the logo. */@@ -72,6 +74,7 @@ export function SlashCommandPalette({onSelect,onClose,onOpenSkillDetails,+ allowProjectSkillDetails = true,onTooltipHoverChange,maxHeight = 400,}: SlashCommandPaletteProps) {@@ -299,7 +302,8 @@ export function SlashCommandPalette({<div className="flex items-center gap-1 text-14 font-medium text-[var(--cmd-palette-item-text)]"><span className="min-w-0 truncate">{focusedCmd.name}</span>{onOpenSkillDetails && focusedCmd.kind === 'agent-skill'- && focusedCmd.source === 'skill' && focusedCmd.path && focusedCmd.origin !== 'package' && (+ && focusedCmd.source === 'skill' && focusedCmd.path && focusedCmd.origin !== 'package'+ && (allowProjectSkillDetails || focusedCmd.scope === 'global' || focusedCmd.scope === 'user') && (<Tip text={t('commandPalette.viewSkillDetails')}><Button variant="secondary"className="w-8 border-transparent bg-transparent p-0 text-[var(--cmd-palette-item-meta)]"diff --git a/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsx b/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsxindex 61f1bb409a..750cb7eaaf 100644--- a/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsx+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsx@@ -80,6 +80,18 @@ describe('SlashCommandPalette project Skill rows', () => {expect(onSelect).toHaveBeenCalledWith(command);});+ it.each(['repo', 'project', 'global', 'user'] as const)('offers only resolvable %s details in a new-task draft', (scope) => {+ const command: UnifiedCommand = { ...discoveredProjectSkill, scope, path: '/draft/demo/SKILL.md', runtimeStatus: 'approved' };+ const onSelect = vi.fn();+ render(<SlashCommandPalette query="" commands={[command]} focusedIndex={0} allowProjectSkillDetails={false}+ onFocusedIndexChange={vi.fn()} onSelect={onSelect} onClose={vi.fn()} onOpenSkillDetails={vi.fn()} />);+ const details = screen.queryByRole('button', { name: 'commandPalette.viewSkillDetails' });+ if (scope === 'global' || scope === 'user') expect(details).not.toBeNull();+ else expect(details).toBeNull();+ fireEvent.mouseDown(screen.getByRole('button', { name: 'demo' }));+ expect(onSelect).toHaveBeenCalledWith(command);+ });+it('keeps a discovered Skill disabled and non-actionable', () => {const onSelect = vi.fn();