@clawtrail/init 1.3.2 → 1.4.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.
- package/dist/index.js +59 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -200,37 +200,77 @@ async function configureOpenClaw(apiKey, staging) {
|
|
|
200
200
|
await fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
201
201
|
console.log(chalk.green(` Configured ClawTrail in ${chalk.cyan("~/.openclaw/openclaw.json")}`));
|
|
202
202
|
}
|
|
203
|
+
async function findOpenClawSkillsDir() {
|
|
204
|
+
const candidates = [
|
|
205
|
+
// npm global (Linux default)
|
|
206
|
+
"/usr/lib/node_modules/openclaw/skills",
|
|
207
|
+
// npm global (macOS/nvm)
|
|
208
|
+
path.join(os.homedir(), ".nvm/versions/node", "**", "lib/node_modules/openclaw/skills"),
|
|
209
|
+
// npm global (macOS Homebrew)
|
|
210
|
+
"/usr/local/lib/node_modules/openclaw/skills",
|
|
211
|
+
// npm global (prefix-based)
|
|
212
|
+
"/usr/local/share/npm/lib/node_modules/openclaw/skills"
|
|
213
|
+
];
|
|
214
|
+
try {
|
|
215
|
+
const { execSync } = await import("child_process");
|
|
216
|
+
const globalRoot = execSync("npm root -g", { timeout: 5e3 }).toString().trim();
|
|
217
|
+
const npmGlobalPath = path.join(globalRoot, "openclaw", "skills");
|
|
218
|
+
try {
|
|
219
|
+
await fs.access(npmGlobalPath);
|
|
220
|
+
return npmGlobalPath;
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
} catch {
|
|
224
|
+
}
|
|
225
|
+
for (const candidate of candidates) {
|
|
226
|
+
if (candidate.includes("**")) continue;
|
|
227
|
+
try {
|
|
228
|
+
await fs.access(candidate);
|
|
229
|
+
return candidate;
|
|
230
|
+
} catch {
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
203
235
|
async function copyToOpenClawSkills(targetDir, staging) {
|
|
204
|
-
const workspaceDir = path.join(os.homedir(), ".openclaw", "workspace");
|
|
205
236
|
const skillFolder = staging ? "clawtrail-staging" : "clawtrail";
|
|
206
|
-
const
|
|
237
|
+
const workspaceDir = path.join(os.homedir(), ".openclaw", "workspace");
|
|
207
238
|
await ensureDirectory(workspaceDir);
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
239
|
+
try {
|
|
240
|
+
await fs.copyFile(path.join(targetDir, "HEARTBEAT.md"), path.join(workspaceDir, "HEARTBEAT.md"));
|
|
241
|
+
console.log(chalk.green(" HEARTBEAT.md -> ") + chalk.cyan("~/.openclaw/workspace/HEARTBEAT.md"));
|
|
242
|
+
} catch {
|
|
243
|
+
}
|
|
244
|
+
const openclawSkillsDir = await findOpenClawSkillsDir();
|
|
245
|
+
if (openclawSkillsDir) {
|
|
246
|
+
const destDir = path.join(openclawSkillsDir, skillFolder);
|
|
247
|
+
await ensureDirectory(destDir);
|
|
248
|
+
try {
|
|
249
|
+
await fs.copyFile(path.join(targetDir, "SKILL.md"), path.join(destDir, "SKILL.md"));
|
|
250
|
+
const prettyPath = openclawSkillsDir.replace(os.homedir(), "~");
|
|
251
|
+
console.log(chalk.green(" SKILL.md -> ") + chalk.cyan(`${prettyPath}/${skillFolder}/SKILL.md`));
|
|
252
|
+
} catch {
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
const skillsDir = path.join(workspaceDir, "skills", skillFolder);
|
|
256
|
+
await ensureDirectory(skillsDir);
|
|
216
257
|
try {
|
|
217
|
-
await fs.copyFile(
|
|
218
|
-
|
|
258
|
+
await fs.copyFile(path.join(targetDir, "SKILL.md"), path.join(skillsDir, "SKILL.md"));
|
|
259
|
+
console.log(
|
|
260
|
+
chalk.yellow(" Could not find OpenClaw global install \u2014 SKILL.md placed in workspace fallback")
|
|
261
|
+
);
|
|
262
|
+
console.log(chalk.gray(` ${chalk.cyan(`~/.openclaw/workspace/skills/${skillFolder}/SKILL.md`)}`));
|
|
263
|
+
console.log(chalk.gray(" You may need to manually copy it to your OpenClaw skills directory."));
|
|
219
264
|
} catch {
|
|
220
265
|
}
|
|
221
266
|
}
|
|
222
|
-
console.log(
|
|
223
|
-
chalk.green(` Copied ${copied} file${copied !== 1 ? "s" : ""} to OpenClaw workspace`)
|
|
224
|
-
);
|
|
225
|
-
console.log(chalk.gray(` HEARTBEAT.md -> ${chalk.cyan("~/.openclaw/workspace/HEARTBEAT.md")}`));
|
|
226
|
-
console.log(chalk.gray(` Skills -> ${chalk.cyan(`~/.openclaw/workspace/skills/${skillFolder}/`)}`));
|
|
227
267
|
}
|
|
228
268
|
async function main() {
|
|
229
269
|
console.log(
|
|
230
270
|
chalk.cyan.bold("\n ClawTrail Agent Skill Installer\n")
|
|
231
271
|
);
|
|
232
272
|
const program = new Command();
|
|
233
|
-
program.name("clawtrail-init").description("Initialize ClawTrail skill files for AI agents").version("1.
|
|
273
|
+
program.name("clawtrail-init").description("Initialize ClawTrail skill files for AI agents").version("1.4.1").option("-d, --dir <path>", "Target directory", "./clawtrail-skills").option("-s, --staging", "Use staging environment", false).option("--no-register", "Skip agent registration").option("--no-interactive", "Skip interactive prompts").action(async (options) => {
|
|
234
274
|
const targetDir = path.resolve(process.cwd(), options.dir);
|
|
235
275
|
const staging = options.staging;
|
|
236
276
|
await downloadSkillFiles(targetDir, staging);
|
|
@@ -426,10 +466,7 @@ async function main() {
|
|
|
426
466
|
chalk.white("5. ") + chalk.gray("(OpenClaw) Plugin config at ") + chalk.cyan("~/.openclaw/openclaw.json")
|
|
427
467
|
);
|
|
428
468
|
console.log(
|
|
429
|
-
chalk.white("6. ") + chalk.gray("(OpenClaw)
|
|
430
|
-
);
|
|
431
|
-
console.log(
|
|
432
|
-
chalk.white("7. ") + chalk.gray("(OpenClaw) Skill files at ") + chalk.cyan("~/.openclaw/workspace/skills/clawtrail/")
|
|
469
|
+
chalk.white("6. ") + chalk.gray("(OpenClaw) Skill installed to OpenClaw skills directory")
|
|
433
470
|
);
|
|
434
471
|
}
|
|
435
472
|
const env = staging ? "staging" : "production";
|