[2f388f42] Feature: Dynamically load Readme paths from Notion projects, update tasks and Notion_Dashboard. Refactor dev_session.py and remove old strategy documents.
This commit is contained in:
@@ -2,7 +2,7 @@ import os
|
||||
import requests
|
||||
import json
|
||||
import re
|
||||
from typing import List, Dict, Optional
|
||||
from typing import List, Dict, Optional, Tuple
|
||||
from getpass import getpass
|
||||
|
||||
# --- API Helper Functions ---
|
||||
@@ -80,6 +80,20 @@ def get_page_title(page: Dict) -> str:
|
||||
return title_parts[0].get("plain_text", "Unbenannt")
|
||||
return "Unbenannt"
|
||||
|
||||
def get_page_property(page: Dict, prop_name: str, prop_type: str = "rich_text") -> Optional[str]:
|
||||
"""Extrahiert den Inhalt einer bestimmten Eigenschaft (Property) von einer Seite."""
|
||||
prop = page.get("properties", {}).get(prop_name)
|
||||
if not prop:
|
||||
return None
|
||||
|
||||
if prop_type == "rich_text" and prop.get("type") == "rich_text":
|
||||
text_parts = prop.get("rich_text", [])
|
||||
if text_parts:
|
||||
return text_parts[0].get("plain_text")
|
||||
|
||||
# Hier könnten weitere Typen wie 'select', 'number' etc. behandelt werden
|
||||
return None
|
||||
|
||||
def get_database_status_options(token: str, db_id: str) -> List[str]:
|
||||
"""Ruft die verfügbaren Status-Optionen für eine Datenbank-Eigenschaft ab."""
|
||||
url = f"https://api.notion.com/v1/databases/{db_id}"
|
||||
@@ -182,18 +196,18 @@ def create_new_notion_task(token: str, project_id: str, tasks_db_id: str) -> Opt
|
||||
|
||||
# --- UI Functions ---
|
||||
|
||||
def select_project(token: str) -> Optional[Dict]:
|
||||
def select_project(token: str) -> Optional[Tuple[Dict, Optional[str]]]:
|
||||
"""Zeigt eine Liste der Projekte an und lässt den Benutzer eines auswählen."""
|
||||
print("--- Lade Projekte aus Notion... ---")
|
||||
|
||||
projects_db_id = find_database_by_title(token, "Projects [UT]")
|
||||
if not projects_db_id:
|
||||
return None
|
||||
return None, None
|
||||
|
||||
projects = query_notion_database(token, projects_db_id)
|
||||
if not projects:
|
||||
print("Keine Projekte in der Datenbank gefunden.")
|
||||
return None
|
||||
return None, None
|
||||
|
||||
print("\nAn welchem Projekt möchtest du arbeiten?")
|
||||
for i, project in enumerate(projects):
|
||||
@@ -203,7 +217,9 @@ def select_project(token: str) -> Optional[Dict]:
|
||||
try:
|
||||
choice = int(input("Bitte wähle eine Nummer: "))
|
||||
if 1 <= choice <= len(projects):
|
||||
return projects[choice - 1]
|
||||
selected_project = projects[choice - 1]
|
||||
readme_path = get_page_property(selected_project, "Readme Path")
|
||||
return selected_project, readme_path
|
||||
else:
|
||||
print("Ungültige Auswahl.")
|
||||
except ValueError:
|
||||
@@ -242,25 +258,13 @@ def select_task(token: str, project_id: str, tasks_db_id: str) -> Optional[Dict]
|
||||
|
||||
# --- Context Generation ---
|
||||
|
||||
def generate_cli_context(project_title: str, task_title: str, task_id: str, suggested_branch_name: str) -> str:
|
||||
def generate_cli_context(project_title: str, task_title: str, task_id: str, suggested_branch_name: str, readme_path: Optional[str]) -> str:
|
||||
"""Erstellt einen formatierten Kontext-String für die Gemini CLI."""
|
||||
|
||||
project_to_path_map = {
|
||||
"Company Explorer": "company-explorer/backend/",
|
||||
"B2B Assistant": "b2b-marketing-assistant/",
|
||||
"GTM Tool": "gtm-architect/",
|
||||
"Market Intelligence": "general-market-intelligence/",
|
||||
"Competitor Analysis": "competitor-analysis-app/",
|
||||
"Meeting Assistant": "transcription-tool/",
|
||||
"Sync Engine": "" # Root-Level
|
||||
}
|
||||
|
||||
base_path = "pfad/zum/modul/"
|
||||
for key, path in project_to_path_map.items():
|
||||
if key in project_title:
|
||||
base_path = path
|
||||
break
|
||||
|
||||
# Fallback, falls kein Pfad in Notion gesetzt ist
|
||||
if not readme_path:
|
||||
readme_path = "readme.md"
|
||||
|
||||
context = (
|
||||
"\n------------------------------------------------------------------"
|
||||
"\n✅ Setup abgeschlossen!"
|
||||
@@ -272,8 +276,8 @@ def generate_cli_context(project_title: str, task_title: str, task_id: str, sugg
|
||||
f"\n\nIch arbeite jetzt am Projekt '{project_title}'. Der Fokus liegt auf dem Task '{task_title}'."
|
||||
"\n\nDie relevanten Dateien für dieses Projekt sind wahrscheinlich:"
|
||||
"\n- Die primäre Projektdokumentation: @readme.md"
|
||||
f"\n- Die spezifische Dokumentation für dieses Modul: @{base_path}README.md (falls vorhanden)"
|
||||
f"\n- Der Haupt-Code befindet sich wahrscheinlich in: @{base_path}**"
|
||||
f"\n- Die spezifische Dokumentation für dieses Modul: @{readme_path}"
|
||||
f"\n- Der Haupt-Code befindet sich wahrscheinlich in: @dev_session.py"
|
||||
f"\n\nMein Ziel ist es, den Task '{task_title}' umzusetzen. Alle Commits für diesen Task sollen die Kennung `[{task_id.split('-')[0]}]` enthalten."
|
||||
"\n------------------------------------------------------------------"
|
||||
)
|
||||
@@ -292,7 +296,7 @@ def main():
|
||||
print("Kein Token angegeben. Abbruch.")
|
||||
return
|
||||
|
||||
selected_project = select_project(token)
|
||||
selected_project, readme_path = select_project(token)
|
||||
if not selected_project:
|
||||
return
|
||||
|
||||
@@ -331,7 +335,7 @@ def main():
|
||||
if not status_updated:
|
||||
print("Warnung: Notion-Task-Status konnte nicht aktualisiert werden.")
|
||||
|
||||
cli_context = generate_cli_context(project_title, task_title, task_id, suggested_branch_name)
|
||||
cli_context = generate_cli_context(project_title, task_title, task_id, suggested_branch_name, readme_path)
|
||||
print(cli_context)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user