@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.
Files changed (190) hide show
  1. package/dist/authoring/assets/aw-runtime-config.mjs +1 -1
  2. package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -1
  3. package/dist/src/commands/console.js +1 -0
  4. package/dist/src/commands/console.js.map +1 -1
  5. package/dist/src/commands/intent-command.d.ts +1 -0
  6. package/dist/src/commands/intent-command.js +6 -2
  7. package/dist/src/commands/intent-command.js.map +1 -1
  8. package/dist/src/commands/plugin-capabilities.js +3 -3
  9. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  10. package/dist/src/commands/public-lifecycle-result.d.ts +11 -5
  11. package/dist/src/commands/public-lifecycle-result.js +131 -46
  12. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  13. package/dist/src/commands/public-lifecycle.d.ts +1 -2
  14. package/dist/src/commands/public-lifecycle.js +56 -34
  15. package/dist/src/commands/public-lifecycle.js.map +1 -1
  16. package/dist/src/commands/public-plugin-query.js +28 -11
  17. package/dist/src/commands/public-plugin-query.js.map +1 -1
  18. package/dist/src/commands/rebuild-command.d.ts +13 -3
  19. package/dist/src/commands/rebuild-command.js +647 -286
  20. package/dist/src/commands/rebuild-command.js.map +1 -1
  21. package/dist/src/commands/rebuild-integration.d.ts +5 -2
  22. package/dist/src/commands/rebuild-integration.js +55 -29
  23. package/dist/src/commands/rebuild-integration.js.map +1 -1
  24. package/dist/src/commands/rebuild-operations.d.ts +1 -0
  25. package/dist/src/commands/rebuild-operations.js +23 -4
  26. package/dist/src/commands/rebuild-operations.js.map +1 -1
  27. package/dist/src/commands/rebuild-platform-integration.d.ts +14 -3
  28. package/dist/src/commands/rebuild-platform-integration.js +240 -137
  29. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  30. package/dist/src/index.js +105 -50
  31. package/dist/src/index.js.map +1 -1
  32. package/dist/src/output/public-result.d.ts +2 -0
  33. package/dist/src/output/public-result.js +43 -6
  34. package/dist/src/output/public-result.js.map +1 -1
  35. package/dist/src/output/rebuild-progress.d.ts +3 -0
  36. package/dist/src/output/rebuild-progress.js +12 -2
  37. package/dist/src/output/rebuild-progress.js.map +1 -1
  38. package/dist/src/output/receipt-projection.js +55 -18
  39. package/dist/src/output/receipt-projection.js.map +1 -1
  40. package/dist/src/output/skill-invocation-notices.d.ts +16 -0
  41. package/dist/src/output/skill-invocation-notices.js +48 -0
  42. package/dist/src/output/skill-invocation-notices.js.map +1 -0
  43. package/dist/src/platforms/capabilities.d.ts +2 -0
  44. package/dist/src/platforms/capabilities.js +73 -34
  45. package/dist/src/platforms/capabilities.js.map +1 -1
  46. package/dist/src/platforms/contracts.d.ts +9 -9
  47. package/dist/src/platforms/discovery.d.ts +0 -7
  48. package/dist/src/platforms/discovery.js +13 -53
  49. package/dist/src/platforms/discovery.js.map +1 -1
  50. package/dist/src/platforms/inspection-native.js +1 -80
  51. package/dist/src/platforms/inspection-native.js.map +1 -1
  52. package/dist/src/platforms/inspection-query.d.ts +2 -3
  53. package/dist/src/platforms/inspection-query.js +7 -18
  54. package/dist/src/platforms/inspection-query.js.map +1 -1
  55. package/dist/src/platforms/inspection.js +2 -2
  56. package/dist/src/platforms/inspection.js.map +1 -1
  57. package/dist/src/platforms/layout.js +1 -5
  58. package/dist/src/platforms/layout.js.map +1 -1
  59. package/dist/src/platforms/lifecycle-native-services.d.ts +1 -1
  60. package/dist/src/platforms/lifecycle-native-services.js +14 -14
  61. package/dist/src/platforms/lifecycle-native-services.js.map +1 -1
  62. package/dist/src/platforms/lifecycle-native.js +4 -88
  63. package/dist/src/platforms/lifecycle-native.js.map +1 -1
  64. package/dist/src/platforms/lifecycle.js +56 -56
  65. package/dist/src/platforms/lifecycle.js.map +1 -1
  66. package/dist/src/platforms/projection-code-extension.js +7 -3
  67. package/dist/src/platforms/projection-code-extension.js.map +1 -1
  68. package/dist/src/platforms/projection.d.ts +3 -0
  69. package/dist/src/platforms/projection.js +86 -54
  70. package/dist/src/platforms/projection.js.map +1 -1
  71. package/dist/src/portable/materializer.js +2 -2
  72. package/dist/src/portable/materializer.js.map +1 -1
  73. package/dist/src/portable/recovery.d.ts +29 -3
  74. package/dist/src/portable/recovery.js +220 -78
  75. package/dist/src/portable/recovery.js.map +1 -1
  76. package/dist/src/recovery/coordinator.d.ts +21 -5
  77. package/dist/src/recovery/coordinator.js +383 -151
  78. package/dist/src/recovery/coordinator.js.map +1 -1
  79. package/dist/src/recovery/install-concurrency.d.ts +48 -0
  80. package/dist/src/recovery/install-concurrency.js +195 -0
  81. package/dist/src/recovery/install-concurrency.js.map +1 -0
  82. package/dist/src/recovery/interruption.d.ts +19 -0
  83. package/dist/src/recovery/interruption.js +43 -0
  84. package/dist/src/recovery/interruption.js.map +1 -0
  85. package/dist/src/recovery/joint-coordinator.d.ts +11 -4
  86. package/dist/src/recovery/joint-coordinator.js +681 -333
  87. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  88. package/dist/src/recovery/joint-demand.d.ts +8 -0
  89. package/dist/src/recovery/joint-demand.js +52 -1
  90. package/dist/src/recovery/joint-demand.js.map +1 -1
  91. package/dist/src/recovery/joint-install-execution.d.ts +19 -0
  92. package/dist/src/recovery/joint-install-execution.js +307 -0
  93. package/dist/src/recovery/joint-install-execution.js.map +1 -0
  94. package/dist/src/recovery/joint-install-native-rebase.d.ts +4 -0
  95. package/dist/src/recovery/joint-install-native-rebase.js +67 -0
  96. package/dist/src/recovery/joint-install-native-rebase.js.map +1 -0
  97. package/dist/src/recovery/receipt.d.ts +20 -0
  98. package/dist/src/recovery/receipt.js +67 -1
  99. package/dist/src/recovery/receipt.js.map +1 -1
  100. package/dist/src/recovery/retirement.js +1 -1
  101. package/dist/src/recovery/retirement.js.map +1 -1
  102. package/dist/src/recovery/status.js +26 -27
  103. package/dist/src/recovery/status.js.map +1 -1
  104. package/dist/src/review/platform-profile.d.ts +4 -1
  105. package/dist/src/review/platform-profile.js +13 -4
  106. package/dist/src/review/platform-profile.js.map +1 -1
  107. package/dist/src/review/skill-materialization.d.ts +1 -0
  108. package/dist/src/review/skill-materialization.js +28 -16
  109. package/dist/src/review/skill-materialization.js.map +1 -1
  110. package/dist/src/review/source-binding.js +6 -4
  111. package/dist/src/review/source-binding.js.map +1 -1
  112. package/dist/src/tui/catalog-generation.d.ts +6 -0
  113. package/dist/src/tui/catalog-generation.js +22 -6
  114. package/dist/src/tui/catalog-generation.js.map +1 -1
  115. package/dist/src/tui/console-app-v4.d.ts +1 -1
  116. package/dist/src/tui/console-app-v4.js +139 -59
  117. package/dist/src/tui/console-app-v4.js.map +1 -1
  118. package/dist/src/tui/controller-runtime.js +145 -53
  119. package/dist/src/tui/controller-runtime.js.map +1 -1
  120. package/dist/src/tui/controller.d.ts +13 -4
  121. package/dist/src/tui/controller.js +241 -102
  122. package/dist/src/tui/controller.js.map +1 -1
  123. package/dist/src/tui/deployment-view.js +6 -1
  124. package/dist/src/tui/deployment-view.js.map +1 -1
  125. package/dist/src/tui/diagnostic-projection.d.ts +4 -2
  126. package/dist/src/tui/diagnostic-projection.js +40 -4
  127. package/dist/src/tui/diagnostic-projection.js.map +1 -1
  128. package/dist/src/tui/glossary.js +1 -0
  129. package/dist/src/tui/glossary.js.map +1 -1
  130. package/dist/src/tui/operation-diagnostic-screens.d.ts +1 -1
  131. package/dist/src/tui/operation-diagnostic-screens.js +3 -1
  132. package/dist/src/tui/operation-diagnostic-screens.js.map +1 -1
  133. package/dist/src/tui/operation-history.d.ts +6 -3
  134. package/dist/src/tui/operation-history.js +15 -2
  135. package/dist/src/tui/operation-history.js.map +1 -1
  136. package/dist/src/tui/scoped-flow.d.ts +3 -1
  137. package/dist/src/tui/scoped-flow.js +99 -1
  138. package/dist/src/tui/scoped-flow.js.map +1 -1
  139. package/dist/src/tui/session-console-app.d.ts +2 -0
  140. package/dist/src/tui/session-console-app.js +11 -0
  141. package/dist/src/tui/session-console-app.js.map +1 -1
  142. package/dist/src/types.d.ts +8 -1
  143. package/dist/src/types.js.map +1 -1
  144. package/dist/src/utils/aw-home-mutation-lock.js +2 -1
  145. package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
  146. package/dist/src/utils/catalog-generation-resolver.d.ts +1 -0
  147. package/dist/src/utils/catalog-generation-resolver.js +1 -0
  148. package/dist/src/utils/catalog-generation-resolver.js.map +1 -1
  149. package/dist/src/utils/catalog-operation-context.d.ts +11 -0
  150. package/dist/src/utils/catalog-operation-context.js +18 -3
  151. package/dist/src/utils/catalog-operation-context.js.map +1 -1
  152. package/dist/src/utils/catalog-source-references.js +2 -14
  153. package/dist/src/utils/catalog-source-references.js.map +1 -1
  154. package/dist/src/utils/component-resources.js +1 -1
  155. package/dist/src/utils/component-resources.js.map +1 -1
  156. package/dist/src/utils/managed-command-materialization.d.ts +2 -1
  157. package/dist/src/utils/managed-command-materialization.js +3 -3
  158. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  159. package/dist/src/utils/managed-command-store.d.ts +6 -0
  160. package/dist/src/utils/managed-command-store.js +90 -18
  161. package/dist/src/utils/managed-command-store.js.map +1 -1
  162. package/dist/src/utils/multi-source-catalog.d.ts +2 -0
  163. package/dist/src/utils/multi-source-catalog.js +3 -2
  164. package/dist/src/utils/multi-source-catalog.js.map +1 -1
  165. package/dist/src/utils/native-cli.d.ts +0 -19
  166. package/dist/src/utils/native-cli.js +2 -42
  167. package/dist/src/utils/native-cli.js.map +1 -1
  168. package/dist/src/utils/ownership.js +1 -1
  169. package/dist/src/utils/ownership.js.map +1 -1
  170. package/dist/src/utils/platform-empty-state.d.ts +1 -3
  171. package/dist/src/utils/platform-empty-state.js +1 -6
  172. package/dist/src/utils/platform-empty-state.js.map +1 -1
  173. package/dist/src/utils/plugin-config-write.d.ts +8 -0
  174. package/dist/src/utils/plugin-config-write.js +89 -25
  175. package/dist/src/utils/plugin-config-write.js.map +1 -1
  176. package/dist/src/utils/plugin-scripts.js +5 -0
  177. package/dist/src/utils/plugin-scripts.js.map +1 -1
  178. package/dist/src/utils/skill-invocation-warning.d.ts +15 -0
  179. package/dist/src/utils/skill-invocation-warning.js +42 -0
  180. package/dist/src/utils/skill-invocation-warning.js.map +1 -0
  181. package/package.json +3 -3
  182. package/dist/src/output/native-consent.d.ts +0 -2
  183. package/dist/src/output/native-consent.js +0 -5
  184. package/dist/src/output/native-consent.js.map +0 -1
  185. package/dist/src/platforms/gemini-activation.d.ts +0 -36
  186. package/dist/src/platforms/gemini-activation.js +0 -331
  187. package/dist/src/platforms/gemini-activation.js.map +0 -1
  188. package/dist/src/platforms/gemini-consent.d.ts +0 -8
  189. package/dist/src/platforms/gemini-consent.js +0 -81
  190. package/dist/src/platforms/gemini-consent.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { ConfigReferenceContext, ConfigReferenceDraft } from './config-references.js';
2
- import type { CatalogActivationMode, CatalogSource, CatalogGenerationActiveV1, CatalogGenerationCandidateEvidence, CatalogGenerationSyncResult, CatalogSourceImpact, CommandProducerResult, DependencyScopeOverride, PlatformName, PlatformTarget, Scope } from '../types.js';
2
+ import type { CatalogActivationMode, CatalogSource, CatalogGenerationActiveV1, CatalogGenerationCandidateEvidence, CatalogGenerationSyncResult, CatalogSourceImpact, CommandProducerResult, ConfigApplyResult, DependencyScopeOverride, PlatformName, PlatformTarget, Scope } from '../types.js';
3
3
  import type { PortableReview, PortableInstallReceipt, PortableRetryReview } from '../portable/commands.js';
4
4
  import type { CatalogSourceUpdate } from '../utils/catalog-sources.js';
5
5
  import type { CatalogGenerationFreshnessState, CatalogGenerationFreshnessResult } from '../utils/catalog-generation-service.js';
@@ -11,12 +11,13 @@ import type { CodexReconcilePlan } from '../utils/codex-reconciler.js';
11
11
  import type { PluginConfigMutationImpact } from '../utils/plugin-config-impact.js';
12
12
  import type { OperationPlan } from '../commands/operation-plan.js';
13
13
  import type { RebuildProgressFeed, RebuildProgressSnapshot } from '../output/rebuild-progress.js';
14
+ import type { Diagnostic } from '../output/public-result.js';
14
15
  import { type ConfigPageViewModel, type ConfigProfileOptions, type ConfigReadOptions, type ConfigProfileKey, type ConfigGroupViewModel, type InstallPlacementDraftViewModel, type PluginListItemViewModel, type PluginDependencyOverviewViewModel, type PortableSkillSelectionViewModel, type SourceHealthViewModel, type SourceDetailViewModel, type TuiViewModel, type UserIssueCategory, type UserIssueViewModel } from './model.js';
15
16
  import type { PluginContentOverview } from './plugin-content.js';
16
17
  import { type PluginDetailSubject } from './plugin-detail.js';
17
18
  import { OperationHistoryStore, type OperationDiagnosticDetail, type OperationEffectFacts, type OperationHistorySummary, type OperationReportPreview, type SafeOperationDiagnostic, type SaveOperationReportResult } from './operation-history.js';
18
19
  import { type ScopedInventoryViewModel, type ScopedInventoryLoadResult, type InventoryRoot } from './scoped-inventory.js';
19
- import type { ScopedTuiPlan } from './scoped-flow.js';
20
+ import { type ScopedTuiPlan } from './scoped-flow.js';
20
21
  import type { RecoveryReceipt } from '../recovery/receipt.js';
21
22
  import type { RecoveryCommand } from '../recovery/coordinator.js';
22
23
  import type { AgentId } from '../intent/deployment-preferences.js';
@@ -152,10 +153,10 @@ export interface ConfigSaveBatchGroup {
152
153
  export interface ConfigSaveBatchGroupResult {
153
154
  scope: 'user';
154
155
  platform?: PlatformTarget;
155
- status: 'succeeded' | 'failed';
156
+ status: 'succeeded' | 'failed' | 'notStarted';
156
157
  configSaved: boolean;
157
158
  applyRequested: boolean;
158
- applyStatus: 'notRequested' | 'notNeeded' | 'succeeded' | 'failed';
159
+ applyStatus: 'notRequested' | 'notStarted' | 'notNeeded' | 'succeeded' | 'partial' | 'failed';
159
160
  errorCode?: string;
160
161
  execution?: unknown;
161
162
  }
@@ -556,6 +557,7 @@ export interface OperationResultSummary {
556
557
  elapsedMs?: number;
557
558
  messages?: string[];
558
559
  configApplied?: boolean;
560
+ configDiagnostics?: Diagnostic[];
559
561
  configApplySkippedReason?: 'invalidConfig';
560
562
  configScope?: Scope;
561
563
  configPlatform?: PlatformTarget;
@@ -565,9 +567,13 @@ export interface OperationResultSummary {
565
567
  platform: PlatformTarget;
566
568
  scope: Scope;
567
569
  state: 'completed' | 'kept' | 'failed' | 'skipped';
570
+ partialDelivery?: true;
568
571
  errorCode?: string;
572
+ diagnosticIds?: string[];
573
+ effects?: OperationEffectFacts;
569
574
  }>;
570
575
  configApplyRetryAvailable?: boolean;
576
+ configApplyRetryTargets?: PlatformTarget[];
571
577
  configRetryApply?: boolean;
572
578
  configGroups?: Array<{
573
579
  scope: Scope;
@@ -575,6 +581,8 @@ export interface OperationResultSummary {
575
581
  configSaved: boolean;
576
582
  applyRequested: boolean;
577
583
  applyStatus: ConfigSaveBatchGroupResult['applyStatus'];
584
+ notStarted?: true;
585
+ retryTargets?: PlatformTarget[];
578
586
  errorCode?: string;
579
587
  }>;
580
588
  resetDisposition?: 'absent' | 'deletedFile' | 'unlinkedSymlink' | 'quarantinedDirectory';
@@ -1026,3 +1034,4 @@ export declare class TuiController {
1026
1034
  executeOperation(reviewToken: string): Promise<OperationExecuteResult>;
1027
1035
  dispose(): void;
1028
1036
  }
1037
+ export declare function configApplyHasCompletedWork(apply: ConfigApplyResult | undefined): boolean;
@@ -4,18 +4,22 @@ import crypto from 'node:crypto';
4
4
  import { CatalogGenerationError } from '../utils/catalog-generation-error.js';
5
5
  import { readSafeOperationError } from '../utils/safe-operation-diagnostic.js';
6
6
  import { NativeCliError } from '../utils/native-cli.js';
7
+ import { ConfigApplyInterruptedError } from '../utils/plugin-config-write.js';
8
+ import { parsePluginId } from '../utils/multi-source-catalog.js';
7
9
  import { flattenStatusTargets, statusTargetActivation, statusTargetIntent, statusTargetOwnershipState, statusTargetSharedNative, } from '../commands/status-v6.js';
8
10
  import { buildRebuildReceiptJson, requestedIntentAction } from '../output/command-receipt.js';
11
+ import { SKILL_INVOCATION_NOTICE } from '../utils/skill-invocation-warning.js';
9
12
  import { buildOperationResultModel } from '../commands/operation-planner.js';
10
13
  import { buildOperationReviewProjection } from './operation-review-planner.js';
11
14
  import { buildTuiViewModel, dependencyPlacementTargets, hasScopedExtensionOwnership, } from './model.js';
12
15
  import { buildPluginDetailSubject } from './plugin-detail.js';
13
16
  import { safeDiagnosticCode, sanitizeDiagnosticText } from './diagnostics.js';
14
- import { projectExecutionDiagnostics, projectThrownOperationDiagnostic } from './diagnostic-projection.js';
17
+ import { projectExecutionDiagnostics, projectSkillInvocationHistory, projectThrownOperationDiagnostic } from './diagnostic-projection.js';
15
18
  import { OperationHistoryStore, } from './operation-history.js';
16
19
  import { targetHasArtifactCollision } from '../utils/target-eligibility.js';
17
20
  import { hasStatusInstallationEvidence } from './scoped-inventory.js';
18
21
  import { buildScopedInventory } from './scoped-inventory.js';
22
+ import { projectScopedRecoveryHistory } from './scoped-flow.js';
19
23
  import { TuiRouter, } from './router.js';
20
24
  import { normalizeTuiRoute } from './screen-registry.js';
21
25
  import { CatalogSourcesSession } from './catalog-sources/session.js';
@@ -401,6 +405,9 @@ function sanitizeOperationSummary(summary, sensitiveValues) {
401
405
  ...(summary.messages ? { messages: summary.messages.map(text) } : {}),
402
406
  ...(summary.changes ? { changes: summary.changes.map(text) } : {}),
403
407
  ...(summary.warnings ? { warnings: summary.warnings.map(text) } : {}),
408
+ ...(summary.configDiagnostics ? { configDiagnostics: summary.configDiagnostics.map((diagnostic) => ({
409
+ ...diagnostic, message: text(diagnostic.message),
410
+ })) } : {}),
404
411
  ...(summary.recoveryActions ? { recoveryActions: summary.recoveryActions.map(text) } : {}),
405
412
  ...(summary.commandResults ? { commandResults: summary.commandResults.map((result) => ({
406
413
  ...result,
@@ -718,7 +725,7 @@ export class TuiController {
718
725
  });
719
726
  if (progressFeed) {
720
727
  this.#progressUnsubscribe = progressFeed.subscribe((progress) => {
721
- if (this.#router.snapshot.current.route.name === 'result')
728
+ if (this.#router.snapshot.current.route.name === 'result' && !this.#scopedTaskInflight)
722
729
  return;
723
730
  this.#progress = {
724
731
  ...structuredClone(progress),
@@ -964,16 +971,20 @@ export class TuiController {
964
971
  finalVerification: result.state === 'succeeded' ? 'completed' : 'unknown',
965
972
  },
966
973
  };
967
- if ('summary' in result && result.summary) {
968
- Object.assign(result.summary, sanitizeOperationSummary(result.summary, projected.sensitiveValues ?? []));
969
- }
970
- const diagnosticIds = projected.diagnostics.map((diagnostic) => diagnostic.id);
974
+ const summary = 'summary' in result ? result.summary : undefined;
975
+ if (summary) {
976
+ Object.assign(summary, sanitizeOperationSummary(summary, projected.sensitiveValues ?? []));
977
+ }
978
+ const diagnostics = [...projected.diagnostics,
979
+ ...projectSkillInvocationHistory(summary?.configDiagnostics ?? [], recordId, 'apply')];
980
+ const diagnosticIds = diagnostics.map((diagnostic) => diagnostic.id);
981
+ const targets = summary ? summary.targets ?? summary.configTargets ?? [] : projected.targets ?? [];
971
982
  Object.assign(result, { operationRecordId: recordId, diagnosticIds, effects: projected.effects });
972
- if ('summary' in result && result.summary) {
973
- result.summary.diagnosticIds = diagnosticIds;
974
- result.summary.effects = projected.effects;
975
- for (const target of result.summary.targets ?? []) {
976
- const targetDiagnostics = projected.diagnostics.filter((diagnostic) => diagnostic.target
983
+ if (summary) {
984
+ summary.diagnosticIds = diagnosticIds;
985
+ summary.effects = projected.effects;
986
+ for (const target of targets) {
987
+ const targetDiagnostics = diagnostics.filter((diagnostic) => diagnostic.target
977
988
  && diagnostic.target.platform === target.platform
978
989
  && diagnostic.target.scope === target.scope
979
990
  && (diagnostic.target.pluginId === undefined || diagnostic.target.pluginId === target.pluginId));
@@ -996,16 +1007,11 @@ export class TuiController {
996
1007
  message,
997
1008
  ...('operationKind' in result && result.operationKind ? { operationKind: result.operationKind } : {}),
998
1009
  ...('pluginId' in result && result.pluginId ? { pluginId: result.pluginId } : {}),
999
- diagnosticCount: projected.diagnostics.length,
1010
+ diagnosticCount: diagnostics.length,
1000
1011
  effects: projected.effects,
1001
1012
  },
1002
- diagnostics: projected.diagnostics,
1003
- targets: 'summary' in result && result.summary
1004
- ? structuredClone((result.summary.targets ?? []).map((target) => ({
1005
- ...target,
1006
- diagnosticIds: target.diagnosticIds ?? [],
1007
- })))
1008
- : structuredClone(projected.targets ?? []),
1013
+ diagnostics,
1014
+ targets: targets.map((target) => ({ ...target, diagnosticIds: target.diagnosticIds ?? [] })),
1009
1015
  }, { sensitiveValues: projected.sensitiveValues });
1010
1016
  this.#operationDiagnostics.delete(result.operationId);
1011
1017
  this.#lastRecordedResultId = recordId;
@@ -1023,7 +1029,7 @@ export class TuiController {
1023
1029
  stage,
1024
1030
  fallbackCode: code,
1025
1031
  sensitiveValues,
1026
- ...(intent && 'pluginId' in intent && 'platform' in intent
1032
+ ...(!(error instanceof ConfigApplyInterruptedError) && intent && 'pluginId' in intent && 'platform' in intent
1027
1033
  && (intent.platform === 'codex' || intent.platform === 'claude')
1028
1034
  && (intent.scope === 'user' || intent.scope === 'project')
1029
1035
  ? { target: { pluginId: intent.pluginId, platform: intent.platform, scope: intent.scope } }
@@ -1542,6 +1548,8 @@ export class TuiController {
1542
1548
  this.#pluginContentInflight.clear();
1543
1549
  this.#phase = 'loading';
1544
1550
  this.#publish();
1551
+ if (!this.#operationIsCurrent(generation))
1552
+ return;
1545
1553
  let status;
1546
1554
  try {
1547
1555
  status = await this.#trackRead(this.dependencies.loadStatus(this.#abort.signal));
@@ -1551,6 +1559,8 @@ export class TuiController {
1551
1559
  return;
1552
1560
  const code = issueCode(error);
1553
1561
  await this.#logErrorSafe(error, code);
1562
+ if (!this.#operationIsCurrent(generation))
1563
+ return;
1554
1564
  this.#phase = 'error';
1555
1565
  this.#loadError = { code, message: '无法安全读取插件状态。请检查诊断后重试或退出。' };
1556
1566
  this.#recordStandaloneFailure(code, 'statusReload', error);
@@ -1657,9 +1667,29 @@ export class TuiController {
1657
1667
  this.#progressFeed?.clearCurrent();
1658
1668
  this.#progress = { messages: [], startedAtMs: this.dependencies.now?.() ?? Date.now() };
1659
1669
  this.#publish();
1660
- const promise = this.dependencies.executeScopedTask(plan).finally(() => {
1670
+ const isBatch = plan.kind === 'recovery' && (plan.plan.command === 'install' || plan.plan.command === 'sync')
1671
+ && plan.plan.receipt.requestedTargets.length > 1;
1672
+ const promise = this.dependencies.executeScopedTask(plan).then((outcome) => {
1673
+ const recordByDefault = isBatch || this.#progress.installProgress !== undefined;
1674
+ if (outcome.kind === 'recovery' && (recordByDefault || outcome.receipt.targetResults.some(({ reasons }) => reasons?.some(({ code }) => code === SKILL_INVOCATION_NOTICE)))) {
1675
+ const operationId = `scoped-${crypto.randomUUID()}`;
1676
+ const record = projectScopedRecoveryHistory(outcome.receipt, {
1677
+ operationId, recordId: `${this.#sessionEpoch}:${operationId}`, epoch: this.#sessionEpoch,
1678
+ createdAtMs: this.dependencies.now?.() ?? Date.now(),
1679
+ });
1680
+ if (recordByDefault || record.diagnostics.some(({ code }) => code === SKILL_INVOCATION_NOTICE)) {
1681
+ this.#operationHistory.record(record);
1682
+ }
1683
+ }
1684
+ return outcome;
1685
+ }, (error) => {
1686
+ if (isBatch || this.#progress.installProgress)
1687
+ this.#recordStandaloneFailure(issueCode(error), 'execute', error);
1688
+ throw error;
1689
+ }).finally(() => {
1661
1690
  if (this.#scopedTaskInflight?.promise === promise)
1662
1691
  this.#scopedTaskInflight = undefined;
1692
+ this.#publish();
1663
1693
  });
1664
1694
  this.#scopedTaskInflight = { plan, promise };
1665
1695
  return promise;
@@ -3081,6 +3111,8 @@ export class TuiController {
3081
3111
  const generation = ++this.#generation;
3082
3112
  this.#phase = 'loading';
3083
3113
  this.#publish();
3114
+ if (!this.#operationIsCurrent(generation))
3115
+ return false;
3084
3116
  try {
3085
3117
  const status = await this.#trackRead(this.dependencies.loadStatus(this.#abort.signal));
3086
3118
  if (this.#disposed || generation !== this.#generation)
@@ -3097,6 +3129,8 @@ export class TuiController {
3097
3129
  return false;
3098
3130
  const code = issueCode(error);
3099
3131
  await this.#logErrorSafe(error, code);
3132
+ if (!this.#operationIsCurrent(generation))
3133
+ return false;
3100
3134
  this.#phase = 'error';
3101
3135
  this.#loadError = { code, message: '无法安全重新加载 Catalog。请检查诊断后重试。' };
3102
3136
  this.#publish();
@@ -3873,20 +3907,21 @@ export class TuiController {
3873
3907
  || Array.isArray(execution.groups)
3874
3908
  && (execution.groups
3875
3909
  .some((group) => group.configSaved)));
3910
+ const configRetryReportedDelivery = ticket.intent.kind === 'configSave' && ticket.intent.retryApply
3911
+ && configApplyHasCompletedWork(configApplyResult(execution));
3876
3912
  if ((ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configSaveBatch'
3877
- || ticket.intent.kind === 'configReset')
3878
- && configCommitted) {
3913
+ || ticket.intent.kind === 'configReset') && (configCommitted || configRetryReportedDelivery)) {
3879
3914
  const baseSummary = operationResultSummary(ticket.intent, execution);
3880
3915
  const elapsedMs = Math.max(0, (this.dependencies.now?.() ?? Date.now()) - startedAtMs);
3881
3916
  const summary = {
3882
3917
  ...baseSummary,
3883
3918
  code: 'operationPartial',
3884
- message: '设置已保存,但最终状态无法刷新。',
3919
+ message: configCommitted ? '设置已保存,但最终状态无法刷新。' : '部分插件内容已就绪,但最终状态无法刷新。',
3885
3920
  elapsedMs,
3886
3921
  messages: [
3887
3922
  ...this.#progress.messages,
3888
3923
  ...(baseSummary.messages ?? []),
3889
- '状态刷新失败。配置写入已经提交;请稍后刷新状态。',
3924
+ configCommitted ? '状态刷新失败。配置写入已经提交;请稍后刷新状态。' : '请稍后刷新状态。',
3890
3925
  ].slice(-8).map((message) => sanitizeDiagnosticText(message, [], collectOperationSensitiveValues(ticket.intent))),
3891
3926
  };
3892
3927
  this.#progress = { ...this.#progress, elapsedMs };
@@ -4109,9 +4144,11 @@ export class TuiController {
4109
4144
  catch (error) {
4110
4145
  if (!this.#operationIsCurrent(generation))
4111
4146
  return this.#detachedBlocked(operationId, ticket.intent);
4112
- const code = issueCode(error);
4147
+ const interruptedApply = error instanceof ConfigApplyInterruptedError ? error : undefined;
4148
+ const code = interruptedApply?.code ?? issueCode(error);
4113
4149
  const metadata = readSafeOperationError(error);
4114
4150
  const preApply = metadata?.stage === 'preApply';
4151
+ const applyCompletedWork = configApplyHasCompletedWork(interruptedApply?.apply);
4115
4152
  const configWrite = error && typeof error === 'object' && 'configWrite' in error
4116
4153
  ? error.configWrite : undefined;
4117
4154
  this.#captureThrownProjection(operationId, error, code, 'execute', ticket.intent, {
@@ -4122,6 +4159,18 @@ export class TuiController {
4122
4159
  preApplyExternalEffect: preApply ? 'possible' : 'notApplicable',
4123
4160
  finalVerification: 'notStarted',
4124
4161
  });
4162
+ if (interruptedApply) {
4163
+ const projected = this.#operationDiagnostics.get(operationId);
4164
+ const applyProjection = projectExecutionDiagnostics(interruptedApply, `${this.#sessionEpoch}:${operationId}:interrupted-apply`, projected.sensitiveValues, ticket.intent.kind);
4165
+ projected.diagnostics.push(...applyProjection.diagnostics);
4166
+ projected.effects = {
4167
+ ...applyProjection.effects,
4168
+ awWrite: applyCompletedWork ? 'partial' : projected.effects.awWrite,
4169
+ preApplyExternalEffect: preApply ? 'possible' : applyProjection.effects.preApplyExternalEffect,
4170
+ finalVerification: 'notStarted',
4171
+ };
4172
+ projected.targetEffects = applyProjection.targetEffects;
4173
+ }
4125
4174
  await this.#logOperationError(error, code, ticket.intent);
4126
4175
  if (!this.#operationIsCurrent(generation))
4127
4176
  return this.#detachedBlocked(operationId, ticket.intent);
@@ -4171,28 +4220,44 @@ export class TuiController {
4171
4220
  }
4172
4221
  if (!this.#operationIsCurrent(generation))
4173
4222
  return this.#detachedBlocked(operationId, ticket.intent);
4223
+ const applySummary = interruptedApply ? operationResultSummary(ticket.intent, interruptedApply) : undefined;
4224
+ const configMadeProgress = configWrite === 'succeeded' || applyCompletedWork;
4225
+ const retryTargets = configMadeProgress ? configApplyUnfinishedPlatforms(interruptedApply?.apply, ticket.intent.kind === 'configSave' ? ticket.intent.targets : undefined) : [];
4226
+ const interruptionMessage = interruptedApply
4227
+ ? configApplyInterruptionMessage(interruptedApply.code, retryTargets) : undefined;
4174
4228
  if ((ticket.intent.kind === 'configSave' || ticket.intent.kind === 'configReset')
4175
- && configWrite === 'succeeded') {
4229
+ && configMadeProgress) {
4176
4230
  const elapsedMs = Math.max(0, (this.dependencies.now?.() ?? Date.now()) - startedAtMs);
4177
4231
  const summary = {
4232
+ ...applySummary,
4178
4233
  code: 'operationPartial',
4179
4234
  message: ticket.intent.kind === 'configReset'
4180
4235
  ? '设置层重置已提交,但后续步骤未完成。'
4181
- : finalVerification === 'failed'
4182
- ? ticket.intent.apply
4183
- ? '设置已保存,但后续应用或状态复核失败。'
4184
- : '设置已保存,但状态复核失败。'
4185
- : ticket.intent.apply
4186
- ? '设置已保存,但后续应用失败。'
4187
- : '设置已保存,但后续步骤未完成。',
4236
+ : applyCompletedWork
4237
+ ? configWrite === 'succeeded' ? '设置已保存,部分插件内容已就绪。' : '部分插件内容已就绪。'
4238
+ : finalVerification === 'failed'
4239
+ ? ticket.intent.apply
4240
+ ? '设置已保存,但后续应用或状态复核失败。'
4241
+ : '设置已保存,但状态复核失败。'
4242
+ : ticket.intent.apply
4243
+ ? '设置已保存,但后续应用失败。'
4244
+ : '设置已保存,但后续步骤未完成。',
4188
4245
  pluginId: ticket.intent.pluginId,
4189
4246
  configScope: 'user', configPlatform: ticket.intent.platform, configContext: ticket.intent.context ?? 'user',
4247
+ ...(interruptedApply ? { configApplied: applyCompletedWork } : {}),
4190
4248
  ...(ticket.intent.kind === 'configSave' && ticket.intent.apply
4191
- ? { configApplyRetryAvailable: true } : {}),
4249
+ ? { configApplyRetryAvailable: !interruptedApply || retryTargets.length > 0 } : {}),
4250
+ ...(interruptedApply ? { configApplyRetryTargets: retryTargets } : {}),
4192
4251
  elapsedMs,
4193
- messages: [ticket.intent.kind === 'configReset'
4194
- ? '设置层重置已经提交;失败的后续步骤没有恢复旧设置。'
4195
- : '配置写入已经提交;失败的后续步骤没有回滚设置。'],
4252
+ messages: [
4253
+ ...(applySummary?.messages ?? []),
4254
+ ...(configWrite === 'succeeded' ? [ticket.intent.kind === 'configReset'
4255
+ ? '设置层重置已经提交;失败的后续步骤没有恢复旧设置。'
4256
+ : '配置写入已经提交;失败的后续步骤没有回滚设置。'] : []),
4257
+ ...(interruptionMessage ? [interruptionMessage] : []),
4258
+ ...(finalVerification === 'failed' && interruptedApply
4259
+ ? ['最终状态无法刷新。请稍后重新检查状态。'] : []),
4260
+ ],
4196
4261
  };
4197
4262
  this.#progress = { ...this.#progress, elapsedMs };
4198
4263
  const result = {
@@ -4214,6 +4279,16 @@ export class TuiController {
4214
4279
  navigation: 'result',
4215
4280
  returnRoute: ticket.returnRoute,
4216
4281
  writeMayHaveCompleted: ticket.intent.kind === 'catalogSourcesRecovery' ? false : true,
4282
+ ...(applySummary && interruptionMessage ? {
4283
+ message: interruptionMessage,
4284
+ summary: {
4285
+ ...applySummary,
4286
+ code: 'operationFailed',
4287
+ message: interruptionMessage,
4288
+ configApplyRetryAvailable: false,
4289
+ configApplyRetryTargets: [],
4290
+ },
4291
+ } : {}),
4217
4292
  });
4218
4293
  }
4219
4294
  }
@@ -4321,7 +4396,7 @@ export class TuiController {
4321
4396
  if (!this.#operationDiagnostics.has(operationId)) {
4322
4397
  this.#captureThrownProjection(operationId, undefined, code, 'execute', options?.intent);
4323
4398
  }
4324
- const message = code === 'codexCliNotFound'
4399
+ const message = options?.message ?? (code === 'codexCliNotFound'
4325
4400
  ? '操作在插件写入前停止。未找到本机 Codex CLI。请检查 PATH,或安装 Codex CLI 或 Codex App 后重试。'
4326
4401
  : code === 'codexSystemCliUnsupported'
4327
4402
  ? '操作在插件写入前停止。本机 Codex CLI 版本不受支持或无法确认。请升级或修复本机 Codex CLI 或 Codex App 后重试。'
@@ -4333,7 +4408,7 @@ export class TuiController {
4333
4408
  ? '重置执行后设置层仍然存在。请重新检查设置问题。'
4334
4409
  : code === 'issueStillPresent'
4335
4410
  ? '写入已完成,但重新检查后原问题仍然存在。'
4336
- : '操作未完成。请重新检查后重试。';
4411
+ : '操作未完成。请重新检查后重试。');
4337
4412
  const result = {
4338
4413
  state: 'blocked',
4339
4414
  operationId,
@@ -4391,6 +4466,64 @@ export class TuiController {
4391
4466
  this.#listeners.clear();
4392
4467
  }
4393
4468
  }
4469
+ function configApplyResult(execution) {
4470
+ if (!execution || typeof execution !== 'object')
4471
+ return undefined;
4472
+ return execution.apply;
4473
+ }
4474
+ export function configApplyHasCompletedWork(apply) {
4475
+ return apply?.targetResults?.some((target) => target.partialDelivery || target.state === 'completed' && target.action !== 'skipped') === true
4476
+ || apply?.commandResults?.some((result) => result.state === 'completed') === true;
4477
+ }
4478
+ function configApplyUnfinishedPlatforms(apply, reviewedPlatforms) {
4479
+ if (!apply || apply.commandResults?.length)
4480
+ return [];
4481
+ const completed = new Set(apply.targetResults.filter((result) => result.state === 'completed' || result.partialDelivery)
4482
+ .map((result) => result.target.platform));
4483
+ return [...new Set(apply.targetResults.filter((result) => (result.state === 'failed' || result.state === 'skipped' && result.errorCode)
4484
+ && !completed.has(result.target.platform)
4485
+ && (!reviewedPlatforms || reviewedPlatforms.includes(result.target.platform)))
4486
+ .map((result) => result.target.platform))];
4487
+ }
4488
+ function configApplyInterruptionMessage(code, retryTargets) {
4489
+ const nextStep = retryTargets.length > 0
4490
+ ? '可为未完成平台重新准备确认。' : CONFIG_APPLY_MANUAL_RECOVERY;
4491
+ return code === 'processCleanupUnconfirmed'
4492
+ ? `无法确认进程已清理。请先检查相关平台进程。${nextStep}`
4493
+ : `应用已中断。${nextStep}`;
4494
+ }
4495
+ const CONFIG_APPLY_MANUAL_RECOVERY = '请检查未完成位置后,从设置重新准备应用。';
4496
+ function configApplyTargets(apply) {
4497
+ return (apply?.targetResults ?? []).flatMap((entry) => {
4498
+ const target = entry.target;
4499
+ if (!target || !isPlatformTarget(target.platform)
4500
+ || (target.scope !== 'user' && target.scope !== 'project')
4501
+ || (entry.state !== 'completed' && entry.state !== 'failed' && entry.state !== 'skipped'))
4502
+ return [];
4503
+ let pluginId;
4504
+ if (typeof target.pluginId === 'string') {
4505
+ try {
4506
+ parsePluginId(target.pluginId);
4507
+ pluginId = target.pluginId;
4508
+ }
4509
+ catch {
4510
+ // Target identity can be unavailable in older receipts.
4511
+ }
4512
+ }
4513
+ return [{
4514
+ ...(pluginId ? { pluginId } : {}),
4515
+ platform: target.platform,
4516
+ scope: target.scope,
4517
+ state: entry.state === 'skipped' || entry.action === 'skipped' ? 'skipped'
4518
+ : entry.state === 'failed' ? 'failed'
4519
+ : entry.action === 'keep' ? 'kept' : 'completed',
4520
+ ...(entry.partialDelivery ? { partialDelivery: true } : {}),
4521
+ ...(typeof entry.errorCode === 'string'
4522
+ ? { errorCode: safeDiagnosticCode(entry.errorCode, 'configApplyFailed') }
4523
+ : {}),
4524
+ }];
4525
+ });
4526
+ }
4394
4527
  function operationResultSummaryUnsafe(intent, execution) {
4395
4528
  if (intent.kind === 'catalogStorePrune') {
4396
4529
  const result = execution;
@@ -4754,9 +4887,27 @@ function operationResultSummaryUnsafe(intent, execution) {
4754
4887
  }
4755
4888
  if (intent.kind === 'configSaveBatch') {
4756
4889
  const batch = execution;
4890
+ const applies = batch.groups.map((group) => configApplyResult(group.execution));
4891
+ const configDiagnostics = applies.flatMap((apply) => apply?.diagnostics ?? []);
4892
+ const commandResults = applies.flatMap((apply) => apply?.commandResults ?? []);
4893
+ const targets = [...new Map(applies.flatMap(configApplyTargets)
4894
+ .map((target) => [[target.pluginId ?? '', target.platform, target.scope].join('\0'), target])).values()];
4757
4895
  const savedCount = batch.groups.filter((group) => group.configSaved).length;
4758
- const failedCount = batch.groups.filter((group) => group.status === 'failed').length;
4759
- const retryScopes = batch.groups.filter((group) => group.configSaved && group.applyStatus === 'failed' && group.errorCode !== 'invalidConfig');
4896
+ const targetsUpdated = applies.some(configApplyHasCompletedWork);
4897
+ const configGroups = batch.groups.map((group, index) => ({
4898
+ scope: group.scope,
4899
+ platform: group.platform,
4900
+ configSaved: group.configSaved,
4901
+ applyRequested: group.applyRequested,
4902
+ applyStatus: group.applyStatus,
4903
+ ...(group.errorCode ? { errorCode: safeDiagnosticCode(group.errorCode, 'configWriteFailed') } : {}),
4904
+ ...(group.status === 'notStarted' ? { notStarted: true } : {}),
4905
+ ...(group.applyStatus === 'partial'
4906
+ || group.errorCode === 'operationInterrupted' || group.errorCode === 'processCleanupUnconfirmed'
4907
+ ? { retryTargets: configApplyUnfinishedPlatforms(applies[index]) } : {}),
4908
+ }));
4909
+ const retryScopes = configGroups.filter((group) => group.configSaved && (group.applyStatus === 'failed' || group.applyStatus === 'partial')
4910
+ && group.errorCode !== 'invalidConfig' && group.retryTargets?.length !== 0);
4760
4911
  const invalidConfig = savedCount === batch.groups.length
4761
4912
  && batch.groups.some((group) => group.configSaved && group.errorCode === 'invalidConfig')
4762
4913
  && retryScopes.length === 0;
@@ -4769,43 +4920,42 @@ function operationResultSummaryUnsafe(intent, execution) {
4769
4920
  const otherProjectsMayRequireSync = batch.groups.some((group) => group.scope === 'user' && group.execution && typeof group.execution === 'object'
4770
4921
  && group.execution.otherProjectsMayRequireSync === true);
4771
4922
  return {
4772
- code: failedCount > 0
4773
- ? savedCount > 0 ? 'operationPartial' : 'operationFailed'
4774
- : 'operationSucceeded',
4923
+ code: batch.status === 'succeeded' ? 'operationSucceeded'
4924
+ : batch.status === 'partial' || targetsUpdated ? 'operationPartial' : 'operationFailed',
4775
4925
  message: invalidConfig
4776
4926
  ? '设置已保存,但没有应用。当前配置仍无效。'
4777
- : failedCount > 0
4927
+ : batch.status !== 'succeeded'
4778
4928
  ? savedCount > 0
4779
- ? `已保存 ${savedCount} 个设置层;${failedCount} 个设置层失败。`
4929
+ ? `已保存 ${savedCount} 个设置层;${targetsUpdated ? '部分插件目标已更新。' : '部分步骤未完成。'}`
4780
4930
  : '设置没有保存。'
4781
4931
  : '设置已保存。',
4782
4932
  pluginId: intent.pluginId,
4933
+ configContext: intent.context ?? 'user',
4783
4934
  configApplyRetryAvailable: retryScopes.length > 0,
4784
4935
  ...(invalidConfig ? { configApplySkippedReason: 'invalidConfig' } : {}),
4785
4936
  configApplied: intent.apply
4786
- ? batch.groups.some((group) => group.applyStatus === 'succeeded')
4937
+ ? targetsUpdated || batch.groups.some((group) => group.applyStatus === 'succeeded')
4787
4938
  : false,
4788
- configGroups: batch.groups.map((group) => ({
4789
- scope: group.scope,
4790
- platform: group.platform,
4791
- configSaved: group.configSaved,
4792
- applyRequested: group.applyRequested,
4793
- applyStatus: group.applyStatus,
4794
- ...(group.errorCode ? { errorCode: safeDiagnosticCode(group.errorCode, 'configWriteFailed') } : {}),
4795
- })),
4796
- commandResults: batch.groups.flatMap((group) => group.execution
4797
- && typeof group.execution === 'object'
4798
- ? (group.execution.apply?.commandResults ?? [])
4799
- : []),
4939
+ configGroups,
4940
+ ...(targets.length > 0 ? { configTargets: targets } : {}),
4941
+ ...(configDiagnostics.length ? { configDiagnostics } : {}),
4942
+ commandResults,
4943
+ ...(commandResults.length ? { recoveryActions: [...new Set(commandResults.flatMap((result) => result.recoveryActions))] } : {}),
4800
4944
  messages: [
4801
- ...batch.groups.map((group) => {
4945
+ ...configGroups.map((group) => {
4802
4946
  const label = group.platform ? `${group.platform} 平台配置` : '公共配置';
4947
+ if (group.notStarted)
4948
+ return `${label}尚未保存。`;
4803
4949
  return group.configSaved
4804
4950
  ? `${label}已保存${group.errorCode === 'invalidConfig'
4805
4951
  ? ',但当前配置无效,未应用'
4806
- : group.applyStatus === 'failed' ? ',但应用失败' : ''}。`
4952
+ : group.applyStatus === 'partial' ? ',部分插件目标已更新'
4953
+ : group.applyStatus === 'failed' ? ',但应用失败' : ''}。`
4807
4954
  : `${label}保存失败。`;
4808
4955
  }),
4956
+ ...configGroups.flatMap((group) => group.errorCode === 'operationInterrupted' || group.errorCode === 'processCleanupUnconfirmed'
4957
+ ? [configApplyInterruptionMessage(group.errorCode, group.retryTargets ?? [])]
4958
+ : group.retryTargets?.length === 0 ? [CONFIG_APPLY_MANUAL_RECOVERY] : []),
4809
4959
  ...publicWarnings.map((warning) => `警告:${warning}`),
4810
4960
  ...(otherProjectsMayRequireSync
4811
4961
  ? ['提示:其它项目没有被扫描,可能需要在对应项目目录中运行 aw plugin sync --context project。']
@@ -4814,43 +4964,15 @@ function operationResultSummaryUnsafe(intent, execution) {
4814
4964
  };
4815
4965
  }
4816
4966
  if (intent.kind === 'configSave' || intent.kind === 'configReset') {
4817
- const rawApply = typeof execution === 'object' && execution !== null
4818
- && typeof execution.apply === 'object'
4819
- && execution.apply !== null
4820
- ? execution.apply
4821
- : {};
4822
- const rawTargets = Array.isArray(rawApply.targetResults)
4823
- ? rawApply.targetResults
4824
- : [];
4825
- const commandResults = Array.isArray(rawApply.commandResults)
4826
- ? rawApply.commandResults : [];
4827
- const targets = rawTargets.flatMap((entry) => {
4828
- const target = typeof entry.target === 'object' && entry.target !== null
4829
- ? entry.target
4830
- : entry;
4831
- if (!isPlatformTarget(target.platform)
4832
- || (target.scope !== 'user' && target.scope !== 'project')
4833
- || (entry.state !== 'completed' && entry.state !== 'failed' && entry.state !== 'skipped'))
4834
- return [];
4835
- return [{
4836
- ...(typeof target.pluginId === 'string' ? { pluginId: target.pluginId } : {}),
4837
- platform: target.platform,
4838
- scope: target.scope,
4839
- state: entry.state === 'skipped' || entry.action === 'skipped' ? 'skipped'
4840
- : entry.state === 'failed' ? 'failed'
4841
- : entry.action === 'keep' ? 'kept'
4842
- : entry.state,
4843
- ...(typeof entry.errorCode === 'string'
4844
- ? { errorCode: safeDiagnosticCode(entry.errorCode, 'configApplyFailed') }
4845
- : {}),
4846
- }];
4847
- });
4967
+ const apply = configApplyResult(execution);
4968
+ const configDiagnostics = apply?.diagnostics ?? [];
4969
+ const commandResults = apply?.commandResults ?? [];
4970
+ const targets = configApplyTargets(apply);
4848
4971
  const overallState = typeof execution === 'object' && execution !== null
4849
4972
  ? execution.overallState
4850
4973
  : undefined;
4851
- const applyState = rawApply.state;
4852
- const applyReason = rawApply.reason;
4853
- const invalidConfig = applyState === 'unavailable' && applyReason === 'invalidConfig';
4974
+ const applyState = apply?.state;
4975
+ const invalidConfig = apply?.state === 'unavailable' && apply.reason === 'invalidConfig';
4854
4976
  const resetDisposition = typeof execution === 'object' && execution !== null
4855
4977
  ? execution.resetDisposition
4856
4978
  : undefined;
@@ -4879,18 +5001,34 @@ function operationResultSummaryUnsafe(intent, execution) {
4879
5001
  const failed = overallState === 'failed'
4880
5002
  || (targets.length > 0
4881
5003
  && targets.every((target) => target.state === 'failed' || target.state === 'skipped'));
5004
+ const retryApply = intent.kind === 'configSave' && intent.retryApply === true;
5005
+ const applied = applyState === 'succeeded' || configApplyHasCompletedWork(apply);
5006
+ const retryable = intent.kind === 'configSave'
5007
+ && intent.apply && !invalidConfig && (applyState === 'partial' || applyState === 'unavailable');
5008
+ const retryTargets = retryable && intent.kind === 'configSave'
5009
+ ? applied || commandResults.some((result) => result.state === 'partial')
5010
+ ? configApplyUnfinishedPlatforms(apply, intent.targets)
5011
+ : intent.targets
5012
+ : undefined;
5013
+ if (retryable && retryTargets?.length === 0 && !(execution instanceof ConfigApplyInterruptedError)) {
5014
+ publicMessages.push(CONFIG_APPLY_MANUAL_RECOVERY);
5015
+ }
4882
5016
  return {
4883
5017
  code: failed || partial ? 'operationPartial' : 'operationSucceeded',
4884
- message: invalidConfig ? '设置已保存,但没有应用。当前配置仍无效。'
4885
- : failed || partial ? '设置已保存,但插件内容重新应用失败或部分失败。' : '操作已完成。',
5018
+ message: retryApply
5019
+ ? invalidConfig ? '当前配置仍无效。请返回设置修复。'
5020
+ : failed || partial ? applied ? '部分插件内容已就绪。' : '插件设置应用未完成。'
5021
+ : applied ? '已应用已保存的设置。' : '应用检查完成。'
5022
+ : invalidConfig ? '设置已保存,但没有应用。当前配置仍无效。'
5023
+ : failed || partial ? '设置已保存,但插件内容重新应用失败或部分失败。' : '操作已完成。',
4886
5024
  pluginId: intent.pluginId,
4887
5025
  configScope: 'user', configPlatform: intent.platform, configContext: intent.context ?? 'user',
4888
- configApplyRetryAvailable: intent.kind === 'configSave'
4889
- && intent.apply && !invalidConfig && (applyState === 'partial' || applyState === 'unavailable'),
4890
- ...(intent.kind === 'configSave' && intent.retryApply ? { configRetryApply: true } : {}),
5026
+ configApplyRetryAvailable: retryable && retryTargets?.length !== 0,
5027
+ ...(retryTargets ? { configApplyRetryTargets: retryTargets } : {}),
5028
+ ...(retryApply ? { configRetryApply: true } : {}),
4891
5029
  ...(publicMessages.length > 0 ? { messages: publicMessages } : {}),
4892
5030
  ...(intent.kind === 'configSave'
4893
- ? { configApplied: applyState === 'succeeded' || applyState === 'partial' }
5031
+ ? { configApplied: applied }
4894
5032
  : invalidConfig ? { configApplied: false } : {}),
4895
5033
  ...(invalidConfig ? { configApplySkippedReason: 'invalidConfig' } : {}),
4896
5034
  ...(intent.kind === 'configReset'
@@ -4905,6 +5043,7 @@ function operationResultSummaryUnsafe(intent, execution) {
4905
5043
  }
4906
5044
  : {}),
4907
5045
  ...(targets.length > 0 ? { configTargets: targets } : {}),
5046
+ ...(configDiagnostics.length ? { configDiagnostics } : {}),
4908
5047
  ...(commandResults.length > 0 ? { commandResults,
4909
5048
  recoveryActions: [...new Set(commandResults.flatMap((result) => result.recoveryActions))] } : {}),
4910
5049
  };