adding top_n_files
All checks were successful
Mindforge Cronjob Build and Deploy / Build Mindforge Cronjob Image (push) Successful in 1m19s
Mindforge Cronjob Build and Deploy / Deploy Mindforge Cronjob (internal) (push) Successful in 43s

This commit is contained in:
2026-03-20 21:25:19 -03:00
parent 510abaa358
commit afff091457
4 changed files with 81 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"strconv"
"github.com/joho/godotenv"
"mindforge.cronjob/internal/agent"
@@ -27,6 +28,14 @@ func main() {
// Initialize services
gitService := git.NewGitService()
// Resolve how many top files to return (TOP_N_FILES env var, default 10)
topN := 10
if v := os.Getenv("TOP_N_FILES"); v != "" {
if n, err := strconv.Atoi(v); err == nil && n > 0 {
topN = n
}
}
// Get modifications
var modifications map[string]string
error := gitService.FetchContents(gitRepo)
@@ -34,7 +43,15 @@ func main() {
log.Println("ERROR: Failed to fetch contents:", error)
}
modifications, error = gitService.GetModifications(7)
// Resolve how many days to look back (LAST_N_DAYS env var, default 7)
days := 7
if v := os.Getenv("LAST_N_DAYS"); v != "" {
if n, err := strconv.Atoi(v); err == nil && n > 0 {
days = n
}
}
modifications, error = gitService.GetModifications(days, topN)
if error != nil {
log.Println("ERROR: Failed to get modifications:", error)
}
@@ -42,7 +59,7 @@ func main() {
fmt.Printf("Found %d modifications\n", len(modifications))
for file, content := range modifications {
fmt.Printf("File: %s\n", file)
fmt.Printf("Processing file: %s\n", file)
raw_summary, err := agent.SummaryCreatorAgent(file, content)
if err != nil {