@vikasitai/vikasit-code 1.0.2 → 1.0.4
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/README.md +5 -169
- package/bin/vikasit +25 -149
- package/package.json +11 -13
- package/vikasit +0 -179
package/README.md
CHANGED
|
@@ -1,172 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @vikasitai/vikasit-code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Your AI coding partner, right in the terminal.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Install: `npm install -g @vikasitai/vikasit-code`
|
|
6
|
+
Run: `vikasit`
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install -g @vikasitai/vikasit-code
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Or with other package managers:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# Yarn
|
|
17
|
-
yarn global add @vikasitai/vikasit-code
|
|
18
|
-
|
|
19
|
-
# pnpm
|
|
20
|
-
pnpm add -g @vikasitai/vikasit-code
|
|
21
|
-
|
|
22
|
-
# Bun
|
|
23
|
-
bun add -g @vikasitai/vikasit-code
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Quick Start
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
# Launch interactive mode
|
|
30
|
-
vikasit
|
|
31
|
-
|
|
32
|
-
# Run a single command
|
|
33
|
-
vikasit run "Fix the bug in login.tsx"
|
|
34
|
-
|
|
35
|
-
# Use a specific model
|
|
36
|
-
vikasit run -m vikasit-ai/vikasit-3-fast "Refactor this function"
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Sign In
|
|
40
|
-
|
|
41
|
-
On first launch, you'll see a welcome screen. Type `/login` to sign in:
|
|
42
|
-
|
|
43
|
-
1. Type `/login` and press Enter
|
|
44
|
-
2. A browser window opens to [vikasit.ai/signup](https://vikasit.ai/signup)
|
|
45
|
-
3. Create your account and copy your API key from the dashboard
|
|
46
|
-
4. Paste the key in the terminal and press Enter
|
|
47
|
-
5. Start coding!
|
|
48
|
-
|
|
49
|
-
**Free Preview models** are included — no payment required to get started.
|
|
50
|
-
|
|
51
|
-
## Features
|
|
52
|
-
|
|
53
|
-
- **Terminal-Native AI** — Works in your terminal, no IDE required
|
|
54
|
-
- **75+ AI Providers** — Use Vikasit models or bring your own keys (OpenAI, Anthropic, Google, etc.)
|
|
55
|
-
- **Tool Calling** — File editing, bash commands, grep, glob built-in
|
|
56
|
-
- **MCP Support** — Extend with Model Context Protocol servers
|
|
57
|
-
- **LSP Integration** — Full language server support for code intelligence
|
|
58
|
-
- **Multi-Agent** — Spawn subagents for complex tasks
|
|
59
|
-
- **Bash Security** — Built-in safety checks for destructive commands
|
|
60
|
-
- **Session Memory** — Persistent context across sessions
|
|
61
|
-
|
|
62
|
-
## Models
|
|
63
|
-
|
|
64
|
-
### Free (Preview)
|
|
65
|
-
| Model | Description |
|
|
66
|
-
|-------|-------------|
|
|
67
|
-
| Nemotron 3 Super | Free 120B model with tool calling |
|
|
68
|
-
| Qwen 3.6 Plus | Free 1M context model |
|
|
69
|
-
|
|
70
|
-
### Paid Plans
|
|
71
|
-
|
|
72
|
-
| Plan | Price | Models |
|
|
73
|
-
|------|-------|--------|
|
|
74
|
-
| **Lite** | $10/mo | Vikasit 3 Small, Flash (9B) |
|
|
75
|
-
| **Pro** | $30/mo | + Vikasit 3 Fast (397B), Coder, Vision |
|
|
76
|
-
| **Max** | $100/mo | + Vikasit 3 (235B), Thinking, Max (480B) |
|
|
77
|
-
|
|
78
|
-
Upgrade at [vikasit.ai/dashboard](https://vikasit.ai/dashboard)
|
|
79
|
-
|
|
80
|
-
## Commands
|
|
81
|
-
|
|
82
|
-
| Command | Description |
|
|
83
|
-
|---------|-------------|
|
|
84
|
-
| `/login` | Sign in to Vikasit |
|
|
85
|
-
| `/logout` | Sign out |
|
|
86
|
-
| `/connect` | Add third-party providers (OpenAI, Anthropic, etc.) |
|
|
87
|
-
| `/models` | Switch between models |
|
|
88
|
-
| `/pass` | Send an invite to try Vikasit Code |
|
|
89
|
-
| `/help` | Show all commands |
|
|
90
|
-
|
|
91
|
-
## CLI Options
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
vikasit [options] [command]
|
|
95
|
-
|
|
96
|
-
Commands:
|
|
97
|
-
vikasit Launch interactive TUI
|
|
98
|
-
vikasit run [message] Run with a prompt (non-interactive)
|
|
99
|
-
vikasit providers login Manage AI provider credentials
|
|
100
|
-
vikasit models List available models
|
|
101
|
-
vikasit stats Show token usage statistics
|
|
102
|
-
vikasit upgrade Upgrade to latest version
|
|
103
|
-
|
|
104
|
-
Options:
|
|
105
|
-
-m, --model <provider/model> Model to use (e.g., vikasit-ai/vikasit-3-fast)
|
|
106
|
-
-p, --prompt <text> Run in non-interactive mode
|
|
107
|
-
-c, --continue Continue last session
|
|
108
|
-
-s, --session <id> Resume a specific session
|
|
109
|
-
-v, --version Show version
|
|
110
|
-
-h, --help Show help
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Configuration
|
|
114
|
-
|
|
115
|
-
Configuration file: `~/.config/vikasit/vikasit.json`
|
|
116
|
-
|
|
117
|
-
```json
|
|
118
|
-
{
|
|
119
|
-
"model": "vikasit-ai/vikasit-3-fast",
|
|
120
|
-
"theme": "vikasit",
|
|
121
|
-
"provider": {
|
|
122
|
-
"vikasit-ai": {
|
|
123
|
-
"npm": "@ai-sdk/openai-compatible",
|
|
124
|
-
"options": { "baseURL": "https://api.vikasit.ai/v1" },
|
|
125
|
-
"env": ["VIKASIT_API_KEY"]
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Environment Variables
|
|
132
|
-
|
|
133
|
-
| Variable | Description |
|
|
134
|
-
|----------|-------------|
|
|
135
|
-
| `VIKASIT_API_KEY` | Your Vikasit API key (skip `/login` flow) |
|
|
136
|
-
| `OPENAI_API_KEY` | Use OpenAI models directly |
|
|
137
|
-
| `ANTHROPIC_API_KEY` | Use Anthropic Claude models directly |
|
|
138
|
-
|
|
139
|
-
## API Access
|
|
140
|
-
|
|
141
|
-
Vikasit Code uses the OpenAI-compatible API at `api.vikasit.ai`:
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
curl https://api.vikasit.ai/v1/chat/completions \
|
|
145
|
-
-H "Authorization: Bearer YOUR_API_KEY" \
|
|
146
|
-
-H "Content-Type: application/json" \
|
|
147
|
-
-d '{
|
|
148
|
-
"model": "vikasit-3-fast",
|
|
149
|
-
"messages": [{"role": "user", "content": "Hello!"}]
|
|
150
|
-
}'
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Rate Limits
|
|
154
|
-
|
|
155
|
-
| Plan | RPM | Daily Budget | Models |
|
|
156
|
-
|------|-----|-------------|--------|
|
|
157
|
-
| Free | 10 | Free models only | Preview models |
|
|
158
|
-
| Lite | 30 | $1/day | 2 models |
|
|
159
|
-
| Pro | 60 | $3/day | 6 models |
|
|
160
|
-
| Max | 120 | $10/day | All 9 models |
|
|
161
|
-
|
|
162
|
-
## Links
|
|
163
|
-
|
|
164
|
-
- **Website**: [vikasit.ai](https://vikasit.ai)
|
|
165
|
-
- **Dashboard**: [vikasit.ai/dashboard](https://vikasit.ai/dashboard)
|
|
166
|
-
- **Chat**: [chat.vikasit.ai](https://chat.vikasit.ai)
|
|
167
|
-
- **API Docs**: [vikasit.ai/api](https://vikasit.ai/api)
|
|
168
|
-
- **GitHub**: [github.com/Vikasit-AI/vikasit-code](https://github.com/Vikasit-AI/vikasit-code)
|
|
169
|
-
|
|
170
|
-
## License
|
|
171
|
-
|
|
172
|
-
MIT — [Vikasit AI](https://vikasit.ai) by Chandorkar Technologies, Pune, India
|
|
8
|
+
Docs: https://vikasit.ai/code
|
package/bin/vikasit
CHANGED
|
@@ -1,179 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
2
|
const childProcess = require("child_process")
|
|
4
3
|
const fs = require("fs")
|
|
5
4
|
const path = require("path")
|
|
6
5
|
const os = require("os")
|
|
7
|
-
|
|
8
6
|
function run(target) {
|
|
9
|
-
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (result.error) {
|
|
13
|
-
console.error(result.error.message)
|
|
14
|
-
process.exit(1)
|
|
15
|
-
}
|
|
16
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
-
process.exit(code)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const envPath = process.env.VIKASIT_BIN_PATH
|
|
21
|
-
if (envPath) {
|
|
22
|
-
run(envPath)
|
|
7
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), { stdio: "inherit" })
|
|
8
|
+
if (result.error) { console.error(result.error.message); process.exit(1) }
|
|
9
|
+
process.exit(typeof result.status === "number" ? result.status : 0)
|
|
23
10
|
}
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const scriptDir = path.dirname(scriptPath)
|
|
27
|
-
|
|
28
|
-
//
|
|
11
|
+
if (process.env.VIKASIT_BIN_PATH) run(process.env.VIKASIT_BIN_PATH)
|
|
12
|
+
const scriptDir = path.dirname(fs.realpathSync(__filename))
|
|
29
13
|
const cached = path.join(scriptDir, ".vikasit")
|
|
30
|
-
if (fs.existsSync(cached))
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
win32: "windows",
|
|
38
|
-
}
|
|
39
|
-
const archMap = {
|
|
40
|
-
x64: "x64",
|
|
41
|
-
arm64: "arm64",
|
|
42
|
-
arm: "arm",
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let platform = platformMap[os.platform()]
|
|
46
|
-
if (!platform) {
|
|
47
|
-
platform = os.platform()
|
|
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"
|
|
55
|
-
|
|
14
|
+
if (fs.existsSync(cached)) run(cached)
|
|
15
|
+
const platformMap = { darwin: "darwin", linux: "linux", win32: "windows" }
|
|
16
|
+
const archMap = { x64: "x64", arm64: "arm64", arm: "arm" }
|
|
17
|
+
const platform = platformMap[os.platform()] || os.platform()
|
|
18
|
+
const arch = archMap[os.arch()] || os.arch()
|
|
19
|
+
const base = "vikasit-code-" + platform + "-" + arch
|
|
20
|
+
const binary = platform === "windows" ? "vikasit.exe" : "vikasit"
|
|
56
21
|
function supportsAvx2() {
|
|
57
22
|
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
|
-
if (platform === "darwin") {
|
|
68
|
-
try {
|
|
69
|
-
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
70
|
-
encoding: "utf8",
|
|
71
|
-
timeout: 1500,
|
|
72
|
-
})
|
|
73
|
-
if (result.status !== 0) return false
|
|
74
|
-
return (result.stdout || "").trim() === "1"
|
|
75
|
-
} catch {
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (platform === "windows") {
|
|
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
|
|
101
|
-
}
|
|
102
|
-
|
|
23
|
+
if (platform === "darwin") { try { const r = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], { encoding: "utf8", timeout: 1500 }); return r.status === 0 && (r.stdout||"").trim() === "1" } catch { return false } }
|
|
24
|
+
if (platform === "linux") { try { return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8")) } catch { return false } }
|
|
103
25
|
return false
|
|
104
26
|
}
|
|
105
|
-
|
|
106
27
|
const names = (() => {
|
|
107
|
-
const
|
|
108
|
-
const baseline = arch === "x64" && !avx2
|
|
109
|
-
|
|
28
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
110
29
|
if (platform === "linux") {
|
|
111
|
-
const musl = (() => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} catch {
|
|
115
|
-
// ignore
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
120
|
-
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
121
|
-
if (text.includes("musl")) return true
|
|
122
|
-
} catch {
|
|
123
|
-
// ignore
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return false
|
|
127
|
-
})()
|
|
128
|
-
|
|
129
|
-
if (musl) {
|
|
130
|
-
if (arch === "x64") {
|
|
131
|
-
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
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`]
|
|
140
|
-
}
|
|
141
|
-
return [base, `${base}-musl`]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (arch === "x64") {
|
|
145
|
-
if (baseline) return [`${base}-baseline`, base]
|
|
146
|
-
return [base, `${base}-baseline`]
|
|
30
|
+
const musl = (() => { try { if (fs.existsSync("/etc/alpine-release")) return true } catch {} try { const r = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" }); if (((r.stdout||"")+(r.stderr||"")).toLowerCase().includes("musl")) return true } catch {} return false })()
|
|
31
|
+
if (musl) { return baseline ? [`${base}-baseline-musl`,`${base}-musl`,`${base}-baseline`,base] : [`${base}-musl`,`${base}-baseline-musl`,base,`${base}-baseline`] }
|
|
32
|
+
return baseline ? [`${base}-baseline`,base] : [base,`${base}-baseline`]
|
|
147
33
|
}
|
|
148
|
-
return [base]
|
|
34
|
+
return baseline ? [`${base}-baseline`,base] : [base,`${base}-baseline`]
|
|
149
35
|
})()
|
|
150
|
-
|
|
151
36
|
function findBinary(startDir) {
|
|
152
37
|
let current = startDir
|
|
153
38
|
for (;;) {
|
|
154
39
|
const modules = path.join(current, "node_modules")
|
|
155
40
|
if (fs.existsSync(modules)) {
|
|
156
41
|
for (const name of names) {
|
|
157
|
-
const
|
|
158
|
-
if (fs.existsSync(
|
|
42
|
+
const scoped = path.join(modules, "@vikasitai", name, "bin", binary)
|
|
43
|
+
if (fs.existsSync(scoped)) return scoped
|
|
44
|
+
const unscoped = path.join(modules, name, "bin", binary)
|
|
45
|
+
if (fs.existsSync(unscoped)) return unscoped
|
|
159
46
|
}
|
|
160
47
|
}
|
|
161
48
|
const parent = path.dirname(current)
|
|
162
|
-
if (parent === current)
|
|
163
|
-
return
|
|
164
|
-
}
|
|
49
|
+
if (parent === current) return
|
|
165
50
|
current = parent
|
|
166
51
|
}
|
|
167
52
|
}
|
|
168
|
-
|
|
169
53
|
const resolved = findBinary(scriptDir)
|
|
170
|
-
if (!resolved) {
|
|
171
|
-
console.error(
|
|
172
|
-
"It seems that your package manager failed to install the right version of the opencode CLI for your platform. You can try manually installing " +
|
|
173
|
-
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
174
|
-
" package",
|
|
175
|
-
)
|
|
176
|
-
process.exit(1)
|
|
177
|
-
}
|
|
178
|
-
|
|
54
|
+
if (!resolved) { console.error("Could not find Vikasit Code binary for " + platform + "/" + arch + ".\nTry: npm install -g @vikasitai/" + names[0] + "\nOr visit: https://vikasit.ai/code"); process.exit(1) }
|
|
179
55
|
run(resolved)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vikasitai/vikasit-code",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Your AI coding partner, right in the terminal",
|
|
5
5
|
"author": "Vikasit AI <info@vikasit.ai>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
"coding",
|
|
15
15
|
"cli",
|
|
16
16
|
"terminal",
|
|
17
|
-
"vikasit"
|
|
18
|
-
"copilot",
|
|
19
|
-
"code-assistant"
|
|
17
|
+
"vikasit"
|
|
20
18
|
],
|
|
21
19
|
"bin": {
|
|
22
20
|
"vikasit": "bin/vikasit"
|
|
@@ -25,17 +23,17 @@
|
|
|
25
23
|
"postinstall": "node ./postinstall.mjs || true"
|
|
26
24
|
},
|
|
27
25
|
"optionalDependencies": {
|
|
28
|
-
"@vikasitai/vikasit-code-
|
|
29
|
-
"@vikasitai/vikasit-code-
|
|
30
|
-
"@vikasitai/vikasit-code-linux-x64-musl": "1.0.0",
|
|
31
|
-
"@vikasitai/vikasit-code-linux-arm64": "1.0.0",
|
|
26
|
+
"@vikasitai/vikasit-code-darwin-arm64": "1.0.0",
|
|
27
|
+
"@vikasitai/vikasit-code-darwin-x64": "1.0.0",
|
|
32
28
|
"@vikasitai/vikasit-code-darwin-x64-baseline": "1.0.0",
|
|
33
|
-
"@vikasitai/vikasit-code-linux-
|
|
29
|
+
"@vikasitai/vikasit-code-linux-arm64": "1.0.0",
|
|
30
|
+
"@vikasitai/vikasit-code-linux-arm64-musl": "1.0.0",
|
|
34
31
|
"@vikasitai/vikasit-code-linux-x64": "1.0.0",
|
|
35
|
-
"@vikasitai/vikasit-code-
|
|
32
|
+
"@vikasitai/vikasit-code-linux-x64-baseline": "1.0.0",
|
|
33
|
+
"@vikasitai/vikasit-code-linux-x64-baseline-musl": "1.0.0",
|
|
34
|
+
"@vikasitai/vikasit-code-linux-x64-musl": "1.0.0",
|
|
36
35
|
"@vikasitai/vikasit-code-windows-arm64": "1.0.0",
|
|
37
|
-
"@vikasitai/vikasit-code-windows-x64
|
|
38
|
-
"@vikasitai/vikasit-code-
|
|
39
|
-
"@vikasitai/vikasit-code-linux-arm64-musl": "1.0.0"
|
|
36
|
+
"@vikasitai/vikasit-code-windows-x64": "1.0.0",
|
|
37
|
+
"@vikasitai/vikasit-code-windows-x64-baseline": "1.0.0"
|
|
40
38
|
}
|
|
41
39
|
}
|
package/vikasit
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
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
|
-
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
-
process.exit(code)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const envPath = process.env.VIKASIT_BIN_PATH
|
|
21
|
-
if (envPath) {
|
|
22
|
-
run(envPath)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
-
const scriptDir = path.dirname(scriptPath)
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
const cached = path.join(scriptDir, ".vikasit")
|
|
30
|
-
if (fs.existsSync(cached)) {
|
|
31
|
-
run(cached)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const platformMap = {
|
|
35
|
-
darwin: "darwin",
|
|
36
|
-
linux: "linux",
|
|
37
|
-
win32: "windows",
|
|
38
|
-
}
|
|
39
|
-
const archMap = {
|
|
40
|
-
x64: "x64",
|
|
41
|
-
arm64: "arm64",
|
|
42
|
-
arm: "arm",
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
let platform = platformMap[os.platform()]
|
|
46
|
-
if (!platform) {
|
|
47
|
-
platform = os.platform()
|
|
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"
|
|
55
|
-
|
|
56
|
-
function supportsAvx2() {
|
|
57
|
-
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
|
-
if (platform === "darwin") {
|
|
68
|
-
try {
|
|
69
|
-
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
70
|
-
encoding: "utf8",
|
|
71
|
-
timeout: 1500,
|
|
72
|
-
})
|
|
73
|
-
if (result.status !== 0) return false
|
|
74
|
-
return (result.stdout || "").trim() === "1"
|
|
75
|
-
} catch {
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (platform === "windows") {
|
|
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
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return false
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const names = (() => {
|
|
107
|
-
const avx2 = supportsAvx2()
|
|
108
|
-
const baseline = arch === "x64" && !avx2
|
|
109
|
-
|
|
110
|
-
if (platform === "linux") {
|
|
111
|
-
const musl = (() => {
|
|
112
|
-
try {
|
|
113
|
-
if (fs.existsSync("/etc/alpine-release")) return true
|
|
114
|
-
} catch {
|
|
115
|
-
// ignore
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
120
|
-
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
121
|
-
if (text.includes("musl")) return true
|
|
122
|
-
} catch {
|
|
123
|
-
// ignore
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return false
|
|
127
|
-
})()
|
|
128
|
-
|
|
129
|
-
if (musl) {
|
|
130
|
-
if (arch === "x64") {
|
|
131
|
-
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
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`]
|
|
140
|
-
}
|
|
141
|
-
return [base, `${base}-musl`]
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (arch === "x64") {
|
|
145
|
-
if (baseline) return [`${base}-baseline`, base]
|
|
146
|
-
return [base, `${base}-baseline`]
|
|
147
|
-
}
|
|
148
|
-
return [base]
|
|
149
|
-
})()
|
|
150
|
-
|
|
151
|
-
function findBinary(startDir) {
|
|
152
|
-
let current = startDir
|
|
153
|
-
for (;;) {
|
|
154
|
-
const modules = path.join(current, "node_modules")
|
|
155
|
-
if (fs.existsSync(modules)) {
|
|
156
|
-
for (const name of names) {
|
|
157
|
-
const candidate = path.join(modules, name, "bin", binary)
|
|
158
|
-
if (fs.existsSync(candidate)) return candidate
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
const parent = path.dirname(current)
|
|
162
|
-
if (parent === current) {
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
current = parent
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
const resolved = findBinary(scriptDir)
|
|
170
|
-
if (!resolved) {
|
|
171
|
-
console.error(
|
|
172
|
-
"It seems that your package manager failed to install the right version of the opencode CLI for your platform. You can try manually installing " +
|
|
173
|
-
names.map((n) => `\"${n}\"`).join(" or ") +
|
|
174
|
-
" package",
|
|
175
|
-
)
|
|
176
|
-
process.exit(1)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
run(resolved)
|