godspeed app sync

This commit is contained in:
Tim Bendt
2025-08-20 08:30:54 -04:00
parent ca6e4cdf5d
commit c46d53b261
17 changed files with 3170 additions and 45 deletions

103
demo_completion_sync.py Normal file
View File

@@ -0,0 +1,103 @@
#!/usr/bin/env python3
"""
Demo script showing how Godspeed completion status sync works.
This creates sample markdown files and shows the sync behavior.
"""
import tempfile
from pathlib import Path
def demo_completion_sync():
print("=== Godspeed Completion Status Sync Demo ===\n")
from src.services.godspeed.sync import GodspeedSync
with tempfile.TemporaryDirectory() as temp_dir:
sync_dir = Path(temp_dir)
sync_engine = GodspeedSync(None, sync_dir)
print("1. Creating sample markdown file with mixed completion states:")
print("-" * 60)
# Create sample tasks
sample_tasks = [
("task001", False, "Buy groceries", "Don't forget milk"),
("task002", True, "Call dentist", ""),
("task003", False, "Finish project", "Due next Friday"),
("task004", True, "Exercise today", "Went for a 30min run"),
]
# Write to markdown file
demo_file = sync_dir / "Personal.md"
sync_engine._write_list_file(demo_file, sample_tasks)
# Show the generated markdown
with open(demo_file, "r") as f:
content = f.read()
print(content)
print("-" * 60)
print("\n2. What this represents in Godspeed:")
for task_id, is_complete, title, notes in sample_tasks:
status = "✅ COMPLETED" if is_complete else "⏳ INCOMPLETE"
print(f" {status}: {title}")
if notes:
print(f" Notes: {notes}")
print("\n3. Now let's modify the markdown file (simulate user editing):")
print("-" * 60)
# Simulate user changes - flip some completion states
modified_content = content.replace(
"- [ ] Buy groceries",
"- [x] Buy groceries", # Mark as complete
).replace(
"- [x] Call dentist",
"- [ ] Call dentist", # Mark as incomplete
)
# Add a new task
modified_content += "- [ ] New task from markdown <!-- id:task005 -->\n"
print(modified_content)
print("-" * 60)
# Write the modified content
with open(demo_file, "w") as f:
f.write(modified_content)
# Parse the changes
updated_tasks = sync_engine._read_list_file(demo_file)
print("\n4. Changes that would sync to Godspeed:")
print("-" * 40)
for i, (task_id, is_complete, title, notes) in enumerate(updated_tasks):
if i < len(sample_tasks):
old_complete = sample_tasks[i][1]
if old_complete != is_complete:
action = "MARK COMPLETE" if is_complete else "MARK INCOMPLETE"
print(f" 🔄 {action}: {title}")
else:
status = "" if is_complete else ""
print(f" {status} No change: {title}")
else:
print(f" CREATE NEW: {title}")
print("\n5. API calls that would be made:")
print("-" * 35)
print(" PATCH /tasks/task001 {'is_complete': True}")
print(" PATCH /tasks/task002 {'is_complete': False}")
print(" POST /tasks {'title': 'New task from markdown'}")
print("\n✨ Summary:")
print(" • Checking [x] or [X] in markdown marks task complete in Godspeed")
print(" • Unchecking [ ] in markdown marks task incomplete in Godspeed")
print(" • Adding new tasks in markdown creates them in Godspeed")
print(" • Changes sync both directions during 'godspeed sync'")
if __name__ == "__main__":
demo_completion_sync()