@lesliechan721/aw 0.1.0-beta.55 → 0.1.0-beta.57

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 (35) hide show
  1. package/dist/authoring/scripts/validate-plugin.mjs +1 -1
  2. package/dist/src/commands/rebuild-command.js +70 -2
  3. package/dist/src/commands/rebuild-command.js.map +1 -1
  4. package/dist/src/commands/rebuild-integration.js +38 -5
  5. package/dist/src/commands/rebuild-integration.js.map +1 -1
  6. package/dist/src/commands/rebuild-operations.js +2 -0
  7. package/dist/src/commands/rebuild-operations.js.map +1 -1
  8. package/dist/src/commands/status-v6.js +3 -5
  9. package/dist/src/commands/status-v6.js.map +1 -1
  10. package/dist/src/constants.d.ts +1 -2
  11. package/dist/src/constants.js +1 -2
  12. package/dist/src/constants.js.map +1 -1
  13. package/dist/src/output/command-receipt.js +2 -6
  14. package/dist/src/output/command-receipt.js.map +1 -1
  15. package/dist/src/tui/controller.js +6 -3
  16. package/dist/src/tui/controller.js.map +1 -1
  17. package/dist/src/tui/model.d.ts +1 -0
  18. package/dist/src/tui/model.js +1 -1
  19. package/dist/src/tui/model.js.map +1 -1
  20. package/dist/src/types.d.ts +0 -1
  21. package/dist/src/types.js.map +1 -1
  22. package/dist/src/utils/agent-version.js +2 -6
  23. package/dist/src/utils/agent-version.js.map +1 -1
  24. package/dist/src/utils/codex-manager.d.ts +3 -3
  25. package/dist/src/utils/codex-manager.js +8 -20
  26. package/dist/src/utils/codex-manager.js.map +1 -1
  27. package/dist/src/utils/codex-reconciler.js +3 -3
  28. package/dist/src/utils/codex-reconciler.js.map +1 -1
  29. package/dist/src/utils/managed-command-store.d.ts +4 -0
  30. package/dist/src/utils/managed-command-store.js +34 -21
  31. package/dist/src/utils/managed-command-store.js.map +1 -1
  32. package/dist/src/utils/ownership.d.ts +2 -0
  33. package/dist/src/utils/ownership.js +6 -1
  34. package/dist/src/utils/ownership.js.map +1 -1
  35. package/package.json +3 -3
@@ -5,7 +5,7 @@ import { catalogFileMode } from '@lesliechan721/aw-plugin-core';
5
5
  import { COMMAND_PRODUCER_RECORD_FILE, getManagedCommandArtifactTargets, getCommandPackageId } from '@lesliechan721/aw-plugin-core/manifest';
6
6
  import os from 'node:os';
7
7
  import { commandSetsForProducer, createManagedCommandReferenceResolver, discoverRetainedManagedCommandPackages, retainedManagedCommandPackageResult, managedCommandProducerIdentity, prepareManagedCommandPackage, resolveSkillManagedCommandReferences, } from '../utils/managed-command-materialization.js';
8
- import { managedCommandDiagnostic, ManagedCommandError, publishManagedCommandBindings, revokeManagedCommandBindings, syncManagedCommandPackage, readInstalledCommandProducer, listManagedCommands } from '../utils/managed-command-store.js';
8
+ import { assertManagedCommandBindingIdentities, normalizeInstalledCommandProducer, managedCommandDiagnostic, ManagedCommandError, publishManagedCommandBindings, revokeManagedCommandBindings, syncManagedCommandPackage, readInstalledCommandProducer, listManagedCommands } from '../utils/managed-command-store.js';
9
9
  import { injectInstalledRuntimeConfig, carryRuntimeConfigNativeReceipt } from '../utils/runtime-config.js';
10
10
  import { resolveCodexSkillsRelativeRoot } from '../utils/codex-skills-root.js';
11
11
  import { resolveClaudeSkillsRelativeRoot } from '../utils/claude-skills-root.js';
@@ -19,6 +19,7 @@ import { createCodexSkillExpectedTree, createCodexSkillStagingTreeContentDigest,
19
19
  import { AW_PLUGIN_REQUIREMENTS_RECEIPT_PATH, createDynamicSkillExpectedTree, createDynamicSkillTreeContentDigest, readDynamicSkillTree, validateSkillDirectory, writeDynamicSkillTree, } from '../utils/dynamic-skill-tree.js';
20
20
  import { parseCodexSharedHooksFile, serializeTrackedHookGroupIdentity, } from '../utils/hooks-contract.js';
21
21
  import { buildCodexMarketplaceAddInvocation, buildCodexMarketplaceRemoveInvocation, buildCodexPluginAddInvocation, buildCodexPluginRemoveInvocation, CodexProjectConfigNotEffectiveError, runNativeCliChecked, SYSTEM_CODEX_MANAGER, } from '../utils/native-cli.js';
22
+ import { attachSafeOperationError, readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
22
23
  import { OWNED_TEXT_HEADER_PREFIX, createSharedOwnerToken, createSkillOwnerMarkerContent, parseSharedOwnerToken, parseOwnedTextHeader, readSkillOwnerMarker, renderOwnedTextFile, inspectOwnedComponents, writeOwnedTextFile, } from '../utils/ownership.js';
23
24
  import { resolveArtifactRenderConfig, resolveArtifactRendererTarget, runArtifactRenderer, } from '../utils/artifact-renderer.js';
24
25
  import { createArtifactConfigDigest, validateArtifactPlan, } from '../utils/artifact-plan.js';
@@ -301,7 +302,7 @@ async function executeCodexReconcileActivationsInSession(options) {
301
302
  for (const pluginId of observedActivationPluginIds) {
302
303
  const marketplaceName = codexMarketplaceFromPluginId(pluginId);
303
304
  const observationScope = options.observationScopeByMarketplace?.get(marketplaceName)
304
- ?? (options.plans.some((plan) => plan.requirement.requiresProjectPluginContract)
305
+ ?? (options.plans.some((plan) => plan.requirement.scope === 'project')
305
306
  ? 'both'
306
307
  : 'user');
307
308
  const registration = await inspectCodexPluginRegistrationLive({
@@ -443,7 +444,7 @@ export async function postcheckCodexReconcileActivations(options) {
443
444
  try {
444
445
  const marketplaceName = codexMarketplaceFromPluginId(check.codexPluginId);
445
446
  const observationScope = options.observationScopeByMarketplace?.get(marketplaceName)
446
- ?? (options.plans.some((plan) => plan.requirement.requiresProjectPluginContract)
447
+ ?? (options.plans.some((plan) => plan.requirement.scope === 'project')
447
448
  ? 'both'
448
449
  : 'user');
449
450
  const registration = await inspectCodexPluginRegistrationLive({
@@ -3536,6 +3537,22 @@ async function applyPlannedOperationAction(action) {
3536
3537
  }
3537
3538
  function createNativeDriver(options) {
3538
3539
  const runner = options.context.nativeCliRunner;
3540
+ const preflightCommandBindings = async (targets) => {
3541
+ const producers = [];
3542
+ for (const target of targets)
3543
+ for (const action of target.operationActions ?? []) {
3544
+ if (action.kind === 'syncManagedCommandPackage') {
3545
+ producers.push({ producer: action.producer, sets: action.sets });
3546
+ }
3547
+ else if (action.kind === 'materializeNativeSkill'
3548
+ || (action.kind === 'writeOwnedArtifact' && action.artifactKind === 'skill-directory')) {
3549
+ const file = action.files?.find((entry) => entry.relativePath === COMMAND_PRODUCER_RECORD_FILE);
3550
+ if (file)
3551
+ producers.push(normalizeInstalledCommandProducer(JSON.parse(Buffer.from(file.contentBase64, 'base64').toString('utf8'))));
3552
+ }
3553
+ }
3554
+ await assertManagedCommandBindingIdentities({ producers, env: options.context.env });
3555
+ };
3539
3556
  const revokeAtRoot = async (root, recursive = false, platform) => {
3540
3557
  const listed = await listManagedCommands(options.context.env);
3541
3558
  const producers = new Map();
@@ -3674,6 +3691,7 @@ function createNativeDriver(options) {
3674
3691
  }
3675
3692
  if (materializing.length === 0)
3676
3693
  return;
3694
+ await preflightCommandBindings(materializing);
3677
3695
  const first = materializing[0];
3678
3696
  if (!first.catalog)
3679
3697
  throw new Error('Missing rebuild target catalog data.');
@@ -3983,6 +4001,11 @@ function createNativeDriver(options) {
3983
4001
  return;
3984
4002
  const target = findTarget(component);
3985
4003
  await prepareNativeGroup(target);
4004
+ const pluginId = `${target.identity.pluginName}@${locator.marketplaceName}`;
4005
+ const stateKey = codexStateKey(target, pluginId);
4006
+ if (codexNativeStates.get(stateKey) === 'present'
4007
+ && pendingCodexNativeStates.get(stateKey) !== 'absent')
4008
+ return;
3986
4009
  codexMutationMarketplaces.add(locator.marketplaceName);
3987
4010
  await runObservedCodexMutation({
3988
4011
  marketplaceName: locator.marketplaceName,
@@ -4138,6 +4161,7 @@ function createNativeDriver(options) {
4138
4161
  : 'user'))));
4139
4162
  },
4140
4163
  preflightMutation: async (target) => {
4164
+ await preflightCommandBindings([target]);
4141
4165
  if (!target.codexNativeObservationExpectation
4142
4166
  && !target.codexNativeSensitivePreflightRequired)
4143
4167
  return;
@@ -4312,8 +4336,16 @@ function createNativeDriver(options) {
4312
4336
  mutation: () => runNativeCliChecked(buildCodexPluginRemoveInvocation(requireCodexManager(currentCodexManager()), component.pluginId, target.identity.cwd, options.context.env), runner),
4313
4337
  });
4314
4338
  }
4315
- catch {
4316
- throw new Error(`codexNativeRemoveFailed: ${CODEX_REMOVE_RECOVERY}`);
4339
+ catch (error) {
4340
+ const diagnostic = readSafeOperationError(error);
4341
+ throw attachSafeOperationError(new Error(`codexNativeRemoveFailed: ${CODEX_REMOVE_RECOVERY}`), {
4342
+ code: 'codexNativeRemoveFailed',
4343
+ safeMessage: `Codex plugin removal did not complete. ${CODEX_REMOVE_RECOVERY}`,
4344
+ ...(diagnostic?.exitCode === undefined ? {} : { exitCode: diagnostic.exitCode }),
4345
+ ...(diagnostic ? {
4346
+ cause: { code: diagnostic.code, safeMessage: diagnostic.safeMessage },
4347
+ } : {}),
4348
+ });
4317
4349
  }
4318
4350
  pendingCodexNativeStates.set(stateKey, 'absent');
4319
4351
  const postcheck = async () => {
@@ -4493,6 +4525,7 @@ function createNativeDriver(options) {
4493
4525
  }
4494
4526
  },
4495
4527
  writeArtifacts: async (target) => {
4528
+ await preflightCommandBindings([target]);
4496
4529
  await publishPackages(target);
4497
4530
  for (const operationAction of target.operationActions ?? []) {
4498
4531
  if (operationAction.kind === 'writeOwnedArtifact'