Initial commit: Linear-integrated autonomous coding agent with Initializer Bis support

This commit is contained in:
2025-12-14 00:45:40 +01:00
commit a310d4b3cf
19 changed files with 3919 additions and 0 deletions

86
progress.py Normal file
View File

@@ -0,0 +1,86 @@
"""
Progress Tracking Utilities
===========================
Functions for tracking and displaying progress of the autonomous coding agent.
Progress is tracked via Linear issues, with local state cached in .linear_project.json.
"""
import json
from pathlib import Path
from linear_config import LINEAR_PROJECT_MARKER
def load_linear_project_state(project_dir: Path) -> dict | None:
"""
Load the Linear project state from the marker file.
Args:
project_dir: Directory containing .linear_project.json
Returns:
Project state dict or None if not initialized
"""
marker_file = project_dir / LINEAR_PROJECT_MARKER
if not marker_file.exists():
return None
try:
with open(marker_file, "r") as f:
return json.load(f)
except (json.JSONDecodeError, IOError):
return None
def is_linear_initialized(project_dir: Path) -> bool:
"""
Check if Linear project has been initialized.
Args:
project_dir: Directory to check
Returns:
True if .linear_project.json exists and is valid
"""
state = load_linear_project_state(project_dir)
return state is not None and state.get("initialized", False)
def print_session_header(session_num: int, is_initializer: bool, is_initializer_bis: bool = False) -> None:
"""Print a formatted header for the session."""
if is_initializer_bis:
session_type = "INITIALIZER BIS"
elif is_initializer:
session_type = "INITIALIZER"
else:
session_type = "CODING AGENT"
print("\n" + "=" * 70)
print(f" SESSION {session_num}: {session_type}")
print("=" * 70)
print()
def print_progress_summary(project_dir: Path) -> None:
"""
Print a summary of current progress.
Since actual progress is tracked in Linear, this reads the local
state file for cached information. The agent updates Linear directly
and reports progress in session comments.
"""
state = load_linear_project_state(project_dir)
if state is None:
print("\nProgress: Linear project not yet initialized")
return
total = state.get("total_issues", 0)
meta_issue = state.get("meta_issue_id", "unknown")
print(f"\nLinear Project Status:")
print(f" Total issues created: {total}")
print(f" META issue ID: {meta_issue}")
print(f" (Check Linear for current Done/In Progress/Todo counts)")