@lesliechan721/aw-plugin-core 0.1.0-beta.7 → 0.1.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aw-capabilities.d.ts +27 -0
- package/dist/aw-capabilities.js +105 -0
- package/dist/aw-capabilities.js.map +1 -0
- package/dist/catalog-workspace-resolution.d.ts +10 -0
- package/dist/catalog-workspace-resolution.js +103 -0
- package/dist/catalog-workspace-resolution.js.map +1 -0
- package/dist/generated/{plugin-manifest-v1.d.ts → plugin-manifest-v2.d.ts} +31 -31
- package/dist/generated/{plugin-manifest-v1.js → plugin-manifest-v2.js} +1 -1
- package/dist/generated/plugin-manifest-v2.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/manifest-contract.d.ts +3 -6
- package/dist/manifest-contract.js +34 -62
- package/dist/manifest-contract.js.map +1 -1
- package/dist/manifest-type-contract.d.ts +2 -2
- package/dist/manifest.d.ts +8 -8
- package/dist/manifest.js +9 -7
- package/dist/manifest.js.map +1 -1
- package/dist/plugin-authoring-capabilities.js +2 -2
- package/dist/plugin-authoring-capabilities.js.map +1 -1
- package/dist/plugin-release.d.ts +3 -3
- package/dist/plugin-requirements.d.ts +33 -0
- package/dist/plugin-requirements.js +388 -0
- package/dist/plugin-requirements.js.map +1 -0
- package/dist/plugin-script-contract.d.ts +8 -0
- package/dist/plugin-script-contract.js +38 -1
- package/dist/plugin-script-contract.js.map +1 -1
- package/dist/types.d.ts +18 -19
- package/dist/workspace.d.ts +20 -4
- package/dist/workspace.js +352 -58
- package/dist/workspace.js.map +1 -1
- package/package.json +2 -2
- package/schemas/{plugin-manifest-v1.json → plugin-manifest-v2.json} +14 -8
- package/dist/generated/plugin-manifest-v1.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { isDeepStrictEqual } from 'node:util';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
|
+
import { normalizeAwCapabilities } from './aw-capabilities.js';
|
|
4
5
|
import { normalizePluginManifestSchemaVersion, PLUGIN_MANIFEST_SCHEMA_VERSION, SOURCE_PLUGIN_MANIFEST_CONTRACT_VERSION, } from './manifest.js';
|
|
5
6
|
import { readJsonFile } from './read-json.js';
|
|
6
7
|
import { parsePermissionCommand } from './permission-command.js';
|
|
@@ -29,7 +30,6 @@ const PLATFORM_PRODUCT_BY_NAME = {
|
|
|
29
30
|
};
|
|
30
31
|
const PLUGIN_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
31
32
|
const DIGEST_PATTERN = /^sha256:[0-9a-f]{64}$/;
|
|
32
|
-
export const DEFAULT_SOURCE_PLUGIN_AW_MIN_VERSION = '0.0.0';
|
|
33
33
|
const STRICT_SEMVER_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|(?:[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))(?:\.(?:0|[1-9]\d*|(?:[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;
|
|
34
34
|
export const STRICT_SEMVER_VALIDATION_CODE = 'invalidStrictSemVer';
|
|
35
35
|
export class StrictSemVerValidationError extends Error {
|
|
@@ -265,30 +265,26 @@ function assertCatalogChannel(value, fieldName) {
|
|
|
265
265
|
}
|
|
266
266
|
return channel;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
269
|
-
return {
|
|
270
|
-
aw: {
|
|
271
|
-
minVersion,
|
|
272
|
-
},
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
function normalizePluginCompatibility(value, fieldName, options) {
|
|
268
|
+
function normalizePluginRequirements(value, fieldName, options) {
|
|
276
269
|
if (value === undefined) {
|
|
277
|
-
if (options.allowMissing)
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
|
-
throw new Error(`Invalid ${fieldName}.aw.minVersion: expected a strict SemVer 2.0.0 string. Received undefined.`);
|
|
270
|
+
if (options.allowMissing)
|
|
271
|
+
return undefined;
|
|
272
|
+
throw new Error(`Invalid ${fieldName}: expected an object.`);
|
|
281
273
|
}
|
|
282
274
|
const input = assertObject(value, fieldName);
|
|
283
275
|
assertAllowedKeys(input, fieldName, ['aw']);
|
|
284
276
|
const aw = assertObject(input.aw, `${fieldName}.aw`);
|
|
285
|
-
assertAllowedKeys(aw, `${fieldName}.aw`, ['
|
|
286
|
-
|
|
287
|
-
}
|
|
288
|
-
function assertPluginMinVersionWithinCatalogBounds(options) {
|
|
289
|
-
if (compareStrictSemVer(options.pluginMinVersion, options.catalogMinVersion) > 0) {
|
|
290
|
-
throw new Error(`Invalid ${options.fieldName}: plugin "${options.pluginName}" requires aw ${options.pluginMinVersion}, which is higher than catalog minimum ${options.catalogMinVersion}.`);
|
|
277
|
+
assertAllowedKeys(aw, `${fieldName}.aw`, ['capabilities']);
|
|
278
|
+
if (aw.capabilities !== undefined && !Array.isArray(aw.capabilities)) {
|
|
279
|
+
throw new Error(`Invalid ${fieldName}.aw.capabilities: expected an array.`);
|
|
291
280
|
}
|
|
281
|
+
return {
|
|
282
|
+
aw: {
|
|
283
|
+
...(aw.capabilities === undefined
|
|
284
|
+
? {}
|
|
285
|
+
: { capabilities: normalizeAwCapabilities(aw.capabilities, `${fieldName}.aw.capabilities`) }),
|
|
286
|
+
},
|
|
287
|
+
};
|
|
292
288
|
}
|
|
293
289
|
function normalizeMarketplaceProducts(value, fieldName) {
|
|
294
290
|
if (value === undefined) {
|
|
@@ -2006,7 +2002,7 @@ export async function assertActualNativePluginCapability(pluginRoot, manifest, m
|
|
|
2006
2002
|
}
|
|
2007
2003
|
}
|
|
2008
2004
|
if (!skills && !slashCommands && !mcpServers && !apps && !bundled) {
|
|
2009
|
-
throw new Error('Invalid plugin manifest: portable-only plugins are not supported
|
|
2005
|
+
throw new Error('Invalid plugin manifest: portable-only plugins are not supported. Declare at least one non-empty native capability.');
|
|
2010
2006
|
}
|
|
2011
2007
|
}
|
|
2012
2008
|
export function validatePluginManifest(pluginRoot, rawManifest, options = {}) {
|
|
@@ -2020,7 +2016,7 @@ export function validatePluginManifest(pluginRoot, rawManifest, options = {}) {
|
|
|
2020
2016
|
'version',
|
|
2021
2017
|
'description',
|
|
2022
2018
|
'dependencies',
|
|
2023
|
-
'
|
|
2019
|
+
'requires',
|
|
2024
2020
|
'skills',
|
|
2025
2021
|
'slashCommands',
|
|
2026
2022
|
'mcpServers',
|
|
@@ -2039,12 +2035,11 @@ export function validatePluginManifest(pluginRoot, rawManifest, options = {}) {
|
|
|
2039
2035
|
name: ensureString(input.name, 'name'),
|
|
2040
2036
|
version: assertStrictSemVer(input.version, 'plugin manifest.version'),
|
|
2041
2037
|
description: ensureString(input.description, 'description'),
|
|
2042
|
-
compatibility: normalizePluginCompatibility(input.compatibility, 'compatibility', {
|
|
2043
|
-
allowMissing: (options.compatibilityMode ?? 'defaulted') === 'defaulted',
|
|
2044
|
-
defaultMinVersion: options.defaultMinVersion,
|
|
2045
|
-
}),
|
|
2046
2038
|
marketplace: normalizeMarketplaceMeta(input.marketplace, 'marketplace'),
|
|
2047
2039
|
};
|
|
2040
|
+
const requires = normalizePluginRequirements(input.requires, 'requires', { allowMissing: true });
|
|
2041
|
+
if (requires !== undefined)
|
|
2042
|
+
manifest.requires = requires;
|
|
2048
2043
|
if (input.dependencies !== undefined) {
|
|
2049
2044
|
const dependencies = ensureStringArray(input.dependencies, 'dependencies');
|
|
2050
2045
|
if (dependencies.length > 64) {
|
|
@@ -2289,18 +2284,7 @@ async function validateSourceJsonNativeAsset(pluginRoot, manifest, field) {
|
|
|
2289
2284
|
}
|
|
2290
2285
|
export async function validateSourcePluginManifest(pluginRoot, rawManifest, options = {}) {
|
|
2291
2286
|
await assertPluginInputTree(pluginRoot);
|
|
2292
|
-
const distributionsInput = rawManifest !== null
|
|
2293
|
-
&& typeof rawManifest === 'object'
|
|
2294
|
-
&& !Array.isArray(rawManifest)
|
|
2295
|
-
? rawManifest.distributions
|
|
2296
|
-
: undefined;
|
|
2297
|
-
const requiresExplicitMinVersion = distributionsInput !== null
|
|
2298
|
-
&& typeof distributionsInput === 'object'
|
|
2299
|
-
&& !Array.isArray(distributionsInput)
|
|
2300
|
-
&& Object.hasOwn(distributionsInput, 'agentSkills');
|
|
2301
2287
|
const manifest = validatePluginManifest(pluginRoot, rawManifest, {
|
|
2302
|
-
compatibilityMode: requiresExplicitMinVersion ? 'required' : 'defaulted',
|
|
2303
|
-
defaultMinVersion: DEFAULT_SOURCE_PLUGIN_AW_MIN_VERSION,
|
|
2304
2288
|
reservedImports: options.reservedImports,
|
|
2305
2289
|
});
|
|
2306
2290
|
const parsedVersion = parseStrictSemVer(manifest.version, 'plugin manifest.version');
|
|
@@ -2337,10 +2321,7 @@ export async function readPluginManifest(pluginRoot, options = {}) {
|
|
|
2337
2321
|
? await validateSourcePluginManifest(pluginRoot, rawManifest, {
|
|
2338
2322
|
reservedImports: options.reservedImports,
|
|
2339
2323
|
})
|
|
2340
|
-
: validatePluginManifest(pluginRoot, rawManifest, {
|
|
2341
|
-
compatibilityMode: 'required',
|
|
2342
|
-
reservedImports: options.reservedImports,
|
|
2343
|
-
});
|
|
2324
|
+
: validatePluginManifest(pluginRoot, rawManifest, { reservedImports: options.reservedImports });
|
|
2344
2325
|
if (mode === 'bundle')
|
|
2345
2326
|
await assertActualNativePluginCapability(pluginRoot, manifest, 'bundle');
|
|
2346
2327
|
return {
|
|
@@ -2438,9 +2419,6 @@ function assertCatalogChannelVersionContract(options) {
|
|
|
2438
2419
|
}
|
|
2439
2420
|
function normalizeCatalogManifestEntry(value, fieldName) {
|
|
2440
2421
|
const input = assertObject(value, fieldName);
|
|
2441
|
-
if (Object.hasOwn(input, 'dependencies')) {
|
|
2442
|
-
throw new Error(`Invalid ${fieldName}: "dependencies" is unsupported.`);
|
|
2443
|
-
}
|
|
2444
2422
|
assertAllowedKeys(input, fieldName, [
|
|
2445
2423
|
'name',
|
|
2446
2424
|
'version',
|
|
@@ -2450,7 +2428,8 @@ function normalizeCatalogManifestEntry(value, fieldName) {
|
|
|
2450
2428
|
'tags',
|
|
2451
2429
|
'strict',
|
|
2452
2430
|
'policy',
|
|
2453
|
-
'
|
|
2431
|
+
'dependencies',
|
|
2432
|
+
'requires',
|
|
2454
2433
|
'source',
|
|
2455
2434
|
'artifactDigest',
|
|
2456
2435
|
'manifestDigest',
|
|
@@ -2462,7 +2441,11 @@ function normalizeCatalogManifestEntry(value, fieldName) {
|
|
|
2462
2441
|
category: ensureString(input.category, `${fieldName}.category`),
|
|
2463
2442
|
strict: ensureBoolean(input.strict, `${fieldName}.strict`),
|
|
2464
2443
|
policy: normalizeMarketplacePolicy(input.policy, `${fieldName}.policy`),
|
|
2465
|
-
|
|
2444
|
+
dependencies: input.dependencies === undefined
|
|
2445
|
+
? []
|
|
2446
|
+
: normalizeComparableStringArray(ensureStringArray(input.dependencies, `${fieldName}.dependencies`))
|
|
2447
|
+
.map((dependency, index) => ensurePluginName(dependency, `${fieldName}.dependencies[${index}]`)),
|
|
2448
|
+
requires: normalizePluginRequirements(input.requires, `${fieldName}.requires`, {
|
|
2466
2449
|
allowMissing: false,
|
|
2467
2450
|
}),
|
|
2468
2451
|
source: normalizeCatalogRelativePath(input.source, `${fieldName}.source`),
|
|
@@ -2486,8 +2469,8 @@ export function normalizeCatalogManifestBase(input, fieldName) {
|
|
|
2486
2469
|
fieldName: `${fieldName}.catalogVersion`,
|
|
2487
2470
|
kind: 'catalog',
|
|
2488
2471
|
});
|
|
2489
|
-
const
|
|
2490
|
-
return { catalogVersion, channel,
|
|
2472
|
+
const requires = normalizePluginRequirements(input.requires, `${fieldName}.requires`, { allowMissing: false });
|
|
2473
|
+
return { catalogVersion, channel, requires };
|
|
2491
2474
|
}
|
|
2492
2475
|
export function normalizeCatalogManifestEntries(rawEntries, base, fieldName) {
|
|
2493
2476
|
if (!Array.isArray(rawEntries)) {
|
|
@@ -2508,16 +2491,10 @@ export function normalizeCatalogManifestEntries(rawEntries, base, fieldName) {
|
|
|
2508
2491
|
kind: 'plugin',
|
|
2509
2492
|
});
|
|
2510
2493
|
}
|
|
2511
|
-
assertPluginMinVersionWithinCatalogBounds({
|
|
2512
|
-
pluginName: entry.name,
|
|
2513
|
-
pluginMinVersion: entry.compatibility.aw.minVersion,
|
|
2514
|
-
catalogMinVersion: base.compatibility.aw.minVersion,
|
|
2515
|
-
fieldName: `${fieldName}.entries.${entry.name}.compatibility.aw.minVersion`,
|
|
2516
|
-
});
|
|
2517
2494
|
}
|
|
2518
2495
|
return entries;
|
|
2519
2496
|
}
|
|
2520
|
-
export function createBundleSourceManifest(plugin) {
|
|
2497
|
+
export function createBundleSourceManifest(plugin, requiredCapabilities) {
|
|
2521
2498
|
const scripts = plugin.manifest.scripts
|
|
2522
2499
|
? structuredClone(plugin.manifest.scripts)
|
|
2523
2500
|
: undefined;
|
|
@@ -2543,9 +2520,9 @@ export function createBundleSourceManifest(plugin) {
|
|
|
2543
2520
|
return {
|
|
2544
2521
|
...plugin.manifest,
|
|
2545
2522
|
buildConfig,
|
|
2546
|
-
|
|
2547
|
-
? structuredClone(plugin.manifest.
|
|
2548
|
-
:
|
|
2523
|
+
requires: requiredCapabilities === undefined
|
|
2524
|
+
? structuredClone(plugin.manifest.requires)
|
|
2525
|
+
: { aw: { capabilities: normalizeAwCapabilities(requiredCapabilities) } },
|
|
2549
2526
|
extensions: plugin.manifest.extensions
|
|
2550
2527
|
? {
|
|
2551
2528
|
instructions: plugin.manifest.extensions.instructions
|
|
@@ -2580,11 +2557,6 @@ export function createPlatformManifestBase(plugin) {
|
|
|
2580
2557
|
name: plugin.manifest.name,
|
|
2581
2558
|
version: plugin.manifest.version,
|
|
2582
2559
|
description: plugin.manifest.description,
|
|
2583
|
-
compatibility: structuredClone(plugin.manifest.compatibility ?? {
|
|
2584
|
-
aw: {
|
|
2585
|
-
minVersion: '0.0.0',
|
|
2586
|
-
},
|
|
2587
|
-
}),
|
|
2588
2560
|
interface: plugin.manifest.interface,
|
|
2589
2561
|
};
|
|
2590
2562
|
}
|