@lesliechan721/aw 0.1.0-beta.14 → 0.1.0-beta.15

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.
@@ -1,6 +1,6 @@
1
1
  import crypto from 'node:crypto';
2
2
  import path from 'node:path';
3
- import { statusCommandV7, statusTargetIntent, } from '../commands/status-v6.js';
3
+ import { statusCommandV7, statusTargetActivation, statusTargetIntent, statusTargetOwnershipState, } from '../commands/status-v6.js';
4
4
  import { addCatalogSourceCommand, listCatalogSources, preflightCatalogSourceMutation, removeCatalogSourceCommand, setPrimaryCatalogSourceCommand, updateCatalogSourceCommand, } from '../commands/catalog-source.js';
5
5
  import { cleanupWriteCommand, failedWriteCommandResult, installWriteCommand, mergeWriteCommandResults, reinstallWriteCommand, syncWriteCommand, taskWriteCommand, uninstallWriteCommand, } from '../commands/write-commands.js';
6
6
  import { resolveSyncIntentSelection } from '../commands/sync-command.js';
@@ -369,40 +369,6 @@ async function loadDependencyOverviews(options) {
369
369
  const unsupportedPluginIds = new Set(options.status.pluginSummaries
370
370
  .filter((summary) => (summary.missingCapabilities?.length ?? 0) > 0)
371
371
  .map((summary) => summary.pluginId));
372
- const placementReferences = new Map();
373
- for (const consumer of options.status.payload.targets.filter((target) => target.state !== 'absent')) {
374
- const consumerNode = nodes.get(consumer.pluginId);
375
- if (!consumerNode)
376
- continue;
377
- for (const dependencyPluginId of consumerNode.dependencies) {
378
- const dependencyTargets = (targetsByPlugin.get(dependencyPluginId) ?? [])
379
- .filter((target) => target.platform === consumer.platform);
380
- const projectTarget = dependencyTargets.find((target) => target.scope === 'project');
381
- const userTarget = dependencyTargets.find((target) => target.scope === 'user');
382
- const dependencyScope = consumer.scope === 'user'
383
- ? 'user'
384
- : userTarget && (!projectTarget
385
- || (userTarget.state !== 'absent' && projectTarget.state === 'absent'))
386
- ? 'user'
387
- : 'project';
388
- const reference = {
389
- consumer: {
390
- pluginId: consumer.pluginId,
391
- platform: consumer.platform,
392
- scope: consumer.scope,
393
- project: consumer.scope === 'project' ? 'current' : null,
394
- },
395
- dependency: {
396
- pluginId: dependencyPluginId,
397
- platform: consumer.platform,
398
- scope: dependencyScope,
399
- project: dependencyScope === 'project' ? 'current' : null,
400
- },
401
- };
402
- const key = `${consumer.pluginId}\0${dependencyPluginId}`;
403
- placementReferences.set(key, [...(placementReferences.get(key) ?? []), reference]);
404
- }
405
- }
406
372
  const placementsFor = (pluginId) => {
407
373
  const targets = targetsByPlugin.get(pluginId) ?? [];
408
374
  if (targets.length > 0) {
@@ -474,7 +440,7 @@ async function loadDependencyOverviews(options) {
474
440
  })),
475
441
  placements,
476
442
  aggregateStatus: aggregateFor(dependency.pluginId, placements),
477
- placementReferences: placementReferences.get(`${pluginId}\0${dependency.pluginId}`) ?? [],
443
+ placementReferences: [],
478
444
  };
479
445
  });
480
446
  const dependentIds = [...new Set(reverse.get(pluginId) ?? [])].sort();
@@ -488,7 +454,7 @@ async function loadDependencyOverviews(options) {
488
454
  requiredBy: [],
489
455
  placements,
490
456
  aggregateStatus: aggregateFor(dependentId, placements),
491
- placementReferences: placementReferences.get(`${dependentId}\0${pluginId}`) ?? [],
457
+ placementReferences: [],
492
458
  };
493
459
  });
494
460
  const targetBlockers = (targetsByPlugin.get(pluginId) ?? []).flatMap((target) => target.reasons.filter((error) => error.code.startsWith('dependency') || error.code === 'sourceChanged')
@@ -683,6 +649,7 @@ export function createTuiControllerDependencies(context, progressFeed, options =
683
649
  const result = await statusCommandV7({
684
650
  cwd: context.cwd,
685
651
  env: context.env,
652
+ nativeCliRunner: context.nativeCliRunner,
686
653
  cliVersion: packageInfo.version,
687
654
  verbose: context.diagnostics.verbose,
688
655
  ...(catalogOperationContext ? { catalogOperationContext } : {}),
@@ -775,6 +742,23 @@ export function createTuiControllerDependencies(context, progressFeed, options =
775
742
  };
776
743
  const captureEvidence = async (intent, signal, preparation, operationInventory = createOperationInventoryReader(), freshCatalog = false, reusableCandidate, codexObservationSession, frozenBatchEvidence) => {
777
744
  reviewedScriptTimeoutMs(intent);
745
+ if ((intent.kind === 'pluginWrite'
746
+ && (intent.platform === 'codex' || intent.platform === 'both')
747
+ || intent.kind === 'pluginWriteTask'
748
+ && intent.targets.some((target) => target.platform === 'codex'))
749
+ && !codexObservationSession) {
750
+ const observationSession = await createCodexNativeObservationSession({
751
+ exactCwd: context.cwd,
752
+ env: context.env,
753
+ runner: context.nativeCliRunner,
754
+ });
755
+ try {
756
+ return await captureEvidence(intent, signal, preparation, operationInventory, freshCatalog, reusableCandidate, observationSession, frozenBatchEvidence);
757
+ }
758
+ finally {
759
+ await observationSession.dispose();
760
+ }
761
+ }
778
762
  if (intent.kind === 'catalogManagement') {
779
763
  signal?.throwIfAborted();
780
764
  await preparation?.reporter.emit('validate');
@@ -1236,6 +1220,8 @@ export function createTuiControllerDependencies(context, progressFeed, options =
1236
1220
  plugins: [...new Set(requestedTargets.map((target) => target.pluginId))],
1237
1221
  cwd: context.cwd,
1238
1222
  env: context.env,
1223
+ nativeCliRunner: context.nativeCliRunner,
1224
+ ...(codexObservationSession ? { codexObservationSession } : {}),
1239
1225
  cliVersion: packageInfo.version,
1240
1226
  catalogOperationContext: catalogOperation,
1241
1227
  inventoryCatalogSourceReferences: operationInventory,
@@ -1635,6 +1621,33 @@ export function createTuiControllerDependencies(context, progressFeed, options =
1635
1621
  await preparation?.reporter.emit('evidence');
1636
1622
  signal?.throwIfAborted();
1637
1623
  const merged = mergeWriteCommandResults(groups.map((group) => group.preview));
1624
+ const targetVersions = groups.flatMap((group) => {
1625
+ if (group.platform === 'both')
1626
+ return [];
1627
+ const platform = group.platform;
1628
+ return group.requestedPluginIds.map((pluginId) => {
1629
+ const live = sessionStatusResult?.payload.targets.find((target) => target.pluginId === pluginId && target.platform === platform
1630
+ && (target.scope === group.scope || statusTargetIntent(target).scopes.includes(group.scope)
1631
+ || platform === 'codex' && statusTargetActivation(target)?.[group.scope] === true));
1632
+ const revision = sessionStatusResult?.targetRevisions?.find((target) => target.pluginId === pluginId && target.platform === platform
1633
+ && target.scope === group.scope)?.revision;
1634
+ const activation = live ? statusTargetActivation(live) : undefined;
1635
+ const ownership = live && live.scope === group.scope
1636
+ ? statusTargetOwnershipState(live) : 'absent';
1637
+ const present = ownership === 'present' || ownership === 'partial'
1638
+ || platform === 'codex' && activation?.[group.scope] === true;
1639
+ const planned = live ? statusTargetIntent(live).scopes.includes(group.scope) : false;
1640
+ return {
1641
+ pluginId,
1642
+ platform,
1643
+ scope: group.scope,
1644
+ presence: present ? 'installed'
1645
+ : ownership === 'absent' && planned ? 'new' : 'unknown',
1646
+ ...(revision?.installedVersion ? { installedVersion: revision.installedVersion } : {}),
1647
+ ...(revision?.availableVersion ? { availableVersion: revision.availableVersion } : {}),
1648
+ };
1649
+ });
1650
+ });
1638
1651
  const evidence = {
1639
1652
  catalog: {
1640
1653
  configDigest: configSnapshot.digest,
@@ -1643,6 +1656,13 @@ export function createTuiControllerDependencies(context, progressFeed, options =
1643
1656
  },
1644
1657
  requestedPluginIds: selection.requestedPluginIds,
1645
1658
  groups,
1659
+ targetVersions: [...new Map(targetVersions.map((target) => [[
1660
+ target.pluginId, target.platform, target.scope,
1661
+ ].join('\0'), target])).values()].sort((left, right) => [
1662
+ left.pluginId, left.platform, left.scope,
1663
+ ].join('\0').localeCompare([
1664
+ right.pluginId, right.platform, right.scope,
1665
+ ].join('\0'), 'en')),
1646
1666
  ...(merged.dependencyPlan ? { dependencyPlan: merged.dependencyPlan } : {}),
1647
1667
  ...(merged.codexReconcilePlans ? { codexReconcilePlans: merged.codexReconcilePlans } : {}),
1648
1668
  ...(merged.operationPlan ? { operationPlan: merged.operationPlan } : {}),
@@ -1843,6 +1863,8 @@ export function createTuiControllerDependencies(context, progressFeed, options =
1843
1863
  : {}),
1844
1864
  cwd: context.cwd,
1845
1865
  env: context.env,
1866
+ nativeCliRunner: context.nativeCliRunner,
1867
+ ...(codexObservationSession ? { codexObservationSession } : {}),
1846
1868
  cliVersion: packageInfo.version,
1847
1869
  ...(statusCatalogOperation ? { catalogOperationContext: statusCatalogOperation } : {}),
1848
1870
  inventoryCatalogSourceReferences: operationInventory,