Skip to content

Commit 9b6e216

Browse files
cursoragentmsukkari
andcommitted
refactor: share REVIEW_AGENT_LOG_DIR constant between app.ts and invokeDiffReviewLlm.ts
Export the log directory constant from invokeDiffReviewLlm.ts and import it in app.ts to ensure a single source of truth for the review agent log directory path. Co-authored-by: Michael Sukkarieh <msukkari@users.noreply.github.com>
1 parent 87894f8 commit 9b6e216

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/web/src/features/agents/review-agent/app.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Octokit } from "octokit";
22
import { generatePrReviews } from "@/features/agents/review-agent/nodes/generatePrReview";
33
import { githubPushPrReviews } from "@/features/agents/review-agent/nodes/githubPushPrReviews";
44
import { githubPrParser } from "@/features/agents/review-agent/nodes/githubPrParser";
5+
import { REVIEW_AGENT_LOG_DIR } from "@/features/agents/review-agent/nodes/invokeDiffReviewLlm";
56
import { env } from "@sourcebot/shared";
67
import { GitHubPullRequest } from "@/features/agents/review-agent/types";
78
import path from "path";
@@ -30,9 +31,8 @@ export async function processGitHubPullRequest(octokit: Octokit, pullRequest: Gi
3031

3132
let reviewAgentLogPath: string | undefined;
3233
if (env.REVIEW_AGENT_LOGGING_ENABLED) {
33-
const reviewAgentLogDir = path.join(env.DATA_CACHE_DIR, "review-agent");
34-
if (!fs.existsSync(reviewAgentLogDir)) {
35-
fs.mkdirSync(reviewAgentLogDir, { recursive: true });
34+
if (!fs.existsSync(REVIEW_AGENT_LOG_DIR)) {
35+
fs.mkdirSync(REVIEW_AGENT_LOG_DIR, { recursive: true });
3636
}
3737

3838
const timestamp = new Date().toLocaleString('en-US', {
@@ -44,7 +44,7 @@ export async function processGitHubPullRequest(octokit: Octokit, pullRequest: Gi
4444
second: '2-digit',
4545
hour12: false
4646
}).replace(/(\d+)\/(\d+)\/(\d+), (\d+):(\d+):(\d+)/, '$3_$1_$2_$4_$5_$6');
47-
reviewAgentLogPath = path.join(reviewAgentLogDir, `review-agent-${pullRequest.number}-${timestamp}.log`);
47+
reviewAgentLogPath = path.join(REVIEW_AGENT_LOG_DIR, `review-agent-${pullRequest.number}-${timestamp}.log`);
4848
logger.info(`Review agent logging to ${reviewAgentLogPath}`);
4949
}
5050

packages/web/src/features/agents/review-agent/nodes/invokeDiffReviewLlm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import { createLogger } from "@sourcebot/shared";
77

88
const logger = createLogger('invoke-diff-review-llm');
99

10-
const REVIEW_AGENT_LOG_BASE = path.join(env.DATA_CACHE_DIR, 'review-agent');
10+
export const REVIEW_AGENT_LOG_DIR = path.join(env.DATA_CACHE_DIR, 'review-agent');
1111

1212
const validateLogPath = (logPath: string): void => {
1313
const resolved = path.resolve(logPath);
14-
if (!resolved.startsWith(REVIEW_AGENT_LOG_BASE + path.sep)) {
14+
if (!resolved.startsWith(REVIEW_AGENT_LOG_DIR + path.sep)) {
1515
throw new Error('reviewAgentLogPath escapes log directory');
1616
}
1717
};

0 commit comments

Comments
 (0)