@zhizhi-ai/cli 0.1.0

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/zhizhi.js +45 -0
  2. package/package.json +20 -0
package/bin/zhizhi.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from "node:child_process";
3
+ import { createRequire } from "node:module";
4
+
5
+ const require = createRequire(import.meta.url);
6
+
7
+ const targets = {
8
+ "darwin-arm64": "@zhizhi-ai/cli-darwin-arm64",
9
+ "linux-x64": "@zhizhi-ai/cli-linux-x64"
10
+ };
11
+
12
+ const targetKey = `${process.platform}-${process.arch}`;
13
+ const packageName = targets[targetKey];
14
+
15
+ if (!packageName) {
16
+ console.error(
17
+ `Unsupported platform: ${targetKey}. Supported platforms: ${Object.keys(targets).join(", ")}.`
18
+ );
19
+ process.exit(1);
20
+ }
21
+
22
+ let binaryPath;
23
+ try {
24
+ binaryPath = require.resolve(`${packageName}/bin/zhizhi`);
25
+ } catch {
26
+ console.error(
27
+ `Missing platform package ${packageName}. Reinstall @zhizhi/cli on this machine and try again.`
28
+ );
29
+ process.exit(1);
30
+ }
31
+
32
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
33
+ stdio: "inherit"
34
+ });
35
+
36
+ if (result.error) {
37
+ console.error(result.error.message);
38
+ process.exit(1);
39
+ }
40
+
41
+ if (result.signal) {
42
+ process.kill(process.pid, result.signal);
43
+ }
44
+
45
+ process.exit(result.status ?? 1);
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@zhizhi-ai/cli",
3
+ "version": "0.1.0",
4
+ "description": "Zhizhi command line client",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "bin": {
8
+ "zhizhi": "bin/zhizhi.js"
9
+ },
10
+ "files": [
11
+ "bin/zhizhi.js"
12
+ ],
13
+ "optionalDependencies": {
14
+ "@zhizhi-ai/cli-darwin-arm64": "0.1.0",
15
+ "@zhizhi-ai/cli-linux-x64": "0.1.0"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ }
20
+ }