@lesliechan721/aw 0.1.0-beta.82 → 0.1.0-beta.84
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/authoring/assets/aw-runtime-config.mjs +1 -1
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
- package/dist/src/commands/console.js +1 -0
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/intent-command.d.ts +1 -0
- package/dist/src/commands/intent-command.js +6 -2
- package/dist/src/commands/intent-command.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +3 -3
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/public-lifecycle-result.d.ts +11 -5
- package/dist/src/commands/public-lifecycle-result.js +131 -46
- package/dist/src/commands/public-lifecycle-result.js.map +1 -1
- package/dist/src/commands/public-lifecycle.d.ts +1 -2
- package/dist/src/commands/public-lifecycle.js +56 -34
- package/dist/src/commands/public-lifecycle.js.map +1 -1
- package/dist/src/commands/public-plugin-query.js +28 -11
- package/dist/src/commands/public-plugin-query.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +13 -3
- package/dist/src/commands/rebuild-command.js +647 -286
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +5 -2
- package/dist/src/commands/rebuild-integration.js +55 -29
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +1 -0
- package/dist/src/commands/rebuild-operations.js +23 -4
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/rebuild-platform-integration.d.ts +14 -3
- package/dist/src/commands/rebuild-platform-integration.js +240 -137
- package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
- package/dist/src/index.js +105 -50
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/public-result.d.ts +2 -0
- package/dist/src/output/public-result.js +43 -6
- package/dist/src/output/public-result.js.map +1 -1
- package/dist/src/output/rebuild-progress.d.ts +3 -0
- package/dist/src/output/rebuild-progress.js +12 -2
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/output/receipt-projection.js +55 -18
- package/dist/src/output/receipt-projection.js.map +1 -1
- package/dist/src/output/skill-invocation-notices.d.ts +16 -0
- package/dist/src/output/skill-invocation-notices.js +48 -0
- package/dist/src/output/skill-invocation-notices.js.map +1 -0
- package/dist/src/platforms/capabilities.d.ts +2 -0
- package/dist/src/platforms/capabilities.js +73 -34
- package/dist/src/platforms/capabilities.js.map +1 -1
- package/dist/src/platforms/contracts.d.ts +9 -9
- package/dist/src/platforms/discovery.d.ts +0 -7
- package/dist/src/platforms/discovery.js +13 -53
- package/dist/src/platforms/discovery.js.map +1 -1
- package/dist/src/platforms/inspection-native.js +1 -80
- package/dist/src/platforms/inspection-native.js.map +1 -1
- package/dist/src/platforms/inspection-query.d.ts +2 -3
- package/dist/src/platforms/inspection-query.js +7 -18
- package/dist/src/platforms/inspection-query.js.map +1 -1
- package/dist/src/platforms/inspection.js +2 -2
- package/dist/src/platforms/inspection.js.map +1 -1
- package/dist/src/platforms/layout.js +1 -5
- package/dist/src/platforms/layout.js.map +1 -1
- package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
- package/dist/src/platforms/lifecycle-native-services.js +14 -14
- package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
- package/dist/src/platforms/lifecycle-native.js +4 -88
- package/dist/src/platforms/lifecycle-native.js.map +1 -1
- package/dist/src/platforms/lifecycle.js +56 -56
- package/dist/src/platforms/lifecycle.js.map +1 -1
- package/dist/src/platforms/projection-code-extension.js +7 -3
- package/dist/src/platforms/projection-code-extension.js.map +1 -1
- package/dist/src/platforms/projection.d.ts +3 -0
- package/dist/src/platforms/projection.js +86 -54
- package/dist/src/platforms/projection.js.map +1 -1
- package/dist/src/portable/materializer.js +2 -2
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/recovery.d.ts +29 -3
- package/dist/src/portable/recovery.js +220 -78
- package/dist/src/portable/recovery.js.map +1 -1
- package/dist/src/recovery/coordinator.d.ts +21 -5
- package/dist/src/recovery/coordinator.js +383 -151
- package/dist/src/recovery/coordinator.js.map +1 -1
- package/dist/src/recovery/install-concurrency.d.ts +48 -0
- package/dist/src/recovery/install-concurrency.js +195 -0
- package/dist/src/recovery/install-concurrency.js.map +1 -0
- package/dist/src/recovery/interruption.d.ts +19 -0
- package/dist/src/recovery/interruption.js +43 -0
- package/dist/src/recovery/interruption.js.map +1 -0
- package/dist/src/recovery/joint-coordinator.d.ts +11 -4
- package/dist/src/recovery/joint-coordinator.js +681 -333
- package/dist/src/recovery/joint-coordinator.js.map +1 -1
- package/dist/src/recovery/joint-demand.d.ts +8 -0
- package/dist/src/recovery/joint-demand.js +52 -1
- package/dist/src/recovery/joint-demand.js.map +1 -1
- package/dist/src/recovery/joint-install-execution.d.ts +19 -0
- package/dist/src/recovery/joint-install-execution.js +307 -0
- package/dist/src/recovery/joint-install-execution.js.map +1 -0
- package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
- package/dist/src/recovery/joint-install-native-rebase.js +67 -0
- package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
- package/dist/src/recovery/receipt.d.ts +20 -0
- package/dist/src/recovery/receipt.js +67 -1
- package/dist/src/recovery/receipt.js.map +1 -1
- package/dist/src/recovery/retirement.js +1 -1
- package/dist/src/recovery/retirement.js.map +1 -1
- package/dist/src/recovery/status.js +26 -27
- package/dist/src/recovery/status.js.map +1 -1
- package/dist/src/review/platform-profile.d.ts +4 -1
- package/dist/src/review/platform-profile.js +13 -4
- 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 +28 -16
- package/dist/src/review/skill-materialization.js.map +1 -1
- package/dist/src/review/source-binding.js +6 -4
- package/dist/src/review/source-binding.js.map +1 -1
- package/dist/src/tui/catalog-generation.d.ts +6 -0
- package/dist/src/tui/catalog-generation.js +22 -6
- package/dist/src/tui/catalog-generation.js.map +1 -1
- package/dist/src/tui/console-app-v4.d.ts +1 -1
- package/dist/src/tui/console-app-v4.js +139 -59
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/controller-runtime.js +145 -53
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +13 -4
- package/dist/src/tui/controller.js +241 -102
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/deployment-view.js +6 -1
- package/dist/src/tui/deployment-view.js.map +1 -1
- package/dist/src/tui/diagnostic-projection.d.ts +4 -2
- package/dist/src/tui/diagnostic-projection.js +40 -4
- package/dist/src/tui/diagnostic-projection.js.map +1 -1
- package/dist/src/tui/glossary.js +1 -0
- package/dist/src/tui/glossary.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +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 -3
- package/dist/src/tui/operation-history.js +15 -2
- package/dist/src/tui/operation-history.js.map +1 -1
- package/dist/src/tui/scoped-flow.d.ts +3 -1
- package/dist/src/tui/scoped-flow.js +99 -1
- package/dist/src/tui/scoped-flow.js.map +1 -1
- package/dist/src/tui/session-console-app.d.ts +2 -0
- package/dist/src/tui/session-console-app.js +11 -0
- package/dist/src/tui/session-console-app.js.map +1 -1
- package/dist/src/types.d.ts +8 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.js +2 -1
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/catalog-generation-resolver.d.ts +1 -0
- package/dist/src/utils/catalog-generation-resolver.js +1 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
- package/dist/src/utils/catalog-operation-context.d.ts +11 -0
- package/dist/src/utils/catalog-operation-context.js +18 -3
- package/dist/src/utils/catalog-operation-context.js.map +1 -1
- package/dist/src/utils/catalog-source-references.js +2 -14
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/component-resources.js +1 -1
- package/dist/src/utils/component-resources.js.map +1 -1
- package/dist/src/utils/managed-command-materialization.d.ts +2 -1
- package/dist/src/utils/managed-command-materialization.js +3 -3
- package/dist/src/utils/managed-command-materialization.js.map +1 -1
- package/dist/src/utils/managed-command-store.d.ts +6 -0
- package/dist/src/utils/managed-command-store.js +90 -18
- package/dist/src/utils/managed-command-store.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +2 -0
- package/dist/src/utils/multi-source-catalog.js +3 -2
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +0 -19
- package/dist/src/utils/native-cli.js +2 -42
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/ownership.js +1 -1
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/platform-empty-state.d.ts +1 -3
- package/dist/src/utils/platform-empty-state.js +1 -6
- package/dist/src/utils/platform-empty-state.js.map +1 -1
- package/dist/src/utils/plugin-config-write.d.ts +8 -0
- package/dist/src/utils/plugin-config-write.js +89 -25
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-scripts.js +5 -0
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/skill-invocation-warning.d.ts +15 -0
- package/dist/src/utils/skill-invocation-warning.js +42 -0
- package/dist/src/utils/skill-invocation-warning.js.map +1 -0
- package/package.json +3 -3
- package/dist/src/output/native-consent.d.ts +0 -2
- package/dist/src/output/native-consent.js +0 -5
- package/dist/src/output/native-consent.js.map +0 -1
- package/dist/src/platforms/gemini-activation.d.ts +0 -36
- package/dist/src/platforms/gemini-activation.js +0 -331
- package/dist/src/platforms/gemini-activation.js.map +0 -1
- package/dist/src/platforms/gemini-consent.d.ts +0 -8
- package/dist/src/platforms/gemini-consent.js +0 -81
- package/dist/src/platforms/gemini-consent.js.map +0 -1
package/dist/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ 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 {
|
|
7
|
+
import { SKILL_INVOCATION_NOTICE } from './utils/skill-invocation-warning.js';
|
|
8
8
|
import { runPublicLifecycle } from './commands/public-lifecycle.js';
|
|
9
9
|
import { runPublicPluginList, runPublicPluginShow, runPublicPluginStatus } from './commands/public-plugin-query.js';
|
|
10
10
|
import fs from 'node:fs';
|
|
@@ -25,14 +25,15 @@ import { createNoopReporter, formatWarnings } from './output/reporter.js';
|
|
|
25
25
|
import { redactString, redactValue } from './output/redact.js';
|
|
26
26
|
import { resolveCliPackageRoot } from './utils/paths.js';
|
|
27
27
|
import { coercePluginConfigUpdates, assertPluginConfigMutationCandidate, findConfigFieldEntry, formatPluginConfigSetRecoveryCommand, listNamespacedPluginConfigStores, readPluginConfigStore, renderPluginConfigValueForDisplay, resolveConfigRead, } from './utils/plugin-config.js';
|
|
28
|
-
import { applyPluginConfigWrite, applyPluginConfig, buildConfigMutationReceipt, configWriteStateForError, resetPluginConfigWithHelper, } from './utils/plugin-config-write.js';
|
|
28
|
+
import { applyPluginConfigWrite, ConfigApplyInterruptedError, applyPluginConfig, buildConfigMutationReceipt, configWriteStateForError, resetPluginConfigWithHelper, } from './utils/plugin-config-write.js';
|
|
29
29
|
import { assertStrictSemVer } from './utils/manifest.js';
|
|
30
30
|
import { assertCatalogSourceReferencesSupported, inventoryLegacyConfigReferences, } from './utils/catalog-source-references.js';
|
|
31
|
-
import { parsePluginId, withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, } from './utils/multi-source-catalog.js';
|
|
31
|
+
import { CatalogLeaseEscapeError, parsePluginId, withResolvedCatalogPlugin, withResolvedMultiSourceCatalog, } from './utils/multi-source-catalog.js';
|
|
32
32
|
import { sanitizeCatalogSourceError, sanitizeCatalogSourceErrorMessage, } from './utils/catalog-public-error.js';
|
|
33
33
|
import { catalogGenerationErrorCode } from './utils/catalog-generation-error.js';
|
|
34
34
|
import { resolveCatalogOperationContext, } from './utils/catalog-operation-context.js';
|
|
35
35
|
import { withAwHomeMutationLock, } from './utils/aw-home-mutation-lock.js';
|
|
36
|
+
import { recoveryInterruptionCode } from './recovery/interruption.js';
|
|
36
37
|
import { materializePortableSkillsToDirectory, PortableCommandError } from './portable/commands.js';
|
|
37
38
|
import { createReviewInspectionFailure, getReviewInspectionExitCode, inspectReviewTarget, } from './commands/review-inspection.js';
|
|
38
39
|
import { prepareReviewTarget, } from './commands/review-preparation.js';
|
|
@@ -116,6 +117,9 @@ function normalizeWriteRequest(normalize) {
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
function configMutationFailure(error, env, cwd) {
|
|
120
|
+
if (error instanceof ConfigApplyInterruptedError)
|
|
121
|
+
return { code: error.code, message: error.operationDiagnostic.safeMessage,
|
|
122
|
+
configWrite: error.configWrite, apply: error.apply };
|
|
119
123
|
const configWrite = error?.configWrite === 'succeeded' ? 'succeeded' : configWriteStateForError(error);
|
|
120
124
|
if (error instanceof CommanderError) {
|
|
121
125
|
return {
|
|
@@ -167,10 +171,11 @@ function writeConfigMutationFailureReceipt(write, request, failure) {
|
|
|
167
171
|
}
|
|
168
172
|
writeJsonReceipt(write, buildConfigMutationReceipt(request.command, {
|
|
169
173
|
ok: false,
|
|
170
|
-
overallState: 'failed',
|
|
174
|
+
overallState: failure.apply ? 'partial' : 'failed',
|
|
171
175
|
configWrite: failure.configWrite,
|
|
176
|
+
...(failure.apply ? { apply: failure.apply } : {}),
|
|
172
177
|
...(plugin ? { plugin } : {}),
|
|
173
|
-
errors: [failure],
|
|
178
|
+
errors: [{ code: failure.code, message: failure.message }],
|
|
174
179
|
}));
|
|
175
180
|
}
|
|
176
181
|
async function runAuthoringScript(options) {
|
|
@@ -492,8 +497,6 @@ function writeJsonReceipt(write, payload) {
|
|
|
492
497
|
writeLine(write, JSON.stringify(payload, null, 2));
|
|
493
498
|
}
|
|
494
499
|
function writeConfigApplyNotice(write, receipt) {
|
|
495
|
-
if (receipt.nativeConsent)
|
|
496
|
-
writeLine(write, geminiNativeConsentDiagnostic().message);
|
|
497
500
|
const sanitizeMessage = (message) => redactString(message)
|
|
498
501
|
.replace(/https?:\/\/\S+/giu, '[REDACTED URL]')
|
|
499
502
|
.replace(/file:\/\/\S+/giu, '[REDACTED PATH]')
|
|
@@ -507,15 +510,17 @@ function writeConfigApplyNotice(write, receipt) {
|
|
|
507
510
|
? `失败原因:${entry.errorCode}。`
|
|
508
511
|
: '未提供安全失败原因。';
|
|
509
512
|
const command = `aw plugin sync ${receipt.plugin} --rebuild --target ${entry.target.platform} --context ${entry.target.scope}`;
|
|
510
|
-
const recovery = entry.
|
|
511
|
-
?
|
|
512
|
-
: entry.errorCode === '
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
? `
|
|
518
|
-
: ''
|
|
513
|
+
const recovery = entry.partialDelivery
|
|
514
|
+
? ' 部分输出已验证。请检查尚未完成的输出后再重新准备应用。'
|
|
515
|
+
: entry.errorCode === 'invalidConfig'
|
|
516
|
+
? ` 请修复无效配置后运行 ${command}。`
|
|
517
|
+
: entry.errorCode === 'preApplyAuthorizationRequired'
|
|
518
|
+
|| entry.errorCode === 'sharedNativeConfigApplyConfirmationRequired'
|
|
519
|
+
|| entry.errorCode === 'sharedNativeImpactAuthorizationRequired'
|
|
520
|
+
? ` 请运行 ${command} --yes 重试。`
|
|
521
|
+
: entry.state === 'failed'
|
|
522
|
+
? ` 请在解决失败原因后运行 ${command}。`
|
|
523
|
+
: '';
|
|
519
524
|
writeLine(write, `${entry.target.platform}/${entry.target.scope}:${reason}${recovery}`);
|
|
520
525
|
}
|
|
521
526
|
};
|
|
@@ -553,9 +558,11 @@ function writeConfigApplyNotice(write, receipt) {
|
|
|
553
558
|
}
|
|
554
559
|
else {
|
|
555
560
|
const completed = targetResults.filter((entry) => entry.state === 'completed').length;
|
|
556
|
-
const
|
|
561
|
+
const partiallyDelivered = targetResults.filter((entry) => entry.partialDelivery).length;
|
|
562
|
+
const failed = targetResults.filter((entry) => entry.state === 'failed' && !entry.partialDelivery).length;
|
|
557
563
|
const skipped = targetResults.filter((entry) => entry.state === 'skipped').length;
|
|
558
|
-
|
|
564
|
+
const partialSummary = partiallyDelivered > 0 ? `部分完成 ${partiallyDelivered} 个;` : '';
|
|
565
|
+
writeLine(write, `配置已保存。已刷新 ${completed} 个当前可见目标;${partialSummary}失败 ${failed} 个;跳过 ${skipped} 个。`);
|
|
559
566
|
writeTargetFailures();
|
|
560
567
|
}
|
|
561
568
|
writeWarnings(write, receipt.warnings);
|
|
@@ -1459,20 +1466,24 @@ export function buildProgram(options = {}) {
|
|
|
1459
1466
|
writeLine(io.stderr, message);
|
|
1460
1467
|
commandExitState.exitCode = failure.code === 'invalidArguments' ? 2 : 1;
|
|
1461
1468
|
};
|
|
1462
|
-
const withResolvedConfigMutationPlugin = (context, selector, consume,
|
|
1469
|
+
const withResolvedConfigMutationPlugin = (context, selector, consume, options) => (async () => {
|
|
1463
1470
|
const parsed = parsePluginId(selector);
|
|
1464
1471
|
return withAwHomeMutationLock({
|
|
1465
1472
|
env: context.env,
|
|
1473
|
+
signal: context.signal,
|
|
1466
1474
|
action: async (awHomeMutationToken) => {
|
|
1467
1475
|
const catalogOperationContext = await resolveCatalogOperationContext({
|
|
1468
1476
|
...(parsed.sourceId ? { sourceIds: [parsed.sourceId] } : {}),
|
|
1469
1477
|
env: context.env,
|
|
1478
|
+
signal: context.signal,
|
|
1470
1479
|
});
|
|
1471
1480
|
return withResolvedCatalogPlugin({
|
|
1472
1481
|
selector,
|
|
1473
1482
|
cliVersion: resolveCliVersion(),
|
|
1474
1483
|
operationContext: catalogOperationContext,
|
|
1475
1484
|
env: context.env,
|
|
1485
|
+
signal: context.signal,
|
|
1486
|
+
retainCompletedResultOnAbort: options?.retainCompletedResultOnAbort,
|
|
1476
1487
|
consume: (resolution) => consume(resolution, awHomeMutationToken, catalogOperationContext),
|
|
1477
1488
|
});
|
|
1478
1489
|
},
|
|
@@ -1898,12 +1909,9 @@ export function buildProgram(options = {}) {
|
|
|
1898
1909
|
.option('--log-file <path>', 'write debug diagnostics to the specified file');
|
|
1899
1910
|
const configMutation = (command) => configCommand(command)
|
|
1900
1911
|
.option('--apply', 'refresh existing affected outputs after saving', false)
|
|
1901
|
-
.option('--native-consent', 'authorize this Gemini operation; may persist source-folder and current-workspace trust', false)
|
|
1902
1912
|
.option('--script-timeout <ms>', 'override plugin preApply timeout in milliseconds')
|
|
1903
1913
|
.option('-y, --yes', 'confirm reviewed output changes', false);
|
|
1904
1914
|
const configContext = async (context, rawOptions, apply = rawOptions.apply === true) => {
|
|
1905
|
-
if (rawOptions.nativeConsent && !apply)
|
|
1906
|
-
throw new WriteCommandRequestError('--native-consent requires --apply or config apply.');
|
|
1907
1915
|
const requested = rawOptions.context === undefined ? apply ? undefined : 'user'
|
|
1908
1916
|
: normalizeWriteRequest(() => parseContextValue(rawOptions.context));
|
|
1909
1917
|
const work = await resolveWorkContext({ cwd: context.cwd, context: requested });
|
|
@@ -2073,20 +2081,20 @@ export function buildProgram(options = {}) {
|
|
|
2073
2081
|
const confirmation = rawOptions.apply ? await preparePublicConfigConfirmation({ plugin, scope: work.context,
|
|
2074
2082
|
context: work.context, platform, cwd: context.cwd, env: context.env, cliVersion: resolveCliVersion(),
|
|
2075
2083
|
nativeCliRunner: context.nativeCliRunner, awHomeMutationToken, yes: rawOptions.yes, mutation,
|
|
2076
|
-
rebuildRuntime: { ...context,
|
|
2084
|
+
rebuildRuntime: { ...context, awHomeMutationToken, catalogOperationContext,
|
|
2077
2085
|
expectedGenerationSetDigest: catalogOperationContext.generationSetDigest } })
|
|
2078
2086
|
: { required: false, provided: rawOptions.yes === true, effects: [] };
|
|
2079
2087
|
const writeReceipt = await applyPluginConfigWrite({ plugin, pluginName: plugin.manifest.name,
|
|
2080
2088
|
scope: work.context, context: work.context, platform, cliVersion: resolveCliVersion(),
|
|
2081
2089
|
cwd: context.cwd, env: context.env, nativeCliRunner: context.nativeCliRunner,
|
|
2082
|
-
rebuildRuntime: { ...context,
|
|
2090
|
+
rebuildRuntime: { ...context, awHomeMutationToken, catalogOperationContext,
|
|
2083
2091
|
expectedGenerationSetDigest: catalogOperationContext.generationSetDigest,
|
|
2084
2092
|
...(scriptTimeoutMs === undefined ? {} : { scriptTimeoutMs }) },
|
|
2085
2093
|
awHomeMutationToken, request: command === 'unset' ? { removeKeys: [key] } : { updates: { [key]: inputValue } },
|
|
2086
2094
|
apply: rawOptions.apply === true, sharedNativeApplyConfirmed: rawOptions.yes === true,
|
|
2087
2095
|
preApplyConfirmed: rawOptions.yes === true });
|
|
2088
2096
|
return buildConfigMutationReceipt(`config:${command}`, {
|
|
2089
|
-
...writeReceipt, confirmation,
|
|
2097
|
+
...writeReceipt, confirmation, ok: writeReceipt.overallState === 'succeeded', plugin: plugin.manifest.name,
|
|
2090
2098
|
pluginName: plugin.manifest.name, pluginId, sourceId: source.sourceId, sourceIdentity: source.sourceIdentity,
|
|
2091
2099
|
context: work, platform: platform ?? 'common',
|
|
2092
2100
|
...(command === 'unset' ? { removedKey: key, existed: true } : {}),
|
|
@@ -2094,7 +2102,7 @@ export function buildProgram(options = {}) {
|
|
|
2094
2102
|
action: command === 'unset' ? 'unset' : 'set', scope: 'user',
|
|
2095
2103
|
...(writeReceipt.staleRemovedKeys?.includes(key) ? { stale: true } : {}) }],
|
|
2096
2104
|
});
|
|
2097
|
-
}
|
|
2105
|
+
}));
|
|
2098
2106
|
if (!receipt)
|
|
2099
2107
|
return;
|
|
2100
2108
|
if (rawOptions.json)
|
|
@@ -2132,7 +2140,7 @@ export function buildProgram(options = {}) {
|
|
|
2132
2140
|
const receipt = await resetPluginConfigWithHelper({ ...located, plugin, pluginError, platform, scope: work.context,
|
|
2133
2141
|
context: work.context, cliVersion: resolveCliVersion(), cwd: context.cwd, env: context.env, awHomeMutationToken,
|
|
2134
2142
|
nativeCliRunner: context.nativeCliRunner, apply: rawOptions.apply === true,
|
|
2135
|
-
rebuildRuntime: { ...context,
|
|
2143
|
+
rebuildRuntime: { ...context, awHomeMutationToken, scriptTimeoutMs: resolveScriptTimeoutMs(rawOptions) },
|
|
2136
2144
|
sharedNativeApplyConfirmed: true, preApplyConfirmed: rawOptions.yes === true });
|
|
2137
2145
|
return { ...receipt, confirmation };
|
|
2138
2146
|
} });
|
|
@@ -2148,7 +2156,7 @@ export function buildProgram(options = {}) {
|
|
|
2148
2156
|
return resetStore(null, error instanceof Error ? error : new Error(String(error)));
|
|
2149
2157
|
}
|
|
2150
2158
|
});
|
|
2151
|
-
const receipt = buildConfigMutationReceipt('config:reset', { ...resetReceipt,
|
|
2159
|
+
const receipt = buildConfigMutationReceipt('config:reset', { ...resetReceipt,
|
|
2152
2160
|
ok: resetReceipt.overallState === 'succeeded', ...located, plugin: located.pluginName,
|
|
2153
2161
|
context: work, platform: platform ?? 'common' });
|
|
2154
2162
|
if (rawOptions.json)
|
|
@@ -2165,30 +2173,59 @@ export function buildProgram(options = {}) {
|
|
|
2165
2173
|
});
|
|
2166
2174
|
contextualCommand(config.command('apply').argument('<plugin>'))
|
|
2167
2175
|
.option('--target <target>', 'limit existing-output refresh to this platform target', collectUniqueOption)
|
|
2168
|
-
.option('--native-consent', 'authorize this Gemini operation; may persist source-folder and current-workspace trust', false)
|
|
2169
2176
|
.option('-y, --yes', 'confirm reviewed output changes', false)
|
|
2170
2177
|
.option('--script-timeout <ms>', 'override plugin preApply timeout in milliseconds')
|
|
2171
2178
|
.action(async (selector, rawOptions) => {
|
|
2172
2179
|
const context = createActionContext('config:apply', rawOptions);
|
|
2173
2180
|
const work = await configContext(context, rawOptions, true);
|
|
2174
2181
|
const targets = rawOptions.target?.map((target) => normalizeWriteRequest(() => parsePlatformTargetValue(target)));
|
|
2182
|
+
let resolved;
|
|
2183
|
+
let confirmed;
|
|
2175
2184
|
const receipt = await runActionWithContext(context, () => withResolvedConfigMutationPlugin(context, selector, async ({ plugin, pluginId, source }, awHomeMutationToken) => {
|
|
2185
|
+
const identity = { plugin: plugin.manifest.name, pluginId, sourceId: source.sourceId };
|
|
2186
|
+
resolved = identity;
|
|
2176
2187
|
const confirmation = await preparePublicConfigConfirmation({ plugin, scope: work.context, context: work.context, targets, cwd: context.cwd, env: context.env, cliVersion: resolveCliVersion(), nativeCliRunner: context.nativeCliRunner, awHomeMutationToken, yes: rawOptions.yes, rebuildRuntime: context });
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2188
|
+
confirmed = confirmation;
|
|
2189
|
+
const applied = await applyPluginConfig({ plugin, scope: work.context, context: work.context, targets,
|
|
2190
|
+
cliVersion: resolveCliVersion(), cwd: context.cwd, env: context.env, awHomeMutationToken,
|
|
2191
|
+
nativeCliRunner: context.nativeCliRunner, sharedNativeApplyConfirmed: rawOptions.yes === true,
|
|
2192
|
+
preApplyConfirmed: rawOptions.yes === true, rebuildRuntime: { ...context, scriptTimeoutMs: resolveScriptTimeoutMs(rawOptions) },
|
|
2193
|
+
}).catch((error) => {
|
|
2194
|
+
if (!(error instanceof ConfigApplyInterruptedError))
|
|
2195
|
+
throw error;
|
|
2196
|
+
const { code, message } = configMutationFailure(error, context.env, context.cwd);
|
|
2197
|
+
return { configWrite: error.configWrite, overallState: 'partial',
|
|
2198
|
+
apply: error.apply, errors: [{ code, message }] };
|
|
2199
|
+
});
|
|
2200
|
+
return { ...applied, ...identity, confirmation, context: work };
|
|
2201
|
+
}, { retainCompletedResultOnAbort: true })).catch((error) => {
|
|
2202
|
+
if (error instanceof CatalogLeaseEscapeError)
|
|
2203
|
+
throw error;
|
|
2204
|
+
const code = recoveryInterruptionCode(error, context.signal);
|
|
2205
|
+
if (!code)
|
|
2206
|
+
throw error;
|
|
2207
|
+
if (!resolved)
|
|
2208
|
+
parsePluginId(selector);
|
|
2209
|
+
const message = code === 'processCleanupUnconfirmed' ? 'Process cleanup could not be confirmed.'
|
|
2210
|
+
: 'The command was interrupted before configuration apply completed.';
|
|
2211
|
+
return { ...(resolved ?? { plugin: selector }), confirmation: confirmed ?? null,
|
|
2212
|
+
context: work, configWrite: 'notStarted',
|
|
2213
|
+
overallState: 'failed', errors: [{ code, message }] };
|
|
2214
|
+
});
|
|
2215
|
+
const result = buildConfigMutationReceipt('config:apply', { ...receipt,
|
|
2186
2216
|
ok: receipt.overallState === 'succeeded' });
|
|
2187
2217
|
if (rawOptions.json)
|
|
2188
2218
|
writeJsonReceipt(io.stdout, result);
|
|
2189
2219
|
else {
|
|
2190
|
-
|
|
2191
|
-
|
|
2220
|
+
const outcome = result.ok ? '完成' : result.overallState === 'partial' ? '部分失败' : '失败';
|
|
2221
|
+
writeLine(io.stdout, `配置应用:${outcome}。`);
|
|
2222
|
+
if ('apply' in result && result.apply) {
|
|
2223
|
+
writeConfigApplyNotice(io.stderr, { ...result, apply: result.apply, warnings: [] });
|
|
2224
|
+
}
|
|
2225
|
+
else if ('errors' in result) {
|
|
2226
|
+
for (const error of result.errors ?? [])
|
|
2227
|
+
writeLine(io.stderr, error.message);
|
|
2228
|
+
}
|
|
2192
2229
|
}
|
|
2193
2230
|
commandExitState.exitCode = result.ok ? 0 : 1;
|
|
2194
2231
|
});
|
|
@@ -2333,8 +2370,7 @@ function configurePublicCommands(program, options, io, exit) {
|
|
|
2333
2370
|
.option('--keep-dependencies', 'Keep orphan dependency output during normal removal')
|
|
2334
2371
|
.option('--force', 'Bypass the dependency guard; with --only outputs, recover provably owned damaged output');
|
|
2335
2372
|
if (name !== 'remove')
|
|
2336
|
-
cmd.option('--script-timeout <ms>', 'Plugin script timeout')
|
|
2337
|
-
.option('--native-consent', 'Authorize this Gemini operation; may persist source-folder and current-workspace trust');
|
|
2373
|
+
cmd.option('--script-timeout <ms>', 'Plugin script timeout');
|
|
2338
2374
|
if (name === 'sync')
|
|
2339
2375
|
cmd.option('--rebuild', 'Rebuild selected owned output').option('--refresh', 'Refresh required Catalog sources');
|
|
2340
2376
|
cmd.action(async (plugins, raw) => {
|
|
@@ -2526,12 +2562,13 @@ export async function runCli(argv, options = {}) {
|
|
|
2526
2562
|
const resolvedCommand = resolveRegisteredCommand(program, awArgs);
|
|
2527
2563
|
const selected = resolvedCommand.command;
|
|
2528
2564
|
const id = selected && selected !== program ? commandId(selected) : null;
|
|
2529
|
-
const controlledInterrupt = ['plugin.install', 'plugin.remove', 'plugin.sync',
|
|
2565
|
+
const controlledInterrupt = ['plugin.install', 'plugin.remove', 'plugin.sync', 'plugin.config.apply',
|
|
2530
2566
|
'dev.plugin.create', 'dev.plugin.validate', 'dev.plugin.remove', 'dev.plugin.status',
|
|
2531
2567
|
'dev.skill.create', 'dev.skill.validate'].includes(id ?? '');
|
|
2532
2568
|
if (controlledInterrupt) {
|
|
2533
2569
|
commandOptions.interruption = interruption;
|
|
2534
|
-
commandOptions.signal =
|
|
2570
|
+
commandOptions.signal = id === 'plugin.config.apply' && options.signal
|
|
2571
|
+
? AbortSignal.any([options.signal, interruption.signal]) : interruption.signal;
|
|
2535
2572
|
}
|
|
2536
2573
|
if (id === 'command.run' && !presentation.help)
|
|
2537
2574
|
return runManagedCommandCli(['run', ...argv.slice(resolvedCommand.index + 1)], { ...context, interactive: false }, { cliEntry: fileURLToPath(import.meta.url), cliVersion: resolveCliVersion() });
|
|
@@ -2545,13 +2582,23 @@ export async function runCli(argv, options = {}) {
|
|
|
2545
2582
|
argv: ['aw', 'dev', 'catalog', 'create', ...(typeof workspaceRoot === 'string' ? ['--workspace-root', workspaceRoot] : [])],
|
|
2546
2583
|
reason: 'Create a Catalog Workspace explicitly before running authoring commands.', requiresConfirmation: false });
|
|
2547
2584
|
}
|
|
2585
|
+
interruption.cleanupFailed ||= result.diagnostics.some((entry) => entry.code === 'processCleanupUnconfirmed');
|
|
2586
|
+
if (interruption.exitCode || interruption.cleanupFailed) {
|
|
2587
|
+
const code = interruption.cleanupFailed ? 'processCleanupUnconfirmed' : 'operationInterrupted';
|
|
2588
|
+
if (!result.diagnostics.some((entry) => entry.code === code && !entry.subject)) {
|
|
2589
|
+
result.diagnostics.push({ code, severity: 'error', message: interruption.cleanupFailed
|
|
2590
|
+
? 'Process cleanup could not be confirmed.'
|
|
2591
|
+
: 'The command was interrupted. Completed changes are retained in the result.' });
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2548
2594
|
io.stdout(json ? `${JSON.stringify(result)}\n` : renderPublicResult(result, awArgs.includes('--verbose') || awArgs.includes('-v')));
|
|
2549
2595
|
for (const diagnostic of result.diagnostics)
|
|
2550
|
-
|
|
2596
|
+
if (json || diagnostic.code !== SKILL_INVOCATION_NOTICE)
|
|
2597
|
+
io.stderr(`${diagnostic.code}: ${diagnostic.message}\n`);
|
|
2551
2598
|
if (options.diagnostics?.verbose || awArgs.includes('--verbose'))
|
|
2552
2599
|
for (const line of stderr)
|
|
2553
2600
|
io.stderr(`${safePublicMessage(line.trim())}\n`);
|
|
2554
|
-
return interruption.
|
|
2601
|
+
return interruption.cleanupFailed ? 1 : interruption.exitCode ?? publicExitCode(result, invalid);
|
|
2555
2602
|
};
|
|
2556
2603
|
if (presentation.version)
|
|
2557
2604
|
return emit(commandResult('version', { version: resolveCliVersion(), resultSchemaVersion: CLI_OUTPUT_SCHEMA_VERSION }));
|
|
@@ -2584,16 +2631,26 @@ export async function runCli(argv, options = {}) {
|
|
|
2584
2631
|
return emit(commandResult('tui', {}, { status: 'failed', diagnostics: [{ code: 'invalidOptionCombination', severity: 'error', message: 'tui cannot use --json.' }] }), true);
|
|
2585
2632
|
if (!context.interactive)
|
|
2586
2633
|
return emit(commandResult('tui', {}, { status: 'blocked', diagnostics: [{ code: 'interactiveTerminalRequired', severity: 'error', message: 'The TUI requires an interactive terminal.' }] }));
|
|
2587
|
-
const tuiContext = createCliExecutionContext({ ...options, io,
|
|
2634
|
+
const tuiContext = createCliExecutionContext({ ...options, io, interruption,
|
|
2635
|
+
signal: options.signal ? AbortSignal.any([options.signal, interruption.signal]) : interruption.signal, diagnostics: toCliDiagnosticsOptions('console', bareOptions ?? {}, options.diagnostics) });
|
|
2636
|
+
const stopListening = interruption.listen();
|
|
2588
2637
|
try {
|
|
2589
2638
|
return await runActionWithContext(tuiContext, async () => {
|
|
2590
2639
|
const { runConsoleController } = await import('./commands/console.js');
|
|
2591
|
-
|
|
2640
|
+
const code = await runConsoleController(tuiContext);
|
|
2641
|
+
if (interruption.cleanupFailed) {
|
|
2642
|
+
io.stderr('processCleanupUnconfirmed: Process cleanup could not be confirmed.\n');
|
|
2643
|
+
return 1;
|
|
2644
|
+
}
|
|
2645
|
+
return interruption.exitCode ?? code;
|
|
2592
2646
|
});
|
|
2593
2647
|
}
|
|
2594
2648
|
catch (error) {
|
|
2595
2649
|
return emit(commandResult('tui', {}, { status: 'failed', diagnostics: [{ code: 'tuiFailed', severity: 'error', message: safePublicMessage(error instanceof Error ? error.message : String(error)) }] }));
|
|
2596
2650
|
}
|
|
2651
|
+
finally {
|
|
2652
|
+
stopListening();
|
|
2653
|
+
}
|
|
2597
2654
|
}
|
|
2598
2655
|
// Only these adapters carry cancellation through every long-running child.
|
|
2599
2656
|
// Other routes retain Node's normal signal termination until their domain
|
|
@@ -2659,8 +2716,6 @@ export async function runCli(argv, options = {}) {
|
|
|
2659
2716
|
io.stderr(redactString(logs.stderr));
|
|
2660
2717
|
}
|
|
2661
2718
|
const result = projectReceipt(id, receipt, { yes: awArgs.includes('--yes') || awArgs.includes('-y'), exitCode, confirmation });
|
|
2662
|
-
if (interruption.exitCode)
|
|
2663
|
-
result.diagnostics.push({ code: interruption.cleanupFailed ? 'processCleanupUnconfirmed' : 'operationInterrupted', severity: 'error', message: interruption.cleanupFailed ? 'Process cleanup could not be confirmed after interruption.' : 'The command was interrupted. Completed changes are retained in the result.' });
|
|
2664
2719
|
if (result.status === 'success' && ['dev.plugin.create', 'dev.skill.create'].includes(id)) {
|
|
2665
2720
|
const data = result.data;
|
|
2666
2721
|
const name = typeof data.pluginName === 'string' ? data.pluginName : selected?.args[0];
|