@clawtrail/init 1.3.2 → 1.4.0
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 +78 -24
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -200,37 +200,94 @@ 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
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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"
|
|
212
213
|
];
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
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");
|
|
216
218
|
try {
|
|
217
|
-
await fs.
|
|
218
|
-
|
|
219
|
+
await fs.access(npmGlobalPath);
|
|
220
|
+
return npmGlobalPath;
|
|
219
221
|
} catch {
|
|
220
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
|
+
}
|
|
235
|
+
async function copyToOpenClawSkills(targetDir, staging) {
|
|
236
|
+
const skillFolder = staging ? "clawtrail-staging" : "clawtrail";
|
|
237
|
+
const openclawSkillsDir = await findOpenClawSkillsDir();
|
|
238
|
+
if (openclawSkillsDir) {
|
|
239
|
+
const destDir = path.join(openclawSkillsDir, skillFolder);
|
|
240
|
+
await ensureDirectory(destDir);
|
|
241
|
+
const copies = [
|
|
242
|
+
{ file: "SKILL.md", dest: path.join(destDir, "SKILL.md") },
|
|
243
|
+
{ file: "HEARTBEAT.md", dest: path.join(destDir, "HEARTBEAT.md") }
|
|
244
|
+
];
|
|
245
|
+
let copied = 0;
|
|
246
|
+
for (const { file, dest } of copies) {
|
|
247
|
+
const src = path.join(targetDir, file);
|
|
248
|
+
try {
|
|
249
|
+
await fs.copyFile(src, dest);
|
|
250
|
+
copied++;
|
|
251
|
+
} catch {
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const prettyPath = openclawSkillsDir.replace(os.homedir(), "~");
|
|
255
|
+
console.log(
|
|
256
|
+
chalk.green(` Installed ${copied} file${copied !== 1 ? "s" : ""} to OpenClaw skills`)
|
|
257
|
+
);
|
|
258
|
+
console.log(chalk.gray(` ${chalk.cyan(`${prettyPath}/${skillFolder}/SKILL.md`)}`));
|
|
259
|
+
console.log(chalk.gray(` ${chalk.cyan(`${prettyPath}/${skillFolder}/HEARTBEAT.md`)}`));
|
|
260
|
+
} else {
|
|
261
|
+
const workspaceDir = path.join(os.homedir(), ".openclaw", "workspace");
|
|
262
|
+
const skillsDir = path.join(workspaceDir, "skills", skillFolder);
|
|
263
|
+
await ensureDirectory(workspaceDir);
|
|
264
|
+
await ensureDirectory(skillsDir);
|
|
265
|
+
const copies = [
|
|
266
|
+
{ file: "SKILL.md", dest: path.join(skillsDir, "SKILL.md") },
|
|
267
|
+
{ file: "HEARTBEAT.md", dest: path.join(skillsDir, "HEARTBEAT.md") }
|
|
268
|
+
];
|
|
269
|
+
let copied = 0;
|
|
270
|
+
for (const { file, dest } of copies) {
|
|
271
|
+
const src = path.join(targetDir, file);
|
|
272
|
+
try {
|
|
273
|
+
await fs.copyFile(src, dest);
|
|
274
|
+
copied++;
|
|
275
|
+
} catch {
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
console.log(
|
|
279
|
+
chalk.yellow(` Could not find OpenClaw global install \u2014 placed files in workspace fallback`)
|
|
280
|
+
);
|
|
281
|
+
console.log(chalk.gray(` ${chalk.cyan(`~/.openclaw/workspace/skills/${skillFolder}/`)}`));
|
|
282
|
+
console.log(chalk.gray(` You may need to manually copy SKILL.md to your OpenClaw skills directory.`));
|
|
221
283
|
}
|
|
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
284
|
}
|
|
228
285
|
async function main() {
|
|
229
286
|
console.log(
|
|
230
287
|
chalk.cyan.bold("\n ClawTrail Agent Skill Installer\n")
|
|
231
288
|
);
|
|
232
289
|
const program = new Command();
|
|
233
|
-
program.name("clawtrail-init").description("Initialize ClawTrail skill files for AI agents").version("1.
|
|
290
|
+
program.name("clawtrail-init").description("Initialize ClawTrail skill files for AI agents").version("1.4.0").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
291
|
const targetDir = path.resolve(process.cwd(), options.dir);
|
|
235
292
|
const staging = options.staging;
|
|
236
293
|
await downloadSkillFiles(targetDir, staging);
|
|
@@ -426,10 +483,7 @@ async function main() {
|
|
|
426
483
|
chalk.white("5. ") + chalk.gray("(OpenClaw) Plugin config at ") + chalk.cyan("~/.openclaw/openclaw.json")
|
|
427
484
|
);
|
|
428
485
|
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/")
|
|
486
|
+
chalk.white("6. ") + chalk.gray("(OpenClaw) Skill installed to OpenClaw skills directory")
|
|
433
487
|
);
|
|
434
488
|
}
|
|
435
489
|
const env = staging ? "staging" : "production";
|