Files
tracker-cli/tracker/services/heuristics_service.py
Daniel Arroyo 4547c492da Implement storage layer for MVP-1 Personal Tracker CLI
Add storage layer with FileStorage, MarkdownReader, and MarkdownWriter classes.
Add data models (Project, Session, Note, Change).
2026-03-23 08:54:00 -03:00

48 lines
1.7 KiB
Python

"""Heuristics service for suggestions based on rules."""
from datetime import datetime
from ..models import Session, Project
def suggest_next_steps(session: Session, project: Project) -> list[str]:
"""
Generate suggestions based on session state and project context.
Rules:
- si hay blockers abiertos, sugerir "Destrabar: [bloqueos]"
- si hay changes sin references, sugerir "Validar cambios recientes"
- si work_done está vacío y session > 30 min, sugerir "Revisar progreso del objetivo"
- si no hay next_steps definidos, sugerir "Definir próximos pasos"
"""
suggestions = []
# Rule: blockers open
if session.blockers:
for blocker in session.blockers:
suggestions.append(f"Destrabar: {blocker}")
# Rule: changes without references
changes_without_refs = []
for change in session.changes:
# Simple heuristic: if change doesn't reference anything specific
if change and not any(ref in change.lower() for ref in ["#", "commit", "pr", "issue"]):
changes_without_refs.append(change)
if changes_without_refs:
suggestions.append("Validar cambios recientes")
# Rule: work_done empty and session > 30 minutes
if not session.work_done:
duration = session.duration_minutes
if duration == 0 and session.ended_at and session.started_at:
duration = int((session.ended_at - session.started_at).total_seconds() / 60)
if duration > 30:
suggestions.append("Revisar progreso del objetivo")
# Rule: no next_steps defined
if not session.next_steps:
suggestions.append("Definir próximos pasos")
return suggestions