MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / updateSkillModes

Method updateSkillModes

src/services/skills/SkillsManager.ts:527–562  ·  view source on GitHub ↗

* Update the mode associations for a skill by modifying its SKILL.md frontmatter. * @param name - Skill name * @param source - Where the skill is located ("global" or "project") * @param newModeSlugs - New mode slugs (undefined/empty = any mode)

(name: string, source: "global" | "project", newModeSlugs?: string[])

Source from the content-addressed store, hash-verified

525 * @param newModeSlugs - New mode slugs (undefined/empty = any mode)
526 */
527 async updateSkillModes(name: string, source: "global" | "project", newModeSlugs?: string[]): Promise<void> {
528 // Find any skill with this name and source (regardless of current mode)
529 let skill: SkillMetadata | undefined
530 for (const s of this.skills.values()) {
531 if (s.name === name && s.source === source) {
532 skill = s
533 break
534 }
535 }
536
537 if (!skill) {
538 throw new Error(t("skills:errors.not_found", { name, source, modeInfo: "" }))
539 }
540
541 // Read the current SKILL.md file
542 const fileContent = await fs.readFile(skill.path, "utf-8")
543 const { data: frontmatter, content: body } = matter(fileContent)
544
545 // Update the frontmatter with new modeSlugs
546 if (newModeSlugs && newModeSlugs.length > 0) {
547 frontmatter.modeSlugs = newModeSlugs
548 // Remove legacy mode field if present
549 delete frontmatter.mode
550 } else {
551 // Empty/undefined = any mode, remove mode restrictions
552 delete frontmatter.modeSlugs
553 delete frontmatter.mode
554 }
555
556 // Serialize back to SKILL.md format
557 const newContent = matter.stringify(body, frontmatter)
558 await fs.writeFile(skill.path, newContent, "utf-8")
559
560 // Refresh skills list
561 await this.discoverSkills()
562 }
563
564 /**
565 * Get all skills directories to scan, including mode-specific directories.

Callers 1

handleUpdateSkillModesFunction · 0.80

Calls 4

discoverSkillsMethod · 0.95
tFunction · 0.90
writeFileMethod · 0.80
readFileMethod · 0.45

Tested by

no test coverage detected