Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 1a9fafc

Browse files
committed
fix: add validation for built-in skills in message handlers
1 parent a0ca389 commit 1a9fafc

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/core/webview/skillsMessageHandler.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ export async function handleCreateSkill(
4444
throw new Error(t("skills:errors.missing_create_fields"))
4545
}
4646

47+
// Built-in skills cannot be created
48+
if (source === "built-in") {
49+
throw new Error(t("skills:errors.cannot_modify_builtin"))
50+
}
51+
4752
const skillsManager = provider.getSkillsManager()
4853
if (!skillsManager) {
4954
throw new Error(t("skills:errors.manager_unavailable"))
@@ -82,6 +87,11 @@ export async function handleDeleteSkill(
8287
throw new Error(t("skills:errors.missing_delete_fields"))
8388
}
8489

90+
// Built-in skills cannot be deleted
91+
if (source === "built-in") {
92+
throw new Error(t("skills:errors.cannot_modify_builtin"))
93+
}
94+
8595
const skillsManager = provider.getSkillsManager()
8696
if (!skillsManager) {
8797
throw new Error(t("skills:errors.manager_unavailable"))
@@ -114,6 +124,11 @@ export async function handleOpenSkillFile(provider: ClineProvider, message: Webv
114124
throw new Error(t("skills:errors.missing_delete_fields"))
115125
}
116126

127+
// Built-in skills cannot be opened as files (they have no file path)
128+
if (source === "built-in") {
129+
throw new Error(t("skills:errors.cannot_open_builtin"))
130+
}
131+
117132
const skillsManager = provider.getSkillsManager()
118133
if (!skillsManager) {
119134
throw new Error(t("skills:errors.manager_unavailable"))

src/core/webview/webviewMessageHandler.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2245,10 +2245,9 @@ export const webviewMessageHandler = async (
22452245
const yamlContent = await fs.readFile(fileUri[0].fsPath, "utf-8")
22462246

22472247
// Import the mode with the specified source level
2248-
const result = await provider.customModesManager.importModeWithRules(
2249-
yamlContent,
2250-
message.source || "project", // Default to project if not specified
2251-
)
2248+
// Note: "built-in" is not a valid source for importing modes
2249+
const importSource = message.source === "global" ? "global" : "project"
2250+
const result = await provider.customModesManager.importModeWithRules(yamlContent, importSource)
22522251

22532252
if (result.success) {
22542253
// Update state after importing

src/i18n/locales/en/skills.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
"missing_create_fields": "Missing required fields: skillName, source, or skillDescription",
1010
"manager_unavailable": "Skills manager not available",
1111
"missing_delete_fields": "Missing required fields: skillName or source",
12-
"skill_not_found": "Skill \"{{name}}\" not found"
12+
"skill_not_found": "Skill \"{{name}}\" not found",
13+
"cannot_modify_builtin": "Built-in skills cannot be created or deleted",
14+
"cannot_open_builtin": "Built-in skills cannot be opened as files"
1315
}
1416
}

0 commit comments

Comments
 (0)