wp-typia 0.20.4 → 0.21.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.
@@ -3,13 +3,15 @@ import {
3
3
  exports_external
4
4
  } from "./cli-hv2yedw2.js";
5
5
  import {
6
+ CLI_DIAGNOSTIC_CODES,
6
7
  createCliCommandError,
8
+ createCliDiagnosticCodeError,
7
9
  serializeCliDiagnosticError
8
- } from "./cli-jcd4wgam.js";
10
+ } from "./cli-p95wr1q8.js";
9
11
  // package.json
10
12
  var package_default = {
11
13
  name: "wp-typia",
12
- version: "0.20.4",
14
+ version: "0.21.0",
13
15
  description: "Canonical CLI package for wp-typia scaffolding and project workflows",
14
16
  packageManager: "bun@1.3.11",
15
17
  type: "module",
@@ -23,7 +25,9 @@ var package_default = {
23
25
  "package.json"
24
26
  ],
25
27
  scripts: {
26
- generate: "bun scripts/generate-bunli-metadata.ts",
28
+ "generate:routing": "node scripts/generate-routing-metadata.mjs",
29
+ "validate:routing": "node scripts/generate-routing-metadata.mjs --check",
30
+ generate: "node scripts/generate-routing-metadata.mjs && bun scripts/generate-bunli-metadata.ts",
27
31
  build: "bun run generate && bun scripts/build-bunli-runtime.ts",
28
32
  "build:standalone": "bun scripts/build-standalone-runtime.ts --targets native --outdir ./dist-standalone",
29
33
  "build:standalone:release": "bun scripts/build-standalone-runtime.ts --targets darwin-arm64,darwin-x64,linux-arm64,linux-x64,windows-x64 --outdir ./.cache/standalone/raw",
@@ -77,7 +81,7 @@ var package_default = {
77
81
  "@bunli/tui": "0.6.0",
78
82
  "@bunli/utils": "0.6.0",
79
83
  "@wp-typia/api-client": "^0.4.5",
80
- "@wp-typia/project-tools": "0.20.1",
84
+ "@wp-typia/project-tools": "0.21.0",
81
85
  "better-result": "^2.7.0",
82
86
  react: "^19.2.5",
83
87
  "react-dom": "^19.2.5",
@@ -196,8 +200,12 @@ var ADD_OPTION_METADATA = {
196
200
  description: "Anchor block name for hooked-block workflows.",
197
201
  type: "string"
198
202
  },
203
+ attribute: {
204
+ description: "Target block attribute for end-to-end binding-source workflows.",
205
+ type: "string"
206
+ },
199
207
  block: {
200
- description: "Target block slug for variation workflows.",
208
+ description: "Target block slug for variation, style, and end-to-end binding-source workflows.",
201
209
  type: "string"
202
210
  },
203
211
  "data-storage": {
@@ -217,6 +225,10 @@ var ADD_OPTION_METADATA = {
217
225
  description: "Local path, GitHub locator, or npm package that exposes wp-typia.layers.json for built-in block templates.",
218
226
  type: "string"
219
227
  },
228
+ from: {
229
+ description: "Source full block name (namespace/block) for transform workflows.",
230
+ type: "string"
231
+ },
220
232
  "inner-blocks-preset": {
221
233
  description: "Compound-only InnerBlocks preset (freeform, ordered, horizontal, locked-structure).",
222
234
  type: "string"
@@ -238,11 +250,31 @@ var ADD_OPTION_METADATA = {
238
250
  type: "string"
239
251
  },
240
252
  slot: {
241
- description: "Document editor shell slot for editor-plugin workflows.",
253
+ description: "Document editor shell slot for editor-plugin workflows (sidebar or document-setting-panel).",
254
+ type: "string"
255
+ },
256
+ source: {
257
+ description: "Optional data source locator for admin-view workflows, such as rest-resource:products.",
242
258
  type: "string"
243
259
  },
244
260
  template: {
245
- description: "Built-in block family for the new block.",
261
+ description: "Optional built-in block family for the new block; interactive flows let you choose it when omitted and non-interactive runs default to basic.",
262
+ type: "string"
263
+ },
264
+ to: {
265
+ description: "Target workspace block slug or full block name for transform workflows.",
266
+ type: "string"
267
+ }
268
+ };
269
+ var INIT_OPTION_METADATA = {
270
+ apply: {
271
+ argumentKind: "flag",
272
+ description: "Write the planned package.json updates and retrofit helper files instead of previewing only.",
273
+ type: "boolean"
274
+ },
275
+ "package-manager": {
276
+ description: "Package manager to use for emitted scripts and next steps.",
277
+ short: "p",
246
278
  type: "string"
247
279
  }
248
280
  };
@@ -294,6 +326,12 @@ var SYNC_OPTION_METADATA = {
294
326
  type: "boolean"
295
327
  }
296
328
  };
329
+ var DOCTOR_OPTION_METADATA = {
330
+ format: {
331
+ description: "Use `json` for machine-readable doctor check output.",
332
+ type: "string"
333
+ }
334
+ };
297
335
  var TEMPLATES_OPTION_METADATA = {
298
336
  id: {
299
337
  description: "Template id for `templates inspect`.",
@@ -319,6 +357,30 @@ var GLOBAL_OPTION_METADATA = {
319
357
  type: "string"
320
358
  }
321
359
  };
360
+ var COMMAND_OPTION_METADATA_BY_GROUP = {
361
+ add: ADD_OPTION_METADATA,
362
+ create: CREATE_OPTION_METADATA,
363
+ doctor: DOCTOR_OPTION_METADATA,
364
+ global: GLOBAL_OPTION_METADATA,
365
+ init: INIT_OPTION_METADATA,
366
+ migrate: MIGRATE_OPTION_METADATA,
367
+ sync: SYNC_OPTION_METADATA,
368
+ templates: TEMPLATES_OPTION_METADATA
369
+ };
370
+ var COMMAND_OPTION_GROUP_NAMES = Object.keys(COMMAND_OPTION_METADATA_BY_GROUP);
371
+ function collectCommandOptionMetadata(...groupNames) {
372
+ const metadata = {};
373
+ for (const groupName of groupNames) {
374
+ for (const [optionName, option] of Object.entries(COMMAND_OPTION_METADATA_BY_GROUP[groupName])) {
375
+ metadata[optionName] = {
376
+ ...metadata[optionName] ?? {},
377
+ ...option
378
+ };
379
+ }
380
+ }
381
+ return metadata;
382
+ }
383
+ var ALL_COMMAND_OPTION_METADATA = collectCommandOptionMetadata(...COMMAND_OPTION_GROUP_NAMES);
322
384
  function buildCommandOptions(metadata) {
323
385
  return Object.fromEntries(Object.entries(metadata).map(([name, option]) => [
324
386
  name,
@@ -334,13 +396,99 @@ function collectOptionNamesByType(metadata, type) {
334
396
  return Object.entries(metadata).filter(([, option]) => option.type === type).map(([name]) => name);
335
397
  }
336
398
  function buildCommandOptionParser(...metadataMaps) {
337
- const metadata = Object.assign({}, ...metadataMaps);
399
+ const metadata = {};
400
+ for (const metadataMap of metadataMaps) {
401
+ for (const [optionName, option] of Object.entries(metadataMap)) {
402
+ metadata[optionName] = {
403
+ ...metadata[optionName] ?? {},
404
+ ...option
405
+ };
406
+ }
407
+ }
338
408
  return {
339
409
  booleanOptionNames: new Set(collectOptionNamesByType(metadata, "boolean")),
340
410
  shortFlagMap: new Map(Object.entries(metadata).flatMap(([name, option]) => option.short ? [[option.short, { name, type: option.type }]] : [])),
341
411
  stringOptionNames: new Set(collectOptionNamesByType(metadata, "string"))
342
412
  };
343
413
  }
414
+ function buildArgvWalkerRoutingMetadata(...metadataMaps) {
415
+ const parser = buildCommandOptionParser(...metadataMaps);
416
+ return {
417
+ longValueOptions: Array.from(parser.stringOptionNames).map((optionName) => `--${optionName}`).sort((left, right) => left.localeCompare(right)),
418
+ shortValueOptions: Array.from(parser.shortFlagMap.entries()).filter(([, option]) => option.type === "string").map(([short]) => `-${short}`).sort((left, right) => left.localeCompare(right))
419
+ };
420
+ }
421
+ var COMMAND_ROUTING_METADATA = buildArgvWalkerRoutingMetadata(ALL_COMMAND_OPTION_METADATA);
422
+ function extractKnownOptionValuesFromArgv(argv, options) {
423
+ const flags = {};
424
+ const nextArgv = [];
425
+ const optionNames = new Set(options.optionNames);
426
+ for (let index = 0;index < argv.length; index += 1) {
427
+ const arg = argv[index];
428
+ if (!arg) {
429
+ continue;
430
+ }
431
+ if (arg === "--") {
432
+ nextArgv.push(...argv.slice(index));
433
+ break;
434
+ }
435
+ if (arg.length === 2 && arg.startsWith("-")) {
436
+ const shortFlag = options.parser.shortFlagMap.get(arg.slice(1));
437
+ if (!shortFlag || !optionNames.has(shortFlag.name)) {
438
+ nextArgv.push(arg);
439
+ continue;
440
+ }
441
+ if (shortFlag.type === "boolean") {
442
+ flags[shortFlag.name] = true;
443
+ continue;
444
+ }
445
+ const next = argv[index + 1];
446
+ if (!next || next.startsWith("-")) {
447
+ throw new Error(`\`${arg}\` requires a value.`);
448
+ }
449
+ flags[shortFlag.name] = next;
450
+ index += 1;
451
+ continue;
452
+ }
453
+ if (arg.startsWith("--")) {
454
+ const option = arg.slice(2);
455
+ const separatorIndex = option.indexOf("=");
456
+ const rawName = separatorIndex === -1 ? option : option.slice(0, separatorIndex);
457
+ const inlineValue = separatorIndex === -1 ? undefined : option.slice(separatorIndex + 1);
458
+ if (!optionNames.has(rawName)) {
459
+ nextArgv.push(arg);
460
+ continue;
461
+ }
462
+ if (options.parser.booleanOptionNames.has(rawName)) {
463
+ flags[rawName] = true;
464
+ continue;
465
+ }
466
+ if (!options.parser.stringOptionNames.has(rawName)) {
467
+ nextArgv.push(arg);
468
+ continue;
469
+ }
470
+ if (inlineValue !== undefined) {
471
+ if (!inlineValue) {
472
+ throw new Error(`\`--${rawName}\` requires a value.`);
473
+ }
474
+ flags[rawName] = inlineValue;
475
+ continue;
476
+ }
477
+ const next = argv[index + 1];
478
+ if (!next || next.startsWith("-")) {
479
+ throw new Error(`\`--${rawName}\` requires a value.`);
480
+ }
481
+ flags[rawName] = next;
482
+ index += 1;
483
+ continue;
484
+ }
485
+ nextArgv.push(arg);
486
+ }
487
+ return {
488
+ argv: nextArgv,
489
+ flags
490
+ };
491
+ }
344
492
  function resolveCommandOptionValues(metadata, options) {
345
493
  const resolved = {};
346
494
  const optionNames = options.optionNames ?? Object.keys(metadata);
@@ -360,47 +508,54 @@ function resolveCommandOptionValues(metadata, options) {
360
508
  return resolved;
361
509
  }
362
510
 
363
- // src/cli-diagnostic-output.ts
364
- var ALL_OPTION_METADATA = {
365
- ...GLOBAL_OPTION_METADATA,
366
- ...CREATE_OPTION_METADATA,
367
- ...ADD_OPTION_METADATA,
368
- ...MIGRATE_OPTION_METADATA,
369
- ...SYNC_OPTION_METADATA,
370
- ...TEMPLATES_OPTION_METADATA
371
- };
372
- var CLI_STRING_OPTION_NAMES = new Set(Object.entries(ALL_OPTION_METADATA).flatMap(([name, option]) => option.type === "string" ? [
373
- `--${name}`,
374
- ..."short" in option && option.short ? [`-${option.short}`] : []
375
- ] : []));
376
- function resolveEntrypointCliCommand(argv) {
511
+ // bin/argv-walker.js
512
+ function normalizeOptionSet(values) {
513
+ return values instanceof Set ? values : new Set(values);
514
+ }
515
+ function collectPositionalIndexes(argv, metadata) {
516
+ const longValueOptionSet = normalizeOptionSet(metadata.longValueOptions);
517
+ const shortValueOptionSet = normalizeOptionSet(metadata.shortValueOptions);
518
+ const positionalIndexes = [];
377
519
  for (let index = 0;index < argv.length; index += 1) {
378
520
  const arg = argv[index];
379
- if (!arg) {
380
- continue;
381
- }
382
521
  if (arg === "--") {
522
+ for (let restIndex = index + 1;restIndex < argv.length; restIndex += 1) {
523
+ positionalIndexes.push(restIndex);
524
+ }
383
525
  break;
384
526
  }
385
- if (CLI_STRING_OPTION_NAMES.has(arg)) {
386
- const next = argv[index + 1];
387
- if (next && !next.startsWith("-")) {
388
- index += 1;
389
- }
527
+ if (!arg.startsWith("-") || arg === "-") {
528
+ positionalIndexes.push(index);
390
529
  continue;
391
530
  }
392
531
  if (arg.startsWith("--")) {
393
- const [inlineName] = arg.split("=", 1);
394
- if (inlineName && CLI_STRING_OPTION_NAMES.has(inlineName)) {
532
+ if (arg.includes("=")) {
395
533
  continue;
396
534
  }
397
- }
398
- if (arg.startsWith("-")) {
535
+ const next = argv[index + 1];
536
+ if (longValueOptionSet.has(arg) && next && !next.startsWith("-")) {
537
+ index += 1;
538
+ }
399
539
  continue;
400
540
  }
401
- return arg;
541
+ if (arg.length === 2 && shortValueOptionSet.has(arg) && argv[index + 1] && !argv[index + 1].startsWith("-")) {
542
+ index += 1;
543
+ }
402
544
  }
403
- return "wp-typia";
545
+ return positionalIndexes;
546
+ }
547
+ function findFirstPositionalIndex(argv, metadata) {
548
+ const positionalIndexes = collectPositionalIndexes(argv, metadata);
549
+ return positionalIndexes[0] ?? -1;
550
+ }
551
+ function findFirstPositional(argv, metadata) {
552
+ const firstPositionalIndex = findFirstPositionalIndex(argv, metadata);
553
+ return firstPositionalIndex === -1 ? undefined : argv[firstPositionalIndex];
554
+ }
555
+
556
+ // src/cli-diagnostic-output.ts
557
+ function resolveEntrypointCliCommand(argv) {
558
+ return findFirstPositional(argv, COMMAND_ROUTING_METADATA) ?? "wp-typia";
404
559
  }
405
560
  function prefersStructuredCliArgv(argv) {
406
561
  for (let index = 0;index < argv.length; index += 1) {
@@ -451,6 +606,150 @@ function writeStructuredCliDiagnosticError(argv, error) {
451
606
  return true;
452
607
  }
453
608
 
609
+ // src/command-registry.ts
610
+ var WP_TYPIA_CANONICAL_CREATE_USAGE = "wp-typia create <project-dir>";
611
+ var WP_TYPIA_COMMAND_REGISTRY = [
612
+ {
613
+ commandTree: true,
614
+ description: "Scaffold a new wp-typia project.",
615
+ name: "create",
616
+ nodeFallback: true,
617
+ optionGroups: ["create"],
618
+ requiresBunRuntime: false
619
+ },
620
+ {
621
+ commandTree: true,
622
+ description: "Preview or apply the minimum retrofit plan for an existing project.",
623
+ name: "init",
624
+ nodeFallback: true,
625
+ optionGroups: ["init"],
626
+ requiresBunRuntime: false
627
+ },
628
+ {
629
+ commandTree: true,
630
+ description: "Run the common generated-project sync workflow.",
631
+ name: "sync",
632
+ nodeFallback: true,
633
+ optionGroups: ["sync"],
634
+ requiresBunRuntime: false,
635
+ subcommands: ["ai"]
636
+ },
637
+ {
638
+ commandTree: true,
639
+ description: "Extend an official wp-typia workspace.",
640
+ name: "add",
641
+ nodeFallback: true,
642
+ optionGroups: ["add"],
643
+ requiresBunRuntime: false,
644
+ subcommands: [
645
+ "block",
646
+ "variation",
647
+ "style",
648
+ "transform",
649
+ "pattern",
650
+ "binding-source",
651
+ "rest-resource",
652
+ "editor-plugin",
653
+ "hooked-block"
654
+ ]
655
+ },
656
+ {
657
+ commandTree: true,
658
+ description: "Run migration workflows.",
659
+ name: "migrate",
660
+ nodeFallback: true,
661
+ optionGroups: ["migrate"],
662
+ requiresBunRuntime: false,
663
+ subcommands: [
664
+ "init",
665
+ "snapshot",
666
+ "diff",
667
+ "scaffold",
668
+ "plan",
669
+ "wizard",
670
+ "verify",
671
+ "doctor",
672
+ "fixtures",
673
+ "fuzz"
674
+ ]
675
+ },
676
+ {
677
+ commandTree: true,
678
+ description: "Inspect scaffold templates.",
679
+ name: "templates",
680
+ nodeFallback: true,
681
+ optionGroups: ["templates"],
682
+ requiresBunRuntime: false,
683
+ subcommands: ["list", "inspect"]
684
+ },
685
+ {
686
+ commandTree: true,
687
+ description: "Run repository and project diagnostics.",
688
+ name: "doctor",
689
+ nodeFallback: true,
690
+ optionGroups: ["doctor"],
691
+ requiresBunRuntime: false
692
+ },
693
+ {
694
+ commandTree: true,
695
+ description: "Inspect or sync schema-driven MCP metadata.",
696
+ name: "mcp",
697
+ nodeFallback: false,
698
+ optionGroups: [],
699
+ requiresBunRuntime: true,
700
+ subcommands: ["list", "sync"]
701
+ },
702
+ {
703
+ commandTree: false,
704
+ name: "help",
705
+ nodeFallback: true,
706
+ optionGroups: [],
707
+ requiresBunRuntime: false
708
+ },
709
+ {
710
+ commandTree: false,
711
+ name: "version",
712
+ nodeFallback: true,
713
+ optionGroups: [],
714
+ requiresBunRuntime: false
715
+ },
716
+ {
717
+ commandTree: false,
718
+ name: "skills",
719
+ nodeFallback: false,
720
+ optionGroups: [],
721
+ requiresBunRuntime: true
722
+ },
723
+ {
724
+ commandTree: false,
725
+ name: "completions",
726
+ nodeFallback: false,
727
+ optionGroups: [],
728
+ requiresBunRuntime: true
729
+ },
730
+ {
731
+ commandTree: false,
732
+ name: "complete",
733
+ nodeFallback: false,
734
+ optionGroups: [],
735
+ requiresBunRuntime: true
736
+ }
737
+ ];
738
+ var WP_TYPIA_RESERVED_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.map((command) => command.name);
739
+ var WP_TYPIA_NODE_FALLBACK_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.nodeFallback).map((command) => command.name);
740
+ var WP_TYPIA_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.commandTree).map((command) => command.name);
741
+ var WP_TYPIA_BUN_REQUIRED_TOP_LEVEL_COMMAND_NAMES = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.requiresBunRuntime).map((command) => command.name);
742
+ var WP_TYPIA_FUTURE_COMMAND_TREE = WP_TYPIA_COMMAND_REGISTRY.filter((command) => command.commandTree).map((command) => ({
743
+ description: command.description,
744
+ name: command.name,
745
+ subcommands: "subcommands" in command ? command.subcommands : undefined
746
+ }));
747
+ var commandOptionGroupNamesByTopLevelCommand = {};
748
+ for (const command of WP_TYPIA_COMMAND_REGISTRY) {
749
+ commandOptionGroupNamesByTopLevelCommand[command.name] = command.optionGroups;
750
+ }
751
+ var WP_TYPIA_COMMAND_OPTION_GROUP_NAMES_BY_TOP_LEVEL_COMMAND = commandOptionGroupNamesByTopLevelCommand;
752
+
454
753
  // src/config.ts
455
754
  import fs from "fs/promises";
456
755
  import os from "os";
@@ -477,16 +776,22 @@ function deepMerge(base, incoming) {
477
776
  return merged;
478
777
  }
479
778
  async function readJsonFile(filePath) {
779
+ let source;
480
780
  try {
481
- const source = await fs.readFile(filePath, "utf8");
482
- const parsed = JSON.parse(source);
483
- return isRecord(parsed) ? parsed : null;
781
+ source = await fs.readFile(filePath, "utf8");
484
782
  } catch (error) {
485
783
  if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
486
784
  return null;
487
785
  }
488
786
  throw error;
489
787
  }
788
+ try {
789
+ const parsed = JSON.parse(source);
790
+ return isRecord(parsed) ? parsed : null;
791
+ } catch (error) {
792
+ const message = error instanceof Error ? error.message : String(error);
793
+ throw createCliDiagnosticCodeError(CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT, `Unable to parse ${filePath}: ${message}`, error instanceof Error ? { cause: error } : undefined);
794
+ }
490
795
  }
491
796
  function resolveConfigPath(cwd, source) {
492
797
  if (source.startsWith("~/")) {
@@ -530,6 +835,6 @@ function getMcpSchemaSources(config) {
530
835
  function createPlugin(input) {
531
836
  return input;
532
837
  }
533
- export { createPlugin, package_default, CREATE_OPTION_METADATA, ADD_OPTION_METADATA, MIGRATE_OPTION_METADATA, SYNC_OPTION_METADATA, TEMPLATES_OPTION_METADATA, GLOBAL_OPTION_METADATA, buildCommandOptions, collectOptionNamesByType, buildCommandOptionParser, resolveCommandOptionValues, prefersStructuredCliOutput, emitCliDiagnosticFailure, writeStructuredCliDiagnosticError, WP_TYPIA_CONFIG_SOURCES, mergeWpTypiaUserConfig, loadWpTypiaUserConfigFromSource, loadWpTypiaUserConfig, getCreateDefaults, getAddBlockDefaults, getMcpSchemaSources };
838
+ export { createPlugin, package_default, CREATE_OPTION_METADATA, ADD_OPTION_METADATA, INIT_OPTION_METADATA, MIGRATE_OPTION_METADATA, SYNC_OPTION_METADATA, DOCTOR_OPTION_METADATA, TEMPLATES_OPTION_METADATA, GLOBAL_OPTION_METADATA, COMMAND_OPTION_METADATA_BY_GROUP, ALL_COMMAND_OPTION_METADATA, buildCommandOptions, collectOptionNamesByType, buildCommandOptionParser, COMMAND_ROUTING_METADATA, extractKnownOptionValuesFromArgv, resolveCommandOptionValues, collectPositionalIndexes, findFirstPositionalIndex, prefersStructuredCliOutput, emitCliDiagnosticFailure, writeStructuredCliDiagnosticError, WP_TYPIA_CANONICAL_CREATE_USAGE, WP_TYPIA_RESERVED_TOP_LEVEL_COMMAND_NAMES, WP_TYPIA_TOP_LEVEL_COMMAND_NAMES, WP_TYPIA_COMMAND_OPTION_GROUP_NAMES_BY_TOP_LEVEL_COMMAND, WP_TYPIA_CONFIG_SOURCES, mergeWpTypiaUserConfig, loadWpTypiaUserConfigFromSource, loadWpTypiaUserConfig, getCreateDefaults, getAddBlockDefaults, getMcpSchemaSources };
534
839
 
535
- //# debugId=33737B5BBB1DCAAF64756E2164756E21
840
+ //# debugId=C2E45FEA52BDC1AC64756E2164756E21