@clawtrail/init 2.5.2 → 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.
Files changed (2) hide show
  1. package/dist/index.js +59 -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,55 @@ 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 });
146
140
  try {
147
141
  execSync(
148
- "npm install -g @clawtrail/context-graph @clawtrail/context-graph-openclaw",
142
+ "openclaw plugins install @clawtrail/context-graph-openclaw",
149
143
  { stdio: "pipe", timeout: 12e4 }
150
144
  );
151
145
  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:
146
+ } catch (err) {
147
+ installError = err.stderr?.toString().trim() || err.stdout?.toString().trim() || err.message || "Unknown error";
148
+ }
149
+ } catch {
150
+ }
151
+ if (!packagesInstalled) {
152
+ try {
153
+ execSync(
154
+ `npm install --prefix "${extensionsDir}" @clawtrail/context-graph @clawtrail/context-graph-openclaw`,
155
+ { stdio: "pipe", timeout: 12e4 }
156
+ );
157
+ packagesInstalled = true;
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:
155
171
  ${localErr.split("\n").slice(-3).join("\n ")}
156
172
  Global install failed:
157
173
  ${globalErr.split("\n").slice(-3).join("\n ")}`;
174
+ }
158
175
  }
159
176
  }
160
177
  if (packagesInstalled) {
161
178
  spinner.succeed(
162
179
  chalk.green(
163
- `Context-graph configured \u2192 auto-submit to ${staging ? "staging" : "production"}`
180
+ `Context-graph plugin installed \u2192 auto-submit to ${staging ? "staging" : "production"}`
164
181
  )
165
182
  );
166
183
  } else {
167
184
  spinner.warn(
168
185
  chalk.yellow(
169
186
  `Context-graph configured but packages not installed \u2014 run manually:
170
- npm install -g @clawtrail/context-graph @clawtrail/context-graph-openclaw`
187
+ openclaw plugins install @clawtrail/context-graph-openclaw`
171
188
  )
172
189
  );
173
190
  if (installError) {
@@ -179,7 +196,7 @@ Global install failed:
179
196
  }
180
197
  return {
181
198
  installed: true,
182
- configPath: "~/.openclaw/plugins/context-graph/config.json",
199
+ configPath: 'plugins.entries["context-graph"] in ~/.openclaw/openclaw.json',
183
200
  packagesInstalled
184
201
  };
185
202
  }
@@ -368,6 +385,12 @@ async function handleUninstall(staging) {
368
385
  }
369
386
  const spinner2a = ora("Removing context-graph...").start();
370
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
+ }
371
394
  try {
372
395
  const cgPluginDir = path.join(openclawDir, "plugins", "context-graph");
373
396
  await fs.rm(cgPluginDir, { recursive: true, force: true });
@@ -410,6 +433,12 @@ async function handleUninstall(staging) {
410
433
  delete config.skills.entries;
411
434
  if (Object.keys(config.skills).length === 0) delete config.skills;
412
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
+ }
413
442
  if (config.plugins?.["context-graph"]) {
414
443
  delete config.plugins["context-graph"];
415
444
  if (Object.keys(config.plugins).length === 0) delete config.plugins;
@@ -464,7 +493,7 @@ async function handleUninstall(staging) {
464
493
  }
465
494
  if (cgRemoved) {
466
495
  console.log(
467
- chalk.white(" Removed: ") + chalk.red("~/.openclaw/plugins/context-graph/")
496
+ chalk.white(" Removed: ") + chalk.red("~/.openclaw/extensions/context-graph/")
468
497
  );
469
498
  }
470
499
  if (configCleaned) {
@@ -487,7 +516,7 @@ async function main() {
487
516
  const program = new Command();
488
517
  program.name("clawtrail-init").description(
489
518
  "Install ClawTrail skill files, configure heartbeat, and optionally register an agent"
490
- ).version("2.5.2").option(
519
+ ).version("2.6.0").option(
491
520
  "-d, --dir <path>",
492
521
  "Download directory for skill files",
493
522
  "./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.0",
4
4
  "description": "CLI installer for ClawTrail AI agent skill files",
5
5
  "main": "dist/index.js",
6
6
  "bin": {