Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(skillhub): 原生确认卸载并校验启动停用目标
xd-bobobe07c6aecbae
diff --git a/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts b/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.tsindex 3e44e00b11..f6c63a8bd4 100644--- a/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts+++ b/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts@@ -10,6 +10,8 @@ vi.mock('../activationPreferences', () => ({ setCindySkillEnabled }));const handlers = new Map<string, (...args: unknown[]) => unknown>();const showOpenDialog = vi.fn();+const showMessageBox = vi.fn();+vi.mock('../../i18n.js', () => ({ t: (key: string) => key }));const assertTrustedAppRendererEvent = vi.fn();const importLocalSkillMocks = vi.hoisted(() => ({inspectLocalSkill: vi.fn(),@@ -34,6 +36,7 @@ vi.mock('electron', () => ({},dialog: {showOpenDialog,+ showMessageBox,},ipcMain: {handle: vi.fn((channel: string, handler: (...args: unknown[]) => unknown) => {@@ -137,6 +140,8 @@ describe('registerSkillhubIpc usage handlers', () => {});ensureReady.mockResolvedValue({ ready: true });requestLocalSkillUsageAnalyticsRefresh.mockReturnValue(null);+ showMessageBox.mockReset();+ showMessageBox.mockResolvedValue({ response: 0 });showOpenDialog.mockResolvedValue({ canceled: true, filePaths: [] });getAllowedProjectRoots.mockResolvedValue(['/repo', '/old', '/new']);resolveExistingSkillPathForGrant.mockImplementation((candidate: string) => (@@ -351,6 +356,8 @@ describe('registerSkillhubIpc usage handlers', () => {});it('issues a sender-bound grant for the file selected and inspected in main', async () => {+ showMessageBox.mockReset();+ showMessageBox.mockResolvedValue({ response: 0 });showOpenDialog.mockResolvedValueOnce({canceled: false,filePaths: ['/selected/demo-skill.zip'],@@ -381,6 +388,8 @@ describe('registerSkillhubIpc usage handlers', () => {});it('imports only the selected path for the grant owner and consumes a successful grant', async () => {+ showMessageBox.mockReset();+ showMessageBox.mockResolvedValue({ response: 0 });showOpenDialog.mockResolvedValueOnce({canceled: false,filePaths: ['/selected/demo-skill.zip'],@@ -432,6 +441,8 @@ describe('registerSkillhubIpc usage handlers', () => {);expect(missing).toMatchObject({ success: false, errorCode: 'PERMISSION_DENIED' });+ showMessageBox.mockReset();+ showMessageBox.mockResolvedValue({ response: 0 });showOpenDialog.mockResolvedValueOnce({canceled: false,filePaths: ['/selected/demo-skill.zip'],@@ -691,6 +702,50 @@ describe('registerSkillhubIpc usage handlers', () => {expect.objectContaining({ operationPath: absolutePath, aliases: expect.arrayContaining(aliases), linkOnly: false }), expect.any(Function));});+ it('requires native confirmation for direct uninstall and never mutates on cancellation', async () => {+ const { event, absolutePath } = await scanLocalFixture();+ showMessageBox.mockResolvedValueOnce({ response: 1 });+ expect(await handlers.get('skillhub:uninstall')!(event, { absolutePath }))+ .toEqual({ success: false, errorCode: 'CANCELLED', message: '' });+ expect(installServiceMocks.uninstall).not.toHaveBeenCalled();+ expect(showMessageBox).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({+ defaultId: 1, cancelId: 1, detail: expect.stringContaining(absolutePath),+ }));+ });++ it.each(['owner', 'reload', 'source', 'project'])('revokes confirmation when %s changes while native dialog is open', async (change) => {+ const { event, absolutePath } = await scanLocalFixture();+ let approve!: (value: { response: number }) => void;+ showMessageBox.mockImplementationOnce(() => new Promise((resolve) => { approve = resolve; }));+ const pending = handlers.get('skillhub:uninstall')!(event, { absolutePath });+ const rejected = expect(pending).rejects.toThrow();+ await vi.waitFor(() => expect(showMessageBox).toHaveBeenCalledOnce());+ expect(installServiceMocks.uninstall).not.toHaveBeenCalled();+ if (change === 'owner') getCurrentDataOwnerId.mockReturnValue('another-owner');+ if (change === 'project') getAllowedProjectRoots.mockResolvedValue([]);+ if (change === 'reload') event.sender.on.mock.calls.find(([name]) => name === 'did-start-navigation');+ if (change === 'source') {+ fs.renameSync(absolutePath, `${absolutePath}-old`);+ fs.mkdirSync(absolutePath);+ fs.writeFileSync(path.join(absolutePath, 'SKILL.md'), 'replacement');+ }+ approve({ response: 0 });+ await rejected;+ expect(installServiceMocks.uninstall).not.toHaveBeenCalled();+ });++ it('does not queue repeated native uninstall dialogs from one renderer', async () => {+ const { event, absolutePath } = await scanLocalFixture();+ let cancel!: (value: { response: number }) => void;+ showMessageBox.mockImplementationOnce(() => new Promise((resolve) => { cancel = resolve; }));+ const pending = handlers.get('skillhub:uninstall')!(event, { absolutePath });+ await vi.waitFor(() => expect(showMessageBox).toHaveBeenCalledOnce());+ await expect(handlers.get('skillhub:uninstall')!(event, { absolutePath })).rejects.toThrow('PRECONDITION_FAILED');+ expect(showMessageBox).toHaveBeenCalledOnce();+ cancel({ response: 1 });+ await pending;+ });+it('refreshes the Codex cwd cache after uninstalling a granted project skill', async () => {const { event, absolutePath, project } = await scanLocalFixture();installServiceMocks.uninstall.mockResolvedValueOnce({ success: true, projectWorkingDir: project });diff --git a/apps/desktop/src/main/skillhub/registerIpc.ts b/apps/desktop/src/main/skillhub/registerIpc.tsindex f4c26753d9..fb34815be0 100644--- a/apps/desktop/src/main/skillhub/registerIpc.ts+++ b/apps/desktop/src/main/skillhub/registerIpc.ts@@ -1,4 +1,5 @@import fs from 'node:fs';+import { t } from '../i18n.js';import { throwIpcError } from '../utils/ipcValidate';import { setCindySkillEnabled } from './activationPreferences';import { inspectLocalSkillTarget, isLocalSkillTargetCurrent, isPluginManagedSkillPath, type LocalSkillTarget } from './localSkillTarget';@@ -115,6 +116,7 @@ async function validateRequestedProjects(export function registerSkillhubIpc(options: RegisterSkillhubIpcOptions): void {const marketService = options.marketService ?? new SkillhubMarketService();const localImportGrants = new Map<string, LocalImportGrant>();+ const uninstallConfirmations = new Set<number>();const cleanupGrants = new Map<string, { ownerId: string | null; senderId: number }>();const scannedSkillRootsBySender = new Map<number, ScannedSkillGrant>();const localSkillsBySender = new Map<number, Array<{@@ -1008,14 +1010,47 @@ export function registerSkillhubIpc(options: RegisterSkillhubIpcOptions): void {ipcMain.handle('skillhub:uninstall',async (event, { absolutePath, skillId }: { absolutePath: string; skillId?: string }) => {- const { target } = await requireLocalSkill(event, absolutePath, skillId);+ const { target, skill } = await requireLocalSkill(event, absolutePath, skillId);if (!target || !isLocalSkillTargetCurrent(target) || isPluginManagedSkillPath(target.sourcePath, options.getManagedSkillRoots())) {throwIpcError('PRECONDITION_FAILED', 'Skill cannot be uninstalled; refresh and retry');}const ownerId = getCurrentDataOwnerId();const cleanupGeneration = cleanupGenerationBySender.get(event.sender) ?? 0;+ const parent = BrowserWindow.fromWebContents(event.sender);+ if (!parent || parent.isDestroyed() || uninstallConfirmations.has(event.sender.id)) {+ throwIpcError('PRECONDITION_FAILED', 'Skill confirmation is unavailable');+ }+ // Renderer confirmation is not authorization. Only this native decision+ // approves the Main-scanned entity, and navigation/owner changes revoke it.+ uninstallConfirmations.add(event.sender.id);+ let response: number;+ try {+ ({ response } = await dialog.showMessageBox(parent, {+ type: 'warning',+ title: t('skillhub.detail.uninstallDialog.title').replace('{{name}}', () => skill.name),+ message: t('skillhub.detail.uninstallDialog.title').replace('{{name}}', () => skill.name),+ detail: [+ t(target.linkOnly ? 'skillhub.management.unlinkDescription' : 'skillhub.management.trashDescription'),+ t(skill.scope === 'project' ? 'skillhub.management.projectScope' : 'skillhub.management.globalScope')+ .replace('{{project}}', () => skill.projectRoot ?? ''),+ t('skillhub.management.sharedImpact'), target.operationPath,+ ].join('\n\n'),+ buttons: [t('skillhub.detail.uninstallDialog.confirm'), t('skillhub.detail.uninstallDialog.cancel')],+ defaultId: 1, cancelId: 1, noLink: true,+ }));+ } catch { throwIpcError('INTERNAL', 'Could not confirm Skill uninstall; retry'); }+ finally { uninstallConfirmations.delete(event.sender.id); }+ if (response !== 0) return { success: false, errorCode: 'CANCELLED', message: '' };+ const current = await requireLocalSkill(event, absolutePath, skillId);+ const approvalCurrent = () => !parent.isDestroyed()+ && cleanupGeneration === (cleanupGenerationBySender.get(event.sender) ?? 0)+ && ownerId === getCurrentDataOwnerId() && !isAppSessionBoundaryPending();+ if (!approvalCurrent() || current.target?.identity !== target.identity+ || JSON.stringify(current.target.aliases) !== JSON.stringify(target.aliases)) {+ throwIpcError('PRECONDITION_FAILED', 'Skill confirmation expired; refresh and retry');+ }const result = await installService.uninstall(absolutePath, target,- () => ownerId === getCurrentDataOwnerId() && !isAppSessionBoundaryPending()+ () => approvalCurrent()&& !isPluginManagedSkillPath(target.sourcePath, options.getManagedSkillRoots()));if (!result.success) throwIpcError('INTERNAL', 'Could not move Skill to the trash; retry');await refreshCodexProjectSkillCache(result.projectWorkingDir);diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.tsindex ab2cd125c9..3e24758131 100644--- a/apps/desktop/src/preload/preload.ts+++ b/apps/desktop/src/preload/preload.ts@@ -3374,7 +3374,7 @@ contextBridge.exposeInMainWorld('electronAPI', {cancelInstall: (name: string): Promise<{ success: boolean }> =>ipcRenderer.invoke('skillhub:cancel-install', { name }),- // Main 校验当前扫描实体后移入系统回收站。+ // Main 原生确认并复核当前扫描实体后移入系统回收站。uninstall: (absolutePath: string,skillId?: string,diff --git a/apps/desktop/src/renderer/features/skillhub/components/LocalSkillControls.tsx b/apps/desktop/src/renderer/features/skillhub/components/LocalSkillControls.tsxindex ff7ad23b56..33ba4ae213 100644--- a/apps/desktop/src/renderer/features/skillhub/components/LocalSkillControls.tsx+++ b/apps/desktop/src/renderer/features/skillhub/components/LocalSkillControls.tsx@@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next';import { Switch } from '@/components/ui/switch';import { Button } from '@/components/ui/button';import { Tip } from '@/components/ui/tooltip';-import { useConfirmDialog } from '@/components/ui/confirm-dialog-provider';import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';import { extractIpcError } from '@/utils/ipcError';import { toast } from '@/lib/toast';@@ -17,7 +16,6 @@ export function LocalSkillControls({ skill, disabled = false, onUninstalled }: {onUninstalled?: () => void;}) {const { t } = useTranslation();- const { confirm } = useConfirmDialog();const busyRef = useRef(false);const [busy, setBusy] = useState(false);const [pendingEnabled, setPendingEnabled] = useState<boolean | null>(null);@@ -48,21 +46,9 @@ export function LocalSkillControls({ skill, disabled = false, onUninstalled }: {busyRef.current = true;setBusy(true);try {- const accepted = await confirm({- title: t('skillhub.detail.uninstallDialog.title', { name: skill.name }),- description: [- t(skill.uninstallLinkOnly ? 'skillhub.management.unlinkDescription' : 'skillhub.management.trashDescription'),- t(skill.scope === 'project' ? 'skillhub.management.projectScope' : 'skillhub.management.globalScope', {- project: skill.projectRoot ?? '',- }),- t('skillhub.management.sharedImpact'),- ].join('\n\n'),- confirmText: t('skillhub.detail.uninstallDialog.confirm'),- cancelText: t('skillhub.detail.uninstallDialog.cancel'),- });- if (!accepted) return;const result = await window.electronAPI.skillhub.uninstall(skill.absolutePath, skill.id);if (!result.success) {+ if (result.errorCode === 'CANCELLED') return;toast.error(t('skillhub.management.uninstallFailed'));return;}diff --git a/apps/desktop/src/renderer/features/skillhub/components/__tests__/LocalSkillControls.test.tsx b/apps/desktop/src/renderer/features/skillhub/components/__tests__/LocalSkillControls.test.tsxindex b5d6c0069a..03713161a1 100644--- a/apps/desktop/src/renderer/features/skillhub/components/__tests__/LocalSkillControls.test.tsx+++ b/apps/desktop/src/renderer/features/skillhub/components/__tests__/LocalSkillControls.test.tsx@@ -74,22 +74,24 @@ describe('Local Skill management', () => {expect(mocks.refresh).toHaveBeenCalledOnce();});- it('does not uninstall when confirmation is cancelled', async () => {- mocks.confirm.mockResolvedValueOnce(false);- render(<LocalSkillControls skill={skill} />);+ it('treats Main confirmation cancellation as a no-op', async () => {+ mocks.uninstall.mockResolvedValueOnce({ success: false, errorCode: 'CANCELLED', message: '' });+ const onUninstalled = vi.fn();+ render(<LocalSkillControls skill={skill} onUninstalled={onUninstalled} />);await chooseUninstall();- await waitFor(() => expect(mocks.confirm).toHaveBeenCalledOnce());- expect(mocks.uninstall).not.toHaveBeenCalled();+ await waitFor(() => expect(mocks.uninstall).toHaveBeenCalledOnce());+ expect(onUninstalled).not.toHaveBeenCalled();+ expect(mocks.error).not.toHaveBeenCalled();+ expect(mocks.refresh).not.toHaveBeenCalled();+ expect(mocks.confirm).not.toHaveBeenCalled();});- it('explains external link and project scope before uninstalling', async () => {+ it('delegates confirmation to Main with the selected skill identity', async () => {const onUninstalled = vi.fn();render(<LocalSkillControls skill={{ ...skill, scope: 'project', projectRoot: '/project', uninstallLinkOnly: true }} onUninstalled={onUninstalled} />);await chooseUninstall();await waitFor(() => expect(onUninstalled).toHaveBeenCalledOnce());- expect(mocks.confirm.mock.calls[0][0].description).toBe([- 'skillhub.management.unlinkDescription', 'skillhub.management.projectScope', 'skillhub.management.sharedImpact',- ].join('\n\n'));+ expect(mocks.confirm).not.toHaveBeenCalled();expect(mocks.uninstall).toHaveBeenCalledWith(skill.absolutePath, skill.id);});diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.mdindex ed7c276ebb..8215c373fc 100644--- a/docs/dev-rules/protocol-compatibility.md+++ b/docs/dev-rules/protocol-compatibility.md@@ -43,7 +43,10 @@`activation-preferences.json` 的可选 `discoveryPaths` 按物理路径保存已扫描的绝对发现路径数组;缺省兼容旧偏好。启动时复核指向,启用时删除该身份的入口记录,重命名时同事务迁移到新入口。活动任务在启动时另存规范化物理身份快照,菜单过滤不重新解析- 停用别名;原始词法入口仅用于原生启动设置。插件托管技能只能在所属插件管理,详情禁用开关,Main 拒绝独立启停。+ 停用别名;同时冻结词法入口到物理身份的映射,在写原生配置前剔除改指向的入口,+ 使原生停用目标与菜单快照一致。插件托管技能只能在所属插件管理,详情禁用开关,Main 拒绝独立启停。+ 卸载由 Main 原生确认框授权,默认取消;确认后再次核对发送窗口、账号、项目与文件+ 身份,导航或身份变化撤销确认。同一窗口最多一个待确认卸载,取消不产生文件或注册副作用。物理卸载的清理快照汇总已扫描 scope 的同源发现链接,外部导入只移除所选 scope 的入口与对应词法注册记录,不追加其它范围的全局候选。斜杠详情路径携带 scope 与工作目录,同源多副本按范围和最近项目匹配;旧路径无法唯一消歧时不任意选择副本。diff --git a/packages/maker-core/src/agents/claude-code/index.ts b/packages/maker-core/src/agents/claude-code/index.tsindex db9c546345..7dcabc4e59 100644--- a/packages/maker-core/src/agents/claude-code/index.ts+++ b/packages/maker-core/src/agents/claude-code/index.ts@@ -173,7 +173,7 @@ import type {MemoryResetResult,} from '../../types/memory.js';import type { McpProviderContext } from '../../interfaces/mcp-provider.js';-import { claudeDisabledSkillOverrides, snapshotDisabledSkillPaths } from '../shared/skill-activation.js';+import { claudeDisabledSkillOverrides, snapshotDisabledSkillLaunch, currentDisabledSkillLaunchPaths } from '../shared/skill-activation.js';import { scanClaudeCustomizations, scanClaudeRuntimeSkills } from './customization-scanner.js';import {REVIEW_SENSITIVE_CREDENTIAL_GLOB_PATTERNS,@@ -2369,9 +2369,10 @@ export class ClaudeCodeAgent extends BaseAgent {// 时快照。装配逻辑(含 apiKeyHelper 恒置空的鉴权防线)在 flag-settings.ts。const disabledSkillPaths = opts.remoteHostId || opts.botRuntimeProfile || reviewMode? [] : [...(this.deps.getDisabledSkillPaths?.() ?? [])];- const disabledSkillSnapshot = snapshotDisabledSkillPaths(disabledSkillPaths);+ const disabledSkillLaunch = snapshotDisabledSkillLaunch(disabledSkillPaths);+ const disabledSkillSnapshot = disabledSkillLaunch.identities;const disabledSkillOverrides = disabledSkillPaths.length > 0- ? claudeDisabledSkillOverrides((await scanClaudeRuntimeSkills(opts.workingDir)).items, disabledSkillPaths)+ ? claudeDisabledSkillOverrides((await scanClaudeRuntimeSkills(opts.workingDir)).items, currentDisabledSkillLaunchPaths(disabledSkillLaunch)): {};const buildSettings = (): Settings => {const settings = buildClaudeFlagSettings({diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.tsindex e15cadb681..b8c39f0ad9 100644--- a/packages/maker-core/src/agents/codex/index.ts+++ b/packages/maker-core/src/agents/codex/index.ts@@ -41,7 +41,7 @@ import {type SendOptions,type TurnPermissionPolicy,} from '../base-agent.js';-import { skillEntryPath, snapshotDisabledSkillPaths } from '../shared/skill-activation.js';+import { skillEntryPath, snapshotDisabledSkillLaunch, currentDisabledSkillLaunchPaths } from '../shared/skill-activation.js';import type { AgentCredentialMode } from '../../interfaces/auth-adapter.js';import type {Capabilities,@@ -4824,7 +4824,8 @@ export class CodexAgent extends BaseAgent {);const disabledSkillPaths = opts.remoteHostId || opts.botRuntimeProfile || reviewMode? [] : [...(this.deps.getDisabledSkillPaths?.() ?? [])];- const disabledSkillSnapshot = snapshotDisabledSkillPaths(disabledSkillPaths);+ const disabledSkillLaunch = snapshotDisabledSkillLaunch(disabledSkillPaths);+ const disabledSkillSnapshot = disabledSkillLaunch.identities;if (disabledSkillPaths.length > 0) {try {const response = await host.request<{ config?: Record<string, unknown> }>(@@ -4838,7 +4839,7 @@ export class CodexAgent extends BaseAgent {Array.isArray(nativeSkills) ? { 'skills.config': nativeSkills } : {},capabilityRoutingConfig,),- { 'skills.config': disabledSkillPaths.map((source) => ({ path: skillEntryPath(source), enabled: false })) },+ { 'skills.config': currentDisabledSkillLaunchPaths(disabledSkillLaunch).map((source) => ({ path: skillEntryPath(source), enabled: false })) },);} catch (error) {releaseHostBindingLeaseIfNeeded();diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.tsindex c105b3c1c3..26332bcffa 100644--- a/packages/maker-core/src/agents/pi/index.ts+++ b/packages/maker-core/src/agents/pi/index.ts@@ -1,4 +1,4 @@-import { snapshotDisabledSkillPaths } from '../shared/skill-activation.js';+import { snapshotDisabledSkillLaunch, currentDisabledSkillLaunchPaths } from '../shared/skill-activation.js';/*** PiAgent —— pi coding agent(earendil-works/pi)接入。*@@ -3048,7 +3048,8 @@ export class PiAgent extends BaseAgent {// approval from permission mode, MCP/plugin state, or caller vendor options.const disabledSkillPaths = opts.remoteHostId || opts.botRuntimeProfile || reviewMode? [] : [...(this.deps.getDisabledSkillPaths?.() ?? [])];- const disabledSkillSnapshot = snapshotDisabledSkillPaths(disabledSkillPaths);+ const disabledSkillLaunch = snapshotDisabledSkillLaunch(disabledSkillPaths);+ const disabledSkillSnapshot = disabledSkillLaunch.identities;let projectResourceAssembly = unavailablePiProjectResourceAssembly(reviewMode ? 'review-mode-project-resources-disabled' : 'approval-resolver-unavailable',);@@ -3060,7 +3061,7 @@ export class PiAgent extends BaseAgent {...(opts.remoteHostId ? { remoteHostId: opts.remoteHostId } : {}),});projectResourceAssembly = await assembleApprovedPiProjectResources(trustInput, opts.workingDir);- projectResourceAssembly = filterPiDisabledProjectSkills(projectResourceAssembly, disabledSkillPaths);+ projectResourceAssembly = filterPiDisabledProjectSkills(projectResourceAssembly, currentDisabledSkillLaunchPaths(disabledSkillLaunch));projectResourceAssembly = await stageApprovedPiProjectResources(projectResourceAssembly, configHome);} catch {projectResourceAssembly = unavailablePiProjectResourceAssembly('approval-resolver-failed');@@ -3142,7 +3143,7 @@ export class PiAgent extends BaseAgent {if (disabledSkillPaths.length > 0) {const settingsPath = path.join(configHome, 'settings.json');const settings = JSON.parse(await fs.readFile(settingsPath, 'utf8'));- await fs.writeFile(settingsPath, JSON.stringify(applyPiDisabledSkillSettings(settings, piDisabledDiscoveryPaths(disabledSkillPaths, [+ await fs.writeFile(settingsPath, JSON.stringify(applyPiDisabledSkillSettings(settings, piDisabledDiscoveryPaths(currentDisabledSkillLaunchPaths(disabledSkillLaunch), [path.join(configHome, 'skills'), path.join(os.homedir(), '.agents', 'skills'),...managedPackageResources.skills.map((skill) => skill.path),])), null, 2) + '\n', { mode: 0o600 });diff --git a/packages/maker-core/src/agents/shared/skill-activation.test.ts b/packages/maker-core/src/agents/shared/skill-activation.test.tsindex b71322880c..bcb80afa0e 100644--- a/packages/maker-core/src/agents/shared/skill-activation.test.ts+++ b/packages/maker-core/src/agents/shared/skill-activation.test.ts@@ -2,8 +2,8 @@ import fs from 'node:fs';import os from 'node:os';import path from 'node:path';import { afterAll, describe, expect, it } from 'vitest';-import { canonicalSkillPath, claudeDisabledSkillOverrides, isSkillDisabled, skillEntryPath } from './skill-activation.js';-import { filterPiDisabledProjectSkills } from '../pi/skill-activation.js';+import { canonicalSkillPath, claudeDisabledSkillOverrides, isSkillDisabled, skillEntryPath, snapshotDisabledSkillLaunch, currentDisabledSkillLaunchPaths } from './skill-activation.js';+import { filterPiDisabledProjectSkills, applyPiDisabledSkillSettings, piDisabledDiscoveryPaths } from '../pi/skill-activation.js';import type { AgentCustomization } from '../../types/customizations.js';const root = fs.mkdtempSync(path.join(os.tmpdir(), 'cindy-skill-activation-'));@@ -25,6 +25,36 @@ describe('Cindy-only Skill activation', () => {expect(canonicalSkillPath(skillEntryPath(global.absolutePath))).toBe(canonicalSkillPath(global.absolutePath));});+ it.each(['alias', 'physical'])('keeps native exclusions aligned when a %s path is retargeted across startup await', async (retarget) => {+ const a = skill(`launch-a-${retarget}`);+ const b = skill(`launch-b-${retarget}`);+ const alias = path.join(root, `launch-alias-${retarget}`);+ fs.symlinkSync(a.absolutePath, alias, process.platform === 'win32' ? 'junction' : 'dir');+ const aKey = canonicalSkillPath(a.absolutePath);+ const snapshot = snapshotDisabledSkillLaunch([alias]);+ await Promise.resolve().then(() => {+ if (retarget === 'alias') {+ fs.unlinkSync(alias);+ fs.symlinkSync(b.absolutePath, alias, process.platform === 'win32' ? 'junction' : 'dir');+ } else {+ fs.renameSync(a.absolutePath, `${a.absolutePath}-moved`);+ fs.symlinkSync(b.absolutePath, a.absolutePath, process.platform === 'win32' ? 'junction' : 'dir');+ }+ });+ const paths = currentDisabledSkillLaunchPaths(snapshot);+ expect(paths).not.toContain(alias);+ expect(paths.some((source) => canonicalSkillPath(source) === canonicalSkillPath(b.absolutePath))).toBe(false);+ expect(snapshot.identities).toEqual([aKey]);+ const claude = claudeDisabledSkillOverrides([a, b], paths);+ expect(claude[b.name]).toBeUndefined();+ expect(claude[a.name]).toBe(retarget === 'alias' ? 'off' : undefined);+ const codex = paths.map((source) => ({ path: skillEntryPath(source), enabled: false }));+ expect(codex.every((item) => canonicalSkillPath(item.path) === aKey)).toBe(true);+ const pi = applyPiDisabledSkillSettings({}, piDisabledDiscoveryPaths(paths, [alias]));+ expect(pi.skills ?? []).not.toContain(`-${alias}`);+ expect(pi.skills ?? []).not.toContain(`-${b.absolutePath}`);+ });+it('uses the winning Claude source, leaving a same-name project Skill enabled', () => {const global = skill('same');const project = skill('same', 'project');diff --git a/packages/maker-core/src/agents/shared/skill-activation.ts b/packages/maker-core/src/agents/shared/skill-activation.tsindex 83f35cba76..5f85c726aa 100644--- a/packages/maker-core/src/agents/shared/skill-activation.ts+++ b/packages/maker-core/src/agents/shared/skill-activation.ts@@ -15,6 +15,24 @@ export function snapshotDisabledSkillPaths(paths: readonly string[]): readonly sreturn Object.freeze([...new Set(paths.map(canonicalSkillPath))]);}+export interface DisabledSkillLaunchSnapshot {+ readonly identities: readonly string[];+ readonly paths: readonly { readonly path: string; readonly identity: string }[];+}++/** Keep lexical exclusions bound to the identities chosen before startup awaits. */+export function snapshotDisabledSkillLaunch(paths: readonly string[]): DisabledSkillLaunchSnapshot {+ const identities = snapshotDisabledSkillPaths(paths);+ return Object.freeze({ identities, paths: Object.freeze([...new Set([...paths, ...identities])]+ .map((source) => Object.freeze({ path: source, identity: canonicalSkillPath(source) }))) });+}++/** Drop stale/retargeted lexical paths immediately before native configuration. */+export function currentDisabledSkillLaunchPaths(snapshot: DisabledSkillLaunchSnapshot): string[] {+ return snapshot.paths.filter((entry) => canonicalSkillPath(entry.path) === entry.identity)+ .map((entry) => entry.path);+}+export function isSkillDisabled(source: string, disabledPaths: readonly string[]): boolean {const key = canonicalSkillPath(source);return disabledPaths.some((candidate) => canonicalSkillPath(candidate) === key);