Skip to content

Commit 866e11f

Browse files
authored
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.
1 parent ba80dff commit 866e11f

1 file changed

Lines changed: 30 additions & 131 deletions

File tree

skills/upgrade-wp-coding-agents/SKILL.md

Lines changed: 30 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ compatibility: "Requires a wp-coding-agents repo clone and an existing setup. Wo
66

77
# Upgrade wp-coding-agents
88

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.
1210

1311
## When to use
1412

@@ -18,140 +16,41 @@ The user says something like:
1816
- "My dm-context-filter.ts is out of date"
1917
- "Regenerate AGENTS.md from the latest template"
2018

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:
38-
39-
| Bridge | VPS unit(s) | Local launchd plist(s) | Per-install artifacts |
40-
|---|---|---|---|
41-
| **kimaki** | `kimaki.service` | `com.wp.kimaki.plist` | `/opt/kimaki-config/` on VPS; `$(npm root -g)/kimaki/plugins` + `$KIMAKI_DATA_DIR/kimaki-config/` on local |
42-
| **cc-connect** | `cc-connect.service` | `com.wp.cc-connect.plist` | none (user owns `$HOME/.cc-connect/config.toml`) |
43-
| **telegram** | `opencode-serve.service` + `opencode-telegram.service` | `com.wp.opencode-serve.plist` + `com.wp.opencode-telegram.plist` | none (user owns `.env` files under `$HOME/.config/opencode-*/`) |
44-
45-
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
7220

73-
Always dry-run first on a live install. The dry-run never modifies anything.
21+
1. **Find the repo and pull main:**
22+
```bash
23+
cd "$(git -C ~/Developer/wp-coding-agents rev-parse --show-toplevel)"
24+
git pull origin main
25+
```
26+
If the user maintains a fork or a feature branch, ask before pulling. Default is `origin/main`.
7427

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).
7934

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.
8536

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.
8738

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.
8940

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.
116-
117-
**VPS verify:**
118-
```bash
119-
systemctl status kimaki
120-
diff -u /opt/kimaki-config/plugins/dm-context-filter.ts \
121-
"$(git -C /path/to/wp-coding-agents rev-parse --show-toplevel)/kimaki/plugins/dm-context-filter.ts"
122-
head -20 /var/www/*/AGENTS.md
123-
```
124-
125-
**Local verify:**
126-
```bash
127-
# launchd (auto-installed on macOS):
128-
launchctl print "gui/$(id -u)/com.wp.kimaki" | head -20
129-
# or, if running kimaki manually:
130-
pgrep -fl kimaki
131-
132-
NPM_ROOT="$(npm root -g)"
133-
diff -u "$NPM_ROOT/kimaki/plugins/dm-context-filter.ts" \
134-
"$(git -C /path/to/wp-coding-agents rev-parse --show-toplevel)/kimaki/plugins/dm-context-filter.ts"
135-
head -20 /path/to/site/AGENTS.md
136-
```
137-
138-
## 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 &lt;bridge&gt; 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
14742

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.
15147

152-
## Never do
48+
## Source of truth
15349

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

Comments
 (0)