@ai-kits/wp-ag-kit 1.0.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 (104) hide show
  1. package/ANTIGRAVITY-README.md +47 -0
  2. package/CONTRIBUTING.md +122 -0
  3. package/README.md +135 -0
  4. package/STRUCTURE.md +200 -0
  5. package/agents/wordpress-expert.md +36 -0
  6. package/agents/wp-frontend-expert.md +21 -0
  7. package/bin/antigravity-agent.js +159 -0
  8. package/docs/authoring-guide.md +56 -0
  9. package/docs/compatibility-policy.md +18 -0
  10. package/docs/packaging.md +26 -0
  11. package/docs/principles.md +7 -0
  12. package/docs/skill-set-v1.md +21 -0
  13. package/docs/upstream-sync.md +52 -0
  14. package/package.json +47 -0
  15. package/rules/GEMINI.md +273 -0
  16. package/shared/references/.gitkeep +1 -0
  17. package/shared/references/gutenberg-releases.json +155 -0
  18. package/shared/references/wordpress-core-versions.json +208 -0
  19. package/shared/references/wp-gutenberg-version-map.json +886 -0
  20. package/shared/scripts/ai-generate-updates.mjs +458 -0
  21. package/shared/scripts/scaffold-skill.mjs +62 -0
  22. package/shared/scripts/skillpack-build.mjs +165 -0
  23. package/shared/scripts/skillpack-install.mjs +275 -0
  24. package/shared/scripts/update-upstream-indices.mjs +173 -0
  25. package/skills/wordpress-router/SKILL.md +51 -0
  26. package/skills/wordpress-router/references/decision-tree.md +55 -0
  27. package/skills/wp-abilities-api/SKILL.md +95 -0
  28. package/skills/wp-abilities-api/references/php-registration.md +67 -0
  29. package/skills/wp-abilities-api/references/rest-api.md +13 -0
  30. package/skills/wp-block-development/SKILL.md +174 -0
  31. package/skills/wp-block-development/references/attributes-and-serialization.md +22 -0
  32. package/skills/wp-block-development/references/block-json.md +49 -0
  33. package/skills/wp-block-development/references/creating-new-blocks.md +46 -0
  34. package/skills/wp-block-development/references/debugging.md +36 -0
  35. package/skills/wp-block-development/references/deprecations.md +24 -0
  36. package/skills/wp-block-development/references/dynamic-rendering.md +23 -0
  37. package/skills/wp-block-development/references/inner-blocks.md +25 -0
  38. package/skills/wp-block-development/references/registration.md +30 -0
  39. package/skills/wp-block-development/references/supports-and-wrappers.md +18 -0
  40. package/skills/wp-block-development/references/tooling-and-testing.md +21 -0
  41. package/skills/wp-block-development/scripts/list_blocks.mjs +121 -0
  42. package/skills/wp-block-themes/SKILL.md +116 -0
  43. package/skills/wp-block-themes/references/creating-new-block-theme.md +37 -0
  44. package/skills/wp-block-themes/references/debugging.md +24 -0
  45. package/skills/wp-block-themes/references/patterns.md +18 -0
  46. package/skills/wp-block-themes/references/style-variations.md +14 -0
  47. package/skills/wp-block-themes/references/templates-and-parts.md +16 -0
  48. package/skills/wp-block-themes/references/theme-json.md +59 -0
  49. package/skills/wp-block-themes/scripts/detect_block_themes.mjs +117 -0
  50. package/skills/wp-interactivity-api/SKILL.md +179 -0
  51. package/skills/wp-interactivity-api/references/debugging.md +29 -0
  52. package/skills/wp-interactivity-api/references/directives-quickref.md +30 -0
  53. package/skills/wp-interactivity-api/references/server-side-rendering.md +310 -0
  54. package/skills/wp-performance/SKILL.md +146 -0
  55. package/skills/wp-performance/references/autoload-options.md +24 -0
  56. package/skills/wp-performance/references/cron.md +20 -0
  57. package/skills/wp-performance/references/database.md +20 -0
  58. package/skills/wp-performance/references/http-api.md +15 -0
  59. package/skills/wp-performance/references/measurement.md +21 -0
  60. package/skills/wp-performance/references/object-cache.md +24 -0
  61. package/skills/wp-performance/references/query-monitor-headless.md +38 -0
  62. package/skills/wp-performance/references/server-timing.md +22 -0
  63. package/skills/wp-performance/references/wp-cli-doctor.md +24 -0
  64. package/skills/wp-performance/references/wp-cli-profile.md +32 -0
  65. package/skills/wp-performance/scripts/perf_inspect.mjs +128 -0
  66. package/skills/wp-phpstan/SKILL.md +97 -0
  67. package/skills/wp-phpstan/references/configuration.md +52 -0
  68. package/skills/wp-phpstan/references/third-party-classes.md +76 -0
  69. package/skills/wp-phpstan/references/wordpress-annotations.md +124 -0
  70. package/skills/wp-phpstan/scripts/phpstan_inspect.mjs +263 -0
  71. package/skills/wp-playground/SKILL.md +101 -0
  72. package/skills/wp-playground/references/blueprints.md +36 -0
  73. package/skills/wp-playground/references/cli-commands.md +39 -0
  74. package/skills/wp-playground/references/debugging.md +16 -0
  75. package/skills/wp-plugin-development/SKILL.md +112 -0
  76. package/skills/wp-plugin-development/references/data-and-cron.md +19 -0
  77. package/skills/wp-plugin-development/references/debugging.md +19 -0
  78. package/skills/wp-plugin-development/references/lifecycle.md +33 -0
  79. package/skills/wp-plugin-development/references/security.md +29 -0
  80. package/skills/wp-plugin-development/references/settings-api.md +22 -0
  81. package/skills/wp-plugin-development/references/structure.md +16 -0
  82. package/skills/wp-plugin-development/scripts/detect_plugins.mjs +122 -0
  83. package/skills/wp-project-triage/SKILL.md +38 -0
  84. package/skills/wp-project-triage/references/triage.schema.json +143 -0
  85. package/skills/wp-project-triage/scripts/detect_wp_project.mjs +592 -0
  86. package/skills/wp-rest-api/SKILL.md +114 -0
  87. package/skills/wp-rest-api/references/authentication.md +18 -0
  88. package/skills/wp-rest-api/references/custom-content-types.md +20 -0
  89. package/skills/wp-rest-api/references/discovery-and-params.md +20 -0
  90. package/skills/wp-rest-api/references/responses-and-fields.md +30 -0
  91. package/skills/wp-rest-api/references/routes-and-endpoints.md +36 -0
  92. package/skills/wp-rest-api/references/schema.md +22 -0
  93. package/skills/wp-wpcli-and-ops/SKILL.md +123 -0
  94. package/skills/wp-wpcli-and-ops/references/automation.md +30 -0
  95. package/skills/wp-wpcli-and-ops/references/cron-and-cache.md +23 -0
  96. package/skills/wp-wpcli-and-ops/references/debugging.md +17 -0
  97. package/skills/wp-wpcli-and-ops/references/multisite.md +22 -0
  98. package/skills/wp-wpcli-and-ops/references/packages-and-updates.md +22 -0
  99. package/skills/wp-wpcli-and-ops/references/safety.md +30 -0
  100. package/skills/wp-wpcli-and-ops/references/search-replace.md +40 -0
  101. package/skills/wp-wpcli-and-ops/scripts/wpcli_inspect.mjs +90 -0
  102. package/skills/wpds/SKILL.md +58 -0
  103. package/workflows/create-block.md +27 -0
  104. package/workflows/wp-lint.md +27 -0
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: wp-block-themes
3
+ description: "Use when developing WordPress block themes: theme.json (global settings/styles), templates and template parts, patterns, style variations, and Site Editor troubleshooting (style hierarchy, overrides, caching)."
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 Block Themes
8
+
9
+ ## When to use
10
+
11
+ Use this skill for block theme work such as:
12
+
13
+ - editing `theme.json` (presets, settings, styles, per-block styles)
14
+ - adding or changing templates (`templates/*.html`) and template parts (`parts/*.html`)
15
+ - adding patterns (`patterns/*.php`) and controlling what appears in the inserter
16
+ - adding style variations (`styles/*.json`)
17
+ - debugging “styles not applying” / “editor doesn’t reflect theme.json”
18
+
19
+ ## Inputs required
20
+
21
+ - Repo root and which theme is targeted (theme directory if multiple exist).
22
+ - Target WordPress version range (theme.json version and features vary by core version).
23
+ - Where the issue manifests: Site Editor, post editor, frontend, or all.
24
+
25
+ ## Procedure
26
+
27
+ ### 0) Triage and locate block theme roots
28
+
29
+ 1. Run triage:
30
+ - `node skills/wp-project-triage/scripts/detect_wp_project.mjs`
31
+ 2. Detect theme roots + key folders:
32
+ - `node skills/wp-block-themes/scripts/detect_block_themes.mjs`
33
+
34
+ If multiple themes exist, pick one and scope all changes to that theme root.
35
+
36
+ ### 1) Create a new block theme (if needed)
37
+
38
+ If you are creating a new block theme from scratch (or converting a classic theme):
39
+
40
+ - Prefer starting from a known-good scaffold (or exporting from a WP environment) rather than guessing file layout.
41
+ - Be explicit about the minimum supported WordPress version because `theme.json` schema versions differ.
42
+
43
+ Read:
44
+ - `references/creating-new-block-theme.md`
45
+
46
+ After creating the theme root, re-run `detect_block_themes` and continue below.
47
+
48
+ ### 2) Confirm theme type and override expectations
49
+
50
+ - Block theme indicators:
51
+ - `theme.json` present
52
+ - `templates/` and/or `parts/` present
53
+ - Remember the style hierarchy:
54
+ - core defaults → theme.json → child theme → user customizations
55
+ - user customizations can make theme.json edits appear “ignored”
56
+
57
+ Read:
58
+ - `references/debugging.md` (style hierarchy + fastest checks)
59
+
60
+ ### 3) Make `theme.json` changes safely
61
+
62
+ Decide whether you are changing:
63
+
64
+ - **settings** (what the UI allows): presets, typography scale, colors, layout, spacing
65
+ - **styles** (how it looks by default): CSS-like rules for elements/blocks
66
+
67
+ Read:
68
+ - `references/theme-json.md`
69
+
70
+ ### 4) Templates and template parts
71
+
72
+ - Templates live under `templates/` and are HTML.
73
+ - Template parts live under `parts/` and must not be nested in subdirectories.
74
+
75
+ Read:
76
+ - `references/templates-and-parts.md`
77
+
78
+ ### 5) Patterns
79
+
80
+ Prefer filesystem patterns under `patterns/` when you want theme-owned patterns.
81
+
82
+ Read:
83
+ - `references/patterns.md`
84
+
85
+ ### 6) Style variations
86
+
87
+ Style variations are JSON files under `styles/`. Note: once a user picks a style variation, that selection is stored in the DB, so changing the file may not “update what the user sees” automatically.
88
+
89
+ Read:
90
+ - `references/style-variations.md`
91
+
92
+ ## Verification
93
+
94
+ - Site Editor reflects changes where expected (Styles UI, templates, patterns).
95
+ - Frontend renders with expected styles.
96
+ - If styles aren’t changing, confirm whether user customizations override theme defaults.
97
+ - Run the repo’s build/lint scripts if assets are involved (fonts, custom JS/CSS build).
98
+
99
+ ## Failure modes / debugging
100
+
101
+ Start with:
102
+
103
+ - `references/debugging.md`
104
+
105
+ Common issues:
106
+
107
+ - wrong theme root (editing an inactive theme)
108
+ - user customizations override your defaults
109
+ - invalid `theme.json` shape/typos prevent application
110
+ - templates/parts in wrong folders (or nested parts)
111
+
112
+ ## Escalation
113
+
114
+ If upstream behavior is unclear, consult canonical docs:
115
+
116
+ - Theme Handbook and Block Editor Handbook for `theme.json`, templates, patterns, and style variations.
@@ -0,0 +1,37 @@
1
+ # Creating a new block theme
2
+
3
+ Use this file when you need to create a new block theme or convert a theme to block theme structure.
4
+
5
+ ## Two practical starting points
6
+
7
+ 1. **Export from a WP environment**
8
+ - Use the official “Create Block Theme” plugin to generate/export a theme from the Site Editor.
9
+ - This tends to produce a structure aligned with current WordPress behavior.
10
+
11
+ 2. **Create the minimal filesystem structure**
12
+ - Create a theme folder with:
13
+ - `style.css` (theme header)
14
+ - `theme.json` (global settings/styles)
15
+ - `templates/index.html` (minimum viable template)
16
+ - `parts/header.html` and `parts/footer.html` (recommended)
17
+
18
+ ## References
19
+
20
+ - Create Block Theme plugin:
21
+ - https://wordpress.org/plugins/create-block-theme/
22
+ - Block theme structure:
23
+ - https://developer.wordpress.org/themes/block-themes/theme-structure/
24
+ - Required templates:
25
+ - https://developer.wordpress.org/themes/block-themes/templates-and-template-parts/
26
+
27
+ ## theme.json version choice (compatibility)
28
+
29
+ `theme.json` has schema versions. Pick the highest version that matches your minimum supported WordPress version.
30
+
31
+ References:
32
+
33
+ - Theme Handbook introduction:
34
+ - https://developer.wordpress.org/themes/global-settings-and-styles/introduction-to-theme-json/
35
+ - Theme.json version 3 dev note:
36
+ - https://make.wordpress.org/core/2024/06/19/theme-json-version-3/
37
+
@@ -0,0 +1,24 @@
1
+ # Debugging block theme issues
2
+
3
+ ## Styles not applying
4
+
5
+ Fast checks:
6
+
7
+ 1. Confirm you edited the active theme (Site Editor → theme).
8
+ 2. Check if user customizations exist (they override theme defaults).
9
+ 3. Validate `theme.json` structure (typos can prevent styles from applying).
10
+
11
+ Remember the hierarchy:
12
+
13
+ - core defaults → theme.json → child theme → user customizations
14
+
15
+ ## Templates/parts not showing
16
+
17
+ - Ensure files are in the correct folders (`templates/`, `parts/`).
18
+ - Template parts must not be nested in subdirectories.
19
+
20
+ ## Style variations not updating
21
+
22
+ - If a user already selected the variation, the selection is stored in the DB.
23
+ - Test with a fresh site/user or reset customizations when appropriate.
24
+
@@ -0,0 +1,18 @@
1
+ # Patterns (filesystem patterns)
2
+
3
+ Use this file when adding patterns that should be available in the inserter.
4
+
5
+ ## Filesystem patterns
6
+
7
+ - Put patterns in `patterns/*.php`.
8
+ - Patterns are registered automatically by WordPress core based on file headers.
9
+
10
+ Upstream reference:
11
+
12
+ - https://developer.wordpress.org/themes/patterns/
13
+
14
+ ## Practical guardrails
15
+
16
+ - Keep pattern markup stable; changing block names inside patterns can break older content in subtle ways.
17
+ - If a pattern should not be inserted directly by users, mark it as non-inserter / internal-only (per upstream header conventions).
18
+
@@ -0,0 +1,14 @@
1
+ # Style variations (`styles/*.json`)
2
+
3
+ Use this file when adding or debugging style variations.
4
+
5
+ Key points:
6
+
7
+ - Style variations are JSON files in `styles/`.
8
+ - Users can pick a style variation in the UI.
9
+ - Once selected, the choice is stored in the DB (so “changing the JSON file” may not update what a user already selected).
10
+
11
+ Upstream reference:
12
+
13
+ - https://developer.wordpress.org/themes/global-settings-and-styles/style-variations/
14
+
@@ -0,0 +1,16 @@
1
+ # Templates and template parts
2
+
3
+ Use this file when creating or editing HTML templates/parts.
4
+
5
+ ## Key folders
6
+
7
+ - `templates/` for templates.
8
+ - `parts/` for template parts.
9
+
10
+ Template parts must not be nested in subdirectories.
11
+
12
+ Upstream references:
13
+
14
+ - Templates + parts overview: https://developer.wordpress.org/themes/block-themes/theme-structure/
15
+ - Template parts details: https://developer.wordpress.org/themes/block-themes/template-parts/
16
+
@@ -0,0 +1,59 @@
1
+ # `theme.json` guidance
2
+
3
+ Use this file when changing global settings/styles or per-block styling.
4
+
5
+ ## High-level structure
6
+
7
+ Common top-level keys:
8
+
9
+ - `version`
10
+ - `settings` (what the UI exposes / allows)
11
+ - `styles` (default appearance)
12
+ - `customTemplates` and `templateParts` (optional, to describe templates and parts)
13
+
14
+ Upstream references:
15
+
16
+ - Theme Handbook: https://developer.wordpress.org/themes/global-settings-and-styles/
17
+ - Block Editor Handbook (often more current): https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-json/
18
+ - Theme JSON living reference: https://developer.wordpress.org/block-editor/reference-guides/theme-json-reference/theme-json-living/
19
+ - Theme JSON version 3 (dev note): https://make.wordpress.org/core/2024/06/19/theme-json-version-3/
20
+
21
+ ## Practical guardrails
22
+
23
+ - Prefer presets when you want editor-visible controls (colors, font sizes, spacing).
24
+ - Prefer `styles` when you want consistent defaults without requiring user choice.
25
+ - Be careful with specificity: user global styles override theme defaults.
26
+
27
+ ## WordPress 6.9 additions
28
+
29
+ **Form element styling:**
30
+ - Style text inputs and selects via `styles.elements` (e.g., `styles.elements.input`, `styles.elements.select`).
31
+ - Supports border, color, outline, shadow, and spacing properties.
32
+ - Note: Focus state styling is not yet available in 6.9.
33
+
34
+ **Border radius presets:**
35
+ - Define presets in `settings.border.radiusSizes` for visual selection in the border radius control.
36
+ - Users can still enter custom values.
37
+
38
+ ```json
39
+ {
40
+ "settings": {
41
+ "border": {
42
+ "radiusSizes": [
43
+ { "name": "Small", "slug": "small", "size": "4px" },
44
+ { "name": "Medium", "slug": "medium", "size": "8px" },
45
+ { "name": "Large", "slug": "large", "size": "16px" }
46
+ ]
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ **Button pseudo-classes:**
53
+ - Style Button block hover and focus states directly in theme.json.
54
+ - No longer requires custom CSS for simple button state styling.
55
+
56
+ References:
57
+
58
+ - Border radius presets: https://make.wordpress.org/core/2025/11/12/theme-json-border-radius-presets-support-in-wordpress-6-9/
59
+ - Form element styling: https://developer.wordpress.org/news/2025/11/how-wordpress-6-9-gives-forms-a-theme-json-makeover/
@@ -0,0 +1,117 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ const DEFAULT_IGNORES = new Set([
5
+ ".git",
6
+ "node_modules",
7
+ "vendor",
8
+ "dist",
9
+ "build",
10
+ "coverage",
11
+ ".next",
12
+ ".turbo",
13
+ ]);
14
+
15
+ function statSafe(p) {
16
+ try {
17
+ return fs.statSync(p);
18
+ } catch {
19
+ return null;
20
+ }
21
+ }
22
+
23
+ function existsDir(p) {
24
+ const st = statSafe(p);
25
+ return Boolean(st && st.isDirectory());
26
+ }
27
+
28
+ function readJsonSafe(p) {
29
+ try {
30
+ return JSON.parse(fs.readFileSync(p, "utf8"));
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+
36
+ function findFilesRecursive(repoRoot, predicate, { maxFiles = 6000, maxDepth = 10 } = {}) {
37
+ const results = [];
38
+ const queue = [{ dir: repoRoot, depth: 0 }];
39
+ let visited = 0;
40
+
41
+ while (queue.length > 0) {
42
+ const { dir, depth } = queue.shift();
43
+ if (depth > maxDepth) continue;
44
+
45
+ let entries;
46
+ try {
47
+ entries = fs.readdirSync(dir, { withFileTypes: true });
48
+ } catch {
49
+ continue;
50
+ }
51
+
52
+ for (const ent of entries) {
53
+ const fullPath = path.join(dir, ent.name);
54
+ if (ent.isDirectory()) {
55
+ if (DEFAULT_IGNORES.has(ent.name)) continue;
56
+ queue.push({ dir: fullPath, depth: depth + 1 });
57
+ continue;
58
+ }
59
+ if (!ent.isFile()) continue;
60
+
61
+ visited += 1;
62
+ if (visited > maxFiles) return { results, truncated: true };
63
+ if (predicate(fullPath)) results.push(fullPath);
64
+ }
65
+ }
66
+
67
+ return { results, truncated: false };
68
+ }
69
+
70
+ function summarizeTheme(repoRoot, themeJsonPath) {
71
+ const json = readJsonSafe(themeJsonPath);
72
+ const rel = path.relative(repoRoot, themeJsonPath);
73
+ const rootDir = path.dirname(rel);
74
+
75
+ const templatesDir = path.join(repoRoot, rootDir, "templates");
76
+ const partsDir = path.join(repoRoot, rootDir, "parts");
77
+ const patternsDir = path.join(repoRoot, rootDir, "patterns");
78
+ const stylesDir = path.join(repoRoot, rootDir, "styles");
79
+
80
+ const hasTemplates = existsDir(templatesDir);
81
+ const hasParts = existsDir(partsDir);
82
+
83
+ return {
84
+ themeRoot: rootDir,
85
+ themeJson: rel,
86
+ version: typeof json?.version === "number" ? json.version : null,
87
+ hasTemplates,
88
+ hasParts,
89
+ hasPatterns: existsDir(patternsDir),
90
+ hasStyles: existsDir(stylesDir),
91
+ isBlockTheme: hasTemplates || hasParts,
92
+ };
93
+ }
94
+
95
+ function main() {
96
+ const repoRoot = process.cwd();
97
+
98
+ const { results: themeJsonFiles, truncated } = findFilesRecursive(repoRoot, (p) => path.basename(p) === "theme.json", {
99
+ maxFiles: 8000,
100
+ maxDepth: 12,
101
+ });
102
+
103
+ const themes = themeJsonFiles.map((p) => summarizeTheme(repoRoot, p));
104
+
105
+ const report = {
106
+ tool: { name: "detect_block_themes", version: "0.1.0" },
107
+ repoRoot,
108
+ truncated,
109
+ count: themes.length,
110
+ themes,
111
+ };
112
+
113
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
114
+ }
115
+
116
+ main();
117
+
@@ -0,0 +1,179 @@
1
+ ---
2
+ name: wp-interactivity-api
3
+ description: "Use when building or debugging WordPress Interactivity API features (data-wp-* directives, @wordpress/interactivity store/state/actions, block viewScriptModule integration, wp_interactivity_*()) including performance, hydration, and directive behavior."
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 Interactivity API
8
+
9
+ ## When to use
10
+
11
+ Use this skill when the user mentions:
12
+
13
+ - Interactivity API, `@wordpress/interactivity`,
14
+ - `data-wp-interactive`, `data-wp-on--*`, `data-wp-bind--*`, `data-wp-context`,
15
+ - block `viewScriptModule` / module-based view scripts,
16
+ - hydration issues or “directives don’t fire”.
17
+
18
+ ## Inputs required
19
+
20
+ - Repo root + triage output (`wp-project-triage`).
21
+ - Which block/theme/plugin surfaces are affected (frontend, editor, both).
22
+ - Any constraints: WP version, whether modules are supported in the build.
23
+
24
+ ## Procedure
25
+
26
+ ### 1) Detect existing usage + integration style
27
+
28
+ Search for:
29
+
30
+ - `data-wp-interactive`
31
+ - `@wordpress/interactivity`
32
+ - `viewScriptModule`
33
+
34
+ Decide:
35
+
36
+ - Is this a block providing interactivity via `block.json` view script module?
37
+ - Is this theme-level interactivity?
38
+ - Is this plugin-side “enhance existing markup” usage?
39
+
40
+ If you’re creating a new interactive block (not just debugging), prefer the official scaffold template:
41
+
42
+ - `@wordpress/create-block-interactive-template` (via `@wordpress/create-block`)
43
+
44
+ ### 2) Identify the store(s)
45
+
46
+ Locate store definitions and confirm:
47
+
48
+ - state shape,
49
+ - actions (mutations),
50
+ - callbacks/event handlers used by `data-wp-on--*`.
51
+
52
+ ### 3) Server-side rendering (best practice)
53
+
54
+ **Pre-render HTML on the server** before outputting to ensure:
55
+
56
+ - Correct initial state in the HTML before JavaScript loads (no layout shift).
57
+ - SEO benefits and faster perceived load time.
58
+ - Seamless hydration when the client-side JavaScript takes over.
59
+
60
+ #### Enable server directive processing
61
+
62
+ For components using `block.json`, add `supports.interactivity`:
63
+
64
+ ```json
65
+ {
66
+ "supports": {
67
+ "interactivity": true
68
+ }
69
+ }
70
+ ```
71
+
72
+ For themes/plugins without `block.json`, use `wp_interactivity_process_directives()` to process directives.
73
+
74
+ #### Initialize state/context in PHP
75
+
76
+ Use `wp_interactivity_state()` to define initial global state:
77
+
78
+ ```php
79
+ wp_interactivity_state( 'myPlugin', array(
80
+ 'items' => array( 'Apple', 'Banana', 'Cherry' ),
81
+ 'hasItems' => true,
82
+ ));
83
+ ```
84
+
85
+ For local context, use `wp_interactivity_data_wp_context()`:
86
+
87
+ ```php
88
+ <?php
89
+ $context = array( 'isOpen' => false );
90
+ ?>
91
+ <div <?php echo wp_interactivity_data_wp_context( $context ); ?>>
92
+ ...
93
+ </div>
94
+ ```
95
+
96
+ #### Define derived state in PHP
97
+
98
+ When derived state affects initial HTML rendering, replicate the logic in PHP:
99
+
100
+ ```php
101
+ wp_interactivity_state( 'myPlugin', array(
102
+ 'items' => array( 'Apple', 'Banana' ),
103
+ 'hasItems' => function() {
104
+ $state = wp_interactivity_state();
105
+ return count( $state['items'] ) > 0;
106
+ }
107
+ ));
108
+ ```
109
+
110
+ This ensures directives like `data-wp-bind--hidden="!state.hasItems"` render correctly on first load.
111
+
112
+ For detailed examples and patterns, see `references/server-side-rendering.md`.
113
+
114
+ ### 4) Implement or change directives safely
115
+
116
+ When touching markup directives:
117
+
118
+ - keep directive usage minimal and scoped,
119
+ - prefer stable data attributes that map clearly to store state,
120
+ - ensure server-rendered markup + client hydration align.
121
+
122
+ **WordPress 6.9 changes:**
123
+
124
+ - **`data-wp-ignore` is deprecated** and will be removed in future versions. It broke context inheritance and caused issues with client-side navigation. Avoid using it.
125
+ - **Unique directive IDs**: Multiple directives of the same type can now exist on one element using the `---` separator (e.g., `data-wp-on--click---plugin-a="..."` and `data-wp-on--click---plugin-b="..."`).
126
+ - **New TypeScript types**: `AsyncAction<ReturnType>` and `TypeYield<T>` help with async action typing.
127
+
128
+ For quick directive reminders, see `references/directives-quickref.md`.
129
+
130
+ ### 5) Build/tooling alignment
131
+
132
+ Verify the repo supports the required module build path:
133
+
134
+ - if it uses `@wordpress/scripts`, prefer its conventions.
135
+ - if it uses custom bundling, confirm module output is supported.
136
+
137
+ ### 6) Debug common failure modes
138
+
139
+ If “nothing happens” on interaction:
140
+
141
+ - confirm the `viewScriptModule` is enqueued/loaded,
142
+ - confirm the DOM element has `data-wp-interactive`,
143
+ - confirm the store namespace matches the directive’s value,
144
+ - confirm there are no JS errors before hydration.
145
+
146
+ See `references/debugging.md`.
147
+
148
+ ## Verification
149
+
150
+ - `wp-project-triage` indicates `signals.usesInteractivityApi: true` after your change (if applicable).
151
+ - Manual smoke test: directive triggers and state updates as expected.
152
+ - If tests exist: add/extend Playwright E2E around the interaction path.
153
+
154
+ ## Failure modes / debugging
155
+
156
+ - Directives present but inert:
157
+ - view script not loading, wrong module entrypoint, or missing `data-wp-interactive`.
158
+ - Hydration mismatch / flicker:
159
+ - server markup differs from client expectations; simplify or align initial state.
160
+ - derived state not defined in PHP: use `wp_interactivity_state()` with closures.
161
+ - Initial content missing or wrong:
162
+ - `supports.interactivity` not set in `block.json` (for blocks).
163
+ - `wp_interactivity_process_directives()` not called (for themes/plugins).
164
+ - state/context not initialized in PHP before render.
165
+ - Layout shift on load:
166
+ - derived state like `state.hasItems` missing on server, causing `hidden` attribute to be absent.
167
+ - Performance regressions:
168
+ - overly broad interactive roots; scope interactivity to smaller subtrees.
169
+ - Client-side navigation issues (WordPress 6.9):
170
+ - `getServerState()` and `getServerContext()` now reset between page transitions—ensure your code doesn't assume stale values persist.
171
+ - Router regions now support `attachTo` for rendering overlays (modals, pop-ups) dynamically.
172
+
173
+ ## Escalation
174
+
175
+ - If repo build constraints are unclear, ask: "Is this using `@wordpress/scripts` or a custom bundler (webpack/vite)?"
176
+ - Consult:
177
+ - `references/server-side-rendering.md`
178
+ - `references/directives-quickref.md`
179
+ - `references/debugging.md`
@@ -0,0 +1,29 @@
1
+ # Debugging checklist
2
+
3
+ 1. Confirm the interactive root exists in the rendered HTML (`data-wp-interactive`).
4
+ 2. Confirm the view script module is loaded (network + source maps).
5
+ 3. Confirm store namespace matches what markup expects.
6
+ 4. Check console for errors before any interaction.
7
+ 5. Reduce scope:
8
+ - temporarily remove directives to isolate which directive/store path breaks.
9
+ 6. If hydration mismatch occurs:
10
+ - ensure initial state/context matches server markup.
11
+
12
+ ## WordPress 6.9 specific issues
13
+
14
+ **State not persisting across navigation:**
15
+ - `getServerState()` and `getServerContext()` now reset between client-side page transitions.
16
+ - If you relied on stale values persisting, refactor to use the store's reactive state instead.
17
+
18
+ **Multiple plugins conflicting on same element:**
19
+ - Use unique directive IDs with the `---` separator to avoid attribute collisions.
20
+ - Example: `data-wp-on--click---my-plugin="actions.handle"`
21
+
22
+ **`data-wp-ignore` not working:**
23
+ - This directive is deprecated in 6.9 and will be removed. It caused context inheritance and navigation bugs.
24
+ - Find an alternative approach (conditional rendering, separate interactive regions).
25
+
26
+ **Router regions / overlays not rendering:**
27
+ - WordPress 6.9 adds `attachTo` property for router regions to render overlays anywhere on the page.
28
+ - Ensure nested router regions are properly structured.
29
+
@@ -0,0 +1,30 @@
1
+ # Directives quick reference (high level)
2
+
3
+ Common directives to recognize in markup:
4
+
5
+ - `data-wp-interactive`: declares an interactive region (and often a store namespace).
6
+ - `data-wp-context`: provides server-rendered context/state.
7
+ - `data-wp-on--event`: attaches event handlers (e.g. `click`, `submit`).
8
+ - `data-wp-on-async--event`: async event handlers (preferred for most actions).
9
+ - `data-wp-bind--attr`: binds DOM attributes to state.
10
+ - `data-wp-class--name`: toggles CSS classes based on state.
11
+
12
+ Use these as search anchors when triaging bugs.
13
+
14
+ ## Unique directive IDs (WordPress 6.9+)
15
+
16
+ HTML doesn't allow duplicate attributes. To attach multiple handlers of the same type from different plugins, use the `---` separator:
17
+
18
+ ```html
19
+ <button
20
+ data-wp-on--click---plugin-a="actions.handleA"
21
+ data-wp-on--click---plugin-b="actions.handleB"
22
+ >
23
+ ```
24
+
25
+ Both handlers will fire. The ID after `---` must be unique per element.
26
+
27
+ ## Deprecated directive
28
+
29
+ - **`data-wp-ignore`**: Deprecated in WordPress 6.9. It was intended to prevent hydration of a region but broke context inheritance and client-side navigation. Will be removed in future versions. Avoid using it.
30
+