@devcodeagent/cli 0.0.1 → 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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 opencode
4
+ Copyright (c) 2026 Harsha Vardhan (Harsha-code-per) and DeV contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # DeV Code
2
2
 
3
- Coming soon.
3
+ Pro coding for everyone. See https://github.com/Harsha-code-per/DeV.
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env node
2
+ // The npm package holds only this launcher, so npm, pnpm, bun and yarn all work without an install
3
+ // script. On first run it downloads the matching release, verifies its checksum, and keeps it in
4
+ // ~/.devcode/npm/<version>. After that it just starts the program.
5
+ import childProcess from "child_process"
6
+ import crypto from "crypto"
7
+ import fs from "fs"
8
+ import os from "os"
9
+ import path from "path"
10
+ import { fileURLToPath } from "url"
11
+
12
+ const packageDir = path.dirname(path.dirname(fileURLToPath(import.meta.url)))
13
+ const { version } = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf8"))
14
+ const releases =
15
+ process.env.DEVCODE_RELEASE_URL ?? `https://github.com/Harsha-code-per/DeV/releases/download/v${version}`
16
+
17
+ const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()]
18
+ const arch = { x64: "x64", arm64: "arm64" }[os.arch()]
19
+ if (!platform || !arch) fail(`DeV Code doesn't support ${os.platform()} ${os.arch()} yet.`)
20
+
21
+ const home = path.join(process.env.DEVCODE_HOME ?? path.join(os.homedir(), ".devcode"), "npm", version)
22
+ const binary = path.join(home, platform === "windows" ? "devcode.exe" : "devcode")
23
+
24
+ if (!fs.existsSync(binary)) await install()
25
+ run()
26
+
27
+ async function install() {
28
+ const baseline = arch === "x64" && !supportsAvx2() ? "-baseline" : ""
29
+ const musl = isMusl() ? "-musl" : ""
30
+ const asset = `devcode-${platform}-${arch}${baseline}${musl}.${platform === "windows" ? "zip" : "tar.gz"}`
31
+ console.error(`Downloading DeV Code ${version}, once only…`)
32
+ const sums = Buffer.from(await download("SHA256SUMS")).toString("utf8")
33
+ const expected = sums
34
+ .split("\n")
35
+ .find((line) => line.trim().endsWith(` ${asset}`))
36
+ ?.split(/\s+/)[0]
37
+ if (!expected) fail(`This release has no build named ${asset}.`)
38
+ const archive = Buffer.from(await download(asset))
39
+ const actual = crypto.createHash("sha256").update(archive).digest("hex")
40
+ if (actual !== expected) fail(`The download of ${asset} failed its checksum, so it wasn't installed. Try again.`)
41
+
42
+ // Unpacked beside the target and renamed, so two terminals starting at once can't see half a copy.
43
+ fs.mkdirSync(path.dirname(home), { recursive: true })
44
+ const staging = fs.mkdtempSync(`${home}.`)
45
+ const file = path.join(staging, asset)
46
+ fs.writeFileSync(file, archive)
47
+ const flags = platform === "windows" ? "-xf" : "-xzf"
48
+ const unpacked = childProcess.spawnSync("tar", [flags, file, "-C", staging], { stdio: "inherit", windowsHide: true })
49
+ if (unpacked.status !== 0) fail("Couldn't unpack the download. Check that tar is installed.")
50
+ fs.rmSync(file)
51
+ fs.chmodSync(path.join(staging, path.basename(binary)), 0o755)
52
+ try {
53
+ fs.renameSync(staging, home)
54
+ } catch (error) {
55
+ fs.rmSync(staging, { recursive: true, force: true })
56
+ if (!fs.existsSync(binary)) throw error
57
+ }
58
+ }
59
+
60
+ async function download(name) {
61
+ const response = await fetch(`${releases}/${name}`).catch((error) => {
62
+ fail(`Couldn't download DeV Code: ${error.message}`)
63
+ })
64
+ if (response.ok) return response.arrayBuffer()
65
+ fail(`Couldn't download ${name}: the server answered ${response.status}.`)
66
+ }
67
+
68
+ function run() {
69
+ const child = childProcess.spawn(binary, process.argv.slice(2), { stdio: "inherit", windowsHide: false })
70
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"])
71
+ process.on(signal, () => {
72
+ child.kill(signal)
73
+ })
74
+ child.on("error", (error) => fail(error.message))
75
+ child.on("exit", (code, signal) => {
76
+ if (signal) process.kill(process.pid, signal)
77
+ process.exit(code ?? 1)
78
+ })
79
+ }
80
+
81
+ function fail(message) {
82
+ console.error(`error: ${message}`)
83
+ process.exit(1)
84
+ }
85
+
86
+ function supportsAvx2() {
87
+ if (arch !== "x64") return false
88
+
89
+ if (platform === "linux") {
90
+ try {
91
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
92
+ } catch {
93
+ return false
94
+ }
95
+ }
96
+
97
+ if (platform === "darwin") {
98
+ try {
99
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
100
+ encoding: "utf8",
101
+ timeout: 1500,
102
+ })
103
+ if (result.status !== 0) return false
104
+ return (result.stdout || "").trim() === "1"
105
+ } catch {
106
+ return false
107
+ }
108
+ }
109
+
110
+ if (platform === "windows") {
111
+ const command =
112
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
113
+
114
+ for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
115
+ try {
116
+ const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
117
+ encoding: "utf8",
118
+ timeout: 3000,
119
+ windowsHide: true,
120
+ })
121
+ if (result.status !== 0) continue
122
+ const output = (result.stdout || "").trim().toLowerCase()
123
+ if (output === "true" || output === "1") return true
124
+ if (output === "false" || output === "0") return false
125
+ } catch {
126
+ continue
127
+ }
128
+ }
129
+ }
130
+
131
+ return false
132
+ }
133
+
134
+ function isMusl() {
135
+ if (platform !== "linux") return false
136
+
137
+ try {
138
+ if (fs.existsSync("/etc/alpine-release")) return true
139
+ } catch {
140
+ // Ignore filesystem probes that are blocked by the host.
141
+ }
142
+
143
+ try {
144
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
145
+ return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
146
+ } catch {
147
+ return false
148
+ }
149
+ }
package/package.json CHANGED
@@ -1,6 +1,18 @@
1
1
  {
2
2
  "name": "@devcodeagent/cli",
3
- "version": "0.0.1",
4
- "description": "DeV Code, a coding agent for your terminal. Coming soon.",
5
- "license": "MIT"
3
+ "version": "1.0.4",
4
+ "description": "DeV Code, a coding agent for your terminal with the premium features included.",
5
+ "license": "MIT",
6
+ "homepage": "https://github.com/Harsha-code-per/DeV",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/Harsha-code-per/DeV.git"
10
+ },
11
+ "type": "module",
12
+ "bin": {
13
+ "devcode": "./bin/devcode.mjs"
14
+ },
15
+ "engines": {
16
+ "node": ">=18"
17
+ }
6
18
  }