@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.
Files changed (96) hide show
  1. package/dist/src/commands/aw-capabilities.d.ts +1 -1
  2. package/dist/src/commands/aw-capabilities.js +4 -1
  3. package/dist/src/commands/aw-capabilities.js.map +1 -1
  4. package/dist/src/commands/plugin-capabilities.js +4 -1
  5. package/dist/src/commands/plugin-capabilities.js.map +1 -1
  6. package/dist/src/commands/public-lifecycle-result.d.ts +3 -0
  7. package/dist/src/commands/public-lifecycle-result.js +30 -5
  8. package/dist/src/commands/public-lifecycle-result.js.map +1 -1
  9. package/dist/src/commands/public-lifecycle.js +8 -0
  10. package/dist/src/commands/public-lifecycle.js.map +1 -1
  11. package/dist/src/commands/public-plugin-query.js +6 -2
  12. package/dist/src/commands/public-plugin-query.js.map +1 -1
  13. package/dist/src/commands/rebuild-command.js +28 -17
  14. package/dist/src/commands/rebuild-command.js.map +1 -1
  15. package/dist/src/commands/rebuild-platform-integration.js +23 -3
  16. package/dist/src/commands/rebuild-platform-integration.js.map +1 -1
  17. package/dist/src/commands/reconcile-operation-plan.d.ts +3 -0
  18. package/dist/src/commands/reconcile-operation-plan.js +1 -0
  19. package/dist/src/commands/reconcile-operation-plan.js.map +1 -1
  20. package/dist/src/commands/status-v6.js +61 -9
  21. package/dist/src/commands/status-v6.js.map +1 -1
  22. package/dist/src/index.js +122 -28
  23. package/dist/src/index.js.map +1 -1
  24. package/dist/src/output/public-result.d.ts +1 -0
  25. package/dist/src/output/public-result.js +21 -3
  26. package/dist/src/output/public-result.js.map +1 -1
  27. package/dist/src/output/receipt-projection.js +19 -5
  28. package/dist/src/output/receipt-projection.js.map +1 -1
  29. package/dist/src/portable/recovery.d.ts +2 -7
  30. package/dist/src/portable/recovery.js +10 -0
  31. package/dist/src/portable/recovery.js.map +1 -1
  32. package/dist/src/recovery/coordinator.js +5 -0
  33. package/dist/src/recovery/coordinator.js.map +1 -1
  34. package/dist/src/recovery/joint-coordinator.js +12 -0
  35. package/dist/src/recovery/joint-coordinator.js.map +1 -1
  36. package/dist/src/recovery/status.d.ts +1 -0
  37. package/dist/src/recovery/status.js +151 -44
  38. package/dist/src/recovery/status.js.map +1 -1
  39. package/dist/src/review/source-binding.js +7 -4
  40. package/dist/src/review/source-binding.js.map +1 -1
  41. package/dist/src/tui/components.js +1 -0
  42. package/dist/src/tui/components.js.map +1 -1
  43. package/dist/src/tui/config-object-suggestions.d.ts +15 -0
  44. package/dist/src/tui/config-object-suggestions.js +71 -0
  45. package/dist/src/tui/config-object-suggestions.js.map +1 -0
  46. package/dist/src/tui/config-suggestions.d.ts +7 -2
  47. package/dist/src/tui/config-suggestions.js +22 -14
  48. package/dist/src/tui/config-suggestions.js.map +1 -1
  49. package/dist/src/tui/console-app-v4.js +569 -102
  50. package/dist/src/tui/console-app-v4.js.map +1 -1
  51. package/dist/src/tui/controller-runtime.js +14 -16
  52. package/dist/src/tui/controller-runtime.js.map +1 -1
  53. package/dist/src/tui/controller.d.ts +6 -4
  54. package/dist/src/tui/controller.js +59 -12
  55. package/dist/src/tui/controller.js.map +1 -1
  56. package/dist/src/tui/guided-setup.d.ts +25 -0
  57. package/dist/src/tui/guided-setup.js +101 -0
  58. package/dist/src/tui/guided-setup.js.map +1 -0
  59. package/dist/src/tui/model.d.ts +5 -0
  60. package/dist/src/tui/model.js +120 -49
  61. package/dist/src/tui/model.js.map +1 -1
  62. package/dist/src/tui/router.d.ts +5 -3
  63. package/dist/src/tui/router.js.map +1 -1
  64. package/dist/src/tui/scoped-flow.d.ts +2 -0
  65. package/dist/src/tui/scoped-flow.js.map +1 -1
  66. package/dist/src/tui/scoped-inventory.d.ts +1 -0
  67. package/dist/src/tui/screen-registry.d.ts +3 -2
  68. package/dist/src/utils/config-platforms.d.ts +21 -0
  69. package/dist/src/utils/config-platforms.js +51 -0
  70. package/dist/src/utils/config-platforms.js.map +1 -0
  71. package/dist/src/utils/managed-command-materialization.d.ts +1 -0
  72. package/dist/src/utils/managed-command-materialization.js +8 -3
  73. package/dist/src/utils/managed-command-materialization.js.map +1 -1
  74. package/dist/src/utils/plugin-config-command-apply.js +7 -1
  75. package/dist/src/utils/plugin-config-command-apply.js.map +1 -1
  76. package/dist/src/utils/plugin-config-diagnostics.d.ts +16 -0
  77. package/dist/src/utils/plugin-config-diagnostics.js +44 -0
  78. package/dist/src/utils/plugin-config-diagnostics.js.map +1 -0
  79. package/dist/src/utils/plugin-config-impact.js +46 -18
  80. package/dist/src/utils/plugin-config-impact.js.map +1 -1
  81. package/dist/src/utils/plugin-config-references.d.ts +5 -0
  82. package/dist/src/utils/plugin-config-references.js +19 -7
  83. package/dist/src/utils/plugin-config-references.js.map +1 -1
  84. package/dist/src/utils/plugin-config-suggestion-runner.d.ts +45 -12
  85. package/dist/src/utils/plugin-config-suggestion-runner.js +174 -33
  86. package/dist/src/utils/plugin-config-suggestion-runner.js.map +1 -1
  87. package/dist/src/utils/plugin-config-suggestions.d.ts +10 -7
  88. package/dist/src/utils/plugin-config-suggestions.js +41 -13
  89. package/dist/src/utils/plugin-config-suggestions.js.map +1 -1
  90. package/dist/src/utils/plugin-config-write.d.ts +2 -0
  91. package/dist/src/utils/plugin-config-write.js +44 -4
  92. package/dist/src/utils/plugin-config-write.js.map +1 -1
  93. package/dist/src/utils/plugin-config.d.ts +1 -0
  94. package/dist/src/utils/plugin-config.js +33 -8
  95. package/dist/src/utils/plugin-config.js.map +1 -1
  96. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import type { ConfigReferenceContext, ConfigReferenceDraft } from './config-references.js';
2
2
  import type { ConfigSuggestionLookup } from './config-suggestions.js';
3
- import type { ConfigSuggestionsResponseV1, PreparedConfigSuggestions } from '../utils/plugin-config-suggestions.js';
3
+ import type { ConfigSuggestionsResponseV2, PreparedConfigSuggestions } from '../utils/plugin-config-suggestions.js';
4
4
  import type { CatalogActivationMode, CatalogSource, CatalogGenerationActiveV1, CatalogGenerationCandidateEvidence, CatalogGenerationSyncResult, CatalogSourceImpact, CommandProducerResult, ConfigApplyResult, DependencyScopeOverride, PlatformName, PlatformTarget, Scope } from '../types.js';
5
5
  import type { PortableReview, PortableInstallReceipt, PortableRetryReview } from '../portable/commands.js';
6
6
  import type { CatalogSourceUpdate } from '../utils/catalog-sources.js';
@@ -24,7 +24,7 @@ import { type ScopedTuiPlan } from './scoped-flow.js';
24
24
  import type { RecoveryReceipt } from '../recovery/receipt.js';
25
25
  import type { RecoveryCommand } from '../recovery/coordinator.js';
26
26
  import type { AgentId } from '../intent/deployment-preferences.js';
27
- import { type ConfigInvalidStoreEvidence, type PluginInstallFilter, type PortableBlockerCode, type TuiPageContext, type TuiRoute, type TuiRouterSnapshot } from './router.js';
27
+ import { type ConfigInvalidStoreEvidence, type ConfigRouteLayer, type PluginInstallFilter, type PortableBlockerCode, type TuiPageContext, type TuiRoute, type TuiRouterSnapshot } from './router.js';
28
28
  import { type CatalogSourceGenerationViewModel } from './catalog-generation.js';
29
29
  import type { CatalogSourceFreshnessViewModel } from './catalog-freshness.js';
30
30
  import type { CatalogSessionReusableCandidate } from './catalog-sources/types.js';
@@ -800,7 +800,7 @@ export interface TuiControllerDependencies {
800
800
  getConfigGroups?: (pluginId: string, options: ConfigReadOptions, signal: AbortSignal) => Promise<ConfigGroupViewModel[]>;
801
801
  getConfigPage?: (pluginId: string, options: ConfigReadOptions, signal: AbortSignal) => Promise<ConfigPageViewModel>;
802
802
  getConfigReferenceContext?: (pluginId: string, options: ConfigProfileOptions, draft: ConfigReferenceDraft, signal: AbortSignal) => Promise<ConfigReferenceContext>;
803
- getConfigSuggestions?: (lookup: ConfigSuggestionLookup, run: (prepared: Pick<PreparedConfigSuggestions, 'cacheKey' | 'project' | 'run'>) => Promise<ConfigSuggestionsResponseV1>, signal: AbortSignal) => Promise<ConfigSuggestionsResponseV1>;
803
+ getConfigSuggestions?: (lookup: ConfigSuggestionLookup, run: (prepared: Pick<PreparedConfigSuggestions, 'kind' | 'hint' | 'sharedCacheKey' | 'hintCacheKey' | 'project' | 'run'>) => Promise<ConfigSuggestionsResponseV2>, signal: AbortSignal) => Promise<ConfigSuggestionsResponseV2>;
804
804
  getConfigResetAvailability?: (pluginId: string, options: ConfigProfileOptions, signal: AbortSignal) => Promise<ConfigResetAvailability>;
805
805
  logError?: (error: unknown, code: string, context?: {
806
806
  privateConfigOperation: boolean;
@@ -940,6 +940,8 @@ export declare class TuiController {
940
940
  discardPortableDraft(): void;
941
941
  replace(route: TuiRoute, context?: TuiPageContext): void;
942
942
  beginConfigFlow(pluginId: string, options?: ConfigProfileOptions): void;
943
+ beginGuidedConfig(pluginId: string, layer: ConfigRouteLayer): string;
944
+ finishGuidedConfig(flowId: string): void;
943
945
  beginConfigReferenceSource(pluginId: string, fieldKey: string): void;
944
946
  beginSavedConfigRecovery(pluginId: string): void;
945
947
  beginConfigSourceRecovery(sourceId: string): void;
@@ -1026,7 +1028,7 @@ export declare class TuiController {
1026
1028
  getConfigGroups(pluginId: string, options: ConfigReadOptions): Promise<ConfigGroupViewModel[]>;
1027
1029
  getConfigPage(pluginId: string, options: ConfigReadOptions, signal?: AbortSignal): Promise<ConfigPageViewModel>;
1028
1030
  getConfigReferenceContext(pluginId: string, options: ConfigProfileOptions, draft: ConfigReferenceDraft, signal?: AbortSignal): Promise<ConfigReferenceContext>;
1029
- getConfigSuggestions(lookup: ConfigSuggestionLookup, refresh: boolean, signal: AbortSignal): Promise<ConfigSuggestionsResponseV1>;
1031
+ getConfigSuggestions(lookup: ConfigSuggestionLookup, refresh: boolean, signal: AbortSignal): Promise<ConfigSuggestionsResponseV2>;
1030
1032
  saveConfigDraft(request: Extract<OperationIntent, {
1031
1033
  kind: 'configSave' | 'configSaveBatch';
1032
1034
  }>, signal?: AbortSignal): Promise<ConfigDraftSaveResult>;
@@ -1,3 +1,4 @@
1
+ import { hasRecommendedHints } from '../utils/plugin-config-suggestion-runner.js';
1
2
  import { isPlatformTarget, PLATFORM_TARGETS } from '@lesliechan721/aw-plugin-core/manifest';
2
3
  import { agentLabel } from './glossary.js';
3
4
  import crypto from 'node:crypto';
@@ -20,6 +21,7 @@ import { OperationHistoryStore, } from './operation-history.js';
20
21
  import { targetHasArtifactCollision } from '../utils/target-eligibility.js';
21
22
  import { hasStatusInstallationEvidence } from './scoped-inventory.js';
22
23
  import { buildScopedInventory } from './scoped-inventory.js';
24
+ import { guidedSkipWarning } from './guided-setup.js';
23
25
  import { projectScopedRecoveryHistory } from './scoped-flow.js';
24
26
  import { TuiRouter, } from './router.js';
25
27
  import { normalizeTuiRoute } from './screen-registry.js';
@@ -1172,7 +1174,12 @@ export class TuiController {
1172
1174
  status: this.#status.payload,
1173
1175
  pluginSummaries: this.#status.pluginSummaries,
1174
1176
  targetRevisions: this.#status.targetRevisions,
1175
- recoveryDiagnostics: Object.values(this.#status.scopedRecovery ?? {}).flatMap((status) => status.errors),
1177
+ recoveryDiagnostics: Object.values(this.#status.scopedRecovery ?? {}).flatMap((status) => [
1178
+ ...status.errors,
1179
+ ...(status.extraObserved ?? []).flatMap((target) => !target.agent ? [] :
1180
+ (target.blockers ?? []).filter(({ code }) => ['requiredConfigMissing', 'configInvalid', 'invalidConfig'].includes(code))
1181
+ .map((entry) => ({ ...entry, subject: { pluginId: target.pluginId, target: target.agent, scope: target.scope, ...entry.subject } }))),
1182
+ ]),
1176
1183
  recoveryTargets: Object.values(this.#status.scopedRecovery ?? {}).flatMap((status) => [
1177
1184
  ...(status.inventory ?? []).flatMap((root) => root.targetResults),
1178
1185
  ...(status.observedTargets ?? []).filter((target) => target.scope === status.scope
@@ -1689,13 +1696,31 @@ export class TuiController {
1689
1696
  const isBatch = plan.kind === 'recovery' && (plan.plan.command === 'install' || plan.plan.command === 'sync')
1690
1697
  && plan.plan.receipt.requestedTargets.length > 1;
1691
1698
  const promise = this.dependencies.executeScopedTask(plan).then((outcome) => {
1692
- const recordByDefault = isBatch || this.#progress.installProgress !== undefined;
1699
+ const skipped = plan.kind === 'recovery' ? plan.skippedConfigTargets ?? [] : [];
1700
+ const recordByDefault = isBatch || skipped.length > 0 || this.#progress.installProgress !== undefined;
1693
1701
  if (outcome.kind === 'recovery' && (recordByDefault || outcome.receipt.targetResults.some(({ reasons }) => reasons?.some(({ code }) => code === SKILL_INVOCATION_NOTICE)))) {
1694
1702
  const operationId = `scoped-${crypto.randomUUID()}`;
1695
1703
  const record = projectScopedRecoveryHistory(outcome.receipt, {
1696
1704
  operationId, recordId: `${this.#sessionEpoch}:${operationId}`, epoch: this.#sessionEpoch,
1697
1705
  createdAtMs: this.dependencies.now?.() ?? Date.now(),
1698
1706
  });
1707
+ for (const target of skipped) {
1708
+ const id = `${record.summary.recordId}:skipped-config:${record.diagnostics.length}`;
1709
+ const position = target.profile === 'common' ? undefined
1710
+ : { pluginId: target.pluginId, platform: target.profile, scope: target.context };
1711
+ record.diagnostics.push({ id, code: 'requiredConfigMissing', stage: 'preflight',
1712
+ safeMessage: guidedSkipWarning([target]), causes: [],
1713
+ detailLines: target.fieldKeys,
1714
+ ...(position ? { target: position } : {}),
1715
+ });
1716
+ if (position)
1717
+ record.targets.push({ ...position, state: 'skipped', errorCode: 'requiredConfigMissing', diagnosticIds: [id] });
1718
+ }
1719
+ if (skipped.length > 0) {
1720
+ record.summary.message = outcome.receipt.ok ? '已就绪平台恢复完成;待配置平台保留 requiredConfigMissing 告警。'
1721
+ : `${record.summary.message} 待配置平台保留 requiredConfigMissing 告警。`;
1722
+ }
1723
+ record.summary.diagnosticCount = record.diagnostics.length;
1699
1724
  if (recordByDefault || record.diagnostics.some(({ code }) => code === SKILL_INVOCATION_NOTICE)) {
1700
1725
  this.#operationHistory.record(record);
1701
1726
  }
@@ -2061,6 +2086,18 @@ export class TuiController {
2061
2086
  });
2062
2087
  this.#publish();
2063
2088
  }
2089
+ beginGuidedConfig(pluginId, layer) {
2090
+ this.#assertAcceptingActions();
2091
+ const origin = this.#router.snapshot.current;
2092
+ const flow = this.#router.beginFlow('configEdit', origin.route, this.#router.snapshot.currentFrameId, origin.context);
2093
+ this.#router.push({ name: 'configFields', pluginId, layer });
2094
+ this.#publish();
2095
+ return flow.id;
2096
+ }
2097
+ finishGuidedConfig(flowId) {
2098
+ this.#router.finishFlowById(flowId, 'configEdit');
2099
+ this.#publish();
2100
+ }
2064
2101
  beginConfigReferenceSource(pluginId, fieldKey) {
2065
2102
  this.#assertAcceptingActions();
2066
2103
  const current = this.#router.snapshot.current;
@@ -3197,7 +3234,7 @@ export class TuiController {
3197
3234
  async getConfigSuggestions(lookup, refresh, signal) {
3198
3235
  this.#assertAcceptingActions();
3199
3236
  if (!this.dependencies.getConfigSuggestions)
3200
- return { schemaVersion: 1, status: 'unavailable', items: [] };
3237
+ return { schemaVersion: 2, status: 'unavailable', items: [] };
3201
3238
  const combined = AbortSignal.any([this.#abort.signal, signal]);
3202
3239
  const frameId = this.#router.snapshot.currentFrameId;
3203
3240
  const epoch = this.#sessionEpoch;
@@ -3210,21 +3247,31 @@ export class TuiController {
3210
3247
  };
3211
3248
  return this.#trackRead(this.dependencies.getConfigSuggestions(structuredClone(lookup), async (prepared) => {
3212
3249
  verifyRequest();
3213
- if (!refresh) {
3214
- const cached = this.#configSuggestions.get(prepared.cacheKey);
3215
- if (cached) {
3250
+ const { kind, hint, sharedCacheKey, hintCacheKey } = prepared;
3251
+ const keys = kind === 'object' ? [sharedCacheKey, hintCacheKey] : [hint === undefined ? sharedCacheKey : hintCacheKey];
3252
+ if (refresh) {
3253
+ this.#configSuggestions.delete(sharedCacheKey);
3254
+ this.#configSuggestions.delete(hintCacheKey);
3255
+ }
3256
+ else {
3257
+ for (const key of keys) {
3258
+ const cached = this.#configSuggestions.get(key);
3259
+ if (!cached)
3260
+ continue;
3216
3261
  // Once a value is recognized as sensitive, keep it out of this shared cache entry.
3217
3262
  const redacted = cloneFrozen(prepared.project(cached, 'cache'));
3218
- this.#configSuggestions.set(prepared.cacheKey, redacted);
3263
+ this.#configSuggestions.set(key, redacted);
3264
+ if (kind === 'object' && key === sharedCacheKey && !hasRecommendedHints(redacted))
3265
+ continue;
3219
3266
  return cloneFrozen(prepared.project(redacted));
3220
3267
  }
3221
3268
  }
3222
- else
3223
- this.#configSuggestions.delete(prepared.cacheKey);
3224
- const response = cloneFrozen(await prepared.run(combined));
3269
+ const response = cloneFrozen(prepared.project(await prepared.run(combined), 'cache'));
3225
3270
  verifyRequest();
3226
- if (response.status === 'ok')
3227
- this.#configSuggestions.set(prepared.cacheKey, response);
3271
+ if (response.status === 'ok') {
3272
+ const shared = kind === 'object' ? hasRecommendedHints(response) : hint === undefined;
3273
+ this.#configSuggestions.set(shared ? sharedCacheKey : hintCacheKey, response);
3274
+ }
3228
3275
  return cloneFrozen(prepared.project(response));
3229
3276
  }, combined));
3230
3277
  }