mirror of
https://github.com/tradecatlabs/vibe-coding-cn.git
synced 2026-08-19 22:08:05 +00:00
feat: Add new files for i18n, libs, and project structure
This commit is contained in:
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import glob
|
||||
import json
|
||||
from .base import BaseParser, SessionData
|
||||
|
||||
class GeminiParser(BaseParser):
|
||||
def find_files(self, paths: list) -> list:
|
||||
files = []
|
||||
for base in paths:
|
||||
if os.path.exists(base):
|
||||
files.extend(glob.glob(os.path.join(base, "*", "chats", "*.json")))
|
||||
return files
|
||||
|
||||
def parse_file(self, filepath: str) -> SessionData:
|
||||
s = SessionData(
|
||||
session_id=os.path.basename(filepath).replace('.json', ''),
|
||||
source='gemini',
|
||||
file_path=filepath,
|
||||
file_mtime=os.path.getmtime(filepath)
|
||||
)
|
||||
|
||||
with open(filepath, 'r', encoding='utf-8') as f:
|
||||
data = json.load(f)
|
||||
|
||||
s.session_id = data.get('sessionId', s.session_id)
|
||||
|
||||
for msg in data.get('messages', []):
|
||||
if msg.get('type') not in ('user', 'gemini'):
|
||||
continue
|
||||
content = msg.get('content', '')
|
||||
if content:
|
||||
s.messages.append({
|
||||
'time': msg.get('timestamp', ''),
|
||||
'role': 'user' if msg.get('type') == 'user' else 'ai',
|
||||
'content': content
|
||||
})
|
||||
|
||||
return s
|
||||
Reference in New Issue
Block a user