opencode-skills-collection 1.0.149 → 1.0.150
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/dist/index.js
CHANGED
|
@@ -2,31 +2,70 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import os from "os";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
|
+
const LOG_FILE = path.join(os.homedir(), ".config", "opencode", "antigravity-debug.log");
|
|
6
|
+
function log(msg) {
|
|
7
|
+
const line = `[${new Date().toISOString()}] ${msg}\n`;
|
|
8
|
+
try {
|
|
9
|
+
fs.appendFileSync(LOG_FILE, line);
|
|
10
|
+
}
|
|
11
|
+
catch (_) { }
|
|
12
|
+
process.stderr.write(line);
|
|
13
|
+
}
|
|
14
|
+
function copyDirContents(srcDir, destDir) {
|
|
15
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
16
|
+
for (const entry of fs.readdirSync(srcDir, { withFileTypes: true })) {
|
|
17
|
+
const srcEntry = path.join(srcDir, entry.name);
|
|
18
|
+
const destEntry = path.join(destDir, entry.name);
|
|
19
|
+
if (entry.isDirectory()) {
|
|
20
|
+
copyDirContents(srcEntry, destEntry);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
fs.copyFileSync(srcEntry, destEntry);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function resolveBundledSkillsPath() {
|
|
28
|
+
const fromFile = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "bundled-skills");
|
|
29
|
+
if (fs.existsSync(fromFile))
|
|
30
|
+
return fromFile;
|
|
31
|
+
let dir = path.dirname(fileURLToPath(import.meta.url));
|
|
32
|
+
for (let i = 0; i < 5; i++) {
|
|
33
|
+
const candidate = path.join(dir, "bundled-skills");
|
|
34
|
+
if (fs.existsSync(candidate))
|
|
35
|
+
return candidate;
|
|
36
|
+
const parent = path.dirname(dir);
|
|
37
|
+
if (parent === dir)
|
|
38
|
+
break;
|
|
39
|
+
dir = parent;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`bundled-skills not found. import.meta.url=${import.meta.url}`);
|
|
42
|
+
}
|
|
5
43
|
const OpenCodeSkillsCollection = async (_ctx) => {
|
|
44
|
+
log("plugin start");
|
|
6
45
|
try {
|
|
7
|
-
|
|
8
|
-
// Works regardless of where OpenCode is launched from
|
|
9
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
10
|
-
const bundledSkillsPath = path.join(__dirname, "..", "bundled-skills");
|
|
11
|
-
// Resolve target path in OpenCode's config directory
|
|
46
|
+
const bundledSkillsPath = resolveBundledSkillsPath();
|
|
12
47
|
const skillsPath = path.join(os.homedir(), ".config", "opencode", "skills");
|
|
13
|
-
|
|
48
|
+
log(`bundled-skills path: ${bundledSkillsPath}`);
|
|
49
|
+
log(`skills dest: ${skillsPath}`);
|
|
14
50
|
fs.mkdirSync(skillsPath, { recursive: true });
|
|
15
|
-
fs.
|
|
51
|
+
const entries = fs.readdirSync(bundledSkillsPath, { withFileTypes: true });
|
|
52
|
+
log(`entries in bundled-skills: ${entries.length}`);
|
|
53
|
+
let installed = 0;
|
|
54
|
+
for (const entry of entries) {
|
|
55
|
+
if (!entry.isDirectory())
|
|
56
|
+
continue;
|
|
57
|
+
if (entry.name.startsWith("."))
|
|
58
|
+
continue;
|
|
59
|
+
const src = path.join(bundledSkillsPath, entry.name);
|
|
60
|
+
if (!fs.existsSync(path.join(src, "SKILL.md")))
|
|
61
|
+
continue;
|
|
62
|
+
copyDirContents(src, path.join(skillsPath, entry.name));
|
|
63
|
+
installed++;
|
|
64
|
+
}
|
|
65
|
+
log(`done — installed ${installed} skills`);
|
|
16
66
|
}
|
|
17
67
|
catch (error) {
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
const { exec } = await import("child_process");
|
|
21
|
-
const util = await import("util");
|
|
22
|
-
const execAsync = util.promisify(exec);
|
|
23
|
-
const fallbackPath = path.join(os.homedir(), ".config", "opencode", "skills");
|
|
24
|
-
await execAsync(`npx --yes antigravity-awesome-skills --path "${fallbackPath}"`);
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
// silently fail completely
|
|
28
|
-
}
|
|
29
|
-
}, 0);
|
|
68
|
+
log(`ERROR: ${String(error)}`);
|
|
30
69
|
}
|
|
31
70
|
return {};
|
|
32
71
|
};
|
package/package.json
CHANGED