Skip to content

Commit 61d608d

Browse files
authored
Merge pull request #34 from Hypercart-Dev-Tools/development
feat: Add preflight.sh session verification and integrate with install.sh
2 parents f23a848 + 9f2cd66 commit 61d608d

9 files changed

Lines changed: 1751 additions & 17 deletions

File tree

.DS_Store

-10 KB
Binary file not shown.

.vscode/tasks.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,54 @@
2929
}
3030
],
3131
"tasks": [
32+
{
33+
"label": "AI-DDTK: Preflight Check",
34+
"type": "shell",
35+
"command": "${workspaceFolder}/preflight.sh",
36+
"presentation": {
37+
"reveal": "always",
38+
"panel": "new",
39+
"focus": true,
40+
"clear": false
41+
},
42+
"runOptions": {
43+
"runOn": "folderOpen"
44+
},
45+
"problemMatcher": []
46+
},
47+
{
48+
"label": "AI-DDTK: Install MCP Server",
49+
"type": "shell",
50+
"command": "~/bin/ai-ddtk/install.sh",
51+
"args": ["setup-mcp"],
52+
"presentation": {
53+
"reveal": "always",
54+
"panel": "new"
55+
},
56+
"problemMatcher": []
57+
},
58+
{
59+
"label": "AI-DDTK: Install WPCC",
60+
"type": "shell",
61+
"command": "~/bin/ai-ddtk/install.sh",
62+
"args": ["setup-wpcc"],
63+
"presentation": {
64+
"reveal": "always",
65+
"panel": "new"
66+
},
67+
"problemMatcher": []
68+
},
69+
{
70+
"label": "AI-DDTK: Check Status",
71+
"type": "shell",
72+
"command": "~/bin/ai-ddtk/install.sh",
73+
"args": ["status"],
74+
"presentation": {
75+
"reveal": "always",
76+
"panel": "new"
77+
},
78+
"problemMatcher": []
79+
},
3280
{
3381
"label": "MCP: Start Server (stdio)",
3482
"type": "shell",

AGENTS.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# WordPress Development and Architecture Guidelines for AI Agents
22

3-
_Last updated: 2026-03-24 · Toolkit version: see [CHANGELOG.md](CHANGELOG.md)_
3+
_Last updated: 2026-03-25 · Toolkit version: see [CHANGELOG.md](CHANGELOG.md)_
44

55
## Purpose
66

@@ -14,27 +14,51 @@ Defines principles, constraints, and best practices for AI agents and Humans wor
1414

1515
This workspace uses **AI-DDTK** (AI Driven Development ToolKit) installed at `~/bin/ai-ddtk`.
1616

17+
### Session Preflight Check (Recommended First Step)
18+
19+
**Before starting any WordPress task, run a preflight check** to verify the toolkit is ready.
20+
21+
There are two modes — use whichever fits your context:
22+
23+
| Mode | When to use | Command |
24+
|------|-------------|---------|
25+
| **Shell preflight** | Quick human/CI check, no MCP needed | `./preflight.sh` |
26+
| **MCP-aware preflight** | Agent sessions with MCP tools available | Follow the prompt in [experimental/preflight.md](experimental/preflight.md) |
27+
28+
**Shell preflight** (`./preflight.sh`) can also be run from the VS Code task palette:
29+
- Press `Cmd+Shift+P` (macOS) or `Ctrl+Shift+P` (Linux/Windows)
30+
- Search for **"AI-DDTK: Preflight Check"**
31+
- Press Enter
32+
33+
**What preflight verifies:**
34+
- AI-DDTK installation at `~/bin/ai-ddtk`
35+
- Shell tools (rg, php, node, python3, git, tmux)
36+
- WPCC availability and features
37+
- MCP server build status and editor configuration
38+
- WordPress site context (Local WP or WP-CLI)
39+
40+
The **MCP-aware preflight** additionally probes live MCP tool connectivity, WordPress site info, and Playwright auth status.
41+
42+
**Why?** AI agents often forget about third-party tools and don't verify toolkit readiness before starting work. Preflight ensures everything is ready in seconds and suggests exact fix commands if anything is missing.
43+
44+
**If preflight detects missing items:**
45+
1. Run the suggested command (e.g., `~/bin/ai-ddtk/install.sh setup-mcp`)
46+
2. Re-run preflight to confirm: `./preflight.sh`
47+
3. Proceed with your task
48+
49+
---
50+
1751
### Before Starting Any Task
1852

19-
1. **Verify AI-DDTK is available and read this file**:
20-
```bash
21-
ls ~/bin/ai-ddtk/AGENTS.md
22-
cat ~/bin/ai-ddtk/AGENTS.md
23-
```
24-
2. **Inventory capabilities once per session**:
53+
1. **Run the preflight check** (see above) — this is the fastest way to verify everything
54+
2. **Establish WordPress site context early**:
55+
- for LocalWP workflows, list/select the site before site-specific commands
56+
- for browser or AJAX work, confirm the target URL/origin before changing anything
57+
3. **Keep runtime and sensitive artifacts under `./temp`** and out of git
58+
4. **Inventory capabilities** (preflight does this automatically, but for reference):
2559
- enumerate connected MCP tools/resources when MCP is available
26-
- probe shell tools with:
27-
```bash
28-
command -v wpcc pw-auth local-wp aiddtk-tmux wp-ajax-test rg php node python3 git tmux
29-
./install.sh status
30-
wpcc --features
31-
```
3260
- `rg`, `python3`, and `tmux` are **optional but recommended**; if missing, note it to the user as a suggestion (e.g. `brew install ripgrep python3 tmux`) rather than treating it as a blocker
3361
- summarize what is available once, keep that summary as session memory, and prefer MCP tools over raw shell when both exist
34-
3. **Establish WordPress site context early**:
35-
- for LocalWP workflows, list/select the site before site-specific commands
36-
- for browser or AJAX work, confirm the target URL/origin before changing anything
37-
4. **Keep runtime and sensitive artifacts under `./temp`** and out of git.
3862

3963
### MCP Server Setup and Lifecycle
4064

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,35 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1313
- Do not edit a version block that has already been committed and pushed
1414
-->
1515

16+
## [1.3.0] - 2026-03-25
17+
18+
### Changed
19+
- **`preflight.sh` reliability overhaul** — removed `set -e` (failures are expected in a diagnostic script), fixed macOS `wc -l` whitespace issue, added exit-code tracking (exits with count of critical failures), improved WPCC feature detection, and switched to ASCII markers for terminal compatibility.
20+
- **`experimental/preflight.md` rewrite for consuming projects** — rewrote from the perspective of agents working in external WordPress projects where AI-DDTK is installed as a toolkit, not agents inside the AI-DDTK repo itself. Removed "Session Rules" directive block that other agents flagged as prompt-injection-like. All MCP and WordPress steps are now conditional with skip guidance.
21+
- **`AGENTS.md` preflight section** — replaced dead link to `temp/PREFLIGHT-INSTALL-INTEGRATION.md` with a table distinguishing shell preflight (`./preflight.sh`) from MCP-aware preflight (`experimental/preflight.md`), clarifying when to use each.
22+
23+
### Removed
24+
- **`temp/ai-ddtk-preflight-complete.md`** — deleted redundant copy of the preflight checklist (content already lives in `experimental/preflight.md`).
25+
26+
## [1.2.9] - 2026-03-25
27+
28+
### Changed
29+
- **`README.md` optional preflight discoverability** — added a short documentation-table entry pointing to `experimental/preflight.md` so users can adopt the session-start preflight workflow without repeated manual reminders.
30+
31+
## [1.2.8] - 2026-03-25
32+
33+
### Changed
34+
- **`experimental/servers.md` troubleshooting hardening** — updated T-2 and T-3 with safer, execution-ready workflows: `local-wp`-scoped commands, DB backup before URL rewrites, `search-replace --dry-run` before apply, and `/etc/hosts` backup before sudo edits.
35+
36+
## [1.2.7] - 2026-03-25
37+
38+
### Added
39+
- **`experimental/servers-audit.sh` baseline report generator** — added a new hostname/port audit helper that captures listening services, DNS and hosts state, Local WP site metadata, service-manager status, and auto-detected conflict sections into a populated Markdown snapshot. The script mirrors the resilient orchestration patterns used in other experimental tooling and also writes machine-readable artifacts under `temp/servers-audit/<run-id>/`.
40+
41+
### Changed
42+
- **`experimental/servers.md` usage alignment** — expanded the template’s run instructions to include the new `--focus` and `--previous-snapshot` options plus the artifact-output note so developers can run targeted hostname audits and maintain diff-friendly baselines.
43+
- **Active-fix guidance for server audits** — expanded the `## AI Agent Instructions` flow in both `experimental/servers.md` and generated audit output to require detect → concrete fix commands → permission-gated execution for privileged actions → post-fix re-audit verification → snapshot diff validation, with explicit iteration stop conditions.
44+
1645
## [1.2.6] - 2026-03-24
1746

1847
### Fixed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,31 @@ local-wp --help
7777
./install.sh status
7878
```
7979

80+
### Getting Started with AI Agents
81+
82+
Before starting any WordPress development task with Claude Code, Augment, Cline, or other AI agents:
83+
84+
**Run the preflight check** (one-time per session):
85+
86+
```bash
87+
# From any AI-DDTK workspace
88+
./preflight.sh
89+
```
90+
91+
Or use the VS Code task palette:
92+
- Press `Cmd+Shift+P` (macOS) or `Ctrl+Shift+P` (Linux/Windows)
93+
- Search for **"AI-DDTK: Preflight Check"**
94+
- Press Enter
95+
96+
The preflight verifies:
97+
- ✓ AI-DDTK installation
98+
- ✓ Shell tools (rg, php, node, python3, git, tmux)
99+
- ✓ WPCC availability
100+
- ✓ MCP server configuration
101+
- ✓ WordPress site context
102+
103+
**Why?** AI agents often forget about third-party tools. Preflight ensures the toolkit is ready before you start coding.
104+
80105
---
81106

82107
## Everyday Workflows
@@ -155,6 +180,7 @@ Beyond initial setup: `doctor-playwright` (diagnose Playwright issues), `setup-w
155180
| **Local WP Commands** | [docs/LOCAL-WP-COMMANDS.md](docs/LOCAL-WP-COMMANDS.md) |
156181
| **Troubleshooting** | [docs/TROUBLESHOOTING.md](docs/TROUBLESHOOTING.md) |
157182
| **CI/CD Integration** | [docs/CI-CD-INTEGRATION.md](docs/CI-CD-INTEGRATION.md) |
183+
| **Session Preflight (Optional)** | [experimental/preflight.md](experimental/preflight.md) |
158184
| **Weekly UX Audit** | [recipes/weekly-ux-audit.md](recipes/weekly-ux-audit.md) |
159185
| **Fix-Iterate Loop Pattern** | [fix-iterate-loop.md](fix-iterate-loop.md) |
160186
| **Security & Performance Rules** | [AGENTS.md — Security](AGENTS.md#-security-sensitive-data-and-performance-guardrails) |

experimental/preflight.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# AI-DDTK Preflight Checklist
2+
3+
A diagnostic checklist for AI agents working in **any WordPress project** where AI-DDTK has been installed locally. This is not specific to the AI-DDTK repo itself — it's designed for agents operating in theme, plugin, or site workspaces where the user has AI-DDTK available as an external toolkit.
4+
5+
AI-DDTK is typically installed at `~/bin/ai-ddtk`. If the user has it, the MCP server may already be wired into their editor, giving you access to tools like `wpcc_*`, `local_wp_*`, `pw_auth_*`, `qm_*`, and `tmux_*` without any shell commands.
6+
7+
---
8+
9+
## When to use this
10+
11+
Run through this checklist at the start of a session when:
12+
- You're in a WordPress project and want to know what toolkit support is available
13+
- The user mentions AI-DDTK, WPCC, or scanning/profiling tools
14+
- You see MCP tools with `ai-ddtk` prefixes in your tool list and want to confirm they work
15+
16+
If none of the above apply, skip this entirely.
17+
18+
---
19+
20+
## Steps
21+
22+
### 1. Check if AI-DDTK is installed
23+
24+
```bash
25+
ls -d ~/bin/ai-ddtk 2>/dev/null && echo "installed" || echo "not installed"
26+
```
27+
28+
If installed, the user has access to WPCC (static analysis), LocalWP helpers, Playwright auth, Query Monitor profiling, and more. Reference docs are at `~/bin/ai-ddtk/AGENTS.md`.
29+
30+
If not installed, none of the below applies — proceed with standard tools.
31+
32+
### 2. Check for MCP tools in the current session
33+
34+
Look at your available tool list. If you see tools prefixed with `ai-ddtk` (e.g., `wpcc_list_features`, `local_wp_list_sites`), the MCP server is connected and you can use them directly.
35+
36+
If MCP tools are not visible:
37+
- The user may need to run `~/bin/ai-ddtk/install.sh setup-mcp` to build the server
38+
- Or the editor may need a `.mcp.json` pointing to the server — check `~/bin/ai-ddtk/AGENTS.md` for setup instructions
39+
- This is not a blocker — you can still use the shell CLI tools (`wpcc`, `pw-auth`, `local-wp`, `aiddtk-tmux`) if they're in PATH
40+
41+
### 3. Check shell tools
42+
43+
```bash
44+
command -v wpcc pw-auth local-wp aiddtk-tmux rg php node python3 git tmux
45+
```
46+
47+
AI-DDTK CLI tools (`wpcc`, `pw-auth`, `local-wp`, `aiddtk-tmux`) are added to PATH by the installer. The rest (`rg`, `php`, `node`, etc.) are general dependencies — optional but recommended.
48+
49+
Report what's available. Missing items are worth noting to the user but are not blockers for most tasks.
50+
51+
### 4. Establish WordPress site context (if relevant)
52+
53+
If the current task involves a WordPress site:
54+
- MCP available: call `local_wp_list_sites` then `local_wp_get_site_info` for the target site
55+
- Shell only: `local-wp --list` or `wp option get siteurl`
56+
- Optionally check Playwright auth: `pw_auth_status` (MCP) or `pw-auth status` (shell)
57+
58+
Skip this step if the task doesn't involve a live WordPress site.
59+
60+
### 5. Summarise what's available
61+
62+
Give the user a brief summary of what you found. Example:
63+
64+
```
65+
AI-DDTK: installed at ~/bin/ai-ddtk
66+
MCP tools: 21 tools connected (wpcc, local_wp, pw_auth, qm, tmux)
67+
WPCC: available, 54 patterns
68+
Site: my-site.local (WP 6.7, PHP 8.2)
69+
Auth: admin session valid
70+
Shell: rg, php, node, python3, git, tmux — all available
71+
```
72+
73+
Only include sections for things that are actually present. If MCP isn't connected, just say so and list the shell tools that are available instead.
74+
75+
---
76+
77+
## Notes
78+
79+
- This checklist helps you discover what's available — it does not change how you should behave. Tool usage guidance is in `~/bin/ai-ddtk/AGENTS.md`, which the user can add to their project's CLAUDE.md if they want it applied.
80+
- If AI-DDTK is not installed, disregard this checklist entirely and work with whatever tools are available in the current environment.

0 commit comments

Comments
 (0)