feat(plugins): bundle project scaffold marketplace plugin
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
||||
|
||||
const PACKAGE_ROOT = path.resolve('resources/coding-plugins/data-service');
|
||||
const GAME_RESOURCE_ROOT = path.resolve('resources/coding-plugins/game-resource');
|
||||
const PROJECT_SCAFFOLD_ROOT = path.resolve('resources/coding-plugins/project-scaffold');
|
||||
|
||||
async function packageManifests(): Promise<{ root: Record<string, unknown>; capability: Record<string, unknown> }> {
|
||||
return {
|
||||
@@ -33,12 +34,17 @@ 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', 'game-resource']);
|
||||
expect(BUNDLED_CODING_PLUGIN_ROOTS).toEqual([
|
||||
'data-service',
|
||||
'game-resource',
|
||||
'project-scaffold',
|
||||
]);
|
||||
expect(resolveBundledCodingPluginRootPaths(path.resolve('resources/coding-plugins'))).toEqual([
|
||||
PACKAGE_ROOT,
|
||||
GAME_RESOURCE_ROOT,
|
||||
PROJECT_SCAFFOLD_ROOT,
|
||||
]);
|
||||
expect(definitions).toHaveLength(2);
|
||||
expect(definitions).toHaveLength(3);
|
||||
expect(definitions[0]).toMatchObject({
|
||||
id: 'makelore.data-service',
|
||||
adapterId: 'data-service',
|
||||
@@ -54,6 +60,17 @@ describe('bundled coding plugin manifests', () => {
|
||||
provenance: { source: 'bundled', packageRoot: 'game-resource' },
|
||||
skills: [{ id: 'game-resource', entryPath: 'skills/game-resource/SKILL.md' }],
|
||||
},
|
||||
{
|
||||
id: 'makelore.project-scaffold', version: '1.0.0', runtimeKind: 'skill_only',
|
||||
acquisitionMode: 'user_acquired', releaseId: '00000000-0000-4000-8000-000000000303',
|
||||
provenance: { source: 'bundled', packageRoot: 'project-scaffold' },
|
||||
skills: [{
|
||||
id: 'makelore-project-scaffold',
|
||||
entryPath: 'skills/makelore-project-scaffold/SKILL.md',
|
||||
grants: [],
|
||||
}],
|
||||
tools: [],
|
||||
},
|
||||
]);
|
||||
expect(startupDefinitions).toEqual(definitions);
|
||||
expect(Object.isFrozen(startupDefinitions)).toBe(true);
|
||||
@@ -128,6 +145,7 @@ describe('bundled coding plugin manifests', () => {
|
||||
expect(resolveBundledCodingPluginRootPaths(path.resolve('tmp'))).toEqual([
|
||||
path.resolve('tmp/data-service'),
|
||||
path.resolve('tmp/game-resource'),
|
||||
path.resolve('tmp/project-scaffold'),
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -1419,8 +1419,8 @@ describe('PluginPackageStore', () => {
|
||||
});
|
||||
const cases = [
|
||||
{
|
||||
name: 'unsupported asset extension',
|
||||
archive: buildSkillOnlyArchive({ 'skills/example-skill/assets/run.exe': Buffer.from('not executable') }),
|
||||
name: 'executable Skill script in a downloadable artifact',
|
||||
archive: buildSkillOnlyArchive({ 'skills/example-skill/scripts/run.mjs': Buffer.from('export {};') }),
|
||||
},
|
||||
{
|
||||
name: 'non-UTF-8 Skill text',
|
||||
|
||||
@@ -261,40 +261,45 @@ describe('buildPluginWorkspaceProjection', () => {
|
||||
});
|
||||
|
||||
it('keeps bundled and downloadable official command sets inside their delivery boundaries', () => {
|
||||
const bundledCatalog = {
|
||||
...catalog.items[0]!,
|
||||
pluginId: 'makelore.game-resource',
|
||||
title: 'Game Resource',
|
||||
runtimeKind: 'bundled_typed' as const,
|
||||
};
|
||||
const bundledLibrary = {
|
||||
...library.items[0]!,
|
||||
pluginId: bundledCatalog.pluginId,
|
||||
title: bundledCatalog.title,
|
||||
};
|
||||
const bundledProject = {
|
||||
...project,
|
||||
items: [{
|
||||
...project.items[0]!,
|
||||
id: bundledCatalog.pluginId,
|
||||
displayName: bundledCatalog.title,
|
||||
enabled: false,
|
||||
state: 'disabled' as const,
|
||||
}],
|
||||
};
|
||||
for (const [pluginId, title, runtimeKind] of [
|
||||
['makelore.game-resource', 'Game Resource', 'platform_hosted'],
|
||||
['makelore.project-scaffold', 'Project Scaffold', 'skill_only'],
|
||||
] as const) {
|
||||
const bundledCatalog = {
|
||||
...catalog.items[0]!,
|
||||
pluginId,
|
||||
title,
|
||||
runtimeKind,
|
||||
};
|
||||
const bundledLibrary = {
|
||||
...library.items[0]!,
|
||||
pluginId: bundledCatalog.pluginId,
|
||||
title: bundledCatalog.title,
|
||||
};
|
||||
const bundledProject = {
|
||||
...project,
|
||||
items: [{
|
||||
...project.items[0]!,
|
||||
id: bundledCatalog.pluginId,
|
||||
displayName: bundledCatalog.title,
|
||||
enabled: false,
|
||||
state: 'disabled' as const,
|
||||
}],
|
||||
};
|
||||
|
||||
expect(commandKinds({
|
||||
catalog: { ...catalog, items: [bundledCatalog] },
|
||||
library: { ...library, items: [] },
|
||||
marketplaceInstallations: {},
|
||||
project: null,
|
||||
})).toEqual(['acquire']);
|
||||
expect(commandKinds({
|
||||
catalog: { ...catalog, items: [bundledCatalog] },
|
||||
library: { ...library, items: [bundledLibrary] },
|
||||
marketplaceInstallations: {},
|
||||
project: bundledProject,
|
||||
})).toEqual(['remove_from_library', 'enable_project', 'open_agent_assignment']);
|
||||
expect(commandKinds({
|
||||
catalog: { ...catalog, items: [bundledCatalog] },
|
||||
library: { ...library, items: [] },
|
||||
marketplaceInstallations: {},
|
||||
project: null,
|
||||
})).toEqual(['acquire']);
|
||||
expect(commandKinds({
|
||||
catalog: { ...catalog, items: [bundledCatalog] },
|
||||
library: { ...library, items: [bundledLibrary] },
|
||||
marketplaceInstallations: {},
|
||||
project: bundledProject,
|
||||
})).toEqual(['remove_from_library', 'enable_project', 'open_agent_assignment']);
|
||||
}
|
||||
|
||||
expect(commandKinds({ marketplaceInstallations: {} })).toEqual([
|
||||
'remove_from_library',
|
||||
|
||||
@@ -3,18 +3,22 @@
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { dirname, join, resolve } from 'node:path';
|
||||
import { join, resolve } from 'node:path';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import {
|
||||
devicePackageKind,
|
||||
inspectDevicePackage,
|
||||
} from '@electron/coding-packages/device-package-format';
|
||||
import { DevicePackageManager } from '@electron/coding-packages/device-package-manager';
|
||||
import { loadBundledCodingPluginDefinitions } from '@electron/coding-plugins/manifest';
|
||||
import { createCodingProjectMetadata } from '@electron/coding-projects/project-config';
|
||||
import { createStaticProjectPackage } from '@electron/services/project-packager';
|
||||
import type { ProjectType } from '../../shared/project-config';
|
||||
import {
|
||||
PROJECT_SCAFFOLD_BUNDLED_RELEASE_ID,
|
||||
PROJECT_SCAFFOLD_PLUGIN_ID,
|
||||
isCodeOwnedOptionalBundledPluginId,
|
||||
} from '../../shared/coding-plugins';
|
||||
|
||||
const pluginRoot = resolve('plugins/makelore-project-scaffold');
|
||||
const pluginRoot = resolve('resources/coding-plugins/project-scaffold');
|
||||
const scaffoldScript = join(
|
||||
pluginRoot,
|
||||
'skills',
|
||||
@@ -42,23 +46,30 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe('MakeLore project scaffold plugin', () => {
|
||||
it('is discovered as a skill-only package with executable Skill scripts', async () => {
|
||||
it('loads as a fixed code-owned bundled Skill while retaining portable plugin metadata', async () => {
|
||||
const packageJson = JSON.parse(await readFile(join(pluginRoot, 'package.json'), 'utf8'));
|
||||
const pluginManifest = JSON.parse(await readFile(
|
||||
const portableManifest = JSON.parse(await readFile(
|
||||
join(pluginRoot, '.codex-plugin', 'plugin.json'),
|
||||
'utf8',
|
||||
));
|
||||
const marketplaceManifest = JSON.parse(await readFile(join(pluginRoot, 'plugin.json'), 'utf8'));
|
||||
const inspected = await inspectDevicePackage(pluginRoot);
|
||||
const definitions = await loadBundledCodingPluginDefinitions(resolve('resources/coding-plugins'));
|
||||
const definition = definitions.find(({ id }) => id === PROJECT_SCAFFOLD_PLUGIN_ID);
|
||||
|
||||
expect({ name: packageJson.name, version: packageJson.version }).toEqual({
|
||||
name: pluginManifest.name,
|
||||
version: pluginManifest.version,
|
||||
name: marketplaceManifest.name,
|
||||
version: marketplaceManifest.version,
|
||||
});
|
||||
expect(pluginManifest.skills).toBe('./skills/');
|
||||
expect({ name: portableManifest.name, version: portableManifest.version }).toEqual({
|
||||
name: marketplaceManifest.name,
|
||||
version: marketplaceManifest.version,
|
||||
});
|
||||
expect(portableManifest.skills).toBe('./skills/');
|
||||
expect(devicePackageKind(inspected)).toBe('skill-only');
|
||||
expect(inspected).toMatchObject({
|
||||
packageId: 'makelore-project-scaffold',
|
||||
resolvedVersion: '0.1.0',
|
||||
packageId: PROJECT_SCAFFOLD_PLUGIN_ID,
|
||||
resolvedVersion: '1.0.0',
|
||||
extensionEntries: [],
|
||||
hasSkillScripts: true,
|
||||
ignoredLifecycleScripts: [],
|
||||
@@ -67,30 +78,25 @@ describe('MakeLore project scaffold plugin', () => {
|
||||
entryPath: 'skills/makelore-project-scaffold/SKILL.md',
|
||||
}],
|
||||
});
|
||||
expect(definition).toMatchObject({
|
||||
id: PROJECT_SCAFFOLD_PLUGIN_ID,
|
||||
version: '1.0.0',
|
||||
runtimeKind: 'skill_only',
|
||||
acquisitionMode: 'user_acquired',
|
||||
releaseId: PROJECT_SCAFFOLD_BUNDLED_RELEASE_ID,
|
||||
provenance: { source: 'bundled', packageRoot: 'project-scaffold' },
|
||||
skills: [{
|
||||
id: 'makelore-project-scaffold',
|
||||
entryPath: 'skills/makelore-project-scaffold/SKILL.md',
|
||||
grants: [],
|
||||
}],
|
||||
tools: [],
|
||||
});
|
||||
expect(isCodeOwnedOptionalBundledPluginId(PROJECT_SCAFFOLD_PLUGIN_ID)).toBe(true);
|
||||
});
|
||||
|
||||
it('prepares, confirms, and installs the real package with every Skill resource', async () => {
|
||||
const root = await mkdtemp(join(tmpdir(), 'makelore-scaffold-device-package-'));
|
||||
tempDirectories.push(root);
|
||||
const manager = new DevicePackageManager({
|
||||
rootDir: join(root, 'store'),
|
||||
now: () => Date.parse('2026-09-04T00:00:00.000Z'),
|
||||
createId: () => 'project-scaffold-plan',
|
||||
});
|
||||
|
||||
const preview = await manager.prepare(pluginRoot, 'prepare-turn');
|
||||
expect(preview).toMatchObject({
|
||||
kind: 'skill-only',
|
||||
includesExecutableCode: true,
|
||||
skillEntries: [{ id: 'makelore-project-scaffold' }],
|
||||
extensionEntries: [],
|
||||
});
|
||||
expect(preview.warnings.join(' ')).toContain('可执行 Skill 脚本');
|
||||
await manager.commit(preview.planId, true, 'confirm-turn');
|
||||
|
||||
const [resource] = (await manager.resolveEnabledResources()).skillEntries;
|
||||
expect(resource?.id).toBe('makelore-project-scaffold');
|
||||
const skillRoot = dirname(join(resource!.packageRoot, resource!.entryPath));
|
||||
it('ships the executable scaffold and every Skill resource in the bundled root', async () => {
|
||||
const skillRoot = join(pluginRoot, 'skills', 'makelore-project-scaffold');
|
||||
expect(await readFile(join(skillRoot, 'scripts', 'scaffold.mjs'), 'utf8'))
|
||||
.toContain('schemaVersion: 1');
|
||||
expect(await readFile(join(skillRoot, 'assets', 'templates', 'common', 'package-lock.json'), 'utf8'))
|
||||
@@ -164,7 +170,7 @@ describe('MakeLore project scaffold plugin', () => {
|
||||
});
|
||||
|
||||
it('creates an interactive AI application accepted by the existing source packager', async () => {
|
||||
const projectType: ProjectType = 'interactive_ai_app';
|
||||
const projectType = 'interactive_ai_app' as const;
|
||||
const projectPath = await mkdtemp(join(tmpdir(), `makelore-${projectType}-`));
|
||||
const outputPath = await mkdtemp(join(tmpdir(), 'makelore-scaffold-package-'));
|
||||
tempDirectories.push(projectPath, outputPath);
|
||||
|
||||
Reference in New Issue
Block a user