wordpress-agent-kit 0.4.0 → 0.6.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 (153) hide show
  1. package/.agents/skills/wp-bootstrap/SKILL.md +314 -0
  2. package/.agents/skills/wp-bootstrap/references/composer-setup.md +275 -0
  3. package/.agents/skills/wp-bootstrap/references/monorepo-patterns.md +184 -0
  4. package/.agents/skills/wp-bootstrap/scripts/bootstrap.sh +151 -0
  5. package/.agents/skills/wp-bootstrap/scripts/detect-structure.mjs +466 -0
  6. package/.agents/skills/wp-bootstrap/scripts/package-wp.sh +173 -0
  7. package/.agents/skills/wp-bootstrap/scripts/playground-start.sh +148 -0
  8. package/.agents/skills/wp-bootstrap/scripts/playground-verify.sh +165 -0
  9. package/.agents/skills/wp-bootstrap/scripts/setup-github.sh +417 -0
  10. package/{.github → .agents}/skills/wp-wpcli-and-ops/SKILL.md +11 -9
  11. package/.agents/skills/wp-wpengine/SKILL.md +462 -0
  12. package/.agents/skills/wp-wpengine/references/ci-gate.md +469 -0
  13. package/.agents/skills/wp-wpengine/references/github-actions-deploy.md +743 -0
  14. package/.agents/skills/wp-wpengine/scripts/ci-gate.sh +118 -0
  15. package/.agents/skills/wp-wpengine/scripts/wpe-check.sh +89 -0
  16. package/.agents/skills/wp-wpengine/scripts/wpe-preflight.sh +104 -0
  17. package/.github/agents/wp-architect.agent.md +1 -2
  18. package/.github/copilot-instructions.md +1 -1
  19. package/.github/instructions/wordpress-workflow.instructions.md +3 -3
  20. package/AGENTS.md +22 -10
  21. package/AGENTS.template.md +20 -10
  22. package/README.md +89 -85
  23. package/dist/cli.js +7 -1
  24. package/dist/commands/bootstrap.js +105 -0
  25. package/dist/commands/clean-skills.js +64 -0
  26. package/dist/commands/setup.js +6 -2
  27. package/dist/commands/sync-skills.js +3 -0
  28. package/dist/lib/api.js +165 -5
  29. package/dist/lib/bootstrap.js +352 -0
  30. package/dist/lib/installer.js +166 -2
  31. package/extensions/wp-agent-kit/index.ts +325 -10
  32. package/package.json +10 -14
  33. package/skills-custom/wp-bootstrap/SKILL.md +314 -0
  34. package/skills-custom/wp-bootstrap/references/composer-setup.md +275 -0
  35. package/skills-custom/wp-bootstrap/references/monorepo-patterns.md +184 -0
  36. package/skills-custom/wp-bootstrap/scripts/bootstrap.sh +151 -0
  37. package/skills-custom/wp-bootstrap/scripts/detect-structure.mjs +466 -0
  38. package/skills-custom/wp-bootstrap/scripts/package-wp.sh +173 -0
  39. package/skills-custom/wp-bootstrap/scripts/playground-start.sh +148 -0
  40. package/skills-custom/wp-bootstrap/scripts/playground-verify.sh +165 -0
  41. package/skills-custom/wp-bootstrap/scripts/setup-github.sh +417 -0
  42. package/skills-custom/wp-wpengine/SKILL.md +362 -27
  43. package/skills-custom/wp-wpengine/references/ci-gate.md +469 -0
  44. package/skills-custom/wp-wpengine/references/github-actions-deploy.md +743 -0
  45. package/skills-custom/wp-wpengine/scripts/ci-gate.sh +118 -0
  46. package/skills-custom/wp-wpengine/scripts/wpe-check.sh +89 -0
  47. package/skills-custom/wp-wpengine/scripts/wpe-preflight.sh +104 -0
  48. package/.github/skills/wp-wpengine/SKILL.md +0 -127
  49. package/.github/workflows/ci.yml +0 -44
  50. package/.husky/pre-commit +0 -7
  51. package/CLI_REVIEW.md +0 -250
  52. package/biome.json +0 -39
  53. /package/{.github → .agents}/skills/blueprint/SKILL.md +0 -0
  54. /package/{.github → .agents}/skills/wordpress-router/SKILL.md +0 -0
  55. /package/{.github → .agents}/skills/wordpress-router/references/decision-tree.md +0 -0
  56. /package/{.github → .agents}/skills/wp-abilities-api/SKILL.md +0 -0
  57. /package/{.github → .agents}/skills/wp-abilities-api/references/delegate-helper-pattern.md +0 -0
  58. /package/{.github → .agents}/skills/wp-abilities-api/references/domain-vs-projection.md +0 -0
  59. /package/{.github → .agents}/skills/wp-abilities-api/references/error-code-vocabulary.md +0 -0
  60. /package/{.github → .agents}/skills/wp-abilities-api/references/grouping-heuristic.md +0 -0
  61. /package/{.github → .agents}/skills/wp-abilities-api/references/input-schema-gotchas.md +0 -0
  62. /package/{.github → .agents}/skills/wp-abilities-api/references/php-registration.md +0 -0
  63. /package/{.github → .agents}/skills/wp-abilities-api/references/plugin-family-patterns.md +0 -0
  64. /package/{.github → .agents}/skills/wp-abilities-api/references/rest-api.md +0 -0
  65. /package/{.github → .agents}/skills/wp-abilities-api/references/shared-core-service.md +0 -0
  66. /package/{.github → .agents}/skills/wp-abilities-audit/SKILL.md +0 -0
  67. /package/{.github → .agents}/skills/wp-abilities-audit/references/audit-schema.md +0 -0
  68. /package/{.github → .agents}/skills/wp-abilities-audit/references/capability-gate-tracing.md +0 -0
  69. /package/{.github → .agents}/skills/wp-abilities-audit/references/controller-enumeration.md +0 -0
  70. /package/{.github → .agents}/skills/wp-abilities-verify/SKILL.md +0 -0
  71. /package/{.github → .agents}/skills/wp-abilities-verify/references/annotation-correctness.md +0 -0
  72. /package/{.github → .agents}/skills/wp-abilities-verify/references/audit-schema-validation.md +0 -0
  73. /package/{.github → .agents}/skills/wp-abilities-verify/references/permission-roundtrip.md +0 -0
  74. /package/{.github → .agents}/skills/wp-abilities-verify/references/runtime-harness.md +0 -0
  75. /package/{.github → .agents}/skills/wp-abilities-verify/references/schema-lints.md +0 -0
  76. /package/{.github → .agents}/skills/wp-abilities-verify/references/static-enumeration.md +0 -0
  77. /package/{.github → .agents}/skills/wp-block-development/SKILL.md +0 -0
  78. /package/{.github → .agents}/skills/wp-block-development/references/attributes-and-serialization.md +0 -0
  79. /package/{.github → .agents}/skills/wp-block-development/references/block-json.md +0 -0
  80. /package/{.github → .agents}/skills/wp-block-development/references/creating-new-blocks.md +0 -0
  81. /package/{.github → .agents}/skills/wp-block-development/references/debugging.md +0 -0
  82. /package/{.github → .agents}/skills/wp-block-development/references/deprecations.md +0 -0
  83. /package/{.github → .agents}/skills/wp-block-development/references/dynamic-rendering.md +0 -0
  84. /package/{.github → .agents}/skills/wp-block-development/references/inner-blocks.md +0 -0
  85. /package/{.github → .agents}/skills/wp-block-development/references/registration.md +0 -0
  86. /package/{.github → .agents}/skills/wp-block-development/references/supports-and-wrappers.md +0 -0
  87. /package/{.github → .agents}/skills/wp-block-development/references/tooling-and-testing.md +0 -0
  88. /package/{.github → .agents}/skills/wp-block-development/scripts/list_blocks.mjs +0 -0
  89. /package/{.github → .agents}/skills/wp-block-themes/SKILL.md +0 -0
  90. /package/{.github → .agents}/skills/wp-block-themes/references/creating-new-block-theme.md +0 -0
  91. /package/{.github → .agents}/skills/wp-block-themes/references/debugging.md +0 -0
  92. /package/{.github → .agents}/skills/wp-block-themes/references/patterns.md +0 -0
  93. /package/{.github → .agents}/skills/wp-block-themes/references/style-variations.md +0 -0
  94. /package/{.github → .agents}/skills/wp-block-themes/references/templates-and-parts.md +0 -0
  95. /package/{.github → .agents}/skills/wp-block-themes/references/theme-json.md +0 -0
  96. /package/{.github → .agents}/skills/wp-block-themes/scripts/detect_block_themes.mjs +0 -0
  97. /package/{.github → .agents}/skills/wp-interactivity-api/SKILL.md +0 -0
  98. /package/{.github → .agents}/skills/wp-interactivity-api/references/debugging.md +0 -0
  99. /package/{.github → .agents}/skills/wp-interactivity-api/references/directives-quickref.md +0 -0
  100. /package/{.github → .agents}/skills/wp-interactivity-api/references/server-side-rendering.md +0 -0
  101. /package/{.github → .agents}/skills/wp-performance/SKILL.md +0 -0
  102. /package/{.github → .agents}/skills/wp-performance/references/autoload-options.md +0 -0
  103. /package/{.github → .agents}/skills/wp-performance/references/cron.md +0 -0
  104. /package/{.github → .agents}/skills/wp-performance/references/database.md +0 -0
  105. /package/{.github → .agents}/skills/wp-performance/references/http-api.md +0 -0
  106. /package/{.github → .agents}/skills/wp-performance/references/measurement.md +0 -0
  107. /package/{.github → .agents}/skills/wp-performance/references/object-cache.md +0 -0
  108. /package/{.github → .agents}/skills/wp-performance/references/query-monitor-headless.md +0 -0
  109. /package/{.github → .agents}/skills/wp-performance/references/server-timing.md +0 -0
  110. /package/{.github → .agents}/skills/wp-performance/references/wp-cli-doctor.md +0 -0
  111. /package/{.github → .agents}/skills/wp-performance/references/wp-cli-profile.md +0 -0
  112. /package/{.github → .agents}/skills/wp-performance/scripts/perf_inspect.mjs +0 -0
  113. /package/{.github → .agents}/skills/wp-phpstan/SKILL.md +0 -0
  114. /package/{.github → .agents}/skills/wp-phpstan/references/configuration.md +0 -0
  115. /package/{.github → .agents}/skills/wp-phpstan/references/third-party-classes.md +0 -0
  116. /package/{.github → .agents}/skills/wp-phpstan/references/wordpress-annotations.md +0 -0
  117. /package/{.github → .agents}/skills/wp-phpstan/scripts/phpstan_inspect.mjs +0 -0
  118. /package/{.github → .agents}/skills/wp-playground/SKILL.md +0 -0
  119. /package/{.github → .agents}/skills/wp-playground/references/blueprints.md +0 -0
  120. /package/{.github → .agents}/skills/wp-playground/references/cli-commands.md +0 -0
  121. /package/{.github → .agents}/skills/wp-playground/references/debugging.md +0 -0
  122. /package/{.github → .agents}/skills/wp-playground/references/e2e-playwright.md +0 -0
  123. /package/{.github → .agents}/skills/wp-plugin-development/SKILL.md +0 -0
  124. /package/{.github → .agents}/skills/wp-plugin-development/references/data-and-cron.md +0 -0
  125. /package/{.github → .agents}/skills/wp-plugin-development/references/debugging.md +0 -0
  126. /package/{.github → .agents}/skills/wp-plugin-development/references/lifecycle.md +0 -0
  127. /package/{.github → .agents}/skills/wp-plugin-development/references/security.md +0 -0
  128. /package/{.github → .agents}/skills/wp-plugin-development/references/settings-api.md +0 -0
  129. /package/{.github → .agents}/skills/wp-plugin-development/references/structure.md +0 -0
  130. /package/{.github → .agents}/skills/wp-plugin-development/scripts/detect_plugins.mjs +0 -0
  131. /package/{.github → .agents}/skills/wp-plugin-directory-guidelines/SKILL.md +0 -0
  132. /package/{.github → .agents}/skills/wp-plugin-directory-guidelines/references/gpl-compliance.md +0 -0
  133. /package/{.github → .agents}/skills/wp-plugin-directory-guidelines/references/guideline-review-checklist.md +0 -0
  134. /package/{.github → .agents}/skills/wp-plugin-directory-guidelines/references/naming-rules.md +0 -0
  135. /package/{.github → .agents}/skills/wp-project-triage/SKILL.md +0 -0
  136. /package/{.github → .agents}/skills/wp-project-triage/references/triage.schema.json +0 -0
  137. /package/{.github → .agents}/skills/wp-project-triage/scripts/detect_wp_project.mjs +0 -0
  138. /package/{.github → .agents}/skills/wp-rest-api/SKILL.md +0 -0
  139. /package/{.github → .agents}/skills/wp-rest-api/references/authentication.md +0 -0
  140. /package/{.github → .agents}/skills/wp-rest-api/references/custom-content-types.md +0 -0
  141. /package/{.github → .agents}/skills/wp-rest-api/references/discovery-and-params.md +0 -0
  142. /package/{.github → .agents}/skills/wp-rest-api/references/responses-and-fields.md +0 -0
  143. /package/{.github → .agents}/skills/wp-rest-api/references/routes-and-endpoints.md +0 -0
  144. /package/{.github → .agents}/skills/wp-rest-api/references/schema.md +0 -0
  145. /package/{.github → .agents}/skills/wp-wpcli-and-ops/references/automation.md +0 -0
  146. /package/{.github → .agents}/skills/wp-wpcli-and-ops/references/cron-and-cache.md +0 -0
  147. /package/{.github → .agents}/skills/wp-wpcli-and-ops/references/debugging.md +0 -0
  148. /package/{.github → .agents}/skills/wp-wpcli-and-ops/references/multisite.md +0 -0
  149. /package/{.github → .agents}/skills/wp-wpcli-and-ops/references/packages-and-updates.md +0 -0
  150. /package/{.github → .agents}/skills/wp-wpcli-and-ops/references/safety.md +0 -0
  151. /package/{.github → .agents}/skills/wp-wpcli-and-ops/references/search-replace.md +0 -0
  152. /package/{.github → .agents}/skills/wp-wpcli-and-ops/scripts/wpcli_inspect.mjs +0 -0
  153. /package/{.github → .agents}/skills/wpds/SKILL.md +0 -0
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env bash
2
+ # playground-start.sh — boot an interactive WordPress Playground with local plugins/themes.
3
+ #
4
+ # Generalized from wp-agent-os tools/playground/run-playground.sh.
5
+ # Reads wp-bootstrap.config.json for mount configuration, or auto-detects
6
+ # WP packages via detect-structure.mjs.
7
+ #
8
+ # Usage:
9
+ # bash .agents/skills/wp-bootstrap/scripts/playground-start.sh [OPTIONS]
10
+ #
11
+ # Options:
12
+ # --port=<port> Port (default: 9400)
13
+ # --site-url=<url> Override WordPress site URL (WSL: use wsl.localhost:<port>)
14
+ # --blueprint=<file> Blueprint JSON file (default: auto-detect or minimal)
15
+ # --no-login Don't auto-login as admin
16
+ # --api-mode Enable Application Password mode (for backend integration)
17
+ # --no-build Skip build step
18
+ #
19
+ # Environment:
20
+ # WPAOS_PG_PORT Port override
21
+ # WPAOS_PG_SITE_URL Site URL override (useful for WSL)
22
+ # WPAOS_PG_API_MODE Set to 1 for Application Password auth mode
23
+
24
+ set -euo pipefail
25
+ root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
26
+ cd "$root"
27
+
28
+ PORT="${WPAOS_PG_PORT:-9400}"
29
+ SITE_URL="${WPAOS_PG_SITE_URL:-}"
30
+ BLUEPRINT=""
31
+ NO_LOGIN=false
32
+ API_MODE="${WPAOS_PG_API_MODE:-0}"
33
+ NO_BUILD=false
34
+
35
+ for arg in "$@"; do
36
+ case "$arg" in
37
+ --port=*) PORT="${arg#--port=}" ;;
38
+ --site-url=*) SITE_URL="${arg#--site-url=}" ;;
39
+ --blueprint=*) BLUEPRINT="${arg#--blueprint=}" ;;
40
+ --no-login) NO_LOGIN=true ;;
41
+ --api-mode) API_MODE=1 ;;
42
+ --no-build) NO_BUILD=true ;;
43
+ esac
44
+ done
45
+
46
+ SITE_URL="${SITE_URL:-http://127.0.0.1:${PORT}}"
47
+
48
+ # ── Detect WP packages for --mount args ───────────────────────────────────────
49
+ DETECT_SCRIPT="$(dirname "$0")/detect-structure.mjs"
50
+ MOUNTS=()
51
+ PKG_TYPES=()
52
+
53
+ if command -v node >/dev/null 2>&1 && [ -f "$DETECT_SCRIPT" ]; then
54
+ STRUCT=$(node "$DETECT_SCRIPT" "$root" 2>/dev/null)
55
+
56
+ while IFS=$'\t' read -r pkg_path pkg_type pkg_slug; do
57
+ [ -z "$pkg_path" ] && continue
58
+ case "$pkg_type" in
59
+ plugin) MOUNTS+=("--mount=$root/$pkg_path:/wordpress/wp-content/plugins/$pkg_slug") ;;
60
+ theme) MOUNTS+=("--mount=$root/$pkg_path:/wordpress/wp-content/themes/$pkg_slug") ;;
61
+ esac
62
+ PKG_TYPES+=("$pkg_type:$pkg_slug ($pkg_path)")
63
+ done < <(echo "$STRUCT" | node -e "
64
+ const chunks = [];
65
+ process.stdin.on('data', c => chunks.push(c));
66
+ process.stdin.on('end', () => {
67
+ const r = JSON.parse(chunks.join(''));
68
+ r.wpPackages.forEach(p => process.stdout.write(p.path + '\t' + p.type + '\t' + (p.slug ?? '') + '\n'));
69
+ });
70
+ " 2>/dev/null)
71
+ else
72
+ # Fallback: manual mount from config or ask user
73
+ CONFIG_FILE="$root/wp-bootstrap.config.json"
74
+ if [ -f "$CONFIG_FILE" ] && command -v node >/dev/null 2>&1; then
75
+ while IFS= read -r mount; do
76
+ MOUNTS+=("--mount=$mount")
77
+ done < <(node -e "
78
+ const c = require('$CONFIG_FILE');
79
+ (c.playgroundMounts ?? []).forEach(m => console.log(m));
80
+ " 2>/dev/null)
81
+ fi
82
+ fi
83
+
84
+ if [ "${#MOUNTS[@]}" -eq 0 ]; then
85
+ echo "⚠ No WP packages detected. Add wp-bootstrap.config.json or run from a repo with plugins/themes."
86
+ echo " Booting plain WordPress Playground..."
87
+ fi
88
+
89
+ # ── Auto-detect or build blueprint ────────────────────────────────────────────
90
+ if [ -z "$BLUEPRINT" ]; then
91
+ # Look for a blueprint in common locations
92
+ for candidate in \
93
+ "tools/playground/playground-blueprint.json" \
94
+ "tools/playground/blueprint.json" \
95
+ "blueprint.json" \
96
+ "playground/blueprint.json"; do
97
+ if [ -f "$root/$candidate" ]; then
98
+ BLUEPRINT="$root/$candidate"
99
+ break
100
+ fi
101
+ done
102
+ fi
103
+
104
+ # ── Run build if needed ───────────────────────────────────────────────────────
105
+ if ! $NO_BUILD && [ -f "$root/package.json" ]; then
106
+ PKG_MGR="npm"; [ -f "pnpm-lock.yaml" ] && PKG_MGR="pnpm"
107
+ if grep -q '"build"' "$root/package.json" 2>/dev/null; then
108
+ echo "▶ Building before starting Playground..."
109
+ "$PKG_MGR" run build >/dev/null 2>&1 || echo " ⚠ Build step failed — using current files"
110
+ fi
111
+ fi
112
+
113
+ # ── Print info ────────────────────────────────────────────────────────────────
114
+ echo ""
115
+ echo "── WordPress Playground ────────────────────────────────────────"
116
+ echo " Mounting:"
117
+ for m in "${PKG_TYPES[@]-}"; do echo " $m"; done
118
+ echo ""
119
+ echo " Open: $SITE_URL"
120
+ echo " wp-admin: $SITE_URL/wp-admin"
121
+ echo " REST API: $SITE_URL/wp-json"
122
+ echo ""
123
+ echo " WSL tip: if styles look broken, try:"
124
+ echo " WPAOS_PG_SITE_URL=http://wsl.localhost:${PORT} bash $0"
125
+ echo ""
126
+ echo " Ctrl-C to stop."
127
+ echo ""
128
+
129
+ # ── Build CLI args ────────────────────────────────────────────────────────────
130
+ ARGS=(server)
131
+ ARGS+=("${MOUNTS[@]-}")
132
+ [ -n "$BLUEPRINT" ] && ARGS+=("--blueprint=$BLUEPRINT")
133
+ ARGS+=("--port=$PORT")
134
+ ARGS+=("--site-url=$SITE_URL")
135
+ ARGS+=("--workers=1")
136
+
137
+ if [ "$API_MODE" = "1" ]; then
138
+ mkdir -p "$root/.wp-dev"
139
+ ARGS+=("--mount=$root/.wp-dev:/wordpress/wp-content/wp-dev")
140
+ echo " API mode: Application Password will be written to .wp-dev/app-password.txt"
141
+ else
142
+ if ! $NO_LOGIN; then
143
+ ARGS+=("--internal-cookie-store" "--login")
144
+ fi
145
+ fi
146
+
147
+ # ── Launch ────────────────────────────────────────────────────────────────────
148
+ exec pnpm dlx @wp-playground/cli@latest "${ARGS[@]}"
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env bash
2
+ # playground-verify.sh — headless WordPress Playground verification.
3
+ #
4
+ # Boots WordPress with all local plugins/themes, runs a PHP verification
5
+ # script, and writes result.json. No browser, no Docker.
6
+ #
7
+ # Generalized from wp-agent-os tools/playground/run-local-verify.sh.
8
+ #
9
+ # Usage:
10
+ # bash .agents/skills/wp-bootstrap/scripts/playground-verify.sh [OPTIONS]
11
+ #
12
+ # Options:
13
+ # --verify-php=<file> PHP verification script to run (default: auto-detect)
14
+ # --blueprint=<file> Blueprint JSON (default: minimal verify blueprint)
15
+ # --result=<file> Output JSON file (default: playground-verify-result.json)
16
+ # --no-build Skip build step
17
+
18
+ set -euo pipefail
19
+ root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
20
+ cd "$root"
21
+
22
+ VERIFY_PHP=""
23
+ BLUEPRINT=""
24
+ RESULT_FILE="playground-verify-result.json"
25
+ NO_BUILD=false
26
+
27
+ for arg in "$@"; do
28
+ case "$arg" in
29
+ --verify-php=*) VERIFY_PHP="${arg#--verify-php=}" ;;
30
+ --blueprint=*) BLUEPRINT="${arg#--blueprint=}" ;;
31
+ --result=*) RESULT_FILE="${arg#--result=}" ;;
32
+ --no-build) NO_BUILD=true ;;
33
+ esac
34
+ done
35
+
36
+ DETECT_SCRIPT="$(dirname "$0")/detect-structure.mjs"
37
+
38
+ # ── Build ─────────────────────────────────────────────────────────────────────
39
+ if ! $NO_BUILD && [ -f "$root/package.json" ]; then
40
+ PKG_MGR="npm"; [ -f "pnpm-lock.yaml" ] && PKG_MGR="pnpm"
41
+ if grep -q '"build"' "$root/package.json" 2>/dev/null; then
42
+ echo "▶ Building before verify..."
43
+ "$PKG_MGR" run build >/dev/null 2>&1 || echo " ⚠ Build failed — verifying current files"
44
+ # Also build:blocks if available
45
+ if grep -q '"build:blocks"' "$root/package.json" 2>/dev/null; then
46
+ "$PKG_MGR" run build:blocks >/dev/null 2>&1 || true
47
+ fi
48
+ fi
49
+ fi
50
+
51
+ # ── Detect mounts ────────────────────────────────────────────────────────────
52
+ MOUNTS=()
53
+ if command -v node >/dev/null 2>&1 && [ -f "$DETECT_SCRIPT" ]; then
54
+ STRUCT=$(node "$DETECT_SCRIPT" "$root" 2>/dev/null)
55
+ while IFS=$'\t' read -r pkg_path pkg_type pkg_slug; do
56
+ [ -z "$pkg_path" ] && continue
57
+ case "$pkg_type" in
58
+ plugin) MOUNTS+=("--mount=$root/$pkg_path:/wordpress/wp-content/plugins/$pkg_slug") ;;
59
+ theme) MOUNTS+=("--mount=$root/$pkg_path:/wordpress/wp-content/themes/$pkg_slug") ;;
60
+ esac
61
+ done < <(echo "$STRUCT" | node -e "
62
+ const chunks = [];
63
+ process.stdin.on('data', c => chunks.push(c));
64
+ process.stdin.on('end', () => {
65
+ const r = JSON.parse(chunks.join(''));
66
+ r.wpPackages.forEach(p => process.stdout.write(p.path + '\t' + p.type + '\t' + (p.slug ?? '') + '\n'));
67
+ });
68
+ " 2>/dev/null)
69
+ fi
70
+
71
+ # ── Find or build verify PHP ──────────────────────────────────────────────────
72
+ VERIFY_MOUNT=""
73
+ if [ -z "$VERIFY_PHP" ]; then
74
+ for candidate in \
75
+ "tools/playground/verify.php" \
76
+ "tools/verify.php" \
77
+ "playground/verify.php"; do
78
+ if [ -f "$root/$candidate" ]; then
79
+ VERIFY_PHP="$root/$candidate"
80
+ break
81
+ fi
82
+ done
83
+ fi
84
+
85
+ if [ -n "$VERIFY_PHP" ]; then
86
+ VERIFY_DIR="$(dirname "$VERIFY_PHP")"
87
+ VERIFY_MOUNT="--mount=$VERIFY_DIR:/wordpress/wp-content/pgwork"
88
+ fi
89
+
90
+ # ── Find or create blueprint ──────────────────────────────────────────────────
91
+ BLUEPRINT_FILE=""
92
+ if [ -n "$BLUEPRINT" ]; then
93
+ BLUEPRINT_FILE="$BLUEPRINT"
94
+ elif [ -n "$VERIFY_PHP" ]; then
95
+ # Auto-detect verify blueprint
96
+ for candidate in \
97
+ "tools/playground/verify-blueprint.json" \
98
+ "tools/verify-blueprint.json"; do
99
+ if [ -f "$root/$candidate" ]; then
100
+ BLUEPRINT_FILE="$root/$candidate"
101
+ break
102
+ fi
103
+ done
104
+ fi
105
+
106
+ if [ -z "$BLUEPRINT_FILE" ]; then
107
+ # Create a minimal verify blueprint inline
108
+ BLUEPRINT_FILE="/tmp/wp-bootstrap-verify-blueprint-$$.json"
109
+ PLUGIN_STEPS=""
110
+ if command -v node >/dev/null 2>&1 && [ -f "$DETECT_SCRIPT" ]; then
111
+ STRUCT=$(node "$DETECT_SCRIPT" "$root" 2>/dev/null)
112
+ PLUGIN_STEPS=$(echo "$STRUCT" | node -e "
113
+ const chunks = [];
114
+ process.stdin.on('data', c => chunks.push(c));
115
+ process.stdin.on('end', () => {
116
+ const r = JSON.parse(chunks.join(''));
117
+ const steps = r.wpPackages
118
+ .filter(p => p.type === 'plugin')
119
+ .map(p => JSON.stringify({ step: 'activatePlugin', pluginPath: p.slug + '/' + p.mainFile }));
120
+ process.stdout.write(steps.join(','));
121
+ });
122
+ " 2>/dev/null)
123
+ fi
124
+
125
+ PHP_STEP=""
126
+ if [ -n "$VERIFY_PHP" ]; then
127
+ PHP_STEP='{"step":"runPHP","code":"<?php require \"/wordpress/wp-content/pgwork/$(basename "$VERIFY_PHP")\";"},'
128
+ fi
129
+
130
+ cat > "$BLUEPRINT_FILE" << BLUEPRINT_EOF
131
+ {
132
+ "\$schema": "https://playground.wordpress.net/blueprint-schema.json",
133
+ "steps": [
134
+ ${PLUGIN_STEPS:+${PLUGIN_STEPS},}
135
+ ${PHP_STEP}
136
+ {"step":"runPHP","code":"<?php echo json_encode(['verify'=>true,'wp_version'=>get_bloginfo('version'),'active_plugins'=>get_option('active_plugins')]);"}
137
+ ]
138
+ }
139
+ BLUEPRINT_EOF
140
+ trap "rm -f $BLUEPRINT_FILE" EXIT
141
+ fi
142
+
143
+ # ── Run verify ────────────────────────────────────────────────────────────────
144
+ echo "▶ Running headless Playground verify..."
145
+ echo " Blueprint: $(basename "$BLUEPRINT_FILE")"
146
+ echo " Mounts: ${#MOUNTS[@]} WP package(s)"
147
+ [ -n "$VERIFY_PHP" ] && echo " Verify script: $(basename "$VERIFY_PHP")"
148
+
149
+ rm -f "$RESULT_FILE"
150
+
151
+ pnpm dlx @wp-playground/cli@latest run-blueprint \
152
+ --blueprint="$BLUEPRINT_FILE" \
153
+ ${VERIFY_MOUNT:+"$VERIFY_MOUNT"} \
154
+ "${MOUNTS[@]-}" \
155
+ --verbosity=quiet
156
+
157
+ if [ -f "$RESULT_FILE" ]; then
158
+ echo ""
159
+ echo "=== $RESULT_FILE ==="
160
+ cat "$RESULT_FILE"
161
+ echo ""
162
+ echo "✅ Verify complete"
163
+ else
164
+ echo "⚠ result.json not written — verify your PHP script outputs to a mounted path"
165
+ fi