@lesliechan721/aw 0.1.0-beta.11 → 0.1.0-beta.13

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 (60) hide show
  1. package/dist/authoring/scripts/validate-plugin.mjs +33 -42
  2. package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
  3. package/dist/src/commands/operation-planner.js +11 -1
  4. package/dist/src/commands/operation-planner.js.map +1 -1
  5. package/dist/src/commands/rebuild-command.d.ts +12 -0
  6. package/dist/src/commands/rebuild-command.js +72 -17
  7. package/dist/src/commands/rebuild-command.js.map +1 -1
  8. package/dist/src/commands/rebuild-integration.d.ts +1 -0
  9. package/dist/src/commands/rebuild-integration.js +323 -105
  10. package/dist/src/commands/rebuild-integration.js.map +1 -1
  11. package/dist/src/commands/status-v6.js +8 -8
  12. package/dist/src/commands/status-v6.js.map +1 -1
  13. package/dist/src/index.js +52 -14
  14. package/dist/src/index.js.map +1 -1
  15. package/dist/src/portable/materializer.js +5 -3
  16. package/dist/src/portable/materializer.js.map +1 -1
  17. package/dist/src/tui/console-app-v4.js +1 -21
  18. package/dist/src/tui/console-app-v4.js.map +1 -1
  19. package/dist/src/tui/controller-runtime.js +165 -48
  20. package/dist/src/tui/controller-runtime.js.map +1 -1
  21. package/dist/src/tui/controller.d.ts +4 -4
  22. package/dist/src/tui/controller.js +19 -7
  23. package/dist/src/tui/controller.js.map +1 -1
  24. package/dist/src/tui/diagnostics.js +6 -6
  25. package/dist/src/tui/diagnostics.js.map +1 -1
  26. package/dist/src/tui/model.js +15 -10
  27. package/dist/src/tui/model.js.map +1 -1
  28. package/dist/src/tui/operation-review-planner.js +66 -19
  29. package/dist/src/tui/operation-review-planner.js.map +1 -1
  30. package/dist/src/utils/artifact-plan.d.ts +2 -2
  31. package/dist/src/utils/artifact-plan.js +8 -6
  32. package/dist/src/utils/artifact-plan.js.map +1 -1
  33. package/dist/src/utils/artifact-renderer.js +96 -77
  34. package/dist/src/utils/artifact-renderer.js.map +1 -1
  35. package/dist/src/utils/artifact-request.d.ts +5 -0
  36. package/dist/src/utils/artifact-request.js +40 -0
  37. package/dist/src/utils/artifact-request.js.map +1 -1
  38. package/dist/src/utils/codex-shared-native.d.ts +4 -0
  39. package/dist/src/utils/codex-shared-native.js +13 -0
  40. package/dist/src/utils/codex-shared-native.js.map +1 -1
  41. package/dist/src/utils/local-marketplace.d.ts +14 -1
  42. package/dist/src/utils/local-marketplace.js +242 -14
  43. package/dist/src/utils/local-marketplace.js.map +1 -1
  44. package/dist/src/utils/plugin-config-impact.d.ts +33 -0
  45. package/dist/src/utils/plugin-config-impact.js +298 -0
  46. package/dist/src/utils/plugin-config-impact.js.map +1 -0
  47. package/dist/src/utils/plugin-config-write.d.ts +22 -2
  48. package/dist/src/utils/plugin-config-write.js +368 -104
  49. package/dist/src/utils/plugin-config-write.js.map +1 -1
  50. package/dist/src/utils/plugin-config.d.ts +10 -0
  51. package/dist/src/utils/plugin-config.js +39 -22
  52. package/dist/src/utils/plugin-config.js.map +1 -1
  53. package/dist/src/utils/plugin-scripts.js +47 -39
  54. package/dist/src/utils/plugin-scripts.js.map +1 -1
  55. package/dist/src/utils/project-boundary.js +22 -9
  56. package/dist/src/utils/project-boundary.js.map +1 -1
  57. package/dist/src/utils/sensitive-content.d.ts +3 -0
  58. package/dist/src/utils/sensitive-content.js +28 -7
  59. package/dist/src/utils/sensitive-content.js.map +1 -1
  60. package/package.json +3 -3
package/dist/src/index.js CHANGED
@@ -694,6 +694,7 @@ async function executeWriteCommand(command, pluginNames, rawOptions, context, di
694
694
  const runtime = {
695
695
  ...context,
696
696
  directCli,
697
+ preApplyConfirmed: rawOptions.yes === true,
697
698
  ...(managedCodexAuthorizer ? { managedCodexAuthorizer } : {}),
698
699
  };
699
700
  switch (command) {
@@ -884,6 +885,30 @@ function configLayerLabel(scope) {
884
885
  return '当前项目';
885
886
  }
886
887
  function writeConfigApplyNotice(write, receipt) {
888
+ const sanitizeMessage = (message) => redactString(message)
889
+ .replace(/https?:\/\/\S+/giu, '[REDACTED URL]')
890
+ .replace(/(?:file:\/\/)?(?:\/[\w.@+-]+){2,}/gu, '[REDACTED PATH]')
891
+ .replace(/[A-Za-z]:\\(?:[^\s\\]+\\)+[^\s\\]*/gu, '[REDACTED PATH]');
892
+ const writeTargetFailures = () => {
893
+ for (const entry of receipt.apply.targetResults.filter((target) => target.state === 'failed' || target.state === 'skipped')) {
894
+ const reason = entry.message
895
+ ? `${entry.errorCode ? `[${entry.errorCode}] ` : ''}${sanitizeMessage(entry.message)}`
896
+ : entry.errorCode
897
+ ? `失败原因:${entry.errorCode}。`
898
+ : '未提供安全失败原因。';
899
+ const command = `aw reinstall ${receipt.plugin} -p ${entry.target.platform} -s ${entry.target.scope}`;
900
+ const recovery = entry.errorCode === 'invalidConfig'
901
+ ? ' 请修复无效配置后运行 aw sync。'
902
+ : entry.errorCode === 'preApplyAuthorizationRequired'
903
+ || entry.errorCode === 'sharedNativeConfigApplyConfirmationRequired'
904
+ || entry.errorCode === 'sharedNativeImpactAuthorizationRequired'
905
+ ? ` 请运行 ${command} --yes 重试。`
906
+ : entry.state === 'failed'
907
+ ? ` 请在解决失败原因后运行 ${command}。`
908
+ : '';
909
+ writeLine(write, `${entry.target.platform}/${entry.target.scope}:${reason}${recovery}`);
910
+ }
911
+ };
887
912
  const targetResults = receipt.apply.targetResults;
888
913
  if (receipt.apply.state === 'skipped') {
889
914
  const message = receipt.apply.reason === 'noConfigChange'
@@ -896,24 +921,34 @@ function writeConfigApplyNotice(write, receipt) {
896
921
  writeLine(write, message);
897
922
  }
898
923
  else if (receipt.apply.state === 'unavailable') {
899
- const message = receipt.apply.reason === 'invalidConfig'
900
- ? '配置已保存,但可见目标的配置无效,因此没有应用。请先修复无效字段。'
901
- : '配置已保存,但当前无法应用配置。请修复报告的问题后运行 aw sync。';
902
- writeLine(write, message);
924
+ const fallbackMessages = {
925
+ invalidConfig: '可见目标的有效配置无效。',
926
+ schemaUnavailable: '配置 schema 不可用。',
927
+ sourceUnavailable: '插件来源不可用。',
928
+ effectiveConfigUnavailable: '无法读取有效配置。',
929
+ targetDiscoveryFailed: '无法发现可应用配置的目标。',
930
+ };
931
+ const detail = receipt.apply.error
932
+ ? `${receipt.apply.error.code}:${sanitizeMessage(receipt.apply.error.message)}`
933
+ : `${receipt.apply.reason}:${fallbackMessages[receipt.apply.reason]}`;
934
+ const recovery = receipt.apply.reason === 'invalidConfig'
935
+ ? '请修复无效配置后运行 aw sync。'
936
+ : receipt.apply.reason === 'effectiveConfigUnavailable'
937
+ ? '请修复配置后运行 aw sync。'
938
+ : receipt.apply.reason === 'schemaUnavailable' || receipt.apply.reason === 'sourceUnavailable'
939
+ ? '请修复插件来源或配置后运行 aw sync。'
940
+ : '请修复来源或配置后运行 aw sync。';
941
+ writeLine(write, `配置已保存,但当前无法应用配置。${detail} ${recovery}`);
942
+ writeTargetFailures();
903
943
  }
904
944
  else {
905
945
  const completed = targetResults.filter((entry) => entry.state === 'completed').length;
906
- const failed = targetResults.filter((entry) => entry.state === 'failed');
946
+ const failed = targetResults.filter((entry) => entry.state === 'failed').length;
907
947
  const skipped = targetResults.filter((entry) => entry.state === 'skipped').length;
908
- writeLine(write, `配置已保存。已重装 ${completed} 个当前可见目标;失败 ${failed.length} 个;跳过 ${skipped} 个。`);
909
- for (const entry of failed) {
910
- writeLine(write, `${entry.target.platform}/${entry.target.scope}:${entry.message ?? 'reinstall 失败。'} `
911
- + `请重试 aw reinstall ${receipt.plugin} -p ${entry.target.platform} -s ${entry.target.scope}。`);
912
- }
913
- }
914
- if (receipt.otherProjectsMayRequireSync) {
915
- writeLine(write, '其它项目没有被扫描,可能需要在对应项目目录中运行 aw sync。');
948
+ writeLine(write, `配置已保存。已重装 ${completed} 个当前可见目标;失败 ${failed} 个;跳过 ${skipped} 个。`);
949
+ writeTargetFailures();
916
950
  }
951
+ writeWarnings(write, receipt.warnings);
917
952
  }
918
953
  function renderConfigFieldState(field) {
919
954
  if (field.valueState === 'invalid') {
@@ -2790,6 +2825,7 @@ export function buildProgram(options = {}) {
2790
2825
  },
2791
2826
  apply: rawOptions.apply === true,
2792
2827
  sharedNativeApplyConfirmed: rawOptions.yes === true,
2828
+ preApplyConfirmed: rawOptions.yes === true,
2793
2829
  });
2794
2830
  return buildConfigMutationReceipt('config:set', {
2795
2831
  ok: writeReceipt.overallState === 'succeeded',
@@ -2878,6 +2914,7 @@ export function buildProgram(options = {}) {
2878
2914
  },
2879
2915
  apply: rawOptions.apply === true,
2880
2916
  sharedNativeApplyConfirmed: confirmed,
2917
+ preApplyConfirmed: rawOptions.yes === true,
2881
2918
  });
2882
2919
  return buildConfigMutationReceipt('config:unset', {
2883
2920
  ok: writeReceipt.overallState === 'succeeded',
@@ -2962,7 +2999,7 @@ export function buildProgram(options = {}) {
2962
2999
  .option('-s, --scope <scope>', 'project or user')
2963
3000
  .option('--apply', 'apply the saved config to visible desired placements', false)
2964
3001
  .option('--script-timeout <ms>', 'override plugin preApply script timeout in milliseconds')
2965
- .option('-y, --yes', 'confirm destructive reset', false)
3002
+ .option('-y, --yes', 'confirm destructive reset and preApply/shared Codex native config apply', false)
2966
3003
  .option('-j, --json', 'print receipt as JSON', false)
2967
3004
  .option('-v, --verbose', 'show command diagnostics', false)
2968
3005
  .option('-D, --debug', 'write debug diagnostics to a log file', false)
@@ -3008,6 +3045,7 @@ export function buildProgram(options = {}) {
3008
3045
  apply: rawOptions.apply === true,
3009
3046
  rebuildRuntime: scriptTimeoutMs === undefined ? undefined : { scriptTimeoutMs },
3010
3047
  sharedNativeApplyConfirmed: confirmed,
3048
+ preApplyConfirmed: rawOptions.yes === true,
3011
3049
  });
3012
3050
  return buildConfigMutationReceipt('config:reset', {
3013
3051
  ok: resetReceipt.overallState === 'succeeded',