diff --git a/markitect/document_manager.py b/markitect/document_manager.py index 40626078..1d56de9e 100644 --- a/markitect/document_manager.py +++ b/markitect/document_manager.py @@ -617,9 +617,82 @@ class DocumentManager: # Edit mode status and error reporting section edit_mode_html = "" if edit_mode: + # Get version info for header + try: + import markitect + from pathlib import Path + import subprocess + + # Get base version + version = "0.3.0" # fallback + try: + from importlib.metadata import version as get_version + version = get_version('markitect') + except: + pass + + # Get git commit with timestamp and local changes info + git_info = "" + try: + repo_path = Path(__file__).parent.parent + + # Get commit hash and timestamp + result = subprocess.run(['git', 'rev-parse', '--short', 'HEAD'], + capture_output=True, text=True, cwd=repo_path) + if result.returncode == 0: + commit_hash = result.stdout.strip() + + # Get commit timestamp + timestamp_result = subprocess.run(['git', 'show', '-s', '--format=%ci', 'HEAD'], + capture_output=True, text=True, cwd=repo_path) + commit_time = "" + if timestamp_result.returncode == 0: + from datetime import datetime + # Parse git timestamp and format it nicely + git_time = timestamp_result.stdout.strip() + try: + dt = datetime.fromisoformat(git_time.replace(' +', '+')) + commit_time = f" ({dt.strftime('%Y-%m-%d %H:%M')})" + except: + pass + + git_info = f"+{commit_hash}{commit_time}" + + # Check for uncommitted changes + status_result = subprocess.run(['git', 'status', '--porcelain'], + capture_output=True, text=True, cwd=repo_path) + if status_result.returncode == 0 and status_result.stdout.strip(): + # Get timestamp of most recent uncommitted change + import os + import glob + + latest_change = 0 + for line in status_result.stdout.strip().split('\n'): + if line.strip(): + # Extract filename (skip first 3 chars which are status indicators) + filename = line[3:].strip() + try: + file_path = repo_path / filename + if file_path.exists(): + mtime = os.path.getmtime(file_path) + latest_change = max(latest_change, mtime) + except: + pass + + if latest_change > 0: + change_dt = datetime.fromtimestamp(latest_change) + git_info += f" including local changes until {change_dt.strftime('%Y-%m-%d %H:%M')}" + + except: + pass + + version_info = f"{version}{git_info}" + except: + version_info = "0.3.0" + edit_mode_html = f"""
-
📝 Markitect Edit Mode
+
📝 Markitect Edit Mode v{version_info}
Loading edit capabilities...