@deep-code/cli 0.1.0-beta
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 +21 -0
- package/bin/deepcode.cjs +130 -0
- package/package.json +41 -0
- package/postinstall.mjs +8 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 deepcode
|
|
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/deepcode.cjs
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
|
|
9
|
+
|
|
10
|
+
function run(target) {
|
|
11
|
+
const child = childProcess.spawn(target, process.argv.slice(2), { stdio: "inherit" })
|
|
12
|
+
child.on("error", (error) => {
|
|
13
|
+
console.error(error.message)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
})
|
|
16
|
+
const forwarders = {}
|
|
17
|
+
for (const signal of forwardedSignals) {
|
|
18
|
+
forwarders[signal] = () => {
|
|
19
|
+
try {
|
|
20
|
+
child.kill(signal)
|
|
21
|
+
} catch {}
|
|
22
|
+
}
|
|
23
|
+
process.on(signal, forwarders[signal])
|
|
24
|
+
}
|
|
25
|
+
child.on("exit", (code, signal) => {
|
|
26
|
+
for (const forwardedSignal of forwardedSignals) process.removeListener(forwardedSignal, forwarders[forwardedSignal])
|
|
27
|
+
if (signal) return process.kill(process.pid, signal)
|
|
28
|
+
process.exit(typeof code === "number" ? code : 0)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const envPath = process.env.DEEPCODE_BIN_PATH
|
|
33
|
+
const scriptDir = path.dirname(fs.realpathSync(__filename))
|
|
34
|
+
const cached = path.join(scriptDir, ".deepcode")
|
|
35
|
+
const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] || os.platform()
|
|
36
|
+
const arch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] || os.arch()
|
|
37
|
+
const base = "@deep-code/cli-" + platform + "-" + arch
|
|
38
|
+
const binary = platform === "windows" ? "deepcode.exe" : "deepcode"
|
|
39
|
+
|
|
40
|
+
function supportsAvx2() {
|
|
41
|
+
if (arch !== "x64") return false
|
|
42
|
+
if (platform === "linux") {
|
|
43
|
+
try {
|
|
44
|
+
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
45
|
+
} catch {
|
|
46
|
+
return false
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (platform === "darwin") {
|
|
50
|
+
try {
|
|
51
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], { encoding: "utf8", timeout: 1500 })
|
|
52
|
+
return result.status === 0 && (result.stdout || "").trim() === "1"
|
|
53
|
+
} catch {
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (platform === "windows") {
|
|
58
|
+
const command =
|
|
59
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
60
|
+
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
61
|
+
try {
|
|
62
|
+
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
|
|
63
|
+
encoding: "utf8",
|
|
64
|
+
timeout: 3000,
|
|
65
|
+
windowsHide: true,
|
|
66
|
+
})
|
|
67
|
+
if (result.status !== 0) continue
|
|
68
|
+
const output = (result.stdout || "").trim().toLowerCase()
|
|
69
|
+
if (output === "true" || output === "1") return true
|
|
70
|
+
if (output === "false" || output === "0") return false
|
|
71
|
+
} catch {
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return false
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const names = (() => {
|
|
80
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
81
|
+
if (platform === "linux") {
|
|
82
|
+
const musl = (() => {
|
|
83
|
+
try {
|
|
84
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
85
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
86
|
+
return ((result.stdout || "") + (result.stderr || "")).toLowerCase().includes("musl")
|
|
87
|
+
} catch {
|
|
88
|
+
return false
|
|
89
|
+
}
|
|
90
|
+
})()
|
|
91
|
+
if (musl)
|
|
92
|
+
return arch === "x64"
|
|
93
|
+
? baseline
|
|
94
|
+
? [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
|
|
95
|
+
: [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
|
|
96
|
+
: [`${base}-musl`, base]
|
|
97
|
+
return arch === "x64"
|
|
98
|
+
? baseline
|
|
99
|
+
? [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
|
|
100
|
+
: [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
|
|
101
|
+
: [base, `${base}-musl`]
|
|
102
|
+
}
|
|
103
|
+
return arch === "x64" ? (baseline ? [`${base}-baseline`, base] : [base, `${base}-baseline`]) : [base]
|
|
104
|
+
})()
|
|
105
|
+
|
|
106
|
+
function findBinary(startDir) {
|
|
107
|
+
let current = startDir
|
|
108
|
+
for (;;) {
|
|
109
|
+
const modules = path.join(current, "node_modules")
|
|
110
|
+
if (fs.existsSync(modules))
|
|
111
|
+
for (const name of names) {
|
|
112
|
+
const candidate = path.join(modules, name, "bin", binary)
|
|
113
|
+
if (fs.existsSync(candidate)) return candidate
|
|
114
|
+
}
|
|
115
|
+
const parent = path.dirname(current)
|
|
116
|
+
if (parent === current) return
|
|
117
|
+
current = parent
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
|
|
122
|
+
if (!resolved) {
|
|
123
|
+
console.error(
|
|
124
|
+
"It seems that your package manager failed to install the right deepcode CLI package. Try manually installing " +
|
|
125
|
+
names.map((name) => `"${name}"`).join(" or ") +
|
|
126
|
+
" package",
|
|
127
|
+
)
|
|
128
|
+
process.exit(1)
|
|
129
|
+
}
|
|
130
|
+
run(resolved)
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deep-code/cli",
|
|
3
|
+
"bin": {
|
|
4
|
+
"deepcode": "./bin/deepcode.cjs"
|
|
5
|
+
},
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node ./postinstall.mjs"
|
|
8
|
+
},
|
|
9
|
+
"version": "0.1.0-beta",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"description": "DeepCode AI - The AI coding agent built for the terminal",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"ai",
|
|
14
|
+
"cli",
|
|
15
|
+
"coding",
|
|
16
|
+
"agent",
|
|
17
|
+
"deepcode",
|
|
18
|
+
"terminal"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/anomalyco/deepcode",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/anomalyco/deepcode.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/anomalyco/deepcode/issues"
|
|
27
|
+
},
|
|
28
|
+
"author": "DeepCode Team",
|
|
29
|
+
"os": [
|
|
30
|
+
"darwin",
|
|
31
|
+
"linux",
|
|
32
|
+
"win32"
|
|
33
|
+
],
|
|
34
|
+
"cpu": [
|
|
35
|
+
"arm64",
|
|
36
|
+
"x64"
|
|
37
|
+
],
|
|
38
|
+
"optionalDependencies": {
|
|
39
|
+
"@deep-code/cli-linux-x64": "0.1.0-beta"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const os = require("os");
|
|
4
|
+
|
|
5
|
+
const platform = { darwin: "darwin", linux: "linux", win32: "windows" }[os.platform()] || os.platform();
|
|
6
|
+
const arch = { x64: "x64", arm64: "arm64", arm: "arm" }[os.arch()] || os.arch();
|
|
7
|
+
|
|
8
|
+
console.log(`DeepCode CLI: Platform detected as ${platform}-${arch}`);
|