devops-whc 1.0.1 → 1.0.2-next

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.
@@ -1,10 +1,10 @@
1
- # WHC MCP Agent Usage Guide
1
+ # WHC CLI Agent Usage Guide
2
2
 
3
- This guide is for AI agents and operators who need predictable, safe usage of the WHC MCP server.
3
+ This guide is for AI agents and operators who need predictable, safe usage of the WHC tool server.
4
4
 
5
5
  ## 1. Goal
6
6
 
7
- Use WHC MCP to run a safe release flow:
7
+ Use WHC CLI to run a safe release flow:
8
8
 
9
9
  1. Initialize workspace state (`whc_prepare`).
10
10
  2. Validate connectivity and environment.
@@ -14,17 +14,16 @@ Use WHC MCP to run a safe release flow:
14
14
 
15
15
  ## 2. Runtime Model
16
16
 
17
- The server supports two workflow modes:
17
+ The server supports two workflow modes:
18
+
19
+ 1. `git_deploy`
20
+ 2. `ssh_scp_wpcli`
21
+
22
+ `git_deploy` means local source is pushed to a cPanel-managed Git repository and deployment is triggered from that repository.
23
+ `ssh_scp_wpcli` means source-first delivery over SSH/SCP with runtime bootstrap via WP-CLI and smoke gating.
24
+ If `WHC_WORKFLOW_MODE` is omitted, default to `ssh_scp_wpcli`.
18
25
 
19
- 1. `managed_clone_sync`
20
- 2. `git_controlled`
21
-
22
- Most WHC managed WordPress flows use `managed_clone_sync`.
23
-
24
- If server env sets `WHC_WORKFLOW_MODE=managed_clone_sync`, treat staging as managed-only.
25
- Do not call `git_controlled` for staging in that mode.
26
-
27
- ## 2.2 MCP Registration Standard
26
+ ## 2.2 Tool Server Registration Standard
28
27
 
29
28
  Use one of these two registration patterns and keep them consistent with README.
30
29
 
@@ -33,36 +32,36 @@ Published package (`npx`) recommended for most users:
33
32
  ```jsonc
34
33
  {
35
34
  "servers": {
36
- "whc-mcp": {
35
+ "whc": {
37
36
  "type": "stdio",
38
37
  "command": "npx",
39
38
  "args": ["-y", "devops-whc", "--serve"],
40
39
  "env": {
41
40
  "WHC_ENV_FILE": "${workspaceFolder}/.env",
42
41
  "WHC_LOCAL_PROJECT_ROOT": "${workspaceFolder}",
43
- "WHC_STATE_ROOT": ".mcp/whc-mcp",
44
- "WHC_MCP_INSTANCE_NAME": "whc-mcp"
42
+ "WHC_STATE_ROOT": ".whc",
43
+ "WHC_INSTANCE_NAME": "whc"
45
44
  }
46
45
  }
47
46
  }
48
47
  }
49
48
  ```
50
49
 
51
- Local clone (`start-mcp.cjs`) for contributors:
50
+ Local clone (`start-whc.cjs`) for contributors:
52
51
 
53
52
  ```jsonc
54
53
  {
55
54
  "servers": {
56
- "whc-mcp": {
55
+ "whc": {
57
56
  "type": "stdio",
58
57
  "command": "node",
59
- "args": ["./scripts/start-mcp.cjs"],
58
+ "args": ["./scripts/start-whc.cjs"],
60
59
  "cwd": "${workspaceFolder}",
61
60
  "env": {
62
61
  "WHC_ENV_FILE": "${workspaceFolder}/.env",
63
62
  "WHC_LOCAL_PROJECT_ROOT": "${workspaceFolder}",
64
- "WHC_STATE_ROOT": ".mcp/whc-mcp",
65
- "WHC_MCP_INSTANCE_NAME": "whc-mcp"
63
+ "WHC_STATE_ROOT": ".whc",
64
+ "WHC_INSTANCE_NAME": "whc"
66
65
  }
67
66
  }
68
67
  }
@@ -85,10 +84,12 @@ Release commands:
85
84
 
86
85
  ```powershell
87
86
  npm run pack:check
88
- npm --prefix packages/devops-whc publish
87
+ npm run publish:npm
89
88
  ```
90
89
 
91
90
  `npm run pack:check` will run publish preparation and package dry-run against the subpackage.
91
+ `npm run publish:npm` runs `npm publish` from the publish subpackage.
92
+ For prerelease versions, `npm run publish:npm` automatically adds `--tag next` unless an explicit tag is provided.
92
93
 
93
94
  ## 2.1 Why `whc_setup_remote` Exists
94
95
 
@@ -98,7 +99,14 @@ It only prepares the remote Git endpoint on cPanel (repository root + SSH hint)
98
99
 
99
100
  Think of it as wiring transport, not shipping release.
100
101
 
101
- After `whc_setup_remote`, a manual or automated `git push` from local source is still required, then `whc_deploy` triggers deployment tasks.
102
+ After `whc_setup_remote`, a manual or automated `git push` from local source is still required.
103
+
104
+ Current boundary:
105
+
106
+ 1. `whc_setup_remote` is ready for remote Git repository setup.
107
+ 2. `check:generic` is the main trustworthy readiness gate for both workflow modes.
108
+ 3. `whc_deploy` for `git_deploy` triggers the real cPanel deployment task for a given `repository_root` and optional `branch`.
109
+ 4. `whc_deploy` does not yet execute the full `ssh_scp_wpcli` runtime pipeline; keep that in project-local scripts for now.
102
110
 
103
111
  ## 3. Required Context Before Any Write
104
112
 
@@ -106,15 +114,9 @@ Always collect these first:
106
114
 
107
115
  1. Active workflow mode.
108
116
  2. Target environment (`staging` or `live`).
109
- 3. Direction (for managed clone/sync):
110
- - `live_to_staging`
111
- - `staging_to_live`
112
- 4. Sync scope:
113
- - `files`
114
- - `database`
115
- - `everything`
116
- 5. Whether `dry_run` and `confirmed` are required by policy.
117
- 6. For `git_controlled`, ensure `repository_root` belongs to current `WHC_USER` home path (`/home/<WHC_USER>/...`).
117
+ 3. For `git_deploy`, identify the remote repository root and branch that should be deployed.
118
+ 4. For `ssh_scp_wpcli`, identify the local app root, staging SSH target, and runtime bootstrap path.
119
+ 5. Whether `dry_run` and `confirmed` are required by policy.
118
120
 
119
121
  ## 3.1 Manual vs Agent Responsibilities
120
122
 
@@ -123,32 +125,42 @@ User/operator must do manually (once per environment):
123
125
  2. Add SSH public key to correct cPanel account.
124
126
  3. Confirm host/path ownership and account scope.
125
127
 
126
- Agent can automate repeatedly:
127
- 1. Validate context and run dry-run checks.
128
- 2. Create/list repository via `whc_setup_remote`.
129
- 3. Trigger deployment via `whc_deploy`.
130
- 4. Execute safe runtime probes and logs/health collection.
128
+ Agent can automate repeatedly:
129
+ 1. Validate context and run dry-run checks.
130
+ 2. Create/list repository via `whc_setup_remote`.
131
+ 3. Push local source to the cPanel-managed Git repository when credentials are available.
132
+ 4. Trigger deployment via `whc_deploy` for the intended `repository_root` and optional `branch`.
133
+ 5. Execute safe runtime probes and logs/health collection.
134
+ 6. Run source-compatibility checks and hidden-state bootstrap for a specific project root.
131
135
 
132
136
  Hybrid step:
133
137
  1. `git push` may be run by agent from local terminal when keys/permissions are ready; otherwise operator performs push manually.
134
138
 
135
139
  ## 4. Safety Rules
136
140
 
137
- 1. Never promote live directly without staging verification.
138
- 2. For `staging_to_live` with `database` or `everything`, provide backup reference unless emergency override is explicitly approved.
139
- 3. Prefer `dry_run=true` before state-changing requests.
140
- 4. Always set `confirmed=true` when the policy requires explicit confirmation.
141
+ 1. Never claim a deploy was executed unless the handler actually changed remote state.
142
+ 2. Never promote live directly without staging verification.
143
+ 3. Prefer `dry_run=true` before state-changing requests.
144
+ 4. Always set `confirmed=true` when the policy requires explicit confirmation.
141
145
 
142
146
  ## 5. Tool Order (Recommended)
143
147
 
144
148
  1. `whc_prepare` to initialize hidden state and readiness checks.
145
149
  2. `whc_check_health` for target status and capability baseline.
146
150
  3. `whc_get_logs` for pre-deploy signal.
147
- 4. `whc_deploy` with `dry_run=true`.
148
- 5. `whc_deploy` real execution after dry-run passes.
149
- 6. `whc_verify` to produce technical verify report.
150
- 7. Run smoke checks outside or via allowed tool path.
151
- 8. If staging passes, run promote flow for live with explicit direction and backup policy.
151
+ 4. For `git_deploy`, run remote repository setup and local `git push`.
152
+ 5. For `ssh_scp_wpcli`, run the project-local doctor/SCP/WP-CLI pipeline.
153
+ 6. `whc_verify` to produce technical verify report.
154
+ 7. Run smoke checks outside or via allowed tool path.
155
+ 8. If staging passes, decide whether live release should proceed.
156
+
157
+ For `ssh_scp_wpcli` projects, replace steps 4-7 with the project-local source pipeline:
158
+ 1. doctor
159
+ 2. backup
160
+ 3. SCP code sync
161
+ 4. WP-CLI runtime bootstrap
162
+ 5. seed/bootstrap
163
+ 6. smoke gate
152
164
 
153
165
  ## 6.4 Rollback (Level D) Contract
154
166
 
@@ -175,74 +187,34 @@ Example rollback preview payload:
175
187
  }
176
188
  ```
177
189
 
178
- ## 6. Canonical Payloads
179
-
180
- ### 6.1 Staging dry-run (managed clone/sync refresh)
181
-
182
- ```json
183
- {
184
- "dry_run": true,
185
- "confirmed": true,
186
- "payload": {
187
- "workflow_mode": "managed_clone_sync",
188
- "target_environment": "staging",
189
- "release_intent": "refresh",
190
- "pipeline_id": "P3D",
191
- "source_profile": {
192
- "source_kind": "full_site",
193
- "deploy_unit": "raw_source"
194
- },
195
- "direction": "live_to_staging",
196
- "sync_scope": "files",
197
- "verify_after_deploy": true,
198
- "auto_rollback_on_verify_failure": false
199
- }
200
- }
201
- ```
202
-
203
- ### 6.2 Staging real refresh sync (managed clone/sync)
204
-
205
- ```json
206
- {
207
- "confirmed": true,
208
- "payload": {
209
- "workflow_mode": "managed_clone_sync",
210
- "target_environment": "staging",
211
- "release_intent": "refresh",
212
- "pipeline_id": "P3D",
213
- "source_profile": {
214
- "source_kind": "full_site",
215
- "deploy_unit": "raw_source"
216
- },
217
- "direction": "live_to_staging",
218
- "sync_scope": "files",
219
- "verify_after_deploy": true,
220
- "auto_rollback_on_verify_failure": false
221
- }
222
- }
223
- ```
224
-
225
- ### 6.3 Live promote (higher risk)
226
-
227
- ```json
228
- {
229
- "confirmed": true,
230
- "payload": {
231
- "workflow_mode": "managed_clone_sync",
232
- "target_environment": "live",
233
- "release_intent": "promote",
234
- "pipeline_id": "P3D",
235
- "source_profile": {
236
- "source_kind": "full_site",
237
- "deploy_unit": "raw_source"
238
- },
239
- "direction": "staging_to_live",
240
- "sync_scope": "files",
241
- "verify_after_deploy": true,
242
- "auto_rollback_on_verify_failure": true
243
- }
244
- }
245
- ```
190
+ ## 6. Canonical Usage Patterns
191
+
192
+ ### 6.1 `git_deploy`
193
+
194
+ Use this mode when the real delivery path is:
195
+
196
+ 1. local Git repository
197
+ 2. push to cPanel-managed repository
198
+ 3. cPanel deployment task runs `.cpanel.yml`
199
+
200
+ Agent expectations today:
201
+
202
+ 1. validate readiness with `check:generic`
203
+ 2. ensure remote repo exists with `whc_setup_remote`
204
+ 3. push with local Git
205
+ 4. trigger the cPanel deployment task with `whc_deploy`
206
+ 5. do not overstate this as WordPress runtime bootstrap; that still belongs to separate checks/scripts
207
+
208
+ ### 6.2 `ssh_scp_wpcli`
209
+
210
+ Use this mode for `mytho/source` style delivery:
211
+
212
+ 1. doctor
213
+ 2. backup
214
+ 3. SCP code sync
215
+ 4. WP-CLI bootstrap
216
+ 5. seed/bootstrap
217
+ 6. smoke gate
246
218
 
247
219
  ## 7. Smoke Gate Expectations
248
220
 
@@ -259,19 +231,24 @@ If preconditions fail (plugin/page/routes absent), gate must be `HOLD`.
259
231
 
260
232
  ## 7.1 Pipeline Mindset Guard
261
233
 
262
- Treat these as two different operations:
263
-
264
- 1. Environment refresh:
265
- - `workflow_mode=managed_clone_sync`
266
- - `direction=live_to_staging`
267
- - `release_intent=refresh`
268
- 2. Release deploy to staging:
269
- - Use release candidate source (typically `git_controlled`), not live mirror sync.
270
- - Use `repository_root` under `/home/<WHC_USER>/...`; cross-account paths are blocked by policy.
271
-
272
- Policy note:
273
-
274
- 1. `managed_clone_sync + live_to_staging + release_intent=deploy` is blocked by policy because it causes release-testing ambiguity.
234
+ Treat these as two different foundations:
235
+
236
+ 1. `git_deploy`
237
+ - repository-driven
238
+ - local `git push`
239
+ - cPanel deployment task
240
+ - `.cpanel.yml` at repo root
241
+ 2. `ssh_scp_wpcli`
242
+ - source-driven
243
+ - SCP file transfer
244
+ - remote WP-CLI runtime/bootstrap
245
+ - project-specific smoke gate
246
+
247
+ Policy note:
248
+
249
+ 1. `ssh_scp_wpcli` is the correct default mindset for `mytho/source`.
250
+ 2. `git_deploy` should not be described as staging/live native sync.
251
+ 3. If a release note or operator guide mentions `managed_clone_sync`, treat that as stale wording and replace it.
275
252
 
276
253
  ## 8. Troubleshooting
277
254
 
@@ -284,15 +261,16 @@ Symptom:
284
261
  Checks:
285
262
 
286
263
  1. Confirm `WHC_ENV_FILE` points to the intended env file.
287
- 2. Confirm the MCP process has reloaded after env edits.
264
+ 2. Confirm The tool server process has reloaded after env edits.
288
265
  3. Avoid malformed quoting in key path values.
289
266
 
290
- ### 8.2 Deploy validation errors in managed mode
291
-
292
- If request fails with missing direction, ensure payload includes:
293
-
294
- 1. `direction`
295
- 2. `sync_scope`
267
+ ### 8.2 Deploy contract confusion
268
+
269
+ If users are mixing repository deploy with environment-sync wording:
270
+
271
+ 1. for `git_deploy`, think `repository_root`, `branch`, `.cpanel.yml`, and cPanel deployment task
272
+ 2. for `ssh_scp_wpcli`, think WordPress app root, `scp`, `wp`, and smoke checks
273
+ 3. do not describe either mode as native WHC staging/live clone sync
296
274
 
297
275
  ## 9. One-Line Operator Playbook
298
276
 
@@ -302,13 +280,13 @@ If request fails with missing direction, ensure payload includes:
302
280
 
303
281
  ### 10.1 Log path
304
282
 
305
- 1. Default path: `.mcp/whc-mcp/logs/flow-events.jsonl`
283
+ 1. Default path: `.whc/logs/flow-events.jsonl`
306
284
  2. Custom path (optional): set `WHC_FLOW_LOG_PATH` in env
307
285
 
308
286
  ### 10.2 Read latest entries (PowerShell)
309
287
 
310
288
  ```powershell
311
- Get-Content .mcp/whc-mcp/logs/flow-events.jsonl -Tail 20
289
+ Get-Content .whc/logs/flow-events.jsonl -Tail 20
312
290
  ```
313
291
 
314
292
  If custom path is configured:
@@ -320,7 +298,7 @@ Get-Content $env:WHC_FLOW_LOG_PATH -Tail 20
320
298
  Filter only deploy events:
321
299
 
322
300
  ```powershell
323
- Get-Content .mcp/whc-mcp/logs/flow-events.jsonl -Tail 200 |
301
+ Get-Content .whc/logs/flow-events.jsonl -Tail 200 |
324
302
  ForEach-Object { $_ | ConvertFrom-Json } |
325
303
  Where-Object { $_.tool -eq 'whc_deploy' } |
326
304
  Select-Object -Last 10
@@ -343,7 +321,7 @@ Minimal response snippet:
343
321
 
344
322
  ```text
345
323
  Flow log:
346
- - path: .mcp/whc-mcp/logs/flow-events.jsonl
324
+ - path: .whc/logs/flow-events.jsonl
347
325
  - action_id: <value>
348
326
  - tool: whc_deploy
349
327
  - status: success|failure
@@ -358,24 +336,24 @@ Flow log:
358
336
  For local clone workflows, run once per workspace:
359
337
 
360
338
  ```powershell
361
- npm run mcp:prepare
339
+ npm run prepare
362
340
  ```
363
341
 
364
- For npm-package workflows, call `whc_prepare` once from the MCP client after the server starts.
342
+ For npm-package workflows, call `whc_prepare` once from The tool server client after the server starts.
365
343
 
366
344
  This initializes hidden management paths automatically:
367
- 1. `.mcp/whc-mcp/state/pipeline-status.json`
368
- 2. `.mcp/whc-mcp/state/releases/`
369
- 3. `.mcp/whc-mcp/state/reports/`
370
- 4. `.mcp/whc-mcp/logs/`
345
+ 1. `.whc/state/pipeline-status.json`
346
+ 2. `.whc/state/releases/`
347
+ 3. `.whc/state/reports/`
348
+ 4. `.whc/logs/`
371
349
 
372
- It also ensures `.mcp/` is ignored by git.
350
+ It also ensures `.whc/` is ignored by git.
373
351
 
374
352
  ## 10.5 Automatic State Tracking
375
353
 
376
- For every write tool run, MCP now auto-updates:
377
- 1. `.mcp/whc-mcp/state/pipeline-status.json` (started/completed/status/next step/error)
378
- 2. `.mcp/whc-mcp/state/releases/<request_id>.auto-manifest.json` (tool metadata + git changed files snapshot)
354
+ For every write tool run, tool server now auto-updates:
355
+ 1. `.whc/state/pipeline-status.json` (started/completed/status/next step/error)
356
+ 2. `.whc/state/releases/<request_id>.auto-manifest.json` (tool metadata + git changed files snapshot)
379
357
 
380
358
  No manual template authoring is required for normal DevOps runs.
381
359
 
@@ -392,3 +370,6 @@ For `whc_deploy` and `whc_setup_remote`, read these response fields first:
392
370
  Decision rule:
393
371
  1. If `pipeline_status=pass_partial`, do not claim end-to-end release completion.
394
372
  2. Follow `next_step` and unresolved `manual_actions` before moving to next gate.
373
+
374
+
375
+