@vikasitai/vikasit-code 2.0.2 → 2.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/opencode +107 -0
- package/package.json +13 -20
- package/postinstall.mjs +18 -0
package/bin/opencode
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const childProcess = require("child_process")
|
|
4
|
+
const fs = require("fs")
|
|
5
|
+
const path = require("path")
|
|
6
|
+
const os = require("os")
|
|
7
|
+
|
|
8
|
+
function run(target) {
|
|
9
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
})
|
|
12
|
+
if (result.error) {
|
|
13
|
+
console.error(result.error.message)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
process.exit(typeof result.status === "number" ? result.status : 0)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const envPath = process.env.VIKASIT_BIN_PATH
|
|
20
|
+
if (envPath) run(envPath)
|
|
21
|
+
|
|
22
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
23
|
+
const scriptDir = path.dirname(scriptPath)
|
|
24
|
+
|
|
25
|
+
const cached = path.join(scriptDir, ".vikasit")
|
|
26
|
+
if (fs.existsSync(cached)) run(cached)
|
|
27
|
+
|
|
28
|
+
const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }
|
|
29
|
+
const archMap = { x64: "x64", arm64: "arm64", arm: "arm" }
|
|
30
|
+
|
|
31
|
+
const platform = platformMap[os.platform()] || os.platform()
|
|
32
|
+
const arch = archMap[os.arch()] || os.arch()
|
|
33
|
+
const base = "vikasit-code-" + platform + "-" + arch
|
|
34
|
+
const binary = platform === "windows" ? "vikasit.exe" : "vikasit"
|
|
35
|
+
|
|
36
|
+
function supportsAvx2() {
|
|
37
|
+
if (arch !== "x64") return false
|
|
38
|
+
if (platform === "darwin") {
|
|
39
|
+
try {
|
|
40
|
+
const r = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], { encoding: "utf8", timeout: 1500 })
|
|
41
|
+
return r.status === 0 && (r.stdout || "").trim() === "1"
|
|
42
|
+
} catch { return false }
|
|
43
|
+
}
|
|
44
|
+
if (platform === "linux") {
|
|
45
|
+
try { return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8")) }
|
|
46
|
+
catch { return false }
|
|
47
|
+
}
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const names = (() => {
|
|
52
|
+
const avx2 = supportsAvx2()
|
|
53
|
+
const baseline = arch === "x64" && !avx2
|
|
54
|
+
|
|
55
|
+
if (platform === "linux") {
|
|
56
|
+
const musl = (() => {
|
|
57
|
+
try { if (fs.existsSync("/etc/alpine-release")) return true } catch {}
|
|
58
|
+
try {
|
|
59
|
+
const r = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
60
|
+
if (((r.stdout || "") + (r.stderr || "")).toLowerCase().includes("musl")) return true
|
|
61
|
+
} catch {}
|
|
62
|
+
return false
|
|
63
|
+
})()
|
|
64
|
+
|
|
65
|
+
if (musl) {
|
|
66
|
+
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
67
|
+
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
68
|
+
}
|
|
69
|
+
if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
70
|
+
return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (baseline) return [`${base}-baseline`, base]
|
|
74
|
+
return [base, `${base}-baseline`]
|
|
75
|
+
})()
|
|
76
|
+
|
|
77
|
+
function findBinary(startDir) {
|
|
78
|
+
let current = startDir
|
|
79
|
+
for (;;) {
|
|
80
|
+
const modules = path.join(current, "node_modules")
|
|
81
|
+
if (fs.existsSync(modules)) {
|
|
82
|
+
for (const name of names) {
|
|
83
|
+
// Check @vikasitai scoped package first
|
|
84
|
+
const scoped = path.join(modules, "@vikasitai", name, "bin", binary)
|
|
85
|
+
if (fs.existsSync(scoped)) return scoped
|
|
86
|
+
// Fallback to unscoped
|
|
87
|
+
const unscoped = path.join(modules, name, "bin", binary)
|
|
88
|
+
if (fs.existsSync(unscoped)) return unscoped
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const parent = path.dirname(current)
|
|
92
|
+
if (parent === current) return
|
|
93
|
+
current = parent
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const resolved = findBinary(scriptDir)
|
|
98
|
+
if (!resolved) {
|
|
99
|
+
console.error(
|
|
100
|
+
"Could not find Vikasit Code binary for your platform (" + platform + "/" + arch + ").\n" +
|
|
101
|
+
"Try: npm install -g @vikasitai/" + names[0] + "\n" +
|
|
102
|
+
"Or visit: https://vikasit.ai/code"
|
|
103
|
+
)
|
|
104
|
+
process.exit(1)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
run(resolved)
|
package/package.json
CHANGED
|
@@ -6,27 +6,20 @@
|
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
8
8
|
},
|
|
9
|
-
"version": "2.0.
|
|
9
|
+
"version": "2.0.3",
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"description": "Your AI coding partner, right in the terminal",
|
|
12
|
-
"homepage": "https://vikasit.ai/code",
|
|
13
|
-
"author": "Vikasit AI <info@vikasit.ai>",
|
|
14
|
-
"repository": {
|
|
15
|
-
"type": "git",
|
|
16
|
-
"url": "git+https://github.com/Vikasit-AI/vikasit-code.git"
|
|
17
|
-
},
|
|
18
11
|
"optionalDependencies": {
|
|
19
|
-
"@vikasitai/vikasit-code-
|
|
20
|
-
"@vikasitai/vikasit-code-
|
|
21
|
-
"@vikasitai/vikasit-code-
|
|
22
|
-
"@vikasitai/vikasit-code-linux-arm64": "
|
|
23
|
-
"@vikasitai/vikasit-code-linux-
|
|
24
|
-
"@vikasitai/vikasit-code-linux-x64": "
|
|
25
|
-
"@vikasitai/vikasit-code-
|
|
26
|
-
"@vikasitai/vikasit-code-
|
|
27
|
-
"@vikasitai/vikasit-code-
|
|
28
|
-
"@vikasitai/vikasit-code-windows-arm64": "
|
|
29
|
-
"@vikasitai/vikasit-code-windows-x64": "
|
|
30
|
-
"@vikasitai/vikasit-code-windows-x64-baseline": "
|
|
12
|
+
"@vikasitai/vikasit-code-linux-arm64": "2.0.3",
|
|
13
|
+
"@vikasitai/vikasit-code-linux-x64": "2.0.3",
|
|
14
|
+
"@vikasitai/vikasit-code-linux-x64-baseline": "2.0.3",
|
|
15
|
+
"@vikasitai/vikasit-code-linux-arm64-musl": "2.0.3",
|
|
16
|
+
"@vikasitai/vikasit-code-linux-x64-musl": "2.0.3",
|
|
17
|
+
"@vikasitai/vikasit-code-linux-x64-baseline-musl": "2.0.3",
|
|
18
|
+
"@vikasitai/vikasit-code-darwin-arm64": "2.0.3",
|
|
19
|
+
"@vikasitai/vikasit-code-darwin-x64": "2.0.3",
|
|
20
|
+
"@vikasitai/vikasit-code-darwin-x64-baseline": "2.0.3",
|
|
21
|
+
"@vikasitai/vikasit-code-windows-arm64": "2.0.3",
|
|
22
|
+
"@vikasitai/vikasit-code-windows-x64": "2.0.3",
|
|
23
|
+
"@vikasitai/vikasit-code-windows-x64-baseline": "2.0.3"
|
|
31
24
|
}
|
|
32
25
|
}
|
package/postinstall.mjs
CHANGED
|
@@ -97,8 +97,26 @@ function symlinkBinary(sourcePath, binaryName) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
// Rewrite any stale dev.vikasit.ai API URL left over from earlier dev-preview
|
|
101
|
+
// CLI builds. Idempotent and silent on failure — must never block install.
|
|
102
|
+
function migrateUserConfig() {
|
|
103
|
+
try {
|
|
104
|
+
const configPath = path.join(os.homedir(), ".config", "vikasit", "vikasit.json")
|
|
105
|
+
if (!fs.existsSync(configPath)) return
|
|
106
|
+
const raw = fs.readFileSync(configPath, "utf-8")
|
|
107
|
+
if (!raw.includes("dev.vikasit.ai")) return
|
|
108
|
+
const fixed = raw.replace(/https:\/\/dev\.vikasit\.ai/g, "https://vikasit.ai")
|
|
109
|
+
fs.writeFileSync(configPath, fixed)
|
|
110
|
+
console.log("vikasit: migrated global config dev.vikasit.ai -> vikasit.ai")
|
|
111
|
+
} catch {
|
|
112
|
+
// swallow — never let migration break install
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
100
116
|
async function main() {
|
|
101
117
|
try {
|
|
118
|
+
migrateUserConfig()
|
|
119
|
+
|
|
102
120
|
if (os.platform() === "win32") {
|
|
103
121
|
// On Windows, the .exe is already included in the package and bin field points to it
|
|
104
122
|
// No postinstall setup needed
|