diff --git a/CHANGELOG.md b/CHANGELOG.md index af503700..687d8e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ All notable changes to DreamCoder will be documented in this file. ### Fixed +- Plugin reloads without an active session now include user-defined and plugin-defined agents in the agent count (#301). - The main session now tells the agent when its memory index is empty or has not been created yet (#296). Thanks @Benson-BS. - Asking the agent to change a setting no longer fails: the `update-config` skill builds its settings reference again (#293). Thanks @KingEmma7. - **Saving a memory no longer asks for approval every time.** Writes to the project's memory folder are allowed like the instructions say, also in bypass mode (#270). diff --git a/src/server/__tests__/plugins.test.ts b/src/server/__tests__/plugins.test.ts index 45ca10bb..be6be5b2 100644 --- a/src/server/__tests__/plugins.test.ts +++ b/src/server/__tests__/plugins.test.ts @@ -179,6 +179,26 @@ describe('Plugins API', () => { expect(typeof body.summary.errors).toBe('number') }) + it('POST /api/plugins/reload counts user agents without a cwd', async () => { + const reload = async () => { + const { req, url, segments } = makeRequest('POST', '/api/plugins/reload', {}) + const res = await handlePluginsApi(req, url, segments) + expect(res.status).toBe(200) + const body = await res.json() as { summary: { agents: number } } + return body.summary.agents + } + + const before = await reload() + await fs.mkdir(path.join(tmpDir, 'agents'), { recursive: true }) + await fs.writeFile( + path.join(tmpDir, 'agents', 'reload-count-agent.md'), + '---\nname: reload-count-agent\ndescription: Counts after a plugin reload.\n---\n\nVerify the reload count.\n', + 'utf-8', + ) + + expect(await reload()).toBe(before + 1) + }) + it('POST /api/plugins/reload hot-reloads an active CLI session and updates slash commands', async () => { const controlRequests: Array<{ sessionId: string; request: Record }> = [] conversationService.hasSession = ((sessionId: string) => sessionId === 'session-plugins') as typeof conversationService.hasSession diff --git a/src/server/services/pluginService.ts b/src/server/services/pluginService.ts index 941f72a6..44249a12 100644 --- a/src/server/services/pluginService.ts +++ b/src/server/services/pluginService.ts @@ -28,6 +28,7 @@ import { getPluginSkills } from '../../utils/plugins/loadPluginCommands.js' import { clearPluginCacheExclusions } from '../../utils/plugins/orphanedPluginFilter.js' import { parseFrontmatter } from '../../utils/frontmatterParser.js' import { extractDescriptionFromMarkdown } from '../../utils/markdownConfigLoader.js' +import { getCwd } from '../../utils/cwd.js' import { resetSettingsCache } from '../../utils/settings/settingsCache.js' import type { PluginInstallationEntry, @@ -240,7 +241,7 @@ export class PluginService { const [skills, agentDefinitions] = await Promise.all([ getPluginSkills(), - getAgentDefinitionsWithOverrides(cwd), + getAgentDefinitionsWithOverrides(cwd ?? getCwd()), ]) const hookCount = await this.getHookCount(enabled)