@lesliechan721/aw 0.1.0-beta.89 → 0.1.0-beta.90
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/aw-capabilities.d.ts +1 -1
- package/dist/src/commands/aw-capabilities.js +4 -1
- package/dist/src/commands/aw-capabilities.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +4 -1
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +3 -0
- package/dist/src/commands/public-lifecycle-result.js +30 -5
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.js +8 -0
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +6 -2
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.js +28 -17
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.js +23 -3
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/commands/reconcile-operation-plan.d.ts +3 -0
- package/dist/src/commands/reconcile-operation-plan.js +1 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -1
- package/dist/src/commands/status-v6.js +61 -9
- package/dist/src/commands/status-v6.js.map +1 -1
- package/dist/src/index.js +122 -28
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/public-result.d.ts +1 -0
- package/dist/src/output/public-result.js +21 -3
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/receipt-projection.js +19 -5
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +2 -7
- package/dist/src/portable/recovery.js +10 -0
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.js +5 -0
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/joint-coordinator.js +12 -0
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/status.d.ts +1 -0
- package/dist/src/recovery/status.js +151 -44
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/source-binding.js +7 -4
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/components.js +1 -0
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-object-suggestions.d.ts +15 -0
- package/dist/src/tui/config-object-suggestions.js +71 -0
- package/dist/src/tui/config-object-suggestions.js.map +1 -0
- package/dist/src/tui/config-suggestions.d.ts +7 -2
- package/dist/src/tui/config-suggestions.js +22 -14
- package/dist/src/tui/config-suggestions.js.map +1 -1
- package/dist/src/tui/console-app-v4.js +569 -102
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +14 -16
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +6 -4
- package/dist/src/tui/controller.js +59 -12
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/guided-setup.d.ts +25 -0
- package/dist/src/tui/guided-setup.js +101 -0
- package/dist/src/tui/guided-setup.js.map +1 -0
- package/dist/src/tui/model.d.ts +5 -0
- package/dist/src/tui/model.js +120 -49
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/router.d.ts +5 -3
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +2 -0
- package/dist/src/tui/scoped-flow.js.map +1 -1
- package/dist/src/tui/scoped-inventory.d.ts +1 -0
- package/dist/src/tui/screen-registry.d.ts +3 -2
- package/dist/src/utils/config-platforms.d.ts +21 -0
- package/dist/src/utils/config-platforms.js +51 -0
- package/dist/src/utils/config-platforms.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +1 -0
- package/dist/src/utils/managed-command-materialization.js +8 -3
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/plugin-config-command-apply.js +7 -1
- package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
- package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
- package/dist/src/utils/plugin-config-diagnostics.js +44 -0
- package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
- package/dist/src/utils/plugin-config-impact.js +46 -18
- package/dist/src/utils/plugin-config-impact.js.map +1 -1
- package/dist/src/utils/plugin-config-references.d.ts +5 -0
- package/dist/src/utils/plugin-config-references.js +19 -7
- package/dist/src/utils/plugin-config-references.js.map +1 -1
- package/dist/src/utils/plugin-config-suggestion-runner.d.ts +45 -12
- package/dist/src/utils/plugin-config-suggestion-runner.js +174 -33
- package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -1
- package/dist/src/utils/plugin-config-suggestions.d.ts +10 -7
- package/dist/src/utils/plugin-config-suggestions.js +41 -13
- package/dist/src/utils/plugin-config-suggestions.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +2 -0
- package/dist/src/utils/plugin-config-write.js +44 -4
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +1 -0
- package/dist/src/utils/plugin-config.js +33 -8
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/package.json +3 -3
package/dist/src/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { preparePublicConfigConfirmation } from './commands/public-config-confir
|
|
|
4
4
|
import { createPublicCommandInterruption } from './commands/public-interruption.js';
|
|
5
5
|
import { CLI_OUTPUT_SCHEMA_VERSION, commandResult, publicExitCode, renderPublicResult, safePublicMessage } from './output/public-result.js';
|
|
6
6
|
import { projectReceipt } from './output/receipt-projection.js';
|
|
7
|
+
import { observePreferences } from './intent/deployment-preferences.js';
|
|
8
|
+
import { assertConfigLayerWritable, ConfigLayerError, resolveActiveConfigPlatforms } from './utils/config-platforms.js';
|
|
7
9
|
import { SKILL_INVOCATION_NOTICE } from './utils/skill-invocation-warning.js';
|
|
8
10
|
import { runPublicLifecycle } from './commands/public-lifecycle.js';
|
|
9
11
|
import { runPublicPluginList, runPublicPluginShow, runPublicPluginStatus } from './commands/public-plugin-query.js';
|
|
@@ -26,7 +28,7 @@ import { createNoopReporter, formatWarnings } from './output/reporter.js';
|
|
|
26
28
|
import { redactString, redactValue } from './output/redact.js';
|
|
27
29
|
import { resolveCliPackageRoot } from './utils/paths.js';
|
|
28
30
|
import { coercePluginConfigUpdates, assertPluginConfigMutationCandidate, findConfigFieldEntry, formatPluginConfigSetRecoveryCommand, listNamespacedPluginConfigStores, PluginConfigValueValidationError, readPluginConfigStore, renderPluginConfigValueForDisplay, resolveConfigRead, } from './utils/plugin-config.js';
|
|
29
|
-
import { applyPluginConfigWrite, ConfigApplyInterruptedError, applyPluginConfig, buildConfigMutationReceipt, configActiveAvailabilityError, configWriteStateForError, resetPluginConfigWithHelper, } from './utils/plugin-config-write.js';
|
|
31
|
+
import { applyPluginConfigWrite, ConfigApplyInterruptedError, applyPluginConfig, buildConfigMutationReceipt, configApplyLayerFailure, configActiveAvailabilityError, configWriteStateForError, resetPluginConfigWithHelper, } from './utils/plugin-config-write.js';
|
|
30
32
|
import { assertStrictSemVer } from './utils/manifest.js';
|
|
31
33
|
import { assertCatalogSourceReferencesSupported, inventoryLegacyConfigReferences, } from './utils/catalog-source-references.js';
|
|
32
34
|
import { CatalogLeaseEscapeError, CatalogPluginNotFoundError, parsePluginId, withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, } from './utils/multi-source-catalog.js';
|
|
@@ -289,18 +291,21 @@ async function resolveStoredOnlyConfigIdentity(options) {
|
|
|
289
291
|
};
|
|
290
292
|
}
|
|
291
293
|
async function resolveMultiSourceConfigRead(options) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
if (!options.schemaOnly) {
|
|
295
|
+
const inventory = await inventoryLegacyConfigReferences({
|
|
296
|
+
cwd: options.context.cwd,
|
|
297
|
+
env: options.context.env,
|
|
298
|
+
scope: options.rawOptions.context === 'project' ? 'project' : 'user',
|
|
299
|
+
});
|
|
300
|
+
assertCatalogSourceReferencesSupported(inventory);
|
|
301
|
+
}
|
|
298
302
|
return withResolvedCatalogPlugin({
|
|
299
303
|
selector: options.selector,
|
|
300
304
|
cliVersion: resolveCliVersion(),
|
|
301
305
|
env: options.context.env,
|
|
302
306
|
consume: async ({ pluginId, source, plugin }) => {
|
|
303
307
|
const result = await resolveConfigRead({
|
|
308
|
+
schemaOnly: options.schemaOnly,
|
|
304
309
|
pluginName: plugin.manifest.name,
|
|
305
310
|
plugin,
|
|
306
311
|
scope: options.rawOptions.context === 'project' ? 'project' : 'user',
|
|
@@ -333,6 +338,7 @@ async function resolveMultiSourceConfigRead(options) {
|
|
|
333
338
|
context: options.context,
|
|
334
339
|
});
|
|
335
340
|
const result = await resolveConfigRead({
|
|
341
|
+
schemaOnly: options.schemaOnly,
|
|
336
342
|
sourceId: stored.sourceId,
|
|
337
343
|
sourceIdentity: stored.sourceIdentity,
|
|
338
344
|
logicalIdentity: stored.logicalIdentity,
|
|
@@ -1455,15 +1461,34 @@ export function buildProgram(options = {}) {
|
|
|
1455
1461
|
writeLine(io.stderr, message);
|
|
1456
1462
|
commandExitState.exitCode = 1;
|
|
1457
1463
|
};
|
|
1464
|
+
const configLayerRecoveryResult = (result, error, pluginId) => {
|
|
1465
|
+
result.nextActions = error.nextActions;
|
|
1466
|
+
for (const diagnostic of result.diagnostics.filter(({ code }) => code === error.code)) {
|
|
1467
|
+
diagnostic.subject = { ...diagnostic.subject, ...(pluginId ? { pluginId } : {}),
|
|
1468
|
+
...(error.target ? { target: error.target } : {}) };
|
|
1469
|
+
}
|
|
1470
|
+
return result;
|
|
1471
|
+
};
|
|
1458
1472
|
const writeConfigMutationFailure = (command, plugin, json, error) => {
|
|
1459
1473
|
const failure = configMutationFailure(error, env, cwd);
|
|
1474
|
+
if (error instanceof ConfigLayerError) {
|
|
1475
|
+
const result = projectReceipt(`plugin.${command.replace(':', '.')}`, buildConfigMutationReceipt(command, {
|
|
1476
|
+
ok: false, overallState: 'failed', configWrite: failure.configWrite,
|
|
1477
|
+
...(plugin ? { pluginId: plugin } : {}),
|
|
1478
|
+
errors: [{ code: error.code, message: error.message }],
|
|
1479
|
+
}));
|
|
1480
|
+
result.status = 'blocked';
|
|
1481
|
+
writeJsonReceipt(io.stdout, configLayerRecoveryResult(result, error, plugin));
|
|
1482
|
+
commandExitState.exitCode = publicExitCode(result);
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1460
1485
|
const confirmation = error?.confirmation;
|
|
1461
1486
|
if (confirmation) {
|
|
1462
1487
|
writeJsonReceipt(io.stdout, { command, ok: false, pluginId: plugin, configWrite: 'notStarted', confirmation, errors: [failure] });
|
|
1463
1488
|
commandExitState.exitCode = 3;
|
|
1464
1489
|
return;
|
|
1465
1490
|
}
|
|
1466
|
-
if (json) {
|
|
1491
|
+
if (json || io.result) {
|
|
1467
1492
|
writeConfigMutationFailureReceipt(io.stdout, {
|
|
1468
1493
|
command,
|
|
1469
1494
|
...(plugin ? { plugin } : {}),
|
|
@@ -1473,7 +1498,8 @@ export function buildProgram(options = {}) {
|
|
|
1473
1498
|
? failure.message
|
|
1474
1499
|
: redactString(sanitizeCatalogSourceErrorMessage(error instanceof Error ? error.message : String(error), env, [cwd]));
|
|
1475
1500
|
writeLine(io.stderr, message);
|
|
1476
|
-
commandExitState.exitCode = failure.code === 'invalidArguments' ? 2
|
|
1501
|
+
commandExitState.exitCode = failure.code === 'invalidArguments' ? 2
|
|
1502
|
+
: ['configSchemaUnavailable', 'schemaUnavailable', 'configUnavailable', 'requiredConfigMissing'].includes(failure.code) ? 3 : 1;
|
|
1477
1503
|
};
|
|
1478
1504
|
const withResolvedConfigMutationPlugin = (context, selector, consume, options) => (async () => {
|
|
1479
1505
|
const parsed = parsePluginId(selector);
|
|
@@ -1965,13 +1991,15 @@ export function buildProgram(options = {}) {
|
|
|
1965
1991
|
dependencyOverrides, timeoutMs, signal: context.signal,
|
|
1966
1992
|
});
|
|
1967
1993
|
const { status, items, message, diagnostics } = prepared.project(await prepared.run());
|
|
1968
|
-
const severity = status === 'unavailable' ? 'error' : status === '
|
|
1969
|
-
const entries = status
|
|
1970
|
-
code: 'configSuggestionsUnavailable'
|
|
1971
|
-
|
|
1994
|
+
const severity = status === 'unavailable' ? 'error' : status === 'ok' ? 'info' : 'warning';
|
|
1995
|
+
const entries = status !== 'ok' && !diagnostics?.length ? [{
|
|
1996
|
+
code: status === 'unavailable' ? 'configSuggestionsUnavailable'
|
|
1997
|
+
: status === 'not-applicable' ? 'configSuggestionsNotApplicable' : 'configSuggestionsNoProbe',
|
|
1998
|
+
message: message || (status === 'unavailable' ? 'Suggestions are unavailable.'
|
|
1999
|
+
: status === 'not-applicable' ? 'Suggestions do not apply to this selection.' : 'No suggestion probe for this selection.'),
|
|
1972
2000
|
}] : diagnostics ?? [];
|
|
1973
2001
|
return commandResult(command, { pluginId: prepared.pluginId, fieldPath: prepared.fieldPath, profile: prepared.profile,
|
|
1974
|
-
provider: prepared.provider, providerPluginId: prepared.providerPluginId, status, items,
|
|
2002
|
+
provider: prepared.provider, providerPluginId: prepared.providerPluginId, kind: prepared.kind, status, items,
|
|
1975
2003
|
...(message === undefined ? {} : { message }), ...(diagnostics === undefined ? {} : { diagnostics }) }, {
|
|
1976
2004
|
status: status === 'unavailable' ? 'failed' : 'success',
|
|
1977
2005
|
diagnostics: entries.map((entry) => ({ ...entry, severity, subject: {
|
|
@@ -1985,6 +2013,15 @@ export function buildProgram(options = {}) {
|
|
|
1985
2013
|
}
|
|
1986
2014
|
catch (error) {
|
|
1987
2015
|
context.signal?.throwIfAborted();
|
|
2016
|
+
if (error instanceof ConfigLayerError) {
|
|
2017
|
+
const result = commandResult(command, {}, { status: 'blocked', diagnostics: [{
|
|
2018
|
+
code: error.code, severity: 'error', message: error.message,
|
|
2019
|
+
subject: { pluginId: selector, ...(platform === undefined ? {} : { target: platform }), field },
|
|
2020
|
+
}], nextActions: error.nextActions });
|
|
2021
|
+
writeJsonReceipt(io.stdout, result);
|
|
2022
|
+
commandExitState.exitCode = publicExitCode(result);
|
|
2023
|
+
return;
|
|
2024
|
+
}
|
|
1988
2025
|
const argumentError = error instanceof ConfigSuggestionArgumentError || error instanceof WriteCommandRequestError
|
|
1989
2026
|
|| error instanceof CatalogPluginNotFoundError;
|
|
1990
2027
|
const result = commandResult(command, {}, { status: 'failed', diagnostics: [{
|
|
@@ -2010,9 +2047,9 @@ export function buildProgram(options = {}) {
|
|
|
2010
2047
|
const context = createActionContext(`config:${command}`, rawOptions);
|
|
2011
2048
|
const work = await configContext(context, rawOptions);
|
|
2012
2049
|
const resolved = await runActionWithContext(context, () => resolveMultiSourceConfigRead({
|
|
2013
|
-
selector, key, rawOptions: { ...rawOptions, context: work.context }, context,
|
|
2050
|
+
selector, key, schemaOnly: command === 'schema', rawOptions: { ...rawOptions, context: work.context }, context,
|
|
2014
2051
|
}));
|
|
2015
|
-
if (rawOptions.json) {
|
|
2052
|
+
if (rawOptions.json || io.result) {
|
|
2016
2053
|
const result = projectReceipt(`plugin.config.${command}`, {
|
|
2017
2054
|
ok: true, configSchemaVersion: 5, command: `config:${command}`,
|
|
2018
2055
|
plugin: resolved.pluginName, pluginName: resolved.pluginName, pluginId: resolved.pluginId,
|
|
@@ -2054,7 +2091,9 @@ export function buildProgram(options = {}) {
|
|
|
2054
2091
|
const rawOptions = args[command === 'edit' ? 1 : 2];
|
|
2055
2092
|
let key = command === 'edit' ? undefined : args[1];
|
|
2056
2093
|
const context = createActionContext(`config:${command}`, rawOptions);
|
|
2094
|
+
let resolvedPluginId;
|
|
2057
2095
|
try {
|
|
2096
|
+
let cleanupApplyError;
|
|
2058
2097
|
const work = await configContext(context, rawOptions);
|
|
2059
2098
|
const platform = configPlatform(rawOptions);
|
|
2060
2099
|
const scriptTimeoutMs = normalizeWriteRequest(() => resolveScriptTimeoutMs(rawOptions));
|
|
@@ -2068,9 +2107,21 @@ export function buildProgram(options = {}) {
|
|
|
2068
2107
|
throw new WriteCommandRequestError('Use exactly one of --value-json, --value-stdin, or --preset.');
|
|
2069
2108
|
}
|
|
2070
2109
|
const receipt = await runActionWithContext(context, () => withResolvedConfigMutationPlugin(context, selector, async ({ pluginId, source, plugin }, awHomeMutationToken, catalogOperationContext) => {
|
|
2071
|
-
|
|
2110
|
+
resolvedPluginId = pluginId;
|
|
2111
|
+
const preferences = await observePreferences({ scope: 'user', cwd: context.cwd, env: context.env });
|
|
2112
|
+
if (command !== 'unset' || rawOptions.apply) {
|
|
2113
|
+
try {
|
|
2114
|
+
assertConfigLayerWritable(pluginId, plugin.manifest, preferences, platform);
|
|
2115
|
+
}
|
|
2116
|
+
catch (error) {
|
|
2117
|
+
if (command !== 'unset' || !(error instanceof ConfigLayerError))
|
|
2118
|
+
throw error;
|
|
2119
|
+
cleanupApplyError = error;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
if (!plugin.manifest.config && command !== 'unset')
|
|
2072
2123
|
throw Object.assign(new Error(`configSchemaUnavailable: Plugin "${plugin.manifest.name}" does not declare an AW config schema.`), { code: 'configSchemaUnavailable' });
|
|
2073
|
-
const fields = selectPluginConfigProfile(plugin.manifest.config, platform).fields;
|
|
2124
|
+
const fields = plugin.manifest.config ? selectPluginConfigProfile(plugin.manifest.config, platform).fields : {};
|
|
2074
2125
|
if (command === 'edit') {
|
|
2075
2126
|
const selected = await context.prompt.select({ message: `编辑用户${platform ?? 'common'}配置`,
|
|
2076
2127
|
choices: Object.entries(fields).map(([value, field]) => ({ value, label: field.title ?? value })) });
|
|
@@ -2156,7 +2207,8 @@ export function buildProgram(options = {}) {
|
|
|
2156
2207
|
throw error;
|
|
2157
2208
|
}
|
|
2158
2209
|
const mutation = command === 'unset' ? { kind: 'patch', removeKeys: [key] } : { kind: 'patch', updates: { [key]: inputValue } };
|
|
2159
|
-
const
|
|
2210
|
+
const apply = rawOptions.apply === true && !cleanupApplyError;
|
|
2211
|
+
const reviewed = apply ? await preparePublicConfigConfirmation({ plugin, scope: work.context,
|
|
2160
2212
|
context: work.context, platform, cwd: context.cwd, env: context.env, cliVersion: resolveCliVersion(),
|
|
2161
2213
|
nativeCliRunner: context.nativeCliRunner, awHomeMutationToken, yes: rawOptions.yes, mutation,
|
|
2162
2214
|
rebuildRuntime: { ...context, awHomeMutationToken, catalogOperationContext,
|
|
@@ -2173,10 +2225,14 @@ export function buildProgram(options = {}) {
|
|
|
2173
2225
|
awHomeMutationToken, request: command === 'unset' ? { removeKeys: [key] } : { updates: { [key]: inputValue } },
|
|
2174
2226
|
expectedCommandPackageEvidence: reviewed?.commandPackageEvidence,
|
|
2175
2227
|
expectedHostPermissionEffects: reviewed?.hostPermissionEffects,
|
|
2176
|
-
apply
|
|
2228
|
+
apply, sharedNativeApplyConfirmed: rawOptions.yes === true,
|
|
2177
2229
|
preApplyConfirmed: rawOptions.yes === true });
|
|
2178
2230
|
return buildConfigMutationReceipt(`config:${command}`, {
|
|
2179
|
-
...writeReceipt, confirmation, ok: writeReceipt.overallState === 'succeeded', plugin: plugin.manifest.name,
|
|
2231
|
+
...writeReceipt, confirmation, ok: writeReceipt.overallState === 'succeeded' && !cleanupApplyError, plugin: plugin.manifest.name,
|
|
2232
|
+
...(cleanupApplyError ? {
|
|
2233
|
+
overallState: 'partial',
|
|
2234
|
+
apply: configApplyLayerFailure(cleanupApplyError),
|
|
2235
|
+
} : {}),
|
|
2180
2236
|
pluginName: plugin.manifest.name, pluginId, sourceId: source.sourceId, sourceIdentity: source.sourceIdentity,
|
|
2181
2237
|
context: work, platform: platform ?? 'common',
|
|
2182
2238
|
...(command === 'unset' ? { removedKey: key, existed: true } : {}),
|
|
@@ -2187,7 +2243,11 @@ export function buildProgram(options = {}) {
|
|
|
2187
2243
|
}));
|
|
2188
2244
|
if (!receipt)
|
|
2189
2245
|
return;
|
|
2190
|
-
if (
|
|
2246
|
+
if (cleanupApplyError) {
|
|
2247
|
+
const result = projectReceipt(`plugin.config.${command}`, receipt);
|
|
2248
|
+
writeJsonReceipt(io.stdout, configLayerRecoveryResult(result, cleanupApplyError, receipt.pluginId));
|
|
2249
|
+
}
|
|
2250
|
+
else if (rawOptions.json || io.result)
|
|
2191
2251
|
writeJsonReceipt(io.stdout, receipt);
|
|
2192
2252
|
else {
|
|
2193
2253
|
writeLine(io.stdout, `已保存 ${receipt.plugin}.${key}(用户 ${platform ?? 'common'} 配置)。`);
|
|
@@ -2196,7 +2256,7 @@ export function buildProgram(options = {}) {
|
|
|
2196
2256
|
commandExitState.exitCode = receipt.overallState === 'succeeded' ? 0 : 1;
|
|
2197
2257
|
}
|
|
2198
2258
|
catch (error) {
|
|
2199
|
-
writeConfigMutationFailure(`config:${command}`, selector, rawOptions.json === true, error);
|
|
2259
|
+
writeConfigMutationFailure(`config:${command}`, resolvedPluginId ?? selector, rawOptions.json === true, error);
|
|
2200
2260
|
}
|
|
2201
2261
|
});
|
|
2202
2262
|
}
|
|
@@ -2204,6 +2264,7 @@ export function buildProgram(options = {}) {
|
|
|
2204
2264
|
.action(async (selector, rawOptions) => {
|
|
2205
2265
|
const context = createActionContext('config:reset', rawOptions);
|
|
2206
2266
|
try {
|
|
2267
|
+
let cleanupApplyError;
|
|
2207
2268
|
const work = await configContext(context, rawOptions);
|
|
2208
2269
|
const platform = configPlatform(rawOptions);
|
|
2209
2270
|
if (!rawOptions.yes) {
|
|
@@ -2215,18 +2276,36 @@ export function buildProgram(options = {}) {
|
|
|
2215
2276
|
}
|
|
2216
2277
|
const located = await resolveStoredConfigResetIdentity({ selector, context, scope: 'user' });
|
|
2217
2278
|
const resetStore = async (plugin, pluginError, awHomeMutationToken, catalogOperationContext) => {
|
|
2279
|
+
if (plugin && rawOptions.apply) {
|
|
2280
|
+
try {
|
|
2281
|
+
assertConfigLayerWritable(located.pluginId, plugin.manifest, await observePreferences({
|
|
2282
|
+
scope: 'user', cwd: context.cwd, env: context.env,
|
|
2283
|
+
}), platform);
|
|
2284
|
+
}
|
|
2285
|
+
catch (error) {
|
|
2286
|
+
if (!(error instanceof ConfigLayerError))
|
|
2287
|
+
throw error;
|
|
2288
|
+
cleanupApplyError = error;
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
const apply = rawOptions.apply === true && !cleanupApplyError;
|
|
2218
2292
|
const rebuildRuntime = { ...context, awHomeMutationToken, catalogOperationContext,
|
|
2219
2293
|
expectedGenerationSetDigest: catalogOperationContext?.generationSetDigest, scriptTimeoutMs: resolveScriptTimeoutMs(rawOptions) };
|
|
2220
|
-
const reviewed = plugin &&
|
|
2294
|
+
const reviewed = plugin && apply ? await preparePublicConfigConfirmation({ plugin,
|
|
2221
2295
|
scope: work.context, context: work.context, platform, cwd: context.cwd, env: context.env,
|
|
2222
2296
|
cliVersion: resolveCliVersion(), nativeCliRunner: context.nativeCliRunner, awHomeMutationToken,
|
|
2223
2297
|
yes: rawOptions.yes, mutation: { kind: 'reset' }, rebuildRuntime }) : null;
|
|
2224
2298
|
const receipt = await resetPluginConfigWithHelper({ ...located, plugin, pluginError, platform, scope: work.context,
|
|
2225
2299
|
context: work.context, cliVersion: resolveCliVersion(), cwd: context.cwd, env: context.env, awHomeMutationToken,
|
|
2226
|
-
nativeCliRunner: context.nativeCliRunner, apply
|
|
2300
|
+
nativeCliRunner: context.nativeCliRunner, apply,
|
|
2227
2301
|
expectedCommandPackageEvidence: reviewed?.commandPackageEvidence, expectedHostPermissionEffects: reviewed?.hostPermissionEffects, rebuildRuntime,
|
|
2228
2302
|
sharedNativeApplyConfirmed: true, preApplyConfirmed: rawOptions.yes === true });
|
|
2229
|
-
return { ...receipt, confirmation: reviewed?.confirmation ?? null
|
|
2303
|
+
return { ...receipt, confirmation: reviewed?.confirmation ?? null,
|
|
2304
|
+
...(cleanupApplyError ? {
|
|
2305
|
+
overallState: 'partial',
|
|
2306
|
+
apply: configApplyLayerFailure(cleanupApplyError),
|
|
2307
|
+
} : {}),
|
|
2308
|
+
};
|
|
2230
2309
|
};
|
|
2231
2310
|
const resetReceipt = await runActionWithContext(context, () => withAwHomeMutationLock({
|
|
2232
2311
|
env: context.env, signal: context.signal, action: async (token) => {
|
|
@@ -2250,7 +2329,11 @@ export function buildProgram(options = {}) {
|
|
|
2250
2329
|
const receipt = buildConfigMutationReceipt('config:reset', { ...resetReceipt,
|
|
2251
2330
|
ok: resetReceipt.overallState === 'succeeded', ...located, plugin: located.pluginName,
|
|
2252
2331
|
context: work, platform: platform ?? 'common' });
|
|
2253
|
-
if (
|
|
2332
|
+
if (cleanupApplyError) {
|
|
2333
|
+
const result = projectReceipt('plugin.config.reset', { ...receipt, confirmation: undefined }, { yes: rawOptions.yes });
|
|
2334
|
+
writeJsonReceipt(io.stdout, configLayerRecoveryResult(result, cleanupApplyError, receipt.pluginId));
|
|
2335
|
+
}
|
|
2336
|
+
else if (rawOptions.json || io.result)
|
|
2254
2337
|
writeJsonReceipt(io.stdout, receipt);
|
|
2255
2338
|
else {
|
|
2256
2339
|
writeLine(io.stdout, `已恢复 ${receipt.plugin} 的用户 ${platform ?? 'common'} 默认配置。`);
|
|
@@ -2277,6 +2360,11 @@ export function buildProgram(options = {}) {
|
|
|
2277
2360
|
const receipt = await runActionWithContext(context, () => withResolvedConfigMutationPlugin(context, selector, async ({ plugin, pluginId, source }, awHomeMutationToken, catalogOperationContext) => {
|
|
2278
2361
|
const identity = { plugin: plugin.manifest.name, pluginId, sourceId: source.sourceId };
|
|
2279
2362
|
resolved = identity;
|
|
2363
|
+
const preferences = await observePreferences({ scope: 'user', cwd: context.cwd, env: context.env });
|
|
2364
|
+
resolveActiveConfigPlatforms(pluginId, plugin.manifest, preferences);
|
|
2365
|
+
for (const selected of [...(platform ? [platform] : []), ...(targets ?? [])]) {
|
|
2366
|
+
assertConfigLayerWritable(pluginId, plugin.manifest, preferences, selected);
|
|
2367
|
+
}
|
|
2280
2368
|
const rebuildRuntime = { ...context, catalogOperationContext,
|
|
2281
2369
|
expectedGenerationSetDigest: catalogOperationContext.generationSetDigest, scriptTimeoutMs: resolveScriptTimeoutMs(rawOptions) };
|
|
2282
2370
|
const reviewed = await preparePublicConfigConfirmation({ plugin, scope: work.context, context: work.context, platform, targets,
|
|
@@ -2298,6 +2386,10 @@ export function buildProgram(options = {}) {
|
|
|
2298
2386
|
});
|
|
2299
2387
|
return { ...applied, ...identity, confirmation: reviewed.confirmation, context: work, platform: platform ?? 'common' };
|
|
2300
2388
|
}, { retainCompletedResultOnAbort: true })).catch((error) => {
|
|
2389
|
+
if (error instanceof ConfigLayerError) {
|
|
2390
|
+
writeConfigMutationFailure('config:apply', resolved?.pluginId ?? selector, rawOptions.json === true, error);
|
|
2391
|
+
return undefined;
|
|
2392
|
+
}
|
|
2301
2393
|
if (error instanceof CatalogLeaseEscapeError)
|
|
2302
2394
|
throw error;
|
|
2303
2395
|
const sourceError = configActiveAvailabilityError(error);
|
|
@@ -2316,9 +2408,11 @@ export function buildProgram(options = {}) {
|
|
|
2316
2408
|
context: work, configWrite: 'notStarted',
|
|
2317
2409
|
overallState: 'failed', errors: [{ code, message }] };
|
|
2318
2410
|
});
|
|
2411
|
+
if (!receipt)
|
|
2412
|
+
return;
|
|
2319
2413
|
const result = buildConfigMutationReceipt('config:apply', { ...receipt,
|
|
2320
2414
|
ok: receipt.overallState === 'succeeded' });
|
|
2321
|
-
if (rawOptions.json)
|
|
2415
|
+
if (rawOptions.json || io.result)
|
|
2322
2416
|
writeJsonReceipt(io.stdout, result);
|
|
2323
2417
|
else {
|
|
2324
2418
|
const outcome = result.ok ? '完成' : result.overallState === 'partial' ? '部分失败' : '失败';
|