Merge pull request #117 from y574444354/fix/hub-command

fix(favorite): ensure /hub enabled skills appear in command list immediately
This commit is contained in:
linkai0924 2026-05-15 22:49:22 +08:00 committed by GitHub
commit 091d3a07d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -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': {

View File

@ -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(),
}