@qitqode/cli 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.
package/bin/qitqode ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import { spawnSync } from "node:child_process"
4
+ import { existsSync, realpathSync } from "node:fs"
5
+ import os from "node:os"
6
+ import path from "node:path"
7
+ import { fileURLToPath } from "node:url"
8
+
9
+ function run(target) {
10
+ const result = spawnSync(target, process.argv.slice(2), {
11
+ stdio: "inherit",
12
+ })
13
+ if (result.error) {
14
+ console.error(result.error.message)
15
+ process.exit(1)
16
+ }
17
+ if (result.signal) {
18
+ const number = os.constants.signals[result.signal]
19
+ process.exit(typeof number === "number" ? 128 + number : 1)
20
+ }
21
+ process.exit(typeof result.status === "number" ? result.status : 1)
22
+ }
23
+
24
+ const envPath = process.env.QITQODE_BIN_PATH
25
+ if (envPath) {
26
+ run(envPath)
27
+ }
28
+
29
+ const scriptPath = realpathSync(fileURLToPath(import.meta.url))
30
+ const scriptDir = path.dirname(scriptPath)
31
+
32
+ //
33
+ const cached = path.join(scriptDir, ".qitqode")
34
+ if (existsSync(cached)) {
35
+ run(cached)
36
+ }
37
+
38
+ const platformMap = {
39
+ darwin: "darwin",
40
+ linux: "linux",
41
+ win32: "windows",
42
+ }
43
+ const archMap = {
44
+ x64: "x64",
45
+ arm64: "arm64",
46
+ arm: "arm",
47
+ }
48
+
49
+ let platform = platformMap[os.platform()]
50
+ if (!platform) {
51
+ platform = os.platform()
52
+ }
53
+ let arch = archMap[os.arch()]
54
+ if (!arch) {
55
+ arch = os.arch()
56
+ }
57
+ const scope = "@qitqode/"
58
+ const base = scope + "qitqode-" + platform + "-" + arch
59
+ const binary = platform === "windows" ? "qitqode.exe" : "qitqode"
60
+
61
+ const names = (() => {
62
+ if (platform === "linux") {
63
+ const musl = (() => {
64
+ try {
65
+ if (existsSync("/etc/alpine-release")) return true
66
+ } catch {
67
+ // ignore
68
+ }
69
+
70
+ try {
71
+ const result = spawnSync("ldd", ["--version"], { encoding: "utf8" })
72
+ const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
73
+ if (text.includes("musl")) return true
74
+ } catch {
75
+ // ignore
76
+ }
77
+
78
+ return false
79
+ })()
80
+
81
+ if (musl) {
82
+ if (arch === "x64") {
83
+ return [base + "-baseline-musl"]
84
+ }
85
+ return [base + "-musl"]
86
+ }
87
+
88
+ if (arch === "x64") {
89
+ return [base + "-baseline"]
90
+ }
91
+ return [base]
92
+ }
93
+
94
+ if (arch === "x64") {
95
+ return [`${base}-baseline`, base]
96
+ }
97
+ return [base]
98
+ })()
99
+
100
+ function findBinary(startDir) {
101
+ let current = startDir
102
+ for (;;) {
103
+ const modules = path.join(current, "node_modules")
104
+ if (existsSync(modules)) {
105
+ for (const name of names) {
106
+ const candidate = path.join(modules, name, "bin", binary)
107
+ if (existsSync(candidate)) return candidate
108
+ }
109
+ }
110
+ const parent = path.dirname(current)
111
+ if (parent === current) {
112
+ return
113
+ }
114
+ current = parent
115
+ }
116
+ }
117
+
118
+ const resolved = findBinary(scriptDir)
119
+ if (!resolved) {
120
+ const musl = platform === "linux" && names.some((name) => name.endsWith("-musl"))
121
+ console.error(
122
+ musl
123
+ ? "The musl Linux binary is not installed. Install @qitqode/cli-musl and ensure Alpine has libstdc++ and libgcc."
124
+ : "Your package manager did not install the QitQode binary for this platform. Reinstall @qitqode/cli or install " +
125
+ names.map((name) => '"' + name + '"').join(" or ") +
126
+ " directly.",
127
+ )
128
+ process.exit(1)
129
+ }
130
+
131
+ run(resolved)
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@qitqode/cli",
3
+ "version": "0.1.1",
4
+ "description": "Terminal-native AI coding agent.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "QitQode",
8
+ "homepage": "https://qitqode.com",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/qitqode/qitqode.git"
12
+ },
13
+ "keywords": [
14
+ "ai",
15
+ "coding",
16
+ "agent",
17
+ "cli",
18
+ "tui"
19
+ ],
20
+ "engines": {
21
+ "bun": ">=1.3.11"
22
+ },
23
+ "bin": {
24
+ "qitqode": "bin/qitqode"
25
+ },
26
+ "files": [
27
+ "bin",
28
+ "README.md",
29
+ "README.zh.md",
30
+ "README.zht.md",
31
+ "README.ja.md",
32
+ "README.fr.md",
33
+ "README.ru.md",
34
+ "README.es.md",
35
+ "README.pt.md",
36
+ "LICENSE",
37
+ "THIRD_PARTY_NOTICES"
38
+ ],
39
+ "optionalDependencies": {
40
+ "@qitqode/qitqode-linux-arm64": "0.1.1",
41
+ "@qitqode/qitqode-linux-x64-baseline": "0.1.1",
42
+ "@qitqode/qitqode-darwin-arm64": "0.1.1",
43
+ "@qitqode/qitqode-darwin-x64-baseline": "0.1.1",
44
+ "@qitqode/qitqode-windows-arm64": "0.1.1",
45
+ "@qitqode/qitqode-windows-x64-baseline": "0.1.1"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }