refactor: 统一项目名称从OpenFang到ZCLAW
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled

重构所有代码和文档中的项目名称,将OpenFang统一更新为ZCLAW。包括:
- 配置文件中的项目名称
- 代码注释和文档引用
- 环境变量和路径
- 类型定义和接口名称
- 测试用例和模拟数据

同时优化部分代码结构,移除未使用的模块,并更新相关依赖项。
This commit is contained in:
iven
2026-03-27 07:36:03 +08:00
parent 4b08804aa9
commit 0d4fa96b82
226 changed files with 7288 additions and 5788 deletions

View File

@@ -1,14 +1,14 @@
#!/usr/bin/env node
/**
* OpenFang Runtime Preparation Script
* ZCLAW Runtime Preparation Script
*
* Prepares the OpenFang binary for bundling with Tauri.
* Prepares the ZCLAW binary for bundling with Tauri.
* Supports cross-platform: Windows, Linux, macOS
*
* Usage:
* node scripts/prepare-openfang-runtime.mjs
* node scripts/prepare-openfang-runtime.mjs --dry-run
* OPENFANG_VERSION=v1.2.3 node scripts/prepare-openfang-runtime.mjs
* node scripts/prepare-zclaw-runtime.mjs
* node scripts/prepare-zclaw-runtime.mjs --dry-run
* ZCLAW_VERSION=v1.2.3 node scripts/prepare-zclaw-runtime.mjs
*/
import { execSync, execFileSync } from 'node:child_process';
@@ -20,64 +20,64 @@ import { arch as osArch, platform as osPlatform, homedir } from 'node:os';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const desktopRoot = path.resolve(__dirname, '..');
const outputDir = path.join(desktopRoot, 'src-tauri', 'resources', 'openfang-runtime');
const outputDir = path.join(desktopRoot, 'src-tauri', 'resources', 'zclaw-runtime');
const dryRun = process.argv.includes('--dry-run');
const openfangVersion = process.env.OPENFANG_VERSION || 'latest';
const zclawVersion = process.env.ZCLAW_VERSION || 'latest';
const PLATFORM = osPlatform();
const ARCH = osArch();
function log(message) {
console.log(`[prepare-openfang-runtime] ${message}`);
console.log(`[prepare-zclaw-runtime] ${message}`);
}
function warn(message) {
console.warn(`[prepare-openfang-runtime] WARN: ${message}`);
console.warn(`[prepare-zclaw-runtime] WARN: ${message}`);
}
function error(message) {
console.error(`[prepare-openfang-runtime] ERROR: ${message}`);
console.error(`[prepare-zclaw-runtime] ERROR: ${message}`);
}
/**
* Get platform-specific binary configuration
* OpenFang releases: .zip for Windows, .tar.gz for Unix
* ZCLAW releases: .zip for Windows, .tar.gz for Unix
*/
function getPlatformConfig() {
const configs = {
win32: {
x64: {
binaryName: 'openfang.exe',
downloadName: 'openfang-x86_64-pc-windows-msvc.zip',
binaryName: 'zclaw.exe',
downloadName: 'zclaw-x86_64-pc-windows-msvc.zip',
archiveFormat: 'zip',
},
arm64: {
binaryName: 'openfang.exe',
downloadName: 'openfang-aarch64-pc-windows-msvc.zip',
binaryName: 'zclaw.exe',
downloadName: 'zclaw-aarch64-pc-windows-msvc.zip',
archiveFormat: 'zip',
},
},
darwin: {
x64: {
binaryName: 'openfang-x86_64-apple-darwin',
downloadName: 'openfang-x86_64-apple-darwin.tar.gz',
binaryName: 'zclaw-x86_64-apple-darwin',
downloadName: 'zclaw-x86_64-apple-darwin.tar.gz',
archiveFormat: 'tar.gz',
},
arm64: {
binaryName: 'openfang-aarch64-apple-darwin',
downloadName: 'openfang-aarch64-apple-darwin.tar.gz',
binaryName: 'zclaw-aarch64-apple-darwin',
downloadName: 'zclaw-aarch64-apple-darwin.tar.gz',
archiveFormat: 'tar.gz',
},
},
linux: {
x64: {
binaryName: 'openfang-x86_64-unknown-linux-gnu',
downloadName: 'openfang-x86_64-unknown-linux-gnu.tar.gz',
binaryName: 'zclaw-x86_64-unknown-linux-gnu',
downloadName: 'zclaw-x86_64-unknown-linux-gnu.tar.gz',
archiveFormat: 'tar.gz',
},
arm64: {
binaryName: 'openfang-aarch64-unknown-linux-gnu',
downloadName: 'openfang-aarch64-unknown-linux-gnu.tar.gz',
binaryName: 'zclaw-aarch64-unknown-linux-gnu',
downloadName: 'zclaw-aarch64-unknown-linux-gnu.tar.gz',
archiveFormat: 'tar.gz',
},
},
@@ -97,26 +97,26 @@ function getPlatformConfig() {
}
/**
* Find OpenFang binary in system PATH
* Find ZCLAW binary in system PATH
*/
function findSystemBinary() {
const override = process.env.OPENFANG_BIN;
const override = process.env.ZCLAW_BIN;
if (override) {
if (fs.existsSync(override)) {
return override;
}
throw new Error(`OPENFANG_BIN specified but file not found: ${override}`);
throw new Error(`ZCLAW_BIN specified but file not found: ${override}`);
}
try {
let result;
if (PLATFORM === 'win32') {
result = execFileSync('where.exe', ['openfang'], {
result = execFileSync('where.exe', ['zclaw'], {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
});
} else {
result = execFileSync('which', ['openfang'], {
result = execFileSync('which', ['zclaw'], {
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
});
@@ -134,7 +134,7 @@ function findSystemBinary() {
}
/**
* Check if OpenFang is installed via install script
* Check if ZCLAW is installed via install script
*/
function findInstalledBinary() {
const config = getPlatformConfig();
@@ -142,12 +142,12 @@ function findInstalledBinary() {
const possiblePaths = [
// Default install location
path.join(home, '.openfang', 'bin', config.binaryName),
path.join(home, '.zclaw', 'bin', config.binaryName),
path.join(home, '.local', 'bin', config.binaryName),
// macOS
path.join(home, '.openfang', 'bin', 'openfang'),
'/usr/local/bin/openfang',
'/usr/bin/openfang',
path.join(home, '.zclaw', 'bin', 'zclaw'),
'/usr/local/bin/zclaw',
'/usr/bin/zclaw',
];
for (const p of possiblePaths) {
@@ -160,21 +160,21 @@ function findInstalledBinary() {
}
/**
* Download OpenFang binary from GitHub Releases
* Download ZCLAW binary from GitHub Releases
* Handles .zip for Windows, .tar.gz for Unix
*/
function downloadBinary(config) {
const baseUrl = 'https://github.com/RightNow-AI/openfang/releases';
const downloadUrl = openfangVersion === 'latest'
const baseUrl = 'https://github.com/RightNow-AI/zclaw/releases';
const downloadUrl = zclawVersion === 'latest'
? `${baseUrl}/latest/download/${config.downloadName}`
: `${baseUrl}/download/${openfangVersion}/${config.downloadName}`;
: `${baseUrl}/download/${zclawVersion}/${config.downloadName}`;
const archivePath = path.join(outputDir, config.downloadName);
const binaryOutputPath = path.join(outputDir, config.binaryName);
log(`Downloading OpenFang binary...`);
log(`Downloading ZCLAW binary...`);
log(` Platform: ${PLATFORM} (${ARCH})`);
log(` Version: ${openfangVersion}`);
log(` Version: ${zclawVersion}`);
log(` Archive: ${config.downloadName}`);
log(` URL: ${downloadUrl}`);
@@ -211,7 +211,7 @@ function downloadBinary(config) {
// Find and rename the extracted binary
// The archive contains a single binary file
const extractedFiles = fs.readdirSync(outputDir).filter(f =>
f.startsWith('openfang') && !f.endsWith('.zip') && !f.endsWith('.tar.gz') && !f.endsWith('.sha256')
f.startsWith('zclaw') && !f.endsWith('.zip') && !f.endsWith('.tar.gz') && !f.endsWith('.sha256')
);
if (extractedFiles.length === 0) {
@@ -285,16 +285,16 @@ function writeManifest(config) {
const manifest = {
source: {
binPath: config.binaryName,
binPathLinux: 'openfang-x86_64-unknown-linux-gnu',
binPathMac: 'openfang-x86_64-apple-darwin',
binPathMacArm: 'openfang-aarch64-apple-darwin',
binPathLinux: 'zclaw-x86_64-unknown-linux-gnu',
binPathMac: 'zclaw-x86_64-apple-darwin',
binPathMacArm: 'zclaw-aarch64-apple-darwin',
},
stagedAt: new Date().toISOString(),
version: openfangVersion === 'latest'
version: zclawVersion === 'latest'
? new Date().toISOString().split('T')[0].replace(/-/g, '.')
: openfangVersion,
runtimeType: 'openfang',
description: 'OpenFang Agent OS - Single binary runtime (~32MB)',
: zclawVersion,
runtimeType: 'zclaw',
description: 'ZCLAW Agent OS - Single binary runtime (~32MB)',
endpoints: {
websocket: 'ws://127.0.0.1:4200/ws',
rest: 'http://127.0.0.1:4200/api',
@@ -322,21 +322,21 @@ function writeLauncherScripts(config) {
// Windows launcher
const cmdLauncher = [
'@echo off',
'REM OpenFang Agent OS - Bundled Binary Launcher',
'REM ZCLAW Agent OS - Bundled Binary Launcher',
`"%~dp0${config.binaryName}" %*`,
'',
].join('\r\n');
fs.writeFileSync(path.join(outputDir, 'openfang.cmd'), cmdLauncher, 'utf8');
fs.writeFileSync(path.join(outputDir, 'zclaw.cmd'), cmdLauncher, 'utf8');
// Unix launcher
const shLauncher = [
'#!/bin/bash',
'# OpenFang Agent OS - Bundled Binary Launcher',
'# ZCLAW Agent OS - Bundled Binary Launcher',
`SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"`,
`exec "$SCRIPT_DIR/${config.binaryName}" "$@"`,
'',
].join('\n');
const shPath = path.join(outputDir, 'openfang.sh');
const shPath = path.join(outputDir, 'zclaw.sh');
fs.writeFileSync(shPath, shLauncher, 'utf8');
fs.chmodSync(shPath, 0o755);
@@ -370,7 +370,7 @@ function cleanOldRuntime() {
*/
function main() {
log('='.repeat(60));
log('OpenFang Runtime Preparation');
log('ZCLAW Runtime Preparation');
log('='.repeat(60));
const config = getPlatformConfig();
@@ -385,23 +385,23 @@ function main() {
let binaryPath = findSystemBinary();
if (binaryPath) {
log(`Found OpenFang in PATH: ${binaryPath}`);
log(`Found ZCLAW in PATH: ${binaryPath}`);
copyBinary(binaryPath, config);
} else {
binaryPath = findInstalledBinary();
if (binaryPath) {
log(`Found installed OpenFang: ${binaryPath}`);
log(`Found installed ZCLAW: ${binaryPath}`);
copyBinary(binaryPath, config);
} else {
log('OpenFang not found locally, downloading...');
log('ZCLAW not found locally, downloading...');
const downloaded = downloadBinary(config);
if (!downloaded && !dryRun) {
error('Failed to obtain OpenFang binary!');
error('Failed to obtain ZCLAW binary!');
error('');
error('Please either:');
error(' 1. Install OpenFang: curl -fsSL https://openfang.sh/install | sh');
error(' 2. Set OPENFANG_BIN environment variable to binary path');
error(' 3. Manually download from: https://github.com/RightNow-AI/openfang/releases');
error(' 1. Install ZCLAW: curl -fsSL https://zclaw.sh/install | sh');
error(' 2. Set ZCLAW_BIN environment variable to binary path');
error(' 3. Manually download from: https://github.com/RightNow-AI/zclaw/releases');
process.exit(1);
}
}
@@ -415,7 +415,7 @@ function main() {
if (dryRun) {
log('DRY RUN complete. No files were written.');
} else {
log('OpenFang runtime ready for build!');
log('ZCLAW runtime ready for build!');
}
log('='.repeat(60));
}