@judydq/wx-cli 0.1.10

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/bin/wx.js +53 -0
  2. package/install.js +31 -0
  3. package/package.json +30 -0
package/bin/wx.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { execFileSync } = require('child_process');
5
+ const path = require('path');
6
+ const fs = require('fs');
7
+
8
+ const PLATFORM_PACKAGES = {
9
+ 'darwin-arm64': '@judydq/wx-cli-darwin-arm64',
10
+ 'darwin-x64': '@judydq/wx-cli-darwin-x64',
11
+ 'linux-x64': '@judydq/wx-cli-linux-x64',
12
+ 'linux-arm64': '@judydq/wx-cli-linux-arm64',
13
+ 'win32-x64': '@judydq/wx-cli-win32-x64',
14
+ };
15
+
16
+ const platformKey = `${process.platform}-${process.arch}`;
17
+ const ext = process.platform === 'win32' ? '.exe' : '';
18
+
19
+ function getBinaryPath() {
20
+ if (process.env.WX_CLI_BINARY) {
21
+ return process.env.WX_CLI_BINARY;
22
+ }
23
+
24
+ const pkg = PLATFORM_PACKAGES[platformKey];
25
+ if (!pkg) {
26
+ console.error(`wx-cli: unsupported platform ${platformKey}`);
27
+ process.exit(1);
28
+ }
29
+
30
+ try {
31
+ return require.resolve(`${pkg}/bin/wx${ext}`);
32
+ } catch {
33
+ const modPath = path.join(
34
+ path.dirname(require.resolve(`${pkg}/package.json`)),
35
+ `bin/wx${ext}`
36
+ );
37
+ if (fs.existsSync(modPath)) return modPath;
38
+ }
39
+
40
+ console.error(`wx-cli: binary not found for ${platformKey}`);
41
+ console.error('Try: npm install -g @judydq/wx-cli');
42
+ process.exit(1);
43
+ }
44
+
45
+ try {
46
+ execFileSync(getBinaryPath(), process.argv.slice(2), {
47
+ stdio: 'inherit',
48
+ env: { ...process.env },
49
+ });
50
+ } catch (e) {
51
+ if (e && e.status != null) process.exit(e.status);
52
+ throw e;
53
+ }
package/install.js ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+
6
+ const PLATFORM_PACKAGES = {
7
+ 'darwin-arm64': '@judydq/wx-cli-darwin-arm64',
8
+ 'darwin-x64': '@judydq/wx-cli-darwin-x64',
9
+ 'linux-x64': '@judydq/wx-cli-linux-x64',
10
+ 'linux-arm64': '@judydq/wx-cli-linux-arm64',
11
+ 'win32-x64': '@judydq/wx-cli-win32-x64',
12
+ };
13
+
14
+ const platformKey = `${process.platform}-${process.arch}`;
15
+ const pkg = PLATFORM_PACKAGES[platformKey];
16
+
17
+ if (!pkg) {
18
+ console.log(`wx-cli: no binary for ${platformKey}, skipping`);
19
+ process.exit(0);
20
+ }
21
+
22
+ const ext = process.platform === 'win32' ? '.exe' : '';
23
+
24
+ try {
25
+ const binaryPath = require.resolve(`${pkg}/bin/wx${ext}`);
26
+ if (process.platform !== 'win32') {
27
+ fs.chmodSync(binaryPath, 0o755);
28
+ }
29
+ } catch {
30
+ console.log(`wx-cli: platform package ${pkg} not installed`);
31
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@judydq/wx-cli",
3
+ "version": "0.1.10",
4
+ "description": "Query your local WeChat data from the command line. Designed for LLM agent tool calls.",
5
+ "bin": {
6
+ "wx": "bin/wx.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "files": [
12
+ "bin/",
13
+ "install.js"
14
+ ],
15
+ "optionalDependencies": {
16
+ "@judydq/wx-cli-darwin-arm64": "0.1.10",
17
+ "@judydq/wx-cli-darwin-x64": "0.1.10",
18
+ "@judydq/wx-cli-linux-x64": "0.1.10",
19
+ "@judydq/wx-cli-linux-arm64": "0.1.10",
20
+ "@judydq/wx-cli-win32-x64": "0.1.10"
21
+ },
22
+ "engines": { "node": ">=14" },
23
+ "keywords": ["wechat", "cli", "wx", "llm", "ai", "sqlite", "sqlcipher"],
24
+ "license": "Apache-2.0",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/judydq/wx-cli"
28
+ },
29
+ "publishConfig": { "access": "public" }
30
+ }