Przeglądaj źródła

feat(tool-moyu): 扩充备选内容降低重复率

- COMMANDS/COMMAND_OUT 命令池 12→24(补 go migrate/pnpm lint/test/docker/redis/nginx/health/race/rebase 等)
- OUTPUTS 裸输出 13→27(补 WARN/ERROR/panic/exit code/200 OK 等)
- STANDALONE ~50→74(补 build/db/redis/nginx/backup/cron/arch/perf/warn/err 等)
- gen_rand_lines 动态行 4→7 类(补随机 deploy sha/p99 延迟/内存占用)
- colorize 错误/警告分支兼容大写 WARN:/ERR:
b 1 miesiąc temu
rodzic
commit
d18e2e2fd3
1 zmienionych plików z 64 dodań i 4 usunięć
  1. 64 4
      tool-moyu.sh

+ 64 - 4
tool-moyu.sh

@@ -79,6 +79,18 @@ COMMANDS=(
 	"journalctl -u backend-admin -n 30 --no-pager"
 	"systemctl status backend-app"
 	"git log --oneline -5"
+	"go run ./cmd/migrate up"
+	"pnpm lint"
+	"pnpm test:unit"
+	"docker compose ps"
+	"redis-cli -h 127.0.0.1 INFO memory"
+	"journalctl -u backend-app --since '10 min ago' --no-pager"
+	"ssh -p 10022 root@18.220.34.224 'nginx -t'"
+	"curl -s https://admin.household.ooo.ink/api/v1/health"
+	"go test -race ./internal/pkg/notify/..."
+	"git pull --rebase origin master"
+	"git diff --stat"
+	"docker exec household-mysql mysql -e 'SELECT COUNT(*) FROM center_orders'"
 )
 COMMAND_OUT=(
 	"ok  0.231s"
@@ -93,6 +105,18 @@ COMMAND_OUT=(
 	"[GIN-debug] Listening and serving HTTP on :8081"
 	"Active: active (running)"
 	"f37eec3 docs(deploy): align backend directory with actual test-machine paths"
+	"migrate: applied 1 change (20260829003_create_notify_logs) in 312ms · dirty=0"
+	"✔ No ESLint errors (148 files, 3.1s)"
+	"Test Files: 6 passed | 48 tests (68.4s) ✓"
+	"CONTAINER STATUS: mysql(Up) redis(Up) backend-app(Up 3 days) · 4/4 healthy"
+	"used_memory_human:1.2G · peak 1.4G · maxmemory_policy:noeviction · keys 12840"
+	"no new entries · last log 12 min ago, no warnings, no OOM"
+	"nginx: configuration file /etc/nginx/nginx.conf test is successful"
+	"{\"status\":\"ok\",\"version\":\"v1.9.2\",\"db\":\"up\",\"redis\":\"up\"}"
+	"ok  git.ooo.ink/household/app/internal/pkg/notify  3.812s · race detected 0"
+	"Updating 8f3a2d1..c1e9b77 · 2 files changed, 41 insertions(+), 3 deletions(-)"
+	"internal/router/route.go +3 · internal/pkg/notify/notify.go +96 · 2 files changed"
+	"COUNT(*) = 128420 · +312 today, no archive lag"
 )
 
 # ---- Standalone lines (tool returns / logs / a few AI actions) ----
@@ -153,6 +177,24 @@ STANDALONE=(
 	"[git] status → clean (working tree) · no untracked files · 3 commits staged, awaiting push"
 	"[git] log --oneline -3 → 3 commits behind origin, need pull · upstream added config refactor + dependency bumps"
 	"Redis: 127.0.0.1:6379 connected · maxclients 10000 · 15/16 dbs used · AOF persistence on, no blocking commands"
+	"[build] docker build -t registry.git.ooo.ink/household/backend:1.9.2 . → 2 layers cached, image 187MB pushed in 4.8s"
+	"[build] pnpm build:admin → 4.2MB dist, tree-shook lodash-es, gzip 1.1MB · zero warnings"
+	"[lint] gofmt -l → 0 files · consistent with .editorconfig"
+	"[test] go test ./... → ok (7 packages) · 2.8s, 0 skipped, no race"
+	"[bench] BenchmarkHandleList → 420ns/op, 3 allocs/op · inlined hot path, 30% faster"
+	"[migrate] 20260829002_orders_partition OK · down migration present, reversible"
+	"[db] ANALYZE TABLE center_orders → 128k rows · cardinality updated, planner now uses orders_idx_created"
+	"[redis] SCAN 'order:*' → 12 keys · all with TTL < 24h, none expired-but-resident"
+	"[nginx] reloaded (graceful) · worker_connections 1024, 3 upstreams healthy"
+	"[backup] daily dump → /backup/household_$(date +%F).sql.gz 48MB · checksum verified, offsite copy synced"
+	"[cron] certbot renew --dry-run → certificate not yet due (17 days left)"
+	"[git] push origin master → 4 commits up, hooks ran, CI passed"
+	"[git] rebase complete · replayed 6 commits onto origin/master, no conflicts"
+	"[docs] CHANGELOG.md +1.9.2 → 3 features, 5 fixes, 2 security patches"
+	"[arch] layering still one-way (cmd→internal→shared) · no new import cycles, graph check green"
+	"[perf] slow-query log (1h) → 0 entries above 100ms · indexes effective under new partition layout"
+	"[warn] disk usage /var 78% · logrotate daily, expect stable below 85%"
+	"[err] worker#2 panic recovered · 1 job lost, requeued to DLQ for manual review"
 )
 
 # 输出/日志/错误行(可重复,作为“裸输出”随机插入)
@@ -170,19 +212,37 @@ OUTPUTS=(
 	"no type errors found"
 	"✓ 307 modules transformed."
 	"Build succeeded after 3 retries"
+	"done"
+	"Compiled successfully."
+	"exit code 0"
+	"✓ 4 checks passed."
+	"200 OK"
+	"Deploy complete."
+	"WARN: 3 unused route handlers detected"
+	"WARN: log file rotated, reopening"
+	"ERROR: context deadline exceeded (Client.Timeout)"
+	"panic: runtime error: index out of range"
+	"gofmt: no files need formatting"
+	"lint clean · 0 warnings"
+	"Test run finished: 3 passed, 0 failed"
+	"security scan: 0 critical, 2 medium findings"
+	"cache flushed"
 )
 
 # 动态随机数字行(消除固定值反复出现)
 gen_rand_lines() {
-	local n=$((1 + RANDOM % 3)) # 1-3 条
+	local n=$((1 + RANDOM % 4)) # 1-4 条
 	local i r
 	for ((i = 0; i < n; i++)); do
-		r=$((RANDOM % 4))
+		r=$((RANDOM % 7))
 		case $r in
 		0) echo "ok  $(awk 'BEGIN{srand(); printf "%.3f", 0.05+rand()*1.5}')s" ;;
 		1) echo "dist/assets/index-*.js  $(awk 'BEGIN{srand(); printf "%.2f", 8+rand()*300}') kB │ gzip: $(awk 'BEGIN{srand(); printf "%.2f", 3+rand()*80}') kB" ;;
 		2) echo "Progress: $((5 + RANDOM % 95))%..." ;;
 		3) echo "$((1 + RANDOM % 40)) test(s), $((RANDOM % 4)) failed" ;;
+		4) echo "deploy $(awk 'BEGIN{srand(); for(i=0;i<6;i++) printf "%c", 97+int(rand()*26)}')  · $(awk 'BEGIN{srand(); printf "%.1f", 0.1+rand()*3}')s · service healthy" ;;
+		5) echo "p99 latency: $(awk 'BEGIN{srand(); printf "%.1f", 5+rand()*180}') ms · $(awk 'BEGIN{srand(); printf "%.1f", 1+rand()*9}')k req/min" ;;
+		6) echo "mem: $(awk 'BEGIN{srand(); printf "%d", 120+rand()*400}') MB RSS · $(awk 'BEGIN{srand(); printf "%d", 3+rand()*12}')% over baseline" ;;
 		esac
 	done
 }
@@ -255,8 +315,8 @@ colorize() {
 	case "$1" in
 	'$ '*)                               printf '\033[1;36m%s\033[0m' "$1" ;;
 	*FATAL*)                             printf '\033[1;31m%s\033[0m' "$1" ;;
-	*ERROR* | *\[err\]* | *err:*)        printf '\033[31m%s\033[0m' "$1" ;;
-	*warn* | *WARNING*)                  printf '\033[33m%s\033[0m' "$1" ;;
+	*ERROR* | *ERR:* | *\[err\]* | *err:*)  printf '\033[31m%s\033[0m' "$1" ;;
+	*warn* | *WARN*)                     printf '\033[33m%s\033[0m' "$1" ;;
 	*'✓'* | *PASS* | *'ok  '* | *'HTTP 200'* | *PONG* | *'no type errors'* | *'completed successfully'* | *'Build succeeded'*) printf '\033[32m%s\033[0m' "$1" ;;
 	*)                                   printf '%s' "$1" ;;
 	esac