Skip to content

feat: integrate templates into AI workflow and enforce strict JSON schemas #66

@thomas-vilte

Description

@thomas-vilte

Context

The AI generation workflow currently lacks awareness of project-specific Issue and Pull Request templates, resulting in content that may not align with project standards. Additionally, the parsing of AI responses has proven fragile, necessitating strict JSON schema enforcement to prevent formatting errors and ensure reliable output parsing.

Technical Details

  • Integrated IssueTemplateService into PRService and IssueGeneratorService to support auto-detection and usage of templates.
  • Refactored AI prompts in internal/ai/prompts.go to include strict JSON schemas, type rules, and prohibited actions.
  • Implemented logic to format and inject template instructions dynamically into AI prompts via FormatTemplateForPrompt.
  • Added support for discovering and loading PR templates from .github/PULL_REQUEST_TEMPLATE.
  • Updated dependency injection in cmd/main.go to wire the template service correctly.
  • Added extensive unit tests covering prompt rendering, template integration, and service logic.

Impact

  • Standardization: AI-generated content now automatically adheres to the structure defined in project templates.
  • Reliability: Strict JSON enforcement eliminates parsing failures caused by malformed AI responses.
  • Efficiency: Reduces manual editing time by producing compliant content straight from the generation step.

Related PR: #64

Metadata

Metadata

Assignees

Labels

enhancementImprovement or extension of an existing functionalityfeatureNew featuresinfraInfrastructure and DevOpsrefactorCode restructuring or cleaning without functional changestestTesting, trials, and coverage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions