@joyihub/cli 0.0.0-stage → 0.2.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 (3) hide show
  1. package/README.md +39 -2
  2. package/bin/joyihub.js +127 -0
  3. package/package.json +34 -4
package/README.md CHANGED
@@ -1,3 +1,40 @@
1
- # Temporary Holding Version
1
+ # @joyihub/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [有亦工坊 JoYiHub](https://joyihub.thebinwang.com/) 创作者套件官方 NPM 分发包。
4
+
5
+ ## 快速使用
6
+
7
+ 无需繁琐配置,智能体或创作者可在终端一键运行:
8
+
9
+ ```bash
10
+ npx @joyihub/cli agent install
11
+ ```
12
+
13
+ 该命令将:
14
+ 1. 自动根据当前操作系统下载匹配的高性能静态二进制;
15
+ 2. 为你的 AI 编码智能体(Cursor、Claude Code、Windsurf、OpenCode、Codex 等)安装并注册三大官方 Skill:
16
+ - [joyihub-project-prepare](https://github.com/BingoWon/joyihub/tree/main/cli/skills/joyihub-project-prepare): 作品接入要求与可选外部资源推荐,不分发第三方技能内容
17
+ - `joyihub-capabilities`: 平台能力与横竖屏适配
18
+ - `joyihub-publish`: 自动化打包、预览与发布
19
+
20
+ ## 全局安装
21
+
22
+ ```bash
23
+ npm install -g @joyihub/cli
24
+ ```
25
+
26
+ 安装后即可直接使用 `joyihub` 命令:
27
+
28
+ ```bash
29
+ joyihub --version
30
+ joyihub capabilities
31
+ joyihub agent doctor
32
+ ```
33
+
34
+ ## 支持平台
35
+
36
+ - macOS (Apple Silicon arm64)
37
+ - macOS (Intel x64)
38
+ - Linux (x64)
39
+ - Linux (arm64)
40
+ - Windows (x64)
package/bin/joyihub.js ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from "node:child_process";
4
+ import fs from "node:fs";
5
+ import path from "node:path";
6
+ import process from "node:process";
7
+ import { fileURLToPath } from "node:url";
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+
11
+ export function resolveBinary() {
12
+ if (process.env.JOYIHUB_BINARY_PATH && fs.existsSync(process.env.JOYIHUB_BINARY_PATH)) {
13
+ return process.env.JOYIHUB_BINARY_PATH;
14
+ }
15
+
16
+ const platform = process.platform;
17
+ const arch = process.arch;
18
+ const isWindows = platform === "win32";
19
+ const binaryName = isWindows ? "joyihub.exe" : "joyihub";
20
+
21
+ const platformKey = `${platform}-${arch}`;
22
+ const validPlatforms = [
23
+ "darwin-arm64",
24
+ "darwin-x64",
25
+ "linux-x64",
26
+ "linux-arm64",
27
+ "win32-x64",
28
+ ];
29
+
30
+ if (!validPlatforms.includes(platformKey)) {
31
+ console.error(
32
+ `[joyihub] Unsupported platform/architecture: ${platformKey}. Supported: ${validPlatforms.join(", ")}`,
33
+ );
34
+ process.exit(1);
35
+ }
36
+
37
+ const subpackageName = `@joyihub/cli-${platformKey}`;
38
+
39
+ // Candidate search paths:
40
+ const candidatePaths = [
41
+ // 1. Sibling inside same scope (node_modules/@joyihub/cli-darwin-arm64/bin/joyihub or dist/packages/@joyihub/...)
42
+ path.join(__dirname, "..", "..", `cli-${platformKey}`, "bin", binaryName),
43
+ // 2. Relative node_modules inside current package
44
+ path.join(__dirname, "..", "node_modules", subpackageName, "bin", binaryName),
45
+ // 3. Root node_modules (pnpm/flat layout)
46
+ path.join(__dirname, "..", "..", "..", subpackageName, "bin", binaryName),
47
+ // 4. Dist directory layout during local development
48
+ path.join(__dirname, "..", "dist", "packages", subpackageName, "bin", binaryName),
49
+ // 5. Direct fallback alongside runner
50
+ path.join(__dirname, binaryName),
51
+ ];
52
+
53
+ for (const candidate of candidatePaths) {
54
+ try {
55
+ if (fs.existsSync(candidate)) {
56
+ return candidate;
57
+ }
58
+ } catch {
59
+ // ignore stat errors
60
+ }
61
+ }
62
+
63
+ // Try resolving using import.meta.resolve
64
+ try {
65
+ const resolvedPackageJson = import.meta.resolve(`${subpackageName}/package.json`);
66
+ const packageDir = path.dirname(fileURLToPath(resolvedPackageJson));
67
+ const resolvedBin = path.join(packageDir, "bin", binaryName);
68
+ if (fs.existsSync(resolvedBin)) {
69
+ return resolvedBin;
70
+ }
71
+ } catch {
72
+ // package not found
73
+ }
74
+
75
+ console.error(
76
+ `[joyihub] Could not find executable binary for ${subpackageName}.\n` +
77
+ `Please make sure the optional dependency "${subpackageName}" was installed successfully.\n` +
78
+ `You can try reinstalling via: npm install -g @joyihub/cli`,
79
+ );
80
+ process.exit(1);
81
+ }
82
+
83
+ export function runJoYiHub(args = process.argv.slice(2)) {
84
+ const binaryPath = resolveBinary();
85
+
86
+ const child = spawn(binaryPath, args, {
87
+ stdio: "inherit",
88
+ env: process.env,
89
+ });
90
+
91
+ const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
92
+ for (const signal of signals) {
93
+ process.on(signal, () => {
94
+ if (!child.killed) {
95
+ child.kill(signal);
96
+ }
97
+ });
98
+ }
99
+
100
+ child.on("exit", (code, signal) => {
101
+ if (signal) {
102
+ process.kill(process.pid, signal);
103
+ } else {
104
+ process.exit(code ?? 0);
105
+ }
106
+ });
107
+
108
+ child.on("error", (error) => {
109
+ console.error(`[joyihub] Failed to launch ${binaryPath}:`, error.message);
110
+ process.exit(1);
111
+ });
112
+ }
113
+
114
+ // If executed directly as a script (support symlinks such as .bin/joyihub)
115
+ function isMain() {
116
+ if (!process.argv[1]) return false;
117
+ try {
118
+ return fs.realpathSync(process.argv[1]) === fs.realpathSync(fileURLToPath(import.meta.url));
119
+ } catch {
120
+ return path.resolve(process.argv[1]) === fileURLToPath(import.meta.url);
121
+ }
122
+ }
123
+
124
+ if (isMain()) {
125
+ runJoYiHub();
126
+ }
127
+
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@joyihub/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "JoYiHub Creator CLI & Agent Skills - Official Distribution",
5
+ "type": "module",
6
+ "bin": {
7
+ "joyihub": "bin/joyihub.js"
8
+ },
9
+ "main": "bin/joyihub.js",
10
+ "files": [
11
+ "bin",
12
+ "README.md"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/BingoWon/joyihub.git",
17
+ "directory": "cli/npm"
18
+ },
19
+ "keywords": [
20
+ "joyihub",
21
+ "game-development",
22
+ "ai-agent",
23
+ "cli"
24
+ ],
25
+ "license": "MIT",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "optionalDependencies": {
30
+ "@joyihub/cli-darwin-arm64": "0.2.0",
31
+ "@joyihub/cli-darwin-x64": "0.2.0",
32
+ "@joyihub/cli-linux-x64": "0.2.0",
33
+ "@joyihub/cli-linux-arm64": "0.2.0",
34
+ "@joyihub/cli-win32-x64": "0.2.0"
35
+ }
36
+ }