fix(plugins): expose enabled skills for agent assignment

This commit is contained in:
2026-09-01 20:27:51 +08:00
parent 08099ea1c2
commit adc28db785
3 changed files with 146 additions and 6 deletions

View File

@@ -218,6 +218,56 @@ describe('PI-105 product Host composition', () => {
}));
});
it('offers an enabled Web Search Skill before its first Agent assignment', async () => {
const root = await configuredProject(['agent-browser']);
const tools = new PiProductTools({
browser: {} as AgentBrowserModule,
attachments: new CodingAttachmentStore(path.join(root, 'attachments')),
bundledSkillsDir: path.resolve('resources/coding-skills'),
pluginSkillSources: [{
id: 'makelore-web-search',
pluginId: 'makelore.web-search',
directory: path.resolve(
'resources/coding-plugins/web-search/skills/makelore-web-search',
),
}],
});
const effectiveResolver = {
resolve: vi.fn(async () => ({
accountSessionId: 'account-a\u00001',
projectId: 'project-a',
pluginReleaseIds: [],
effectiveSkillIds: [],
skillEntries: [],
toolDefinitions: [],
runtimePolicies: [],
unavailableReasons: [{
pluginId: 'makelore.web-search',
code: 'skill_unassigned' as const,
message: 'Plugin Skill is not assigned',
}],
})),
getSkillSources: vi.fn(async () => []),
getPolicyState: vi.fn(() => ({
status: 'current' as const, catalog: null, revision: 1, lastVerifiedAt: 1,
})),
};
const host = createCodingProductHost({
projects: projectService(root),
productTools: tools,
effectiveResolver,
getEnabledPluginIds: async () => ['makelore.web-search'],
});
await expect(host.listSkills()).resolves.toContainEqual(expect.objectContaining({
id: 'makelore-web-search', selected: false, available: true, effective: false,
}));
expect(effectiveResolver.resolve).not.toHaveBeenCalled();
await expect(host.listSkills('builder')).resolves.not.toContainEqual(
expect.objectContaining({ id: 'makelore-web-search', available: true }),
);
});
it('reads exact-run changes from the same PiProductTools tracker instance', async () => {
const root = await configuredProject();
await writeFile(path.join(root, 'notes.txt'), 'baseline\n', 'utf8');