Skip to content

Commit 686eeaf

Browse files
committed
fix: keep review and release events in github-data.yaml and LLM context
Review events show which PRs were approved/rejected (not available from PR data alone). Release events provide tag/name info not in commits or PRs. Other event types (PushEvent, CreateEvent, etc.) remain excluded as their payloads are empty.
1 parent 2b2057a commit 686eeaf

3 files changed

Lines changed: 82 additions & 5 deletions

File tree

src/cli/commands/fetch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ const runWeeklyFetch = async (options: BaseOptions): Promise<void> => {
257257
repositories,
258258
pullRequests,
259259
issues: [],
260-
events: [],
260+
events: events.filter((e) => e.payload.kind === "review" || e.payload.kind === "release"),
261261
commitMessages,
262262
externalContributions: [],
263263
};

src/llm/preprocess.test.ts

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,67 @@ describe("buildLLMContext", () => {
157157
expect(context).not.toContain("commit_messages:");
158158
});
159159

160-
it("does not include events in LLM context", () => {
161-
const context = buildLLMContext(MOCK_INPUT);
162-
expect(context).not.toContain("events:");
160+
it("does not include push/generic events in LLM context", () => {
161+
const input: NarrativeInput = {
162+
...MOCK_INPUT,
163+
events: [
164+
{
165+
id: "p1",
166+
type: "PushEvent",
167+
repo: "org/repo-a",
168+
createdAt: "2026-04-01T10:00:00Z",
169+
payload: { kind: "push", ref: "refs/heads/main", commits: [] },
170+
},
171+
{
172+
id: "w1",
173+
type: "WatchEvent",
174+
repo: "org/repo-a",
175+
createdAt: "2026-04-01T10:00:00Z",
176+
payload: { kind: "generic", action: "started" },
177+
},
178+
],
179+
};
180+
const context = buildLLMContext(input);
181+
expect(context).not.toContain("reviews_and_releases:");
182+
expect(context).not.toContain("PushEvent");
183+
expect(context).not.toContain("WatchEvent");
184+
});
185+
186+
it("includes review events in LLM context", () => {
187+
const input: NarrativeInput = {
188+
...MOCK_INPUT,
189+
events: [
190+
{
191+
id: "r1",
192+
type: "PullRequestReviewEvent",
193+
repo: "org/repo-a",
194+
createdAt: "2026-04-01T10:00:00Z",
195+
payload: { kind: "review", action: "submitted", prNumber: 42, prTitle: "Add feature", state: "approved" },
196+
},
197+
],
198+
};
199+
const context = buildLLMContext(input);
200+
expect(context).toContain("reviews_and_releases:");
201+
expect(context).toContain("Add feature");
202+
expect(context).toContain("approved");
203+
});
204+
205+
it("includes release events in LLM context", () => {
206+
const input: NarrativeInput = {
207+
...MOCK_INPUT,
208+
events: [
209+
{
210+
id: "rel1",
211+
type: "ReleaseEvent",
212+
repo: "org/repo-a",
213+
createdAt: "2026-04-01T10:00:00Z",
214+
payload: { kind: "release", action: "published", tag: "v2.0.0", name: "Major Release" },
215+
},
216+
],
217+
};
218+
const context = buildLLMContext(input);
219+
expect(context).toContain("reviews_and_releases:");
220+
expect(context).toContain("v2.0.0");
221+
expect(context).toContain("Major Release");
163222
});
164223
});

src/llm/preprocess.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { stringify as toYaml } from "yaml";
55
import type { NarrativeInput } from "./types.js";
6-
import type { PullRequest, Issue, RepoCommitMessages } from "../types.js";
6+
import type { PullRequest, Issue, GitHubEvent, PullRequestReviewEventPayload, ReleaseEventPayload, RepoCommitMessages } from "../types.js";
77

88
const MAX_PRS = 20;
99
const MAX_ISSUES = 15;
@@ -55,6 +55,24 @@ export const buildLLMContext = (input: NarrativeInput): string => {
5555
.map(formatIssue);
5656
}
5757

58+
// Include review and release events (other event types have empty payloads)
59+
const reviewsAndReleases = input.events
60+
.map((event: GitHubEvent) => {
61+
if (event.payload.kind === "review") {
62+
const r = event.payload as PullRequestReviewEventPayload;
63+
return { type: "review", repo: event.repo, pr: r.prTitle, state: r.state };
64+
}
65+
if (event.payload.kind === "release") {
66+
const rel = event.payload as ReleaseEventPayload;
67+
return { type: "release", repo: event.repo, tag: rel.tag, name: rel.name };
68+
}
69+
return null;
70+
})
71+
.filter(Boolean);
72+
if (reviewsAndReleases.length > 0) {
73+
context.reviews_and_releases = reviewsAndReleases;
74+
}
75+
5876
if (input.repositories.length > 0) {
5977
context.repositories = input.repositories
6078
.slice(0, 8)

0 commit comments

Comments
 (0)