@lesliechan721/aw 0.1.0-beta.95 → 0.1.0-beta.97

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 (114) hide show
  1. package/dist/scripts/aw-skill-eval-materializer.js +3 -2
  2. package/dist/scripts/aw-skill-eval-materializer.js.map +1 -1
  3. package/dist/scripts/bundle-plugins.js +10 -3
  4. package/dist/scripts/bundle-plugins.js.map +1 -1
  5. package/dist/scripts/plugin-staging.js +2 -1
  6. package/dist/scripts/plugin-staging.js.map +1 -1
  7. package/dist/scripts/plugin-test-context-guard.d.mts +1 -0
  8. package/dist/scripts/plugin-test-context-guard.mjs +59 -0
  9. package/dist/scripts/plugin-test-context-guard.mjs.map +1 -0
  10. package/dist/scripts/test-plugin-scripts.js +90 -44
  11. package/dist/scripts/test-plugin-scripts.js.map +1 -1
  12. package/dist/scripts/test-workers.mjs +1 -1
  13. package/dist/scripts/test-workers.mjs.map +1 -1
  14. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  15. package/dist/src/commands/aw-capabilities.js +3 -0
  16. package/dist/src/commands/aw-capabilities.js.map +1 -1
  17. package/dist/src/commands/permission-batch.d.ts +1 -1
  18. package/dist/src/commands/permission-batch.js +6 -3
  19. package/dist/src/commands/permission-batch.js.map +1 -1
  20. package/dist/src/commands/plugin-capabilities.js +5 -0
  21. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  22. package/dist/src/commands/public-lifecycle-result.js +3 -2
  23. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  24. package/dist/src/commands/public-lifecycle.js +12 -8
  25. package/dist/src/commands/public-lifecycle.js.map +1 -1
  26. package/dist/src/commands/public-plugin-query.js +3 -2
  27. package/dist/src/commands/public-plugin-query.js.map +1 -1
  28. package/dist/src/commands/rebuild-command.d.ts +12 -0
  29. package/dist/src/commands/rebuild-command.js +78 -8
  30. package/dist/src/commands/rebuild-command.js.map +1 -1
  31. package/dist/src/commands/rebuild-integration.d.ts +8 -5
  32. package/dist/src/commands/rebuild-integration.js +21 -7
  33. package/dist/src/commands/rebuild-integration.js.map +1 -1
  34. package/dist/src/commands/rebuild-platform-integration.d.ts +16 -2
  35. package/dist/src/commands/rebuild-platform-integration.js +314 -23
  36. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  37. package/dist/src/commands/review-inspection.js +3 -2
  38. package/dist/src/commands/review-inspection.js.map +1 -1
  39. package/dist/src/generators/local-plugin.js +117 -37
  40. package/dist/src/generators/local-plugin.js.map +1 -1
  41. package/dist/src/platforms/contracts.d.ts +6 -0
  42. package/dist/src/platforms/discovery.js +20 -18
  43. package/dist/src/platforms/discovery.js.map +1 -1
  44. package/dist/src/platforms/inspection-grok.js +20 -6
  45. package/dist/src/platforms/inspection-grok.js.map +1 -1
  46. package/dist/src/platforms/inspection-native.js +9 -2
  47. package/dist/src/platforms/inspection-native.js.map +1 -1
  48. package/dist/src/platforms/inspection-query.d.ts +2 -0
  49. package/dist/src/platforms/inspection-query.js +20 -21
  50. package/dist/src/platforms/inspection-query.js.map +1 -1
  51. package/dist/src/platforms/read-only-retry-policy.d.ts +34 -0
  52. package/dist/src/platforms/read-only-retry-policy.js +70 -0
  53. package/dist/src/platforms/read-only-retry-policy.js.map +1 -0
  54. package/dist/src/portable/commands.d.ts +3 -1
  55. package/dist/src/portable/commands.js +11 -23
  56. package/dist/src/portable/commands.js.map +1 -1
  57. package/dist/src/portable/historical-materialization.d.ts +4 -1
  58. package/dist/src/portable/historical-materialization.js +35 -11
  59. package/dist/src/portable/historical-materialization.js.map +1 -1
  60. package/dist/src/portable/materializer.d.ts +17 -1
  61. package/dist/src/portable/materializer.js +95 -29
  62. package/dist/src/portable/materializer.js.map +1 -1
  63. package/dist/src/portable/recovery.d.ts +3 -2
  64. package/dist/src/portable/recovery.js +49 -8
  65. package/dist/src/portable/recovery.js.map +1 -1
  66. package/dist/src/recovery/coordinator.d.ts +9 -2
  67. package/dist/src/recovery/coordinator.js +105 -39
  68. package/dist/src/recovery/coordinator.js.map +1 -1
  69. package/dist/src/recovery/joint-coordinator.d.ts +3 -3
  70. package/dist/src/recovery/joint-coordinator.js +402 -320
  71. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  72. package/dist/src/recovery/retirement.d.ts +2 -2
  73. package/dist/src/recovery/retirement.js +3 -3
  74. package/dist/src/recovery/retirement.js.map +1 -1
  75. package/dist/src/review/skill-materialization.d.ts +2 -1
  76. package/dist/src/review/skill-materialization.js +2 -3
  77. package/dist/src/review/skill-materialization.js.map +1 -1
  78. package/dist/src/tui/config-value-presentation.js +7 -4
  79. package/dist/src/tui/config-value-presentation.js.map +1 -1
  80. package/dist/src/tui/console-app-v4.js +1 -1
  81. package/dist/src/tui/console-app-v4.js.map +1 -1
  82. package/dist/src/utils/artifact-renderer.d.ts +9 -2
  83. package/dist/src/utils/artifact-renderer.js +67 -31
  84. package/dist/src/utils/artifact-renderer.js.map +1 -1
  85. package/dist/src/utils/bundle-layout.d.ts +2 -0
  86. package/dist/src/utils/bundle-layout.js +40 -13
  87. package/dist/src/utils/bundle-layout.js.map +1 -1
  88. package/dist/src/utils/catalog-generation-resolver.d.ts +9 -2
  89. package/dist/src/utils/catalog-generation-resolver.js +82 -10
  90. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  91. package/dist/src/utils/catalog-operation-context.d.ts +35 -2
  92. package/dist/src/utils/catalog-operation-context.js +155 -5
  93. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  94. package/dist/src/utils/catalog-source-references.js +11 -4
  95. package/dist/src/utils/catalog-source-references.js.map +1 -1
  96. package/dist/src/utils/codex-native-observation.js +8 -12
  97. package/dist/src/utils/codex-native-observation.js.map +1 -1
  98. package/dist/src/utils/codex-skills-root.js +5 -1
  99. package/dist/src/utils/codex-skills-root.js.map +1 -1
  100. package/dist/src/utils/component-resources.js +2 -3
  101. package/dist/src/utils/component-resources.js.map +1 -1
  102. package/dist/src/utils/multi-source-catalog.d.ts +2 -1
  103. package/dist/src/utils/multi-source-catalog.js +2 -1
  104. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  105. package/dist/src/utils/plugin-config-suggestions.js +13 -4
  106. package/dist/src/utils/plugin-config-suggestions.js.map +1 -1
  107. package/dist/src/utils/plugin-config.js +13 -4
  108. package/dist/src/utils/plugin-config.js.map +1 -1
  109. package/dist/src/utils/runtime-skill-closure.d.ts +1 -1
  110. package/dist/src/utils/runtime-skill-closure.js +3 -1
  111. package/dist/src/utils/runtime-skill-closure.js.map +1 -1
  112. package/dist/vitest.config.js +3 -0
  113. package/dist/vitest.config.js.map +1 -1
  114. package/package.json +4 -3
@@ -20,7 +20,7 @@ import { configIssueDiagnostic, configReadDiagnostic } from '../utils/plugin-con
20
20
  import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
21
21
  import { catalogGenerationErrorCode, isOfflineCleanupCatalogGenerationError, } from '../utils/catalog-generation-error.js';
22
22
  import { resolveActiveCatalogGeneration, resolveActiveCatalogPluginShallow } from '../utils/catalog-generation-resolver.js';
23
- import { CatalogPreparationReadScope, resolveCatalogOperationContext, } from '../utils/catalog-operation-context.js';
23
+ import { CatalogPreparationReadScope, catalogOperationBindingsMatch, resolveCatalogOperationContext, } from '../utils/catalog-operation-context.js';
24
24
  import { sanitizeCatalogSourceErrorMessage } from '../utils/catalog-public-error.js';
25
25
  import { validateCatalogSnapshotComplete } from '../utils/catalog-snapshot.js';
26
26
  import { assertCatalogSourceInventoryComplete, resolveCleanupMarketplaceIdentity, scopedCleanupMarketplaceEvidence, inventoryCatalogSourceReferences, offlineOwnedPathEvidence, } from '../utils/catalog-source-references.js';
@@ -48,7 +48,7 @@ import { createDependencyPlacementPlan, } from './dependency-operation-plan.js';
48
48
  import { forceOfflineCleanupEvidence, intentOnlyOfflineCleanupEvidence, offlineCleanupEvidenceFromInventory, offlineCleanupEvidenceMatches, } from './offline-cleanup-evidence.js';
49
49
  import { assertOperationPlanFingerprint, createOperationPlan, createOperationPlanConfigDigest, operationPlanNativeToolChanges, } from './operation-plan.js';
50
50
  import { deploymentConfirmationEffects } from './deployment-confirmation.js';
51
- import { assertNoClaudeUnboundNativeNameCollision, CodexActivationPostcheckError, createRebuildIntegration, disposePreparedPlatformRebuildSession, executeCodexReconcileActivations, inspectNativeMarketplaceRegistration, isNativeActivationOnlyTarget, postcheckCodexReconcileActivations, removeForceCleanupCodexRoleRegistration } from './rebuild-integration.js';
51
+ import { assertNoClaudeUnboundNativeNameCollision, CodexActivationPostcheckError, createRebuildIntegration, disposePreparedPlatformRebuildSession, executeCodexReconcileActivations, inspectNativeMarketplaceRegistration, isNativeActivationOnlyTarget, postcheckCodexReconcileActivations, recordPreparedGrokOfflineRuleRemoval, recordPreparedOfflinePermissionRemoval, recordPreparedPermissionWrite, removeForceCleanupCodexRoleRegistration } from './rebuild-integration.js';
52
52
  import { executeRebuildOperation, hasPlannedPreApply, prepareRebuildOperation } from './rebuild-operations.js';
53
53
  import { createReconcileOperationPlan, } from './reconcile-operation-plan.js';
54
54
  // A read scope belongs to one Review or its independent locked recheck.
@@ -990,6 +990,20 @@ function needsFrozenNativeRemoval(candidate) {
990
990
  return !['opencode-directory', 'antigravity-directory', 'grok-directory'].includes(candidate.binding.route);
991
991
  }
992
992
  async function prepareOfflineNativeCleanup(options) {
993
+ const removal = options.ordinaryNativeRemoval;
994
+ let activeRemovalSourceIdentity;
995
+ if (removal) {
996
+ const readScope = options.runtime?.catalogReadScope ?? new CatalogPreparationReadScope({ env: options.env, signal: options.runtime?.signal });
997
+ const current = await readScope.rebind(removal.catalog);
998
+ const { sourceId, pluginName } = parsePluginId(removal.target.pluginId);
999
+ const source = current.catalog.sources.find((entry) => entry.sourceId === sourceId)?.resolution;
1000
+ if (!catalogOperationBindingsMatch(removal.catalog, current) || !source
1001
+ || !source.manifest.entries.some((entry) => entry.name === pluginName)) {
1002
+ throw new Error('operationReviewStale: Active Catalog binding changed before native removal.');
1003
+ }
1004
+ await CatalogPreparationReadScope.validateEntries(readScope, source);
1005
+ activeRemovalSourceIdentity = source.sourceIdentity;
1006
+ }
993
1007
  const candidates = options.evidence.flatMap((target) => target.plan.actions.flatMap((action) => action.recoveryCandidate && needsFrozenNativeRemoval(action.recoveryCandidate) ? [action.recoveryCandidate] : []));
994
1008
  const context = { ...options.runtime, env: options.env,
995
1009
  confirmedCatalogRetirement: options.retirementNativePlatforms ? true : undefined,
@@ -1011,9 +1025,14 @@ async function prepareOfflineNativeCleanup(options) {
1011
1025
  plugin.sourceIdentity = evidence.sourceIdentity;
1012
1026
  plugin.pluginId = evidence.pluginId;
1013
1027
  try {
1028
+ const ordinaryRemove = removal && evidence.pluginId === removal.target.pluginId
1029
+ && evidence.platform === removal.target.platform && evidence.scope === removal.target.scope
1030
+ && evidence.sourceIdentity === activeRemovalSourceIdentity;
1014
1031
  const target = await integration.buildTarget({ sourceId: evidence.sourceId, sourceIdentity: evidence.sourceIdentity,
1015
1032
  pluginId: evidence.pluginId, plugin, platform: evidence.platform, scope: evidence.scope, cwd: options.cwd,
1016
- command: 'cleanup', catalog: { rootDir: resolveAwHome(options.env), source: 'local' } });
1033
+ // Select the adapter's remove operation only. The enclosing execution
1034
+ // remains cleanup, using frozen live evidence and scoped ordering.
1035
+ command: ordinaryRemove ? 'uninstall' : 'cleanup', catalog: { rootDir: resolveAwHome(options.env), source: 'local' } });
1017
1036
  targets.set(offlineCleanupKey(evidence), target);
1018
1037
  deploymentExclusions.push(...target.deploymentExclusions ?? []);
1019
1038
  }
@@ -1022,9 +1041,20 @@ async function prepareOfflineNativeCleanup(options) {
1022
1041
  warnings.push(`nativeCleanupPreparationFailed: ${evidence.pluginId}:${evidence.platform}/${evidence.scope}: ${error instanceof Error ? error.message : String(error)}`);
1023
1042
  }
1024
1043
  }
1025
- await integration.sealMarketplaceGenerations([...targets.values()]);
1026
1044
  const locators = options.evidence.flatMap((target) => target.plan.actions.flatMap(({ action, component }) => action === 'removeOwnedOutput' && component?.kind === 'shared-config' && component.locator.kind === 'host-permissions'
1027
1045
  ? [component.locator] : []));
1046
+ if (context.preparedArtifactRenderResults) {
1047
+ for (const evidence of options.evidence) {
1048
+ if (targets.has(offlineCleanupKey(evidence)))
1049
+ continue;
1050
+ for (const { action, component } of evidence.plan.actions) {
1051
+ if (action === 'removeOwnedOutput' && component?.kind === 'shared-config' && component.locator.kind === 'host-permissions') {
1052
+ recordPreparedOfflinePermissionRemoval(context.preparedArtifactRenderResults, component.locator.settingsPath, component.locator.ownerKey);
1053
+ }
1054
+ }
1055
+ }
1056
+ }
1057
+ await integration.sealMarketplaceGenerations([...targets.values()]);
1028
1058
  const invocationCwd = options.runtime?.invocationCwd ?? options.cwd;
1029
1059
  const permissionRemovals = await reviewPermissionRemovals({ cwd: options.cwd, env: options.env, invocationCwd }, locators);
1030
1060
  return { integration, targets, warnings, deploymentExclusions, permissionRemovals, invocationCwd };
@@ -1045,7 +1075,12 @@ async function cleanupOfflineOwnedComponents(options) {
1045
1075
  throw permissionConflict();
1046
1076
  const expected = advanced.get(locator.settingsPath) ?? review.fingerprint;
1047
1077
  try {
1048
- await updateHostPermissions({ env: options.env, cwd: options.cwd, invocationCwd: options.nativePreparation?.invocationCwd }, locator, undefined, (_previous, current, target = locator.settingsPath) => advanced.set(target, current), review.batch, (notices) => permissionNotices.push(...notices), expected, locator.platform === 'opencode' && !locator.projectRoot ? relatedProjectBatch : undefined);
1078
+ await updateHostPermissions({ env: options.env, cwd: options.cwd, invocationCwd: options.nativePreparation?.invocationCwd }, locator, undefined, (previous, current, target = locator.settingsPath, host) => {
1079
+ advanced.set(target, current);
1080
+ if (options.preparedArtifactRenderResults) {
1081
+ recordPreparedPermissionWrite(options.preparedArtifactRenderResults, target, previous, current, locator.platform === 'grok' ? host : undefined);
1082
+ }
1083
+ }, review.batch, (notices) => permissionNotices.push(...notices), expected, locator.platform === 'opencode' && !locator.projectRoot ? relatedProjectBatch : undefined);
1049
1084
  }
1050
1085
  catch (error) {
1051
1086
  const notices = relatedProjectPermissionNotices(error, {
@@ -1243,6 +1278,25 @@ async function cleanupOfflineOwnedComponents(options) {
1243
1278
  target: desired,
1244
1279
  driver: integration.driver,
1245
1280
  });
1281
+ if (target.platform === 'grok' && options.preparedArtifactRenderResults
1282
+ && result.status === 'succeeded' && !result.failures.length && !result.residual.length && !result.quarantined.length) {
1283
+ const scopeRoot = target.scope === 'project'
1284
+ ? canonicalizePathThroughExistingAncestorSync(resolveRepoRootSync(options.cwd))
1285
+ : canonicalizePathThroughExistingAncestorSync(resolvePlatformConfigRoot('grok', cleanupContext));
1286
+ const rulesRoot = canonicalizePathThroughExistingAncestorSync(target.scope === 'project' ? path.join(scopeRoot, '.grok', 'rules') : path.join(scopeRoot, 'rules'));
1287
+ for (const component of desired.ownedComponents) {
1288
+ if (component.kind !== 'owned-text-file')
1289
+ continue;
1290
+ const normalized = canonicalizePathThroughExistingAncestorSync(component.path);
1291
+ if (path.dirname(normalized) !== rulesRoot)
1292
+ continue;
1293
+ if (!result.removed.includes(component.path))
1294
+ continue;
1295
+ recordPreparedGrokOfflineRuleRemoval(options.preparedArtifactRenderResults, {
1296
+ scope: target.scope, scopeRoot, pluginId: target.pluginId, rulePath: normalized,
1297
+ });
1298
+ }
1299
+ }
1246
1300
  if (nativeResult) {
1247
1301
  const combined = { ...result, actions: [...nativeResult.actions, ...result.actions],
1248
1302
  cleanupAttempted: nativeResult.cleanupAttempted || result.cleanupAttempted,
@@ -1713,8 +1767,21 @@ export async function inspectRemovedPluginCleanup(options) {
1713
1767
  return null;
1714
1768
  let generation;
1715
1769
  try {
1716
- generation = await resolveActiveCatalogGeneration({ sourceId: parsed.sourceId, env: options.env });
1717
- await validateCatalogSnapshotComplete(generation.snapshotPath);
1770
+ const previous = options.preparation?.catalogOperationContext.catalog.sources
1771
+ .find((source) => source.sourceId === parsed.sourceId)?.resolution;
1772
+ if (previous && options.preparation) {
1773
+ const { active, reused } = await options.preparation.catalogReadScope.resolveActiveGeneration(parsed.sourceId, previous);
1774
+ generation = active;
1775
+ // Transport evidence alone does not establish a healthy Catalog for retirement.
1776
+ if (reused)
1777
+ await CatalogPreparationReadScope.validateEntries(options.preparation.catalogReadScope, previous);
1778
+ else
1779
+ await validateCatalogSnapshotComplete(generation.snapshotPath);
1780
+ }
1781
+ else {
1782
+ generation = await resolveActiveCatalogGeneration({ sourceId: parsed.sourceId, env: options.env });
1783
+ await validateCatalogSnapshotComplete(generation.snapshotPath);
1784
+ }
1718
1785
  }
1719
1786
  catch {
1720
1787
  return null;
@@ -1849,6 +1916,7 @@ async function removedPluginOutputCleanupInContext(options) {
1849
1916
  env: options.context.env,
1850
1917
  nativeCliRunner: options.runtime?.nativeCliRunner ?? getDefaultNativeCliRunner(),
1851
1918
  codexManager: options.runtime?.codexManager,
1919
+ preparation: options.runtime?.previewOperationPlan ? options.preparation : undefined,
1852
1920
  });
1853
1921
  if (!current || current.sourceIdentity !== options.target.sourceIdentity
1854
1922
  || current.logicalIdentity !== options.target.logicalIdentity
@@ -1908,6 +1976,7 @@ async function removedPluginOutputCleanupInContext(options) {
1908
1976
  executeCleanupOperation: options.runtime?.executeCleanupOperation,
1909
1977
  preserveLegacyNativeSkills: options.runtime?.preserveLegacyNativeSkills,
1910
1978
  removeObsoleteInstallationContracts: options.runtime?.removeObsoleteInstallationContracts,
1979
+ preparedArtifactRenderResults: options.runtime?.preparedArtifactRenderResults,
1911
1980
  });
1912
1981
  withRetainedPackages(result, operationPlan);
1913
1982
  const residual = current.blockers.filter((blocker) => !blocker.includes('Config'));
@@ -2394,7 +2463,7 @@ async function runRebuildCommandInSession(options) {
2394
2463
  && candidate.scope === target.scope)
2395
2464
  ?? intentOnlyOfflineCleanupEvidence(target));
2396
2465
  const nativePreparation = await prepareOfflineNativeCleanup({ evidence, cwd: options.commandOptions.cwd,
2397
- env: runtimeEnv, runtime: options.runtime });
2466
+ env: runtimeEnv, runtime: options.runtime, ordinaryNativeRemoval: options.runtime?.ordinaryNativeRemoval });
2398
2467
  const operationPlan = createOfflineCleanupOperationPlan(evidence, { scope: options.commandOptions.scope, view: cleanupRequirements }, [...cleanupInventoryWarnings(cleanupInventory, cleanupTargets), ...cleanupMarketplaceIdentityWarnings(cleanupTargets), ...cleanupUnavailableWarnings], retainedPackageActions, nativePreparation);
2399
2468
  if (options.runtime?.expectedPlanFingerprint) {
2400
2469
  assertOperationPlanFingerprint(options.runtime.expectedPlanFingerprint, operationPlan);
@@ -2423,6 +2492,7 @@ async function runRebuildCommandInSession(options) {
2423
2492
  codexManager: options.runtime?.codexManager,
2424
2493
  executeCleanupOperation: options.runtime?.executeCleanupOperation,
2425
2494
  preserveLegacyNativeSkills: options.runtime?.preserveLegacyNativeSkills,
2495
+ preparedArtifactRenderResults: options.runtime?.preparedArtifactRenderResults,
2426
2496
  });
2427
2497
  const liveKeys = new Set(cleanupLiveTargets.map((target) => `${target.pluginId}\0${target.platform}\0${target.scope}`));
2428
2498
  const intentOnlyResults = cleanupTargets