Skip to content

Commit 2272cdc

Browse files
committed
feat: add functions to manage user plugin skills directory paths and refactor skill manifest listing
1 parent c6eada6 commit 2272cdc

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

agent/skills/registry.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { parse as parseYaml } from "yaml";
66
const PLUGIN_SKILLS_DIRECTORY_PATH = fileURLToPath(
77
new URL("../../custom/skills/", import.meta.url),
88
);
9+
const USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS = [
10+
"plugins",
11+
"adminforth-agent",
12+
"skills",
13+
];
914
const SKILL_MARKDOWN_FILENAME = "SKILL.md";
1015
const SKILL_FRONTMATTER_SEPARATOR = "\n---\n";
1116

@@ -78,13 +83,31 @@ export function getProjectSkillsDirectoryPath(customComponentsDir: string) {
7883
return path.resolve(customComponentsDir, "skills");
7984
}
8085

86+
export function getProjectPluginSkillsDirectoryPath(customComponentsDir: string) {
87+
return path.resolve(
88+
customComponentsDir,
89+
...USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS,
90+
);
91+
}
92+
93+
function getProjectSkillDirectoryPaths(customComponentsDir: string) {
94+
return [
95+
getProjectSkillsDirectoryPath(customComponentsDir),
96+
getProjectPluginSkillsDirectoryPath(customComponentsDir),
97+
];
98+
}
99+
81100
export async function listBundledSkillManifests() {
82101
return await listDirectorySkillManifests(PLUGIN_SKILLS_DIRECTORY_PATH);
83102
}
84103

85104
export async function listProjectSkillManifests(customComponentsDir: string) {
86-
return await listDirectorySkillManifests(
87-
getProjectSkillsDirectoryPath(customComponentsDir),
105+
return mergeSkillManifests(
106+
await Promise.all(
107+
getProjectSkillDirectoryPaths(customComponentsDir).map(
108+
listDirectorySkillManifests,
109+
),
110+
),
88111
);
89112
}
90113

@@ -114,7 +137,7 @@ export async function loadSkillMarkdown(skillName: string, customComponentsDir:
114137
}
115138

116139
const directories = [
117-
getProjectSkillsDirectoryPath(customComponentsDir),
140+
...getProjectSkillDirectoryPaths(customComponentsDir),
118141
PLUGIN_SKILLS_DIRECTORY_PATH,
119142
];
120143

0 commit comments

Comments
 (0)