@clawtrail/init 2.5.1 → 2.6.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 +68 -26
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -100,18 +100,9 @@ async function downloadSkillFiles(targetDir, staging = false) {
|
|
|
100
100
|
async function installContextGraph(staging, agentId, apiKey) {
|
|
101
101
|
const spinner = ora("Setting up context-graph provenance...").start();
|
|
102
102
|
const openclawDir = path.join(os.homedir(), ".openclaw");
|
|
103
|
-
const
|
|
104
|
-
await ensureDirectory(
|
|
103
|
+
const extensionsDir = path.join(openclawDir, "extensions", "context-graph");
|
|
104
|
+
await ensureDirectory(extensionsDir);
|
|
105
105
|
const apiUrl = staging ? "https://sapi.clawtrail.ai/ct/api" : "https://api.clawtrail.ai/ct/api";
|
|
106
|
-
const cgConfig = {
|
|
107
|
-
submitUrl: `${apiUrl}/context-graph/submit`,
|
|
108
|
-
agentId: agentId || null,
|
|
109
|
-
apiKey: apiKey || null,
|
|
110
|
-
autoSubmit: true,
|
|
111
|
-
environment: staging ? "staging" : "production"
|
|
112
|
-
};
|
|
113
|
-
const configPath = path.join(pluginDir, "config.json");
|
|
114
|
-
await fs.writeFile(configPath, JSON.stringify(cgConfig, null, 2), "utf-8");
|
|
115
106
|
const openclawConfigPath = path.join(openclawDir, "openclaw.json");
|
|
116
107
|
try {
|
|
117
108
|
let config = {};
|
|
@@ -120,11 +111,20 @@ async function installContextGraph(staging, agentId, apiKey) {
|
|
|
120
111
|
config = JSON5.parse(existing);
|
|
121
112
|
} catch {
|
|
122
113
|
}
|
|
114
|
+
if (config.plugins?.["context-graph"]) {
|
|
115
|
+
delete config.plugins["context-graph"];
|
|
116
|
+
}
|
|
123
117
|
config.plugins ??= {};
|
|
124
|
-
config.plugins
|
|
118
|
+
config.plugins.entries ??= {};
|
|
119
|
+
config.plugins.entries["context-graph"] = {
|
|
125
120
|
enabled: true,
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
config: {
|
|
122
|
+
submitUrl: `${apiUrl}/context-graph/submit`,
|
|
123
|
+
agentId: agentId || void 0,
|
|
124
|
+
apiKey: apiKey || void 0,
|
|
125
|
+
autoSubmit: true,
|
|
126
|
+
environment: staging ? "staging" : "production"
|
|
127
|
+
}
|
|
128
128
|
};
|
|
129
129
|
await fs.writeFile(
|
|
130
130
|
openclawConfigPath,
|
|
@@ -134,39 +134,69 @@ async function installContextGraph(staging, agentId, apiKey) {
|
|
|
134
134
|
} catch {
|
|
135
135
|
}
|
|
136
136
|
let packagesInstalled = false;
|
|
137
|
+
let installError = "";
|
|
137
138
|
try {
|
|
138
|
-
execSync(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
execSync("openclaw --version", { stdio: "pipe", timeout: 5e3 });
|
|
140
|
+
try {
|
|
141
|
+
execSync(
|
|
142
|
+
"openclaw plugins install @clawtrail/context-graph-openclaw",
|
|
143
|
+
{ stdio: "pipe", timeout: 12e4 }
|
|
144
|
+
);
|
|
145
|
+
packagesInstalled = true;
|
|
146
|
+
} catch (err) {
|
|
147
|
+
installError = err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message || "Unknown error";
|
|
148
|
+
}
|
|
143
149
|
} catch {
|
|
150
|
+
}
|
|
151
|
+
if (!packagesInstalled) {
|
|
144
152
|
try {
|
|
145
153
|
execSync(
|
|
146
|
-
|
|
154
|
+
`npm install --prefix "${extensionsDir}" @clawtrail/context-graph @clawtrail/context-graph-openclaw`,
|
|
147
155
|
{ stdio: "pipe", timeout: 12e4 }
|
|
148
156
|
);
|
|
149
157
|
packagesInstalled = true;
|
|
150
|
-
|
|
158
|
+
installError = "";
|
|
159
|
+
} catch (err) {
|
|
160
|
+
const localErr = err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message || "Unknown error";
|
|
161
|
+
try {
|
|
162
|
+
execSync(
|
|
163
|
+
"npm install -g @clawtrail/context-graph @clawtrail/context-graph-openclaw",
|
|
164
|
+
{ stdio: "pipe", timeout: 12e4 }
|
|
165
|
+
);
|
|
166
|
+
packagesInstalled = true;
|
|
167
|
+
installError = "";
|
|
168
|
+
} catch (err2) {
|
|
169
|
+
const globalErr = err2.stderr?.toString().trim() || err2.stdout?.toString().trim() || err2.message || "Unknown error";
|
|
170
|
+
installError = `Local install failed:
|
|
171
|
+
${localErr.split("\n").slice(-3).join("\n ")}
|
|
172
|
+
Global install failed:
|
|
173
|
+
${globalErr.split("\n").slice(-3).join("\n ")}`;
|
|
174
|
+
}
|
|
151
175
|
}
|
|
152
176
|
}
|
|
153
177
|
if (packagesInstalled) {
|
|
154
178
|
spinner.succeed(
|
|
155
179
|
chalk.green(
|
|
156
|
-
`Context-graph
|
|
180
|
+
`Context-graph plugin installed \u2192 auto-submit to ${staging ? "staging" : "production"}`
|
|
157
181
|
)
|
|
158
182
|
);
|
|
159
183
|
} else {
|
|
160
184
|
spinner.warn(
|
|
161
185
|
chalk.yellow(
|
|
162
186
|
`Context-graph configured but packages not installed \u2014 run manually:
|
|
163
|
-
|
|
187
|
+
openclaw plugins install @clawtrail/context-graph-openclaw`
|
|
164
188
|
)
|
|
165
189
|
);
|
|
190
|
+
if (installError) {
|
|
191
|
+
console.log(chalk.dim(`
|
|
192
|
+
Install errors:
|
|
193
|
+
${installError}
|
|
194
|
+
`));
|
|
195
|
+
}
|
|
166
196
|
}
|
|
167
197
|
return {
|
|
168
198
|
installed: true,
|
|
169
|
-
configPath: "
|
|
199
|
+
configPath: 'plugins.entries["context-graph"] in ~/.openclaw/openclaw.json',
|
|
170
200
|
packagesInstalled
|
|
171
201
|
};
|
|
172
202
|
}
|
|
@@ -355,6 +385,12 @@ async function handleUninstall(staging) {
|
|
|
355
385
|
}
|
|
356
386
|
const spinner2a = ora("Removing context-graph...").start();
|
|
357
387
|
let cgRemoved = false;
|
|
388
|
+
try {
|
|
389
|
+
const cgExtDir = path.join(openclawDir, "extensions", "context-graph");
|
|
390
|
+
await fs.rm(cgExtDir, { recursive: true, force: true });
|
|
391
|
+
cgRemoved = true;
|
|
392
|
+
} catch {
|
|
393
|
+
}
|
|
358
394
|
try {
|
|
359
395
|
const cgPluginDir = path.join(openclawDir, "plugins", "context-graph");
|
|
360
396
|
await fs.rm(cgPluginDir, { recursive: true, force: true });
|
|
@@ -397,6 +433,12 @@ async function handleUninstall(staging) {
|
|
|
397
433
|
delete config.skills.entries;
|
|
398
434
|
if (Object.keys(config.skills).length === 0) delete config.skills;
|
|
399
435
|
}
|
|
436
|
+
if (config.plugins?.entries?.["context-graph"]) {
|
|
437
|
+
delete config.plugins.entries["context-graph"];
|
|
438
|
+
if (Object.keys(config.plugins.entries).length === 0)
|
|
439
|
+
delete config.plugins.entries;
|
|
440
|
+
if (Object.keys(config.plugins).length === 0) delete config.plugins;
|
|
441
|
+
}
|
|
400
442
|
if (config.plugins?.["context-graph"]) {
|
|
401
443
|
delete config.plugins["context-graph"];
|
|
402
444
|
if (Object.keys(config.plugins).length === 0) delete config.plugins;
|
|
@@ -451,7 +493,7 @@ async function handleUninstall(staging) {
|
|
|
451
493
|
}
|
|
452
494
|
if (cgRemoved) {
|
|
453
495
|
console.log(
|
|
454
|
-
chalk.white(" Removed: ") + chalk.red("~/.openclaw/
|
|
496
|
+
chalk.white(" Removed: ") + chalk.red("~/.openclaw/extensions/context-graph/")
|
|
455
497
|
);
|
|
456
498
|
}
|
|
457
499
|
if (configCleaned) {
|
|
@@ -474,7 +516,7 @@ async function main() {
|
|
|
474
516
|
const program = new Command();
|
|
475
517
|
program.name("clawtrail-init").description(
|
|
476
518
|
"Install ClawTrail skill files, configure heartbeat, and optionally register an agent"
|
|
477
|
-
).version("2.
|
|
519
|
+
).version("2.6.0").option(
|
|
478
520
|
"-d, --dir <path>",
|
|
479
521
|
"Download directory for skill files",
|
|
480
522
|
"./clawtrail-skills"
|