This commit is contained in:
2026-03-13 21:53:38 -03:00
commit e001b458f9
16 changed files with 813 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
package main
import (
"fmt"
"log"
"os"
"github.com/joho/godotenv"
"mindforge.cronjob/internal/agent"
"mindforge.cronjob/internal/git"
"mindforge.cronjob/internal/message"
)
func main() {
// Read "GIT_REPOSITORY" environment variable
if err := godotenv.Load(); err != nil {
log.Println("WARNING: No .env file found or error loading it")
}
gitRepo := os.Getenv("GIT_REPOSITORY")
if gitRepo == "" {
log.Println("WARNING: GIT_REPOSITORY environment variable is not set")
} else {
fmt.Printf("Starting Mindforge.Cronjob for repo: %s\n", gitRepo)
}
// Initialize services
gitService := git.NewGitService()
// Get modifications
var modifications map[string]string
error := gitService.FetchContents(gitRepo)
if error != nil {
log.Println("ERROR: Failed to fetch contents:", error)
}
modifications, error = gitService.GetModifications(1)
if error != nil {
log.Println("ERROR: Failed to get modifications:", error)
}
fmt.Printf("Found %d modifications\n", len(modifications))
for file, content := range modifications {
fmt.Printf("File: %s\n", file)
raw_summary, err := agent.SummaryCreatorAgent(file, content)
if err != nil {
log.Println("ERROR: Failed to create summary:", err)
continue
}
md_summary, err := agent.SummaryFormatterAgent(raw_summary)
if err != nil {
log.Println("ERROR: Failed to create markdown summary:", err)
continue
}
fmt.Printf("Summary: %s\n", md_summary)
err = message.SendDiscordNotification(file, md_summary)
if err != nil {
log.Println("ERROR: Failed to send Discord notification:", err)
}
}
}