diff --git a/.well-known/agent-skills/index.json b/.well-known/agent-skills/index.json index 5e47868..18cb954 100644 --- a/.well-known/agent-skills/index.json +++ b/.well-known/agent-skills/index.json @@ -34,7 +34,7 @@ "type": "archive", "description": "Phase-based WordPress project setup workflow with dry-run planning and confirmed apply for predictable scaffolding/standardization.", "url": "https://soderlind.no/.well-known/agent-skills/prepare-wordpress.tar.gz", - "digest": "sha256:9184137e00076315359b4298eeb577beee1dd7353976d1fc463443e565e51b66" + "digest": "sha256:28fd8747a249eddb8308c4d3eb5bfe730db6a3470ab169092fe506b6a1fd26f2" }, { "name": "wp-bump", diff --git a/.well-known/agent-skills/prepare-wordpress.tar.gz b/.well-known/agent-skills/prepare-wordpress.tar.gz index 8a0a9f3..43d8ceb 100644 Binary files a/.well-known/agent-skills/prepare-wordpress.tar.gz and b/.well-known/agent-skills/prepare-wordpress.tar.gz differ diff --git a/plugins/wordpress-skills/skills/prepare-wordpress/SKILL.md b/plugins/wordpress-skills/skills/prepare-wordpress/SKILL.md index 42e4575..1af34c5 100644 --- a/plugins/wordpress-skills/skills/prepare-wordpress/SKILL.md +++ b/plugins/wordpress-skills/skills/prepare-wordpress/SKILL.md @@ -1,8 +1,8 @@ --- name: prepare-wordpress description: "Phase-based WordPress project setup workflow with dry-run planning and confirmed apply for predictable scaffolding/standardization." -compatibility: "macOS/Linux with Node.js 18+, Composer 2+, PHP 8.3+, git. Optional: WP-CLI for i18n commands." -version: "1.1.0" +compatibility: "macOS/Linux with Node.js 18+, Composer 2+, PHP 8.3+, git. Optional: WP-CLI for i18n commands, curl for downloading coding instructions." +version: "1.2.0" --- # Prepare WordPress Project @@ -60,8 +60,9 @@ Hard gate: Do not run any `--apply` command until dry-run output is shown and th - `skills` — install agent skills - `composer` — install PHP dev deps and merge scripts - `config` — create/merge `.editorconfig` and `.gitignore` -- `vitest` — install and scaffold Vitest +- `vitest` — install and scaffold Vitest (JavaScript test runner) - `i18n` — scaffold i18n files/scripts +- `instructions` — download WordPress Copilot coding instructions - `cleanup` — remove stray `yarn.lock` Use the planner script to preview actions: @@ -245,9 +246,13 @@ Completion criterion: Each listed skill is installed or explicitly skipped becau Install all PHP dev dependencies in a single command: ```sh -composer require --dev phpunit/phpunit wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer pestphp/pest +composer require --dev phpunit/phpunit brain/monkey wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer pestphp/pest ``` +> **Dependencies:** Do not pin versions — let Composer resolve the latest compatible releases. Run `composer update` periodically to stay current. + +Unit tests mock WordPress functions with **Brain Monkey** (`brain/monkey`, which pulls in `mockery/mockery`), so tests run without a full WordPress install. See: `references/php-testing.md`. + Then merge these scripts into `composer.json` (do not overwrite existing scripts). Replace `` with the actual plugin slug (folder name / text domain). @@ -284,6 +289,9 @@ Completion criterion: `.editorconfig` and `.gitignore` are present, and existing **Skip if `vitest.config.js` already exists.** +Vitest is the JavaScript test runner for this project. Install the latest +releases (no pinned versions): + ```sh npm install --save-dev vitest jsdom ``` @@ -323,6 +331,27 @@ See: `references/i18n-setup.md` Completion criterion: `i18n-map.json`, `languages/`, and i18n npm scripts are present (or explicit skip/defer rationale is recorded). +### 6b) WordPress Copilot coding instructions + +**Skip if `.github/instructions/wordpress.instructions.md` already exists.** + +Add the community WordPress coding, security, and testing rules from +[github/awesome-copilot](https://github.com/github/awesome-copilot/blob/main/instructions/wordpress.instructions.md) +so agents follow WordPress best practices in this project: + +```sh +mkdir -p .github/instructions +curl -fsSL https://raw.githubusercontent.com/github/awesome-copilot/main/instructions/wordpress.instructions.md \ + -o .github/instructions/wordpress.instructions.md +``` + +If `curl` is unavailable or you are offline, create the file manually from +`references/copilot-instructions.md`. + +See: `references/copilot-instructions.md` + +Completion criterion: `.github/instructions/wordpress.instructions.md` exists (downloaded or created manually), or a skip reason is recorded. + ### 7) Cleanup Remove any stray `yarn.lock` file that may have been created by `npx` commands: @@ -350,6 +379,7 @@ Completion criterion: Final report includes per-phase status, skipped reasons, a - `composer validate` passes. - `npm ls` shows no missing peer dependencies for vitest. - Agent skills are present under `~/.copilot/skills/` or `~/.agents/skills/`. +- `.github/instructions/wordpress.instructions.md` exists when the `instructions` phase ran. ## Failure modes / debugging diff --git a/plugins/wordpress-skills/skills/prepare-wordpress/references/composer-setup.md b/plugins/wordpress-skills/skills/prepare-wordpress/references/composer-setup.md index 5351ed9..6dd127e 100644 --- a/plugins/wordpress-skills/skills/prepare-wordpress/references/composer-setup.md +++ b/plugins/wordpress-skills/skills/prepare-wordpress/references/composer-setup.md @@ -2,10 +2,11 @@ ## Dependencies -Install all PHP dev dependencies in one command: +Install all PHP dev dependencies in one command (no pinned versions — Composer +resolves the latest compatible releases): ```sh -composer require --dev phpunit/phpunit wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer pestphp/pest +composer require --dev phpunit/phpunit brain/monkey wp-coding-standards/wpcs dealerdirect/phpcodesniffer-composer-installer pestphp/pest ``` ### What each package does @@ -13,10 +14,16 @@ composer require --dev phpunit/phpunit wp-coding-standards/wpcs dealerdirect/php | Package | Purpose | | --- | --- | | `phpunit/phpunit` | PHP unit testing framework | +| `brain/monkey` | Mocks WordPress core functions/hooks in unit tests (pulls in `mockery/mockery`) so tests run without a WordPress install | | `wp-coding-standards/wpcs` | WordPress PHP Coding Standards ruleset for PHP_CodeSniffer | | `dealerdirect/phpcodesniffer-composer-installer` | Auto-registers PHPCS standards (including WPCS) with Composer | | `pestphp/pest` | Elegant PHP testing framework built on PHPUnit | +> **Latest versions:** Do not pin versions in `composer require`. Run +> `composer update` periodically to pick up new compatible releases. + +For how to write unit tests with Brain Monkey, see `php-testing.md`. + ## Scripts Merge these scripts into `composer.json`. Do NOT overwrite existing scripts — only add missing keys. diff --git a/plugins/wordpress-skills/skills/prepare-wordpress/references/copilot-instructions.md b/plugins/wordpress-skills/skills/prepare-wordpress/references/copilot-instructions.md new file mode 100644 index 0000000..8eb1021 --- /dev/null +++ b/plugins/wordpress-skills/skills/prepare-wordpress/references/copilot-instructions.md @@ -0,0 +1,92 @@ +# WordPress Copilot Coding Instructions + +This phase adds a project-scoped Copilot instructions file so agents follow +WordPress coding, security, i18n, performance, and testing best practices. + +Source: [github/awesome-copilot](https://github.com/github/awesome-copilot/blob/main/instructions/wordpress.instructions.md) +(MIT License). Prefer downloading the canonical file so it stays current. + +## Preferred: download the latest + +```sh +mkdir -p .github/instructions +curl -fsSL https://raw.githubusercontent.com/github/awesome-copilot/main/instructions/wordpress.instructions.md \ + -o .github/instructions/wordpress.instructions.md +``` + +The `applyTo` frontmatter in that file scopes the rules to WordPress plugin, +theme, PHP, JS, and CSS paths automatically. + +## Fallback: create manually (offline) + +If `curl` is unavailable, create `.github/instructions/wordpress.instructions.md` +with the content below. This is a condensed version adapted from +github/awesome-copilot (MIT); replace it with the canonical file when online. + +````markdown +--- +applyTo: 'wp-content/plugins/**,wp-content/themes/**,**/*.php,**/*.inc,**/*.js,**/*.jsx,**/*.ts,**/*.tsx,**/*.css,**/*.scss,**/*.json' +description: 'Coding, security, and testing rules for WordPress plugins and themes' +--- + +# WordPress Development — Copilot Instructions + +Generate WordPress code that is secure, performant, testable, and compliant with +official WordPress practices. Prefer hooks, small functions, and clear separation +of concerns. + +## Core principles +- Never modify WordPress core. Extend via actions and filters. +- Guard entry PHP files with `defined('ABSPATH') || exit;` and a plugin header. +- Use unique prefixes or PHP namespaces to avoid global collisions. +- Enqueue assets; never inline raw `