imagera-code 0.0.0-stage → 1.18.33

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,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 opencode
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/README.md CHANGED
@@ -1,3 +1,13 @@
1
- # Temporary Holding Version
1
+ # Imagera Code
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A coding agent for your terminal, running on Imagera.
4
+
5
+ ```sh
6
+ npm i -g imagera-code
7
+ imagera-code login
8
+ imagera-code
9
+ ```
10
+
11
+ Plans and usage: https://imagera.ai/code · Terms: https://imagera.ai/terms · Support: https://imagera.ai/support
12
+
13
+ Based on OpenCode (MIT). See LICENSE.
@@ -0,0 +1,201 @@
1
+ #!/usr/bin/env node
2
+ // Imagera Code launcher: upstream bin/opencode with the package and binary names changed. It finds the platform
3
+ // package (imagera-code-<os>-<arch>) at run time, so no install script is needed (npm 12 turns those off by default).
4
+
5
+ const childProcess = require("child_process")
6
+ const fs = require("fs")
7
+ const path = require("path")
8
+ const os = require("os")
9
+
10
+ const forwardedSignals = ["SIGINT", "SIGTERM", "SIGHUP"]
11
+
12
+ function run(target) {
13
+ const child = childProcess.spawn(target, process.argv.slice(2), {
14
+ stdio: "inherit",
15
+ })
16
+
17
+ child.on("error", (error) => {
18
+ console.error(error.message)
19
+ process.exit(1)
20
+ })
21
+
22
+ const forwarders = {}
23
+ for (const signal of forwardedSignals) {
24
+ forwarders[signal] = () => {
25
+ try {
26
+ child.kill(signal)
27
+ } catch {
28
+ // The child may have already exited.
29
+ }
30
+ }
31
+ process.on(signal, forwarders[signal])
32
+ }
33
+
34
+ child.on("exit", (code, signal) => {
35
+ for (const forwardedSignal of forwardedSignals) {
36
+ process.removeListener(forwardedSignal, forwarders[forwardedSignal])
37
+ }
38
+
39
+ if (signal) {
40
+ process.kill(process.pid, signal)
41
+ return
42
+ }
43
+
44
+ process.exit(typeof code === "number" ? code : 0)
45
+ })
46
+ }
47
+
48
+ const envPath = process.env.IMAGERA_CODE_BIN_PATH
49
+
50
+ const scriptPath = fs.realpathSync(__filename)
51
+ const scriptDir = path.dirname(scriptPath)
52
+
53
+ //
54
+ const cached = path.join(scriptDir, ".imagera-code")
55
+
56
+ const platformMap = {
57
+ darwin: "darwin",
58
+ linux: "linux",
59
+ win32: "windows",
60
+ }
61
+ const archMap = {
62
+ x64: "x64",
63
+ arm64: "arm64",
64
+ arm: "arm",
65
+ }
66
+
67
+ let platform = platformMap[os.platform()]
68
+ if (!platform) {
69
+ platform = os.platform()
70
+ }
71
+ let arch = archMap[os.arch()]
72
+ if (!arch) {
73
+ arch = os.arch()
74
+ }
75
+ const base = "imagera-code-" + platform + "-" + arch
76
+ const binary = platform === "windows" ? "imagera-code.exe" : "imagera-code"
77
+
78
+ function supportsAvx2() {
79
+ if (arch !== "x64") return false
80
+
81
+ if (platform === "linux") {
82
+ try {
83
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"))
84
+ } catch {
85
+ return false
86
+ }
87
+ }
88
+
89
+ if (platform === "darwin") {
90
+ try {
91
+ const result = childProcess.spawnSync("sysctl", ["-n", "hw.optional.avx2_0"], {
92
+ encoding: "utf8",
93
+ timeout: 1500,
94
+ })
95
+ if (result.status !== 0) return false
96
+ return (result.stdout || "").trim() === "1"
97
+ } catch {
98
+ return false
99
+ }
100
+ }
101
+
102
+ if (platform === "windows") {
103
+ const cmd =
104
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)'
105
+
106
+ for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
107
+ try {
108
+ const result = childProcess.spawnSync(exe, ["-NoProfile", "-NonInteractive", "-Command", cmd], {
109
+ encoding: "utf8",
110
+ timeout: 3000,
111
+ windowsHide: true,
112
+ })
113
+ if (result.status !== 0) continue
114
+ const out = (result.stdout || "").trim().toLowerCase()
115
+ if (out === "true" || out === "1") return true
116
+ if (out === "false" || out === "0") return false
117
+ } catch {
118
+ continue
119
+ }
120
+ }
121
+
122
+ return false
123
+ }
124
+
125
+ return false
126
+ }
127
+
128
+ const names = (() => {
129
+ const avx2 = supportsAvx2()
130
+ const baseline = arch === "x64" && !avx2
131
+
132
+ if (platform === "linux") {
133
+ const musl = (() => {
134
+ try {
135
+ if (fs.existsSync("/etc/alpine-release")) return true
136
+ } catch {
137
+ // ignore
138
+ }
139
+
140
+ try {
141
+ const result = childProcess.spawnSync("ldd", ["--version"], { encoding: "utf8" })
142
+ const text = ((result.stdout || "") + (result.stderr || "")).toLowerCase()
143
+ if (text.includes("musl")) return true
144
+ } catch {
145
+ // ignore
146
+ }
147
+
148
+ return false
149
+ })()
150
+
151
+ if (musl) {
152
+ if (arch === "x64") {
153
+ if (baseline) return [`${base}-baseline-musl`, `${base}-musl`, `${base}-baseline`, base]
154
+ return [`${base}-musl`, `${base}-baseline-musl`, base, `${base}-baseline`]
155
+ }
156
+ return [`${base}-musl`, base]
157
+ }
158
+
159
+ if (arch === "x64") {
160
+ if (baseline) return [`${base}-baseline`, base, `${base}-baseline-musl`, `${base}-musl`]
161
+ return [base, `${base}-baseline`, `${base}-musl`, `${base}-baseline-musl`]
162
+ }
163
+ return [base, `${base}-musl`]
164
+ }
165
+
166
+ if (arch === "x64") {
167
+ if (baseline) return [`${base}-baseline`, base]
168
+ return [base, `${base}-baseline`]
169
+ }
170
+ return [base]
171
+ })()
172
+
173
+ function findBinary(startDir) {
174
+ let current = startDir
175
+ for (;;) {
176
+ const modules = path.join(current, "node_modules")
177
+ if (fs.existsSync(modules)) {
178
+ for (const name of names) {
179
+ const candidate = path.join(modules, name, "bin", binary)
180
+ if (fs.existsSync(candidate)) return candidate
181
+ }
182
+ }
183
+ const parent = path.dirname(current)
184
+ if (parent === current) {
185
+ return
186
+ }
187
+ current = parent
188
+ }
189
+ }
190
+
191
+ const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir))
192
+ if (!resolved) {
193
+ console.error(
194
+ "It seems that your package manager failed to install the right version of Imagera Code for your platform. You can try manually installing " +
195
+ names.map((n) => `\"${n}\"`).join(" or ") +
196
+ " package",
197
+ )
198
+ process.exit(1)
199
+ }
200
+
201
+ run(resolved)
package/package.json CHANGED
@@ -1,6 +1,33 @@
1
1
  {
2
2
  "name": "imagera-code",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.18.33",
4
+ "license": "MIT",
5
+ "homepage": "https://imagera.ai/code",
6
+ "description": "Imagera Code: a coding agent for your terminal.",
7
+ "bin": {
8
+ "imagera-code": "./bin/imagera-code"
9
+ },
10
+ "os": [
11
+ "darwin",
12
+ "linux",
13
+ "win32"
14
+ ],
15
+ "cpu": [
16
+ "arm64",
17
+ "x64"
18
+ ],
19
+ "optionalDependencies": {
20
+ "imagera-code-windows-x64-baseline": "1.18.33",
21
+ "imagera-code-linux-x64-baseline": "1.18.33",
22
+ "imagera-code-linux-x64-musl": "1.18.33",
23
+ "imagera-code-linux-arm64-musl": "1.18.33",
24
+ "imagera-code-darwin-arm64": "1.18.33",
25
+ "imagera-code-windows-arm64": "1.18.33",
26
+ "imagera-code-darwin-x64-baseline": "1.18.33",
27
+ "imagera-code-linux-arm64": "1.18.33",
28
+ "imagera-code-linux-x64-baseline-musl": "1.18.33",
29
+ "imagera-code-darwin-x64": "1.18.33",
30
+ "imagera-code-linux-x64": "1.18.33",
31
+ "imagera-code-windows-x64": "1.18.33"
32
+ }
33
+ }