@adminforth/agent 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/agent/skills/registry.ts
CHANGED
|
@@ -6,6 +6,11 @@ import { parse as parseYaml } from "yaml";
|
|
|
6
6
|
const PLUGIN_SKILLS_DIRECTORY_PATH = fileURLToPath(
|
|
7
7
|
new URL("../../custom/skills/", import.meta.url),
|
|
8
8
|
);
|
|
9
|
+
const USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS = [
|
|
10
|
+
"plugins",
|
|
11
|
+
"adminforth-agent",
|
|
12
|
+
"skills",
|
|
13
|
+
];
|
|
9
14
|
const SKILL_MARKDOWN_FILENAME = "SKILL.md";
|
|
10
15
|
const SKILL_FRONTMATTER_SEPARATOR = "\n---\n";
|
|
11
16
|
|
|
@@ -78,13 +83,31 @@ export function getProjectSkillsDirectoryPath(customComponentsDir: string) {
|
|
|
78
83
|
return path.resolve(customComponentsDir, "skills");
|
|
79
84
|
}
|
|
80
85
|
|
|
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
|
+
|
|
81
100
|
export async function listBundledSkillManifests() {
|
|
82
101
|
return await listDirectorySkillManifests(PLUGIN_SKILLS_DIRECTORY_PATH);
|
|
83
102
|
}
|
|
84
103
|
|
|
85
104
|
export async function listProjectSkillManifests(customComponentsDir: string) {
|
|
86
|
-
return
|
|
87
|
-
|
|
105
|
+
return mergeSkillManifests(
|
|
106
|
+
await Promise.all(
|
|
107
|
+
getProjectSkillDirectoryPaths(customComponentsDir).map(
|
|
108
|
+
listDirectorySkillManifests,
|
|
109
|
+
),
|
|
110
|
+
),
|
|
88
111
|
);
|
|
89
112
|
}
|
|
90
113
|
|
|
@@ -114,7 +137,7 @@ export async function loadSkillMarkdown(skillName: string, customComponentsDir:
|
|
|
114
137
|
}
|
|
115
138
|
|
|
116
139
|
const directories = [
|
|
117
|
-
|
|
140
|
+
...getProjectSkillDirectoryPaths(customComponentsDir),
|
|
118
141
|
PLUGIN_SKILLS_DIRECTORY_PATH,
|
|
119
142
|
];
|
|
120
143
|
|
|
@@ -12,6 +12,11 @@ import path from "path";
|
|
|
12
12
|
import { fileURLToPath } from "url";
|
|
13
13
|
import { parse as parseYaml } from "yaml";
|
|
14
14
|
const PLUGIN_SKILLS_DIRECTORY_PATH = fileURLToPath(new URL("../../custom/skills/", import.meta.url));
|
|
15
|
+
const USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS = [
|
|
16
|
+
"plugins",
|
|
17
|
+
"adminforth-agent",
|
|
18
|
+
"skills",
|
|
19
|
+
];
|
|
15
20
|
const SKILL_MARKDOWN_FILENAME = "SKILL.md";
|
|
16
21
|
const SKILL_FRONTMATTER_SEPARATOR = "\n---\n";
|
|
17
22
|
function parseSkillManifest(directoryName, markdown) {
|
|
@@ -58,6 +63,15 @@ function mergeSkillManifests(skillGroups) {
|
|
|
58
63
|
export function getProjectSkillsDirectoryPath(customComponentsDir) {
|
|
59
64
|
return path.resolve(customComponentsDir, "skills");
|
|
60
65
|
}
|
|
66
|
+
export function getProjectPluginSkillsDirectoryPath(customComponentsDir) {
|
|
67
|
+
return path.resolve(customComponentsDir, ...USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS);
|
|
68
|
+
}
|
|
69
|
+
function getProjectSkillDirectoryPaths(customComponentsDir) {
|
|
70
|
+
return [
|
|
71
|
+
getProjectSkillsDirectoryPath(customComponentsDir),
|
|
72
|
+
getProjectPluginSkillsDirectoryPath(customComponentsDir),
|
|
73
|
+
];
|
|
74
|
+
}
|
|
61
75
|
export function listBundledSkillManifests() {
|
|
62
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
77
|
return yield listDirectorySkillManifests(PLUGIN_SKILLS_DIRECTORY_PATH);
|
|
@@ -65,7 +79,7 @@ export function listBundledSkillManifests() {
|
|
|
65
79
|
}
|
|
66
80
|
export function listProjectSkillManifests(customComponentsDir) {
|
|
67
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
return yield
|
|
82
|
+
return mergeSkillManifests(yield Promise.all(getProjectSkillDirectoryPaths(customComponentsDir).map(listDirectorySkillManifests)));
|
|
69
83
|
});
|
|
70
84
|
}
|
|
71
85
|
export function listSkillManifests(customComponentsDir) {
|
|
@@ -90,7 +104,7 @@ export function loadSkillMarkdown(skillName, customComponentsDir) {
|
|
|
90
104
|
return null;
|
|
91
105
|
}
|
|
92
106
|
const directories = [
|
|
93
|
-
|
|
107
|
+
...getProjectSkillDirectoryPaths(customComponentsDir),
|
|
94
108
|
PLUGIN_SKILLS_DIRECTORY_PATH,
|
|
95
109
|
];
|
|
96
110
|
for (const skillsDirectoryPath of directories) {
|