feat: todo API server, daily brief gen, extract todos, balance checker

- Todo API server (:9001) with CRUD + priority support
- Daily brief aggregator (trading + inspiration)
- Todo extraction from inspiration digest markdown
- DeepSeek balance checker for nav page
This commit is contained in:
Beast
2026-06-14 13:06:35 +08:00
parent 901efb872e
commit 745ce62322
4 changed files with 344 additions and 0 deletions

View File

@ -0,0 +1,64 @@
import sys, os
sys.path.insert(0, '/home/ubuntu/inspiration-collector')
from tools.config import load_secrets, get_output_dir
from tools.llm import DeepSeekClient
from tools.memos_client import MemosClient
from datetime import datetime, timezone, timedelta
import subprocess
secrets = load_secrets()
mc = MemosClient(secrets.get('memos_url','http://localhost:5230'), secrets['memos_token'])
llm = DeepSeekClient(secrets['deepseek_api_key'], secrets.get('deepseek_model','deepseek-chat'), temperature=0.5)
TZ_BJ = timezone(timedelta(hours=8))
PROJ = '/home/ubuntu/inspiration-collector'
memos = mc.list_memos(days=2)
lines = []
for m in memos:
ct = m['created_at']
try:
dt = datetime.fromisoformat(ct.replace('Z','+00:00')) + timedelta(hours=8)
ts = dt.strftime('%m/%d %H:%M')
except:
ts = ct[:16]
lines.append('- **[' + ts + ']** ' + m['content'].strip())
text = '\n\n'.join(lines)
sp = '''将以下在浙江两天的学习记录,整理成一篇客观记述文章。
要求:
1. 以第三人称或客观视角写作,不使用"""我们"等第一人称
2. 按时间线组织6月13日浙大章丰/科大讯飞/系统搭建)→ 6月14日浙大厉敏
3. 如实记录事实:时间、地点、人物、课程内容、关键观点
4. 对关键概念补充简要背景信息如王坚理论、Sora、奇点临近等
5. 文风克制、客观,不抒情不评价,这是给自己看的记录
6. 篇幅约3000字开头写一句摘要+结构指引
7. 结尾可做简要总结
输出纯Markdown。'''
prompt = '以下是在浙江两天的完整灵感记录:\n\n' + text
result = llm.ask(system_prompt=sp, user_prompt=prompt)
cc = len(result.replace(' ','').replace('\n',''))
rm = max(1, round(cc/300))
content = '---\ndate: 2026-06-14\ntype: zhejiang-records\ntags: [浙江, 学习记录]\n---\n\n'
content += '> 本文共 **' + str(cc) + '** 字 · 预计阅读 **' + str(rm) + '** 分钟\n\n'
content += result
daily_dir = os.path.join(get_output_dir('daily'), '2026-06-14')
os.makedirs(daily_dir, exist_ok=True)
now_str = datetime.now(TZ_BJ).strftime('%H%M%S')
fname = '浙江两日记_' + now_str + '.md'
fpath = os.path.join(daily_dir, fname)
with open(fpath, 'w') as f:
f.write(content)
print('Done: ' + fpath + ' (' + str(cc) + ' chars)')
subprocess.run(['git','add',fpath], cwd=PROJ, capture_output=True, timeout=15)
subprocess.run(['git','commit','-m','zhejiang 2 days objective ' + now_str], cwd=PROJ, capture_output=True, timeout=15)
subprocess.run(['git','push','origin','main'], cwd=PROJ, capture_output=True, timeout=30)
print('Pushed')