aiguild 1.0.0 → 1.0.2

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 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.0" };
11
+ const pkg = { version: "1.0.2" };
12
12
 
13
13
  const program = new Command();
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiguild",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "AIGuild CLI — install and manage AI skills from your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -66,7 +66,7 @@ export function registerAuth(program) {
66
66
 
67
67
  auth
68
68
  .command("set-url <url>")
69
- .description("Override the AIGuild server URL (default: https://aiguild.replit.app)")
69
+ .description("Override the AIGuild server URL (default: https://api.aiguild.dev)")
70
70
  .action((url) => {
71
71
  saveConfig({ apiUrl: url });
72
72
  console.log(`\x1b[32m✔\x1b[0m API URL set to \x1b[36m${url}\x1b[0m`);
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import { apiFetch } from "../api.mjs";
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
- const cfg = loadConfig();
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 params = opts.version ? `?version=${encodeURIComponent(opts.version)}` : "";
37
- const data = await apiFetch(`/api/v1/skills/${encodeURIComponent(slug)}/download${params}`);
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 || data;
41
- const version = data.version || skill.currentVersion || "1.0.0";
42
- const content = data.content || skill.yamlContent || "";
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
- fs.writeFileSync(filePath, content, "utf8");
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: filePath,
76
+ path: skillDir,
53
77
  };
54
78
  saveInstalled(installed);
55
79
 
56
- console.log(`\x1b[32m✔\x1b[0m Installed \x1b[1m${skill.name || slug}\x1b[0m \x1b[2mv${version}\x1b[0m`);
57
- console.log(` \x1b[2m→ ${filePath}\x1b[0m`);
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 { fs.unlinkSync(record.path); } catch {}
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`);