@@ -128,15 +128,20 @@ func (e *Engine) persistJournalEntry(journalEntry string, day string) {
128128
129129 journalPath := filepath .Join (e .repoPath , "docs/JOURNAL.md" )
130130 _ = os .MkdirAll (filepath .Dir (journalPath ), 0o755 )
131- journal , _ := os .ReadFile (journalPath )
131+ journal , err := os .ReadFile (journalPath )
132+ if err != nil && ! os .IsNotExist (err ) {
133+ e .logger .Warn ("failed to read JOURNAL.md, will overwrite" , "err" , err )
134+ }
132135
133136 header := "# iterate Evolution Journal\n "
134137 if ! strings .HasPrefix (string (journal ), header ) {
135138 journal = []byte (header )
136139 }
137140 rest := strings .TrimPrefix (strings .TrimPrefix (string (journal ), header ), "\n " )
138141 newContent := header + "\n " + extracted + "\n \n " + rest
139- _ = os .WriteFile (journalPath , []byte (newContent ), 0o644 )
142+ if err := os .WriteFile (journalPath , []byte (newContent ), 0o644 ); err != nil {
143+ e .logger .Warn ("failed to write JOURNAL.md" , "err" , err )
144+ }
140145}
141146
142147// issueAlreadyCommented checks if the bot already commented on an issue today.
@@ -154,17 +159,24 @@ func (e *Engine) issueAlreadyCommented(ctx context.Context, issueNum int, day st
154159
155160// postIssueComments posts GitHub comments for addressed issues.
156161func (e * Engine ) postIssueComments (ctx context.Context , p iteragent.Provider , tools []iteragent.Tool , systemPrompt string , skills * iteragent.SkillSet , plan string ) {
162+ day := e .readDayCount ()
157163 responses := parseIssueResponses (plan )
158164 for _ , resp := range responses {
165+ if e .issueAlreadyCommented (ctx , resp .IssueNum , day ) {
166+ e .logger .Info ("skipping already-commented issue" , "issue" , resp .IssueNum , "day" , day )
167+ continue
168+ }
159169 body := fmt .Sprintf ("Status: %s\n Reason: %s" , resp .Status , resp .Reason )
160170 userMsg := fmt .Sprintf (`Post a GitHub issue comment on issue #%d. Be brief. Sign off with your day count.
161171
162172Body: %s
163173
164174Use: gh issue comment %d --repo %s --body "..."` , resp .IssueNum , body , resp .IssueNum , e .repo )
175+ issueCtx , issueCancel := context .WithTimeout (ctx , 90 * time .Second )
165176 a := e .newAgent (p , tools , systemPrompt , skills )
166- e .forwardEvents (a .Prompt (ctx , userMsg ))
177+ e .forwardEvents (a .Prompt (issueCtx , userMsg ))
167178 a .Finish ()
179+ issueCancel ()
168180 }
169181}
170182
0 commit comments