@agent-nexus/csreg 0.1.11 → 0.1.15
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/commands/push.ts
|
|
2
2
|
import { Command as Command2 } from "commander";
|
|
3
3
|
import { resolve as resolve3, join as join6, basename as basename3 } from "path";
|
|
4
|
-
import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync2, statSync as statSync3, readdirSync as readdirSync3, lstatSync as lstatSync2 } from "fs";
|
|
4
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync2, unlinkSync, statSync as statSync3, readdirSync as readdirSync3, lstatSync as lstatSync2 } from "fs";
|
|
5
5
|
import { input } from "@inquirer/prompts";
|
|
6
6
|
import { createHash as createHash2 } from "crypto";
|
|
7
7
|
|
|
@@ -572,105 +572,112 @@ async function pushSingle(resolved) {
|
|
|
572
572
|
spin.start("Packing skill...");
|
|
573
573
|
const archive = await pack(resolved);
|
|
574
574
|
spin.succeed(`Packed (${(archive.size / 1024).toFixed(1)}KB).`);
|
|
575
|
-
const client = new ApiClient();
|
|
576
|
-
spin.start("Checking registry...");
|
|
577
575
|
try {
|
|
578
|
-
|
|
579
|
-
spin.
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
576
|
+
const client = new ApiClient();
|
|
577
|
+
spin.start("Checking registry...");
|
|
578
|
+
try {
|
|
579
|
+
await client.get(`/api/v1/skills/${manifest.scope}/${manifest.name}`);
|
|
580
|
+
spin.succeed("Skill found in registry.");
|
|
581
|
+
} catch {
|
|
582
|
+
spin.start(`Creating skill ${manifest.scope}/${manifest.name}...`);
|
|
583
|
+
await client.post("/api/v1/skills", {
|
|
584
|
+
body: {
|
|
585
|
+
scope: manifest.scope,
|
|
586
|
+
slug: manifest.name,
|
|
587
|
+
displayName: manifest.name,
|
|
588
|
+
description: manifest.description || "",
|
|
589
|
+
tags: manifest.tags || []
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
spin.succeed(`Created skill ${manifest.scope}/${manifest.name}.`);
|
|
593
|
+
}
|
|
594
|
+
spin.start("Preparing version...");
|
|
595
|
+
const fileTree = collectFileTree(resolved);
|
|
596
|
+
const prepared = await client.post(
|
|
597
|
+
`/api/v1/skills/${manifest.scope}/${manifest.name}/versions`,
|
|
598
|
+
{
|
|
599
|
+
body: {
|
|
600
|
+
version: manifest.version,
|
|
601
|
+
fileTree,
|
|
602
|
+
archiveSha256: archive.sha256,
|
|
603
|
+
archiveSize: archive.size,
|
|
604
|
+
entryPoint: "SKILL.md",
|
|
605
|
+
manifestJson: {
|
|
606
|
+
name: manifest.name,
|
|
607
|
+
description: manifest.description,
|
|
608
|
+
version: manifest.version,
|
|
609
|
+
scope: manifest.scope,
|
|
610
|
+
"allowed-tools": manifest["allowed-tools"],
|
|
611
|
+
"argument-hint": manifest["argument-hint"],
|
|
612
|
+
"disable-model-invocation": manifest["disable-model-invocation"],
|
|
613
|
+
"user-invocable": manifest["user-invocable"],
|
|
614
|
+
tags: manifest.tags
|
|
615
|
+
}
|
|
616
|
+
}
|
|
589
617
|
}
|
|
618
|
+
);
|
|
619
|
+
spin.succeed("Version prepared.");
|
|
620
|
+
spin.start("Uploading archive...");
|
|
621
|
+
const archiveData = readFileSync3(archive.path);
|
|
622
|
+
const uploadHeaders = {
|
|
623
|
+
"Content-Type": "application/gzip",
|
|
624
|
+
"Content-Length": String(archive.size)
|
|
625
|
+
};
|
|
626
|
+
let uploadResponse = await fetch(prepared.uploadUrl, {
|
|
627
|
+
method: "PUT",
|
|
628
|
+
headers: uploadHeaders,
|
|
629
|
+
body: archiveData,
|
|
630
|
+
redirect: "manual"
|
|
590
631
|
});
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
fileTree,
|
|
601
|
-
archiveSha256: archive.sha256,
|
|
602
|
-
archiveSize: archive.size,
|
|
603
|
-
entryPoint: "SKILL.md",
|
|
604
|
-
manifestJson: {
|
|
605
|
-
name: manifest.name,
|
|
606
|
-
description: manifest.description,
|
|
607
|
-
version: manifest.version,
|
|
608
|
-
scope: manifest.scope,
|
|
609
|
-
"allowed-tools": manifest["allowed-tools"],
|
|
610
|
-
"argument-hint": manifest["argument-hint"],
|
|
611
|
-
"disable-model-invocation": manifest["disable-model-invocation"],
|
|
612
|
-
"user-invocable": manifest["user-invocable"],
|
|
613
|
-
tags: manifest.tags
|
|
632
|
+
if (uploadResponse.status === 301 || uploadResponse.status === 302 || uploadResponse.status === 307 || uploadResponse.status === 308) {
|
|
633
|
+
let redirectUrl = uploadResponse.headers.get("location");
|
|
634
|
+
if (!redirectUrl) {
|
|
635
|
+
const body = await uploadResponse.text();
|
|
636
|
+
const endpointMatch = body.match(/<Endpoint>([^<]+)<\/Endpoint>/);
|
|
637
|
+
if (endpointMatch) {
|
|
638
|
+
const url = new URL(prepared.uploadUrl);
|
|
639
|
+
url.hostname = endpointMatch[1];
|
|
640
|
+
redirectUrl = url.toString();
|
|
614
641
|
}
|
|
615
642
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const uploadHeaders = {
|
|
622
|
-
"Content-Type": "application/gzip",
|
|
623
|
-
"Content-Length": String(archive.size)
|
|
624
|
-
};
|
|
625
|
-
let uploadResponse = await fetch(prepared.uploadUrl, {
|
|
626
|
-
method: "PUT",
|
|
627
|
-
headers: uploadHeaders,
|
|
628
|
-
body: archiveData,
|
|
629
|
-
redirect: "manual"
|
|
630
|
-
});
|
|
631
|
-
if (uploadResponse.status === 301 || uploadResponse.status === 302 || uploadResponse.status === 307 || uploadResponse.status === 308) {
|
|
632
|
-
let redirectUrl = uploadResponse.headers.get("location");
|
|
633
|
-
if (!redirectUrl) {
|
|
634
|
-
const body = await uploadResponse.text();
|
|
635
|
-
const endpointMatch = body.match(/<Endpoint>([^<]+)<\/Endpoint>/);
|
|
636
|
-
if (endpointMatch) {
|
|
637
|
-
const url = new URL(prepared.uploadUrl);
|
|
638
|
-
url.hostname = endpointMatch[1];
|
|
639
|
-
redirectUrl = url.toString();
|
|
643
|
+
if (!redirectUrl) {
|
|
644
|
+
spin.fail("Upload failed.");
|
|
645
|
+
throw new CliError("S3 returned a redirect but no usable endpoint.", [
|
|
646
|
+
"This may be a region mismatch. Contact support."
|
|
647
|
+
]);
|
|
640
648
|
}
|
|
649
|
+
uploadResponse = await fetch(redirectUrl, {
|
|
650
|
+
method: "PUT",
|
|
651
|
+
headers: uploadHeaders,
|
|
652
|
+
body: archiveData
|
|
653
|
+
});
|
|
641
654
|
}
|
|
642
|
-
if (!
|
|
655
|
+
if (!uploadResponse.ok) {
|
|
643
656
|
spin.fail("Upload failed.");
|
|
644
|
-
|
|
645
|
-
|
|
657
|
+
const errorBody = await uploadResponse.text();
|
|
658
|
+
const codeMatch = errorBody.match(/<Code>([^<]+)<\/Code>/);
|
|
659
|
+
const msgMatch = errorBody.match(/<Message>([^<]+)<\/Message>/);
|
|
660
|
+
const detail = codeMatch ? `S3 error: ${codeMatch[1]}${msgMatch ? ` \u2014 ${msgMatch[1]}` : ""}` : `Status ${uploadResponse.status}`;
|
|
661
|
+
throw new CliError(`Upload failed: ${detail}`, [
|
|
662
|
+
"Try again. If the problem persists, contact support."
|
|
646
663
|
]);
|
|
647
664
|
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
]);
|
|
663
|
-
}
|
|
664
|
-
spin.succeed("Archive uploaded.");
|
|
665
|
-
spin.start("Finalizing version...");
|
|
666
|
-
await client.post(
|
|
667
|
-
`/api/v1/skills/${manifest.scope}/${manifest.name}/versions/${manifest.version}/finalize`,
|
|
668
|
-
{
|
|
669
|
-
body: { status: "published" }
|
|
665
|
+
spin.succeed("Archive uploaded.");
|
|
666
|
+
spin.start("Finalizing version...");
|
|
667
|
+
await client.post(
|
|
668
|
+
`/api/v1/skills/${manifest.scope}/${manifest.name}/versions/${manifest.version}/finalize`,
|
|
669
|
+
{
|
|
670
|
+
body: { status: "published" }
|
|
671
|
+
}
|
|
672
|
+
);
|
|
673
|
+
spin.succeed("Version finalized.");
|
|
674
|
+
return `${manifest.scope}/${manifest.name}@${manifest.version}`;
|
|
675
|
+
} finally {
|
|
676
|
+
try {
|
|
677
|
+
unlinkSync(archive.path);
|
|
678
|
+
} catch {
|
|
670
679
|
}
|
|
671
|
-
|
|
672
|
-
spin.succeed("Version finalized.");
|
|
673
|
-
return `${manifest.scope}/${manifest.name}@${manifest.version}`;
|
|
680
|
+
}
|
|
674
681
|
}
|
|
675
682
|
var pushCommand = new Command2("push").description("Publish a skill to the registry").argument("[dir]", "Skill directory", ".").option("--all", "Push all skills in .claude/skills/").action(async (dir, opts) => {
|
|
676
683
|
try {
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
success,
|
|
20
20
|
validateCommand,
|
|
21
21
|
warn
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-K2BDEOOF.js";
|
|
23
23
|
|
|
24
24
|
// src/index.ts
|
|
25
25
|
import { Command as Command11 } from "commander";
|
|
@@ -231,45 +231,64 @@ var releaseCommand = new Command6("release").description("Bump the version in SK
|
|
|
231
231
|
try {
|
|
232
232
|
const resolved = resolve3(dir);
|
|
233
233
|
const manifest = parseManifest(resolved);
|
|
234
|
+
let newVersion;
|
|
234
235
|
if (!manifest.version) {
|
|
235
|
-
|
|
236
|
-
'Add a version field: version: "1.0.0"'
|
|
237
|
-
]);
|
|
238
|
-
}
|
|
239
|
-
const currentVersion = manifest.version;
|
|
240
|
-
const nextPatch = bumpPatch(currentVersion);
|
|
241
|
-
info(`Current version: ${currentVersion}`);
|
|
242
|
-
const chosen = await select({
|
|
243
|
-
message: "Version to release:",
|
|
244
|
-
choices: [
|
|
245
|
-
{ name: `${nextPatch} (patch bump)`, value: nextPatch },
|
|
246
|
-
{ name: `${currentVersion} (current)`, value: currentVersion },
|
|
247
|
-
{ name: "Enter manually", value: "__manual__" }
|
|
248
|
-
]
|
|
249
|
-
});
|
|
250
|
-
let newVersion = chosen;
|
|
251
|
-
if (chosen === "__manual__") {
|
|
236
|
+
info("No version found in SKILL.md frontmatter.");
|
|
252
237
|
newVersion = await input3({
|
|
253
|
-
message: "
|
|
238
|
+
message: "Initial version:",
|
|
239
|
+
default: "1.0.0",
|
|
254
240
|
validate: (value) => {
|
|
255
241
|
const semver = /^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/;
|
|
256
|
-
if (!semver.test(value.trim())) return "Must be valid semver (e.g., 1.
|
|
242
|
+
if (!semver.test(value.trim())) return "Must be valid semver (e.g., 1.0.0).";
|
|
257
243
|
return true;
|
|
258
244
|
}
|
|
259
245
|
});
|
|
260
246
|
newVersion = newVersion.trim();
|
|
261
|
-
}
|
|
262
|
-
if (newVersion !== currentVersion) {
|
|
263
247
|
const skillPath = join2(resolved, "SKILL.md");
|
|
264
248
|
const raw = readFileSync(skillPath, "utf-8");
|
|
265
249
|
const updated = raw.replace(
|
|
266
|
-
/^(
|
|
267
|
-
`$
|
|
250
|
+
/^(---\s*\n[\s\S]*?\n)(---\s*\n?)/,
|
|
251
|
+
`$1version: "${newVersion}"
|
|
252
|
+
$2`
|
|
268
253
|
);
|
|
269
254
|
writeFileSync2(skillPath, updated, "utf-8");
|
|
270
|
-
info(`
|
|
255
|
+
info(`Set version to ${newVersion}`);
|
|
256
|
+
} else {
|
|
257
|
+
const currentVersion = manifest.version;
|
|
258
|
+
const nextPatch = bumpPatch(currentVersion);
|
|
259
|
+
info(`Current version: ${currentVersion}`);
|
|
260
|
+
const chosen = await select({
|
|
261
|
+
message: "Version to release:",
|
|
262
|
+
choices: [
|
|
263
|
+
{ name: `${nextPatch} (patch bump)`, value: nextPatch },
|
|
264
|
+
{ name: `${currentVersion} (current)`, value: currentVersion },
|
|
265
|
+
{ name: "Enter manually", value: "__manual__" }
|
|
266
|
+
]
|
|
267
|
+
});
|
|
268
|
+
newVersion = chosen;
|
|
269
|
+
if (chosen === "__manual__") {
|
|
270
|
+
newVersion = await input3({
|
|
271
|
+
message: "Version:",
|
|
272
|
+
validate: (value) => {
|
|
273
|
+
const semver = /^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/;
|
|
274
|
+
if (!semver.test(value.trim())) return "Must be valid semver (e.g., 1.2.3).";
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
newVersion = newVersion.trim();
|
|
279
|
+
}
|
|
280
|
+
if (newVersion !== currentVersion) {
|
|
281
|
+
const skillPath = join2(resolved, "SKILL.md");
|
|
282
|
+
const raw = readFileSync(skillPath, "utf-8");
|
|
283
|
+
const updated = raw.replace(
|
|
284
|
+
/^(version:\s*)"?[^"\n]+"?\s*$/m,
|
|
285
|
+
`$1"${newVersion}"`
|
|
286
|
+
);
|
|
287
|
+
writeFileSync2(skillPath, updated, "utf-8");
|
|
288
|
+
info(`Updated version to ${newVersion}`);
|
|
289
|
+
}
|
|
271
290
|
}
|
|
272
|
-
const { pushCommand: pushCommand2 } = await import("./push-
|
|
291
|
+
const { pushCommand: pushCommand2 } = await import("./push-IUV2SDXE.js");
|
|
273
292
|
await pushCommand2.parseAsync([dir], { from: "user" });
|
|
274
293
|
} catch (err) {
|
|
275
294
|
handleError(err);
|