完善客户端模块与工作区能力
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user