wordpress-agent-kit 0.2.1
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/.github/agents/wp-architect.agent.md +42 -0
- package/.github/copilot-instructions.md +2 -0
- package/.github/instructions/wordpress-workflow.instructions.md +41 -0
- package/.github/prompts/plan-smartDetectionSetup.prompt.md +189 -0
- package/.github/skills/wordpress-router/SKILL.md +51 -0
- package/.github/skills/wordpress-router/references/decision-tree.md +55 -0
- package/.github/skills/wp-abilities-api/SKILL.md +95 -0
- package/.github/skills/wp-abilities-api/references/php-registration.md +67 -0
- package/.github/skills/wp-abilities-api/references/rest-api.md +13 -0
- package/.github/skills/wp-block-development/SKILL.md +174 -0
- package/.github/skills/wp-block-development/references/attributes-and-serialization.md +22 -0
- package/.github/skills/wp-block-development/references/block-json.md +49 -0
- package/.github/skills/wp-block-development/references/creating-new-blocks.md +46 -0
- package/.github/skills/wp-block-development/references/debugging.md +36 -0
- package/.github/skills/wp-block-development/references/deprecations.md +24 -0
- package/.github/skills/wp-block-development/references/dynamic-rendering.md +23 -0
- package/.github/skills/wp-block-development/references/inner-blocks.md +25 -0
- package/.github/skills/wp-block-development/references/registration.md +30 -0
- package/.github/skills/wp-block-development/references/supports-and-wrappers.md +18 -0
- package/.github/skills/wp-block-development/references/tooling-and-testing.md +21 -0
- package/.github/skills/wp-block-development/scripts/list_blocks.mjs +121 -0
- package/.github/skills/wp-block-themes/SKILL.md +116 -0
- package/.github/skills/wp-block-themes/references/creating-new-block-theme.md +37 -0
- package/.github/skills/wp-block-themes/references/debugging.md +24 -0
- package/.github/skills/wp-block-themes/references/patterns.md +18 -0
- package/.github/skills/wp-block-themes/references/style-variations.md +14 -0
- package/.github/skills/wp-block-themes/references/templates-and-parts.md +16 -0
- package/.github/skills/wp-block-themes/references/theme-json.md +59 -0
- package/.github/skills/wp-block-themes/scripts/detect_block_themes.mjs +117 -0
- package/.github/skills/wp-interactivity-api/SKILL.md +179 -0
- package/.github/skills/wp-interactivity-api/references/debugging.md +29 -0
- package/.github/skills/wp-interactivity-api/references/directives-quickref.md +30 -0
- package/.github/skills/wp-interactivity-api/references/server-side-rendering.md +310 -0
- package/.github/skills/wp-performance/SKILL.md +146 -0
- package/.github/skills/wp-performance/references/autoload-options.md +24 -0
- package/.github/skills/wp-performance/references/cron.md +20 -0
- package/.github/skills/wp-performance/references/database.md +20 -0
- package/.github/skills/wp-performance/references/http-api.md +15 -0
- package/.github/skills/wp-performance/references/measurement.md +21 -0
- package/.github/skills/wp-performance/references/object-cache.md +24 -0
- package/.github/skills/wp-performance/references/query-monitor-headless.md +38 -0
- package/.github/skills/wp-performance/references/server-timing.md +22 -0
- package/.github/skills/wp-performance/references/wp-cli-doctor.md +24 -0
- package/.github/skills/wp-performance/references/wp-cli-profile.md +32 -0
- package/.github/skills/wp-performance/scripts/perf_inspect.mjs +128 -0
- package/.github/skills/wp-phpstan/SKILL.md +97 -0
- package/.github/skills/wp-phpstan/references/configuration.md +52 -0
- package/.github/skills/wp-phpstan/references/third-party-classes.md +76 -0
- package/.github/skills/wp-phpstan/references/wordpress-annotations.md +124 -0
- package/.github/skills/wp-phpstan/scripts/phpstan_inspect.mjs +263 -0
- package/.github/skills/wp-playground/SKILL.md +101 -0
- package/.github/skills/wp-playground/references/blueprints.md +36 -0
- package/.github/skills/wp-playground/references/cli-commands.md +39 -0
- package/.github/skills/wp-playground/references/debugging.md +16 -0
- package/.github/skills/wp-plugin-development/SKILL.md +112 -0
- package/.github/skills/wp-plugin-development/references/data-and-cron.md +19 -0
- package/.github/skills/wp-plugin-development/references/debugging.md +19 -0
- package/.github/skills/wp-plugin-development/references/lifecycle.md +33 -0
- package/.github/skills/wp-plugin-development/references/security.md +29 -0
- package/.github/skills/wp-plugin-development/references/settings-api.md +22 -0
- package/.github/skills/wp-plugin-development/references/structure.md +16 -0
- package/.github/skills/wp-plugin-development/scripts/detect_plugins.mjs +122 -0
- package/.github/skills/wp-project-triage/SKILL.md +38 -0
- package/.github/skills/wp-project-triage/references/triage.schema.json +143 -0
- package/.github/skills/wp-project-triage/scripts/detect_wp_project.mjs +592 -0
- package/.github/skills/wp-rest-api/SKILL.md +114 -0
- package/.github/skills/wp-rest-api/references/authentication.md +18 -0
- package/.github/skills/wp-rest-api/references/custom-content-types.md +20 -0
- package/.github/skills/wp-rest-api/references/discovery-and-params.md +20 -0
- package/.github/skills/wp-rest-api/references/responses-and-fields.md +30 -0
- package/.github/skills/wp-rest-api/references/routes-and-endpoints.md +36 -0
- package/.github/skills/wp-rest-api/references/schema.md +22 -0
- package/.github/skills/wp-wpcli-and-ops/SKILL.md +123 -0
- package/.github/skills/wp-wpcli-and-ops/references/automation.md +30 -0
- package/.github/skills/wp-wpcli-and-ops/references/cron-and-cache.md +23 -0
- package/.github/skills/wp-wpcli-and-ops/references/debugging.md +17 -0
- package/.github/skills/wp-wpcli-and-ops/references/multisite.md +22 -0
- package/.github/skills/wp-wpcli-and-ops/references/packages-and-updates.md +22 -0
- package/.github/skills/wp-wpcli-and-ops/references/safety.md +30 -0
- package/.github/skills/wp-wpcli-and-ops/references/search-replace.md +40 -0
- package/.github/skills/wp-wpcli-and-ops/scripts/wpcli_inspect.mjs +90 -0
- package/.github/skills/wpds/SKILL.md +58 -0
- package/AGENTS.md +39 -0
- package/AGENTS.template.md +31 -0
- package/LICENSE +342 -0
- package/README.md +118 -0
- package/dist/cli.js +19 -0
- package/dist/commands/install.js +27 -0
- package/dist/commands/run-playground.js +28 -0
- package/dist/commands/setup.js +237 -0
- package/dist/commands/sync-skills.js +70 -0
- package/dist/lib/installer.js +56 -0
- package/dist/lib/triage-mapper.js +98 -0
- package/dist/utils/paths.js +12 -0
- package/dist/utils/run.js +20 -0
- package/package.json +55 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: WordPress Architect
|
|
3
|
+
description: Expert developer that orchestrates Agent Skills, official Handbooks, and project-specific instructions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Role
|
|
7
|
+
|
|
8
|
+
You are the **WordPress Architect**. Your purpose is to build secure, scalable, and standards-compliant WordPress solutions by strictly following the project's specialized intelligence hierarchy.
|
|
9
|
+
|
|
10
|
+
# Information Hierarchy (Strict Order)
|
|
11
|
+
|
|
12
|
+
When a task is assigned, you must retrieve information in this sequence:
|
|
13
|
+
|
|
14
|
+
1. **Local Project Instructions**: Read `.github/instructions/wordpress-workflow.instructions.md` to understand the specific prefix, folder structure, and dev workflow for this repo.
|
|
15
|
+
|
|
16
|
+
2. **Agent Skills**: Consult the `.github/skills/` directory.
|
|
17
|
+
|
|
18
|
+
- Reference `wp-project-triage` to confirm if you are in a Plugin or Theme context.
|
|
19
|
+
- Reference `wp-block-development` for any Gutenberg/React tasks.
|
|
20
|
+
- Reference `wp-playground` to provide testable blueprints for your code.
|
|
21
|
+
|
|
22
|
+
3. **Official Manuals**: If local skills are insufficient, use the [WordPress Developer Handbooks](https://developer.wordpress.org) (Plugin, Theme, or Block Editor).
|
|
23
|
+
|
|
24
|
+
4. **Community Knowledge**: Use [WordPress Stack Exchange](https://wordpress.stackexchange.com) only as a final fallback for edge cases or legacy bugs.
|
|
25
|
+
|
|
26
|
+
# Technical Requirements
|
|
27
|
+
|
|
28
|
+
- **Standards**: Adhere strictly to [WordPress PHP Coding Standards](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/) (e.g., tabs for indentation, Yoda conditions).
|
|
29
|
+
|
|
30
|
+
- **Security**: Mandatory data validation on input (sanitization) and late-escaping on output (`esc_html`, `esc_attr`, `wp_kses`, etc.). Use nonces for all state-changing actions.
|
|
31
|
+
|
|
32
|
+
- **Hooks**: Always prefer the Plugin API (Actions/Filters) over overriding global variables.
|
|
33
|
+
|
|
34
|
+
- **Modernity**: Default to Block-first patterns and PHP 8.0+ features unless the project triage indicates otherwise.
|
|
35
|
+
|
|
36
|
+
# Response Protocol
|
|
37
|
+
|
|
38
|
+
- **Cite Your Source**: Briefly state which skill or handbook section informed your solution.
|
|
39
|
+
|
|
40
|
+
- **Testability**: Whenever possible, provide a [WordPress Playground](https://playground.wordpress.net) link or JSON blueprint to demonstrate the code.
|
|
41
|
+
|
|
42
|
+
- **Verification**: Cross-check your code against the `AGENTS.md` file in the root directory before finalized output.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
\# WordPress Agent Skills Workflow
|
|
2
|
+
|
|
3
|
+
This repo uses a local, filesystem-based set of WordPress agent skills under `.github/skills/`. Follow these procedures for every interaction.
|
|
4
|
+
|
|
5
|
+
\## 1. Skill Discovery & Activation
|
|
6
|
+
|
|
7
|
+
\- \*\*Always start by scanning \`.github/skills/\`\*\* to see which specialized modules are active.
|
|
8
|
+
|
|
9
|
+
\- If the user asks for a Block, explicitly activate the \`wp-block-development\` skill.
|
|
10
|
+
|
|
11
|
+
\- If the task involves environment setup, use the \`wp-playground\` skill patterns to provide a \`blueprint.json\` or a [Playground link]\(https://playground.wordpress.net).
|
|
12
|
+
|
|
13
|
+
\## 2. Directory Mapping (Triage)
|
|
14
|
+
|
|
15
|
+
Follow the \`wp-project-triage\` skill to identify where to place code:
|
|
16
|
+
|
|
17
|
+
\- \*\*PHP Logic\*\*: Prefer the repo\'s existing structure first. If you\'re introducing structure to a single-file plugin, use \`includes/\` for PHP modules/classes.
|
|
18
|
+
|
|
19
|
+
\- \*\*Blocks/Assets\*\*: Use the \`src/\` directory for development and \`build/\` for compiled assets.
|
|
20
|
+
|
|
21
|
+
\- \*\*Tests\*\*: Locate existing tests in \`tests/phpunit/\` or \`tests/pest/\` before writing new ones.
|
|
22
|
+
|
|
23
|
+
\## 3. Mandatory Implementation Standards
|
|
24
|
+
|
|
25
|
+
When generating code, you must merge \*\*General Skills\*\* with \*\*Project Rules\*\*:
|
|
26
|
+
|
|
27
|
+
\- \*\*Hooks\*\*: Use the \`wordpress-router\` skill logic to determine if a hook belongs in \`init\`, \`admin_init\`, or \`wp_enqueue_scripts\`.
|
|
28
|
+
|
|
29
|
+
\- \*\*Naming\*\*: Prefix all PHP functions and classes with the existing project prefix (determine it from the codebase during triage). If there is no established prefix, pick one and apply it consistently.
|
|
30
|
+
|
|
31
|
+
\- \*\*Documentation\*\*: Every function must include a [PHPDoc block]\(https://developer.wordpress.org) as defined in the WordPress Handbook.
|
|
32
|
+
|
|
33
|
+
\## 4. Validation Step
|
|
34
|
+
|
|
35
|
+
Before finalizing a response:
|
|
36
|
+
|
|
37
|
+
1\. Cross-reference the code against the WordPress PHP Coding Standards (and keep indentation consistent with the existing file).
|
|
38
|
+
|
|
39
|
+
2\. Check if a [WordPress.org Plugin Handbook]\(https://developer.wordpress.org) rule supersedes a generic community pattern.
|
|
40
|
+
|
|
41
|
+
3\. State which skill was used (e.g., \*"Applied patterns from wp-block-development"\*).
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Plan: Smart Detection-First Setup Flow
|
|
2
|
+
|
|
3
|
+
Run triage before asking ANY questions. Only prompt when detection is unclear or user wants to override. Add "Not sure" options everywhere.
|
|
4
|
+
|
|
5
|
+
**TL;DR:** Flip the current flow - detect first, ask later. The script becomes intelligent: if it confidently detects your project type and tech stack, it just shows you what it found and asks for confirmation. Only falls back to questions if needed. Makes setup feel magical instead of interrogative.
|
|
6
|
+
|
|
7
|
+
**Key Changes from Current:**
|
|
8
|
+
|
|
9
|
+
Current: Ask → Run triage → Customize
|
|
10
|
+
**New:** Run triage → Show detection → Confirm or Override → Customize
|
|
11
|
+
|
|
12
|
+
## Steps
|
|
13
|
+
|
|
14
|
+
### 1. Restructure main flow in scripts/setup.mjs
|
|
15
|
+
|
|
16
|
+
- Move triage execution to run BEFORE any project questions (currently line 113)
|
|
17
|
+
- Place it right after kit installation check (after line 73)
|
|
18
|
+
- Actually call real triage script: `vendor/wp-agent-skills/skills/wp-project-triage/scripts/detect_wp_project.mjs`
|
|
19
|
+
- Parse JSON output into `triageResult` object
|
|
20
|
+
|
|
21
|
+
### 2. Create detection mapper
|
|
22
|
+
|
|
23
|
+
Map `triageResult.project.primary` to setup's project type options:
|
|
24
|
+
- `wp-block-theme` → `block-theme`
|
|
25
|
+
- `wp-block-plugin` → `blocks`
|
|
26
|
+
- `wp-plugin` → `plugin`
|
|
27
|
+
- `wp-theme` → `theme`
|
|
28
|
+
- `wp-site` → `site`
|
|
29
|
+
|
|
30
|
+
Map `triageResult.signals.*` to tech stack:
|
|
31
|
+
- `blockJsonFiles.length > 0` → add `gutenberg`
|
|
32
|
+
- `usesInteractivityApi` → add `interactivity`
|
|
33
|
+
- `hasRestEndpoints` → add `rest-api`
|
|
34
|
+
- `hasWpCliCommands` → add `wpcli`
|
|
35
|
+
|
|
36
|
+
Map `triageResult.tooling.*`:
|
|
37
|
+
- `tooling.php.hasComposerJson` → add `composer`
|
|
38
|
+
- `tooling.node.packageManager` → add `npm`
|
|
39
|
+
- `tooling.php.hasPhpStan` → add `phpstan`
|
|
40
|
+
- `signals.hasPlaygroundBlueprint` → add `playground`
|
|
41
|
+
|
|
42
|
+
### 3. Add confidence check and smart prompting
|
|
43
|
+
|
|
44
|
+
If `detectedType` exists AND `detectedTech` has items:
|
|
45
|
+
- Show `p.note()` with detected values in nice format
|
|
46
|
+
- Single confirm: "Use these detected values? (y/n)"
|
|
47
|
+
- If yes → skip all questions, use detected values
|
|
48
|
+
- If no → proceed to manual questions with detected values as defaults
|
|
49
|
+
|
|
50
|
+
If detection fails or finds nothing:
|
|
51
|
+
- Proceed directly to manual questions (no confirmation prompt)
|
|
52
|
+
|
|
53
|
+
### 4. Enhance question options
|
|
54
|
+
|
|
55
|
+
Add to project type select:
|
|
56
|
+
```javascript
|
|
57
|
+
{ value: 'unsure', label: "I'm not sure" }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Update tech stack message:
|
|
61
|
+
- Change "Select technologies used" → "Select technologies (or skip if unsure):"
|
|
62
|
+
|
|
63
|
+
Add `initialValue` / `initialValues` to all prompts:
|
|
64
|
+
- Use detected values if available
|
|
65
|
+
- Undefined otherwise (no pre-selection)
|
|
66
|
+
|
|
67
|
+
### 5. Remove redundant triage prompt
|
|
68
|
+
|
|
69
|
+
- Delete the old "Run project triage?" question (currently in `p.group` after techStack)
|
|
70
|
+
- Triage now always runs automatically
|
|
71
|
+
- Include graceful fallback if triage script missing/fails
|
|
72
|
+
|
|
73
|
+
### 6. Handle edge cases
|
|
74
|
+
|
|
75
|
+
- Wrap triage in try/catch - if fails, show "Auto-detection unavailable" and continue
|
|
76
|
+
- Check if triage script exists before attempting to run
|
|
77
|
+
- If user selects "I'm not sure" for type → default to `other` for AGENTS.md generation
|
|
78
|
+
- If tech stack is empty → generate minimal AGENTS.md with generic setup
|
|
79
|
+
|
|
80
|
+
## Verification
|
|
81
|
+
|
|
82
|
+
**Test detection works:**
|
|
83
|
+
```bash
|
|
84
|
+
# Should auto-detect and only confirm:
|
|
85
|
+
cd test-block-plugin
|
|
86
|
+
npm run setup
|
|
87
|
+
|
|
88
|
+
# Should detect partially and pre-fill:
|
|
89
|
+
cd test-theme-with-composer
|
|
90
|
+
npm run setup
|
|
91
|
+
|
|
92
|
+
# Should fall back to questions:
|
|
93
|
+
cd empty-directory
|
|
94
|
+
npm run setup
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Expected UX:**
|
|
98
|
+
- Fast projects (has clear WP structure): 1 confirmation prompt only
|
|
99
|
+
- Ambiguous projects: Questions with smart defaults pre-selected
|
|
100
|
+
- Empty/new projects: All questions, no pre-selection
|
|
101
|
+
|
|
102
|
+
## Decisions
|
|
103
|
+
|
|
104
|
+
**Decision: Triage runs unconditionally**
|
|
105
|
+
- Always attempt triage before questions
|
|
106
|
+
- Graceful degradation: if fails → proceed with questions
|
|
107
|
+
- User never sees errors, just "detection unavailable"
|
|
108
|
+
|
|
109
|
+
**Decision: Single confirmation vs detailed review**
|
|
110
|
+
- Chose: Single yes/no confirm on detection
|
|
111
|
+
- Alternative considered: Show detection, then let user edit each field
|
|
112
|
+
- Reasoning: Faster UX, user can override by saying "no"
|
|
113
|
+
|
|
114
|
+
**Decision: "I'm not sure" is an option, not required**
|
|
115
|
+
- Some users want to explore options
|
|
116
|
+
- Others know nothing about their project
|
|
117
|
+
- Giving them an explicit "unsure" choice prevents wrong guesses
|
|
118
|
+
|
|
119
|
+
**Decision: Keep tech stack optional**
|
|
120
|
+
- `required: false` stays
|
|
121
|
+
- Empty array is valid (means "detect later" or "none yet")
|
|
122
|
+
- AGENTS.md can still generate with minimal tech
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Phase 2: AI Enhancement Layer (Future)
|
|
127
|
+
|
|
128
|
+
### Optional Local AI for Natural Language Explanations
|
|
129
|
+
|
|
130
|
+
**Options:**
|
|
131
|
+
- **Transformers.js** (Xenova/transformers.js) - Runs ONNX models in Node
|
|
132
|
+
- **llama.cpp via llama-node** - Tiny local models (Phi-3.5-mini, TinyLlama)
|
|
133
|
+
- **Recommended:** Phi-3.5-mini-instruct (3.8B quantized → ~2GB) via llama.cpp
|
|
134
|
+
|
|
135
|
+
**Use Cases:**
|
|
136
|
+
- Convert triage JSON → friendly paragraph: "I detected a WordPress block plugin with Interactivity API usage across 3 blocks..."
|
|
137
|
+
- Explain recommendations: "I suggest adding PHPStan because..."
|
|
138
|
+
- Answer simple Q&A during setup
|
|
139
|
+
|
|
140
|
+
**Implementation:**
|
|
141
|
+
- New module: `scripts/lib/ai-explainer.mjs`
|
|
142
|
+
- Lazy-load model (only if user opts in with env var: `AI_EXPLAIN=1`)
|
|
143
|
+
- Fallback to templates if model loading fails
|
|
144
|
+
- Keep deterministic as default, AI as opt-in enhancement
|
|
145
|
+
|
|
146
|
+
**Interactive Q&A:**
|
|
147
|
+
- After showing recommendations, offer: "Have questions? (y/n)"
|
|
148
|
+
- Simple REPL-style Q&A using RAG over skill files
|
|
149
|
+
- Knowledge sources: All SKILL.md files + references
|
|
150
|
+
- Exit Q&A → continue setup
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Architecture Philosophy
|
|
155
|
+
|
|
156
|
+
**Core Principle:** Deterministic first, AI is additive
|
|
157
|
+
|
|
158
|
+
**Phase 1 (Implement Now):**
|
|
159
|
+
- Zero new dependencies
|
|
160
|
+
- Works offline
|
|
161
|
+
- Fast execution (< 5 seconds typical)
|
|
162
|
+
- Smart use of structured triage data
|
|
163
|
+
|
|
164
|
+
**Phase 2 (Optional Future):**
|
|
165
|
+
- Feature flag: `AI_EXPLAIN=1`
|
|
166
|
+
- Lazy-loaded AI models
|
|
167
|
+
- Graceful degradation always
|
|
168
|
+
- No cloud APIs, all local
|
|
169
|
+
|
|
170
|
+
**Aligns with project principles:**
|
|
171
|
+
- Prefer deterministic checks (see vendor/wp-agent-skills/docs/principles.md)
|
|
172
|
+
- Filesystem-based intelligence
|
|
173
|
+
- No "agent guesswork"
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## Implementation Checklist
|
|
178
|
+
|
|
179
|
+
- [x] Create new branch: `feature/smart-detection`
|
|
180
|
+
- [x] Step 1: Restructure flow, call real triage
|
|
181
|
+
- [x] Step 2: Implement detection mapper
|
|
182
|
+
- [x] Step 3: Add confidence check and smart prompting
|
|
183
|
+
- [x] Step 4: Enhance question options with "unsure"
|
|
184
|
+
- [x] Step 5: Remove redundant triage question
|
|
185
|
+
- [x] Step 6: Add error handling for edge cases
|
|
186
|
+
- [x] Test on multiple project types
|
|
187
|
+
- [x] Document new behavior in README
|
|
188
|
+
- [x] Optional: Create lib/triage-mapper.mjs module for clean separation
|
|
189
|
+
- [x] Optional: Create lib/agents-generator.mjs for template-based AGENTS.md generation
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wordpress-router
|
|
3
|
+
description: "Use when the user asks about WordPress codebases (plugins, themes, block themes, Gutenberg blocks, WP core checkouts) and you need to quickly classify the repo and route to the correct workflow/skill (blocks, theme.json, REST API, WP-CLI, performance, security, testing, release packaging)."
|
|
4
|
+
compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# WordPress Router
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
Use this skill at the start of most WordPress tasks to:
|
|
12
|
+
|
|
13
|
+
- identify what kind of WordPress codebase this is (plugin vs theme vs block theme vs WP core checkout vs full site),
|
|
14
|
+
- pick the right workflow and guardrails,
|
|
15
|
+
- delegate to the most relevant domain skill(s).
|
|
16
|
+
|
|
17
|
+
## Inputs required
|
|
18
|
+
|
|
19
|
+
- Repo root (current working directory).
|
|
20
|
+
- The user’s intent (what they want changed) and any constraints (WP version targets, WP.com specifics, release requirements).
|
|
21
|
+
|
|
22
|
+
## Procedure
|
|
23
|
+
|
|
24
|
+
1. Run the project triage script:
|
|
25
|
+
- `node skills/wp-project-triage/scripts/detect_wp_project.mjs`
|
|
26
|
+
2. Read the triage output and classify:
|
|
27
|
+
- primary project kind(s),
|
|
28
|
+
- tooling available (PHP/Composer, Node, @wordpress/scripts),
|
|
29
|
+
- tests present (PHPUnit, Playwright, wp-env),
|
|
30
|
+
- any version hints.
|
|
31
|
+
3. Route to domain workflows based on user intent + repo kind:
|
|
32
|
+
- For the decision tree, read: `skills/wordpress-router/references/decision-tree.md`.
|
|
33
|
+
4. Apply guardrails before making changes:
|
|
34
|
+
- Confirm any version constraints if unclear.
|
|
35
|
+
- Prefer the repo’s existing tooling and conventions for builds/tests.
|
|
36
|
+
|
|
37
|
+
## Verification
|
|
38
|
+
|
|
39
|
+
- Re-run the triage script if you create or restructure significant files.
|
|
40
|
+
- Run the repo’s lint/test/build commands that the triage output recommends (if available).
|
|
41
|
+
|
|
42
|
+
## Failure modes / debugging
|
|
43
|
+
|
|
44
|
+
- If triage reports `kind: unknown`, inspect:
|
|
45
|
+
- root `composer.json`, `package.json`, `style.css`, `block.json`, `theme.json`, `wp-content/`.
|
|
46
|
+
- If the repo is huge, consider narrowing scanning scope or adding ignore rules to the triage script.
|
|
47
|
+
|
|
48
|
+
## Escalation
|
|
49
|
+
|
|
50
|
+
- If routing is ambiguous, ask one question:
|
|
51
|
+
- “Is this intended to be a WordPress plugin, a theme (classic/block), or a full site repo?”
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Router decision tree (v1)
|
|
2
|
+
|
|
3
|
+
This is a lightweight routing guide. It assumes you can run `wp-project-triage` first.
|
|
4
|
+
|
|
5
|
+
## Step 1: classify repo kind (from triage)
|
|
6
|
+
|
|
7
|
+
Use `triage.project.kind` and the strongest signals:
|
|
8
|
+
|
|
9
|
+
- `wp-core` → treat as WordPress core checkout work (core patches, PHPUnit, build tools).
|
|
10
|
+
- `wp-site` → treat as a full site repo (wp-content present; changes might be theme + plugins).
|
|
11
|
+
- `wp-block-theme` → theme.json/templates/patterns workflows.
|
|
12
|
+
- `wp-theme` → classic theme workflows (templates PHP, `functions.php`, `style.css`).
|
|
13
|
+
- `wp-block-plugin` → Gutenberg block development in a plugin (block.json, build pipeline).
|
|
14
|
+
- `wp-plugin` / `wp-mu-plugin` → plugin workflows (hooks, admin, settings, cron, REST, security).
|
|
15
|
+
- `gutenberg` → Gutenberg monorepo workflows (packages, tooling, docs).
|
|
16
|
+
|
|
17
|
+
If multiple kinds match, prefer the most specific:
|
|
18
|
+
`gutenberg` > `wp-core` > `wp-site` > `wp-block-theme` > `wp-block-plugin` > `wp-theme` > `wp-plugin`.
|
|
19
|
+
|
|
20
|
+
## Step 2: route by user intent (keywords)
|
|
21
|
+
|
|
22
|
+
Route by intent even if repo kind is broad (like `wp-site`):
|
|
23
|
+
|
|
24
|
+
- **Interactivity API / data-wp-* directives / @wordpress/interactivity / viewScriptModule**
|
|
25
|
+
- Route → `wp-interactivity-api`.
|
|
26
|
+
- **Abilities API / wp_register_ability / wp-abilities/v1 / @wordpress/abilities**
|
|
27
|
+
- Route → `wp-abilities-api`.
|
|
28
|
+
- **Playground / run-blueprint / build-snapshot / @wp-playground/cli / playground.wordpress.net**
|
|
29
|
+
- Route → `wp-playground`.
|
|
30
|
+
- **Blocks / block.json / registerBlockType / attributes / save serialization**
|
|
31
|
+
- Route → `wp-block-development`.
|
|
32
|
+
- **theme.json / Global Styles / templates/*.html / patterns/**
|
|
33
|
+
- Route → `wp-block-themes`.
|
|
34
|
+
- **Plugins / hooks / activation hook / uninstall / Settings API / admin pages**
|
|
35
|
+
- Route → `wp-plugin-development`.
|
|
36
|
+
- **REST endpoint / register_rest_route / permission_callback**
|
|
37
|
+
- Route → `wp-rest-api`.
|
|
38
|
+
- **WP-CLI / wp-cli.yml / commands**
|
|
39
|
+
- Route → `wp-wpcli-and-ops`.
|
|
40
|
+
- **Build tooling / @wordpress/scripts / webpack / Vite / npm scripts**
|
|
41
|
+
- Route → `wp-build-tooling` (planned).
|
|
42
|
+
- **Testing / PHPUnit / wp-env / Playwright**
|
|
43
|
+
- Route → `wp-testing` (planned).
|
|
44
|
+
- **PHPStan / static analysis / phpstan.neon / phpstan-baseline.neon**
|
|
45
|
+
- Route → `wp-phpstan`.
|
|
46
|
+
- **Performance / caching / query profiling / editor slowness**
|
|
47
|
+
- Route → `wp-performance`.
|
|
48
|
+
- **Security / nonces / capabilities / sanitization/escaping / uploads**
|
|
49
|
+
- Route → `wp-security` (planned).
|
|
50
|
+
|
|
51
|
+
## Step 3: guardrails checklist (always)
|
|
52
|
+
|
|
53
|
+
- Verify detected tooling before suggesting commands (Composer vs npm/yarn/pnpm).
|
|
54
|
+
- Prefer existing lint/test scripts if present.
|
|
55
|
+
- If version constraints aren’t detectable, ask for target WP core and PHP versions.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: wp-abilities-api
|
|
3
|
+
description: "Use when working with the WordPress Abilities API (wp_register_ability, wp_register_ability_category, /wp-json/wp-abilities/v1/*, @wordpress/abilities) including defining abilities, categories, meta, REST exposure, and permissions checks for clients."
|
|
4
|
+
compatibility: "Targets WordPress 6.9+ (PHP 7.2.24+). Filesystem-based agent with bash + node. Some workflows require WP-CLI."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# WP Abilities API
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
Use this skill when the task involves:
|
|
12
|
+
|
|
13
|
+
- registering abilities or ability categories in PHP,
|
|
14
|
+
- exposing abilities to clients via REST (`wp-abilities/v1`),
|
|
15
|
+
- consuming abilities in JS (notably `@wordpress/abilities`),
|
|
16
|
+
- diagnosing “ability doesn’t show up” / “client can’t see ability” / “REST returns empty”.
|
|
17
|
+
|
|
18
|
+
## Inputs required
|
|
19
|
+
|
|
20
|
+
- Repo root (run `wp-project-triage` first if you haven’t).
|
|
21
|
+
- Target WordPress version(s) and whether this is WP core or a plugin/theme.
|
|
22
|
+
- Where the change should live (plugin vs theme vs mu-plugin).
|
|
23
|
+
|
|
24
|
+
## Procedure
|
|
25
|
+
|
|
26
|
+
### 1) Confirm availability and version constraints
|
|
27
|
+
|
|
28
|
+
- If this is WP core work, check `signals.isWpCoreCheckout` and `versions.wordpress.core`.
|
|
29
|
+
- If the project targets WP < 6.9, you may need the Abilities API plugin/package rather than relying on core.
|
|
30
|
+
|
|
31
|
+
### 2) Find existing Abilities usage
|
|
32
|
+
|
|
33
|
+
Search for these in the repo:
|
|
34
|
+
|
|
35
|
+
- `wp_register_ability(`
|
|
36
|
+
- `wp_register_ability_category(`
|
|
37
|
+
- `wp_abilities_api_init`
|
|
38
|
+
- `wp_abilities_api_categories_init`
|
|
39
|
+
- `wp-abilities/v1`
|
|
40
|
+
- `@wordpress/abilities`
|
|
41
|
+
|
|
42
|
+
If none exist, decide whether you’re introducing Abilities API fresh (new registrations + client consumption) or only consuming.
|
|
43
|
+
|
|
44
|
+
### 3) Register categories (optional)
|
|
45
|
+
|
|
46
|
+
If you need a logical grouping, register an ability category early (see `references/php-registration.md`).
|
|
47
|
+
|
|
48
|
+
### 4) Register abilities (PHP)
|
|
49
|
+
|
|
50
|
+
Implement the ability in PHP registration with:
|
|
51
|
+
|
|
52
|
+
- stable `id` (namespaced),
|
|
53
|
+
- `label`/`description`,
|
|
54
|
+
- `category`,
|
|
55
|
+
- `meta`:
|
|
56
|
+
- add `readonly: true` when the ability is informational,
|
|
57
|
+
- set `show_in_rest: true` for abilities you want visible to clients.
|
|
58
|
+
|
|
59
|
+
Use the documented init hooks for Abilities API registration so they load at the right time (see `references/php-registration.md`).
|
|
60
|
+
|
|
61
|
+
### 5) Confirm REST exposure
|
|
62
|
+
|
|
63
|
+
- Verify the REST endpoints exist and return expected results (see `references/rest-api.md`).
|
|
64
|
+
- If the client still can’t see the ability, confirm `meta.show_in_rest` is enabled and you’re querying the right endpoint.
|
|
65
|
+
|
|
66
|
+
### 6) Consume from JS (if needed)
|
|
67
|
+
|
|
68
|
+
- Prefer `@wordpress/abilities` APIs for client-side access and checks.
|
|
69
|
+
- Ensure build tooling includes the dependency and the project’s build pipeline bundles it.
|
|
70
|
+
|
|
71
|
+
## Verification
|
|
72
|
+
|
|
73
|
+
- `wp-project-triage` indicates `signals.usesAbilitiesApi: true` after your change (if applicable).
|
|
74
|
+
- REST check (in a WP environment): endpoints under `wp-abilities/v1` return your ability and category when expected.
|
|
75
|
+
- If the repo has tests, add/update coverage near:
|
|
76
|
+
- PHP: ability registration and meta exposure
|
|
77
|
+
- JS: ability consumption and UI gating
|
|
78
|
+
|
|
79
|
+
## Failure modes / debugging
|
|
80
|
+
|
|
81
|
+
- Ability never appears:
|
|
82
|
+
- registration code not running (wrong hook / file not loaded),
|
|
83
|
+
- missing `meta.show_in_rest`,
|
|
84
|
+
- incorrect category/ID mismatch.
|
|
85
|
+
- REST shows ability but JS doesn’t:
|
|
86
|
+
- wrong REST base/namespace,
|
|
87
|
+
- JS dependency not bundled,
|
|
88
|
+
- caching (object/page caches) masking changes.
|
|
89
|
+
|
|
90
|
+
## Escalation
|
|
91
|
+
|
|
92
|
+
- If you’re uncertain about version support, confirm target WP core versions and whether Abilities API is expected from core or as a plugin.
|
|
93
|
+
- For canonical details, consult:
|
|
94
|
+
- `references/rest-api.md`
|
|
95
|
+
- `references/php-registration.md`
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# PHP registration quick guide
|
|
2
|
+
|
|
3
|
+
Key concepts and entrypoints for the WordPress Abilities API:
|
|
4
|
+
|
|
5
|
+
- Register ability categories and abilities in PHP.
|
|
6
|
+
- Use the Abilities API init hooks to ensure registration occurs at the right lifecycle time.
|
|
7
|
+
|
|
8
|
+
## Hook order (critical)
|
|
9
|
+
|
|
10
|
+
**Categories must be registered before abilities.** Use the correct hooks:
|
|
11
|
+
|
|
12
|
+
1. `wp_abilities_api_categories_init` — Register categories here first.
|
|
13
|
+
2. `wp_abilities_api_init` — Register abilities here (after categories exist).
|
|
14
|
+
|
|
15
|
+
**Warning:** Registering abilities outside `wp_abilities_api_init` triggers `_doing_it_wrong()` and the registration will fail.
|
|
16
|
+
|
|
17
|
+
```php
|
|
18
|
+
// 1. Register category first
|
|
19
|
+
add_action( 'wp_abilities_api_categories_init', function() {
|
|
20
|
+
wp_register_ability_category( 'my-plugin', [
|
|
21
|
+
'label' => __( 'My Plugin', 'my-plugin' ),
|
|
22
|
+
] );
|
|
23
|
+
} );
|
|
24
|
+
|
|
25
|
+
// 2. Then register abilities
|
|
26
|
+
add_action( 'wp_abilities_api_init', function() {
|
|
27
|
+
wp_register_ability( 'my-plugin/get-info', [
|
|
28
|
+
'label' => __( 'Get Site Info', 'my-plugin' ),
|
|
29
|
+
'description' => __( 'Returns basic site information.', 'my-plugin' ),
|
|
30
|
+
'category' => 'my-plugin',
|
|
31
|
+
'callback' => 'my_plugin_get_info_callback',
|
|
32
|
+
'meta' => [ 'show_in_rest' => true ],
|
|
33
|
+
] );
|
|
34
|
+
} );
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Common primitives
|
|
38
|
+
|
|
39
|
+
- `wp_register_ability_category( $category_id, $args )`
|
|
40
|
+
- `wp_register_ability( $ability_id, $args )`
|
|
41
|
+
|
|
42
|
+
## Key arguments for `wp_register_ability()`
|
|
43
|
+
|
|
44
|
+
| Argument | Description |
|
|
45
|
+
|----------|-------------|
|
|
46
|
+
| `label` | Human-readable name for UI (e.g., command palette) |
|
|
47
|
+
| `description` | What the ability does |
|
|
48
|
+
| `category` | Category ID (must be registered first) |
|
|
49
|
+
| `callback` | Function that executes the ability |
|
|
50
|
+
| `input_schema` | JSON Schema for expected input (enables validation) |
|
|
51
|
+
| `output_schema` | JSON Schema for returned output |
|
|
52
|
+
| `permission_callback` | Optional function to check if current user can execute |
|
|
53
|
+
| `meta.show_in_rest` | Set `true` to expose via REST API |
|
|
54
|
+
| `meta.readonly` | Set `true` if ability is informational only |
|
|
55
|
+
|
|
56
|
+
## Recommended patterns
|
|
57
|
+
|
|
58
|
+
- Namespace IDs (e.g. `my-plugin:feature.edit`).
|
|
59
|
+
- Treat IDs as stable API; changing IDs is a breaking change.
|
|
60
|
+
- Use `input_schema` and `output_schema` for validation and to help AI agents understand usage.
|
|
61
|
+
- Always include a `permission_callback` for abilities that modify data.
|
|
62
|
+
|
|
63
|
+
## References
|
|
64
|
+
|
|
65
|
+
- Abilities API handbook: https://developer.wordpress.org/apis/abilities-api/
|
|
66
|
+
- Dev note: https://make.wordpress.org/core/2025/11/10/abilities-api-in-wordpress-6-9/
|
|
67
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# REST API quick guide (`wp-abilities/v1`)
|
|
2
|
+
|
|
3
|
+
The Abilities API exposes endpoints under the REST namespace:
|
|
4
|
+
|
|
5
|
+
- `wp-abilities/v1/abilities`
|
|
6
|
+
- `wp-abilities/v1/categories`
|
|
7
|
+
|
|
8
|
+
Debug checklist:
|
|
9
|
+
|
|
10
|
+
- Confirm the route exists under `wp-json/wp-abilities/v1/...`.
|
|
11
|
+
- Verify the ability/category shows in REST responses.
|
|
12
|
+
- If missing, confirm `meta.show_in_rest` is enabled for that ability.
|
|
13
|
+
|