diff --git a/src/auggie.ts b/src/auggie.ts index bdb0d59..bdf8070 100644 --- a/src/auggie.ts +++ b/src/auggie.ts @@ -14,6 +14,8 @@ export type RunAuggieOptions = { context?: GithubPullRequest; /** The body of the comment that triggered this action, if triggered by a comment */ commentBody?: string; + /** The ID of the comment that triggered this action, if triggered by a comment */ + commentId?: number; }; /** @@ -27,6 +29,7 @@ export async function runAuggie(options: RunAuggieOptions): Promise { workspaceRoot, context, commentBody, + commentId, } = options; const workspace = workspaceRoot || process.cwd(); @@ -70,6 +73,12 @@ export async function runAuggie(options: RunAuggieOptions): Promise { core.info("📨 User comment included in prompt"); } + // Add triggering comment ID if available + if (commentId) { + fullPrompt = `${fullPrompt}\n\n## Triggering Comment ID:\n${commentId}`; + core.info(`📍 Triggering comment ID: ${commentId}`); + } + // Add user prompt fullPrompt = `${fullPrompt}\n\n${userPrompt}`; diff --git a/src/index.ts b/src/index.ts index 27a9bf6..e35f1b2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,7 @@ async function main(): Promise { augmentApiUrl, workspaceRoot, commentBody, + commentId, } = getAuggieParams(); const { owner, repo } = parseRepository(); const githubToken = process.env.GITHUB_TOKEN; @@ -34,6 +35,7 @@ async function main(): Promise { apiUrl: augmentApiUrl, workspaceRoot: workspaceRoot || undefined, commentBody, + commentId, }); core.info("✅ Auggie agent completed successfully"); diff --git a/src/utils/index.ts b/src/utils/index.ts index fcdbca0..ed29d6e 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -169,6 +169,7 @@ type AuggieParams = { augmentApiUrl: string; workspaceRoot: string | undefined; commentBody: string | undefined; + commentId: number | undefined; }; /** @@ -189,6 +190,7 @@ export function getAuggieParams(): AuggieParams { const augmentApiUrl = getInput("augment_api_url", true); const workspaceRoot = getInput("workspace_root"); const commentBody = getCommentBodyFromEvent(); + const commentId = getCommentIdFromEvent(); return { eventName, prompt, @@ -196,5 +198,6 @@ export function getAuggieParams(): AuggieParams { augmentApiUrl, workspaceRoot, commentBody, + commentId, } } diff --git a/src/utils/prompt.ts b/src/utils/prompt.ts index 4926356..506e4a4 100644 --- a/src/utils/prompt.ts +++ b/src/utils/prompt.ts @@ -6,11 +6,31 @@ Important: How you handle changes depends on the context: - If you are working on a Pull Request (PR): You are allowed to commit directly to that PR's branch. - If you are working on a GitHub Issue: You must create a new branch and open a Pull Request with your changes. +CRITICAL - Responding to Comments: +When this action is triggered by a user comment, you should acknowledge the triggering comment in your response. +- A "Triggering Comment ID" will be provided in the prompt context. +- Use the github-api tool to interact with GitHub. + +How to respond depends on the comment type: + +1. For issue/PR timeline comments (most common): + - GitHub issue comments do NOT support threaded replies - there is no reply endpoint. + - Create a new comment using: POST /repos/{owner}/{repo}/issues/{issue_number}/comments + - In your comment body, reference the triggering comment by quoting it or linking to it. + - Example: Start your comment with "> Replying to [comment](link):" or quote the relevant text. + +2. For PR review comments (inline code comments): + - These DO support threaded replies via the \`in_reply_to\` parameter. + - Use: POST /repos/{owner}/{repo}/pulls/{pull_number}/comments with \`in_reply_to\` set to the triggering comment ID. + +If no triggering comment ID is provided, simply create a new comment on the issue/PR. + Your workflow: -1. Add a comment to the PR letting the user know you're starting to work on it. +1. Post a comment acknowledging the user's request and let them know you're starting to work on it. + - Reference the triggering comment (see instructions above for how to respond to comments). 2. Read the PR context and understand the request. 3. Create a Todo List: - - Update the original comment on the PR with a todo list of what you're going to do. (Use the github-api tool to update the comment. Replace the initial message with the todo list.) + - Update your comment with a todo list of what you're going to do. (Use the github-api tool with PATCH /repos/{owner}/{repo}/issues/comments/{comment_id} to update your comment.) - Use your GitHub comment to maintain a detailed task list based on the request. - Format todos as a checklist (- [ ] for incomplete, - [x] for complete). - Update the comment with each task completion. @@ -29,7 +49,7 @@ Your workflow: - Files modified - Links to PRs/commits 5. Final Comment Update (IMPORTANT): - - When you are completely done with all tasks, update the original comment ONE FINAL TIME. + - When you are completely done with all tasks, update your comment ONE FINAL TIME. - REMOVE the entire task list/checklist from the comment. - Replace the comment body with ONLY a concise, minimal final summary. - Keep it brief: just state what was attempted and what was done.