From 207469af85cf2764b7aecc80e6ae31188760e022 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 29 Dec 2025 20:04:50 +0530 Subject: [PATCH 01/11] read and inject skills to system message --- core/config/load.ts | 2 + core/config/markdown/loadMarkdownSkills.ts | 64 ++++++++++++++++++++++ core/config/profile/doLoadConfig.ts | 7 +++ core/config/yaml/loadYaml.ts | 1 + core/index.d.ts | 11 ++++ core/llm/skills.ts | 24 ++++++++ gui/src/redux/thunks/streamNormalInput.ts | 1 + gui/src/redux/util/constructMessages.ts | 31 +++++++---- 8 files changed, 131 insertions(+), 10 deletions(-) create mode 100644 core/config/markdown/loadMarkdownSkills.ts create mode 100644 core/llm/skills.ts diff --git a/core/config/load.ts b/core/config/load.ts index 35d12d421..ff14b8115 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -525,6 +525,7 @@ async function intermediateToFinalConfig({ summarize: null, // Not implemented }, rules: [], + skills: [], }; for (const cmd of config.slashCommands ?? []) { @@ -670,6 +671,7 @@ async function finalToBrowserConfig( ui: final.ui, experimental: final.experimental, rules: final.rules, + skills: final.skills, docs: final.docs, tools: final.tools.map(serializeTool), mcpServerStatuses: final.mcpServerStatuses, diff --git a/core/config/markdown/loadMarkdownSkills.ts b/core/config/markdown/loadMarkdownSkills.ts new file mode 100644 index 000000000..a59ec2534 --- /dev/null +++ b/core/config/markdown/loadMarkdownSkills.ts @@ -0,0 +1,64 @@ +import { ConfigValidationError } from "@continuedev/config-yaml"; +import * as YAML from "yaml"; +import { IDE, Skill } from "../.."; +import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; + +// todo: refactor this to packages/config-yaml (like parseMarkdownRule) +function parseSkillMarkdown(content: string): Skill { + const normalizedContent = content.replace(/\r\n/g, "\n"); + + const parts = normalizedContent.split(/^---\s*$/m); + + if (parts.length < 3) { + throw new Error("Invalid skill markdown file"); + } + const frontmatterStr = parts[1]; + const markdownContent = parts.slice(2).join("---"); + + const frontmatter = YAML.parse(frontmatterStr) || {}; // Handle empty frontmatter + // todo: validate frontmatter with zod + + return { + ...frontmatter, + content: markdownContent, + }; +} + +export async function loadMarkdownSkills(ide: IDE) { + const errors: ConfigValidationError[] = []; + const skills: Skill[] = []; + + try { + const yamlAndMarkdownFiles = await getAllDotContinueDefinitionFiles( + ide, + { + includeGlobal: true, + includeWorkspace: true, + fileExtType: "markdown", + }, + "", // SKILL.md can exist in any .continue subdirectory + ); + + const skillFiles = yamlAndMarkdownFiles.filter((file) => + file.path.endsWith("SKILL.md"), + ); + for (const file of skillFiles) { + try { + const skill = parseSkillMarkdown(file.content); + skills.push({ ...skill, path: file.path.slice(7) }); + } catch (error) { + errors.push({ + fatal: false, + message: `Failed to parse markdown skill file: ${error instanceof Error ? error.message : error}`, + }); + } + } + } catch (err) { + errors.push({ + fatal: false, + message: `Error loading markdown skill files: ${err instanceof Error ? err.message : err}`, + }); + } + + return { skills, errors }; +} diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index f33c8a1e9..d06e5541f 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -42,6 +42,7 @@ import { getWorkspaceContinueRuleDotFiles } from "../getWorkspaceContinueRuleDot import { loadContinueConfigFromJson } from "../load"; import { CodebaseRulesCache } from "../markdown/loadCodebaseRules"; import { loadMarkdownRules } from "../markdown/loadMarkdownRules"; +import { loadMarkdownSkills } from "../markdown/loadMarkdownSkills"; import { migrateJsonSharedConfig } from "../migrateSharedConfig"; import { rectifySelectedModelsFromGlobalContext } from "../selectedModels"; import { loadContinueConfigFromYaml } from "../yaml/loadYaml"; @@ -69,6 +70,7 @@ async function loadRules(ide: IDE) { return { rules, errors }; } + export default async function doLoadConfig(options: { ide: IDE; controlPlaneClient: ControlPlaneClient; @@ -157,6 +159,11 @@ export default async function doLoadConfig(options: { errors.push(...rulesErrors); newConfig.rules.unshift(...rules); + // load skills + const { skills, errors: skillsErrors } = await loadMarkdownSkills(ide); + errors.push(...skillsErrors); + newConfig.skills.unshift(...skills); + // Convert invokable rules to slash commands for (const rule of newConfig.rules) { if (rule.invokable) { diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 40821bb04..a7b87b174 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -198,6 +198,7 @@ export async function configYamlToContinueConfig(options: { summarize: null, }, rules: [], + skills: [], requestOptions: { ...config.requestOptions }, }; diff --git a/core/index.d.ts b/core/index.d.ts index 197b5516d..d6d964e94 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1796,6 +1796,7 @@ export interface ContinueConfig { tools: Tool[]; mcpServerStatuses: MCPServerStatus[]; rules: RuleWithSource[]; + skills: Skill[]; modelsByRole: Record; selectedModelByRole: Record; data?: DataDestination[]; @@ -1818,6 +1819,7 @@ export interface BrowserSerializedContinueConfig { tools: Omit[]; mcpServerStatuses: MCPServerStatus[]; rules: RuleWithSource[]; + skills: Skill[]; usePlatform: boolean; tabAutocompleteOptions?: Partial; modelsByRole: Record; @@ -1895,6 +1897,15 @@ export interface RuleWithSource extends RuleMetadata { rule: string; } +export interface Skill { + name: string; + description: string; + path: string; + toolName: string; + content: string; + license?: string; +} + export interface CompleteOnboardingPayload { mode: OnboardingModes; provider?: string; diff --git a/core/llm/skills.ts b/core/llm/skills.ts new file mode 100644 index 000000000..6a186c2d4 --- /dev/null +++ b/core/llm/skills.ts @@ -0,0 +1,24 @@ +import { Skill } from ".."; + +export function getSystemMessageWithSkills( + systemMessage: string, + skills: Skill[], +) { + const lines = [ + "You have access to skills listed in ``. When a task matches a skill's description, read its SKILL.md file to get detailed instructions.", + "", + "", + ]; + for (const skill of skills) { + lines.push(" "); + lines.push(` ${skill.name}`); + lines.push(` ${skill.description}`); + lines.push(` ${skill.path}`); + lines.push(" "); + } + lines.push(""); + + console.log("debug1 with skills", lines.join("\n")); + + return systemMessage + "\n\n" + lines.join("\n"); +} diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 13cc5ebbf..9829bb0a8 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -144,6 +144,7 @@ export const streamNormalInput = createAsyncThunk< systemMessage, state.config.config.rules, state.ui.ruleSettings, + state.config.config.skills, systemToolsFramework, ); diff --git a/gui/src/redux/util/constructMessages.ts b/gui/src/redux/util/constructMessages.ts index 46472f9e2..9e2ba28e9 100644 --- a/gui/src/redux/util/constructMessages.ts +++ b/gui/src/redux/util/constructMessages.ts @@ -4,6 +4,7 @@ import { ContextItemWithId, RuleMetadata, RuleWithSource, + Skill, TextMessagePart, ToolResultChatMessage, UserChatMessage, @@ -11,6 +12,7 @@ import { import { chatMessageIsEmpty } from "core/llm/messages"; import { getSystemMessageWithRules } from "core/llm/rules/getSystemMessageWithRules"; import { RulePolicies } from "core/llm/rules/types"; +import { getSystemMessageWithSkills } from "core/llm/skills"; import { BuiltInToolNames } from "core/tools/builtIn"; import { CANCELLED_TOOL_CALL_MESSAGE, @@ -39,6 +41,7 @@ export function constructMessages( baseSystemMessage: string | undefined, availableRules: RuleWithSource[], rulePolicies: RulePolicies, + skills: Skill[], useSystemToolsFramework?: SystemMessageToolsFramework, ): { messages: ChatMessage[]; @@ -195,19 +198,27 @@ export function constructMessages( .map((item) => item.ctxItems) .flat(); - const { systemMessage, appliedRules } = getSystemMessageWithRules({ - baseSystemMessage, - availableRules, - userMessage: lastUserOrToolMsg, - contextItems: rulesContextItems, - rulePolicies, - }); + const { systemMessage: systemMessageWithRules, appliedRules } = + getSystemMessageWithRules({ + baseSystemMessage, + availableRules, + userMessage: lastUserOrToolMsg, + contextItems: rulesContextItems, + rulePolicies, + }); + + const systemMessageWithSkills = getSystemMessageWithSkills( + systemMessageWithRules, + skills, + ); + + console.log("debug1 with skills", systemMessageWithSkills); // Append conversation summary to system message if it exists - let finalSystemMessage = systemMessage; + let finalSystemMessage = systemMessageWithRules; if (summaryContent) { - finalSystemMessage = systemMessage - ? `${systemMessage}\n\nPrevious conversation summary:\n\n ${summaryContent}` + finalSystemMessage = systemMessageWithRules + ? `${systemMessageWithRules}\n\nPrevious conversation summary:\n\n ${summaryContent}` : `Previous conversation summary:\n\n ${summaryContent}`; } From b6eddec2f474c92c11c13d2e11a8a6a6fa334716 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 30 Dec 2025 12:51:16 +0530 Subject: [PATCH 02/11] add read skill tool --- core/config/profile/doLoadConfig.ts | 1 + core/index.d.ts | 1 + core/llm/skills.ts | 1 - core/tools/builtIn.ts | 1 + core/tools/callTool.ts | 3 ++ core/tools/definitions/index.ts | 1 + core/tools/definitions/readSkill.ts | 29 +++++++++++++++++++ .../tools/definitions/toolDefinitions.test.ts | 1 + core/tools/implementations/readSkill.ts | 29 +++++++++++++++++++ core/tools/index.ts | 7 ++++- core/tools/searchWebGating.vitest.ts | 2 ++ core/util/errors.ts | 3 ++ 12 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 core/tools/definitions/readSkill.ts create mode 100644 core/tools/implementations/readSkill.ts diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index d06e5541f..f18f44536 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -308,6 +308,7 @@ export default async function doLoadConfig(options: { newConfig.tools.push( ...getConfigDependentToolDefinitions({ rules: newConfig.rules, + skills: newConfig.skills, enableExperimentalTools: newConfig.experimental?.enableExperimentalTools ?? false, isSignedIn, diff --git a/core/index.d.ts b/core/index.d.ts index d6d964e94..a61603837 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1148,6 +1148,7 @@ interface ToolChoice { export interface ConfigDependentToolParams { rules: RuleWithSource[]; + skills: Skill[]; enableExperimentalTools: boolean; isSignedIn: boolean; isRemote: boolean; diff --git a/core/llm/skills.ts b/core/llm/skills.ts index 6a186c2d4..fdb6a27cc 100644 --- a/core/llm/skills.ts +++ b/core/llm/skills.ts @@ -13,7 +13,6 @@ export function getSystemMessageWithSkills( lines.push(" "); lines.push(` ${skill.name}`); lines.push(` ${skill.description}`); - lines.push(` ${skill.path}`); lines.push(" "); } lines.push(""); diff --git a/core/tools/builtIn.ts b/core/tools/builtIn.ts index 47cd6769f..0b1346bbc 100644 --- a/core/tools/builtIn.ts +++ b/core/tools/builtIn.ts @@ -16,6 +16,7 @@ export enum BuiltInToolNames { RequestRule = "request_rule", FetchUrlContent = "fetch_url_content", CodebaseTool = "codebase", + ReadSkill = "read_skill", // excluded from allTools for now ViewRepoMap = "view_repo_map", diff --git a/core/tools/callTool.ts b/core/tools/callTool.ts index 8d695e1e1..2dd53474c 100644 --- a/core/tools/callTool.ts +++ b/core/tools/callTool.ts @@ -16,6 +16,7 @@ import { readCurrentlyOpenFileImpl } from "./implementations/readCurrentlyOpenFi import { readFileImpl } from "./implementations/readFile"; import { readFileRangeImpl } from "./implementations/readFileRange"; +import { readSkillImpl } from "./implementations/readSkill"; import { requestRuleImpl } from "./implementations/requestRule"; import { runTerminalCommandImpl } from "./implementations/runTerminalCommand"; import { searchWebImpl } from "./implementations/searchWeb"; @@ -179,6 +180,8 @@ export async function callBuiltInTool( return await requestRuleImpl(args, extras); case BuiltInToolNames.CodebaseTool: return await codebaseToolImpl(args, extras); + case BuiltInToolNames.ReadSkill: + return await readSkillImpl(args, extras); case BuiltInToolNames.ViewRepoMap: return await viewRepoMapImpl(args, extras); case BuiltInToolNames.ViewSubdirectory: diff --git a/core/tools/definitions/index.ts b/core/tools/definitions/index.ts index bf3dc02d9..bfc78ac3d 100644 --- a/core/tools/definitions/index.ts +++ b/core/tools/definitions/index.ts @@ -11,6 +11,7 @@ export { readCurrentlyOpenFileTool } from "./readCurrentlyOpenFile"; export { readFileTool } from "./readFile"; export { readFileRangeTool } from "./readFileRange"; +export { readSkillTool } from "./readSkill"; export { requestRuleTool } from "./requestRule"; export { runTerminalCommandTool } from "./runTerminalCommand"; export { searchWebTool } from "./searchWeb"; diff --git a/core/tools/definitions/readSkill.ts b/core/tools/definitions/readSkill.ts new file mode 100644 index 000000000..66044760e --- /dev/null +++ b/core/tools/definitions/readSkill.ts @@ -0,0 +1,29 @@ +import { Tool } from "../.."; +import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; + +export const readSkillTool: Tool = { + type: "function", + displayTitle: "Read Skill", + wouldLikeTo: "read skill {{{ skillName }}}", + isCurrently: "reading skill {{{ skillName }}}", + hasAlready: "read skill {{{ skillName }}}", + readonly: true, + isInstant: true, + group: BUILT_IN_GROUP_NAME, + function: { + name: BuiltInToolNames.ReadSkill, + description: + "Use this tool to read the content of a skill by its name. Skills contain detailed instructions for specific tasks. The skill name should match one of the available skills listed in the system message.", + parameters: { + type: "object", + required: ["skillName"], + properties: { + skillName: { + type: "string", + description: + "The name of the skill to read. This should match the name field from the available skills.", + }, + }, + }, + }, +}; diff --git a/core/tools/definitions/toolDefinitions.test.ts b/core/tools/definitions/toolDefinitions.test.ts index 265ebe5e1..2534958f5 100644 --- a/core/tools/definitions/toolDefinitions.test.ts +++ b/core/tools/definitions/toolDefinitions.test.ts @@ -6,6 +6,7 @@ describe("Tool Definitions", () => { // Mock params for tools that need them const mockParams: ConfigDependentToolParams = { rules: [], + skills: [], enableExperimentalTools: false, isSignedIn: false, isRemote: false, diff --git a/core/tools/implementations/readSkill.ts b/core/tools/implementations/readSkill.ts new file mode 100644 index 000000000..28b479a72 --- /dev/null +++ b/core/tools/implementations/readSkill.ts @@ -0,0 +1,29 @@ +import { ToolImpl } from "."; +import { ContinueError, ContinueErrorReason } from "../../util/errors"; +import { getStringArg } from "../parseArgs"; + +export const readSkillImpl: ToolImpl = async (args, extras) => { + const skillName = getStringArg(args, "skillName"); + + const skill = extras.config.skills.find((s) => s.name === skillName); + + if (!skill) { + const availableSkills = extras.config.skills.map((s) => s.name).join(", "); + throw new ContinueError( + ContinueErrorReason.SkillNotFound, + `Skill "${skillName}" not found. Available skills: ${availableSkills || "none"}`, + ); + } + + return [ + { + name: `Skill: ${skill.name}`, + description: skill.description, + content: `# ${skill.name}\n\n${skill.description}\n\n## Instructions\n\n${skill.content}`, + uri: { + type: "file", + value: skill.path, + }, + }, + ]; +}; diff --git a/core/tools/index.ts b/core/tools/index.ts index bdc519dc9..c85de5dbb 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -18,11 +18,16 @@ export const getBaseToolDefinitions = () => [ export const getConfigDependentToolDefinitions = ( params: ConfigDependentToolParams, ): Tool[] => { - const { modelName, isSignedIn, enableExperimentalTools, isRemote } = params; + const { modelName, isSignedIn, enableExperimentalTools, isRemote, skills } = + params; const tools: Tool[] = []; tools.push(toolDefinitions.requestRuleTool(params)); + if (skills.length > 0) { + tools.push(toolDefinitions.readSkillTool); + } + if (isSignedIn) { // Web search is only available for signed-in users tools.push(toolDefinitions.searchWebTool); diff --git a/core/tools/searchWebGating.vitest.ts b/core/tools/searchWebGating.vitest.ts index 4ebb6e5b4..2a76d4fa3 100644 --- a/core/tools/searchWebGating.vitest.ts +++ b/core/tools/searchWebGating.vitest.ts @@ -6,6 +6,7 @@ test("searchWeb tool is only available when user is signed in", () => { // Test with signed-in user const signedInTools = getConfigDependentToolDefinitions({ rules: [], + skills: [], enableExperimentalTools: false, isSignedIn: true, isRemote: false, @@ -21,6 +22,7 @@ test("searchWeb tool is only available when user is signed in", () => { // Test with non-signed-in user const notSignedInTools = getConfigDependentToolDefinitions({ rules: [], + skills: [], enableExperimentalTools: false, isSignedIn: false, isRemote: false, diff --git a/core/util/errors.ts b/core/util/errors.ts index 69df7c814..b94b5ac00 100644 --- a/core/util/errors.ts +++ b/core/util/errors.ts @@ -62,6 +62,9 @@ export enum ContinueErrorReason { // Rules RuleNotFound = "rule_not_found", + // Skills + SkillNotFound = "skill_not_found", + // Other Unspecified = "unspecified", // I.e. a known error but no specific code for it Unknown = "unknown", // I.e. an unexpected error From d7543312c23074e5948912efe5491239f10466db Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:22:59 +0530 Subject: [PATCH 03/11] prevent loading in system message --- core/config/load.ts | 2 -- core/config/yaml/loadYaml.ts | 1 - .../tools/definitions/toolDefinitions.test.ts | 1 - core/tools/searchWebGating.vitest.ts | 2 -- gui/src/redux/thunks/streamNormalInput.ts | 1 - gui/src/redux/util/constructMessages.ts | 31 ++++++------------- 6 files changed, 10 insertions(+), 28 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index ff14b8115..35d12d421 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -525,7 +525,6 @@ async function intermediateToFinalConfig({ summarize: null, // Not implemented }, rules: [], - skills: [], }; for (const cmd of config.slashCommands ?? []) { @@ -671,7 +670,6 @@ async function finalToBrowserConfig( ui: final.ui, experimental: final.experimental, rules: final.rules, - skills: final.skills, docs: final.docs, tools: final.tools.map(serializeTool), mcpServerStatuses: final.mcpServerStatuses, diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index a7b87b174..40821bb04 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -198,7 +198,6 @@ export async function configYamlToContinueConfig(options: { summarize: null, }, rules: [], - skills: [], requestOptions: { ...config.requestOptions }, }; diff --git a/core/tools/definitions/toolDefinitions.test.ts b/core/tools/definitions/toolDefinitions.test.ts index 2534958f5..265ebe5e1 100644 --- a/core/tools/definitions/toolDefinitions.test.ts +++ b/core/tools/definitions/toolDefinitions.test.ts @@ -6,7 +6,6 @@ describe("Tool Definitions", () => { // Mock params for tools that need them const mockParams: ConfigDependentToolParams = { rules: [], - skills: [], enableExperimentalTools: false, isSignedIn: false, isRemote: false, diff --git a/core/tools/searchWebGating.vitest.ts b/core/tools/searchWebGating.vitest.ts index 2a76d4fa3..4ebb6e5b4 100644 --- a/core/tools/searchWebGating.vitest.ts +++ b/core/tools/searchWebGating.vitest.ts @@ -6,7 +6,6 @@ test("searchWeb tool is only available when user is signed in", () => { // Test with signed-in user const signedInTools = getConfigDependentToolDefinitions({ rules: [], - skills: [], enableExperimentalTools: false, isSignedIn: true, isRemote: false, @@ -22,7 +21,6 @@ test("searchWeb tool is only available when user is signed in", () => { // Test with non-signed-in user const notSignedInTools = getConfigDependentToolDefinitions({ rules: [], - skills: [], enableExperimentalTools: false, isSignedIn: false, isRemote: false, diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 9829bb0a8..13cc5ebbf 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -144,7 +144,6 @@ export const streamNormalInput = createAsyncThunk< systemMessage, state.config.config.rules, state.ui.ruleSettings, - state.config.config.skills, systemToolsFramework, ); diff --git a/gui/src/redux/util/constructMessages.ts b/gui/src/redux/util/constructMessages.ts index 9e2ba28e9..46472f9e2 100644 --- a/gui/src/redux/util/constructMessages.ts +++ b/gui/src/redux/util/constructMessages.ts @@ -4,7 +4,6 @@ import { ContextItemWithId, RuleMetadata, RuleWithSource, - Skill, TextMessagePart, ToolResultChatMessage, UserChatMessage, @@ -12,7 +11,6 @@ import { import { chatMessageIsEmpty } from "core/llm/messages"; import { getSystemMessageWithRules } from "core/llm/rules/getSystemMessageWithRules"; import { RulePolicies } from "core/llm/rules/types"; -import { getSystemMessageWithSkills } from "core/llm/skills"; import { BuiltInToolNames } from "core/tools/builtIn"; import { CANCELLED_TOOL_CALL_MESSAGE, @@ -41,7 +39,6 @@ export function constructMessages( baseSystemMessage: string | undefined, availableRules: RuleWithSource[], rulePolicies: RulePolicies, - skills: Skill[], useSystemToolsFramework?: SystemMessageToolsFramework, ): { messages: ChatMessage[]; @@ -198,27 +195,19 @@ export function constructMessages( .map((item) => item.ctxItems) .flat(); - const { systemMessage: systemMessageWithRules, appliedRules } = - getSystemMessageWithRules({ - baseSystemMessage, - availableRules, - userMessage: lastUserOrToolMsg, - contextItems: rulesContextItems, - rulePolicies, - }); - - const systemMessageWithSkills = getSystemMessageWithSkills( - systemMessageWithRules, - skills, - ); - - console.log("debug1 with skills", systemMessageWithSkills); + const { systemMessage, appliedRules } = getSystemMessageWithRules({ + baseSystemMessage, + availableRules, + userMessage: lastUserOrToolMsg, + contextItems: rulesContextItems, + rulePolicies, + }); // Append conversation summary to system message if it exists - let finalSystemMessage = systemMessageWithRules; + let finalSystemMessage = systemMessage; if (summaryContent) { - finalSystemMessage = systemMessageWithRules - ? `${systemMessageWithRules}\n\nPrevious conversation summary:\n\n ${summaryContent}` + finalSystemMessage = systemMessage + ? `${systemMessage}\n\nPrevious conversation summary:\n\n ${summaryContent}` : `Previous conversation summary:\n\n ${summaryContent}`; } From cef4b8ded245d1dbfcc7e5f4e18bebde267578e3 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:30:19 +0530 Subject: [PATCH 04/11] get config dependent tool definitions async --- core/config/profile/doLoadConfig.ts | 12 +++--------- core/index.d.ts | 6 ++---- core/tools/definitions/requestRule.ts | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index f18f44536..5ead1d914 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -42,7 +42,6 @@ import { getWorkspaceContinueRuleDotFiles } from "../getWorkspaceContinueRuleDot import { loadContinueConfigFromJson } from "../load"; import { CodebaseRulesCache } from "../markdown/loadCodebaseRules"; import { loadMarkdownRules } from "../markdown/loadMarkdownRules"; -import { loadMarkdownSkills } from "../markdown/loadMarkdownSkills"; import { migrateJsonSharedConfig } from "../migrateSharedConfig"; import { rectifySelectedModelsFromGlobalContext } from "../selectedModels"; import { loadContinueConfigFromYaml } from "../yaml/loadYaml"; @@ -159,11 +158,6 @@ export default async function doLoadConfig(options: { errors.push(...rulesErrors); newConfig.rules.unshift(...rules); - // load skills - const { skills, errors: skillsErrors } = await loadMarkdownSkills(ide); - errors.push(...skillsErrors); - newConfig.skills.unshift(...skills); - // Convert invokable rules to slash commands for (const rule of newConfig.rules) { if (rule.invokable) { @@ -306,15 +300,15 @@ export default async function doLoadConfig(options: { } newConfig.tools.push( - ...getConfigDependentToolDefinitions({ + ...(await getConfigDependentToolDefinitions({ rules: newConfig.rules, - skills: newConfig.skills, enableExperimentalTools: newConfig.experimental?.enableExperimentalTools ?? false, isSignedIn, isRemote: await ide.isWorkspaceRemote(), modelName: newConfig.selectedModelByRole.chat?.model, - }), + ide, + })), ); // Detect duplicate tool names diff --git a/core/index.d.ts b/core/index.d.ts index a61603837..74ace973d 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1148,14 +1148,14 @@ interface ToolChoice { export interface ConfigDependentToolParams { rules: RuleWithSource[]; - skills: Skill[]; enableExperimentalTools: boolean; isSignedIn: boolean; isRemote: boolean; modelName: string | undefined; + ide: IDE; } -export type GetTool = (params: ConfigDependentToolParams) => Tool; +export type GetTool = (params: ConfigDependentToolParams) => Promise; export interface BaseCompletionOptions { temperature?: number; @@ -1797,7 +1797,6 @@ export interface ContinueConfig { tools: Tool[]; mcpServerStatuses: MCPServerStatus[]; rules: RuleWithSource[]; - skills: Skill[]; modelsByRole: Record; selectedModelByRole: Record; data?: DataDestination[]; @@ -1820,7 +1819,6 @@ export interface BrowserSerializedContinueConfig { tools: Omit[]; mcpServerStatuses: MCPServerStatus[]; rules: RuleWithSource[]; - skills: Skill[]; usePlatform: boolean; tabAutocompleteOptions?: Partial; modelsByRole: Record; diff --git a/core/tools/definitions/requestRule.ts b/core/tools/definitions/requestRule.ts index 30443506c..7b2d2e42c 100644 --- a/core/tools/definitions/requestRule.ts +++ b/core/tools/definitions/requestRule.ts @@ -37,7 +37,7 @@ function getRequestRuleSystemMessageDescription( return prefix + availableRules + suffix; } -export const requestRuleTool: GetTool = ({ rules }) => ({ +export const requestRuleTool: GetTool = async ({ rules }) => ({ type: "function", displayTitle: "Request Rules", wouldLikeTo: "request rule {{{ name }}}", From c219e3e5c9d6b0a727ba4ab7afc2cd41605da1f3 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:31:04 +0530 Subject: [PATCH 05/11] read skill is a tool definition --- core/tools/definitions/readSkill.ts | 51 ++++++++++++++----------- core/tools/implementations/readSkill.ts | 7 +++- core/tools/index.ts | 14 +++---- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/core/tools/definitions/readSkill.ts b/core/tools/definitions/readSkill.ts index 66044760e..7d0b18218 100644 --- a/core/tools/definitions/readSkill.ts +++ b/core/tools/definitions/readSkill.ts @@ -1,29 +1,34 @@ -import { Tool } from "../.."; +import { GetTool } from "../.."; +import { loadMarkdownSkills } from "../../config/markdown/loadMarkdownSkills"; import { BUILT_IN_GROUP_NAME, BuiltInToolNames } from "../builtIn"; -export const readSkillTool: Tool = { - type: "function", - displayTitle: "Read Skill", - wouldLikeTo: "read skill {{{ skillName }}}", - isCurrently: "reading skill {{{ skillName }}}", - hasAlready: "read skill {{{ skillName }}}", - readonly: true, - isInstant: true, - group: BUILT_IN_GROUP_NAME, - function: { - name: BuiltInToolNames.ReadSkill, - description: - "Use this tool to read the content of a skill by its name. Skills contain detailed instructions for specific tasks. The skill name should match one of the available skills listed in the system message.", - parameters: { - type: "object", - required: ["skillName"], - properties: { - skillName: { - type: "string", - description: - "The name of the skill to read. This should match the name field from the available skills.", +export const readSkillTool: GetTool = async (params) => { + const { skills } = await loadMarkdownSkills(params.ide); + return { + type: "function", + displayTitle: "Read Skill", + wouldLikeTo: "read skill {{{ skillName }}}", + isCurrently: "reading skill {{{ skillName }}}", + hasAlready: "read skill {{{ skillName }}}", + readonly: true, + isInstant: true, + group: BUILT_IN_GROUP_NAME, + function: { + name: BuiltInToolNames.ReadSkill, + description: ` +Use this tool to read the content of a skill by its name. Skills contain detailed instructions for specific tasks. The skill name should match one of the available skills listed below: +${skills.map((skill) => `\nname: ${skill.name}\ndescription: ${skill.description}\n`)}`, + parameters: { + type: "object", + required: ["skillName"], + properties: { + skillName: { + type: "string", + description: + "The name of the skill to read. This should match the name from the available skills.", + }, }, }, }, - }, + }; }; diff --git a/core/tools/implementations/readSkill.ts b/core/tools/implementations/readSkill.ts index 28b479a72..5cb471581 100644 --- a/core/tools/implementations/readSkill.ts +++ b/core/tools/implementations/readSkill.ts @@ -1,14 +1,17 @@ import { ToolImpl } from "."; +import { loadMarkdownSkills } from "../../config/markdown/loadMarkdownSkills"; import { ContinueError, ContinueErrorReason } from "../../util/errors"; import { getStringArg } from "../parseArgs"; export const readSkillImpl: ToolImpl = async (args, extras) => { const skillName = getStringArg(args, "skillName"); - const skill = extras.config.skills.find((s) => s.name === skillName); + const { skills } = await loadMarkdownSkills(extras.ide); + + const skill = skills.find((s) => s.name === skillName); if (!skill) { - const availableSkills = extras.config.skills.map((s) => s.name).join(", "); + const availableSkills = skills.map((s) => s.name).join(", "); throw new ContinueError( ContinueErrorReason.SkillNotFound, `Skill "${skillName}" not found. Available skills: ${availableSkills || "none"}`, diff --git a/core/tools/index.ts b/core/tools/index.ts index c85de5dbb..15d52d3ac 100644 --- a/core/tools/index.ts +++ b/core/tools/index.ts @@ -15,18 +15,14 @@ export const getBaseToolDefinitions = () => [ toolDefinitions.fetchUrlContentTool, ]; -export const getConfigDependentToolDefinitions = ( +export const getConfigDependentToolDefinitions = async ( params: ConfigDependentToolParams, -): Tool[] => { - const { modelName, isSignedIn, enableExperimentalTools, isRemote, skills } = - params; +): Promise => { + const { modelName, isSignedIn, enableExperimentalTools, isRemote } = params; const tools: Tool[] = []; - tools.push(toolDefinitions.requestRuleTool(params)); - - if (skills.length > 0) { - tools.push(toolDefinitions.readSkillTool); - } + tools.push(await toolDefinitions.requestRuleTool(params)); + tools.push(await toolDefinitions.readSkillTool(params)); if (isSignedIn) { // Web search is only available for signed-in users From 5f7ecaba01f5272b8ac8fcbf0b1a34cf12f33130 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 6 Jan 2026 17:58:48 +0530 Subject: [PATCH 06/11] fix test lints --- core/tools/definitions/toolDefinitions.test.ts | 13 ++++++++----- core/tools/searchWebGating.vitest.ts | 8 +++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/tools/definitions/toolDefinitions.test.ts b/core/tools/definitions/toolDefinitions.test.ts index 265ebe5e1..6b64f542c 100644 --- a/core/tools/definitions/toolDefinitions.test.ts +++ b/core/tools/definitions/toolDefinitions.test.ts @@ -10,21 +10,24 @@ describe("Tool Definitions", () => { isSignedIn: false, isRemote: false, modelName: "a model", + ide: {} as any, }; // Helper function to get the actual tool object - const getToolObject = (toolDefinition: Tool | GetTool): Tool => { + const getToolObject = async ( + toolDefinition: Tool | GetTool, + ): Promise => { if (typeof toolDefinition === "function") { return toolDefinition(mockParams); } return toolDefinition; }; - it("should have all required parameters defined in properties for each tool", () => { + it("should have all required parameters defined in properties for each tool", async () => { const exportedTools = Object.values(toolDefinitions); - exportedTools.forEach((toolDefinition) => { - const tool = getToolObject(toolDefinition); + for (const toolDefinition of exportedTools) { + const tool = await getToolObject(toolDefinition); // Each tool should have the required structure expect(tool).toHaveProperty("type", "function"); @@ -52,6 +55,6 @@ describe("Tool Definitions", () => { expect(typeof property.type).toBe("string"); }); } - }); + } }); }); diff --git a/core/tools/searchWebGating.vitest.ts b/core/tools/searchWebGating.vitest.ts index 4ebb6e5b4..e49984bea 100644 --- a/core/tools/searchWebGating.vitest.ts +++ b/core/tools/searchWebGating.vitest.ts @@ -2,14 +2,15 @@ import { expect, test } from "vitest"; import { BuiltInToolNames } from "./builtIn"; import { getConfigDependentToolDefinitions } from "./index"; -test("searchWeb tool is only available when user is signed in", () => { +test("searchWeb tool is only available when user is signed in", async () => { // Test with signed-in user - const signedInTools = getConfigDependentToolDefinitions({ + const signedInTools = await getConfigDependentToolDefinitions({ rules: [], enableExperimentalTools: false, isSignedIn: true, isRemote: false, modelName: "", + ide: {} as any, }); const searchWebToolSignedIn = signedInTools.find( @@ -19,12 +20,13 @@ test("searchWeb tool is only available when user is signed in", () => { expect(searchWebToolSignedIn?.displayTitle).toBe("Search Web"); // Test with non-signed-in user - const notSignedInTools = getConfigDependentToolDefinitions({ + const notSignedInTools = await getConfigDependentToolDefinitions({ rules: [], enableExperimentalTools: false, isSignedIn: false, isRemote: false, modelName: "", + ide: {} as any, }); const searchWebToolNotSignedIn = notSignedInTools.find( From 6df421fad99486d54fc1383805d63c12933176eb Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:02:59 +0530 Subject: [PATCH 07/11] remove system message skill --- core/llm/skills.ts | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 core/llm/skills.ts diff --git a/core/llm/skills.ts b/core/llm/skills.ts deleted file mode 100644 index fdb6a27cc..000000000 --- a/core/llm/skills.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Skill } from ".."; - -export function getSystemMessageWithSkills( - systemMessage: string, - skills: Skill[], -) { - const lines = [ - "You have access to skills listed in ``. When a task matches a skill's description, read its SKILL.md file to get detailed instructions.", - "", - "", - ]; - for (const skill of skills) { - lines.push(" "); - lines.push(` ${skill.name}`); - lines.push(` ${skill.description}`); - lines.push(" "); - } - lines.push(""); - - console.log("debug1 with skills", lines.join("\n")); - - return systemMessage + "\n\n" + lines.join("\n"); -} From e0753f5be225aa89a4355286a4c3951744217ae0 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 6 Jan 2026 18:16:45 +0530 Subject: [PATCH 08/11] simplify tool frontmatter validation --- core/config/markdown/loadMarkdownSkills.ts | 44 ++++++++++------------ core/index.d.ts | 1 - 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/core/config/markdown/loadMarkdownSkills.ts b/core/config/markdown/loadMarkdownSkills.ts index a59ec2534..a06d64408 100644 --- a/core/config/markdown/loadMarkdownSkills.ts +++ b/core/config/markdown/loadMarkdownSkills.ts @@ -1,28 +1,15 @@ -import { ConfigValidationError } from "@continuedev/config-yaml"; -import * as YAML from "yaml"; +import { + ConfigValidationError, + parseMarkdownRule, +} from "@continuedev/config-yaml"; +import z from "zod"; import { IDE, Skill } from "../.."; import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; -// todo: refactor this to packages/config-yaml (like parseMarkdownRule) -function parseSkillMarkdown(content: string): Skill { - const normalizedContent = content.replace(/\r\n/g, "\n"); - - const parts = normalizedContent.split(/^---\s*$/m); - - if (parts.length < 3) { - throw new Error("Invalid skill markdown file"); - } - const frontmatterStr = parts[1]; - const markdownContent = parts.slice(2).join("---"); - - const frontmatter = YAML.parse(frontmatterStr) || {}; // Handle empty frontmatter - // todo: validate frontmatter with zod - - return { - ...frontmatter, - content: markdownContent, - }; -} +const skillFrontmatterSchema = z.object({ + name: z.string().min(1), + description: z.string().min(1), +}); export async function loadMarkdownSkills(ide: IDE) { const errors: ConfigValidationError[] = []; @@ -44,8 +31,17 @@ export async function loadMarkdownSkills(ide: IDE) { ); for (const file of skillFiles) { try { - const skill = parseSkillMarkdown(file.content); - skills.push({ ...skill, path: file.path.slice(7) }); + const { frontmatter, markdown } = parseMarkdownRule( + file.content, + ) as unknown as { frontmatter: Skill; markdown: string }; + + const validatedFrontmatter = skillFrontmatterSchema.parse(frontmatter); + + skills.push({ + ...validatedFrontmatter, + content: markdown, + path: file.path.slice(7), + }); } catch (error) { errors.push({ fatal: false, diff --git a/core/index.d.ts b/core/index.d.ts index 74ace973d..ed9dfb0aa 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1900,7 +1900,6 @@ export interface Skill { name: string; description: string; path: string; - toolName: string; content: string; license?: string; } From 85759451cb53b9dd9b5e5c1fecef2bbee9b6b05e Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 15 Jan 2026 12:42:45 +0530 Subject: [PATCH 09/11] load skills from .claude directory also put skills inside skills/ directory --- core/config/markdown/loadMarkdownSkills.ts | 65 +++++++++++++++++----- 1 file changed, 51 insertions(+), 14 deletions(-) diff --git a/core/config/markdown/loadMarkdownSkills.ts b/core/config/markdown/loadMarkdownSkills.ts index a06d64408..b690e06ca 100644 --- a/core/config/markdown/loadMarkdownSkills.ts +++ b/core/config/markdown/loadMarkdownSkills.ts @@ -4,6 +4,10 @@ import { } from "@continuedev/config-yaml"; import z from "zod"; import { IDE, Skill } from "../.."; +import { walkDir } from "../../indexing/walkDir"; +import { localPathToUri } from "../../util/pathToUri"; +import { getGlobalFolderWithName } from "../../util/paths"; +import { joinPathsToUri } from "../../util/uri"; import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; const skillFrontmatterSchema = z.object({ @@ -11,28 +15,61 @@ const skillFrontmatterSchema = z.object({ description: z.string().min(1), }); +const SKILLS_DIR = "skills"; + +/** + * Get skills from .claude/skills directory + */ +async function getClaudeSkillsDir(ide: IDE) { + const fullDirs = (await ide.getWorkspaceDirs()).map((dir) => + joinPathsToUri(dir, ".claude", SKILLS_DIR), + ); + + fullDirs.push(localPathToUri(getGlobalFolderWithName(SKILLS_DIR))); + + return ( + await Promise.all( + fullDirs.map(async (dir) => { + const exists = await ide.fileExists(dir); + if (!exists) return []; + const uris = await walkDir(dir, ide, { + source: "get claude skills files", + }); + // filter markdown files only + return uris.filter((uri) => uri.endsWith(".md")); + }), + ) + ).flat(); +} + export async function loadMarkdownSkills(ide: IDE) { const errors: ConfigValidationError[] = []; const skills: Skill[] = []; try { - const yamlAndMarkdownFiles = await getAllDotContinueDefinitionFiles( - ide, - { - includeGlobal: true, - includeWorkspace: true, - fileExtType: "markdown", - }, - "", // SKILL.md can exist in any .continue subdirectory - ); + const yamlAndMarkdownFileUris = [ + ...( + await getAllDotContinueDefinitionFiles( + ide, + { + includeGlobal: true, + includeWorkspace: true, + fileExtType: "markdown", + }, + SKILLS_DIR, + ) + ).map((file) => file.path), + ...(await getClaudeSkillsDir(ide)), + ]; - const skillFiles = yamlAndMarkdownFiles.filter((file) => - file.path.endsWith("SKILL.md"), + const skillFiles = yamlAndMarkdownFileUris.filter((path) => + path.endsWith("SKILL.md"), ); - for (const file of skillFiles) { + for (const fileUri of skillFiles) { try { + const content = await ide.readFile(fileUri); const { frontmatter, markdown } = parseMarkdownRule( - file.content, + content, ) as unknown as { frontmatter: Skill; markdown: string }; const validatedFrontmatter = skillFrontmatterSchema.parse(frontmatter); @@ -40,7 +77,7 @@ export async function loadMarkdownSkills(ide: IDE) { skills.push({ ...validatedFrontmatter, content: markdown, - path: file.path.slice(7), + path: fileUri, }); } catch (error) { errors.push({ From b9bcd33ccef3c90b8d9c1fb01a1073e547274771 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 15 Jan 2026 13:04:58 +0530 Subject: [PATCH 10/11] add supporting files for skill tool --- core/config/markdown/loadMarkdownSkills.ts | 11 ++++++++++- core/index.d.ts | 1 + core/tools/implementations/readSkill.ts | 11 ++++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/core/config/markdown/loadMarkdownSkills.ts b/core/config/markdown/loadMarkdownSkills.ts index b690e06ca..2ef03e19e 100644 --- a/core/config/markdown/loadMarkdownSkills.ts +++ b/core/config/markdown/loadMarkdownSkills.ts @@ -33,7 +33,7 @@ async function getClaudeSkillsDir(ide: IDE) { const exists = await ide.fileExists(dir); if (!exists) return []; const uris = await walkDir(dir, ide, { - source: "get claude skills files", + source: "get .claude skills files", }); // filter markdown files only return uris.filter((uri) => uri.endsWith(".md")); @@ -74,10 +74,19 @@ export async function loadMarkdownSkills(ide: IDE) { const validatedFrontmatter = skillFrontmatterSchema.parse(frontmatter); + const filesInSkillsDirectory = await walkDir( + fileUri.substring(0, fileUri.lastIndexOf("/")), + ide, + { + source: "get skill files", + }, + ); + skills.push({ ...validatedFrontmatter, content: markdown, path: fileUri, + files: filesInSkillsDirectory, }); } catch (error) { errors.push({ diff --git a/core/index.d.ts b/core/index.d.ts index ed9dfb0aa..6f23bfbde 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -1901,6 +1901,7 @@ export interface Skill { description: string; path: string; content: string; + files: string[]; license?: string; } diff --git a/core/tools/implementations/readSkill.ts b/core/tools/implementations/readSkill.ts index 5cb471581..7dd1df5d5 100644 --- a/core/tools/implementations/readSkill.ts +++ b/core/tools/implementations/readSkill.ts @@ -22,7 +22,16 @@ export const readSkillImpl: ToolImpl = async (args, extras) => { { name: `Skill: ${skill.name}`, description: skill.description, - content: `# ${skill.name}\n\n${skill.description}\n\n## Instructions\n\n${skill.content}`, + content: `# ${skill.name}\n +${skill.description}\n +## Instructions\n +${skill.content}\n +## Supporting files +Skill directory: +${skill.files.join("\n")} + +Use the read file tool to access these files as needed. +`, uri: { type: "file", value: skill.path, From f5c345254d0cb4c062f3378e340e77cffff324c6 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 15 Jan 2026 19:00:09 +0530 Subject: [PATCH 11/11] support relative path for workspace dirs --- core/config/markdown/loadMarkdownSkills.ts | 22 ++++++++++++++-------- core/tools/implementations/readSkill.ts | 22 ++++++++++++---------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/core/config/markdown/loadMarkdownSkills.ts b/core/config/markdown/loadMarkdownSkills.ts index 2ef03e19e..a4681daf2 100644 --- a/core/config/markdown/loadMarkdownSkills.ts +++ b/core/config/markdown/loadMarkdownSkills.ts @@ -7,7 +7,7 @@ import { IDE, Skill } from "../.."; import { walkDir } from "../../indexing/walkDir"; import { localPathToUri } from "../../util/pathToUri"; import { getGlobalFolderWithName } from "../../util/paths"; -import { joinPathsToUri } from "../../util/uri"; +import { findUriInDirs, joinPathsToUri } from "../../util/uri"; import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants"; const skillFrontmatterSchema = z.object({ @@ -65,6 +65,8 @@ export async function loadMarkdownSkills(ide: IDE) { const skillFiles = yamlAndMarkdownFileUris.filter((path) => path.endsWith("SKILL.md"), ); + + const workspaceDirs = await ide.getWorkspaceDirs(); for (const fileUri of skillFiles) { try { const content = await ide.readFile(fileUri); @@ -74,18 +76,22 @@ export async function loadMarkdownSkills(ide: IDE) { const validatedFrontmatter = skillFrontmatterSchema.parse(frontmatter); - const filesInSkillsDirectory = await walkDir( - fileUri.substring(0, fileUri.lastIndexOf("/")), - ide, - { + const filesInSkillsDirectory = ( + await walkDir(fileUri.substring(0, fileUri.lastIndexOf("/")), ide, { source: "get skill files", - }, - ); + }) + ) + // do not include SKILL.md as it is already in content + .filter((file) => !file.endsWith("SKILL.md")); + + const foundRelativeUri = findUriInDirs(fileUri, workspaceDirs); skills.push({ ...validatedFrontmatter, content: markdown, - path: fileUri, + path: foundRelativeUri.foundInDir + ? foundRelativeUri.relativePathOrBasename + : fileUri, files: filesInSkillsDirectory, }); } catch (error) { diff --git a/core/tools/implementations/readSkill.ts b/core/tools/implementations/readSkill.ts index 7dd1df5d5..6fa9f7e98 100644 --- a/core/tools/implementations/readSkill.ts +++ b/core/tools/implementations/readSkill.ts @@ -18,20 +18,22 @@ export const readSkillImpl: ToolImpl = async (args, extras) => { ); } - return [ - { - name: `Skill: ${skill.name}`, - description: skill.description, - content: `# ${skill.name}\n -${skill.description}\n -## Instructions\n -${skill.content}\n + let content = skill.content; + + if (skill.files.length > 0) { + content += `\n ## Supporting files Skill directory: ${skill.files.join("\n")} -Use the read file tool to access these files as needed. -`, +Use the read file tool to access these files as needed.`; + } + + return [ + { + name: `Skill: ${skill.name}`, + description: skill.description, + content, uri: { type: "file", value: skill.path,