You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(skill): trim upgrade-wp-coding-agents to policy + procedure (#75)
The previous SKILL.md was ~157 lines and 70% of it restated what
`./upgrade.sh --help` and the script's own summary block already
print at runtime. The skill's actual job — what it does that
`upgrade.sh` cannot — is enforce policy:
- never restart the chat bridge automatically (kills active
sessions including the one the agent is talking in)
- never skip the dry-run on a live install
- never touch user state (auth, OAuth, memory files, etc.)
- never hardcode workspace paths
That's the load-trigger value. A slash command can run the script,
but it can't enforce dry-run-first, can't gate restart on user
confirmation, and can't pivot mid-upgrade when the agent spots an
upstream bug worth fixing in the same session.
Trim to 56 lines:
- keep the frontmatter description verbatim (load-trigger key)
- keep "When to use" verbatim (recall trigger)
- collapse Steps 1-6 into one 4-step procedure block
- drop the chat-bridge-identification table (script auto-detects + summary prints)
- drop the verify section (summary block already prints the right commands)
- drop the persistent-skill-source explainer (implementation detail, not user-facing)
- keep "Never do" verbatim (this IS the skill's job)
- add a "Source of truth" table pointing at `--help` and the
summary block for everything that was cut
Net: 157 → 56 lines (−64%). No behaviour change — the skill still
loads on the same triggers, still enforces the same policies, still
points at the same script.
Surfaced during a live upgrade session where I noticed the procedural
half of the skill was just narrating what the script's output already
said. The fix-bug-and-release pivot in that same session would have
been impossible behind a slash command — that conversational pivot is
exactly the value Option B (trim) preserves and Option A (replace
with slash command) would have lost.
## AI assistance
- **AI assistance:** Yes
- **Tool(s):** Claude Code (Sonnet 4.5)
- **Used for:** drafted the trimmed skill body and this commit message.
Chris reviewed the cut against the actual session usage and
approved the structure (policy + 4-step procedure + source-of-truth
table) before commit.
@@ -6,9 +6,7 @@ compatibility: "Requires a wp-coding-agents repo clone and an existing setup. Wo
6
6
7
7
# Upgrade wp-coding-agents
8
8
9
-
**Purpose:** Pull the latest wp-coding-agents improvements onto a live install — new plugin versions, updated skills, regenerated AGENTS.md, systemd template fixes (VPS), and the opencode-claude-auth patch — without touching opencode config, WordPress, or agent memory.
10
-
11
-
The same `upgrade.sh` script handles both environments. It auto-detects and branches internally; you do not need to memorise paths.
9
+
`upgrade.sh` already auto-detects the environment, picks the chat bridge, prints a diff in dry-run, and emits the right verify + restart commands in its summary block. This skill exists for the **policy boundary** the script can't enforce on its own.
12
10
13
11
## When to use
14
12
@@ -18,140 +16,41 @@ The user says something like:
18
16
- "My dm-context-filter.ts is out of date"
19
17
- "Regenerate AGENTS.md from the latest template"
20
18
21
-
## Step 1 — Detect the environment and chat bridge
22
-
23
-
Before running anything, identify (a) which side you are on and (b) which chat bridge is installed. The script auto-detects both, but you should know too so you can give the user the right restart instructions.
24
-
25
-
### Environment signals
26
-
27
-
| Signal | VPS | Local |
28
-
|---|---|---|
29
-
|`/etc/systemd/system/<bridge>.service` exists | yes | no |
30
-
|`command -v studio` succeeds | usually no | usually yes |
31
-
| Platform | Linux | macOS or Linux |
32
-
33
-
**On macOS the script auto-enables `--local`.** On Linux without `--local`, the script assumes VPS.
34
-
35
-
### Supported chat bridges
36
-
37
-
`upgrade.sh` auto-detects one of three chat bridges based on installed service files or binaries:
|**kimaki**|`kimaki.service`|`com.wp.kimaki.plist`|`/opt/kimaki-config/` on VPS; `$(npm root -g)/kimaki/plugins` + `$KIMAKI_DATA_DIR/kimaki-config/` on local |
Ordering matches install priority: kimaki > cc-connect > telegram if more than one is installed.
46
-
47
-
### Restart commands
48
-
49
-
Do not guess restart commands. The script's summary block prints the exact command for the detected bridge × environment combination at the end of every run — pass that through to the user verbatim. The source of truth for these commands is `lib/chat-bridges.sh::bridge_restart_cmd`; they are rendered once and reused by both `upgrade.sh` and setup-time summary output, so the skill never needs its own copy.
50
-
51
-
## Step 2 — Resolve the repo path
52
-
53
-
Never hardcode the workspace path. Use whichever clone the user has on disk:
54
-
55
-
```bash
56
-
# Inside the wp-coding-agents clone:
57
-
cd"$(git rev-parse --show-toplevel)"
58
-
59
-
# Or from a known checkout:
60
-
cd /path/to/wp-coding-agents
61
-
```
62
-
63
-
Then pull latest:
64
-
65
-
```bash
66
-
git pull origin main
67
-
```
68
-
69
-
> If the user maintains a fork or a feature branch, ask before pulling. Default is `origin/main`.
70
-
71
-
## Step 3 — Dry run
19
+
## Procedure
72
20
73
-
Always dry-run first on a live install. The dry-run never modifies anything.
If the user maintains a fork or a feature branch, ask before pulling. Default is `origin/main`.
74
27
75
-
**VPS:**
76
-
```bash
77
-
./upgrade.sh --dry-run
78
-
```
28
+
2.**Dry-run first.** Always.
29
+
```bash
30
+
./upgrade.sh --dry-run # VPS
31
+
./upgrade.sh --dry-run --wp-path /path # local (auto-set on macOS)
32
+
```
33
+
Read the output. Stop and investigate if anything looks wrong (wrong runtime, unexpected unit rewrite, plugin paths point somewhere weird).
79
34
80
-
**Local:**
81
-
```bash
82
-
./upgrade.sh --dry-run --wp-path "/path/to/site"
83
-
# --local is auto on macOS; pass it explicitly on Linux local installs.
84
-
```
35
+
3.**Apply** by dropping `--dry-run`. The script prints a summary with the exact verify + restart commands for the detected bridge × environment. Pass them through to the user verbatim — do not paraphrase, do not guess.
85
36
86
-
Review the diff output. If anything looks wrong (wrong runtime detected, unexpected unit rewrite, plugin paths point somewhere weird), stop and investigate before proceeding.
37
+
4.**Tell the user to restart the chat bridge themselves.** Active chat sessions die on restart, so the user picks the moment.
87
38
88
-
## Step 4 — Run the upgrade
39
+
Run `./upgrade.sh --help` for scope flags (`--kimaki-only`, `--skills-only`, `--agents-md-only`, `--repair-opencode-json`, etc.) and the full list of what the script touches and never touches.
89
40
90
-
Drop `--dry-run`:
91
-
92
-
**VPS:**
93
-
```bash
94
-
./upgrade.sh
95
-
```
96
-
97
-
**Local:**
98
-
```bash
99
-
./upgrade.sh --wp-path "/path/to/site"
100
-
```
101
-
102
-
Backups are written next to each touched file with a timestamp suffix. On VPS that means `/opt/kimaki-config.backup.<ts>`, `AGENTS.md.backup.<ts>`, `kimaki.service.backup.<ts>`. On local, the kimaki-config backup lands under `$KIMAKI_DATA_DIR/backups/` (defaults to `~/.kimaki/backups/`).
103
-
104
-
### Persistent skill source
105
-
106
-
`--skills-only` (and a full run) also mirrors every installed skill into the persistent kimaki-config skill source dir. This is the durable copy that survives `npm update -g kimaki` wipes of `$(npm root -g)/kimaki/skills/`:
107
-
108
-
-**Local:**`$KIMAKI_DATA_DIR/kimaki-config/skills/` (defaults to `~/.kimaki/kimaki-config/skills/`)
109
-
-**VPS:**`/opt/kimaki-config/skills/`
110
-
111
-
On local, `upgrade.sh` runs `post-upgrade.sh` inline. On VPS, `kimaki.service`'s `ExecStartPre` runs it on next service start. `post-upgrade.sh` performs two symmetric passes against `$(npm root -g)/kimaki/skills/`: (1) remove the unwanted bundled skills listed in `skills-kill-list.txt`, and (2) restore the wp-coding-agents skills from the persistent source dir. Both passes are idempotent and run on every kimaki restart.
112
-
113
-
## Step 5 — Verify
114
-
115
-
The script's summary block prints the right verify commands for the detected environment. Run them and sanity-check.
## Step 6 — Tell the user to restart the chat bridge
139
-
140
-
The upgrade script never restarts the chat bridge automatically — active chat sessions would die mid-turn. Hand the right command to the user based on what the summary block printed. See the restart-command table in Step 1.
141
-
142
-
> Always say something like: *"Restart <bridge> when ready — active sessions will die."* Let the user pick the moment. For the telegram bridge there are two services (`opencode-serve` + `opencode-telegram`) — restart both, in that order.
143
-
144
-
## Scope flags
145
-
146
-
These work in both VPS and local mode:
41
+
## Never do
147
42
148
-
-`--kimaki-only` — only sync the chat-bridge config (name kept for backwards compatibility — also handles cc-connect and telegram when they are the detected bridge)
149
-
-`--skills-only` — only refresh agent skills (WordPress/agent-skills + Extra-Chill/data-machine-skills)
150
-
-`--agents-md-only` — only regenerate AGENTS.md via `datamachine memory compose`
43
+
-**Never restart the chat bridge automatically.** It kills active sessions including the one you're talking in.
44
+
-**Never skip the dry-run** on a live install.
45
+
-**Never touch user state:**`opencode.json` (the script does additive-only repair), the WordPress DB, nginx, SSL certs, `~/.kimaki/` auth state and OAuth tokens, the DM workspace cloned repos, or agent memory files (`SOUL.md` / `MEMORY.md` / `USER.md`).
46
+
-**Never hardcode workspace paths** (`/var/lib/...`, `/opt/...`, `/var/www/...`, `/root/...`) in commands you give the user. Use `git rev-parse --show-toplevel`, `$(npm root -g)`, `$KIMAKI_DATA_DIR`, and the script's auto-detection.
151
47
152
-
## Never do
48
+
## Source of truth
153
49
154
-
- Never restart kimaki automatically. Always let the user decide.
155
-
- Never touch `opencode.json`, the WordPress DB, nginx, SSL certs, `~/.kimaki/` auth state and OAuth tokens, the DM workspace cloned repos, or agent memory files (`SOUL.md` / `MEMORY.md` / `USER.md`).
156
-
- Never run without a dry-run first on a live install.
157
-
- Never hardcode `/var/lib/...`, `/opt/...`, `/var/www/...`, or `/root/...` paths in the steps you give the user. Use `git rev-parse --show-toplevel`, `$(npm root -g)`, `$KIMAKI_DATA_DIR`, and the script's auto-detection.
50
+
| Question | Where to look |
51
+
|---|---|
52
+
| What flags exist? |`./upgrade.sh --help`|
53
+
| What did the upgrade actually do? | The script's summary block (printed at the end of every run) |
54
+
| What's the right restart command for this bridge × env? | The summary block — rendered from `lib/chat-bridges.sh::bridge_restart_cmd`|
55
+
| What's the right verify command? | The summary block |
56
+
| What chat bridges are supported? |`lib/chat-bridges.sh::bridge_names` (currently kimaki, cc-connect, telegram) |
0 commit comments