完善客户端模块与工作区能力
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-13 19:45:30 +08:00
parent 0148b91a15
commit 22add3f01f
97 changed files with 4756 additions and 3226 deletions

View File

@@ -94,6 +94,24 @@ describe('project-owned contact configuration', () => {
expect('templateId' in normalized).toBe(false);
});
it('preserves a valid compressed custom avatar and drops unsafe avatar data', () => {
const customAvatar = 'data:image/webp;base64,YXZhdGFy';
const config = createProjectConfig();
const normalized = normalizeProjectConfig({
...config,
initialized: true,
agents: [createContact({ avatarDataUrl: customAvatar })],
});
expect(normalized.agents[0]?.avatarDataUrl).toBe(customAvatar);
const invalid = normalizeProjectConfig({
...config,
initialized: true,
agents: [createContact({ avatarDataUrl: 'file:///tmp/avatar.png' })],
});
expect(invalid.agents[0]?.avatarDataUrl).toBeUndefined();
});
it('migrates a legacy project default model into contacts without one', () => {
const normalized = normalizeProjectConfig({
...createProjectConfig(),
@@ -165,6 +183,37 @@ describe('project-owned contact configuration', () => {
expect(markdown).toContain('"*": deny');
});
it('denies unselected skills when a contact has selected skills', async () => {
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-project-config-selected-skills-'));
const initial = await createInitialProjectConfig(projectPath);
await writeProjectConfig(projectPath, {
...initial,
initialized: true,
agents: [createContact({ skillIds: ['game-assets'] })],
});
const markdown = await readFile(path.join(projectPath, '.opencode', 'agent', 'agent-test.md'), 'utf8');
expect(markdown).toContain(' "*": deny\n game-assets: allow');
expect(markdown).not.toContain(' "*": allow');
});
it('repairs stale Agent skill permissions when reading an existing project', async () => {
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-project-config-skill-migration-'));
const initial = await createInitialProjectConfig(projectPath);
await writeProjectConfig(projectPath, {
...initial,
initialized: true,
agents: [createContact({ skillIds: ['game-assets'] })],
});
const agentPath = path.join(projectPath, '.opencode', 'agent', 'agent-test.md');
const staleMarkdown = (await readFile(agentPath, 'utf8')).replace(' "*": deny\n', '');
await writeFile(agentPath, staleMarkdown, 'utf8');
await expect(readProjectConfig(projectPath)).resolves.toMatchObject({ status: 'valid' });
expect(await readFile(agentPath, 'utf8')).toContain(' "*": deny\n game-assets: allow');
});
it('does not install default Agent files or template documents in a new project', async () => {
const projectPath = await mkdtemp(path.join(tmpdir(), 'makelore-project-config-empty-'));
const initial = await createInitialProjectConfig(projectPath);