@lesliechan721/aw 0.1.0-beta.80 → 0.1.0-beta.82

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.
Files changed (69) hide show
  1. package/dist/authoring/scripts/validate-plugin.mjs +114 -81
  2. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  3. package/dist/src/commands/catalog-publication-inspection.d.ts +0 -1
  4. package/dist/src/commands/catalog-publication-inspection.js +36 -29
  5. package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
  6. package/dist/src/commands/intent-command.d.ts +2 -1
  7. package/dist/src/commands/intent-command.js +3 -4
  8. package/dist/src/commands/intent-command.js.map +1 -1
  9. package/dist/src/commands/public-lifecycle-result.js +4 -0
  10. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  11. package/dist/src/commands/public-lifecycle.js +1 -1
  12. package/dist/src/commands/public-lifecycle.js.map +1 -1
  13. package/dist/src/commands/rebuild-command.d.ts +2 -1
  14. package/dist/src/commands/rebuild-command.js +22 -13
  15. package/dist/src/commands/rebuild-command.js.map +1 -1
  16. package/dist/src/commands/rebuild-integration.d.ts +2 -0
  17. package/dist/src/commands/rebuild-integration.js.map +1 -1
  18. package/dist/src/commands/rebuild-platform-integration.d.ts +1 -0
  19. package/dist/src/commands/rebuild-platform-integration.js +56 -9
  20. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  21. package/dist/src/platforms/discovery.d.ts +4 -3
  22. package/dist/src/platforms/discovery.js +33 -9
  23. package/dist/src/platforms/discovery.js.map +1 -1
  24. package/dist/src/platforms/inspection-native.js +15 -4
  25. package/dist/src/platforms/inspection-native.js.map +1 -1
  26. package/dist/src/platforms/inspection-query.d.ts +12 -1
  27. package/dist/src/platforms/inspection-query.js +24 -6
  28. package/dist/src/platforms/inspection-query.js.map +1 -1
  29. package/dist/src/portable/commands.d.ts +2 -2
  30. package/dist/src/portable/commands.js +7 -3
  31. package/dist/src/portable/commands.js.map +1 -1
  32. package/dist/src/portable/materializer.d.ts +2 -1
  33. package/dist/src/portable/materializer.js +4 -4
  34. package/dist/src/portable/materializer.js.map +1 -1
  35. package/dist/src/portable/recovery.d.ts +3 -3
  36. package/dist/src/portable/recovery.js +7 -7
  37. package/dist/src/portable/recovery.js.map +1 -1
  38. package/dist/src/recovery/coordinator.d.ts +11 -2
  39. package/dist/src/recovery/coordinator.js +12 -9
  40. package/dist/src/recovery/coordinator.js.map +1 -1
  41. package/dist/src/recovery/demand.d.ts +3 -1
  42. package/dist/src/recovery/demand.js +36 -6
  43. package/dist/src/recovery/demand.js.map +1 -1
  44. package/dist/src/recovery/joint-coordinator.d.ts +8 -1
  45. package/dist/src/recovery/joint-coordinator.js +110 -26
  46. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  47. package/dist/src/recovery/joint-demand.d.ts +2 -0
  48. package/dist/src/recovery/joint-demand.js +46 -9
  49. package/dist/src/recovery/joint-demand.js.map +1 -1
  50. package/dist/src/recovery/status.d.ts +4 -0
  51. package/dist/src/recovery/status.js +37 -19
  52. package/dist/src/recovery/status.js.map +1 -1
  53. package/dist/src/utils/catalog-generation-resolver.d.ts +4 -0
  54. package/dist/src/utils/catalog-generation-resolver.js +28 -17
  55. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  56. package/dist/src/utils/catalog-generation-store.d.ts +3 -0
  57. package/dist/src/utils/catalog-generation-store.js +7 -4
  58. package/dist/src/utils/catalog-generation-store.js.map +1 -1
  59. package/dist/src/utils/catalog-operation-context.d.ts +16 -3
  60. package/dist/src/utils/catalog-operation-context.js +58 -3
  61. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  62. package/dist/src/utils/catalog-snapshot.d.ts +3 -0
  63. package/dist/src/utils/catalog-snapshot.js +4 -1
  64. package/dist/src/utils/catalog-snapshot.js.map +1 -1
  65. package/dist/src/utils/codex-executable-discovery.js +8 -8
  66. package/dist/src/utils/codex-executable-discovery.js.map +1 -1
  67. package/dist/src/utils/native-cli.js +36 -9
  68. package/dist/src/utils/native-cli.js.map +1 -1
  69. package/package.json +3 -3
@@ -1312,8 +1312,87 @@ function overlayPortableRuntimeFiles(files, manifest, pluginDir, skillKey, runti
1312
1312
  }
1313
1313
  }
1314
1314
  }
1315
- async function validateAuthorComponentFixtures(pluginDir, manifest, runtimeImports, tools, referenceContext, referencePlugins, skillValidationTools, validationOptions) {
1316
- if (!manifest.skills && !manifest.artifacts && !(manifest.managedCommands?.sets?.length || manifest.managedCommands?.packages?.length))
1315
+ async function prepareSourceComponentFixture(root, pluginDir, manifest, runtimeImports, tools) {
1316
+ const packageRoot = manifest.scripts?.node?.packageRoot;
1317
+ if (packageRoot) {
1318
+ const installedModules = path.join(pluginDir, packageRoot, 'node_modules');
1319
+ if (fs.statSync(installedModules, { throwIfNoEntry: false })?.isDirectory()) {
1320
+ const destination = path.join(root, packageRoot, 'node_modules');
1321
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
1322
+ // Source validation uses already installed declared dependencies. It does
1323
+ // not install packages or publish this temporary dependency link.
1324
+ fs.symlinkSync(installedModules, destination, 'junction');
1325
+ }
1326
+ }
1327
+ const fixtureManifest = structuredClone(manifest);
1328
+ for (const reference of fixtureManifest.artifacts?.runtimeImports ?? []) {
1329
+ const input = runtimeImports?.artifactImports.get(reference.name);
1330
+ if (!input)
1331
+ throw new Error(`Unresolved runtime input: ${reference.name}`);
1332
+ const relative = `./.agents-plugin/runtime-imports/${reference.name}`;
1333
+ const destination = path.join(root, relative);
1334
+ fs.mkdirSync(path.dirname(destination), { recursive: true });
1335
+ fs.writeFileSync(destination, input.bytes, { mode: input.mode });
1336
+ reference.resolved = { path: relative, digest: input.digest, providerPluginId: input.providerPluginId,
1337
+ providerVersion: input.providerVersion, source: input.source, requiredCapabilities: input.requiredCapabilities,
1338
+ capabilitySetDigest: input.capabilitySetDigest };
1339
+ }
1340
+ if (manifest.nativeTools) {
1341
+ const reader = path.join(root, normalizeRelativePath(manifest.nativeTools.reader ?? './.aw/native-tool-reader.mjs'));
1342
+ fs.mkdirSync(path.dirname(reader), { recursive: true });
1343
+ fs.writeFileSync(reader, createNativeToolReaderSource());
1344
+ }
1345
+ // Apply the declared static source projection before the shared normalizer reads it.
1346
+ for (const platform of resolveSupportedPlatforms(manifest)) {
1347
+ if (manifest.mcpServers) {
1348
+ const relative = normalizeRelativePath(manifest.mcpServers);
1349
+ const input = fs.readFileSync(path.join(pluginDir, relative), 'utf8');
1350
+ const output = path.join(root, platform, relative);
1351
+ fs.mkdirSync(path.dirname(output), { recursive: true });
1352
+ fs.writeFileSync(output, renderTemplateForPlatform(manifest, relative, input, platform));
1353
+ }
1354
+ const sourceRoot = manifest.skills && path.join(pluginDir, manifest.skills);
1355
+ if (!sourceRoot || !fs.existsSync(sourceRoot))
1356
+ continue;
1357
+ for (const entry of fs.readdirSync(sourceRoot, { withFileTypes: true })) {
1358
+ if (!entry.isDirectory() || await isAuthorOnlySkillDirectory(path.join(sourceRoot, entry.name)))
1359
+ continue;
1360
+ const files = new Map();
1361
+ collectArtifactSourceFiles(path.join(sourceRoot, entry.name), `static Skill ${entry.name}`, files, (relative, bytes) => isTemplateTextFile(relative)
1362
+ ? Buffer.from(renderTemplateForPlatform(manifest, `${normalizeRelativePath(manifest.skills)}/${entry.name}/${relative}`, bytes.toString('utf8'), platform)) : bytes);
1363
+ overlayPortableRuntimeFiles(files, manifest, pluginDir, entry.name, runtimeImports, platform);
1364
+ for (const [relative, bytes] of files) {
1365
+ const output = path.join(root, platform, 'skills', entry.name, relative);
1366
+ fs.mkdirSync(path.dirname(output), { recursive: true });
1367
+ const original = path.join(sourceRoot, entry.name, relative);
1368
+ const projection = (manifest.buildConfig?.skillRuntimeFiles ?? []).find((file) => file.skill === entry.name && file.target === relative && (!file.platforms?.length || file.platforms.includes(platform)));
1369
+ const mode = projection?.source ? fs.statSync(path.join(pluginDir, projection.source)).mode
1370
+ : fs.existsSync(original) ? fs.statSync(original).mode : 0o644;
1371
+ fs.writeFileSync(output, bytes, { mode: mode & 0o111 ? 0o755 : 0o644 });
1372
+ }
1373
+ }
1374
+ }
1375
+ for (const platform of resolveSupportedPlatforms(manifest)) {
1376
+ const skillsRoot = path.join(root, platform, 'skills');
1377
+ if (!fs.existsSync(skillsRoot))
1378
+ continue;
1379
+ for (const entry of fs.readdirSync(skillsRoot, { withFileTypes: true })) {
1380
+ if (!entry.isDirectory())
1381
+ continue;
1382
+ const generated = (manifest.buildConfig?.generatedSkillRuntimeFiles ?? [])
1383
+ .filter((file) => file.skill === entry.name && (!file.platforms?.length || file.platforms.includes(platform)))
1384
+ .map((file) => file.target);
1385
+ await tools.validateRuntimeSkillClosure(path.join(skillsRoot, entry.name), { declaredGeneratedFiles: new Set(generated) });
1386
+ }
1387
+ }
1388
+ const manifestPath = path.join(root, '.agents-plugin', 'plugin.json');
1389
+ fs.writeFileSync(manifestPath, JSON.stringify(fixtureManifest));
1390
+ return { rootDir: root, manifestPath, manifest: fixtureManifest };
1391
+ }
1392
+ async function validateAuthorComponentFixtures(pluginDir, sourceManifest, runtimeImports, tools, referenceContext, referencePlugins, skillValidationTools, validationOptions) {
1393
+ const builtBundle = validationOptions.builtBundle;
1394
+ if (!builtBundle && !sourceManifest.skills && !sourceManifest.artifacts
1395
+ && !(sourceManifest.managedCommands?.sets?.length || sourceManifest.managedCommands?.packages?.length))
1317
1396
  return;
1318
1397
  if (runtimeImports === null)
1319
1398
  return;
@@ -1321,82 +1400,22 @@ async function validateAuthorComponentFixtures(pluginDir, manifest, runtimeImpor
1321
1400
  const packagePreparationCache = new Map();
1322
1401
  try {
1323
1402
  const root = path.join(tempRoot, 'plugin');
1324
- fs.cpSync(pluginDir, root, { recursive: true, filter: (source) => !['.git', 'node_modules'].includes(path.basename(source)) });
1325
- const packageRoot = manifest.scripts?.node?.packageRoot;
1326
- if (packageRoot) {
1327
- const installedModules = path.join(pluginDir, packageRoot, 'node_modules');
1328
- if (fs.statSync(installedModules, { throwIfNoEntry: false })?.isDirectory()) {
1329
- const destination = path.join(root, packageRoot, 'node_modules');
1330
- fs.mkdirSync(path.dirname(destination), { recursive: true });
1331
- // Source validation uses already installed declared dependencies. It does
1332
- // not install packages or publish this temporary dependency link.
1333
- fs.symlinkSync(installedModules, destination, 'junction');
1334
- }
1403
+ if (builtBundle) {
1404
+ // Preserve the renderer's shipped dependencies without exposing the publication snapshot to writes.
1405
+ fs.cpSync(builtBundle, root, { recursive: true });
1335
1406
  }
1336
- const fixtureManifest = structuredClone(manifest);
1337
- for (const reference of fixtureManifest.artifacts?.runtimeImports ?? []) {
1338
- const input = runtimeImports?.artifactImports.get(reference.name);
1339
- if (!input)
1340
- throw new Error(`Unresolved runtime input: ${reference.name}`);
1341
- const relative = `./.agents-plugin/runtime-imports/${reference.name}`;
1342
- const destination = path.join(root, relative);
1343
- fs.mkdirSync(path.dirname(destination), { recursive: true });
1344
- fs.writeFileSync(destination, input.bytes, { mode: input.mode });
1345
- reference.resolved = { path: relative, digest: input.digest, providerPluginId: input.providerPluginId,
1346
- providerVersion: input.providerVersion, source: input.source, requiredCapabilities: input.requiredCapabilities,
1347
- capabilitySetDigest: input.capabilitySetDigest };
1348
- }
1349
- if (manifest.nativeTools) {
1350
- const reader = path.join(root, normalizeRelativePath(manifest.nativeTools.reader ?? './.aw/native-tool-reader.mjs'));
1351
- fs.mkdirSync(path.dirname(reader), { recursive: true });
1352
- fs.writeFileSync(reader, createNativeToolReaderSource());
1353
- }
1354
- // Apply the declared static source projection before the shared normalizer reads it.
1355
- for (const platform of resolveSupportedPlatforms(manifest)) {
1356
- if (manifest.mcpServers) {
1357
- const relative = normalizeRelativePath(manifest.mcpServers);
1358
- const input = fs.readFileSync(path.join(pluginDir, relative), 'utf8');
1359
- const output = path.join(root, platform, relative);
1360
- fs.mkdirSync(path.dirname(output), { recursive: true });
1361
- fs.writeFileSync(output, renderTemplateForPlatform(manifest, relative, input, platform));
1362
- }
1363
- const sourceRoot = manifest.skills && path.join(pluginDir, manifest.skills);
1364
- if (!sourceRoot || !fs.existsSync(sourceRoot))
1365
- continue;
1366
- for (const entry of fs.readdirSync(sourceRoot, { withFileTypes: true })) {
1367
- if (!entry.isDirectory() || await isAuthorOnlySkillDirectory(path.join(sourceRoot, entry.name)))
1368
- continue;
1369
- const files = new Map();
1370
- collectArtifactSourceFiles(path.join(sourceRoot, entry.name), `static Skill ${entry.name}`, files, (relative, bytes) => isTemplateTextFile(relative)
1371
- ? Buffer.from(renderTemplateForPlatform(manifest, `${normalizeRelativePath(manifest.skills)}/${entry.name}/${relative}`, bytes.toString('utf8'), platform)) : bytes);
1372
- overlayPortableRuntimeFiles(files, manifest, pluginDir, entry.name, runtimeImports, platform);
1373
- for (const [relative, bytes] of files) {
1374
- const output = path.join(root, platform, 'skills', entry.name, relative);
1375
- fs.mkdirSync(path.dirname(output), { recursive: true });
1376
- const original = path.join(sourceRoot, entry.name, relative);
1377
- const projection = (manifest.buildConfig?.skillRuntimeFiles ?? []).find((file) => file.skill === entry.name && file.target === relative && (!file.platforms?.length || file.platforms.includes(platform)));
1378
- const mode = projection?.source ? fs.statSync(path.join(pluginDir, projection.source)).mode
1379
- : fs.existsSync(original) ? fs.statSync(original).mode : 0o644;
1380
- fs.writeFileSync(output, bytes, { mode: mode & 0o111 ? 0o755 : 0o644 });
1381
- }
1382
- }
1383
- }
1384
- for (const platform of resolveSupportedPlatforms(manifest)) {
1385
- const skillsRoot = path.join(root, platform, 'skills');
1386
- if (!fs.existsSync(skillsRoot))
1387
- continue;
1388
- for (const entry of fs.readdirSync(skillsRoot, { withFileTypes: true })) {
1389
- if (!entry.isDirectory())
1390
- continue;
1391
- const generated = (manifest.buildConfig?.generatedSkillRuntimeFiles ?? [])
1392
- .filter((file) => file.skill === entry.name && (!file.platforms?.length || file.platforms.includes(platform)))
1393
- .map((file) => file.target);
1394
- await tools.validateRuntimeSkillClosure(path.join(skillsRoot, entry.name), { declaredGeneratedFiles: new Set(generated) });
1395
- }
1407
+ else {
1408
+ fs.cpSync(pluginDir, root, {
1409
+ recursive: true, filter: (source) => !['.git', 'node_modules'].includes(path.basename(source)),
1410
+ });
1396
1411
  }
1397
- const manifestPath = path.join(root, '.agents-plugin', 'plugin.json');
1398
- fs.writeFileSync(manifestPath, JSON.stringify(fixtureManifest));
1399
- const plugin = { rootDir: root, manifestPath, manifest: fixtureManifest, sourceId: 'authoring',
1412
+ const fixture = builtBundle
1413
+ ? await tools.readPluginManifest(root, { mode: 'bundle' })
1414
+ : await prepareSourceComponentFixture(root, pluginDir, sourceManifest, runtimeImports, tools);
1415
+ const { manifest } = fixture;
1416
+ if (manifest.name !== sourceManifest.name)
1417
+ throw new Error('Built bundle plugin does not match the source plugin.');
1418
+ const plugin = { ...fixture, sourceId: 'authoring',
1400
1419
  sourceIdentity: `sha256:${createHash('sha256').update(fs.realpathSync(pluginDir)).digest('hex')}` };
1401
1420
  const plugins = [plugin, ...(referencePlugins ?? runtimeImports?.referencePlugins ?? []).filter((entry) => entry.manifest.name !== manifest.name)];
1402
1421
  const env = await tools.createIsolatedSkillEnv(process.env, path.join(tempRoot, 'state'));
@@ -1437,7 +1456,7 @@ async function validateAuthorComponentFixtures(pluginDir, manifest, runtimeImpor
1437
1456
  catch (cause) {
1438
1457
  const pending = (manifest.buildConfig?.generatedSkillRuntimeFiles ?? []).filter((file) => (!file.platforms?.length || file.platforms.includes(platform))
1439
1458
  && !fs.existsSync(path.join(root, platform, 'skills', file.skill, file.target)));
1440
- if (cause.message.startsWith('Invalid runtime Skill closure:') && cause.message.endsWith(' is missing.')
1459
+ if (!builtBundle && cause.message.startsWith('Invalid runtime Skill closure:') && cause.message.endsWith(' is missing.')
1441
1460
  && pending.some((file) => cause.message.includes(JSON.stringify(file.target)))) {
1442
1461
  warn(`component profile unverified (${platform}/${scope}): declared generated runtime files require a staging build; ${cause.message}`);
1443
1462
  }
@@ -1889,6 +1908,10 @@ async function validatePluginDir(pluginDir, options) {
1889
1908
  error(e.message);
1890
1909
  return;
1891
1910
  }
1911
+ if (options.builtBundle) {
1912
+ await validateAuthorComponentFixtures(pluginDir, manifest, undefined, cliManifestTools, referenceContext, referencePlugins, skillValidationTools, options);
1913
+ return;
1914
+ }
1892
1915
  validatePlatformFieldSupport(manifest);
1893
1916
  validateNameMatchesDirectory(pluginDir, manifest);
1894
1917
  validateNoBuildOutputDirs(pluginDir);
@@ -1902,7 +1925,12 @@ async function validatePluginDir(pluginDir, options) {
1902
1925
  repoRoot: options.repoRoot,
1903
1926
  cliManifestTools,
1904
1927
  });
1905
- await validateAuthorComponentFixtures(pluginDir, manifest, runtimeImports, cliManifestTools, referenceContext, referencePlugins, skillValidationTools, options);
1928
+ if (manifest.scripts?.node?.build && manifest.scripts?.artifacts?.render) {
1929
+ warn('Component profiles require a staging build; source validation has not verified them.');
1930
+ }
1931
+ else {
1932
+ await validateAuthorComponentFixtures(pluginDir, manifest, runtimeImports, cliManifestTools, referenceContext, referencePlugins, skillValidationTools, options);
1933
+ }
1906
1934
  validateMcpContent(pluginDir, manifest);
1907
1935
  validateExtensionNameUniqueness(manifest);
1908
1936
  await validateSkills(pluginDir, manifest, options, skillValidationTools);
@@ -1944,6 +1972,7 @@ function parseArgs(argv) {
1944
1972
  claudeSkillProfile: 'current',
1945
1973
  versionBase: 'HEAD',
1946
1974
  workspaceRoot: null,
1975
+ builtBundle: null,
1947
1976
  json: args.includes('--json'),
1948
1977
  };
1949
1978
  for (let index = 0; index < args.length; index += 1) {
@@ -1980,13 +2009,16 @@ function parseArgs(argv) {
1980
2009
  options.versionBase = value;
1981
2010
  continue;
1982
2011
  }
1983
- if (arg === '--workspace-root') {
2012
+ if (arg === '--workspace-root' || arg === '--built-bundle') {
1984
2013
  const value = args[index + 1];
1985
2014
  if (!value || value.startsWith('--')) {
1986
- exitCliError('--workspace-root requires a value.', options.json);
2015
+ exitCliError(`${arg} requires a value.`, options.json);
1987
2016
  }
1988
2017
  index += 1;
1989
- options.workspaceRoot = value;
2018
+ if (arg === '--workspace-root')
2019
+ options.workspaceRoot = value;
2020
+ else
2021
+ options.builtBundle = path.resolve(value);
1990
2022
  continue;
1991
2023
  }
1992
2024
  if (!arg.startsWith('--')) {
@@ -2033,6 +2065,7 @@ async function main() {
2033
2065
  repoRoot,
2034
2066
  gitRoot,
2035
2067
  enforceCanonicalRoot: requestedWorkspaceRoot !== null,
2068
+ builtBundle: args.builtBundle,
2036
2069
  });
2037
2070
  if (args.json) {
2038
2071
  console.log(JSON.stringify({