Implement project templates for file generation

This commit is contained in:
2026-03-23 08:55:48 -03:00
parent 88a474a78d
commit 40a33d773b

View File

@@ -1 +1,153 @@
"""Templates package."""
"""Templates package for generating project files."""
from datetime import datetime
from typing import Optional
from tracker.models import Project
def get_readme_template(project: Optional[Project] = None) -> str:
"""Get the README.md template for a project.
Args:
project: Optional project instance for personalization.
Returns:
README.md template string.
"""
name = project.name if project else "Project Name"
description = project.description if project else "_No description_"
status = project.status if project else "inbox"
return f"""# {name}
{description}
## Objective
_TODO: Define objective_
## Status
**Current Status:** {status}
<!-- AUTOGEN:STATUS_START -->
Status: {status}
<!-- AUTOGEN:STATUS_END -->
## Context
_Current context and background_
## Stack / Tools
- _Tool 1_
- _Tool 2_
## Architecture
_Brief architecture description_
## Technical Decisions
_No decisions recorded yet_
## Risks / Blockers
_No blockers_
<!-- AUTOGEN:NEXT_STEPS_START -->
<!-- AUTOGEN:NEXT_STEPS_END -->
## Recent Sessions
<!-- AUTOGEN:SESSIONS_START -->
<!-- AUTOGEN:SESSIONS_END -->
_Last updated: {datetime.now().strftime('%Y-%m-%d')}_
"""
def get_log_template() -> str:
"""Get the LOG.md template.
Returns:
LOG.md template string.
"""
return """# Log
_Project activity log_
"""
def get_changelog_template() -> str:
"""Get the CHANGELOG.md template.
Returns:
CHANGELOG.md template string.
"""
return """# Changelog
_Project changes_
"""
def get_tasks_template() -> str:
"""Get the TASKS.md template.
Returns:
TASKS.md template string.
"""
return """# Tasks
## Inbox
-
## Next
-
## In Progress
-
## Blocked
-
## Waiting
-
## Done
-
"""
def get_meta_template(project: Project) -> dict:
"""Get the meta/project.yaml template data.
Args:
project: Project instance.
Returns:
Dictionary suitable for YAML serialization.
"""
return {
"id": project.id,
"name": project.name,
"slug": project.slug,
"description": project.description,
"type": project.type,
"status": project.status,
"tags": project.tags,
"root_path": str(project.root_path),
"repo_path": str(project.repo_path) if project.repo_path else None,
"created_at": project.created_at.isoformat(),
"updated_at": project.updated_at.isoformat(),
"last_session_at": None,
}