@thesolaceproject/emberharmony 1.2.1
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/README.md +149 -0
- package/bin/emberharmony +161 -0
- package/package.json +39 -0
- package/postinstall.mjs +156 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sydney Renee
|
|
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
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://solace.ofharmony.ai">
|
|
3
|
+
<picture>
|
|
4
|
+
<source srcset="packages/console/app/src/asset/logo-ornate-dark.svg" media="(prefers-color-scheme: dark)">
|
|
5
|
+
<source srcset="packages/console/app/src/asset/logo-ornate-light.svg" media="(prefers-color-scheme: light)">
|
|
6
|
+
<img src="packages/console/app/src/asset/logo-ornate-light.svg" alt="EmberHarmony logo">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
<p align="center">The open source AI coding agent.</p>
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://discord.gg/EdF8f7JR"><img alt="Discord" src="https://img.shields.io/discord/1391832426048651334?style=flat-square&label=discord" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/package/@thesolaceproject/emberharmony"><img alt="npm" src="https://img.shields.io/npm/v/%40thesolaceproject%2Femberharmony?style=flat-square" /></a>
|
|
14
|
+
<a href="https://github.com/SolaceHarmony/emberharmony/actions/workflows/publish.yml"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/SolaceHarmony/emberharmony/publish.yml?style=flat-square&branch=dev" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p align="center">
|
|
18
|
+
<a href="README.md">English</a> |
|
|
19
|
+
<a href="README.zh.md">简体中文</a> |
|
|
20
|
+
<a href="README.zht.md">繁體中文</a> |
|
|
21
|
+
<a href="README.ko.md">한국어</a> |
|
|
22
|
+
<a href="README.de.md">Deutsch</a> |
|
|
23
|
+
<a href="README.es.md">Español</a> |
|
|
24
|
+
<a href="README.fr.md">Français</a> |
|
|
25
|
+
<a href="README.it.md">Italiano</a> |
|
|
26
|
+
<a href="README.da.md">Dansk</a> |
|
|
27
|
+
<a href="README.ja.md">日本語</a> |
|
|
28
|
+
<a href="README.pl.md">Polski</a> |
|
|
29
|
+
<a href="README.ru.md">Русский</a> |
|
|
30
|
+
<a href="README.ar.md">العربية</a> |
|
|
31
|
+
<a href="README.no.md">Norsk</a> |
|
|
32
|
+
<a href="README.br.md">Português (Brasil)</a> |
|
|
33
|
+
<a href="README.th.md">ไทย</a>
|
|
34
|
+
</p>
|
|
35
|
+
|
|
36
|
+
[](https://solace.ofharmony.ai)
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# YOLO
|
|
44
|
+
curl -fsSL https://raw.githubusercontent.com/SolaceHarmony/emberharmony/dev/install | bash
|
|
45
|
+
|
|
46
|
+
# Package managers
|
|
47
|
+
npm i -g @thesolaceproject/emberharmony@latest # or bun/pnpm/yarn
|
|
48
|
+
scoop install emberharmony # Windows
|
|
49
|
+
choco install emberharmony # Windows
|
|
50
|
+
paru -S emberharmony-bin # Arch Linux
|
|
51
|
+
mise use -g emberharmony # Any OS
|
|
52
|
+
nix run nixpkgs#emberharmony # or github:SolaceHarmony/emberharmony for latest dev branch
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
> [!TIP]
|
|
56
|
+
> Remove versions older than 0.1.x before installing.
|
|
57
|
+
|
|
58
|
+
#### Local Build + Install (No CI)
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
bun install
|
|
62
|
+
npm run pack:local
|
|
63
|
+
# prints a .tgz path you can install, e.g.
|
|
64
|
+
# npm i -g /absolute/path/to/emberharmony-1.0.0.tgz
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Desktop App (BETA)
|
|
68
|
+
|
|
69
|
+
EmberHarmony is also available as a desktop application. Download directly from the [releases page](https://github.com/SolaceHarmony/emberharmony/releases) or [solace.ofharmony.ai/download](https://github.com/SolaceHarmony/emberharmony/releases).
|
|
70
|
+
|
|
71
|
+
| Platform | Download |
|
|
72
|
+
| --------------------- | ----------------------------------------- |
|
|
73
|
+
| macOS (Apple Silicon) | `emberharmony-desktop-darwin-aarch64.dmg` |
|
|
74
|
+
| macOS (Intel) | `emberharmony-desktop-darwin-x64.dmg` |
|
|
75
|
+
| Windows | `emberharmony-desktop-windows-x64.exe` |
|
|
76
|
+
| Linux | `.deb`, `.rpm`, or AppImage |
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Windows (Scoop)
|
|
80
|
+
scoop bucket add extras; scoop install extras@thesolaceproject/emberharmony-desktop
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### Installation Directory
|
|
84
|
+
|
|
85
|
+
The install script respects the following priority order for the installation path:
|
|
86
|
+
|
|
87
|
+
1. `$EMBERHARMONY_INSTALL_DIR` - Custom installation directory (preferred)
|
|
88
|
+
2. `$EMBERHARMONY_INSTALL_DIR` - Backward compat
|
|
89
|
+
3. `$XDG_BIN_DIR` - XDG Base Directory Specification compliant path
|
|
90
|
+
4. `$HOME/bin` - Standard user binary directory (if exists or can be created)
|
|
91
|
+
5. `$HOME/.emberharmony/bin` - Default fallback
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Examples
|
|
95
|
+
EMBERHARMONY_INSTALL_DIR=/usr/local/bin curl -fsSL https://raw.githubusercontent.com/SolaceHarmony/emberharmony/dev/install | bash
|
|
96
|
+
XDG_BIN_DIR=$HOME/.local/bin curl -fsSL https://raw.githubusercontent.com/SolaceHarmony/emberharmony/dev/install | bash
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Agents
|
|
100
|
+
|
|
101
|
+
EmberHarmony includes two built-in agents you can switch between with the `Tab` key.
|
|
102
|
+
|
|
103
|
+
- **build** - Default, full access agent for development work
|
|
104
|
+
- **plan** - Read-only agent for analysis and code exploration
|
|
105
|
+
- Denies file edits by default
|
|
106
|
+
- Asks permission before running bash commands
|
|
107
|
+
- Ideal for exploring unfamiliar codebases or planning changes
|
|
108
|
+
|
|
109
|
+
Also, included is a **general** subagent for complex searches and multistep tasks.
|
|
110
|
+
This is used internally and can be invoked using `@general` in messages.
|
|
111
|
+
|
|
112
|
+
Learn more about [agents](https://solace.ofharmony.ai/docs/agents).
|
|
113
|
+
|
|
114
|
+
### Documentation
|
|
115
|
+
|
|
116
|
+
For more info on how to configure EmberHarmony [**head over to our docs**](https://solace.ofharmony.ai/docs).
|
|
117
|
+
|
|
118
|
+
### Contributing
|
|
119
|
+
|
|
120
|
+
If you're interested in contributing to EmberHarmony, please read our [contributing docs](./CONTRIBUTING.md) before submitting a pull request.
|
|
121
|
+
|
|
122
|
+
### Building on EmberHarmony
|
|
123
|
+
|
|
124
|
+
If you are working on a project that's related to EmberHarmony and is using "emberharmony" or "emberharmony" as a part of its name, please add a note in your README to clarify that it is not built by The Solace Project and is not affiliated with us in any way.
|
|
125
|
+
|
|
126
|
+
### FAQ
|
|
127
|
+
|
|
128
|
+
#### How is this different from Claude Code?
|
|
129
|
+
|
|
130
|
+
It's very similar to Claude Code in terms of capability. Here are the key differences:
|
|
131
|
+
|
|
132
|
+
- 100% open source
|
|
133
|
+
- Not coupled to any provider. EmberHarmony can be used with Claude, OpenAI, Google, or even local models. As models evolve the gaps between them will close and pricing will drop, so being provider-agnostic is important.
|
|
134
|
+
- Out of the box LSP support
|
|
135
|
+
- A focus on TUI — we are going to push the limits of what's possible in the terminal.
|
|
136
|
+
- A client/server architecture. This for example can allow EmberHarmony to run on your computer, while you can drive it remotely from a mobile app. The TUI frontend is just one of the possible clients.
|
|
137
|
+
|
|
138
|
+
### Acknowledgments
|
|
139
|
+
|
|
140
|
+
EmberHarmony is a fork of [EmberHarmony](https://github.com/sst/emberharmony) by the [SST](https://sst.dev) team. We are deeply grateful for their foundational work in building an exceptional open source AI coding agent. This project would not exist without their vision and engineering.
|
|
141
|
+
|
|
142
|
+
### Maintainer
|
|
143
|
+
|
|
144
|
+
**Sydney Renee** — sydney@solace.ofharmony.ai
|
|
145
|
+
[The Solace Project](https://solace.ofharmony.ai)
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
**Join our community** [Discord](https://discord.gg/EdF8f7JR) | [GitHub Discussions](https://github.com/SolaceHarmony/emberharmony/discussions)
|
package/bin/emberharmony
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
function run(target) {
|
|
9
|
+
const result = childProcess.spawnSync(target, process.argv.slice(2), {
|
|
10
|
+
stdio: "inherit",
|
|
11
|
+
})
|
|
12
|
+
if (result.error) {
|
|
13
|
+
console.error(result.error.message)
|
|
14
|
+
process.exit(1)
|
|
15
|
+
}
|
|
16
|
+
const code = typeof result.status === "number" ? result.status : 0
|
|
17
|
+
process.exit(code)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const envPath = process.env.EMBERHARMONY_BIN_PATH
|
|
21
|
+
if (envPath) {
|
|
22
|
+
run(envPath)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const scriptPath = fs.realpathSync(__filename)
|
|
26
|
+
const scriptDir = path.dirname(scriptPath)
|
|
27
|
+
const pkgDir = path.join(scriptDir, "..")
|
|
28
|
+
|
|
29
|
+
function readPackageName() {
|
|
30
|
+
try {
|
|
31
|
+
const pkgPath = path.join(scriptDir, "..", "package.json")
|
|
32
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
|
|
33
|
+
const name = typeof pkg.name === "string" ? pkg.name : "emberharmony"
|
|
34
|
+
return name.includes("/") ? name.split("/").pop() : name
|
|
35
|
+
} catch {
|
|
36
|
+
return "emberharmony"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readCpuInfo() {
|
|
41
|
+
const path = "/proc/cpuinfo"
|
|
42
|
+
if (!fs.existsSync(path)) return ""
|
|
43
|
+
return fs.readFileSync(path, "utf8")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function hasAvx2() {
|
|
47
|
+
const info = readCpuInfo()
|
|
48
|
+
if (!info) return true
|
|
49
|
+
return info.includes("avx2")
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isMusl(arch) {
|
|
53
|
+
const checks = []
|
|
54
|
+
if (arch === "x64") checks.push("/lib/ld-musl-x86_64.so.1")
|
|
55
|
+
if (arch === "arm64") checks.push("/lib/ld-musl-aarch64.so.1")
|
|
56
|
+
if (arch === "arm") checks.push("/lib/ld-musl-arm.so.1")
|
|
57
|
+
checks.push("/lib/ld-musl.so.1")
|
|
58
|
+
return checks.some((item) => fs.existsSync(item))
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function localCandidates(platform, arch) {
|
|
62
|
+
const list = []
|
|
63
|
+
const base = platform + "-" + arch
|
|
64
|
+
if (platform !== "linux") {
|
|
65
|
+
list.push(base)
|
|
66
|
+
list.push(base + "-baseline")
|
|
67
|
+
return list
|
|
68
|
+
}
|
|
69
|
+
const musl = isMusl(arch)
|
|
70
|
+
const baseline = arch === "x64" && !hasAvx2()
|
|
71
|
+
const suffix = (baseline ? "-baseline" : "") + (musl ? "-musl" : "")
|
|
72
|
+
list.push(base + suffix)
|
|
73
|
+
if (musl) {
|
|
74
|
+
list.push(base + (baseline ? "-baseline" : ""))
|
|
75
|
+
}
|
|
76
|
+
if (baseline) {
|
|
77
|
+
if (musl) list.push(base + "-musl")
|
|
78
|
+
list.push(base)
|
|
79
|
+
}
|
|
80
|
+
if (!baseline && !musl) {
|
|
81
|
+
list.push(base + "-baseline")
|
|
82
|
+
}
|
|
83
|
+
return Array.from(new Set(list))
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function findLocalBinary(startDir, platform, arch, binaryName) {
|
|
87
|
+
const binDir = path.join(startDir, "bin")
|
|
88
|
+
if (!fs.existsSync(binDir)) {
|
|
89
|
+
return
|
|
90
|
+
}
|
|
91
|
+
const variants = localCandidates(platform, arch)
|
|
92
|
+
for (const variant of variants) {
|
|
93
|
+
const candidate = path.join(binDir, variant, binaryName)
|
|
94
|
+
if (fs.existsSync(candidate)) {
|
|
95
|
+
return candidate
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const platformMap = {
|
|
101
|
+
darwin: "darwin",
|
|
102
|
+
linux: "linux",
|
|
103
|
+
win32: "windows",
|
|
104
|
+
}
|
|
105
|
+
const archMap = {
|
|
106
|
+
x64: "x64",
|
|
107
|
+
arm64: "arm64",
|
|
108
|
+
arm: "arm",
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let platform = platformMap[os.platform()]
|
|
112
|
+
if (!platform) {
|
|
113
|
+
platform = os.platform()
|
|
114
|
+
}
|
|
115
|
+
let arch = archMap[os.arch()]
|
|
116
|
+
if (!arch) {
|
|
117
|
+
arch = os.arch()
|
|
118
|
+
}
|
|
119
|
+
const base = readPackageName() + "-" + platform + "-" + arch
|
|
120
|
+
const binary = platform === "windows" ? "emberharmony.exe" : "emberharmony"
|
|
121
|
+
|
|
122
|
+
function findBinary(startDir) {
|
|
123
|
+
let current = startDir
|
|
124
|
+
for (;;) {
|
|
125
|
+
const modules = path.join(current, "node_modules")
|
|
126
|
+
if (fs.existsSync(modules)) {
|
|
127
|
+
const entries = fs.readdirSync(modules)
|
|
128
|
+
for (const entry of entries) {
|
|
129
|
+
if (!entry.startsWith(base)) {
|
|
130
|
+
continue
|
|
131
|
+
}
|
|
132
|
+
const candidate = path.join(modules, entry, "bin", binary)
|
|
133
|
+
if (fs.existsSync(candidate)) {
|
|
134
|
+
return candidate
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const parent = path.dirname(current)
|
|
139
|
+
if (parent === current) {
|
|
140
|
+
return
|
|
141
|
+
}
|
|
142
|
+
current = parent
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const local = findLocalBinary(pkgDir, platform, arch, binary)
|
|
147
|
+
if (local) {
|
|
148
|
+
run(local)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const resolved = findBinary(pkgDir)
|
|
152
|
+
if (!resolved) {
|
|
153
|
+
console.error(
|
|
154
|
+
'It seems that your package manager failed to install the right version of the EmberHarmony CLI for your platform. You can try manually installing the "' +
|
|
155
|
+
base +
|
|
156
|
+
'" package',
|
|
157
|
+
)
|
|
158
|
+
process.exit(1)
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
run(resolved)
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@thesolaceproject/emberharmony",
|
|
3
|
+
"description": "EmberHarmony — the open source AI coding agent",
|
|
4
|
+
"homepage": "https://solace.ofharmony.ai",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/SolaceHarmony/emberharmony"
|
|
8
|
+
},
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/SolaceHarmony/emberharmony/issues"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"bin": {
|
|
14
|
+
"emberharmony": "bin/emberharmony"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
|
|
18
|
+
},
|
|
19
|
+
"version": "1.2.1",
|
|
20
|
+
"optionalDependencies": {
|
|
21
|
+
"@thesolaceproject/emberharmony-windows-x64": "1.2.1",
|
|
22
|
+
"@thesolaceproject/emberharmony-darwin-x64": "1.2.1",
|
|
23
|
+
"@thesolaceproject/emberharmony-darwin-x64-baseline": "1.2.1",
|
|
24
|
+
"@thesolaceproject/emberharmony-windows-x64-baseline": "1.2.1",
|
|
25
|
+
"@thesolaceproject/emberharmony-linux-arm64-musl": "1.2.1",
|
|
26
|
+
"@thesolaceproject/emberharmony-linux-x64-baseline": "1.2.1",
|
|
27
|
+
"@thesolaceproject/emberharmony-darwin-arm64": "1.2.1",
|
|
28
|
+
"@thesolaceproject/emberharmony-linux-arm64": "1.2.1",
|
|
29
|
+
"@thesolaceproject/emberharmony-linux-x64-musl": "1.2.1",
|
|
30
|
+
"@thesolaceproject/emberharmony-linux-x64-baseline-musl": "1.2.1",
|
|
31
|
+
"@thesolaceproject/emberharmony-linux-x64": "1.2.1"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"bin/**",
|
|
35
|
+
"postinstall.mjs",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE"
|
|
38
|
+
]
|
|
39
|
+
}
|
package/postinstall.mjs
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from "fs"
|
|
4
|
+
import path from "path"
|
|
5
|
+
import os from "os"
|
|
6
|
+
import { fileURLToPath } from "url"
|
|
7
|
+
import { createRequire } from "module"
|
|
8
|
+
|
|
9
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const require = createRequire(import.meta.url)
|
|
11
|
+
|
|
12
|
+
function readPackageName() {
|
|
13
|
+
try {
|
|
14
|
+
const pkgPath = path.join(__dirname, "package.json")
|
|
15
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
|
|
16
|
+
const name = typeof pkg.name === "string" ? pkg.name : "emberharmony"
|
|
17
|
+
return name.includes("/") ? name.split("/").pop() : name
|
|
18
|
+
} catch {
|
|
19
|
+
return "emberharmony"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function detectPlatformAndArch() {
|
|
24
|
+
// Map platform names
|
|
25
|
+
let platform
|
|
26
|
+
switch (os.platform()) {
|
|
27
|
+
case "darwin":
|
|
28
|
+
platform = "darwin"
|
|
29
|
+
break
|
|
30
|
+
case "linux":
|
|
31
|
+
platform = "linux"
|
|
32
|
+
break
|
|
33
|
+
case "win32":
|
|
34
|
+
platform = "windows"
|
|
35
|
+
break
|
|
36
|
+
default:
|
|
37
|
+
platform = os.platform()
|
|
38
|
+
break
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Map architecture names
|
|
42
|
+
let arch
|
|
43
|
+
switch (os.arch()) {
|
|
44
|
+
case "x64":
|
|
45
|
+
arch = "x64"
|
|
46
|
+
break
|
|
47
|
+
case "arm64":
|
|
48
|
+
arch = "arm64"
|
|
49
|
+
break
|
|
50
|
+
case "arm":
|
|
51
|
+
arch = "arm"
|
|
52
|
+
break
|
|
53
|
+
default:
|
|
54
|
+
arch = os.arch()
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return { platform, arch }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function findBinary() {
|
|
62
|
+
const { platform, arch } = detectPlatformAndArch()
|
|
63
|
+
const base = readPackageName()
|
|
64
|
+
const packageName = `${base}-${platform}-${arch}`
|
|
65
|
+
const binaryName = platform === "windows" ? "emberharmony.exe" : "emberharmony"
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
// Use require.resolve to find the package
|
|
69
|
+
const packageJsonPath = require.resolve(`${packageName}/package.json`)
|
|
70
|
+
const packageDir = path.dirname(packageJsonPath)
|
|
71
|
+
const binaryPath = path.join(packageDir, "bin", binaryName)
|
|
72
|
+
|
|
73
|
+
if (!fs.existsSync(binaryPath)) {
|
|
74
|
+
throw new Error(`Binary not found at ${binaryPath}`)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { binaryPath, binaryName }
|
|
78
|
+
} catch (error) {
|
|
79
|
+
throw new Error(`Could not find package ${packageName}: ${error.message}`)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function prepareBinDirectory(binaryName) {
|
|
84
|
+
const binDir = path.join(__dirname, "bin")
|
|
85
|
+
const targetPath = path.join(binDir, binaryName)
|
|
86
|
+
|
|
87
|
+
// Ensure bin directory exists
|
|
88
|
+
if (!fs.existsSync(binDir)) {
|
|
89
|
+
fs.mkdirSync(binDir, { recursive: true })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Remove existing binary/symlink if it exists
|
|
93
|
+
if (fs.existsSync(targetPath)) {
|
|
94
|
+
fs.unlinkSync(targetPath)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return { binDir, targetPath }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function symlinkBinary(sourcePath, binaryName) {
|
|
101
|
+
const { targetPath } = prepareBinDirectory(binaryName)
|
|
102
|
+
|
|
103
|
+
fs.symlinkSync(sourcePath, targetPath)
|
|
104
|
+
console.log(`emberharmony binary symlinked: ${targetPath} -> ${sourcePath}`)
|
|
105
|
+
|
|
106
|
+
// Verify the file exists after operation
|
|
107
|
+
if (!fs.existsSync(targetPath)) {
|
|
108
|
+
throw new Error(`Failed to symlink binary to ${targetPath}`)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function findLocalBinary() {
|
|
113
|
+
const binDir = path.join(__dirname, "bin")
|
|
114
|
+
if (!fs.existsSync(binDir)) return
|
|
115
|
+
const binaryName = os.platform() === "win32" ? "emberharmony.exe" : "emberharmony"
|
|
116
|
+
const entries = fs.readdirSync(binDir)
|
|
117
|
+
for (const entry of entries) {
|
|
118
|
+
const candidate = path.join(binDir, entry, binaryName)
|
|
119
|
+
if (fs.existsSync(candidate)) {
|
|
120
|
+
return candidate
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function main() {
|
|
126
|
+
try {
|
|
127
|
+
if (os.platform() === "win32") {
|
|
128
|
+
// On Windows, the .exe is already included in the package and bin field points to it
|
|
129
|
+
// No postinstall setup needed
|
|
130
|
+
console.log("Windows detected: binary setup not needed (using packaged .exe)")
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const local = findLocalBinary()
|
|
135
|
+
if (local) {
|
|
136
|
+
console.log(`Local binary verified at: ${local}`)
|
|
137
|
+
return
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// On non-Windows platforms, just verify the binary package exists
|
|
141
|
+
// Don't replace the wrapper script - it handles binary execution
|
|
142
|
+
const { binaryPath } = findBinary()
|
|
143
|
+
console.log(`Platform binary verified at: ${binaryPath}`)
|
|
144
|
+
console.log("Wrapper script will handle binary execution")
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error("Failed to setup emberharmony binary:", error.message)
|
|
147
|
+
process.exit(1)
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
main()
|
|
153
|
+
} catch (error) {
|
|
154
|
+
console.error("Postinstall script error:", error.message)
|
|
155
|
+
process.exit(0)
|
|
156
|
+
}
|