@wp-typia/project-tools 0.19.2 → 0.20.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.
- package/README.md +23 -0
- package/dist/runtime/ability-spec.d.ts +90 -0
- package/dist/runtime/ability-spec.js +51 -0
- package/dist/runtime/ai-artifacts.d.ts +39 -0
- package/dist/runtime/ai-artifacts.js +68 -0
- package/dist/runtime/ai-feature-artifacts.d.ts +85 -0
- package/dist/runtime/ai-feature-artifacts.js +139 -0
- package/dist/runtime/ai-feature-capability.d.ts +114 -0
- package/dist/runtime/ai-feature-capability.js +150 -0
- package/dist/runtime/block-generator-service-spec.js +6 -0
- package/dist/runtime/cli-add-shared.d.ts +32 -1
- package/dist/runtime/cli-add-shared.js +44 -0
- package/dist/runtime/cli-add-workspace-ability.d.ts +8 -0
- package/dist/runtime/cli-add-workspace-ability.js +810 -0
- package/dist/runtime/cli-add-workspace-ai-anchors.d.ts +22 -0
- package/dist/runtime/cli-add-workspace-ai-anchors.js +277 -0
- package/dist/runtime/cli-add-workspace-ai-source-emitters.d.ts +28 -0
- package/dist/runtime/cli-add-workspace-ai-source-emitters.js +346 -0
- package/dist/runtime/cli-add-workspace-ai.d.ts +14 -0
- package/dist/runtime/cli-add-workspace-ai.js +484 -0
- package/dist/runtime/cli-add-workspace.d.ts +10 -0
- package/dist/runtime/cli-add-workspace.js +10 -0
- package/dist/runtime/cli-add.d.ts +1 -1
- package/dist/runtime/cli-add.js +1 -1
- package/dist/runtime/cli-core.d.ts +3 -1
- package/dist/runtime/cli-core.js +3 -1
- package/dist/runtime/cli-diagnostics.d.ts +2 -0
- package/dist/runtime/cli-diagnostics.js +10 -1
- package/dist/runtime/cli-doctor-workspace.js +140 -1
- package/dist/runtime/cli-help.js +7 -0
- package/dist/runtime/cli-init.d.ts +49 -0
- package/dist/runtime/cli-init.js +354 -0
- package/dist/runtime/cli-scaffold.d.ts +1 -0
- package/dist/runtime/cli-scaffold.js +5 -1
- package/dist/runtime/cli-templates.js +36 -6
- package/dist/runtime/external-template-guards.d.ts +31 -0
- package/dist/runtime/external-template-guards.js +132 -0
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/package-managers.d.ts +8 -0
- package/dist/runtime/package-managers.js +13 -0
- package/dist/runtime/package-versions.d.ts +8 -0
- package/dist/runtime/package-versions.js +84 -19
- package/dist/runtime/scaffold-compatibility.d.ts +65 -0
- package/dist/runtime/scaffold-compatibility.js +152 -0
- package/dist/runtime/scaffold-documents.js +19 -1
- package/dist/runtime/scaffold-onboarding.d.ts +4 -0
- package/dist/runtime/scaffold-onboarding.js +25 -1
- package/dist/runtime/scaffold-template-variable-groups.d.ts +2 -0
- package/dist/runtime/scaffold-template-variables.js +6 -0
- package/dist/runtime/scaffold.d.ts +3 -0
- package/dist/runtime/scaffold.js +2 -5
- package/dist/runtime/template-registry.d.ts +23 -1
- package/dist/runtime/template-registry.js +37 -3
- package/dist/runtime/template-source-external.js +9 -3
- package/dist/runtime/template-source-remote.js +5 -0
- package/dist/runtime/template-source-seeds.js +40 -6
- package/dist/runtime/typia-llm.d.ts +213 -0
- package/dist/runtime/typia-llm.js +348 -0
- package/dist/runtime/wordpress-ai.d.ts +122 -0
- package/dist/runtime/wordpress-ai.js +177 -0
- package/dist/runtime/workspace-inventory.d.ts +51 -4
- package/dist/runtime/workspace-inventory.js +157 -4
- package/package.json +17 -2
- package/templates/_shared/base/package.json.mustache +0 -1
- package/templates/_shared/base/{{slugKebabCase}}.php.mustache +3 -3
- package/templates/_shared/compound/core/package.json.mustache +0 -1
- package/templates/_shared/compound/core/{{slugKebabCase}}.php.mustache +3 -3
- package/templates/_shared/compound/persistence/package.json.mustache +0 -1
- package/templates/_shared/compound/persistence-auth/{{slugKebabCase}}.php.mustache +3 -3
- package/templates/_shared/compound/persistence-public/{{slugKebabCase}}.php.mustache +3 -3
- package/templates/_shared/persistence/auth/{{slugKebabCase}}.php.mustache +3 -3
- package/templates/_shared/persistence/core/package.json.mustache +0 -1
- package/templates/_shared/persistence/core/{{slugKebabCase}}.php.mustache +3 -3
- package/templates/_shared/persistence/public/{{slugKebabCase}}.php.mustache +3 -3
- package/templates/interactivity/package.json.mustache +0 -1
- package/templates/query-loop/{{slugKebabCase}}.php.mustache +3 -3
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, getTemplateById, getTemplateSelectOptions, isBuiltInTemplateId, listTemplates, } from "./template-registry.js";
|
|
2
|
-
const WORKSPACE_TEMPLATE_ALIAS = "workspace";
|
|
1
|
+
import { OFFICIAL_WORKSPACE_TEMPLATE_ALIAS, OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE, getUserFacingTemplateId, getTemplateById, getTemplateSelectOptions, isBuiltInTemplateId, listTemplates, } from "./template-registry.js";
|
|
3
2
|
/**
|
|
4
3
|
* Format one line of template list output for a built-in template.
|
|
5
4
|
*
|
|
@@ -7,7 +6,7 @@ const WORKSPACE_TEMPLATE_ALIAS = "workspace";
|
|
|
7
6
|
* @returns One-line summary text for `templates list`.
|
|
8
7
|
*/
|
|
9
8
|
export function formatTemplateSummary(template) {
|
|
10
|
-
return `${template.id.padEnd(14)} ${template.description}`;
|
|
9
|
+
return `${getUserFacingTemplateId(template.id).padEnd(14)} ${template.description}`;
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
12
|
* Format the feature and capability hint lines shown under a template summary.
|
|
@@ -17,6 +16,10 @@ export function formatTemplateSummary(template) {
|
|
|
17
16
|
*/
|
|
18
17
|
export function formatTemplateFeatures(template) {
|
|
19
18
|
const lines = [` Features: ${template.features.join(" • ")}`];
|
|
19
|
+
const bestForHint = getTemplateBestForHint(template);
|
|
20
|
+
if (bestForHint) {
|
|
21
|
+
lines.push(` Best for: ${bestForHint}`);
|
|
22
|
+
}
|
|
20
23
|
const capabilityHints = getTemplateCapabilityHints(template);
|
|
21
24
|
if (capabilityHints.length > 0) {
|
|
22
25
|
lines.push(` Supports: ${capabilityHints.join(" • ")}`);
|
|
@@ -26,7 +29,7 @@ export function formatTemplateFeatures(template) {
|
|
|
26
29
|
lines.push(` Notes: ${specialNotes.join(" • ")}`);
|
|
27
30
|
}
|
|
28
31
|
if (template.id === OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE) {
|
|
29
|
-
lines.push(` Alias: ${
|
|
32
|
+
lines.push(` Alias: ${OFFICIAL_WORKSPACE_TEMPLATE_ALIAS} (\`--template ${OFFICIAL_WORKSPACE_TEMPLATE_ALIAS}\`)`);
|
|
30
33
|
}
|
|
31
34
|
return lines.join("\n");
|
|
32
35
|
}
|
|
@@ -43,8 +46,9 @@ export function formatTemplateFeatures(template) {
|
|
|
43
46
|
*/
|
|
44
47
|
export function formatTemplateDetails(template) {
|
|
45
48
|
const detailLines = [
|
|
46
|
-
template.id,
|
|
49
|
+
getUserFacingTemplateId(template.id),
|
|
47
50
|
`Summary: ${template.description}`,
|
|
51
|
+
`Best for: ${getTemplateBestForHint(template)}`,
|
|
48
52
|
...getTemplateIdentityLines(template),
|
|
49
53
|
`Category: ${template.defaultCategory}`,
|
|
50
54
|
];
|
|
@@ -69,6 +73,24 @@ export function formatTemplateDetails(template) {
|
|
|
69
73
|
detailLines.push(`Features: ${template.features.join(", ")}`);
|
|
70
74
|
return detailLines.join("\n");
|
|
71
75
|
}
|
|
76
|
+
function getTemplateBestForHint(template) {
|
|
77
|
+
if (template.id === "basic") {
|
|
78
|
+
return "minimal static-first block scaffolds with Typia validation and the lightest default surface";
|
|
79
|
+
}
|
|
80
|
+
if (template.id === "interactivity") {
|
|
81
|
+
return "interactive single-block experiences that keep client-side state and actions inside one scaffold";
|
|
82
|
+
}
|
|
83
|
+
if (template.id === "persistence") {
|
|
84
|
+
return "typed REST-backed blocks that need persistence-aware reads, writes, and schema refresh workflows";
|
|
85
|
+
}
|
|
86
|
+
if (template.id === "compound") {
|
|
87
|
+
return "parent-and-child block families that own nested authoring conventions and optional persistence wiring";
|
|
88
|
+
}
|
|
89
|
+
if (template.id === "query-loop") {
|
|
90
|
+
return "create-time `core/query` variations with connected starter patterns instead of `add block` families";
|
|
91
|
+
}
|
|
92
|
+
return "official multi-block workspaces that extend through `wp-typia add ...` and workspace doctor flows";
|
|
93
|
+
}
|
|
72
94
|
function getTemplateCapabilityHints(template) {
|
|
73
95
|
if (template.id === "persistence" || template.id === "compound") {
|
|
74
96
|
return [
|
|
@@ -99,11 +121,19 @@ function getTemplateIdentityLines(template) {
|
|
|
99
121
|
if (template.id === OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE) {
|
|
100
122
|
return [
|
|
101
123
|
"Identity:",
|
|
124
|
+
` - User-facing alias: ${OFFICIAL_WORKSPACE_TEMPLATE_ALIAS} (\`--template ${OFFICIAL_WORKSPACE_TEMPLATE_ALIAS}\`)`,
|
|
102
125
|
` - Official package: ${OFFICIAL_WORKSPACE_TEMPLATE_PACKAGE}`,
|
|
103
|
-
` - Alias: ${WORKSPACE_TEMPLATE_ALIAS} (\`--template ${WORKSPACE_TEMPLATE_ALIAS}\`)`,
|
|
104
126
|
"Type: official workspace scaffold",
|
|
105
127
|
];
|
|
106
128
|
}
|
|
129
|
+
if (template.id === "query-loop") {
|
|
130
|
+
return [
|
|
131
|
+
"Identity:",
|
|
132
|
+
" - Built-in template id: query-loop",
|
|
133
|
+
"Type: create-time core/query variation scaffold",
|
|
134
|
+
"Output model: variation-only scaffold; does not generate block.json or Typia manifests",
|
|
135
|
+
];
|
|
136
|
+
}
|
|
107
137
|
return [
|
|
108
138
|
"Identity:",
|
|
109
139
|
` - Built-in template id: ${template.id}`,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare const TEMPLATE_SOURCE_TIMEOUT_CODE: "template-source-timeout";
|
|
2
|
+
export declare const TEMPLATE_SOURCE_TOO_LARGE_CODE: "template-source-too-large";
|
|
3
|
+
export declare function getExternalTemplateTimeoutMs(): number;
|
|
4
|
+
export declare function getExternalTemplateConfigMaxBytes(): number;
|
|
5
|
+
export declare function getExternalTemplatePackageJsonMaxBytes(): number;
|
|
6
|
+
export declare function getExternalTemplateMetadataMaxBytes(): number;
|
|
7
|
+
export declare function getExternalTemplateTarballMaxBytes(): number;
|
|
8
|
+
export declare function createExternalTemplateTimeoutError(label: string, timeoutMs: number): Error & {
|
|
9
|
+
code: typeof TEMPLATE_SOURCE_TIMEOUT_CODE;
|
|
10
|
+
};
|
|
11
|
+
export declare function createExternalTemplateTooLargeError(label: string, maxBytes: number): Error & {
|
|
12
|
+
code: typeof TEMPLATE_SOURCE_TOO_LARGE_CODE;
|
|
13
|
+
};
|
|
14
|
+
export declare function assertExternalTemplateFileSize(filePath: string, options: {
|
|
15
|
+
label: string;
|
|
16
|
+
maxBytes: number;
|
|
17
|
+
}): void;
|
|
18
|
+
export declare function withExternalTemplateTimeout<T>(label: string, task: Promise<T> | (() => Promise<T>), timeoutMs?: number): Promise<T>;
|
|
19
|
+
export declare function fetchWithExternalTemplateTimeout(input: string, options: {
|
|
20
|
+
init?: RequestInit;
|
|
21
|
+
label: string;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
}): Promise<Response>;
|
|
24
|
+
export declare function readJsonResponseWithLimit(response: Response, options: {
|
|
25
|
+
label: string;
|
|
26
|
+
maxBytes: number;
|
|
27
|
+
}): Promise<Record<string, unknown>>;
|
|
28
|
+
export declare function readBufferResponseWithLimit(response: Response, options: {
|
|
29
|
+
label: string;
|
|
30
|
+
maxBytes: number;
|
|
31
|
+
}): Promise<Buffer>;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
export const TEMPLATE_SOURCE_TIMEOUT_CODE = "template-source-timeout";
|
|
3
|
+
export const TEMPLATE_SOURCE_TOO_LARGE_CODE = "template-source-too-large";
|
|
4
|
+
const DEFAULT_EXTERNAL_TEMPLATE_TIMEOUT_MS = 20000;
|
|
5
|
+
const DEFAULT_EXTERNAL_TEMPLATE_CONFIG_MAX_BYTES = 256 * 1024;
|
|
6
|
+
const DEFAULT_EXTERNAL_TEMPLATE_PACKAGE_JSON_MAX_BYTES = 1 * 1024 * 1024;
|
|
7
|
+
const DEFAULT_EXTERNAL_TEMPLATE_METADATA_MAX_BYTES = 1 * 1024 * 1024;
|
|
8
|
+
const DEFAULT_EXTERNAL_TEMPLATE_TARBALL_MAX_BYTES = 32 * 1024 * 1024;
|
|
9
|
+
function parsePositiveIntegerEnv(value, fallback) {
|
|
10
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
11
|
+
return fallback;
|
|
12
|
+
}
|
|
13
|
+
const parsed = Number.parseInt(value, 10);
|
|
14
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
15
|
+
}
|
|
16
|
+
function createTemplateGuardError(code, message) {
|
|
17
|
+
const error = new Error(message);
|
|
18
|
+
error.code = code;
|
|
19
|
+
return error;
|
|
20
|
+
}
|
|
21
|
+
export function getExternalTemplateTimeoutMs() {
|
|
22
|
+
return parsePositiveIntegerEnv(process.env.WP_TYPIA_EXTERNAL_TEMPLATE_TIMEOUT_MS, DEFAULT_EXTERNAL_TEMPLATE_TIMEOUT_MS);
|
|
23
|
+
}
|
|
24
|
+
export function getExternalTemplateConfigMaxBytes() {
|
|
25
|
+
return parsePositiveIntegerEnv(process.env.WP_TYPIA_EXTERNAL_TEMPLATE_CONFIG_MAX_BYTES, DEFAULT_EXTERNAL_TEMPLATE_CONFIG_MAX_BYTES);
|
|
26
|
+
}
|
|
27
|
+
export function getExternalTemplatePackageJsonMaxBytes() {
|
|
28
|
+
return parsePositiveIntegerEnv(process.env.WP_TYPIA_EXTERNAL_TEMPLATE_PACKAGE_JSON_MAX_BYTES, DEFAULT_EXTERNAL_TEMPLATE_PACKAGE_JSON_MAX_BYTES);
|
|
29
|
+
}
|
|
30
|
+
export function getExternalTemplateMetadataMaxBytes() {
|
|
31
|
+
return parsePositiveIntegerEnv(process.env.WP_TYPIA_EXTERNAL_TEMPLATE_METADATA_MAX_BYTES, DEFAULT_EXTERNAL_TEMPLATE_METADATA_MAX_BYTES);
|
|
32
|
+
}
|
|
33
|
+
export function getExternalTemplateTarballMaxBytes() {
|
|
34
|
+
return parsePositiveIntegerEnv(process.env.WP_TYPIA_EXTERNAL_TEMPLATE_TARBALL_MAX_BYTES, DEFAULT_EXTERNAL_TEMPLATE_TARBALL_MAX_BYTES);
|
|
35
|
+
}
|
|
36
|
+
export function createExternalTemplateTimeoutError(label, timeoutMs) {
|
|
37
|
+
return createTemplateGuardError(TEMPLATE_SOURCE_TIMEOUT_CODE, `Timed out while ${label} after ${timeoutMs}ms.`);
|
|
38
|
+
}
|
|
39
|
+
export function createExternalTemplateTooLargeError(label, maxBytes) {
|
|
40
|
+
return createTemplateGuardError(TEMPLATE_SOURCE_TOO_LARGE_CODE, `${label} exceeded the external template size limit (${maxBytes} bytes).`);
|
|
41
|
+
}
|
|
42
|
+
export function assertExternalTemplateFileSize(filePath, options) {
|
|
43
|
+
const stats = fs.statSync(filePath);
|
|
44
|
+
if (stats.size > options.maxBytes) {
|
|
45
|
+
throw createExternalTemplateTooLargeError(options.label, options.maxBytes);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function withExternalTemplateTimeout(label, task, timeoutMs = getExternalTemplateTimeoutMs()) {
|
|
49
|
+
let timeoutHandle;
|
|
50
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
51
|
+
timeoutHandle = setTimeout(() => {
|
|
52
|
+
reject(createExternalTemplateTimeoutError(label, timeoutMs));
|
|
53
|
+
}, timeoutMs);
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
const pendingTask = typeof task === "function" ? task() : task;
|
|
57
|
+
return await Promise.race([pendingTask, timeoutPromise]);
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
if (timeoutHandle) {
|
|
61
|
+
clearTimeout(timeoutHandle);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export async function fetchWithExternalTemplateTimeout(input, options) {
|
|
66
|
+
const controller = new AbortController();
|
|
67
|
+
const timeoutMs = options.timeoutMs ?? getExternalTemplateTimeoutMs();
|
|
68
|
+
const timeoutHandle = setTimeout(() => controller.abort(), timeoutMs);
|
|
69
|
+
try {
|
|
70
|
+
return await fetch(input, {
|
|
71
|
+
...(options.init ?? {}),
|
|
72
|
+
signal: controller.signal,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
if (error instanceof Error &&
|
|
77
|
+
(error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
78
|
+
throw createExternalTemplateTimeoutError(options.label, timeoutMs);
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
clearTimeout(timeoutHandle);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async function readResponseBodyWithLimit(response, options) {
|
|
87
|
+
const contentLengthHeader = response.headers.get("content-length");
|
|
88
|
+
if (typeof contentLengthHeader === "string") {
|
|
89
|
+
const declaredLength = Number.parseInt(contentLengthHeader, 10);
|
|
90
|
+
if (Number.isFinite(declaredLength) && declaredLength > options.maxBytes) {
|
|
91
|
+
throw createExternalTemplateTooLargeError(options.label, options.maxBytes);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (!response.body) {
|
|
95
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
96
|
+
if (buffer.length > options.maxBytes) {
|
|
97
|
+
throw createExternalTemplateTooLargeError(options.label, options.maxBytes);
|
|
98
|
+
}
|
|
99
|
+
return buffer;
|
|
100
|
+
}
|
|
101
|
+
const reader = response.body.getReader();
|
|
102
|
+
const chunks = [];
|
|
103
|
+
let totalBytes = 0;
|
|
104
|
+
while (true) {
|
|
105
|
+
const { done, value } = await reader.read();
|
|
106
|
+
if (done) {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
if (!value) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
totalBytes += value.byteLength;
|
|
113
|
+
if (totalBytes > options.maxBytes) {
|
|
114
|
+
await reader.cancel();
|
|
115
|
+
throw createExternalTemplateTooLargeError(options.label, options.maxBytes);
|
|
116
|
+
}
|
|
117
|
+
chunks.push(Buffer.from(value));
|
|
118
|
+
}
|
|
119
|
+
return Buffer.concat(chunks);
|
|
120
|
+
}
|
|
121
|
+
export async function readJsonResponseWithLimit(response, options) {
|
|
122
|
+
const buffer = await readResponseBodyWithLimit(response, options);
|
|
123
|
+
try {
|
|
124
|
+
return JSON.parse(buffer.toString("utf8"));
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
throw new Error(`Failed to parse ${options.label}: ${error instanceof Error ? error.message : String(error)}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export async function readBufferResponseWithLimit(response, options) {
|
|
131
|
+
return readResponseBodyWithLimit(response, options);
|
|
132
|
+
}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID, getCompoundInnerBlocksPresetDefinition, isCompoundInnerBlocksPresetId, parseCompoundInnerBlocksPreset, resolveCompoundInnerBlocksPreset, } from "./compound-inner-blocks.js";
|
|
14
14
|
export type { CompoundInnerBlocksPresetDefinition, CompoundInnerBlocksPresetId, CompoundInnerBlocksTemplateLock, } from "./compound-inner-blocks.js";
|
|
15
15
|
export { scaffoldProject, collectScaffoldAnswers, getScaffoldTemplateVariableGroups, getDefaultAnswers, getTemplateVariables, resolvePackageManagerId, resolveTemplateId, } from "./scaffold.js";
|
|
16
|
+
export { DEFAULT_SCAFFOLD_COMPATIBILITY, OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY, REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY, createScaffoldCompatibilityConfig, renderScaffoldCompatibilityConfig, resolveScaffoldCompatibilityPolicy, updatePluginHeaderCompatibility, } from "./scaffold-compatibility.js";
|
|
17
|
+
export type { ScaffoldCompatibilityConfig, ScaffoldCompatibilityPolicy, ScaffoldPluginHeaderCompatibility, } from "./scaffold-compatibility.js";
|
|
16
18
|
export { BlockGeneratorService } from "./block-generator-service.js";
|
|
17
19
|
export type { BasicScaffoldTemplateVariableGroups, CompoundScaffoldTemplateVariableGroups, ExternalScaffoldTemplateVariableGroups, FlatScaffoldTemplateVariables, InteractivityScaffoldTemplateVariableGroups, PersistenceScaffoldTemplateVariableGroups, QueryLoopScaffoldTemplateVariableGroups, ScaffoldTemplateFamily, ScaffoldTemplateVariableGroups, } from "./scaffold.js";
|
|
18
20
|
export type { ApplyBlockInput, BlockGenerationTarget, BlockSpec, PlanBlockInput, PlanBlockResult, RenderBlockInput, RenderBlockResult, ValidateBlockInput, ValidateBlockResult, } from "./block-generator-service.js";
|
|
@@ -26,5 +28,5 @@ export type { EndpointAuthIntent, EndpointOpenApiAuthMode, EndpointOpenApiContra
|
|
|
26
28
|
export { PACKAGE_MANAGER_IDS, PACKAGE_MANAGERS, formatPackageExecCommand, formatInstallCommand, formatRunScript, getPackageManager, getPackageManagerSelectOptions, transformPackageManagerText, } from "./package-managers.js";
|
|
27
29
|
export { TEMPLATE_IDS, TEMPLATE_REGISTRY, getTemplateById, getTemplateSelectOptions, listTemplates, } from "./template-registry.js";
|
|
28
30
|
export { STALE_TEMP_ROOT_MAX_AGE_MS, WP_TYPIA_TEMP_ROOT_PREFIX, cleanupManagedTempRoot, cleanupStaleTempRoots, createManagedTempRoot, getTrackedTempRoots, } from "./temp-roots.js";
|
|
29
|
-
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddBindingSourceCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
31
|
+
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
30
32
|
export type { CliDiagnosticMessage, DoctorCheck, EditorPluginSlotId, HookedBlockPositionId, ReadlinePrompt, } from "./cli-core.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
export { COMPOUND_INNER_BLOCKS_PRESET_IDS, DEFAULT_COMPOUND_INNER_BLOCKS_PRESET_ID, getCompoundInnerBlocksPresetDefinition, isCompoundInnerBlocksPresetId, parseCompoundInnerBlocksPreset, resolveCompoundInnerBlocksPreset, } from "./compound-inner-blocks.js";
|
|
14
14
|
export { scaffoldProject, collectScaffoldAnswers, getScaffoldTemplateVariableGroups, getDefaultAnswers, getTemplateVariables, resolvePackageManagerId, resolveTemplateId, } from "./scaffold.js";
|
|
15
|
+
export { DEFAULT_SCAFFOLD_COMPATIBILITY, OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY, REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY, createScaffoldCompatibilityConfig, renderScaffoldCompatibilityConfig, resolveScaffoldCompatibilityPolicy, updatePluginHeaderCompatibility, } from "./scaffold-compatibility.js";
|
|
15
16
|
export { BlockGeneratorService } from "./block-generator-service.js";
|
|
16
17
|
export { BLOCK_GENERATION_TOOL_CONTRACT_VERSION, inspectBlockGeneration, } from "./block-generator-tool-contract.js";
|
|
17
18
|
export { formatMigrationHelpText, parseMigrationArgs, runMigrationCommand, } from "./migrations.js";
|
|
@@ -21,4 +22,4 @@ export { buildCompoundChildStarterManifestDocument, getStarterManifestFiles, str
|
|
|
21
22
|
export { PACKAGE_MANAGER_IDS, PACKAGE_MANAGERS, formatPackageExecCommand, formatInstallCommand, formatRunScript, getPackageManager, getPackageManagerSelectOptions, transformPackageManagerText, } from "./package-managers.js";
|
|
22
23
|
export { TEMPLATE_IDS, TEMPLATE_REGISTRY, getTemplateById, getTemplateSelectOptions, listTemplates, } from "./template-registry.js";
|
|
23
24
|
export { STALE_TEMP_ROOT_MAX_AGE_MS, WP_TYPIA_TEMP_ROOT_PREFIX, cleanupManagedTempRoot, cleanupStaleTempRoots, createManagedTempRoot, getTrackedTempRoots, } from "./temp-roots.js";
|
|
24
|
-
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddBindingSourceCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
25
|
+
export { createReadlinePrompt, createCliCommandError, CliDiagnosticError, formatCliDiagnosticError, formatAddHelpText, formatDoctorCheckLine, formatDoctorSummaryLine, formatHelpText, formatTemplateDetails, formatTemplateFeatures, formatTemplateSummary, getDoctorChecks, getDoctorFailureDetailLines, getFailingDoctorChecks, getNextSteps, getOptionalOnboarding, getWorkspaceBlockSelectOptions, HOOKED_BLOCK_POSITION_IDS, EDITOR_PLUGIN_SLOT_IDS, isCliDiagnosticError, runAddAbilityCommand, runAddAiFeatureCommand, runAddBindingSourceCommand, runAddBlockCommand, runAddEditorPluginCommand, runAddHookedBlockCommand, runAddPatternCommand, runDoctor, runAddVariationCommand, runScaffoldFlow, } from "./cli-core.js";
|
|
@@ -16,6 +16,14 @@ export declare function getPackageManagerSelectOptions(): Array<{
|
|
|
16
16
|
}>;
|
|
17
17
|
export declare function formatRunScript(packageManagerId: PackageManagerId, scriptName: string, extraArgs?: string): string;
|
|
18
18
|
export declare function formatInstallCommand(packageManagerId: PackageManagerId): string;
|
|
19
|
+
/**
|
|
20
|
+
* Format a package-manager-specific devDependency install command.
|
|
21
|
+
*
|
|
22
|
+
* @param packageManagerId Package manager identifier.
|
|
23
|
+
* @param packages Package specifiers to add as devDependencies.
|
|
24
|
+
* @returns Command string suitable for shell execution.
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatAddDevDependenciesCommand(packageManagerId: PackageManagerId, packages: string[]): string;
|
|
19
27
|
/**
|
|
20
28
|
* Format a package-manager-specific one-off package execution command.
|
|
21
29
|
*
|
|
@@ -67,6 +67,19 @@ export function formatRunScript(packageManagerId, scriptName, extraArgs = "") {
|
|
|
67
67
|
export function formatInstallCommand(packageManagerId) {
|
|
68
68
|
return getPackageManager(packageManagerId).installCommand;
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Format a package-manager-specific devDependency install command.
|
|
72
|
+
*
|
|
73
|
+
* @param packageManagerId Package manager identifier.
|
|
74
|
+
* @param packages Package specifiers to add as devDependencies.
|
|
75
|
+
* @returns Command string suitable for shell execution.
|
|
76
|
+
*/
|
|
77
|
+
export function formatAddDevDependenciesCommand(packageManagerId, packages) {
|
|
78
|
+
if (packages.length === 0) {
|
|
79
|
+
return formatInstallCommand(packageManagerId);
|
|
80
|
+
}
|
|
81
|
+
return `${packageManagerId} ${DEV_INSTALL_FLAGS[packageManagerId]} ${packages.join(" ")}`;
|
|
82
|
+
}
|
|
70
83
|
/**
|
|
71
84
|
* Format a package-manager-specific one-off package execution command.
|
|
72
85
|
*
|
|
@@ -7,5 +7,13 @@ interface PackageVersions {
|
|
|
7
7
|
wpTypiaPackageExactVersion: string;
|
|
8
8
|
wpTypiaPackageVersion: string;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Clears the in-memory cache used by `getPackageVersions()`.
|
|
12
|
+
*
|
|
13
|
+
* Long-lived processes can call this after regenerating or updating package
|
|
14
|
+
* manifests when they want the next lookup to recompute version metadata
|
|
15
|
+
* synchronously from disk.
|
|
16
|
+
*/
|
|
17
|
+
export declare function invalidatePackageVersionsCache(): void;
|
|
10
18
|
export declare function getPackageVersions(): PackageVersions;
|
|
11
19
|
export {};
|
|
@@ -31,55 +31,120 @@ function normalizeExactVersion(value) {
|
|
|
31
31
|
}
|
|
32
32
|
return trimmed.replace(/^[~^<>=]+/, "");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function createContentFingerprint(source) {
|
|
35
|
+
let hash = 2166136261;
|
|
36
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
37
|
+
hash ^= source.charCodeAt(index);
|
|
38
|
+
hash = Math.imul(hash, 16777619);
|
|
39
|
+
}
|
|
40
|
+
return (hash >>> 0).toString(16);
|
|
41
|
+
}
|
|
42
|
+
function resolvePackageManifestLocation(packageJsonPath) {
|
|
35
43
|
try {
|
|
36
|
-
|
|
44
|
+
const stats = fs.statSync(packageJsonPath);
|
|
45
|
+
const source = fs.readFileSync(packageJsonPath, "utf8");
|
|
46
|
+
return {
|
|
47
|
+
cacheKey: `file:${packageJsonPath}:${stats.ino}:${stats.mtimeMs}:${stats.ctimeMs}:${stats.size}:${createContentFingerprint(source)}`,
|
|
48
|
+
packageJsonPath,
|
|
49
|
+
source,
|
|
50
|
+
};
|
|
37
51
|
}
|
|
38
52
|
catch (error) {
|
|
39
53
|
if (getErrorCode(error) === "ENOENT") {
|
|
40
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
cacheKey: `missing-file:${packageJsonPath}`,
|
|
56
|
+
packageJsonPath: null,
|
|
57
|
+
source: null,
|
|
58
|
+
};
|
|
41
59
|
}
|
|
42
60
|
throw error;
|
|
43
61
|
}
|
|
44
62
|
}
|
|
45
|
-
function
|
|
63
|
+
function readPackageManifest(location) {
|
|
64
|
+
if (!location.packageJsonPath || location.source === null) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
return JSON.parse(location.source);
|
|
68
|
+
}
|
|
69
|
+
function resolveInstalledPackageManifestLocation(packageName) {
|
|
46
70
|
try {
|
|
47
|
-
return
|
|
71
|
+
return resolvePackageManifestLocation(require.resolve(`${packageName}/package.json`));
|
|
48
72
|
}
|
|
49
73
|
catch (error) {
|
|
50
74
|
if (getErrorCode(error) === "MODULE_NOT_FOUND") {
|
|
51
|
-
return
|
|
75
|
+
return {
|
|
76
|
+
cacheKey: `missing-module:${packageName}`,
|
|
77
|
+
packageJsonPath: null,
|
|
78
|
+
source: null,
|
|
79
|
+
};
|
|
52
80
|
}
|
|
53
81
|
throw error;
|
|
54
82
|
}
|
|
55
83
|
}
|
|
84
|
+
function composePackageVersionsCacheKey(locations) {
|
|
85
|
+
return locations.map((location) => location.cacheKey).join("|");
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Clears the in-memory cache used by `getPackageVersions()`.
|
|
89
|
+
*
|
|
90
|
+
* Long-lived processes can call this after regenerating or updating package
|
|
91
|
+
* manifests when they want the next lookup to recompute version metadata
|
|
92
|
+
* synchronously from disk.
|
|
93
|
+
*/
|
|
94
|
+
export function invalidatePackageVersionsCache() {
|
|
95
|
+
cachedPackageVersions = null;
|
|
96
|
+
}
|
|
56
97
|
export function getPackageVersions() {
|
|
57
|
-
|
|
58
|
-
|
|
98
|
+
const createManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "package.json"));
|
|
99
|
+
const blockRuntimeManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia-block-runtime", "package.json"));
|
|
100
|
+
const wpTypiaManifestLocation = resolvePackageManifestLocation(path.join(PROJECT_TOOLS_PACKAGE_ROOT, "..", "wp-typia", "package.json"));
|
|
101
|
+
const installedProjectToolsManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/project-tools");
|
|
102
|
+
const installedApiClientManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/api-client");
|
|
103
|
+
const installedBlockRuntimeManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/block-runtime");
|
|
104
|
+
const installedBlockTypesManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/block-types");
|
|
105
|
+
const installedRestManifestLocation = resolveInstalledPackageManifestLocation("@wp-typia/rest");
|
|
106
|
+
const installedWpTypiaManifestLocation = resolveInstalledPackageManifestLocation("wp-typia");
|
|
107
|
+
const cacheKey = composePackageVersionsCacheKey([
|
|
108
|
+
createManifestLocation,
|
|
109
|
+
blockRuntimeManifestLocation,
|
|
110
|
+
wpTypiaManifestLocation,
|
|
111
|
+
installedProjectToolsManifestLocation,
|
|
112
|
+
installedApiClientManifestLocation,
|
|
113
|
+
installedBlockRuntimeManifestLocation,
|
|
114
|
+
installedBlockTypesManifestLocation,
|
|
115
|
+
installedRestManifestLocation,
|
|
116
|
+
installedWpTypiaManifestLocation,
|
|
117
|
+
]);
|
|
118
|
+
if (cachedPackageVersions?.cacheKey === cacheKey) {
|
|
119
|
+
return cachedPackageVersions.versions;
|
|
59
120
|
}
|
|
60
|
-
const createManifest = readPackageManifest(
|
|
61
|
-
|
|
121
|
+
const createManifest = readPackageManifest(createManifestLocation) ??
|
|
122
|
+
readPackageManifest(installedProjectToolsManifestLocation) ??
|
|
62
123
|
{};
|
|
63
|
-
const blockRuntimeManifest = readPackageManifest(
|
|
64
|
-
|
|
124
|
+
const blockRuntimeManifest = readPackageManifest(blockRuntimeManifestLocation) ??
|
|
125
|
+
readPackageManifest(installedBlockRuntimeManifestLocation) ??
|
|
65
126
|
{};
|
|
66
|
-
const wpTypiaManifest = readPackageManifest(
|
|
67
|
-
|
|
127
|
+
const wpTypiaManifest = readPackageManifest(wpTypiaManifestLocation) ??
|
|
128
|
+
readPackageManifest(installedWpTypiaManifestLocation) ??
|
|
68
129
|
{};
|
|
69
130
|
const blockRuntimeDependencyVersion = normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-runtime"]);
|
|
70
|
-
|
|
131
|
+
const versions = {
|
|
71
132
|
apiClientPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/api-client"] ??
|
|
72
|
-
|
|
133
|
+
readPackageManifest(installedApiClientManifestLocation)?.version),
|
|
73
134
|
blockRuntimePackageVersion: blockRuntimeDependencyVersion !== DEFAULT_VERSION_RANGE
|
|
74
135
|
? blockRuntimeDependencyVersion
|
|
75
136
|
: normalizeVersionRange(blockRuntimeManifest.version),
|
|
76
137
|
blockTypesPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/block-types"] ??
|
|
77
|
-
|
|
138
|
+
readPackageManifest(installedBlockTypesManifestLocation)?.version),
|
|
78
139
|
projectToolsPackageVersion: normalizeVersionRange(createManifest.version),
|
|
79
140
|
restPackageVersion: normalizeVersionRange(createManifest.dependencies?.["@wp-typia/rest"] ??
|
|
80
|
-
|
|
141
|
+
readPackageManifest(installedRestManifestLocation)?.version),
|
|
81
142
|
wpTypiaPackageExactVersion: normalizeExactVersion(wpTypiaManifest.version),
|
|
82
143
|
wpTypiaPackageVersion: normalizeVersionRange(wpTypiaManifest.version),
|
|
83
144
|
};
|
|
84
|
-
|
|
145
|
+
cachedPackageVersions = {
|
|
146
|
+
cacheKey,
|
|
147
|
+
versions,
|
|
148
|
+
};
|
|
149
|
+
return versions;
|
|
85
150
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compatibility policy helpers for generated scaffold outputs.
|
|
3
|
+
*
|
|
4
|
+
* The policy keeps plugin headers, runtime gates, and workspace inventory
|
|
5
|
+
* metadata aligned when optional or required AI-capable features are added.
|
|
6
|
+
*/
|
|
7
|
+
import { type AiFeatureCapabilitySelection, type AiFeatureCompatibilityFloor, type ResolvedAiFeatureCapabilityPlan } from "./ai-feature-capability.js";
|
|
8
|
+
/**
|
|
9
|
+
* WordPress plugin header version floors emitted by scaffold templates.
|
|
10
|
+
*/
|
|
11
|
+
export interface ScaffoldPluginHeaderCompatibility {
|
|
12
|
+
requiresAtLeast: string;
|
|
13
|
+
requiresPhp: string;
|
|
14
|
+
testedUpTo: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolved compatibility policy for a set of scaffold feature capabilities.
|
|
18
|
+
*/
|
|
19
|
+
export interface ScaffoldCompatibilityPolicy {
|
|
20
|
+
capabilityPlan: ResolvedAiFeatureCapabilityPlan;
|
|
21
|
+
pluginHeader: ScaffoldPluginHeaderCompatibility;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Serializable compatibility metadata stored in generated workspace inventory.
|
|
25
|
+
*/
|
|
26
|
+
export interface ScaffoldCompatibilityConfig {
|
|
27
|
+
hardMinimums: AiFeatureCompatibilityFloor;
|
|
28
|
+
mode: "baseline" | "optional" | "required";
|
|
29
|
+
optionalFeatures: string[];
|
|
30
|
+
requiredFeatures: string[];
|
|
31
|
+
runtimeGates: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Baseline headers used by scaffold output before optional features are added.
|
|
35
|
+
*/
|
|
36
|
+
export declare const DEFAULT_SCAFFOLD_COMPATIBILITY: ScaffoldPluginHeaderCompatibility;
|
|
37
|
+
/**
|
|
38
|
+
* Optional WordPress AI Client surface used by server-only AI feature scaffold.
|
|
39
|
+
*/
|
|
40
|
+
export declare const OPTIONAL_WORDPRESS_AI_CLIENT_COMPATIBILITY: readonly AiFeatureCapabilitySelection[];
|
|
41
|
+
/**
|
|
42
|
+
* Required Abilities API surface used by typed workflow ability scaffold.
|
|
43
|
+
*/
|
|
44
|
+
export declare const REQUIRED_WORKSPACE_ABILITY_COMPATIBILITY: readonly AiFeatureCapabilitySelection[];
|
|
45
|
+
/**
|
|
46
|
+
* Resolve plugin header floors and capability gates for scaffold selections.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveScaffoldCompatibilityPolicy(selections: readonly AiFeatureCapabilitySelection[], { baseline, }?: {
|
|
49
|
+
baseline?: ScaffoldPluginHeaderCompatibility;
|
|
50
|
+
}): ScaffoldCompatibilityPolicy;
|
|
51
|
+
/**
|
|
52
|
+
* Convert a resolved policy into workspace-inventory-safe JSON metadata.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createScaffoldCompatibilityConfig(policy: ScaffoldCompatibilityPolicy): ScaffoldCompatibilityConfig;
|
|
55
|
+
/**
|
|
56
|
+
* Render compatibility metadata as formatted TypeScript object literal JSON.
|
|
57
|
+
*/
|
|
58
|
+
export declare function renderScaffoldCompatibilityConfig(policy: ScaffoldCompatibilityPolicy, indent?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Patch a generated plugin bootstrap header without lowering custom floors.
|
|
61
|
+
*
|
|
62
|
+
* Preserves the original header line endings while replacing empty or invalid
|
|
63
|
+
* version strings with the policy values.
|
|
64
|
+
*/
|
|
65
|
+
export declare function updatePluginHeaderCompatibility(source: string, policy: ScaffoldCompatibilityPolicy): string;
|