fix(plugins): load official hosted plugins from bundled resources

This commit is contained in:
2026-09-01 18:20:24 +08:00
parent 52e2a97a12
commit 1530ac7740
23 changed files with 835 additions and 48 deletions

View File

@@ -20,6 +20,8 @@ import {
} from '../../shared/coding-plugins';
const PACKAGE_ROOT = path.resolve('resources/coding-plugins/data-service');
const GAME_RESOURCE_ROOT = path.resolve('resources/coding-plugins/game-resource');
const WEB_SEARCH_ROOT = path.resolve('resources/coding-plugins/web-search');
async function packageManifests(): Promise<{ root: Record<string, unknown>; capability: Record<string, unknown> }> {
return {
@@ -32,9 +34,13 @@ describe('bundled coding plugin manifests', () => {
it('loads the fixed Data Service package and immutable declarations', async () => {
const definitions = await loadBundledCodingPluginDefinitions(path.resolve('resources/coding-plugins'));
const startupDefinitions = loadBundledCodingPluginDefinitionsSync(path.resolve('resources/coding-plugins'));
expect(BUNDLED_CODING_PLUGIN_ROOTS).toEqual(['data-service']);
expect(resolveBundledCodingPluginRootPaths(path.resolve('resources/coding-plugins'))).toEqual([PACKAGE_ROOT]);
expect(definitions).toHaveLength(1);
expect(BUNDLED_CODING_PLUGIN_ROOTS).toEqual(['data-service', 'game-resource', 'web-search']);
expect(resolveBundledCodingPluginRootPaths(path.resolve('resources/coding-plugins'))).toEqual([
PACKAGE_ROOT,
GAME_RESOURCE_ROOT,
WEB_SEARCH_ROOT,
]);
expect(definitions).toHaveLength(3);
expect(definitions[0]).toMatchObject({
id: 'makelore.data-service',
adapterId: 'data-service',
@@ -42,7 +48,21 @@ describe('bundled coding plugin manifests', () => {
skills: [{ id: 'data-service', entryPath: 'skills/data-service/SKILL.md' }],
});
expect(definitions[0]?.tools.map(({ name }) => name)).toEqual(DATA_SERVICE_TOOL_NAMES);
expect(definitions).toEqual([DATA_SERVICE_PLUGIN_DEFINITION]);
expect(definitions[0]).toEqual(DATA_SERVICE_PLUGIN_DEFINITION);
expect(definitions.slice(1)).toMatchObject([
{
id: 'makelore.game-resource', version: '1.0.0', runtimeKind: 'platform_hosted',
acquisitionMode: 'user_acquired', releaseId: '00000000-0000-4000-8000-000000000105',
provenance: { source: 'bundled', packageRoot: 'game-resource' },
skills: [{ id: 'game-resource', entryPath: 'skills/game-resource/SKILL.md' }],
},
{
id: 'makelore.web-search', version: '1.0.0', runtimeKind: 'platform_hosted',
acquisitionMode: 'user_acquired', releaseId: '00000000-0000-4000-8000-000000000204',
provenance: { source: 'bundled', packageRoot: 'web-search' },
skills: [{ id: 'makelore-web-search', entryPath: 'skills/makelore-web-search/SKILL.md' }],
},
]);
expect(startupDefinitions).toEqual(definitions);
expect(Object.isFrozen(startupDefinitions)).toBe(true);
expect(Object.isFrozen(startupDefinitions[0]?.operations)).toBe(true);
@@ -115,6 +135,8 @@ describe('bundled coding plugin manifests', () => {
it('does not infer package roots from arbitrary directories', async () => {
expect(resolveBundledCodingPluginRootPaths(path.resolve('tmp'))).toEqual([
path.resolve('tmp/data-service'),
path.resolve('tmp/game-resource'),
path.resolve('tmp/web-search'),
]);
});