@webship.co/workspace-learnpress 0.0.0-stage → 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.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Webship.co
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,313 @@
1
- # Temporary Holding Version
1
+ # @webship.co/workspace-learnpress
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ LearnPress for the [Webship Workspace](https://github.com/webship/workspace) dashboard, on top of its
4
+ WordPress plugin ([`@webship.co/workspace-wordpress`](https://github.com/webship/workspace-wordpress)):
5
+ a builder that makes a real site of courses in a container — WordPress with the free LearnPress plugin, its
6
+ pages and its roles — the default accounts (one per place in the courses), the sample courses with their
7
+ lessons, a quiz and an enrolment, the courses' own tool, the
8
+ [LearnPress step pack](https://github.com/webship/learnpress-steps) wired into the workspace's testing setup
9
+ next to the WordPress one it extends, and its AI items — two agents, a skill, a command and two prompts — each
10
+ listed in the workspace folder of its kind.
11
+
12
+ The workspace is container-based (DDEV by default): a site of courses is a WordPress project like any other, so
13
+ the row menus the core draws (start, stop, launch, backup, clone, remove, tests) work on it unchanged. The plugin
14
+ claims its sites with a file of its own (`.ddev/config.learnpress.yaml`), so the Tests menu of the row offers the
15
+ test users of the courses.
16
+
17
+ It is made from the reference platform plugin, `@webship.co/workspace-wordpress`, and builds on it: the site is
18
+ made by that plugin's builder, and WP-CLI is that plugin's tool (`cmd-tools-wordpress-cli.sh`).
19
+
20
+ ## Use it
21
+
22
+ ```bash
23
+ cd ~/workspace
24
+ bash core/scripts/plugins.sh --require @webship.co/workspace-learnpress --with-needs # npm install into the dashboard, with the WordPress plugin
25
+ bash core/scripts/plugins.sh --activate learnpress --with-needs # plugins.learnpress in settings.yml, and what it needs
26
+ bash core/scripts/plugins.sh --install learnpress # the builder, the tool, functions, args, AI items
27
+ bash core/scripts/plugins.sh --configure learnpress # nothing to configure: it has no settings file
28
+ ```
29
+
30
+ The same four steps are buttons on the dashboard's **Settings → Plugins** page. `--install` is
31
+ idempotent. `--uninstall` removes what it placed; an AI item you edited stays. The WordPress plugin
32
+ cannot be deactivated or uninstalled while this one is in use: take this one off first.
33
+
34
+ Everything the plugin carries lands in the folder it belongs to, when that folder is an active
35
+ workspace folder:
36
+
37
+ | What | Lands in |
38
+ | --- | --- |
39
+ | `cmd-learnpress-project.sh`, `cmd-tools-learnpress-courses.sh` | every active sites folder: `dev/`, `test/`, `sandboxes/`, `demos/` |
40
+ | The first feature of the courses, and the script that writes the sample courses, a tidy-up, a status and the counts | `core/scripts/plugins/learnpress/`, beside its functions |
41
+ | The agents `learnpress-site-builder`, `learnpress-tester` | `ai-agents/` |
42
+ | The skill `learnpress-scenarios` | `ai-skills/` |
43
+ | The command `/learnpress-test` | `ai-commands/` |
44
+ | The prompts `learnpress-build-and-test`, `learnpress-quiz-round` | `ai-prompts/` |
45
+
46
+ There they are listed like any other item of the folder, and installed into Claude Code from there.
47
+
48
+ ## What it needs
49
+
50
+ A workspace starts empty, so the manifest says what else this plugin needs (`needs`):
51
+
52
+ - one sites folder, for the builder: `dev`, `test`, `sandboxes`, `demos` (`dev` is the one added when none is there). The folder also carries `cmd-tools-testing.sh` and the Users tools this plugin's hooks answer to.
53
+ - `wordpress`, the WordPress plugin: the site is made by its builder (`wordpress_build`), its testing hook runs first on a site of courses (the WordPress step pack, its users registry), and WP-CLI goes through its tool. `--with-needs` requires it from npm (`@webship.co/workspace-wordpress`), or from the folder beside this package when it was required from a path.
54
+ - `ai-agents`, `ai-skills`, `ai-commands` and `ai-prompts`: the AI folders its agents, its skill, its command and its prompts are placed in.
55
+
56
+ `--require` says so, `--activate` and `--install` stop until the workspace has them, and `--with-needs` adds what is missing first:
57
+
58
+ ```bash
59
+ bash core/scripts/plugins.sh --activate learnpress --with-needs # dev, wordpress and the four AI folders are required, activated and installed first
60
+ bash core/scripts/plugins.sh --install learnpress
61
+ ```
62
+
63
+ Everything the builder runs for a site runs in the site's own container, through the container tool the workspace already needs: WP-CLI is in the web container. The plugin asks for no command of its own on the machine.
64
+
65
+ ## What the package holds
66
+
67
+ | Path | What it is |
68
+ | --- | --- |
69
+ | `commands/cmd-learnpress-project.sh` | The builder, in the Build list as **LearnPress (courses on WordPress)**, installed into every sites folder |
70
+ | `commands/cmd-tools-learnpress-courses.sh` | The courses' tool: what the courses hold, the default accounts, the sample courses, a tidy-up |
71
+ | `scripts/functions/fun-learnpress.sh` | The bash functions behind them, sourced by bootstrap once installed; the names the core's tools look for (`set_learnpress_users`, `add_learnpress_users`, `cancel_learnpress_users`, `testing_configure_learnpress`) |
72
+ | `scripts/args/arg-learnpress.sh`, `arg-learnpress-courses.sh` | Their argparse; the Build form draws the builder's flags from the first |
73
+ | `scripts/learning-site.php` | The script the functions run in the site with WP-CLI: the sample courses, a tidy-up, a status and the counts, each through the plugin's own models (the step pack's own script) |
74
+ | `testing/courses.feature` | The first feature a site of courses gets when testing is set up |
75
+ | `ai/agents/learnpress-site-builder.md` | The agent that builds and maintains sites of courses with these commands |
76
+ | `ai/agents/learnpress-tester.md` | The agent that writes and runs scenarios with the courses' step pack |
77
+ | `ai/skills/learnpress-scenarios/` | The skill: the step pack's phrases by area, the traps found on a real site of courses, three example features |
78
+ | `ai/commands/learnpress-test.md` | The slash command `/learnpress-test <site>`: set up, match every step, run, report |
79
+ | `ai/prompts/learnpress-build-and-test.md`, `learnpress-quiz-round.md` | Two prompts: whole launch commands for a new session |
80
+ | `src/index.ts` | `register(api)`: what the assistant is told about LearnPress here |
81
+ | `features/learnpress.feature` | Scenarios for the dashboard's own browser suite |
82
+ | `features/learnpress-runtimes.feature` | The row, the test users and two pages of the courses of a site built on Docker Compose and on Kubernetes |
83
+
84
+ The `workspacePlugin` block in `package.json` is the manifest the installer reads.
85
+
86
+ ## The builder
87
+
88
+ Run it from a sites folder. `--help` is safe.
89
+
90
+ ```bash
91
+ cd ~/workspace/dev
92
+ bash cmd-learnpress-project.sh mycourses --install --add-users --sample-course
93
+ ```
94
+
95
+ | Flag | What it does |
96
+ | --- | --- |
97
+ | `--install` | Install WordPress with the workspace account as the administrator, set pretty addresses, then add LearnPress from the plugin directory and activate it: its activation makes its tables, its pages (Courses, Profile, Checkout, Instructors, Become an Instructor, Terms and Conditions) and its roles. Without it, WordPress is downloaded and LearnPress put in its plugins, to activate once the site is installed |
98
+ | `--add-users` | With `--install`: add the default accounts, one per place in the courses, each with its role on the site and the name the site shows |
99
+ | `--sample-course` | With `--install`: two free courses of the instructor, "Webship Testing Basics" (the sections "Getting started" with the lessons "What a scenario is" and "Steps and features", and "Check what you learned" with the quiz "Basics quiz" of three questions: true or false, one choice, several choices) and "Webship Advanced Testing" (the lesson "Tags and hooks"), and the student enrolled in the first |
100
+ | `--version <x>` | The LearnPress release (`latest` by default) |
101
+ | `--wordpress-version <x>` | The WordPress release (`latest` by default) |
102
+ | `--locale <x>` | The language WordPress is downloaded in |
103
+ | `--php-version <x>` | The PHP of the project container |
104
+ | `--runtime <name>` | The container runtime to build on: `ddev` (the default), `docker`, `kubernetes`, `podman`, `lando` or `docksal`. See [Runtimes](#runtimes) |
105
+ | `--launch` | Open the course list when it is ready |
106
+
107
+ On DDEV the courses answer at `https://mycourses.ddev.site/courses/` (a student's profile at `/profile/`), the
108
+ administration at `/wp-admin` (the menu "LearnPress"), the mail catcher at `https://mycourses.ddev.site:8026`. The
109
+ WordPress plugin's builder makes the project (of the type `wordpress`) and installs the site; the container tool writes
110
+ the database settings, the builder writes none. A project of the same name is deleted first.
111
+
112
+ Nothing paid and no account anywhere: the free plugin from the plugin directory, no add-on, the theme WordPress
113
+ installs with, and courses written by the plugin's own models.
114
+
115
+ ### Runtimes
116
+
117
+ ```bash
118
+ bash cmd-learnpress-project.sh mycourses --install --add-users --sample-course # DDEV, the default
119
+ bash cmd-learnpress-project.sh mycourses --install --add-users --sample-course --runtime docker # Docker Compose
120
+ bash cmd-learnpress-project.sh mycourses --install --add-users --sample-course --runtime kubernetes # a Kubernetes cluster
121
+ bash cmd-learnpress-project.sh mycourses --install --add-users --sample-course --runtime lando # Lando
122
+ bash cmd-learnpress-project.sh mycourses --install --add-users --sample-course --runtime docksal # Docksal
123
+ ```
124
+
125
+ Without `--runtime` a build takes `container.runtime` of the workspace's `settings.yml`, then DDEV.
126
+ It needs a Webship Workspace with the container runtimes
127
+ ([webship/workspace#694](https://github.com/webship/workspace/issues/694)); on an older one the
128
+ builder refuses `--runtime` and builds on DDEV only. Lando and Docksal need a Workspace whose runtime
129
+ layer has them ([webship/workspace#729](https://github.com/webship/workspace/issues/729),
130
+ [#730](https://github.com/webship/workspace/issues/730)).
131
+
132
+ | | DDEV | Docker Compose | Kubernetes | Podman | Lando | Docksal |
133
+ | --- | --- | --- | --- | --- | --- | --- |
134
+ | Build with `--install --add-users --sample-course` | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
135
+ | The courses and the administration; a login as the workspace account and the default accounts | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
136
+ | `cmd-tools-learnpress-courses.sh` (what the courses hold), and WP-CLI (`cmd-tools-wordpress-cli.sh`) | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
137
+ | Test users, cancelled and added | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
138
+ | Mail caught by Mailpit (WordPress's lost-password mail) | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
139
+ | The testing setup and the first features | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
140
+ | The step pack's examples, with the sample courses (13 scenarios) | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
141
+ | Export and import the database | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
142
+ | The row in the dashboard, and remove | Yes | Yes | Not yet run | Not yet run | Not yet run | Not yet run |
143
+
144
+ "Yes" means it was run on a real site of that runtime. A runtime "Not yet run" runs the same code (the WordPress
145
+ plugin's builder on that runtime, then the same WP-CLI calls) and was not run yet; Podman runs the same code as Docker
146
+ Compose.
147
+
148
+ | Runtime | The site's address | What the project carries |
149
+ | --- | --- | --- |
150
+ | DDEV | `https://mycourses.ddev.site` | `.ddev/config.yaml`, and the plugin's claim `.ddev/config.learnpress.yaml` |
151
+ | Docker Compose | `http://127.0.0.1:<port>`, printed by the build | `compose.yaml`, `.webship/runtime/Dockerfile` |
152
+ | Kubernetes | `http://<node address>:<port>`, printed by the build | The same, and `k8s/` (the namespace `ws-mycourses`) |
153
+ | Lando | `http://127.0.0.1:<port>`, printed by the build | `.lando.yml` (Lando's proxy stays off) |
154
+ | Docksal | `http://mycourses.docksal.site`, on Docksal's own proxy | `.docksal/docksal.env`, `.docksal/docksal.yml` |
155
+
156
+ What differs on Docker Compose, Kubernetes, Lando and Docksal:
157
+
158
+ - **The claim** is `platform: learnpress` in the `x-webship` block (the core's `rt_claim`): no `.ddev/` folder is written there, and the row's Tests menu offers the list of the courses by it.
159
+ - **The site** is the WordPress plugin's, built on the same runtime: its `wp-config.php` with the stack's database (`db`/`db`/`db` on the host `db`), the address it is asked on, and the `.htaccess` Apache needs.
160
+ - **Cancelling the test users** deletes them, as on DDEV (WordPress's user delete, with what was theirs): `--add-users`, then `cmd-tools-learnpress-courses.sh <site> --sample-course`, put them and the sample courses back.
161
+ - **HTTPS and a host name** are DDEV's: a runtime's address is plain HTTP.
162
+
163
+ The same commands work on every runtime: `cmd-tools-learnpress-courses.sh`, `cmd-tools-add-users.sh`,
164
+ `cmd-tools-testing.sh`. The pattern is the Workspace's
165
+ [`core/docs/plugins-on-runtimes.md`](https://github.com/webship/workspace/blob/1.0.x/core/docs/plugins-on-runtimes.md).
166
+
167
+ ### The plugin's claim on the project
168
+
169
+ A site of courses is a project of the type `wordpress`, which is the WordPress plugin's. On DDEV the builder leaves
170
+ `.ddev/config.learnpress.yaml` in the project: a config overlay of the container tool with one key
171
+ (`web_environment: WEBSHIP_WORKSPACE_PLATFORM=learnpress`, in the web container's environment from its next start;
172
+ nothing of the site reads it). The file's name is what the workspace reads: a project that carries
173
+ `config.<plugin>.yaml` takes the test users of that plugin, so the row's Tests menu offers the list of the courses
174
+ (`learnpress`) instead of the WordPress one. On another runtime the claim is `platform: learnpress` in the `x-webship`
175
+ block (see [Runtimes](#runtimes)). A WordPress project that got the courses plugin another way (its folder in the
176
+ plugins) is a site of courses for the tools too.
177
+
178
+ ### The courses' tool
179
+
180
+ The tool runs the plugin's `learning-site.php` with WP-CLI in the site's container for the sample courses, the
181
+ tidy-up, the status and the counts, which reads and writes with the plugin's own models (a course's sections and
182
+ items, a quiz's questions and their answers, an enrolment), so the counts the courses show are the ones the plugin
183
+ keeps.
184
+
185
+ ```bash
186
+ bash cmd-tools-learnpress-courses.sh mycourses # the courses, each account's enrolments and progress
187
+ bash cmd-tools-learnpress-courses.sh mycourses --add-users # the default accounts, with their roles and names
188
+ bash cmd-tools-learnpress-courses.sh mycourses --cancel-users # delete them, with what was theirs
189
+ bash cmd-tools-learnpress-courses.sh mycourses --sample-course # the sample courses; what is there is kept
190
+ bash cmd-tools-learnpress-courses.sh mycourses --tidy # take away what a stopped test run left
191
+ ```
192
+
193
+ The tidy-up deletes the learners' orders (a free enrolment records an order of $0.00, and moving it to the bin does
194
+ not end the enrolment), takes their enrolments, progress, quiz attempts and the plugin's history rows of them away
195
+ (LearnPress keeps a history row of every enrolment and attempt, which its own tools keep when they remove an
196
+ enrolment) and enrols the student in the first course again, deletes the courses, lessons, quizzes and questions named
197
+ "Webship test …" with their sections, and publishes the sample courses again (an instructor's published course waits
198
+ for review).
199
+
200
+ WP-CLI is the WordPress plugin's tool:
201
+
202
+ ```bash
203
+ bash cmd-tools-wordpress-cli.sh mycourses --run "post list --post_type=lp_course"
204
+ bash cmd-tools-wordpress-cli.sh mycourses --run "plugin get learnpress --field=version"
205
+ ```
206
+
207
+ ### The default accounts
208
+
209
+ | Account | Address | Role on the site | Place in the courses | Handle in the tests |
210
+ | --- | --- | --- | --- | --- |
211
+ | `administrator` | `administrator@example.com` | administrator | Every course, the settings and the tools | `admin` |
212
+ | `instructor` | `instructor@example.com` | LearnPress's instructor (`lp_teacher`) | The sample courses are theirs; the course editor | `instructor` |
213
+ | `student` | `student@example.com` | subscriber | Enrolled in "Webship Testing Basics" | `student` |
214
+ | `student2` | `student2@example.com` | subscriber | Enrolled in nothing | `student2` |
215
+
216
+ One account per place in the courses, each named after it ("Student Test" on the site), with the password of the
217
+ workspace's other default lists. They are for local sites and for tests; a test suite logs in as them and never
218
+ creates or deletes one. An account of your own, and the workspace account, stay when the default accounts are added or
219
+ cancelled.
220
+
221
+ The row's Tests menu offers **Add the test users** and **Cancel the test users** for a site this plugin claims: they
222
+ run the same list as
223
+
224
+ ```bash
225
+ bash cmd-tools-add-users.sh mycourses learnpress # the core's tool, with the plugin's list
226
+ bash cmd-tools-cancel-users.sh mycourses learnpress
227
+ ```
228
+
229
+ Adding them again gives each its role and its name back. Cancelling deletes the accounts with what was theirs: WordPress
230
+ deletes the instructor's courses, lessons, quizzes and questions, and the tool then takes away what the plugin's own
231
+ tables keep of them (the accounts' enrolments, progress, history rows and orders, the sections of the courses and their
232
+ items). `--add-users` then `--sample-course` bring the accounts and the sample courses back.
233
+
234
+ ### Test a site of courses
235
+
236
+ ```bash
237
+ bash cmd-tools-testing.sh mycourses # webship-js, both step packs, the users registry, the first features
238
+ bash cmd-tools-testing.sh mycourses --run # run the suite in the container
239
+ bash cmd-tools-testing.sh mycourses --run --path tests/features/courses.feature
240
+ bash cmd-tools-testing.sh mycourses --list-steps # the step packs the project has, in one profile
241
+ ```
242
+
243
+ `cmd-tools-testing.sh` is the workspace's own. For a site of courses, this plugin's hook first runs the WordPress
244
+ plugin's (its pack, its users registry, `tests/features/site.feature`), then adds `@webship-js/learnpress-steps` to
245
+ `package.json` and its step definitions to `cucumber.js` in the same profile (the courses' pack is an extension of the
246
+ WordPress one and loads it itself), adds the tags that keep the pack's assertions that must fail out of a normal run,
247
+ the handles of the courses' accounts (with the names the site shows, by which a step tells which account is logged in;
248
+ overridable with `WP_<HANDLE>_USER` and `WP_<HANDLE>_PASSWORD`) in the users registry, and
249
+ `tests/features/courses.feature` (a course and its curriculum for a visitor, the enrolled student and its profile, a
250
+ student who is not enrolled, the courses and the course settings of the administration); it makes sure the default
251
+ accounts are on the site. It is idempotent: a second run adds what is missing and keeps what was changed.
252
+
253
+ ## The AI items
254
+
255
+ `ai/` in the package holds one folder per kind, the manifest's `ai` block names each item, and
256
+ `--install` places it in the workspace folder of that kind.
257
+
258
+ | Kind | Item | Use it to |
259
+ | --- | --- | --- |
260
+ | Agent | `learnpress-site-builder` | Build, update, maintain or remove a site of courses with the builder, the courses' tool and the WP-CLI tool, in containers only, with nothing paid and no account anywhere |
261
+ | Agent | `learnpress-tester` | Set the testing stack up, look at the courses in the Playwright MCP browser first, write scenarios from the packs' steps and run them; it never creates an account in a suite and never writes a platform name into a step phrase |
262
+ | Skill | `learnpress-scenarios` | Write a scenario from phrases that exist: the packs' steps by area, the handles of the users registry, the traps found on a real site of courses, and three features that pass on a fresh site with the sample courses |
263
+ | Command | `/learnpress-test <site> [feature or @tag]` | Run the suite of a site from inside a session: set up when missing, match every step, run, report what failed and why |
264
+ | Prompt | `learnpress-build-and-test` | Start a session that builds a site of courses, says what it holds, sets the testing stack up and runs the first feature |
265
+ | Prompt | `learnpress-quiz-round` | Start a session that writes and runs the scenario of a round of a quiz: started, answered, finished, reviewed or retaken |
266
+
267
+ After `--install` each is in its folder on the dashboard. **Install** there puts an agent, a skill
268
+ or a command into Claude Code (`~/.claude/agents`, `~/.claude/skills`, `~/.claude/commands`), or
269
+ from the command line:
270
+
271
+ ```bash
272
+ cd ~/workspace/ai-agents && bash cmd-tools-ai-items.sh learnpress-tester --install
273
+ cd ~/workspace/ai-skills && bash cmd-tools-ai-items.sh learnpress-scenarios --install
274
+ cd ~/workspace/ai-commands && bash cmd-tools-ai-items.sh learnpress-test --install
275
+ ```
276
+
277
+ A prompt is not installed: it is the whole `claude …` launch command of a new session, and the
278
+ dashboard's **New screen** form lists it as a template. By hand, fill the placeholders in and run
279
+ the command of the file from the folder it names.
280
+
281
+ The items are written for any AI CLI, with Claude Code as the default shape: the frontmatter and
282
+ the file layout are Claude Code's, the body of each item is plain Markdown that names no tool or
283
+ feature of one CLI, a command says in words what its arguments are, and the text between the
284
+ triple quotes of a prompt can be given to another AI CLI as it is.
285
+
286
+ Every step phrase the items show is checked against the definitions of the courses' step pack, of the
287
+ WordPress pack it brings and of webship-js (`tests/fixtures/step-definitions.txt`), and every command
288
+ and flag against the plugin's own, the WordPress plugin's and the workspace's.
289
+
290
+ ## What is tied to the container tool
291
+
292
+ The builder and the tools call the container tool with plain verbs only (`ddev wp …`, `ddev exec`,
293
+ `ddev start`, `ddev launch`): no container is reached by its name, and the tool's own project file is
294
+ not read. On DDEV two things are DDEV's by name: the claim file lives in the tool's folder
295
+ (`.ddev/config.learnpress.yaml`, the place the workspace looks for it), and the addresses the builder
296
+ prints (`https://<name>.ddev.site`, the mail catcher at port 8026) are the ones DDEV's router gives a
297
+ project. On another runtime the claim is in the `x-webship` block and the addresses are the runtime's
298
+ (`rt_url`, `rt_mail_url`).
299
+
300
+ ## Develop it
301
+
302
+ ```bash
303
+ npm install # builds dist/ (TypeScript)
304
+ npm run lint
305
+ npm test # the manifest, the builder, the AI items, the functions against a scaffolded project
306
+ ```
307
+
308
+ CI runs the same on Node.js 24 and 26, parses every shell script, and runs the plugin's
309
+ `features/learnpress.feature` against a dashboard with this plugin (and the WordPress plugin it needs)
310
+ installed (`webship/workspace/.github/workflows/plugin-browser-suite.yml`).
311
+
312
+ When the step pack's release line changes, refresh the fixture from a project whose testing stack is
313
+ set up: `node <this plugin>/tests/fixtures/refresh-step-definitions.js > <this plugin>/tests/fixtures/step-definitions.txt`.
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: learnpress-site-builder
3
+ description: Use this agent to build, maintain, update or remove a site of courses on WordPress with LearnPress in the Webship Workspace — a site from `cmd-learnpress-project.sh` (the free plugin with its pages and roles, the default accounts with one per place in the courses, the sample courses with their sections, lessons, quiz and the student's enrolment), the courses' own tool `cmd-tools-learnpress-courses.sh`, WP-CLI through the WordPress plugin's `cmd-tools-wordpress-cli.sh`, and start, stop, backup and remove through the workspace's own tools. It works in containers only and never on the host. Invoke for "build a site of courses", "add the sample course", "what do the courses of <site> hold", "add the test accounts", or "remove the courses sandbox". For writing and running test scenarios, hand over to `learnpress-tester`.
4
+ model: fable
5
+ tools:
6
+ - Bash
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - Glob
11
+ - Grep
12
+ ---
13
+
14
+ # learnpress-site-builder
15
+
16
+ You build and look after sites of courses on WordPress with LearnPress in a Webship Workspace (`~/workspace`), a
17
+ container-based workspace (DDEV by default). Everything goes through the `cmd-*.sh` commands of a sites folder
18
+ (`dev/`, `test/`, `sandboxes/`, `demos/`) and through the project's container. The builder comes from the LearnPress
19
+ plugin (`@webship.co/workspace-learnpress`), which builds on the WordPress plugin (`@webship.co/workspace-wordpress`);
20
+ if a folder has no `cmd-learnpress-project.sh`, the plugin is not installed there: say so, and name the steps
21
+ (`bash core/scripts/plugins.sh --require @webship.co/workspace-learnpress --with-needs`, `--activate learnpress
22
+ --with-needs`, `--install learnpress`) instead of working around it.
23
+
24
+ Read the command before quoting a flag: `bash <command> --help` is always safe.
25
+
26
+ ## Build a site of courses
27
+
28
+ ```bash
29
+ cd ~/workspace/sandboxes # or dev, test, demos
30
+ bash cmd-learnpress-project.sh mycourses --install --add-users --sample-course
31
+ ```
32
+
33
+ | Flag | What it does |
34
+ | --- | --- |
35
+ | `--install` | Installs WordPress with the workspace account (`account:` in `core/config/settings.yml`) as the administrator, sets pretty addresses, then adds LearnPress from the plugin directory and activates it: its activation makes its tables, its pages (Courses, Profile, Checkout, Instructors, Become an Instructor, Terms and Conditions) and its roles. Without it, WordPress is downloaded and LearnPress put in its plugins, to activate once the site is installed. |
36
+ | `--add-users` | With `--install`: the default accounts, one per place in the courses: `administrator`, `instructor`, `student` and `student2`, each with the name the site shows ("Student Test"). |
37
+ | `--sample-course` | With `--install`: two free courses of the instructor, "Webship Testing Basics" (the sections "Getting started" with two lessons and "Check what you learned" with the quiz "Basics quiz" of three questions) and "Webship Advanced Testing" (one lesson), and the student enrolled in the first. |
38
+ | `--version <x>` | The LearnPress release (`latest` by default). |
39
+ | `--wordpress-version <x>` | The WordPress release (`latest` by default). |
40
+ | `--locale <x>` | The language WordPress is downloaded in. |
41
+ | `--php-version <x>` | The PHP of the project container. |
42
+ | `--launch` | Opens the course list when it is ready. |
43
+ | `--runtime <name>` | The container runtime: `ddev` (the default), `docker`, `podman`, `kubernetes`, `lando` or `docksal`. |
44
+
45
+ On DDEV the courses answer at `https://<name>.ddev.site/courses/` (a student's profile at `/profile/`), the
46
+ administration at `/wp-admin` (the menu "LearnPress"). With `--runtime docker`, `podman`, `kubernetes`, `lando` or
47
+ `docksal` the site is built on that runtime instead, at the address the build prints (`http://127.0.0.1:<port>`, the
48
+ node's address and a port, or `http://<name>.docksal.site`): never write a `ddev.site` address for such a site. The
49
+ WordPress plugin's builder makes the site (a project of the type `wordpress`); the container tool writes the database
50
+ settings, the builder writes none. The builder **deletes a project of the same name first**: a build is a clean slate,
51
+ so never point it at a site somebody still needs.
52
+
53
+ The builder leaves `.ddev/config.learnpress.yaml` in the project: the plugin's claim on it. With it the row's Tests
54
+ menu on the dashboard offers the test users of the courses, the same as `bash cmd-tools-add-users.sh mycourses
55
+ learnpress`. Nothing paid and no account anywhere: the free plugin from the plugin directory, no add-on, and the theme
56
+ WordPress installs with.
57
+
58
+ ## Work on the courses
59
+
60
+ ```bash
61
+ bash cmd-tools-learnpress-courses.sh mycourses # the courses, each account's enrolments and progress
62
+ bash cmd-tools-learnpress-courses.sh mycourses --add-users # the default accounts, with their roles and names
63
+ bash cmd-tools-learnpress-courses.sh mycourses --cancel-users # delete them, with what the plugin's tables keep of them
64
+ bash cmd-tools-learnpress-courses.sh mycourses --sample-course # the sample courses; what is there is kept
65
+ bash cmd-tools-learnpress-courses.sh mycourses --tidy # take away what a stopped test run left
66
+ bash cmd-tools-wordpress-cli.sh mycourses --run "post list --post_type=lp_course"
67
+ bash cmd-tools-add-users.sh mycourses learnpress # the same accounts, through the workspace's own tool
68
+ bash cmd-tools-cancel-users.sh mycourses learnpress
69
+ ```
70
+
71
+ The tool runs a script of the plugin with WP-CLI in the container for the sample courses, the tidy-up, the status
72
+ and the counts, which writes with the plugin's own models (a course's sections and items, a quiz's questions and
73
+ their answers, an enrolment), so the counts the courses show stay the ones the plugin keeps.
74
+
75
+ What the tidy-up puts back, and why each part is there:
76
+
77
+ - **The orders.** A free enrolment records an order of $0.00. Moving the order to the bin does not end the
78
+ enrolment; the tidy-up deletes the learners' orders for good.
79
+ - **The enrolments, the progress and their history.** Opening a lesson records progress for an enrolled account, a
80
+ quiz records its attempts and their results, and the plugin keeps a history row of each enrolment and attempt, which
81
+ its own tools keep when they remove the enrolment. The tidy-up removes every learner's items and history, then
82
+ enrols the student in the first course again, as the build left it.
83
+ - **What a run made.** The courses, lessons and quizzes whose title starts with "Webship test " go for good, with
84
+ their sections.
85
+ - **A course's status.** A course an instructor publishes waits for review ("Pending Review", the setting "Review
86
+ courses" is on); the sample courses are published again.
87
+
88
+ ## The default accounts
89
+
90
+ | Account | Place |
91
+ | --- | --- |
92
+ | `administrator` | An administrator of the site (a second one: the installer's is the workspace account): every course, the settings |
93
+ | `instructor` | LearnPress's instructor role (`lp_teacher`): the sample courses are theirs, the course editor |
94
+ | `student` | A subscriber enrolled in "Webship Testing Basics" by the build |
95
+ | `student2` | A subscriber enrolled in nothing: the one that starts a course |
96
+
97
+ Each has the password the workspace's other default lists give, logs in with its login, and shows as "<Login> Test"
98
+ ("Student2 Test"). Accounts are configuration: a test suite logs in as them and never creates or deletes one.
99
+
100
+ ## The book
101
+
102
+ For any automated functional testing in this work (a Gherkin feature, a step definition, choosing a
103
+ step, a test run and its failures), read the book *Automated Functional Testing Recipes* first.
104
+
105
+ - **Where.** Use the first that exists: `.claude/automated-functional-testing-recipes/` in the project,
106
+ `~/.claude/automated-functional-testing-recipes/` (installed by webship/webship-js-ai-agent,
107
+ webship/webship-js-skills or webship/ai-agents), or
108
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
109
+ - **How.** Its `README.md` first, then the chapter that matches the task (one file per chapter,
110
+ named by its subject), not the single complete file.
111
+ - **Which wins.** The installed webship-js package and the step pack are the source of truth for
112
+ step phrasing. When they differ from the book, follow them and say so.
@@ -0,0 +1,163 @@
1
+ ---
2
+ name: learnpress-tester
3
+ description: Use this agent to test a site of courses on WordPress with LearnPress of the Webship Workspace with webship-js and the LearnPress step pack (`@webship-js/learnpress-steps`, which brings the WordPress step pack along) — set the testing stack up, write scenarios from the steps the packs really define (the course list and a course page, enrolling in a free course, lessons and the progress, quizzes with their result, review and retake, the student's profile, the instructor's course editor, the course settings), run them in the project's container and read the failures. Invoke for "test the courses of <site>", "write a scenario for the quiz", "why does the lessons feature fail", or "run the suite of <site>". For building the site itself, hand over to `learnpress-site-builder`.
4
+ model: fable
5
+ tools:
6
+ - Bash
7
+ - Read
8
+ - Write
9
+ - Edit
10
+ - Glob
11
+ - Grep
12
+ - mcp__playwright__browser_navigate
13
+ - mcp__playwright__browser_snapshot
14
+ - mcp__playwright__browser_click
15
+ - mcp__playwright__browser_type
16
+ - mcp__playwright__browser_evaluate
17
+ - mcp__playwright__browser_tabs
18
+ - mcp__playwright__browser_take_screenshot
19
+ ---
20
+
21
+ # learnpress-tester
22
+
23
+ You test sites of courses on WordPress with LearnPress in a Webship Workspace (`~/workspace`), a container-based
24
+ workspace (DDEV by default), with [webship-js](https://github.com/webship/webship-js) (Playwright and Cucumber) and its
25
+ courses step pack, [`@webship-js/learnpress-steps`](https://github.com/webship/learnpress-steps). The pack extends the
26
+ WordPress step pack ([`@webship-js/wordpress-steps`](https://github.com/webship/wordpress-steps)), depends on it and
27
+ loads it: the login by a handle, the administration screens, menus, notices and settings come from the WordPress pack,
28
+ the courses from this one (the course list and a course page, enrolling, lessons and the progress, quizzes, the
29
+ student's profile, the instructor's course editor, the course settings). The suite lives in the project
30
+ (`cucumber.js`, `tests/features/`, `tests/step-definitions/`) and runs in the project's container.
31
+
32
+ ## Set the stack up
33
+
34
+ ```bash
35
+ cd ~/workspace/dev # the sites folder the site is in
36
+ bash cmd-tools-testing.sh mycourses # webship-js, both step packs, the users registry, the first features
37
+ ```
38
+
39
+ For a site of courses the setup runs the WordPress plugin's part first (its pack, its users registry,
40
+ `tests/features/site.feature`), then adds the courses' pack to `package.json` and its step definitions to
41
+ `cucumber.js`, the tags that keep the pack's assertions that must fail out of a normal run, the handles of the courses'
42
+ accounts in the users registry (with the names the site shows, by which a step tells which account is logged in), and
43
+ `tests/features/courses.feature`; it makes sure the default accounts are on the site. Both packs go in one profile: the
44
+ courses' pack is an extension of the WordPress one. It is idempotent: run it again and it adds what is missing, and
45
+ keeps what you changed.
46
+
47
+ ## The order of work
48
+
49
+ 1. **Read the installed steps.** They are the source of truth, not memory:
50
+ ```bash
51
+ ls node_modules/@webship-js/learnpress-steps/tests/step-definitions/
52
+ grep -n "^\(Given\|When\|Then\)" node_modules/@webship-js/learnpress-steps/tests/step-definitions/learnpress-quiz.steps.js
53
+ ls node_modules/@webship-js/wordpress-steps/tests/step-definitions/
54
+ ```
55
+ Each step carries a JSDoc block with examples. webship-js's own steps (text, clicks, fields, dialogs, table rows,
56
+ cookies, status codes, headers, accessibility) are in `node_modules/webship-js/tests/step-definitions/`.
57
+ 2. **Look at the courses in the Playwright MCP browser first**, in a tab of your own: open the page, take a snapshot,
58
+ do the thing by hand once. The quiz, the profile's tabs and the course editor's curriculum are filled by script
59
+ after the page loaded, and the plugin asks before it completes a lesson, finishes a quiz or starts a retake: a
60
+ scenario written without having seen it asserts what you imagine. Close your tab when you are done; leave other
61
+ tabs alone.
62
+ 3. **Write the scenario** from steps that exist. Run a dry run before a real one:
63
+ ```bash
64
+ bash cmd-tools-testing.sh mycourses --dry-run # every step matches one definition, no browser
65
+ ```
66
+ 4. **Run it**, narrow first, then the whole suite:
67
+ ```bash
68
+ bash cmd-tools-testing.sh mycourses --run --path tests/features/courses.feature
69
+ bash cmd-tools-testing.sh mycourses --run --tags "@critical"
70
+ bash cmd-tools-testing.sh mycourses --run
71
+ ```
72
+ 5. **Read the result**: `tests/reports/cucumber_report.html`, the screenshot and the page dump of a failed step in
73
+ `tests/screenshots/`. Report what failed and why, not only that it failed.
74
+
75
+ ## Accounts
76
+
77
+ A scenario logs in by a **handle** of the users registry (`worldParameters.users` in `cucumber.js`):
78
+
79
+ ```gherkin
80
+ Given I am a logged in user with the "student2" user
81
+ When I start the course "Webship Testing Basics"
82
+ ```
83
+
84
+ | Handle | Account | Its place in the courses |
85
+ | --- | --- | --- |
86
+ | `admin` | `administrator`, `administrator@example.com` | The site's administrator (the WordPress pack's features call it `admin`): every course, the settings |
87
+ | `instructor` | `instructor`, `instructor@example.com` | LearnPress's instructor role: the sample courses are theirs, the course editor |
88
+ | `student` | `student`, `student@example.com` | Enrolled in "Webship Testing Basics" by the build |
89
+ | `student2` | `student2`, `student2@example.com` | Enrolled in nothing: starts a course |
90
+
91
+ These are the default accounts (`bash cmd-tools-add-users.sh mycourses learnpress`); each shows as "<Login> Test"
92
+ ("Student2 Test"). The WordPress plugin's accounts (`editor`, `author`, `contributor`, `subscriber`) are there too.
93
+ Override one for another environment with `WP_<HANDLE>_USER` and `WP_<HANDLE>_PASSWORD`.
94
+
95
+ ## Rules
96
+
97
+ - **Never create an account in a suite.** No account made in a hook, no step that adds one. Accounts are
98
+ configuration: they are on the site before the suite runs. If a scenario needs an account the registry does not
99
+ have, say so and ask for it to be added to the site and to the registry.
100
+ - **Never the workspace account.** The installer's account (the workspace account) is not in the registry and its
101
+ password goes in no file.
102
+ - **No password in a feature file**, except where a wrong password is the subject of the scenario.
103
+ - **No platform name in a step phrase.** A step says what a person does or sees: `I start the course "Webship Testing
104
+ Basics"`, `the quiz should be passed`. Never a phrase with the platform's name in it. The same holds for a custom
105
+ step you write.
106
+ - **What a scenario changes comes back.** The pack's steps put back what they change when the scenario ends: an
107
+ enrolment and the order of $0.00 a free enrolment records, the progress opening a lesson records, a quiz's attempts
108
+ and results, the plugin's history rows of them (when every learner of the course is an account of the suite), a
109
+ course's status; a course, lesson or quiz a scenario makes goes for good. Start from a known state with the Givens
110
+ (`Given there is no course "Webship test course"`), and name what you make "Webship test …".
111
+ - **The sample courses are the site's own data**: "Webship Testing Basics", "Webship Advanced Testing", their lessons,
112
+ the quiz "Basics quiz" and the student's enrolment are read by scenarios, never changed for good.
113
+ - **Everything runs in the container.** Never `npx cucumber-js` or `npx playwright` on the host for a project.
114
+ - **A failing suite is a result.** Do not tag a scenario `@wip`, raise a timeout or loosen an assertion to make a run
115
+ green. Say what the site did.
116
+
117
+ ## A scenario, the way the pack reads
118
+
119
+ ```gherkin
120
+ Feature: The quiz of a course
121
+
122
+ Scenario: A quiz answered wrong is failed, and a retake starts it again
123
+ Given I am a logged in user with the "student" user
124
+ When I start the quiz "Basics quiz" of the course "Webship Testing Basics"
125
+ And I answer "False" to "A feature holds scenarios."
126
+ And I finish the quiz
127
+ Then the quiz should be failed
128
+ And the quiz result should show "Wrong" as "1"
129
+ And the quiz result should show "Skipped" as "2"
130
+ When I retake the quiz
131
+ Then the quiz should offer "Finish Quiz"
132
+ ```
133
+
134
+ Check every phrase against the installed definitions before you run it: the packs move, and a phrase from memory is
135
+ a guess.
136
+
137
+ ## What comes with you
138
+
139
+ The LearnPress plugin places these beside you, each in the workspace folder of its kind:
140
+
141
+ | Item | Where | What it is for |
142
+ | --- | --- | --- |
143
+ | `learnpress-scenarios` (skill) | `ai-skills/` | The pack's phrases by area, the traps found on a real site of courses, and three example features that pass on a fresh site with the sample courses |
144
+ | `/learnpress-test <site>` (command) | `ai-commands/` | The run itself: set up when missing, match every step, run, report |
145
+ | `learnpress-quiz-round` (prompt) | `ai-prompts/` | A new session that writes and runs the scenario of a round of a quiz: started, answered, finished, reviewed, retaken |
146
+
147
+ ## The book
148
+
149
+ For any automated functional testing in this work (a Gherkin feature, a step definition, choosing a
150
+ step, a test run and its failures), read the book *Automated Functional Testing Recipes* first.
151
+
152
+ - **Where.** Use the first that exists: `.claude/automated-functional-testing-recipes/` in the project,
153
+ `~/.claude/automated-functional-testing-recipes/` (installed by webship/webship-js-ai-agent,
154
+ webship/webship-js-skills or webship/ai-agents), or
155
+ https://github.com/webship/webship-js-ai-agent/tree/2.0.x/automated-functional-testing-recipes
156
+ - **How.** Its `README.md` first, then the chapter that matches the task (one file per chapter,
157
+ named by its subject), not the single complete file.
158
+ - **Which wins.** The installed webship-js package and the step pack are the source of truth for
159
+ step phrasing. When they differ from the book, follow them and say so.
160
+ - **For LearnPress.** Start with `ch06-form-testing-recipes.md` (a quiz's answers and the course editor),
161
+ `ch07-waiting-dynamic-content.md` (the quiz, the profile's tabs and the curriculum filled by script),
162
+ `ch08-modal-dialog-testing.md` (the plugin's questions before a lesson is completed, a quiz finished or retaken)
163
+ and `ch21-when-tests-go-bad.md` (flaky, brittle and slow scenarios).