@webship.co/workspace-craft-cms 0.0.0-stage → 1.0.8
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/README.md +214 -2
- package/ai/agents/craft-cms-site-builder.md +120 -0
- package/ai/agents/craft-cms-tester.md +139 -0
- package/ai/commands/craft-cms-test.md +90 -0
- package/ai/prompts/craft-cms-build-and-test.md +27 -0
- package/ai/skills/craft-cms-scenarios/SKILL.md +179 -0
- package/ai/skills/craft-cms-scenarios/examples/control-panel-navigation.feature +34 -0
- package/ai/skills/craft-cms-scenarios/examples/control-panel-session.feature +31 -0
- package/ai/skills/craft-cms-scenarios/examples/front-page.feature +15 -0
- package/commands/cmd-craft-cms-project.sh +35 -0
- package/commands/cmd-tools-craft-cms-cli.sh +26 -0
- package/dist/src/index.d.ts +32 -0
- package/dist/src/index.js +54 -0
- package/dist/src/index.js.map +1 -0
- package/docs/plugin-items-pattern.md +150 -0
- package/features/craft-cms.feature +30 -0
- package/package.json +95 -4
- package/scripts/args/arg-craft-cms-cli.sh +25 -0
- package/scripts/args/arg-craft-cms.sh +25 -0
- package/scripts/functions/fun-craft-cms.sh +333 -0
- package/testing/site.feature +39 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: craft-cms-scenarios
|
|
3
|
+
description: Write and run webship-js scenarios for a Craft CMS site of the Webship Workspace with the Craft CMS step pack (`@webship-js/craft-cms-steps`) — the phrases of the pack that a fresh site of the free Solo edition answers to (the control panel session, its navigation, its settings pages, what the admin may open, the public site), the one handle of the users registry, and the workspace command that runs them in the site's container. Use when asked to "write a scenario for this Craft site", "test the control panel login", "which step is there for the control panel navigation", "add a feature for the settings pages", or when a `.feature` file of a Craft CMS project is being written or fixed.
|
|
4
|
+
argument-hint: '<site> [what to cover]'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# craft-cms-scenarios
|
|
8
|
+
|
|
9
|
+
Scenarios for a Craft CMS site of a Webship Workspace (`~/workspace`, container-based, DDEV by
|
|
10
|
+
default), written from the steps of [`@webship-js/craft-cms-steps`](https://github.com/webship/craft-cms-steps)
|
|
11
|
+
and of [webship-js](https://github.com/webship/webship-js) itself, and run in the site's container
|
|
12
|
+
by the workspace's own command. It comes with the Craft CMS plugin
|
|
13
|
+
(`@webship.co/workspace-craft-cms`), like the builder (`cmd-craft-cms-project.sh`), the console
|
|
14
|
+
tool (`cmd-tools-craft-cms-cli.sh`) and the agents `craft-cms-site-builder` and
|
|
15
|
+
`craft-cms-tester`.
|
|
16
|
+
|
|
17
|
+
## Where everything is
|
|
18
|
+
|
|
19
|
+
| What | Where |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| The site | `~/workspace/<folder>/<site>`, at `https://<site>.ddev.site`, the control panel at `/admin` (`<folder>` is a sites folder: `dev`, `test`, `sandboxes`, `demos`) |
|
|
22
|
+
| The suite's configuration | `<site>/cucumber.js`: the step definitions it loads and the users registry (`worldParameters.users`) |
|
|
23
|
+
| The features | `<site>/tests/features/*.feature` (`site.feature` is the first one the setup wrote) |
|
|
24
|
+
| The pack's steps | `<site>/node_modules/@webship-js/craft-cms-steps/tests/step-definitions/*.steps.js` |
|
|
25
|
+
| webship-js's steps | `<site>/node_modules/webship-js/tests/step-definitions/*.js` |
|
|
26
|
+
| The reports | `<site>/tests/reports/` |
|
|
27
|
+
|
|
28
|
+
## The order of work
|
|
29
|
+
|
|
30
|
+
1. **Make sure the testing stack is there.** From the sites folder:
|
|
31
|
+
```bash
|
|
32
|
+
cd ~/workspace/<folder>
|
|
33
|
+
bash cmd-tools-testing.sh <site>
|
|
34
|
+
```
|
|
35
|
+
It adds webship-js, the step pack, the users registry and `tests/features/site.feature`. It is
|
|
36
|
+
safe to run again: it adds what is missing and keeps what was changed.
|
|
37
|
+
2. **Read the installed steps before writing a phrase.** They are the source of truth: the pack
|
|
38
|
+
moves, and a phrase from memory is a guess.
|
|
39
|
+
```bash
|
|
40
|
+
cd ~/workspace/<folder>/<site>
|
|
41
|
+
grep -hE "^(Given|When|Then)\(" node_modules/@webship-js/craft-cms-steps/tests/step-definitions/*.steps.js
|
|
42
|
+
```
|
|
43
|
+
Every step carries a comment block with examples above it; open the file when a phrase is not
|
|
44
|
+
obvious.
|
|
45
|
+
3. **Look at the page first** (the Playwright MCP browser, a tab of your own) when the scenario
|
|
46
|
+
is about a screen you have not seen. A scenario written without having seen the page asserts
|
|
47
|
+
what you imagine.
|
|
48
|
+
4. **Write the feature** in `<site>/tests/features/`, from phrases that exist (the lists below).
|
|
49
|
+
5. **Match every step without a browser**, then run the feature, then the suite:
|
|
50
|
+
```bash
|
|
51
|
+
cd ~/workspace/<folder>
|
|
52
|
+
bash cmd-tools-testing.sh <site> --dry-run --path tests/features/<name>.feature
|
|
53
|
+
bash cmd-tools-testing.sh <site> --run --path tests/features/<name>.feature
|
|
54
|
+
bash cmd-tools-testing.sh <site> --run --tags "@critical"
|
|
55
|
+
bash cmd-tools-testing.sh <site> --run
|
|
56
|
+
```
|
|
57
|
+
A dry run says `Undefined` for a phrase no definition matches: fix the phrase, do not write a
|
|
58
|
+
step for it.
|
|
59
|
+
|
|
60
|
+
## The account: one handle, never a password
|
|
61
|
+
|
|
62
|
+
A site built by the plugin is on the free Solo edition, which has one account, an admin, and no
|
|
63
|
+
user groups. The users registry has one handle for it:
|
|
64
|
+
|
|
65
|
+
| Handle | Account | Role |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| `admin` | `administrator` | admin, the only account of the site |
|
|
68
|
+
|
|
69
|
+
```gherkin
|
|
70
|
+
Given I am logged in to the control panel as "admin"
|
|
71
|
+
Then I should be logged in to the control panel as "admin"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
`bash cmd-tools-craft-cms-cli.sh <site> --add-users` says whether the one account of the site is
|
|
75
|
+
that default account; it creates none.
|
|
76
|
+
|
|
77
|
+
## The phrases, by area
|
|
78
|
+
|
|
79
|
+
Each line is a phrase the pack defines, and each one passed on a site built with
|
|
80
|
+
`bash cmd-craft-cms-project.sh <site> --install --add-users` (Craft CMS 5, the Solo edition; the
|
|
81
|
+
names in quotes are that site's).
|
|
82
|
+
|
|
83
|
+
### The control panel session
|
|
84
|
+
|
|
85
|
+
```gherkin
|
|
86
|
+
Given I am logged in to the control panel as "admin"
|
|
87
|
+
When I log in to the control panel with the username "nobody" and the password "wrong-password"
|
|
88
|
+
When I log out of the control panel
|
|
89
|
+
Then I should be logged in to the control panel as "admin"
|
|
90
|
+
Then I should not be logged in to the control panel
|
|
91
|
+
Then I should see the control panel login form
|
|
92
|
+
Then I should see the login error "Invalid username or password."
|
|
93
|
+
When I ask for a password reset for "nobody@example.com"
|
|
94
|
+
Then I should see the password reset confirmation
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The wrong login above is the one place a password stands in a scenario: it is the subject, and it
|
|
98
|
+
is nobody's.
|
|
99
|
+
|
|
100
|
+
### The control panel: navigation, pages, settings
|
|
101
|
+
|
|
102
|
+
```gherkin
|
|
103
|
+
Then the control panel heading should be "Dashboard"
|
|
104
|
+
Then the control panel navigation item "Dashboard" should be selected
|
|
105
|
+
Then I should see "Settings" in the control panel navigation
|
|
106
|
+
Then I should not see "Entries" in the control panel navigation
|
|
107
|
+
When I click "Settings" in the control panel navigation
|
|
108
|
+
When I go to the control panel page "settings/sections"
|
|
109
|
+
Then the control panel breadcrumb should be "Settings"
|
|
110
|
+
Then I should be allowed to open the control panel page "utilities"
|
|
111
|
+
Then I should not see an error notification
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### The public site
|
|
115
|
+
|
|
116
|
+
`I am an anonymous user`, `I am on the homepage`, `I go to "<path>"`,
|
|
117
|
+
`the page should have a title` and `the response status code should be 200` (or `404`) are
|
|
118
|
+
webship-js's own steps; its status codes, classes, landmarks and accessibility audits are used as
|
|
119
|
+
they are and never redefined for this platform.
|
|
120
|
+
|
|
121
|
+
## Traps found on a real site
|
|
122
|
+
|
|
123
|
+
- **A fresh site has no content model.** No section, no entry type, no field, no volume: the
|
|
124
|
+
control panel navigation has no `Entries`, and the pack's steps for entries, indexes, the edit
|
|
125
|
+
form, fields and assets have nothing to work on. They are not listed above because they were
|
|
126
|
+
not run on a site as built. The content model is made first, in Settings, by a person; the
|
|
127
|
+
console does not make one unattended:
|
|
128
|
+
`bash cmd-tools-craft-cms-cli.sh <site> --run "sections/create --name=Notes --handle=notes --type=channel"`
|
|
129
|
+
answers `Entry Types cannot be blank`.
|
|
130
|
+
- **One account.** The Solo edition has no second account and no user group: there is no `Users`
|
|
131
|
+
item in the navigation, no role to be refused a page, and a scenario about permissions has
|
|
132
|
+
nothing to log in as. The `should not be allowed to open` form of the step needs an edition
|
|
133
|
+
this plugin does not build.
|
|
134
|
+
- **The system name is `<folder> <site>`** after a build (`dev mysite`), not the site's name
|
|
135
|
+
alone: `the "System Name" field should have the value "mysite"` fails.
|
|
136
|
+
- **A password reset answers the same for any address**: the confirmation is shown for an address
|
|
137
|
+
nobody has, and no account is touched.
|
|
138
|
+
- A page of the control panel is named by its path after `/admin/` (`"settings/sections"`,
|
|
139
|
+
`"myaccount"`), and the breadcrumb is the trail above the page (`Settings`), without the page
|
|
140
|
+
itself.
|
|
141
|
+
|
|
142
|
+
## Rules
|
|
143
|
+
|
|
144
|
+
- **No account is created in a suite**, and on the Solo edition none can be. A second account is
|
|
145
|
+
asked for (it needs another edition), not made.
|
|
146
|
+
- **Never the workspace account in a feature.** With `--add-users` the one account of the site is
|
|
147
|
+
the default account, and its password is in no feature file.
|
|
148
|
+
- **No password in a feature file**, except where a wrong password is the subject.
|
|
149
|
+
- **No platform name in a step phrase**: `I am logged in to the control panel as "admin"`, never
|
|
150
|
+
a phrase that names the platform. The same holds for a custom step.
|
|
151
|
+
- **No selector when a step says it**: `the control panel heading`, `the control panel
|
|
152
|
+
navigation`, not their classes.
|
|
153
|
+
- **What a scenario creates, it removes** in the same scenario, under a title nobody else uses.
|
|
154
|
+
- **No licence, no paid edition, no plugin store** in a scenario: the site stays on the free Solo
|
|
155
|
+
edition.
|
|
156
|
+
- **A custom step is the last resort**: look in the pack and in webship-js first, write it in
|
|
157
|
+
`<site>/tests/step-definitions/` with a comment block and examples, and say it may belong in
|
|
158
|
+
the pack.
|
|
159
|
+
- **Everything runs in the container**, through `cmd-tools-testing.sh`. Never `npx cucumber-js`
|
|
160
|
+
or `npx playwright` on the host.
|
|
161
|
+
- **A failing scenario is a result.** No `@wip`, no longer timeout, no looser assertion to turn a
|
|
162
|
+
run green: say what the site did.
|
|
163
|
+
|
|
164
|
+
## Examples that run
|
|
165
|
+
|
|
166
|
+
`examples/` holds three features that pass on a site built with
|
|
167
|
+
`bash cmd-craft-cms-project.sh <site> --install --add-users`. Copy one into the suite and run it:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
cp ~/workspace/ai-skills/craft-cms-scenarios/examples/control-panel-session.feature ~/workspace/<folder>/<site>/tests/features/
|
|
171
|
+
cd ~/workspace/<folder>
|
|
172
|
+
bash cmd-tools-testing.sh <site> --run --path tests/features/control-panel-session.feature
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
| Feature | What it shows |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| `examples/control-panel-session.feature` | The admin logging in and out, a wrong login refused, a password reset, a visitor sent to the login form |
|
|
178
|
+
| `examples/control-panel-navigation.feature` | The navigation of a fresh Solo site, the settings pages with their heading and breadcrumb, the pages an admin may open |
|
|
179
|
+
| `examples/front-page.feature` | The front page served to a visitor, and an unknown address answered with 404 |
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Feature: The control panel of a fresh site has the navigation of the Solo edition
|
|
2
|
+
As the owner of the site
|
|
3
|
+
I want the navigation, the settings and the pages an admin may open checked
|
|
4
|
+
So that a change of edition or of permissions is caught by the suite
|
|
5
|
+
|
|
6
|
+
Scenario: The navigation lists what a fresh Solo site has
|
|
7
|
+
Given I am logged in to the control panel as "admin"
|
|
8
|
+
Then the control panel navigation item "Dashboard" should be selected
|
|
9
|
+
And I should see "Settings" in the control panel navigation
|
|
10
|
+
And I should see "Utilities" in the control panel navigation
|
|
11
|
+
And I should not see "Entries" in the control panel navigation
|
|
12
|
+
And I should not see "Users" in the control panel navigation
|
|
13
|
+
|
|
14
|
+
Scenario: The navigation leads to the settings and the utilities
|
|
15
|
+
Given I am logged in to the control panel as "admin"
|
|
16
|
+
When I click "Settings" in the control panel navigation
|
|
17
|
+
Then the control panel heading should be "Settings"
|
|
18
|
+
And the control panel navigation item "Settings" should be selected
|
|
19
|
+
When I click "Utilities" in the control panel navigation
|
|
20
|
+
Then the control panel navigation item "Utilities" should be selected
|
|
21
|
+
|
|
22
|
+
Scenario: A settings page has its heading and its breadcrumb
|
|
23
|
+
Given I am logged in to the control panel as "admin"
|
|
24
|
+
When I go to the control panel page "settings/sections"
|
|
25
|
+
Then the control panel heading should be "Sections"
|
|
26
|
+
And the control panel breadcrumb should be "Settings"
|
|
27
|
+
When I go to the control panel page "settings/general"
|
|
28
|
+
Then the control panel heading should be "General Settings"
|
|
29
|
+
|
|
30
|
+
Scenario: The admin may open every page of an admin
|
|
31
|
+
Given I am logged in to the control panel as "admin"
|
|
32
|
+
Then I should be allowed to open the control panel page "settings"
|
|
33
|
+
And I should be allowed to open the control panel page "utilities"
|
|
34
|
+
And I should be allowed to open the control panel page "myaccount"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Feature: The control panel lets the admin in, and nobody else
|
|
2
|
+
As the owner of the site
|
|
3
|
+
I want the admin to log in and out, and a wrong login to be refused
|
|
4
|
+
So that a broken login is caught before anything else is tested
|
|
5
|
+
|
|
6
|
+
# The site is on the free Solo edition: one account, the admin. A scenario logs in by the
|
|
7
|
+
# "admin" handle of the users registry.
|
|
8
|
+
|
|
9
|
+
Scenario: The admin logs in and out
|
|
10
|
+
Given I am logged in to the control panel as "admin"
|
|
11
|
+
Then I should be logged in to the control panel as "admin"
|
|
12
|
+
And the control panel heading should be "Dashboard"
|
|
13
|
+
And I should not see an error notification
|
|
14
|
+
When I log out of the control panel
|
|
15
|
+
Then I should not be logged in to the control panel
|
|
16
|
+
And I should see the control panel login form
|
|
17
|
+
|
|
18
|
+
Scenario: An account nobody has is refused
|
|
19
|
+
When I log in to the control panel with the username "nobody" and the password "wrong-password"
|
|
20
|
+
Then I should see the login error "Invalid username or password."
|
|
21
|
+
And I should not be logged in to the control panel
|
|
22
|
+
|
|
23
|
+
Scenario: A password reset answers the same for an address nobody has
|
|
24
|
+
When I ask for a password reset for "nobody@example.com"
|
|
25
|
+
Then I should see the password reset confirmation
|
|
26
|
+
|
|
27
|
+
Scenario: A visitor is sent to the login form
|
|
28
|
+
Given I am an anonymous user
|
|
29
|
+
When I go to "/admin/settings"
|
|
30
|
+
Then I should see the control panel login form
|
|
31
|
+
And I should not be logged in to the control panel
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Feature: The site answers a visitor
|
|
2
|
+
As a visitor
|
|
3
|
+
I want the front page served and an unknown address refused
|
|
4
|
+
So that a broken template or routing is caught by the suite
|
|
5
|
+
|
|
6
|
+
Scenario: The front page is served
|
|
7
|
+
Given I am an anonymous user
|
|
8
|
+
And I am on the homepage
|
|
9
|
+
Then the response status code should be 200
|
|
10
|
+
And the page should have a title
|
|
11
|
+
|
|
12
|
+
Scenario: An address nobody made is not found
|
|
13
|
+
Given I am an anonymous user
|
|
14
|
+
When I go to "/no-such-page-anywhere"
|
|
15
|
+
Then the response status code should be 404
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# workspace-name: Craft CMS (5, Solo)
|
|
4
|
+
|
|
5
|
+
# Installed by the Craft CMS plugin (plugins.sh --install craft-cms); __WORKSPACE__ is the workspace it was installed into.
|
|
6
|
+
#
|
|
7
|
+
# Build a Craft CMS site in a container: the current release of Craft CMS 5, or the one --version
|
|
8
|
+
# names, at https://<name>.ddev.site, on the free Solo edition. With --install the site is
|
|
9
|
+
# installed with the workspace account as its one account, an admin; with --add-users that one
|
|
10
|
+
# account is the default account instead, the one the test scenarios log in as.
|
|
11
|
+
|
|
12
|
+
# Bootstrap.
|
|
13
|
+
# Find the workspace tooling from this script, so a fresh clone needs no setup.
|
|
14
|
+
WORKSPACE_SCRIPTS="${WORKSPACE_SCRIPTS:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../core/scripts" && pwd)}";
|
|
15
|
+
source ${WORKSPACE_SCRIPTS}/bootstrap.sh || exit 1 ;
|
|
16
|
+
|
|
17
|
+
# Load workspace settings.
|
|
18
|
+
eval $(parse_yaml ${WORKSPACE_CONFIG}/workspace.__WORKSPACE__.settings.yml);
|
|
19
|
+
|
|
20
|
+
# Set site version.
|
|
21
|
+
site_version="^5";
|
|
22
|
+
|
|
23
|
+
# Distribution: the name is the DDEV project type, which the user list is named after.
|
|
24
|
+
distribution_name="craftcms";
|
|
25
|
+
distribution_title="Craft CMS";
|
|
26
|
+
distribution_webroot="web";
|
|
27
|
+
project_template="craftcms/craft";
|
|
28
|
+
|
|
29
|
+
ARGPARSE_DESCRIPTION="Build a ${distribution_title} project in __WORKSPACE__"
|
|
30
|
+
# The args file comes with the plugin: core/scripts/plugins/craft-cms/ is where plugins.sh --install puts it.
|
|
31
|
+
source ${WORKSPACE_SCRIPTS}/plugins/craft-cms/args/arg-craft-cms.sh || exit 1 ;
|
|
32
|
+
|
|
33
|
+
shift $#;
|
|
34
|
+
|
|
35
|
+
craftcms_build ;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Installed by the Craft CMS plugin (plugins.sh --install craft-cms); __WORKSPACE__ is the workspace it was installed into.
|
|
4
|
+
#
|
|
5
|
+
# The craft console (php craft) for one Craft CMS project of this workspace, in its container: say
|
|
6
|
+
# what the site is, run a console command, update Craft CMS and its plugins, clear the caches, say
|
|
7
|
+
# whether the default account is the site's. Nothing here runs on the host.
|
|
8
|
+
|
|
9
|
+
# Bootstrap.
|
|
10
|
+
# Find the workspace tooling from this script, so a fresh clone needs no setup.
|
|
11
|
+
WORKSPACE_SCRIPTS="${WORKSPACE_SCRIPTS:-$(cd "$(dirname "${BASH_SOURCE[0]}")/../core/scripts" && pwd)}";
|
|
12
|
+
source ${WORKSPACE_SCRIPTS}/bootstrap.sh || exit 1 ;
|
|
13
|
+
|
|
14
|
+
# Load workspace settings.
|
|
15
|
+
eval $(parse_yaml ${WORKSPACE_CONFIG}/workspace.__WORKSPACE__.settings.yml);
|
|
16
|
+
|
|
17
|
+
# Distribution: the name is the DDEV project type, which the user list is named after.
|
|
18
|
+
distribution_name="craftcms";
|
|
19
|
+
|
|
20
|
+
ARGPARSE_DESCRIPTION="Run the craft console on a Craft CMS project of __WORKSPACE__: status, a command, updates, caches, the default account"
|
|
21
|
+
# The args file comes with the plugin: core/scripts/plugins/craft-cms/ is where plugins.sh --install puts it.
|
|
22
|
+
source ${WORKSPACE_SCRIPTS}/plugins/craft-cms/args/arg-craft-cms-cli.sh || exit 1 ;
|
|
23
|
+
|
|
24
|
+
shift $#;
|
|
25
|
+
|
|
26
|
+
craftcms_cli_tool ;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Craft CMS for Webship Workspace: a platform plugin.
|
|
3
|
+
*
|
|
4
|
+
* What the package carries is placed by the installer from the manifest: the builder and the
|
|
5
|
+
* craft console tool in the sites folders, their functions and argparse under core/scripts/plugins/craft-cms/,
|
|
6
|
+
* its AI items (ai/ in this package) in the folder of their kind:
|
|
7
|
+
* the agents in AI Agents, the skill in AI Skills, the command in AI Commands, the prompt in AI Prompts.
|
|
8
|
+
* The dashboard needs nothing drawn for it: the builder is in the
|
|
9
|
+
* Build list because it is a cmd-*-project.sh, the row menus are the core's, the AI items are listed
|
|
10
|
+
* like any other. What register() adds is what the assistant is told.
|
|
11
|
+
*
|
|
12
|
+
* Everything the dashboard is asked for goes through `api`; this package requires nothing from the
|
|
13
|
+
* dashboard's own files, so it can be installed from npm and removed without a trace.
|
|
14
|
+
*/
|
|
15
|
+
import type { PluginApi } from '@webship.co/workspace-plugin-api';
|
|
16
|
+
/** The plugin's name: what --activate and --install take, and the folder under core/scripts/plugins/. */
|
|
17
|
+
export declare const PLATFORM = "craft-cms";
|
|
18
|
+
/** The DDEV project type of a Craft CMS project, which the functions and the user list are named after. */
|
|
19
|
+
export declare const PROJECT_TYPE = "craftcms";
|
|
20
|
+
/** The commands the installer places in every sites folder. */
|
|
21
|
+
export declare const COMMANDS: string[];
|
|
22
|
+
/** The agents the installer places in the AI Agents folder. */
|
|
23
|
+
export declare const AGENTS: string[];
|
|
24
|
+
/** The skill the installer places in the AI Skills folder (a folder each, with its SKILL.md). */
|
|
25
|
+
export declare const SKILLS: string[];
|
|
26
|
+
/** The slash command the installer places in the AI Commands folder. */
|
|
27
|
+
export declare const AI_COMMANDS: string[];
|
|
28
|
+
/** The prompt the installer places in the AI Prompts folder: each a whole launch command for a new session. */
|
|
29
|
+
export declare const PROMPTS: string[];
|
|
30
|
+
/** What the assistant is told about Craft CMS in this workspace. */
|
|
31
|
+
export declare function assistantContext(): string;
|
|
32
|
+
export declare function register(api: PluginApi): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Craft CMS for Webship Workspace: a platform plugin.
|
|
4
|
+
*
|
|
5
|
+
* What the package carries is placed by the installer from the manifest: the builder and the
|
|
6
|
+
* craft console tool in the sites folders, their functions and argparse under core/scripts/plugins/craft-cms/,
|
|
7
|
+
* its AI items (ai/ in this package) in the folder of their kind:
|
|
8
|
+
* the agents in AI Agents, the skill in AI Skills, the command in AI Commands, the prompt in AI Prompts.
|
|
9
|
+
* The dashboard needs nothing drawn for it: the builder is in the
|
|
10
|
+
* Build list because it is a cmd-*-project.sh, the row menus are the core's, the AI items are listed
|
|
11
|
+
* like any other. What register() adds is what the assistant is told.
|
|
12
|
+
*
|
|
13
|
+
* Everything the dashboard is asked for goes through `api`; this package requires nothing from the
|
|
14
|
+
* dashboard's own files, so it can be installed from npm and removed without a trace.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.PROMPTS = exports.AI_COMMANDS = exports.SKILLS = exports.AGENTS = exports.COMMANDS = exports.PROJECT_TYPE = exports.PLATFORM = void 0;
|
|
18
|
+
exports.assistantContext = assistantContext;
|
|
19
|
+
exports.register = register;
|
|
20
|
+
/** The plugin's name: what --activate and --install take, and the folder under core/scripts/plugins/. */
|
|
21
|
+
exports.PLATFORM = 'craft-cms';
|
|
22
|
+
/** The DDEV project type of a Craft CMS project, which the functions and the user list are named after. */
|
|
23
|
+
exports.PROJECT_TYPE = 'craftcms';
|
|
24
|
+
/** The commands the installer places in every sites folder. */
|
|
25
|
+
exports.COMMANDS = ['cmd-craft-cms-project.sh', 'cmd-tools-craft-cms-cli.sh'];
|
|
26
|
+
/** The agents the installer places in the AI Agents folder. */
|
|
27
|
+
exports.AGENTS = ['craft-cms-site-builder', 'craft-cms-tester'];
|
|
28
|
+
/** The skill the installer places in the AI Skills folder (a folder each, with its SKILL.md). */
|
|
29
|
+
exports.SKILLS = ['craft-cms-scenarios'];
|
|
30
|
+
/** The slash command the installer places in the AI Commands folder. */
|
|
31
|
+
exports.AI_COMMANDS = ['craft-cms-test'];
|
|
32
|
+
/** The prompt the installer places in the AI Prompts folder: each a whole launch command for a new session. */
|
|
33
|
+
exports.PROMPTS = ['craft-cms-build-and-test'];
|
|
34
|
+
/** What the assistant is told about Craft CMS in this workspace. */
|
|
35
|
+
function assistantContext() {
|
|
36
|
+
return [
|
|
37
|
+
'Craft CMS (a plugin, @webship.co/workspace-craft-cms): a Craft CMS 5 site is built with',
|
|
38
|
+
'`bash cmd-craft-cms-project.sh <name> --install` from a sites folder (dev, test, sandboxes, demos),',
|
|
39
|
+
'in a container like every other project, at https://<name>.ddev.site (the control panel at /admin).',
|
|
40
|
+
'It is the free Solo edition and stays on it: one account, an admin, and no user groups; never a licence, a paid edition, a trial, or a sign-in to any account or store.',
|
|
41
|
+
'That one account is the workspace account; with --add-users it is the default account instead, the one the test scenarios log in as.',
|
|
42
|
+
'`bash cmd-tools-craft-cms-cli.sh <name>` says what the site is; `--run "<command>"` runs the craft console (php craft) in it,',
|
|
43
|
+
'`--update` updates Craft CMS and its plugins, `--flush` clears the caches.',
|
|
44
|
+
'`bash cmd-tools-testing.sh <name>` sets up webship-js with the Craft CMS step pack; `--run` runs the suite.',
|
|
45
|
+
`For Craft CMS work, hand over to the agents ${exports.AGENTS.map((a) => `\`${a}\``).join(' and ')}.`,
|
|
46
|
+
`The plugin also places the skill ${exports.SKILLS.map((a) => `\`${a}\``).join(', ')} (the step pack's phrases, by area) in ai-skills/,`,
|
|
47
|
+
`the command ${exports.AI_COMMANDS.map((a) => `\`/${a} <site>\``).join(', ')} in ai-commands/ and the prompt ${exports.PROMPTS.map((a) => `\`${a}\``).join(' and ')} in ai-prompts/.`,
|
|
48
|
+
'Never run php, composer, npm or mysql on the host for a project.',
|
|
49
|
+
].join(' ');
|
|
50
|
+
}
|
|
51
|
+
function register(api) {
|
|
52
|
+
api.addAssistantContext(assistantContext);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AA0BH,4CAeC;AAED,4BAEC;AAzCD,yGAAyG;AAC5F,QAAA,QAAQ,GAAG,WAAW,CAAC;AAEpC,2GAA2G;AAC9F,QAAA,YAAY,GAAG,UAAU,CAAC;AAEvC,+DAA+D;AAClD,QAAA,QAAQ,GAAG,CAAC,0BAA0B,EAAE,4BAA4B,CAAC,CAAC;AAEnF,+DAA+D;AAClD,QAAA,MAAM,GAAG,CAAC,wBAAwB,EAAE,kBAAkB,CAAC,CAAC;AAErE,iGAAiG;AACpF,QAAA,MAAM,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAE9C,wEAAwE;AAC3D,QAAA,WAAW,GAAG,CAAC,gBAAgB,CAAC,CAAC;AAE9C,+GAA+G;AAClG,QAAA,OAAO,GAAG,CAAC,0BAA0B,CAAC,CAAC;AAEpD,oEAAoE;AACpE,SAAgB,gBAAgB;IAC9B,OAAO;QACL,yFAAyF;QACzF,qGAAqG;QACrG,qGAAqG;QACrG,yKAAyK;QACzK,sIAAsI;QACtI,+HAA+H;QAC/H,4EAA4E;QAC5E,6GAA6G;QAC7G,+CAA+C,cAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG;QAC7F,oCAAoC,cAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,oDAAoD;QAChI,eAAe,mBAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAmC,eAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB;QACrK,kEAAkE;KACnE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAc;IACrC,GAAG,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# A plugin carries its own items
|
|
2
|
+
|
|
3
|
+
Every `@webship.co/workspace-<name>` plugin manages what belongs to it: its `cmd-*.sh` commands and
|
|
4
|
+
its AI items (agents, skills, commands, prompts). The package holds them, the manifest names them,
|
|
5
|
+
and `plugins.sh --install <name>` lists each one in the workspace folder of its kind, when that
|
|
6
|
+
folder is an active workspace folder. `--uninstall` takes them away again. The reference is
|
|
7
|
+
[`@webship.co/workspace-wordpress`](https://github.com/webship/workspace-wordpress), and this plugin
|
|
8
|
+
follows it; below, `<p>` is the plugin's name.
|
|
9
|
+
|
|
10
|
+
## The layout
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
commands/cmd-<p>-project.sh cmd-*.sh scripts only: builders and tools, placed in workspace folders
|
|
14
|
+
commands/cmd-tools-<p>-cli.sh
|
|
15
|
+
ai/agents/<p>-<role>.md one file per agent
|
|
16
|
+
ai/skills/<p>-<topic>/SKILL.md one folder per skill; every file in it is placed (examples/, references/)
|
|
17
|
+
ai/commands/<p>-<verb>.md one file per slash command
|
|
18
|
+
ai/prompts/<p>-<task>.md one file per prompt
|
|
19
|
+
tests/items.test.ts the shape of every item, and that it names nothing that does not exist
|
|
20
|
+
tests/fixtures/step-definitions.txt the step definitions the items' phrases are checked against (a plugin with a step pack)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`commands/` is taken by the `cmd-*.sh` scripts, so the AI items live under `ai/`, one folder per
|
|
24
|
+
kind, named like the manifest's `ai` keys. The installer places an item by the last part of its
|
|
25
|
+
path, whatever folder the package keeps it in, so a plugin that kept its agents in `agents/` moves
|
|
26
|
+
them with `git mv agents ai/agents` and changes two lines of its manifest.
|
|
27
|
+
|
|
28
|
+
## The manifest
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
"files": ["dist/src", "ai", "commands", "docs", "features", "scripts", "testing", "README.md"],
|
|
32
|
+
"workspacePlugin": {
|
|
33
|
+
"name": "<p>",
|
|
34
|
+
"needs": [["dev", "test", "sandboxes", "demos"], "ai-agents", "ai-skills", "ai-commands", "ai-prompts"],
|
|
35
|
+
"commands": { "types": ["sites"], "workspaces": ["dev", "test", "sandboxes", "demos"],
|
|
36
|
+
"files": ["commands/cmd-<p>-project.sh", "commands/cmd-tools-<p>-cli.sh"] },
|
|
37
|
+
"ai": {
|
|
38
|
+
"agents": ["ai/agents/<p>-site-builder.md", "ai/agents/<p>-tester.md"],
|
|
39
|
+
"skills": ["ai/skills/<p>-scenarios"],
|
|
40
|
+
"commands": ["ai/commands/<p>-test.md"],
|
|
41
|
+
"prompts": ["ai/prompts/<p>-build-and-test.md"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
- `ai` is in `files`, or the items are not in the published package.
|
|
47
|
+
- A skill is named by its folder, with no `/SKILL.md` and no trailing slash.
|
|
48
|
+
- `needs` names the folder of every kind the plugin ships, after the folder its commands need. A
|
|
49
|
+
plugin with no `cmd-*.sh` for a sites folder leaves the first entry out; a kind it does not ship
|
|
50
|
+
is left out of `ai` and of `needs`.
|
|
51
|
+
|
|
52
|
+
| Kind | Lands in | Claude Code reads it from |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `commands.files` | every active folder `commands.workspaces` names, else every active folder of `commands.types` | the folder itself: `bash cmd-….sh` |
|
|
55
|
+
| `ai.agents` | `ai-agents/<name>.md` | `~/.claude/agents`, after Install |
|
|
56
|
+
| `ai.skills` | `ai-skills/<name>/` | `~/.claude/skills`, after Install |
|
|
57
|
+
| `ai.commands` | `ai-commands/<name>.md` | `~/.claude/commands`, after Install: `/<name>` |
|
|
58
|
+
| `ai.prompts` | `ai-prompts/<name>.md` | nothing: the New screen form lists it as a template for a new session |
|
|
59
|
+
|
|
60
|
+
## The shape of each kind
|
|
61
|
+
|
|
62
|
+
| Kind | Shape |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| Agent | Frontmatter `name` (the file's name), `description` (when to use it, with the phrases a person says), `model: fable`, `tools`; then what it does, the commands it runs, its rules |
|
|
65
|
+
| Skill | `SKILL.md` with frontmatter `name` (the folder's name) and `description` (what it does, then `Use when …`); files beside it for what is too long or is meant to be copied |
|
|
66
|
+
| Command | Frontmatter `description` and `argument-hint`, no `name` (the file names it); the body reads what was typed from `$ARGUMENTS` |
|
|
67
|
+
| Prompt | No frontmatter. One sentence that says what it is for, then a fenced block holding the whole launch command: `claude --permission-mode bypassPermissions """` … `"""`, with `<placeholders>` to fill in and a `#` line that says where it runs |
|
|
68
|
+
|
|
69
|
+
Names start with the plugin's name (`<p>-…`): an item that is already in the folder under the same
|
|
70
|
+
name is kept, so a name another plugin could also choose would never be placed. A command and a
|
|
71
|
+
prompt never share a name: both end in `~/.claude/commands`.
|
|
72
|
+
|
|
73
|
+
## What an item may say
|
|
74
|
+
|
|
75
|
+
Nothing generic and nothing invented. An item is about what this plugin does in the workspace, and
|
|
76
|
+
every command, flag, path and step phrase in it exists:
|
|
77
|
+
|
|
78
|
+
- commands and flags: the plugin's own (`scripts/args/*.sh`) and the workspace's (`cmd-tools-testing.sh`
|
|
79
|
+
and its flags, `cmd-tools-remove.sh`, `cmd-tools-clone.sh --to`, `cmd-tools-ai-items.sh --install`);
|
|
80
|
+
- step phrases: the plugin's step pack and webship-js, as installed in a real project;
|
|
81
|
+
- the body is for any AI CLI, Claude Code being the default shape: plain Markdown ("run this
|
|
82
|
+
command", "read this file", "the AI assistant") that names no tool or feature of one CLI; the
|
|
83
|
+
frontmatter and a prompt's `claude …` launch line stay, with one line saying that the text between
|
|
84
|
+
the quotes can be given to another AI CLI as it is; a command keeps `$ARGUMENTS` and says in
|
|
85
|
+
words what the arguments are;
|
|
86
|
+
- the workspace is container-based (DDEV by default); no platform name in a step phrase; no
|
|
87
|
+
account created by a scenario; no password, no personal path, addresses at `example.com`.
|
|
88
|
+
|
|
89
|
+
Run every command an item tells its reader to run, and every scenario it shows, on a real site
|
|
90
|
+
before it is pushed. Two of the three example features of the reference failed on their first real
|
|
91
|
+
run, each on a phrase that exists and matched in a dry run.
|
|
92
|
+
|
|
93
|
+
## The tests to copy
|
|
94
|
+
|
|
95
|
+
`tests/items.test.ts` checks, with no site and no network:
|
|
96
|
+
|
|
97
|
+
1. the manifest: one list per kind, each item under `ai/<kind>/`, in the package, named `<p>-…`,
|
|
98
|
+
`ai` in `files`, the folder of each kind in `needs`, no command and prompt of the same name;
|
|
99
|
+
2. the shape of each kind (the table above; the two expressions the dashboard reads a prompt with);
|
|
100
|
+
3. every `cmd-*.sh` an item names is the plugin's or the workspace's, with flags that exist;
|
|
101
|
+
4. every step in a `gherkin` block or a `.feature` file matches a definition in
|
|
102
|
+
`tests/fixtures/step-definitions.txt`, names no platform and carries no password;
|
|
103
|
+
5. the words: container-based, no personal value, the README lists every item.
|
|
104
|
+
|
|
105
|
+
Refresh the fixture from a project whose testing stack is set up, whenever the pack's release
|
|
106
|
+
line changes (`<pack>` is the plugin's step pack):
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cd ~/workspace/<folder>/<site>
|
|
110
|
+
{ echo "# <pack> <version> and webship-js <version>" ;
|
|
111
|
+
grep -hE "^(Given|When|Then)\(/" node_modules/<pack>/tests/step-definitions/*.steps.js node_modules/webship-js/tests/step-definitions/*.steps.js \
|
|
112
|
+
| sed -nE 's/^(Given|When|Then)\(\/(.*)\/, (\{[^}]*\}, )?(async )?function.*/\2/p' | sort -u ; } > step-definitions.txt
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`tests/needs.test.ts` holds the exact `needs` list, and `tests/plugin.test.ts` that every file the
|
|
116
|
+
manifest names ships.
|
|
117
|
+
|
|
118
|
+
## Prove it on a fresh workspace
|
|
119
|
+
|
|
120
|
+
Never in a workspace somebody works in. `webship-workspace init <folder>` makes an empty one.
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npm pack # in the plugin: the tarball of the branch
|
|
124
|
+
cd <the fresh workspace>
|
|
125
|
+
bash core/scripts/plugins.sh --require <path>/webship.co-workspace-<p>-<version>.tgz # says what it needs
|
|
126
|
+
bash core/scripts/plugins.sh --activate <p> # stops: lists what is not here, changes nothing
|
|
127
|
+
bash core/scripts/plugins.sh --activate <p> --with-needs # adds the folders, then activates
|
|
128
|
+
bash core/scripts/plugins.sh --install <p> # "placed …" once per file
|
|
129
|
+
ls dev ai-agents ai-skills ai-commands ai-prompts # each item in its folder
|
|
130
|
+
bash core/scripts/plugins.sh --list # needs: … met by …
|
|
131
|
+
bash core/scripts/plugins.sh --uninstall <p> # "removed …" once per file
|
|
132
|
+
grep -c "<p>" core/config/plugins.installed.yml # 0: the record is gone
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Then, installed again: build one site with the builder, run each command the items name, copy the
|
|
136
|
+
skill's examples into the suite and run them, look at the four AI folders on the dashboard, and
|
|
137
|
+
remove the site with `cmd-tools-remove.sh`.
|
|
138
|
+
|
|
139
|
+
## What was found on the way
|
|
140
|
+
|
|
141
|
+
- A phrase that matches in a dry run can still fail: a step may need another one before it
|
|
142
|
+
(`I should see the page title` needs `Given I am on a page`), or assert something the site does
|
|
143
|
+
not do as built. Only a real run tells.
|
|
144
|
+
- Content a failed scenario created stays on the site. Name it so it is found, and remove it
|
|
145
|
+
through the CLI tool before the next run (an entry in the trash is not in a list of every status).
|
|
146
|
+
- A folder that is not active gets nothing: the install says `skipped <n> <kind>` for it, and
|
|
147
|
+
places the items when the folder is added. With the folder in `needs`, `--activate` and
|
|
148
|
+
`--install` stop before that and offer to add it.
|
|
149
|
+
- An item a person edited in its folder is kept by `--install` and by `--uninstall`: the record
|
|
150
|
+
holds the hash of what was placed.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Feature: The Craft CMS plugin on the dashboard
|
|
2
|
+
Once the plugin is activated and installed, the sites folders offer the Craft CMS builder, each
|
|
3
|
+
AI folder lists the items of its kind the plugin ships, and the Plugins page lists the plugin
|
|
4
|
+
with its steps.
|
|
5
|
+
|
|
6
|
+
Scenario: The plugin is listed on the Plugins page
|
|
7
|
+
Given I am on "/settings/plugins"
|
|
8
|
+
Then I should see "Craft CMS"
|
|
9
|
+
And I should see "@webship.co/workspace-craft-cms"
|
|
10
|
+
|
|
11
|
+
Scenario: A sites folder offers the Craft CMS builder
|
|
12
|
+
Given I am on "/dev"
|
|
13
|
+
Then "option[value='cmd-craft-cms-project.sh']" should be attached
|
|
14
|
+
|
|
15
|
+
Scenario: The AI Agents folder lists the agents the plugin ships
|
|
16
|
+
Given I am on "/ai-agents"
|
|
17
|
+
Then I should see "craft-cms-site-builder"
|
|
18
|
+
And I should see "craft-cms-tester"
|
|
19
|
+
|
|
20
|
+
Scenario: The AI Skills folder lists the skill the plugin ships
|
|
21
|
+
Given I am on "/ai-skills"
|
|
22
|
+
Then I should see "craft-cms-scenarios"
|
|
23
|
+
|
|
24
|
+
Scenario: The AI Commands folder lists the command the plugin ships
|
|
25
|
+
Given I am on "/ai-commands"
|
|
26
|
+
Then I should see "craft-cms-test"
|
|
27
|
+
|
|
28
|
+
Scenario: The AI Prompts folder lists the prompt the plugin ships
|
|
29
|
+
Given I am on "/ai-prompts"
|
|
30
|
+
Then I should see "craft-cms-build-and-test"
|