-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopilot-designer-portal.sh
More file actions
executable file
Β·188 lines (159 loc) Β· 8.17 KB
/
Copy pathcopilot-designer-portal.sh
File metadata and controls
executable file
Β·188 lines (159 loc) Β· 8.17 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
#!/bin/bash
# Load central configuration
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "${SCRIPT_DIR}/config.sh"
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PORTAL DESIGNER β Research agent (READ-ONLY)
# Analyzes the logged-in portal/dashboard UX, admin panel, user flows
# Writes 10 detailed ideas to ideas/portal_design_latest.md
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
PROJECT_DIR="${PROJECT_DIR:-/opt/yourproject}"
LOG_FILE="${LOG_FILE:-/opt/copilot-hive/copilot-designer-portal.log}"
NOTIFY="/opt/copilot-hive/notify-smartthings.sh"
IDEAS_DIR="${IDEAS_DIR:-/opt/copilot-hive/ideas}"
COPILOT="/usr/local/bin/copilot"
mkdir -p "$IDEAS_DIR"
PAUSE_FILE="${PAUSE_FILE:-/opt/copilot-hive/.agents-paused}"
AGENT_PAUSE_FILE="${AGENT_PAUSE_FILE:-/opt/copilot-hive/.agent-paused-designer-portal}"
if [ -f "$PAUSE_FILE" ] || [ -f "$AGENT_PAUSE_FILE" ]; then
echo "$(date) β SKIPPED: Agent paused" >> "$LOG_FILE"
exit 0
fi
# Prevent concurrent runs of same agent
acquire_agent_lock "designer-portal${PROJECT_ID:+-$PROJECT_ID}" || { echo "$(date) β SKIPPED: Another instance already running" >> "$LOG_FILE"; exit 0; }
echo "======================================" >> "$LOG_FILE"
echo "Portal Designer Started: $(date)" >> "$LOG_FILE"
# ββ Urgent Admin Ideas Check βββββββββββββββββββββββββββββββββββββββββββββββββ
_IDEAS_DIR="${IDEAS_DIR:-/opt/copilot-hive/ideas}"
URGENT_IDEA=$(python3 -c "
import json
try:
with open('${_IDEAS_DIR}/admin_ideas.json') as f:
data = json.load(f)
urgent = [i for i in data.get('ideas',[]) if i.get('urgent') and i.get('status')=='pending']
if urgent:
idea = urgent[0]
print(idea['title'] + '|||' + idea['description'] + '|||' + idea['id'])
except: pass
" 2>/dev/null)
if [ -n "$URGENT_IDEA" ]; then
URGENT_TITLE=$(echo "$URGENT_IDEA" | cut -d'|||' -f1)
URGENT_DESC=$(echo "$URGENT_IDEA" | cut -d'|||' -f2)
URGENT_ID=$(echo "$URGENT_IDEA" | cut -d'|||' -f3)
echo "$(date) β URGENT ADMIN IDEA: $URGENT_TITLE" >> "$LOG_FILE"
OVERRIDE_PROMPT="You are temporarily a DEVELOPER for Your Project. Your normal role is Portal Designer but the ADMIN has an urgent request.
The source code is at ${PROJECT_DIR}. Docker-compose at /opt/docker-compose/yourproject.yml.
URGENT: ${URGENT_TITLE}
Details: ${URGENT_DESC}
RULES: Implement completely. Do not break existing functionality."
cd "$PROJECT_DIR"
"$COPILOT" --prompt "$OVERRIDE_PROMPT" --yolo --allow-all-paths >> "$LOG_FILE" 2>&1
URGENT_EXIT=$?
if [ $URGENT_EXIT -eq 0 ]; then
python3 -c "
import json, datetime
with open('${_IDEAS_DIR}/admin_ideas.json') as f: data = json.load(f)
for i in data['ideas']:
if i['id'] == '$URGENT_ID':
i['status'] = 'implemented'; i['urgent'] = False
i['implemented_at'] = datetime.datetime.now(datetime.timezone.utc).isoformat()
break
with open('${_IDEAS_DIR}/admin_ideas.json', 'w') as f: json.dump(data, f, indent=2)
" 2>/dev/null
echo "β
DONE | $(date '+%Y-%m-%d %H:%M') | admin | $URGENT_TITLE" >> "${_IDEAS_DIR}/implemented.log"
fi
if git -C "$PROJECT_DIR" status --porcelain | grep -q .; then
git -C "$PROJECT_DIR" add -A
git -C "$PROJECT_DIR" commit -m "urgent: admin request β $URGENT_TITLE
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>"
git -C "$PROJECT_DIR" push origin main 2>&1 || true
fi
fi
IMPLEMENTED=""
[ -f "${IDEAS_DIR}/implemented.log" ] && IMPLEMENTED=$(tail -100 "${IDEAS_DIR}/implemented.log" 2>/dev/null)
# ββ Load prompt from file if available ββββββββββββββββββββββββββββββββ
PROMPT_FILE="${SCRIPTS_DIR}/prompts/portal-designer.md"
if [ -f "$PROMPT_FILE" ]; then
PROMPT=$(cat "$PROMPT_FILE")
echo "Loaded prompt from $PROMPT_FILE" >> "$LOG_FILE"
else
# Fallback to inline prompt below
PROMPT=$(cat <<'PROMPTEOF'
You are the PORTAL DESIGNER agent for the project at /opt/yourproject. You analyze the logged-in user experience and propose improvements.
You are a READ-ONLY research agent. You CANNOT modify any source code. You analyze and write ideas ONLY.
YOUR FOCUS: The LOGGED-IN EXPERIENCE β everything after a user signs in:
- User dashboard (activity overview, key metrics, status indicators)
- Core workflow UI (the main actions users perform in the app)
- Results/output display (data cards, detail panels, status indicators)
- Report viewing and generation
- Admin panel (user management, system settings, configuration)
- Settings page (profile, notifications, API keys, integrations)
- Data visualizations (charts, graphs, trend lines, heat maps)
- Tables, filters, search, pagination
- Loading states, empty states, error states
- Notifications and toast messages
- Dark mode / theme consistency
- Responsive portal experience on tablets/phones
STEPS:
1. READ the project codebase to understand what it does and what the portal currently looks like
2. Review the database schema and API endpoints to understand data available
3. Search for 3-5 competitors in the same product category and compare their portal UX
4. Identify the TOP 5 most impactful portal improvements
OUTPUT: Write EXACTLY 10 ideas to ideas/portal_design_latest.md in this format:
# π₯οΈ Portal Design Ideas β [date]
## Idea 1: [Title]
**Priority:** HIGH/MEDIUM/LOW
**Category:** Dashboard/Workflow/Reports/Admin/Visualizations/Tables/States
**Current state:** What the portal looks like now for this feature
**Proposed change:** Detailed description with specific UI/UX changes
**Why it matters:** User experience impact, retention, professionalism
**Implementation guide:** Step-by-step β files, components, CSS classes, JS logic
**Data requirements:** What API endpoints or DB queries are needed
[repeat for all 10 ideas]
RULES:
- Do NOT modify any source files β ONLY write to ideas/portal_design_latest.md
- Each idea must include enough detail for a developer to implement it fully
- Skip ideas already in the IMPLEMENTED LOG below
- Think like a product designer at a top SaaS company
- Include mockup descriptions or ASCII layouts where helpful
FORMAT: For each idea, include:
- **Priority**: high / medium / low
- **Impact**: 1-10 (10 = game-changing)
- **Effort**: small / medium / large
Order ideas by impact score (highest first).
PROMPTEOF
)
fi # end prompt file fallback
# Inject project-specific context if available
if [ -n "${PROJECT_CONTEXT:-}" ]; then
PROMPT="${PROMPT}
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
PROJECT-SPECIFIC CONTEXT:
${PROJECT_CONTEXT}
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ"
fi
CONTEXT=$(cat <<CTXEOF
ALREADY IMPLEMENTED (skip these):
${IMPLEMENTED:- (none yet)}
CTXEOF
)
cd "$IDEAS_DIR" || exit 1
"$COPILOT" --prompt "${PROMPT}${CONTEXT}" --yolo \
--add-dir "$PROJECT_DIR" \
--add-dir "$IDEAS_DIR" \
--allow-all-urls \
--deny-tool 'shell(git push)' \
--deny-tool 'shell(git commit)' \
--deny-tool 'shell(git add)' \
--deny-tool 'shell(rm:*)' \
>> "$LOG_FILE" 2>&1
EXIT_CODE=$?
echo "Portal Designer Finished: $(date) (exit: $EXIT_CODE)" >> "$LOG_FILE"
# Validate output file was created with content
OUTPUT_FILE="${IDEAS_DIR}/portal_design_latest.md"
if [ ! -f "$OUTPUT_FILE" ] || [ $(wc -l < "$OUTPUT_FILE" 2>/dev/null || echo 0) -lt 5 ]; then
echo "β Output file missing or too short β agent may have failed silently" >> "$LOG_FILE"
"$NOTIFY" "Portal Designer: output file empty or missing" >> "$LOG_FILE" 2>&1
fi
[ $EXIT_CODE -ne 0 ] && "$NOTIFY" "Portal Designer agent failed (exit $EXIT_CODE)" >> "$LOG_FILE" 2>&1
exit $EXIT_CODE