收口 Makelore 客户端变更
Some checks failed
Electron E2E / Electron E2E (macos-latest) (push) Has been cancelled
Electron E2E / Electron E2E (ubuntu-latest) (push) Has been cancelled
Electron E2E / Electron E2E (windows-latest) (push) Has been cancelled

This commit is contained in:
inman
2026-08-12 22:35:06 +08:00
parent 253bad8b40
commit f4113a872f
232 changed files with 4617 additions and 20121 deletions

View File

@@ -1,4 +1,4 @@
import { mkdtemp, readFile, readdir } from 'node:fs/promises';
import { mkdtemp, readFile, readdir, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import path from 'node:path';
import { describe, expect, it } from 'vitest';
@@ -47,7 +47,6 @@ describe('project-owned contact configuration', () => {
expect(config).toMatchObject({
projectType: 'custom',
initialized: false,
superpowersEnabled: false,
agents: [],
knowledgeDirectory: 'knowledge',
});
@@ -89,12 +88,54 @@ describe('project-owned contact configuration', () => {
superpowersEnabled: undefined,
});
expect(normalized).toMatchObject({
superpowersEnabled: false,
agents: [{ builtIn: false, prompt: '', skillIds: [], model: 'openai/gpt-4o-mini' }],
});
expect('superpowersEnabled' in normalized).toBe(false);
expect('templateId' in normalized).toBe(false);
});
it('migrates a legacy project default model into contacts without one', () => {
const normalized = normalizeProjectConfig({
...createProjectConfig(),
initialized: true,
defaultModel: 'qwen/qwen3.5-plus',
agents: [
createContact({ model: null }),
createContact({ id: 'agent-test-2', name: '小红', model: 'deepseek/deepseek-chat' }),
],
});
expect(normalized.defaultModel).toBe('qwen/qwen3.5-plus');
expect(normalized.agents).toEqual([
expect.objectContaining({ id: 'agent-test', model: 'qwen/qwen3.5-plus' }),
expect.objectContaining({ id: 'agent-test-2', model: 'deepseek/deepseek-chat' }),
]);
});
it('reads and materializes the migrated model for a legacy project', async () => {
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-project-config-migration-'));
const initial = await createInitialProjectConfig(projectPath, { defaultModel: 'qwen/qwen3.5-plus' });
await writeFile(
path.join(projectPath, '.niancode', 'project.json'),
`${JSON.stringify({
...initial,
initialized: true,
agents: [createContact({ model: null })],
}, null, 2)}\n`,
'utf8',
);
const loaded = await readProjectConfig(projectPath);
expect(loaded).toMatchObject({
status: 'valid',
config: { agents: [expect.objectContaining({ model: 'qwen/qwen3.5-plus' })] },
});
const persisted = JSON.parse(await readFile(path.join(projectPath, '.niancode', 'project.json'), 'utf8')) as { agents: ProjectAgentConfig[] };
expect(persisted.agents[0]?.model).toBe('qwen/qwen3.5-plus');
expect(await readFile(path.join(projectPath, '.opencode', 'agent', 'agent-test.md'), 'utf8'))
.toContain('model: "qwen/qwen3.5-plus"');
});
it('preserves the legacy built-in marker when reading an existing project', () => {
const config = createProjectConfig();
const normalized = normalizeProjectConfig({