-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpcc
More file actions
executable file
·225 lines (202 loc) · 8.55 KB
/
Copy pathwpcc
File metadata and controls
executable file
·225 lines (202 loc) · 8.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env bash
# ============================================================
# WPCC (WP Code Check) Wrapper
# Part of AI-DDTK - AI Driven Development ToolKit
# ============================================================
#
# PURPOSE:
# Thin wrapper that calls WP Code Check from the tools/ directory.
# Allows WPCC to be called from any project directory.
#
# USAGE:
# wpcc <command> [args...]
# wpcc analyze ./wp-content/plugins/my-plugin
# wpcc --help
#
# FOR LLM AGENTS:
# - This wrapper resolves the path to tools/wp-code-check/
# - It passes all arguments through to the actual WPCC script
# - If WPCC is later merged into AI-DDTK, update the WPCC_PATH below
# - The wrapper ensures WPCC works regardless of current directory
#
# ============================================================
set -e
# Resolve the directory where this script lives
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TOOLKIT_ROOT="$(dirname "$SCRIPT_DIR")"
# Path to WPCC (git subtree location)
WPCC_PATH="$TOOLKIT_ROOT/tools/wp-code-check"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
# ============================================================
# FOR LLM AGENTS: WPCC LOCATION
# ============================================================
# WPCC is embedded via git subtree at: tools/wp-code-check/
#
# If WPCC structure changes, update these paths:
# - WPCC_ENTRY_POINT: Main executable script
# - WPCC_PATH: Root directory of WPCC
#
# Current structure (as of v1.3.14):
# tools/wp-code-check/
# ├── dist/
# │ └── bin/
# │ └── check-performance.sh <-- Main entry point
# └── ...
# ============================================================
# Check if WPCC is installed
if [ ! -d "$WPCC_PATH" ]; then
echo -e "${RED}Error: WP Code Check not found at: $WPCC_PATH${NC}"
echo ""
echo -e "${YELLOW}WPCC needs to be added via git subtree.${NC}"
echo "Run the following command from the AI-DDTK root:"
echo ""
echo " git subtree add --prefix=tools/wp-code-check \\"
echo " https://github.com/Hypercart-Dev-Tools/WP-Code-Check.git main --squash"
echo ""
echo "Or run: ./install.sh setup-wpcc"
exit 1
fi
# Determine the WPCC entry point (try multiple locations)
WPCC_ENTRY_POINT=""
ENTRY_POINTS=(
"$WPCC_PATH/dist/bin/check-performance.sh"
"$WPCC_PATH/check-performance.sh"
"$WPCC_PATH/bin/check-performance.sh"
"$WPCC_PATH/wp-code-check.sh"
)
for entry in "${ENTRY_POINTS[@]}"; do
if [ -f "$entry" ] && [ -x "$entry" ]; then
WPCC_ENTRY_POINT="$entry"
break
fi
done
if [ -z "$WPCC_ENTRY_POINT" ]; then
echo -e "${RED}Error: Cannot find WPCC entry point${NC}"
echo "Looked for:"
for entry in "${ENTRY_POINTS[@]}"; do
echo " - $entry"
done
echo ""
echo -e "${YELLOW}FOR LLM AGENTS: Update ENTRY_POINTS array in this script${NC}"
exit 1
fi
# ============================================================
# FEATURE DISCOVERY
# ============================================================
# Shows all available WPCC capabilities via --features flag
# ============================================================
show_features() {
echo ""
echo -e "${BLUE}╔══════════════════════════════════════════════════════════════╗${NC}"
echo -e "${BLUE}║${NC} ${GREEN}AI-DDTK WordPress Code Check - Features${NC} ${BLUE}║${NC}"
echo -e "${BLUE}╚══════════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${GREEN}BASIC SCANNING${NC}"
echo " wpcc --paths <path> Run security/performance scan"
echo " wpcc --paths <path> --format json Output as JSON for AI processing"
echo " wpcc --paths <path> --verbose Show detailed progress"
echo ""
echo -e "${GREEN}PROJECT TEMPLATES${NC} (Recommended for recurring scans)"
echo " Templates let you save scan configuration for plugins/themes you scan often."
echo ""
# Count templates
TEMPLATE_COUNT=$(ls -1 "$WPCC_PATH/dist/TEMPLATES/"*.txt 2>/dev/null | grep -v "_" | wc -l | tr -d ' ')
echo -e " ${YELLOW}Templates saved:${NC} $TEMPLATE_COUNT"
echo -e " ${YELLOW}Location:${NC} $WPCC_PATH/dist/TEMPLATES/"
echo -e " ${YELLOW}Guide:${NC} $WPCC_PATH/dist/HOWTO-TEMPLATES.md"
echo ""
if [ "$TEMPLATE_COUNT" -gt 0 ]; then
echo " Available templates:"
for t in "$WPCC_PATH/dist/TEMPLATES/"*.txt; do
if [[ "$(basename "$t")" != "_"* ]]; then
echo " - $(basename "$t" .txt)"
fi
done 2>/dev/null
echo ""
fi
echo -e "${GREEN}AI-ASSISTED TRIAGE${NC} (Reduces false positives)"
echo " After a scan, AI can analyze findings to identify false positives"
echo " and provide prioritized recommendations."
echo ""
echo " Ask your AI agent:"
echo " • \"Triage this scan\""
echo " • \"Analyze the scan results for false positives\""
echo " • \"Run [template] end to end\" (includes triage)"
echo ""
echo -e "${GREEN}GITHUB ISSUE CREATION${NC} (Automated tracking)"
echo " Convert scan findings into GitHub issues with checkboxes."
echo " Also exports to: Jira, Linear, Asana, Trello, Monday.com"
echo ""
echo " Ask your AI agent:"
echo " • \"Create GitHub issue for this scan\""
echo " • \"Export findings for Jira\""
echo ""
echo -e " ${YELLOW}Script:${NC} $WPCC_PATH/dist/bin/create-github-issue.sh"
echo -e " ${YELLOW}Output:${NC} $WPCC_PATH/dist/issues/"
echo ""
echo -e "${GREEN}END-TO-END WORKFLOW${NC} (Full automation)"
echo " Combine scan → AI triage → HTML report → GitHub issue in one flow."
echo ""
echo " Ask your AI agent:"
echo " • \"Run [plugin-name] end to end\""
echo " • \"Execute complete workflow for [template]\""
echo ""
echo " Phases:"
echo " Phase 1: Scan → JSON findings"
echo " Phase 2: AI Triage → False positive detection"
echo " Phase 3: HTML Report → With AI summary"
echo " Phase 4: GitHub Issue → With checkboxes"
echo ""
echo -e "${GREEN}IRL AUDIT MODE${NC} (Pattern library contribution)"
echo " Audit real-world code examples and add to the pattern library."
echo ""
echo " Ask your AI agent:"
echo " • \"Audit this file for anti-patterns\""
echo " • \"Add this to IRL examples\""
echo ""
echo -e " ${YELLOW}Guide:${NC} $WPCC_PATH/dist/tests/irl/_AI_AUDIT_INSTRUCTIONS.md"
echo ""
echo -e "${GREEN}JSON TO HTML CONVERTER${NC} (Standalone tool)"
echo " Regenerate HTML reports from JSON logs (useful after AI triage)."
echo ""
echo " Usage:"
echo " python3 $WPCC_PATH/dist/bin/json-to-html.py [input.json] [output.html]"
echo ""
echo -e "${BLUE}───────────────────────────────────────────────────────────────${NC}"
echo ""
echo -e "${GREEN}DOCUMENTATION${NC}"
echo -e " ${YELLOW}AI Instructions:${NC} $WPCC_PATH/dist/TEMPLATES/_AI_INSTRUCTIONS.md"
echo -e " ${YELLOW}IRL Audit Guide:${NC} $WPCC_PATH/dist/tests/irl/_AI_AUDIT_INSTRUCTIONS.md"
echo -e " ${YELLOW}WordPress Guidelines:${NC} $TOOLKIT_ROOT/AGENTS.md"
echo ""
echo -e "${BLUE}───────────────────────────────────────────────────────────────${NC}"
echo ""
}
# Show help if no arguments
if [ $# -eq 0 ]; then
echo -e "${BLUE}WPCC - WP Code Check${NC}"
echo "Part of AI-DDTK (AI Driven Development ToolKit)"
echo ""
echo "Usage: wpcc <command> [args...]"
echo ""
echo "Quick Start:"
echo " wpcc --paths <path> Run a scan"
echo " wpcc --features Show all available features"
echo " wpcc --help Full CLI documentation"
echo ""
echo -e "${GREEN}WPCC Location:${NC} $WPCC_PATH"
echo -e "${GREEN}Toolkit Root:${NC} $TOOLKIT_ROOT"
exit 0
fi
# Handle --features flag
if [ "$1" = "--features" ] || [ "$1" = "-f" ] || [ "$1" = "features" ]; then
show_features
exit 0
fi
# Pass all arguments to WPCC
exec "$WPCC_ENTRY_POINT" "$@"