@hippox/codegenie 1.2.15

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.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # CodeGenie CLI
2
+
3
+ `CodeGenie` 是面向 HarmonyOS 开发场景的 AI CLI。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install -g codegenie
9
+ ```
10
+
11
+ 安装完成后直接执行:
12
+
13
+ ```bash
14
+ codegenie --version
15
+ ```
16
+
17
+ ## 平台说明
18
+
19
+ - npm 安装默认提供主流 `Windows/macOS/Linux` 二进制包
20
+ - `baseline` 兼容构建不会通过 npm 分发,老 CPU 请改用独立二进制发布件
21
+ - `upgrade` 在 npm 安装场景下会提示或委托 `npm install -g codegenie@<tag>`,不会直接覆写 npm 全局目录
22
+
23
+ ## 发布说明
24
+
25
+ 仓库中的 `packages/npm/codegenie` 为元包模板。正式发布前请先运行仓库脚本生成 `dist/npm/` 下的 publishable 包,再按发布顺序上传各平台包和元包。
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require("child_process")
4
+ const { resolveBinary } = require("../lib/resolve-binary.js")
5
+
6
+ function main() {
7
+ const resolved = resolveBinary()
8
+ const result = spawnSync(resolved.binaryPath, process.argv.slice(2), {
9
+ stdio: "inherit",
10
+ env: {
11
+ ...process.env,
12
+ CODEGENIE_INSTALL_SOURCE: "npm",
13
+ CODEGENIE_NPM_PACKAGE: resolved.packageName,
14
+ },
15
+ })
16
+
17
+ if (result.error) {
18
+ console.error(`[codegenie] Failed to start ${resolved.packageName}: ${result.error.message}`)
19
+ process.exit(1)
20
+ }
21
+
22
+ process.exit(result.status ?? 1)
23
+ }
24
+
25
+ main()
@@ -0,0 +1,76 @@
1
+ const fs = require("fs")
2
+ const path = require("path")
3
+
4
+ function loadPlatformMap() {
5
+ const platformMapPath = path.join(__dirname, "..", "platform-map.json")
6
+ return JSON.parse(fs.readFileSync(platformMapPath, "utf8"))
7
+ }
8
+
9
+ function detectLibc() {
10
+ if (process.platform !== "linux") return null
11
+ if (process.report && typeof process.report.getReport === "function") {
12
+ const report = process.report.getReport()
13
+ if (report && report.header && report.header.glibcVersionRuntime) {
14
+ return "glibc"
15
+ }
16
+ }
17
+ return "musl"
18
+ }
19
+
20
+ function resolvePackageName() {
21
+ const platformMap = loadPlatformMap()
22
+ const libc = detectLibc()
23
+
24
+ let platformKey = null
25
+ if (process.platform === "darwin" && process.arch === "arm64") platformKey = "darwin-arm64"
26
+ else if (process.platform === "darwin" && process.arch === "x64") platformKey = "darwin-x64"
27
+ else if (process.platform === "linux" && process.arch === "arm64" && libc === "musl") platformKey = "linux-arm64-musl"
28
+ else if (process.platform === "linux" && process.arch === "arm64") platformKey = "linux-arm64"
29
+ else if (process.platform === "linux" && process.arch === "x64" && libc === "musl") platformKey = "linux-x64-musl"
30
+ else if (process.platform === "linux" && process.arch === "x64") platformKey = "linux-x64"
31
+ else if (process.platform === "win32" && process.arch === "x64") platformKey = "win32-x64"
32
+
33
+ if (platformKey && platformMap[platformKey]) {
34
+ return platformMap[platformKey]
35
+ }
36
+
37
+ const libcSuffix = libc ? `/${libc}` : ""
38
+ throw new Error(`Unsupported npm platform: ${process.platform}/${process.arch}${libcSuffix}`)
39
+ }
40
+
41
+ function resolveBinary() {
42
+ const packageName = resolvePackageName()
43
+ let packageJsonPath = ""
44
+ try {
45
+ packageJsonPath = require.resolve(`${packageName}/package.json`)
46
+ } catch (error) {
47
+ const hint = [
48
+ `[codegenie] Failed to locate installed binary package for ${process.platform}/${process.arch}.`,
49
+ `[codegenie] Expected package: ${packageName}`,
50
+ "[codegenie] Reinstall with `npm install -g codegenie` or use the standalone binary for baseline / unsupported CPUs.",
51
+ ].join("\n")
52
+ const wrapped = new Error(hint)
53
+ wrapped.cause = error
54
+ throw wrapped
55
+ }
56
+
57
+ const binaryPath = path.join(
58
+ path.dirname(packageJsonPath),
59
+ "bin",
60
+ process.platform === "win32" ? "codegenie.exe" : "codegenie",
61
+ )
62
+ if (!fs.existsSync(binaryPath)) {
63
+ throw new Error(`[codegenie] Binary file missing from ${packageName}: ${binaryPath}`)
64
+ }
65
+
66
+ return {
67
+ packageName,
68
+ binaryPath,
69
+ }
70
+ }
71
+
72
+ module.exports = {
73
+ detectLibc,
74
+ resolveBinary,
75
+ resolvePackageName,
76
+ }
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@hippox/codegenie",
3
+ "version": "1.2.15",
4
+ "private": false,
5
+ "description": "HarmonyOS AI 开发 CLI,binary-first 发布并通过 npm 分发平台二进制",
6
+ "license": "MIT",
7
+ "bin": {
8
+ "codegenie": "bin/codegenie.js"
9
+ },
10
+ "files": [
11
+ "bin",
12
+ "lib",
13
+ "README.md",
14
+ "platform-map.json"
15
+ ],
16
+ "keywords": [
17
+ "cli",
18
+ "harmonyos",
19
+ "codegenie",
20
+ "ai"
21
+ ],
22
+ "optionalDependencies": {
23
+ "@hippox/codegenie-win32-x64": "1.2.15"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "https://gitcode.com/codegenie/codegenie.git"
31
+ }
32
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "win32-x64": "@hippox/codegenie-win32-x64"
3
+ }