@wp-typia/project-tools 0.20.2 → 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.
Files changed (47) hide show
  1. package/dist/runtime/cli-add-shared.d.ts +73 -5
  2. package/dist/runtime/cli-add-shared.js +58 -11
  3. package/dist/runtime/cli-add-workspace-ability.js +11 -57
  4. package/dist/runtime/cli-add-workspace-admin-view.d.ts +23 -0
  5. package/dist/runtime/cli-add-workspace-admin-view.js +872 -0
  6. package/dist/runtime/cli-add-workspace-ai-anchors.js +2 -5
  7. package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +0 -4
  8. package/dist/runtime/cli-add-workspace-ai-source-emitters.js +7 -17
  9. package/dist/runtime/cli-add-workspace-ai.js +4 -6
  10. package/dist/runtime/cli-add-workspace-assets.d.ts +13 -5
  11. package/dist/runtime/cli-add-workspace-assets.js +290 -106
  12. package/dist/runtime/cli-add-workspace-rest-anchors.js +2 -5
  13. package/dist/runtime/cli-add-workspace-rest-source-emitters.d.ts +0 -1
  14. package/dist/runtime/cli-add-workspace-rest-source-emitters.js +7 -14
  15. package/dist/runtime/cli-add-workspace-rest.js +4 -6
  16. package/dist/runtime/cli-add-workspace.d.ts +58 -1
  17. package/dist/runtime/cli-add-workspace.js +588 -18
  18. package/dist/runtime/cli-add.d.ts +1 -1
  19. package/dist/runtime/cli-add.js +1 -1
  20. package/dist/runtime/cli-core.d.ts +8 -5
  21. package/dist/runtime/cli-core.js +7 -4
  22. package/dist/runtime/cli-diagnostics.d.ts +83 -1
  23. package/dist/runtime/cli-diagnostics.js +85 -2
  24. package/dist/runtime/cli-doctor-workspace.js +552 -13
  25. package/dist/runtime/cli-doctor.d.ts +4 -2
  26. package/dist/runtime/cli-doctor.js +2 -1
  27. package/dist/runtime/cli-help.js +19 -9
  28. package/dist/runtime/cli-init.d.ts +67 -3
  29. package/dist/runtime/cli-init.js +603 -64
  30. package/dist/runtime/cli-validation.js +4 -3
  31. package/dist/runtime/index.d.ts +9 -4
  32. package/dist/runtime/index.js +7 -3
  33. package/dist/runtime/package-json-types.d.ts +12 -0
  34. package/dist/runtime/package-json-types.js +1 -0
  35. package/dist/runtime/package-versions.d.ts +17 -2
  36. package/dist/runtime/package-versions.js +46 -1
  37. package/dist/runtime/php-utils.d.ts +16 -0
  38. package/dist/runtime/php-utils.js +59 -0
  39. package/dist/runtime/scaffold-answer-resolution.js +7 -6
  40. package/dist/runtime/scaffold-apply-utils.d.ts +2 -3
  41. package/dist/runtime/scaffold-apply-utils.js +3 -43
  42. package/dist/runtime/template-source-cache.d.ts +112 -0
  43. package/dist/runtime/template-source-cache.js +434 -0
  44. package/dist/runtime/template-source-seeds.js +319 -53
  45. package/dist/runtime/workspace-inventory.d.ts +43 -2
  46. package/dist/runtime/workspace-inventory.js +138 -5
  47. package/package.json +2 -2
@@ -8,6 +8,7 @@
8
8
  * Import `formatAddHelpText`, `runAddBlockCommand`,
9
9
  * `runAddVariationCommand`, `runAddPatternCommand`,
10
10
  * `runAddBindingSourceCommand`, `runAddHookedBlockCommand`,
11
+ * `runAddAdminViewCommand` for DataViews-backed admin screen scaffolds,
11
12
  * `runAddAbilityCommand` for typed workflow ability scaffolds,
12
13
  * and `HOOKED_BLOCK_POSITION_IDS`,
13
14
  * `getWorkspaceBlockSelectOptions`, and `seedWorkspaceMigrationProject` for
@@ -15,8 +16,10 @@
15
16
  * `runAddAiFeatureCommand` for server-owned WordPress AI feature scaffolds,
16
17
  * `runAddRestResourceCommand` for plugin-level REST resource scaffolds,
17
18
  * `getDoctorChecks`, `runDoctor`, and `DoctorCheck` for diagnostics,
18
- * `createCliCommandError` and `formatCliDiagnosticError` for shared
19
- * non-interactive failure rendering,
19
+ * `createCliCommandError`, `createCliDiagnosticCodeError`,
20
+ * `CLI_DIAGNOSTIC_CODES`, `CLI_DIAGNOSTIC_CODE_METADATA`,
21
+ * `getCliDiagnosticCodeMetadata`, and `formatCliDiagnosticError` for shared
22
+ * non-interactive failure rendering and explicit diagnostic-code ownership,
20
23
  * `formatHelpText` for top-level CLI usage output, scaffold helpers such as
21
24
  * `createReadlinePrompt`, `getNextSteps`, `getOptionalOnboarding`,
22
25
  * `runScaffoldFlow`, and `ReadlinePrompt` for interactive project creation,
@@ -26,9 +29,9 @@
26
29
  * template inspection flows.
27
30
  */
28
31
  export { getDoctorChecks, runDoctor, type DoctorCheck } from "./cli-doctor.js";
29
- export { createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
30
- export type { CliDiagnosticMessage } from "./cli-diagnostics.js";
31
- export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
32
+ export { createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODE_METADATA, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getCliDiagnosticCodeMetadata, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
33
+ export type { CliDiagnosticCode, CliDiagnosticCodeError, CliDiagnosticMessage, } from "./cli-diagnostics.js";
34
+ export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
32
35
  export { COMPOUND_INNER_BLOCKS_PRESET_IDS, getCompoundInnerBlocksPresetDefinition, } from "./compound-inner-blocks.js";
33
36
  export type { CompoundInnerBlocksPresetId } from "./compound-inner-blocks.js";
34
37
  export { HOOKED_BLOCK_POSITION_IDS } from "./hooked-blocks.js";
@@ -8,6 +8,7 @@
8
8
  * Import `formatAddHelpText`, `runAddBlockCommand`,
9
9
  * `runAddVariationCommand`, `runAddPatternCommand`,
10
10
  * `runAddBindingSourceCommand`, `runAddHookedBlockCommand`,
11
+ * `runAddAdminViewCommand` for DataViews-backed admin screen scaffolds,
11
12
  * `runAddAbilityCommand` for typed workflow ability scaffolds,
12
13
  * and `HOOKED_BLOCK_POSITION_IDS`,
13
14
  * `getWorkspaceBlockSelectOptions`, and `seedWorkspaceMigrationProject` for
@@ -15,8 +16,10 @@
15
16
  * `runAddAiFeatureCommand` for server-owned WordPress AI feature scaffolds,
16
17
  * `runAddRestResourceCommand` for plugin-level REST resource scaffolds,
17
18
  * `getDoctorChecks`, `runDoctor`, and `DoctorCheck` for diagnostics,
18
- * `createCliCommandError` and `formatCliDiagnosticError` for shared
19
- * non-interactive failure rendering,
19
+ * `createCliCommandError`, `createCliDiagnosticCodeError`,
20
+ * `CLI_DIAGNOSTIC_CODES`, `CLI_DIAGNOSTIC_CODE_METADATA`,
21
+ * `getCliDiagnosticCodeMetadata`, and `formatCliDiagnosticError` for shared
22
+ * non-interactive failure rendering and explicit diagnostic-code ownership,
20
23
  * `formatHelpText` for top-level CLI usage output, scaffold helpers such as
21
24
  * `createReadlinePrompt`, `getNextSteps`, `getOptionalOnboarding`,
22
25
  * `runScaffoldFlow`, and `ReadlinePrompt` for interactive project creation,
@@ -26,8 +29,8 @@
26
29
  * template inspection flows.
27
30
  */
28
31
  export { getDoctorChecks, runDoctor } from "./cli-doctor.js";
29
- export { createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
30
- export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
32
+ export { createCliCommandError, createCliDiagnosticCodeError, CliDiagnosticError, CLI_DIAGNOSTIC_CODE_METADATA, CLI_DIAGNOSTIC_CODES, formatCliDiagnosticError, formatDoctorCheckLine, formatDoctorSummaryLine, getCliDiagnosticCodeMetadata, getDoctorFailureDetailLines, getFailingDoctorChecks, isCliDiagnosticError, } from "./cli-diagnostics.js";
33
+ export { EDITOR_PLUGIN_SLOT_IDS, formatAddHelpText, getWorkspaceBlockSelectOptions, runAddAdminViewCommand, runAddAbilityCommand, runAddBindingSourceCommand, runAddAiFeatureCommand, runAddBlockCommand, runAddBlockStyleCommand, runAddBlockTransformCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runAddRestResourceCommand, runAddVariationCommand, seedWorkspaceMigrationProject, } from "./cli-add.js";
31
34
  export { COMPOUND_INNER_BLOCKS_PRESET_IDS, getCompoundInnerBlocksPresetDefinition, } from "./compound-inner-blocks.js";
32
35
  export { HOOKED_BLOCK_POSITION_IDS } from "./hooked-blocks.js";
33
36
  export { formatHelpText } from "./cli-help.js";
@@ -23,10 +23,80 @@ export declare const CLI_DIAGNOSTIC_CODES: {
23
23
  readonly UNSUPPORTED_COMMAND: "unsupported-command";
24
24
  };
25
25
  export type CliDiagnosticCode = (typeof CLI_DIAGNOSTIC_CODES)[keyof typeof CLI_DIAGNOSTIC_CODES];
26
+ /**
27
+ * Human-readable guidance attached to one stable CLI diagnostic code.
28
+ */
29
+ export interface CliDiagnosticCodeMetadata {
30
+ /** Why this diagnostic code is emitted. */
31
+ cause: string;
32
+ /** The recommended recovery path for users and automation. */
33
+ recovery: string;
34
+ }
35
+ /**
36
+ * Stable cause and recovery metadata for every supported CLI diagnostic code.
37
+ */
38
+ export declare const CLI_DIAGNOSTIC_CODE_METADATA: {
39
+ "command-execution": {
40
+ cause: string;
41
+ recovery: string;
42
+ };
43
+ "configuration-missing": {
44
+ cause: string;
45
+ recovery: string;
46
+ };
47
+ "dependencies-not-installed": {
48
+ cause: string;
49
+ recovery: string;
50
+ };
51
+ "doctor-check-failed": {
52
+ cause: string;
53
+ recovery: string;
54
+ };
55
+ "invalid-argument": {
56
+ cause: string;
57
+ recovery: string;
58
+ };
59
+ "invalid-command": {
60
+ cause: string;
61
+ recovery: string;
62
+ };
63
+ "missing-argument": {
64
+ cause: string;
65
+ recovery: string;
66
+ };
67
+ "missing-build-artifact": {
68
+ cause: string;
69
+ recovery: string;
70
+ };
71
+ "outside-project-root": {
72
+ cause: string;
73
+ recovery: string;
74
+ };
75
+ "template-source-timeout": {
76
+ cause: string;
77
+ recovery: string;
78
+ };
79
+ "template-source-too-large": {
80
+ cause: string;
81
+ recovery: string;
82
+ };
83
+ "unknown-template": {
84
+ cause: string;
85
+ recovery: string;
86
+ };
87
+ "unsupported-command": {
88
+ cause: string;
89
+ recovery: string;
90
+ };
91
+ };
92
+ export type CliDiagnosticCodeError<TCode extends CliDiagnosticCode = CliDiagnosticCode> = Error & {
93
+ code: TCode;
94
+ };
26
95
  type DoctorCheckLike = {
96
+ code?: string;
27
97
  detail: string;
28
98
  label: string;
29
- status: "pass" | "fail";
99
+ status: "pass" | "fail" | "warn";
30
100
  };
31
101
  /**
32
102
  * Structured CLI failure carrying a stable summary/detail layout.
@@ -42,6 +112,18 @@ export declare class CliDiagnosticError extends Error {
42
112
  * Narrow an unknown error to the shared CLI diagnostic error shape.
43
113
  */
44
114
  export declare function isCliDiagnosticError(error: unknown): error is CliDiagnosticError;
115
+ /**
116
+ * Look up cause and recovery guidance for a stable CLI diagnostic code.
117
+ */
118
+ export declare function getCliDiagnosticCodeMetadata(code: CliDiagnosticCode): CliDiagnosticCodeMetadata;
119
+ /**
120
+ * Tag a user-facing CLI throw site with a stable diagnostic code.
121
+ *
122
+ * Prefer this helper, or `createCliCommandError({ code })`, for new known CLI
123
+ * failures. `inferCliDiagnosticCode()` remains only a compatibility fallback
124
+ * for legacy or untyped errors.
125
+ */
126
+ export declare function createCliDiagnosticCodeError<TCode extends CliDiagnosticCode>(code: TCode, message: string, options?: ErrorOptions): CliDiagnosticCodeError<TCode>;
45
127
  /**
46
128
  * Build a shared diagnostic error for one CLI command failure.
47
129
  */
@@ -13,6 +13,63 @@ export const CLI_DIAGNOSTIC_CODES = {
13
13
  UNKNOWN_TEMPLATE: "unknown-template",
14
14
  UNSUPPORTED_COMMAND: "unsupported-command",
15
15
  };
16
+ /**
17
+ * Stable cause and recovery metadata for every supported CLI diagnostic code.
18
+ */
19
+ export const CLI_DIAGNOSTIC_CODE_METADATA = {
20
+ [CLI_DIAGNOSTIC_CODES.COMMAND_EXECUTION]: {
21
+ cause: "The command failed after argument parsing and preflight checks completed.",
22
+ recovery: "Read the detail lines for the underlying tool failure, rerun with the same command once corrected, and report the full JSON envelope if the recovery is unclear.",
23
+ },
24
+ [CLI_DIAGNOSTIC_CODES.CONFIGURATION_MISSING]: {
25
+ cause: "A command needs configuration that is not present in the current project.",
26
+ recovery: "Add the missing wp-typia config section or rerun the scaffold/init flow that creates the expected configuration.",
27
+ },
28
+ [CLI_DIAGNOSTIC_CODES.DEPENDENCIES_NOT_INSTALLED]: {
29
+ cause: "Generated project or workspace dependencies are missing from the local install.",
30
+ recovery: "Run the package-manager install command from the reported project root, then rerun the wp-typia command.",
31
+ },
32
+ [CLI_DIAGNOSTIC_CODES.DOCTOR_CHECK_FAILED]: {
33
+ cause: "One or more doctor checks reported a failing environment or workspace row.",
34
+ recovery: "Inspect the failed check labels and details, fix the reported drift or missing prerequisite, then rerun `wp-typia doctor`.",
35
+ },
36
+ [CLI_DIAGNOSTIC_CODES.INVALID_ARGUMENT]: {
37
+ cause: "An argument was present but did not match the supported value, shape, or project state.",
38
+ recovery: "Correct the argument value using command help or the detail lines, then rerun the command.",
39
+ },
40
+ [CLI_DIAGNOSTIC_CODES.INVALID_COMMAND]: {
41
+ cause: "The command or subcommand is not part of the supported wp-typia command tree.",
42
+ recovery: "Run `wp-typia --help` or the relevant command help and switch to a supported command/subcommand.",
43
+ },
44
+ [CLI_DIAGNOSTIC_CODES.MISSING_ARGUMENT]: {
45
+ cause: "A required positional argument or flag value was omitted.",
46
+ recovery: "Provide the missing argument or flag value shown in the detail lines, then rerun the command.",
47
+ },
48
+ [CLI_DIAGNOSTIC_CODES.MISSING_BUILD_ARTIFACT]: {
49
+ cause: "The published or standalone CLI layout is missing bundled build artifacts.",
50
+ recovery: "Reinstall the package or standalone binary, or rebuild the workspace before invoking the command again.",
51
+ },
52
+ [CLI_DIAGNOSTIC_CODES.OUTSIDE_PROJECT_ROOT]: {
53
+ cause: "The command was run outside a generated wp-typia project or official workspace root.",
54
+ recovery: "Change into the scaffolded project/workspace root, or rerun the scaffold/init workflow that creates the expected root files.",
55
+ },
56
+ [CLI_DIAGNOSTIC_CODES.TEMPLATE_SOURCE_TIMEOUT]: {
57
+ cause: "External template resolution did not complete within the allowed time.",
58
+ recovery: "Retry with a reachable template source, use a local path, or cache the template package before rerunning.",
59
+ },
60
+ [CLI_DIAGNOSTIC_CODES.TEMPLATE_SOURCE_TOO_LARGE]: {
61
+ cause: "External template content exceeded the safety size limit.",
62
+ recovery: "Reduce the template package size or point wp-typia at a smaller official template layer.",
63
+ },
64
+ [CLI_DIAGNOSTIC_CODES.UNKNOWN_TEMPLATE]: {
65
+ cause: "The requested scaffold template or add-block template id is not registered.",
66
+ recovery: "Run `wp-typia templates list` and rerun with one of the listed template ids.",
67
+ },
68
+ [CLI_DIAGNOSTIC_CODES.UNSUPPORTED_COMMAND]: {
69
+ cause: "The requested command exists conceptually but is not supported by the current runtime surface.",
70
+ recovery: "Install Bun 1.3.11+ or use the standalone wp-typia binary when the detail lines say the Bun-powered runtime is required.",
71
+ },
72
+ };
16
73
  const DEFAULT_CLI_FAILURE_SUMMARIES = {
17
74
  add: "Unable to complete the requested add workflow.",
18
75
  create: "Unable to complete the requested create workflow.",
@@ -151,6 +208,24 @@ function readCliDiagnosticCode(error) {
151
208
  }
152
209
  return null;
153
210
  }
211
+ /**
212
+ * Look up cause and recovery guidance for a stable CLI diagnostic code.
213
+ */
214
+ export function getCliDiagnosticCodeMetadata(code) {
215
+ return CLI_DIAGNOSTIC_CODE_METADATA[code];
216
+ }
217
+ /**
218
+ * Tag a user-facing CLI throw site with a stable diagnostic code.
219
+ *
220
+ * Prefer this helper, or `createCliCommandError({ code })`, for new known CLI
221
+ * failures. `inferCliDiagnosticCode()` remains only a compatibility fallback
222
+ * for legacy or untyped errors.
223
+ */
224
+ export function createCliDiagnosticCodeError(code, message, options) {
225
+ const error = new Error(message, options);
226
+ error.code = code;
227
+ return error;
228
+ }
154
229
  function inferCliDiagnosticCode(options) {
155
230
  const inheritedCode = readCliDiagnosticCode(options.error);
156
231
  if (inheritedCode) {
@@ -269,7 +344,8 @@ export function serializeCliDiagnosticError(error) {
269
344
  * Format one human-readable doctor check row.
270
345
  */
271
346
  export function formatDoctorCheckLine(check) {
272
- return formatWrappedPrefixedLine(`${check.status === "pass" ? "PASS" : "FAIL"} ${check.label}: `, check.detail, resolveCliWrapColumns(process.stdout.columns)).join("\n");
347
+ const statusLabel = check.status === "pass" ? "PASS" : check.status === "warn" ? "WARN" : "FAIL";
348
+ return formatWrappedPrefixedLine(`${statusLabel} ${check.label}: `, check.detail, resolveCliWrapColumns(process.stdout.columns)).join("\n");
273
349
  }
274
350
  /**
275
351
  * Return the failing doctor checks from one doctor run.
@@ -282,7 +358,14 @@ export function getFailingDoctorChecks(checks) {
282
358
  */
283
359
  export function formatDoctorSummaryLine(checks) {
284
360
  const failedChecks = getFailingDoctorChecks(checks);
285
- return formatWrappedPrefixedLine(`${failedChecks.length === 0 ? "PASS" : "FAIL"} wp-typia doctor summary: `, `${checks.length - failedChecks.length}/${checks.length} checks passed`, resolveCliWrapColumns(process.stdout.columns)).join("\n");
361
+ const warningCount = checks.filter((check) => check.status === "warn").length;
362
+ const summaryStatus = failedChecks.length > 0 ? "FAIL" : warningCount > 0 ? "WARN" : "PASS";
363
+ return formatWrappedPrefixedLine(`${summaryStatus} wp-typia doctor summary: `, [
364
+ `${checks.length - failedChecks.length - warningCount}/${checks.length} checks passed`,
365
+ warningCount > 0 ? `${warningCount} warning(s)` : null,
366
+ ]
367
+ .filter((detail) => detail !== null)
368
+ .join(", "), resolveCliWrapColumns(process.stdout.columns)).join("\n");
286
369
  }
287
370
  /**
288
371
  * Build detail lines for doctor failures so the non-interactive formatter can