redcode-cli 0.0.0-stage → 2.4.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 +31 -2
- package/bin/redcode.js +56 -0
- package/package.json +44 -4
- package/scripts/install.js +328 -0
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# redcode-cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official npm installer & launcher for **RedCode CLI `v2.4.5`** (Linux ARM64 — `glibc` & `musl`).
|
|
4
|
+
|
|
5
|
+
## Install Globally
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i -g redcode-cli --foreground-scripts
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run anytime without global flags:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i -g redcode-cli
|
|
15
|
+
redcode
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
redcode # Launch interactive RedCode TUI
|
|
22
|
+
redcode serve # Launch RedCode Web UI on http://127.0.0.1:4444
|
|
23
|
+
redcode run "hello" # One-shot autonomous run
|
|
24
|
+
redcode --version # Verify version
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Built-in Frontier Capabilities (`v2.4.5`)
|
|
28
|
+
- **Intelligence Tools**: `repo_map` (PageRank symbol map), `lsp`, `ast_search`, `codebase_search`, `dep_graph`, `refactor`, `repo_pack`, `git_intel`, `secret_scan`, `db_intel`, `test_mutate`, `perf_bench`, persistent cross-session `memory`
|
|
29
|
+
- **Specialist Subagents**: `explore`, `architect`, `reviewer`, `debugger`, `tester`, `critic`, `swarm`
|
|
30
|
+
- **Slash Commands**: `/swarm`, `/issue`, `/critic`, `/perf`, `/architect`, `/debug`, `/test`, `/security`, `/review`, `/init`
|
|
31
|
+
|
|
32
|
+
Downloads are fetched directly from [red-code-cli/redcodecli](https://github.com/red-code-cli/redcodecli/releases) and verified against `SHA256SUMS`.
|
package/bin/redcode.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict"
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs")
|
|
5
|
+
const os = require("node:os")
|
|
6
|
+
const path = require("node:path")
|
|
7
|
+
const { spawnSync } = require("node:child_process")
|
|
8
|
+
|
|
9
|
+
const root = path.join(__dirname, "..")
|
|
10
|
+
const vendorBin = path.join(root, "vendor", "redcode")
|
|
11
|
+
const installScript = path.join(root, "scripts", "install.js")
|
|
12
|
+
|
|
13
|
+
function run(binary, args) {
|
|
14
|
+
const result = spawnSync(binary, args, { stdio: "inherit" })
|
|
15
|
+
if (result.error) {
|
|
16
|
+
if (result.error.code === "EACCES") {
|
|
17
|
+
// Fallback for noexec mounts (e.g., certain Android / shared filesystems)
|
|
18
|
+
const fallbackDir = path.join(os.homedir(), ".redcode-run")
|
|
19
|
+
const fallbackBin = path.join(fallbackDir, "redcode")
|
|
20
|
+
fs.mkdirSync(fallbackDir, { recursive: true })
|
|
21
|
+
fs.copyFileSync(binary, fallbackBin)
|
|
22
|
+
fs.chmodSync(fallbackBin, 0o755)
|
|
23
|
+
const retry = spawnSync(fallbackBin, args, { stdio: "inherit" })
|
|
24
|
+
if (retry.error) {
|
|
25
|
+
console.error(retry.error.message)
|
|
26
|
+
process.exit(1)
|
|
27
|
+
}
|
|
28
|
+
process.exit(retry.status ?? 1)
|
|
29
|
+
}
|
|
30
|
+
console.error(result.error.message)
|
|
31
|
+
process.exit(1)
|
|
32
|
+
}
|
|
33
|
+
process.exit(result.status ?? 1)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const args = process.argv.slice(2)
|
|
37
|
+
if (args[0] === "--reinstall-binary") {
|
|
38
|
+
const res = spawnSync(process.execPath, [installScript, "--force"], { stdio: "inherit" })
|
|
39
|
+
process.exit(res.status ?? 1)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let binary = process.env.REDCODE_BIN
|
|
43
|
+
if (!binary) {
|
|
44
|
+
if (!fs.existsSync(vendorBin)) {
|
|
45
|
+
spawnSync(process.execPath, [installScript], { stdio: "inherit" })
|
|
46
|
+
}
|
|
47
|
+
binary = vendorBin
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!fs.existsSync(binary)) {
|
|
51
|
+
console.error("\x1b[38;5;196mRedCode CLI binary is not installed.\x1b[0m")
|
|
52
|
+
console.error("Run: \x1b[1mredcode --reinstall-binary\x1b[0m or \x1b[1mnpm rebuild redcode-cli --foreground-scripts\x1b[0m")
|
|
53
|
+
process.exit(1)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
run(binary, args)
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redcode-cli",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.4.5",
|
|
4
|
+
"description": "RedCode CLI v2.4.5 — Autonomous AI coding agent, Swarm/Judge workflows & Web UI for Linux ARM64",
|
|
5
|
+
"bin": {
|
|
6
|
+
"redcode": "bin/redcode.js",
|
|
7
|
+
"redcode-cli": "bin/redcode.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"bin",
|
|
11
|
+
"scripts",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"postinstall": "node scripts/install.js"
|
|
16
|
+
},
|
|
17
|
+
"os": [
|
|
18
|
+
"linux"
|
|
19
|
+
],
|
|
20
|
+
"cpu": [
|
|
21
|
+
"arm64"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"preferGlobal": true,
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"homepage": "https://github.com/red-code-cli/redcodecli#readme",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/red-code-cli/redcodecli.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/red-code-cli/redcodecli/issues"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"redcode",
|
|
38
|
+
"redcode-cli",
|
|
39
|
+
"ai",
|
|
40
|
+
"coding-agent",
|
|
41
|
+
"cli",
|
|
42
|
+
"swarm",
|
|
43
|
+
"lsp",
|
|
44
|
+
"arm64"
|
|
45
|
+
]
|
|
46
|
+
}
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict"
|
|
3
|
+
|
|
4
|
+
const fs = require("node:fs")
|
|
5
|
+
const path = require("node:path")
|
|
6
|
+
const https = require("node:https")
|
|
7
|
+
const crypto = require("node:crypto")
|
|
8
|
+
const { spawnSync } = require("node:child_process")
|
|
9
|
+
|
|
10
|
+
const PKG = require("../package.json")
|
|
11
|
+
const VERSION = PKG.version
|
|
12
|
+
const REPO = "red-code-cli/redcodecli"
|
|
13
|
+
const BASE = `https://github.com/${REPO}/releases/download/v${VERSION}`
|
|
14
|
+
const root = path.join(__dirname, "..")
|
|
15
|
+
const vendor = path.join(root, "vendor")
|
|
16
|
+
const bin = path.join(vendor, "redcode")
|
|
17
|
+
const FORCE = process.argv.includes("--force")
|
|
18
|
+
|
|
19
|
+
// Open controlling TTY so animation stays visible even when npm buffers postinstall stdout.
|
|
20
|
+
function createDisplay() {
|
|
21
|
+
let ttyFd = null
|
|
22
|
+
let interactive = Boolean(process.stdout.isTTY)
|
|
23
|
+
if (!process.env.CI) {
|
|
24
|
+
try {
|
|
25
|
+
ttyFd = fs.openSync("/dev/tty", "w")
|
|
26
|
+
interactive = true
|
|
27
|
+
} catch {
|
|
28
|
+
ttyFd = null
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const write = (str) => {
|
|
32
|
+
if (ttyFd !== null) {
|
|
33
|
+
try {
|
|
34
|
+
fs.writeSync(ttyFd, str)
|
|
35
|
+
return
|
|
36
|
+
} catch {}
|
|
37
|
+
}
|
|
38
|
+
process.stdout.write(str)
|
|
39
|
+
}
|
|
40
|
+
const close = () => {
|
|
41
|
+
if (ttyFd !== null) {
|
|
42
|
+
try {
|
|
43
|
+
fs.closeSync(ttyFd)
|
|
44
|
+
} catch {}
|
|
45
|
+
ttyFd = null
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { write, close, interactive }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ui = createDisplay()
|
|
52
|
+
const C = ui.interactive
|
|
53
|
+
? {
|
|
54
|
+
reset: "\x1b[0m",
|
|
55
|
+
bold: "\x1b[1m",
|
|
56
|
+
dim: "\x1b[2m",
|
|
57
|
+
red1: "\x1b[38;5;196m",
|
|
58
|
+
red2: "\x1b[38;5;203m",
|
|
59
|
+
red3: "\x1b[38;5;160m",
|
|
60
|
+
slate: "\x1b[38;5;246m",
|
|
61
|
+
white: "\x1b[97m",
|
|
62
|
+
green: "\x1b[38;5;46m",
|
|
63
|
+
amber: "\x1b[38;5;214m",
|
|
64
|
+
cyan: "\x1b[38;5;51m",
|
|
65
|
+
hideCursor: "\x1b[?25l",
|
|
66
|
+
showCursor: "\x1b[?25h",
|
|
67
|
+
clearLine: "\r\x1b[2K",
|
|
68
|
+
}
|
|
69
|
+
: {
|
|
70
|
+
reset: "",
|
|
71
|
+
bold: "",
|
|
72
|
+
dim: "",
|
|
73
|
+
red1: "",
|
|
74
|
+
red2: "",
|
|
75
|
+
red3: "",
|
|
76
|
+
slate: "",
|
|
77
|
+
white: "",
|
|
78
|
+
green: "",
|
|
79
|
+
amber: "",
|
|
80
|
+
cyan: "",
|
|
81
|
+
hideCursor: "",
|
|
82
|
+
showCursor: "",
|
|
83
|
+
clearLine: "",
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const SPINNER = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
|
|
87
|
+
const LOGO = [
|
|
88
|
+
" ____ _ ____ _ ",
|
|
89
|
+
"| _ \\ ___ __| |/ ___|___ __| | ___ ",
|
|
90
|
+
"| |_) / _ \\/ _` | | / _ \\ / _` |/ _ \\",
|
|
91
|
+
"| _ < __/ (_| | |__| (_) | (_| | __/",
|
|
92
|
+
"|_| \\_\\___|\\__,_|\\____\\___/ \\__,_|\\___|",
|
|
93
|
+
]
|
|
94
|
+
const GRADIENT = [C.red1, C.red1, C.red2, C.red2, C.red3]
|
|
95
|
+
|
|
96
|
+
function sleep(ms) {
|
|
97
|
+
return new Promise((r) => setTimeout(r, ms))
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
async function renderBanner() {
|
|
101
|
+
ui.write("\n")
|
|
102
|
+
if (ui.interactive) ui.write(C.hideCursor)
|
|
103
|
+
for (let i = 0; i < LOGO.length; i++) {
|
|
104
|
+
const tag = i === LOGO.length - 1 ? ` ${C.bold}${C.white}v${VERSION}${C.reset}` : ""
|
|
105
|
+
ui.write(` ${C.bold}${GRADIENT[i]}${LOGO[i]}${C.reset}${tag}\n`)
|
|
106
|
+
if (ui.interactive) await sleep(35)
|
|
107
|
+
}
|
|
108
|
+
ui.write(` ${C.slate}Autonomous Coding Agent • Linux ARM64 CLI${C.reset}\n`)
|
|
109
|
+
ui.write(` ${C.red3}${"━".repeat(48)}${C.reset}\n`)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function createSpinner(label) {
|
|
113
|
+
let idx = 0
|
|
114
|
+
let current = label
|
|
115
|
+
let timer = null
|
|
116
|
+
if (ui.interactive) {
|
|
117
|
+
const draw = () => {
|
|
118
|
+
const frame = SPINNER[idx++ % SPINNER.length]
|
|
119
|
+
ui.write(`${C.clearLine} ${C.red1}${frame}${C.reset} ${C.white}${current}${C.reset}`)
|
|
120
|
+
}
|
|
121
|
+
draw()
|
|
122
|
+
timer = setInterval(draw, 80)
|
|
123
|
+
} else {
|
|
124
|
+
ui.write(` * ${label}\n`)
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
update(next) {
|
|
128
|
+
current = next
|
|
129
|
+
if (!ui.interactive) ui.write(` * ${next}\n`)
|
|
130
|
+
},
|
|
131
|
+
succeed(msg) {
|
|
132
|
+
if (timer) clearInterval(timer)
|
|
133
|
+
if (ui.interactive) ui.write(`${C.clearLine} ${C.green}✓${C.reset} ${C.white}${msg}${C.reset}\n`)
|
|
134
|
+
else ui.write(` [ok] ${msg}\n`)
|
|
135
|
+
},
|
|
136
|
+
fail(msg) {
|
|
137
|
+
if (timer) clearInterval(timer)
|
|
138
|
+
if (ui.interactive) ui.write(`${C.clearLine} ${C.amber}!${C.reset} ${C.amber}${msg}${C.reset}\n`)
|
|
139
|
+
else ui.write(` [warn] ${msg}\n`)
|
|
140
|
+
},
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function detectLibc() {
|
|
145
|
+
try {
|
|
146
|
+
if (fs.existsSync("/lib/ld-musl-aarch64.so.1")) return "musl"
|
|
147
|
+
const probe = spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
148
|
+
const out = `${probe.stdout || ""}${probe.stderr || ""}`.toLowerCase()
|
|
149
|
+
if (out.includes("musl")) return "musl"
|
|
150
|
+
} catch {}
|
|
151
|
+
return "glibc"
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function httpGet(url, redirects = 8) {
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
const req = https.get(
|
|
157
|
+
url,
|
|
158
|
+
{ headers: { "user-agent": `redcode-cli/${VERSION}` }, timeout: 30_000 },
|
|
159
|
+
(res) => {
|
|
160
|
+
if ([301, 302, 303, 307, 308].includes(res.statusCode) && res.headers.location && redirects > 0) {
|
|
161
|
+
res.resume()
|
|
162
|
+
const nextUrl = new URL(res.headers.location, url).toString()
|
|
163
|
+
return resolve(httpGet(nextUrl, redirects - 1))
|
|
164
|
+
}
|
|
165
|
+
if (res.statusCode !== 200) {
|
|
166
|
+
res.resume()
|
|
167
|
+
return reject(new Error(`HTTP ${res.statusCode} for ${url}`))
|
|
168
|
+
}
|
|
169
|
+
resolve(res)
|
|
170
|
+
},
|
|
171
|
+
)
|
|
172
|
+
req.on("timeout", () => req.destroy(new Error(`Request timeout for ${url}`)))
|
|
173
|
+
req.on("error", reject)
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async function fetchText(url) {
|
|
178
|
+
const res = await httpGet(url)
|
|
179
|
+
return await new Promise((resolve, reject) => {
|
|
180
|
+
const chunks = []
|
|
181
|
+
res.on("data", (d) => chunks.push(d))
|
|
182
|
+
res.on("end", () => resolve(Buffer.concat(chunks).toString("utf8")))
|
|
183
|
+
res.on("error", reject)
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function formatMB(bytes) {
|
|
188
|
+
return (bytes / (1024 * 1024)).toFixed(1)
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async function downloadWithProgress(url, dest) {
|
|
192
|
+
const res = await httpGet(url)
|
|
193
|
+
const total = Number.parseInt(res.headers["content-length"] || "0", 10)
|
|
194
|
+
const out = fs.createWriteStream(dest)
|
|
195
|
+
let loaded = 0
|
|
196
|
+
let spinIdx = 0
|
|
197
|
+
let lastDraw = 0
|
|
198
|
+
const startedAt = Date.now()
|
|
199
|
+
const barWidth = 22
|
|
200
|
+
|
|
201
|
+
const renderBar = (force = false) => {
|
|
202
|
+
const now = Date.now()
|
|
203
|
+
if (!force && now - lastDraw < 90) return
|
|
204
|
+
lastDraw = now
|
|
205
|
+
const elapsedSec = Math.max((now - startedAt) / 1000, 0.1)
|
|
206
|
+
const mbPerSec = (loaded / (1024 * 1024) / elapsedSec).toFixed(1)
|
|
207
|
+
const frame = SPINNER[spinIdx++ % SPINNER.length]
|
|
208
|
+
if (total > 0) {
|
|
209
|
+
const pct = Math.min(100, Math.round((loaded / total) * 100))
|
|
210
|
+
const filled = Math.round((pct / 100) * barWidth)
|
|
211
|
+
const bar = `${C.red1}${"█".repeat(filled)}${C.slate}${"░".repeat(barWidth - filled)}${C.reset}`
|
|
212
|
+
ui.write(
|
|
213
|
+
`${C.clearLine} ${C.red1}${frame}${C.reset} Downloading [${bar}] ${C.bold}${C.white}${pct}%${C.reset} ${C.slate}${formatMB(loaded)}/${formatMB(total)} MB (${mbPerSec} MB/s)${C.reset}`,
|
|
214
|
+
)
|
|
215
|
+
} else {
|
|
216
|
+
ui.write(
|
|
217
|
+
`${C.clearLine} ${C.red1}${frame}${C.reset} Downloading ${C.white}${formatMB(loaded)} MB${C.reset} ${C.slate}(${mbPerSec} MB/s)${C.reset}`,
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return await new Promise((resolve, reject) => {
|
|
223
|
+
res.on("data", (chunk) => {
|
|
224
|
+
loaded += chunk.length
|
|
225
|
+
if (ui.interactive) renderBar(false)
|
|
226
|
+
})
|
|
227
|
+
res.pipe(out)
|
|
228
|
+
out.on("finish", () => {
|
|
229
|
+
if (ui.interactive) {
|
|
230
|
+
ui.write(
|
|
231
|
+
`${C.clearLine} ${C.green}✓${C.reset} ${C.white}Downloaded ${formatMB(loaded)} MB${C.reset}\n`,
|
|
232
|
+
)
|
|
233
|
+
} else {
|
|
234
|
+
ui.write(` [ok] Downloaded ${formatMB(loaded)} MB\n`)
|
|
235
|
+
}
|
|
236
|
+
resolve()
|
|
237
|
+
})
|
|
238
|
+
out.on("error", reject)
|
|
239
|
+
res.on("error", reject)
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function main() {
|
|
244
|
+
if (process.platform !== "linux" || process.arch !== "arm64") {
|
|
245
|
+
ui.write(`\n ${C.amber}! redcode-cli currently ships Linux ARM64 binaries (detected ${process.platform}/${process.arch}).${C.reset}\n`)
|
|
246
|
+
ui.write(` ${C.slate} Set REDCODE_BIN=/path/to/redcode if using a custom build.${C.reset}\n\n`)
|
|
247
|
+
return
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (!FORCE && fs.existsSync(bin)) {
|
|
251
|
+
const probe = spawnSync(bin, ["--version"], { encoding: "utf8" })
|
|
252
|
+
if ((probe.stdout || "").includes(VERSION)) {
|
|
253
|
+
ui.write(`\n ${C.green}✓${C.reset} ${C.bold}${C.white}RedCode CLI v${VERSION}${C.reset} ${C.slate}is already installed (${bin})${C.reset}\n\n`)
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
fs.mkdirSync(vendor, { recursive: true })
|
|
259
|
+
await renderBanner()
|
|
260
|
+
|
|
261
|
+
const libc = detectLibc()
|
|
262
|
+
const asset = libc === "musl" ? "redcode-linux-arm64-musl.tar.gz" : "redcode-linux-arm64.tar.gz"
|
|
263
|
+
const archive = path.join(vendor, `${asset}.tmp`)
|
|
264
|
+
const cleanup = () => {
|
|
265
|
+
if (fs.existsSync(archive)) {
|
|
266
|
+
try {
|
|
267
|
+
fs.unlinkSync(archive)
|
|
268
|
+
} catch {}
|
|
269
|
+
}
|
|
270
|
+
if (ui.interactive) ui.write(C.showCursor)
|
|
271
|
+
ui.close()
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
process.on("SIGINT", () => {
|
|
275
|
+
cleanup()
|
|
276
|
+
process.exit(130)
|
|
277
|
+
})
|
|
278
|
+
|
|
279
|
+
try {
|
|
280
|
+
const s1 = createSpinner(`Inspecting v${VERSION} checksums (linux-arm64 / ${libc})...`)
|
|
281
|
+
const sums = await fetchText(`${BASE}/SHA256SUMS`)
|
|
282
|
+
const sumLine = sums.split(/\r?\n/).find((l) => l.trim().endsWith(asset))
|
|
283
|
+
if (!sumLine) throw new Error(`SHA256SUMS missing entry for ${asset}`)
|
|
284
|
+
const expectedSha = sumLine.trim().split(/\s+/)[0]
|
|
285
|
+
s1.succeed(`Target matched: ${asset} (${libc})`)
|
|
286
|
+
|
|
287
|
+
if (!ui.interactive) ui.write(` * Downloading ${BASE}/${asset}\n`)
|
|
288
|
+
await downloadWithProgress(`${BASE}/${asset}`, archive)
|
|
289
|
+
|
|
290
|
+
const s2 = createSpinner("Verifying SHA-256 integrity...")
|
|
291
|
+
const actualSha = await new Promise((resolve, reject) => {
|
|
292
|
+
const hash = crypto.createHash("sha256")
|
|
293
|
+
const stream = fs.createReadStream(archive)
|
|
294
|
+
stream.on("data", (d) => hash.update(d))
|
|
295
|
+
stream.on("end", () => resolve(hash.digest("hex")))
|
|
296
|
+
stream.on("error", reject)
|
|
297
|
+
})
|
|
298
|
+
if (actualSha !== expectedSha) {
|
|
299
|
+
throw new Error(`SHA-256 mismatch (expected ${expectedSha.slice(0, 12)}..., got ${actualSha.slice(0, 12)}...)`)
|
|
300
|
+
}
|
|
301
|
+
s2.succeed(`SHA-256 verified (${expectedSha.slice(0, 12)}...)`)
|
|
302
|
+
|
|
303
|
+
const s3 = createSpinner("Extracting RedCode binary...")
|
|
304
|
+
const untar = spawnSync("tar", ["-xzf", archive, "-C", vendor, "redcode"], { encoding: "utf8" })
|
|
305
|
+
if (untar.status !== 0) {
|
|
306
|
+
throw new Error(`tar extraction failed: ${untar.stderr || "unknown error"}`)
|
|
307
|
+
}
|
|
308
|
+
fs.chmodSync(bin, 0o755)
|
|
309
|
+
try {
|
|
310
|
+
fs.unlinkSync(archive)
|
|
311
|
+
} catch {}
|
|
312
|
+
s3.succeed(`RedCode CLI v${VERSION} installed`)
|
|
313
|
+
|
|
314
|
+
ui.write(` ${C.red3}${"━".repeat(48)}${C.reset}\n`)
|
|
315
|
+
ui.write(` ${C.green}★${C.reset} ${C.bold}${C.white}Ready!${C.reset} Run ${C.red2}redcode${C.reset} (TUI) or ${C.red2}redcode serve${C.reset} (Web UI :4444)\n`)
|
|
316
|
+
ui.write(` ${C.slate} Commands: /swarm /issue /critic /perf /architect /security${C.reset}\n\n`)
|
|
317
|
+
} finally {
|
|
318
|
+
cleanup()
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
main().catch((err) => {
|
|
323
|
+
if (ui.interactive) ui.write(C.showCursor)
|
|
324
|
+
ui.write(`\n ${C.amber}! RedCode binary auto-install skipped: ${err.message}${C.reset}\n`)
|
|
325
|
+
ui.write(` ${C.slate} Run 'redcode' later to auto-download with animation, or set REDCODE_BIN.${C.reset}\n\n`)
|
|
326
|
+
ui.close()
|
|
327
|
+
process.exit(0)
|
|
328
|
+
})
|