artificial-code 1.17.15 → 1.17.16
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 +7 -7
- package/bin/ac.js +17 -6
- package/package.json +10 -20
- package/bin/ac +0 -224
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Artificial Code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Open-source AI coding agent for the terminal.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
4
6
|
|
|
5
7
|
```bash
|
|
6
|
-
|
|
8
|
+
npm install -g artificial-code
|
|
7
9
|
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
Then run:
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
|
-
|
|
14
|
+
ac
|
|
13
15
|
```
|
|
14
|
-
|
|
15
|
-
This project was created using `bun init` in bun v1.2.12. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
package/bin/ac.js
CHANGED
|
@@ -80,11 +80,15 @@ const archMap = {
|
|
|
80
80
|
const platform = platformMap[os.platform()] || os.platform()
|
|
81
81
|
const arch = archMap[os.arch()] || os.arch()
|
|
82
82
|
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
const
|
|
83
|
+
// We first look for our own "artificial-code-<os>-<arch>" packages (binary: "ac" / "ac.exe"),
|
|
84
|
+
// then fall back to the upstream "opencode-<os>-<arch>" packages (binary: "opencode" / "opencode.exe").
|
|
85
|
+
const acPkgPrefix = "artificial-code-" + platform + "-" + arch
|
|
86
|
+
const ocPkgPrefix = "opencode-" + platform + "-" + arch
|
|
87
|
+
const acBinary = platform === "windows" ? "ac.exe" : "ac"
|
|
88
|
+
const ocBinary = platform === "windows" ? "opencode.exe" : "opencode"
|
|
89
|
+
// Legacy alias for the pkgNames / binary resolution below (ac packages take priority)
|
|
90
|
+
const pkgPrefix = acPkgPrefix
|
|
91
|
+
const binary = acBinary
|
|
88
92
|
|
|
89
93
|
function supportsAvx2() {
|
|
90
94
|
if (arch !== "x64") return false
|
|
@@ -188,8 +192,15 @@ function findBinary(startDir) {
|
|
|
188
192
|
for (;;) {
|
|
189
193
|
const modules = path.join(current, "node_modules")
|
|
190
194
|
if (fs.existsSync(modules)) {
|
|
195
|
+
// First try our own artificial-code-* packages (binary named "ac")
|
|
191
196
|
for (const pkg of pkgNames) {
|
|
192
|
-
const candidate = path.join(modules, pkg, "bin",
|
|
197
|
+
const candidate = path.join(modules, pkg, "bin", acBinary)
|
|
198
|
+
if (fs.existsSync(candidate)) return candidate
|
|
199
|
+
}
|
|
200
|
+
// Fall back to upstream opencode-* packages (binary named "opencode")
|
|
201
|
+
const ocPkgNames = pkgNames.map((p) => p.replace(acPkgPrefix, ocPkgPrefix))
|
|
202
|
+
for (const pkg of ocPkgNames) {
|
|
203
|
+
const candidate = path.join(modules, pkg, "bin", ocBinary)
|
|
193
204
|
if (fs.existsSync(candidate)) return candidate
|
|
194
205
|
}
|
|
195
206
|
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "artificial-code",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.16",
|
|
4
4
|
"description": "Artificial Code — open-source AI coding agent for the terminal",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"bin": {
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
"publishConfig": {
|
|
10
|
-
"access": "public"
|
|
11
|
-
},
|
|
6
|
+
"bin": { "ac": "bin/ac.js" },
|
|
7
|
+
"publishConfig": { "access": "public" },
|
|
12
8
|
"optionalDependencies": {
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"opencode-darwin-arm64": "1.17.13",
|
|
20
|
-
"opencode-darwin-x64": "1.17.13",
|
|
21
|
-
"opencode-darwin-x64-baseline": "1.17.13",
|
|
22
|
-
"opencode-windows-x64": "1.17.13",
|
|
23
|
-
"opencode-windows-arm64": "1.17.13",
|
|
24
|
-
"opencode-windows-x64-baseline": "1.17.13"
|
|
9
|
+
"artificial-code-linux-x64": "1.17.16",
|
|
10
|
+
"artificial-code-linux-arm64": "1.17.16",
|
|
11
|
+
"artificial-code-darwin-arm64": "1.17.16",
|
|
12
|
+
"artificial-code-darwin-x64": "1.17.16",
|
|
13
|
+
"artificial-code-windows-x64": "1.17.16",
|
|
14
|
+
"artificial-code-windows-arm64": "1.17.16"
|
|
25
15
|
}
|
|
26
|
-
}
|
|
16
|
+
}
|
package/bin/ac
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Launcher for Artificial Code (ac).
|
|
5
|
-
*
|
|
6
|
-
* Resolves the pre-compiled native binary from the platform-specific
|
|
7
|
-
* opencode-* npm packages (the same packages used by opencode-ai) and
|
|
8
|
-
* runs it, forwarding all arguments and signals.
|
|
9
|
-
*
|
|
10
|
-
* Override the binary path with the AC_BIN_PATH environment variable,
|
|
11
|
-
* or point to a cached binary with the .ac file next to this script.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const childProcess = require("child_process")
|
|
15
|
-
const fs = require("fs")
|
|
16
|
-
const path = require("path")
|
|
17
|
-
const os = require("os")
|
|
18
|
-
|
|
19
|
-
const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
|
|
20
|
-
|
|
21
|
-
function run(target) {
|
|
22
|
-
const child = childProcess.spawn(target, process.argv.slice(2), {
|
|
23
|
-
stdio: "inherit",
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
child.on("error", (error) => {
|
|
27
|
-
console.error(error.message)
|
|
28
|
-
process.exit(1)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
const forwarders = {}
|
|
32
|
-
for (const signal of forwardedSignals) {
|
|
33
|
-
forwarders[signal] = () => {
|
|
34
|
-
try {
|
|
35
|
-
child.kill(signal)
|
|
36
|
-
} catch {
|
|
37
|
-
// The child may have already exited.
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
process.on(signal, forwarders[signal])
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
child.on("exit", (code, signal) => {
|
|
44
|
-
for (const forwardedSignal of forwardedSignals) {
|
|
45
|
-
process.removeListener(forwardedSignal, forwarders[forwardedSignal])
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (signal) {
|
|
49
|
-
process.kill(process.pid, signal)
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
process.exit(typeof code === "number" ? code : 0)
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ── Environment override ──────────────────────────────────────────────────────
|
|
58
|
-
|
|
59
|
-
const envPath = process.env.AC_BIN_PATH
|
|
60
|
-
|
|
61
|
-
const scriptPath = fs.realpathSync(__filename)
|
|
62
|
-
const scriptDir = path.dirname(scriptPath)
|
|
63
|
-
|
|
64
|
-
// A manually cached binary written next to this script takes second priority.
|
|
65
|
-
const cached = path.join(scriptDir, ".ac")
|
|
66
|
-
|
|
67
|
-
// ── Platform detection ────────────────────────────────────────────────────────
|
|
68
|
-
|
|
69
|
-
const platformMap = {
|
|
70
|
-
darwin: "darwin",
|
|
71
|
-
linux: "linux",
|
|
72
|
-
win32: "windows",
|
|
73
|
-
}
|
|
74
|
-
const archMap = {
|
|
75
|
-
x64: "x64",
|
|
76
|
-
arm64: "arm64",
|
|
77
|
-
arm: "arm",
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const platform = platformMap[os.platform()] || os.platform()
|
|
81
|
-
const arch = archMap[os.arch()] || os.arch()
|
|
82
|
-
|
|
83
|
-
// The platform packages use the "opencode-<os>-<arch>" naming convention and
|
|
84
|
-
// contain a binary called "opencode" (or "opencode.exe" on Windows).
|
|
85
|
-
// These are the packages that opencode-ai depends on and that are published to npm.
|
|
86
|
-
const pkgPrefix = "opencode-" + platform + "-" + arch
|
|
87
|
-
const binary = platform === "windows" ? "opencode.exe" : "opencode"
|
|
88
|
-
|
|
89
|
-
function supportsAvx2() {
|
|
90
|
-
if (arch !== "x64") return false
|
|
91
|
-
|
|
92
|
-
if (platform === "linux") {
|
|
93
|
-
try {
|
|
94
|
-
return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
|
|
95
|
-
} catch {
|
|
96
|
-
return false
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (platform === "darwin") {
|
|
101
|
-
try {
|
|
102
|
-
const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
|
|
103
|
-
encoding: "utf8",
|
|
104
|
-
timeout: 1500,
|
|
105
|
-
})
|
|
106
|
-
if (result.status !== 0) return false
|
|
107
|
-
return (result.stdout || "").trim() === "1"
|
|
108
|
-
} catch {
|
|
109
|
-
return false
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (platform === "windows") {
|
|
114
|
-
const cmd =
|
|
115
|
-
'(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
|
|
116
|
-
|
|
117
|
-
for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
|
|
118
|
-
try {
|
|
119
|
-
const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
|
|
120
|
-
encoding: "utf8",
|
|
121
|
-
timeout: 3000,
|
|
122
|
-
windowsHide: true,
|
|
123
|
-
})
|
|
124
|
-
if (result.status !== 0) continue
|
|
125
|
-
const out = (result.stdout || "").trim().toLowerCase()
|
|
126
|
-
if (out === "true" || out === "1") return true
|
|
127
|
-
if (out === "false" || out === "0") return false
|
|
128
|
-
} catch {
|
|
129
|
-
continue
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
return false
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return false
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Build the ordered list of package names to try, from most-specific to least.
|
|
140
|
-
// Mirrors the priority used by opencode-ai's own wrapper.
|
|
141
|
-
const pkgNames = (() => {
|
|
142
|
-
const avx2 = supportsAvx2()
|
|
143
|
-
const baseline = arch === "x64" && !avx2
|
|
144
|
-
|
|
145
|
-
if (platform === "linux") {
|
|
146
|
-
const musl = (() => {
|
|
147
|
-
try {
|
|
148
|
-
if (fs.existsSync("/etc/alpine-release")) return true
|
|
149
|
-
} catch {
|
|
150
|
-
// ignore
|
|
151
|
-
}
|
|
152
|
-
try {
|
|
153
|
-
const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
|
|
154
|
-
const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
|
|
155
|
-
if (text.includes("musl")) return true
|
|
156
|
-
} catch {
|
|
157
|
-
// ignore
|
|
158
|
-
}
|
|
159
|
-
return false
|
|
160
|
-
})()
|
|
161
|
-
|
|
162
|
-
if (musl) {
|
|
163
|
-
if (arch === "x64") {
|
|
164
|
-
if (baseline) return [`${pkgPrefix}-baseline-musl`, `${pkgPrefix}-musl`, `${pkgPrefix}-baseline`, pkgPrefix]
|
|
165
|
-
return [`${pkgPrefix}-musl`, `${pkgPrefix}-baseline-musl`, pkgPrefix, `${pkgPrefix}-baseline`]
|
|
166
|
-
}
|
|
167
|
-
return [`${pkgPrefix}-musl`, pkgPrefix]
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (arch === "x64") {
|
|
171
|
-
if (baseline) return [`${pkgPrefix}-baseline`, pkgPrefix, `${pkgPrefix}-baseline-musl`, `${pkgPrefix}-musl`]
|
|
172
|
-
return [pkgPrefix, `${pkgPrefix}-baseline`, `${pkgPrefix}-musl`, `${pkgPrefix}-baseline-musl`]
|
|
173
|
-
}
|
|
174
|
-
return [pkgPrefix, `${pkgPrefix}-musl`]
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (arch === "x64") {
|
|
178
|
-
if (baseline) return [`${pkgPrefix}-baseline`, pkgPrefix]
|
|
179
|
-
return [pkgPrefix, `${pkgPrefix}-baseline`]
|
|
180
|
-
}
|
|
181
|
-
return [pkgPrefix]
|
|
182
|
-
})()
|
|
183
|
-
|
|
184
|
-
// ── Binary resolution ─────────────────────────────────────────────────────────
|
|
185
|
-
|
|
186
|
-
function findBinary(startDir) {
|
|
187
|
-
let current = startDir
|
|
188
|
-
for (;;) {
|
|
189
|
-
const modules = path.join(current, "node_modules")
|
|
190
|
-
if (fs.existsSync(modules)) {
|
|
191
|
-
for (const pkg of pkgNames) {
|
|
192
|
-
const candidate = path.join(modules, pkg, "bin", binary)
|
|
193
|
-
if (fs.existsSync(candidate)) return candidate
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const parent = path.dirname(current)
|
|
197
|
-
if (parent === current) return undefined
|
|
198
|
-
current = parent
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
|
|
203
|
-
|
|
204
|
-
if (!resolved) {
|
|
205
|
-
console.error(
|
|
206
|
-
[
|
|
207
|
-
"Error: Artificial Code binary not found for your platform.",
|
|
208
|
-
"",
|
|
209
|
-
"This usually means the platform package was not installed.",
|
|
210
|
-
"Try reinstalling:",
|
|
211
|
-
" npm install -g artificial-code",
|
|
212
|
-
" pnpm add -g artificial-code",
|
|
213
|
-
" bun add -g artificial-code",
|
|
214
|
-
"",
|
|
215
|
-
"You can also override the binary path:",
|
|
216
|
-
" AC_BIN_PATH=/path/to/opencode ac",
|
|
217
|
-
"",
|
|
218
|
-
"Expected package (one of): " + pkgNames.join(", "),
|
|
219
|
-
].join("\n"),
|
|
220
|
-
)
|
|
221
|
-
process.exit(1)
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
run(resolved)
|