-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopencode-plugin.js
More file actions
45 lines (36 loc) · 1.13 KB
/
Copy pathopencode-plugin.js
File metadata and controls
45 lines (36 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const pluginRoot = dirname(fileURLToPath(import.meta.url));
const profiles = Object.freeze({
base: ["base"],
nextjs: ["base", "nextjs"],
turborepo: ["base", "turborepo"],
"nextjs-turbo": ["base", "nextjs", "turborepo"],
});
function selectedProfile() {
const requestedProfile = process.env.OPENPOWERS_PROFILE?.trim() || "base";
if (Object.hasOwn(profiles, requestedProfile)) {
return requestedProfile;
}
console.warn(
`[openpowers] Unknown profile "${requestedProfile}". Falling back to "base".`,
);
return "base";
}
function skillDirectoriesFor(profile) {
return profiles[profile].map((group) => join(pluginRoot, "skills", group));
}
export const OpenPowersPlugin = async () => {
return {
config(config) {
config.skills ??= {};
config.skills.paths ??= [];
for (const skillDirectory of skillDirectoriesFor(selectedProfile())) {
if (!config.skills.paths.includes(skillDirectory)) {
config.skills.paths.push(skillDirectory);
}
}
},
};
};
export default OpenPowersPlugin;