Add Task Manager scripts (Moltbot port)
This commit is contained in:
55
scripts/finish_task.py
Normal file
55
scripts/finish_task.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import clawd_notion as notion
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
from datetime import datetime
|
||||
|
||||
SESSION_FILE = ".dev_session/SESSION_INFO"
|
||||
|
||||
def main():
|
||||
if not os.path.exists(SESSION_FILE):
|
||||
print("Keine aktive Session.")
|
||||
return
|
||||
|
||||
# Parse args manually strictly for summary
|
||||
# Usage: python finish_task.py "My Summary"
|
||||
summary = sys.argv[1] if len(sys.argv) > 1 else "Update"
|
||||
|
||||
with open(SESSION_FILE) as f:
|
||||
session = json.load(f)
|
||||
|
||||
task_id = session["task_id"]
|
||||
|
||||
# 1. Update Notion
|
||||
# Calculate time
|
||||
start = datetime.fromisoformat(session["start_time"])
|
||||
hours = (datetime.now() - start).total_seconds() / 3600
|
||||
|
||||
# Get current duration
|
||||
# (Skipping read for now, just appending blocks)
|
||||
|
||||
blocks = [
|
||||
{
|
||||
"object": "block",
|
||||
"type": "heading_2",
|
||||
"heading_2": {"rich_text": [{"text": {"content": f"Update {datetime.now().strftime('%Y-%m-%d %H:%M')}"}}]}
|
||||
},
|
||||
{
|
||||
"object": "block",
|
||||
"type": "paragraph",
|
||||
"paragraph": {"rich_text": [{"text": {"content": f"Time invested: {hours:.2f}h\n\n{summary}"}}]}
|
||||
}
|
||||
]
|
||||
notion.append_blocks(task_id, blocks)
|
||||
|
||||
# 2. Git Commit
|
||||
subprocess.run(["git", "add", "."])
|
||||
subprocess.run(["git", "commit", "-m", f"[{task_id[:4]}] {summary}"])
|
||||
|
||||
# Cleanup
|
||||
os.remove(SESSION_FILE)
|
||||
print("Session beendet, Notion geupdated, Commited.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user