@genspark/gencode 1.18.27-gencode.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 opencode
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # GenCode
2
+
3
+ GenCode is Genspark's coding agent for the terminal, built on [opencode](https://github.com/anomalyco/opencode) (MIT).
4
+
5
+ ```sh
6
+ npm install -g @genspark/gencode
7
+ gencode # start the TUI in the current project
8
+ gencode auth login # sign in to Genspark
9
+ ```
10
+
11
+ GenCode keeps its own config, data and cache directories (`~/.config/gencode`, `~/.local/share/gencode`, …), so it coexists with an existing opencode install.
12
+
13
+ Issues: https://github.com/wework5119/opencode/issues
@@ -0,0 +1,10 @@
1
+ echo "Error: @genspark/gencode's postinstall script was not run." >&2
2
+ echo "" >&2
3
+ echo "This occurs when using --ignore-scripts during installation, or when using a" >&2
4
+ echo "package manager like pnpm that does not run postinstall scripts by default." >&2
5
+ echo "" >&2
6
+ echo "To fix this, run the postinstall script manually:" >&2
7
+ echo " cd node_modules/@genspark/gencode && node postinstall.mjs" >&2
8
+ echo "" >&2
9
+ echo "Or reinstall @genspark/gencode without the --ignore-scripts flag." >&2
10
+ exit 1
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@genspark/gencode",
3
+ "description": "GenCode — Genspark's coding agent for the terminal",
4
+ "bin": {
5
+ "gencode": "./bin/gencode.exe"
6
+ },
7
+ "scripts": {
8
+ "postinstall": "node ./postinstall.mjs"
9
+ },
10
+ "version": "1.18.27-gencode.1",
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/wework5119/opencode.git"
15
+ },
16
+ "homepage": "https://github.com/wework5119/opencode/releases",
17
+ "bugs": {
18
+ "url": "https://github.com/wework5119/opencode/issues"
19
+ },
20
+ "os": [
21
+ "darwin",
22
+ "linux",
23
+ "win32"
24
+ ],
25
+ "cpu": [
26
+ "arm64",
27
+ "x64"
28
+ ],
29
+ "optionalDependencies": {
30
+ "@genspark/gencode-linux-x64-baseline": "1.18.27-gencode.1",
31
+ "@genspark/gencode-linux-x64-musl": "1.18.27-gencode.1",
32
+ "@genspark/gencode-linux-arm64-musl": "1.18.27-gencode.1",
33
+ "@genspark/gencode-darwin-x64": "1.18.27-gencode.1",
34
+ "@genspark/gencode-linux-x64": "1.18.27-gencode.1",
35
+ "@genspark/gencode-windows-x64": "1.18.27-gencode.1",
36
+ "@genspark/gencode-linux-x64-baseline-musl": "1.18.27-gencode.1",
37
+ "@genspark/gencode-darwin-x64-baseline": "1.18.27-gencode.1",
38
+ "@genspark/gencode-windows-arm64": "1.18.27-gencode.1",
39
+ "@genspark/gencode-linux-arm64": "1.18.27-gencode.1",
40
+ "@genspark/gencode-windows-x64-baseline": "1.18.27-gencode.1",
41
+ "@genspark/gencode-darwin-arm64": "1.18.27-gencode.1"
42
+ }
43
+ }
@@ -0,0 +1,193 @@
1
+ #!/usr/bin/env node
2
+
3
+ import childProcess from "child_process"
4
+ import fs from "fs"
5
+ import os from "os"
6
+ import path from "path"
7
+ import { createRequire } from "module"
8
+ import { fileURLToPath } from "url"
9
+
10
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
11
+ const require = createRequire(import.meta.url)
12
+ const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8"))
13
+
14
+ const platformMap = {
15
+ darwin: "darwin",
16
+ linux: "linux",
17
+ win32: "windows",
18
+ }
19
+ const archMap = {
20
+ x64: "x64",
21
+ arm64: "arm64",
22
+ arm: "arm",
23
+ }
24
+
25
+ const platform = platformMap[os.platform()] ?? os.platform()
26
+ const arch = archMap[os.arch()] ?? os.arch()
27
+ // Genspark fork: the wrapper is `@genspark/gencode` with bin `gencode`; the
28
+ // platform packages are `<wrapper name>-<platform>-<arch>[-baseline][-musl]`.
29
+ // Read both from this package.json instead of hardcoding upstream's names.
30
+ const cli = Object.keys(packageJson.bin ?? {})[0] ?? "gencode"
31
+ const base = `${packageJson.name}-${platform}-${arch}`
32
+ const sourceBinary = platform === "windows" ? `${cli}.exe` : cli
33
+ const targetBinary = path.join(__dirname, "bin", `${cli}.exe`)
34
+
35
+ function supportsAvx2() {
36
+ if (arch !== "x64") return false
37
+
38
+ if (platform === "linux") {
39
+ try {
40
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
41
+ } catch {
42
+ return false
43
+ }
44
+ }
45
+
46
+ if (platform === "darwin") {
47
+ try {
48
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
49
+ encoding: "utf8",
50
+ timeout: 1500,
51
+ })
52
+ if (result.status !== 0) return false
53
+ return (result.stdout || "").trim() === "1"
54
+ } catch {
55
+ return false
56
+ }
57
+ }
58
+
59
+ if (platform === "windows") {
60
+ const command =
61
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
62
+
63
+ for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
64
+ try {
65
+ const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
66
+ encoding: "utf8",
67
+ timeout: 3000,
68
+ windowsHide: true,
69
+ })
70
+ if (result.status !== 0) continue
71
+ const output = (result.stdout || "").trim().toLowerCase()
72
+ if (output === "true" || output === "1") return true
73
+ if (output === "false" || output === "0") return false
74
+ } catch {
75
+ continue
76
+ }
77
+ }
78
+ }
79
+
80
+ return false
81
+ }
82
+
83
+ function isMusl() {
84
+ if (platform !== "linux") return false
85
+
86
+ try {
87
+ if (fs.existsSync("/etc/alpine-release")) return true
88
+ } catch {
89
+ // Ignore filesystem probes that are blocked by the host.
90
+ }
91
+
92
+ try {
93
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
94
+ return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
95
+ } catch {
96
+ return false
97
+ }
98
+ }
99
+
100
+ function packageNames() {
101
+ const baseline = arch === "x64" && !supportsAvx2()
102
+
103
+ if (platform === "linux") {
104
+ if (isMusl()) {
105
+ if (arch === "x64")
106
+ return baseline
107
+ ? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
108
+ : [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
109
+ return [`${base}-musl`, base]
110
+ }
111
+
112
+ if (arch === "x64")
113
+ return baseline
114
+ ? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
115
+ : [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
116
+ return [base, `${base}-musl`]
117
+ }
118
+
119
+ if (arch === "x64") return baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]
120
+ return [base]
121
+ }
122
+
123
+ function resolveBinary(name) {
124
+ const packageJsonPath = require.resolve(`${name}/package.json`)
125
+ const binaryPath = path.join(path.dirname(packageJsonPath), "bin", sourceBinary)
126
+ if (!fs.existsSync(binaryPath)) throw new Error(`Binary not found at ${binaryPath}`)
127
+ return binaryPath
128
+ }
129
+
130
+ function installPackage(name) {
131
+ const version = packageJson.optionalDependencies?.[name]
132
+ if (!version) return
133
+
134
+ const temp = fs.mkdtempSync(path.join(os.tmpdir(), `${cli}-install-`))
135
+ try {
136
+ const result = childProcess.spawnSync(
137
+ "npm",
138
+ ["install", "--ignore-scripts", "--no-save", "--loglevel=error", "--prefix", temp, `${name}@${version}`],
139
+ { stdio: "inherit", windowsHide: true },
140
+ )
141
+ if (result.status !== 0) return
142
+ const packageDir = path.join(temp, "node_modules", name)
143
+ copyBinary(path.join(packageDir, "bin", sourceBinary), targetBinary)
144
+ return true
145
+ } finally {
146
+ fs.rmSync(temp, { recursive: true, force: true })
147
+ }
148
+ }
149
+
150
+ function copyBinary(source, target) {
151
+ if (!fs.existsSync(source)) throw new Error(`Binary not found at ${source}`)
152
+ fs.mkdirSync(path.dirname(target), { recursive: true })
153
+ if (fs.existsSync(target)) fs.unlinkSync(target)
154
+ try {
155
+ fs.linkSync(source, target)
156
+ } catch {
157
+ fs.copyFileSync(source, target)
158
+ }
159
+ fs.chmodSync(target, 0o755)
160
+ }
161
+
162
+ function verifyBinary() {
163
+ const result = childProcess.spawnSync(targetBinary, ["--version"], {
164
+ encoding: "utf8",
165
+ stdio: "ignore",
166
+ windowsHide: true,
167
+ })
168
+ return result.status === 0
169
+ }
170
+
171
+ function main() {
172
+ for (const name of packageNames()) {
173
+ try {
174
+ copyBinary(resolveBinary(name), targetBinary)
175
+ if (verifyBinary()) return
176
+ } catch {
177
+ if (installPackage(name) && verifyBinary()) return
178
+ }
179
+ }
180
+
181
+ throw new Error(
182
+ `It seems your package manager failed to install the right ${cli} CLI package. Try manually installing ${packageNames()
183
+ .map((name) => JSON.stringify(name))
184
+ .join(" or ")}.`,
185
+ )
186
+ }
187
+
188
+ try {
189
+ main()
190
+ } catch (error) {
191
+ console.error(error.message)
192
+ process.exit(1)
193
+ }