skild 0.2.8 → 0.2.9
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 +39 -7
- package/package.json +2 -2
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, loadRegistryAuth, resolveRegistryAlias, resolveRegistryUrl, SkildError } from "@skild/core";
|
|
12
|
+
import { fetchWithTimeout, installRegistrySkill, installSkill, isValidAlias, loadRegistryAuth, resolveRegistryAlias, resolveRegistryUrl, SkildError } from "@skild/core";
|
|
13
13
|
|
|
14
14
|
// src/utils/logger.ts
|
|
15
15
|
import chalk from "chalk";
|
|
@@ -79,9 +79,7 @@ function looksLikeAlias(input) {
|
|
|
79
79
|
if (s.includes("/") || s.includes("\\")) return false;
|
|
80
80
|
if (/^https?:\/\//i.test(s) || s.includes("github.com")) return false;
|
|
81
81
|
if (fs.existsSync(path.resolve(s))) return false;
|
|
82
|
-
if (s
|
|
83
|
-
if (!/^[a-z0-9][a-z0-9-]*[a-z0-9]$/.test(s)) return false;
|
|
84
|
-
if (s.includes("--")) return false;
|
|
82
|
+
if (!isValidAlias(s)) return false;
|
|
85
83
|
return true;
|
|
86
84
|
}
|
|
87
85
|
async function install(source, options = {}) {
|
|
@@ -708,7 +706,7 @@ import path2 from "path";
|
|
|
708
706
|
import crypto from "crypto";
|
|
709
707
|
import * as tar from "tar";
|
|
710
708
|
import chalk13 from "chalk";
|
|
711
|
-
import { fetchWithTimeout as fetchWithTimeout5, loadRegistryAuth as loadRegistryAuth3, resolveRegistryUrl as resolveRegistryUrl5, SkildError as SkildError9, splitCanonicalName, validateSkillDir } from "@skild/core";
|
|
709
|
+
import { assertValidAlias, fetchWithTimeout as fetchWithTimeout5, loadRegistryAuth as loadRegistryAuth3, normalizeAlias, resolveRegistryUrl as resolveRegistryUrl5, SkildError as SkildError9, splitCanonicalName, validateSkillDir } from "@skild/core";
|
|
712
710
|
function sha256Hex(buf) {
|
|
713
711
|
const h = crypto.createHash("sha256");
|
|
714
712
|
h.update(buf);
|
|
@@ -738,6 +736,7 @@ async function publish(options = {}) {
|
|
|
738
736
|
const fm = validation.frontmatter;
|
|
739
737
|
let name = (options.name || fm.name || "").trim();
|
|
740
738
|
const version2 = (options.skillVersion || fm.version || "").trim();
|
|
739
|
+
const alias = normalizeAlias(options.alias);
|
|
741
740
|
const description = (options.description || fm.description || "").trim();
|
|
742
741
|
const tag = (options.tag || "latest").trim() || "latest";
|
|
743
742
|
const targets = parseTargets(options.targets);
|
|
@@ -785,6 +784,16 @@ async function publish(options = {}) {
|
|
|
785
784
|
process.exitCode = 1;
|
|
786
785
|
return;
|
|
787
786
|
}
|
|
787
|
+
if (alias) {
|
|
788
|
+
try {
|
|
789
|
+
assertValidAlias(alias);
|
|
790
|
+
} catch (error) {
|
|
791
|
+
const message = error instanceof SkildError9 ? error.message : error instanceof Error ? error.message : String(error);
|
|
792
|
+
console.error(chalk13.red(message));
|
|
793
|
+
process.exitCode = 1;
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
788
797
|
const spinner = createSpinner(`Publishing ${chalk13.cyan(`${name}@${version2}`)} to ${chalk13.dim(registry)}...`);
|
|
789
798
|
const tempDir = fs2.mkdtempSync(path2.join(os.tmpdir(), "skild-publish-"));
|
|
790
799
|
const tarballPath = path2.join(tempDir, "skill.tgz");
|
|
@@ -826,11 +835,34 @@ async function publish(options = {}) {
|
|
|
826
835
|
process.exitCode = 1;
|
|
827
836
|
return;
|
|
828
837
|
}
|
|
838
|
+
if (alias) {
|
|
839
|
+
spinner.text = `Publishing ${chalk13.cyan(`${name}@${version2}`)} \u2014 setting alias ${chalk13.cyan(alias)}...`;
|
|
840
|
+
const aliasRes = await fetchWithTimeout5(
|
|
841
|
+
`${registry}/publisher/skills/${encodeURIComponent(scope)}/${encodeURIComponent(skillName)}/alias`,
|
|
842
|
+
{
|
|
843
|
+
method: "POST",
|
|
844
|
+
headers: {
|
|
845
|
+
authorization: `Bearer ${token}`,
|
|
846
|
+
"content-type": "application/json"
|
|
847
|
+
},
|
|
848
|
+
body: JSON.stringify({ alias })
|
|
849
|
+
},
|
|
850
|
+
1e4
|
|
851
|
+
);
|
|
852
|
+
const aliasText = await aliasRes.text();
|
|
853
|
+
if (!aliasRes.ok) {
|
|
854
|
+
spinner.fail(`Failed to set alias (${aliasRes.status})`);
|
|
855
|
+
console.error(chalk13.red(aliasText));
|
|
856
|
+
process.exitCode = 1;
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
829
860
|
if (options.json) {
|
|
830
861
|
console.log(text);
|
|
831
862
|
return;
|
|
832
863
|
}
|
|
833
|
-
|
|
864
|
+
const suffix = alias ? ` (alias: ${chalk13.cyan(alias)})` : "";
|
|
865
|
+
spinner.succeed(`Published ${chalk13.green(`${name}@${version2}`)}${suffix} (sha256:${integrity.slice(0, 12)}\u2026)`);
|
|
834
866
|
try {
|
|
835
867
|
const parsed = JSON.parse(text);
|
|
836
868
|
const warnings = Array.isArray(parsed.warnings) ? parsed.warnings.map(String).filter(Boolean) : [];
|
|
@@ -898,7 +930,7 @@ program.command("signup").description("Create a publisher account in the registr
|
|
|
898
930
|
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));
|
|
899
931
|
program.command("logout").description("Remove stored registry credentials").action(async () => logout());
|
|
900
932
|
program.command("whoami").description("Show current registry identity").action(async () => whoami());
|
|
901
|
-
program.command("publish").description("Publish a Skill directory to the registry (hosted tarball)").option("--dir <path>", "Skill directory (defaults to cwd)").option("--name <@publisher/skill>", "Override skill name (defaults to SKILL.md frontmatter)").option("--skill-version <semver>", "Override version (defaults to SKILL.md frontmatter)").option("--description <text>", "Override description (defaults to SKILL.md frontmatter)").option("--targets <list>", "Comma-separated target platforms metadata (optional)").option("--tag <tag>", "Dist-tag (default: latest)", "latest").option("--registry <url>", "Registry base URL (defaults to saved login)").option("--json", "Output JSON").action(async (options) => publish(options));
|
|
933
|
+
program.command("publish").description("Publish a Skill directory to the registry (hosted tarball)").option("--dir <path>", "Skill directory (defaults to cwd)").option("--name <@publisher/skill>", "Override skill name (defaults to SKILL.md frontmatter)").option("--skill-version <semver>", "Override version (defaults to SKILL.md frontmatter)").option("--alias <alias>", "Optional short identifier (global unique) for `skild install <alias>`").option("--description <text>", "Override description (defaults to SKILL.md frontmatter)").option("--targets <list>", "Comma-separated target platforms metadata (optional)").option("--tag <tag>", "Dist-tag (default: latest)", "latest").option("--registry <url>", "Registry base URL (defaults to saved login)").option("--json", "Output JSON").action(async (options) => publish(options));
|
|
902
934
|
program.command("search <query>").description("Search Skills in the registry").option("--registry <url>", "Registry base URL (default: https://registry.skild.sh)").option("--limit <n>", "Max results (default: 50)", "50").option("--json", "Output JSON").action(async (query, options) => search(query, options));
|
|
903
935
|
program.action(() => {
|
|
904
936
|
console.log(chalk15.bold("\n\u{1F6E1}\uFE0F skild \u2014 Get your agents skilled.\n"));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skild",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
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",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"commander": "^12.1.0",
|
|
38
38
|
"ora": "^8.0.1",
|
|
39
39
|
"tar": "^7.4.3",
|
|
40
|
-
"@skild/core": "^0.2.
|
|
40
|
+
"@skild/core": "^0.2.9"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/node": "^20.10.0",
|