Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

Fix OpenClaw dist plugin installs

JerrettDavis95f7a0b74e7c
diff --git a/plugins/openclaw/README.md b/plugins/openclaw/README.md
index 86dc1cace..61d8dd36d 100644
--- a/plugins/openclaw/README.md
+++ b/plugins/openclaw/README.md
@@ -13,19 +13,26 @@ This plugin can auto-start a local `headroom proxy` when needed. OpenClaw treats
## Local Development Install (Detection-Friendly)
-If you are testing from this repo, run npm install/build from the plugin directory so local launcher detection aligns with runtime paths:
+If you are testing from this repo, run npm install/build from the plugin directory so local launcher detection aligns with runtime paths. The build now emits a self-contained `dist/` plugin root, so either of these linked installs works:
```bash
cd plugins/openclaw
npm install
npm run build
+openclaw plugins install --dangerously-force-unsafe-install --link dist
+```
+
+Or, from inside `dist/`:
+
+```bash
+cd plugins/openclaw/dist
openclaw plugins install --dangerously-force-unsafe-install --link .
```
Why this matters:
- The plugin checks launchers in this order: PATH -> local npm bin -> global npm -> python.
-- "local npm bin" means `plugins/openclaw/node_modules/.bin/headroom` relative to the installed plugin root.
-- Using `--link .` from `plugins/openclaw` keeps that local path aligned for detection.
+- "local npm bin" means `plugins/openclaw/node_modules/.bin/headroom` relative to the source checkout.
+- Using `--link dist` (or `--link .` from `dist/`) still keeps runtime code adjacent to the checkout, and launcher detection falls back to PATH/global/python if a local npm bin is not present under the installed root.
- If you install from a `.tgz`, local npm bin may not exist in the installed extension and detection will fall back to PATH/global/python.
## Configure
diff --git a/plugins/openclaw/package.json b/plugins/openclaw/package.json
index 4ffcaf8ec..c34372ad7 100644
--- a/plugins/openclaw/package.json
+++ b/plugins/openclaw/package.json
@@ -11,7 +11,7 @@
"README.md"
],
"scripts": {
- "build": "tsup",
+ "build": "tsup && node prepare-dist.mjs",
"test": "vitest run",
"test:watch": "vitest",
"typecheck": "tsc --noEmit"
@@ -34,12 +34,6 @@
"vitest": "^2.0.0"
},
"openclaw": {
- "hooks": {
- "contextEngine": "dist/index.js",
- "tools": [
- "dist/index.js"
- ]
- },
"extensions": [
"./dist/index.js"
],
diff --git a/plugins/openclaw/prepare-dist.mjs b/plugins/openclaw/prepare-dist.mjs
new file mode 100644
index 000000000..a431bffd5
--- /dev/null
+++ b/plugins/openclaw/prepare-dist.mjs
@@ -0,0 +1,43 @@
+import fs from "node:fs/promises";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const __dirname = path.dirname(fileURLToPath(import.meta.url));
+const rootDir = __dirname;
+const distDir = path.join(rootDir, "dist");
+
+const rootPackage = JSON.parse(
+ await fs.readFile(path.join(rootDir, "package.json"), "utf8"),
+);
+
+const distPackage = {
+ name: rootPackage.name,
+ version: rootPackage.version,
+ description: rootPackage.description,
+ type: rootPackage.type,
+ main: "./index.js",
+ types: "./index.d.ts",
+ license: rootPackage.license,
+ dependencies: rootPackage.dependencies,
+ peerDependencies: rootPackage.peerDependencies,
+ peerDependenciesMeta: rootPackage.peerDependenciesMeta,
+ openclaw: {
+ extensions: ["./index.js"],
+ capabilities: rootPackage.openclaw?.capabilities ?? {},
+ },
+};
+
+await fs.mkdir(distDir, { recursive: true });
+await fs.writeFile(
+ path.join(distDir, "package.json"),
+ `${JSON.stringify(distPackage, null, 2)}\n`,
+ "utf8",
+);
+
+await Promise.all([
+ fs.copyFile(
+ path.join(rootDir, "openclaw.plugin.json"),
+ path.join(distDir, "openclaw.plugin.json"),
+ ),
+ fs.copyFile(path.join(rootDir, "README.md"), path.join(distDir, "README.md")),
+]);