@lesliechan721/aw 0.1.0-beta.101 → 0.1.0-beta.103
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/src/commands/catalog-generation.d.ts +2 -5
- package/dist/src/commands/catalog-generation.js +2 -4
- package/dist/src/commands/catalog-generation.js.map +1 -1
- package/dist/src/commands/lifecycle-command-package.d.ts +1 -1
- package/dist/src/commands/lifecycle-command-package.js +40 -2
- package/dist/src/commands/lifecycle-command-package.js.map +1 -1
- package/dist/src/commands/managed-commands.d.ts +2 -1
- package/dist/src/commands/managed-commands.js +4 -2
- package/dist/src/commands/managed-commands.js.map +1 -1
- package/dist/src/commands/operation-plan.d.ts +2 -8
- package/dist/src/commands/operation-plan.js.map +1 -1
- package/dist/src/commands/public-config-confirmation.d.ts +16 -10
- package/dist/src/commands/public-config-confirmation.js +87 -52
- package/dist/src/commands/public-config-confirmation.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -1
- package/dist/src/commands/public-lifecycle.js +36 -8
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +6 -4
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +22 -6
- package/dist/src/commands/rebuild-command.js +273 -557
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +12 -39
- package/dist/src/commands/rebuild-integration.js +67 -303
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +0 -4
- package/dist/src/commands/rebuild-operations.js +9 -8
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +14 -6
- package/dist/src/commands/rebuild-platform-integration.js +310 -101
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/commands/status-v6.d.ts +3 -117
- package/dist/src/commands/status-v6.js +0 -2886
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/commands/write-commands.js +0 -3
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/index.js +44 -36
- package/dist/src/index.js.map +1 -1
- package/dist/src/intent/deployment-preferences.js +4 -3
- package/dist/src/intent/deployment-preferences.js.map +1 -1
- package/dist/src/intent/intent-store.js +3 -2
- package/dist/src/intent/intent-store.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +0 -6
- package/dist/src/output/command-receipt.js +0 -15
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/receipt-projection.js +2 -1
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/platforms/capabilities.js +8 -2
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +2 -0
- package/dist/src/platforms/discovery.d.ts +2 -0
- package/dist/src/platforms/discovery.js +95 -49
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-native.d.ts +7 -1
- package/dist/src/platforms/inspection-native.js +6 -3
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +28 -14
- package/dist/src/platforms/inspection-query.js +102 -8
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +7 -2
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.js +20 -3
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.js +5 -0
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/supplement-state.js +11 -2
- package/dist/src/platforms/supplement-state.js.map +1 -1
- package/dist/src/portable/commands.d.ts +1 -0
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +2 -0
- package/dist/src/portable/materializer.js +4 -4
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +1 -0
- package/dist/src/portable/recovery.js +3 -2
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +6 -1
- package/dist/src/recovery/coordinator.js +113 -108
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/demand.d.ts +1 -2
- package/dist/src/recovery/demand.js +4 -11
- package/dist/src/recovery/demand.js.map +1 -1
- package/dist/src/recovery/install-concurrency.d.ts +12 -0
- package/dist/src/recovery/install-concurrency.js +39 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.d.ts +3 -4
- package/dist/src/recovery/joint-coordinator.js +324 -188
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.js +4 -3
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.js +46 -2
- package/dist/src/recovery/joint-install-execution.js.map +1 -1
- package/dist/src/recovery/joint-install-native-rebase.js +5 -2
- package/dist/src/recovery/joint-install-native-rebase.js.map +1 -1
- package/dist/src/recovery/locked-prepared-execution.d.ts +32 -0
- package/dist/src/recovery/locked-prepared-execution.js +67 -0
- package/dist/src/recovery/locked-prepared-execution.js.map +1 -0
- package/dist/src/recovery/status.d.ts +20 -6
- package/dist/src/recovery/status.js +153 -98
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/skill-materialization.d.ts +1 -0
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +4 -14
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +201 -57
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +8 -9
- package/dist/src/tui/controller.js +5 -6
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/operation-review-planner.js +14 -103
- package/dist/src/tui/operation-review-planner.js.map +1 -1
- package/dist/src/types.d.ts +5 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.js +1 -0
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +10 -0
- package/dist/src/utils/artifact-renderer.js +28 -2
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.d.ts +8 -0
- package/dist/src/utils/aw-home-mutation-lock.js +44 -8
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/bundle-integrity.js +126 -33
- package/dist/src/utils/bundle-integrity.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +4 -0
- package/dist/src/utils/catalog-generation-resolver.js +4 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-generation-service.d.ts +50 -11
- package/dist/src/utils/catalog-generation-service.js +276 -130
- package/dist/src/utils/catalog-generation-service.js.map +1 -1
- package/dist/src/utils/catalog-generation-state.js +6 -1
- package/dist/src/utils/catalog-generation-state.js.map +1 -1
- package/dist/src/utils/catalog-generation-store.d.ts +5 -0
- package/dist/src/utils/catalog-generation-store.js +36 -13
- package/dist/src/utils/catalog-generation-store.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.d.ts +17 -3
- package/dist/src/utils/catalog-operation-context.js +220 -22
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-performance.d.ts +3 -0
- package/dist/src/utils/catalog-performance.js +26 -0
- package/dist/src/utils/catalog-performance.js.map +1 -0
- package/dist/src/utils/catalog-snapshot.d.ts +5 -2
- package/dist/src/utils/catalog-snapshot.js +3 -2
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +2 -1
- package/dist/src/utils/catalog-source-impact.js +2 -2
- package/dist/src/utils/catalog-source-impact.js.map +1 -1
- package/dist/src/utils/catalog-source-references.d.ts +2 -0
- package/dist/src/utils/catalog-source-references.js +284 -148
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/codex-executable-discovery.js +1 -0
- package/dist/src/utils/codex-executable-discovery.js.map +1 -1
- package/dist/src/utils/codex-manager.js +1 -0
- package/dist/src/utils/codex-manager.js.map +1 -1
- package/dist/src/utils/codex-native-observation.d.ts +5 -2
- package/dist/src/utils/codex-native-observation.js +8 -4
- package/dist/src/utils/codex-native-observation.js.map +1 -1
- package/dist/src/utils/component-command-preparation.d.ts +1 -0
- package/dist/src/utils/component-command-preparation.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +38 -5
- package/dist/src/utils/git-catalog-provider.js +365 -156
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/managed-command-closure.d.ts +3 -1
- package/dist/src/utils/managed-command-closure.js +10 -5
- package/dist/src/utils/managed-command-closure.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +2 -0
- package/dist/src/utils/managed-command-materialization.js +4 -3
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-preparation.js +1 -1
- package/dist/src/utils/managed-command-preparation.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +1 -1
- package/dist/src/utils/multi-source-catalog.js +3 -3
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +6 -1
- package/dist/src/utils/native-cli.js +67 -32
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +2 -0
- package/dist/src/utils/platform-empty-state.js +5 -5
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-command-apply.d.ts +14 -4
- package/dist/src/utils/plugin-config-command-apply.js +49 -5
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +42 -0
- package/dist/src/utils/plugin-config-impact.js +170 -14
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-references.d.ts +3 -1
- package/dist/src/utils/plugin-config-references.js +3 -5
- package/dist/src/utils/plugin-config-references.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +14 -5
- package/dist/src/utils/plugin-config-write.js +213 -117
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +2 -0
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-scripts.d.ts +2 -0
- package/dist/src/utils/plugin-scripts.js +102 -3
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/package.json +3 -5
- package/dist/src/utils/codex-reconciler.d.ts +0 -123
- package/dist/src/utils/codex-reconciler.js +0 -322
- package/dist/src/utils/codex-reconciler.js.map +0 -1
|
@@ -15,16 +15,16 @@ import { syncWriteCommand } from '../commands/write-commands.js';
|
|
|
15
15
|
import { skillInvocationDiagnostics } from '../output/skill-invocation-notices.js';
|
|
16
16
|
import { CONFIG_MUTATION_RECEIPT_SCHEMA_VERSION, } from '../types.js';
|
|
17
17
|
import { assertPluginConfigMutationCandidate, assertSafePluginConfigSegment, coercePluginConfigUpdates, patchPluginConfigStore, PluginConfigSchemaResolutionError, readPluginConfigStore, readNamespacedPluginConfigStoreIdentity, resetPluginConfigStore, resolveConfigRead, resolveEffectivePluginConfig, resolvePluginConfigStorePath, resolvePluginConfigSchemaAccess, summarizeEffectivePluginConfig, } from './plugin-config.js';
|
|
18
|
-
import { analyzePluginConfigMutationImpact, discoverPluginConfigManagedCommandPackages, pluginSharedNativeConfigRenderUnits } from './plugin-config-impact.js';
|
|
18
|
+
import { analyzePluginConfigMutationImpact, discoverPluginConfigManagedCommandPackages, pluginClosureMayRunPreApply, pluginSharedNativeConfigRenderUnits, projectConfigMutation, selectConfigMutationApply, } from './plugin-config-impact.js';
|
|
19
19
|
import { collectPluginConfigReferenceEvidence, resolvePluginConfigReferencePlugins, resolvePluginConfigReferenceConsumers, formatPluginConfigReferenceBlocker, PluginConfigReferenceBlockedError } from './plugin-config-references.js';
|
|
20
20
|
import { resolvePluginMetaDependencyClosure } from './plugin-dependencies.js';
|
|
21
21
|
import { publishPreparedManagedCommandPackage } from './managed-command-materialization.js';
|
|
22
22
|
import { ManagedCommandError, managedCommandDiagnostic } from './managed-command-store.js';
|
|
23
|
-
import { configPackageResult, inspectConfigCommandPackageReview, prepareConfigCommandPackages } from './plugin-config-command-apply.js';
|
|
23
|
+
import { configPackageResult, inspectConfigCommandPackageReview, prepareConfigCommandPackages, prepareConfigSelectionPackages, verifyConfigSelectionPackages, commandOnlyCandidatesMatch } from './plugin-config-command-apply.js';
|
|
24
24
|
import { collectSensitivePluginConfigValues, redactPluginScriptOutput, } from './plugin-scripts.js';
|
|
25
25
|
import { resolveCliPackageRoot } from './paths.js';
|
|
26
26
|
import { readSafeOperationError } from './safe-operation-diagnostic.js';
|
|
27
|
-
import { withAwHomeMutationLock, } from './aw-home-mutation-lock.js';
|
|
27
|
+
import { withAwHomeMutationLock, advanceAwHomeMutationEpoch, } from './aw-home-mutation-lock.js';
|
|
28
28
|
import fs from 'fs-extra';
|
|
29
29
|
import path from 'node:path';
|
|
30
30
|
export function buildConfigMutationReceipt(command, receipt) {
|
|
@@ -118,17 +118,19 @@ async function configApplyHasValidSharedNativeTarget(options) {
|
|
|
118
118
|
export async function resolveConfigPreApplyAuthorization(options) {
|
|
119
119
|
const applyTargets = dedupeTargets(options.applyTargets).filter((target) => !options.rebuildRuntime?.configApplyPackages?.targets.some((entry) => entry.blocker
|
|
120
120
|
&& entry.pluginId === (target.pluginId ?? options.plugin.pluginId) && entry.platforms.includes(target.platform)));
|
|
121
|
+
if (!applyTargets.length)
|
|
122
|
+
return { targets: [], availableApplyTargets: [], unavailableTargetResults: [] };
|
|
123
|
+
const plugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
124
|
+
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
125
|
+
env: options.env, plugins: options.rebuildRuntime?.referencePlugins, operationContext: options.rebuildRuntime?.catalogOperationContext });
|
|
121
126
|
if (applyTargets.some((target) => target.pluginName !== options.plugin.manifest.name)) {
|
|
122
|
-
const plugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
123
|
-
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
124
|
-
env: options.env, plugins: options.rebuildRuntime?.referencePlugins });
|
|
125
127
|
const results = await Promise.all(plugins.map((plugin) => resolveConfigPreApplyAuthorization({ ...options, plugin,
|
|
126
128
|
applyTargets: applyTargets.filter((target) => target.pluginName === plugin.manifest.name) })));
|
|
127
129
|
return { targets: results.flatMap((result) => result.targets),
|
|
128
130
|
availableApplyTargets: results.flatMap((result) => result.availableApplyTargets),
|
|
129
131
|
unavailableTargetResults: results.flatMap((result) => result.unavailableTargetResults) };
|
|
130
132
|
}
|
|
131
|
-
if (
|
|
133
|
+
if (!pluginClosureMayRunPreApply(options.plugin, plugins)) {
|
|
132
134
|
return { targets: [], availableApplyTargets: applyTargets, unavailableTargetResults: [] };
|
|
133
135
|
}
|
|
134
136
|
if (options.plugin.sourceId && !options.plugin.pluginId) {
|
|
@@ -219,9 +221,8 @@ export async function resolveConfigPreApplyAuthorization(options) {
|
|
|
219
221
|
unavailableTargetResults,
|
|
220
222
|
};
|
|
221
223
|
}
|
|
222
|
-
function
|
|
223
|
-
return
|
|
224
|
-
|| (plugin.manifest.dependencies?.length ?? 0) > 0;
|
|
224
|
+
function unresolvedPreApplyAuthorization() {
|
|
225
|
+
return Object.assign(new Error('The preApply authorization scope cannot be resolved for the affected outputs.'), { code: 'sourceUnavailable' });
|
|
225
226
|
}
|
|
226
227
|
function throwPreApplyAuthorizationRequired(targets) {
|
|
227
228
|
const plugins = [...new Set(targets.map((target) => target.pluginId))].join(', ');
|
|
@@ -287,7 +288,8 @@ function configApplyPackageHook(options, entries, referencePlugins) {
|
|
|
287
288
|
scope: 'user',
|
|
288
289
|
packageId: target.packageId,
|
|
289
290
|
platforms: evidence.review?.routeChanges.length || evidence.blocker
|
|
290
|
-
? [...plugin.manifest.command?.platforms ?? target.runtimeConfigPlatforms]
|
|
291
|
+
? [...plugin.manifest.command?.platforms ?? target.runtimeConfigPlatforms]
|
|
292
|
+
: plugin.manifest.dependencies?.length ? target.runtimeConfigPlatforms.filter((platform) => !options.platform || platform === options.platform) : [],
|
|
291
293
|
...(evidence.blocker && ['nativeToolSyncRequired', 'configApplyVersionMismatch'].includes(evidence.blocker.code)
|
|
292
294
|
? { blocker: evidence.blocker } : {}),
|
|
293
295
|
dependencies: resolvePluginMetaDependencyClosure(referencePlugins, [plugin.manifest.name])
|
|
@@ -296,7 +298,7 @@ function configApplyPackageHook(options, entries, referencePlugins) {
|
|
|
296
298
|
const selected = (pluginId, packageId) => entries.filter(({ target, plugin }) => (plugin.pluginId ?? plugin.manifest.name) === pluginId && (!packageId || target.packageId === packageId));
|
|
297
299
|
return { targets, evidence: entries.map(({ evidence }) => evidence),
|
|
298
300
|
blocked: (pluginId, _scope, code, packageId) => selected(pluginId, packageId).map(({ target, candidate, evidence }) => configPackageResult(target, [evidence.blocker ?? { code, message: 'The command package refresh did not complete.' }], candidate)),
|
|
299
|
-
execute: async (pluginId, _scope,
|
|
301
|
+
execute: async (pluginId, _scope, token, packageId) => {
|
|
300
302
|
const results = [];
|
|
301
303
|
for (const { target, plugin, candidate, evidence } of selected(pluginId, packageId)) {
|
|
302
304
|
if (evidence.blocker || !candidate) {
|
|
@@ -311,6 +313,7 @@ function configApplyPackageHook(options, entries, referencePlugins) {
|
|
|
311
313
|
throw new ManagedCommandError('operationReviewStale', 'Permissions affecting the reviewed routes changed. Prepare a new Review.');
|
|
312
314
|
}
|
|
313
315
|
const published = await publishPreparedManagedCommandPackage({ plugin, candidate, cwd: options.cwd, env, referencePlugins });
|
|
316
|
+
advanceAwHomeMutationEpoch(token);
|
|
314
317
|
results.push(configPackageResult(target, [], candidate, published));
|
|
315
318
|
}
|
|
316
319
|
catch (error) {
|
|
@@ -324,8 +327,8 @@ function configApplyPackageHook(options, entries, referencePlugins) {
|
|
|
324
327
|
};
|
|
325
328
|
}
|
|
326
329
|
/** Prepare the same existing-output plan used by apply, without saving config or output. */
|
|
327
|
-
export async function preparePluginConfigApply(options, {
|
|
328
|
-
const { prepareRecovery, describeRecoveryPlan } = await import('../recovery/coordinator.js');
|
|
330
|
+
export async function preparePluginConfigApply(options, { comparePublishedOutputs = false } = {}) {
|
|
331
|
+
const { prepareRecovery, describeRecoveryPlan, collectPortablePreApplyAuthorization, isPortableConfigRepairBlocker } = await import('../recovery/coordinator.js');
|
|
329
332
|
const context = options.context ?? options.scope;
|
|
330
333
|
const referencePlugins = await resolvePluginConfigReferencePlugins({ sourceId: options.plugin.sourceId,
|
|
331
334
|
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity,
|
|
@@ -352,7 +355,7 @@ export async function preparePluginConfigApply(options, { inspectOnly = false }
|
|
|
352
355
|
}
|
|
353
356
|
const plugins = await resolvePluginConfigReferenceConsumers({ plugin: options.plugin, env: options.env,
|
|
354
357
|
plugins: referencePlugins });
|
|
355
|
-
|
|
358
|
+
let selectors = plugins.map((plugin) => plugin.pluginId ?? plugin.manifest.name);
|
|
356
359
|
const version = options.cliVersion
|
|
357
360
|
?? (await fs.readJson(path.join(resolveCliPackageRoot(), 'package.json'))).version;
|
|
358
361
|
let exactTargets = options.applyTargets?.map((target) => ({
|
|
@@ -361,11 +364,17 @@ export async function preparePluginConfigApply(options, { inspectOnly = false }
|
|
|
361
364
|
scope: target.scope,
|
|
362
365
|
}));
|
|
363
366
|
const retainedLegacyTargets = [];
|
|
364
|
-
|
|
367
|
+
const verifiedLiveUnderCurrentLock = options.allNativeTargetsLive === true
|
|
368
|
+
&& options.awHomeMutationToken !== undefined
|
|
369
|
+
&& options.allNativeTargetsLiveToken === options.awHomeMutationToken;
|
|
370
|
+
if (exactTargets?.length && !verifiedLiveUnderCurrentLock) {
|
|
365
371
|
const { readRecoveryStatus } = await import('../recovery/status.js');
|
|
366
|
-
const observed = await readRecoveryStatus({ context,
|
|
367
|
-
|
|
368
|
-
|
|
372
|
+
const observed = await readRecoveryStatus({ context, plugins: [...new Set(exactTargets.map((target) => target.pluginId))],
|
|
373
|
+
targets: [...new Set(exactTargets.map((target) => target.agent))], cwd: options.cwd, env: options.env, cliVersion: version,
|
|
374
|
+
signal: options.rebuildRuntime?.signal,
|
|
375
|
+
catalogOperationContext: options.rebuildRuntime?.catalogOperationContext,
|
|
376
|
+
catalogReadScope: options.rebuildRuntime?.catalogReadScope,
|
|
377
|
+
nativeCliRunner: options.nativeCliRunner ?? options.rebuildRuntime?.nativeCliRunner });
|
|
369
378
|
const key = (target) => `${target.pluginId}\0${target.agent}\0${target.scope}`;
|
|
370
379
|
const live = new Set(observed.existingTargets?.map(key));
|
|
371
380
|
const owned = new Set(observed.ownedTargets?.map(key));
|
|
@@ -377,9 +386,15 @@ export async function preparePluginConfigApply(options, { inspectOnly = false }
|
|
|
377
386
|
return true;
|
|
378
387
|
});
|
|
379
388
|
}
|
|
389
|
+
if (exactTargets) {
|
|
390
|
+
exactTargets.push(...options.applyGenericTargets?.map(({ pluginId, scope }) => ({ pluginId, scope, agent: 'generic' })) ?? []);
|
|
391
|
+
const selectedIds = new Set(exactTargets.map((target) => target.pluginId));
|
|
392
|
+
if (selectedIds.size)
|
|
393
|
+
selectors = selectors.filter((id) => selectedIds.has(id));
|
|
394
|
+
}
|
|
380
395
|
const env = options.env ?? process.env;
|
|
381
396
|
const commands = await discoverPluginConfigManagedCommandPackages({ plugin: options.plugin, scope: context,
|
|
382
|
-
cwd: options.cwd, env, referencePlugins });
|
|
397
|
+
cwd: options.cwd, env, referencePlugins, consumers: plugins });
|
|
383
398
|
let selectedPackages = commands.packages.filter((target) => {
|
|
384
399
|
if (options.applyCommandPackages && !options.applyCommandPackages.includes(target.packageId))
|
|
385
400
|
return false;
|
|
@@ -390,12 +405,11 @@ export async function preparePluginConfigApply(options, { inspectOnly = false }
|
|
|
390
405
|
return (target.refreshKeys.length > 0 || target.runtimeConfigKeys.length > 0)
|
|
391
406
|
&& (!options.targets || platforms.some((platform) => options.targets.includes(platform)));
|
|
392
407
|
});
|
|
393
|
-
if (options.mutation) {
|
|
394
|
-
const
|
|
395
|
-
|
|
396
|
-
selectedPackages = impact.affectedCommandPackages;
|
|
408
|
+
if (options.mutation && options.applyCommandPackages === undefined) {
|
|
409
|
+
const { selection: { applyCommandPackages } } = await projectConfigMutation(options, options.mutation);
|
|
410
|
+
selectedPackages = selectedPackages.filter((target) => applyCommandPackages.includes(target.packageId));
|
|
397
411
|
}
|
|
398
|
-
const entries = await prepareConfigCommandPackages(options, selectedPackages, plugins, referencePlugins
|
|
412
|
+
const entries = await prepareConfigCommandPackages(options, selectedPackages, plugins, referencePlugins);
|
|
399
413
|
const cleanup = () => Promise.all(entries.map(({ candidate }) => candidate?.cleanup()));
|
|
400
414
|
const packagePreparationCache = new Map();
|
|
401
415
|
for (const { target, candidate } of entries) {
|
|
@@ -412,6 +426,9 @@ export async function preparePluginConfigApply(options, { inspectOnly = false }
|
|
|
412
426
|
signal: options.rebuildRuntime?.signal,
|
|
413
427
|
cliVersion: version,
|
|
414
428
|
existingOnly: true,
|
|
429
|
+
...(comparePublishedOutputs && !exactTargets && !entries.length && !commands.errors.length
|
|
430
|
+
&& !plugins.some((entry) => pluginClosureMayRunPreApply(entry, referencePlugins))
|
|
431
|
+
? { comparePublishedConfigOutputs: true } : {}),
|
|
415
432
|
...(exactTargets ? { exactTargets } : {}),
|
|
416
433
|
...(options.platform ? { targets: [options.platform] } : options.targets ? { targets: options.targets } : {}),
|
|
417
434
|
}, {
|
|
@@ -438,19 +455,49 @@ export async function preparePluginConfigApply(options, { inspectOnly = false }
|
|
|
438
455
|
}
|
|
439
456
|
const references = await collectPluginConfigReferenceEvidence({ plugin: options.plugin, plugins: referencePlugins,
|
|
440
457
|
profiles, cwd: options.cwd, env: options.env });
|
|
441
|
-
const authorization =
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
458
|
+
const authorization = [];
|
|
459
|
+
const repairTargets = [];
|
|
460
|
+
const collectAuthorization = (current) => {
|
|
461
|
+
const portable = options.mutation && !current.joint
|
|
462
|
+
? collectPortablePreApplyAuthorization(current, true) : current.preApplyAuthorization ?? [];
|
|
463
|
+
authorization.push(...portable);
|
|
464
|
+
if (options.mutation && current.blockExecution
|
|
465
|
+
&& plugins.some((entry) => pluginClosureMayRunPreApply(entry, referencePlugins)))
|
|
466
|
+
throw unresolvedPreApplyAuthorization();
|
|
467
|
+
if (options.mutation && !current.joint && current.receipt.targetResults.some((target) => target.agent === 'generic' && target.blockers.length && referencePlugins.some((entry) => entry.pluginId === target.pluginId && pluginClosureMayRunPreApply(entry, referencePlugins))
|
|
468
|
+
&& (!current.portableGroups.some((group) => group.options.selector === target.pluginId)
|
|
469
|
+
|| target.blockers.some((entry) => !isPortableConfigRepairBlocker(entry))))) {
|
|
470
|
+
throw unresolvedPreApplyAuthorization();
|
|
471
|
+
}
|
|
472
|
+
for (const group of current.nativeGroups) {
|
|
473
|
+
authorization.push(...group.preview.preApplyAuthorization ?? []);
|
|
474
|
+
// A blocked preview may have omitted a script that the proposed value repairs.
|
|
475
|
+
if (group.preview.overallState === 'succeeded' && group.preview.preApplyAuthorization
|
|
476
|
+
&& !group.preview.dependencyPlan?.targets.some((target) => target.action === 'block'))
|
|
477
|
+
continue;
|
|
478
|
+
for (const target of configApplyRequestedTargets(current)) {
|
|
479
|
+
if (target.agent === 'generic' || !group.pluginIds.includes(target.pluginId)
|
|
480
|
+
|| !(group.platform === target.agent || group.platform === 'both' && ['claude', 'codex'].includes(target.agent)))
|
|
481
|
+
continue;
|
|
482
|
+
const plugin = referencePlugins.find((entry) => entry.pluginId === target.pluginId) ?? options.plugin;
|
|
483
|
+
if (pluginClosureMayRunPreApply(plugin, referencePlugins))
|
|
484
|
+
repairTargets.push({
|
|
485
|
+
pluginName: plugin.manifest.name, pluginId: target.pluginId, platform: target.agent, scope: target.scope,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
for (const child of current.joint?.children ?? [])
|
|
490
|
+
collectAuthorization(child);
|
|
491
|
+
};
|
|
492
|
+
collectAuthorization(plan);
|
|
493
|
+
if (repairTargets.length) {
|
|
494
|
+
const repair = await resolveConfigPreApplyAuthorization({ ...options, applyTargets: repairTargets,
|
|
495
|
+
rebuildRuntime: { ...plan.runtime, referencePlugins } });
|
|
496
|
+
if (repair.unavailableTargetResults.length)
|
|
497
|
+
throw unresolvedPreApplyAuthorization();
|
|
498
|
+
authorization.push(...repair.targets);
|
|
499
|
+
}
|
|
500
|
+
const preApplyAuthorization = [...new Map(authorization.map((target) => [[target.pluginId, target.sourceIdentity, target.platform, target.scope].join('\0'), target])).values()];
|
|
454
501
|
const commandPackageEvidence = entries.map(({ evidence }) => evidence);
|
|
455
502
|
return { plan, retainedLegacyTargets, commandPackages: commands.packages, commandDiscoveryErrors: commands.errors,
|
|
456
503
|
commandPackageEvidence, commandPackageReviews: commandPackageEvidence.flatMap(({ review }) => review ? [review] : []),
|
|
@@ -509,15 +556,16 @@ function configApplyHasPartialDelivery(target) {
|
|
|
509
556
|
&& Array.isArray(outcome.blockers) && outcome.blockers.length === 0;
|
|
510
557
|
});
|
|
511
558
|
}
|
|
512
|
-
export async function applyPluginConfig(options) {
|
|
513
|
-
return withAwHomeMutationLock({ env: options.env, token: options.awHomeMutationToken, action: async (token) => {
|
|
559
|
+
export async function applyPluginConfig(options, lockedPreparation) {
|
|
560
|
+
return withAwHomeMutationLock({ tracksWrites: true, env: options.env, token: options.awHomeMutationToken, action: async (token) => {
|
|
514
561
|
await options.reviewPreflight?.();
|
|
515
562
|
let prepared;
|
|
516
563
|
try {
|
|
517
564
|
const { executeRecovery } = await import('../recovery/coordinator.js');
|
|
518
565
|
const expectedCommands = options.expectedCommandPackageEvidence
|
|
519
566
|
?? options.expectedEvidence?.commandPackageEvidence;
|
|
520
|
-
prepared = await preparePluginConfigApply({ ...options, awHomeMutationToken: token,
|
|
567
|
+
prepared = lockedPreparation ?? await preparePluginConfigApply({ ...options, awHomeMutationToken: token,
|
|
568
|
+
rebuildRuntime: { ...options.rebuildRuntime, prepareLockedExecution: true },
|
|
521
569
|
expectedCommandPackageEvidence: expectedCommands });
|
|
522
570
|
if (options.expectedEvidence !== undefined
|
|
523
571
|
&& JSON.stringify(options.expectedEvidence) !== JSON.stringify(prepared.evidence)) {
|
|
@@ -541,6 +589,16 @@ export async function applyPluginConfig(options) {
|
|
|
541
589
|
const discoveryErrors = prepared.commandDiscoveryErrors.map((error) => ({
|
|
542
590
|
stage: 'targetDiscovery', code: error.code, message: error.message,
|
|
543
591
|
}));
|
|
592
|
+
// The fast selection may not have enough visibility evidence (for
|
|
593
|
+
// example an offline source). The full existing-output plan is then
|
|
594
|
+
// authoritative. Do not report an empty successful execution as apply.
|
|
595
|
+
const { plan } = prepared;
|
|
596
|
+
if (!plan.blockExecution && !plan.receipt.blockers.length && !plan.receipt.errors.length
|
|
597
|
+
&& !configApplyRequestedTargets(plan).length && !plan.receipt.targetResults.length
|
|
598
|
+
&& !prepared.retainedLegacyTargets.length && !prepared.commandPackages.length && !discoveryErrors.length) {
|
|
599
|
+
return { configWrite: 'notStarted', overallState: 'succeeded',
|
|
600
|
+
apply: skippedApply('noVisibleTarget'), otherProjectsMayRequireSync: true };
|
|
601
|
+
}
|
|
544
602
|
let interruption;
|
|
545
603
|
const receipt = await executeRecovery(prepared.plan, {
|
|
546
604
|
yes: options.sharedNativeApplyConfirmed === true || options.preApplyConfirmed === true,
|
|
@@ -618,7 +676,7 @@ function throwSharedNativeApplyConfirmationRequired() {
|
|
|
618
676
|
error.code = 'sharedNativeConfigApplyConfirmationRequired';
|
|
619
677
|
throw error;
|
|
620
678
|
}
|
|
621
|
-
async function applyPluginConfigWriteUnlocked(options) {
|
|
679
|
+
async function applyPluginConfigWriteUnlocked(options, checkedImpact) {
|
|
622
680
|
const pluginName = assertSafePluginConfigSegment(options.pluginName ?? options.plugin?.manifest.name ?? '');
|
|
623
681
|
const identity = options.plugin?.sourceId ? { sourceId: options.plugin.sourceId,
|
|
624
682
|
sourceIdentity: options.plugin.sourceIdentity, logicalIdentity: options.plugin.catalogLogicalIdentity } : {};
|
|
@@ -635,7 +693,7 @@ async function applyPluginConfigWriteUnlocked(options) {
|
|
|
635
693
|
throw new PluginConfigSchemaResolutionError('configSchemaUnavailable', `Plugin "${pluginName}" does not declare an AW config schema.`);
|
|
636
694
|
}
|
|
637
695
|
const updates = await coercePluginConfigUpdates({ schema: definition?.fields ?? {}, updates: requestedUpdates, cwd: options.cwd });
|
|
638
|
-
const impact = await analyzePluginConfigMutationImpact({ plugin, scope: options.scope, platform: options.platform,
|
|
696
|
+
const impact = checkedImpact ?? await analyzePluginConfigMutationImpact({ plugin, scope: options.scope, platform: options.platform,
|
|
639
697
|
cwd: options.cwd, env: options.env, visibleTargets: [], commandDiscovery: { packages: [], errors: [] },
|
|
640
698
|
referencePlugins: options.rebuildRuntime?.referencePlugins, mutation: { kind: 'patch', updates, removeKeys } });
|
|
641
699
|
await assertPluginConfigMutationCandidate({ ...identity, pluginName, manifest: plugin.manifest,
|
|
@@ -647,6 +705,8 @@ async function applyPluginConfigWriteUnlocked(options) {
|
|
|
647
705
|
try {
|
|
648
706
|
await patchPluginConfigStore({ ...identity, pluginName, scope: 'user', platform: options.platform,
|
|
649
707
|
cwd: options.cwd, env: options.env, updates: Object.fromEntries(impact.updatedKeys.map((key) => [key, updates[key]])), removeKeys });
|
|
708
|
+
if (options.awHomeMutationToken)
|
|
709
|
+
advanceAwHomeMutationEpoch(options.awHomeMutationToken);
|
|
650
710
|
}
|
|
651
711
|
catch (error) {
|
|
652
712
|
throw markConfigWriteFailed(error);
|
|
@@ -671,48 +731,70 @@ async function applyPluginConfigWriteUnlocked(options) {
|
|
|
671
731
|
apply: skippedApply(impact.storeChanged ? 'notRequested' : 'noConfigChange'),
|
|
672
732
|
otherProjectsMayRequireSync: impact.storeChanged, warnings };
|
|
673
733
|
}
|
|
674
|
-
|
|
734
|
+
/** Keep a staged runtime-snapshot candidate until the saved profile can be checked by its publisher. */
|
|
735
|
+
async function withConfigMutationSelection(options, consume) {
|
|
675
736
|
if (options.apply !== true || !options.plugin)
|
|
676
|
-
return
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
737
|
+
return consume();
|
|
738
|
+
const mutation = 'request' in options ? { kind: 'patch', ...options.request } : { kind: 'reset' };
|
|
739
|
+
const applyOptions = { ...options, plugin: options.plugin, mutation,
|
|
740
|
+
rebuildRuntime: { ...options.rebuildRuntime, referencePlugins: options.reviewedSelection?.referencePlugins ?? options.rebuildRuntime?.referencePlugins } };
|
|
741
|
+
let selection = options.reviewedSelection;
|
|
742
|
+
if (selection) {
|
|
743
|
+
const current = await projectConfigMutation(applyOptions, mutation);
|
|
744
|
+
if (current.selection.candidateDigest !== selection.candidateDigest) {
|
|
745
|
+
throw new ManagedCommandError('operationReviewStale', 'The reviewed configuration candidate changed. Prepare a new Review.');
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
else
|
|
749
|
+
selection = await selectConfigMutationApply(applyOptions, mutation);
|
|
750
|
+
if (!options.reviewedSelection && !selection.skipReason && !options.preApplyAuthorizedTargets
|
|
751
|
+
&& selection.consumers.some((entry) => pluginClosureMayRunPreApply(entry, selection.referencePlugins))) {
|
|
752
|
+
// Direct callers may have no Review. Resolve the affected scripts before committing the Store.
|
|
753
|
+
const available = selection.applyTargets;
|
|
754
|
+
if (!available || selection.applyGenericTargets?.length) {
|
|
755
|
+
const prepared = await preparePluginConfigApply({ ...applyOptions, ...selection });
|
|
756
|
+
try {
|
|
757
|
+
if (prepared.preApplyAuthorization.length && options.preApplyConfirmed !== true) {
|
|
758
|
+
throwPreApplyAuthorizationRequired(prepared.preApplyAuthorization);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
finally {
|
|
762
|
+
await disposePluginConfigApply(prepared.plan);
|
|
763
|
+
}
|
|
697
764
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
765
|
+
else {
|
|
766
|
+
const auth = await resolveConfigPreApplyAuthorization({ ...applyOptions, applyTargets: available,
|
|
767
|
+
rebuildRuntime: { ...applyOptions.rebuildRuntime, referencePlugins: selection.referencePlugins } });
|
|
768
|
+
if (auth.unavailableTargetResults.length)
|
|
769
|
+
throw unresolvedPreApplyAuthorization();
|
|
770
|
+
if (auth.targets.length && options.preApplyConfirmed !== true)
|
|
771
|
+
throwPreApplyAuthorizationRequired(auth.targets);
|
|
702
772
|
}
|
|
703
|
-
return { applyTargets: hasGeneric ? undefined : impact.affectedTargets,
|
|
704
|
-
applyCommandPackages: impact.affectedCommandPackages.map((target) => target.packageId),
|
|
705
|
-
...(!hasGeneric && impact.noEffectiveChange ? { skipReason: 'noEffectiveConfigChange' } : {}) };
|
|
706
773
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
774
|
+
if (!selection.commandOnly && options.expectedCommandPackageEvidence === undefined)
|
|
775
|
+
return consume(selection);
|
|
776
|
+
const staged = options.lockedCommands && options.lockedCommands.token === options.awHomeMutationToken ? options.lockedCommands.entries : undefined;
|
|
777
|
+
const entries = staged ?? await prepareConfigSelectionPackages(applyOptions, selection);
|
|
778
|
+
if (staged)
|
|
779
|
+
await verifyConfigSelectionPackages(applyOptions, selection, staged);
|
|
780
|
+
try {
|
|
781
|
+
if (!selection.commandOnly)
|
|
782
|
+
return await consume(selection);
|
|
783
|
+
if (!commandOnlyCandidatesMatch(selection, entries))
|
|
784
|
+
return await consume(await selectConfigMutationApply(applyOptions, mutation, false));
|
|
785
|
+
const hook = configApplyPackageHook(applyOptions, entries, selection.referencePlugins);
|
|
786
|
+
return await consume(selection, async () => {
|
|
787
|
+
const results = [];
|
|
788
|
+
for (const target of hook.targets) {
|
|
789
|
+
results.push(...await hook.execute(target.pluginId, target.scope, options.awHomeMutationToken, target.packageId));
|
|
790
|
+
}
|
|
791
|
+
return { state: results.every((result) => result.state === 'completed') ? 'succeeded' : 'partial',
|
|
792
|
+
targetResults: [], commandResults: results };
|
|
793
|
+
});
|
|
712
794
|
}
|
|
713
795
|
finally {
|
|
714
|
-
if (
|
|
715
|
-
await
|
|
796
|
+
if (!staged)
|
|
797
|
+
await Promise.all(entries.map(({ candidate }) => candidate?.cleanup()));
|
|
716
798
|
}
|
|
717
799
|
}
|
|
718
800
|
export async function applyPluginConfigWrite(options) {
|
|
@@ -723,7 +805,7 @@ export async function applyPluginConfigWrite(options) {
|
|
|
723
805
|
throw new Error('Plugin name is required for config write.');
|
|
724
806
|
assertSafePluginConfigSegment(requestedPluginName);
|
|
725
807
|
return withAwHomeMutationLock({
|
|
726
|
-
env: options.env,
|
|
808
|
+
tracksWrites: true, env: options.env,
|
|
727
809
|
token: options.awHomeMutationToken,
|
|
728
810
|
action: async (awHomeMutationToken) => {
|
|
729
811
|
await options.reviewPreflight?.();
|
|
@@ -734,20 +816,27 @@ export async function applyPluginConfigWrite(options) {
|
|
|
734
816
|
throw layerError;
|
|
735
817
|
let configCommitted = false;
|
|
736
818
|
try {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
819
|
+
return await withConfigMutationSelection({ ...options, apply: options.apply && !layerError, awHomeMutationToken }, async (selection, commandOnly) => {
|
|
820
|
+
const rebuildRuntime = { ...options.rebuildRuntime, awHomeMutationToken,
|
|
821
|
+
referencePlugins: selection?.referencePlugins ?? options.rebuildRuntime?.referencePlugins };
|
|
822
|
+
const saved = await applyPluginConfigWriteUnlocked({ ...options, scope: options.context ?? options.scope,
|
|
823
|
+
apply: false, awHomeMutationToken, rebuildRuntime }, selection?.impact);
|
|
824
|
+
configCommitted = true;
|
|
825
|
+
if (options.apply !== true || !options.plugin)
|
|
826
|
+
return saved;
|
|
827
|
+
if (layerError)
|
|
828
|
+
return { ...saved, overallState: 'partial', apply: configApplyLayerFailure(layerError) };
|
|
829
|
+
if (saved.apply.state === 'skipped' && saved.apply.reason === 'noConfigChange')
|
|
830
|
+
return saved;
|
|
831
|
+
if (selection?.skipReason)
|
|
832
|
+
return { ...saved, apply: skippedApply(selection.skipReason) };
|
|
833
|
+
if (commandOnly) {
|
|
834
|
+
const apply = await commandOnly();
|
|
835
|
+
return { ...saved, apply, overallState: apply.state === 'succeeded' ? 'succeeded' : 'partial' };
|
|
836
|
+
}
|
|
837
|
+
const applied = await applyPluginConfig({ ...options, ...selection, plugin: options.plugin, rebuildRuntime, awHomeMutationToken });
|
|
838
|
+
return { ...saved, overallState: applied.overallState, apply: applied.apply };
|
|
839
|
+
});
|
|
751
840
|
}
|
|
752
841
|
catch (error) {
|
|
753
842
|
let sensitiveValues = options.plugin
|
|
@@ -873,6 +962,8 @@ async function resetPluginConfigWithHelperUnlocked(options) {
|
|
|
873
962
|
catch (error) {
|
|
874
963
|
throw markConfigWriteFailed(error);
|
|
875
964
|
}
|
|
965
|
+
if (reset.existed && options.awHomeMutationToken)
|
|
966
|
+
advanceAwHomeMutationEpoch(options.awHomeMutationToken);
|
|
876
967
|
let effective;
|
|
877
968
|
let schema;
|
|
878
969
|
if (options.plugin) {
|
|
@@ -900,35 +991,40 @@ export async function resetPluginConfigWithHelper(options) {
|
|
|
900
991
|
await resolveWorkContext({ cwd: options.cwd, context: options.context });
|
|
901
992
|
assertSafePluginConfigSegment(options.pluginName);
|
|
902
993
|
return withAwHomeMutationLock({
|
|
903
|
-
env: options.env,
|
|
994
|
+
tracksWrites: true, env: options.env,
|
|
904
995
|
token: options.awHomeMutationToken,
|
|
905
996
|
action: async (awHomeMutationToken) => {
|
|
906
997
|
await options.reviewPreflight?.();
|
|
907
998
|
const layerError = options.plugin && options.apply
|
|
908
999
|
? await observeConfigLayerError({ ...options, plugin: options.plugin }) : undefined;
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
1000
|
+
return withConfigMutationSelection({ ...options, apply: options.apply && !layerError, awHomeMutationToken }, async (selection, commandOnly) => {
|
|
1001
|
+
const saved = await resetPluginConfigWithHelperUnlocked({ ...options, scope: options.context ?? options.scope,
|
|
1002
|
+
apply: false, awHomeMutationToken, rebuildRuntime: { ...options.rebuildRuntime, awHomeMutationToken } });
|
|
1003
|
+
if (options.apply !== true)
|
|
1004
|
+
return saved;
|
|
1005
|
+
if (layerError)
|
|
1006
|
+
return { ...saved, overallState: 'partial', apply: configApplyLayerFailure(layerError) };
|
|
1007
|
+
if (!options.plugin) {
|
|
1008
|
+
const apply = unavailableApply('sourceUnavailable', 'source');
|
|
1009
|
+
const cause = configActiveAvailabilityError(options.pluginError);
|
|
1010
|
+
return { ...saved, overallState: 'partial', apply: cause ? { ...apply, error: { stage: 'source', ...cause } } : apply };
|
|
1011
|
+
}
|
|
1012
|
+
if (saved.apply.state === 'skipped' && saved.apply.reason === 'noConfigChange')
|
|
1013
|
+
return saved;
|
|
1014
|
+
if (selection?.skipReason)
|
|
1015
|
+
return { ...saved, apply: skippedApply(selection.skipReason) };
|
|
1016
|
+
if (commandOnly) {
|
|
1017
|
+
const apply = await commandOnly();
|
|
1018
|
+
return { ...saved, apply, overallState: apply.state === 'succeeded' ? 'succeeded' : 'partial' };
|
|
1019
|
+
}
|
|
1020
|
+
const applied = await applyPluginConfig({ ...options, ...selection, plugin: options.plugin, awHomeMutationToken })
|
|
1021
|
+
.catch((error) => {
|
|
1022
|
+
if (error instanceof ConfigApplyInterruptedError)
|
|
1023
|
+
error.configWrite = 'succeeded';
|
|
1024
|
+
throw error;
|
|
1025
|
+
});
|
|
1026
|
+
return { ...saved, overallState: applied.overallState, apply: applied.apply };
|
|
930
1027
|
});
|
|
931
|
-
return { ...saved, overallState: applied.overallState, apply: applied.apply };
|
|
932
1028
|
},
|
|
933
1029
|
});
|
|
934
1030
|
}
|