dfcode 3.3.17-beta.2 → 3.3.17
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/bin/dfcode +81 -17
- package/package.json +15 -18
package/bin/dfcode
CHANGED
|
@@ -15,9 +15,9 @@ const os = require("os")
|
|
|
15
15
|
process.on("SIGINT", () => {})
|
|
16
16
|
|
|
17
17
|
function run(target) {
|
|
18
|
-
const
|
|
18
|
+
const runPlatform = process.env.DFCODE_TEST_PLATFORM || os.platform()
|
|
19
19
|
const env = { ...process.env }
|
|
20
|
-
if (
|
|
20
|
+
if (runPlatform === "win32" && env.BUN_JSC_useJIT === undefined) env.BUN_JSC_useJIT = "0"
|
|
21
21
|
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
22
22
|
stdio: "inherit",
|
|
23
23
|
env,
|
|
@@ -67,28 +67,92 @@ const archMap = {
|
|
|
67
67
|
arm: "arm",
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
let arch = archMap[os.arch()]
|
|
75
|
-
if (!arch) {
|
|
76
|
-
arch = os.arch()
|
|
77
|
-
}
|
|
70
|
+
const platformName = process.env.DFCODE_TEST_PLATFORM || os.platform()
|
|
71
|
+
const archName = process.env.DFCODE_TEST_ARCH || os.arch()
|
|
72
|
+
const platform = platformMap[platformName] || platformName
|
|
73
|
+
const arch = archMap[archName] || archName
|
|
78
74
|
const base = "dfcode-" + platform + "-" + arch
|
|
79
75
|
const binary = platform === "windows" ? "dfcode.exe" : "dfcode"
|
|
80
76
|
|
|
77
|
+
function supportsAvx2() {
|
|
78
|
+
if (arch !== "x64") return false
|
|
79
|
+
|
|
80
|
+
const override = process.env.DFCODE_TEST_AVX2
|
|
81
|
+
if (override === "1" || override === "true") return true
|
|
82
|
+
if (override === "0" || override === "false") return false
|
|
83
|
+
|
|
84
|
+
if (platform === "linux") {
|
|
85
|
+
const result = childProcess.spawnSync("cat", ["/proc/cpuinfo"], { encoding: "utf8" })
|
|
86
|
+
return result.status === 0 && /(^|\s)avx2(\s|$)/i.test(result.stdout || "")
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (platform === "darwin") {
|
|
90
|
+
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
91
|
+
encoding: "utf8",
|
|
92
|
+
timeout: 1500,
|
|
93
|
+
})
|
|
94
|
+
if (result.status !== 0) return false
|
|
95
|
+
return (result.stdout || "").trim() === "1"
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (platform === "windows") {
|
|
99
|
+
const command =
|
|
100
|
+
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
101
|
+
|
|
102
|
+
for (const executable of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
103
|
+
const result = childProcess.spawnSync(executable, ["-NoProfile", "-NonInteractive", "-Command", command], {
|
|
104
|
+
encoding: "utf8",
|
|
105
|
+
timeout: 3000,
|
|
106
|
+
windowsHide: true,
|
|
107
|
+
})
|
|
108
|
+
if (result.status !== 0 || result.error) continue
|
|
109
|
+
const output = (result.stdout || "").trim().toLowerCase()
|
|
110
|
+
if (output === "true" || output === "1") return true
|
|
111
|
+
if (output === "false" || output === "0") return false
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return false
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function isMusl() {
|
|
119
|
+
if (platform !== "linux") return false
|
|
120
|
+
|
|
121
|
+
const override = process.env.DFCODE_TEST_LIBC?.toLowerCase()
|
|
122
|
+
if (override) return override === "musl"
|
|
123
|
+
|
|
124
|
+
if (fs.existsSync("/etc/alpine-release")) return true
|
|
125
|
+
|
|
126
|
+
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
127
|
+
return `${result.stdout || ""}${result.stderr || ""}`.toLowerCase().includes("musl")
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function packageNames() {
|
|
131
|
+
const baseline = arch === "x64" && !supportsAvx2()
|
|
132
|
+
|
|
133
|
+
if (platform === "linux") {
|
|
134
|
+
if (isMusl()) {
|
|
135
|
+
if (arch === "x64")
|
|
136
|
+
return baseline ? [`${base}-baseline-musl`] : [`${base}-musl`, `${base}-baseline-musl`]
|
|
137
|
+
return [`${base}-musl`]
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (arch === "x64") return baseline ? [`${base}-baseline`] : [base, `${base}-baseline`]
|
|
141
|
+
return [base]
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (arch === "x64") return baseline ? [`${base}-baseline`] : [base, `${base}-baseline`]
|
|
145
|
+
return [base]
|
|
146
|
+
}
|
|
147
|
+
|
|
81
148
|
function findBinary(startDir) {
|
|
82
149
|
let current = startDir
|
|
150
|
+
const names = packageNames()
|
|
83
151
|
for (;;) {
|
|
84
152
|
const modules = path.join(current, "node_modules")
|
|
85
153
|
if (fs.existsSync(modules)) {
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
if (!entry.startsWith(base)) {
|
|
89
|
-
continue
|
|
90
|
-
}
|
|
91
|
-
const candidate = path.join(modules, entry, "bin", binary)
|
|
154
|
+
for (const name of names) {
|
|
155
|
+
const candidate = path.join(modules, name, "bin", binary)
|
|
92
156
|
if (fs.existsSync(candidate)) {
|
|
93
157
|
return candidate
|
|
94
158
|
}
|
|
@@ -106,7 +170,7 @@ const resolved = findBinary(scriptDir)
|
|
|
106
170
|
if (!resolved) {
|
|
107
171
|
console.error(
|
|
108
172
|
'It seems that your package manager failed to install the right version of the dfcode CLI for your platform. You can try manually installing the "' +
|
|
109
|
-
|
|
173
|
+
packageNames().join('" or "') +
|
|
110
174
|
'" package',
|
|
111
175
|
)
|
|
112
176
|
process.exit(1)
|
package/package.json
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfcode",
|
|
3
|
-
"version": "3.3.17-beta.2",
|
|
4
|
-
"description": "AI-powered coding assistant - TUI interface",
|
|
5
3
|
"bin": {
|
|
6
4
|
"dfcode": "./bin/dfcode"
|
|
7
5
|
},
|
|
8
6
|
"scripts": {
|
|
9
|
-
"postinstall": "node ./postinstall.mjs"
|
|
7
|
+
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
10
8
|
},
|
|
9
|
+
"version": "3.3.17",
|
|
11
10
|
"optionalDependencies": {
|
|
12
|
-
"dfcode-
|
|
13
|
-
"dfcode-
|
|
14
|
-
"dfcode-
|
|
15
|
-
"dfcode-linux-arm64": "3.3.17
|
|
16
|
-
"dfcode-linux-
|
|
17
|
-
"dfcode-linux-x64": "3.3.17
|
|
18
|
-
"dfcode-
|
|
19
|
-
"dfcode-
|
|
20
|
-
"dfcode-
|
|
21
|
-
"dfcode-windows-x64": "3.3.17
|
|
22
|
-
"dfcode-windows-x64-baseline": "3.3.17
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
"keywords": ["ai", "coding", "assistant", "tui", "llm", "claude", "openai", "gpt"]
|
|
26
|
-
}
|
|
11
|
+
"dfcode-linux-arm64": "3.3.17",
|
|
12
|
+
"dfcode-linux-x64": "3.3.17",
|
|
13
|
+
"dfcode-linux-x64-baseline": "3.3.17",
|
|
14
|
+
"dfcode-linux-arm64-musl": "3.3.17",
|
|
15
|
+
"dfcode-linux-x64-musl": "3.3.17",
|
|
16
|
+
"dfcode-linux-x64-baseline-musl": "3.3.17",
|
|
17
|
+
"dfcode-darwin-arm64": "3.3.17",
|
|
18
|
+
"dfcode-darwin-x64": "3.3.17",
|
|
19
|
+
"dfcode-darwin-x64-baseline": "3.3.17",
|
|
20
|
+
"dfcode-windows-x64": "3.3.17",
|
|
21
|
+
"dfcode-windows-x64-baseline": "3.3.17"
|
|
22
|
+
}
|
|
23
|
+
}
|