1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
|
--- package.json.orig 2026-02-22 13:55:09.528328022 +0100
+++ package.json 2026-02-22 13:55:09.534328023 +0100
@@ -51,20 +51,20 @@
"android:install": "cd apps/android && ./gradlew :app:installDebug",
"android:run": "cd apps/android && ./gradlew :app:installDebug && adb shell am start -n ai.openclaw.android/.MainActivity",
"android:test": "cd apps/android && ./gradlew :app:testDebugUnitTest",
- "build": "pnpm canvas:a2ui:bundle && tsdown && pnpm build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --import tsx scripts/write-cli-compat.ts",
+ "build": "bun run canvas:a2ui:bundle && tsdown && bun run build:plugin-sdk:dts && node --import tsx scripts/write-plugin-sdk-entry-dts.ts && node --import tsx scripts/canvas-a2ui-copy.ts && node --import tsx scripts/copy-hook-metadata.ts && node --import tsx scripts/copy-export-html-templates.ts && node --import tsx scripts/write-build-info.ts && node --import tsx scripts/write-cli-compat.ts",
"build:plugin-sdk:dts": "tsc -p tsconfig.plugin-sdk.dts.json",
"canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh",
- "check": "pnpm format:check && pnpm tsgo && pnpm lint",
- "check:docs": "pnpm format:docs:check && pnpm lint:docs && pnpm docs:check-links",
+ "check": "bun run format:check && bun run tsgo && bun run lint",
+ "check:docs": "bun run format:docs:check && bun run lint:docs && bun run docs:check-links",
"check:loc": "node --import tsx scripts/check-ts-max-loc.ts --max 500",
- "deadcode:ci": "pnpm deadcode:report:ci:knip && pnpm deadcode:report:ci:ts-prune && pnpm deadcode:report:ci:ts-unused",
- "deadcode:knip": "pnpm dlx knip --no-progress",
- "deadcode:report": "pnpm deadcode:knip; pnpm deadcode:ts-prune; pnpm deadcode:ts-unused",
- "deadcode:report:ci:knip": "mkdir -p .artifacts/deadcode && pnpm deadcode:knip > .artifacts/deadcode/knip.txt 2>&1 || true",
- "deadcode:report:ci:ts-prune": "mkdir -p .artifacts/deadcode && pnpm deadcode:ts-prune > .artifacts/deadcode/ts-prune.txt 2>&1 || true",
- "deadcode:report:ci:ts-unused": "mkdir -p .artifacts/deadcode && pnpm deadcode:ts-unused > .artifacts/deadcode/ts-unused-exports.txt 2>&1 || true",
- "deadcode:ts-prune": "pnpm dlx ts-prune src extensions scripts",
- "deadcode:ts-unused": "pnpm dlx ts-unused-exports tsconfig.json --ignoreTestFiles --exitWithCount",
+ "deadcode:ci": "bun run deadcode:report:ci:knip && bun run deadcode:report:ci:ts-prune && bun run deadcode:report:ci:ts-unused",
+ "deadcode:knip": "bun run dlx knip --no-progress",
+ "deadcode:report": "bun run deadcode:knip; bun run deadcode:ts-prune; bun run deadcode:ts-unused",
+ "deadcode:report:ci:knip": "mkdir -p .artifacts/deadcode && bun run deadcode:knip > .artifacts/deadcode/knip.txt 2>&1 || true",
+ "deadcode:report:ci:ts-prune": "mkdir -p .artifacts/deadcode && bun run deadcode:ts-prune > .artifacts/deadcode/ts-prune.txt 2>&1 || true",
+ "deadcode:report:ci:ts-unused": "mkdir -p .artifacts/deadcode && bun run deadcode:ts-unused > .artifacts/deadcode/ts-unused-exports.txt 2>&1 || true",
+ "deadcode:ts-prune": "bun run dlx ts-prune src extensions scripts",
+ "deadcode:ts-unused": "bun run dlx ts-unused-exports tsconfig.json --ignoreTestFiles --exitWithCount",
"dev": "node scripts/run-node.mjs",
"docs:bin": "node scripts/build-docs-list.mjs",
"docs:check-links": "node scripts/docs-link-audit.mjs",
@@ -73,7 +73,7 @@
"docs:spellcheck": "bash scripts/docs-spellcheck.sh",
"docs:spellcheck:fix": "bash scripts/docs-spellcheck.sh --write",
"format": "oxfmt --write",
- "format:all": "pnpm format && pnpm format:swift",
+ "format:all": "bun run format && bun run format:swift",
"format:check": "oxfmt --check",
"format:diff": "oxfmt --write && git --no-pager diff",
"format:docs": "git ls-files 'docs/**/*.md' 'docs/**/*.mdx' 'README.md' | xargs oxfmt --write",
@@ -88,10 +88,10 @@
"ios:open": "bash -lc './scripts/ios-configure-signing.sh && cd apps/ios && xcodegen generate && open OpenClaw.xcodeproj'",
"ios:run": "bash -lc './scripts/ios-configure-signing.sh && cd apps/ios && xcodegen generate && xcodebuild -project OpenClaw.xcodeproj -scheme OpenClaw -destination \"${IOS_DEST:-platform=iOS Simulator,name=iPhone 17}\" -configuration Debug build && xcrun simctl boot \"${IOS_SIM:-iPhone 17}\" || true && xcrun simctl launch booted ai.openclaw.ios'",
"lint": "oxlint --type-aware",
- "lint:all": "pnpm lint && pnpm lint:swift",
- "lint:docs": "pnpm dlx markdownlint-cli2",
- "lint:docs:fix": "pnpm dlx markdownlint-cli2 --fix",
- "lint:fix": "oxlint --type-aware --fix && pnpm format",
+ "lint:all": "bun run lint && bun run lint:swift",
+ "lint:docs": "bun run dlx markdownlint-cli2",
+ "lint:docs:fix": "bun run dlx markdownlint-cli2 --fix",
+ "lint:fix": "oxlint --type-aware --fix && bun run format",
"lint:swift": "swiftlint lint --config .swiftlint.yml && (cd apps/ios && swiftlint lint --config .swiftlint.yml)",
"mac:open": "open dist/OpenClaw.app",
"mac:package": "bash scripts/package-mac-app.sh",
@@ -100,17 +100,17 @@
"openclaw": "node scripts/run-node.mjs",
"openclaw:rpc": "node scripts/run-node.mjs agent --mode rpc --json",
"plugins:sync": "node --import tsx scripts/sync-plugin-versions.ts",
- "prepack": "pnpm build && pnpm ui:build",
+ "prepack": "bun run build && bun run ui:build",
"prepare": "command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1 && git config core.hooksPath git-hooks || exit 0",
- "protocol:check": "pnpm protocol:gen && pnpm protocol:gen:swift && git diff --exit-code -- dist/protocol.schema.json apps/macos/Sources/OpenClawProtocol/GatewayModels.swift",
+ "protocol:check": "bun run protocol:gen && bun run protocol:gen:swift && git diff --exit-code -- dist/protocol.schema.json apps/macos/Sources/OpenClawProtocol/GatewayModels.swift",
"protocol:gen": "node --import tsx scripts/protocol-gen.ts",
"protocol:gen:swift": "node --import tsx scripts/protocol-gen-swift.ts",
"release:check": "node --import tsx scripts/release-check.ts",
"start": "node scripts/run-node.mjs",
"test": "node scripts/test-parallel.mjs",
- "test:all": "pnpm lint && pnpm build && pnpm test && pnpm test:e2e && pnpm test:live && pnpm test:docker:all",
+ "test:all": "bun run lint && bun run build && bun run test && bun run test:e2e && bun run test:live && bun run test:docker:all",
"test:coverage": "vitest run --config vitest.unit.config.ts --coverage",
- "test:docker:all": "pnpm test:docker:live-models && pnpm test:docker:live-gateway && pnpm test:docker:onboard && pnpm test:docker:gateway-network && pnpm test:docker:qr && pnpm test:docker:doctor-switch && pnpm test:docker:plugins && pnpm test:docker:cleanup",
+ "test:docker:all": "bun run test:docker:live-models && bun run test:docker:live-gateway && bun run test:docker:onboard && bun run test:docker:gateway-network && bun run test:docker:qr && bun run test:docker:doctor-switch && bun run test:docker:plugins && bun run test:docker:cleanup",
"test:docker:cleanup": "bash scripts/test-cleanup-docker.sh",
"test:docker:doctor-switch": "bash scripts/e2e/doctor-install-switch-docker.sh",
"test:docker:gateway-network": "bash scripts/e2e/gateway-network-docker.sh",
@@ -128,7 +128,7 @@
"test:install:smoke": "bash scripts/test-install-sh-docker.sh",
"test:live": "OPENCLAW_LIVE_TEST=1 CLAWDBOT_LIVE_TEST=1 vitest run --config vitest.live.config.ts",
"test:macmini": "OPENCLAW_TEST_VM_FORKS=0 OPENCLAW_TEST_PROFILE=serial node scripts/test-parallel.mjs",
- "test:ui": "pnpm --dir ui test",
+ "test:ui": "bun run --dir ui test",
"test:voicecall:closedloop": "vitest run extensions/voice-call/src/manager.test.ts extensions/voice-call/src/media-stream.test.ts src/plugins/voice-call.plugin.test.ts --maxWorkers=1",
"test:watch": "vitest",
"tui": "node scripts/run-node.mjs tui",
@@ -142,7 +142,6 @@
"@aws-sdk/client-bedrock": "^3.995.0",
"@buape/carbon": "0.0.0-beta-20260216184201",
"@clack/prompts": "^1.0.1",
- "@discordjs/opus": "^0.10.0",
"@discordjs/voice": "^0.19.0",
"@grammyjs/runner": "^2.0.3",
"@grammyjs/transformer-throttler": "^1.2.1",
@@ -203,6 +202,7 @@
"@typescript/native-preview": "7.0.0-dev.20260221.1",
"@vitest/coverage-v8": "^4.0.18",
"lit": "^3.3.2",
+ "node-gyp": "^12.2.0",
"oxfmt": "0.34.0",
"oxlint": "^1.49.0",
"oxlint-tsgolint": "^0.14.2",
@@ -219,7 +219,7 @@
"engines": {
"node": ">=22.12.0"
},
- "packageManager": "pnpm@10.23.0",
+ "packageManager": "bun@1.2.0",
"pnpm": {
"minimumReleaseAge": 2880,
"overrides": {
--- scripts/bundle-a2ui.sh.orig 2026-02-22 13:55:09.535328023 +0100
+++ scripts/bundle-a2ui.sh 2026-02-22 13:55:09.536328023 +0100
@@ -85,7 +85,7 @@
fi
fi
-pnpm -s exec tsc -p "$A2UI_RENDERER_DIR/tsconfig.json"
+bun run tsc -p "$A2UI_RENDERER_DIR/tsconfig.json"
if command -v rolldown >/dev/null 2>&1; then
rolldown -c "$A2UI_APP_DIR/rolldown.config.mjs"
else
--- scripts/ui.js.orig 2026-02-22 13:55:09.536328023 +0100
+++ scripts/ui.js 2026-02-22 13:55:09.539328023 +0100
@@ -46,6 +46,10 @@
}
function resolveRunner() {
+ const bun = which("bun");
+ if (bun) {
+ return { cmd: bun, kind: "bun" };
+ }
const pnpm = which("pnpm");
if (pnpm) {
return { cmd: pnpm, kind: "pnpm" };
@@ -168,7 +172,7 @@
const runner = resolveRunner();
if (!runner) {
- process.stderr.write("Missing UI runner: install pnpm, then retry.\n");
+ process.stderr.write("Missing UI runner: install bun or pnpm, then retry.\n");
process.exit(1);
}
--- src/agents/skills-install.ts.orig 2026-02-22 13:55:09.542328024 +0100
+++ src/agents/skills-install.ts 2026-02-22 13:55:09.549328025 +0100
@@ -4,7 +4,7 @@
import { resolveBrewExecutable } from "../infra/brew.js";
import { runCommandWithTimeout, type CommandOptions } from "../process/exec.js";
import { scanDirectoryWithSummary } from "../security/skill-scanner.js";
-import { resolveUserPath } from "../utils.js";
+import { resolveUserPath, CONFIG_DIR } from "../utils.js";
import { installDownloadSpec } from "./skills-install-download.js";
import { formatInstallFailureMessage } from "./skills-install-output.js";
import {
@@ -370,6 +370,7 @@
argv: string[] | null;
timeoutMs: number;
env?: NodeJS.ProcessEnv;
+ cwd?: string;
}): Promise<SkillInstallResult> {
if (!params.argv || params.argv.length === 0) {
return createInstallFailure({ message: "invalid install command" });
@@ -378,6 +379,7 @@
const result = await runCommandSafely(params.argv, {
timeoutMs: params.timeoutMs,
env: params.env,
+ cwd: params.cwd,
});
if (result.code === 0) {
return createInstallSuccess(result);
@@ -443,6 +445,10 @@
return withWarnings(resolveBrewMissingFailure(spec), warnings);
}
+ // Force installation into user config directory if package.json exists there or forced by env
+ const configPkgJson = path.join(CONFIG_DIR, "package.json");
+ const forceLocal = process.env.OPENCLAW_FORCE_LOCAL_SKILLS === "1";
+
const uvInstallFailure = await ensureUvInstalled({ spec, brewExe, timeoutMs });
if (uvInstallFailure) {
return withWarnings(uvInstallFailure, warnings);
@@ -454,6 +460,16 @@
}
const argv = command.argv ? [...command.argv] : null;
+ if (spec.kind === "node" && argv && (forceLocal || fs.existsSync(configPkgJson))) {
+ // Remove global flags
+ for (let i = 0; i < argv.length; i++) {
+ if (argv[i] === "-g" || argv[i] === "global") {
+ argv.splice(i, 1);
+ i--;
+ }
+ }
+ }
+
if (spec.kind === "brew" && brewExe && argv?.[0] === "brew") {
argv[0] = brewExe;
}
@@ -466,5 +482,11 @@
}
}
- return withWarnings(await executeInstallCommand({ argv, timeoutMs, env }), warnings);
+
+ // Use CONFIG_DIR as cwd if we are installing locally (stripped globals)
+ const cwd = (spec.kind === "node" && (forceLocal || fs.existsSync(configPkgJson)))
+ ? CONFIG_DIR
+ : undefined;
+
+ return withWarnings(await executeInstallCommand({ argv, timeoutMs, env, cwd }), warnings);
}
--- src/plugins/discovery.ts.orig 2026-02-22 13:55:09.550328025 +0100
+++ src/plugins/discovery.ts 2026-02-22 13:55:09.552328025 +0100
@@ -589,6 +589,15 @@
seen,
});
+ // Discover NPM package plugins in config dir (e.g. ~/.openclaw/node_modules)
+ discoverNpmPlugins({
+ dir: resolveConfigDir(),
+ origin: "global",
+ candidates,
+ diagnostics,
+ seen,
+ });
+
const bundledDir = resolveBundledPluginsDir();
if (bundledDir) {
discoverInDirectory({
@@ -603,3 +612,71 @@
return { candidates, diagnostics };
}
+
+function discoverNpmPlugins(params: {
+ dir: string;
+ origin: PluginOrigin;
+ workspaceDir?: string;
+ candidates: PluginCandidate[];
+ diagnostics: PluginDiagnostic[];
+ seen: Set<string>;
+}) {
+ const nodeModules = path.join(params.dir, "node_modules");
+ if (!fs.existsSync(nodeModules)) {
+ return;
+ }
+
+ let entries: fs.Dirent[] = [];
+ try {
+ entries = fs.readdirSync(nodeModules, { withFileTypes: true });
+ } catch {
+ return;
+ }
+
+ for (const entry of entries) {
+ if (!entry.isDirectory()) continue;
+
+ // Handle scoped packages
+ if (entry.name.startsWith("@")) {
+ const scopeDir = path.join(nodeModules, entry.name);
+ let scopeEntries: fs.Dirent[] = [];
+ try {
+ scopeEntries = fs.readdirSync(scopeDir, { withFileTypes: true });
+ } catch {
+ continue;
+ }
+ for (const scopeEntry of scopeEntries) {
+ if (!scopeEntry.isDirectory()) continue;
+ const fullPath = path.join(scopeDir, scopeEntry.name);
+ const manifest = readPackageManifest(fullPath);
+ if (!manifest || !getPackageManifestMetadata(manifest)) continue;
+
+ // Use generic discovery but only because we confirmed manifest metadata exists
+ discoverInDirectory({
+ dir: fullPath,
+ origin: params.origin,
+ workspaceDir: params.workspaceDir,
+ candidates: params.candidates,
+ diagnostics: params.diagnostics,
+ seen: params.seen,
+ });
+ }
+ continue;
+ }
+
+ if (entry.name.startsWith(".")) continue;
+
+ const fullPath = path.join(nodeModules, entry.name);
+ const manifest = readPackageManifest(fullPath);
+ if (!manifest || !getPackageManifestMetadata(manifest)) continue;
+
+ discoverInDirectory({
+ dir: fullPath,
+ origin: params.origin,
+ workspaceDir: params.workspaceDir,
+ candidates: params.candidates,
+ diagnostics: params.diagnostics,
+ seen: params.seen,
+ });
+ }
+}
--- src/plugins/install.ts.orig 2026-02-22 13:55:09.553328025 +0100
+++ src/plugins/install.ts 2026-02-22 13:55:09.555328025 +0100
@@ -24,6 +24,7 @@
import { validateRegistryNpmSpec } from "../infra/npm-registry-spec.js";
import { extensionUsesSkippedScannerPath, isPathInside } from "../security/scan-paths.js";
import * as skillScanner from "../security/skill-scanner.js";
+import { runCommandWithTimeout } from "../process/exec.js";
import { CONFIG_DIR, resolveUserPath } from "../utils.js";
type PluginInstallLogger = {
@@ -309,6 +310,34 @@
dryRun?: boolean;
expectedPluginId?: string;
}): Promise<InstallPluginResult> {
+ // Force installation into user config directory if package.json exists there
+ const configPkgJson = path.join(CONFIG_DIR, "package.json");
+ if (await fileExists(configPkgJson)) {
+ const logger = params.logger ?? defaultLogger;
+ logger.info?.(`Installing ${params.archivePath} to ${CONFIG_DIR} using system package manager...`);
+
+ const hasPnpmLock = await fileExists(path.join(CONFIG_DIR, "pnpm-lock.yaml"));
+ const hasBunLock = await fileExists(path.join(CONFIG_DIR, "bun.lockb"));
+ const pm = hasBunLock ? "bun" : (hasPnpmLock ? "pnpm" : "npm");
+
+ await fs.mkdir(path.join(CONFIG_DIR, "node_modules"), { recursive: true });
+
+ const res = await runCommandWithTimeout([pm, "install", params.archivePath], {
+ cwd: CONFIG_DIR,
+ timeoutMs: params.timeoutMs ?? 300_000,
+ });
+
+ if (res.code !== 0) {
+ return { ok: false, error: `${pm} install failed: ${res.stderr || res.stdout}` };
+ }
+
+ return {
+ ok: true,
+ pluginId: params.archivePath,
+ targetDir: path.join(CONFIG_DIR, "node_modules", params.archivePath),
+ extensions: [],
+ };
+ }
const logger = params.logger ?? defaultLogger;
const timeoutMs = params.timeoutMs ?? 120_000;
const mode = params.mode ?? "install";
|