opencode-agent-skills
Advanced tools
+1
-1
| { | ||
| "name": "opencode-agent-skills", | ||
| "version": "0.6.0", | ||
| "version": "0.6.1", | ||
| "description": "A dynamic skills plugin for OpenCode that provides tools for loading and using reusable AI agent skills.", | ||
@@ -5,0 +5,0 @@ "author": "Josh Thomas <josh@joshthomas.dev>", |
+20
-3
@@ -26,3 +26,13 @@ /** | ||
| const setupCompleteSessions = new Set<string>(); | ||
| const loadedSkillsPerSession = new Map<string, Set<string>>(); | ||
| function getLoadedSkills(sessionID: string): Set<string> { | ||
| let set = loadedSkillsPerSession.get(sessionID); | ||
| if (!set) { | ||
| set = new Set<string>(); | ||
| loadedSkillsPerSession.set(sessionID, set); | ||
| } | ||
| return set; | ||
| } | ||
| function formatMatchedSkillsInjection( | ||
@@ -118,7 +128,10 @@ matchedSkills: Array<{ name: string; description: string }> | ||
| if (matchedSkills.length === 0) { | ||
| const loadedSkills = getLoadedSkills(sessionID); | ||
| const newSkills = matchedSkills.filter(s => !loadedSkills.has(s.name)); | ||
| if (newSkills.length === 0) { | ||
| return; | ||
| } | ||
| const injectionText = formatMatchedSkillsInjection(matchedSkills); | ||
| const injectionText = formatMatchedSkillsInjection(newSkills); | ||
@@ -139,2 +152,3 @@ const context: SessionContext = { | ||
| await injectSkillsList(directory, client, sessionID, context); | ||
| loadedSkillsPerSession.delete(sessionID); | ||
| } | ||
@@ -145,2 +159,3 @@ | ||
| setupCompleteSessions.delete(sessionID); | ||
| loadedSkillsPerSession.delete(sessionID); | ||
| } | ||
@@ -153,5 +168,7 @@ }, | ||
| run_skill_script: RunSkillScript(directory, $), | ||
| use_skill: UseSkill(directory, client), | ||
| use_skill: UseSkill(directory, client, (sessionID, skillName) => { | ||
| getLoadedSkills(sessionID).add(skillName); | ||
| }), | ||
| }, | ||
| }; | ||
| }; |
+7
-1
@@ -200,3 +200,7 @@ /** | ||
| export const UseSkill = (directory: string, client: OpencodeClient) => { | ||
| export const UseSkill = ( | ||
| directory: string, | ||
| client: OpencodeClient, | ||
| onSkillLoaded?: (sessionID: string, skillName: string) => void | ||
| ) => { | ||
| return tool({ | ||
@@ -251,2 +255,4 @@ description: "Load a skill's SKILL.md content into context. Skills contain proven workflows, techniques, and patterns.", | ||
| onSkillLoaded?.(ctx.sessionID, skill.name); | ||
| const scriptInfo = skill.scripts.length > 0 | ||
@@ -253,0 +259,0 @@ ? `\nAvailable scripts: ${skill.scripts.map(s => s.relativePath).join(', ')}` |
62671
1.17%1445
1.4%