@clawtrail/init 2.5.2 → 2.6.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.
Files changed (2) hide show
  1. package/dist/index.js +99 -30
  2. 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 pluginDir = path.join(openclawDir, "plugins", "context-graph");
104
- await ensureDirectory(pluginDir);
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["context-graph"] = {
118
+ config.plugins.entries ??= {};
119
+ config.plugins.entries["context-graph"] = {
125
120
  enabled: true,
126
- configPath: "~/.openclaw/plugins/context-graph/config.json",
127
- autoSubmit: true
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,
@@ -136,38 +136,95 @@ async function installContextGraph(staging, agentId, apiKey) {
136
136
  let packagesInstalled = false;
137
137
  let installError = "";
138
138
  try {
139
- execSync(
140
- `npm install --prefix "${pluginDir}" @clawtrail/context-graph @clawtrail/context-graph-openclaw`,
141
- { stdio: "pipe", timeout: 12e4 }
142
- );
143
- packagesInstalled = true;
144
- } catch (err) {
145
- const localErr = err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message || "Unknown error";
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
+ }
149
+ } catch {
150
+ }
151
+ if (!packagesInstalled) {
146
152
  try {
147
153
  execSync(
148
- "npm install -g @clawtrail/context-graph @clawtrail/context-graph-openclaw",
154
+ `npm install --prefix "${extensionsDir}" @clawtrail/context-graph @clawtrail/context-graph-openclaw`,
149
155
  { stdio: "pipe", timeout: 12e4 }
150
156
  );
151
157
  packagesInstalled = true;
152
- } catch (err2) {
153
- const globalErr = err2.stderr?.toString().trim() || err2.stdout?.toString().trim() || err2.message || "Unknown error";
154
- installError = `Local install failed:
158
+ installError = "";
159
+ const pkgRoot = path.join(
160
+ extensionsDir,
161
+ "node_modules",
162
+ "@clawtrail",
163
+ "context-graph-openclaw"
164
+ );
165
+ const manifestSrc = path.join(pkgRoot, "openclaw.plugin.json");
166
+ const skillsSrc = path.join(pkgRoot, "skills");
167
+ try {
168
+ await fs.copyFile(
169
+ manifestSrc,
170
+ path.join(extensionsDir, "openclaw.plugin.json")
171
+ );
172
+ } catch {
173
+ }
174
+ try {
175
+ await fs.cp(skillsSrc, path.join(extensionsDir, "skills"), {
176
+ recursive: true
177
+ });
178
+ } catch {
179
+ }
180
+ const rootPkg = {
181
+ name: "context-graph",
182
+ private: true,
183
+ type: "module",
184
+ openclaw: {
185
+ extensions: [
186
+ "./node_modules/@clawtrail/context-graph-openclaw/dist/register.js"
187
+ ]
188
+ },
189
+ dependencies: {
190
+ "@clawtrail/context-graph": "^0.1.0",
191
+ "@clawtrail/context-graph-openclaw": "^0.2.0"
192
+ }
193
+ };
194
+ await fs.writeFile(
195
+ path.join(extensionsDir, "package.json"),
196
+ JSON.stringify(rootPkg, null, 2),
197
+ "utf-8"
198
+ );
199
+ } catch (err) {
200
+ const localErr = err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message || "Unknown error";
201
+ try {
202
+ execSync(
203
+ "npm install -g @clawtrail/context-graph @clawtrail/context-graph-openclaw",
204
+ { stdio: "pipe", timeout: 12e4 }
205
+ );
206
+ packagesInstalled = true;
207
+ installError = "";
208
+ } catch (err2) {
209
+ const globalErr = err2.stderr?.toString().trim() || err2.stdout?.toString().trim() || err2.message || "Unknown error";
210
+ installError = `Local install failed:
155
211
  ${localErr.split("\n").slice(-3).join("\n ")}
156
212
  Global install failed:
157
213
  ${globalErr.split("\n").slice(-3).join("\n ")}`;
214
+ }
158
215
  }
159
216
  }
160
217
  if (packagesInstalled) {
161
218
  spinner.succeed(
162
219
  chalk.green(
163
- `Context-graph configured \u2192 auto-submit to ${staging ? "staging" : "production"}`
220
+ `Context-graph plugin installed \u2192 auto-submit to ${staging ? "staging" : "production"}`
164
221
  )
165
222
  );
166
223
  } else {
167
224
  spinner.warn(
168
225
  chalk.yellow(
169
226
  `Context-graph configured but packages not installed \u2014 run manually:
170
- npm install -g @clawtrail/context-graph @clawtrail/context-graph-openclaw`
227
+ openclaw plugins install @clawtrail/context-graph-openclaw`
171
228
  )
172
229
  );
173
230
  if (installError) {
@@ -179,7 +236,7 @@ Global install failed:
179
236
  }
180
237
  return {
181
238
  installed: true,
182
- configPath: "~/.openclaw/plugins/context-graph/config.json",
239
+ configPath: 'plugins.entries["context-graph"] in ~/.openclaw/openclaw.json',
183
240
  packagesInstalled
184
241
  };
185
242
  }
@@ -368,6 +425,12 @@ async function handleUninstall(staging) {
368
425
  }
369
426
  const spinner2a = ora("Removing context-graph...").start();
370
427
  let cgRemoved = false;
428
+ try {
429
+ const cgExtDir = path.join(openclawDir, "extensions", "context-graph");
430
+ await fs.rm(cgExtDir, { recursive: true, force: true });
431
+ cgRemoved = true;
432
+ } catch {
433
+ }
371
434
  try {
372
435
  const cgPluginDir = path.join(openclawDir, "plugins", "context-graph");
373
436
  await fs.rm(cgPluginDir, { recursive: true, force: true });
@@ -410,6 +473,12 @@ async function handleUninstall(staging) {
410
473
  delete config.skills.entries;
411
474
  if (Object.keys(config.skills).length === 0) delete config.skills;
412
475
  }
476
+ if (config.plugins?.entries?.["context-graph"]) {
477
+ delete config.plugins.entries["context-graph"];
478
+ if (Object.keys(config.plugins.entries).length === 0)
479
+ delete config.plugins.entries;
480
+ if (Object.keys(config.plugins).length === 0) delete config.plugins;
481
+ }
413
482
  if (config.plugins?.["context-graph"]) {
414
483
  delete config.plugins["context-graph"];
415
484
  if (Object.keys(config.plugins).length === 0) delete config.plugins;
@@ -464,7 +533,7 @@ async function handleUninstall(staging) {
464
533
  }
465
534
  if (cgRemoved) {
466
535
  console.log(
467
- chalk.white(" Removed: ") + chalk.red("~/.openclaw/plugins/context-graph/")
536
+ chalk.white(" Removed: ") + chalk.red("~/.openclaw/extensions/context-graph/")
468
537
  );
469
538
  }
470
539
  if (configCleaned) {
@@ -487,7 +556,7 @@ async function main() {
487
556
  const program = new Command();
488
557
  program.name("clawtrail-init").description(
489
558
  "Install ClawTrail skill files, configure heartbeat, and optionally register an agent"
490
- ).version("2.5.2").option(
559
+ ).version("2.6.1").option(
491
560
  "-d, --dir <path>",
492
561
  "Download directory for skill files",
493
562
  "./clawtrail-skills"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawtrail/init",
3
- "version": "2.5.2",
3
+ "version": "2.6.1",
4
4
  "description": "CLI installer for ClawTrail AI agent skill files",
5
5
  "main": "dist/index.js",
6
6
  "bin": {