wp-typia 0.22.7 → 0.22.8

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.7",
6
+ version: "0.22.8",
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.7",
76
+ "@wp-typia/project-tools": "0.22.8",
77
77
  "better-result": "^2.7.0",
78
78
  react: "^19.2.5",
79
79
  "react-dom": "^19.2.5",
@@ -97,8 +97,8 @@ var package_default = {
97
97
 
98
98
  // src/node-cli.ts
99
99
  import {
100
- CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES8,
101
- createCliCommandError as createCliCommandError3,
100
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES11,
101
+ createCliCommandError as createCliCommandError5,
102
102
  formatCliDiagnosticError,
103
103
  serializeCliDiagnosticError as serializeCliDiagnosticError2
104
104
  } from "@wp-typia/project-tools/cli-diagnostics";
@@ -754,10 +754,189 @@ import {
754
754
  listTemplates
755
755
  } from "@wp-typia/project-tools/cli-templates";
756
756
 
757
+ // src/config.ts
758
+ import fs from "node:fs/promises";
759
+ import os from "node:os";
760
+ import path from "node:path";
761
+ import { isPlainObject as isRecord } from "@wp-typia/api-client/runtime-primitives";
762
+ import {
763
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES3,
764
+ createCliDiagnosticCodeError as createCliDiagnosticCodeError2
765
+ } from "@wp-typia/project-tools/cli-diagnostics";
766
+ import { z as z2 } from "zod";
767
+ var WP_TYPIA_CONFIG_SOURCES = [
768
+ "~/.config/wp-typia/config.json",
769
+ ".wp-typiarc",
770
+ ".wp-typiarc.json"
771
+ ];
772
+ var wpTypiaSchemaSourceSchema = z2.object({
773
+ namespace: z2.string(),
774
+ path: z2.string()
775
+ }).strict();
776
+ var createConfigSchema = z2.object({
777
+ "alternate-render-targets": z2.string().optional(),
778
+ "inner-blocks-preset": z2.string().optional(),
779
+ "data-storage": z2.string().optional(),
780
+ "dry-run": z2.boolean().optional(),
781
+ "external-layer-id": z2.string().optional(),
782
+ "external-layer-source": z2.string().optional(),
783
+ namespace: z2.string().optional(),
784
+ "no-install": z2.boolean().optional(),
785
+ "package-manager": z2.string().optional(),
786
+ "persistence-policy": z2.string().optional(),
787
+ "php-prefix": z2.string().optional(),
788
+ "query-post-type": z2.string().optional(),
789
+ template: z2.string().optional(),
790
+ "text-domain": z2.string().optional(),
791
+ variant: z2.string().optional(),
792
+ "with-migration-ui": z2.boolean().optional(),
793
+ "with-test-preset": z2.boolean().optional(),
794
+ "with-wp-env": z2.boolean().optional(),
795
+ yes: z2.boolean().optional()
796
+ }).strict();
797
+ var addBlockConfigSchema = z2.object({
798
+ "alternate-render-targets": z2.string().optional(),
799
+ "data-storage": z2.string().optional(),
800
+ "external-layer-id": z2.string().optional(),
801
+ "external-layer-source": z2.string().optional(),
802
+ "inner-blocks-preset": z2.string().optional(),
803
+ "persistence-policy": z2.string().optional(),
804
+ template: z2.string().optional()
805
+ }).strict();
806
+ var addConfigSchema = z2.object({
807
+ block: addBlockConfigSchema.optional()
808
+ }).strict();
809
+ var mcpConfigSchema = z2.object({
810
+ schemaSources: z2.array(wpTypiaSchemaSourceSchema).optional()
811
+ }).strict();
812
+ var wpTypiaUserConfigSchema = z2.object({
813
+ add: addConfigSchema.optional(),
814
+ create: createConfigSchema.optional(),
815
+ mcp: mcpConfigSchema.optional()
816
+ }).strict();
817
+ function formatIssuePath(issuePath) {
818
+ if (issuePath.length === 0) {
819
+ return "config";
820
+ }
821
+ return issuePath.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${String(segment)}`).join("").replace(/^\./u, "");
822
+ }
823
+ function formatConfigValidationIssue(issue) {
824
+ const pathLabel = formatIssuePath(issue.path);
825
+ if (issue.code === "unrecognized_keys") {
826
+ const keys = issue.keys.map((key) => `"${String(key)}"`).join(", ");
827
+ const label = issue.keys.length === 1 ? "unknown key" : "unknown keys";
828
+ return `${pathLabel}: ${label} ${keys}. Unknown keys are errors in wp-typia config.`;
829
+ }
830
+ return `${pathLabel}: ${issue.message}`;
831
+ }
832
+ function validateWpTypiaUserConfig(value, source) {
833
+ const result = wpTypiaUserConfigSchema.safeParse(value);
834
+ if (result.success) {
835
+ return result.data;
836
+ }
837
+ const issueLines = result.error.issues.map(formatConfigValidationIssue);
838
+ throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.INVALID_ARGUMENT, [
839
+ `Invalid wp-typia config at ${source}.`,
840
+ ...issueLines.map((line) => `- ${line}`)
841
+ ].join(`
842
+ `));
843
+ }
844
+ function deepMerge(base, incoming) {
845
+ const merged = { ...base };
846
+ for (const [key, value] of Object.entries(incoming)) {
847
+ if (Array.isArray(value)) {
848
+ merged[key] = value.slice();
849
+ continue;
850
+ }
851
+ if (isRecord(value) && isRecord(merged[key])) {
852
+ merged[key] = deepMerge(merged[key], value);
853
+ continue;
854
+ }
855
+ merged[key] = value;
856
+ }
857
+ return merged;
858
+ }
859
+ async function readJsonFile(filePath) {
860
+ let source;
861
+ try {
862
+ source = await fs.readFile(filePath, "utf8");
863
+ } catch (error) {
864
+ if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
865
+ return;
866
+ }
867
+ throw error;
868
+ }
869
+ try {
870
+ return JSON.parse(source);
871
+ } catch (error) {
872
+ const message = error instanceof Error ? error.message : String(error);
873
+ throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.INVALID_ARGUMENT, `Unable to parse ${filePath}: ${message}`, error instanceof Error ? { cause: error } : undefined);
874
+ }
875
+ }
876
+ async function readWpTypiaConfigFile(filePath) {
877
+ const parsed = await readJsonFile(filePath);
878
+ return parsed === undefined ? null : validateWpTypiaUserConfig(parsed, filePath);
879
+ }
880
+ function resolveConfigPath(cwd, source) {
881
+ if (source.startsWith("~/")) {
882
+ return path.join(os.homedir(), source.slice(2));
883
+ }
884
+ return path.resolve(cwd, source);
885
+ }
886
+ function mergeWpTypiaUserConfig(base, incoming) {
887
+ return deepMerge(base, incoming);
888
+ }
889
+ async function loadWpTypiaUserConfigFromSource(cwd, source) {
890
+ const config = await readWpTypiaConfigFile(resolveConfigPath(cwd, source));
891
+ return config ?? {};
892
+ }
893
+ async function loadWpTypiaUserConfig(cwd) {
894
+ let merged = {};
895
+ for (const source of WP_TYPIA_CONFIG_SOURCES) {
896
+ const configPath = resolveConfigPath(cwd, source);
897
+ const config = await readWpTypiaConfigFile(configPath);
898
+ if (config) {
899
+ merged = deepMerge(merged, config);
900
+ }
901
+ }
902
+ const packageJsonPath = path.join(cwd, "package.json");
903
+ const packageJson = await readJsonFile(packageJsonPath);
904
+ if (isRecord(packageJson) && "wp-typia" in packageJson) {
905
+ const packageConfig = validateWpTypiaUserConfig(packageJson["wp-typia"], `${packageJsonPath}#wp-typia`);
906
+ merged = deepMerge(merged, packageConfig);
907
+ }
908
+ return merged;
909
+ }
910
+ function getCreateDefaults(config) {
911
+ return config.create ?? {};
912
+ }
913
+ function getAddBlockDefaults(config) {
914
+ return config.add?.block ?? {};
915
+ }
916
+
917
+ // src/config-override.ts
918
+ var GLOBAL_OPTION_PARSER = buildCommandOptionParser(GLOBAL_OPTION_METADATA);
919
+ function extractWpTypiaConfigOverride(argv) {
920
+ const { argv: nextArgv, flags } = extractKnownOptionValuesFromArgv(argv, {
921
+ optionNames: ["config"],
922
+ parser: GLOBAL_OPTION_PARSER
923
+ });
924
+ return {
925
+ argv: nextArgv,
926
+ configOverridePath: typeof flags.config === "string" ? flags.config : undefined
927
+ };
928
+ }
929
+
930
+ // src/runtime-bridge.ts
931
+ import {
932
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES7,
933
+ createCliDiagnosticCodeError as createCliDiagnosticCodeError6
934
+ } from "@wp-typia/project-tools/cli-diagnostics";
935
+
757
936
  // src/add-kind-registry.ts
758
937
  import {
759
- CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES4,
760
- createCliDiagnosticCodeError as createCliDiagnosticCodeError3
938
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES5,
939
+ createCliDiagnosticCodeError as createCliDiagnosticCodeError4
761
940
  } from "@wp-typia/project-tools/cli-diagnostics";
762
941
 
763
942
  // src/add-kind-ids.ts
@@ -765,8 +944,8 @@ import { ADD_KIND_IDS } from "@wp-typia/project-tools/cli-add-kind-ids";
765
944
 
766
945
  // src/cli-string-flags.ts
767
946
  import {
768
- CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES3,
769
- createCliDiagnosticCodeError as createCliDiagnosticCodeError2
947
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES4,
948
+ createCliDiagnosticCodeError as createCliDiagnosticCodeError3
770
949
  } from "@wp-typia/project-tools/cli-diagnostics";
771
950
  function readOptionalCliStringFlagValue(flags, name, mode) {
772
951
  const value = flags[name];
@@ -774,12 +953,12 @@ function readOptionalCliStringFlagValue(flags, name, mode) {
774
953
  return;
775
954
  }
776
955
  if (typeof value !== "string") {
777
- throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, `\`--${name}\` requires a value.`);
956
+ throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.MISSING_ARGUMENT, `\`--${name}\` requires a value.`);
778
957
  }
779
958
  const trimmed = value.trim();
780
959
  if (trimmed.length === 0) {
781
960
  if (mode === "strict") {
782
- throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, `\`--${name}\` requires a value.`);
961
+ throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.MISSING_ARGUMENT, `\`--${name}\` requires a value.`);
783
962
  }
784
963
  return;
785
964
  }
@@ -794,7 +973,7 @@ function readOptionalStrictStringFlag(flags, name) {
794
973
  function requireStrictStringFlag(flags, name, message) {
795
974
  const value = readOptionalStrictStringFlag(flags, name);
796
975
  if (!value) {
797
- throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, message);
976
+ throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.MISSING_ARGUMENT, message);
798
977
  }
799
978
  return value;
800
979
  }
@@ -802,7 +981,7 @@ function readOptionalPairedStrictStringFlags(flags, leftName, rightName, message
802
981
  const leftValue = readOptionalStrictStringFlag(flags, leftName);
803
982
  const rightValue = readOptionalStrictStringFlag(flags, rightName);
804
983
  if (Boolean(leftValue) !== Boolean(rightValue)) {
805
- throw createCliDiagnosticCodeError2(CLI_DIAGNOSTIC_CODES3.MISSING_ARGUMENT, message);
984
+ throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.MISSING_ARGUMENT, message);
806
985
  }
807
986
  return [leftValue, rightValue];
808
987
  }
@@ -883,7 +1062,7 @@ var NAME_NAMESPACE_VISIBLE_FIELDS = [
883
1062
  ];
884
1063
  function requireAddKindName(context, message) {
885
1064
  if (!context.name) {
886
- throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.MISSING_ARGUMENT, message);
1065
+ throw createCliDiagnosticCodeError4(CLI_DIAGNOSTIC_CODES5.MISSING_ARGUMENT, message);
887
1066
  }
888
1067
  return context.name;
889
1068
  }
@@ -910,9 +1089,9 @@ function assertAddBlockTemplateId(context, templateId) {
910
1089
  return templateId;
911
1090
  }
912
1091
  if (templateId === "query-loop") {
913
- throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.INVALID_ARGUMENT, "`wp-typia add block --template query-loop` is not supported. Query Loop is a create-time `core/query` variation scaffold, so use `wp-typia create <project-dir> --template query-loop` instead.");
1092
+ throw createCliDiagnosticCodeError4(CLI_DIAGNOSTIC_CODES5.INVALID_ARGUMENT, "`wp-typia add block --template query-loop` is not supported. Query Loop is a create-time `core/query` variation scaffold, so use `wp-typia create <project-dir> --template query-loop` instead.");
914
1093
  }
915
- throw createCliDiagnosticCodeError3(CLI_DIAGNOSTIC_CODES4.UNKNOWN_TEMPLATE, `Unknown add-block template "${templateId}". Expected one of: ${formatAddBlockTemplateIds(context.addRuntime)}. Run \`wp-typia templates list\` to inspect available templates.`);
1094
+ throw createCliDiagnosticCodeError4(CLI_DIAGNOSTIC_CODES5.UNKNOWN_TEMPLATE, `Unknown add-block template "${templateId}". Expected one of: ${formatAddBlockTemplateIds(context.addRuntime)}. Run \`wp-typia templates list\` to inspect available templates.`);
916
1095
  }
917
1096
  var ADD_KIND_REGISTRY = {
918
1097
  "admin-view": defineAddKindRegistryEntry({
@@ -1414,203 +1593,24 @@ function isAddKindId(value) {
1414
1593
  }
1415
1594
  async function getAddKindExecutionPlan(kind, context) {
1416
1595
  return ADD_KIND_REGISTRY[kind].prepareExecution(context);
1417
- }
1418
- function buildAddKindCompletionDetails(kind, options) {
1419
- const descriptor = ADD_KIND_REGISTRY[kind].completion;
1420
- return {
1421
- nextSteps: descriptor.nextSteps(options.values),
1422
- summaryLines: descriptor.summaryLines(options.values, options.projectDir),
1423
- title: descriptor.title
1424
- };
1425
- }
1426
- function formatAddKindList() {
1427
- return ADD_KIND_IDS.join(", ");
1428
- }
1429
- function formatAddKindUsagePlaceholder() {
1430
- return `<${ADD_KIND_IDS.join("|")}>`;
1431
- }
1432
- function supportsAddKindDryRun(kind) {
1433
- return ADD_KIND_REGISTRY[kind].supportsDryRun;
1434
- }
1435
-
1436
- // src/config.ts
1437
- import fs from "node:fs/promises";
1438
- import os from "node:os";
1439
- import path from "node:path";
1440
- import { isPlainObject as isRecord } from "@wp-typia/api-client/runtime-primitives";
1441
- import {
1442
- CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES5,
1443
- createCliDiagnosticCodeError as createCliDiagnosticCodeError4
1444
- } from "@wp-typia/project-tools/cli-diagnostics";
1445
- import { z as z2 } from "zod";
1446
- var WP_TYPIA_CONFIG_SOURCES = [
1447
- "~/.config/wp-typia/config.json",
1448
- ".wp-typiarc",
1449
- ".wp-typiarc.json"
1450
- ];
1451
- var wpTypiaSchemaSourceSchema = z2.object({
1452
- namespace: z2.string(),
1453
- path: z2.string()
1454
- }).strict();
1455
- var createConfigSchema = z2.object({
1456
- "alternate-render-targets": z2.string().optional(),
1457
- "inner-blocks-preset": z2.string().optional(),
1458
- "data-storage": z2.string().optional(),
1459
- "dry-run": z2.boolean().optional(),
1460
- "external-layer-id": z2.string().optional(),
1461
- "external-layer-source": z2.string().optional(),
1462
- namespace: z2.string().optional(),
1463
- "no-install": z2.boolean().optional(),
1464
- "package-manager": z2.string().optional(),
1465
- "persistence-policy": z2.string().optional(),
1466
- "php-prefix": z2.string().optional(),
1467
- "query-post-type": z2.string().optional(),
1468
- template: z2.string().optional(),
1469
- "text-domain": z2.string().optional(),
1470
- variant: z2.string().optional(),
1471
- "with-migration-ui": z2.boolean().optional(),
1472
- "with-test-preset": z2.boolean().optional(),
1473
- "with-wp-env": z2.boolean().optional(),
1474
- yes: z2.boolean().optional()
1475
- }).strict();
1476
- var addBlockConfigSchema = z2.object({
1477
- "alternate-render-targets": z2.string().optional(),
1478
- "data-storage": z2.string().optional(),
1479
- "external-layer-id": z2.string().optional(),
1480
- "external-layer-source": z2.string().optional(),
1481
- "inner-blocks-preset": z2.string().optional(),
1482
- "persistence-policy": z2.string().optional(),
1483
- template: z2.string().optional()
1484
- }).strict();
1485
- var addConfigSchema = z2.object({
1486
- block: addBlockConfigSchema.optional()
1487
- }).strict();
1488
- var mcpConfigSchema = z2.object({
1489
- schemaSources: z2.array(wpTypiaSchemaSourceSchema).optional()
1490
- }).strict();
1491
- var wpTypiaUserConfigSchema = z2.object({
1492
- add: addConfigSchema.optional(),
1493
- create: createConfigSchema.optional(),
1494
- mcp: mcpConfigSchema.optional()
1495
- }).strict();
1496
- function formatIssuePath(issuePath) {
1497
- if (issuePath.length === 0) {
1498
- return "config";
1499
- }
1500
- return issuePath.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${String(segment)}`).join("").replace(/^\./u, "");
1501
- }
1502
- function formatConfigValidationIssue(issue) {
1503
- const pathLabel = formatIssuePath(issue.path);
1504
- if (issue.code === "unrecognized_keys") {
1505
- const keys = issue.keys.map((key) => `"${String(key)}"`).join(", ");
1506
- const label = issue.keys.length === 1 ? "unknown key" : "unknown keys";
1507
- return `${pathLabel}: ${label} ${keys}. Unknown keys are errors in wp-typia config.`;
1508
- }
1509
- return `${pathLabel}: ${issue.message}`;
1510
- }
1511
- function validateWpTypiaUserConfig(value, source) {
1512
- const result = wpTypiaUserConfigSchema.safeParse(value);
1513
- if (result.success) {
1514
- return result.data;
1515
- }
1516
- const issueLines = result.error.issues.map(formatConfigValidationIssue);
1517
- throw createCliDiagnosticCodeError4(CLI_DIAGNOSTIC_CODES5.INVALID_ARGUMENT, [
1518
- `Invalid wp-typia config at ${source}.`,
1519
- ...issueLines.map((line) => `- ${line}`)
1520
- ].join(`
1521
- `));
1522
- }
1523
- function deepMerge(base, incoming) {
1524
- const merged = { ...base };
1525
- for (const [key, value] of Object.entries(incoming)) {
1526
- if (Array.isArray(value)) {
1527
- merged[key] = value.slice();
1528
- continue;
1529
- }
1530
- if (isRecord(value) && isRecord(merged[key])) {
1531
- merged[key] = deepMerge(merged[key], value);
1532
- continue;
1533
- }
1534
- merged[key] = value;
1535
- }
1536
- return merged;
1537
- }
1538
- async function readJsonFile(filePath) {
1539
- let source;
1540
- try {
1541
- source = await fs.readFile(filePath, "utf8");
1542
- } catch (error) {
1543
- if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
1544
- return;
1545
- }
1546
- throw error;
1547
- }
1548
- try {
1549
- return JSON.parse(source);
1550
- } catch (error) {
1551
- const message = error instanceof Error ? error.message : String(error);
1552
- throw createCliDiagnosticCodeError4(CLI_DIAGNOSTIC_CODES5.INVALID_ARGUMENT, `Unable to parse ${filePath}: ${message}`, error instanceof Error ? { cause: error } : undefined);
1553
- }
1554
- }
1555
- async function readWpTypiaConfigFile(filePath) {
1556
- const parsed = await readJsonFile(filePath);
1557
- return parsed === undefined ? null : validateWpTypiaUserConfig(parsed, filePath);
1558
- }
1559
- function resolveConfigPath(cwd, source) {
1560
- if (source.startsWith("~/")) {
1561
- return path.join(os.homedir(), source.slice(2));
1562
- }
1563
- return path.resolve(cwd, source);
1564
- }
1565
- function mergeWpTypiaUserConfig(base, incoming) {
1566
- return deepMerge(base, incoming);
1567
- }
1568
- async function loadWpTypiaUserConfigFromSource(cwd, source) {
1569
- const config = await readWpTypiaConfigFile(resolveConfigPath(cwd, source));
1570
- return config ?? {};
1571
- }
1572
- async function loadWpTypiaUserConfig(cwd) {
1573
- let merged = {};
1574
- for (const source of WP_TYPIA_CONFIG_SOURCES) {
1575
- const configPath = resolveConfigPath(cwd, source);
1576
- const config = await readWpTypiaConfigFile(configPath);
1577
- if (config) {
1578
- merged = deepMerge(merged, config);
1579
- }
1580
- }
1581
- const packageJsonPath = path.join(cwd, "package.json");
1582
- const packageJson = await readJsonFile(packageJsonPath);
1583
- if (isRecord(packageJson) && "wp-typia" in packageJson) {
1584
- const packageConfig = validateWpTypiaUserConfig(packageJson["wp-typia"], `${packageJsonPath}#wp-typia`);
1585
- merged = deepMerge(merged, packageConfig);
1586
- }
1587
- return merged;
1588
- }
1589
- function getCreateDefaults(config) {
1590
- return config.create ?? {};
1591
- }
1592
- function getAddBlockDefaults(config) {
1593
- return config.add?.block ?? {};
1594
- }
1595
-
1596
- // src/config-override.ts
1597
- var GLOBAL_OPTION_PARSER = buildCommandOptionParser(GLOBAL_OPTION_METADATA);
1598
- function extractWpTypiaConfigOverride(argv) {
1599
- const { argv: nextArgv, flags } = extractKnownOptionValuesFromArgv(argv, {
1600
- optionNames: ["config"],
1601
- parser: GLOBAL_OPTION_PARSER
1602
- });
1596
+ }
1597
+ function buildAddKindCompletionDetails(kind, options) {
1598
+ const descriptor = ADD_KIND_REGISTRY[kind].completion;
1603
1599
  return {
1604
- argv: nextArgv,
1605
- configOverridePath: typeof flags.config === "string" ? flags.config : undefined
1600
+ nextSteps: descriptor.nextSteps(options.values),
1601
+ summaryLines: descriptor.summaryLines(options.values, options.projectDir),
1602
+ title: descriptor.title
1606
1603
  };
1607
1604
  }
1608
-
1609
- // src/runtime-bridge.ts
1610
- import {
1611
- CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES7,
1612
- createCliDiagnosticCodeError as createCliDiagnosticCodeError6
1613
- } from "@wp-typia/project-tools/cli-diagnostics";
1605
+ function formatAddKindList() {
1606
+ return ADD_KIND_IDS.join(", ");
1607
+ }
1608
+ function formatAddKindUsagePlaceholder() {
1609
+ return `<${ADD_KIND_IDS.join("|")}>`;
1610
+ }
1611
+ function supportsAddKindDryRun(kind) {
1612
+ return ADD_KIND_REGISTRY[kind].supportsDryRun;
1613
+ }
1614
1614
 
1615
1615
  // src/runtime-bridge-add-dry-run.ts
1616
1616
  import fs2 from "node:fs";
@@ -2273,6 +2273,7 @@ var loadCliInitRuntime = () => import("@wp-typia/project-tools/cli-init");
2273
2273
  var loadCliPromptRuntime = () => import("@wp-typia/project-tools/cli-prompt");
2274
2274
  var loadCliScaffoldRuntime = () => import("@wp-typia/project-tools/cli-scaffold");
2275
2275
  var loadCliTemplatesRuntime = () => import("@wp-typia/project-tools/cli-templates");
2276
+ var loadCreateTemplateValidationRuntime = () => import("@wp-typia/project-tools/create-template-validation");
2276
2277
  var loadMigrationsRuntime = () => import("@wp-typia/project-tools/migrations");
2277
2278
  async function wrapCliCommandError(command, error) {
2278
2279
  const { createCliCommandError: createCliCommandError3 } = await loadCliDiagnosticsRuntime();
@@ -2386,20 +2387,24 @@ async function executeCreateCommand({
2386
2387
  prompt,
2387
2388
  warnLine = console.warn
2388
2389
  }) {
2389
- const [
2390
- { createReadlinePrompt },
2391
- { runScaffoldFlow },
2392
- { getTemplateSelectOptions }
2393
- ] = await Promise.all([
2394
- loadCliPromptRuntime(),
2395
- loadCliScaffoldRuntime(),
2396
- loadCliTemplatesRuntime()
2397
- ]);
2398
- const shouldPrompt = interactive ?? (!Boolean(flags.yes) && isInteractiveTerminal());
2399
- const activePrompt = shouldPrompt ? prompt ?? createReadlinePrompt() : undefined;
2400
- const shouldPromptForExternalLayerSelection = Boolean(activePrompt) && activePrompt !== prompt;
2401
- const effectiveYes = Boolean(flags.yes) || Boolean(flags["dry-run"]) && !Boolean(activePrompt);
2390
+ let activePrompt;
2402
2391
  try {
2392
+ const requestedTemplateId = readOptionalLooseStringFlag(flags, "template");
2393
+ const resolvedTemplateId = requestedTemplateId ? (await loadCreateTemplateValidationRuntime()).validateExplicitCreateTemplateId(requestedTemplateId) : undefined;
2394
+ const [
2395
+ { createReadlinePrompt },
2396
+ { runScaffoldFlow },
2397
+ { getTemplateSelectOptions }
2398
+ ] = await Promise.all([
2399
+ loadCliPromptRuntime(),
2400
+ loadCliScaffoldRuntime(),
2401
+ loadCliTemplatesRuntime()
2402
+ ]);
2403
+ const shouldPrompt = interactive ?? (!Boolean(flags.yes) && isInteractiveTerminal());
2404
+ activePrompt = shouldPrompt ? prompt ?? createReadlinePrompt() : undefined;
2405
+ const scaffoldPrompt = activePrompt;
2406
+ const shouldPromptForExternalLayerSelection = Boolean(scaffoldPrompt) && scaffoldPrompt !== prompt;
2407
+ const effectiveYes = Boolean(flags.yes) || Boolean(flags["dry-run"]) && !Boolean(scaffoldPrompt);
2403
2408
  const flow = await runScaffoldFlow({
2404
2409
  alternateRenderTargets: readOptionalLooseStringFlag(flags, "alternate-render-targets"),
2405
2410
  cwd,
@@ -2408,7 +2413,7 @@ async function executeCreateCommand({
2408
2413
  externalLayerId: readOptionalLooseStringFlag(flags, "external-layer-id"),
2409
2414
  externalLayerSource: readOptionalLooseStringFlag(flags, "external-layer-source"),
2410
2415
  innerBlocksPreset: readOptionalLooseStringFlag(flags, "inner-blocks-preset"),
2411
- isInteractive: Boolean(activePrompt),
2416
+ isInteractive: Boolean(scaffoldPrompt),
2412
2417
  namespace: readOptionalLooseStringFlag(flags, "namespace"),
2413
2418
  noInstall: Boolean(flags["no-install"]),
2414
2419
  packageManager: readOptionalLooseStringFlag(flags, "package-manager"),
@@ -2425,17 +2430,17 @@ async function executeCreateCommand({
2425
2430
  printLine(formatCreateProgressLine(payload2));
2426
2431
  }
2427
2432
  },
2428
- promptText: activePrompt ? (message, defaultValue, validate) => activePrompt.text(message, defaultValue, validate) : undefined,
2433
+ promptText: scaffoldPrompt ? (message, defaultValue, validate) => scaffoldPrompt.text(message, defaultValue, validate) : undefined,
2429
2434
  queryPostType: readOptionalLooseStringFlag(flags, "query-post-type"),
2430
- selectDataStorage: activePrompt ? () => activePrompt.select("Select a data storage mode", [...DATA_STORAGE_PROMPT_OPTIONS], 1) : undefined,
2431
- selectExternalLayerId: shouldPromptForExternalLayerSelection && activePrompt ? (options) => activePrompt.select("Select an external layer", toExternalLayerPromptOptions(options), 1) : undefined,
2432
- selectPackageManager: activePrompt ? () => activePrompt.select("Select a package manager", [...PACKAGE_MANAGER_PROMPT_OPTIONS], 1) : undefined,
2433
- selectPersistencePolicy: activePrompt ? () => activePrompt.select("Select a persistence policy", [...PERSISTENCE_POLICY_PROMPT_OPTIONS], 1) : undefined,
2434
- selectTemplate: activePrompt ? () => activePrompt.select("Select a template", getTemplateSelectOptions(), 1) : undefined,
2435
- selectWithMigrationUi: activePrompt ? async () => await activePrompt.select("Enable migration UI support?", [...BOOLEAN_PROMPT_OPTIONS], 2) === "yes" : undefined,
2436
- selectWithTestPreset: activePrompt ? async () => await activePrompt.select("Include the Playwright test preset?", [...BOOLEAN_PROMPT_OPTIONS], 2) === "yes" : undefined,
2437
- selectWithWpEnv: activePrompt ? async () => await activePrompt.select("Include a local wp-env preset?", [...BOOLEAN_PROMPT_OPTIONS], 2) === "yes" : undefined,
2438
- templateId: readOptionalLooseStringFlag(flags, "template"),
2435
+ selectDataStorage: scaffoldPrompt ? () => scaffoldPrompt.select("Select a data storage mode", [...DATA_STORAGE_PROMPT_OPTIONS], 1) : undefined,
2436
+ selectExternalLayerId: shouldPromptForExternalLayerSelection && scaffoldPrompt ? (options) => scaffoldPrompt.select("Select an external layer", toExternalLayerPromptOptions(options), 1) : undefined,
2437
+ selectPackageManager: scaffoldPrompt ? () => scaffoldPrompt.select("Select a package manager", [...PACKAGE_MANAGER_PROMPT_OPTIONS], 1) : undefined,
2438
+ selectPersistencePolicy: scaffoldPrompt ? () => scaffoldPrompt.select("Select a persistence policy", [...PERSISTENCE_POLICY_PROMPT_OPTIONS], 1) : undefined,
2439
+ selectTemplate: scaffoldPrompt ? () => scaffoldPrompt.select("Select a template", getTemplateSelectOptions(), 1) : undefined,
2440
+ selectWithMigrationUi: scaffoldPrompt ? async () => await scaffoldPrompt.select("Enable migration UI support?", [...BOOLEAN_PROMPT_OPTIONS], 2) === "yes" : undefined,
2441
+ selectWithTestPreset: scaffoldPrompt ? async () => await scaffoldPrompt.select("Include the Playwright test preset?", [...BOOLEAN_PROMPT_OPTIONS], 2) === "yes" : undefined,
2442
+ selectWithWpEnv: scaffoldPrompt ? async () => await scaffoldPrompt.select("Include a local wp-env preset?", [...BOOLEAN_PROMPT_OPTIONS], 2) === "yes" : undefined,
2443
+ templateId: resolvedTemplateId,
2439
2444
  textDomain: readOptionalLooseStringFlag(flags, "text-domain"),
2440
2445
  variant: readOptionalLooseStringFlag(flags, "variant"),
2441
2446
  withMigrationUi: flags["with-migration-ui"],
@@ -2637,6 +2642,10 @@ async function executeMigrateCommand({
2637
2642
 
2638
2643
  // src/command-contract.ts
2639
2644
  import path4 from "node:path";
2645
+ import {
2646
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES8,
2647
+ createCliDiagnosticCodeError as createCliDiagnosticCodeError7
2648
+ } from "@wp-typia/project-tools/cli-diagnostics";
2640
2649
 
2641
2650
  // src/command-registry.ts
2642
2651
  var WP_TYPIA_CANONICAL_CREATE_USAGE = "wp-typia create <project-dir>";
@@ -2906,10 +2915,10 @@ function looksLikeStructuredProjectInput(value) {
2906
2915
  function assertPositionalAliasProjectDir(projectDir) {
2907
2916
  const normalizedProjectDir = path4.normalize(projectDir).replace(/[\\/]+$/u, "") || path4.normalize(projectDir);
2908
2917
  if (normalizedProjectDir === "." || normalizedProjectDir === "..") {
2909
- throw new Error(`The positional alias does not scaffold into \`${projectDir}\`. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` with an explicit child directory instead.`);
2918
+ throw createCliDiagnosticCodeError7(CLI_DIAGNOSTIC_CODES8.INVALID_ARGUMENT, `The positional alias does not scaffold into \`${projectDir}\`. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` with an explicit child directory instead.`);
2910
2919
  }
2911
2920
  if (looksLikeStructuredProjectInput(projectDir)) {
2912
- throw new Error(`The positional alias only accepts unambiguous local project directories. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` for \`${projectDir}\`.`);
2921
+ throw createCliDiagnosticCodeError7(CLI_DIAGNOSTIC_CODES8.INVALID_ARGUMENT, `The positional alias only accepts unambiguous local project directories. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` for \`${projectDir}\`.`);
2913
2922
  }
2914
2923
  }
2915
2924
  function normalizeWpTypiaArgv(argv) {
@@ -2923,7 +2932,7 @@ function normalizeWpTypiaArgv(argv) {
2923
2932
  return argv;
2924
2933
  }
2925
2934
  if (firstPositional === "migrations") {
2926
- throw new Error("`wp-typia migrations` was removed in favor of `wp-typia migrate`. Use `wp-typia migrate <subcommand>` instead.");
2935
+ throw createCliDiagnosticCodeError7(CLI_DIAGNOSTIC_CODES8.INVALID_ARGUMENT, "`wp-typia migrations` was removed in favor of `wp-typia migrate`. Use `wp-typia migrate <subcommand>` instead.");
2927
2936
  }
2928
2937
  if (isReservedTopLevelCommandName(firstPositional)) {
2929
2938
  assertStringOptionValues(argv);
@@ -2931,7 +2940,7 @@ function normalizeWpTypiaArgv(argv) {
2931
2940
  }
2932
2941
  if (positionalIndexes.length > 1) {
2933
2942
  const extraPositionals = positionalIndexes.slice(1).map((index) => argv[index]).filter((value) => typeof value === "string" && value.length > 0);
2934
- throw new Error(`The positional alias only accepts a single project directory. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` for scaffold invocations with additional positional arguments, or check the command spelling if you meant another top-level command. Extra positional arguments: ${extraPositionals.map((value) => `\`${value}\``).join(", ")}.`);
2943
+ throw createCliDiagnosticCodeError7(CLI_DIAGNOSTIC_CODES8.INVALID_ARGUMENT, `The positional alias only accepts a single project directory. Use \`${WP_TYPIA_CANONICAL_CREATE_USAGE}\` for scaffold invocations with additional positional arguments, or check the command spelling if you meant another top-level command. Extra positional arguments: ${extraPositionals.map((value) => `\`${value}\``).join(", ")}.`);
2935
2944
  }
2936
2945
  assertPositionalAliasProjectDir(firstPositional);
2937
2946
  const normalizedArgv = [
@@ -2943,9 +2952,111 @@ function normalizeWpTypiaArgv(argv) {
2943
2952
  return normalizedArgv;
2944
2953
  }
2945
2954
 
2946
- // src/node-cli.ts
2947
- var NODE_FALLBACK_OPTION_PARSER = buildCommandOptionParser(ALL_COMMAND_OPTION_METADATA);
2948
- var NODE_FALLBACK_BOOLEAN_OPTION_NAMES = ["help", "version"];
2955
+ // src/node-fallback/dispatchers/add.ts
2956
+ import {
2957
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES9,
2958
+ createCliCommandError as createCliCommandError3
2959
+ } from "@wp-typia/project-tools/cli-diagnostics";
2960
+ async function dispatchNodeFallbackAdd({
2961
+ cwd,
2962
+ mergedFlags,
2963
+ positionals,
2964
+ printLine
2965
+ }) {
2966
+ if (!positionals[1]) {
2967
+ if (mergedFlags.format !== "json") {
2968
+ const { formatAddHelpText } = await import("@wp-typia/project-tools/cli-add");
2969
+ printLine(formatAddHelpText());
2970
+ }
2971
+ throw createCliCommandError3({
2972
+ code: CLI_DIAGNOSTIC_CODES9.MISSING_ARGUMENT,
2973
+ command: "add",
2974
+ detailLines: [
2975
+ `\`wp-typia add\` requires <kind>. Usage: wp-typia add ${formatAddKindUsagePlaceholder()} ...`
2976
+ ]
2977
+ });
2978
+ }
2979
+ if (mergedFlags.format === "json") {
2980
+ let completion;
2981
+ try {
2982
+ completion = await executeAddCommand({
2983
+ cwd,
2984
+ emitOutput: false,
2985
+ flags: mergedFlags,
2986
+ interactive: false,
2987
+ kind: positionals[1],
2988
+ name: positionals[2]
2989
+ });
2990
+ } catch (error) {
2991
+ throw createCliCommandError3({
2992
+ command: "add",
2993
+ error
2994
+ });
2995
+ }
2996
+ printLine(JSON.stringify(buildStructuredCompletionSuccessPayload("add", completion, {
2997
+ dryRun: Boolean(mergedFlags["dry-run"]),
2998
+ kind: positionals[1],
2999
+ name: positionals[2],
3000
+ projectDir: extractCompletionProjectDir(completion) ?? cwd
3001
+ }), null, 2));
3002
+ return;
3003
+ }
3004
+ await executeAddCommand({
3005
+ cwd,
3006
+ flags: mergedFlags,
3007
+ interactive: undefined,
3008
+ kind: positionals[1],
3009
+ name: positionals[2]
3010
+ });
3011
+ }
3012
+
3013
+ // src/node-fallback/dispatchers/create.ts
3014
+ import {
3015
+ CLI_DIAGNOSTIC_CODES as CLI_DIAGNOSTIC_CODES10,
3016
+ createCliCommandError as createCliCommandError4
3017
+ } from "@wp-typia/project-tools/cli-diagnostics";
3018
+ async function dispatchNodeFallbackCreate({
3019
+ cwd,
3020
+ mergedFlags,
3021
+ positionals,
3022
+ printLine
3023
+ }) {
3024
+ const projectDir = positionals[1];
3025
+ if (!projectDir) {
3026
+ throw createCliCommandError4({
3027
+ code: CLI_DIAGNOSTIC_CODES10.MISSING_ARGUMENT,
3028
+ command: "create",
3029
+ detailLines: [
3030
+ "`wp-typia create` requires <project-dir>.",
3031
+ "`--dry-run` still needs a logical project directory name because wp-typia derives slugs, package names, and planned file paths from it."
3032
+ ]
3033
+ });
3034
+ }
3035
+ let completion;
3036
+ try {
3037
+ completion = await executeCreateCommand({
3038
+ cwd,
3039
+ emitOutput: mergedFlags.format !== "json",
3040
+ flags: mergedFlags,
3041
+ interactive: mergedFlags.format === "json" ? false : undefined,
3042
+ projectDir
3043
+ });
3044
+ } catch (error) {
3045
+ throw createCliCommandError4({
3046
+ command: "create",
3047
+ error
3048
+ });
3049
+ }
3050
+ if (mergedFlags.format === "json") {
3051
+ printLine(JSON.stringify(buildStructuredCompletionSuccessPayload("create", completion, {
3052
+ dryRun: Boolean(mergedFlags["dry-run"]),
3053
+ projectDir: extractCompletionProjectDir(completion) ?? projectDir,
3054
+ template: typeof mergedFlags.template === "string" ? mergedFlags.template : undefined
3055
+ }), null, 2));
3056
+ }
3057
+ }
3058
+
3059
+ // src/node-fallback/help.ts
2949
3060
  var STANDALONE_GUIDANCE_LINE = "Prefer not to install Bun? Use the standalone wp-typia binary from the GitHub release assets.";
2950
3061
  var NODE_FALLBACK_RUNTIME_SUMMARY_LINES = [
2951
3062
  "Runtime: Node fallback",
@@ -2953,72 +3064,13 @@ var NODE_FALLBACK_RUNTIME_SUMMARY_LINES = [
2953
3064
  `Install Bun 1.3.11+ or use \`bunx wp-typia ...\` for the full Bunli/OpenTUI runtime and Bun-only command surfaces such as \`skills\`, \`completions\`, and \`mcp\`. ${STANDALONE_GUIDANCE_LINE}`,
2954
3065
  "Output markers: WP_TYPIA_ASCII=1 forces ASCII markers, WP_TYPIA_ASCII=0 opts back into Unicode markers, and non-empty NO_COLOR requests ASCII markers when WP_TYPIA_ASCII is unset."
2955
3066
  ];
2956
- var printLine = (line) => {
2957
- console.log(line);
2958
- };
2959
- function printBlock2(lines) {
3067
+ function printBlock2(printLine, lines) {
2960
3068
  for (const line of lines) {
2961
3069
  printLine(line);
2962
3070
  }
2963
3071
  }
2964
- function hasFlagBeforeTerminator(argv, flag) {
2965
- for (const arg of argv) {
2966
- if (arg === "--") {
2967
- return false;
2968
- }
2969
- if (arg === flag) {
2970
- return true;
2971
- }
2972
- }
2973
- return false;
2974
- }
2975
- function parseGlobalFlags(argv) {
2976
- const { argv: nextArgv, flags } = extractKnownOptionValuesFromArgv(argv, {
2977
- optionNames: ["format", "id"],
2978
- parser: NODE_FALLBACK_OPTION_PARSER
2979
- });
2980
- return {
2981
- argv: nextArgv,
2982
- flags: {
2983
- format: typeof flags.format === "string" ? flags.format : undefined,
2984
- id: typeof flags.id === "string" ? flags.id : undefined
2985
- }
2986
- };
2987
- }
2988
- async function applyNodeFallbackConfigDefaults(command, subcommand, flags, configOverridePath, cwd) {
2989
- let config = await loadWpTypiaUserConfig(cwd);
2990
- if (configOverridePath) {
2991
- const overrideConfig = await loadWpTypiaUserConfigFromSource(cwd, configOverridePath);
2992
- config = mergeWpTypiaUserConfig(config, overrideConfig);
2993
- }
2994
- if (command === "create") {
2995
- return {
2996
- ...flags,
2997
- ...resolveCommandOptionValues(CREATE_OPTION_METADATA, {
2998
- defaults: getCreateDefaults(config),
2999
- flags
3000
- })
3001
- };
3002
- }
3003
- if (command === "add" && subcommand === "block") {
3004
- return {
3005
- ...flags,
3006
- ...resolveCommandOptionValues(ADD_OPTION_METADATA, {
3007
- defaults: getAddBlockDefaults(config),
3008
- flags
3009
- })
3010
- };
3011
- }
3012
- return flags;
3013
- }
3014
- function parseArgv(argv) {
3015
- return parseCommandArgvWithMetadata(argv, {
3016
- extraBooleanOptionNames: NODE_FALLBACK_BOOLEAN_OPTION_NAMES,
3017
- parser: NODE_FALLBACK_OPTION_PARSER
3018
- });
3019
- }
3020
- function renderGeneralHelp() {
3021
- printBlock2([
3072
+ function renderGeneralHelp(printLine) {
3073
+ printBlock2(printLine, [
3022
3074
  `wp-typia ${package_default.version}`,
3023
3075
  "",
3024
3076
  "Canonical CLI package for wp-typia scaffolding and project workflows.",
@@ -3035,8 +3087,8 @@ function renderGeneralHelp() {
3035
3087
  `- ${WP_TYPIA_POSITIONAL_ALIAS_USAGE}`
3036
3088
  ]);
3037
3089
  }
3038
- function renderNodeFallbackCommandHelp(config) {
3039
- printBlock2([
3090
+ function renderNodeFallbackCommandHelp(printLine, config) {
3091
+ printBlock2(printLine, [
3040
3092
  config.heading,
3041
3093
  "",
3042
3094
  ...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
@@ -3085,8 +3137,71 @@ var NODE_FALLBACK_COMMAND_HELP_CONFIG = {
3085
3137
  };
3086
3138
  var NODE_FALLBACK_HELP_RENDERERS = Object.fromEntries(Object.entries(NODE_FALLBACK_COMMAND_HELP_CONFIG).map(([command, config]) => [
3087
3139
  command,
3088
- () => renderNodeFallbackCommandHelp(config)
3140
+ (printLine) => renderNodeFallbackCommandHelp(printLine, config)
3089
3141
  ]));
3142
+
3143
+ // src/node-cli.ts
3144
+ var NODE_FALLBACK_OPTION_PARSER = buildCommandOptionParser(ALL_COMMAND_OPTION_METADATA);
3145
+ var NODE_FALLBACK_BOOLEAN_OPTION_NAMES = ["help", "version"];
3146
+ var printLine = (line) => {
3147
+ console.log(line);
3148
+ };
3149
+ function hasFlagBeforeTerminator(argv, flag) {
3150
+ for (const arg of argv) {
3151
+ if (arg === "--") {
3152
+ return false;
3153
+ }
3154
+ if (arg === flag) {
3155
+ return true;
3156
+ }
3157
+ }
3158
+ return false;
3159
+ }
3160
+ function parseGlobalFlags(argv) {
3161
+ const { argv: nextArgv, flags } = extractKnownOptionValuesFromArgv(argv, {
3162
+ optionNames: ["format", "id"],
3163
+ parser: NODE_FALLBACK_OPTION_PARSER
3164
+ });
3165
+ return {
3166
+ argv: nextArgv,
3167
+ flags: {
3168
+ format: typeof flags.format === "string" ? flags.format : undefined,
3169
+ id: typeof flags.id === "string" ? flags.id : undefined
3170
+ }
3171
+ };
3172
+ }
3173
+ async function applyNodeFallbackConfigDefaults(command, subcommand, flags, configOverridePath, cwd) {
3174
+ let config = await loadWpTypiaUserConfig(cwd);
3175
+ if (configOverridePath) {
3176
+ const overrideConfig = await loadWpTypiaUserConfigFromSource(cwd, configOverridePath);
3177
+ config = mergeWpTypiaUserConfig(config, overrideConfig);
3178
+ }
3179
+ if (command === "create") {
3180
+ return {
3181
+ ...flags,
3182
+ ...resolveCommandOptionValues(CREATE_OPTION_METADATA, {
3183
+ defaults: getCreateDefaults(config),
3184
+ flags
3185
+ })
3186
+ };
3187
+ }
3188
+ if (command === "add" && subcommand === "block") {
3189
+ return {
3190
+ ...flags,
3191
+ ...resolveCommandOptionValues(ADD_OPTION_METADATA, {
3192
+ defaults: getAddBlockDefaults(config),
3193
+ flags
3194
+ })
3195
+ };
3196
+ }
3197
+ return flags;
3198
+ }
3199
+ function parseArgv(argv) {
3200
+ return parseCommandArgvWithMetadata(argv, {
3201
+ extraBooleanOptionNames: NODE_FALLBACK_BOOLEAN_OPTION_NAMES,
3202
+ parser: NODE_FALLBACK_OPTION_PARSER
3203
+ });
3204
+ }
3090
3205
  function renderVersion(options = {}) {
3091
3206
  if (options.format === "json") {
3092
3207
  printLine(JSON.stringify({
@@ -3110,16 +3225,16 @@ function renderTemplatesJson(flags, subcommand) {
3110
3225
  }
3111
3226
  const templateId = flags.id;
3112
3227
  if (!templateId) {
3113
- throw createCliCommandError3({
3114
- code: CLI_DIAGNOSTIC_CODES8.MISSING_ARGUMENT,
3228
+ throw createCliCommandError5({
3229
+ code: CLI_DIAGNOSTIC_CODES11.MISSING_ARGUMENT,
3115
3230
  command: "templates",
3116
3231
  detailLines: ["`wp-typia templates inspect` requires <template-id>."]
3117
3232
  });
3118
3233
  }
3119
3234
  const template = getTemplateById(templateId);
3120
3235
  if (!template) {
3121
- throw createCliCommandError3({
3122
- code: CLI_DIAGNOSTIC_CODES8.INVALID_ARGUMENT,
3236
+ throw createCliCommandError5({
3237
+ code: CLI_DIAGNOSTIC_CODES11.INVALID_ARGUMENT,
3123
3238
  command: "templates",
3124
3239
  detailLines: [`Unknown template "${templateId}".`]
3125
3240
  });
@@ -3129,8 +3244,8 @@ function renderTemplatesJson(flags, subcommand) {
3129
3244
  }, null, 2));
3130
3245
  }
3131
3246
  function renderUnsupportedCommand(command) {
3132
- throw createCliCommandError3({
3133
- code: CLI_DIAGNOSTIC_CODES8.UNSUPPORTED_COMMAND,
3247
+ throw createCliCommandError5({
3248
+ code: CLI_DIAGNOSTIC_CODES11.UNSUPPORTED_COMMAND,
3134
3249
  command,
3135
3250
  detailLines: [
3136
3251
  [
@@ -3145,7 +3260,7 @@ function renderUnsupportedCommand(command) {
3145
3260
  async function renderDoctorJson() {
3146
3261
  const [
3147
3262
  { getDoctorChecks },
3148
- { createCliCommandError: createCliCommandError4, getDoctorFailureDetailLines }
3263
+ { createCliCommandError: createCliCommandError6, getDoctorFailureDetailLines }
3149
3264
  ] = await Promise.all([
3150
3265
  import("@wp-typia/project-tools/cli-doctor"),
3151
3266
  import("@wp-typia/project-tools/cli-diagnostics")
@@ -3155,8 +3270,8 @@ async function renderDoctorJson() {
3155
3270
  checks
3156
3271
  }, null, 2));
3157
3272
  if (checks.some((check) => check.status === "fail")) {
3158
- throw createCliCommandError4({
3159
- code: CLI_DIAGNOSTIC_CODES8.DOCTOR_CHECK_FAILED,
3273
+ throw createCliCommandError6({
3274
+ code: CLI_DIAGNOSTIC_CODES11.DOCTOR_CHECK_FAILED,
3160
3275
  command: "doctor",
3161
3276
  detailLines: getDoctorFailureDetailLines(checks),
3162
3277
  summary: "One or more doctor checks failed."
@@ -3164,94 +3279,8 @@ async function renderDoctorJson() {
3164
3279
  }
3165
3280
  }
3166
3281
  var NODE_FALLBACK_COMMAND_DISPATCHERS = {
3167
- add: async ({
3168
- cwd,
3169
- mergedFlags,
3170
- positionals
3171
- }) => {
3172
- if (!positionals[1]) {
3173
- const { formatAddHelpText } = await import("@wp-typia/project-tools/cli-add");
3174
- printLine(formatAddHelpText());
3175
- throw createCliCommandError3({
3176
- code: CLI_DIAGNOSTIC_CODES8.MISSING_ARGUMENT,
3177
- command: "add",
3178
- detailLines: [
3179
- `\`wp-typia add\` requires <kind>. Usage: wp-typia add ${formatAddKindUsagePlaceholder()} ...`
3180
- ]
3181
- });
3182
- }
3183
- if (mergedFlags.format === "json") {
3184
- let completion;
3185
- try {
3186
- completion = await executeAddCommand({
3187
- cwd,
3188
- emitOutput: false,
3189
- flags: mergedFlags,
3190
- interactive: false,
3191
- kind: positionals[1],
3192
- name: positionals[2]
3193
- });
3194
- } catch (error) {
3195
- throw createCliCommandError3({
3196
- command: "add",
3197
- error
3198
- });
3199
- }
3200
- printLine(JSON.stringify(buildStructuredCompletionSuccessPayload("add", completion, {
3201
- dryRun: Boolean(mergedFlags["dry-run"]),
3202
- kind: positionals[1],
3203
- name: positionals[2],
3204
- projectDir: extractCompletionProjectDir(completion) ?? cwd
3205
- }), null, 2));
3206
- return;
3207
- }
3208
- await executeAddCommand({
3209
- cwd,
3210
- flags: mergedFlags,
3211
- interactive: undefined,
3212
- kind: positionals[1],
3213
- name: positionals[2]
3214
- });
3215
- },
3216
- create: async ({
3217
- cwd,
3218
- mergedFlags,
3219
- positionals
3220
- }) => {
3221
- const projectDir = positionals[1];
3222
- if (!projectDir) {
3223
- throw createCliCommandError3({
3224
- code: CLI_DIAGNOSTIC_CODES8.MISSING_ARGUMENT,
3225
- command: "create",
3226
- detailLines: [
3227
- "`wp-typia create` requires <project-dir>.",
3228
- "`--dry-run` still needs a logical project directory name because wp-typia derives slugs, package names, and planned file paths from it."
3229
- ]
3230
- });
3231
- }
3232
- let completion;
3233
- try {
3234
- completion = await executeCreateCommand({
3235
- cwd,
3236
- emitOutput: mergedFlags.format !== "json",
3237
- flags: mergedFlags,
3238
- interactive: mergedFlags.format === "json" ? false : undefined,
3239
- projectDir
3240
- });
3241
- } catch (error) {
3242
- throw createCliCommandError3({
3243
- command: "create",
3244
- error
3245
- });
3246
- }
3247
- if (mergedFlags.format === "json") {
3248
- printLine(JSON.stringify(buildStructuredCompletionSuccessPayload("create", completion, {
3249
- dryRun: Boolean(mergedFlags["dry-run"]),
3250
- projectDir: extractCompletionProjectDir(completion) ?? projectDir,
3251
- template: typeof mergedFlags.template === "string" ? mergedFlags.template : undefined
3252
- }), null, 2));
3253
- }
3254
- },
3282
+ add: dispatchNodeFallbackAdd,
3283
+ create: dispatchNodeFallbackCreate,
3255
3284
  doctor: async ({ cwd, mergedFlags }) => {
3256
3285
  if (mergedFlags.format === "json") {
3257
3286
  await renderDoctorJson();
@@ -3317,7 +3346,7 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
3317
3346
  }));
3318
3347
  }
3319
3348
  } catch (error) {
3320
- throw createCliCommandError3({
3349
+ throw createCliCommandError5({
3321
3350
  command: "sync",
3322
3351
  error
3323
3352
  });
@@ -3331,8 +3360,8 @@ var NODE_FALLBACK_COMMAND_DISPATCHERS = {
3331
3360
  const templateId = typeof mergedFlags.id === "string" ? mergedFlags.id : positionals[2];
3332
3361
  const resolvedSubcommand = templateId ? "inspect" : subcommand ?? "list";
3333
3362
  if (resolvedSubcommand !== "list" && resolvedSubcommand !== "inspect") {
3334
- throw createCliCommandError3({
3335
- code: CLI_DIAGNOSTIC_CODES8.INVALID_COMMAND,
3363
+ throw createCliCommandError5({
3364
+ code: CLI_DIAGNOSTIC_CODES11.INVALID_COMMAND,
3336
3365
  command: "templates",
3337
3366
  detailLines: [
3338
3367
  `Unknown templates subcommand "${resolvedSubcommand}". Expected list or inspect.`
@@ -3370,7 +3399,7 @@ async function runNodeCli(argv = process.argv.slice(2)) {
3370
3399
  const helpTarget = command === "help" ? subcommand : command;
3371
3400
  const versionRequested = hasFlagBeforeTerminator(cliArgv, "--version") || command === "version";
3372
3401
  if (cliArgv.length === 0) {
3373
- renderGeneralHelp();
3402
+ renderGeneralHelp(printLine);
3374
3403
  process.exitCode = 1;
3375
3404
  return;
3376
3405
  }
@@ -3378,18 +3407,18 @@ async function runNodeCli(argv = process.argv.slice(2)) {
3378
3407
  if (helpTarget) {
3379
3408
  const helpRenderer = NODE_FALLBACK_HELP_RENDERERS[helpTarget];
3380
3409
  if (helpRenderer) {
3381
- helpRenderer();
3410
+ helpRenderer(printLine);
3382
3411
  return;
3383
3412
  }
3384
3413
  if (helpTarget === "help" || helpTarget === "version") {
3385
- renderGeneralHelp();
3414
+ renderGeneralHelp(printLine);
3386
3415
  return;
3387
3416
  }
3388
3417
  } else {
3389
- renderGeneralHelp();
3418
+ renderGeneralHelp(printLine);
3390
3419
  return;
3391
3420
  }
3392
- renderGeneralHelp();
3421
+ renderGeneralHelp(printLine);
3393
3422
  return;
3394
3423
  }
3395
3424
  if (versionRequested) {
@@ -3404,7 +3433,8 @@ async function runNodeCli(argv = process.argv.slice(2)) {
3404
3433
  await commandDispatcher({
3405
3434
  cwd: process.cwd(),
3406
3435
  mergedFlags,
3407
- positionals
3436
+ positionals,
3437
+ printLine
3408
3438
  });
3409
3439
  return;
3410
3440
  }
@@ -3416,7 +3446,7 @@ async function runNodeCliEntrypoint(argv = process.argv.slice(2)) {
3416
3446
  await runNodeCli(argv);
3417
3447
  } catch (error) {
3418
3448
  if (prefersStructuredErrorOutput) {
3419
- const diagnostic = createCliCommandError3({
3449
+ const diagnostic = createCliCommandError5({
3420
3450
  command: resolveCanonicalCommandContext(argv),
3421
3451
  error
3422
3452
  });
@@ -3439,4 +3469,4 @@ export {
3439
3469
  hasFlagBeforeTerminator
3440
3470
  };
3441
3471
 
3442
- //# debugId=5D4E56BAE8A1432964756E2164756E21
3472
+ //# debugId=8C4AF690141E04CA64756E2164756E21