@vikasitai/vikasit-code 0.0.0-dev-202604290739

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/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/bin/vikasit 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 ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@vikasitai/vikasit-code",
3
+ "bin": {
4
+ "vikasit": "./bin/vikasit"
5
+ },
6
+ "scripts": {
7
+ "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
8
+ },
9
+ "version": "0.0.0-dev-202604290739",
10
+ "license": "MIT",
11
+ "optionalDependencies": {
12
+ "@vikasitai/vikasit-code-linux-arm64-musl": "0.0.0-dev-202604290739",
13
+ "@vikasitai/vikasit-code-darwin-x64": "0.0.0-dev-202604290739",
14
+ "@vikasitai/vikasit-code-windows-x64-baseline": "0.0.0-dev-202604290739",
15
+ "@vikasitai/vikasit-code-windows-arm64": "0.0.0-dev-202604290739",
16
+ "@vikasitai/vikasit-code-darwin-arm64": "0.0.0-dev-202604290739",
17
+ "@vikasitai/vikasit-code-linux-x64": "0.0.0-dev-202604290739",
18
+ "@vikasitai/vikasit-code-linux-x64-baseline-musl": "0.0.0-dev-202604290739",
19
+ "@vikasitai/vikasit-code-darwin-x64-baseline": "0.0.0-dev-202604290739",
20
+ "@vikasitai/vikasit-code-linux-arm64": "0.0.0-dev-202604290739",
21
+ "@vikasitai/vikasit-code-linux-x64-musl": "0.0.0-dev-202604290739",
22
+ "@vikasitai/vikasit-code-linux-x64-baseline": "0.0.0-dev-202604290739",
23
+ "@vikasitai/vikasit-code-windows-x64": "0.0.0-dev-202604290739"
24
+ }
25
+ }
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import os from "os"
6
+ import { fileURLToPath } from "url"
7
+ import { createRequire } from "module"
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
10
+ const require = createRequire(import.meta.url)
11
+
12
+ function detectPlatformAndArch() {
13
+ // Map platform names
14
+ let platform
15
+ switch (os.platform()) {
16
+ case "darwin":
17
+ platform = "darwin"
18
+ break
19
+ case "linux":
20
+ platform = "linux"
21
+ break
22
+ case "win32":
23
+ platform = "windows"
24
+ break
25
+ default:
26
+ platform = os.platform()
27
+ break
28
+ }
29
+
30
+ // Map architecture names
31
+ let arch
32
+ switch (os.arch()) {
33
+ case "x64":
34
+ arch = "x64"
35
+ break
36
+ case "arm64":
37
+ arch = "arm64"
38
+ break
39
+ case "arm":
40
+ arch = "arm"
41
+ break
42
+ default:
43
+ arch = os.arch()
44
+ break
45
+ }
46
+
47
+ return { platform, arch }
48
+ }
49
+
50
+ function findBinary() {
51
+ const { platform, arch } = detectPlatformAndArch()
52
+ const packageName = `@vikasitai/vikasit-code-${platform}-${arch}`
53
+ const binaryName = platform === "windows" ? "vikasit.exe" : "vikasit"
54
+
55
+ try {
56
+ // Use require.resolve to find the package
57
+ const packageJsonPath = require.resolve(`${packageName}/package.json`)
58
+ const packageDir = path.dirname(packageJsonPath)
59
+ const binaryPath = path.join(packageDir, "bin", binaryName)
60
+
61
+ if (!fs.existsSync(binaryPath)) {
62
+ throw new Error(`Binary not found at ${binaryPath}`)
63
+ }
64
+
65
+ return { binaryPath, binaryName }
66
+ } catch (error) {
67
+ throw new Error(`Could not find package ${packageName}: ${error.message}`)
68
+ }
69
+ }
70
+
71
+ function prepareBinDirectory(binaryName) {
72
+ const binDir = path.join(__dirname, "bin")
73
+ const targetPath = path.join(binDir, binaryName)
74
+
75
+ // Ensure bin directory exists
76
+ if (!fs.existsSync(binDir)) {
77
+ fs.mkdirSync(binDir, { recursive: true })
78
+ }
79
+
80
+ // Remove existing binary/symlink if it exists
81
+ if (fs.existsSync(targetPath)) {
82
+ fs.unlinkSync(targetPath)
83
+ }
84
+
85
+ return { binDir, targetPath }
86
+ }
87
+
88
+ function symlinkBinary(sourcePath, binaryName) {
89
+ const { targetPath } = prepareBinDirectory(binaryName)
90
+
91
+ fs.symlinkSync(sourcePath, targetPath)
92
+ console.log(`vikasit binary symlinked: ${targetPath} -> ${sourcePath}`)
93
+
94
+ // Verify the file exists after operation
95
+ if (!fs.existsSync(targetPath)) {
96
+ throw new Error(`Failed to symlink binary to ${targetPath}`)
97
+ }
98
+ }
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
+
116
+ async function main() {
117
+ try {
118
+ migrateUserConfig()
119
+
120
+ if (os.platform() === "win32") {
121
+ // On Windows, the .exe is already included in the package and bin field points to it
122
+ // No postinstall setup needed
123
+ console.log("Windows detected: binary setup not needed (using packaged .exe)")
124
+ return
125
+ }
126
+
127
+ // On non-Windows platforms, just verify the binary package exists
128
+ // Don't replace the wrapper script - it handles binary execution
129
+ const { binaryPath } = findBinary()
130
+ const target = path.join(__dirname, "bin", ".vikasit")
131
+ if (fs.existsSync(target)) fs.unlinkSync(target)
132
+ try {
133
+ fs.linkSync(binaryPath, target)
134
+ } catch {
135
+ fs.copyFileSync(binaryPath, target)
136
+ }
137
+ fs.chmodSync(target, 0o755)
138
+ } catch (error) {
139
+ console.error("Failed to setup vikasit binary:", error.message)
140
+ process.exit(1)
141
+ }
142
+ }
143
+
144
+ try {
145
+ main()
146
+ } catch (error) {
147
+ console.error("Postinstall script error:", error.message)
148
+ process.exit(0)
149
+ }