v0.5.0: NomadArch - Binary-Free Mode Release
Some checks failed
Release Binaries / release (push) Has been cancelled
Some checks failed
Release Binaries / release (push) Has been cancelled
Features: - Binary-Free Mode: No OpenCode binary required - NomadArch Native mode with free Zen models - Native session management - Provider routing (Zen, Qwen, Z.AI) - Fixed MCP connection with explicit connectAll() - Updated installers and launchers for all platforms - UI binary selector with Native option Free Models Available: - GPT-5 Nano (400K context) - Grok Code Fast 1 (256K context) - GLM-4.7 (205K context) - Doubao Seed Code (256K context) - Big Pickle (200K context)
This commit is contained in:
131
packages/electron-app/scripts/build.js
Normal file
131
packages/electron-app/scripts/build.js
Normal file
@@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { spawn } from "child_process"
|
||||
import { existsSync } from "fs"
|
||||
import { join } from "path"
|
||||
import { fileURLToPath } from "url"
|
||||
|
||||
const __dirname = fileURLToPath(new URL(".", import.meta.url))
|
||||
const appDir = join(__dirname, "..")
|
||||
const workspaceRoot = join(appDir, "..", "..")
|
||||
|
||||
const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm"
|
||||
const npxCmd = process.platform === "win32" ? "npx.cmd" : "npx"
|
||||
const nodeModulesPath = join(appDir, "node_modules")
|
||||
const workspaceNodeModulesPath = join(workspaceRoot, "node_modules")
|
||||
|
||||
const platforms = {
|
||||
mac: {
|
||||
args: ["--mac", "--x64", "--arm64"],
|
||||
description: "macOS (Intel & Apple Silicon)",
|
||||
},
|
||||
"mac-x64": {
|
||||
args: ["--mac", "--x64"],
|
||||
description: "macOS (Intel only)",
|
||||
},
|
||||
"mac-arm64": {
|
||||
args: ["--mac", "--arm64"],
|
||||
description: "macOS (Apple Silicon only)",
|
||||
},
|
||||
win: {
|
||||
args: ["--win", "--x64"],
|
||||
description: "Windows (x64)",
|
||||
},
|
||||
"win-arm64": {
|
||||
args: ["--win", "--arm64"],
|
||||
description: "Windows (ARM64)",
|
||||
},
|
||||
linux: {
|
||||
args: ["--linux", "--x64"],
|
||||
description: "Linux (x64)",
|
||||
},
|
||||
"linux-arm64": {
|
||||
args: ["--linux", "--arm64"],
|
||||
description: "Linux (ARM64)",
|
||||
},
|
||||
"linux-rpm": {
|
||||
args: ["--linux", "rpm", "--x64", "--arm64"],
|
||||
description: "Linux RPM packages (x64 & ARM64)",
|
||||
},
|
||||
all: {
|
||||
args: ["--mac", "--win", "--linux", "--x64", "--arm64"],
|
||||
description: "All platforms (macOS, Windows, Linux)",
|
||||
},
|
||||
}
|
||||
|
||||
function run(command, args, options = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const spawnOptions = {
|
||||
cwd: appDir,
|
||||
stdio: "inherit",
|
||||
shell: process.platform === "win32",
|
||||
...options,
|
||||
env: { ...process.env, NODE_PATH: nodeModulesPath, ...(options.env || {}) },
|
||||
}
|
||||
|
||||
const child = spawn(command, args, spawnOptions)
|
||||
|
||||
child.on("error", reject)
|
||||
child.on("exit", (code) => {
|
||||
if (code === 0) {
|
||||
resolve(undefined)
|
||||
} else {
|
||||
reject(new Error(`${command} ${args.join(" ")} exited with code ${code}`))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function printAvailablePlatforms() {
|
||||
console.error(`\nAvailable platforms:`)
|
||||
for (const [name, cfg] of Object.entries(platforms)) {
|
||||
console.error(` - ${name.padEnd(12)} : ${cfg.description}`)
|
||||
}
|
||||
}
|
||||
|
||||
async function build(platform) {
|
||||
const config = platforms[platform]
|
||||
|
||||
if (!config) {
|
||||
console.error(`❌ Unknown platform: ${platform}`)
|
||||
printAvailablePlatforms()
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(`\n🔨 Building for: ${config.description}\n`)
|
||||
|
||||
try {
|
||||
console.log("📦 Step 1/3: Building CLI dependency...\n")
|
||||
await run(npmCmd, ["run", "build", "--workspace", "@neuralnomads/codenomad"], {
|
||||
cwd: workspaceRoot,
|
||||
env: { NODE_PATH: workspaceNodeModulesPath },
|
||||
})
|
||||
|
||||
console.log("\n📦 Step 2/3: Building Electron app...\n")
|
||||
await run(npmCmd, ["run", "build"])
|
||||
|
||||
console.log("\n📦 Step 3/3: Packaging binaries...\n")
|
||||
const distPath = join(appDir, "dist")
|
||||
if (!existsSync(distPath)) {
|
||||
throw new Error("dist/ directory not found. Build failed.")
|
||||
}
|
||||
|
||||
await run(npxCmd, ["electron-builder", "--publish=never", ...config.args])
|
||||
|
||||
console.log("\n✅ Build complete!")
|
||||
console.log(`📁 Binaries available in: ${join(appDir, "release")}\n`)
|
||||
} catch (error) {
|
||||
console.error("\n❌ Build failed:", error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
const platform = process.argv[2] || "mac"
|
||||
|
||||
console.log(`
|
||||
╔════════════════════════════════════════╗
|
||||
║ CodeNomad - Binary Builder ║
|
||||
╚════════════════════════════════════════╝
|
||||
`)
|
||||
|
||||
await build(platform)
|
||||
30
packages/electron-app/scripts/dev.sh
Normal file
30
packages/electron-app/scripts/dev.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
if ! command -v node >/dev/null 2>&1; then
|
||||
echo "Node.js is required to run the development environment." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Resolve the Electron binary via Node to avoid Bun resolution hiccups
|
||||
ELECTRON_EXEC_PATH="$(node -p "require('electron')")"
|
||||
|
||||
if [[ -z "${ELECTRON_EXEC_PATH}" ]]; then
|
||||
echo "Failed to resolve the Electron binary path." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NODE_ENV="${NODE_ENV:-development}"
|
||||
export ELECTRON_EXEC_PATH
|
||||
|
||||
# ELECTRON_VITE_BIN="$ROOT_DIR/node_modules/.bin/electron-vite"
|
||||
|
||||
if [[ ! -x "${ELECTRON_VITE_BIN}" ]]; then
|
||||
echo "electron-vite binary not found. Have you installed dependencies?" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "${ELECTRON_VITE_BIN}" dev "$@"
|
||||
155
packages/electron-app/scripts/generate-icons.js
Normal file
155
packages/electron-app/scripts/generate-icons.js
Normal file
@@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { mkdirSync, readFileSync, writeFileSync } from "fs"
|
||||
import { resolve, join, basename } from "path"
|
||||
import { PNG } from "pngjs"
|
||||
import png2icons from "png2icons"
|
||||
|
||||
function printUsage() {
|
||||
console.log(`\nUsage: node scripts/generate-icons.js <input.png> [outputDir] [--name icon] [--radius 0.22]\n\nOptions:\n --name Base filename for generated assets (default: icon)\n --radius Corner radius ratio between 0 and 0.5 (default: 0.22)\n --help Show this message\n`)
|
||||
}
|
||||
|
||||
function parseArgs(argv) {
|
||||
const args = [...argv]
|
||||
const options = {
|
||||
name: "icon",
|
||||
radius: 0.22,
|
||||
}
|
||||
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
const token = args[i]
|
||||
if (token === "--help" || token === "-h") {
|
||||
options.help = true
|
||||
continue
|
||||
}
|
||||
if (token === "--name" && i + 1 < args.length) {
|
||||
options.name = args[i + 1]
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if (token === "--radius" && i + 1 < args.length) {
|
||||
options.radius = Number(args[i + 1])
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if (!options.input) {
|
||||
options.input = token
|
||||
continue
|
||||
}
|
||||
if (!options.output) {
|
||||
options.output = token
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
function applyRoundedCorners(png, ratio) {
|
||||
const { width, height, data } = png
|
||||
const clamped = Math.max(0, Math.min(ratio, 0.5))
|
||||
if (clamped === 0) return png
|
||||
|
||||
const radius = Math.max(1, Math.min(width, height) * clamped)
|
||||
const radiusSq = radius * radius
|
||||
const rightThreshold = width - radius
|
||||
const bottomThreshold = height - radius
|
||||
|
||||
for (let y = 0; y < height; y++) {
|
||||
for (let x = 0; x < width; x++) {
|
||||
const idx = (width * y + x) * 4
|
||||
if (data[idx + 3] === 0) continue
|
||||
|
||||
const px = x + 0.5
|
||||
const py = y + 0.5
|
||||
|
||||
const inLeft = px < radius
|
||||
const inRight = px > rightThreshold
|
||||
const inTop = py < radius
|
||||
const inBottom = py > bottomThreshold
|
||||
|
||||
let outside = false
|
||||
|
||||
if (inLeft && inTop) {
|
||||
outside = (px - radius) ** 2 + (py - radius) ** 2 > radiusSq
|
||||
} else if (inRight && inTop) {
|
||||
outside = (px - rightThreshold) ** 2 + (py - radius) ** 2 > radiusSq
|
||||
} else if (inLeft && inBottom) {
|
||||
outside = (px - radius) ** 2 + (py - bottomThreshold) ** 2 > radiusSq
|
||||
} else if (inRight && inBottom) {
|
||||
outside = (px - rightThreshold) ** 2 + (py - bottomThreshold) ** 2 > radiusSq
|
||||
}
|
||||
|
||||
if (outside) {
|
||||
data[idx + 3] = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return png
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = parseArgs(process.argv.slice(2))
|
||||
|
||||
if (args.help || !args.input) {
|
||||
printUsage()
|
||||
process.exit(args.help ? 0 : 1)
|
||||
}
|
||||
|
||||
const inputPath = resolve(args.input)
|
||||
const outputDir = resolve(args.output || "electron/resources")
|
||||
const baseName = args.name || basename(inputPath, ".png")
|
||||
const radiusRatio = Number.isFinite(args.radius) ? args.radius : 0.22
|
||||
|
||||
let buffer
|
||||
try {
|
||||
buffer = readFileSync(inputPath)
|
||||
} catch (error) {
|
||||
console.error(`Failed to read ${inputPath}:`, error.message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
let png
|
||||
try {
|
||||
png = PNG.sync.read(buffer)
|
||||
} catch (error) {
|
||||
console.error("Input must be a valid PNG:", error.message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
applyRoundedCorners(png, radiusRatio)
|
||||
|
||||
const roundedBuffer = PNG.sync.write(png)
|
||||
|
||||
try {
|
||||
mkdirSync(outputDir, { recursive: true })
|
||||
} catch (error) {
|
||||
console.error("Failed to create output directory:", error.message)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const pngPath = join(outputDir, `${baseName}.png`)
|
||||
writeFileSync(pngPath, roundedBuffer)
|
||||
|
||||
const icns = png2icons.createICNS(roundedBuffer, png2icons.BICUBIC, false)
|
||||
if (!icns) {
|
||||
console.error("Failed to create ICNS file. Make sure the source PNG is at least 256x256.")
|
||||
process.exit(1)
|
||||
}
|
||||
writeFileSync(join(outputDir, `${baseName}.icns`), icns)
|
||||
|
||||
const ico = png2icons.createICO(roundedBuffer, png2icons.BICUBIC, false)
|
||||
if (!ico) {
|
||||
console.error("Failed to create ICO file. Make sure the source PNG is at least 256x256.")
|
||||
process.exit(1)
|
||||
}
|
||||
writeFileSync(join(outputDir, `${baseName}.ico`), ico)
|
||||
|
||||
console.log(`\nGenerated assets in ${outputDir}:`)
|
||||
console.log(`- ${baseName}.png`)
|
||||
console.log(`- ${baseName}.icns`)
|
||||
console.log(`- ${baseName}.ico`)
|
||||
}
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user