Skip to content

Commit 5c87e57

Browse files
authored
fix(homeboy): verify WordPress extension during setup (#101)
1 parent fe9c4a4 commit 5c87e57

5 files changed

Lines changed: 164 additions & 13 deletions

File tree

homeboy.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
"changelog_target": "docs/changelog.md",
44
"id": "wp-coding-agents",
55
"remote_path": "",
6+
"extensions": {
7+
"wordpress": {}
8+
},
69
"version_targets": [
710
{
811
"file": "VERSION",
912
"pattern": "^([0-9.]+)$"
1013
}
1114
]
12-
}
15+
}

lib/data-machine.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,8 @@ create_dm_agent() {
6969
}
7070

7171
sync_homeboy_availability() {
72-
local homeboy_available=false
73-
74-
if command -v homeboy >/dev/null 2>&1; then
75-
homeboy_available=true
76-
fi
77-
7872
if [ "$DRY_RUN" = true ]; then
79-
if [ "$homeboy_available" = true ]; then
73+
if [ "${HOMEBOY_WORDPRESS_READY:-false}" = true ] || homeboy_wordpress_extension_ready; then
8074
echo -e "${BLUE}[dry-run]${NC} $WP_CMD option update datamachine_code_homeboy_available 1"
8175
else
8276
echo -e "${BLUE}[dry-run]${NC} $WP_CMD option delete datamachine_code_homeboy_available"
@@ -85,7 +79,7 @@ sync_homeboy_availability() {
8579
return 0
8680
fi
8781

88-
if [ "$homeboy_available" = true ]; then
82+
if [ "${HOMEBOY_WORDPRESS_READY:-false}" = true ] || homeboy_wordpress_extension_ready; then
8983
wp_cmd option update datamachine_code_homeboy_available 1 >/dev/null 2>&1 || \
9084
warn "Could not record Homeboy availability for AGENTS.md compose"
9185
sync_homeboy_project_components

lib/homeboy.sh

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
2-
# Homeboy project registration for the installed WordPress site.
2+
# Homeboy project registration plus optional WordPress extension readiness.
3+
4+
HOMEBOY_EXTENSIONS_SOURCE_DEFAULT="https://github.com/Extra-Chill/homeboy-extensions.git"
5+
HOMEBOY_WORDPRESS_READY=false
36

47
homeboy_slugify() {
58
printf '%s' "$1" | sed 's|https\?://||; s|/.*$||; s|\..*$||' | \
@@ -79,14 +82,65 @@ ensure_homeboy_local_server() {
7982
fi
8083
}
8184

85+
homeboy_wordpress_extension_ready() {
86+
command -v homeboy >/dev/null 2>&1 || return 1
87+
88+
local list_json
89+
list_json=$(homeboy extension list 2>/dev/null) || return 1
90+
91+
printf '%s' "$list_json" | python3 -c '
92+
import json, sys
93+
try:
94+
data = json.load(sys.stdin)
95+
except Exception:
96+
sys.exit(1)
97+
extensions = data.get("data", {}).get("extensions", [])
98+
for extension in extensions:
99+
if extension.get("id") == "wordpress":
100+
if extension.get("ready") is True and extension.get("compatible") is not False:
101+
sys.exit(0)
102+
sys.exit(1)
103+
sys.exit(1)
104+
' >/dev/null 2>&1
105+
}
106+
107+
homeboy_wordpress_extension_linked() {
108+
command -v homeboy >/dev/null 2>&1 || return 1
109+
110+
local show_json
111+
show_json=$(homeboy extension show wordpress 2>/dev/null) || return 1
112+
113+
printf '%s' "$show_json" | python3 -c '
114+
import json, sys
115+
try:
116+
data = json.load(sys.stdin)
117+
except Exception:
118+
sys.exit(1)
119+
sys.exit(0 if data.get("data", {}).get("extension", {}).get("linked") is True else 1)
120+
' >/dev/null 2>&1
121+
}
122+
123+
homeboy_required() {
124+
[ "${HOMEBOY_MODE:-auto}" = "enabled" ] || [ "${WITH_HOMEBOY:-false}" = true ]
125+
}
126+
127+
homeboy_handle_failure() {
128+
local message="$1"
129+
if homeboy_required; then
130+
error "$message"
131+
fi
132+
warn "$message"
133+
return 0
134+
}
135+
82136
setup_homeboy_project() {
83137
if [ "${HOMEBOY_MODE:-auto}" = "disabled" ]; then
84138
log "Skipping Homeboy project setup (--no-homeboy)"
85139
return 0
86140
fi
87141

88142
if ! command -v homeboy >/dev/null 2>&1; then
89-
if [ "${HOMEBOY_MODE:-auto}" = "enabled" ]; then
143+
if homeboy_required; then
90144
error "Homeboy project setup requested, but the 'homeboy' command was not found"
91145
fi
92146
log "Skipping Homeboy project setup (homeboy not installed)"
@@ -122,3 +176,97 @@ setup_homeboy_project() {
122176
log "Created Homeboy project '$project_id'"
123177
fi
124178
}
179+
180+
configure_homeboy_wordpress_extension() {
181+
HOMEBOY_WORDPRESS_READY=false
182+
183+
if [ "${HOMEBOY_MODE:-auto}" = "disabled" ]; then
184+
sync_homeboy_availability
185+
recompose_agents_md_for_homeboy
186+
return 0
187+
fi
188+
189+
if ! command -v homeboy >/dev/null 2>&1; then
190+
homeboy_handle_failure "Homeboy is not callable from this setup/runtime PATH; skipping Homeboy WordPress extension setup."
191+
sync_homeboy_availability
192+
recompose_agents_md_for_homeboy
193+
return 0
194+
fi
195+
196+
log "Detected Homeboy: $(command -v homeboy)"
197+
198+
if ! homeboy_required; then
199+
if homeboy_wordpress_extension_ready; then
200+
HOMEBOY_WORDPRESS_READY=true
201+
log "Homeboy WordPress extension is installed and ready."
202+
else
203+
warn "Homeboy is callable, but the WordPress extension is not ready. Run setup with --with-homeboy to install and verify it."
204+
fi
205+
sync_homeboy_availability
206+
recompose_agents_md_for_homeboy
207+
return 0
208+
fi
209+
210+
local source="${HOMEBOY_EXTENSIONS_SOURCE:-$HOMEBOY_EXTENSIONS_SOURCE_DEFAULT}"
211+
212+
if [ "$DRY_RUN" = true ]; then
213+
echo -e "${BLUE}[dry-run]${NC} homeboy extension install $source --id wordpress"
214+
echo -e "${BLUE}[dry-run]${NC} homeboy extension update wordpress # if already installed and not linked"
215+
echo -e "${BLUE}[dry-run]${NC} homeboy extension setup wordpress"
216+
echo -e "${BLUE}[dry-run]${NC} homeboy extension list"
217+
echo -e "${BLUE}[dry-run]${NC} $WP_CMD option update datamachine_code_homeboy_available 1"
218+
print_homeboy_verification_commands
219+
return 0
220+
fi
221+
222+
if homeboy extension show wordpress >/dev/null 2>&1; then
223+
if homeboy_wordpress_extension_linked; then
224+
log "Homeboy WordPress extension is linked locally — skipping git update."
225+
else
226+
log "Updating Homeboy WordPress extension..."
227+
homeboy extension update wordpress >/dev/null || homeboy_handle_failure "Homeboy WordPress extension update failed."
228+
fi
229+
else
230+
log "Installing Homeboy WordPress extension from $source..."
231+
homeboy extension install "$source" --id wordpress >/dev/null || homeboy_handle_failure "Homeboy WordPress extension install failed from $source."
232+
fi
233+
234+
log "Running Homeboy WordPress extension setup..."
235+
homeboy extension setup wordpress >/dev/null || homeboy_handle_failure "Homeboy WordPress extension setup failed."
236+
237+
if homeboy_wordpress_extension_ready; then
238+
HOMEBOY_WORDPRESS_READY=true
239+
log "Homeboy WordPress extension is ready."
240+
else
241+
homeboy_handle_failure "Homeboy WordPress extension did not pass readiness verification."
242+
fi
243+
244+
sync_homeboy_availability
245+
recompose_agents_md_for_homeboy
246+
print_homeboy_verification_commands
247+
}
248+
249+
recompose_agents_md_for_homeboy() {
250+
if [ "$DRY_RUN" = true ]; then
251+
echo -e "${BLUE}[dry-run]${NC} $WP_CMD datamachine memory compose AGENTS.md $WP_ROOT_FLAG"
252+
return 0
253+
fi
254+
255+
if [ ! -f "$SITE_PATH/wp-config.php" ] && [ ! -f "$SITE_PATH/wp-load.php" ]; then
256+
return 0
257+
fi
258+
259+
if (cd "$SITE_PATH" && $WP_CMD datamachine memory compose AGENTS.md $WP_ROOT_FLAG >/dev/null 2>&1); then
260+
log "AGENTS.md recomposed after Homeboy availability sync."
261+
else
262+
homeboy_handle_failure "Could not recompose AGENTS.md after Homeboy availability sync."
263+
fi
264+
}
265+
266+
print_homeboy_verification_commands() {
267+
log "Homeboy verification commands:"
268+
echo " homeboy extension list"
269+
echo " homeboy extension show wordpress"
270+
echo " homeboy project show <project-id>"
271+
echo " homeboy project components list <project-id>"
272+
}

setup.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ MULTISITE_TYPE="subdirectory"
5757
INSTALL_SKILLS=true
5858
SKILLS_ONLY=false
5959
RUNTIME_ONLY=false
60+
WITH_HOMEBOY=false
6061
RUNTIME=""
6162
HOMEBOY_MODE="auto"
6263
HOMEBOY_PROJECT_ID="${HOMEBOY_PROJECT_ID:-}"
@@ -128,6 +129,7 @@ while [[ $# -gt 0 ]]; do
128129
;;
129130
--with-homeboy)
130131
HOMEBOY_MODE="enabled"
132+
WITH_HOMEBOY=true
131133
shift
132134
;;
133135
--no-homeboy)
@@ -199,7 +201,8 @@ OPTIONS:
199201
--multisite Convert to WordPress Multisite (subdirectory by default)
200202
--subdomain Use subdomain multisite (requires wildcard DNS; use with --multisite)
201203
--no-skills Skip WordPress agent skills installation
202-
--with-homeboy Create/update a Homeboy project for this WordPress site
204+
--with-homeboy Create/update a Homeboy project and install/verify the
205+
WordPress Homeboy extension
203206
--no-homeboy Skip Homeboy project setup, even if homeboy is installed
204207
--homeboy-project-id <id>
205208
Override Homeboy project ID (default: agent/site slug)
@@ -231,6 +234,8 @@ ENVIRONMENT VARIABLES:
231234
EXTRA_PLUGINS Space-separated slug:url pairs for additional plugins
232235
MCP_SERVERS JSON object merged into runtime config (requires jq)
233236
WP_CMD Override WP-CLI command (default: wp; e.g., "studio wp")
237+
HOMEBOY_EXTENSIONS_SOURCE Homeboy extensions git URL/path
238+
(default: https://github.com/Extra-Chill/homeboy-extensions.git)
234239
235240
MIGRATION WORKFLOW:
236241
1. On old server: Export database and wp-content
@@ -329,6 +334,7 @@ runtime_install
329334
runtime_discover_dm_paths
330335
runtime_generate_config
331336
runtime_install_hooks
337+
configure_homeboy_wordpress_extension
332338
runtime_generate_instructions
333339
runtime_merge_mcp_servers
334340
install_skills

upgrade.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ TIMESTAMP="$(date +%Y%m%d-%H%M%S)"
6666

6767
# Source shared modules (common, detect needed for environment resolution;
6868
# wordpress is needed for wp_cmd helper used by compose and plugin updates).
69-
for lib in common detect wordpress data-machine skills; do
69+
for lib in common detect wordpress data-machine homeboy skills; do
7070
source "$SCRIPT_DIR/lib/${lib}.sh"
7171
done
7272

0 commit comments

Comments
 (0)