@long_88/openclaw-aicc-channel-cli 0.1.0 → 0.1.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 (3) hide show
  1. package/README.md +3 -0
  2. package/cli.mjs +60 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -8,6 +8,9 @@ CLI installer for the `@long_88/openclaw-aicc-channel` plugin.
8
8
  npx -y @long_88/openclaw-aicc-channel-cli install
9
9
  ```
10
10
 
11
+ When the install completes, the CLI also inspects `~/.openclaw/openclaw-weixin/accounts.json`.
12
+ If exactly one Weixin account is available, it prints that `weixinFanoutAccountId`, the matching `weixinFanoutTo` from `~/.openclaw/openclaw-weixin/accounts/<id>.json`, and the full account config JSON to help with AICC bridge testing. If multiple accounts are detected, the CLI exits with an error so you can resolve the ambiguity first.
13
+
11
14
  Configure a bridge account while installing:
12
15
 
13
16
  ```bash
package/cli.mjs CHANGED
@@ -1,6 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawnSync } from "node:child_process";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import { homedir } from "node:os";
6
+ import { join } from "node:path";
4
7
 
5
8
  const CLI_SPEC = "@long_88/openclaw-aicc-channel-cli";
6
9
  const PLUGIN_SPEC = "@long_88/openclaw-aicc-channel";
@@ -185,6 +188,61 @@ function runCommand(args) {
185
188
  return result;
186
189
  }
187
190
 
191
+ function readJsonFile(filePath) {
192
+ return JSON.parse(readFileSync(filePath, "utf8"));
193
+ }
194
+
195
+ function logWeixinAccounts() {
196
+ const weixinDir = join(homedir(), ".openclaw", "openclaw-weixin");
197
+ const accountsPath = join(weixinDir, "accounts.json");
198
+
199
+ if (!existsSync(accountsPath)) {
200
+ log(`weixin accounts file was not found: ${accountsPath}`);
201
+ return;
202
+ }
203
+
204
+ let accountIds;
205
+
206
+ try {
207
+ accountIds = readJsonFile(accountsPath);
208
+ } catch (error) {
209
+ log(`failed to read weixin accounts file: ${error.message}`);
210
+ return;
211
+ }
212
+
213
+ if (!Array.isArray(accountIds) || accountIds.length === 0) {
214
+ log(`detected weixin accounts: none (${accountsPath})`);
215
+ return;
216
+ }
217
+
218
+ if (accountIds.length > 1) {
219
+ fail(`multiple weixin accounts were detected: ${accountIds.join(", ")}`);
220
+ }
221
+
222
+ const accountId = accountIds[0];
223
+ const accountPath = join(weixinDir, "accounts", `${accountId}.json`);
224
+
225
+ log(`weixinFanoutAccountId=${accountId}`);
226
+
227
+ if (!existsSync(accountPath)) {
228
+ log(`account config file was not found: ${accountPath}`);
229
+ return;
230
+ }
231
+
232
+ try {
233
+ const accountConfig = readJsonFile(accountPath);
234
+
235
+ if (accountConfig?.userId) {
236
+ log(`weixinFanoutTo=${accountConfig.userId}`);
237
+ }
238
+
239
+ log(`account config (${accountPath}):`);
240
+ console.log(JSON.stringify(accountConfig, null, 2));
241
+ } catch (error) {
242
+ log(`failed to read account config ${accountPath}: ${error.message}`);
243
+ }
244
+ }
245
+
188
246
  function install(options) {
189
247
  const commands = buildCommands(options);
190
248
 
@@ -217,6 +275,8 @@ function install(options) {
217
275
  fail(`command failed: ${formatCommand(command)}`);
218
276
  }
219
277
  }
278
+
279
+ logWeixinAccounts();
220
280
  }
221
281
 
222
282
  const command = process.argv[2];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@long_88/openclaw-aicc-channel-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI installer for the OpenClaw AICC channel plugin.",
5
5
  "license": "MIT",
6
6
  "type": "module",