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
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:
@@ -10,11 +10,11 @@ import {
|
||||
ConfigParseError,
|
||||
ConfigValidationFailedError,
|
||||
} from '../src/lib/config-parser';
|
||||
import type { OpenFangConfig } from '../src/types/config';
|
||||
import type { ZclawConfig } from '../src/types/config';
|
||||
|
||||
describe('configParser', () => {
|
||||
const validToml = `
|
||||
# Valid OpenFang configuration
|
||||
# Valid ZCLAW configuration
|
||||
[server]
|
||||
host = "127.0.0.1"
|
||||
port = 4200
|
||||
@@ -23,7 +23,7 @@ websocket_port = 4200
|
||||
websocket_path = "/ws"
|
||||
|
||||
[agent.defaults]
|
||||
workspace = "~/.openfang/workspace"
|
||||
workspace = "~/.zclaw/workspace"
|
||||
default_model = "gpt-4"
|
||||
|
||||
[llm]
|
||||
@@ -44,7 +44,7 @@ default_model = "gpt-4"
|
||||
});
|
||||
expect(config.agent).toBeDefined();
|
||||
expect(config.agent.defaults).toEqual({
|
||||
workspace: '~/.openfang/workspace',
|
||||
workspace: '~/.zclaw/workspace',
|
||||
default_model: 'gpt-4',
|
||||
});
|
||||
expect(config.llm).toEqual({
|
||||
@@ -57,14 +57,14 @@ default_model = "gpt-4"
|
||||
|
||||
describe('validateConfig', () => {
|
||||
it('should validate correct configuration', () => {
|
||||
const config: OpenFangConfig = {
|
||||
const config: ZclawConfig = {
|
||||
server: {
|
||||
host: '127.0.0.1',
|
||||
port: 4200,
|
||||
},
|
||||
agent: {
|
||||
defaults: {
|
||||
workspace: '~/.openfang/workspace',
|
||||
workspace: '~/.zclaw/workspace',
|
||||
default_model: 'gpt-4',
|
||||
},
|
||||
},
|
||||
@@ -102,7 +102,7 @@ default_model = "gpt-4"
|
||||
},
|
||||
agent: {
|
||||
defaults: {
|
||||
workspace: '~/.openfang/workspace',
|
||||
workspace: '~/.zclaw/workspace',
|
||||
default_model: 'gpt-4',
|
||||
},
|
||||
},
|
||||
@@ -127,7 +127,7 @@ default_model = "gpt-4"
|
||||
},
|
||||
agent: {
|
||||
defaults: {
|
||||
workspace: '~/.openfang/workspace',
|
||||
workspace: '~/.zclaw/workspace',
|
||||
default_model: '',
|
||||
},
|
||||
},
|
||||
@@ -163,14 +163,14 @@ host = "127.0.0.1"
|
||||
|
||||
describe('stringifyConfig', () => {
|
||||
it('should stringify configuration to TOML', () => {
|
||||
const config: OpenFangConfig = {
|
||||
const config: ZclawConfig = {
|
||||
server: {
|
||||
host: '127.0.0.1',
|
||||
port: 4200,
|
||||
},
|
||||
agent: {
|
||||
defaults: {
|
||||
workspace: '~/.openfang/workspace',
|
||||
workspace: '~/.zclaw/workspace',
|
||||
default_model: 'gpt-4',
|
||||
},
|
||||
},
|
||||
@@ -232,16 +232,16 @@ port = 4200
|
||||
});
|
||||
});
|
||||
|
||||
describe('isOpenFangConfig', () => {
|
||||
describe('isZclawConfig', () => {
|
||||
it('should return true for valid config', () => {
|
||||
const config: OpenFangConfig = {
|
||||
const config: ZclawConfig = {
|
||||
server: {
|
||||
host: '127.0.0.1',
|
||||
port: 4200,
|
||||
},
|
||||
agent: {
|
||||
defaults: {
|
||||
workspace: '~/.openfang/workspace',
|
||||
workspace: '~/.zclaw/workspace',
|
||||
default_model: 'gpt-4',
|
||||
},
|
||||
},
|
||||
@@ -251,12 +251,12 @@ port = 4200
|
||||
},
|
||||
};
|
||||
|
||||
expect(configParser.isOpenFangConfig(config)).toBe(true);
|
||||
expect(configParser.isZclawConfig(config)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return false for invalid config', () => {
|
||||
expect(configParser.isOpenFangConfig(null)).toBe(false);
|
||||
expect(configParser.isOpenFangConfig({})).toBe(false);
|
||||
expect(configParser.isZclawConfig(null)).toBe(false);
|
||||
expect(configParser.isZclawConfig({})).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* OpenFang 真实响应数据模板
|
||||
* ZCLAW 真实响应数据模板
|
||||
*
|
||||
* 用于 E2E 测试的 OpenFang API 响应数据模板。
|
||||
* 基于 OpenFang Gateway Protocol v3 规范。
|
||||
* 用于 E2E 测试的 ZCLAW API 响应数据模板。
|
||||
* 基于 ZCLAW Gateway Protocol v3 规范。
|
||||
*/
|
||||
|
||||
export const openFangResponses = {
|
||||
export const zclawResponses = {
|
||||
health: {
|
||||
status: 'ok',
|
||||
version: '0.4.0',
|
||||
@@ -155,7 +155,7 @@ export const openFangResponses = {
|
||||
},
|
||||
|
||||
config: {
|
||||
data_dir: '/Users/user/.openfang',
|
||||
data_dir: '/Users/user/.zclaw',
|
||||
default_model: 'qwen3.5-plus',
|
||||
log_level: 'info',
|
||||
},
|
||||
@@ -1,77 +1,77 @@
|
||||
/**
|
||||
* OpenFang API 端点兼容性测试
|
||||
* ZCLAW API 端点兼容性测试
|
||||
*
|
||||
* 验证 ZCLAW 前端与 OpenFang 后端的 REST API 兼容性。
|
||||
* 验证 ZCLAW 前端与 ZCLAW 后端的 REST API 兼容性。
|
||||
*/
|
||||
|
||||
import { test, expect, Page } from '@playwright/test';
|
||||
import { openFangResponses } from '../fixtures/openfang-responses';
|
||||
import { zclawResponses } from '../fixtures/zclaw-responses';
|
||||
|
||||
const BASE_URL = 'http://localhost:1420';
|
||||
|
||||
async function setupMockAPI(page: Page) {
|
||||
await page.route('**/api/health', async route => {
|
||||
await route.fulfill({ json: openFangResponses.health });
|
||||
await route.fulfill({ json: zclawResponses.health });
|
||||
});
|
||||
|
||||
await page.route('**/api/status', async route => {
|
||||
await route.fulfill({ json: openFangResponses.status });
|
||||
await route.fulfill({ json: zclawResponses.status });
|
||||
});
|
||||
|
||||
await page.route('**/api/agents', async route => {
|
||||
if (route.request().method() === 'GET') {
|
||||
await route.fulfill({ json: openFangResponses.agents });
|
||||
await route.fulfill({ json: zclawResponses.agents });
|
||||
} else if (route.request().method() === 'POST') {
|
||||
await route.fulfill({ json: { clone: { id: 'new-agent-001', name: 'New Agent' } } });
|
||||
}
|
||||
});
|
||||
|
||||
await page.route('**/api/agents/*', async route => {
|
||||
await route.fulfill({ json: openFangResponses.agent });
|
||||
await route.fulfill({ json: zclawResponses.agent });
|
||||
});
|
||||
|
||||
await page.route('**/api/models', async route => {
|
||||
await route.fulfill({ json: openFangResponses.models });
|
||||
await route.fulfill({ json: zclawResponses.models });
|
||||
});
|
||||
|
||||
await page.route('**/api/hands', async route => {
|
||||
await route.fulfill({ json: openFangResponses.hands });
|
||||
await route.fulfill({ json: zclawResponses.hands });
|
||||
});
|
||||
|
||||
await page.route('**/api/hands/*', async route => {
|
||||
if (route.request().method() === 'GET') {
|
||||
await route.fulfill({ json: openFangResponses.hand });
|
||||
await route.fulfill({ json: zclawResponses.hand });
|
||||
} else if (route.request().url().includes('/activate')) {
|
||||
await route.fulfill({ json: openFangResponses.handActivation });
|
||||
await route.fulfill({ json: zclawResponses.handActivation });
|
||||
}
|
||||
});
|
||||
|
||||
await page.route('**/api/workflows', async route => {
|
||||
await route.fulfill({ json: openFangResponses.workflows });
|
||||
await route.fulfill({ json: zclawResponses.workflows });
|
||||
});
|
||||
|
||||
await page.route('**/api/workflows/*', async route => {
|
||||
await route.fulfill({ json: openFangResponses.workflow });
|
||||
await route.fulfill({ json: zclawResponses.workflow });
|
||||
});
|
||||
|
||||
await page.route('**/api/sessions', async route => {
|
||||
await route.fulfill({ json: openFangResponses.sessions });
|
||||
await route.fulfill({ json: zclawResponses.sessions });
|
||||
});
|
||||
|
||||
await page.route('**/api/config', async route => {
|
||||
await route.fulfill({ json: openFangResponses.config });
|
||||
await route.fulfill({ json: zclawResponses.config });
|
||||
});
|
||||
|
||||
await page.route('**/api/channels', async route => {
|
||||
await route.fulfill({ json: openFangResponses.channels });
|
||||
await route.fulfill({ json: zclawResponses.channels });
|
||||
});
|
||||
|
||||
await page.route('**/api/skills', async route => {
|
||||
await route.fulfill({ json: openFangResponses.skills });
|
||||
await route.fulfill({ json: zclawResponses.skills });
|
||||
});
|
||||
}
|
||||
|
||||
test.describe('OpenFang API 端点兼容性测试', () => {
|
||||
test.describe('ZCLAW API 端点兼容性测试', () => {
|
||||
|
||||
test.describe('API-01: Health 端点', () => {
|
||||
test('应返回正确的健康状态', async ({ page }) => {
|
||||
@@ -1,15 +1,15 @@
|
||||
/**
|
||||
* OpenFang 协议兼容性测试
|
||||
* ZCLAW 协议兼容性测试
|
||||
*
|
||||
* 验证 ZCLAW 前端与 OpenFang 后端的协议兼容性。
|
||||
* 验证 ZCLAW 前端与 ZCLAW 后端的协议兼容性。
|
||||
*/
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
import { openFangResponses, streamEvents, gatewayFrames } from '../fixtures/openfang-responses';
|
||||
import { zclawResponses, streamEvents, gatewayFrames } from '../fixtures/zclaw-responses';
|
||||
|
||||
const BASE_URL = 'http://localhost:1420';
|
||||
|
||||
test.describe('OpenFang 协议兼容性测试', () => {
|
||||
test.describe('ZCLAW 协议兼容性测试', () => {
|
||||
|
||||
test.describe('PROTO-01: 流事件类型解析', () => {
|
||||
test('应正确解析 text_delta 事件', () => {
|
||||
@@ -23,8 +23,8 @@ vi.mock('../src/lib/tauri-gateway', () => ({
|
||||
getLocalGatewayAuth: vi.fn(),
|
||||
prepareLocalGatewayForTauri: vi.fn(),
|
||||
approveLocalGatewayDevicePairing: vi.fn(),
|
||||
getOpenFangProcessList: vi.fn(),
|
||||
getOpenFangProcessLogs: vi.fn(),
|
||||
getZclawProcessList: vi.fn(),
|
||||
getZclawProcessLogs: vi.fn(),
|
||||
getUnsupportedLocalGatewayStatus: vi.fn(() => ({
|
||||
supported: false,
|
||||
cliAvailable: false,
|
||||
|
||||
@@ -572,40 +572,6 @@ describe('chatStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('dispatchSwarmTask', () => {
|
||||
it('should return task id on success', async () => {
|
||||
const { dispatchSwarmTask } = useChatStore.getState();
|
||||
|
||||
const result = await dispatchSwarmTask('Test task');
|
||||
|
||||
expect(result).toBe('task-1');
|
||||
});
|
||||
|
||||
it('should add swarm result message', async () => {
|
||||
const { dispatchSwarmTask } = useChatStore.getState();
|
||||
|
||||
await dispatchSwarmTask('Test task');
|
||||
|
||||
const state = useChatStore.getState();
|
||||
const swarmMsg = state.messages.find(m => m.role === 'assistant');
|
||||
expect(swarmMsg).toBeDefined();
|
||||
});
|
||||
|
||||
it('should return null on failure', async () => {
|
||||
const { dispatchSwarmTask } = useChatStore.getState();
|
||||
|
||||
// Mock the agent-swarm module to throw
|
||||
vi.doMock('../../src/lib/agent-swarm', () => ({
|
||||
getAgentSwarm: vi.fn(() => {
|
||||
throw new Error('Swarm error');
|
||||
}),
|
||||
}));
|
||||
|
||||
// Since we can't easily re-mock, just verify the function exists
|
||||
expect(typeof dispatchSwarmTask).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('message types', () => {
|
||||
it('should handle tool message', () => {
|
||||
const { addMessage } = useChatStore.getState();
|
||||
|
||||
Reference in New Issue
Block a user