|
2 | 2 | import * as core from "@actions/core"; |
3 | 3 | import { Octokit } from "@octokit/rest"; |
4 | 4 | import { runAuggie } from "./auggie"; |
5 | | -import { |
6 | | - getInput, |
7 | | - parseRepository, |
8 | | - postComment, |
9 | | - reactToComment, |
10 | | -} from "./utils"; |
11 | | - |
12 | | -// Regex patterns for extracting issue/PR numbers from URLs |
13 | | -const ISSUE_URL_PATTERN = /\/issues\/(\d+)$/; |
14 | | -const PR_URL_PATTERN = /\/pulls\/(\d+)$/; |
15 | | - |
16 | | -type GetIssueNumberParams = { |
17 | | - octokit: Octokit; |
18 | | - owner: string; |
19 | | - repo: string; |
20 | | - commentId: number; |
21 | | - eventName: string; |
22 | | -}; |
23 | | - |
24 | | -/** |
25 | | - * Get issue/PR number from the comment |
26 | | - * For issue_comment events, we need to fetch the comment to get the issue number |
27 | | - * For pull_request_review_comment events, we need to fetch the comment to get the PR number |
28 | | - */ |
29 | | -async function getIssueNumber({ |
30 | | - octokit, |
31 | | - owner, |
32 | | - repo, |
33 | | - commentId, |
34 | | - eventName, |
35 | | -}: GetIssueNumberParams): Promise<number> { |
36 | | - if (eventName === "issue_comment") { |
37 | | - // Fetch the comment to get the issue URL |
38 | | - const { data: comment } = await octokit.rest.issues.getComment({ |
39 | | - owner, |
40 | | - repo, |
41 | | - comment_id: commentId, |
42 | | - }); |
43 | | - |
44 | | - // Extract issue number from the issue URL |
45 | | - const issueUrlMatch = comment.issue_url.match(ISSUE_URL_PATTERN); |
46 | | - if (!issueUrlMatch?.[1]) { |
47 | | - throw new Error( |
48 | | - `Could not extract issue number from URL: ${comment.issue_url}` |
49 | | - ); |
50 | | - } |
51 | | - |
52 | | - return Number.parseInt(issueUrlMatch[1], 10); |
53 | | - } |
54 | | - |
55 | | - if (eventName === "pull_request_review_comment") { |
56 | | - // Fetch the review comment to get the PR URL |
57 | | - const { data: comment } = await octokit.rest.pulls.getReviewComment({ |
58 | | - owner, |
59 | | - repo, |
60 | | - comment_id: commentId, |
61 | | - }); |
62 | | - |
63 | | - // Extract PR number from the pull request URL |
64 | | - const prUrlMatch = comment.pull_request_url.match(PR_URL_PATTERN); |
65 | | - if (!prUrlMatch?.[1]) { |
66 | | - throw new Error( |
67 | | - `Could not extract PR number from URL: ${comment.pull_request_url}` |
68 | | - ); |
69 | | - } |
70 | | - |
71 | | - return Number.parseInt(prUrlMatch[1], 10); |
72 | | - } |
73 | | - |
74 | | - throw new Error(`Unsupported event type: ${eventName}`); |
75 | | -} |
| 5 | +import { getInput, parseRepository, reactToComment } from "./utils"; |
76 | 6 |
|
77 | 7 | /** |
78 | 8 | * Main function |
@@ -101,35 +31,25 @@ async function main(): Promise<void> { |
101 | 31 | // React to the comment to acknowledge receipt |
102 | 32 | await reactToComment({ octokit, owner, repo, commentId, eventName }); |
103 | 33 |
|
| 34 | + // Log GITHUB_STEP_SUMMARY availability |
| 35 | + const stepSummaryPath = process.env.GITHUB_STEP_SUMMARY; |
| 36 | + if (stepSummaryPath) { |
| 37 | + core.info(`📊 GITHUB_STEP_SUMMARY available at: ${stepSummaryPath}`); |
| 38 | + } else { |
| 39 | + core.warning("⚠️ GITHUB_STEP_SUMMARY not available"); |
| 40 | + } |
| 41 | + |
104 | 42 | // Run Auggie agent with the prompt |
105 | 43 | core.info("🚀 Running Auggie agent..."); |
106 | | - const response = await runAuggie({ |
107 | | - prompt, |
| 44 | + await runAuggie({ |
| 45 | + userPrompt: prompt, |
108 | 46 | apiKey: augmentApiKey, |
109 | 47 | apiUrl: augmentApiUrl, |
110 | 48 | workspaceRoot: workspaceRoot || undefined, |
111 | 49 | githubToken, |
112 | 50 | }); |
113 | 51 |
|
114 | | - // Get issue number for posting the response |
115 | | - const issueNumber = await getIssueNumber({ |
116 | | - octokit, |
117 | | - owner, |
118 | | - repo, |
119 | | - commentId, |
120 | | - eventName, |
121 | | - }); |
122 | | - |
123 | | - // Post the response as a comment |
124 | | - await postComment({ |
125 | | - octokit, |
126 | | - owner, |
127 | | - repo, |
128 | | - issueNumber, |
129 | | - body: response, |
130 | | - eventName, |
131 | | - }); |
132 | | - |
| 52 | + core.info("✅ Auggie agent completed successfully"); |
133 | 53 | core.setOutput("success", "true"); |
134 | 54 | } catch (error) { |
135 | 55 | const errorMessage = error instanceof Error ? error.message : String(error); |
|
0 commit comments