Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
### Added
- **Native `.wpcignore` support in WPCC** — `check-performance.sh` now loads gitignore-style patterns from a `.wpcignore` file and filters the PHP file list before scanning. Auto-detects `.wpcignore` in the scan target directory or current working directory. Supports directory patterns (`tools/`), extension globs (`*.min.js`), and literal substring matches. New flags: `--wpcignore-file <path>` for explicit file, `--no-wpcignore` to disable. Unblocks repo-wide scanning without false positives from embedded tools, temp files, and vendor directories.
- **VS Code extension dynamic MCP discovery (v0.2.0)** — the extension's MCP server definition provider now merges configs from 5 layers (static AI-DDTK fallback, workspace `.mcp.json`, `.vscode/mcp.json`, `.mcp.local.json`, `temp/mcp/local-snippets/*.json`) with file watchers for live re-discovery. Site-specific WP MCP Adapter servers are automatically provided to all VS Code MCP clients without manual wiring or restart.
- **`experimental/end-of-day.sh` — solo developer session cleanup script** — automated script for end-of-work synchronization. Checks 4X4.md, CHANGELOG.md, and MEMORY.md freshness; archives session-scoped MEMORY.md to `PROJECT/1-INBOX/MEMORY-<timestamp>.md` for clean sessions. Supports `--commit` (with confirmation), `--push` (implies commit, with confirmation), `--force` (skip prompts for automation), `--dry-run`, and agent hook integration for orchestration. Default mode reports findings only; opt-in flags enable commit/push. Includes build validation (PHP syntax check) and structured event emission for agent coordination.
- **MCP tool: `end_of_day_session_cleanup`** — expose end-of-day.sh as a typed MCP tool (v0.9.0). Agents can call `end_of_day_session_cleanup` with `mode` (report/commit/push), `dryRun`, `force`, `skipValidation` flags. Returns structured check results (4X4.md, CHANGELOG.md, MEMORY.md, build validation), git state (branch, modified files, untracked), and command exit code. Enables VS Code agents to orchestrate session cleanup without shell escaping.
- **`experimental/post-flight.sh` — solo developer post-flight session cleanup script** — automated script for post-session synchronization. Checks 4X4.md, CHANGELOG.md, and MEMORY.md freshness; archives session-scoped MEMORY.md to `PROJECT/1-INBOX/MEMORY-<timestamp>.md` for clean sessions. Supports `--commit` (with confirmation), `--push` (implies commit, with confirmation), `--force` (skip prompts for automation), `--dry-run`, and agent hook integration for orchestration. Default mode reports findings only; opt-in flags enable commit/push. Includes build validation (PHP syntax check) and structured event emission for agent coordination.
- **MCP tool: `post_flight_session_cleanup`** — expose post-flight.sh as a typed MCP tool (v0.9.0). Agents can call `post_flight_session_cleanup` with `mode` (report/commit/push), `dryRun`, `force`, `skipValidation` flags. Returns structured check results (4X4.md, CHANGELOG.md, MEMORY.md, build validation), git state (branch, modified files, untracked), and command exit code. Enables VS Code agents to orchestrate session cleanup without shell escaping.

### Changed
- **`end-of-day.sh` pluggable build validation** — `validate_build()` now auto-detects and runs PHP syntax checks (up to 200 files), `npm run build` (if `package.json` has a `build` script), and `composer validate` (if `composer.json` exists). Skips gracefully when no validators are detected. Previously only checked a single hardcoded PHP file. MCP handler updated to capture per-validator results.
- **`post-flight.sh` pluggable build validation** — `validate_build()` now auto-detects and runs PHP syntax checks (up to 200 files), `npm run build` (if `package.json` has a `build` script), and `composer validate` (if `composer.json` exists). Skips gracefully when no validators are detected. Previously only checked a single hardcoded PHP file. MCP handler updated to capture per-validator results.
- **`servers-audit.sh` and `servers-preflight.sh` promoted to `tools/`** — moved from `experimental/` to `tools/` alongside `servers.md` template. These scripts have received 4+ consecutive hardening releases (Launchd plist parsing, KeepAlive detection, expanded TLD coverage, Valet site discovery) and are no longer experimental. Internal path references (`$SCRIPT_DIR`) are relative and required no changes. CLI-REFERENCE.md updated with new sections for both scripts.

## [1.8.6] - 2026-04-05
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# End-of-Day Session Cleanup Script
# Post-Flight Session Cleanup Script

## Overview

**Status**: ✅ DRAFT COMPLETE
**Location**: `experimental/end-of-day.sh`
**Purpose**: Solo developer session cleanup — ensures 4X4.md, CHANGELOG.md, MEMORY.md are synced, optionally commits and pushes.
**Location**: `experimental/post-flight.sh`
**Purpose**: Solo developer post-flight session cleanup — ensures 4X4.md, CHANGELOG.md, MEMORY.md are synced, optionally commits and pushes.

---

Expand All @@ -20,7 +20,7 @@ The original analysis included pushback on auto-commit/push risks. However, for

---

## Analysis & Feedback on "end-of-day" Script
## Analysis & Feedback on "post-flight" Script

**Good idea.** This addresses a real friction point. But let me push back on scope and add some nuances based on what `servers-preflight.sh` and `servers-audit.sh` do well.

Expand Down Expand Up @@ -83,13 +83,13 @@ Check:

```bash
#!/usr/bin/env bash
# end-of-day.sh — Session cleanup & doc synchronization
# post-flight.sh — Session cleanup & doc synchronization
#
# Ensures 4X4.md, CHANGELOG.md, MEMORY.md are synced before close-of-day.
# Ensures 4X4.md, CHANGELOG.md, MEMORY.md are synced after session.
# Reports findings, suggests fixes, but does NOT auto-commit/push unless --auto-commit.
#
# Usage:
# end-of-day.sh [--auto-commit] [--push] [--no-validate] [--hook <script>]
# post-flight.sh [--auto-commit] [--push] [--no-validate] [--hook <script>]
#
# Exit codes:
# 0 = OK, all docs fresh, working tree clean
Expand Down Expand Up @@ -130,7 +130,7 @@ check_changelog() {
}

check_memory() {
# MEMORY.md exists, should be archived at EOD if present
# MEMORY.md exists, should be archived at post-flight if present
# Return: "fresh" | "missing" | "should_archive"
}

Expand Down Expand Up @@ -167,7 +167,7 @@ main() {

The agent could call it like:
```bash
end-of-day.sh --hook ./agent-hook.sh --json-events \
post-flight.sh --hook ./agent-hook.sh --json-events \
&& git log -1 --oneline \
|| echo "Session cleanup needed"
```
Expand All @@ -189,7 +189,7 @@ Not dumb—it's **solving a real problem**. But I'd recommend:
1. **Don't auto-commit by default**—make it opt-in with `--auto-commit`
2. **Use the event/hook pattern** from `servers-audit.sh`—lets agents orchestrate without you baking in every decision
3. **Validate before committing**—quick syntax check + git state sanity
4. **Archive MEMORY.md at EOD**—keeps it from growing and cluttering the repo
4. **Archive MEMORY.md at post-flight**—keeps it from growing and cluttering the repo
5. **Generate commit messages from diffs**—human-friendly, not "Lazy commit"

**Thoughts? Should I sketch out a full draft?**
Expand All @@ -198,13 +198,13 @@ Not dumb—it's **solving a real problem**. But I'd recommend:

## ✅ Implementation Complete

The script has been drafted and placed at `experimental/end-of-day.sh`.
The script has been drafted and placed at `experimental/post-flight.sh`.

### Key Features

#### **Default Behavior (No Flags)**
```bash
end-of-day.sh
post-flight.sh
```
- ✓ Checks 4X4.md, CHANGELOG.md, MEMORY.md freshness
- ✓ Archives MEMORY.md if present → `PROJECT/1-INBOX/MEMORY-<timestamp>.md`
Expand All @@ -215,7 +215,7 @@ end-of-day.sh

#### **Commit Mode**
```bash
end-of-day.sh --commit
post-flight.sh --commit
```
- Runs all checks (as above)
- Prompts: "Continue with commit?" `[y/N]`
Expand All @@ -224,7 +224,7 @@ end-of-day.sh --commit

#### **Push Mode**
```bash
end-of-day.sh --push
post-flight.sh --push
```
- Implies `--commit`
- After commit, prompts: "Push to remote?" `[y/N]`
Expand All @@ -233,7 +233,7 @@ end-of-day.sh --push

#### **Force Mode (Automation)**
```bash
end-of-day.sh --push --force
post-flight.sh --push --force
```
- Skips ALL confirmation prompts
- Archives MEMORY.md, commits, pushes automatically
Expand All @@ -242,7 +242,7 @@ end-of-day.sh --push --force

#### **Dry-Run Mode**
```bash
end-of-day.sh --push --dry-run
post-flight.sh --push --dry-run
```
- Shows what WOULD happen, but doesn't execute
- Useful for testing, previewing before automation
Expand Down Expand Up @@ -275,7 +275,7 @@ Keeps MEMORY.md fresh for each session without losing context.
The script emits **structured events** that agents can hook into:

```bash
end-of-day.sh --push --hook ./agent-hook.sh
post-flight.sh --push --hook ./agent-hook.sh
```

**Agent Hook Protocol**: Hook receives `<script> <event-name> '<json-payload>'`
Expand Down Expand Up @@ -303,4 +303,4 @@ end-of-day.sh --push --hook ./agent-hook.sh
- [ ] Pre-commit validation (run tests, linters if configured)
- [ ] Selective archiving (different locations by file type)
- [ ] Rollback support (easy undo if push fails)
- [ ] Config file support (`.end-of-day.toml` per-repo settings)
- [ ] Config file support (`.post-flight.toml` per-repo settings)
18 changes: 9 additions & 9 deletions experimental/end-of-day.sh → experimental/post-flight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

set -euo pipefail

# ─── end-of-day.sh ─────────────────────────────────────────────────────────
# ─── post-flight.sh ─────────────────────────────────────────────────────────
#
# Session cleanup & documentation synchronization for solo developers.
#
# Ensures 4X4.md, CHANGELOG.md, MEMORY.md are synced, optionally commits and
# pushes with a single confirmation prompt.
#
# Usage:
# end-of-day.sh [OPTIONS]
# post-flight.sh [OPTIONS]
#
# Options:
# --commit Stage & commit if docs changed (requires confirmation)
Expand All @@ -28,19 +28,19 @@ set -euo pipefail
#
# Examples:
# # Report only (default)
# end-of-day.sh
# post-flight.sh
#
# # Commit with confirmation
# end-of-day.sh --commit
# post-flight.sh --commit
#
# # Commit + push with confirmation
# end-of-day.sh --push
# post-flight.sh --push
#
# # Full automation (no prompts)
# end-of-day.sh --push --force
# post-flight.sh --push --force
#
# # With agent hook for orchestration
# end-of-day.sh --push --hook ./my-agent-hook.sh
# post-flight.sh --push --hook ./my-agent-hook.sh
#
# Agent Hook Events:
# check:4x4 '{"status":"ok|missing|stale|mismatch"}'
Expand Down Expand Up @@ -333,7 +333,7 @@ done
# ─── Main ────────────────────────────────────────────────────────────────────

main() {
echo "${BOLD}[end-of-day] 📋 Session Summary${NC}"
echo "${BOLD}[post-flight] 📋 Session Summary${NC}"
echo ""

check_4x4 || true
Expand All @@ -342,7 +342,7 @@ main() {
check_git_state || true

echo ""
echo "${BOLD}[end-of-day] 🔍 Validation${NC}"
echo "${BOLD}[post-flight] 🔍 Validation${NC}"
validate_build || true

if [ "$MODE_COMMIT" -eq 0 ]; then
Expand Down
4 changes: 2 additions & 2 deletions tools/mcp-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> Version: 0.9.0

Unified MCP server for AI-DDTK. Exposes LocalWP, WPCC, `pw-auth`, `wp-ajax-test`, tmux, Query Monitor, and end-of-day session cleanup workflows as typed **Tools**, **Resources**, and **Prompts** — compatible with Claude Code, GitHub Copilot, Cline, Augment Code, Cursor, Claude Desktop, and any MCP-capable client.
Unified MCP server for AI-DDTK. Exposes LocalWP, WPCC, `pw-auth`, `wp-ajax-test`, tmux, Query Monitor, and post-flight session cleanup workflows as typed **Tools**, **Resources**, and **Prompts** — compatible with Claude Code, GitHub Copilot, Cline, Augment Code, Cursor, Claude Desktop, and any MCP-capable client.

## Quick Start

Expand Down Expand Up @@ -55,7 +55,7 @@ npm run mcp:http
| AJAX | `wp_ajax_test` | Test `admin-ajax.php` endpoints with structured inputs |
| tmux | `tmux_start`, `tmux_send`, `tmux_capture`, `tmux_stop`, `tmux_list`, `tmux_status` | Run resilient long-lived commands and inspect output |
| Query Monitor | `qm_profile_page`, `qm_slow_queries`, `qm_duplicate_queries` | Profile pages, find slow queries, detect N+1 patterns |
| Session cleanup | `end_of_day_session_cleanup` | Automated solo dev session cleanup: sync 4X4.md/CHANGELOG.md/MEMORY.md, optionally commit and push with confirmation |
| Session cleanup | `post_flight_session_cleanup` | Automated solo dev post-flight session cleanup: sync 4X4.md/CHANGELOG.md/MEMORY.md, optionally commit and push with confirmation |

## Resources

Expand Down
4 changes: 2 additions & 2 deletions tools/mcp-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tools/mcp-server/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ai-ddtk-mcp",
"version": "0.9.0",
"description": "AI-DDTK MCP server for LocalWP, pw-auth, wp-ajax-test, tmux, WPCC, Query Monitor, and end-of-day session cleanup workflows",
"description": "AI-DDTK MCP server for LocalWP, pw-auth, wp-ajax-test, tmux, WPCC, Query Monitor, and post-flight session cleanup workflows",
"type": "module",
"main": "dist/src/index.js",
"bin": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { ExecFileTextError, execFileText, type ExecFileText, type ExecResult } f

const DEFAULT_TIMEOUT_MS = 30_000;

export type EndOfDayMode = "report" | "commit" | "push";
export type PostFlightMode = "report" | "commit" | "push";

export type EndOfDayCheckResult = Record<string, unknown> & {
export type PostFlightCheckResult = Record<string, unknown> & {
check: string;
status: "ok" | "missing" | "stale" | "dirty" | "error";
message: string;
};

export type EndOfDayResult = Record<string, unknown> & {
mode: EndOfDayMode;
export type PostFlightResult = Record<string, unknown> & {
mode: PostFlightMode;
dryRun: boolean;
force: boolean;
checks: EndOfDayCheckResult[];
checks: PostFlightCheckResult[];
gitBranch: string;
gitState: "clean" | "dirty";
modifiedFiles: number;
Expand All @@ -25,22 +25,22 @@ export type EndOfDayResult = Record<string, unknown> & {
exitCode: number;
};

export interface EndOfDayHandlerDeps {
export interface PostFlightHandlerDeps {
repoRoot: string;
timeoutMs?: number;
execRunner?: ExecFileText;
}

export function createEndOfDayHandlers(deps: EndOfDayHandlerDeps) {
export function createPostFlightHandlers(deps: PostFlightHandlerDeps) {
const { repoRoot, timeoutMs = DEFAULT_TIMEOUT_MS, execRunner = execFileText } = deps;
const scriptPath = path.join(repoRoot, "experimental/end-of-day.sh");
const scriptPath = path.join(repoRoot, "experimental/post-flight.sh");

async function runEndOfDay(options: {
mode?: EndOfDayMode;
async function runPostFlight(options: {
mode?: PostFlightMode;
dryRun?: boolean;
force?: boolean;
skipValidation?: boolean;
}): Promise<EndOfDayResult> {
}): Promise<PostFlightResult> {
const { mode = "report", dryRun = false, force = false, skipValidation = false } = options;

const args: string[] = [];
Expand Down Expand Up @@ -71,7 +71,7 @@ export function createEndOfDayHandlers(deps: EndOfDayHandlerDeps) {

// Parse stdout for check results and git state
const lines = result.stdout.split("\n");
const checks: EndOfDayCheckResult[] = [];
const checks: PostFlightCheckResult[] = [];
let gitBranch = "unknown";
let gitState: "clean" | "dirty" = "clean";
let modifiedFiles = 0;
Expand Down Expand Up @@ -157,6 +157,6 @@ export function createEndOfDayHandlers(deps: EndOfDayHandlerDeps) {
}
}

return { runEndOfDay };
return { runPostFlight };
}

10 changes: 5 additions & 5 deletions tools/mcp-server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { createTmuxHandlers } from "./handlers/tmux.js";
import { createWpAjaxTestHandlers } from "./handlers/wp-ajax-test.js";
import { createQmHandlers } from "./handlers/qm.js";
import { WPCC_LATEST_REPORT_URI, WPCC_LATEST_SCAN_URI, WPCC_SCAN_URI_TEMPLATE, createWpccHandlers } from "./handlers/wpcc.js";
import { createEndOfDayHandlers } from "./handlers/end-of-day.js";
import { createPostFlightHandlers } from "./handlers/post-flight.js";
import { SessionStore, SiteState } from "./state.js";
import { loadOrGenerateToken, getTokenFilePath } from "./utils/token.js";

Expand Down Expand Up @@ -165,7 +165,7 @@ export function createServer() {
const wpAjaxTestHandlers = createWpAjaxTestHandlers({ repoRoot });
const wpccHandlers = createWpccHandlers({ repoRoot });
const qmHandlers = createQmHandlers({ getCookiesForSite: (user, domain) => pwAuthHandlers.getCookiesForSite(user, domain), repoRoot });
const endOfDayHandlers = createEndOfDayHandlers({ repoRoot });
const postFlightHandlers = createPostFlightHandlers({ repoRoot });

const server = new McpServer({
name: "ai-ddtk-mcp",
Expand Down Expand Up @@ -860,10 +860,10 @@ export function createServer() {
);

server.registerTool(
"end_of_day_session_cleanup",
"post_flight_session_cleanup",
{
description:
"Solo developer session cleanup — ensures 4X4.md, CHANGELOG.md, and MEMORY.md are synced. Optionally commits and pushes with confirmation. Archives MEMORY.md to PROJECT/1-INBOX/ for clean sessions. Runs build validation.",
"Solo developer post-flight session cleanup — ensures 4X4.md, CHANGELOG.md, and MEMORY.md are synced. Optionally commits and pushes with confirmation. Archives MEMORY.md to PROJECT/1-INBOX/ for clean sessions. Runs build validation.",
inputSchema: {
mode: z.enum(["report", "commit", "push"]).default("report").describe("report (default, no git actions), commit (with confirmation), or push (commit + push with confirmations)"),
dryRun: z.boolean().default(false).describe("Show what would happen without executing"),
Expand Down Expand Up @@ -891,7 +891,7 @@ export function createServer() {
async ({ mode = "report", dryRun = false, force = false, skipValidation = false }) => {
try {
return successResult(
await endOfDayHandlers.runEndOfDay({
await postFlightHandlers.runPostFlight({
mode: mode as "report" | "commit" | "push",
dryRun,
force,
Expand Down
Loading