wp-typia 0.20.2 → 0.20.4

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.20.2",
6
+ version: "0.20.4",
7
7
  description: "Canonical CLI package for wp-typia scaffolding and project workflows",
8
8
  packageManager: "bun@1.3.11",
9
9
  type: "module",
@@ -71,7 +71,7 @@ var package_default = {
71
71
  "@bunli/tui": "0.6.0",
72
72
  "@bunli/utils": "0.6.0",
73
73
  "@wp-typia/api-client": "^0.4.5",
74
- "@wp-typia/project-tools": "0.19.3",
74
+ "@wp-typia/project-tools": "0.20.1",
75
75
  "better-result": "^2.7.0",
76
76
  react: "^19.2.5",
77
77
  "react-dom": "^19.2.5",
@@ -229,7 +229,7 @@ var ADD_OPTION_METADATA = {
229
229
  type: "string"
230
230
  },
231
231
  namespace: {
232
- description: "REST namespace for rest-resource workflows.",
232
+ description: "REST namespace for rest-resource and ai-feature workflows.",
233
233
  type: "string"
234
234
  },
235
235
  "persistence-policy": {
@@ -441,6 +441,8 @@ var ADD_KIND_IDS = [
441
441
  "pattern",
442
442
  "binding-source",
443
443
  "rest-resource",
444
+ "ability",
445
+ "ai-feature",
444
446
  "editor-plugin",
445
447
  "hooked-block"
446
448
  ];
@@ -505,6 +507,22 @@ var ADD_KIND_REGISTRY = {
505
507
  return true;
506
508
  })
507
509
  },
510
+ ability: {
511
+ completion: {
512
+ nextSteps: (values) => [
513
+ `Review src/abilities/${values.abilitySlug}/ and inc/abilities/${values.abilitySlug}.php.`,
514
+ "Run `wp-typia sync` or `npm run sync-abilities -- --check` and then your workspace build/dev command to verify the generated workflow ability."
515
+ ],
516
+ summaryLines: (values, projectDir) => [
517
+ `Ability: ${values.abilitySlug}`,
518
+ `Project directory: ${projectDir}`
519
+ ],
520
+ title: "Added workflow ability"
521
+ },
522
+ description: "Add a typed server/client workflow ability scaffold",
523
+ nameLabel: "Ability name",
524
+ visibleFieldNames: () => ["kind", "name"]
525
+ },
508
526
  "editor-plugin": {
509
527
  completion: {
510
528
  nextSteps: (values) => [
@@ -574,6 +592,23 @@ var ADD_KIND_REGISTRY = {
574
592
  nameLabel: "REST resource name",
575
593
  visibleFieldNames: () => ["kind", "name", "namespace", "methods"]
576
594
  },
595
+ "ai-feature": {
596
+ completion: {
597
+ nextSteps: (values) => [
598
+ `Review src/ai-features/${values.aiFeatureSlug}/ and inc/ai-features/${values.aiFeatureSlug}.php.`,
599
+ "Run `wp-typia sync-rest` and `wp-typia sync ai` or your workspace build/dev command to verify the generated REST artifacts and AI schema."
600
+ ],
601
+ summaryLines: (values, projectDir) => [
602
+ `AI feature: ${values.aiFeatureSlug}`,
603
+ `Namespace: ${values.namespace}`,
604
+ `Project directory: ${projectDir}`
605
+ ],
606
+ title: "Added server-only AI feature"
607
+ },
608
+ description: "Add a server-owned WordPress AI feature endpoint",
609
+ nameLabel: "AI feature name",
610
+ visibleFieldNames: () => ["kind", "name", "namespace"]
611
+ },
577
612
  variation: {
578
613
  completion: {
579
614
  nextSteps: (values) => [
@@ -1090,16 +1125,19 @@ function buildAddDryRunPayload(options, markerOptions) {
1090
1125
  };
1091
1126
  }
1092
1127
  function buildSyncDryRunPayload(options, markerOptions) {
1128
+ const targetSuffix = options.target === "ai" ? " ai" : "";
1129
+ const targetSummary = options.target === "ai" ? "Sync target: AI artifacts only." : options.target === "default" ? "Sync target: generated project defaults." : undefined;
1093
1130
  return {
1094
1131
  optionalLines: options.plannedCommands.map((command) => command.displayCommand),
1095
- optionalNote: options.check ? "No sync scripts were executed because --dry-run was enabled. Re-run `wp-typia sync --check` to verify generated artifacts without rewriting them." : "No sync scripts were executed because --dry-run was enabled. Re-run without --dry-run to apply generated-file updates, or add --check to verify without rewriting.",
1132
+ optionalNote: options.check ? `No sync scripts were executed because --dry-run was enabled. Re-run \`wp-typia sync${targetSuffix} --check\` to verify generated artifacts without rewriting them.` : `No sync scripts were executed because --dry-run was enabled. Re-run \`wp-typia sync${targetSuffix}\` without --dry-run to apply generated-file updates, or add --check to verify without rewriting.`,
1096
1133
  optionalTitle: `Planned sync commands (${options.plannedCommands.length}):`,
1097
1134
  summaryLines: [
1098
1135
  `Project directory: ${options.projectDir}`,
1099
1136
  `Package manager: ${options.packageManager}`,
1137
+ ...targetSummary ? [targetSummary] : [],
1100
1138
  options.check ? "Execution mode: would run generated sync scripts in verification mode." : "Execution mode: would run generated sync scripts in apply mode."
1101
1139
  ],
1102
- title: formatOutputMarker("dryRun", "Dry run for wp-typia sync", markerOptions)
1140
+ title: formatOutputMarker("dryRun", `Dry run for wp-typia sync${targetSuffix}`, markerOptions)
1103
1141
  };
1104
1142
  }
1105
1143
  function printBlock(lines, printLine) {
@@ -1134,9 +1172,22 @@ function isInteractiveTerminal({
1134
1172
  import { spawnSync } from "node:child_process";
1135
1173
  import fs4 from "node:fs";
1136
1174
  import path4 from "node:path";
1137
- var SYNC_INSTALL_MARKERS = ["node_modules", ".pnp.cjs", ".pnp.loader.mjs"];
1175
+ var SYNC_INSTALL_MARKERS = [
1176
+ "node_modules",
1177
+ ".pnp.cjs",
1178
+ ".pnp.loader.mjs"
1179
+ ];
1138
1180
  var LOCAL_SYNC_TOOL_PATTERN = /(^|[\s;&|()])(?:tsx|wp-scripts)(?=($|[\s;&|()]))/u;
1139
1181
  var CAPTURED_SYNC_OUTPUT_MAX_BUFFER = 16 * 1024 * 1024;
1182
+ function resolveSyncExecutionTarget(subcommand) {
1183
+ if (!subcommand) {
1184
+ return "default";
1185
+ }
1186
+ if (subcommand === "ai") {
1187
+ return "ai";
1188
+ }
1189
+ throw new Error(`Unknown sync subcommand "${subcommand}". Expected one of: "ai".`);
1190
+ }
1140
1191
  function formatRunScript(packageManagerId, scriptName, extraArgs = "") {
1141
1192
  const args = extraArgs.trim();
1142
1193
  if (packageManagerId === "bun") {
@@ -1197,13 +1248,26 @@ function resolveSyncProjectContext(cwd) {
1197
1248
  const packageJson = JSON.parse(fs4.readFileSync(packageJsonPath, "utf8"));
1198
1249
  const scripts = packageJson.scripts ?? {};
1199
1250
  const syncScripts = {
1200
- sync: typeof scripts.sync === "string" ? scripts.sync : undefined,
1201
- "sync-rest": typeof scripts["sync-rest"] === "string" ? scripts["sync-rest"] : undefined,
1202
- "sync-types": typeof scripts["sync-types"] === "string" ? scripts["sync-types"] : undefined
1251
+ sync: typeof scripts.sync === "string" ? {
1252
+ command: scripts.sync,
1253
+ scriptName: "sync"
1254
+ } : undefined,
1255
+ "sync-ai": typeof scripts["sync-ai"] === "string" ? {
1256
+ command: scripts["sync-ai"],
1257
+ scriptName: "sync-ai"
1258
+ } : typeof scripts["sync-wordpress-ai"] === "string" ? {
1259
+ command: scripts["sync-wordpress-ai"],
1260
+ scriptName: "sync-wordpress-ai"
1261
+ } : undefined,
1262
+ "sync-rest": typeof scripts["sync-rest"] === "string" ? {
1263
+ command: scripts["sync-rest"],
1264
+ scriptName: "sync-rest"
1265
+ } : undefined,
1266
+ "sync-types": typeof scripts["sync-types"] === "string" ? {
1267
+ command: scripts["sync-types"],
1268
+ scriptName: "sync-types"
1269
+ } : undefined
1203
1270
  };
1204
- if (!syncScripts.sync && !syncScripts["sync-types"]) {
1205
- throw new Error(`Expected ${packageJsonPath} to define either a \`sync\` or \`sync-types\` script.`);
1206
- }
1207
1271
  return {
1208
1272
  cwd,
1209
1273
  packageJsonPath,
@@ -1224,12 +1288,16 @@ function findInstalledDependencyMarkerDir(projectDir) {
1224
1288
  currentDir = parentDir;
1225
1289
  }
1226
1290
  }
1227
- function scriptsLikelyNeedInstalledDependencies(project) {
1228
- const candidateScripts = project.scripts.sync ? [project.scripts.sync] : [project.scripts["sync-types"], project.scripts["sync-rest"]];
1229
- return candidateScripts.some((script) => typeof script === "string" && LOCAL_SYNC_TOOL_PATTERN.test(script));
1291
+ function scriptsLikelyNeedInstalledDependencies(project, target) {
1292
+ const candidateScripts = target === "ai" ? [project.scripts["sync-ai"]] : project.scripts.sync ? [project.scripts.sync] : [
1293
+ project.scripts["sync-types"],
1294
+ project.scripts["sync-rest"],
1295
+ project.scripts["sync-ai"]
1296
+ ];
1297
+ return candidateScripts.some((script) => script !== undefined && LOCAL_SYNC_TOOL_PATTERN.test(script.command));
1230
1298
  }
1231
- function assertSyncDependenciesInstalled(project) {
1232
- if (!scriptsLikelyNeedInstalledDependencies(project)) {
1299
+ function assertSyncDependenciesInstalled(project, target) {
1300
+ if (!scriptsLikelyNeedInstalledDependencies(project, target)) {
1233
1301
  return;
1234
1302
  }
1235
1303
  const markerDir = findInstalledDependencyMarkerDir(project.cwd);
@@ -1244,7 +1312,11 @@ function getPackageManagerRunInvocation(packageManager, scriptName, extraArgs) {
1244
1312
  return { args: ["run", scriptName, ...extraArgs], command: "bun" };
1245
1313
  case "npm":
1246
1314
  return {
1247
- args: ["run", scriptName, ...extraArgs.length > 0 ? ["--", ...extraArgs] : []],
1315
+ args: [
1316
+ "run",
1317
+ scriptName,
1318
+ ...extraArgs.length > 0 ? ["--", ...extraArgs] : []
1319
+ ],
1248
1320
  command: "npm"
1249
1321
  };
1250
1322
  case "pnpm":
@@ -1258,23 +1330,38 @@ function createSyncPlannedCommand(project, scriptName, extraArgs) {
1258
1330
  if (!script) {
1259
1331
  return null;
1260
1332
  }
1261
- const invocation = getPackageManagerRunInvocation(project.packageManager, scriptName, extraArgs);
1333
+ const invocation = getPackageManagerRunInvocation(project.packageManager, script.scriptName, extraArgs);
1262
1334
  return {
1263
1335
  args: invocation.args,
1264
1336
  command: invocation.command,
1265
- displayCommand: formatRunScript(project.packageManager, scriptName, extraArgs.join(" ")),
1266
- scriptName
1337
+ displayCommand: formatRunScript(project.packageManager, script.scriptName, extraArgs.join(" ")),
1338
+ scriptName: script.scriptName
1267
1339
  };
1268
1340
  }
1269
- function buildSyncPlannedCommands(project, extraArgs) {
1341
+ function buildSyncPlannedCommands(project, extraArgs, target) {
1342
+ if (target === "ai") {
1343
+ const syncAiCommand2 = createSyncPlannedCommand(project, "sync-ai", extraArgs);
1344
+ if (!syncAiCommand2) {
1345
+ throw new Error(`Expected ${project.packageJsonPath} to define a \`sync-ai\` script for \`wp-typia sync ai\`.`);
1346
+ }
1347
+ return [syncAiCommand2];
1348
+ }
1270
1349
  if (project.scripts.sync) {
1271
1350
  return [createSyncPlannedCommand(project, "sync", extraArgs)];
1272
1351
  }
1273
- const plannedCommands = [createSyncPlannedCommand(project, "sync-types", extraArgs)];
1352
+ const syncTypesCommand = createSyncPlannedCommand(project, "sync-types", extraArgs);
1353
+ if (!syncTypesCommand) {
1354
+ throw new Error(`Expected ${project.packageJsonPath} to define either a \`sync\` or \`sync-types\` script.`);
1355
+ }
1356
+ const plannedCommands = [syncTypesCommand];
1274
1357
  const syncRestCommand = createSyncPlannedCommand(project, "sync-rest", extraArgs);
1275
1358
  if (syncRestCommand) {
1276
1359
  plannedCommands.push(syncRestCommand);
1277
1360
  }
1361
+ const syncAiCommand = createSyncPlannedCommand(project, "sync-ai", extraArgs);
1362
+ if (syncAiCommand) {
1363
+ plannedCommands.push(syncAiCommand);
1364
+ }
1278
1365
  return plannedCommands;
1279
1366
  }
1280
1367
  function runProjectScript(project, plannedCommand, options) {
@@ -1303,23 +1390,25 @@ async function executeSyncCommand({
1303
1390
  captureOutput = false,
1304
1391
  check = false,
1305
1392
  cwd,
1306
- dryRun = false
1393
+ dryRun = false,
1394
+ target = "default"
1307
1395
  }) {
1308
1396
  const project = resolveSyncProjectContext(cwd);
1309
1397
  const extraArgs = check ? ["--check"] : [];
1310
- const plannedCommands = buildSyncPlannedCommands(project, extraArgs);
1398
+ const plannedCommands = buildSyncPlannedCommands(project, extraArgs, target);
1311
1399
  const result = {
1312
1400
  check,
1313
1401
  dryRun,
1314
1402
  packageJsonPath: project.packageJsonPath,
1315
1403
  packageManager: project.packageManager,
1316
1404
  plannedCommands,
1317
- projectDir: project.cwd
1405
+ projectDir: project.cwd,
1406
+ target
1318
1407
  };
1319
1408
  if (dryRun) {
1320
1409
  return result;
1321
1410
  }
1322
- assertSyncDependenciesInstalled(project);
1411
+ assertSyncDependenciesInstalled(project, target);
1323
1412
  result.executedCommands = plannedCommands.map((plannedCommand) => runProjectScript(project, plannedCommand, {
1324
1413
  captureOutput
1325
1414
  }));
@@ -1397,6 +1486,22 @@ function runRegisteredAddKind(context, plan) {
1397
1486
  });
1398
1487
  }
1399
1488
  var ADD_KIND_EXECUTION_REGISTRY = {
1489
+ ability: async (context) => {
1490
+ const name = requireAddKindName(context, "`wp-typia add ability` requires <name>. Usage: wp-typia add ability <name>.");
1491
+ return runRegisteredAddKind(context, {
1492
+ buildCompletion: (result) => buildAddCompletionPayload({
1493
+ kind: "ability",
1494
+ projectDir: result.projectDir,
1495
+ values: {
1496
+ abilitySlug: result.abilitySlug
1497
+ }
1498
+ }),
1499
+ execute: (targetCwd) => context.addRuntime.runAddAbilityCommand({
1500
+ abilityName: name,
1501
+ cwd: targetCwd
1502
+ })
1503
+ });
1504
+ },
1400
1505
  "binding-source": async (context) => {
1401
1506
  const name = requireAddKindName(context, "`wp-typia add binding-source` requires <name>. Usage: wp-typia add binding-source <name>.");
1402
1507
  return runRegisteredAddKind(context, {
@@ -1471,6 +1576,26 @@ var ADD_KIND_EXECUTION_REGISTRY = {
1471
1576
  })
1472
1577
  });
1473
1578
  },
1579
+ "ai-feature": async (context) => {
1580
+ const name = requireAddKindName(context, "`wp-typia add ai-feature` requires <name>. Usage: wp-typia add ai-feature <name> [--namespace <vendor/v1>].");
1581
+ const namespace = readOptionalStringFlag(context.flags, "namespace");
1582
+ return runRegisteredAddKind(context, {
1583
+ buildCompletion: (result) => buildAddCompletionPayload({
1584
+ kind: "ai-feature",
1585
+ projectDir: result.projectDir,
1586
+ values: {
1587
+ aiFeatureSlug: result.aiFeatureSlug,
1588
+ namespace: result.namespace
1589
+ },
1590
+ warnings: result.warnings
1591
+ }),
1592
+ execute: (targetCwd) => context.addRuntime.runAddAiFeatureCommand({
1593
+ aiFeatureName: name,
1594
+ cwd: targetCwd,
1595
+ namespace
1596
+ })
1597
+ });
1598
+ },
1474
1599
  "hooked-block": async (context) => {
1475
1600
  const name = requireAddKindName(context, "`wp-typia add hooked-block` requires <block-slug>. Usage: wp-typia add hooked-block <block-slug> --anchor <anchor-block-name> --position <before|after|firstChild|lastChild>.");
1476
1601
  const anchorBlockName = readOptionalStringFlag(context.flags, "anchor");
@@ -1957,7 +2082,8 @@ var WP_TYPIA_FUTURE_COMMAND_TREE = [
1957
2082
  },
1958
2083
  {
1959
2084
  description: "Run the common generated-project sync workflow.",
1960
- name: "sync"
2085
+ name: "sync",
2086
+ subcommands: ["ai"]
1961
2087
  },
1962
2088
  {
1963
2089
  description: "Extend an official wp-typia workspace.",
@@ -2256,6 +2382,8 @@ function renderAddHelp() {
2256
2382
  "",
2257
2383
  ...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
2258
2384
  "",
2385
+ `Supported kinds: ${formatAddKindList()}`,
2386
+ "",
2259
2387
  "Supported flags:",
2260
2388
  ...formatNodeFallbackOptionHelp(ADD_OPTION_METADATA)
2261
2389
  ]);
@@ -2272,7 +2400,7 @@ function renderMigrateHelp() {
2272
2400
  }
2273
2401
  function renderSyncHelp() {
2274
2402
  printBlock2([
2275
- "Usage: wp-typia sync",
2403
+ "Usage: wp-typia sync [ai]",
2276
2404
  "",
2277
2405
  ...NODE_FALLBACK_RUNTIME_SUMMARY_LINES,
2278
2406
  "",
@@ -2516,11 +2644,13 @@ async function runNodeCli(argv = process.argv.slice(2)) {
2516
2644
  }
2517
2645
  if (command === "sync") {
2518
2646
  try {
2647
+ const syncTarget = resolveSyncExecutionTarget(positionals[1]);
2519
2648
  const sync = await executeSyncCommand({
2520
2649
  captureOutput: mergedFlags.format === "json" && !Boolean(mergedFlags["dry-run"]),
2521
2650
  check: Boolean(mergedFlags.check),
2522
2651
  cwd: process.cwd(),
2523
- dryRun: Boolean(mergedFlags["dry-run"])
2652
+ dryRun: Boolean(mergedFlags["dry-run"]),
2653
+ target: syncTarget
2524
2654
  });
2525
2655
  if (mergedFlags.format === "json") {
2526
2656
  printLine(JSON.stringify({
@@ -2533,7 +2663,8 @@ async function runNodeCli(argv = process.argv.slice(2)) {
2533
2663
  check: sync.check,
2534
2664
  packageManager: sync.packageManager,
2535
2665
  plannedCommands: sync.plannedCommands,
2536
- projectDir: sync.projectDir
2666
+ projectDir: sync.projectDir,
2667
+ target: sync.target
2537
2668
  }));
2538
2669
  }
2539
2670
  } catch (error) {
@@ -2576,4 +2707,4 @@ export {
2576
2707
  hasFlagBeforeTerminator
2577
2708
  };
2578
2709
 
2579
- //# debugId=0ECCDE28BD4229FC64756E2164756E21
2710
+ //# debugId=2B2288BD839BD95964756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wp-typia",
3
- "version": "0.20.2",
3
+ "version": "0.20.4",
4
4
  "description": "Canonical CLI package for wp-typia scaffolding and project workflows",
5
5
  "packageManager": "bun@1.3.11",
6
6
  "type": "module",
@@ -68,7 +68,7 @@
68
68
  "@bunli/tui": "0.6.0",
69
69
  "@bunli/utils": "0.6.0",
70
70
  "@wp-typia/api-client": "^0.4.5",
71
- "@wp-typia/project-tools": "0.19.3",
71
+ "@wp-typia/project-tools": "0.20.1",
72
72
  "better-result": "^2.7.0",
73
73
  "react": "^19.2.5",
74
74
  "react-dom": "^19.2.5",