aiguild 1.0.0 → 1.0.1
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/bin/aiguild.mjs +1 -1
- package/package.json +1 -1
- package/src/commands/install.mjs +46 -18
package/bin/aiguild.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { registerList } from "../src/commands/list.mjs";
|
|
|
8
8
|
import { registerUpdate } from "../src/commands/update.mjs";
|
|
9
9
|
import { loadConfig } from "../src/config.mjs";
|
|
10
10
|
|
|
11
|
-
const pkg = { version: "1.0.
|
|
11
|
+
const pkg = { version: "1.0.1" };
|
|
12
12
|
|
|
13
13
|
const program = new Command();
|
|
14
14
|
|
package/package.json
CHANGED
package/src/commands/install.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { apiAuthFetch } from "../api.mjs";
|
|
4
4
|
import { requireAuth, loadConfig, saveConfig } from "../config.mjs";
|
|
5
5
|
|
|
6
6
|
const INSTALL_DIR_DEFAULT = path.join(process.cwd(), ".aiguild", "skills");
|
|
@@ -12,8 +12,7 @@ function getInstallDir(opts) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function loadInstalled() {
|
|
15
|
-
|
|
16
|
-
return cfg.installed || {};
|
|
15
|
+
return loadConfig().installed || {};
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
function saveInstalled(installed) {
|
|
@@ -27,37 +26,64 @@ export function registerInstall(program) {
|
|
|
27
26
|
.option("-d, --dir <path>", "Target directory (default: ./.aiguild/skills)")
|
|
28
27
|
.option("--version <ver>", "Install a specific version")
|
|
29
28
|
.action(async (slug, opts) => {
|
|
30
|
-
requireAuth();
|
|
29
|
+
const apiKey = requireAuth();
|
|
31
30
|
const installDir = getInstallDir(opts);
|
|
32
|
-
fs.mkdirSync(installDir, { recursive: true });
|
|
33
31
|
|
|
34
32
|
process.stdout.write(` Fetching \x1b[36m${slug}\x1b[0m...`);
|
|
35
33
|
try {
|
|
36
|
-
const
|
|
37
|
-
const data = await
|
|
34
|
+
const versionParam = opts.version ? `&version=${encodeURIComponent(opts.version)}` : "";
|
|
35
|
+
const data = await apiAuthFetch(
|
|
36
|
+
`/api/skills/${encodeURIComponent(slug)}/download?format=json${versionParam}`,
|
|
37
|
+
apiKey,
|
|
38
|
+
);
|
|
38
39
|
process.stdout.write("\r");
|
|
39
40
|
|
|
40
|
-
const skill = data.skill
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const filename = `${slug}.yaml`;
|
|
44
|
-
const filePath = path.join(installDir, filename);
|
|
41
|
+
const skill = data.skill;
|
|
42
|
+
const skillMdContent = data.content ?? "";
|
|
43
|
+
const extraFiles = data.files ?? [];
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
if (!skill) {
|
|
46
|
+
console.error(`\x1b[31m✖\x1b[0m Unexpected response from server — skill data missing`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Create skill directory: <installDir>/<slug>/
|
|
51
|
+
const skillDir = path.join(installDir, skill.slug);
|
|
52
|
+
fs.mkdirSync(skillDir, { recursive: true });
|
|
53
|
+
|
|
54
|
+
// Write SKILL.md
|
|
55
|
+
fs.writeFileSync(path.join(skillDir, "SKILL.md"), skillMdContent, "utf8");
|
|
56
|
+
|
|
57
|
+
// Write extra files preserving sub-paths
|
|
58
|
+
for (const f of extraFiles) {
|
|
59
|
+
const rel = f.path.startsWith("/") ? f.path.slice(1) : f.path;
|
|
60
|
+
const dest = path.join(skillDir, rel);
|
|
61
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
62
|
+
fs.writeFileSync(dest, f.content ?? "", "utf8");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Write metadata.json
|
|
66
|
+
fs.writeFileSync(
|
|
67
|
+
path.join(skillDir, "metadata.json"),
|
|
68
|
+
JSON.stringify(skill, null, 2),
|
|
69
|
+
"utf8",
|
|
70
|
+
);
|
|
47
71
|
|
|
48
72
|
const installed = loadInstalled();
|
|
49
73
|
installed[slug] = {
|
|
50
|
-
version,
|
|
74
|
+
version: skill.version,
|
|
51
75
|
installedAt: new Date().toISOString(),
|
|
52
|
-
path:
|
|
76
|
+
path: skillDir,
|
|
53
77
|
};
|
|
54
78
|
saveInstalled(installed);
|
|
55
79
|
|
|
56
|
-
console.log(`\x1b[32m✔\x1b[0m Installed \x1b[1m${skill.name
|
|
57
|
-
console.log(` \x1b[2m→ ${
|
|
80
|
+
console.log(`\x1b[32m✔\x1b[0m Installed \x1b[1m${skill.name}\x1b[0m \x1b[2mv${skill.version}\x1b[0m`);
|
|
81
|
+
console.log(` \x1b[2m→ ${skillDir}\x1b[0m`);
|
|
58
82
|
if (skill.compatibleAgents?.length) {
|
|
59
83
|
console.log(` Compatible with: \x1b[36m${skill.compatibleAgents.join(", ")}\x1b[0m`);
|
|
60
84
|
}
|
|
85
|
+
const fileCount = 1 + extraFiles.length + 1; // SKILL.md + extra + metadata.json
|
|
86
|
+
console.log(` \x1b[2m${fileCount} file${fileCount !== 1 ? "s" : ""} written\x1b[0m`);
|
|
61
87
|
} catch (e) {
|
|
62
88
|
process.stdout.write("\r");
|
|
63
89
|
console.error(`\x1b[31m✖\x1b[0m Install failed: ${e.message}`);
|
|
@@ -76,7 +102,9 @@ export function registerInstall(program) {
|
|
|
76
102
|
process.exit(1);
|
|
77
103
|
}
|
|
78
104
|
const record = installed[slug];
|
|
79
|
-
try {
|
|
105
|
+
try {
|
|
106
|
+
fs.rmSync(record.path, { recursive: true, force: true });
|
|
107
|
+
} catch {}
|
|
80
108
|
delete installed[slug];
|
|
81
109
|
saveInstalled(installed);
|
|
82
110
|
console.log(`\x1b[32m✔\x1b[0m Uninstalled \x1b[1m${slug}\x1b[0m`);
|