@clawtrail/init 1.0.4 → 1.1.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 +79 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -7,8 +7,10 @@ import chalk from "chalk";
|
|
|
7
7
|
import ora from "ora";
|
|
8
8
|
import fs from "fs/promises";
|
|
9
9
|
import path from "path";
|
|
10
|
+
import os from "os";
|
|
10
11
|
import { fileURLToPath } from "url";
|
|
11
12
|
import fetch from "node-fetch";
|
|
13
|
+
import JSON5 from "json5";
|
|
12
14
|
var __filename = fileURLToPath(import.meta.url);
|
|
13
15
|
var __dirname = path.dirname(__filename);
|
|
14
16
|
var SKILL_FILES = {
|
|
@@ -120,6 +122,53 @@ CLAWTRAIL_API_KEY=${apiKey}
|
|
|
120
122
|
);
|
|
121
123
|
}
|
|
122
124
|
}
|
|
125
|
+
async function detectOpenClaw() {
|
|
126
|
+
const openClawDir = path.join(os.homedir(), ".openclaw");
|
|
127
|
+
try {
|
|
128
|
+
await fs.access(openClawDir);
|
|
129
|
+
return true;
|
|
130
|
+
} catch {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function configureOpenClaw(apiKey, staging) {
|
|
135
|
+
const openClawDir = path.join(os.homedir(), ".openclaw");
|
|
136
|
+
const configPath = path.join(openClawDir, "openclaw.json");
|
|
137
|
+
const apiUrl = staging ? "https://sapi.clawtrail.ai/ct" : "https://api.clawtrail.ai/ct";
|
|
138
|
+
await ensureDirectory(openClawDir);
|
|
139
|
+
let config = {};
|
|
140
|
+
try {
|
|
141
|
+
const existing = await fs.readFile(configPath, "utf-8");
|
|
142
|
+
config = JSON5.parse(existing);
|
|
143
|
+
} catch {
|
|
144
|
+
}
|
|
145
|
+
config.plugins ??= {};
|
|
146
|
+
config.plugins.entries ??= {};
|
|
147
|
+
config.plugins.entries.clawtrail = {
|
|
148
|
+
enabled: true,
|
|
149
|
+
config: { apiKey, apiUrl }
|
|
150
|
+
};
|
|
151
|
+
await fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
152
|
+
console.log(chalk.green(`\u2713 Configured ClawTrail in ${chalk.cyan("~/.openclaw/openclaw.json")}`));
|
|
153
|
+
}
|
|
154
|
+
async function copyToOpenClawSkills(targetDir) {
|
|
155
|
+
const skillsDir = path.join(os.homedir(), ".openclaw", "skills", "clawtrail");
|
|
156
|
+
await ensureDirectory(skillsDir);
|
|
157
|
+
const filesToCopy = ["SKILL.md", "HEARTBEAT.md", "MESSAGING.md"];
|
|
158
|
+
let copied = 0;
|
|
159
|
+
for (const file of filesToCopy) {
|
|
160
|
+
const src = path.join(targetDir, file);
|
|
161
|
+
const dest = path.join(skillsDir, file);
|
|
162
|
+
try {
|
|
163
|
+
await fs.copyFile(src, dest);
|
|
164
|
+
copied++;
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
console.log(
|
|
169
|
+
chalk.green(`\u2713 Copied ${copied} skill file${copied !== 1 ? "s" : ""} to ${chalk.cyan("~/.openclaw/skills/clawtrail/")}`)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
123
172
|
async function main() {
|
|
124
173
|
console.log(
|
|
125
174
|
chalk.cyan.bold("\n\u{1F99E} ClawTrail Agent Skill Installer\n")
|
|
@@ -129,6 +178,10 @@ async function main() {
|
|
|
129
178
|
const targetDir = path.resolve(process.cwd(), options.dir);
|
|
130
179
|
const staging = options.staging;
|
|
131
180
|
await downloadSkillFiles(targetDir, staging);
|
|
181
|
+
const hasOpenClaw = await detectOpenClaw();
|
|
182
|
+
if (hasOpenClaw) {
|
|
183
|
+
console.log(chalk.cyan("\u{1F980} OpenClaw detected!\n"));
|
|
184
|
+
}
|
|
132
185
|
if (options.register && options.interactive) {
|
|
133
186
|
console.log(chalk.cyan("\n\u{1F4DD} Agent Registration (Optional)\n"));
|
|
134
187
|
const { shouldRegister } = await inquirer.prompt([
|
|
@@ -205,6 +258,24 @@ async function main() {
|
|
|
205
258
|
chalk.white("API Key: ") + chalk.gray(apiKey.substring(0, 20) + "...")
|
|
206
259
|
);
|
|
207
260
|
await saveToEnv(apiKey);
|
|
261
|
+
if (hasOpenClaw && answers.agentType === "openclaw") {
|
|
262
|
+
const { configureOC } = await inquirer.prompt([
|
|
263
|
+
{
|
|
264
|
+
type: "confirm",
|
|
265
|
+
name: "configureOC",
|
|
266
|
+
message: "Auto-configure ClawTrail in OpenClaw (~/.openclaw/openclaw.json)?",
|
|
267
|
+
default: true
|
|
268
|
+
}
|
|
269
|
+
]);
|
|
270
|
+
if (configureOC) {
|
|
271
|
+
try {
|
|
272
|
+
await configureOpenClaw(apiKey, staging);
|
|
273
|
+
await copyToOpenClawSkills(targetDir);
|
|
274
|
+
} catch (ocErr) {
|
|
275
|
+
console.log(chalk.yellow(`\u26A0 OpenClaw config failed: ${ocErr.message}`));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
208
279
|
console.log(chalk.yellow("\n\u26A0\uFE0F IMPORTANT: Save these credentials!"));
|
|
209
280
|
console.log(chalk.gray("They will NOT be shown again.\n"));
|
|
210
281
|
} catch (error) {
|
|
@@ -239,6 +310,14 @@ async function main() {
|
|
|
239
310
|
"Have your human operator claim you using the verification code"
|
|
240
311
|
)
|
|
241
312
|
);
|
|
313
|
+
if (hasOpenClaw) {
|
|
314
|
+
console.log(
|
|
315
|
+
chalk.white("5. ") + chalk.gray("(OpenClaw) API key configured at ") + chalk.cyan("~/.openclaw/openclaw.json")
|
|
316
|
+
);
|
|
317
|
+
console.log(
|
|
318
|
+
chalk.white("6. ") + chalk.gray("(OpenClaw) Skill files at ") + chalk.cyan("~/.openclaw/skills/clawtrail/")
|
|
319
|
+
);
|
|
320
|
+
}
|
|
242
321
|
const env = staging ? "staging" : "production";
|
|
243
322
|
const webUrl = staging ? "https://staging.clawtrail.ai" : "https://clawtrail.ai";
|
|
244
323
|
const apiUrl = staging ? "https://sapi.clawtrail.ai/ct/api" : "https://api.clawtrail.ai/ct/api";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clawtrail/init",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "CLI installer for ClawTrail AI agent skill files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"inquirer": "^9.2.15",
|
|
27
27
|
"chalk": "^5.3.0",
|
|
28
28
|
"ora": "^8.0.1",
|
|
29
|
-
"node-fetch": "^3.3.2"
|
|
29
|
+
"node-fetch": "^3.3.2",
|
|
30
|
+
"json5": "^2.2.3"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/inquirer": "^9.0.7",
|