From 5bfaeb21bda3a7a5dbef22f1af6ef1ba9a99ac4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=87=AF90331?= <90331@sangfor.com> Date: Fri, 15 May 2026 22:46:03 +0800 Subject: [PATCH] fix(favorite): ensure /hub enabled skills appear in command list immediately MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace incomplete clearSkillCaches() with clearCommandsCache() so the loadAllCommands memoize layer is also busted when a cloud favorite skill is enabled or disabled via /hub. Add skillChangeDetector.notify() to trigger an immediate REPL command list refresh instead of waiting for the file watcher to detect the change. Signed-off-by: 林凯90331 <90331@sangfor.com> Co-authored-by: CoStrict --- src/costrict/favorite/favorite.ts | 9 ++++++--- src/utils/skills/skillChangeDetector.ts | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/costrict/favorite/favorite.ts b/src/costrict/favorite/favorite.ts index 443f20fc0..f27a9e9df 100644 --- a/src/costrict/favorite/favorite.ts +++ b/src/costrict/favorite/favorite.ts @@ -11,7 +11,8 @@ import { createCoStrictFetch } from '../provider/fetch.js' import { getCoStrictBaseURL } from '../provider/auth.js' import { getClaudeConfigHomeDir } from '../../utils/envUtils.js' import { saveGlobalConfig, getGlobalConfig } from '../../utils/config.js' -import { clearSkillCaches } from '../../skills/loadSkillsDir.js' +import { clearCommandsCache } from '../../commands.js' +import { skillChangeDetector } from '../../utils/skills/skillChangeDetector.js' import { parseFrontmatter } from '../../utils/frontmatterParser.js' import { logForDebugging } from '../../utils/debug.js' import type { McpServerConfig } from '../../services/mcp/types.js' @@ -516,7 +517,8 @@ async function addItemToConfig(item: FavoriteItem, localPath: string) { const destDir = path.join(skillsDir(), item.slug) await mkdir(skillsDir(), { recursive: true }) await copyDir(localPath, destDir) - clearSkillCaches() + clearCommandsCache() + skillChangeDetector.notify() break } case 'agent': { @@ -591,7 +593,8 @@ async function removeItemFromConfig( case 'skill': { const destDir = path.join(skillsDir(), slug) await rm(destDir, { recursive: true, force: true }) - clearSkillCaches() + clearCommandsCache() + skillChangeDetector.notify() break } case 'agent': { diff --git a/src/utils/skills/skillChangeDetector.ts b/src/utils/skills/skillChangeDetector.ts index a3acb5e21..8c323bc56 100644 --- a/src/utils/skills/skillChangeDetector.ts +++ b/src/utils/skills/skillChangeDetector.ts @@ -308,4 +308,10 @@ export const skillChangeDetector = { dispose, subscribe, resetForTesting, + /** + * Manually trigger a skill-change notification. Used when code mutates + * skill directories directly (e.g. /hub enabling a cloud favorite) and + * needs the REPL to refresh its command list immediately. + */ + notify: () => skillsChanged.emit(), }