#!/usr/bin/env python3 """ Weekly Knowledge Base Review Runs every Sunday at 22:00 Compares git commits of the past week against knowledge/ directory. If no new knowledge was added, alert Wang Bing via Feishu. """ import subprocess from datetime import datetime, timedelta APP_ID = "cli_a92569ec8b7bdcd1" APP_SECRET = "VV5RJy8aotspOjRUkapqrhGfW0GomUi6" USER_OPEN_ID = "ou_f442e20fd980363ea486b5a6cd8d2a2f" def get_git_commits_since(days=7): since = (datetime.now() - timedelta(days=days)).strftime("%Y-%m-%d") r = subprocess.run( ["git", "log", f"--since={since}", "--oneline", "--name-only"], capture_output=True, text=True ) return r.stdout def main(): log = get_git_commits_since(7) lines = log.split("\n") knowledge_changes = [l for l in lines if "knowledge/" in l] if not knowledge_changes: msg = f"[Weekly Review] No new knowledge base entries this week. Consider adding lessons learned." print(msg) # TODO: send Feishu alert when network is available else: print(f"Knowledge updates found: {knowledge_changes}") if __name__ == "__main__": main()