fix(favorite): ensure /hub enabled skills appear in command list immediately
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 <zgsm@sangfor.com.cn>
This commit is contained in:
parent
754157fd88
commit
5bfaeb21bd
|
|
@ -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': {
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user