@vikasitai/vikasit-code 1.0.3 → 1.0.5
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 +14 -118
- package/package.json +14 -16
- 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,120 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
const childProcess
|
|
4
|
-
|
|
5
|
-
const path
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
const cached = path.join(scriptDir, ".vikasit")
|
|
29
|
-
if (fs.existsSync(cached)) {
|
|
30
|
-
run(cached)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const platformMap = {
|
|
34
|
-
darwin: "darwin",
|
|
35
|
-
linux: "linux",
|
|
36
|
-
win32: "windows",
|
|
37
|
-
}
|
|
38
|
-
const archMap = {
|
|
39
|
-
x64: "x64",
|
|
40
|
-
arm64: "arm64",
|
|
41
|
-
arm: "arm",
|
|
42
|
-
}
|
|
43
|
-
|
|
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"
|
|
48
|
-
|
|
49
|
-
function supportsAvx2() {
|
|
50
|
-
if (arch !== "x64") return false
|
|
51
|
-
if (platform === "darwin") {
|
|
52
|
-
try {
|
|
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 }
|
|
56
|
-
}
|
|
57
|
-
if (platform === "linux") {
|
|
58
|
-
try { return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8")) } catch { return false }
|
|
59
|
-
}
|
|
60
|
-
return false
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const names = (() => {
|
|
64
|
-
const avx2 = supportsAvx2()
|
|
65
|
-
const baseline = arch === "x64" && !avx2
|
|
66
|
-
|
|
67
|
-
if (platform === "linux") {
|
|
68
|
-
const musl = (() => {
|
|
69
|
-
try { if (fs.existsSync("/etc/alpine-release")) return true } catch {}
|
|
70
|
-
try {
|
|
71
|
-
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
72
|
-
if (((result.stdout || "") + (result.stderr || "")).toLowerCase().includes("musl")) return true
|
|
73
|
-
} catch {}
|
|
74
|
-
return false
|
|
75
|
-
})()
|
|
76
|
-
|
|
77
|
-
if (musl) {
|
|
78
|
-
if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
79
|
-
return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
80
|
-
}
|
|
81
|
-
if (baseline) return [`${base}-baseline`, base]
|
|
82
|
-
return [base, `${base}-baseline`]
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (baseline) return [`${base}-baseline`, base]
|
|
86
|
-
return [base, `${base}-baseline`]
|
|
87
|
-
})()
|
|
88
|
-
|
|
89
|
-
// Look for the binary in node_modules with @vikasitai scope
|
|
90
|
-
function findBinary(startDir) {
|
|
91
|
-
let current = startDir
|
|
92
|
-
for (;;) {
|
|
93
|
-
const modules = path.join(current, "node_modules")
|
|
94
|
-
if (fs.existsSync(modules)) {
|
|
95
|
-
for (const name of names) {
|
|
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
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const parent = path.dirname(current)
|
|
105
|
-
if (parent === current) return
|
|
106
|
-
current = parent
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const resolved = findBinary(scriptDir)
|
|
111
|
-
if (!resolved) {
|
|
112
|
-
console.error(
|
|
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."
|
|
116
|
-
)
|
|
117
|
-
process.exit(1)
|
|
118
|
-
}
|
|
119
|
-
|
|
2
|
+
const childProcess=require("child_process"),fs=require("fs"),path=require("path"),os=require("os")
|
|
3
|
+
function run(t){const r=childProcess.spawnSync(t,process.argv.slice(2),{stdio:"inherit"});r.error&&(console.error(r.error.message),process.exit(1));process.exit("number"==typeof r.status?r.status:0)}
|
|
4
|
+
if(process.env.VIKASIT_BIN_PATH)run(process.env.VIKASIT_BIN_PATH)
|
|
5
|
+
const scriptDir=path.dirname(fs.realpathSync(__filename)),cached=path.join(scriptDir,".vikasit")
|
|
6
|
+
if(fs.existsSync(cached))run(cached)
|
|
7
|
+
const p={darwin:"darwin",linux:"linux",win32:"windows"},a={x64:"x64",arm64:"arm64",arm:"arm"}
|
|
8
|
+
const platform=p[os.platform()]||os.platform(),arch=a[os.arch()]||os.arch()
|
|
9
|
+
const base="vikasit-code-"+platform+"-"+arch,binary=platform==="windows"?"vikasit.exe":"vikasit"
|
|
10
|
+
function avx2(){if(arch!=="x64")return false;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}}if(platform==="linux"){try{return/(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo","utf8"))}catch{return false}}return false}
|
|
11
|
+
const bl=arch==="x64"&&!avx2()
|
|
12
|
+
const names=(()=>{if(platform==="linux"){const m=(()=>{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})();if(m)return bl?[base+"-baseline-musl",base+"-musl",base+"-baseline",base]:[base+"-musl",base+"-baseline-musl",base,base+"-baseline"];return bl?[base+"-baseline",base]:[base,base+"-baseline"]}return bl?[base+"-baseline",base]:[base,base+"-baseline"]})()
|
|
13
|
+
function findBin(d){let c=d;for(;;){const m=path.join(c,"node_modules");if(fs.existsSync(m))for(const n of names){const s=path.join(m,"@vikasitai",n,"bin",binary);if(fs.existsSync(s))return s;const u=path.join(m,n,"bin",binary);if(fs.existsSync(u))return u}const p2=path.dirname(c);if(p2===c)return;c=p2}}
|
|
14
|
+
const resolved=findBin(scriptDir)
|
|
15
|
+
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)}
|
|
120
16
|
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.5",
|
|
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-
|
|
31
|
-
"@vikasitai/vikasit-code-linux-arm64": "1.0.
|
|
32
|
-
"@vikasitai/vikasit-code-
|
|
33
|
-
"@vikasitai/vikasit-code-linux-x64
|
|
34
|
-
"@vikasitai/vikasit-code-linux-x64": "1.0.
|
|
35
|
-
"@vikasitai/vikasit-code-
|
|
36
|
-
"@vikasitai/vikasit-code-
|
|
37
|
-
"@vikasitai/vikasit-code-windows-
|
|
38
|
-
"@vikasitai/vikasit-code-
|
|
39
|
-
"@vikasitai/vikasit-code-
|
|
26
|
+
"@vikasitai/vikasit-code-darwin-arm64": "1.0.5",
|
|
27
|
+
"@vikasitai/vikasit-code-darwin-x64": "1.0.5",
|
|
28
|
+
"@vikasitai/vikasit-code-darwin-x64-baseline": "1.0.5",
|
|
29
|
+
"@vikasitai/vikasit-code-linux-arm64": "1.0.5",
|
|
30
|
+
"@vikasitai/vikasit-code-linux-arm64-musl": "1.0.5",
|
|
31
|
+
"@vikasitai/vikasit-code-linux-x64": "1.0.5",
|
|
32
|
+
"@vikasitai/vikasit-code-linux-x64-baseline": "1.0.5",
|
|
33
|
+
"@vikasitai/vikasit-code-linux-x64-baseline-musl": "1.0.5",
|
|
34
|
+
"@vikasitai/vikasit-code-linux-x64-musl": "1.0.5",
|
|
35
|
+
"@vikasitai/vikasit-code-windows-arm64": "1.0.5",
|
|
36
|
+
"@vikasitai/vikasit-code-windows-x64": "1.0.5",
|
|
37
|
+
"@vikasitai/vikasit-code-windows-x64-baseline": "1.0.5"
|
|
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)
|