@clawtrail/init 1.0.3 → 1.0.4
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 +23 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38,23 +38,31 @@ async function ensureDirectory(dirPath) {
|
|
|
38
38
|
}
|
|
39
39
|
async function downloadSkillFiles(targetDir, staging = false) {
|
|
40
40
|
const spinner = ora("Downloading ClawTrail skill files...").start();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
await ensureDirectory(targetDir);
|
|
42
|
+
const files = staging ? STAGING_SKILL_FILES : SKILL_FILES;
|
|
43
|
+
const env = staging ? "staging" : "production";
|
|
44
|
+
const downloads = [
|
|
45
|
+
{ url: files.SKILL, dest: path.join(targetDir, "SKILL.md"), name: "SKILL.md" },
|
|
46
|
+
{ url: files.HEARTBEAT, dest: path.join(targetDir, "HEARTBEAT.md"), name: "HEARTBEAT.md" },
|
|
47
|
+
{ url: files.MESSAGING, dest: path.join(targetDir, "MESSAGING.md"), name: "MESSAGING.md" }
|
|
48
|
+
];
|
|
49
|
+
const results = await Promise.allSettled(
|
|
50
|
+
downloads.map(({ url, dest }) => downloadFile(url, dest))
|
|
51
|
+
);
|
|
52
|
+
const succeeded = results.filter((r) => r.status === "fulfilled").length;
|
|
53
|
+
const failed = downloads.filter((_, i) => results[i]?.status === "rejected").map((d) => d.name);
|
|
54
|
+
if (succeeded === 0) {
|
|
55
|
+
spinner.fail(chalk.red("Failed to download any skill files \u2014 check your internet connection"));
|
|
56
|
+
throw new Error("All downloads failed");
|
|
57
|
+
}
|
|
58
|
+
if (failed.length > 0) {
|
|
59
|
+
spinner.warn(
|
|
60
|
+
chalk.yellow(`Downloaded ${succeeded}/${downloads.length} skill files to ${chalk.cyan(targetDir)} (${env}) \u2014 ${failed.join(", ")} unavailable`)
|
|
61
|
+
);
|
|
62
|
+
} else {
|
|
50
63
|
spinner.succeed(
|
|
51
|
-
chalk.green(
|
|
52
|
-
`\u2713 Downloaded skill files to ${chalk.cyan(targetDir)} (${env})`
|
|
53
|
-
)
|
|
64
|
+
chalk.green(`\u2713 Downloaded ${succeeded} skill files to ${chalk.cyan(targetDir)} (${env})`)
|
|
54
65
|
);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
spinner.fail(chalk.red(`Failed to download skill files: ${error.message}`));
|
|
57
|
-
throw error;
|
|
58
66
|
}
|
|
59
67
|
}
|
|
60
68
|
async function registerAgent(data, staging = false) {
|