@agent-nexus/csreg 0.1.12 → 0.1.16
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
|
|
|
@@ -94,8 +94,8 @@ function validateManifest(manifest) {
|
|
|
94
94
|
}
|
|
95
95
|
if (!manifest.description || typeof manifest.description !== "string") {
|
|
96
96
|
errors.push('Missing "description" field. Claude uses this to decide when to invoke the skill.');
|
|
97
|
-
} else if (manifest.description.length >
|
|
98
|
-
errors.push('"description" must be at most
|
|
97
|
+
} else if (manifest.description.length > 5e3) {
|
|
98
|
+
errors.push('"description" must be at most 5000 characters.');
|
|
99
99
|
}
|
|
100
100
|
if (manifest.version !== void 0) {
|
|
101
101
|
const semverRegex = /^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/;
|
|
@@ -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-EJMLPDX6.js";
|
|
23
23
|
|
|
24
24
|
// src/index.ts
|
|
25
25
|
import { Command as Command11 } from "commander";
|
|
@@ -288,7 +288,7 @@ $2`
|
|
|
288
288
|
info(`Updated version to ${newVersion}`);
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
const { pushCommand: pushCommand2 } = await import("./push-
|
|
291
|
+
const { pushCommand: pushCommand2 } = await import("./push-VX47YMLM.js");
|
|
292
292
|
await pushCommand2.parseAsync([dir], { from: "user" });
|
|
293
293
|
} catch (err) {
|
|
294
294
|
handleError(err);
|