import json, re with open('/home/hoon/kis_bot/.cursor_chat/d8d6e45a-37b6-463f-8e19-b57bbce698af/d8d6e45a-37b6-463f-8e19-b57bbce698af.jsonl') as f: lines = f.readlines() # timestamp 파싱: Wednesday, Sep 2, 2026, 5:30 PM (UTC+9) # 17:30 이후 = 5:30 PM 이후 TS_PATTERN = re.compile(r'(.*?)') # Sep 2, 2026 이고 시간 >= 5:30 PM 인 메시지 추출 def parse_hour(ts_str): """Sep 2, 2026, 5:30 PM → (date_str, hour_24)""" m = re.search(r'(\w+ \d+, \d+), (\d+:\d+) (AM|PM)', ts_str) if not m: return None, None date_str = m.group(1) # e.g. "Sep 2, 2026" time_str = m.group(2) # e.g. "5:30" ampm = m.group(3) h, mi = map(int, time_str.split(':')) if ampm == 'PM' and h != 12: h += 12 elif ampm == 'AM' and h == 12: h = 0 return date_str, h * 60 + mi TARGET_DATE = "Sep 2, 2026" CUTOFF_MIN = 17 * 60 + 30 # 17:30 results = [] current_ts = None current_ts_min = None current_date = None for i, line in enumerate(lines): obj = json.loads(line) role = obj.get('role', '?') msg = obj.get('message', '') # 메시지 텍스트 추출 raw_text = '' if isinstance(msg, dict): content = msg.get('content', []) if isinstance(content, list): for c in content: if isinstance(c, dict) and c.get('type') == 'text': raw_text += c.get('text', '') elif isinstance(content, str): raw_text = content elif isinstance(msg, str): raw_text = msg # timestamp 찾기 ts_match = TS_PATTERN.search(raw_text) if ts_match: ts_str = ts_match.group(1) date_str, ts_min = parse_hour(ts_str) if date_str: current_ts = ts_str current_ts_min = ts_min current_date = date_str # Sep 2, 2026 && >= 17:30 인 경우만 수집 if current_date == TARGET_DATE and current_ts_min is not None and current_ts_min >= CUTOFF_MIN: # 텍스트에서 timestamp 제거하고 user_query/assistant 내용만 추출 clean = re.sub(r'.*?', '', raw_text) clean = re.sub(r'|', '', clean).strip() results.append((i, role, current_ts, clean[:800])) print(f'=== 2026-09-02 17:30 이후 메시지: {len(results)}개 ===\n') for idx, (line_no, role, ts, text) in enumerate(results): print(f'--- [{line_no}] {role.upper()} | {ts} ---') print(text[:600]) print()