forked from pinchtab/pinchtab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev
More file actions
executable file
·489 lines (463 loc) · 14.4 KB
/
Copy pathdev
File metadata and controls
executable file
·489 lines (463 loc) · 14.4 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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
#!/usr/bin/env bash
set -euo pipefail
# dev — Pinchtab developer toolkit
# Usage: dev [command] [sub] Run a command directly
# dev Interactive picker
cd "$(dirname "$0")"
BOLD=$'\033[1m'
ACCENT=$'\033[38;2;251;191;36m'
MUTED=$'\033[38;2;90;100;128m'
SUCCESS=$'\033[38;2;0;229;204m'
ERROR=$'\033[38;2;230;57;70m'
NC=$'\033[0m'
# ── Commands ─────────────────────────────────────────────────────────
# name:emoji:description
COMMANDS=(
"build:🔨:Build the application"
"dev:🚀:Build & run"
"dashboard:🔥:Hot-reload dashboard development"
"run:🏃:Run the application"
"check:🧪:All checks"
"all:✅:check + test + e2e"
"test unit:🔬:Go unit tests"
"test dashboard:🔬:Dashboard unit tests"
"test plugin:🔬:Plugin unit tests"
"e2e:🐳:E2E suites"
" basic:🐳:Basic suite (api + cli + infra)"
" extended:🐳:Extended suite (all extended)"
" smoke:🐳:Smoke suite"
" smoke-docker:🐳:Host Docker smoke checks only"
" smoke-plugin:🐳:OpenClaw plugin Docker smoke"
" api:🐳:API basic tests"
" cli:🐳:CLI basic tests"
" infra:🐳:Infra basic tests"
" plugin:🐳:Plugin tests"
" api-extended:🐳:API extended (multi-instance)"
" cli-extended:🐳:CLI extended tests"
" infra-extended:🐳:Infra extended (multi-instance)"
" test <name>:🐳:Run a single E2E test by start_test name"
"opt:⚡:Optimization baseline"
" baseline:⚡:Run optimization baseline lane"
"bench:📊:Benchmark lanes"
" pinchtab:📊:Run PinchTab benchmark via Anthropic Messages API"
" agent-browser:📊:Run agent-browser benchmark via Anthropic Messages API"
" browserbench:📊:Run BrowserBench CSV tasks through PinchTab"
"doctor:🩺:Setup dev environment"
"zombie:🧟:Run long Docker zombie-process soak smoke"
"install:📦:Build & install to ~/.local/bin (override with PINCHTAB_INSTALL_DIR)"
" skills:📦:Symlink ./skills/* into ~/.claude/skills (override with CLAUDE_SKILLS_DIR)"
"pack plugin:🎁:Build a ClawHub-ready plugin tarball (optionally pass <version>)"
"check go:🧪:Go only"
"check dashboard:🧪:Dashboard only"
"check npm:🧪:npm package only"
"check plugin:🧪:Plugin only"
"check security:🧪:Gosec security scan"
"check docs:🧪:Validate docs JSON"
"binary:📦:Build release-style binary into dist/"
" all:📦:Build the full release binary matrix into dist/"
"format dashboard:🎨:Run Prettier on dashboard sources"
)
# ── Helpers ──────────────────────────────────────────────────────────
show_help() {
echo ""
echo " ${ACCENT}${BOLD}🦀 Pinchtab Dev${NC}"
echo ""
for cmd in "${COMMANDS[@]}"; do
IFS=':' read -r name emoji desc <<< "$cmd"
if [[ "$name" == " "* ]]; then
local trimmed="${name#"${name%%[![:space:]]*}"}"
printf " ${BOLD}%-18s${NC} ${MUTED}%s${NC}\n" "$trimmed" "$desc"
else
printf " ${SUCCESS}%s${NC} ${BOLD}%-18s${NC} ${MUTED}%s${NC}\n" "$emoji" "$name" "$desc"
fi
done
echo ""
echo " ${MUTED}Usage: dev [command] [sub]${NC}"
echo ""
}
run_e2e_runner() {
local suite="extended"
local filter_seen=0
local -a runner_args=()
if [ "$#" -gt 0 ] && [[ "${1:-}" != --* && "${1:-}" != *=* ]]; then
suite="$1"
shift
fi
runner_args=(--suite "$suite")
while [ "$#" -gt 0 ]; do
case "$1" in
filter=*)
runner_args+=(--filter "${1#filter=}")
filter_seen=1
;;
test=*)
runner_args+=(--test "${1#test=}")
;;
extra=*)
runner_args+=(--extra "${1#extra=}")
;;
logs=*)
runner_args+=(--logs "${1#logs=}")
;;
--suite|--filter|--test|--extra|--logs)
if [ "$#" -lt 2 ]; then
echo " ${ERROR}Missing value for $1${NC}" >&2
exit 1
fi
local opt="$1"
local value="$2"
shift
runner_args+=("$opt" "$value")
[ "$opt" = "--filter" ] && filter_seen=1
;;
--suite=*|--filter=*|--test=*|--extra=*|--logs=*)
local opt="${1%%=*}"
local value="${1#*=}"
runner_args+=("$opt" "$value")
[ "$opt" = "--filter" ] && filter_seen=1
;;
--dry-run|--help|-h)
runner_args+=("$1")
;;
--*)
runner_args+=("$1")
;;
*)
if [ "$filter_seen" -ne 0 ]; then
echo " ${ERROR}Unexpected extra e2e argument: $1${NC}" >&2
exit 1
fi
runner_args+=(--filter "$1")
filter_seen=1
;;
esac
shift
done
exec env E2E_LOGS="${E2E_LOGS:-hide}" go run ./tests/tools/runner e2e "${runner_args[@]}"
}
run_command() {
local target="$1"
echo ""
case "$target" in
"check")
echo " ${ACCENT}${BOLD}🧪 Running all checks (Go + Dashboard + Plugin)${NC}"
echo ""
bash scripts/check.sh
local go_exit=$?
echo ""
echo " ${ACCENT}${BOLD}🧪 Dashboard checks${NC}"
echo ""
bash scripts/check-dashboard.sh
local dash_exit=$?
echo ""
echo " ${ACCENT}${BOLD}🧪 Plugin checks${NC}"
echo ""
bash scripts/check-plugin.sh
local plugin_exit=$?
if [ $go_exit -ne 0 ] || [ $dash_exit -ne 0 ] || [ $plugin_exit -ne 0 ]; then exit 1; fi
exit 0
;;
"check go")
echo " ${ACCENT}${BOLD}🧪 Go checks${NC}"
echo ""
exec bash scripts/check.sh
;;
"check dashboard")
echo " ${ACCENT}${BOLD}🧪 Dashboard checks${NC}"
echo ""
exec bash scripts/check-dashboard.sh
;;
"check npm")
echo " ${ACCENT}${BOLD}🧪 npm package checks${NC}"
echo ""
exec bash scripts/check-npm.sh
;;
"check plugin")
echo " ${ACCENT}${BOLD}🧪 Plugin checks${NC}"
echo ""
exec bash scripts/check-plugin.sh
;;
"check security")
echo " ${ACCENT}${BOLD}🔒 Security scan${NC}"
echo ""
exec bash scripts/check-gosec.sh
;;
"check docs")
echo " ${ACCENT}${BOLD}📖 Docs validation${NC}"
echo ""
exec bash scripts/check-docs-json.sh
;;
"format dashboard")
echo " ${ACCENT}${BOLD}🎨 Dashboard formatting${NC}"
echo ""
exec bash -lc 'cd dashboard && if command -v bun >/dev/null 2>&1; then bun run format; else npx prettier --write '"'"'src/**/*.{ts,tsx,css}'"'"'; fi'
;;
"test")
echo " ${ACCENT}${BOLD}🔬 All tests${NC}"
echo ""
exec bash scripts/test.sh all
;;
"test unit")
echo " ${ACCENT}${BOLD}🔬 Go unit tests${NC}"
echo ""
exec bash scripts/test.sh unit
;;
"test dashboard")
echo " ${ACCENT}${BOLD}🔬 Dashboard tests${NC}"
echo ""
exec bash scripts/test.sh dashboard
;;
"test plugin")
echo " ${ACCENT}${BOLD}🔬 Plugin tests${NC}"
echo ""
cd plugin && exec npx tsx --test *.test.ts
;;
"unit")
echo " ${ACCENT}${BOLD}🔬 Unit tests${NC}"
echo ""
exec bash scripts/test.sh unit
;;
"system")
echo " ${ACCENT}${BOLD}🔬 System tests${NC}"
echo ""
exec bash scripts/test.sh system
;;
"opt")
echo " ${ACCENT}${BOLD}⚡ Optimization${NC}"
echo ""
exec bash scripts/dev-opt.sh help
;;
"opt "*)
echo " ${ACCENT}${BOLD}⚡ Optimization${NC}"
echo ""
local opt_args="${target#opt }"
exec bash scripts/dev-opt.sh ${opt_args}
;;
"bench")
echo " ${ACCENT}${BOLD}📊 Benchmark${NC}"
echo ""
exec bash scripts/dev-bench.sh help
;;
"bench "*)
echo " ${ACCENT}${BOLD}📊 Benchmark${NC}"
echo ""
local bench_args="${target#bench }"
exec bash scripts/dev-bench.sh ${bench_args}
;;
"e2e test")
echo " ${ERROR}Missing test name. Usage: dev e2e test \"<name substring>\"${NC}"
exit 1
;;
"e2e test "*)
local test_name="${target#e2e test }"
echo " ${ACCENT}${BOLD}🎯 Single E2E test${NC}"
echo ""
exec env E2E_LOGS="${E2E_LOGS:-show}" bash scripts/dev-e2e.sh "$test_name"
;;
"e2e smoke-plugin"|"e2e smoke-plugin "*)
echo " ${ACCENT}${BOLD}🐳 OpenClaw plugin smoke${NC}"
echo ""
local -a smoke_args=()
if [ "$target" != "e2e smoke-plugin" ]; then
read -r -a smoke_args <<< "${target#e2e smoke-plugin }"
fi
exec bash tests/manual/openclaw-plugin-smoke/run.sh "${smoke_args[@]}"
;;
"e2e"*)
local -a e2e_args=()
if [ "$target" != "e2e" ]; then
read -r -a e2e_args <<< "${target#e2e }"
fi
run_e2e_runner "${e2e_args[@]}"
;;
"dev") exec bash scripts/dev.sh ;;
"dashboard") exec bash scripts/dev-dashboard.sh ;;
"build") exec bash scripts/build.sh ;;
"install") exec bash scripts/install.sh ;;
"install skills") exec bash scripts/install-skills.sh ;;
"pack plugin") exec bash scripts/pack-plugin.sh ;;
"pack plugin "*) exec bash scripts/pack-plugin.sh "${target#pack plugin }" ;;
"binary") exec bash scripts/binary.sh ;;
"binary all"|"binaries") exec bash scripts/binary.sh all ;;
"all")
echo " ${ACCENT}${BOLD}✅ all: check + test + e2e${NC}"
echo ""
bash scripts/check.sh || exit 1
bash scripts/check-dashboard.sh || exit 1
bash scripts/check-plugin.sh || exit 1
bash scripts/test.sh all || exit 1
exec env E2E_LOGS="${E2E_LOGS:-hide}" go run ./tests/tools/runner e2e --suite extended
;;
"run") exec bash scripts/run.sh ;;
"doctor") exec bash scripts/doctor.sh ;;
"zombie") exec bash scripts/docker-zombie-soak-smoke.sh ;;
"hooks") exec bash scripts/install-hooks.sh ;;
*)
echo " ${ERROR}Unknown command: $target${NC}"
show_help
exit 1
;;
esac
}
pick_with_gum() {
local options=()
local commands_map=() # parallel array: full command string for each option
local parent=""
for cmd in "${COMMANDS[@]}"; do
IFS=':' read -r name emoji desc <<< "$cmd"
local trimmed="${name#"${name%%[![:space:]]*}"}"
if [[ "$name" == " "* ]]; then
# Subcommand: indent, no emoji — prefix with parent
options+=("$(printf ' %-18s %s' "$trimmed" "$desc")")
commands_map+=("$parent $trimmed")
else
parent="$trimmed"
options+=("$(printf '%s %-18s %s' "$emoji" "$trimmed" "$desc")")
commands_map+=("$trimmed")
fi
done
local choice
choice=$(printf '%s\n' "${options[@]}" | gum choose \
--header "🦀 Pinchtab Dev" \
--header.foreground "#fbbf24" \
--cursor.foreground "#00e5cc" \
--selected.foreground "#00e5cc" \
--item.foreground "#8892b0")
# Find the index of the chosen option and look up the full command
local picked=""
for i in "${!options[@]}"; do
if [[ "${options[$i]}" == "$choice" ]]; then
picked="${commands_map[$i]}"
break
fi
done
# Clear the picker before streaming command output.
printf '\033[2J\033[H'
run_command "$picked"
}
pick_with_select() {
echo ""
echo " ${ACCENT}${BOLD}🦀 Pinchtab Dev${NC}"
echo ""
local names=()
local i=1
for cmd in "${COMMANDS[@]}"; do
IFS=':' read -r name emoji desc <<< "$cmd"
local trimmed="${name#"${name%%[![:space:]]*}"}"
if [[ "$name" == " "* ]]; then
printf " ${MUTED}[%3d]${NC} ${BOLD}%-18s${NC} ${MUTED}%s${NC}\n" "$i" "$trimmed" "$desc"
else
printf " ${MUTED}[%3d]${NC} ${SUCCESS}%s${NC} ${BOLD}%-18s${NC} ${MUTED}%s${NC}\n" "$i" "$emoji" "$trimmed" "$desc"
fi
names+=("$trimmed")
i=$((i + 1))
done
echo ""
echo -ne " ${BOLD}Pick [1-${#COMMANDS[@]}]:${NC} "
read -r choice
# Handle numeric or name input
if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le ${#COMMANDS[@]} ]; then
run_command "${names[$((choice - 1))]}"
else
run_command "$choice"
fi
}
# ── Main ─────────────────────────────────────────────────────────────
# Direct command with optional subcommand
if [ $# -gt 0 ]; then
case "$1" in
-h|--help|help) show_help; exit 0 ;;
-i|--interactive)
if command -v gum &>/dev/null; then pick_with_gum; else pick_with_select; fi
exit 0
;;
check)
if [ $# -gt 1 ]; then
run_command "check $2"
else
run_command "check"
fi
;;
install)
if [ $# -gt 1 ]; then
run_command "install $2"
else
run_command "install"
fi
;;
pack)
if [ "${2:-}" = "plugin" ]; then
if [ $# -gt 2 ]; then
run_command "pack plugin $3"
else
run_command "pack plugin"
fi
else
echo " ${ERROR}Unknown pack target: ${2:-}${NC}" >&2
echo " Usage: dev pack plugin [<version>]" >&2
exit 1
fi
;;
test)
if [ $# -gt 1 ]; then
run_command "test $2"
else
run_command "test"
fi
;;
format)
if [ $# -gt 1 ]; then
run_command "format $2"
else
run_command "format"
fi
;;
e2e)
if [ "${2:-}" = "test" ]; then
if [ $# -lt 3 ] || [ -z "${3:-}" ]; then
echo " ${ERROR}Missing test name. Usage: dev e2e test \"<name substring>\"${NC}" >&2
exit 1
fi
echo ""
echo " ${ACCENT}${BOLD}🎯 Single E2E test${NC}"
echo ""
exec env E2E_LOGS="${E2E_LOGS:-show}" bash scripts/dev-e2e.sh "$3"
fi
if [ "${2:-}" = "smoke-plugin" ]; then
echo ""
echo " ${ACCENT}${BOLD}🐳 OpenClaw plugin smoke${NC}"
echo ""
exec bash tests/manual/openclaw-plugin-smoke/run.sh "${@:3}"
fi
run_e2e_runner "${@:2}"
;;
binary)
if [ $# -gt 1 ]; then
run_command "binary $2"
else
run_command "binary"
fi
;;
opt)
if [ $# -gt 1 ]; then
exec bash scripts/dev-opt.sh "${@:2}"
else
exec bash scripts/dev-opt.sh help
fi
;;
bench)
if [ $# -gt 1 ]; then
exec bash scripts/dev-bench.sh "${@:2}"
else
exec bash scripts/dev-bench.sh help
fi
;;
*) run_command "$1" ;;
esac
fi
# No args → interactive picker
if command -v gum &>/dev/null; then
pick_with_gum
else
pick_with_select
fi