@vikasitai/vikasit-code 1.0.2 → 1.0.3
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/vikasit +28 -87
- package/package.json +1 -1
package/bin/vikasit
CHANGED
|
@@ -25,7 +25,6 @@ if (envPath) {
|
|
|
25
25
|
const scriptPath = fs.realpathSync(__filename)
|
|
26
26
|
const scriptDir = path.dirname(scriptPath)
|
|
27
27
|
|
|
28
|
-
//
|
|
29
28
|
const cached = path.join(scriptDir, ".vikasit")
|
|
30
29
|
if (fs.existsSync(cached)) {
|
|
31
30
|
run(cached)
|
|
@@ -42,64 +41,22 @@ const archMap = {
|
|
|
42
41
|
arm: "arm",
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
let platform = platformMap[os.platform()]
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
let arch = archMap[os.arch()]
|
|
50
|
-
if (!arch) {
|
|
51
|
-
arch = os.arch()
|
|
52
|
-
}
|
|
53
|
-
const base = "opencode-" + platform + "-" + arch
|
|
54
|
-
const binary = platform === "windows" ? "opencode.exe" : "vikasit"
|
|
44
|
+
let platform = platformMap[os.platform()] || os.platform()
|
|
45
|
+
let arch = archMap[os.arch()] || os.arch()
|
|
46
|
+
const base = "vikasit-code-" + platform + "-" + arch
|
|
47
|
+
const binary = platform === "windows" ? "vikasit.exe" : "vikasit"
|
|
55
48
|
|
|
56
49
|
function supportsAvx2() {
|
|
57
50
|
if (arch !== "x64") return false
|
|
58
|
-
|
|
59
|
-
if (platform === "linux") {
|
|
60
|
-
try {
|
|
61
|
-
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
62
|
-
} catch {
|
|
63
|
-
return false
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
51
|
if (platform === "darwin") {
|
|
68
52
|
try {
|
|
69
|
-
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
73
|
-
if (result.status !== 0) return false
|
|
74
|
-
return (result.stdout || "").trim() === "1"
|
|
75
|
-
} catch {
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
53
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], { encoding: "utf8", timeout: 1500 })
|
|
54
|
+
return result.status === 0 && (result.stdout || "").trim() === "1"
|
|
55
|
+
} catch { return false }
|
|
78
56
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const cmd =
|
|
82
|
-
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
83
|
-
|
|
84
|
-
for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
85
|
-
try {
|
|
86
|
-
const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
|
|
87
|
-
encoding: "utf8",
|
|
88
|
-
timeout: 3000,
|
|
89
|
-
windowsHide: true,
|
|
90
|
-
})
|
|
91
|
-
if (result.status !== 0) continue
|
|
92
|
-
const out = (result.stdout || "").trim().toLowerCase()
|
|
93
|
-
if (out === "true" || out === "1") return true
|
|
94
|
-
if (out === "false" || out === "0") return false
|
|
95
|
-
} catch {
|
|
96
|
-
continue
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return false
|
|
57
|
+
if (platform === "linux") {
|
|
58
|
+
try { return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8")) } catch { return false }
|
|
101
59
|
}
|
|
102
|
-
|
|
103
60
|
return false
|
|
104
61
|
}
|
|
105
62
|
|
|
@@ -109,59 +66,43 @@ const names = (() => {
|
|
|
109
66
|
|
|
110
67
|
if (platform === "linux") {
|
|
111
68
|
const musl = (() => {
|
|
112
|
-
try {
|
|
113
|
-
if (fs.existsSync("/etc/alpine-release")) return true
|
|
114
|
-
} catch {
|
|
115
|
-
// ignore
|
|
116
|
-
}
|
|
117
|
-
|
|
69
|
+
try { if (fs.existsSync("/etc/alpine-release")) return true } catch {}
|
|
118
70
|
try {
|
|
119
71
|
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
} catch {
|
|
123
|
-
// ignore
|
|
124
|
-
}
|
|
125
|
-
|
|
72
|
+
if (((result.stdout || "") + (result.stderr || "")).toLowerCase().includes("musl")) return true
|
|
73
|
+
} catch {}
|
|
126
74
|
return false
|
|
127
75
|
})()
|
|
128
76
|
|
|
129
77
|
if (musl) {
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
133
|
-
}
|
|
134
|
-
return [`${base}-musl`, base]
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (arch === "x64") {
|
|
138
|
-
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
139
|
-
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
78
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
79
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
140
80
|
}
|
|
141
|
-
return [base, `${base}-musl`]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (arch === "x64") {
|
|
145
81
|
if (baseline) return [`${base}-baseline`, base]
|
|
146
82
|
return [base, `${base}-baseline`]
|
|
147
83
|
}
|
|
148
|
-
|
|
84
|
+
|
|
85
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
86
|
+
return [base, `${base}-baseline`]
|
|
149
87
|
})()
|
|
150
88
|
|
|
89
|
+
// Look for the binary in node_modules with @vikasitai scope
|
|
151
90
|
function findBinary(startDir) {
|
|
152
91
|
let current = startDir
|
|
153
92
|
for (;;) {
|
|
154
93
|
const modules = path.join(current, "node_modules")
|
|
155
94
|
if (fs.existsSync(modules)) {
|
|
156
95
|
for (const name of names) {
|
|
157
|
-
|
|
158
|
-
|
|
96
|
+
// Check scoped package: @vikasitai/vikasit-code-darwin-arm64
|
|
97
|
+
const scoped = path.join(modules, "@vikasitai", name, "bin", binary)
|
|
98
|
+
if (fs.existsSync(scoped)) return scoped
|
|
99
|
+
// Check unscoped fallback
|
|
100
|
+
const unscoped = path.join(modules, name, "bin", binary)
|
|
101
|
+
if (fs.existsSync(unscoped)) return unscoped
|
|
159
102
|
}
|
|
160
103
|
}
|
|
161
104
|
const parent = path.dirname(current)
|
|
162
|
-
if (parent === current)
|
|
163
|
-
return
|
|
164
|
-
}
|
|
105
|
+
if (parent === current) return
|
|
165
106
|
current = parent
|
|
166
107
|
}
|
|
167
108
|
}
|
|
@@ -169,9 +110,9 @@ function findBinary(startDir) {
|
|
|
169
110
|
const resolved = findBinary(scriptDir)
|
|
170
111
|
if (!resolved) {
|
|
171
112
|
console.error(
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
|
|
113
|
+
"Could not find the Vikasit Code binary for your platform (" + platform + "/" + arch + ").\n" +
|
|
114
|
+
"Try: npm install -g @vikasitai/" + names[0] + "\n" +
|
|
115
|
+
"Or visit: https://vikasit.ai/code for other install methods."
|
|
175
116
|
)
|
|
176
117
|
process.exit(1)
|
|
177
118
|
}
|