17 Commits

Author SHA1 Message Date
OoO
f2aece5b71 perf: 外部化觀測台圖表腳本
All checks were successful
CD Pipeline / deploy (push) Successful in 1m9s
2026-05-18 09:30:34 +08:00
OoO
ff49d31f73 fix: 強化 AI 觀測台新版視覺規範
All checks were successful
CD Pipeline / deploy (push) Successful in 1m9s
2026-05-17 22:50:18 +08:00
OoO
8a7eed3505 整理觀測台顯示字典
All checks were successful
CD Pipeline / deploy (push) Successful in 1m8s
2026-05-13 19:59:30 +08:00
OoO
250dd58172 統一觀測台新版工作台規範
All checks were successful
CD Pipeline / deploy (push) Successful in 59s
2026-05-13 19:39:33 +08:00
OoO
b21b40cae2 fix(observability): soften frontend error copy
All checks were successful
CD Pipeline / deploy (push) Successful in 1m2s
2026-05-05 21:58:49 +08:00
OoO
ccd26415f3 fix(observability): 導入標題尺度 token 與 modal 樣式
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 14:54:17 +08:00
OoO
668d98cd3c fix(observability): 清理硬編碼樣式與圖表容器
Some checks failed
CD Pipeline / deploy (push) Failing after 9m49s
2026-05-05 14:41:00 +08:00
OoO
4afcf3376b fix(observability): 統一標題字型並卡片化商業建議
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 14:09:41 +08:00
OoO
054685826a feat(observability): 重塑 AI 觀測台戰情室 UI
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
2026-05-05 13:17:42 +08:00
OoO
df2311d4f0 feat(p55): 3 個圓餅圖補齊 — promotion_review/ppt_audit/budget
All checks were successful
CD Pipeline / deploy (push) Successful in 7m39s
S-1: promotion_review 蒸餾池 30d doughnut
- 取代原 col-md-2 卡片網格
- 8 種狀態各自分色:
  pending(灰) / awaiting_review(黃) / approved(綠) /
  rejected_quality(紅) / rejected_hallucination(深紅) /
  rejected_duplicate(橘) / rejected_human(暗紅) / expired(灰)
- 左圓餅 + 右表格雙視角

S-2: ppt_audit 30d 結果 doughnut
- 取代部分 col-md-2 卡片佈局
- 通過(綠)/失敗(黃)/錯誤(紅)/跳過(灰) 圓餅
- 6 個 KPI 卡併入右側 col-6 grid(總筆數/通過率/通過/issue/失敗/錯誤)
- 統一視覺語言:「圖+表」雙視角

S-3: budget 當月各 provider 成本 doughnut
- 新加 query:ai_calls.cost_usd GROUP BY provider 月初至今
- 8 個 provider 分色(本地 Ollama 綠系 vs 付費 LLM 橘紫系)
- 左圓餅 + 右表格(供應商/成本/佔比)+ 總計列

chart.js 視覺化從 7 個 → 10 個:
- hourly trend line
- 30d cost stacked bar
- 三主機 sparkline × 3
- RAG feedback doughnut
- KPI sparkline × 3 (calls/cost/errors)
- verdict doughnut
- heal 7d trend
- **promotion_review status doughnut(新)**
- **ppt_audit pass/fail doughnut(新)**
- **provider cost doughnut(新)**

Phase 38→55 累計 20 commits / 10 觀測頁 / 10 chart.js / DB 100%。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 01:15:58 +08:00
OoO
87d460e243 feat(p50): chart.js 折線圖視覺化 + Playbook 一鍵啟用/停用
All checks were successful
CD Pipeline / deploy (push) Successful in 2m40s
統帥要求「視覺方格 UI/UX」:raw 表格不夠,加 chart.js 雙圖 + L2 管理。

N-1: ai_calls hourly trend chart.js(雙軸混合)
- 取代原 progress bar 表格
- 折線:呼叫數(藍)+ 錯誤次數(紅)→ 共用左軸
- 柱狀:成本 USD(黃)→ 右軸
- interaction mode index:滑鼠 hover 同時顯示三個指標
- chart.js 4.4.1 CDN 加在 {% block extra_js %}

N-2: budget 30d cost trend stacked bar chart
- 取代原 30d cost trend 表格(max-height 滾動 → 一目瞭然圖)
- 8 個 provider 各自分色
  本地 Ollama(綠系)vs 付費(橘/紫/青系)
- stacked bar:每日總成本一柱,依 provider 堆疊
- tooltip 顯示每個 provider $X.XXXX

N-3: Playbook 一鍵啟用/停用(L2 補強第 7 個)
- 新 POST /observability/playbooks/toggle/<id>
  翻轉 is_active + UPDATE updated_at
- host_health.html playbook 排行表加「切換」欄
- 動態按鈕:啟用顯示「停用」、停用顯示「啟用」
- 對應觀測台直接管理 AutoHeal 庫,不需 SSH 改 DB

L2 一鍵自動化從 6 個 → 7 個入口:
- AutoHeal / AiderHeal / Code Review / Force Throttle(既有)
- Telegram Heal / Throttle(既有)
- Playbook Toggle(Phase 50 新增)

Phase 38→50 累計 15 commits。
觀測台從 raw stats → AI 自動化專業舞台 → 視覺方格 UI 終局。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 20:04:13 +08:00
OoO
2e124db602 feat(p47): 6 頁深挖資料庫 — 從 5 表 → 17 表,每頁加 3-5 個 widget
All checks were successful
CD Pipeline / deploy (push) Successful in 2m36s
統帥質疑:「6 頁內容太空洞,要更貼近資料庫裡所有數據」
盤點:DB 有 22 表,6 頁原本只用 5 表(22.7% 利用率)。
本 commit 新接 12 張既有但未用的表。

K-1 host_health(接 +5 表 → 8 表)
- 加 incidents 最近 10 筆詳細(task_name/error_type/嚴重度/狀態/重試/錯誤訊息)
- 加 heal_logs 最近 10 筆(action_type/result/耗時/incident 關聯)
- 加 playbooks 庫排行 TOP 12(success_count/fail_count/成功率/啟用狀態)
- 加 backup_log 7 日歷史(type/status/size/duration/error)
- 加 embedding_retry_queue pending/failed 警示

K-2 ai_calls(接 +3 表)
- 加 24h 每小時呼叫趨勢 bucket(含成本+錯誤+流量分布條)
- 加 by model 細分(不只 provider,到 model 版本級別)TOP 15
- 加 agent_context 最近 10 筆(OpenClaw/Hermes 對話 session preview)

K-3 budget(接 +3 表)
- 加當月 Top 5 燒錢呼叫端(caller × cost ranking)
- 加過去 30 日每日成本 by provider 趨勢表
- 加 ai_price_recommendations 7 日統計(strategy 分布 + 平均信心度)

K-4 promotion_review(接 +2 表)
- 加蒸餾池 30 日 status 分布(不只 awaiting,看 8 種完整流動)
- 加 ai_insights 最近 10 筆已晉升內容預覽
- 加 agent_strategy_weights TOP 12(OpenClaw 學習權重 + 成功率)

K-5 quality_trend(接 +3 表)
- 加 RAG 整體 feedback 1-5 分分布(過去 N 日,星等視覺)
- 加 action_plans status 分布(pending/approved/executed/rejected)
- 加 action_outcomes verdict 分布(effective/neutral/backfired
  — ADR-012 閉環學習核心 KPI)

K-6 ppt_audit_history(接 +0 表,但 deeper SQL)
- 加 30 日統計卡(total/passed/failed/error/通過率/總 issue 數/平均信心度)
- 加 Top 10 反覆失敗檔案(30d 失敗次數 + total issues)
- 加 empty state 說明(PPT_VISION_ENABLED=false 時顯示啟用步驟)

DB 利用率對應:
- Phase 38 起點:5 表(22.7%)
- Phase 39-46 累計:12 表(54.5%)
- Phase 47 收官:17 表(77.3%)
  新接:playbooks / backup_log / embedding_retry_queue / agent_context /
        ai_price_recommendations / agent_strategy_weights / action_plans /
        action_outcomes(之前已接:incidents/heal_logs/ai_insights/learning_episodes/
        rag_query_log/mcp_calls/ai_calls/host_health_probes/ppt_audit_results)

每頁 widget 數對應:
- host_health: 5 卡 → 11 卡
- ai_calls: 5 卡 → 8 卡
- budget: 4 卡 → 7 卡
- promotion_review: 2 卡 → 5 卡
- quality_trend: 4 卡 → 7 卡
- ppt_audit: 3 卡 → 6 卡

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 19:49:52 +08:00
OoO
849e189b60 feat(p45): UI/UX 升級 ewoooc_base.html + sidebar AI 觀測 7 項 + 新增總覽頁
All checks were successful
CD Pipeline / deploy (push) Successful in 2m37s
統帥質疑:「那六頁的視覺方格 UI/UX 搞好了嗎?還有新增頁面嗎?」
回答:沒有,從 Phase 38 開始一直推遲。本 commit 補做。

I-1: 6 頁 base.html → ewoooc_base.html
- host_health / ai_calls_dashboard / budget / promotion_review /
  quality_trend / ppt_audit_history 全改
- {% extends "base.html" %} → {% extends "ewoooc_base.html" %}
- {% block content %} → {% block ewooo_content %}
- 自動繼承:sidebar 240px / topbar 64px / fonts (Inter+JetBrains+Noto Sans TC)
  / ewoooc-tokens.css / ewoooc-shell.css / search box / 米色背景

I-2: _ewoooc_shell.html 加「AI 觀測」nav group
- 7 個項目:觀測台總覽 / 主機健康 / AI 呼叫 / 預算控管 /
  RAG 晉升審核 / 反饋趨勢 / PPT 視覺審核
- 對應 active_page='obs_*',正確高亮
- 編號 07-13(系統管理改 14)

I-3: 新增頁面 /observability/ + /observability/overview
- routes/admin_observability_routes.py::observability_overview
- 單頁聚合 8 表跨 JOIN 的 KPI:
  • 三主機 24h 在線率(host_health_probes,per host card)
  • AI 呼叫 24h(ai_calls:total/tokens/cost/error rate/RAG hit/cache hit)
  • 當月成本累計
  • 預算告警(ratio ≥ alert_pct 自動列表)
  • AIOps 7d(incidents + heal_logs:自癒成功率)
  • MCP 24h(mcp_calls:tool 呼叫 + cache 率 + cost)
  • RAG 學習 30d(learning_episodes:待審 + 晉升率)
  • PPT 視覺審核 7d(ppt_audit_results:通過率)
  • 6 大子頁入口卡(含一行說明)
- 對應 Phase 44 daily Telegram summary 的 web 版本
- 全部失敗安全(個別 query 失敗只跳過該卡,不擋整頁)

升級對應:
- UI 框架:base.html → ewoooc_base.html (sidebar + topbar + token css 已生效)
- 設計憲法:8 卡片 + 8 表跨 JOIN 全景 + 一頁式總覽
- 入口:sidebar 7 項 + 觀測台首頁
- 資料表覆蓋:4 表(Phase 38)→ 8 表(Phase 45)

注意:完整 design token 重塑(Bootstrap class → --momo-* token / 焦糖橘)
留待後續 phase;本 commit 重點是「框架升級 + 新總覽頁」。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 19:34:18 +08:00
OoO
79cf08c58c feat(p39): 觀測台升級 — DB + MCP + RAG + AI 自動化深度整合
All checks were successful
CD Pipeline / deploy (push) Successful in 2m30s
統帥質疑:6 頁觀測台只是 raw stats dashboard,沒展現 AI 自動化專業。
深度盤點 4 軸結果:
- DB 利用率 22.7%(22 表只用 5 張)
- MCP 整合 1/6(mcp_calls 表完全沒被讀)
- RAG 整合 0/6(沒 import rag_service)
- AI 自動化 L0 × 5 + L1 × 1(純讀 dashboard,無一鍵觸發)

本 commit 5 個增強:

D-1: promotion_review 加 RAG「Top 3 相似已晉升」
- 對每筆 awaiting_review episode 跑 rag_service.query 找 ai_insights 中
  cosine ≥ 0.7 的相似已晉升內容
- 輔助人工判斷:是否冗餘?是否新領域?
- header 顯示 ai_insights 知識庫 size
- fail-safe: 單筆 RAG 失敗不影響其餘

D-2: host_health 加 MCP 24h 工作量 widget
- 從 mcp_calls 統計各 server 24h 呼叫次數 / 成功率 / cache 率 /
  使用 tool 數 / 平均耗時 / cost
- 展現「AI×MCP 編排規模」而非只「server 健康與否」

D-3: ai_calls × rag_query_log × mcp_calls 三表 JOIN
- 新增「呼叫端 × RAG × MCP 編排矩陣」card
- 每個 caller:總呼叫 / RAG 命中率 / MCP 編排率(透過 request_id 串接)
  / RAG 反饋分數 / 反饋筆數
- 展現「AI 自動化專業」核心指標

D-4: budget 加 RAG 自動策略建議 + 一鍵 force-throttle (L2)
- ratio ≥ 0.8 時自動 RAG 召回 ai_insights 中的 budget_strategy 知識
- POST /budget/force_throttle endpoint:立即重算 cost_throttle 狀態
  (不等下次每小時 cron)— 升級到 L2 自動化
- 對應頁面加「立即重算節流狀態」按鈕

D-5: host_health 加 incidents + heal_logs 7d 摘要
- 顯示 ADR-013 AutoHeal 閉環核心 KPI:
  總事件 / 未解決 / 已解決 / P0+P1 / 自癒成功率 / 平均自癒耗時
- 展現「AIOps 自癒系統」運作實況

對應升級:
- DB 利用率 22.7% → ~50%(新接 mcp_calls + rag_query_log JOIN
  + ai_insights + incidents + heal_logs)
- MCP 整合 1/6 → 3/6(host_health + ai_calls + budget 都接 mcp_calls)
- RAG 整合 0/6 → 3/6(promotion_review + budget + 待 quality_trend)
- AI 自動化 L1 → L2 一鍵 force-throttle 一個(其餘按鈕待 D-6)

全部 fail-safe:DB 表/RAG/MCP 失敗都不擋頁面渲染。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 19:08:41 +08:00
OoO
19f1340f5c feat(p38): admin 觀測台 6 頁完整繁中化 + 加入導航選單
All checks were successful
CD Pipeline / deploy (push) Successful in 2m42s
問題:
1. 6 個 /observability/* 頁面標題與欄位英文殘留(違反設計憲法繁中要求)
2. 6 頁完全沒掛 navbar,使用者進不去(只能彼此 footer link 互連)
3. emoji 取代 Font Awesome,違反設計規範

修補:
- _navbar.html 新增「AI 觀測台」dropdown(位於 AI 助手 與 雲端匯入 之間)
  - AI 監控組:AI 呼叫總覽 / 主機健康監控 / 預算控管
  - AI 學習組:RAG 學習晉升審核 / Caller 反饋趨勢 / PPT 視覺審核歷史
- 6 個 admin/observability template 全面繁中化:
  - 標題、表格欄位、按鈕、badge 文字、JS alert 文案
  - emoji → Font Awesome icon(fa-heartbeat / fa-chart-bar / fa-wallet / fa-brain / fa-comments / fa-search 等)
  - 移除 5 處 footer 手寫 link 條(已由 navbar 取代,避免雙寫)
- routes/admin_observability_routes.py 6 個 render_template 加 active_page='obs_*'
  讓 navbar dropdown 正確高亮

完整覆蓋:host_health / ai_calls_dashboard / budget / promotion_review / quality_trend / ppt_audit_history

設計規範對齊:仍待 Phase 後續工作(ewoooc_base.html 框架升級 + --momo-* design token)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-04 18:49:44 +08:00
OoO
99d2f3c543 fix(p32): admin URL prefix /admin → /observability — 避開 188 nginx SPA shadow
All checks were successful
CD Pipeline / deploy (push) Successful in 2m25s
Root cause(curl 實證):
  prod 188 nginx 對 /admin/* 設 try_files → SPA index.html fallback
  → Phase 27-31 的 6 個 Flask admin 路由全被 nginx 攔截
  → 外部 GET /admin/ai_calls 回 7480 byte 靜態 HTML(同 etag = SPA shell)
  → 我之前說「6 admin 頁 prod 200」是回了 200,但 body 不是 Flask 渲染

修法:
  Blueprint url_prefix /admin → /observability
  → 6 個觀測頁實際生效在 /observability/* 不被 SPA 遮蔽
  → SPA frontend 仍擁有 /admin/* 命名空間(不破壞既有前端)

更新範圍:
  - routes/admin_observability_routes.py: url_prefix + 註解全改
  - 6 templates: 所有 href / fetch() 路徑改 /observability/
  - tests/test_admin_observability_routes.py: client.get/post 路徑改
  - 10/10 smoke tests 仍 PASS

統帥訪問新路徑:
  http://192.168.0.188/observability/ai_calls
  http://192.168.0.188/observability/host_health
  http://192.168.0.188/observability/budget
  http://192.168.0.188/observability/promotion_review
  http://192.168.0.188/observability/quality_trend
  http://192.168.0.188/observability/ppt_audit_history
2026-05-04 14:13:27 +08:00
OoO
69ccf8029b feat(p29): 預算管理頁 + PPT vision 歷史頁 — 完成 6 個 admin 觀測頁
All checks were successful
CD Pipeline / deploy (push) Successful in 2m23s
承接 Phase 27/28(48b8fda)剩 2 個前端頁:

1. /admin/budget — 預算編輯器
   - GET: ai_call_budgets × 當月 spent 即時對比 + throttle 狀態
   - POST /admin/budget/update/<id>: AJAX 編輯 budget_usd / alert_pct
   - 不需 restart 立即生效(cost_throttle hourly cron 自動讀新值)
   - ratio ≥80% 黃 / ≥110% 紅 / throttled 標 ⚠️ THROTTLED

2. /admin/ppt_audit_history — PPT 視覺審核歷史
   - 掃 reports/ 過去 7 日 .pptx 檔(檔名/大小/修改時間)
   - 顯示 PPT_VISION_ENABLED 狀態(true=daily 22:00 cron 自動跑)
   - 手動觸發 SOP 提示(SSH 188 跑單檔審核)

完工里程碑:6 個 admin 頁 + 1 個導覽
- /admin/ai_calls          (Phase 27)
- /admin/promotion_review  (Phase 27)
- /admin/quality_trend     (Phase 28)
- /admin/host_health       (Phase 28)
- /admin/budget            (Phase 29) ← 新增
- /admin/ppt_audit_history (Phase 29) ← 新增

Operation Ollama-First v5.0 — 前端互補互動系列收官
2026-05-04 13:44:08 +08:00