Skip to content

Commit aead069

Browse files
committed
test message
1 parent bc6a751 commit aead069

10 files changed

Lines changed: 107 additions & 82 deletions

File tree

cmd/iterate/features.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,6 @@ func listGitHubIssues(repoPath string, limit int) (string, error) {
106106
return strings.TrimSpace(out.String()), nil
107107
}
108108

109-
// ---------------------------------------------------------------------------
110-
// lastResponse stores the most recent agent response for /copy and /retry
111-
// ---------------------------------------------------------------------------
112-
113-
var lastResponse string
114-
var lastPrompt string
115-
116109
// ---------------------------------------------------------------------------
117110
// /search-replace — find and replace text across all Go files
118111
// ---------------------------------------------------------------------------

cmd/iterate/repl.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ var (
3535
colorPurple = "\033[38;5;141m"
3636
)
3737

38-
// replRepoPath is the repo path used in the current REPL session (for prompt display).
39-
var replRepoPath string
40-
4138
// replRegistry is the shared command registry (initialized once, reused across calls).
4239
var replRegistry = commands.DefaultRegistry()
4340

@@ -174,7 +171,6 @@ func initREPL(repoPath string, thinking iteragent.ThinkingLevel) iteragent.Think
174171
loadedCfg := loadConfig()
175172
thinking = applyLoadedConfig(loadedCfg, thinking)
176173

177-
replRepoPath = repoPath
178174
selector.RepoPath = repoPath
179175
selector.SafeMode = cfg.SafeMode
180176
return thinking

cmd/iterate/repl_streaming.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ func logTokenDelta(beforeTokens int) {
100100

101101
// streamAndPrint runs the agent and prints the streamed response.
102102
func streamAndPrint(ctx context.Context, a *iteragent.Agent, prompt string, repoPath string) {
103-
lastPrompt = prompt
104103
recordMessage()
105104

106105
reqCtx, cancel := context.WithCancel(ctx)
@@ -128,7 +127,6 @@ func streamAndPrint(ctx context.Context, a *iteragent.Agent, prompt string, repo
128127
stopOnce()
129128

130129
if fullContent != "" {
131-
lastResponse = fullContent
132130
fmt.Print("\r\033[K")
133131
highlight.RenderResponse(fullContent)
134132
fmt.Println()

internal/agent/mutation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func summariseMutationResults(raw string) string {
9393
}
9494

9595
var sb strings.Builder
96-
sb.WriteString(fmt.Sprintf("=== Mutation testing results ===\n"))
96+
sb.WriteString("=== Mutation testing results ===\n")
9797
sb.WriteString(fmt.Sprintf("Total: %d | Killed: %d | Survived: %d\n", total, killed, survived))
9898

9999
if total > 0 {

internal/community/discussions_extended_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package community
22

33
import (
4+
"context"
45
"strings"
56
"testing"
67
)
@@ -106,7 +107,7 @@ func TestIssueTypeConstants(t *testing.T) {
106107

107108
func TestFetchIssues_NoTokenReturnsNil(t *testing.T) {
108109
t.Setenv("GITHUB_TOKEN", "")
109-
result, err := FetchIssues(nil, "owner", "repo", []IssueType{IssueTypeInput}, 10)
110+
result, err := FetchIssues(context.TODO(), "owner", "repo", []IssueType{IssueTypeInput}, 10)
110111
if err != nil {
111112
t.Errorf("expected nil error, got %v", err)
112113
}
@@ -121,7 +122,7 @@ func TestFetchIssues_NoTokenReturnsNil(t *testing.T) {
121122

122123
func TestPostReply_NoTokenError(t *testing.T) {
123124
t.Setenv("GITHUB_TOKEN", "")
124-
err := PostReply(nil, "owner", "repo", 1, "hello")
125+
err := PostReply(context.TODO(), "owner", "repo", 1, "hello")
125126
if err == nil {
126127
t.Fatal("expected error")
127128
}
@@ -136,7 +137,7 @@ func TestPostReply_NoTokenError(t *testing.T) {
136137

137138
func TestCreateDiscussion_NoTokenError(t *testing.T) {
138139
t.Setenv("GITHUB_TOKEN", "")
139-
err := CreateDiscussion(nil, "owner", "repo", "General", "Title", "Body")
140+
err := CreateDiscussion(context.TODO(), "owner", "repo", "General", "Title", "Body")
140141
if err == nil {
141142
t.Fatal("expected error")
142143
}
@@ -151,7 +152,7 @@ func TestCreateDiscussion_NoTokenError(t *testing.T) {
151152

152153
func TestNewGitHubClient_NoToken(t *testing.T) {
153154
t.Setenv("GITHUB_TOKEN", "")
154-
client := NewGitHubClient(nil)
155+
client := NewGitHubClient(context.TODO())
155156
if client != nil {
156157
t.Error("expected nil client when GITHUB_TOKEN is not set")
157158
}

internal/social/engine.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,3 @@ func (e *Engine) postIssueComment(ctx context.Context, number int, body string)
350350
return err
351351
}
352352

353-
func min(a, b int) int {
354-
if a < b {
355-
return a
356-
}
357-
return b
358-
}

internal/social/engine_discussions.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ func parseDiscussionNodes(nodes []discussionNode) []Discussion {
8888
}
8989

9090
func (e *Engine) postDiscussionReply(ctx context.Context, discussionID, body string) error {
91-
mutation := fmt.Sprintf(`{"query":"mutation{addDiscussionComment(input:{discussionId:\"%s\",body:\"%s\"}){comment{id}}}"}`,
92-
discussionID, strings.ReplaceAll(body, `"`, `\"`))
91+
idJSON, _ := json.Marshal(discussionID)
92+
bodyJSON, _ := json.Marshal(body)
93+
mutation := fmt.Sprintf(`{"query":"mutation{addDiscussionComment(input:{discussionId:%s,body:%s}){comment{id}}}"}`,
94+
string(idJSON), string(bodyJSON))
9395

9496
req, err := http.NewRequestWithContext(ctx, "POST", "https://api.github.com/graphql", strings.NewReader(mutation))
9597
if err != nil {
@@ -116,10 +118,12 @@ func (e *Engine) createDiscussion(ctx context.Context, title, body string) error
116118
return err
117119
}
118120

119-
mutation := fmt.Sprintf(`{"query":"mutation{createDiscussion(input:{repositoryId:\"%s\",categoryId:\"%s\",title:\"%s\",body:\"%s\"}){discussion{id}}}"}`,
120-
repoID, categoryID,
121-
strings.ReplaceAll(title, `"`, `\"`),
122-
strings.ReplaceAll(body, `"`, `\"`))
121+
repoIDJSON, _ := json.Marshal(repoID)
122+
catIDJSON, _ := json.Marshal(categoryID)
123+
titleJSON, _ := json.Marshal(title)
124+
bodyJSON, _ := json.Marshal(body)
125+
mutation := fmt.Sprintf(`{"query":"mutation{createDiscussion(input:{repositoryId:%s,categoryId:%s,title:%s,body:%s}){discussion{id}}}"}`,
126+
string(repoIDJSON), string(catIDJSON), string(titleJSON), string(bodyJSON))
123127

124128
return e.doGraphQLPost(ctx, mutation)
125129
}
@@ -190,5 +194,9 @@ func (e *Engine) doGraphQLPost(ctx context.Context, gqlBody string) error {
190194
return err
191195
}
192196
defer resp.Body.Close()
197+
if resp.StatusCode >= 300 {
198+
b, _ := io.ReadAll(resp.Body)
199+
return fmt.Errorf("GraphQL error %d: %s", resp.StatusCode, string(b))
200+
}
193201
return nil
194202
}

internal/social/engine_extended_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package social
22

33
import (
4+
"context"
45
"log/slog"
56
"os"
67
"path/filepath"
@@ -15,7 +16,7 @@ import (
1516
func TestRun_NoToken(t *testing.T) {
1617
e := New(t.TempDir(), "o", "r", slog.Default())
1718
e.token = "" // ensure no token
18-
err := e.Run(nil, nil)
19+
err := e.Run(context.TODO(), nil)
1920
if err != nil {
2021
t.Errorf("expected nil error when token is empty, got %v", err)
2122
}

internal/ui/highlight/highlight.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ import (
99
)
1010

1111
var (
12-
colorGreen = "\033[38;5;114m"
13-
colorAmber = "\033[38;5;221m"
14-
colorBlue = "\033[38;5;75m"
15-
colorPurple = "\033[38;5;141m"
12+
colorGreen = "\033[38;5;114m"
13+
colorAmber = "\033[38;5;221m"
14+
colorBlue = "\033[38;5;75m"
1615
)
1716

1817
// contextWindow is the assumed token context window size used for % calculations.

scripts/evolution/evolve.sh

Lines changed: 82 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,27 @@ if [[ -f "${REPOPATH}/.iterate/ISSUES_TODAY.md" ]] && grep -q "Issue #" "${REPOP
9494
HAS_ISSUES=true
9595
fi
9696

97-
# ── Clean stale plan ──
98-
rm -f "$PLAN_FILE"
97+
PR_STATE_FILE="${REPOPATH}/.iterate/pr_state.json"
9998

100-
# ── Phase 1: Planning ──
101-
log "Phase 1: Planning..."
102-
if ! ./iterate --phase plan --gh-owner GrayCodeAI --gh-repo iterate 2>>"$LOG_FILE"; then
103-
log "WARNING: plan phase exited with error — checking for fallback"
104-
fi
99+
# ── Resume detection: skip completed phases on re-run ──
100+
# If pr_state.json exists, a PR was already created — skip phases 1-3.
101+
if [[ -f "$PR_STATE_FILE" ]]; then
102+
log "Detected existing pr_state.json — resuming from Phase 4 (Review)"
103+
else
104+
# ── Clean stale plan ──
105+
rm -f "$PLAN_FILE"
106+
107+
# ── Phase 1: Planning ──
108+
log "Phase 1: Planning..."
109+
if ! ./iterate --phase plan --gh-owner GrayCodeAI --gh-repo iterate 2>>"$LOG_FILE"; then
110+
log "WARNING: plan phase exited with error — checking for fallback"
111+
fi
105112

106-
# Fallback plan if agent didn't create one
107-
if [[ ! -f "$PLAN_FILE" ]]; then
108-
log "Agent did not create SESSION_PLAN.md — writing fallback"
109-
if [[ "$HAS_ISSUES" == "true" ]]; then
110-
cat > "$PLAN_FILE" <<'EOF'
113+
# Fallback plan if agent didn't create one
114+
if [[ ! -f "$PLAN_FILE" ]]; then
115+
log "Agent did not create SESSION_PLAN.md — writing fallback"
116+
if [[ "$HAS_ISSUES" == "true" ]]; then
117+
cat > "$PLAN_FILE" <<'EOF'
111118
## Session Plan
112119
113120
Session Title: Address community issues
@@ -120,8 +127,8 @@ Issue: multiple
120127
### Issue Responses
121128
- TBD
122129
EOF
123-
else
124-
cat > "$PLAN_FILE" <<'EOF'
130+
else
131+
cat > "$PLAN_FILE" <<'EOF'
125132
## Session Plan
126133
127134
Session Title: General self-improvement
@@ -133,42 +140,43 @@ Issue: none
133140
134141
### Issue Responses
135142
EOF
143+
fi
136144
fi
137-
fi
138-
139-
# ── Phase 2: Implementation ──
140-
log "Phase 2: Implementation..."
141-
sleep 5 # Brief pause between phases
142-
if ! ./iterate --phase implement --gh-owner GrayCodeAI --gh-repo iterate 2>>"$LOG_FILE"; then
143-
log "WARNING: implement phase exited with error — continuing"
144-
fi
145-
146-
# Update DAY_COUNT before creating PR
147-
echo "$DAY" > "${REPOPATH}/DAY_COUNT"
148-
git add DAY_COUNT 2>/dev/null || true
149-
git diff --cached --quiet || git commit -m "chore: update DAY_COUNT to day $DAY" 2>/dev/null || true
150-
151-
# ── Track coverage and generate stats before PR ──
152-
log "Tracking test coverage..."
153-
python3 scripts/build/track_coverage.py . 2>/dev/null || true
154-
git add memory/coverage_history.jsonl 2>/dev/null || true
155-
git diff --cached --quiet || git commit -m "chore: update coverage history" 2>/dev/null || true
156-
157-
log "Generating stats..."
158-
python3 scripts/build/generate_stats.py . 2>/dev/null || true
159-
git add docs/stats.json memory/weekly_summary.md 2>/dev/null || true
160-
git diff --cached --quiet || git commit -m "chore: update stats" 2>/dev/null || true
161145

162-
log "Generating dashboard..."
163-
python3 scripts/build/generate_dashboard.py . 2>/dev/null || true
164-
git add docs/dashboard.html 2>/dev/null || true
165-
git diff --cached --quiet || git commit -m "chore: update metrics dashboard" 2>/dev/null || true
146+
# ── Phase 2: Implementation ──
147+
log "Phase 2: Implementation..."
148+
sleep 5 # Brief pause between phases
149+
if ! ./iterate --phase implement --gh-owner GrayCodeAI --gh-repo iterate 2>>"$LOG_FILE"; then
150+
log "WARNING: implement phase exited with error — continuing"
151+
fi
166152

167-
# ── Phase 3: Pull Request ──
168-
log "Phase 3: Pull Request..."
169-
sleep 5
170-
if ! ./iterate --phase pr --gh-owner GrayCodeAI --gh-repo iterate 2>>"$LOG_FILE"; then
171-
log "WARNING: PR phase exited with error — continuing"
153+
# Update DAY_COUNT before creating PR
154+
echo "$DAY" > "${REPOPATH}/DAY_COUNT"
155+
git add DAY_COUNT 2>/dev/null || true
156+
git diff --cached --quiet || git commit -m "chore: update DAY_COUNT to day $DAY" 2>/dev/null || true
157+
158+
# ── Track coverage and generate stats before PR ──
159+
log "Tracking test coverage..."
160+
python3 scripts/build/track_coverage.py . 2>/dev/null || true
161+
git add memory/coverage_history.jsonl 2>/dev/null || true
162+
git diff --cached --quiet || git commit -m "chore: update coverage history" 2>/dev/null || true
163+
164+
log "Generating stats..."
165+
python3 scripts/build/generate_stats.py . 2>/dev/null || true
166+
git add docs/stats.json memory/weekly_summary.md 2>/dev/null || true
167+
git diff --cached --quiet || git commit -m "chore: update stats" 2>/dev/null || true
168+
169+
log "Generating dashboard..."
170+
python3 scripts/build/generate_dashboard.py . 2>/dev/null || true
171+
git add docs/dashboard.html 2>/dev/null || true
172+
git diff --cached --quiet || git commit -m "chore: update metrics dashboard" 2>/dev/null || true
173+
174+
# ── Phase 3: Pull Request ──
175+
log "Phase 3: Pull Request..."
176+
sleep 5
177+
if ! ./iterate --phase pr --gh-owner GrayCodeAI --gh-repo iterate 2>>"$LOG_FILE"; then
178+
log "WARNING: PR phase exited with error — continuing"
179+
fi
172180
fi
173181

174182
BRANCH="evolution/day-${DAY}"
@@ -231,10 +239,37 @@ gh api repos/"$GITHUB_REPO"/branches --jq '.[].name' 2>/dev/null | grep "^evolut
231239
fi
232240
done
233241

242+
<<<<<<< Updated upstream
234243
# ── Cost estimation ──
235244
SESSION_DURATION=$SECONDS
236245
log "Session duration: ${SESSION_DURATION}s"
237246
log "Estimated cost: ~\$0.00 (depends on API usage)"
247+
=======
248+
# ── Generate stats ──
249+
log "Generating stats..."
250+
python3 scripts/build/generate_stats.py . 2>/dev/null || true
251+
git add docs/stats.json memory/weekly_summary.md 2>/dev/null || true
252+
253+
# ── Final commit and push ──
254+
log "Pushing changes..."
255+
256+
# Re-calculate day after pull (pull may overwrite DAY_COUNT)
257+
DAY=$(( ($(date -u +%s) - $(date -d "$BIRTH_DATE" +%s 2>/dev/null || date -j -f "%Y-%m-%d" "$BIRTH_DATE" +%s)) / 86400 ))
258+
echo "$DAY" > "${REPOPATH}/DAY_COUNT"
259+
260+
if [[ -n $(git status -s) ]]; then
261+
git add -A
262+
git commit -m "iterate: Day $DAY evolution session" 2>/dev/null || true
263+
fi
264+
git pull --rebase origin main 2>/dev/null || true
265+
266+
# Always ensure DAY_COUNT is correct after pull
267+
echo "$DAY" > "${REPOPATH}/DAY_COUNT"
268+
git add DAY_COUNT 2>/dev/null || true
269+
git commit --amend --no-edit 2>/dev/null || git commit -m "iterate: Day $DAY evolution session" 2>/dev/null || true
270+
271+
git push origin main 2>/dev/null || log "Push failed"
272+
>>>>>>> Stashed changes
238273

239274
# ── Summary ──
240275
log "=== evolution cycle completed ==="

0 commit comments

Comments
 (0)