@lesliechan721/aw 0.1.0-beta.84 → 0.1.0-beta.85
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/index.js +2 -6
- package/dist/index.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +3 -8
- package/dist/src/commands/public-lifecycle-result.js +85 -30
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +21 -5
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.js +19 -3
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +1 -0
- package/dist/src/commands/rebuild-integration.js +5 -0
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.js +5 -2
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +7 -2
- package/dist/src/commands/rebuild-platform-integration.js +539 -65
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +7 -1
- package/dist/src/generators/permissions.js +56 -0
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +7 -4
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/scope-context.d.ts +4 -2
- package/dist/src/intent/scope-context.js +37 -7
- package/dist/src/intent/scope-context.js.map +1 -1
- package/dist/src/output/component-delivery.d.ts +21 -0
- package/dist/src/output/component-delivery.js +82 -0
- package/dist/src/output/component-delivery.js.map +1 -0
- package/dist/src/output/public-result.d.ts +2 -0
- package/dist/src/output/public-result.js +49 -16
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/receipt-projection.js +13 -5
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/output/skill-invocation-notices.d.ts +2 -0
- package/dist/src/output/skill-invocation-notices.js +40 -4
- package/dist/src/output/skill-invocation-notices.js.map +1 -1
- package/dist/src/platforms/capabilities.d.ts +4 -1
- package/dist/src/platforms/capabilities.js +93 -9
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +36 -1
- package/dist/src/platforms/discovery.d.ts +11 -0
- package/dist/src/platforms/discovery.js +170 -30
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-grok.js +121 -9
- package/dist/src/platforms/inspection-grok.js.map +1 -1
- package/dist/src/platforms/inspection-native.js +53 -18
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-pi.d.ts +7 -1
- package/dist/src/platforms/inspection-pi.js +295 -95
- package/dist/src/platforms/inspection-pi.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +4 -2
- package/dist/src/platforms/inspection-query.js +24 -8
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/inspection.d.ts +4 -1
- package/dist/src/platforms/inspection.js +36 -4
- package/dist/src/platforms/inspection.js.map +1 -1
- package/dist/src/platforms/layout.d.ts +6 -0
- package/dist/src/platforms/layout.js +44 -7
- package/dist/src/platforms/layout.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.d.ts +1 -0
- package/dist/src/platforms/lifecycle-native.js +25 -1
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.d.ts +2 -0
- package/dist/src/platforms/lifecycle.js +67 -16
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/projection-code-extension.js +2 -1
- package/dist/src/platforms/projection-code-extension.js.map +1 -1
- package/dist/src/platforms/projection.js +70 -22
- package/dist/src/platforms/projection.js.map +1 -1
- package/dist/src/platforms/supplement-layout.d.ts +5 -1
- package/dist/src/platforms/supplement-layout.js +23 -1
- package/dist/src/platforms/supplement-layout.js.map +1 -1
- package/dist/src/platforms/supplement-state.d.ts +1 -1
- package/dist/src/platforms/supplement-state.js +18 -7
- package/dist/src/platforms/supplement-state.js.map +1 -1
- package/dist/src/portable/commands.js +1 -1
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +4 -0
- package/dist/src/portable/materializer.js +8 -1
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +2 -0
- package/dist/src/portable/recovery.js +45 -8
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +1 -1
- package/dist/src/recovery/coordinator.js +77 -10
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/install-concurrency.js +3 -2
- package/dist/src/recovery/install-concurrency.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.d.ts +7 -0
- package/dist/src/recovery/joint-coordinator.js +173 -23
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +14 -2
- package/dist/src/recovery/joint-demand.js +54 -7
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/receipt.d.ts +15 -4
- package/dist/src/recovery/receipt.js +23 -0
- package/dist/src/recovery/receipt.js.map +1 -1
- package/dist/src/recovery/status.d.ts +20 -8
- package/dist/src/recovery/status.js +380 -90
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/platform-profile.js +2 -1
- package/dist/src/review/platform-profile.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +1 -0
- package/dist/src/review/skill-materialization.js +45 -39
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.js +5 -1
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +67 -30
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +1 -1
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +2 -1
- package/dist/src/tui/controller.js +17 -4
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/deployment-view.d.ts +6 -3
- package/dist/src/tui/deployment-view.js +39 -10
- package/dist/src/tui/deployment-view.js.map +1 -1
- package/dist/src/tui/diagnostic-projection.d.ts +7 -1
- package/dist/src/tui/diagnostic-projection.js +47 -2
- package/dist/src/tui/diagnostic-projection.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +2 -1
- package/dist/src/tui/entity-cards.js +34 -11
- package/dist/src/tui/entity-cards.js.map +1 -1
- package/dist/src/tui/glossary.js +5 -0
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/tui/model.js +2 -1
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.js +3 -1
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
- package/dist/src/tui/operation-history.d.ts +6 -0
- package/dist/src/tui/operation-history.js +20 -2
- package/dist/src/tui/operation-history.js.map +1 -1
- package/dist/src/tui/plugin-detail.d.ts +4 -1
- package/dist/src/tui/plugin-detail.js +9 -2
- package/dist/src/tui/plugin-detail.js.map +1 -1
- package/dist/src/tui/scoped-flow.js +34 -16
- package/dist/src/tui/scoped-flow.js.map +1 -1
- package/dist/src/tui/scoped-inventory.d.ts +6 -2
- package/dist/src/tui/scoped-inventory.js +29 -7
- package/dist/src/tui/scoped-inventory.js.map +1 -1
- package/dist/src/types.d.ts +2 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/artifact-plan.js +5 -1
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +1 -1
- package/dist/src/utils/artifact-renderer.js +29 -8
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/catalog-source-references.js +12 -3
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +6 -0
- package/dist/src/utils/codex-native-observation.js +32 -3
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +2 -0
- package/dist/src/utils/component-command-preparation.js +23 -4
- package/dist/src/utils/component-command-preparation.js.map +1 -1
- package/dist/src/utils/component-gap.d.ts +4 -0
- package/dist/src/utils/component-gap.js +20 -0
- package/dist/src/utils/component-gap.js.map +1 -0
- package/dist/src/utils/component-resources.js +2 -4
- package/dist/src/utils/component-resources.js.map +1 -1
- package/dist/src/utils/dynamic-skill-tree.js +2 -32
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/native-cli-interruption.d.ts +8 -0
- package/dist/src/utils/native-cli-interruption.js +65 -0
- package/dist/src/utils/native-cli-interruption.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +5 -0
- package/dist/src/utils/native-cli.js +166 -53
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +1 -0
- package/dist/src/utils/ownership.js +17 -3
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/package-content.d.ts +7 -0
- package/dist/src/utils/package-content.js +70 -0
- package/dist/src/utils/package-content.js.map +1 -0
- package/dist/src/utils/platform-empty-state.d.ts +31 -6
- package/dist/src/utils/platform-empty-state.js +135 -65
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-write.js +5 -1
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-scripts.js +19 -8
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +1 -1
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/skill-invocation-warning.d.ts +8 -3
- package/dist/src/utils/skill-invocation-warning.js +27 -1
- package/dist/src/utils/skill-invocation-warning.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCommandPackageId } from '@lesliechan721/aw-plugin-core/manifest';
|
|
2
|
-
import { finalizePreparedPlatformRebuildSession } from '../commands/rebuild-integration.js';
|
|
2
|
+
import { finalizePreparedPlatformRebuildSession, recordPreparedGrokProjectRetirement } from '../commands/rebuild-integration.js';
|
|
3
3
|
import { addRequirements } from '../commands/intent-command.js';
|
|
4
4
|
import { createEmptyIntent, calculateIntentDigest, removeIntentRoot } from '../intent/intent-codec.js';
|
|
5
5
|
import { observeIntent, writeIntent, resolveIntentPath } from '../intent/intent-store.js';
|
|
@@ -20,7 +20,7 @@ import { parsePluginId } from '../utils/multi-source-catalog.js';
|
|
|
20
20
|
import { readDemand, resolveDelivery } from './demand.js';
|
|
21
21
|
import { hasSharedUserPackage } from '../platforms/layout.js';
|
|
22
22
|
import { preparePortableRecovery } from '../portable/recovery.js';
|
|
23
|
-
import { canReuseProviderAcrossScopes, readJointDemand, deriveJointDemand, deriveSharedReferenceView, indexJointDependencies } from './joint-demand.js';
|
|
23
|
+
import { canReuseProviderAcrossScopes, hasInheritableSkills, isInstalledSkillProvider, projectSkillCandidates, readJointDemand, deriveJointDemand, deriveSharedReferenceView, indexJointDependencies } from './joint-demand.js';
|
|
24
24
|
import { checkFootprints, prepareScopedRecovery, executeScopedRecovery, executeRecoveryPreApply, refreshRecoveryNativePreviews, describeRecoveryPlan, errorCode } from './coordinator.js';
|
|
25
25
|
import { isTargetObservationReadError, readScopedRecoveryStatus, readRecoveryStatus } from './status.js';
|
|
26
26
|
import { recoveryRetryDispositions, recoveryStatusContext, retriesFromRequestedRoots } from './receipt.js';
|
|
@@ -119,8 +119,11 @@ function mergeReceipts(plan, receipts) {
|
|
|
119
119
|
target.relation = selectedContributions.some((item) => item.root === target.pluginId && item.scope === target.scope) ? 'root' : 'dependency';
|
|
120
120
|
if (target.relation === 'dependency')
|
|
121
121
|
target.contributions = selectedContributions;
|
|
122
|
-
if (placement.scope !== target.scope)
|
|
122
|
+
if (placement.scope !== target.scope) {
|
|
123
123
|
target.requirementScope = target.scope;
|
|
124
|
+
if (target.satisfaction === 'installed' && placement.scope === 'user')
|
|
125
|
+
target.satisfaction = 'inherited-user';
|
|
126
|
+
}
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
129
|
const executed = new Set(receipt.targetResults.map(targetKey));
|
|
@@ -322,7 +325,14 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
322
325
|
targets: normalizeAgents([...snapshot.preferences.targets, ...installed.map((item) => item.agent)]) };
|
|
323
326
|
}
|
|
324
327
|
}
|
|
325
|
-
|
|
328
|
+
let previousDemand = deriveJointDemand(snapshot);
|
|
329
|
+
const previousCandidates = projectSkillCandidates(previousDemand);
|
|
330
|
+
if (command === 'uninstall' && previousCandidates.length) {
|
|
331
|
+
observedStatus ??= await readRecoveryStatus({ ...options, catalogReadScope, ...initialNativeReads, targets: undefined }, savedDemand);
|
|
332
|
+
previousDemand = deriveJointDemand(snapshot, observedStatus.projectSkillProviders);
|
|
333
|
+
}
|
|
334
|
+
const previousUserProvided = (pluginId, target) => previousDemand.placements.some((item) => item.pluginId === pluginId && item.target === target && item.scope === 'user'
|
|
335
|
+
&& item.contributions.some((entry) => entry.scope === 'project'));
|
|
326
336
|
const previousPlugins = [...new Map([...(snapshot.user.plugins), ...(snapshot.project?.plugins ?? [])]
|
|
327
337
|
.map((plugin) => [plugin.pluginId, plugin])).values()];
|
|
328
338
|
const dependencyClosures = new Map();
|
|
@@ -410,7 +420,31 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
410
420
|
}
|
|
411
421
|
}
|
|
412
422
|
}
|
|
413
|
-
|
|
423
|
+
let demand = deriveJointDemand(snapshot);
|
|
424
|
+
const pendingUserSkills = [];
|
|
425
|
+
const candidates = projectSkillCandidates(demand).filter((item) => !options.targets || options.targets.includes(item.target));
|
|
426
|
+
if (candidates.length) {
|
|
427
|
+
observedStatus ??= await readRecoveryStatus({ ...options, catalogReadScope, ...initialNativeReads, targets: undefined,
|
|
428
|
+
projectSkillProbes: candidates }, savedDemand);
|
|
429
|
+
const providers = observedStatus.projectSkillProviders?.map((provider) => {
|
|
430
|
+
if ((!provider.userNeedsRepair && !provider.userAbsent) || provider.projectCopy === 'blocked' || command !== 'sync' || options.existingOnly)
|
|
431
|
+
return provider;
|
|
432
|
+
// A joint sync can repair its selected, owned User package before the Project consumer runs.
|
|
433
|
+
const owned = observedStatus.observedTargets?.some((target) => target.pluginId === provider.pluginId && target.agent === provider.target
|
|
434
|
+
&& target.scope === 'user' && target.content === 'drifted' && !target.blockers.length
|
|
435
|
+
&& target.deploymentObservations?.every(({ after }) => after.ownership === 'aw'));
|
|
436
|
+
const selectedUserRoot = demand.placements.some((item) => item.scope === 'user' && item.pluginId === provider.pluginId
|
|
437
|
+
&& item.target === provider.target && item.contributions.some((entry) => entry.scope === 'user'
|
|
438
|
+
&& (!selectors.length || selectors.some((id) => id === entry.root || id === parsePluginId(entry.root).pluginName))
|
|
439
|
+
&& (!options.exactTargets || options.exactTargets.some((exact) => exact.scope === 'user'
|
|
440
|
+
&& exact.agent === item.target && exact.pluginId === entry.root))));
|
|
441
|
+
if (!selectedUserRoot || !owned && !provider.userAbsent)
|
|
442
|
+
return provider;
|
|
443
|
+
pendingUserSkills.push({ pluginId: provider.pluginId, target: provider.target, sourceIdentity: provider.sourceIdentity });
|
|
444
|
+
return { ...provider, userNeedsRepair: false, userAbsent: false };
|
|
445
|
+
});
|
|
446
|
+
demand = deriveJointDemand(snapshot, providers);
|
|
447
|
+
}
|
|
414
448
|
const rootIds = [...new Set([...(snapshot.user.roots ?? []), ...(snapshot.project?.roots ?? [])]
|
|
415
449
|
.map((root) => root.pluginId))];
|
|
416
450
|
if (command !== 'install' && command !== 'uninstall') {
|
|
@@ -461,7 +495,7 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
461
495
|
if (!targets.includes(placement.target))
|
|
462
496
|
return false;
|
|
463
497
|
if (command === 'uninstall')
|
|
464
|
-
return canReuseProviderAcrossScopes(placement.target)
|
|
498
|
+
return (canReuseProviderAcrossScopes(placement.target) || previousUserProvided(placement.pluginId, placement.target))
|
|
465
499
|
&& !(options.force && requestedIds.has(placement.pluginId))
|
|
466
500
|
&& previousDemand.placements.some((previous) => previous.pluginId === placement.pluginId && previous.target === placement.target
|
|
467
501
|
&& previous.scope !== placement.scope && previous.contributions.some((item) => item.scope === scope && requestedIds.has(item.root))
|
|
@@ -544,7 +578,7 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
544
578
|
};
|
|
545
579
|
const children = [];
|
|
546
580
|
const { signal: _signal, ...executionOptions } = options;
|
|
547
|
-
const joint = { snapshot, demand, unplacedRoots, removalDependencies: dependencyClosures, selectedContributions, children, originalOptions: executionOptions,
|
|
581
|
+
const joint = { snapshot, demand, unplacedRoots, removalDependencies: dependencyClosures, selectedContributions, children, originalOptions: executionOptions, pendingUserSkills, providerRetirements: new Set(),
|
|
548
582
|
selectors: [...selectors], declaration, evidence };
|
|
549
583
|
const plan = { command, options: { ...executionOptions, scope }, receipt, context, demand: baseDemand,
|
|
550
584
|
originalIntent: observationEvidence(original.intent), preferencesEvidence: observationEvidence(snapshot.user.preferences),
|
|
@@ -567,9 +601,10 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
567
601
|
const sharedReferenceView = deriveSharedReferenceView(snapshot, demand, currentStatus);
|
|
568
602
|
const ownsOutput = (item) => currentStatus.ownedTargets?.some((owned) => owned.pluginId === item.pluginId
|
|
569
603
|
&& owned.agent === item.agent && owned.scope === item.scope) === true;
|
|
570
|
-
const
|
|
604
|
+
const liveTargets = currentStatus.existingTargets ?? [];
|
|
605
|
+
const liveConsumers = [...liveTargets, ...(currentStatus.retainedProjectPackages ?? [])];
|
|
571
606
|
const sameProvider = (consumer, provider) => consumer.agent === provider.agent && (consumer.scope === provider.scope
|
|
572
|
-
|| provider.scope === 'user' && canReuseProviderAcrossScopes(consumer.agent));
|
|
607
|
+
|| provider.scope === 'user' && (canReuseProviderAcrossScopes(consumer.agent) || previousUserProvided(provider.pluginId, consumer.agent)));
|
|
573
608
|
const automaticRetirements = command === 'uninstall' && !options.keepDependencies && demand.complete
|
|
574
609
|
? previousDemand.placements.filter((placement) => placement.scope === scope && targets.includes(placement.target)
|
|
575
610
|
&& (placement.target !== 'generic' ? currentStatus.coverage.native : currentStatus.coverage.portable)
|
|
@@ -578,20 +613,36 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
578
613
|
: snapshot[placement.scope]?.roots?.some((root) => root.pluginId === placement.pluginId))
|
|
579
614
|
&& placement.contributions.some((item) => explicitlyRemoves({ pluginId: item.root, agent: placement.target, scope: item.scope }))
|
|
580
615
|
&& !demand.placements.some((item) => item.pluginId === placement.pluginId && item.target === placement.target
|
|
581
|
-
&& (item.scope === placement.scope || canReuseProviderAcrossScopes(placement.target)))
|
|
616
|
+
&& (item.scope === placement.scope || canReuseProviderAcrossScopes(placement.target) || previousUserProvided(placement.pluginId, placement.target)))
|
|
582
617
|
&& ownsOutput({ pluginId: placement.pluginId, agent: placement.target, scope: placement.scope })) : [];
|
|
583
618
|
// A live consumer can outlast its Intent or its Active catalog entry.
|
|
584
619
|
const retainedConsumerFor = (provider) => liveConsumers.find((consumer) => {
|
|
585
620
|
if (explicitlyRemoves(consumer) && ownsOutput(consumer) || automaticRetirements.some((item) => item.pluginId === consumer.pluginId && item.target === consumer.agent && item.scope === consumer.scope))
|
|
586
621
|
return false;
|
|
587
|
-
|
|
622
|
+
const sourceIdentity = consumer.nativePackage?.sourceIdentity;
|
|
623
|
+
const providerManifest = sourceIdentity && previousPlugins.find((plugin) => plugin.pluginId === provider.pluginId && plugin.sourceIdentity === sourceIdentity);
|
|
624
|
+
if (consumer.dependencies !== undefined && !providerManifest)
|
|
625
|
+
return false;
|
|
626
|
+
const liveNativeInheritance = provider.scope === 'user' && consumer.scope === 'project' && consumer.agent === provider.agent
|
|
627
|
+
&& providerManifest && !canReuseProviderAcrossScopes(consumer.agent) && hasInheritableSkills(providerManifest)
|
|
628
|
+
&& liveTargets.some((item) => item.pluginId === provider.pluginId && item.agent === provider.agent && item.scope === 'user'
|
|
629
|
+
&& item.nativePackage?.sourceIdentity === sourceIdentity);
|
|
630
|
+
if (!sameProvider(consumer, provider) && !liveNativeInheritance)
|
|
588
631
|
return false;
|
|
589
|
-
const closure = dependencies(consumer.pluginId);
|
|
632
|
+
const closure = consumer.dependencies === undefined ? dependencies(consumer.pluginId) : consumer.dependencies;
|
|
590
633
|
if (!closure?.includes(provider.pluginId) && !(closure === null
|
|
591
634
|
&& parsePluginId(consumer.pluginId).sourceId === parsePluginId(provider.pluginId).sourceId))
|
|
592
635
|
return false;
|
|
636
|
+
if (liveNativeInheritance) {
|
|
637
|
+
const projectCopyReady = liveTargets.some((item) => item.pluginId === provider.pluginId
|
|
638
|
+
&& item.agent === provider.agent && item.scope === 'project' && item.nativePackage?.sourceIdentity === sourceIdentity
|
|
639
|
+
&& item.nativePackage?.skillsReady);
|
|
640
|
+
const stagedReplacement = selected.some((item) => item.pluginId === provider.pluginId
|
|
641
|
+
&& item.target === provider.agent && item.scope === 'project' && item.plugin.sourceIdentity === sourceIdentity);
|
|
642
|
+
return !projectCopyReady && !stagedReplacement;
|
|
643
|
+
}
|
|
593
644
|
return !demand.placements.some((item) => item.pluginId === provider.pluginId && item.target === provider.agent
|
|
594
|
-
&& item.scope !== provider.scope && sameProvider(consumer, { agent: item.target, scope: item.scope }));
|
|
645
|
+
&& item.scope !== provider.scope && sameProvider(consumer, { pluginId: item.pluginId, agent: item.target, scope: item.scope }));
|
|
595
646
|
});
|
|
596
647
|
for (let index = automaticRetirements.length - 1; index >= 0; index--) {
|
|
597
648
|
const candidate = automaticRetirements[index];
|
|
@@ -648,6 +699,11 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
648
699
|
const nativeTargets = targets.filter((target) => target !== 'generic');
|
|
649
700
|
const batch = isInstallBatch(command);
|
|
650
701
|
const hasSelectedScripts = selected.some((item) => item.plugin.manifest.scripts?.preApply);
|
|
702
|
+
if (batch && nativeObservationBatch && [...demand.placements, ...selected].every(({ plugin }) => {
|
|
703
|
+
const scripts = plugin.manifest.scripts;
|
|
704
|
+
return !scripts?.artifacts?.render && !scripts?.preApply && !scripts?.node?.build;
|
|
705
|
+
}))
|
|
706
|
+
nativeObservationBatch.scriptFreePlacement = true;
|
|
651
707
|
const portableGenerations = new Map();
|
|
652
708
|
const targetGroups = batch ? [...nativeTargets, ...targets.filter((target) => target === 'generic')].map((target) => [target])
|
|
653
709
|
: [...(nativeTargets.length ? [nativeTargets] : []), ...targets.filter((target) => target === 'generic').map((target) => [target])];
|
|
@@ -664,6 +720,10 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
664
720
|
}) : [];
|
|
665
721
|
const inheritedPortableProviderIds = inheritedScripts.filter((item) => item.target === 'generic').map((item) => item.pluginId);
|
|
666
722
|
const placements = selected.filter((item) => item.scope === currentScope && groupTargets.includes(item.target)
|
|
723
|
+
&& !(item.scope === 'user' && !canReuseProviderAcrossScopes(item.target)
|
|
724
|
+
&& selectedContributions.get(item)?.every((entry) => entry.scope === 'project')
|
|
725
|
+
&& currentStatus.observedTargets?.some((actual) => actual.pluginId === item.pluginId
|
|
726
|
+
&& actual.agent === item.target && isInstalledSkillProvider(actual)))
|
|
667
727
|
&& !(command === 'install' && scope === 'project' && currentScope === 'user'
|
|
668
728
|
&& currentStatus.observedTargets?.some((observed) => observed.pluginId === item.pluginId
|
|
669
729
|
&& observed.agent === item.target && observed.scope === 'user' && observed.content === 'satisfied'))
|
|
@@ -823,13 +883,29 @@ async function prepareJointRecoveryInSession(command, selectors, { checkInstallC
|
|
|
823
883
|
|| selected.some((placement) => canReuseProviderAcrossScopes(placement.target)
|
|
824
884
|
&& placement.pluginId === item.pluginId && placement.target === item.agent && placement.scope !== item.scope
|
|
825
885
|
&& (item.delivery?.kind !== 'agent-skills' || item.backend?.logicalIdentity === placement.plugin.catalogLogicalIdentity))));
|
|
886
|
+
if (scope === 'project')
|
|
887
|
+
for (const provider of currentStatus.projectSkillProviders ?? []) {
|
|
888
|
+
if (provider.target === 'generic' || provider.projectCopy !== 'owned' || !selected.some((placement) => placement.pluginId === provider.pluginId
|
|
889
|
+
&& placement.target === provider.target && placement.scope === 'user'
|
|
890
|
+
&& selectedContributions.get(placement)?.some((entry) => entry.scope === 'project')))
|
|
891
|
+
continue;
|
|
892
|
+
const position = { pluginId: provider.pluginId, agent: provider.target, scope: 'project' };
|
|
893
|
+
if (ownsOutput(position)) {
|
|
894
|
+
joint.providerRetirements.add(targetKey(position));
|
|
895
|
+
retire.push({ ...position, delivery: { kind: 'native', platform: provider.target }, observation: 'verified' });
|
|
896
|
+
}
|
|
897
|
+
}
|
|
826
898
|
for (const item of currentStatus.observedTargets ?? []) {
|
|
827
|
-
if (ownsOutput(item) && !requiredNativeActivation(item) && selected.some((placement) => canReuseProviderAcrossScopes(placement.target)
|
|
899
|
+
if (ownsOutput(item) && !requiredNativeActivation(item) && selected.some((placement) => (canReuseProviderAcrossScopes(placement.target)
|
|
900
|
+
|| command === 'uninstall' && item.scope === scope && previousUserProvided(placement.pluginId, placement.target))
|
|
828
901
|
&& placement.pluginId === item.pluginId
|
|
829
902
|
&& placement.target === item.agent && placement.scope !== item.scope)
|
|
830
903
|
&& !demand.placements.some((placement) => placement.pluginId === item.pluginId
|
|
831
|
-
&& placement.target === item.agent && placement.scope === item.scope))
|
|
904
|
+
&& placement.target === item.agent && placement.scope === item.scope)) {
|
|
832
905
|
retire.push(item);
|
|
906
|
+
if (item.agent && !canReuseProviderAcrossScopes(item.agent))
|
|
907
|
+
joint.providerRetirements.add(targetKey(item));
|
|
908
|
+
}
|
|
833
909
|
}
|
|
834
910
|
// A removed declaration is still present in the observed snapshot, so include its exact old outputs.
|
|
835
911
|
if (command === 'uninstall')
|
|
@@ -1041,7 +1117,7 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1041
1117
|
const checked = await measureRecoveryPerformanceStage(performanceRuntime, 'recovery.locked.recheck', () => prepareJointRecovery(plan.command, joint.selectors, preparation.options, { ...performanceRuntime, awHomeMutationToken: token }, preparation.catalogReadScope ? preparation : undefined));
|
|
1042
1118
|
const stable = !checked.blockExecution && JSON.stringify(describeRecoveryPlan(plan)) === JSON.stringify(describeRecoveryPlan(checked));
|
|
1043
1119
|
lockedPlan = checked;
|
|
1044
|
-
const parallel = isInstallBatch(plan.command) && !joint.children.some((child) => child.command === 'cleanup');
|
|
1120
|
+
const parallel = isInstallBatch(plan.command) && !joint.pendingUserSkills.length && !joint.children.some((child) => child.command === 'cleanup');
|
|
1045
1121
|
const children = parallel ? checked.joint.children : joint.children;
|
|
1046
1122
|
if (!stable)
|
|
1047
1123
|
return blockedBeforeDeployment(plan);
|
|
@@ -1104,16 +1180,23 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1104
1180
|
else {
|
|
1105
1181
|
const packages = runtime.configApplyPackages;
|
|
1106
1182
|
const dependencyGraph = indexJointDependencies(joint.demand);
|
|
1183
|
+
const readCurrentProviders = (plugins, targets) => {
|
|
1184
|
+
const { cwd, env, cliVersion } = joint.originalOptions;
|
|
1185
|
+
return readRecoveryStatus({ cwd, env, cliVersion, context: joint.snapshot.context.context,
|
|
1186
|
+
expectedProjectRoot: joint.snapshot.context.projectRoot, plugins: [...new Set(plugins)], targets: [...new Set(targets)],
|
|
1187
|
+
nativeCliRunner: runtime.nativeCliRunner, signal: runtime.signal });
|
|
1188
|
+
};
|
|
1107
1189
|
const portableProgress = { completed: [], failed: [] };
|
|
1108
1190
|
const failedCleanups = [];
|
|
1109
1191
|
const executeChild = async (child, pluginIds, agent) => {
|
|
1192
|
+
const childRuntime = { ...runtime, batchInstallPlatform: child.runtime.batchInstallPlatform };
|
|
1110
1193
|
const currentIntent = await observeIntent(child.options);
|
|
1111
1194
|
if (!joint.originalOptions.existingOnly)
|
|
1112
1195
|
child.demand.intent = currentIntent;
|
|
1113
1196
|
const fresh = await measureRecoveryPerformanceStage(runtime, 'recovery.child.plan', () => prepareScopedRecovery(child.command, typeof pluginIds === 'string' ? [pluginIds] : pluginIds, {
|
|
1114
1197
|
...child.options, targets: agent !== 'generic' ? child.options.targets : [agent], all: false,
|
|
1115
1198
|
exactTargets: child.options.exactTargets?.filter((target) => (typeof pluginIds === 'string' ? [pluginIds] : pluginIds).includes(target.pluginId)),
|
|
1116
|
-
},
|
|
1199
|
+
}, childRuntime));
|
|
1117
1200
|
fresh.originalIntent = observationEvidence(currentIntent);
|
|
1118
1201
|
for (const target of fresh.receipt.targetResults) {
|
|
1119
1202
|
const reviewed = child.receipt.targetResults.find((entry) => entry.pluginId === target.pluginId && entry.agent === target.agent);
|
|
@@ -1125,7 +1208,7 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1125
1208
|
// Keep only joint constraints and an already failed script gate.
|
|
1126
1209
|
target.blockers.push(...(reviewed?.blockers ?? []).filter((error) => reviewed?.execution === 'failed'
|
|
1127
1210
|
|| ['configApplyRequiresExistingOutput', 'crossScopeSkillCollision', 'targetPlacementConflict',
|
|
1128
|
-
'preApplyAuthorizationRequired', 'nativeToolAuthorizationRequired', 'providerSwitchPreApplyFailed', 'dependencyStillRequired'].includes(error.code)));
|
|
1211
|
+
'preApplyAuthorizationRequired', 'nativeToolAuthorizationRequired', 'providerSwitchPreApplyFailed', 'providerSwitchVerificationFailed', 'dependencyStillRequired'].includes(error.code)));
|
|
1129
1212
|
if (reviewed?.execution === 'failed') {
|
|
1130
1213
|
target.execution = 'failed';
|
|
1131
1214
|
if (reviewed.backend)
|
|
@@ -1147,7 +1230,21 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1147
1230
|
message: `依赖提供者 ${failedDependency.pluginId}(${failedDependency.target}/${failedDependency.scope})未完成。` });
|
|
1148
1231
|
}
|
|
1149
1232
|
}
|
|
1150
|
-
|
|
1233
|
+
if (child.command !== 'cleanup' && child.options.scope === 'project') {
|
|
1234
|
+
const required = joint.pendingUserSkills.filter((item) => fresh.receipt.targetResults.some((target) => target.agent === item.target && dependencyGraph.reaches(target.pluginId, item.pluginId)));
|
|
1235
|
+
if (required.length) {
|
|
1236
|
+
const verified = await readCurrentProviders(required.map((item) => item.pluginId), required.map((item) => item.target));
|
|
1237
|
+
for (const provider of required) {
|
|
1238
|
+
if (verified.projectSkillProviders?.some((item) => item.pluginId === provider.pluginId && item.target === provider.target
|
|
1239
|
+
&& item.sourceIdentity === provider.sourceIdentity && !item.userAbsent && !item.userNeedsRepair && item.projectCopy !== 'blocked'))
|
|
1240
|
+
continue;
|
|
1241
|
+
for (const target of fresh.receipt.targetResults.filter((item) => item.agent === provider.target
|
|
1242
|
+
&& dependencyGraph.reaches(item.pluginId, provider.pluginId)))
|
|
1243
|
+
target.blockers.push(diagnostic('userProviderNotSatisfied'));
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
const result = await measureRecoveryPerformanceStage(runtime, 'recovery.child.execute', () => executeScopedRecovery(fresh, { ...execution, runtime: childRuntime,
|
|
1151
1248
|
...(plan.command !== 'uninstall' && child.command !== 'cleanup' ? { portableProgress } : {}) }));
|
|
1152
1249
|
if (joint.originalOptions.existingOnly)
|
|
1153
1250
|
for (const target of result.targetResults) {
|
|
@@ -1164,7 +1261,9 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1164
1261
|
};
|
|
1165
1262
|
// Provider changes can remove a working output. Complete the replacement's
|
|
1166
1263
|
// authorization and scripts first, sharing the normal execution cache.
|
|
1167
|
-
const
|
|
1264
|
+
const cleanups = joint.children.filter((child) => child.command === 'cleanup');
|
|
1265
|
+
const deferred = cleanups.filter((child) => child.receipt.requestedTargets.some((target) => joint.providerRetirements.has(targetKey(target))));
|
|
1266
|
+
const cleanupChildren = cleanups.filter((child) => !deferred.includes(child));
|
|
1168
1267
|
const replacementFailures = new Set();
|
|
1169
1268
|
for (const child of joint.children.filter((child) => child.command !== 'cleanup')) {
|
|
1170
1269
|
for (const target of child.receipt.targetResults) {
|
|
@@ -1192,9 +1291,12 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1192
1291
|
}
|
|
1193
1292
|
// Target exits can replace one Agent with another. Preserve the reviewed
|
|
1194
1293
|
// old output when its corresponding replacement cannot run.
|
|
1195
|
-
|
|
1294
|
+
const clean = async (child, verified = true, onSuccess) => {
|
|
1196
1295
|
for (const target of child.receipt.requestedTargets) {
|
|
1197
|
-
if (
|
|
1296
|
+
if (!verified)
|
|
1297
|
+
child.receipt.targetResults.find((entry) => entry.pluginId === target.pluginId && entry.agent === target.agent)
|
|
1298
|
+
.blockers.push(diagnostic('providerSwitchVerificationFailed', '替代位置尚未确认就绪,保留原输出。'));
|
|
1299
|
+
if ((plan.command === 'uninstall' || deferred.includes(child)) && failedCleanups.some((failed) => {
|
|
1198
1300
|
if (failed.agent !== target.agent)
|
|
1199
1301
|
return false;
|
|
1200
1302
|
const required = joint.removalDependencies.get(failed.pluginId);
|
|
@@ -1214,8 +1316,49 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1214
1316
|
const result = await executeChild(child, target.pluginId, target.agent);
|
|
1215
1317
|
if (!result.ok)
|
|
1216
1318
|
failedCleanups.push(...result.requestedTargets);
|
|
1319
|
+
else
|
|
1320
|
+
onSuccess?.(result);
|
|
1217
1321
|
}
|
|
1218
|
-
}
|
|
1322
|
+
};
|
|
1323
|
+
for (const child of cleanupChildren)
|
|
1324
|
+
await clean(child);
|
|
1325
|
+
const retireVerified = async (oldScope) => {
|
|
1326
|
+
const retiring = deferred.filter((child) => child.options.scope === oldScope);
|
|
1327
|
+
if (!retiring.length)
|
|
1328
|
+
return;
|
|
1329
|
+
const old = retiring.flatMap((child) => child.receipt.requestedTargets);
|
|
1330
|
+
const verified = await readCurrentProviders(old.map((item) => item.pluginId), old.map((item) => item.agent));
|
|
1331
|
+
for (const child of retiring) {
|
|
1332
|
+
const target = child.receipt.requestedTargets[0];
|
|
1333
|
+
const replacement = { ...target, scope: oldScope === 'user' ? 'project' : 'user' };
|
|
1334
|
+
const reviewedSource = joint.demand.placements.find((item) => item.pluginId === replacement.pluginId
|
|
1335
|
+
&& item.scope === replacement.scope && item.target === replacement.agent)?.plugin.sourceIdentity;
|
|
1336
|
+
const confirmed = reviewedSource && !failedProviders.has(targetKey(replacement)) && (oldScope === 'project'
|
|
1337
|
+
? verified.projectSkillProviders?.some((item) => item.pluginId === target.pluginId && item.target === target.agent
|
|
1338
|
+
&& item.sourceIdentity === reviewedSource && !item.userAbsent && !item.userNeedsRepair && item.projectCopy === 'owned')
|
|
1339
|
+
: verified.observedTargets?.some((item) => targetKey(item) === targetKey(replacement)
|
|
1340
|
+
&& item.observation === 'verified' && item.content === 'satisfied' && !item.blockers.length)
|
|
1341
|
+
&& verified.existingTargets?.some((item) => targetKey(item) === targetKey(replacement)
|
|
1342
|
+
&& item.nativePackage?.sourceIdentity === reviewedSource && item.nativePackage.skillsReady));
|
|
1343
|
+
await clean(child, Boolean(confirmed), (receipt) => {
|
|
1344
|
+
const projectRoot = joint.snapshot.context.projectRoot;
|
|
1345
|
+
if (!confirmed || !projectRoot || oldScope !== 'project' || target.agent !== 'grok' || !runtime.preparedArtifactRenderResults)
|
|
1346
|
+
return;
|
|
1347
|
+
const project = verified.extraObserved.find((item) => item.pluginId === target.pluginId && item.agent === 'grok' && item.scope === 'project')
|
|
1348
|
+
?.deploymentObservations?.find(({ after }) => after.nativeIdentity?.route === 'grok-directory')?.after;
|
|
1349
|
+
const user = verified.observedTargets?.find((item) => targetKey(item) === targetKey(replacement))
|
|
1350
|
+
?.deploymentObservations?.find(({ after }) => after.nativeIdentity?.route === 'grok-cli')?.after;
|
|
1351
|
+
const backend = receipt.targetResults.find((item) => targetKey(item) === targetKey(target))?.backend;
|
|
1352
|
+
const removed = backend?.command === 'cleanup' && backend.ok ? backend.targetResults.find(({ target: item }) => item.pluginId === target.pluginId && item.platform === 'grok' && item.scope === 'project')?.removed : undefined;
|
|
1353
|
+
const reviewedRemoval = child.nativeGroups.some(({ preview }) => preview.operationPlan?.actions.some((action) => action.kind === 'removeOwnedArtifact' && action.pluginId === target.pluginId && action.platform === 'grok'
|
|
1354
|
+
&& action.scope === 'project' && action.path === project?.nativeIdentity?.sourceLocation));
|
|
1355
|
+
if (project && user && reviewedRemoval && removed?.length) {
|
|
1356
|
+
recordPreparedGrokProjectRetirement(runtime.preparedArtifactRenderResults, projectRoot, project, user, removed);
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
};
|
|
1361
|
+
let retiredProjectCopies = false;
|
|
1219
1362
|
const nodes = new Map();
|
|
1220
1363
|
const nodeFor = (pluginId, scope) => {
|
|
1221
1364
|
const key = `${pluginId}\0${scope}`;
|
|
@@ -1299,6 +1442,10 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1299
1442
|
break;
|
|
1300
1443
|
}
|
|
1301
1444
|
const node = pending.splice(index, 1)[0];
|
|
1445
|
+
if (node.scope === 'project' && !retiredProjectCopies) {
|
|
1446
|
+
await retireVerified('project');
|
|
1447
|
+
retiredProjectCopies = true;
|
|
1448
|
+
}
|
|
1302
1449
|
const key = `${node.pluginId}\0${node.scope}`;
|
|
1303
1450
|
if (node.packages?.length && packages && !hasNative(node)) {
|
|
1304
1451
|
if (failedNodes.has(key) || [...node.dependencies].some((dependency) => failedNodes.has(dependency))) {
|
|
@@ -1342,6 +1489,9 @@ export async function executeJointRecovery(plan, execution) {
|
|
|
1342
1489
|
}
|
|
1343
1490
|
}
|
|
1344
1491
|
}
|
|
1492
|
+
if (!retiredProjectCopies)
|
|
1493
|
+
await retireVerified('project');
|
|
1494
|
+
await retireVerified('user');
|
|
1345
1495
|
}
|
|
1346
1496
|
const receipt = mergeReceipts(plan, results);
|
|
1347
1497
|
receipt.commandResults = [...new Map([...packageResults, ...(receipt.commandResults ?? [])]
|