@wp-typia/project-tools 0.22.2 → 0.22.3

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 (30) hide show
  1. package/dist/runtime/built-in-block-code-templates/interactivity.d.ts +1 -1
  2. package/dist/runtime/built-in-block-code-templates/interactivity.js +4 -2
  3. package/dist/runtime/cli-add-shared.d.ts +49 -0
  4. package/dist/runtime/cli-add-shared.js +204 -71
  5. package/dist/runtime/cli-add-workspace-ability-scaffold.d.ts +5 -0
  6. package/dist/runtime/cli-add-workspace-ability-scaffold.js +392 -0
  7. package/dist/runtime/cli-add-workspace-ability-templates.d.ts +34 -0
  8. package/dist/runtime/cli-add-workspace-ability-templates.js +500 -0
  9. package/dist/runtime/cli-add-workspace-ability-types.d.ts +27 -0
  10. package/dist/runtime/cli-add-workspace-ability-types.js +14 -0
  11. package/dist/runtime/cli-add-workspace-ability.js +12 -852
  12. package/dist/runtime/cli-add-workspace-ai-scaffold.d.ts +21 -0
  13. package/dist/runtime/cli-add-workspace-ai-scaffold.js +91 -0
  14. package/dist/runtime/cli-add-workspace-ai-templates.d.ts +4 -0
  15. package/dist/runtime/cli-add-workspace-ai-templates.js +605 -0
  16. package/dist/runtime/cli-add-workspace-ai.js +15 -688
  17. package/dist/runtime/cli-add-workspace-assets.js +7 -4
  18. package/dist/runtime/cli-add-workspace.js +1 -19
  19. package/dist/runtime/cli-doctor-workspace-bindings.d.ts +11 -0
  20. package/dist/runtime/cli-doctor-workspace-bindings.js +134 -0
  21. package/dist/runtime/cli-doctor-workspace-blocks.d.ts +11 -0
  22. package/dist/runtime/cli-doctor-workspace-blocks.js +504 -0
  23. package/dist/runtime/cli-doctor-workspace-features.d.ts +11 -0
  24. package/dist/runtime/cli-doctor-workspace-features.js +383 -0
  25. package/dist/runtime/cli-doctor-workspace-package.d.ts +18 -0
  26. package/dist/runtime/cli-doctor-workspace-package.js +59 -0
  27. package/dist/runtime/cli-doctor-workspace-shared.d.ts +69 -0
  28. package/dist/runtime/cli-doctor-workspace-shared.js +87 -0
  29. package/dist/runtime/cli-doctor-workspace.js +25 -1062
  30. package/package.json +3 -3
@@ -0,0 +1,21 @@
1
+ import type { ScaffoldCompatibilityPolicy } from "./scaffold-compatibility.js";
2
+ import type { WorkspaceProject } from "./workspace-project.js";
3
+ /**
4
+ * Inputs required to scaffold a generated AI feature into a workspace.
5
+ */
6
+ export interface ScaffoldAiFeatureWorkspaceOptions {
7
+ /** Kebab-case feature slug used for file paths and route ids. */
8
+ aiFeatureSlug: string;
9
+ /** Compatibility metadata applied to the generated workspace bootstrap. */
10
+ compatibilityPolicy: ScaffoldCompatibilityPolicy;
11
+ /** WordPress REST namespace used for generated feature routes. */
12
+ namespace: string;
13
+ /** Resolved workspace metadata and filesystem paths for the target project. */
14
+ workspace: WorkspaceProject;
15
+ }
16
+ /**
17
+ * Write generated AI feature sources and patch shared workspace anchors.
18
+ */
19
+ export declare function scaffoldAiFeatureWorkspace({ aiFeatureSlug, compatibilityPolicy, namespace, workspace, }: ScaffoldAiFeatureWorkspaceOptions): Promise<{
20
+ warnings: string[];
21
+ }>;
@@ -0,0 +1,91 @@
1
+ import { promises as fsp } from "node:fs";
2
+ import path from "node:path";
3
+ import { ensureBlockConfigCanAddRestManifests } from "./cli-add-block-legacy-validator.js";
4
+ import { buildAiFeatureConfigEntry, buildAiFeatureDataSource, buildAiFeatureSyncScriptSource, buildAiFeatureTypesSource, buildAiFeatureValidatorsSource, buildAiFeatureApiSource, } from "./cli-add-workspace-ai-source-emitters.js";
5
+ import { ensureAiFeatureBootstrapAnchors, ensureAiFeaturePackageScripts, ensureAiFeatureSyncProjectAnchors, ensureAiFeatureSyncRestAnchors, } from "./cli-add-workspace-ai-anchors.js";
6
+ import { buildAiFeaturePhpSource } from "./cli-add-workspace-ai-templates.js";
7
+ import { appendWorkspaceInventoryEntries } from "./workspace-inventory.js";
8
+ import { getWorkspaceBootstrapPath, patchFile, rollbackWorkspaceMutation, snapshotWorkspaceFiles, } from "./cli-add-shared.js";
9
+ import { updatePluginHeaderCompatibility } from "./scaffold-compatibility.js";
10
+ import { toPascalCase, toTitleCase } from "./string-case.js";
11
+ import { syncAiFeatureRestArtifacts, syncAiFeatureSchemaArtifact, } from "./ai-feature-artifacts.js";
12
+ /**
13
+ * Write generated AI feature sources and patch shared workspace anchors.
14
+ */
15
+ export async function scaffoldAiFeatureWorkspace({ aiFeatureSlug, compatibilityPolicy, namespace, workspace, }) {
16
+ const blockConfigPath = path.join(workspace.projectDir, "scripts", "block-config.ts");
17
+ const bootstrapPath = getWorkspaceBootstrapPath(workspace);
18
+ const packageJsonPath = path.join(workspace.projectDir, "package.json");
19
+ const syncAiScriptPath = path.join(workspace.projectDir, "scripts", "sync-ai-features.ts");
20
+ const syncProjectScriptPath = path.join(workspace.projectDir, "scripts", "sync-project.ts");
21
+ const syncRestScriptPath = path.join(workspace.projectDir, "scripts", "sync-rest-contracts.ts");
22
+ const aiFeatureDir = path.join(workspace.projectDir, "src", "ai-features", aiFeatureSlug);
23
+ const typesFilePath = path.join(aiFeatureDir, "api-types.ts");
24
+ const validatorsFilePath = path.join(aiFeatureDir, "api-validators.ts");
25
+ const apiFilePath = path.join(aiFeatureDir, "api.ts");
26
+ const dataFilePath = path.join(aiFeatureDir, "data.ts");
27
+ const phpFilePath = path.join(workspace.projectDir, "inc", "ai-features", `${aiFeatureSlug}.php`);
28
+ const mutationSnapshot = {
29
+ fileSources: await snapshotWorkspaceFiles([
30
+ blockConfigPath,
31
+ bootstrapPath,
32
+ packageJsonPath,
33
+ syncAiScriptPath,
34
+ syncProjectScriptPath,
35
+ syncRestScriptPath,
36
+ ]),
37
+ snapshotDirs: [],
38
+ targetPaths: [aiFeatureDir, phpFilePath, syncAiScriptPath],
39
+ };
40
+ try {
41
+ await fsp.mkdir(aiFeatureDir, { recursive: true });
42
+ await fsp.mkdir(path.dirname(phpFilePath), { recursive: true });
43
+ await ensureAiFeatureBootstrapAnchors(workspace);
44
+ await patchFile(bootstrapPath, (source) => updatePluginHeaderCompatibility(source, compatibilityPolicy));
45
+ const packageScriptChanges = await ensureAiFeaturePackageScripts(workspace);
46
+ await ensureAiFeatureSyncProjectAnchors(workspace);
47
+ await ensureAiFeatureSyncRestAnchors(workspace);
48
+ await fsp.writeFile(syncAiScriptPath, buildAiFeatureSyncScriptSource(), "utf8");
49
+ await fsp.writeFile(typesFilePath, buildAiFeatureTypesSource(aiFeatureSlug), "utf8");
50
+ await fsp.writeFile(validatorsFilePath, buildAiFeatureValidatorsSource(aiFeatureSlug), "utf8");
51
+ await fsp.writeFile(apiFilePath, buildAiFeatureApiSource(aiFeatureSlug), "utf8");
52
+ await fsp.writeFile(dataFilePath, buildAiFeatureDataSource(aiFeatureSlug), "utf8");
53
+ await fsp.writeFile(phpFilePath, buildAiFeaturePhpSource(aiFeatureSlug, namespace, workspace.workspace.phpPrefix, workspace.workspace.textDomain), "utf8");
54
+ const pascalCase = toPascalCase(aiFeatureSlug);
55
+ await syncAiFeatureRestArtifacts({
56
+ clientFile: `src/ai-features/${aiFeatureSlug}/api-client.ts`,
57
+ outputDir: path.join("src", "ai-features", aiFeatureSlug),
58
+ projectDir: workspace.projectDir,
59
+ typesFile: `src/ai-features/${aiFeatureSlug}/api-types.ts`,
60
+ validatorsFile: `src/ai-features/${aiFeatureSlug}/api-validators.ts`,
61
+ variables: {
62
+ namespace,
63
+ pascalCase,
64
+ slugKebabCase: aiFeatureSlug,
65
+ title: toTitleCase(aiFeatureSlug),
66
+ },
67
+ });
68
+ await syncAiFeatureSchemaArtifact({
69
+ aiSchemaFile: `src/ai-features/${aiFeatureSlug}/ai-schemas/feature-result.ai.schema.json`,
70
+ outputDir: path.join("src", "ai-features", aiFeatureSlug),
71
+ projectDir: workspace.projectDir,
72
+ });
73
+ await appendWorkspaceInventoryEntries(workspace.projectDir, {
74
+ aiFeatureEntries: [
75
+ buildAiFeatureConfigEntry(aiFeatureSlug, namespace),
76
+ ],
77
+ transformSource: ensureBlockConfigCanAddRestManifests,
78
+ });
79
+ return {
80
+ warnings: packageScriptChanges.addedProjectToolsDependency
81
+ ? [
82
+ "Added `@wp-typia/project-tools` to devDependencies for `sync-ai`. If this workspace was already installed, rerun your package manager install command before the first `wp-typia sync ai`.",
83
+ ]
84
+ : [],
85
+ };
86
+ }
87
+ catch (error) {
88
+ await rollbackWorkspaceMutation(mutationSnapshot);
89
+ throw error;
90
+ }
91
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Build the generated PHP controller and hook surface for a workspace AI feature.
3
+ */
4
+ export declare function buildAiFeaturePhpSource(aiFeatureSlug: string, namespace: string, phpPrefix: string, textDomain: string): string;