neurocode-ai 1.18.18 → 1.18.21

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/neurocode.cjs +7 -202
  2. package/package.json +1 -1
package/bin/neurocode.cjs CHANGED
@@ -1,202 +1,7 @@
1
- #!/usr/bin/env node
2
-
3
-
4
-
5
-
6
- const childProcess = require("child_process")
7
- const fs = require("fs")
8
- const path = require("path")
9
- const os = require("os")
10
-
11
- const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
12
-
13
- function run(target) {
14
- const child = childProcess.spawn(target, process.argv.slice(2), {
15
- stdio: "inherit",
16
- })
17
-
18
- child.on("error", (error) => {
19
- console.error(error.message)
20
- process.exit(1)
21
- })
22
-
23
- const forwarders = {}
24
- for (const signal of forwardedSignals) {
25
- forwarders[signal] = () => {
26
- try {
27
- child.kill(signal)
28
- } catch {
29
- // The child may have already exited.
30
- }
31
- }
32
- process.on(signal, forwarders[signal])
33
- }
34
-
35
- child.on("exit", (code, signal) => {
36
- for (const forwardedSignal of forwardedSignals) {
37
- process.removeListener(forwardedSignal, forwarders[forwardedSignal])
38
- }
39
-
40
- if (signal) {
41
- process.kill(process.pid, signal)
42
- return
43
- }
44
-
45
- process.exit(typeof code === "number" ? code : 0)
46
- })
47
- }
48
-
49
- const envPath = process.env.NEUROCODE_BIN_PATH
50
-
51
- const scriptPath = fs.realpathSync(__filename)
52
- const scriptDir = path.dirname(scriptPath)
53
-
54
- //
55
- const cached = path.join(scriptDir, ".neurocode")
56
-
57
- const platformMap = {
58
- darwin: "darwin",
59
- linux: "linux",
60
- win32: "windows",
61
- }
62
- const archMap = {
63
- x64: "x64",
64
- arm64: "arm64",
65
- arm: "arm",
66
- }
67
-
68
- let platform = platformMap[os.platform()]
69
- if (!platform) {
70
- platform = os.platform()
71
- }
72
- let arch = archMap[os.arch()]
73
- if (!arch) {
74
- arch = os.arch()
75
- }
76
- const base = "neurocode-" + platform + "-" + arch
77
- const binary = platform === "windows" ? "neurocode.exe" : "neurocode"
78
-
79
- function supportsAvx2() {
80
- if (arch !== "x64") return false
81
-
82
- if (platform === "linux") {
83
- try {
84
- return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
85
- } catch {
86
- return false
87
- }
88
- }
89
-
90
- if (platform === "darwin") {
91
- try {
92
- const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
93
- encoding: "utf8",
94
- timeout: 1500,
95
- })
96
- if (result.status !== 0) return false
97
- return (result.stdout || "").trim() === "1"
98
- } catch {
99
- return false
100
- }
101
- }
102
-
103
- if (platform === "windows") {
104
- const cmd =
105
- '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
106
-
107
- for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
108
- try {
109
- const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
110
- encoding: "utf8",
111
- timeout: 3000,
112
- windowsHide: true,
113
- })
114
- if (result.status !== 0) continue
115
- const out = (result.stdout || "").trim().toLowerCase()
116
- if (out === "true" || out === "1") return true
117
- if (out === "false" || out === "0") return false
118
- } catch {
119
- continue
120
- }
121
- }
122
-
123
- return false
124
- }
125
-
126
- return false
127
- }
128
-
129
- const names = (() => {
130
- const avx2 = supportsAvx2()
131
- const baseline = arch === "x64" && !avx2
132
-
133
- if (platform === "linux") {
134
- const musl = (() => {
135
- try {
136
- if (fs.existsSync("/etc/alpine-release")) return true
137
- } catch {
138
- // ignore
139
- }
140
-
141
- try {
142
- const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
143
- const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
144
- if (text.includes("musl")) return true
145
- } catch {
146
- // ignore
147
- }
148
-
149
- return false
150
- })()
151
-
152
- if (musl) {
153
- if (arch === "x64") {
154
- if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
155
- return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
156
- }
157
- return [`${base}-musl`, base]
158
- }
159
-
160
- if (arch === "x64") {
161
- if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
162
- return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
163
- }
164
- return [base, `${base}-musl`]
165
- }
166
-
167
- if (arch === "x64") {
168
- if (baseline) return [`${base}-baseline`, base]
169
- return [base, `${base}-baseline`]
170
- }
171
- return [base]
172
- })()
173
-
174
- function findBinary(startDir) {
175
- let current = startDir
176
- for (;;) {
177
- const modules = path.join(current, "node_modules")
178
- if (fs.existsSync(modules)) {
179
- for (const name of names) {
180
- const candidate = path.join(modules, name, "bin", binary)
181
- if (fs.existsSync(candidate)) return candidate
182
- }
183
- }
184
- const parent = path.dirname(current)
185
- if (parent === current) {
186
- return
187
- }
188
- current = parent
189
- }
190
- }
191
-
192
- const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
193
- if (!resolved) {
194
- console.error(
195
- "It seems that your package manager failed to install the right version of the neurocode CLI for your platform. You can try manually installing " +
196
- names.map((n) => `\"${n}\"`).join(" or ") +
197
- " package",
198
- )
199
- process.exit(1)
200
- }
201
-
202
- run(resolved)
1
+ #!/usr/bin/env node
2
+ const { spawnSync } = require("child_process")
3
+ const result = spawnSync("bun", ["run", "--cwd", __dirname + "/..", "--conditions=browser", "./src/index.ts", ...process.argv.slice(2)], {
4
+ stdio: "inherit",
5
+ env: { ...process.env, BUN_BE_BUN: "1" },
6
+ })
7
+ process.exit(result.status ?? 1)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
- "version": "1.18.18",
3
+ "version": "1.18.21",
4
4
  "name": "neurocode-ai",
5
5
  "type": "module",
6
6
  "license": "MIT",