feat: add built-in agent(general-purpose)

This commit is contained in:
tanzhenxin
2025-09-09 20:53:53 +08:00
parent 3c67dc0c0b
commit 549f296eb5
19 changed files with 896 additions and 228 deletions

View File

@@ -584,11 +584,12 @@ System prompt 3`);
it('should list subagents from both levels', async () => {
const subagents = await manager.listSubagents();
expect(subagents).toHaveLength(3); // agent1 (project takes precedence), agent2, agent3
expect(subagents).toHaveLength(4); // agent1 (project takes precedence), agent2, agent3, general-purpose (built-in)
expect(subagents.map((s) => s.name)).toEqual([
'agent1',
'agent2',
'agent3',
'general-purpose',
]);
});
@@ -615,7 +616,7 @@ System prompt 3`);
});
const names = subagents.map((s) => s.name);
expect(names).toEqual(['agent1', 'agent2', 'agent3']);
expect(names).toEqual(['agent1', 'agent2', 'agent3', 'general-purpose']);
});
it('should handle empty directories', async () => {
@@ -626,7 +627,9 @@ System prompt 3`);
const subagents = await manager.listSubagents();
expect(subagents).toHaveLength(0);
expect(subagents).toHaveLength(1); // Only built-in agents remain
expect(subagents[0].name).toBe('general-purpose');
expect(subagents[0].level).toBe('builtin');
});
it('should handle directory read errors', async () => {
@@ -636,7 +639,9 @@ System prompt 3`);
const subagents = await manager.listSubagents();
expect(subagents).toHaveLength(0);
expect(subagents).toHaveLength(1); // Only built-in agents remain
expect(subagents[0].name).toBe('general-purpose');
expect(subagents[0].level).toBe('builtin');
});
it('should skip invalid subagent files', async () => {
@@ -656,7 +661,7 @@ System prompt 3`);
const subagents = await manager.listSubagents();
expect(subagents).toHaveLength(1);
expect(subagents).toHaveLength(2); // 1 valid file + 1 built-in agent
expect(consoleSpy).toHaveBeenCalledWith(
expect.stringContaining('Skipping invalid subagent file'),
);