整理:灵感日报按年/月/日分层归档 + 生成脚本同步更新

This commit is contained in:
Beast
2026-06-24 00:23:09 +08:00
parent 6859c3d7ba
commit 26202b5529
70 changed files with 14 additions and 13 deletions

View File

@ -36,7 +36,8 @@ def read_previous_digest(date):
daily_root = get_output_dir("daily")
for days_back in range(1, 8):
prev_date = date - timedelta(days=days_back)
prev_dir = os.path.join(daily_root, prev_date.strftime("%Y-%m-%d"))
pd = prev_date.strftime("%Y-%m-%d").split("-")
prev_dir = os.path.join(daily_root, pd[0], pd[1], pd[2])
if not os.path.isdir(prev_dir):
continue
files = sorted([f for f in os.listdir(prev_dir) if f.endswith(".md")], reverse=True)
@ -235,7 +236,8 @@ def run(memos_client, llm_client, date=None):
logger.info("No memos today, skipping")
content = format_daily_digest(date, ai_body="今天没有记录灵感。", tags=["灵感收集器", "每日总结", "静默"], doc_type="daily-digest")
date_str = date.strftime("%Y-%m-%d")
daily_dir = os.path.join(get_output_dir("daily"), date_str)
parts = date_str.split("-")
daily_dir = os.path.join(get_output_dir("daily"), parts[0], parts[1], parts[2])
os.makedirs(daily_dir, exist_ok=True)
now_str = datetime.now(TZ_BEIJING).strftime("%H%M%S")
filename = date_str + "_digest_" + now_str + ".md"
@ -269,7 +271,8 @@ def run(memos_client, llm_client, date=None):
prev_tags_line = None
# Extract tags from previous digest frontmatter
daily_root = get_output_dir("daily")
prev_dir = os.path.join(daily_root, prev_date.strftime("%Y-%m-%d"))
pd = prev_date.strftime("%Y-%m-%d").split("-")
prev_dir = os.path.join(daily_root, pd[0], pd[1], pd[2])
if os.path.isdir(prev_dir):
prev_files = sorted([f for f in os.listdir(prev_dir) if f.endswith(".md")], reverse=True)
if prev_files:
@ -328,7 +331,8 @@ def run(memos_client, llm_client, date=None):
)
date_str = date.strftime("%Y-%m-%d")
daily_dir = os.path.join(get_output_dir("daily"), date_str)
parts = date_str.split("-")
daily_dir = os.path.join(get_output_dir("daily"), parts[0], parts[1], parts[2])
os.makedirs(daily_dir, exist_ok=True)
now_str = datetime.now(TZ_BEIJING).strftime("%H%M%S")
filename = date_str + "_digest_" + now_str + ".md"

View File

@ -14,20 +14,17 @@ echo "[$(date '+%Y-%m-%d %H:%M:%S')] Starting daily digest..." >> "$LOG_FILE"
cd "$PROJECT_DIR"
python3 analyzers/daily_digest.py >> "$LOG_FILE" 2>&1
# Git push to Gitea
# Git sync: pull rebase first, then always push
cd "$PROJECT_DIR"
git pull --rebase origin main >> "$LOG_FILE" 2>&1 || echo "WARNING: rebase failed, continuing..." >> "$LOG_FILE"
# 先拉取远程,避免分支分歧
git pull --rebase origin main >> "$LOG_FILE" 2>&1 || true
# Check if there are changes
# Check if anything to commit
if [[ -n $(git status --porcelain ai-insights/) ]]; then
git add ai-insights/
git commit -m "daily digest $(date '+%Y-%m-%d')"
git push origin main 2>&1 >> "$LOG_FILE"
echo "Pushed to Gitea" >> "$LOG_FILE"
else
echo "No changes to push" >> "$LOG_FILE"
fi
# Always push (covers both new commits and rebased pending commits)
git push origin main >> "$LOG_FILE" 2>&1 && echo "Pushed to Gitea successfully" >> "$LOG_FILE" || echo "WARNING: push failed" >> "$LOG_FILE"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Daily digest done." >> "$LOG_FILE"