Repository navigation
feat: gói Tháng/Năm + mã kích hoạt cho LUMINA AI - #2
Open
baoduy3108 wants to merge 204 commits into
Open
baoduy3108 wants to merge 204 commits into
baoduy3108 wants to merge 204 commits into
Conversation
Thêm hệ thống thuê bao trả phí bên cạnh gói Miễn phí — không tích hợp cổng thanh toán tự động (chưa có tài khoản merchant), thay vào đó dùng mã kích hoạt thủ công: người dùng chuyển khoản/Momo, chủ web xác nhận rồi tạo mã qua trang quản trị trong web, người dùng nhập mã để nâng cấp ngay lập tức. - config.py: PLANS (free/monthly/yearly — giá, rpm/burst, daily cap, apex), ADMIN_EMAILS, PAYMENT_* (thông tin chuyển khoản hiển thị cho người dùng). Gói Miễn phí mặc định CHỈ 2 tin nhắn/ngày (ngân sách API ban đầu nhỏ) — buộc phải mua gói mới dùng được nhiều. - db.py: cột plan/plan_expires_at trên users, bảng activation_codes + usage_daily; get_effective_plan tự hạ về free khi hết hạn; redeem chống dùng lại mã, cộng dồn thời hạn nếu cùng gói. - ratelimit.py: bucket cấp lại dung lượng ngay khi người dùng vừa nâng cấp. - router.py: gate chế độ 🌌 Đỉnh cao (Fable) theo gói — free bị khóa, hạ xuống 🧠 Tư duy sâu kèm gợi ý nâng cấp (apex_locked). - auth.py/main.py: is_admin theo ADMIN_EMAILS; endpoint /api/plans, /api/redeem, /api/admin/codes; chat_stream áp rate-limit + daily-cap theo gói hiệu lực, phát sự kiện SSE "upsell" khi bị khóa Đỉnh cao. - Frontend: modal Nâng cấp (bảng giá 3 gói + thông tin chuyển khoản + nhập mã) và modal Quản trị (tạo/liệt kê mã) trong static/index.html+app.js+style.css. - Sửa lỗi phát hiện qua kiểm thử trình duyệt: sau đăng nhập phải gọi lại /api/me để lấy is_admin/plan (response đăng nhập không có 2 field này). - 8 test mới cho router apex-gating, rate-limiter nâng cấp dung lượng, DB gói/mã kích hoạt/daily-cap — tổng 18/18 test pass. - Đã kiểm thử thủ công qua curl + Playwright: tạo mã → kích hoạt → nâng cấp phản ánh đúng → dùng lại mã cũ bị từ chối → non-admin bị 403 → rate-limit và daily-cap chặn đúng lượt. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…eepSeek/Ollama)
Cho phép LUMINA chạy gần như miễn phí và giấu tên model khỏi người dùng:
- Tầng cao cấp (Claude) lo N lượt đầu/ngày mỗi người; hết lượt thì TỰ tụt xuống
chuỗi bộ não miễn phí (Gemini free → Groq free → DeepSeek → Ollama → OpenAI),
người dùng vẫn chat tiếp, không hề biết đã đổi bộ não. Không có Claude cũng
chạy 100% bằng engine free.
- Giấu tên model: nhãn chế độ khi chạy tầng free hiển thị "✨ LUMINA", bỏ "(Fable)"
khỏi nhãn Đỉnh cao, mọi thông báo lỗi không nêu tên nhà cung cấp, system prompt
cấm model tự nhận là Claude/Gemini/GPT.
- Gói trả phí giờ = "thêm token": premium_daily_cap (lượt cao cấp) + total_daily_cap
(tổng lượt/ngày) thay cho daily_message_cap. Free=2/30, Tháng=200/1000, Năm=200/2000.
- engines/openai_compatible.py: một lớp chung cho DeepSeek/Groq/Ollama/OpenAI (cùng
chuẩn /chat/completions), có streaming SSE thật; thay engines/openai_engine.py.
- db.py: usage_daily tách premium_count/total_count; consume_daily_usage quyết định
tầng bộ não; get_daily_usage. ALTER TABLE an toàn cho DB cũ.
- config.py: thêm GROQ/DEEPSEEK/OLLAMA, FREE_FALLBACK_CHAIN, has_any_engine();
validate_config không còn bắt buộc Claude.
- README/.env.example/render.yaml: hướng dẫn lấy key free (Gemini/Groq), giải thích
tầng bộ não + cách chạy $0.
- Tests: 19/19 pass (thêm test premium→free→chặn, chuỗi engine theo tầng).
Kiểm thử: server chạy thật với engine giả → label ẩn model đúng ("✨ LUMINA"),
lỗi không lộ tên "Gemini", UI modal hiển thị đúng lượt cao cấp/tổng theo gói.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
OpenRouter (tương thích OpenAI, 1 key dùng nhiều model free) vào chuỗi free sau Groq. Chuỗi free: gemini → groq → openrouter → deepseek → ollama → openai. Kèm header khuyến nghị HTTP-Referer/X-Title của OpenRouter. Model free mặc định llama-3.3-70b-instruct:free, đổi được qua OPENROUTER_MODEL. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Bỏ mã kích hoạt thủ công, thay bằng thanh toán tự động, tiền về thẳng tài
khoản chủ web, gói tự kích hoạt khi tiền vào.
- db.py: bảng orders + create_order/get_order/list_orders/mark_order_paid
(idempotent — webhook bắn trùng không cộng dồn); bỏ activation_codes.
- payments.py (mới): build_vietqr_url (mã QR động miễn phí), verify_sepay_
authorization (Apikey header) + extract_order_id_from_content; PayPal
create_paypal_order + capture_paypal_order (Orders API v2).
- main.py: POST /api/orders (SePay→QR / PayPal→order id), GET /api/orders/{id}
(poll), POST /api/orders/{id}/paypal-capture, POST /api/webhook/sepay
(xác thực → khớp đơn theo nội dung + số tiền → kích hoạt), GET /api/admin/
orders + confirm (lưới an toàn khi webhook lỗi); bỏ /api/redeem, /api/admin/codes.
- config.py: SePay/PayPal config, price_usd (tháng $20/năm $200), helper
sepay_enabled/paypal_enabled/paypal_api_base.
- Frontend: modal Nâng cấp có nút "Chuyển khoản VN" (QR + poll) và "Thẻ quốc
tế" (PayPal JS Buttons); modal QR; admin Đơn hàng thay admin mã.
- Bảo mật: webhook SePay xác thực Apikey; PayPal xác nhận lại phía server
(khớp custom_id + số tiền) chống giả mạo; secret chỉ trong .env.
- Tests 21/21 pass (order tạo/kích hoạt/idempotent, SePay auth + khớp nội
dung, VietQR builder). Kiểm thử curl: sai key→401, đúng→kích hoạt 30 ngày,
trùng→không cộng thêm, thiếu tiền→không kích hoạt. UI Playwright: modal
nâng cấp (giá VNĐ+USD), QR, admin đơn hàng render đúng.
- .env.example/render.yaml/README: hướng dẫn SePay + PayPal, nhắc vẫn 1 key
Claude, secret không lên git.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Key thật vô tình bị commit vào file mẫu. File .env.example bị đưa lên GitHub nên KHÔNG được chứa secret. Key thật chỉ để trong .env trên máy chủ/Render. Key đã lộ cần được regenerate tại console.groq.com. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
- config.py: tự động load .env qua python-dotenv (chỉ cần tạo .env rồi chạy, không phải export biến môi trường thủ công) - requirements.txt: thêm python-dotenv - gemini.py / openai_compatible.py: nâng maxOutputTokens cho chế độ deep/apex/search để câu trả lời code dài không bị cắt cụt giữa chừng - examples/: thêm game voxel kiểu Minecraft do LUMINA tạo ra (demo end-to-end với bộ não free, tên model được giấu) Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
… bằng giọng
Bổ sung khả năng đa phương thức từ khung mẫu (PHẦN 32/35/36) mà bản chat
ban đầu chưa có, tất cả chạy được trên web miễn phí:
- 🖼 Xem/hiểu ảnh: đính kèm ảnh → Gemini/Claude "nhìn" và trả lời
(media.py tách data URL; gemini.py + claude.py nhận ảnh base64;
orchestrator giới hạn chuỗi engine sang loại nhìn được khi có ảnh)
- 🔬 Nghiên cứu sâu: tìm nhiều nguồn + viết báo cáo có trích dẫn
(router nhận diện; orchestrator chèn chỉ thị nghiên cứu; output dài hơn)
- 🎨 Vẽ ảnh: Pollinations (miễn phí, không cần key) hoặc DALL-E nếu có
OpenAI key (imagegen.py; router mode image_gen; render markdown ảnh)
- 🎤 Nói bằng giọng: Web Speech API ngay trong trình duyệt, không cần server
Frontend: nút 📎 đính kèm (thu nhỏ ảnh về 1024px), 🎤 mic, toggle
🎨 Vẽ ảnh / 🔬 Nghiên cứu sâu; hiển thị ảnh gửi lên và ảnh sinh ra.
Router: thêm nhận diện ý định vẽ ảnh + nghiên cứu, cờ force_mode cho nút.
Tests: +9 (nay 30/30) — nhận diện chế độ, tách ảnh, tạo ảnh.
Đã kiểm thử thật với Gemini: xem ảnh ("Màu đỏ."), nghiên cứu (báo cáo
7757 ký tự + 10 nguồn), vẽ ảnh (URL Pollinations), UI (Playwright).
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
- Không hiển thị con số "lượt cao cấp/ngày" và "tổng tin nhắn/ngày" cho gói Miễn phí (sidebar, thẻ giá, thông báo hết lượt) — tránh làm người dùng ngại; chỉ nói lời thân thiện + mời nâng cấp. - Nâng tổng lượt/ngày gói free 30 → 120 (bộ não free như Gemini cho nhiều lượt, cap chỉ để chống lạm dụng), lượt cao cấp 2 → 3. - Thông báo hết lượt bỏ số cụ thể + tên gói, giữ chữ "Nâng cấp" để giao diện hiện nút nâng cấp. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…nguồn sai Bản khả thi của ý tưởng "học các dataset mở": không thể tải Wikipedia/ CommonCrawl (TB→PB) về web free, nên kho tri thức TỰ LỚN DẦN theo câu hỏi: - knowledge.py: kho SQLite trong data/knowledge.db — câu cần tra cứu đọc kho trước (0 token, 0 mạng); chưa có thì học từ Wikipedia API miễn phí (vi → en) rồi lưu lại; tư liệu quá 90 ngày tự coi là cũ. - Chống nguồn bị sửa bịp: tư liệu luôn kèm link nguồn + chỉ thị bắt bộ não ĐỐI CHIẾU CHÉO với hiểu biết đã huấn luyện và kết quả tìm kiếm, mâu thuẫn phải nói rõ. - orchestrator: chèn tư liệu vào system prompt cho các chế độ tìm kiếm/ nghiên cứu; phát chip "📚 Tra kho tri thức" (app.js). - Hỏng mạng/nguồn → bỏ qua êm, chat vẫn chạy bình thường. - Tests +6 (nay 36/36): lưu/tra kho, chống trùng, từ khóa bỏ từ dừng, chỉ thị đối chiếu, ưu tiên kho nội bộ, offline không nổ lỗi. Đã kiểm thử thật: gieo tri thức "trà xanh" vào kho → hỏi qua chế độ tìm kiếm → LUMINA trả lời đúng nội dung kho (EGCG, Camellia sinensis) kèm chip 📚, engine Gemini free. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Hoàn thiện 4 khả năng đa phương thức còn thiếu: - 🎬 Xem/phân tích video: media.py tách data URL video (giới hạn ~18MB); gemini.py nhận video qua inlineData (chỉ Gemini hỗ trợ video, Claude/ OpenAI chưa có); orchestrator giới hạn chuỗi engine sang loại xem được video khi có đính kèm. - 📄 Gửi tệp PDF/Word/Excel/txt: files.py tách chữ (pypdf/python-docx/ openpyxl), chèn vào ngữ cảnh câu hỏi — mọi bộ não đọc chữ đều dùng được, không cần "nhìn" đặc biệt. - 📝 Tạo phụ đề: router mode "subtitle" (ép qua nút hoặc tự đoán), buộc bộ não xuất transcript đúng định dạng SRT kèm mốc thời gian. Chặn sớm (400) nếu bấm nút mà quên đính kèm video, tránh bộ não bịa nội dung. - 🗣 Lồng tiếng + gắn phụ đề tự động (video_dub.py, tính năng nặng nhất): pipeline nghe video (Gemini) → dịch → sinh giọng đọc mới (edge-tts, miễn phí) → ghép đúng mốc thời gian + gắn cứng phụ đề (ffmpeg qua imageio-ffmpeg — mang sẵn binary tĩnh, không cần cài đặt hệ thống, chạy được trên Render free). Job chạy nền + endpoint poll/tải, giới hạn video ~3 phút, chỉ mở cho gói Tháng/Năm (tốn tài nguyên nhất). Phát hiện và sửa 2 lỗi khi viết: audio bị cắt ngắn hơn video gốc (thiếu đệm khoảng lặng) và lệch chỉ số input ffmpeg khi một đoạn giọng đọc bị lỗi. - Tiện thể sửa lỗi hiển thị "Gói Gói Tháng" ở sidebar (nhãn gói bị lặp tiền tố). Frontend: nút 📎 nhận thêm video/tài liệu (tự phân loại + xem trước), toggle 📝 Phụ đề, modal 🗣 Lồng tiếng phim (chọn video/ngôn ngữ/phụ đề, theo dõi tiến trình, tải kết quả). Tests: +11 (nay 47/47) — gồm kiểm thử ffmpeg THẬT (tạo video, ghép audio, xác nhận không bị cắt ngắn) và đọc PDF/Word/Excel thật. Đã kiểm thử qua HTTP thật: gửi video màu đỏ → LUMINA trả lời đúng "Đỏ."; gửi file Word có mã bí mật → LUMINA đọc đúng nội dung; chế độ phụ đề xuất đúng khối SRT; job lồng tiếng chạy đến bước nghe video thành công qua Gemini, xử lý lỗi TTS/mạng êm khi bị chặn (đã xác minh bằng mock). UI xác nhận bằng Playwright — mọi nút/modal mới hiển thị đúng. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Mỗi hội thoại trong sidebar vốn tách biệt — mở hội thoại mới thì LUMINA "quên sạch" nội dung đã trao đổi trước đó, người dùng phải nhắc lại từ đầu. - db.py: thêm search_messages() — tìm tin nhắn cũ của CHÍNH người dùng (join messages + conversations, lọc theo user_id, loại trừ hội thoại hiện tại). - recall.py: gather() rút từ khóa câu hỏi mới (tái dùng knowledge. extract_keywords), tìm trong hội thoại cũ, xếp hạng theo hội thoại (điểm = số từ khóa khớp), lấy tối đa 3 hội thoại liên quan nhất. build_context() kèm chỉ thị chống bịa — chỉ dùng nếu liên quan, không tự thêm chi tiết ngoài đoạn trích. - main.py: chỉ kích hoạt khi MỞ HỘI THOẠI MỚI (đã có lịch sử trong hội thoại hiện tại thì không cần — model tự thấy trong history rồi); phát chip "🧠 Nhớ lại cuộc trò chuyện" qua SSE. Không tốn API ngoài — chỉ là câu SQL nội bộ. Bảo mật quan trọng nhất: MỌI truy vấn đều lọc theo user_id — tuyệt đối không trộn dữ liệu giữa hai người dùng khác nhau. Tests +6 (nay 53/53) — gồm test cách ly 2 người dùng (assert dữ liệu người này KHÔNG lộ sang người kia). Đã kiểm thử thật qua HTTP với Gemini: kể LUMINA "mèo tên Bún, màu cam" ở hội thoại 1 → mở hội thoại 2 (mới hoàn toàn) hỏi "mèo tên gì" → LUMINA trả lời đúng "Bún, màu cam" — không cần nhắc lại. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Nền gradient tím/xanh cũ nhìn khá giống phong cách Gemini. Thay bằng ảnh minh họa vũ trụ tối (tia sáng vàng ở giữa, dải ngân hà tím) do người dùng cung cấp — nén PNG 1.9MB → JPEG 195KB để không làm chậm màn đăng nhập. Viền tối pha dần vào nền (radial-gradient overlay) để card đăng nhập luôn nổi bật và đọc rõ dù ở màn hình rộng hay hẹp. Đã kiểm tra bằng Playwright trên cả desktop (1280x800) và mobile (390x844) — hiển thị đúng, không tràn, không che chữ. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…hào) Logo trước là ký tự Unicode "✦" tô gradient — đơn điệu. Cắt vùng ngôi sao/nguyên tử trung tâm của ảnh bìa mới (định vị bằng làm mờ + tìm điểm sáng nhất để căn giữa chính xác), làm logo tròn phát sáng dùng nhất quán ở 4 chỗ: favicon tab trình duyệt, logo lớn màn đăng nhập, logo nhỏ sidebar, logo màn chào khi mở hội thoại mới (kể cả bản JS tạo động). Đã kiểm tra bằng Playwright — cả 4 vị trí hiển thị đúng, không lỗi tải ảnh. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Trước đây chỉ Claude ở chế độ 🔍 tìm kiếm mới đọc được link người dùng dán vào (qua server tool web_fetch của Anthropic) — Gemini/Groq/ DeepSeek/OpenAI thì không, kể cả Claude ở chế độ thường. - webpage.py (mới): tự phát hiện URL http(s) trong câu hỏi (tối đa 2 link/lượt), tự tải trang bằng httpx (không cần key), tách tiêu đề + nội dung đọc được bằng BeautifulSoup (loại script/style/nav/header/ footer), đưa vào ngữ cảnh. Chặn trang >3MB hoặc không phải HTML; timeout 12s; không bao giờ raise — lỗi mạng trả về thông báo thân thiện thay vì làm hỏng cả lượt chat. - main.py: quét link trong body.message, tải song song (asyncio.gather), chèn nội dung vào effective_message TRƯỚC khi gọi orchestrator — nên hoạt động với MỌI bộ não, không phụ thuộc chế độ định tuyến. Phát chip "🌐 Đang đọc trang" (tái dùng nhãn web_fetch có sẵn ở frontend). - requirements.txt: thêm beautifulsoup4. - Tests +7 (nay 60/60): tách URL (loại trùng, giới hạn số lượng), phân tích HTML loại bỏ boilerplate, không raise khi domain lỗi, build context bỏ qua trang lỗi. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Chế độ chat mới (kích hoạt qua nút bấm, không auto-detect) buộc bộ não đi qua SPEC ANALYSIS → DESIGN REVIEW → IMPLEMENTATION → VALIDATION → REVIEW → HANDOVER cho các yêu cầu kỹ thuật/lập trình phức tạp. Directive bắt buộc thành thật về việc không có quyền truy cập file hệ thống/kho mã nguồn — hỏi lại người dùng dán code/đính kèm/link thay vì bịa đã đọc source code. Mở rộng _LONG_MODES ở 3 engine để phản hồi 6 giai đoạn không bị cắt cụt giữa chừng. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Tên cũ khá chung chung, không có điểm nhấn thương hiệu. Đổi nhãn hiển thị + mọi chỗ nhắc tới tên chế độ (nút bấm, chỉ thị hệ thống, test, README) — giữ nguyên mode="agent" nội bộ, route, directive 6 giai đoạn và mọi logic khác không đổi. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Đổi lại theo đúng tên người dùng yêu cầu (thay cho Công Trình Sư). Nhãn hiển thị + mọi chỗ nhắc tên chế độ (nút bấm, chỉ thị hệ thống, test, README) — mode="agent" nội bộ, route và directive 6 giai đoạn không đổi. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Chế độ chat mới (kích hoạt qua nút bấm, không auto-detect — giữ hành vi mặc định cho câu hỏi code thường) buộc bộ não trả lời như kỹ sư phần mềm cấp cao: chọn ngôn ngữ/framework phù hợp, trình bày kiến trúc trước khi viết code, nêu rủi ro bảo mật + cách kiểm thử, kèm Dockerfile/CI-CD nếu liên quan. Hỗ trợ Python/TypeScript/JavaScript/Rust/Go/Java/C#/C++/SQL/ Bash. Mở rộng _LONG_MODES ở 3 engine để phản hồi không bị cắt cụt. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…êm Thư viện Kỹ năng nội bộ Gộp mode: chỉ còn 1 nút ⚙️ Lumina Forge — yêu cầu nhỏ trả lời gọn ở mức chuyên gia (kiến trúc/bảo mật/test, không ép tiêu đề PHASE), yêu cầu lớn tự động dùng đủ quy trình 6 giai đoạn. Bỏ route/directive/nút "code" riêng. Thư viện Kỹ năng nội bộ (app/skills.py): tuyển chọn 53 skill THUẦN VĂN BẢN/PHƯƠNG PHÁP LUẬN (không cần tool/MCP/browser thật) từ 5 repo Claude Skills mã nguồn mở (MIT/Apache-2.0) — kỹ thuật phần mềm + gu thiết kế UI/UX. Nạp tĩnh từ data/skills/*.md, so khớp từ khóa kích hoạt tiếng Việt tự viết (keywords_vi) bằng substring — tránh lỗi so token chính xác Việt-Anh không bao giờ trúng. Chỉ áp dụng trong chế độ Lumina Forge, tiêm kỹ năng khớp nhất (nếu có) kèm chỉ thị rõ đây là tài liệu tham khảo, LUMINA không có công cụ chạy bash/git/browser/MCP thật. Đã loại các repo/skill cần hạ tầng chạy tool thật (gstack, understand- anything, codebase-memory-mcp, ruflo, docx/pptx/xlsx/pdf sinh file...) vì LUMINA là REST API chat thuần, không có sandbox thực thi. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Cả 2 đều là MCP server/CLI thật cần hạ tầng chạy nền (LSP server theo ngôn ngữ / semantic search + vector embeddings) — không có nội dung tư vấn thuần văn bản để đưa vào thư viện kỹ năng, giống lý do đã loại gstack/understand-anything/codebase-memory-mcp/ruflo trước đó. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…ile thật Skill mới (từ 1 file zip lẻ người dùng gửi, license MIT tự khai trong frontmatter): tài liệu hóa codebase theo 7 mục (STACK/STRUCTURE/ ARCHITECTURE/CONVENTIONS/INTEGRATIONS/TESTING/CONCERNS). Bản gốc giả định chạy scripts/scan.py + ghi file thật vào docs/codebase/ — LUMINA không làm được 2 việc này, nên củng cố build_skill_context() để chỉ thị rõ: trình bày kết quả trong khung chat, không khẳng định đã tạo/ghi file thật lên hệ thống (áp dụng chung cho mọi skill có tính chất sinh file). 54 → 55 skill trong thư viện. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…o/tạo ảnh Rà nhóm skill "tạo ảnh"/"edit video" trong danh sách awesome-agent-skills theo yêu cầu — hầu hết đều gọi API trả phí bên thứ ba cụ thể (fal.ai, MiniMax, OpenAI Sora, Venice.ai, NVIDIA VSS, Remotion...) mà LUMINA không có key/tích hợp — loại khỏi thư viện. Ngoại lệ: dashmotion (sinh sơ đồ kỹ thuật động dạng HTML+SVG tự chứa, không gọi API ngoài) — đã dịch + thích nghi sang tiếng Việt, thay bước "chạy scripts/layout.py" bằng "cách tính tay" mà chính tài liệu gốc mô tả (LUMINA không chạy được script). Đã kiểm tra hand-drawn-diagrams (loại, phụ thuộc Excalidraw hosted) và các skill nhắc "Codex" (đều là tích hợp tool/API cụ thể, không có nội dung phương pháp luận chung mới). 55 skill trong thư viện. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…gent 5 skill từ mattpocock/skills (MIT): domain-modeling, codebase-design, resolving-merge-conflicts, diagnosing-bugs, prototype. 1 skill từ uucz/moyu (MIT): anti-over-engineering — nguyên tắc tránh làm quá tay, chỉ sửa đúng phạm vi yêu cầu. 3 skill từ Agent-Skills-for-Context-Engineering (MIT): context-degradation, multi-agent-patterns, memory-systems — kiến trúc AI agent (context/bộ nhớ/nhiều agent phối hợp). 1 skill dashmotion đã thêm ở commit trước — tổng 65 skill. Đã rà nhóm video/tạo ảnh AI theo yêu cầu — phần lớn phụ thuộc API trả phí bên thứ ba cụ thể (fal.ai, MiniMax, Sora, Venice.ai...) không dùng được; đã rà thêm nhóm "Codex"/năng lực agent chung — không có gì mới ngoài phạm vi agent-skills/superpowers đã có. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
… sâu 2 skill từ ehmo/platform-design-skills (MIT): platform-design-web (WCAG 2.2 + responsive + performance), platform-design-android (Material Design 3). 1 skill từ zscole/model-hierarchy-skill (MIT): model-hierarchy — chọn model AI theo chi phí/độ khó tác vụ, cùng tinh thần với auto-router của chính LUMINA. 1 skill từ massimodeluisa/recursive-decomposition-skill (MIT): recursive-decomposition — xử lý task/context quá dài bằng phân rã, có thêm đoạn thích nghi riêng cho việc LUMINA không có grep/glob thật. 3 skill từ mcollina/skills (MIT, Matteo Collina): documentation-diataxis (khung 4 loại tài liệu kỹ thuật), typescript-magician (type nâng cao, loại bỏ any), oauth-security (PKCE, JWT validation, chống CSRF). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
4 skill từ dembrandt/dembrandt-skills (MIT): nielsen-usability-heuristics (10 nguyên tắc usability kinh điển), information-architecture (đặt tên/ điều hướng), modular-scale-typography (hệ thống cỡ chữ), gestalt-ui- organisation (nguyên tắc thị giác nhóm phần tử). 1 skill từ BehiSecc/VibeSec-Skill (Apache-2.0): vibesec — bảo mật code góc nhìn bug hunter (IDOR/XSS/CSRF/SQLi/SSRF/XXE/JWT). 1 skill từ meodai/skill.color-expert (CC BY 4.0 — giấy phép khác MIT/ Apache, đã ghi rõ trong ATTRIBUTION): color-expert — khoa học màu sắc (OKLCH, contrast WCAG/APCA, design token màu). Đã kiểm tra và loại NeoLabHQ/context-engineering-kit — dùng GPLv3 (copyleft mạnh), không phù hợp trộn vào dự án có mục đích thương mại. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…S, lint grilling (mattpocock/skills, MIT) — hỏi dồn từng câu để stress-test kế hoạch/quyết định trước khi triển khai. unslop (MohamedAbdallah-14/unslop, MIT) — nhận diện và loại bỏ văn phong "giống AI viết" (sáo rỗng, hedging, tricolon, em-dash thừa). swiftui-expert (AvdLee/SwiftUI-Agent-Skill, MIT) — quy tắc SwiftUI đúng (state management, ForEach identity, animation). eslint-neostandard-linting (mcollina/skills, MIT) — thiết lập ESLint v9 flat config + neostandard. Đã kiểm tra và loại: apple-hig-skills (nội dung © Apple Inc., không được phép sao chép), K-Dense-AI/claude-scientific-skills và Anthropic-Cybersecurity-Skills (quá chuyên sâu/hẹp, cần công cụ chuyên ngành thật). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
teaching-framework, loading-states-perceived-performance, status-colors- and-errors, form-design, micro-interactions, responsive-paradigms, notifications-and-recovery, data-display-and-selection — 7/8 từ dembrandt/dembrandt-skills (MIT), 1 từ mattpocock/skills (MIT). Đã kiểm tra và loại thêm: Digidai/product-manager-skills (CC BY-NC-SA 4.0 — cấm dùng thương mại, LUMINA có gói trả phí), hanfang/claude- memory-skill (cần agent nền + ghi file thật, đã có memory-systems làm kiến thức khái niệm tương đương). Baseline trước khi bắt đầu tìm thêm: 54 skill. Hiện tại: 90 skill (+36 skill mới, đủ mục tiêu). Toàn bộ đã ghi công đầy đủ trong data/skills/ATTRIBUTION.md. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Bổ sung từ dembrandt/dembrandt-skills (MIT, đã vetted): WCAG 2.2, trạng thái nút bấm, dark mode, elevation/shadow, modal/overlay, tab navigation, scroll area, sticky header, mật độ giao diện, semantic HTML/SEO, phân cấp thị giác, luồng người dùng, tính nhất quán layout/component, ẩn dụ giao diện, bảng màu thuật toán, ngôn ngữ hình ảnh thương hiệu, Core Web Vitals, chuyển động kể chuyện, dashboard nhiều view đồng bộ. Bỏ từ khóa "wcag" khỏi platform-design-web để tránh trùng với skill wcag-accessibility mới. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Thêm: authentic-product-representation, global-toolbar-controls, repeated-component-alignment, ui-context-and-scope, operational-expert-tool-ui. Đã vét hết dembrandt/dembrandt-skills (36/40 folder; 4 folder còn lại là CLI/MCP orchestration nên loại). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Trước đây LUMINA chỉ ĐỌC được tệp đính kèm (files.py). Nay thêm khả năng SINH FILE: đọc nhiều tệp nguồn → bộ não nghĩ & tổng hợp kiến thức thành MỘT tài liệu/ sách mới mạch lạc → xuất file để tải về. Ví dụ: gửi 2 bản PDF Đạo Đức Kinh → nhận về 1 cuốn sách tổng hợp. - app/docgen.py: Markdown → docx (python-docx, mọi ngôn ngữ), pdf (fpdf2 + DejaVu, Latin/Việt), html (tự chứa, mở điện thoại → Lưu thành PDF). Parser markdown thực dụng (tiêu đề/bullet/quote/hr/đoạn). - POST /api/compose (schemas.ComposeRequest): đọc tệp qua files.extract_text → chèn directive "đọc→nghĩ→tổng hợp thành sách" → orchestrator.run → docgen → trả Response file kèm Content-Disposition (ASCII filename + UTF-8 filename*). Dùng chung hạn mức ngày với chat; gói trả phí → bộ não cao cấp. - requirements: +fpdf2. - Frontend: nút "📚 Tổng hợp thành file" hiện khi có tệp đính kèm → hỏi tên + định dạng → tải blob về. CSS .compose-btn. - Tests: docgen 3 định dạng (tiếng Việt roundtrip) + /api/compose (docx/pdf, lỗi 400). 300 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Kinh tế học: - microeconomics-and-market-behavior (cung/cầu, elasticity, marginal, market structure) - macroeconomics-fundamentals (GDP, lạm phát, chu kỳ, tiền tệ/tài khóa) - behavioral-economics-and-nudges (prospect theory, loss aversion, nudge, đạo đức) Tâm lý học: - cognitive-biases-and-decision-making (System 1/2, heuristics, debiasing) - memory-and-learning-psychology (forgetting curve, spaced repetition, retrieval) - social-psychology-fundamentals (conformity, Cialdini, dissonance, in/out-group) Kỹ thuật điện-cơ: - analog-circuit-design-fundamentals (Ohm/Kirchhoff, RC/RL, op-amp, filter) - statics-and-mechanics-of-materials (equilibrium, FBD, stress/strain, beams) Sửa tie nội bộ + 2 overlap với mmo-economies/spaced-repetition. 302 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Mở rộng nhóm "dạy kiến thức" (category: knowledge) vốn còn mỏng: - newtonian-mechanics-and-forces (3 định luật, lực, momentum, năng lượng) - electromagnetism-fundamentals (điện trường, cảm ứng, Maxwell, sóng/ánh sáng) - atomic-structure-and-periodic-table (nguyên tử, electron shell, xu hướng tuần hoàn) - chemical-bonding-and-reactions (ion/cộng hóa trị, phương trình, axit/bazơ) - cell-biology-and-heredity (bào quan, phân bào, di truyền Mendel) - evolution-and-natural-selection (biến dị/di truyền/chọn lọc, bằng chứng, hiểu lầm) - calculus-intuition (giới hạn, đạo hàm, tích phân, định lý cơ bản) - linear-algebra-intuition (vector, ma trận là phép biến đổi, eigenvector) Sửa tie newtonian/statics (FBD). 304 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Phủ chương trình thi tốt nghiệp THPT: - trigonometry-and-functions (Toán: lượng giác, hàm số) - exponentials-and-logarithms (Toán: mũ, logarit) - oscillations-and-waves (Lí: dao động điều hòa, sóng, cộng hưởng) - optics-and-light (Lí: phản xạ/khúc xạ, thấu kính, giao thoa) - organic-chemistry-basics (Hóa: hydrocacbon, nhóm chức, đồng phân) - ecology-and-ecosystems (Sinh: chuỗi thức ăn, dòng năng lượng, sinh thái) - world-history-overview (Sử: dòng chảy lịch sử thế giới + tư duy sử) - physical-geography-and-climate (Địa: kiến tạo mảng, khí hậu, tài nguyên) Cộng các skill khoa học đã có (cơ học Newton, điện từ, nguyên tử, liên kết, tế bào/di truyền, tiến hóa, giải tích, đại số tuyến tính, xác suất, thống kê) → phủ khá đủ kiến thức nền THPT. 306 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Tầng nâng cao trên phần THPT cơ bản — tới trình thi chuyên/28+ điểm: Toán chuyên: - number-theory-and-divisibility (chia hết, modulo, Fermat, Diophantine) - inequalities-and-optimization (AM-GM, Cauchy-Schwarz, SOS, dấu bằng) - combinatorics-and-counting (song ánh, bù trừ, Dirichlet, truy hồi) Lý chuyên: - rigid-body-and-rotational-dynamics (mô men quán tính, L bảo toàn, lăn) - kinetic-theory-and-gas-laws (khí lý tưởng, Maxwell-Boltzmann, nhiệt động) Hóa chuyên: - chemical-equilibrium-and-kinetics (K, Le Chatelier, Arrhenius) - electrochemistry-and-redox (pin, thế điện cực, Faraday) - acid-base-and-ph-equilibria (Ka/Kb, pH, đệm, chuẩn độ) 308 test pass, không vỡ test cũ. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Batch 1/2 của "+50 chuyên sâu". Tầng nâng cao đầy đủ 3 môn: Toán (8): plane-geometry-olympiad, polynomials-and-roots, functional-equations, complex-numbers, sequences-limits-and-series, mathematical-induction-and-proof, coordinate-and-vector-geometry, graph-theory-and-invariants Lý (8): ac-circuits-and-impedance, nuclear-and-particle-physics, special-relativity-deep, electrostatics-and-electric-fields, magnetism-and-induction-deep, fluid-mechanics-and-pressure, gravitation-and-kepler, momentum-collisions-and-cm Hóa (8): stoichiometry-and-mole-calculations, thermochemistry-and-hess-law, organic-reaction-mechanisms, transition-metals-and-coordination, inorganic-chemistry-and-periodicity, solutions-and-colligative-properties, polymers-and-biomolecules, electron-configuration-and-quantum-numbers Mỗi skill: kỹ thuật giải + trực giác, hướng thi chuyên/28+ điểm. 310 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Sinh chuyên sâu (8): molecular-genetics-and-biotech, human-physiology-and-organ-systems, photosynthesis-and-plant-biology, cellular-respiration-and-metabolism, immunology-and-disease, population-genetics-and-evolution, nervous-and-endocrine-systems, microbiology-and-viruses Nhân văn/mở rộng (8): literary-analysis-and-criticism, advanced-english-grammar-and-usage, vietnamese-history-overview, vietnamese-geography, economic-and-human-geography, philosophy-and-critical-thinking, formal-logic-and-argumentation, astronomy-and-cosmology 312 test pass. (Batch 2/2 của "+50" — còn batch F cuối.) Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…N THÀNH +50 Batch F hoàn tất "+50 chuyên sâu": - limits-and-continuity, derivatives-and-function-analysis, integration-techniques, differential-equations-intro (giải tích đầy đủ THPT→nâng cao) - matrices-and-linear-systems, combinatorial-probability, discrete-math-and-set-theory - geology-and-earth-science, environmental-science-and-sustainability, scientific-method-and-experimentation Tổng lượt này +50 skill chuyên sâu (6 batch): Toán/Lý/Hóa/Sinh olympiad + nhân văn + giải tích + khoa học nền. Sửa tie combinatorial-probability/credit-risk. 314 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…on) — 1087 → 1093 Theo yêu cầu + lấp gap thật sau khi kiểm kho: - competitive-programming-techniques (thi chuyên Tin: DP, đồ thị, đọc ràng buộc) - advanced-solid-geometry (hình học không gian nâng cao) - analytical-chemistry (hóa phân tích: chuẩn độ, phổ, sắc ký, đường chuẩn) - lottie-and-dotlottie-animation (JSON/dotLottie export, phát web/mobile) - svg-animation-techniques (stroke-dasharray, morph, path motion) - ai-motion-design-workflow (design→motion→export pipeline) 316 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Bộ đọc tệp 2 tầng, giữ app nhẹ mặc định: - Tầng 1 (TÙY CHỌN): markitdown → Markdown sạch (giữ bảng/tiêu đề/list) cho mọi định dạng, thêm .pptx/.html/.epub. Truyền sẵn extension+mimetype nên KHÔNG gọi magika lúc chạy. Bật khi `pip install "markitdown[all]"`. - Tầng 2 (mặc định): fallback nhẹ pypdf/python-docx/openpyxl (như cũ). - Tự nhận mimetype từ đuôi file khi data URL ghi octet-stream. - Tắt markitdown kể cả khi đã cài: MARKITDOWN_DISABLE=1. - Không đưa markitdown vào requirements mặc định (kéo ~35MB onnxruntime) — để comment + hướng dẫn; deploy mặc định vẫn ~nhẹ. Frontend accept thêm .pptx/.html/.epub/.json. README cập nhật. 317 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…bal search RAG trên KNOWLEDGE GRAPH thay vì vector phẳng: - app/graph_rag.py: trích thực thể (danh từ riêng, phủ dấu tiếng Việt — sửa bug dải À-Ỹ lỡ gồm chữ thường) + quan hệ đồng-xuất-hiện theo câu → sqlite (nodes/edges). Bản nhẹ KHÔNG tốn token; cắm LLM-extractor qua set_llm_extractor() để tăng chất lượng. - local_search: bám thực thể trong câu hỏi → mở rộng hàng xóm. - global_overview: hub/chủ đề toàn cục (trả lời câu hỏi tổng thể mà RAG vector khó). - Endpoints: POST /api/graph/ingest, GET /api/graph/query?scope=local|global. - Tích hợp vào /api/compose: nạp các tệp nguồn vào đồ thị + chèn overview → bộ não NỐI kiến thức GIỮA các tệp khi tổng hợp (đúng bài "gộp 2 file thành sách"). 319 test pass. Skill how-graphrag-works đã có sẵn để bộ não hiểu cơ chế. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…te-forge — 1094 skills Worldmonitor (app/worldmonitor.py): - Lấy DỮ LIỆU QUỐC GIA TƯƠI (dân số/thủ đô/tiền tệ/ngôn ngữ…) từ REST Countries API — miễn phí, KHÔNG key. Câu "dân số Việt Nam" → số liệu mới thay vì trọng số cũ. - detect_country (Việt/Anh, không để "hà" nuốt "hàn quốc"), cache TTL 6h. - Tích hợp vào knowledge.gather: câu hỏi quốc gia → fetch tươi + remember() → "trọng số" thế giới của LUMINA dày lên theo thời gian. - Endpoint GET /api/world?country=. (Sandbox proxy chặn restcountries → chạy thật trên Render; logic detect/parse đã test đủ, không cần mạng.) Skill: ai-sprite-and-game-art-generation (mở rộng từ agent-sprite-forge) — sinh sprite/pixel-art/tileset bằng AI, giữ style nhất quán, sprite sheet, pipeline prompt→asset game-ready. 320 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…cài agent Mảnh "hệ sinh thái" #2: nền tảng để người dùng TẠO & CHIA SẺ agent, không chỉ tiêu thụ. Backend (db.py): - agents +cột shared/installs/author/origin_id (migration ALTER an toàn). - set_agent_shared, list_shared_agents (xếp theo installs), get_shared_agent, install_shared_agent (fork vào bộ sưu tập người cài; chống trùng; +installs; không tự cài). Endpoints: POST /api/agents/{id}/share, GET /api/marketplace?q=, POST /api/marketplace/{id}/install. Frontend: - Khôi phục + mở rộng UI agent: + Tạo agent (modal name/emoji/persona + tick Chia sẻ), sửa/xóa, danh sách "Agent của tôi". - 🌐 Chợ Agent (modal): duyệt agent cộng đồng (tác giả, ⬇ installs, preview) + nút Cài. - CSS .agent-actions/.market-card… 322 test pass (share/install + endpoints). JS hợp lệ. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
#1 — LUMINA thành API dùng được từ app/script ngoài: - db.api_keys (lưu HASH sha256, prefix hiển thị) + create/list/delete + user_by_api_key. - auth.require_api_key: 'Authorization: Bearer lum_…'. - POST /v1/chat/completions — TƯƠNG THÍCH OpenAI (trỏ SDK OpenAI vào <host>/v1, model 'lumina'): định tuyến qua bộ não nhiều tầng, KHÔNG lộ model thật, stream & non-stream, tôn trọng hạn mức gói. Quản lý key: POST/GET/DELETE /api/keys. - Frontend: modal 🔑 API (tạo/sao chép/thu hồi key + ví dụ curl). #2 — thêm ~30 bộ não phụ MIỄN PHÍ: - config.OPENROUTER_MODELS (~31 model free: Llama/Qwen/Gemma/DeepSeek/Mistral/Phi…). - orchestrator đăng ký mỗi model thành engine openrouter-N (như LOCAL_MODELS cho Ollama), chèn vào chuỗi free → nay 52 engine, 51 bộ não free (chỉ chạy khi có OPENROUTER_API_KEY; engine chết thì fallback tự nhảy). OpenRouterEngine nhận model/name. 324 test pass (API key lifecycle + /v1 + đếm engine). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Skill mô tả đúng kiến trúc vừa build: cổng hợp nhất nhiều nhà cung cấp LLM sau một API, định tuyến theo cost/quality/latency, chuỗi fallback phân tầng + circuit breaker, bề mặt OpenAI-compatible, ẩn danh tính model. 324 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…— 1095 → 1097 Đúng chủ đề vừa build (API riêng + đa LLM): sản phẩm hóa API LLM (OpenAI-compat, key, quota, billing, DX) + độ tin cậy/fallback (chuỗi phân tầng, circuit breaker, retry backoff, timeout, health check). Sửa tie với load-shedding. 324 test pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Cho phép chủ web điền GROQ_API_KEYS / GEMINI_API_KEYS / OPENROUTER_API_KEYS...
(nhiều key cách nhau bằng dấu phẩy) để GỘP hạn mức free của nhiều tài khoản —
phục vụ đông người dùng (vd app Android công khai) mà không đụng trần free của
một key.
- app/config.py: helper _multikey(prefix) đọc {PREFIX}_API_KEYS, fallback về
{PREFIX}_API_KEY; thêm *_API_KEYS cho Gemini/Groq/OpenRouter/DeepSeek/Mistral/
Kimi/GitHub/OpenAI.
- app/keyring.py (mới): rotation_order() round-robin bền qua các request, an toàn
luồng — cân bằng tải qua các key.
- engines/openai_compatible.py: stream_chat xoay vòng key, tách _stream_once();
nhảy key kế khi 429/401/403 và CHƯA phát chữ (không retry giữa dòng stream).
- engines/gemini.py: xoay vòng key trong POST generateContent.
- engines/base.py: EngineError thêm cờ rotate (lỗi do key → nên thử key khác).
- Tương thích ngược: chỉ 1 key thì để *_API_KEY như cũ, hành vi không đổi.
- Tests: +6 (parse/dedup/fallback, round-robin, availability, xoay khi key hỏng,
không retry sau khi đã phát chữ, không xoay với lỗi khác) → 330 pass.
- README + .env.example: hướng dẫn gộp key + cảnh báo ToS khi tạo nhiều tài khoản.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
… chính nén 22B - finetune/kaggle_lumina_lora.ipynb (mới): chạy trọn QLoRA 4-bit trên GPU FREE của Kaggle (2×T4/P100) → xuất LoRA adapter (~50–400MB) tải về. Mặc định Qwen2.5-7B (an toàn cho Kaggle free); ô cuối đính chính rõ vì sao KHÔNG thể nén 22B < 400MB. - prepare_data.py: thêm nguồn 'skills' (đọc data/skills/*.md → cặp SFT) cho ai muốn bake skill vào trọng số — kèm cảnh báo tiêm prompt lúc chạy vẫn tốt hơn. - finetune/README.md: hướng dẫn Kaggle, nguồn skills, và mục "❌ nén 22B<400MB không thể" (AWQ 4-bit = ~11–13GB, không phải 400MB; <400MB chỉ có thể là LoRA adapter). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…ệnh) - prepare_data.py: thêm nguồn 'flan' (SirNeural/flan_v2, map inputs/targets). Đây là dataset DUY NHẤT trong danh sách người dùng gửi mà chưa có — tất cả còn lại (OpenCodeInstruct/Reasoning-2, ToolBench, SWE-smith, NuminaMath, UltraChat, OpenOrca, OpenHermes, No Robots, Tulu2, Capybara, WizardLM) đã wired sẵn; Rico/WebCode2M/Vision2UI đã có trong vlm/prepare_vlm_data.py. - merge_lora.py (mới): gộp LoRA adapter vào model nền bằng 1 lệnh (base tự suy từ adapter) → model độc lập, KHÔNG cần gửi file cho ai. Thay đoạn snippet inline cũ. - export_ollama.md + README.md: trỏ sang merge_lora.py, liệt kê file mới. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Đổi BASE mặc định Qwen2.5-7B → Qwen2.5-1.5B-Instruct (file Ollama cuối ~1GB, train rất nhanh trên Kaggle free). Kèm gợi ý 0.5B (~0.4GB) / true-1B (Llama-3.2-1B, gemma-3-1b) / 3B / 7B với dung lượng tương ứng. Cập nhật ghi chú mục 3. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…7 → 1099
Đối chiếu danh sách repo người dùng gửi: gần như đã có sẵn (MMO, three.js/img→3D,
system-design, crawl4ai→web-crawling, SkillOPT→skill-optimization, DesktopCommander→
computer-use-and-gui-agents, mcp-builder). Thêm 2 cái thật sự thiếu:
- automatic-prompt-optimization (shenkx/prompt-optimizer + Microsoft/SkillOPT): DSPy/
APE/OPRO, vòng lặp tối ưu prompt/skill theo thước đo. Keyword atomic tránh đụng
algorithms-and-complexity ("thuật toán").
- last-30-days-briefing (mvanhorn/last30days-skill): bản tin N ngày qua — cửa sổ thời
gian, ghi ngày từng mục, khử trùng lặp, phát hiện thay đổi, cảnh báo tin mới chưa kiểm.
Tests +2 (count ≥1099 + topic match) → 332 pass.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…— 1100 skills - knowledge.py: is_recent_digest_query + recent_window_days + _fetch_recent_digest. Câu "30 ngày qua có gì mới / what's new last 7 days" → tự lấy bản tin cửa sổ thời gian qua Google News `when:Nd` (lọc ĐÚNG số ngày), đóng nhãn tin tức + cảnh báo chưa kiểm chứng (3 tầng chống bịp). Wire vào gather() TRƯỚC nhánh thời sự chung. - skill agent-loop-engineering (cobusgreyling/loop-engineering): pattern vòng lặp agent (plan-act-observe/critic/budget-guarded/scheduled), điều kiện dừng, ngân sách, trạng thái giữa vòng, kiểm toán. - Tests +4 (count ≥1100, routing, detector+window, gather offline không raise) → 335 pass. 3 repo còn lại đều là HẠ TẦNG (không nhét skill được): HKUDS/OpenSpace = MCP daemon quản lý skill; robbyant/lingbot-map = model 3D cần GPU; loop-engineering = CLI+method (đã rút phần method thành skill trên). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
LUMINA thiên về code → thêm skill CODE game theo engine (đối chiếu list repo user gửi): - godot-engine-and-gdscript (godotengine/godot): node/scene, scene tree, signal, vòng đời _ready/_process/_physics_process, GDScript, @export, resource. - unity-engine-gameplay-scripting (Unity, OPENMMO): GameObject/component, MonoBehaviour lifecycle (Awake/Start/Update/FixedUpdate), prefab, SerializeField, coroutine, Rigidbody, object pooling. Keyword atomic tránh đụng "comm*unity*". - raylib-and-immediate-mode-games (raysan5/raylib-games, GDevelop, libGDX, Bevy, build-your-own-X): tự viết game loop, immediate vs retained mode, poll input. Đã có sẵn (không thêm lại): ECS (entity-component-system-architecture), game AI + behavior tree (game-ai-behavior), C# (dotnet-csharp-patterns), flutter/css/gsap/ lottie/svg animation, sprite/atlas, roguelike, vampire-survivors, collision, physics, shader, tilemap, character-controller, how-game-engines-work… Hạ tầng KHÔNG nhét được: ComfyUI (workflow image-gen), magictools (list link). Tests +2 (count ≥1103, routing 3 engine) → 337 pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
- bevy-and-rust-game-development: App/plugin, ECS system+query, Resource/Component, Commands spawn, schedule ordering, change detection, ownership Rust trong game. - phaser-web-game-development: config+Scene, preload/create/update, display list, Arcade Physics, tween, input, ship HTML5 static + wrap mobile. - cocos-creator-game-development: node/component, lifecycle onLoad/start/update, @Property, prefab, UI Widget, xuất web/iOS/Android/mini-game (WeChat). Keyword atomic (phaser/cocos/cocos2d distinctive) tránh đụng how-game-engines-work/ how-browsers-work. Tests +2 (count ≥1106, routing) → 339 pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
- unreal-engine-cpp-gameplay: Actor/Component, Gameplay Framework (GameMode/Pawn/ Controller/PlayerState), C++↔Blueprint qua UPROPERTY/UFUNCTION, UObject GC, Tick. - pixijs-webgl-2d-rendering: Application/stage scene graph, ticker, texture atlas + batching draw call, filter/shader; Pixi (2D) vs Phaser (framework) vs Three.js (3D). - gamemaker-studio-and-gml: object/instance/room, event model (Create/Step/Draw/ Alarm/Collision), GML + built-in vars, xuất đa nền. Keyword atomic (unreal/pixi/gamemaker/gml distinctive) tránh đụng docker/how-browsers/ collision-detection. Tests +2 (count ≥1109, routing) → 341 pass. Multiplayer networking ĐÃ có sẵn (không thêm lại): game-networking-and-netcode (client prediction/reconciliation/interpolation/lockstep/rollback/lag comp), server-authoritative- multiplayer, asymmetric-multiplayer-design. Three.js 3D web đã có three-js-and-web-3d. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…h, HTN, profiling — 1109 → 1114 - audio-middleware-fmod-wwise: event/bank, parameter/RTPC, bus/snapshot mixing, 3D audio, streaming, tích hợp Unity/Unreal. - procedural-dungeon-and-level-generation: BSP, cellular automata cave, drunkard walk, room-and-corridor, Delaunay+MST connectivity, đảm bảo solvability + seed. - shader-graphs-and-node-based-materials: Unity Shader Graph/Unreal Material/Godot visual shader — node UV/Time/Noise/Fresnel/Lerp, recipe dissolve/water/hologram/toon. - htn-hierarchical-task-network-planning: compound/primitive task, method decomposition, planning loop + replan; HTN vs GOAP vs behavior tree. - game-performance-optimization-and-profiling: frame budget 16.6ms, CPU/GPU-bound, draw call/batching, overdraw, GC spike + pooling, LOD/culling, profile-first. Keyword atomic tránh đụng how-cellular-networks. Tests +2 → 343 pass. Đã có sẵn: procedural chung (procedural-generation-in-games + wave-function-collapse), GOAP (goap-planning), particle/VFX (particle-systems-and-vfx), audio design (game-audio-and-adaptive-music). Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
… → 1116 Rà gap thật cho chính sản phẩm AI này (nhiều thứ đã có sẵn → không nhồi trùng): - voice-ai-agents-and-realtime-speech: pipeline STT→LLM→TTS, ngân sách độ trễ, turn-taking (VAD/endpointing/barge-in), speech-to-speech, telephony, fallback. - streaming-ux-for-ai-chat: token streaming qua SSE, render markdown CHƯA hoàn chỉnh an toàn, stop/regenerate (huỷ sinh phía server), chỉ báo thinking/tool, auto-scroll đúng cách, xử lý mất kết nối — đúng thứ LUMINA đang là (chat streaming). Đã có sẵn nên KHÔNG thêm (trung thực): semantic-caching-for-llms, how-vector-databases- work (HNSW/IVF/PQ), evaluation (LLM-as-judge), llm-function-calling, structured-output, rag-chunking/reranking, memory-systems (agent memory), pii-handling, agentic-rag. Keyword atomic tránh đụng how-grpc-works/api-and-interface-design. Tests +2 → 345 pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…reasoning — 1116 → 1118 2 repo user gửi đều là HẠ TẦNG/DATA (không nhét skill được), nhưng concept lõi là gap thật: - the_well (15TB dataset mô phỏng vật lý + PyTorch lib) → skill scientific-machine-learning-and-neural-surrogates: neural operator/FNO, PINN, operator learning, thay solver PDE đắt bằng surrogate nhanh; kèm giới hạn extrapolation. - semantica (KG infra: NER/reasoning Datalog/SPARQL/Rete/PROV-O) → skill rule-engines-and-logic-reasoning: forward/backward chaining, Rete, Datalog, SPARQL/ ontology, neuro-symbolic (LLM trích fact + rule engine suy luận có kiểm chứng). (KG storage/GraphRAG đã có how-graphrag-works + graph-databases; provenance ≈ data-lineage.) Keyword atomic tránh đụng how-physics-engines/how-neural-networks. Tests +2 → 347 pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
Theo yêu cầu "lấy Open Library API ghép vào". Mirror pattern worldmonitor: - app/openlibrary.py: is_book_query (nhận diện câu hỏi sách/tác giả, chặn nhầm 'chính sách'/'sách lược'), fetch_book (Open Library search.json, cache 1 ngày), _parse_book → fact (tựa, tác giả, năm xuất bản đầu, số ấn bản, chủ đề). - knowledge.gather: wire sau worldmonitor → câu hỏi "sách X của ai / tác giả cuốn Y" trả metadata THẬT + lưu kho, best-effort (offline không raise). - Tests +2 (detection/parse + gather offline) → 349 pass. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
…ning — 1118 → 1120 Từ "2 repo tạo phim ai" (dramaclaw + voicebox): - ai-film-production-and-character-consistency: pipeline script→storyboard→shot→edit, và bài toán KHÓ nhất — giữ NHẤT QUÁN NHÂN VẬT qua các cảnh (reference image, fixed seed, LoRA nhân vật, wardrobe bible), continuity 180 độ. - voice-cloning-and-synthetic-speech: zero/few-shot cloning, speaker embedding tách prosody, chất lượng phụ thuộc audio sạch, VÀ mảng đạo đức bắt buộc (đồng thuận, disclosure, watermark, chống deepfake/impersonation). Keyword atomic (character consistency/voice cloning) tránh đụng ai-avatar/voice-ai-agents. Tests +2 → 351 pass. Đã có sẵn (không thêm): short-video pipeline (ai-short-video-generation), lip-sync, multi-agent (multi-agent-patterns ~ KiroCrew), dataviz (~ flint-chart), curriculum ML (~ AI-For-Beginners). Open Library đã ghép ở commit trước. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01HUmDaZPaPfY5Sb8ezVkwAG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Thêm hệ thống thuê bao trả phí (Tháng/Năm) bên cạnh gói Miễn phí cho
lumina-ai/. Chưa tích hợp cổng thanh toán tự động — dùng mã kích hoạt thủ công: người dùng chuyển khoản/Momo → chủ web xác nhận → tạo mã qua trang quản trị → người dùng nhập mã, nâng cấp ngay.Gói Miễn phí mặc định chỉ 2 tin nhắn/ngày (
FREE_DAILY_CAP) để bảo vệ ngân sách API ban đầu nhỏ — buộc phải mua gói mới dùng nhiều.Thay đổi chính:
config.py:PLANS(free/monthly/yearly),ADMIN_EMAILS,PAYMENT_*.db.py: cộtplan/plan_expires_at, bảngactivation_codes+usage_daily;get_effective_plantự hạ về free khi hết hạn; redeem chống dùng lại mã.ratelimit.py: bucket cấp lại dung lượng khi vừa nâng cấp.router.py: gate 🌌 Đỉnh cao (Fable) theo gói; free hạ xuống 🧠 Tư duy sâu + cờapex_locked.auth.py/main.py:is_admin; endpoint/api/plans,/api/redeem,/api/admin/codes; chat_stream áp rate-limit + daily-cap theo gói, sự kiện SSEupsell.Testing
pytest tests/— 18/18 pass (10 cũ + 8 mới: apex-gating, rate-limiter nâng cấp, DB gói/mã/daily-cap)curl: tạo mã → kích hoạt → nâng cấp phản ánh đúng → dùng lại mã cũ bị từ chối → non-admin 403 → rate-limit + daily-cap chặn đúng lượt/api/mesau đăng nhập để lấyis_admin/plan)AI Disclosure
Code viết bởi Claude (Claude Code), bổ sung gói trả phí cho LUMINA AI (đã có ở PR #1).
Generated by Claude Code