skild 0.2.9 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +82 -32
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { createRequire } from "module";
9
9
  import fs from "fs";
10
10
  import path from "path";
11
11
  import chalk2 from "chalk";
12
- import { fetchWithTimeout, installRegistrySkill, installSkill, isValidAlias, loadRegistryAuth, resolveRegistryAlias, resolveRegistryUrl, SkildError } from "@skild/core";
12
+ import { fetchWithTimeout, installRegistrySkill, installSkill, isValidAlias, loadRegistryAuth, resolveRegistryAlias, resolveRegistryUrl, SkildError, PLATFORMS } from "@skild/core";
13
13
 
14
14
  // src/utils/logger.ts
15
15
  import chalk from "chalk";
@@ -83,51 +83,101 @@ function looksLikeAlias(input) {
83
83
  return true;
84
84
  }
85
85
  async function install(source, options = {}) {
86
- const platform = options.target || "claude";
87
86
  const scope = options.local ? "project" : "global";
88
87
  const auth = loadRegistryAuth();
89
88
  const registryUrlForDeps = options.registry || auth?.registryUrl;
89
+ const all = Boolean(options.all);
90
+ const jsonOnly = Boolean(options.json);
91
+ const platform = options.target || "claude";
92
+ if (all && options.target) {
93
+ const message = "Invalid options: use either --all or --target, not both.";
94
+ if (jsonOnly) console.log(JSON.stringify({ ok: false, error: message }, null, 2));
95
+ else console.error(chalk2.red(message));
96
+ process.exitCode = 1;
97
+ return;
98
+ }
90
99
  let resolvedSource = source.trim();
91
100
  try {
92
101
  if (looksLikeAlias(resolvedSource)) {
93
102
  const registryUrl = resolveRegistryUrl(registryUrlForDeps);
94
103
  const resolved = await resolveRegistryAlias(registryUrl, resolvedSource);
95
- if (!options.json) logger.info(`Resolved ${chalk2.cyan(resolvedSource)} \u2192 ${chalk2.cyan(resolved.spec)} (${resolved.type})`);
104
+ if (!jsonOnly) logger.info(`Resolved ${chalk2.cyan(resolvedSource)} \u2192 ${chalk2.cyan(resolved.spec)} (${resolved.type})`);
96
105
  resolvedSource = resolved.spec;
97
106
  }
98
107
  } catch (error) {
99
108
  const message = error instanceof SkildError ? error.message : error instanceof Error ? error.message : String(error);
100
- console.error(chalk2.red(message));
109
+ if (jsonOnly) console.log(JSON.stringify({ ok: false, error: message }, null, 2));
110
+ else console.error(chalk2.red(message));
101
111
  process.exitCode = 1;
102
112
  return;
103
113
  }
104
- const spinner = createSpinner(`Installing ${chalk2.cyan(source)} to ${chalk2.dim(platform)} (${scope})...`);
114
+ const targets = all ? [...PLATFORMS] : [platform];
115
+ const results = [];
116
+ const errors = [];
105
117
  try {
106
- const record = resolvedSource.startsWith("@") && resolvedSource.includes("/") ? await installRegistrySkill(
107
- { spec: resolvedSource, registryUrl: registryUrlForDeps },
108
- { platform, scope, force: Boolean(options.force) }
109
- ) : await installSkill({ source: resolvedSource }, { platform, scope, force: Boolean(options.force), registryUrl: registryUrlForDeps });
110
- const displayName = record.canonicalName || record.name;
111
- spinner.succeed(`Installed ${chalk2.green(displayName)} to ${chalk2.dim(record.installDir)}`);
112
- if (options.json) {
113
- console.log(JSON.stringify(record, null, 2));
118
+ const spinner = jsonOnly ? null : createSpinner(
119
+ all ? `Installing ${chalk2.cyan(source)} to ${chalk2.dim("all platforms")} (${scope})...` : `Installing ${chalk2.cyan(source)} to ${chalk2.dim(platform)} (${scope})...`
120
+ );
121
+ for (const targetPlatform of targets) {
122
+ if (spinner) spinner.text = `Installing ${chalk2.cyan(source)} to ${chalk2.dim(targetPlatform)} (${scope})...`;
123
+ try {
124
+ const record = resolvedSource.startsWith("@") && resolvedSource.includes("/") ? await installRegistrySkill(
125
+ { spec: resolvedSource, registryUrl: registryUrlForDeps },
126
+ { platform: targetPlatform, scope, force: Boolean(options.force) }
127
+ ) : await installSkill(
128
+ { source: resolvedSource },
129
+ { platform: targetPlatform, scope, force: Boolean(options.force), registryUrl: registryUrlForDeps }
130
+ );
131
+ results.push(record);
132
+ void reportDownload(record, registryUrlForDeps);
133
+ } catch (error) {
134
+ const message = error instanceof SkildError ? error.message : error instanceof Error ? error.message : String(error);
135
+ errors.push({ platform: targetPlatform, error: message });
136
+ }
137
+ }
138
+ if (jsonOnly) {
139
+ if (!all) {
140
+ if (errors.length) console.log(JSON.stringify({ ok: false, error: errors[0]?.error || "Install failed." }, null, 2));
141
+ else console.log(JSON.stringify(results[0] ?? null, null, 2));
142
+ } else {
143
+ console.log(JSON.stringify({ ok: errors.length === 0, source, resolvedSource, scope, results, errors }, null, 2));
144
+ }
145
+ process.exitCode = errors.length ? 1 : 0;
114
146
  return;
115
147
  }
116
- if (record.hasSkillMd) {
117
- logger.installDetail("SKILL.md found \u2713");
148
+ if (errors.length === 0) {
149
+ const displayName = results[0]?.canonicalName || results[0]?.name || source;
150
+ spinner.succeed(
151
+ all ? `Installed ${chalk2.green(displayName)} to ${chalk2.dim(`${results.length} platforms`)}` : `Installed ${chalk2.green(displayName)} to ${chalk2.dim(results[0]?.installDir || "")}`
152
+ );
118
153
  } else {
119
- logger.installDetail("Warning: No SKILL.md found", true);
154
+ spinner.fail(`Failed to install ${chalk2.red(source)} to ${errors.length}/${targets.length} platforms`);
120
155
  }
121
- if (record.skill?.validation && !record.skill.validation.ok) {
122
- logger.installDetail(`Validation: ${chalk2.yellow("failed")} (${record.skill.validation.issues.length} issues)`, true);
123
- } else if (record.skill?.validation?.ok) {
124
- logger.installDetail(`Validation: ${chalk2.green("ok")}`);
156
+ if (!all && results[0]) {
157
+ const record = results[0];
158
+ if (record.hasSkillMd) logger.installDetail("SKILL.md found \u2713");
159
+ else logger.installDetail("Warning: No SKILL.md found", true);
160
+ if (record.skill?.validation && !record.skill.validation.ok) {
161
+ logger.installDetail(`Validation: ${chalk2.yellow("failed")} (${record.skill.validation.issues.length} issues)`, true);
162
+ } else if (record.skill?.validation?.ok) {
163
+ logger.installDetail(`Validation: ${chalk2.green("ok")}`);
164
+ }
165
+ } else if (all) {
166
+ for (const r of results) {
167
+ const displayName = r.canonicalName || r.name;
168
+ const suffix = r.hasSkillMd ? chalk2.green("\u2713") : chalk2.yellow("\u26A0");
169
+ console.log(` ${suffix} ${chalk2.cyan(displayName)} \u2192 ${chalk2.dim(r.platform)}`);
170
+ }
171
+ if (errors.length) {
172
+ console.log(chalk2.yellow("\nFailures:"));
173
+ for (const e of errors) console.log(chalk2.yellow(` - ${e.platform}: ${e.error}`));
174
+ }
175
+ process.exitCode = errors.length ? 1 : 0;
125
176
  }
126
- void reportDownload(record, registryUrlForDeps);
127
177
  } catch (error) {
128
- spinner.fail(`Failed to install ${chalk2.red(source)}`);
129
178
  const message = error instanceof SkildError ? error.message : error instanceof Error ? error.message : String(error);
130
- console.error(chalk2.red(message));
179
+ if (jsonOnly) console.log(JSON.stringify({ ok: false, error: message }, null, 2));
180
+ else console.error(chalk2.red(message));
131
181
  process.exitCode = 1;
132
182
  }
133
183
  }
@@ -164,7 +214,7 @@ async function reportDownload(record, registryOverride) {
164
214
 
165
215
  // src/commands/list.ts
166
216
  import chalk3 from "chalk";
167
- import { PLATFORMS, listAllSkills, listSkills } from "@skild/core";
217
+ import { PLATFORMS as PLATFORMS2, listAllSkills, listSkills } from "@skild/core";
168
218
  function isSkillset(skill) {
169
219
  return Boolean(skill.record?.skillset || skill.record?.skill?.frontmatter?.skillset);
170
220
  }
@@ -300,7 +350,7 @@ async function list(options = {}) {
300
350
  console.log(chalk3.dim(`Use ${chalk3.cyan("skild install <source>")} to install a skill.`));
301
351
  return;
302
352
  }
303
- for (const p of PLATFORMS) {
353
+ for (const p of PLATFORMS2) {
304
354
  const platformSkills = allSkills.filter((s) => s.platform === p).sort((a, b) => a.name.localeCompare(b.name));
305
355
  if (platformSkills.length === 0) continue;
306
356
  printPlatform(platformSkills, p, scope, { paths, verbose });
@@ -912,19 +962,19 @@ async function search(query, options = {}) {
912
962
  }
913
963
 
914
964
  // src/index.ts
915
- import { PLATFORMS as PLATFORMS2 } from "@skild/core";
965
+ import { PLATFORMS as PLATFORMS3 } from "@skild/core";
916
966
  var require2 = createRequire(import.meta.url);
917
967
  var { version } = require2("../package.json");
918
968
  var program = new Command();
919
969
  program.name("skild").description("The npm for Agent Skills \u2014 Discover, install, manage, and publish AI Agent Skills with ease.").version(version);
920
- program.command("install <source>").alias("i").description("Install a Skill from a Git URL, degit shorthand, or local directory").option("-t, --target <platform>", `Target platform: ${PLATFORMS2.join(", ")}`, "claude").option("-l, --local", "Install to project-level directory instead of global").option("-f, --force", "Overwrite existing installation").option("--registry <url>", "Registry base URL (default: https://registry.skild.sh)").option("--json", "Output JSON").action(async (source, options) => {
970
+ program.command("install <source>").alias("i").description("Install a Skill from a Git URL, degit shorthand, or local directory").option("-t, --target <platform>", `Target platform: ${PLATFORMS3.join(", ")}`).option("--all", `Install to all platforms: ${PLATFORMS3.join(", ")}`).option("-l, --local", "Install to project-level directory instead of global").option("-f, --force", "Overwrite existing installation").option("--registry <url>", "Registry base URL (default: https://registry.skild.sh)").option("--json", "Output JSON").action(async (source, options) => {
921
971
  await install(source, options);
922
972
  });
923
- program.command("list").alias("ls").description("List installed Skills").option("-t, --target <platform>", `Target platform: ${PLATFORMS2.join(", ")} (optional; omit to list all)`).option("-l, --local", "List project-level directory instead of global").option("--paths", "Show install paths").option("--verbose", "Show skillset dependency details").option("--json", "Output JSON").action(async (options) => list(options));
924
- program.command("info <skill>").description("Show installed Skill details").option("-t, --target <platform>", `Target platform: ${PLATFORMS2.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("--json", "Output JSON").action(async (skill, options) => info(skill, options));
925
- program.command("uninstall <skill>").alias("rm").description("Uninstall a Skill").option("-t, --target <platform>", `Target platform: ${PLATFORMS2.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("-f, --force", "Uninstall even if metadata is missing").option("--with-deps", "Uninstall dependencies that are only required by this skill").action(async (skill, options) => uninstall(skill, options));
926
- program.command("update [skill]").alias("up").description("Update one or all installed Skills").option("-t, --target <platform>", `Target platform: ${PLATFORMS2.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("--json", "Output JSON").action(async (skill, options) => update(skill, options));
927
- program.command("validate [target]").alias("v").description("Validate a Skill folder (path) or an installed Skill name").option("-t, --target <platform>", `Target platform: ${PLATFORMS2.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("--json", "Output JSON").action(async (target, options) => validate(target, options));
973
+ program.command("list").alias("ls").description("List installed Skills").option("-t, --target <platform>", `Target platform: ${PLATFORMS3.join(", ")} (optional; omit to list all)`).option("-l, --local", "List project-level directory instead of global").option("--paths", "Show install paths").option("--verbose", "Show skillset dependency details").option("--json", "Output JSON").action(async (options) => list(options));
974
+ program.command("info <skill>").description("Show installed Skill details").option("-t, --target <platform>", `Target platform: ${PLATFORMS3.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("--json", "Output JSON").action(async (skill, options) => info(skill, options));
975
+ program.command("uninstall <skill>").alias("rm").description("Uninstall a Skill").option("-t, --target <platform>", `Target platform: ${PLATFORMS3.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("-f, --force", "Uninstall even if metadata is missing").option("--with-deps", "Uninstall dependencies that are only required by this skill").action(async (skill, options) => uninstall(skill, options));
976
+ program.command("update [skill]").alias("up").description("Update one or all installed Skills").option("-t, --target <platform>", `Target platform: ${PLATFORMS3.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("--json", "Output JSON").action(async (skill, options) => update(skill, options));
977
+ program.command("validate [target]").alias("v").description("Validate a Skill folder (path) or an installed Skill name").option("-t, --target <platform>", `Target platform: ${PLATFORMS3.join(", ")}`, "claude").option("-l, --local", "Use project-level directory instead of global").option("--json", "Output JSON").action(async (target, options) => validate(target, options));
928
978
  program.command("init <name>").description("Create a new Skill project").option("--dir <path>", "Target directory (defaults to <name>)").option("--description <text>", "Skill description").option("-f, --force", "Overwrite target directory if it exists").action(async (name, options) => init(name, options));
929
979
  program.command("signup").description("Create a publisher account in the registry (no GitHub required)").option("--registry <url>", "Registry base URL (default: https://registry.skild.sh)").option("--email <email>", "Email (optional; will prompt)").option("--handle <handle>", "Publisher handle (owns @handle/* scope) (optional; will prompt)").option("--password <password>", "Password (optional; will prompt)").option("--json", "Output JSON").action(async (options) => signup(options));
930
980
  program.command("login").description("Login to a registry and store an access token locally").option("--registry <url>", "Registry base URL (default: https://registry.skild.sh)").option("--handle-or-email <value>", "Handle or email (optional; will prompt)").option("--password <password>", "Password (optional; will prompt)").option("--token-name <name>", "Token label").option("--json", "Output JSON").action(async (options) => login(options));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skild",
3
- "version": "0.2.9",
3
+ "version": "0.3.1",
4
4
  "description": "The npm for Agent Skills — Discover, install, manage, and publish AI Agent Skills with ease.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",