wp-typia 0.22.0 → 0.22.2

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.
@@ -3,7 +3,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
3
  // package.json
4
4
  var package_default = {
5
5
  name: "wp-typia",
6
- version: "0.22.0",
6
+ version: "0.22.2",
7
7
  description: "Canonical CLI package for wp-typia scaffolding and project workflows",
8
8
  packageManager: "bun@1.3.11",
9
9
  type: "module",
@@ -73,7 +73,7 @@ var package_default = {
73
73
  "@bunli/tui": "0.6.0",
74
74
  "@bunli/utils": "0.6.0",
75
75
  "@wp-typia/api-client": "^0.4.5",
76
- "@wp-typia/project-tools": "0.22.0",
76
+ "@wp-typia/project-tools": "0.22.2",
77
77
  "better-result": "^2.7.0",
78
78
  react: "^19.2.5",
79
79
  "react-dom": "^19.2.5",
@@ -98,10 +98,10 @@ var package_default = {
98
98
  // src/node-cli.ts
99
99
  import {
100
100
  CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES5,
101
- createCliCommandError,
101
+ createCliCommandError as createCliCommandError2,
102
102
  createCliDiagnosticCodeError as createCliDiagnosticCodeError5,
103
103
  formatCliDiagnosticError,
104
- serializeCliDiagnosticError
104
+ serializeCliDiagnosticError as serializeCliDiagnosticError2
105
105
  } from "@wp-typia/project-tools/cli-diagnostics";
106
106
 
107
107
  // src/command-option-metadata.ts
@@ -316,6 +316,12 @@ var MIGRATE_OPTION_METADATA = {
316
316
  type: "string"
317
317
  }
318
318
  };
319
+ var MCP_OPTION_METADATA = {
320
+ "output-dir": {
321
+ description: "Output directory for generated MCP metadata.",
322
+ type: "string"
323
+ }
324
+ };
319
325
  var SYNC_OPTION_METADATA = {
320
326
  check: {
321
327
  argumentKind: "flag",
@@ -353,10 +359,6 @@ var GLOBAL_OPTION_METADATA = {
353
359
  id: {
354
360
  description: "Template id for top-level `templates inspect` convenience.",
355
361
  type: "string"
356
- },
357
- "output-dir": {
358
- description: "Output directory for generated MCP metadata.",
359
- type: "string"
360
362
  }
361
363
  };
362
364
  var COMMAND_OPTION_METADATA_BY_GROUP = {
@@ -366,6 +368,7 @@ var COMMAND_OPTION_METADATA_BY_GROUP = {
366
368
  global: GLOBAL_OPTION_METADATA,
367
369
  init: INIT_OPTION_METADATA,
368
370
  migrate: MIGRATE_OPTION_METADATA,
371
+ mcp: MCP_OPTION_METADATA,
369
372
  sync: SYNC_OPTION_METADATA,
370
373
  templates: TEMPLATES_OPTION_METADATA
371
374
  };
@@ -575,6 +578,73 @@ function resolveCommandOptionValues(metadata, options) {
575
578
  return resolved;
576
579
  }
577
580
 
581
+ // src/cli-diagnostic-output.ts
582
+ import {
583
+ createCliCommandError,
584
+ serializeCliDiagnosticError
585
+ } from "@wp-typia/project-tools/cli-diagnostics";
586
+
587
+ // bin/argv-walker.js
588
+ function normalizeOptionSet(values) {
589
+ return values instanceof Set ? values : new Set(values);
590
+ }
591
+ function collectPositionalIndexes(argv, metadata) {
592
+ const longValueOptionSet = normalizeOptionSet(metadata.longValueOptions);
593
+ const shortValueOptionSet = normalizeOptionSet(metadata.shortValueOptions);
594
+ const positionalIndexes = [];
595
+ for (let index = 0;index < argv.length; index += 1) {
596
+ const arg = argv[index];
597
+ if (arg === "--") {
598
+ for (let restIndex = index + 1;restIndex < argv.length; restIndex += 1) {
599
+ positionalIndexes.push(restIndex);
600
+ }
601
+ break;
602
+ }
603
+ if (!arg.startsWith("-") || arg === "-") {
604
+ positionalIndexes.push(index);
605
+ continue;
606
+ }
607
+ if (arg.startsWith("--")) {
608
+ if (arg.includes("=")) {
609
+ continue;
610
+ }
611
+ const next = argv[index + 1];
612
+ if (longValueOptionSet.has(arg) && next && !next.startsWith("-")) {
613
+ index += 1;
614
+ }
615
+ continue;
616
+ }
617
+ if (arg.length === 2 && shortValueOptionSet.has(arg) && argv[index + 1] && !argv[index + 1].startsWith("-")) {
618
+ index += 1;
619
+ }
620
+ }
621
+ return positionalIndexes;
622
+ }
623
+ function findFirstPositionalIndex(argv, metadata) {
624
+ const positionalIndexes = collectPositionalIndexes(argv, metadata);
625
+ return positionalIndexes[0] ?? -1;
626
+ }
627
+
628
+ // src/cli-diagnostic-output.ts
629
+ function prefersStructuredCliArgv(argv) {
630
+ for (let index = 0;index < argv.length; index += 1) {
631
+ const arg = argv[index];
632
+ if (!arg) {
633
+ continue;
634
+ }
635
+ if (arg === "--") {
636
+ return false;
637
+ }
638
+ if (arg === "--format") {
639
+ return argv[index + 1] === "json";
640
+ }
641
+ if (arg.startsWith("--format=")) {
642
+ return arg.slice("--format=".length) === "json";
643
+ }
644
+ }
645
+ return false;
646
+ }
647
+
578
648
  // src/node-cli.ts
579
649
  import {
580
650
  getTemplateById,
@@ -586,6 +656,24 @@ import {
586
656
  CLI_DIAGNOSTIC_CODES,
587
657
  createCliDiagnosticCodeError
588
658
  } from "@wp-typia/project-tools/cli-diagnostics";
659
+
660
+ // src/add-kind-ids.ts
661
+ var ADD_KIND_IDS = [
662
+ "admin-view",
663
+ "block",
664
+ "variation",
665
+ "style",
666
+ "transform",
667
+ "pattern",
668
+ "binding-source",
669
+ "rest-resource",
670
+ "ability",
671
+ "ai-feature",
672
+ "hooked-block",
673
+ "editor-plugin"
674
+ ];
675
+
676
+ // src/add-kind-registry.ts
589
677
  var BLOCK_VISIBLE_FIELD_ORDER = [
590
678
  "kind",
591
679
  "name",
@@ -595,6 +683,54 @@ var BLOCK_VISIBLE_FIELD_ORDER = [
595
683
  "data-storage",
596
684
  "persistence-policy"
597
685
  ];
686
+ var NAME_ONLY_VISIBLE_FIELDS = [
687
+ "kind",
688
+ "name"
689
+ ];
690
+ var NAME_SOURCE_VISIBLE_FIELDS = [
691
+ "kind",
692
+ "name",
693
+ "source"
694
+ ];
695
+ var NAME_BLOCK_ATTRIBUTE_VISIBLE_FIELDS = [
696
+ "kind",
697
+ "name",
698
+ "block",
699
+ "attribute"
700
+ ];
701
+ var NAME_BLOCK_VISIBLE_FIELDS = [
702
+ "kind",
703
+ "name",
704
+ "block"
705
+ ];
706
+ var NAME_SLOT_VISIBLE_FIELDS = [
707
+ "kind",
708
+ "name",
709
+ "slot"
710
+ ];
711
+ var NAME_ANCHOR_POSITION_VISIBLE_FIELDS = [
712
+ "kind",
713
+ "name",
714
+ "anchor",
715
+ "position"
716
+ ];
717
+ var NAME_FROM_TO_VISIBLE_FIELDS = [
718
+ "kind",
719
+ "name",
720
+ "from",
721
+ "to"
722
+ ];
723
+ var NAME_NAMESPACE_METHODS_VISIBLE_FIELDS = [
724
+ "kind",
725
+ "name",
726
+ "namespace",
727
+ "methods"
728
+ ];
729
+ var NAME_NAMESPACE_VISIBLE_FIELDS = [
730
+ "kind",
731
+ "name",
732
+ "namespace"
733
+ ];
598
734
  function readOptionalStringFlag(flags, name) {
599
735
  const value = flags[name];
600
736
  if (value === undefined || value === null) {
@@ -605,6 +741,21 @@ function readOptionalStringFlag(flags, name) {
605
741
  }
606
742
  return value;
607
743
  }
744
+ function requireStringFlag(flags, name, message) {
745
+ const value = readOptionalStringFlag(flags, name);
746
+ if (!value) {
747
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, message);
748
+ }
749
+ return value;
750
+ }
751
+ function readOptionalPairedStringFlags(flags, leftName, rightName, message) {
752
+ const leftValue = readOptionalStringFlag(flags, leftName);
753
+ const rightValue = readOptionalStringFlag(flags, rightName);
754
+ if (Boolean(leftValue) !== Boolean(rightValue)) {
755
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, message);
756
+ }
757
+ return [leftValue, rightValue];
758
+ }
608
759
  function requireAddKindName(context, message) {
609
760
  if (!context.name) {
610
761
  throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, message);
@@ -628,6 +779,15 @@ function toExternalLayerPromptOptions(options) {
628
779
  function defineAddKindRegistryEntry(entry) {
629
780
  return entry;
630
781
  }
782
+ function createNamedExecutionPlan(context, options) {
783
+ const name = options.name ?? requireAddKindName(context, options.missingNameMessage);
784
+ return {
785
+ execute: (cwd) => options.execute({ cwd, name }),
786
+ getValues: options.getValues,
787
+ ...options.getWarnings ? { getWarnings: options.getWarnings } : {},
788
+ ...options.warnLine ? { warnLine: options.warnLine } : {}
789
+ };
790
+ }
631
791
  function isAddPersistenceTemplate(template) {
632
792
  return template === "persistence" || template === "compound";
633
793
  }
@@ -650,22 +810,24 @@ var ADD_KIND_REGISTRY = {
650
810
  async prepareExecution(context) {
651
811
  const name = requireAddKindName(context, "`wp-typia add admin-view` requires <name>. Usage: wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>].");
652
812
  const source = readOptionalStringFlag(context.flags, "source");
653
- return {
654
- execute: (cwd) => context.addRuntime.runAddAdminViewCommand({
655
- adminViewName: name,
813
+ return createNamedExecutionPlan(context, {
814
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddAdminViewCommand({
815
+ adminViewName: name2,
656
816
  cwd,
657
817
  source
658
818
  }),
659
819
  getValues: (result) => ({
660
820
  adminViewSlug: result.adminViewSlug,
661
821
  ...result.source ? { source: result.source } : {}
662
- })
663
- };
822
+ }),
823
+ missingNameMessage: "`wp-typia add admin-view` requires <name>. Usage: wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>].",
824
+ name
825
+ });
664
826
  },
665
827
  sortOrder: 10,
666
828
  supportsDryRun: true,
667
829
  usage: "wp-typia add admin-view <name> [--source <rest-resource:slug|core-data:kind/name>] [--dry-run]",
668
- visibleFieldNames: () => ["kind", "name", "source"]
830
+ visibleFieldNames: () => NAME_SOURCE_VISIBLE_FIELDS
669
831
  }),
670
832
  "binding-source": defineAddKindRegistryEntry({
671
833
  completion: {
@@ -687,15 +849,11 @@ var ADD_KIND_REGISTRY = {
687
849
  nameLabel: "Binding source name",
688
850
  async prepareExecution(context) {
689
851
  const name = requireAddKindName(context, "`wp-typia add binding-source` requires <name>. Usage: wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>].");
690
- const blockName = readOptionalStringFlag(context.flags, "block");
691
- const attributeName = readOptionalStringFlag(context.flags, "attribute");
692
- if (Boolean(blockName) !== Boolean(attributeName)) {
693
- throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add binding-source` requires --block and --attribute to be provided together.");
694
- }
695
- return {
696
- execute: (cwd) => context.addRuntime.runAddBindingSourceCommand({
852
+ const [blockName, attributeName] = readOptionalPairedStringFlags(context.flags, "block", "attribute", "`wp-typia add binding-source` requires --block and --attribute to be provided together.");
853
+ return createNamedExecutionPlan(context, {
854
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddBindingSourceCommand({
697
855
  attributeName,
698
- bindingSourceName: name,
856
+ bindingSourceName: name2,
699
857
  blockName,
700
858
  cwd
701
859
  }),
@@ -703,13 +861,15 @@ var ADD_KIND_REGISTRY = {
703
861
  ...result.attributeName ? { attributeName: result.attributeName } : {},
704
862
  ...result.blockSlug ? { blockSlug: result.blockSlug } : {},
705
863
  bindingSourceSlug: result.bindingSourceSlug
706
- })
707
- };
864
+ }),
865
+ missingNameMessage: "`wp-typia add binding-source` requires <name>. Usage: wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>].",
866
+ name
867
+ });
708
868
  },
709
869
  sortOrder: 70,
710
870
  supportsDryRun: true,
711
871
  usage: "wp-typia add binding-source <name> [--block <block-slug|namespace/block-slug> --attribute <attribute>] [--dry-run]",
712
- visibleFieldNames: () => ["kind", "name", "block", "attribute"]
872
+ visibleFieldNames: () => NAME_BLOCK_ATTRIBUTE_VISIBLE_FIELDS
713
873
  }),
714
874
  block: defineAddKindRegistryEntry({
715
875
  completion: {
@@ -747,10 +907,10 @@ var ADD_KIND_REGISTRY = {
747
907
  })), 1);
748
908
  }
749
909
  resolvedTemplateId ??= "basic";
750
- return {
751
- execute: (cwd) => context.addRuntime.runAddBlockCommand({
910
+ return createNamedExecutionPlan(context, {
911
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddBlockCommand({
752
912
  alternateRenderTargets,
753
- blockName: name,
913
+ blockName: name2,
754
914
  cwd,
755
915
  dataStorageMode,
756
916
  externalLayerId,
@@ -765,8 +925,10 @@ var ADD_KIND_REGISTRY = {
765
925
  templateId: result.templateId
766
926
  }),
767
927
  getWarnings: (result) => result.warnings,
928
+ missingNameMessage: "`wp-typia add block` requires <name>. Usage: wp-typia add block <name> [--template <basic|interactivity|persistence|compound>]",
929
+ name,
768
930
  warnLine: context.warnLine
769
- };
931
+ });
770
932
  },
771
933
  sortOrder: 20,
772
934
  supportsDryRun: true,
@@ -799,21 +961,21 @@ var ADD_KIND_REGISTRY = {
799
961
  description: "Add a typed server/client workflow ability scaffold",
800
962
  nameLabel: "Ability name",
801
963
  async prepareExecution(context) {
802
- const name = requireAddKindName(context, "`wp-typia add ability` requires <name>. Usage: wp-typia add ability <name>.");
803
- return {
804
- execute: (cwd) => context.addRuntime.runAddAbilityCommand({
964
+ return createNamedExecutionPlan(context, {
965
+ execute: ({ cwd, name }) => context.addRuntime.runAddAbilityCommand({
805
966
  abilityName: name,
806
967
  cwd
807
968
  }),
808
969
  getValues: (result) => ({
809
970
  abilitySlug: result.abilitySlug
810
- })
811
- };
971
+ }),
972
+ missingNameMessage: "`wp-typia add ability` requires <name>. Usage: wp-typia add ability <name>."
973
+ });
812
974
  },
813
975
  sortOrder: 90,
814
976
  supportsDryRun: true,
815
977
  usage: "wp-typia add ability <name> [--dry-run]",
816
- visibleFieldNames: () => ["kind", "name"]
978
+ visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
817
979
  }),
818
980
  "editor-plugin": defineAddKindRegistryEntry({
819
981
  completion: {
@@ -833,22 +995,24 @@ var ADD_KIND_REGISTRY = {
833
995
  async prepareExecution(context) {
834
996
  const name = requireAddKindName(context, "`wp-typia add editor-plugin` requires <name>. Usage: wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>].");
835
997
  const slot = readOptionalStringFlag(context.flags, "slot");
836
- return {
837
- execute: (cwd) => context.addRuntime.runAddEditorPluginCommand({
998
+ return createNamedExecutionPlan(context, {
999
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddEditorPluginCommand({
838
1000
  cwd,
839
- editorPluginName: name,
1001
+ editorPluginName: name2,
840
1002
  slot
841
1003
  }),
842
1004
  getValues: (result) => ({
843
1005
  editorPluginSlug: result.editorPluginSlug,
844
1006
  slot: result.slot
845
- })
846
- };
1007
+ }),
1008
+ missingNameMessage: "`wp-typia add editor-plugin` requires <name>. Usage: wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>].",
1009
+ name
1010
+ });
847
1011
  },
848
1012
  sortOrder: 120,
849
1013
  supportsDryRun: true,
850
1014
  usage: "wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>] [--dry-run]",
851
- visibleFieldNames: () => ["kind", "name", "slot"]
1015
+ visibleFieldNames: () => NAME_SLOT_VISIBLE_FIELDS
852
1016
  }),
853
1017
  "hooked-block": defineAddKindRegistryEntry({
854
1018
  completion: {
@@ -868,18 +1032,12 @@ var ADD_KIND_REGISTRY = {
868
1032
  nameLabel: "Target block",
869
1033
  async prepareExecution(context) {
870
1034
  const name = requireAddKindName(context, "`wp-typia add hooked-block` requires <block-slug>. Usage: wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild>.");
871
- const anchorBlockName = readOptionalStringFlag(context.flags, "anchor");
872
- if (!anchorBlockName) {
873
- throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add hooked-block` requires --anchor <anchor-block-name>.");
874
- }
875
- const position = readOptionalStringFlag(context.flags, "position");
876
- if (!position) {
877
- throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add hooked-block` requires --position <before|after|firstChild|lastChild>.");
878
- }
879
- return {
880
- execute: (cwd) => context.addRuntime.runAddHookedBlockCommand({
1035
+ const anchorBlockName = requireStringFlag(context.flags, "anchor", "`wp-typia add hooked-block` requires --anchor <anchor-block-name>.");
1036
+ const position = requireStringFlag(context.flags, "position", "`wp-typia add hooked-block` requires --position <before|after|firstChild|lastChild>.");
1037
+ return createNamedExecutionPlan(context, {
1038
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddHookedBlockCommand({
881
1039
  anchorBlockName,
882
- blockName: name,
1040
+ blockName: name2,
883
1041
  cwd,
884
1042
  position
885
1043
  }),
@@ -887,13 +1045,15 @@ var ADD_KIND_REGISTRY = {
887
1045
  anchorBlockName: result.anchorBlockName,
888
1046
  blockSlug: result.blockSlug,
889
1047
  position: result.position
890
- })
891
- };
1048
+ }),
1049
+ missingNameMessage: "`wp-typia add hooked-block` requires <block-slug>. Usage: wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild>.",
1050
+ name
1051
+ });
892
1052
  },
893
1053
  sortOrder: 110,
894
1054
  supportsDryRun: true,
895
1055
  usage: "wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild> [--dry-run]",
896
- visibleFieldNames: () => ["kind", "name", "anchor", "position"]
1056
+ visibleFieldNames: () => NAME_ANCHOR_POSITION_VISIBLE_FIELDS
897
1057
  }),
898
1058
  pattern: defineAddKindRegistryEntry({
899
1059
  completion: {
@@ -910,21 +1070,21 @@ var ADD_KIND_REGISTRY = {
910
1070
  description: "Add a PHP block pattern shell",
911
1071
  nameLabel: "Pattern name",
912
1072
  async prepareExecution(context) {
913
- const name = requireAddKindName(context, "`wp-typia add pattern` requires <name>. Usage: wp-typia add pattern <name>.");
914
- return {
915
- execute: (cwd) => context.addRuntime.runAddPatternCommand({
1073
+ return createNamedExecutionPlan(context, {
1074
+ execute: ({ cwd, name }) => context.addRuntime.runAddPatternCommand({
916
1075
  cwd,
917
1076
  patternName: name
918
1077
  }),
919
1078
  getValues: (result) => ({
920
1079
  patternSlug: result.patternSlug
921
- })
922
- };
1080
+ }),
1081
+ missingNameMessage: "`wp-typia add pattern` requires <name>. Usage: wp-typia add pattern <name>."
1082
+ });
923
1083
  },
924
1084
  sortOrder: 60,
925
1085
  supportsDryRun: true,
926
1086
  usage: "wp-typia add pattern <name> [--dry-run]",
927
- visibleFieldNames: () => ["kind", "name"]
1087
+ visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
928
1088
  }),
929
1089
  style: defineAddKindRegistryEntry({
930
1090
  completion: {
@@ -943,26 +1103,25 @@ var ADD_KIND_REGISTRY = {
943
1103
  nameLabel: "Style name",
944
1104
  async prepareExecution(context) {
945
1105
  const name = requireAddKindName(context, "`wp-typia add style` requires <name>. Usage: wp-typia add style <name> --block <block-slug>.");
946
- const blockSlug = readOptionalStringFlag(context.flags, "block");
947
- if (!blockSlug) {
948
- throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add style` requires --block <block-slug>.");
949
- }
950
- return {
951
- execute: (cwd) => context.addRuntime.runAddBlockStyleCommand({
1106
+ const blockSlug = requireStringFlag(context.flags, "block", "`wp-typia add style` requires --block <block-slug>.");
1107
+ return createNamedExecutionPlan(context, {
1108
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddBlockStyleCommand({
952
1109
  blockName: blockSlug,
953
1110
  cwd,
954
- styleName: name
1111
+ styleName: name2
955
1112
  }),
956
1113
  getValues: (result) => ({
957
1114
  blockSlug: result.blockSlug,
958
1115
  styleSlug: result.styleSlug
959
- })
960
- };
1116
+ }),
1117
+ missingNameMessage: "`wp-typia add style` requires <name>. Usage: wp-typia add style <name> --block <block-slug>.",
1118
+ name
1119
+ });
961
1120
  },
962
1121
  sortOrder: 40,
963
1122
  supportsDryRun: true,
964
1123
  usage: "wp-typia add style <name> --block <block-slug> [--dry-run]",
965
- visibleFieldNames: () => ["kind", "name", "block"]
1124
+ visibleFieldNames: () => NAME_BLOCK_VISIBLE_FIELDS
966
1125
  }),
967
1126
  transform: defineAddKindRegistryEntry({
968
1127
  completion: {
@@ -982,33 +1141,29 @@ var ADD_KIND_REGISTRY = {
982
1141
  nameLabel: "Transform name",
983
1142
  async prepareExecution(context) {
984
1143
  const name = requireAddKindName(context, "`wp-typia add transform` requires <name>. Usage: wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>.");
985
- const fromBlockName = readOptionalStringFlag(context.flags, "from");
986
- if (!fromBlockName) {
987
- throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add transform` requires --from <namespace/block>.");
988
- }
989
- const toBlockName = readOptionalStringFlag(context.flags, "to");
990
- if (!toBlockName) {
991
- throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add transform` requires --to <block-slug|namespace/block-slug>.");
992
- }
993
- return {
994
- execute: (cwd) => context.addRuntime.runAddBlockTransformCommand({
1144
+ const fromBlockName = requireStringFlag(context.flags, "from", "`wp-typia add transform` requires --from <namespace/block>.");
1145
+ const toBlockName = requireStringFlag(context.flags, "to", "`wp-typia add transform` requires --to <block-slug|namespace/block-slug>.");
1146
+ return createNamedExecutionPlan(context, {
1147
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddBlockTransformCommand({
995
1148
  cwd,
996
1149
  fromBlockName,
997
1150
  toBlockName,
998
- transformName: name
1151
+ transformName: name2
999
1152
  }),
1000
1153
  getValues: (result) => ({
1001
1154
  blockSlug: result.blockSlug,
1002
1155
  fromBlockName: result.fromBlockName,
1003
1156
  toBlockName: result.toBlockName,
1004
1157
  transformSlug: result.transformSlug
1005
- })
1006
- };
1158
+ }),
1159
+ missingNameMessage: "`wp-typia add transform` requires <name>. Usage: wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug>.",
1160
+ name
1161
+ });
1007
1162
  },
1008
1163
  sortOrder: 50,
1009
1164
  supportsDryRun: true,
1010
1165
  usage: "wp-typia add transform <name> --from <namespace/block> --to <block-slug|namespace/block-slug> [--dry-run]",
1011
- visibleFieldNames: () => ["kind", "name", "from", "to"]
1166
+ visibleFieldNames: () => NAME_FROM_TO_VISIBLE_FIELDS
1012
1167
  }),
1013
1168
  "rest-resource": defineAddKindRegistryEntry({
1014
1169
  completion: {
@@ -1030,24 +1185,26 @@ var ADD_KIND_REGISTRY = {
1030
1185
  const name = requireAddKindName(context, "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create>].");
1031
1186
  const methods = readOptionalStringFlag(context.flags, "methods");
1032
1187
  const namespace = readOptionalStringFlag(context.flags, "namespace");
1033
- return {
1034
- execute: (cwd) => context.addRuntime.runAddRestResourceCommand({
1188
+ return createNamedExecutionPlan(context, {
1189
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddRestResourceCommand({
1035
1190
  cwd,
1036
1191
  methods,
1037
1192
  namespace,
1038
- restResourceName: name
1193
+ restResourceName: name2
1039
1194
  }),
1040
1195
  getValues: (result) => ({
1041
1196
  methods: result.methods.join(", "),
1042
1197
  namespace: result.namespace,
1043
1198
  restResourceSlug: result.restResourceSlug
1044
- })
1045
- };
1199
+ }),
1200
+ missingNameMessage: "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create>].",
1201
+ name
1202
+ });
1046
1203
  },
1047
1204
  sortOrder: 80,
1048
1205
  supportsDryRun: true,
1049
1206
  usage: "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--dry-run]",
1050
- visibleFieldNames: () => ["kind", "name", "namespace", "methods"]
1207
+ visibleFieldNames: () => NAME_NAMESPACE_METHODS_VISIBLE_FIELDS
1051
1208
  }),
1052
1209
  "ai-feature": defineAddKindRegistryEntry({
1053
1210
  completion: {
@@ -1067,9 +1224,9 @@ var ADD_KIND_REGISTRY = {
1067
1224
  async prepareExecution(context) {
1068
1225
  const name = requireAddKindName(context, "`wp-typia add ai-feature` requires <name>. Usage: wp-typia add ai-feature <name> [--namespace <vendor/v1>].");
1069
1226
  const namespace = readOptionalStringFlag(context.flags, "namespace");
1070
- return {
1071
- execute: (cwd) => context.addRuntime.runAddAiFeatureCommand({
1072
- aiFeatureName: name,
1227
+ return createNamedExecutionPlan(context, {
1228
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddAiFeatureCommand({
1229
+ aiFeatureName: name2,
1073
1230
  cwd,
1074
1231
  namespace
1075
1232
  }),
@@ -1078,13 +1235,15 @@ var ADD_KIND_REGISTRY = {
1078
1235
  namespace: result.namespace
1079
1236
  }),
1080
1237
  getWarnings: (result) => result.warnings,
1238
+ missingNameMessage: "`wp-typia add ai-feature` requires <name>. Usage: wp-typia add ai-feature <name> [--namespace <vendor/v1>].",
1239
+ name,
1081
1240
  warnLine: context.warnLine
1082
- };
1241
+ });
1083
1242
  },
1084
1243
  sortOrder: 100,
1085
1244
  supportsDryRun: true,
1086
1245
  usage: "wp-typia add ai-feature <name> [--namespace <vendor/v1>] [--dry-run]",
1087
- visibleFieldNames: () => ["kind", "name", "namespace"]
1246
+ visibleFieldNames: () => NAME_NAMESPACE_VISIBLE_FIELDS
1088
1247
  }),
1089
1248
  variation: defineAddKindRegistryEntry({
1090
1249
  completion: {
@@ -1103,29 +1262,27 @@ var ADD_KIND_REGISTRY = {
1103
1262
  nameLabel: "Variation name",
1104
1263
  async prepareExecution(context) {
1105
1264
  const name = requireAddKindName(context, "`wp-typia add variation` requires <name>. Usage: wp-typia add variation <name> --block <block-slug>");
1106
- const blockSlug = readOptionalStringFlag(context.flags, "block");
1107
- if (!blockSlug) {
1108
- throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, "`wp-typia add variation` requires --block <block-slug>.");
1109
- }
1110
- return {
1111
- execute: (cwd) => context.addRuntime.runAddVariationCommand({
1265
+ const blockSlug = requireStringFlag(context.flags, "block", "`wp-typia add variation` requires --block <block-slug>.");
1266
+ return createNamedExecutionPlan(context, {
1267
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddVariationCommand({
1112
1268
  blockName: blockSlug,
1113
1269
  cwd,
1114
- variationName: name
1270
+ variationName: name2
1115
1271
  }),
1116
1272
  getValues: (result) => ({
1117
1273
  blockSlug: result.blockSlug,
1118
1274
  variationSlug: result.variationSlug
1119
- })
1120
- };
1275
+ }),
1276
+ missingNameMessage: "`wp-typia add variation` requires <name>. Usage: wp-typia add variation <name> --block <block-slug>",
1277
+ name
1278
+ });
1121
1279
  },
1122
1280
  sortOrder: 30,
1123
1281
  supportsDryRun: true,
1124
1282
  usage: "wp-typia add variation <name> --block <block-slug> [--dry-run]",
1125
- visibleFieldNames: () => ["kind", "name", "block"]
1283
+ visibleFieldNames: () => NAME_BLOCK_VISIBLE_FIELDS
1126
1284
  })
1127
1285
  };
1128
- var ADD_KIND_IDS = Object.keys(ADD_KIND_REGISTRY).sort((left, right) => ADD_KIND_REGISTRY[left].sortOrder - ADD_KIND_REGISTRY[right].sortOrder);
1129
1286
  function isAddKindId(value) {
1130
1287
  return typeof value === "string" && ADD_KIND_IDS.includes(value);
1131
1288
  }
@@ -1528,15 +1685,7 @@ function buildStructuredCompletionSuccessPayload(command, completion, metadata =
1528
1685
  command,
1529
1686
  ...serializedCompletion ? {
1530
1687
  completion: serializedCompletion,
1531
- files: extractPlannedFiles(serializedCompletion),
1532
- nextSteps: serializedCompletion.nextSteps,
1533
- optionalLines: serializedCompletion.optionalLines,
1534
- optionalNote: serializedCompletion.optionalNote,
1535
- optionalTitle: serializedCompletion.optionalTitle,
1536
- preambleLines: serializedCompletion.preambleLines,
1537
- summaryLines: serializedCompletion.summaryLines,
1538
- title: serializedCompletion.title,
1539
- warnings: serializedCompletion.warningLines
1688
+ files: extractPlannedFiles(serializedCompletion)
1540
1689
  } : {}
1541
1690
  }
1542
1691
  };
@@ -1555,14 +1704,11 @@ function buildStructuredInitSuccessPayload(plan) {
1555
1704
  detectedLayout: plan.detectedLayout,
1556
1705
  files: toNonEmptyArray(files),
1557
1706
  mode: plan.commandMode === "apply" ? "apply" : "preview",
1558
- nextSteps: toNonEmptyArray(plan.nextSteps),
1559
1707
  packageManager: plan.packageManager,
1560
1708
  plan,
1561
1709
  projectDir: plan.projectDir,
1562
1710
  status: plan.status,
1563
- summary: plan.summary,
1564
- title: completion.title,
1565
- warnings: toNonEmptyArray(plan.notes)
1711
+ summary: plan.summary
1566
1712
  }
1567
1713
  };
1568
1714
  }
@@ -2008,8 +2154,8 @@ var loadCliScaffoldRuntime = () => import("@wp-typia/project-tools/cli-scaffold"
2008
2154
  var loadCliTemplatesRuntime = () => import("@wp-typia/project-tools/cli-templates");
2009
2155
  var loadMigrationsRuntime = () => import("@wp-typia/project-tools/migrations");
2010
2156
  async function wrapCliCommandError(command, error) {
2011
- const { createCliCommandError } = await loadCliDiagnosticsRuntime();
2012
- return createCliCommandError({ command, error });
2157
+ const { createCliCommandError: createCliCommandError2 } = await loadCliDiagnosticsRuntime();
2158
+ return createCliCommandError2({ command, error });
2013
2159
  }
2014
2160
  function shouldWrapCliCommandError(options) {
2015
2161
  if (options.emitOutput === false) {
@@ -2382,47 +2528,6 @@ async function executeMigrateCommand({
2382
2528
  // src/command-contract.ts
2383
2529
  import path5 from "node:path";
2384
2530
 
2385
- // bin/argv-walker.js
2386
- function normalizeOptionSet(values) {
2387
- return values instanceof Set ? values : new Set(values);
2388
- }
2389
- function collectPositionalIndexes(argv, metadata) {
2390
- const longValueOptionSet = normalizeOptionSet(metadata.longValueOptions);
2391
- const shortValueOptionSet = normalizeOptionSet(metadata.shortValueOptions);
2392
- const positionalIndexes = [];
2393
- for (let index = 0;index < argv.length; index += 1) {
2394
- const arg = argv[index];
2395
- if (arg === "--") {
2396
- for (let restIndex = index + 1;restIndex < argv.length; restIndex += 1) {
2397
- positionalIndexes.push(restIndex);
2398
- }
2399
- break;
2400
- }
2401
- if (!arg.startsWith("-") || arg === "-") {
2402
- positionalIndexes.push(index);
2403
- continue;
2404
- }
2405
- if (arg.startsWith("--")) {
2406
- if (arg.includes("=")) {
2407
- continue;
2408
- }
2409
- const next = argv[index + 1];
2410
- if (longValueOptionSet.has(arg) && next && !next.startsWith("-")) {
2411
- index += 1;
2412
- }
2413
- continue;
2414
- }
2415
- if (arg.length === 2 && shortValueOptionSet.has(arg) && argv[index + 1] && !argv[index + 1].startsWith("-")) {
2416
- index += 1;
2417
- }
2418
- }
2419
- return positionalIndexes;
2420
- }
2421
- function findFirstPositionalIndex(argv, metadata) {
2422
- const positionalIndexes = collectPositionalIndexes(argv, metadata);
2423
- return positionalIndexes[0] ?? -1;
2424
- }
2425
-
2426
2531
  // src/command-registry.ts
2427
2532
  var WP_TYPIA_CANONICAL_CREATE_USAGE = "wp-typia create <project-dir>";
2428
2533
  var WP_TYPIA_POSITIONAL_ALIAS_USAGE = "wp-typia <project-dir>";
@@ -2462,17 +2567,7 @@ var WP_TYPIA_COMMAND_REGISTRY = [
2462
2567
  nodeFallback: true,
2463
2568
  optionGroups: ["add"],
2464
2569
  requiresBunRuntime: false,
2465
- subcommands: [
2466
- "block",
2467
- "variation",
2468
- "style",
2469
- "transform",
2470
- "pattern",
2471
- "binding-source",
2472
- "rest-resource",
2473
- "editor-plugin",
2474
- "hooked-block"
2475
- ]
2570
+ subcommands: ADD_KIND_IDS
2476
2571
  },
2477
2572
  {
2478
2573
  commandTree: true,
@@ -2517,7 +2612,7 @@ var WP_TYPIA_COMMAND_REGISTRY = [
2517
2612
  description: "Inspect or sync schema-driven MCP metadata.",
2518
2613
  name: "mcp",
2519
2614
  nodeFallback: false,
2520
- optionGroups: [],
2615
+ optionGroups: ["mcp"],
2521
2616
  requiresBunRuntime: true,
2522
2617
  subcommands: ["list", "sync"]
2523
2618
  },
@@ -2891,7 +2986,7 @@ function renderTemplatesJson(flags, subcommand) {
2891
2986
  }
2892
2987
  const templateId = flags.id;
2893
2988
  if (!templateId) {
2894
- throw createCliCommandError({
2989
+ throw createCliCommandError2({
2895
2990
  code: CLI_DIAGNOSTIC_CODES5.MISSING_ARGUMENT,
2896
2991
  command: "templates",
2897
2992
  detailLines: ["`wp-typia templates inspect` requires <template-id>."]
@@ -2899,7 +2994,7 @@ function renderTemplatesJson(flags, subcommand) {
2899
2994
  }
2900
2995
  const template = getTemplateById(templateId);
2901
2996
  if (!template) {
2902
- throw createCliCommandError({
2997
+ throw createCliCommandError2({
2903
2998
  code: CLI_DIAGNOSTIC_CODES5.INVALID_ARGUMENT,
2904
2999
  command: "templates",
2905
3000
  detailLines: [`Unknown template "${templateId}".`]
@@ -2910,7 +3005,7 @@ function renderTemplatesJson(flags, subcommand) {
2910
3005
  }, null, 2));
2911
3006
  }
2912
3007
  function renderUnsupportedCommand(command) {
2913
- throw createCliCommandError({
3008
+ throw createCliCommandError2({
2914
3009
  code: CLI_DIAGNOSTIC_CODES5.UNSUPPORTED_COMMAND,
2915
3010
  command,
2916
3011
  detailLines: [
@@ -2926,7 +3021,7 @@ function renderUnsupportedCommand(command) {
2926
3021
  async function renderDoctorJson() {
2927
3022
  const [
2928
3023
  { getDoctorChecks },
2929
- { createCliCommandError: createCliCommandError2, getDoctorFailureDetailLines }
3024
+ { createCliCommandError: createCliCommandError3, getDoctorFailureDetailLines }
2930
3025
  ] = await Promise.all([
2931
3026
  import("@wp-typia/project-tools/cli-doctor"),
2932
3027
  import("@wp-typia/project-tools/cli-diagnostics")
@@ -2936,7 +3031,7 @@ async function renderDoctorJson() {
2936
3031
  checks
2937
3032
  }, null, 2));
2938
3033
  if (checks.some((check) => check.status === "fail")) {
2939
- throw createCliCommandError2({
3034
+ throw createCliCommandError3({
2940
3035
  code: CLI_DIAGNOSTIC_CODES5.DOCTOR_CHECK_FAILED,
2941
3036
  command: "doctor",
2942
3037
  detailLines: getDoctorFailureDetailLines(checks),
@@ -2953,7 +3048,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
2953
3048
  if (!positionals[1]) {
2954
3049
  const { formatAddHelpText } = await import("@wp-typia/project-tools/cli-add");
2955
3050
  printLine(formatAddHelpText());
2956
- throw createCliCommandError({
3051
+ throw createCliCommandError2({
2957
3052
  code: CLI_DIAGNOSTIC_CODES5.MISSING_ARGUMENT,
2958
3053
  command: "add",
2959
3054
  detailLines: [
@@ -2973,7 +3068,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
2973
3068
  name: positionals[2]
2974
3069
  });
2975
3070
  } catch (error) {
2976
- throw createCliCommandError({
3071
+ throw createCliCommandError2({
2977
3072
  command: "add",
2978
3073
  error
2979
3074
  });
@@ -3001,7 +3096,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
3001
3096
  }) => {
3002
3097
  const projectDir = positionals[1];
3003
3098
  if (!projectDir) {
3004
- throw createCliCommandError({
3099
+ throw createCliCommandError2({
3005
3100
  code: CLI_DIAGNOSTIC_CODES5.MISSING_ARGUMENT,
3006
3101
  command: "create",
3007
3102
  detailLines: [
@@ -3020,7 +3115,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
3020
3115
  projectDir
3021
3116
  });
3022
3117
  } catch (error) {
3023
- throw createCliCommandError({
3118
+ throw createCliCommandError2({
3024
3119
  command: "create",
3025
3120
  error
3026
3121
  });
@@ -3098,7 +3193,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
3098
3193
  }));
3099
3194
  }
3100
3195
  } catch (error) {
3101
- throw createCliCommandError({
3196
+ throw createCliCommandError2({
3102
3197
  command: "sync",
3103
3198
  error
3104
3199
  });
@@ -3112,7 +3207,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
3112
3207
  const templateId = typeof mergedFlags.id === "string" ? mergedFlags.id : positionals[2];
3113
3208
  const resolvedSubcommand = templateId ? "inspect" : subcommand ?? "list";
3114
3209
  if (resolvedSubcommand !== "list" && resolvedSubcommand !== "inspect") {
3115
- throw createCliCommandError({
3210
+ throw createCliCommandError2({
3116
3211
  code: CLI_DIAGNOSTIC_CODES5.INVALID_COMMAND,
3117
3212
  command: "templates",
3118
3213
  detailLines: [
@@ -3185,21 +3280,16 @@ async function runNodeCli(argv = process.argv.slice(2)) {
3185
3280
  renderUnsupportedCommand(command ?? "(missing)");
3186
3281
  }
3187
3282
  async function runNodeCliEntrypoint(argv = process.argv.slice(2)) {
3283
+ const prefersStructuredErrorOutput = prefersStructuredCliArgv(argv);
3188
3284
  try {
3189
3285
  await runNodeCli(argv);
3190
3286
  } catch (error) {
3191
- let prefersStructuredErrorOutput = false;
3192
- try {
3193
- const normalizedArgv = normalizeWpTypiaArgv(argv);
3194
- const { argv: argvWithoutConfigOverride } = extractWpTypiaConfigOverride(normalizedArgv);
3195
- const { flags } = parseGlobalFlags(argvWithoutConfigOverride);
3196
- prefersStructuredErrorOutput = flags.format === "json";
3197
- } catch {}
3198
3287
  if (prefersStructuredErrorOutput) {
3199
- console.error(JSON.stringify({
3288
+ process.stderr.write(`${JSON.stringify({
3200
3289
  ok: false,
3201
- error: serializeCliDiagnosticError(error)
3202
- }, null, 2));
3290
+ error: serializeCliDiagnosticError2(error)
3291
+ }, null, 2)}
3292
+ `);
3203
3293
  process.exitCode = 1;
3204
3294
  return;
3205
3295
  }
@@ -3214,4 +3304,4 @@ export {
3214
3304
  hasFlagBeforeTerminator
3215
3305
  };
3216
3306
 
3217
- //# debugId=9D8430CB181D13B964756E2164756E21
3307
+ //# debugId=F8B7C97D684FB07764756E2164756E21