wp-typia 0.22.10 → 0.23.0

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.
@@ -19,7 +19,7 @@ import {
19
19
  package_default,
20
20
  prefersStructuredCliOutput,
21
21
  resolveCommandOptionValues
22
- } from "./cli-spdrcg8k.js";
22
+ } from "./cli-z5qkx2pn.js";
23
23
  import {
24
24
  Result,
25
25
  TaggedError,
@@ -38,7 +38,7 @@ import {
38
38
  } from "./cli-t73q5aqz.js";
39
39
  import {
40
40
  ADD_KIND_IDS
41
- } from "./cli-fys8vm2t.js";
41
+ } from "./cli-43mx1vfb.js";
42
42
  import {
43
43
  CLI_DIAGNOSTIC_CODES,
44
44
  createCliDiagnosticCodeError
@@ -59,6 +59,26 @@ import {
59
59
  // src/commands/add.ts
60
60
  var import_react34 = __toESM(require_react(), 1);
61
61
 
62
+ // src/commands/output-adapters.ts
63
+ var defaultPrintLine = (line) => {
64
+ process.stdout.write(`${line}
65
+ `);
66
+ };
67
+ var defaultWarnLine = (line) => {
68
+ process.stderr.write(`${line}
69
+ `);
70
+ };
71
+ function resolveCommandPrintLine(args) {
72
+ return args.printLine ?? defaultPrintLine;
73
+ }
74
+ function resolveCommandOutputAdapters(args) {
75
+ const adapters = args;
76
+ return {
77
+ printLine: adapters.printLine ?? defaultPrintLine,
78
+ warnLine: adapters.warnLine ?? defaultWarnLine
79
+ };
80
+ }
81
+
62
82
  // src/render-loader.ts
63
83
  import fs from "fs";
64
84
  import { fileURLToPath } from "url";
@@ -99,6 +119,11 @@ var NAME_SOURCE_VISIBLE_FIELDS = [
99
119
  "name",
100
120
  "source"
101
121
  ];
122
+ var NAME_TYPE_VISIBLE_FIELDS = [
123
+ "kind",
124
+ "name",
125
+ "type"
126
+ ];
102
127
  var NAME_BLOCK_ATTRIBUTE_VISIBLE_FIELDS = [
103
128
  "kind",
104
129
  "name",
@@ -138,6 +163,12 @@ var NAME_NAMESPACE_VISIBLE_FIELDS = [
138
163
  "name",
139
164
  "namespace"
140
165
  ];
166
+ var NAME_POST_TYPE_TYPE_VISIBLE_FIELDS = [
167
+ "kind",
168
+ "name",
169
+ "post-type",
170
+ "type"
171
+ ];
141
172
  function requireAddKindName(context, message) {
142
173
  if (!context.name) {
143
174
  throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT, message);
@@ -243,6 +274,9 @@ function readOptionalLooseStringFlag(flags, name) {
243
274
  function readOptionalStrictStringFlag(flags, name) {
244
275
  return readOptionalCliStringFlagValue(flags, name, "strict");
245
276
  }
277
+ function readOptionalDashedOrCamelStringFlag(flags, dashedName, camelName) {
278
+ return readOptionalStrictStringFlag(flags, dashedName) ?? readOptionalStrictStringFlag(flags, camelName);
279
+ }
246
280
  function requireStrictStringFlag(flags, name, message) {
247
281
  const value = readOptionalStrictStringFlag(flags, name);
248
282
  if (!value) {
@@ -290,7 +324,8 @@ var adminViewAddKindEntry = defineAddKindRegistryEntry({
290
324
  ...result.source ? { source: result.source } : {}
291
325
  }),
292
326
  missingNameMessage: ADMIN_VIEW_MISSING_NAME_MESSAGE,
293
- name
327
+ name,
328
+ warnLine: context.warnLine
294
329
  });
295
330
  },
296
331
  sortOrder: 10,
@@ -377,7 +412,8 @@ var bindingSourceAddKindEntry = defineAddKindRegistryEntry({
377
412
  bindingSourceSlug: result.bindingSourceSlug
378
413
  }),
379
414
  missingNameMessage: BINDING_SOURCE_MISSING_NAME_MESSAGE,
380
- name
415
+ name,
416
+ warnLine: context.warnLine
381
417
  });
382
418
  },
383
419
  sortOrder: 70,
@@ -481,6 +517,50 @@ var blockAddKindEntry = defineAddKindRegistryEntry({
481
517
  })
482
518
  });
483
519
 
520
+ // src/add-kinds/contract.ts
521
+ var CONTRACT_MISSING_NAME_MESSAGE = "`wp-typia add contract` requires <name>. Usage: wp-typia add contract <name> [--type <ExportedTypeName>].";
522
+ var contractAddKindEntry = defineAddKindRegistryEntry({
523
+ completion: {
524
+ nextSteps: (values) => [
525
+ `Edit ${values.typesFile} when the standalone wire shape changes.`,
526
+ "Run `wp-typia sync-rest` or `wp-typia sync` to refresh the generated schema artifact."
527
+ ],
528
+ summaryLines: (values, projectDir) => [
529
+ `Contract: ${values.contractSlug}`,
530
+ `Source type: ${values.sourceTypeName}`,
531
+ `Schema: ${values.schemaFile}`,
532
+ `Project directory: ${projectDir}`
533
+ ],
534
+ title: "Added standalone contract"
535
+ },
536
+ description: "Add a standalone TypeScript schema contract",
537
+ nameLabel: "Contract name",
538
+ async prepareExecution(context) {
539
+ const name = requireAddKindName(context, CONTRACT_MISSING_NAME_MESSAGE);
540
+ const typeName = readOptionalStrictStringFlag(context.flags, "type");
541
+ return createNamedExecutionPlan(context, {
542
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddContractCommand({
543
+ contractName: name2,
544
+ cwd,
545
+ typeName
546
+ }),
547
+ getValues: (result) => ({
548
+ contractSlug: result.contractSlug,
549
+ schemaFile: result.schemaFile,
550
+ sourceTypeName: result.sourceTypeName,
551
+ typesFile: result.typesFile
552
+ }),
553
+ missingNameMessage: CONTRACT_MISSING_NAME_MESSAGE,
554
+ name,
555
+ warnLine: context.warnLine
556
+ });
557
+ },
558
+ sortOrder: 75,
559
+ supportsDryRun: true,
560
+ usage: "wp-typia add contract <name> [--type <ExportedTypeName>] [--dry-run]",
561
+ visibleFieldNames: () => NAME_TYPE_VISIBLE_FIELDS
562
+ });
563
+
484
564
  // src/add-kinds/editor-plugin.ts
485
565
  var EDITOR_PLUGIN_MISSING_NAME_MESSAGE = "`wp-typia add editor-plugin` requires <name>. Usage: wp-typia add editor-plugin <name> [--slot <sidebar|document-setting-panel>].";
486
566
  var editorPluginAddKindEntry = defineAddKindRegistryEntry({
@@ -512,7 +592,8 @@ var editorPluginAddKindEntry = defineAddKindRegistryEntry({
512
592
  slot: result.slot
513
593
  }),
514
594
  missingNameMessage: EDITOR_PLUGIN_MISSING_NAME_MESSAGE,
515
- name
595
+ name,
596
+ warnLine: context.warnLine
516
597
  });
517
598
  },
518
599
  sortOrder: 120,
@@ -556,7 +637,8 @@ var hookedBlockAddKindEntry = defineAddKindRegistryEntry({
556
637
  position: result.position
557
638
  }),
558
639
  missingNameMessage: HOOKED_BLOCK_MISSING_NAME_MESSAGE,
559
- name
640
+ name,
641
+ warnLine: context.warnLine
560
642
  });
561
643
  },
562
644
  sortOrder: 110,
@@ -565,6 +647,51 @@ var hookedBlockAddKindEntry = defineAddKindRegistryEntry({
565
647
  visibleFieldNames: () => NAME_ANCHOR_POSITION_VISIBLE_FIELDS
566
648
  });
567
649
 
650
+ // src/add-kinds/integration-env.ts
651
+ var INTEGRATION_ENV_MISSING_NAME_MESSAGE = "`wp-typia add integration-env` requires <name>. Usage: wp-typia add integration-env <name> [--wp-env] [--service <none|docker-compose>].";
652
+ var integrationEnvAddKindEntry = defineAddKindRegistryEntry({
653
+ completion: {
654
+ nextSteps: (values) => [
655
+ `Review scripts/integration-smoke/${values.integrationEnvSlug}.mjs and docs/integration-env/${values.integrationEnvSlug}.md.`,
656
+ "Copy `.env.example` to `.env`, adjust local URLs or credentials, then run the generated smoke script.",
657
+ ...values.withWpEnv === "true" ? ["Run `npm run wp-env:start` before the smoke check when using the generated wp-env preset."] : []
658
+ ],
659
+ summaryLines: (values, projectDir) => [
660
+ `Integration env: ${values.integrationEnvSlug}`,
661
+ `wp-env preset: ${values.withWpEnv}`,
662
+ `Service starter: ${values.service}`,
663
+ `Project directory: ${projectDir}`
664
+ ],
665
+ title: "Added integration environment starter"
666
+ },
667
+ description: "Add an opt-in local WordPress integration smoke environment starter",
668
+ nameLabel: "Integration env name",
669
+ async prepareExecution(context) {
670
+ const service = readOptionalStrictStringFlag(context.flags, "service");
671
+ const withWpEnv = Boolean(context.flags["wp-env"]);
672
+ return createNamedExecutionPlan(context, {
673
+ execute: ({ cwd, name }) => context.addRuntime.runAddIntegrationEnvCommand({
674
+ cwd,
675
+ integrationEnvName: name,
676
+ service,
677
+ withWpEnv
678
+ }),
679
+ getValues: (result) => ({
680
+ integrationEnvSlug: result.integrationEnvSlug,
681
+ service: result.service,
682
+ withWpEnv: String(result.withWpEnv)
683
+ }),
684
+ getWarnings: (result) => result.warnings,
685
+ missingNameMessage: INTEGRATION_ENV_MISSING_NAME_MESSAGE,
686
+ warnLine: context.warnLine
687
+ });
688
+ },
689
+ sortOrder: 25,
690
+ supportsDryRun: true,
691
+ usage: "wp-typia add integration-env <name> [--wp-env] [--service <none|docker-compose>] [--dry-run]",
692
+ visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
693
+ });
694
+
568
695
  // src/add-kinds/pattern.ts
569
696
  var PATTERN_MISSING_NAME_MESSAGE = "`wp-typia add pattern` requires <name>. Usage: wp-typia add pattern <name>.";
570
697
  var patternAddKindEntry = defineAddKindRegistryEntry({
@@ -600,47 +727,177 @@ var patternAddKindEntry = defineAddKindRegistryEntry({
600
727
  visibleFieldNames: () => NAME_ONLY_VISIBLE_FIELDS
601
728
  });
602
729
 
730
+ // src/add-kinds/post-meta.ts
731
+ var POST_META_MISSING_NAME_MESSAGE = "`wp-typia add post-meta` requires <name>. Usage: wp-typia add post-meta <name> --post-type <post-type> [--type <ExportedTypeName>] [--meta-key <meta-key>].";
732
+ var POST_META_MISSING_POST_TYPE_MESSAGE = "`wp-typia add post-meta` requires --post-type <post-type>. Usage: wp-typia add post-meta <name> --post-type <post-type>.";
733
+ var postMetaAddKindEntry = defineAddKindRegistryEntry({
734
+ completion: {
735
+ nextSteps: (values) => [
736
+ `Edit ${values.typesFile} when the post meta shape changes.`,
737
+ "Run `wp-typia sync-rest --check` to verify the generated meta schema is current.",
738
+ `Smoke test ${values.metaKey} on the ${values.postType} post type in WordPress.`
739
+ ],
740
+ summaryLines: (values, projectDir) => [
741
+ `Post meta contract: ${values.postMetaSlug}`,
742
+ `Post type: ${values.postType}`,
743
+ `Meta key: ${values.metaKey}`,
744
+ `REST/editor exposure: ${values.showInRest}`,
745
+ `Schema: ${values.schemaFile}`,
746
+ `PHP: ${values.phpFile}`,
747
+ `Project directory: ${projectDir}`
748
+ ],
749
+ title: "Added post meta contract"
750
+ },
751
+ description: "Add a typed WordPress post meta contract",
752
+ hiddenBooleanSubmitFields: ["hide-from-rest"],
753
+ hiddenStringSubmitFields: ["meta-key"],
754
+ nameLabel: "Post meta name",
755
+ async prepareExecution(context) {
756
+ const name = requireAddKindName(context, POST_META_MISSING_NAME_MESSAGE);
757
+ const hideFromRest = Boolean(context.flags["hide-from-rest"] ?? context.flags.hideFromRest);
758
+ const metaKey = readOptionalDashedOrCamelStringFlag(context.flags, "meta-key", "metaKey");
759
+ const postType = readOptionalDashedOrCamelStringFlag(context.flags, "post-type", "postType") ?? requireStrictStringFlag(context.flags, "post-type", POST_META_MISSING_POST_TYPE_MESSAGE);
760
+ const typeName = readOptionalStrictStringFlag(context.flags, "type");
761
+ return createNamedExecutionPlan(context, {
762
+ execute: ({ cwd, name: name2 }) => context.addRuntime.runAddPostMetaCommand({
763
+ cwd,
764
+ hideFromRest,
765
+ metaKey,
766
+ postMetaName: name2,
767
+ postType,
768
+ typeName
769
+ }),
770
+ getValues: (result) => ({
771
+ metaKey: result.metaKey,
772
+ phpFile: result.phpFile,
773
+ postMetaSlug: result.postMetaSlug,
774
+ postType: result.postType,
775
+ schemaFile: result.schemaFile,
776
+ showInRest: result.showInRest ? "enabled" : "disabled",
777
+ sourceTypeName: result.sourceTypeName,
778
+ typesFile: result.typesFile
779
+ }),
780
+ missingNameMessage: POST_META_MISSING_NAME_MESSAGE,
781
+ name,
782
+ warnLine: context.warnLine
783
+ });
784
+ },
785
+ sortOrder: 85,
786
+ supportsDryRun: true,
787
+ usage: "wp-typia add post-meta <name> --post-type <post-type> [--type <ExportedTypeName>] [--meta-key <meta-key>] [--hide-from-rest] [--dry-run]",
788
+ visibleFieldNames: () => NAME_POST_TYPE_TYPE_VISIBLE_FIELDS
789
+ });
790
+
603
791
  // src/add-kinds/rest-resource.ts
604
- var REST_RESOURCE_MISSING_NAME_MESSAGE = "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>].";
792
+ var REST_RESOURCE_MISSING_NAME_MESSAGE = "`wp-typia add rest-resource` requires <name>. Usage: wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] or wp-typia add rest-resource <name> --manual [--method GET] [--path /external].";
793
+ function readOptionalDashedOrCamelStringFlag2(flags, dashedName, camelName) {
794
+ return readOptionalStrictStringFlag(flags, dashedName) ?? readOptionalStrictStringFlag(flags, camelName);
795
+ }
605
796
  var restResourceAddKindEntry = defineAddKindRegistryEntry({
606
797
  completion: {
607
- nextSteps: (values) => [
798
+ nextSteps: (values) => values.mode === "manual" ? [
799
+ `Review src/rest/${values.restResourceSlug}/ and edit the manual contract types to match the external route owner.`,
800
+ "Run sync-rest --check after changing the contract types to verify schemas, OpenAPI, and client artifacts."
801
+ ] : [
608
802
  `Review src/rest/${values.restResourceSlug}/ and inc/rest/${values.restResourceSlug}.php.`,
609
803
  "Run your workspace build or dev command to verify the generated REST resource contract."
610
804
  ],
611
805
  summaryLines: (values, projectDir) => [
612
806
  `REST resource: ${values.restResourceSlug}`,
807
+ `Mode: ${values.mode}`,
613
808
  `Namespace: ${values.namespace}`,
614
- `Methods: ${values.methods}`,
809
+ ...values.mode === "manual" ? [
810
+ `Route: ${values.method} /${values.namespace}${values.pathPattern}`,
811
+ `Auth: ${values.auth}`,
812
+ ...values.secretFieldName ? [
813
+ `Secret field: ${values.secretFieldName} -> ${values.secretStateFieldName}`
814
+ ] : []
815
+ ] : [
816
+ `Methods: ${values.methods}`,
817
+ ...values.routePattern ? [`Item route: /${values.namespace}${values.routePattern}`] : [],
818
+ ...values.permissionCallback ? [`Permission callback: ${values.permissionCallback}`] : [],
819
+ ...values.controllerClass ? [`Controller class: ${values.controllerClass}`] : []
820
+ ],
615
821
  `Project directory: ${projectDir}`
616
822
  ],
617
- title: "Added plugin-level REST resource"
823
+ title: "Added REST resource contract"
618
824
  },
619
- description: "Add a plugin-level typed REST resource",
825
+ description: "Add a generated or type-only REST resource contract",
826
+ hiddenBooleanSubmitFields: ["manual"],
827
+ hiddenStringSubmitFields: [
828
+ "auth",
829
+ "body-type",
830
+ "controller-class",
831
+ "controller-extends",
832
+ "method",
833
+ "path",
834
+ "permission-callback",
835
+ "query-type",
836
+ "response-type",
837
+ "route-pattern",
838
+ "secret-field",
839
+ "secret-state-field"
840
+ ],
620
841
  nameLabel: "REST resource name",
621
842
  async prepareExecution(context) {
622
843
  const name = requireAddKindName(context, REST_RESOURCE_MISSING_NAME_MESSAGE);
844
+ const auth = readOptionalStrictStringFlag(context.flags, "auth");
845
+ const bodyTypeName = readOptionalStrictStringFlag(context.flags, "body-type");
846
+ const controllerClass = readOptionalDashedOrCamelStringFlag2(context.flags, "controller-class", "controllerClass");
847
+ const controllerExtends = readOptionalDashedOrCamelStringFlag2(context.flags, "controller-extends", "controllerExtends");
848
+ const manual = Boolean(context.flags.manual);
849
+ const method = readOptionalStrictStringFlag(context.flags, "method");
623
850
  const methods = readOptionalStrictStringFlag(context.flags, "methods");
624
851
  const namespace = readOptionalStrictStringFlag(context.flags, "namespace");
852
+ const permissionCallback = readOptionalDashedOrCamelStringFlag2(context.flags, "permission-callback", "permissionCallback");
853
+ const pathPattern = readOptionalStrictStringFlag(context.flags, "path");
854
+ const queryTypeName = readOptionalStrictStringFlag(context.flags, "query-type");
855
+ const responseTypeName = readOptionalStrictStringFlag(context.flags, "response-type");
856
+ const routePattern = readOptionalDashedOrCamelStringFlag2(context.flags, "route-pattern", "routePattern");
857
+ const secretFieldName = readOptionalDashedOrCamelStringFlag2(context.flags, "secret-field", "secretField");
858
+ const secretStateFieldName = readOptionalDashedOrCamelStringFlag2(context.flags, "secret-state-field", "secretStateField");
625
859
  return createNamedExecutionPlan(context, {
626
860
  execute: ({ cwd, name: name2 }) => context.addRuntime.runAddRestResourceCommand({
861
+ auth,
862
+ bodyTypeName,
863
+ controllerClass,
864
+ controllerExtends,
627
865
  cwd,
866
+ manual,
867
+ method,
628
868
  methods,
629
869
  namespace,
630
- restResourceName: name2
870
+ permissionCallback,
871
+ pathPattern,
872
+ queryTypeName,
873
+ restResourceName: name2,
874
+ responseTypeName,
875
+ routePattern,
876
+ secretFieldName,
877
+ secretStateFieldName
631
878
  }),
632
879
  getValues: (result) => ({
880
+ auth: result.auth ?? "",
881
+ controllerClass: result.controllerClass ?? "",
882
+ method: result.method ?? "",
633
883
  methods: result.methods.join(", "),
884
+ mode: result.mode,
634
885
  namespace: result.namespace,
635
- restResourceSlug: result.restResourceSlug
886
+ pathPattern: result.pathPattern ?? "",
887
+ permissionCallback: result.permissionCallback ?? "",
888
+ restResourceSlug: result.restResourceSlug,
889
+ routePattern: result.routePattern ?? "",
890
+ secretFieldName: result.secretFieldName ?? "",
891
+ secretStateFieldName: result.secretStateFieldName ?? ""
636
892
  }),
637
893
  missingNameMessage: REST_RESOURCE_MISSING_NAME_MESSAGE,
638
- name
894
+ name,
895
+ warnLine: context.warnLine
639
896
  });
640
897
  },
641
898
  sortOrder: 80,
642
899
  supportsDryRun: true,
643
- usage: "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--dry-run]",
900
+ usage: "wp-typia add rest-resource <name> [--namespace <vendor/v1>] [--methods <list,read,create,update,delete>] [--route-pattern <route-pattern>] [--permission-callback <callback>] [--controller-class <ClassName>] [--controller-extends <BaseClass>] [--manual --method <GET|POST|PUT|PATCH|DELETE> --auth <public|authenticated|public-write-protected> --path <route-pattern> --query-type <Type> --body-type <Type> --response-type <Type> --secret-field <field> --secret-state-field <field>] [--dry-run]",
644
901
  visibleFieldNames: () => NAME_NAMESPACE_METHODS_VISIBLE_FIELDS
645
902
  });
646
903
 
@@ -675,7 +932,8 @@ var styleAddKindEntry = defineAddKindRegistryEntry({
675
932
  styleSlug: result.styleSlug
676
933
  }),
677
934
  missingNameMessage: STYLE_MISSING_NAME_MESSAGE,
678
- name
935
+ name,
936
+ warnLine: context.warnLine
679
937
  });
680
938
  },
681
939
  sortOrder: 40,
@@ -720,7 +978,8 @@ var transformAddKindEntry = defineAddKindRegistryEntry({
720
978
  transformSlug: result.transformSlug
721
979
  }),
722
980
  missingNameMessage: TRANSFORM_MISSING_NAME_MESSAGE,
723
- name
981
+ name,
982
+ warnLine: context.warnLine
724
983
  });
725
984
  },
726
985
  sortOrder: 50,
@@ -760,7 +1019,8 @@ var variationAddKindEntry = defineAddKindRegistryEntry({
760
1019
  variationSlug: result.variationSlug
761
1020
  }),
762
1021
  missingNameMessage: VARIATION_MISSING_NAME_MESSAGE,
763
- name
1022
+ name,
1023
+ warnLine: context.warnLine
764
1024
  });
765
1025
  },
766
1026
  sortOrder: 30,
@@ -773,12 +1033,15 @@ var variationAddKindEntry = defineAddKindRegistryEntry({
773
1033
  var ADD_KIND_REGISTRY = {
774
1034
  "admin-view": adminViewAddKindEntry,
775
1035
  block: blockAddKindEntry,
1036
+ "integration-env": integrationEnvAddKindEntry,
776
1037
  variation: variationAddKindEntry,
777
1038
  style: styleAddKindEntry,
778
1039
  transform: transformAddKindEntry,
779
1040
  pattern: patternAddKindEntry,
780
1041
  "binding-source": bindingSourceAddKindEntry,
1042
+ contract: contractAddKindEntry,
781
1043
  "rest-resource": restResourceAddKindEntry,
1044
+ "post-meta": postMetaAddKindEntry,
782
1045
  ability: abilityAddKindEntry,
783
1046
  "ai-feature": aiFeatureAddKindEntry,
784
1047
  "hooked-block": hookedBlockAddKindEntry,
@@ -987,6 +1250,11 @@ async function simulateWorkspaceAddDryRun({
987
1250
  }
988
1251
  }
989
1252
 
1253
+ // src/string-utils.ts
1254
+ function escapeRegExp(source) {
1255
+ return source.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
1256
+ }
1257
+
990
1258
  // src/output-markers.ts
991
1259
  var UNICODE_OUTPUT_MARKERS = {
992
1260
  dryRun: "\uD83E\uDDEA",
@@ -1002,9 +1270,6 @@ var ASCII_OUTPUT_MARKERS = {
1002
1270
  };
1003
1271
  var ASCII_ENV_TRUTHY_VALUES = new Set(["1", "on", "true", "yes"]);
1004
1272
  var ASCII_ENV_FALSY_VALUES = new Set(["0", "off", "false", "no"]);
1005
- function escapeRegExp(source) {
1006
- return source.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1007
- }
1008
1273
  function readAsciiPreferenceFromEnv(env) {
1009
1274
  const rawValue = env.WP_TYPIA_ASCII;
1010
1275
  if (typeof rawValue !== "string") {
@@ -1158,10 +1423,7 @@ function buildStructuredInitSuccessPayload(plan) {
1158
1423
  };
1159
1424
  }
1160
1425
  // src/runtime-output/create.ts
1161
- function escapeRegExp2(source) {
1162
- return source.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
1163
- }
1164
- var LOOSE_CREATE_COMPLETION_PACKAGE_MANAGER_PATTERN = new RegExp(`^(?:corepack\\s+)?(${PACKAGE_MANAGER_IDS.map(escapeRegExp2).join("|")})(?=$|[@:/+\\s])`, "iu");
1426
+ var LOOSE_CREATE_COMPLETION_PACKAGE_MANAGER_PATTERN = new RegExp(`^(?:corepack\\s+)?(${PACKAGE_MANAGER_IDS.map(escapeRegExp).join("|")})(?=$|[@:/+\\s])`, "iu");
1165
1427
  function parseCreateCompletionPackageManager(packageManager) {
1166
1428
  const normalizedPackageManager = packageManager.trim();
1167
1429
  const parsedPackageManager = parsePackageManagerField(normalizedPackageManager);
@@ -1371,7 +1633,7 @@ function pushFlag(argv, name, value) {
1371
1633
  }
1372
1634
 
1373
1635
  // src/runtime-bridge-add.ts
1374
- var loadCliAddRuntime = () => import("./cli-add-8rvmezy0.js");
1636
+ var loadCliAddRuntime = () => import("./cli-add-21bvpfgw.js");
1375
1637
  var loadCliPromptRuntime = () => import("./cli-prompt-614tq57c.js");
1376
1638
  async function executeWorkspaceAddWithOptionalDryRun(options) {
1377
1639
  const simulated = options.dryRun ? await simulateWorkspaceAddDryRun({
@@ -1479,7 +1741,7 @@ async function executeAddCommand({
1479
1741
  }
1480
1742
  // src/runtime-bridge-create.ts
1481
1743
  var loadCliPromptRuntime2 = () => import("./cli-prompt-614tq57c.js");
1482
- var loadCliScaffoldRuntime = () => import("./cli-scaffold-b1ex2y80.js");
1744
+ var loadCliScaffoldRuntime = () => import("./cli-scaffold-zhp2ym8z.js");
1483
1745
  var loadCliTemplatesRuntime = () => import("./cli-templates-hc71dfc2.js");
1484
1746
  var loadCreateTemplateValidationRuntime = () => import("./create-template-validation-rtec5sng.js");
1485
1747
  var PACKAGE_MANAGER_PROMPT_OPTIONS = [
@@ -1599,7 +1861,7 @@ async function executeCreateCommand({
1599
1861
  }
1600
1862
  }
1601
1863
  // src/runtime-bridge-doctor.ts
1602
- var loadCliDoctorRuntime = () => import("./cli-doctor-5m6xyx9q.js");
1864
+ var loadCliDoctorRuntime = () => import("./cli-doctor-wy2yjsge.js");
1603
1865
  async function executeDoctorCommand(cwd) {
1604
1866
  try {
1605
1867
  const { runDoctor } = await loadCliDoctorRuntime();
@@ -1610,7 +1872,7 @@ async function executeDoctorCommand(cwd) {
1610
1872
  }
1611
1873
  // src/runtime-bridge-init.ts
1612
1874
  import path2 from "path";
1613
- var loadCliInitRuntime = () => import("./cli-init-qv3zxmvc.js");
1875
+ var loadCliInitRuntime = () => import("./cli-init-xnsbxncv.js");
1614
1876
  async function executeInitCommand({ apply, cwd, packageManager, projectDir }, options = {}) {
1615
1877
  try {
1616
1878
  const { runInitCommand } = await loadCliInitRuntime();
@@ -1636,23 +1898,25 @@ async function executeInitCommand({ apply, cwd, packageManager, projectDir }, op
1636
1898
  }
1637
1899
  }
1638
1900
  // src/runtime-bridge-migrate.ts
1639
- var loadMigrationsRuntime = () => import("./migrations-7g9rag5d.js");
1901
+ var loadMigrationsRuntime = () => import("./migrations-bx0yvc2v.js");
1902
+ var defaultPrintLine2 = (line) => {
1903
+ process.stdout.write(`${line}
1904
+ `);
1905
+ };
1640
1906
  async function executeMigrateCommand({
1641
1907
  command,
1642
1908
  cwd,
1643
1909
  flags,
1910
+ printLine = defaultPrintLine2,
1644
1911
  prompt,
1645
1912
  renderLine
1646
1913
  }) {
1647
1914
  try {
1648
1915
  const { formatMigrationHelpText, parseMigrationArgs, runMigrationCommand } = await loadMigrationsRuntime();
1916
+ const outputLine = renderLine ?? printLine;
1649
1917
  if (!command) {
1650
1918
  const helpText = formatMigrationHelpText();
1651
- if (renderLine) {
1652
- renderLine(helpText);
1653
- } else {
1654
- console.log(helpText);
1655
- }
1919
+ outputLine(helpText);
1656
1920
  return;
1657
1921
  }
1658
1922
  const argv = [command];
@@ -1668,11 +1932,7 @@ async function executeMigrateCommand({
1668
1932
  const lines = renderLine ? [] : null;
1669
1933
  const captureLine = (line) => {
1670
1934
  lines?.push(line);
1671
- if (renderLine) {
1672
- renderLine(line);
1673
- return;
1674
- }
1675
- console.log(line);
1935
+ outputLine(line);
1676
1936
  };
1677
1937
  const result = await runMigrationCommand(parsed, cwd, {
1678
1938
  prompt,
@@ -2363,9 +2623,10 @@ function loadAddFlow() {
2363
2623
  var addOptions = buildCommandOptions(ADD_OPTION_METADATA);
2364
2624
  var addCommand = defineCommand({
2365
2625
  defaultFormat: "toon",
2366
- description: "Extend an official wp-typia workspace with blocks, variations, block styles, transforms, patterns, binding sources, plugin-level REST resources, workflow abilities, server-only AI features, editor plugins, or hooked blocks.",
2626
+ description: "Extend an official wp-typia workspace with blocks, integration envs, variations, block styles, transforms, patterns, binding sources, standalone contracts, plugin-level REST resources, post meta contracts, workflow abilities, server-only AI features, editor plugins, or hooked blocks.",
2367
2627
  handler: async (args) => {
2368
2628
  const prefersStructuredOutput = prefersStructuredCliOutput(args);
2629
+ const { printLine, warnLine } = resolveCommandOutputAdapters(args);
2369
2630
  try {
2370
2631
  if (prefersStructuredOutput) {
2371
2632
  const completion = await executeAddCommand({
@@ -2374,7 +2635,9 @@ var addCommand = defineCommand({
2374
2635
  flags: args.flags,
2375
2636
  interactive: false,
2376
2637
  kind: args.positional[0],
2377
- name: args.positional[1]
2638
+ name: args.positional[1],
2639
+ printLine,
2640
+ warnLine
2378
2641
  });
2379
2642
  args.output(buildStructuredCompletionSuccessPayload("add", completion, {
2380
2643
  dryRun: Boolean(args.flags["dry-run"]),
@@ -2388,7 +2651,9 @@ var addCommand = defineCommand({
2388
2651
  cwd: args.cwd,
2389
2652
  flags: args.flags,
2390
2653
  kind: args.positional[0],
2391
- name: args.positional[1]
2654
+ name: args.positional[1],
2655
+ printLine,
2656
+ warnLine
2392
2657
  });
2393
2658
  } catch (error) {
2394
2659
  emitCliDiagnosticFailure(args, {
@@ -2446,6 +2711,7 @@ var createCommand = defineCommand({
2446
2711
  description: "Scaffold a new wp-typia project.",
2447
2712
  handler: async (args) => {
2448
2713
  const prefersStructuredOutput = prefersStructuredCliOutput(args);
2714
+ const { printLine, warnLine } = resolveCommandOutputAdapters(args);
2449
2715
  const projectDir = args.positional[0];
2450
2716
  if (!projectDir) {
2451
2717
  emitCliDiagnosticFailure(args, {
@@ -2461,7 +2727,9 @@ var createCommand = defineCommand({
2461
2727
  emitOutput: !prefersStructuredOutput,
2462
2728
  flags: args.flags,
2463
2729
  interactive: prefersStructuredOutput ? false : undefined,
2464
- projectDir
2730
+ printLine,
2731
+ projectDir,
2732
+ warnLine
2465
2733
  });
2466
2734
  if (prefersStructuredOutput) {
2467
2735
  args.output(buildStructuredCompletionSuccessPayload("create", completion, {
@@ -2513,7 +2781,7 @@ var doctorCommand = defineCommand({
2513
2781
  const prefersStructuredOutput = prefersStructuredCliOutput(args);
2514
2782
  if (prefersStructuredOutput) {
2515
2783
  const [{ getDoctorChecks }, { getDoctorFailureDetailLines }] = await Promise.all([
2516
- import("./cli-doctor-5m6xyx9q.js"),
2784
+ import("./cli-doctor-wy2yjsge.js"),
2517
2785
  import("./cli-diagnostics-5dvztm7q.js")
2518
2786
  ]);
2519
2787
  const checks = await getDoctorChecks(args.cwd);
@@ -2549,13 +2817,18 @@ var initCommand = defineCommand({
2549
2817
  description: "Preview or apply the minimum wp-typia retrofit plan for an existing project.",
2550
2818
  handler: async (args) => {
2551
2819
  const prefersStructuredOutput = prefersStructuredCliOutput(args);
2820
+ const { printLine, warnLine } = resolveCommandOutputAdapters(args);
2552
2821
  try {
2553
2822
  const plan = await executeInitCommand({
2554
2823
  apply: Boolean(args.flags.apply),
2555
2824
  cwd: args.cwd,
2556
2825
  packageManager: typeof args.flags["package-manager"] === "string" ? args.flags["package-manager"] : undefined,
2557
2826
  projectDir: args.positional[0]
2558
- }, { emitOutput: !prefersStructuredOutput });
2827
+ }, {
2828
+ emitOutput: !prefersStructuredOutput,
2829
+ printLine,
2830
+ warnLine
2831
+ });
2559
2832
  if (prefersStructuredOutput) {
2560
2833
  args.output(buildStructuredInitSuccessPayload(plan));
2561
2834
  }
@@ -3161,13 +3434,6 @@ async function syncMcpSchemas(cwd, schemaSources, outputDir = path4.join(cwd, ".
3161
3434
  }
3162
3435
 
3163
3436
  // src/commands/mcp.ts
3164
- var defaultPrintLine = (line) => {
3165
- process.stdout.write(`${line}
3166
- `);
3167
- };
3168
- function resolveMcpPrintLine(args) {
3169
- return args.printLine ?? defaultPrintLine;
3170
- }
3171
3437
  function printMcpToolGroupSummary(summary, printLine) {
3172
3438
  for (const group of summary) {
3173
3439
  printLine(`${group.namespace} (${group.toolCount})`);
@@ -3185,7 +3451,7 @@ var mcpCommand = defineCommand({
3185
3451
  handler: async (args) => {
3186
3452
  const subcommand = args.positional[0] ?? "list";
3187
3453
  const prefersStructuredOutput = prefersStructuredCliOutput(args);
3188
- const printLine = resolveMcpPrintLine(args);
3454
+ const printLine = resolveCommandPrintLine(args);
3189
3455
  const userConfig = args.context?.store?.wpTypiaUserConfig && typeof args.context.store.wpTypiaUserConfig === "object" ? args.context.store.wpTypiaUserConfig : {};
3190
3456
  const schemaSources = getMcpSchemaSources(userConfig);
3191
3457
  if (schemaSources.length === 0) {
@@ -3257,11 +3523,13 @@ var migrateCommand = defineCommand({
3257
3523
  defaultFormat: "toon",
3258
3524
  description: "Run migration workflows for migration-capable wp-typia projects.",
3259
3525
  handler: async (args) => {
3526
+ const printLine = resolveCommandPrintLine(args);
3260
3527
  try {
3261
3528
  await executeMigrateCommand({
3262
3529
  command: args.positional[0],
3263
3530
  cwd: args.cwd,
3264
- flags: args.flags
3531
+ flags: args.flags,
3532
+ printLine
3265
3533
  });
3266
3534
  } catch (error) {
3267
3535
  emitCliDiagnosticFailure(args, {
@@ -3346,6 +3614,7 @@ var templatesCommand = defineCommand({
3346
3614
  const id = args.positional[1] ?? args.flags.id;
3347
3615
  const effectiveSubcommand = subcommand === "list" && typeof id === "string" && id.length > 0 ? "inspect" : subcommand;
3348
3616
  const prefersStructuredOutput = prefersStructuredCliOutput(args);
3617
+ const printLine = resolveCommandPrintLine(args);
3349
3618
  try {
3350
3619
  if (prefersStructuredOutput) {
3351
3620
  const templates = await listTemplatesForRuntime();
@@ -3376,7 +3645,7 @@ var templatesCommand = defineCommand({
3376
3645
  }
3377
3646
  await executeTemplatesCommand({
3378
3647
  flags: { id, subcommand: effectiveSubcommand }
3379
- });
3648
+ }, printLine);
3380
3649
  } catch (error) {
3381
3650
  emitCliDiagnosticFailure(args, {
3382
3651
  command: "templates",
@@ -3404,4 +3673,4 @@ export {
3404
3673
  wpTypiaCommands
3405
3674
  };
3406
3675
 
3407
- //# debugId=8B3272B9527B417864756E2164756E21
3676
+ //# debugId=5AAD37B0D7C6B20F64756E2164756E21