Skip to content

Commit 07fba65

Browse files
committed
AI prompts command
1 parent df11f6a commit 07fba65

2 files changed

Lines changed: 176 additions & 0 deletions

File tree

commands/host/ai-prompts

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/usr/bin/env bash
2+
#ddev-generated
3+
#annertech-ddev
4+
5+
## Description: AI Prompts Operations Centre
6+
## Usage: ai-prompts
7+
## Example: "ddev ai-prompts"
8+
## Aliases: ai
9+
10+
# Colours
11+
RED='\033[0;31m'
12+
GREEN='\033[0;32m'
13+
YELLOW='\033[1;33m'
14+
NC='\033[0m'
15+
16+
echo_red() { echo -e "${RED}$1${NC}" >&2; }
17+
echo_green() { echo -e "${GREEN}$1${NC}" >&2; }
18+
echo_yellow() { echo -e "${YELLOW}$1${NC}" >&2; }
19+
20+
# Menu options
21+
OPTIONS=(
22+
"1. BackstopJS Init"
23+
)
24+
25+
# AI Agent options
26+
AI_AGENTS=(
27+
"1. Gemini"
28+
"2. Claude"
29+
)
30+
31+
# Select action
32+
select_action() {
33+
echo_green "Start typing to select a prompt"
34+
printf '%s\n' "${OPTIONS[@]}" | fzf --reverse --height=50% --header="AI Prompt"
35+
}
36+
37+
# Select AI agent
38+
select_agent() {
39+
echo_green "Select AI agent"
40+
printf '%s\n' "${AI_AGENTS[@]}" | fzf --reverse --height=50% --header="AI Agent"
41+
}
42+
43+
# BackstopJS Init function
44+
backstop_init() {
45+
# Extract environment variables from DDEV container
46+
TEST_DOMAIN=$(ddev exec env | grep -E '^DDEV_PRIMARY_URL=' | cut -d= -f2)
47+
REFERENCE_DOMAIN=$(ddev exec env | grep -E '^STAGE_FILE_PROXY_URL=' | cut -d= -f2)
48+
49+
# Validate variables
50+
if [ -z "$TEST_DOMAIN" ]; then
51+
echo_red "Error: DDEV_PRIMARY_URL not found"
52+
exit 1
53+
fi
54+
55+
if [ -z "$REFERENCE_DOMAIN" ]; then
56+
echo_red "Error: STAGE_FILE_PROXY_URL not found"
57+
exit 1
58+
fi
59+
60+
# Change to tests/backstop directory
61+
if ! cd tests/backstop 2>/dev/null; then
62+
echo_red "Error: tests/backstop directory not found"
63+
exit 1
64+
fi
65+
66+
# Select AI agent
67+
local agent_selection
68+
agent_selection=$(select_agent)
69+
if [[ -z "$agent_selection" ]]; then
70+
echo_red "No agent selected... Exiting"
71+
exit 0
72+
fi
73+
74+
# Extract agent label
75+
local agent_label
76+
agent_label=$(echo "$agent_selection" | sed 's/^[0-9]*\. //')
77+
78+
echo_green "Initializing BackstopJS configuration with ${agent_label}..."
79+
echo ""
80+
81+
# Read and populate the prompt
82+
local prompt_content
83+
prompt_content=$(sed -e "s|__TEST_DOMAIN__|$TEST_DOMAIN|g" \
84+
-e "s|__REFERENCE_DOMAIN__|$REFERENCE_DOMAIN|g" \
85+
../../.ddev/scripts/prompts/backstop-init.md)
86+
87+
# Call the selected AI agent
88+
case "$agent_label" in
89+
"Gemini")
90+
gemini "$prompt_content"
91+
;;
92+
"Claude")
93+
claude "$prompt_content"
94+
;;
95+
*)
96+
echo_red "Unknown agent: $agent_label"
97+
exit 1
98+
;;
99+
esac
100+
}
101+
102+
# Main function
103+
main() {
104+
# Banner
105+
echo_green "
106+
█████╗ ██╗ ██████╗ ██████╗ ██████╗ ███╗ ███╗██████╗ ████████╗███████╗
107+
██╔══██╗██║ ██╔══██╗██╔══██╗██╔═══██╗████╗ ████║██╔══██╗╚══██╔══╝██╔════╝
108+
███████║██║ ██████╔╝██████╔╝██║ ██║██╔████╔██║██████╔╝ ██║ ███████╗
109+
██╔══██║██║ ██╔═══╝ ██╔══██╗██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ╚════██║
110+
██║ ██║██║ ██║ ██║ ██║╚██████╔╝██║ ╚═╝ ██║██║ ██║ ███████║
111+
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝
112+
"
113+
echo " AI-Powered Prompt Operations by Annertech"
114+
echo ""
115+
116+
# Select action
117+
local action_selection
118+
action_selection=$(select_action)
119+
if [[ -z "$action_selection" ]]; then
120+
echo_red "Nothing selected... Exiting"
121+
exit 0
122+
fi
123+
124+
# Extract action from selection (remove number prefix)
125+
local action_label
126+
action_label=$(echo "$action_selection" | sed 's/^[0-9]*\. //')
127+
128+
echo ""
129+
130+
# Execute selected action
131+
case "$action_label" in
132+
"BackstopJS Init")
133+
backstop_init
134+
;;
135+
*)
136+
echo_red "Unknown action: $action_label"
137+
exit 1
138+
;;
139+
esac
140+
}
141+
142+
main

scripts/prompts/backstop-init.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## 1. Scan and collect URLs
2+
3+
- Fetch homepage from __REFERENCE_DOMAIN__
4+
- Extract random set of pages linked on homepage main area
5+
- Extract pages linked in in homepage main menu
6+
- Extract pages linked in in homepage footer
7+
- Fetch sitemap from __REFERENCE_DOMAIN__/sitemap.xml
8+
- Extract 10-12 diverse page types from sitemap (services, planning, housing, events, etc.)
9+
- Include all language versions
10+
- Add search page: __REFERENCE_DOMAIN__/search?s=test
11+
12+
## 2. Configure backstop.json
13+
14+
- Use the default `backstop.json` file in this folder as a starting point
15+
- Test environment domain: __TEST_DOMAIN__
16+
- Reference domain: __REFERENCE_DOMAIN__
17+
- Viewports: phone (320×480) and HD (1920×1080). Remove other viewports.
18+
- Remove any scenarios pointing to patternlab!
19+
20+
## 3. Per-scenario configuration (add to EACH scenario, not globally)
21+
22+
- removeSelectors: "#CybotCookiebotDialog", ".anrt-gdpr-floating-cookie"
23+
- requireSameDimensions: true
24+
- Do not use any delay on scenarios
25+
26+
## 4. Deliverables
27+
28+
- Updated backstop.json with all scenarios
29+
- Provide changelog-ready list grouped by category using bold formatting (no headings, no backticks around paths)
30+
- Clean-up any temporary files afterwards
31+
32+
**Note:** Use curl with browser user agent for sitemap access to avoid 403 errors.
33+
34+
<!-- #ddev-generated -->

0 commit comments

Comments
 (0)