codewave-openclaw-installer 2.2.2 → 2.2.3

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/bin/install.mjs +54 -0
  2. package/package.json +1 -1
package/bin/install.mjs CHANGED
@@ -134,6 +134,59 @@ function readJson(filePath) {
134
134
  }
135
135
  }
136
136
 
137
+ function clearPluginRegistration(pluginIds) {
138
+ if (DRY_RUN) {
139
+ return false;
140
+ }
141
+
142
+ const ids = [...new Set(pluginIds.filter(Boolean))];
143
+ if (ids.length === 0) {
144
+ return false;
145
+ }
146
+
147
+ const config = readJson(OPENCLAW_CONFIG_PATH) || {};
148
+ const currentPlugins = config.plugins;
149
+ if (!currentPlugins) {
150
+ return false;
151
+ }
152
+
153
+ const allow = Array.isArray(currentPlugins.allow) ? currentPlugins.allow.filter((id) => !ids.includes(id)) : currentPlugins.allow;
154
+ const entries = { ...(currentPlugins.entries || {}) };
155
+ const installs = { ...(currentPlugins.installs || {}) };
156
+ let changed = false;
157
+
158
+ for (const id of ids) {
159
+ if (entries[id] !== undefined) {
160
+ delete entries[id];
161
+ changed = true;
162
+ }
163
+ if (installs[id] !== undefined) {
164
+ delete installs[id];
165
+ changed = true;
166
+ }
167
+ }
168
+
169
+ if (Array.isArray(currentPlugins.allow) && allow.length !== currentPlugins.allow.length) {
170
+ changed = true;
171
+ }
172
+
173
+ if (!changed) {
174
+ return false;
175
+ }
176
+
177
+ const nextConfig = {
178
+ ...config,
179
+ plugins: {
180
+ ...currentPlugins,
181
+ ...(Array.isArray(currentPlugins.allow) ? { allow } : {}),
182
+ entries,
183
+ installs,
184
+ },
185
+ };
186
+ writeFileSync(OPENCLAW_CONFIG_PATH, `${JSON.stringify(nextConfig, null, 2)}\n`, 'utf8');
187
+ return true;
188
+ }
189
+
137
190
  function ensurePluginTrusted(pluginId) {
138
191
  if (DRY_RUN) {
139
192
  return false;
@@ -1130,6 +1183,7 @@ async function runExtensionInstall(context) {
1130
1183
  }
1131
1184
 
1132
1185
  if (await commandExists('openclaw')) {
1186
+ clearPluginRegistration([extensionId, 'codewave-toolkit']);
1133
1187
  console.log(dim(` 优先使用 OpenClaw 官方插件安装流程注册 ${extensionId}...`));
1134
1188
  const installCode = await run('openclaw', ['plugins', 'install', PKG_ROOT]);
1135
1189
  if (installCode === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codewave-openclaw-installer",
3
- "version": "2.2.2",
3
+ "version": "2.2.3",
4
4
  "description": "网易智企 CodeWave OpenClaw 扩展:Skills + CLI 依赖一键安装",
5
5
  "type": "module",
6
6
  "main": "index.js",