31 Commits

Author SHA1 Message Date
OoO
c0a06e1798 Share review envelopes with OpenClaw and PPT 2026-05-24 23:25:51 +08:00
OoO
f7772cc465 統一競品價差方向語意
All checks were successful
CD Pipeline / deploy (push) Successful in 1m7s
2026-05-20 10:47:20 +08:00
OoO
124ddc7376 加入 PChome 單位價比較證據
All checks were successful
CD Pipeline / deploy (push) Successful in 1m19s
2026-05-20 00:05:18 +08:00
OoO
dafde7e1a7 強化 MOMO PChome 比價可信鏈路
All checks were successful
CD Pipeline / deploy (push) Successful in 1m45s
2026-05-19 15:26:10 +08:00
OoO
8b76e3872f feat(ppt): competitor v4 — 5-forces strategic analysis (Wave 4 partial)
All checks were successful
CD Pipeline / deploy (push) Successful in 2m49s
Wave 4 部分完成:competitor v4 五力升級(戰略視角)

generate_competitor_v4_ppt — 7 頁
- P1 封面:含整體領先/勢均力敵/落後徽章 + 三句話戰略指引
- P2 五力雷達圖(matplotlib polar)+ 右側 6 維度分數明細表(含雙條視覺化)
- P3 商品力 + 價格力(雙卡)
- P4 行銷力 + 服務力(雙卡)
- P5 品牌力 + 財務力(雙卡含 momo 8454/PChome 8044/蝦皮 SE/酷澎基本面)
- P6 AI 戰略整合(差異化建議)
- P7 附錄

新增 helper:_mpl_radar_png()
- matplotlib polar projection 五力雷達
- momo 焦糖橘 + 競品蜂蜜金
- 0-10 分尺度,含格線/標籤/圖例

query_competitor_5forces — 半實作
- 商品力:momo SKU 數從 DB 算 / 競品靜態 fallback
- 價格力:靜態(待擴 competitor_price_history 整合)
- 行銷力 / 服務力:靜態知識(電視購物頻道 / 24h 物流 / 訂閱制)
- 品牌力:靜態 + 預留 mcp_collector 整合空間
- 財務力:上市公司公開資訊(momo 8454 富邦集團、PChome 8044、SEA、酷澎)

每個維度自動算 momo - 競品差異 → 識別最大優勢力與最大劣勢力

_ppt_ai_analysis 加 is_5forces 分支
- 角色:BCG/麥肯錫資深戰略顧問
- 結構:整體競爭態勢 / 優勢加碼 / 劣勢補強或避戰 / SMART 三層 / 競爭風險
- max_tokens 2400

路由:
- /ppt competitor_v4         vs PChome(預設)
- /ppt competitor_v4 蝦皮    vs 蝦皮
- /ppt competitor_v4 酷澎    vs 酷澎

Telegram 按鈕:「⚔️ 競業五力 v4」

bump TEMPLATE_VERSIONS['competitor_v4'] = v4.0.0(新類型獨立版本)

簡化限制:商品力/價格力/品牌力的競品具體數據需後續擴 mcp_collector
(PChome SKU API、Dcard 品牌討論度量化等),靜態 fallback 已維持結構完整性

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 13:10:15 +08:00
OoO
16b169d3ee feat(ppt): price_elasticity sweet spot report v3.1.0 (simplified)
All checks were successful
CD Pipeline / deploy (push) Successful in 2m56s
Wave 3.3:價格彈性簡化版(採購/PM 定價策略用)

generate_price_elasticity_ppt — 7 頁
- P1 封面:含集中度徽章(過度集中/主流明確/分布健康)+ 三句話結論
- P2 KPI:SKU 數/總訂單/甜蜜點價位/甜蜜點 SKU 數
- P3 各價位桶訂單分布橫條(找甜蜜點,焦糖橘=最高訂單桶)
- P4 各價位桶業績分布橫條(評估高價帶健康度,業界基準 30-50%)
- P5 甜蜜點 TOP 5 SKU(明星價位代表商品,新品設計參考)
- P6 AI 採購策略洞察
- P7 附錄

query_price_elasticity(category, days)
- 對 SKU 算平均售價(總業績 / 數量)
- 7 個價位桶分組(< 200 / 200-500 / 500-1K / 1K-2K / 2K-5K / 5K-10K / > 10K)
- 識別「訂單數最多」的桶 = 價格甜蜜點
- 計算高價帶(>NT$2K)業績佔比(業界基準健康 30-50%)
- 選 sweet_spot 桶內 TOP 5 SKU 作為代表

簡化版限制(為後續 ADR 註明):
- 非完整 price_elasticity(需要時間序列定價變化資料)
- 但能展示「該品類消費者最買單的價位帶」這個關鍵採購洞察

_ppt_ai_analysis 加 is_price_elast 分支
- 角色:採購主管 + PM
- 結構:甜蜜點解讀 / 高低價帶結構 / SMART 三層 / 風險預警
- 含「斷層補強」概念(識別 SKU 數明顯偏少的價位區間)
- max_tokens 1700

路由:
- /ppt price_elasticity                 全平台 90 天
- /ppt price_elasticity 美妝保養        單品類 90 天
- /ppt price_elasticity 美妝保養 30     自訂天數

Telegram 按鈕:「💰 價格彈性報告」

bump TEMPLATE_VERSIONS['price_elasticity'] = v3.1.0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:48:15 +08:00
OoO
fe3cba8496 feat(ppt): market_intel_weekly external signal aggregation v3.1.0
All checks were successful
CD Pipeline / deploy (push) Successful in 3m6s
Wave 3.2:市場情報週報 — 把 mcp_collector 所有外部 API 彙整成一份內部簡報。

generate_market_intel_weekly_ppt — 7 頁
- P1 封面:本週重點/市場機會/風險警訊三句話(從 AI 自動抽)
- P2 節慶日曆 + 季節情境(雙卡)
- P3 電商新聞 + Google 熱搜(雙卡)
- P4 Dcard 口碑 + YouTube 爆紅(雙卡)
- P5 天氣 + 匯率(雙卡,影響消費行為)
- P6 AI 整合洞察與行動建議
- P7 附錄

外部資料來源(mcp_collector_service / mcp_context_service):
- mcp_collector.get_holiday_context()  節慶日曆(靜態)
- mcp_collector.get_seasonal_context() 季節情境(靜態)
- get_ecommerce_news()  電商產業新聞(Gemini Grounding)
- get_taiwan_trends()   Google 台灣熱搜
- get_dcard_trends()    Dcard 熱門討論
- get_youtube_trending() YouTube 爆紅商品
- get_taiwan_weather()  台灣天氣
- get_twbank_exchange_rates() 台幣匯率

每個外部 API 用 _safe() wrapper,失敗時填預設文字「(本次擷取失敗或無資料)」。

_ppt_ai_analysis 加 is_market_intel 分支
- 角色:行銷情報分析師 + BU 主管
- 結構:本週市場大事 / 消費者情緒口碑 / 競爭態勢差異化 / SMART 三層 /
  外部風險預警
- max_tokens 2000

路由:
- /ppt market_intel    本週情報週報(自動對齊週一)

Telegram 按鈕:「🌐 市場情報週報」

bump TEMPLATE_VERSIONS['market_intel'] = v3.1.0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:39:57 +08:00
OoO
95a74c3502 feat(ppt): new_product 30-day tracking report v3.1.0
All checks were successful
CD Pipeline / deploy (push) Successful in 2m35s
Wave 3.1:新品追蹤報告(PM/採購用)

generate_new_product_ppt — 9 頁
- P1 封面:含新品力徽章(強勁/穩健/偏弱/疲弱,依業績佔比)+ 三亮點
- P2 KPI:新品總數/業績/佔比/平均單品業績 + AI 解讀
- P3 新品整體日業績曲線(爬榜軌跡 matplotlib)
- P4 新品依品類分佈橫條
- P5-P7 新品 TOP 50(自動分頁)
- P8 AI PM 戰術洞察
- P9 附錄

query_new_products(days_recent=30, days_baseline=60)
- PostgreSQL CTE:recent EXCEPT early
  recent = 近 30 天有銷售
  early  = 31-90 天前有銷售
- 自動回傳:新品 TOP 50 / 子品類分佈 / 日業績曲線
- 含 ANY array 查詢新品集合的整體日業績

_ppt_ai_analysis 加 is_new_prod 分支
- 角色:PM 商品經理 + 採購主管
- 結構:新品力評估 / 明星新品識別 / 品類分佈與機會 / SMART 三層 / 風險預警
- SMART 行動含:加碼 TOP3 / 觀察排名 11-30 / 數據追蹤
- max_tokens 1800

業界基準:新品業績佔比 5-10% 為健康,>8% 強勁,<3% 偏弱

路由:
- /ppt new_product       預設近 30 天
- /ppt new_product 14    自訂追蹤天數

Telegram 按鈕:「🆕 新品 30 天追蹤」

bump TEMPLATE_VERSIONS['new_product'] = v3.1.0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:37:06 +08:00
OoO
af6157f8ba docs(adr): ADR-024 PPT Wave 2 (forecast + promo_compare) + deprecate bcg/growth
All checks were successful
CD Pipeline / deploy (push) Successful in 2m41s
Wave 2 完成 2 種新報表:
- forecast_pre_event (9f04dc3) — 檔期前 14 天備戰策略 (BU 主管用)
- promo_compare (958f705) — 多活動 ROI 並排比較 (行銷主管覆盤)

正式廢除(DEPRECATED 標記,函式保留作 internal helper):
- bcg — 與 strategy 報表功能重疊(strategy 已含 BCG 五級分類)
- growth — 已被 quarterly + half_yearly + annual + ttm 完全取代

報表體系現況:16 種有效(v3 重做 6 + Wave 1 新增 8 + Wave 2 新增 2)+ 2 種
DEPRECATED;4 種角色覆蓋(採購/PM/行銷/CFO/CEO)。

forecast 核心:baseline 日均 × 21 天 × lift_factor,含 8 種檔期靜態知識
(雙11 1.65× / 母親節 1.40× 等),封面倒數天數徽章自動切換。

promo_compare 核心:N 場活動並排 KPI 表 + 拉抬 % 排序橫條 + 4 排名亮點
(最高拉抬/最低拉抬/最佳毛利/最高業績)。

Wave 3 待辦:market_intel_weekly / new_product / clv / price_elasticity
Wave 4 待辦:inventory / operations / finance(依資料層)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:30:35 +08:00
OoO
958f705c8e feat(ppt): promo_compare multi-promo ROI report v3.1.0
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
Wave 2.2:N 場促銷活動橫向比較(行銷主管覆盤用)。

generate_promo_compare_ppt — 5 頁
- P1 封面:含活動數徽章 + 排名亮點(最高拉抬/最低拉抬/最佳毛利)
- P2 並排 KPI 表:8 欄(活動/期間/天數/業績/訂單/毛利/業績拉抬/訂單拉抬)
  支援 14 場以下並排顯示
- P3 業績拉抬橫條圖(matplotlib,按拉抬 % 排序)
- P4 AI 跨活動洞察(成功要素 / 失敗診斷 / SMART 三層)
- P5 附錄

路由:
- /ppt promo_compare 母親節:2026/05/05-2026/05/14|520:2026/05/18-2026/05/22|618:2026/06/14-2026/06/22

每場活動透過 query_promo_comparison 取 ROI 數據,自動產生 4 個排名。

_ppt_ai_analysis 加 is_promo_cmp 分支
- 角色:資深行銷主管
- 結構:整體比較 / 勝出活動成功要素 / 失敗活動診斷 / SMART 三層
- max_tokens 1600

Telegram 按鈕:「🆚 多活動比較」(await:promo_compare)

bump TEMPLATE_VERSIONS['promo_compare'] = v3.1.0

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:28:17 +08:00
OoO
9f04dc3951 feat(ppt): forecast_pre_event report v3.1.0 (BU pre-event battle plan)
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
Wave 2.1:檔期前瞻報告 — 給 BU 主管在檔期前 14 天決定備戰策略。

generate_forecast_pre_event_ppt — 7 頁
- P1 封面:含倒數天數徽章(備戰期/衝刺期/檔期中/已結束)+ 三段預期業績
- P2 KPI 三段對比:本期預期 / 去年同檔期 / Baseline 日均 / 已執行業績
- P3 去年同檔期業績曲線(matplotlib 折線,預測基準視覺化)
- P4 庫存盤點 TOP 30(基於 baseline 期銷量)
- P5 AI 戰術洞察
- P6 附錄

query_forecast_pre_event(event_name, event_date)
- baseline 期:檔期前 60-30 天(去除檔期前期效應)
- 去年同檔期:去年同日期 ± 7 天
- 本期準備窗口:檔期前 14 天到檔期後 7 天
- 預期業績 = baseline 日均 × 21 天 × lift_factor
- lift_factor 靜態知識(母親節 1.40 / 618 1.45 / 雙11 1.65 / 黑五 1.45 等)

_ppt_ai_analysis 加 is_forecast 分支
- 角色:BU 主管 + 行銷投放主管 + 採購三合一
- 結構:檔期定位 / 準備窗口進度 / 庫存戰術 / 廣告滿額門檻 /
  SMART 三層(檔期前7/當日+3/檔期後7)/ 風險預警
- max_tokens 2000

路由:
- /ppt forecast 母親節 2026/05/12
- /ppt forecast 618 2026/06/18

Telegram 按鈕:「🎯 檔期前瞻報告」(await:forecast_event)

bump TEMPLATE_VERSIONS['forecast_pre_event'] = v3.1.0

煙霧測試:7 頁 140KB 全綠。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 12:25:42 +08:00
OoO
48e3dacfc9 feat(ppt): customer analytics report v3.1.0 (simplified RFM, no user_id)
All checks were successful
CD Pipeline / deploy (push) Successful in 2m49s
Wave 1.4:客戶/訂單分析報告(行銷主管用)— 受限於資料層無 user_id,
做訂單級分析而非完整 RFM。

generate_customer_analytics_ppt — 7 頁
- P1 封面:含客單定位徽章(高/中/低)+ 限制聲明(無 user_id 註腳)
- P2 KPI:總訂單/總業績/平均客單/高客單訂單數
- P3 客單價分佈:6 級分桶橫條(< NT$500 / 500-1K / 1-2K / 2-5K / 5-10K / >10K)
- P4 消費星期分佈:matplotlib 橫條(找熱門時段)
- P5 商品復購排行 TOP 30:同商品在多筆獨立訂單中的次數
- P6 AI 行銷洞察
- P7 附錄

query_customer_analytics
- AOV 分桶(CASE WHEN bucket)
- DOW 星期聚合(PostgreSQL EXTRACT(DOW))
- 復購商品(GROUP BY 商品名稱 HAVING COUNT(訂單) >= 5)

_ppt_ai_analysis 加 is_customer 分支
- 角色:資深行銷主管(10 年 RFM/CRM 經驗)
- 結構:訂單規模解讀 / 消費熱點 / 商品復購信號 / SMART 三層
- 長期建議:建立會員系統取得 user_id 升級完整 RFM

路由:
- /ppt customer            預設近 30 天
- /ppt customer 2026/04    指定月份

Telegram 按鈕:「👥 客戶/訂單分析」

bump TEMPLATE_VERSIONS['customer'] = v3.1.0

煙霧測試:7 頁 100KB 全綠。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 02:17:48 +08:00
OoO
d8260fcd25 feat(ppt): category deep dive report v3.1.0 (90-day single category)
All checks were successful
CD Pipeline / deploy (push) Successful in 3m31s
Wave 1.3:單一品類 90 天縱向深度分析(PM/採購用)。

generate_category_deep_ppt(services/ppt_generator.py)— 12 頁
- P1 封面:含品類定位徽章(主力/成長/長尾)+ 新進榜商品 hero box
- P2 執行摘要:4 KPI(業績/訂單/毛利/SKU 數)+ AI 高階解讀
- P3 90 天日業績走勢(matplotlib 折線 + 日均線 + 高低點)+ 結論帶
- P4 子品類結構:橫條 + 帕雷托雙視圖
- P5-P7 TOP 50 商品(自動分頁)
- P8 TOP 30 廠商
- P9 新進榜商品專頁(近 30 天進榜,過去 60 天無交易判定)
- P10 AI 採購/PM 視角洞察
- P11 附錄

query_category_deep(routes/openclaw_bot_routes.py)
- 一次拉齊:kpis / daily(逐日) / top_products(50) / top_vendors(30) /
  sub_categories(L2) / new_products(近 30 天 vs 60 天前比對)
- 用 PostgreSQL CTE 做新進榜判定(recent EXCEPT early)

_ppt_ai_analysis 加 is_category 分支
- 角色:採購主管 + PM 商品經理
- 結構:品類整體 / 90 天趨勢 / 子品類結構 / SKU 與廠商組合 /
  SMART 三層 / 風險預警
- max_tokens 1800

路由:
- /ppt category 美妝保養        90 天深度(預設)
- /ppt category 美妝保養 30     自訂期間

Telegram 按鈕:「🗂 品類深度報告」(await:category_deep)
TODO:實作 await:category_deep 對應品類選擇互動(下一波)

bump TEMPLATE_VERSIONS['category'] = v3.1.0

煙霧測試:12 頁 300KB 全綠。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 02:14:07 +08:00
OoO
1af96f5be4 feat(ppt): period_review unified generator for quarterly/half/annual/ttm
All checks were successful
CD Pipeline / deploy (push) Successful in 3m37s
Wave 1.2:用一份 generator 解 4 種時間維度報表(季/半年/年/TTM)。

generate_period_review_ppt(services/ppt_generator.py)— 12 頁
- 期間類型徽章自動切換(季報/半年報/年報/TTM 滾動)
- P1 封面:含業績狀態徽章 + elevator pitch + 期間動能
- P2 執行摘要:KPI v2 含 △% (vs 上季/上半/去年) + AI 解讀 + YoY 對比帶
- P3 月度業績走勢(matplotlib 折線:本期 + 上期 + 月均線 + 高低點)+ 4 卡指標
- P4 品類分析:橫條 + 帕雷托雙視圖
- P5-P7 TOP 50 商品(自動分頁)
- P8 TOP 30 廠商
- P9 MCP 市場情報
- P10 AI 結構化洞察
- P11 附錄

query_period_summary(routes/openclaw_bot_routes.py)
- 一次拉齊:kpis / monthly_breakdown / top_products(50) / top_categories(8) /
  top_vendors(30)
- 自動算月度聚合(PostgreSQL TO_CHAR)

路由層加 4 種 sub_type 分支:
- /ppt quarterly [YYYY/Q1-4]    當季或指定季
- /ppt half_yearly [YYYY/H1-2]  當半年或指定半年
- /ppt annual [YYYY]            當年或指定年
- /ppt ttm                      最近 12 個月(自動算到本月底)

每種自動抓三段資料:本期 + 上期同等 + 去年同期
- quarterly: 上季 + 去年同季
- half_yearly: 上半年 + 去年同半年
- annual: 去年 + 前年
- ttm: 上一個 TTM (24-12 月前) + 同上

_ppt_ai_analysis 加 is_period 分支
- 角色:策略顧問 + BU 主管 + CFO 三合一視角
- 結構:整體解讀 / 市場趨勢對位 / 月度走勢分析 / 品類結構 / 戰略級 SMART /
  風險預警
- SMART 行動分三層:下期立即啟動(30 天)/ 下期戰略(60-90 天)/
  下下期預備(6-12 月)
- max_tokens 2600,字數 1000-1300

Telegram 按鈕:報表選單加 4 顆季/半/年/TTM 按鈕

bump TEMPLATE_VERSIONS:quarterly / half_yearly / annual / ttm 全 v3.1.0

煙霧測試:4 種全綠,每份 12 頁 220KB。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 02:10:14 +08:00
OoO
b6fdb4f473 feat(ppt): awaken vendor report + v3.1.0 procurement strategy upgrade
All checks were successful
CD Pipeline / deploy (push) Successful in 2m32s
Wave 1.1:把沉睡的 vendor generator 喚醒並全面升 v3.1.0:

generate_vendor_ppt(services/ppt_generator.py)— 8 頁
- P1 封面:含集中度警示徽章(健康分散 / 偏高 / 過高)+ 三句話策略要點
- P2 執行摘要:4 KPI 含 △% vs 上期 + 帕雷托 80/20 集中度結論帶
- P3 廠商業績排行:橫條 + 帕雷托雙視圖(matplotlib 暖色系)
- P4-P5 廠商明細表 TOP 30:含 △ 排名變化、🆕 新進榜、業績佔比 bar、
  毛利率紅綠燈(綠 ≥15% / 黃 8~15% / 紅 <8%)
- P6 AI 採購策略洞察(結構化 8 段)
- P7 附錄

query_vendor_summary(routes/openclaw_bot_routes.py)
- 期間(單月/自訂日期區間)廠商業績聚合
- 計算 sales / profit / margin / qty / orders
- 同步抓上期同等期間做 vs 上期 △ 比對

_ppt_ai_analysis 加 is_vendor 分支
- 角色:採購主管 + 供應鏈管理顧問
- 結構:整體解讀 / 集中度與供應風險 / 議價優先 / SMART 行動 / 風險預警
- SMART 行動分三層:立即執行 / 中期強化 / 長期結構(含 OEM/ODM 自有品牌)
- 引用 MARKET_TREND_2026 共用知識基底
- max_tokens 1800,字數 800-1000

路由綁定 _generate_ppt_cmd
- /ppt vendor          當月廠商報告
- /ppt vendor 2026/04  指定月份
- /ppt vendor 2026/04/01-2026/04/15  自訂期間
- 自動抓上期同等期間做 △ 比對

Telegram 按鈕(menu_keyboards.py 的 _submenu_reports)
- 新增「🏭 廠商業績報告」進報表選單

bump TEMPLATE_VERSIONS['vendor'] v2.0 (DEPRECATED) → v3.1.0

煙霧測試:本機 venv 跑 vendor PPT 生成 8 頁 200KB 全綠。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 02:04:41 +08:00
OoO
993bdda1fd feat(ppt-ai): inject shared 2026 Taiwan e-commerce market knowledge to all 6 prompts
All checks were successful
CD Pipeline / deploy (push) Successful in 2m25s
完成 project memory 待補事項:抽取共用市場趨勢常數 + 補齊未升級的 prompt。

新增 MARKET_TREND_2026 共用常數(routes/openclaw_bot_routes.py):
- 6 大關鍵檔期 + 拉動幅度(母親節 +30~50% 美妝 / 618 全品類 +30~50% / 雙11 +50~80%)
- 6 條 2026 熱門賽道(永續美妝/母嬰高端/機能性食品/IP 聯名/男性保養/寵物經濟)
- 4 大平台競爭定位(蝦皮/PChome/酷澎/momo)

Inject 到 5 條 prompt(monthly/strategy/promo/competitor/else):
- 月報、策略、促銷:原 prompt + MARKET_TREND_2026 知識基底
- 競品比較:補上 2026 熱門賽道做美妝/保健/母嬰專項分析的事實基礎
- daily/weekly(else 分支):完整重寫從 250 字 → 350-450 字 SMART 框架
  + 含市場機會與風險段(檔期卡位 + 競品風險)

bump 版本(所有 6 種 v3.x):
- daily   v3.0.2 → v3.1.0
- weekly  v3.0.2 → v3.1.0
- monthly v3.1.3 → v3.1.4
- strategy v3.0   → v3.1.0
- competitor v3.0 → v3.1.0
- promo   v3.0   → v3.1.0

效果:6 種報表 AI 分析現在都有共同的市場事實基底,跨報表敘事一致;
單一資料來源避免「不同報表給的市場數字打架」問題。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 01:42:43 +08:00
OoO
5a7012f1fa fix(ppt): AI parser drops empty-body sections + cap raised 6→10
All checks were successful
CD Pipeline / deploy (push) Successful in 2m33s
實戰問題:升級 monthly AI prompt 後,AI 輸出多了【行銷與銷售行動建議
— SMART 框架】這個「主段」加 3 個 ■ 子段(本週/本月/下月)。原 parser:

1. ■ 子段被當成新 section(這是正確行為)
2. 但「行銷與銷售行動建議」主段自己 body 變空殼
3. 顯示成「(本段無內容)」醜陋占位
4. 加上 sections[:6] 切斷,後面的競爭定位/風險預警被丟掉

修補(services/ppt_generator.py:_parse_ai_sections):
- 過濾空 body section(len(body) < 5 視為空殼)
- 上限放寬 6 → 10(容納升級 prompt 後的 9 段:整體/市場/品類/熱銷/
  MCP/本週/本月/下月/風險)

驗證:模擬 9 段輸入 → 過濾後得 6 個非空段,正確包含本週/本月/下月。

bump monthly v3.1.2 → v3.1.3

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:15:19 +08:00
OoO
c7b7ceeb8d fix(ppt): line chart resilience — sparse data + dense xtick + inset legend
Some checks failed
CD Pipeline / deploy (push) Has been cancelled
實戰在 188 prod 抓到的問題:N=1 時 title/legend/data marker 全擠在頂部。

修補:
- 加 `sparse = n_pts <= 2` 旗標,N<=2 時:
  * 略過平均水平線(單點下無意義且標籤撞 title)
  * marker 加大(5 → 7)讓單點更顯眼
  * 中央加「⚠ 期間僅 N 個資料點」提示框(圓角米底+焦糖橘邊)
  * legend 改 lower right inset(避開 title)
  * x 軸 set_xlim 加邊距避免 marker 貼牆
- 正常 N>=3:
  * legend 從 bbox_to_anchor 上方移到 axes 內 upper right
    (frameon=True 米底邊框,避免與 title 撞)
  * xticklabel 在 N>14 時 rotation=45 ha=right(避免 30 點擠成一團)
  * title pad 加大為 18

bump 版本:
- daily   v3.0.1 → v3.0.2
- weekly  v3.0.1 → v3.0.2
- monthly v3.1.1 → v3.1.2

本機驗證:
- N=1:「資料不足」提示框正確顯示,無重疊
- N=30:30 個 xticklabel 旋轉 45° 清楚分離,legend 右上 inset 不撞 title

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 23:52:04 +08:00
OoO
b5a2b09445 fix(ppt): matplotlib CJK fallback covers container Noto CJK JP variant
All checks were successful
CD Pipeline / deploy (push) Successful in 2m19s
實戰驗證在 188 容器內發現:matplotlib font_manager 從 fonts-noto-cjk
ttc 檔只載入 'Noto Sans CJK JP' / 'Noto Serif CJK JP' 兩個變體(TC/SC/HK/KR
名稱未列入 ttflist),導致原本 fallback 清單比對失敗 → font.family 退到
'sans-serif'(DejaVu Sans)→ 中文 glyph 全部缺失印出 UserWarning。

修正:
- _mpl_setup() fallback 清單加入 'Noto Sans CJK JP' / 'Noto Serif CJK JP'
- 最終 fallback 加 substring match(涵蓋未列入但名稱含 CJK/PingFang/
  JhengHei/YaHei/Source Han/WenQuanYi/Hiragino 的字型)
- _mpl_horiz_bar_png 內重複的 cjk_candidates 邏輯移除,改呼叫 _mpl_setup
  避免兩處清單漂移

註:Noto Sans CJK JP ttc 檔本身含完整 CJK Unified Ideographs,可正常
渲染中文(漢字共用),只是字型名稱叫 JP 而已。

bump 模板版本(舊圖表中文方塊版本快取應失效重生):
- daily   v3.0   → v3.0.1
- weekly  v3.0   → v3.0.1
- monthly v3.1   → v3.1.1

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 23:38:51 +08:00
OoO
1c81866541 fix(ppt): final critic cleanup — Medium-1 OOXML order + Info-1/2 docs
All checks were successful
CD Pipeline / deploy (push) Successful in 2m29s
清掉剩餘 critic finding(Medium-1 + Info-1 + Info-2):

Medium-1: _set_run_fonts 違反 OOXML CT_TextCharacterProperties 子元素順序
- 抽出 _insert_rpr_child(rPr, tag) helper:依 ECMA-376 §21.1.2.3 規定
  的順序表(_RPR_CHILD_ORDER)找正確位置插入
- 找第一個排在 target 之後的子元素 → insert 前面;否則 append
- 當前 from-scratch 場景安全;未來改讀模板 .pptx 時也不會踩雷
- 驗證:產生 monthly v3.1,399 個 rPr 全部符合 schema 順序,0 違反

Info-1: cleanup_expired_ppt_cache docstring 補語意說明
- 明確說明 dry_run=True/False 時 deleted_files / deleted_rows / freed_bytes
  欄位語意分別為「將刪除」預估值 vs「已實刪」實際值

Info-2: TEMPLATE_VERSIONS 標記退役 type
- growth / vendor / bcg 三個 type 從未實際落地(依 ADR-014 校正 2026-04-28)
- 加 DEPRECATED 註解,避免後人誤以為已支援

Info-3 SKIP(評估後不做):
- get_template_version import 改放模組頂部會 trigger ppt_generator 模組級
  REPORTS_DIR.mkdir() 副作用,read-only filesystem 環境會掛
- 保留延遲 import 是 graceful degradation 的 intentional 設計

至此 critic 38967ce 審查清單全綠:
- 0 critical, 2 HIGH (3b0b4b3), 4 medium (52c06f6 + 本 commit), 3 info

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 17:39:27 +08:00
OoO
3b0b4b3d42 fix(ppt): address critic findings on commit 38967ce (HIGH-1, HIGH-2, Medium-4)
All checks were successful
CD Pipeline / deploy (push) Successful in 2m27s
Critic 審查 38967ce 找出 2 HIGH + 4 medium,本 commit 修最緊急三項:

HIGH-2: cleanup_expired_ppt_cache 預設 dry_run=False 危險
- 函式 default 改 dry_run=True(呼叫方需明確傳 False 才實刪)
- launchd 排程腳本改用 DRY_RUN 環境變數,預設 false→實刪,
  但測試時可 DRY_RUN=true 安全跑
- /cache cleanup Telegram 指令預設乾跑,需加 confirm 才實刪
- /cache cleanup days<1 強制乾跑(防呆)

HIGH-1: matplotlib 三個 helper 缺 try/finally → 渲染失敗洩漏 figure
- _mpl_horiz_bar_png / _mpl_line_chart_png / _mpl_pareto_chart_png
  全部用 try/except/finally 包住,例外時 plt.close() 仍執行
- 同時讓渲染失敗回 None(呼叫端自然 fallback 到原生 chart)

Medium-4: scripts/ppt_cleanup.sh PROJECT_DIR 寫死
- 改用相對路徑解析(cd $SCRIPT_DIR/..),手動執行不再需要設環境變數
- VENV_PY 找不到時 fallback 到系統 python3(容器友善)
- 新增 DRY_RUN 環境變數開關(預設 false)

煙霧測試:
- syntax OK (services/ppt_generator.py + routes/openclaw_bot_routes.py)
- monthly v3.1 重生 10 頁 290KB
- cleanup_expired_ppt_cache dry_run default = True ✓

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 17:23:02 +08:00
OoO
38967ceea3 feat(ppt): redesign all 6 reports to professional standard + cache versioning
All checks were successful
CD Pipeline / deploy (push) Successful in 13m18s
PPT 模板全面升版至市場專業標準(McKinsey / BCG 月報級別):

Monthly v3.1(10 頁)
- 暖紙感封面(去黑底)+ elevator pitch(亮點/警訊/動能徽章)
- KPI 卡含 △% vs 上月 + 紅綠燈、YoY 同期對比帶
- matplotlib 業績趨勢折線(本月+上月+日均線+高低點)
- 品類分析雙視圖:橫條 + 帕雷托累計(80% 主力線)
- TOP 50 商品(自動分頁)+ vs 上月 △ 排名變化 / 🆕 新進榜
- MCP 情報 4 卡片結構化、AI 行動結構化分區、附錄頁

Daily / Weekly / Strategy / Promo / Competitor v3.0
- 統一暖紙封面、AI 頁去黑底改暖紙 + 焦糖橘色條
- 日週改 matplotlib 折線(含日均線、高低點)
- 全部加附錄頁(資料來源 / 計算口徑 / 模板版本)

Cache 版本控制
- TEMPLATE_VERSIONS 字典自動注入 cache key (tpl_ver)
- 模板升版舊快取自動 miss → 重生
- 新增 _invalidate_ppt_cache() 與 cleanup_expired_ppt_cache() helper
- 新增 /cache status / flush / cleanup Telegram 指令

字型系統
- _set_run_fonts() 用 lxml 直寫 a:latin/a:ea,中英分軌
- 中文走 Microsoft JhengHei,數字/英文走 Consolas(點陣等寬)
- Dockerfile 加 fonts-noto-cjk + fonts-noto-cjk-extra

部署排程
- scripts/install_ppt_cleanup.sh 一鍵安裝 launchd(每日 03:15)
- scripts/ppt_cleanup.sh 清 7 天前過期 PPT 檔 + DB row

資料層
- routes monthly: query_monthly_summary LIMIT 10 → 50,補 orders 欄位
- routes monthly: 拉 prev_month / prev_year 比較資料供 KPI △ 與商品 △ 計算

煙霧測試 6/6 全綠:
- 日報 v3.0 (5 頁) / 週報 v3.0 (6 頁) / 月報 v3.1 (10 頁)
- 策略 v3.0 (6 頁) / 促銷 v3.0 (6 頁) / 競品 v3.0 (5 頁)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 16:26:27 +08:00
OoO
76304602b1 fix(ppt): footer→bottom, font spec (Courier New/Microsoft JhengHei), 50-item paginated table, remove old single-page remnant
All checks were successful
CD Pipeline / deploy (push) Successful in 2m41s
2026-05-02 15:32:54 +08:00
OoO
0b82350745 style(ppt): comprehensive warm-tone redesign - caramel KPI cards, warm paper MCP/AI pages, revenue ratio bars in product table, chart→caramel orange, cover with warm decorative bands 2026-05-02 15:20:02 +08:00
OoO
4c6e4ca5fb style(ppt): align PPT palette perfectly with MOMO Pro v2 design tokens (Beige, Warm Ink, Caramel Orange) as per frontend upgrade roadmap 2026-05-02 15:01:55 +08:00
OoO
934adc957c style(ppt): redesign ppt layouts, align palette with frontend, and add dedicated MCP RAG slide 2026-05-02 14:59:45 +08:00
OoO
d88dcc8f75 fix(devops): 清理舊端口與危險 compose 操作
All checks were successful
CD Pipeline / deploy (push) Successful in 1m45s
2026-04-30 14:24:53 +08:00
ogt
48804553cd feat: PPT 簡報系統 V2 — 新增 growth/vendor/bcg 三種報告 + 原生圖表升級
All checks were successful
CD Pipeline / deploy (push) Successful in 1m15s
- ppt_generator.py: 新增 generate_growth_ppt(6頁)、generate_vendor_ppt(5頁)、generate_bcg_ppt(5頁)
- openclaw_bot_routes.py: 新增 query_growth_data()、query_vendor_bcg_data()、_generate_ppt_cmd 三路分支、_submenu_reports 4顆新按鈕、type_labels、await:date_ppt_vendor 流程
- ADR-014: 記錄 V2 完整架構(9種報告類型、圖表技術方案、callback_data 格式)
- CLAUDE.md: 新增 PPT 簡報系統索引表

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 20:26:47 +08:00
ogt
34620b7b04 feat: upgrade ppt_generator to v2 with native charts
All checks were successful
CD Pipeline / deploy (push) Successful in 1m16s
- daily: 3→4頁,新增 P3 近7日業績柱狀圖
- weekly: 2→5頁,新增 KPI摘要、7日走勢圖、TOP10商品表
- monthly: 2→5頁,新增 KPI卡、品類橫條圖、TOP10商品表
- strategy: 3→5頁,新增策略矩陣柱狀圖+行動清單(含策略標籤)
- promo: 2→5頁,新增促銷vs對比期KPI、業績雙柱圖、TOP商品表
- competitor: 維持4頁,架構不變
- 新增 _add_column_chart / _add_horiz_chart 原生圖表 helper
- 新增 _product_table_slide 通用商品表格元件

圖表來源對照:daily_sales trendChart、monthly_summary_analysis、
growth_analysis revenueChart/momChart

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 20:08:18 +08:00
ogt
4c8edecd12 feat: rewrite ppt_generator.py with premium dark-theme design
All checks were successful
CD Pipeline / deploy (push) Successful in 1m22s
Previous version was an emergency stub (緊急復原版) using plain white
PowerPoint default layouts. This commit restores the full premium design
visible in the product screenshot.

Design system:
  - 16:9 canvas (33.87 × 19.05 cm)
  - Cover: deep navy bg #0D1B2A + orange brand stripe #FF5722
  - Header bar: orange #FF5722 on all content slides
  - KPI cards: blue #1565C0 / green #2E7D32 / orange #E65100
  - Horizontal bar chart for competitor distribution
  - Striped data table with red/green price-diff coloring
  - Footer: ♥ Powered by OpenClaw on every slide

Slides per report type:
  competitor_ppt: Cover → KPI+BarChart → ProductTable → AI Insight
  daily_ppt:      Cover → KPI+TOP5     → AI Insight
  strategy_ppt:   Cover → KPI+TOP5     → AI Insight
  weekly/monthly/promo: Cover → AI Insight
2026-04-20 06:56:14 +08:00
ogt
1b4f3a7bbe feat: EwoooC 初始化 — 完整專案推版至 Gitea
Some checks failed
CD Pipeline / deploy (push) Failing after 59s
- 建立 Gitea Actions CD pipeline (.gitea/workflows/cd.yaml)
- 部署模式: rsync Python 檔案至 188 → docker restart (volume mount)
- Dockerfile/requirements 變動時自動重建 Docker image
- 部署通知: Telegram (開始/成功/失敗)
- 健康檢查: https://mo.wooo.work/health (最多 5 次重試)
- 同步最新 CLAUDE.md / ADR-008 / memory (2026-04-19)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-19 01:21:13 +08:00