mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 21:44:25 -07:00
feat(core, ui): Add /agents refresh command. (#16204)
This commit is contained in:
@@ -99,7 +99,7 @@ describe('AgentRegistry', () => {
|
||||
|
||||
const agentCount = debugRegistry.getAllDefinitions().length;
|
||||
expect(debugLogSpy).toHaveBeenCalledWith(
|
||||
`[AgentRegistry] Initialized with ${agentCount} agents.`,
|
||||
`[AgentRegistry] Loaded with ${agentCount} agents.`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -444,6 +444,37 @@ describe('AgentRegistry', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('reload', () => {
|
||||
it('should clear existing agents and reload from directories', async () => {
|
||||
const config = makeFakeConfig({ enableAgents: true });
|
||||
const registry = new TestableAgentRegistry(config);
|
||||
|
||||
const initialAgent = { ...MOCK_AGENT_V1, name: 'InitialAgent' };
|
||||
await registry.testRegisterAgent(initialAgent);
|
||||
expect(registry.getDefinition('InitialAgent')).toBeDefined();
|
||||
|
||||
const newAgent = { ...MOCK_AGENT_V1, name: 'NewAgent' };
|
||||
vi.mocked(tomlLoader.loadAgentsFromDirectory).mockResolvedValue({
|
||||
agents: [newAgent],
|
||||
errors: [],
|
||||
});
|
||||
|
||||
const clearCacheSpy = vi.fn();
|
||||
vi.mocked(A2AClientManager.getInstance).mockReturnValue({
|
||||
clearCache: clearCacheSpy,
|
||||
} as unknown as A2AClientManager);
|
||||
|
||||
const emitSpy = vi.spyOn(coreEvents, 'emitAgentsRefreshed');
|
||||
|
||||
await registry.reload();
|
||||
|
||||
expect(clearCacheSpy).toHaveBeenCalled();
|
||||
expect(registry.getDefinition('InitialAgent')).toBeUndefined();
|
||||
expect(registry.getDefinition('NewAgent')).toBeDefined();
|
||||
expect(emitSpy).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('inheritance and refresh', () => {
|
||||
it('should resolve "inherit" to the current model from configuration', async () => {
|
||||
const config = makeFakeConfig({ model: 'current-model' });
|
||||
|
||||
Reference in New Issue
Block a user