claude-plugin-wordpress-manager 2.6.0 → 2.9.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/CHANGELOG.md +61 -0
- package/agents/wp-monitoring-agent.md +44 -0
- package/agents/wp-site-manager.md +19 -0
- package/docs/plans/2026-03-01-tier4-5-implementation.md +1783 -0
- package/docs/plans/2026-03-01-tier4-5-observability-automation-design.md +426 -0
- package/docs/plans/2026-03-01-wcop-reassessment-v2.6.0.md +403 -0
- package/hooks/hooks.json +9 -0
- package/package.json +10 -3
- package/servers/wp-rest-bridge/build/tools/cwv.d.ts +3 -0
- package/servers/wp-rest-bridge/build/tools/cwv.js +196 -0
- package/servers/wp-rest-bridge/build/tools/ga4.d.ts +3 -0
- package/servers/wp-rest-bridge/build/tools/ga4.js +323 -0
- package/servers/wp-rest-bridge/build/tools/index.js +15 -0
- package/servers/wp-rest-bridge/build/tools/plausible.d.ts +3 -0
- package/servers/wp-rest-bridge/build/tools/plausible.js +207 -0
- package/servers/wp-rest-bridge/build/tools/slack.d.ts +3 -0
- package/servers/wp-rest-bridge/build/tools/slack.js +129 -0
- package/servers/wp-rest-bridge/build/tools/wc-workflows.d.ts +3 -0
- package/servers/wp-rest-bridge/build/tools/wc-workflows.js +222 -0
- package/servers/wp-rest-bridge/build/wordpress.d.ts +18 -0
- package/servers/wp-rest-bridge/build/wordpress.js +139 -0
- package/skills/wordpress-router/SKILL.md +1 -1
- package/skills/wordpress-router/references/decision-tree.md +8 -2
- package/skills/wp-alerting/SKILL.md +142 -0
- package/skills/wp-alerting/references/alert-thresholds.md +79 -0
- package/skills/wp-alerting/references/escalation-paths.md +92 -0
- package/skills/wp-alerting/references/report-scheduling.md +142 -0
- package/skills/wp-alerting/references/slack-integration.md +109 -0
- package/skills/wp-alerting/scripts/alerting_inspect.mjs +150 -0
- package/skills/wp-analytics/SKILL.md +158 -0
- package/skills/wp-analytics/references/analytics-dashboards.md +83 -0
- package/skills/wp-analytics/references/cwv-monitoring.md +101 -0
- package/skills/wp-analytics/references/ga4-integration.md +76 -0
- package/skills/wp-analytics/references/plausible-setup.md +92 -0
- package/skills/wp-analytics/references/traffic-attribution.md +92 -0
- package/skills/wp-analytics/scripts/analytics_inspect.mjs +153 -0
- package/skills/wp-content-attribution/SKILL.md +1 -0
- package/skills/wp-content-optimization/SKILL.md +1 -0
- package/skills/wp-content-workflows/SKILL.md +142 -0
- package/skills/wp-content-workflows/references/content-lifecycle-hooks.md +131 -0
- package/skills/wp-content-workflows/references/multi-channel-actions.md +151 -0
- package/skills/wp-content-workflows/references/schedule-triggers.md +118 -0
- package/skills/wp-content-workflows/references/trigger-management.md +159 -0
- package/skills/wp-content-workflows/references/wp-action-hooks.md +114 -0
- package/skills/wp-content-workflows/scripts/workflow_inspect.mjs +202 -0
- package/skills/wp-monitoring/SKILL.md +2 -0
- package/skills/wp-search-console/SKILL.md +1 -0
- package/skills/wp-social-email/SKILL.md +1 -0
- package/skills/wp-webhooks/SKILL.md +1 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# Schedule-Based Triggers
|
|
2
|
+
|
|
3
|
+
## WP-Cron Built-in Intervals
|
|
4
|
+
|
|
5
|
+
| Interval | Hook Name | Frequency |
|
|
6
|
+
|----------|-----------|-----------|
|
|
7
|
+
| `hourly` | `wp_scheduled_event` | Every hour |
|
|
8
|
+
| `twicedaily` | `wp_scheduled_event` | Every 12 hours |
|
|
9
|
+
| `daily` | `wp_scheduled_event` | Every 24 hours |
|
|
10
|
+
| `weekly` | `wp_scheduled_event` | Every 7 days |
|
|
11
|
+
|
|
12
|
+
## Custom Cron Intervals
|
|
13
|
+
|
|
14
|
+
Register custom intervals via `cron_schedules` filter:
|
|
15
|
+
|
|
16
|
+
```php
|
|
17
|
+
add_filter('cron_schedules', function ($schedules) {
|
|
18
|
+
$schedules['every_15_minutes'] = [
|
|
19
|
+
'interval' => 900,
|
|
20
|
+
'display' => 'Every 15 Minutes',
|
|
21
|
+
];
|
|
22
|
+
$schedules['every_monday_9am'] = [
|
|
23
|
+
'interval' => 604800, // weekly
|
|
24
|
+
'display' => 'Weekly (Monday 9am)',
|
|
25
|
+
];
|
|
26
|
+
return $schedules;
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Schedule a recurring event:
|
|
31
|
+
|
|
32
|
+
```php
|
|
33
|
+
if (!wp_next_scheduled('wpm_weekly_report')) {
|
|
34
|
+
wp_schedule_event(
|
|
35
|
+
strtotime('next Monday 09:00'),
|
|
36
|
+
'weekly',
|
|
37
|
+
'wpm_weekly_report'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
add_action('wpm_weekly_report', 'generate_weekly_performance_report');
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Scheduled Content Publishing
|
|
44
|
+
|
|
45
|
+
WordPress natively supports future-dated posts via `publish_future_post` hook:
|
|
46
|
+
|
|
47
|
+
- Set post status to `future` with a future `post_date`
|
|
48
|
+
- WP-Cron fires `publish_future_post` at the scheduled time
|
|
49
|
+
- Trigger workflow actions on publish (e.g., notify Slack)
|
|
50
|
+
|
|
51
|
+
Trigger config example:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"type": "schedule",
|
|
56
|
+
"event": "publish_future_post",
|
|
57
|
+
"actions": [
|
|
58
|
+
{ "channel": "slack", "message": "New post published: {{post_title}}" }
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Recurring Health Check Triggers
|
|
64
|
+
|
|
65
|
+
Common scheduled workflow patterns:
|
|
66
|
+
|
|
67
|
+
| Trigger | Interval | Purpose |
|
|
68
|
+
|---------|----------|---------|
|
|
69
|
+
| Performance report | Weekly | CWV scores, uptime stats |
|
|
70
|
+
| Plugin update check | Daily | Security and compatibility |
|
|
71
|
+
| Content freshness | Weekly | Stale draft detection |
|
|
72
|
+
| Backup verification | Daily | Confirm last backup age |
|
|
73
|
+
| SSL expiry check | Daily | Certificate renewal reminder |
|
|
74
|
+
|
|
75
|
+
## External Cron Setup (Server Cron)
|
|
76
|
+
|
|
77
|
+
When `DISABLE_WP_CRON` is `true`, use server-side cron:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
# crontab entry — fire WP-Cron every 5 minutes
|
|
81
|
+
*/5 * * * * wget -qO- https://example.com/wp-cron.php > /dev/null 2>&1
|
|
82
|
+
|
|
83
|
+
# Alternative with curl
|
|
84
|
+
*/5 * * * * curl -s https://example.com/wp-cron.php > /dev/null 2>&1
|
|
85
|
+
|
|
86
|
+
# WP-CLI approach (recommended for reliability)
|
|
87
|
+
*/5 * * * * cd /var/www/html && wp cron event run --due-now > /dev/null 2>&1
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**When to use external cron:**
|
|
91
|
+
- High-traffic sites (WP-Cron adds latency to page loads)
|
|
92
|
+
- Sites behind caching layers that block `wp-cron.php`
|
|
93
|
+
- When precise timing is required (WP-Cron is visitor-triggered)
|
|
94
|
+
|
|
95
|
+
## Example: Weekly Performance Report Every Monday 9am
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"name": "Weekly Performance Report",
|
|
100
|
+
"type": "schedule",
|
|
101
|
+
"schedule": "weekly",
|
|
102
|
+
"first_run": "2026-03-02T09:00:00Z",
|
|
103
|
+
"actions": [
|
|
104
|
+
{
|
|
105
|
+
"channel": "slack",
|
|
106
|
+
"template": "weekly_report",
|
|
107
|
+
"variables": { "site": "{{site_url}}", "period": "last_7_days" }
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"channel": "email",
|
|
111
|
+
"to": "team@example.com",
|
|
112
|
+
"subject": "Weekly WP Report — {{site_url}}",
|
|
113
|
+
"template": "weekly_report_email"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"status": "active"
|
|
117
|
+
}
|
|
118
|
+
```
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Trigger Management
|
|
2
|
+
|
|
3
|
+
## Listing and Filtering Triggers
|
|
4
|
+
|
|
5
|
+
Use `wf_list_triggers` to retrieve all registered triggers:
|
|
6
|
+
|
|
7
|
+
```json
|
|
8
|
+
// List all triggers
|
|
9
|
+
{ "tool": "wf_list_triggers" }
|
|
10
|
+
|
|
11
|
+
// Filter by status
|
|
12
|
+
{ "tool": "wf_list_triggers", "status": "active" }
|
|
13
|
+
{ "tool": "wf_list_triggers", "status": "inactive" }
|
|
14
|
+
|
|
15
|
+
// Filter by type
|
|
16
|
+
{ "tool": "wf_list_triggers", "type": "schedule" }
|
|
17
|
+
{ "tool": "wf_list_triggers", "type": "content_lifecycle" }
|
|
18
|
+
{ "tool": "wf_list_triggers", "type": "action_hook" }
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Trigger List Response Format
|
|
22
|
+
|
|
23
|
+
| Field | Description |
|
|
24
|
+
|-------|-------------|
|
|
25
|
+
| `id` | Unique trigger identifier |
|
|
26
|
+
| `name` | Human-readable trigger name |
|
|
27
|
+
| `type` | `schedule`, `content_lifecycle`, or `action_hook` |
|
|
28
|
+
| `event` | The WordPress event or cron schedule |
|
|
29
|
+
| `status` | `active` or `inactive` |
|
|
30
|
+
| `actions` | Array of action channel configurations |
|
|
31
|
+
| `last_fired` | Timestamp of last execution (null if never) |
|
|
32
|
+
| `fire_count` | Total number of times fired |
|
|
33
|
+
| `created_at` | Creation timestamp |
|
|
34
|
+
|
|
35
|
+
## Activate/Deactivate Without Deleting
|
|
36
|
+
|
|
37
|
+
Toggle triggers on or off without losing configuration:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
// Deactivate a trigger
|
|
41
|
+
{ "tool": "wf_update_trigger", "id": "trg_001", "status": "inactive" }
|
|
42
|
+
|
|
43
|
+
// Reactivate a trigger
|
|
44
|
+
{ "tool": "wf_update_trigger", "id": "trg_001", "status": "active" }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Use cases for deactivation:**
|
|
48
|
+
- Temporarily silence during maintenance windows
|
|
49
|
+
- Pause triggers during site migration
|
|
50
|
+
- Debug by isolating triggers one at a time
|
|
51
|
+
- Seasonal triggers (e.g., holiday sale workflows)
|
|
52
|
+
|
|
53
|
+
## Testing Triggers (Dry-Run Mode)
|
|
54
|
+
|
|
55
|
+
Test a trigger without executing real actions:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"tool": "wf_update_trigger",
|
|
60
|
+
"id": "trg_001",
|
|
61
|
+
"dry_run": true
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Dry-run behavior:
|
|
66
|
+
- Evaluates conditions against current site state
|
|
67
|
+
- Resolves all template variables with real data
|
|
68
|
+
- Logs the fully rendered action payloads
|
|
69
|
+
- Does NOT send Slack messages, emails, or webhooks
|
|
70
|
+
- Returns the rendered output for review
|
|
71
|
+
|
|
72
|
+
### Manual Test Fire
|
|
73
|
+
|
|
74
|
+
Force a trigger to execute once (real actions):
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"tool": "wf_update_trigger",
|
|
79
|
+
"id": "trg_001",
|
|
80
|
+
"test_fire": true
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Warning:** `test_fire` sends real messages. Use `dry_run` first to verify payload format.
|
|
85
|
+
|
|
86
|
+
## Trigger Audit Log
|
|
87
|
+
|
|
88
|
+
Every trigger execution is logged:
|
|
89
|
+
|
|
90
|
+
| Field | Description |
|
|
91
|
+
|-------|-------------|
|
|
92
|
+
| `trigger_id` | ID of the trigger that fired |
|
|
93
|
+
| `timestamp` | When the trigger fired |
|
|
94
|
+
| `event` | WordPress event that caused the fire |
|
|
95
|
+
| `actions_executed` | List of actions taken (channel + status) |
|
|
96
|
+
| `dry_run` | Whether this was a dry-run execution |
|
|
97
|
+
| `error` | Error message if any action failed |
|
|
98
|
+
| `duration_ms` | Total execution time in milliseconds |
|
|
99
|
+
|
|
100
|
+
Query audit logs via the WordPress admin or REST API for debugging and compliance.
|
|
101
|
+
|
|
102
|
+
## Bulk Operations
|
|
103
|
+
|
|
104
|
+
### Enable/Disable All Triggers
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
// Disable all triggers (maintenance mode)
|
|
108
|
+
{ "tool": "wf_update_trigger", "bulk": true, "status": "inactive" }
|
|
109
|
+
|
|
110
|
+
// Re-enable all triggers
|
|
111
|
+
{ "tool": "wf_update_trigger", "bulk": true, "status": "active" }
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Export/Import Triggers
|
|
115
|
+
|
|
116
|
+
Export all trigger configurations as JSON for backup or migration:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
// Export triggers
|
|
120
|
+
{ "tool": "wf_list_triggers", "format": "export" }
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The export includes full trigger config without runtime data (fire_count, last_fired). Import by creating triggers from the exported JSON array.
|
|
124
|
+
|
|
125
|
+
### Bulk Delete
|
|
126
|
+
|
|
127
|
+
Remove all inactive or stale triggers:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
// Delete a specific trigger (requires confirmation)
|
|
131
|
+
{ "tool": "wf_delete_trigger", "id": "trg_001" }
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The `wf_delete_trigger` tool has a safety hook that requires explicit confirmation before deletion.
|
|
135
|
+
|
|
136
|
+
## Cleanup: Removing Stale Triggers
|
|
137
|
+
|
|
138
|
+
A trigger is considered stale if:
|
|
139
|
+
- Status is `inactive` for more than 30 days
|
|
140
|
+
- `last_fired` is null and `created_at` is older than 30 days
|
|
141
|
+
- Referenced hook or event no longer exists (e.g., plugin deactivated)
|
|
142
|
+
|
|
143
|
+
### Cleanup Workflow
|
|
144
|
+
|
|
145
|
+
1. List inactive triggers: `wf_list_triggers` with `status: "inactive"`
|
|
146
|
+
2. Review each trigger's `last_fired` and `created_at`
|
|
147
|
+
3. Identify stale triggers based on criteria above
|
|
148
|
+
4. Delete stale triggers with `wf_delete_trigger`
|
|
149
|
+
5. Verify remaining triggers are all active and functional
|
|
150
|
+
|
|
151
|
+
### Recommended Maintenance Schedule
|
|
152
|
+
|
|
153
|
+
| Task | Frequency | Tool |
|
|
154
|
+
|------|-----------|------|
|
|
155
|
+
| Review trigger list | Weekly | `wf_list_triggers` |
|
|
156
|
+
| Test critical triggers | Monthly | `wf_update_trigger` (dry_run) |
|
|
157
|
+
| Clean stale triggers | Monthly | `wf_delete_trigger` |
|
|
158
|
+
| Export trigger backup | Before updates | `wf_list_triggers` (export) |
|
|
159
|
+
| Audit log review | Weekly | WordPress admin |
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# WordPress Action/Filter Hooks for Workflows
|
|
2
|
+
|
|
3
|
+
## Core WordPress Action Hooks
|
|
4
|
+
|
|
5
|
+
### User Actions
|
|
6
|
+
|
|
7
|
+
| Hook | Fires When | Key Parameters |
|
|
8
|
+
|------|------------|----------------|
|
|
9
|
+
| `user_register` | New user created | `$user_id` |
|
|
10
|
+
| `wp_login` | User logs in | `$user_login`, `$user` |
|
|
11
|
+
| `wp_logout` | User logs out | `$user_id` |
|
|
12
|
+
| `profile_update` | Profile updated | `$user_id`, `$old_user_data` |
|
|
13
|
+
| `delete_user` | User deleted | `$user_id`, `$reassign` |
|
|
14
|
+
| `set_user_role` | Role changed | `$user_id`, `$role`, `$old_roles` |
|
|
15
|
+
|
|
16
|
+
### Comment Actions
|
|
17
|
+
|
|
18
|
+
| Hook | Fires When | Key Parameters |
|
|
19
|
+
|------|------------|----------------|
|
|
20
|
+
| `comment_post` | New comment posted | `$comment_id`, `$approved` |
|
|
21
|
+
| `edit_comment` | Comment edited | `$comment_id` |
|
|
22
|
+
| `wp_set_comment_status` | Status changed (approve/spam/trash) | `$comment_id`, `$status` |
|
|
23
|
+
| `delete_comment` | Comment deleted | `$comment_id` |
|
|
24
|
+
|
|
25
|
+
### Plugin & Theme Actions
|
|
26
|
+
|
|
27
|
+
| Hook | Fires When | Key Parameters |
|
|
28
|
+
|------|------------|----------------|
|
|
29
|
+
| `activated_plugin` | Plugin activated | `$plugin`, `$network_wide` |
|
|
30
|
+
| `deactivated_plugin` | Plugin deactivated | `$plugin` |
|
|
31
|
+
| `upgrader_process_complete` | Update completed | `$upgrader`, `$options` |
|
|
32
|
+
| `switch_theme` | Theme switched | `$new_name`, `$new_theme` |
|
|
33
|
+
|
|
34
|
+
### System Actions
|
|
35
|
+
|
|
36
|
+
| Hook | Fires When | Key Parameters |
|
|
37
|
+
|------|------------|----------------|
|
|
38
|
+
| `wp_mail_failed` | Email delivery failed | `$wp_error` |
|
|
39
|
+
| `recovery_mode_email_sent` | Recovery mode triggered | — |
|
|
40
|
+
| `wp_privacy_personal_data_export_file_created` | GDPR export ready | `$archive_pathname` |
|
|
41
|
+
|
|
42
|
+
## WooCommerce Action Hooks
|
|
43
|
+
|
|
44
|
+
| Hook | Fires When | Key Parameters |
|
|
45
|
+
|------|------------|----------------|
|
|
46
|
+
| `woocommerce_new_order` | New order placed | `$order_id` |
|
|
47
|
+
| `woocommerce_order_status_changed` | Order status transition | `$order_id`, `$old_status`, `$new_status` |
|
|
48
|
+
| `woocommerce_payment_complete` | Payment received | `$order_id` |
|
|
49
|
+
| `woocommerce_order_refunded` | Order refunded | `$order_id`, `$refund_id` |
|
|
50
|
+
| `woocommerce_low_stock` | Product low stock | `$product` |
|
|
51
|
+
| `woocommerce_no_stock` | Product out of stock | `$product` |
|
|
52
|
+
| `woocommerce_new_customer_note` | Customer note added | `$args` |
|
|
53
|
+
|
|
54
|
+
### Trigger Config Example (WooCommerce)
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"type": "action_hook",
|
|
59
|
+
"event": "woocommerce_order_status_changed",
|
|
60
|
+
"condition": "new_status == 'completed'",
|
|
61
|
+
"actions": [
|
|
62
|
+
{ "channel": "slack", "message": ":package: Order #{{order_id}} completed — {{order_total}}" },
|
|
63
|
+
{ "channel": "email", "to": "fulfillment@example.com", "subject": "Order #{{order_id}} ready for shipping" }
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Filter Hooks for Content Transformation
|
|
69
|
+
|
|
70
|
+
Filters modify data before saving or displaying. Use for content transformation workflows:
|
|
71
|
+
|
|
72
|
+
| Filter | Purpose | Parameters |
|
|
73
|
+
|--------|---------|------------|
|
|
74
|
+
| `wp_insert_post_data` | Modify post before save | `$data`, `$postarr` |
|
|
75
|
+
| `the_content` | Transform content on display | `$content` |
|
|
76
|
+
| `wp_handle_upload_prefilter` | Validate uploads before processing | `$file` |
|
|
77
|
+
| `comment_text` | Transform comment text on display | `$comment_text` |
|
|
78
|
+
|
|
79
|
+
**Note:** Filter-based triggers observe data flow but should not block it. Use filters for logging and auditing, not for heavy action dispatch.
|
|
80
|
+
|
|
81
|
+
## Hook Priority and Execution Order
|
|
82
|
+
|
|
83
|
+
```php
|
|
84
|
+
// Default priority is 10. Lower = earlier execution.
|
|
85
|
+
add_action('user_register', 'workflow_on_register', 20); // Fires after core handlers
|
|
86
|
+
add_action('user_register', 'audit_log_register', 5); // Fires before most handlers
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
- Use priority `20+` for workflow triggers to ensure core WordPress operations complete first
|
|
90
|
+
- Avoid priority `1` unless the trigger must run before all other handlers
|
|
91
|
+
|
|
92
|
+
## Example: Email Admin on New User Registration
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"name": "New User Registration Alert",
|
|
97
|
+
"type": "action_hook",
|
|
98
|
+
"event": "user_register",
|
|
99
|
+
"actions": [
|
|
100
|
+
{
|
|
101
|
+
"channel": "email",
|
|
102
|
+
"to": "admin@example.com",
|
|
103
|
+
"subject": "New user registered: {{user_name}}",
|
|
104
|
+
"body": "A new user ({{user_email}}) registered on {{site_url}} at {{timestamp}}.",
|
|
105
|
+
"template": "new_user_alert"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"channel": "slack",
|
|
109
|
+
"message": ":bust_in_silhouette: New user: *{{user_name}}* ({{user_email}})"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"status": "active"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* workflow_inspect.mjs — Detect workflow automation configuration readiness.
|
|
3
|
+
*
|
|
4
|
+
* Checks WP_SITES_CONFIG for Slack/SendGrid/Mailchimp credentials.
|
|
5
|
+
* Scans for automation plugins, custom REST endpoints, WP-Cron config,
|
|
6
|
+
* and webhook setup.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* node workflow_inspect.mjs [--cwd=/path/to/project]
|
|
10
|
+
*
|
|
11
|
+
* Exit codes:
|
|
12
|
+
* 0 — workflow configuration found
|
|
13
|
+
* 1 — no workflow configuration found
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { readFileSync, existsSync, readdirSync } from 'node:fs';
|
|
17
|
+
import { join, resolve } from 'node:path';
|
|
18
|
+
import { argv, stdout, exit } from 'node:process';
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Helpers
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
function readFileSafe(filePath) {
|
|
25
|
+
try { return readFileSync(filePath, 'utf-8'); } catch { return null; }
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function existsSafe(filePath) {
|
|
29
|
+
try { return existsSync(filePath); } catch { return false; }
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function globDir(dirPath) {
|
|
33
|
+
try { return readdirSync(dirPath); } catch { return []; }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Detectors
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
function detectActionChannelConfig() {
|
|
41
|
+
const channels = { configured: false, indicators: [], missing: [] };
|
|
42
|
+
const raw = process.env.WP_SITES_CONFIG;
|
|
43
|
+
if (!raw) { channels.missing.push('WP_SITES_CONFIG env var not set'); return channels; }
|
|
44
|
+
|
|
45
|
+
let sites;
|
|
46
|
+
try { sites = JSON.parse(raw); } catch { channels.missing.push('WP_SITES_CONFIG is not valid JSON'); return channels; }
|
|
47
|
+
if (!Array.isArray(sites)) { channels.missing.push('WP_SITES_CONFIG is not an array'); return channels; }
|
|
48
|
+
|
|
49
|
+
const keys = ['slack_webhook_url', 'slack_bot_token', 'sendgrid_api_key', 'mailchimp_api_key'];
|
|
50
|
+
|
|
51
|
+
for (const site of sites) {
|
|
52
|
+
const label = site.id || site.url || 'unknown';
|
|
53
|
+
for (const key of keys) {
|
|
54
|
+
if (site[key]) {
|
|
55
|
+
channels.configured = true;
|
|
56
|
+
channels.indicators.push(`${key} configured for ${label}`);
|
|
57
|
+
} else {
|
|
58
|
+
channels.missing.push(`${key} not set for ${label}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return channels;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function detectAutomationPlugins(cwd) {
|
|
66
|
+
const result = { found: false, indicators: [], recommendations: [] };
|
|
67
|
+
const pluginsDir = join(cwd, 'wp-content', 'plugins');
|
|
68
|
+
const plugins = globDir(pluginsDir);
|
|
69
|
+
|
|
70
|
+
const automationPlugins = [
|
|
71
|
+
'automatewoo',
|
|
72
|
+
'wp-fusion',
|
|
73
|
+
'fluent-crm',
|
|
74
|
+
'suretriggers',
|
|
75
|
+
'wp-crontrol',
|
|
76
|
+
'advanced-cron-manager',
|
|
77
|
+
'advanced-cron-manager-pro',
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
for (const plugin of automationPlugins) {
|
|
81
|
+
if (plugins.includes(plugin)) {
|
|
82
|
+
result.found = true;
|
|
83
|
+
result.indicators.push(`plugin: ${plugin}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (!result.found) {
|
|
88
|
+
result.recommendations.push('Install wp-crontrol for cron event management');
|
|
89
|
+
result.recommendations.push('Consider FluentCRM or AutomateWoo for advanced workflows');
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function detectCustomRestEndpoints(cwd) {
|
|
95
|
+
const rest = { found: false, indicators: [] };
|
|
96
|
+
|
|
97
|
+
// Look for wp-manager workflow namespace in plugin/theme files
|
|
98
|
+
const muPluginsDir = join(cwd, 'wp-content', 'mu-plugins');
|
|
99
|
+
const pluginsDir = join(cwd, 'wp-content', 'plugins');
|
|
100
|
+
const themeDir = join(cwd, 'wp-content', 'themes');
|
|
101
|
+
|
|
102
|
+
const searchDirs = [muPluginsDir, pluginsDir, themeDir];
|
|
103
|
+
const pattern = /register_rest_route\s*\(\s*['"]wp-manager\/v1\/workflows['"]/;
|
|
104
|
+
|
|
105
|
+
for (const dir of searchDirs) {
|
|
106
|
+
const files = globDir(dir);
|
|
107
|
+
for (const file of files) {
|
|
108
|
+
const filePath = join(dir, file);
|
|
109
|
+
if (file.endsWith('.php')) {
|
|
110
|
+
const content = readFileSafe(filePath);
|
|
111
|
+
if (content && pattern.test(content)) {
|
|
112
|
+
rest.found = true;
|
|
113
|
+
rest.indicators.push(`REST endpoint in ${filePath}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return rest;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function detectWpCronConfig(cwd) {
|
|
122
|
+
const cron = { disabled: false, alternate: false, indicators: [], recommendations: [] };
|
|
123
|
+
|
|
124
|
+
const wpConfig = readFileSafe(join(cwd, 'wp-config.php'));
|
|
125
|
+
if (!wpConfig) {
|
|
126
|
+
cron.recommendations.push('wp-config.php not found — cannot check cron config');
|
|
127
|
+
return cron;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (/define\s*\(\s*['"]DISABLE_WP_CRON['"]\s*,\s*true\s*\)/i.test(wpConfig)) {
|
|
131
|
+
cron.disabled = true;
|
|
132
|
+
cron.indicators.push('DISABLE_WP_CRON is true — server-side cron expected');
|
|
133
|
+
}
|
|
134
|
+
if (/define\s*\(\s*['"]ALTERNATE_WP_CRON['"]\s*,\s*true\s*\)/i.test(wpConfig)) {
|
|
135
|
+
cron.alternate = true;
|
|
136
|
+
cron.indicators.push('ALTERNATE_WP_CRON is true — redirect-based cron active');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const cronPath = join(cwd, 'wp-cron.php');
|
|
140
|
+
if (existsSafe(cronPath)) {
|
|
141
|
+
cron.indicators.push('wp-cron.php found');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (cron.disabled) {
|
|
145
|
+
cron.recommendations.push('Ensure server cron job calls wp-cron.php for scheduled triggers');
|
|
146
|
+
}
|
|
147
|
+
return cron;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function detectWebhookConfig() {
|
|
151
|
+
const webhooks = { configured: false, indicators: [] };
|
|
152
|
+
const raw = process.env.WP_SITES_CONFIG;
|
|
153
|
+
if (!raw) return webhooks;
|
|
154
|
+
|
|
155
|
+
let sites;
|
|
156
|
+
try { sites = JSON.parse(raw); } catch { return webhooks; }
|
|
157
|
+
if (!Array.isArray(sites)) return webhooks;
|
|
158
|
+
|
|
159
|
+
for (const site of sites) {
|
|
160
|
+
const label = site.id || site.url || 'unknown';
|
|
161
|
+
if (site.wc_webhook_secret || site.webhook_secret) {
|
|
162
|
+
webhooks.configured = true;
|
|
163
|
+
webhooks.indicators.push(`webhook secret configured for ${label}`);
|
|
164
|
+
}
|
|
165
|
+
if (site.url) {
|
|
166
|
+
webhooks.indicators.push(`site URL available for ${label} — wc-webhooks tools can be used`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return webhooks;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// ---------------------------------------------------------------------------
|
|
173
|
+
// Main
|
|
174
|
+
// ---------------------------------------------------------------------------
|
|
175
|
+
|
|
176
|
+
function main() {
|
|
177
|
+
const cwdArg = argv.find(a => a.startsWith('--cwd='));
|
|
178
|
+
const cwd = cwdArg ? resolve(cwdArg.split('=')[1]) : process.cwd();
|
|
179
|
+
|
|
180
|
+
const channels = detectActionChannelConfig();
|
|
181
|
+
const plugins = detectAutomationPlugins(cwd);
|
|
182
|
+
const rest = detectCustomRestEndpoints(cwd);
|
|
183
|
+
const cron = detectWpCronConfig(cwd);
|
|
184
|
+
const webhooks = detectWebhookConfig();
|
|
185
|
+
|
|
186
|
+
const anyConfigured = channels.configured || plugins.found || rest.found || webhooks.configured || cron.indicators.length > 0;
|
|
187
|
+
|
|
188
|
+
const report = {
|
|
189
|
+
workflow_configured: anyConfigured,
|
|
190
|
+
action_channels: channels,
|
|
191
|
+
automation_plugins: plugins,
|
|
192
|
+
custom_rest_endpoints: rest,
|
|
193
|
+
wp_cron: cron,
|
|
194
|
+
webhooks,
|
|
195
|
+
cwd,
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
stdout.write(JSON.stringify(report, null, 2) + '\n');
|
|
199
|
+
exit(anyConfigured ? 0 : 1);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
main();
|
|
@@ -130,3 +130,5 @@ See `references/fleet-monitoring.md`
|
|
|
130
130
|
- **`wp-performance`** — optimization actions based on performance trends
|
|
131
131
|
- **`wp-cicd`** — CI/CD quality gates that complement monitoring (pre-deploy checks)
|
|
132
132
|
- **`wp-search-console`** — add GSC search performance checks to periodic SEO monitoring
|
|
133
|
+
- **`wp-alerting`** — severity-based alert routing (Slack + email) for monitoring findings
|
|
134
|
+
- **`wp-analytics`** — analytics data used in performance dashboards and threshold evaluation
|
|
@@ -119,3 +119,4 @@ Use the **`wp-content-strategist`** agent for SEO feedback loops and content opt
|
|
|
119
119
|
- **`wp-social-email`** — distribute optimized content across social and email channels
|
|
120
120
|
- **`wp-content`** — create and manage WordPress content informed by search analytics
|
|
121
121
|
- **`wp-content-optimization`** — use GSC data as input for AI-driven content optimization and triage
|
|
122
|
+
- Per correlare keyword GSC con traffico GA4, vedi `wp-analytics`
|
|
@@ -150,3 +150,4 @@ Use the **`wp-distribution-manager`** agent for complex multi-channel distributi
|
|
|
150
150
|
- **`wp-webhooks`** — trigger distribution on WordPress events (publish, update)
|
|
151
151
|
- **`wp-content`** — create and manage WordPress content for distribution
|
|
152
152
|
- **`wp-content-attribution`** — track content sources and attribution across channels
|
|
153
|
+
- **`wp-content-workflows`** — automate distribution via workflow triggers (schedule, content lifecycle, hooks)
|
|
@@ -106,3 +106,4 @@ See `references/payload-formats.md`
|
|
|
106
106
|
- **`wp-woocommerce`** — WooCommerce store operations (webhook source events)
|
|
107
107
|
- **`wp-cicd`** — CI/CD webhooks for deployment triggers
|
|
108
108
|
- **wp-social-email** — direct publishing to social/email (alternative to webhook-based distribution)
|
|
109
|
+
- **`wp-content-workflows`** — workflow triggers that can fire webhook actions on WordPress events
|