Skip to content

Commit dc45e00

Browse files
committed
feature-296-bugbot-autofix: Add support for configurable verify commands after autofix, enhance bugbot context loading, and improve documentation for bugbot autofix functionality.
1 parent 6055de0 commit dc45e00

File tree

55 files changed

+2480
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2480
-217
lines changed

.cursor/rules/architecture.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ alwaysApply: true
2929
| Steps (commit) | `src/usecase/steps/commit/` | notify commit, check size |
3030
| Steps (issue comment) | `src/usecase/steps/issue_comment/` | check_issue_comment_language (translation) |
3131
| Steps (PR review comment) | `src/usecase/steps/pull_request_review_comment/` | check_pull_request_comment_language (translation) |
32+
| Bugbot autofix | `src/usecase/steps/commit/bugbot/` | detect_bugbot_fix_intent_use_case (OpenCode decides if user asks to fix findings), bugbot_autofix_use_case (build agent applies fixes), bugbot_autofix_commit (verify + git commit/push). Intent via OpenCode plan agent; fix via build agent; no diff API. |
3233
| Manager (content) | `src/manager/` | description handlers, configuration_handler, markdown_content_hotfix_handler (PR description, hotfix changelog content) |
3334
| Models | `src/data/model/` | Execution, Issue, PullRequest, SingleAction, etc. |
3435
| Repos | `src/data/repository/` | branch_repository, issue_repository, workflow_repository, ai_repository (OpenCode), file_repository, project_repository |

.github/workflows/copilot_issue_comment.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
copilot-issues:
99
name: Copilot - Issue Comment
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
1113
steps:
1214
- name: Checkout Repository
1315
uses: actions/checkout@v4
@@ -19,3 +21,4 @@ jobs:
1921
opencode-model: ${{ vars.OPENCODE_MODEL }}
2022
project-ids: ${{ vars.PROJECT_IDS }}
2123
token: ${{ secrets.PAT }}
24+
bugbot-fix-verify-commands: ${{ vars.BUGBOT_AUTOFIX_VERIFY_COMMANDS }}

.github/workflows/copilot_pull_request_comment.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
copilot-pull-requests:
99
name: Copilot - Pull Request Comment
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
1113
steps:
1214
- name: Checkout Repository
1315
uses: actions/checkout@v4
@@ -19,4 +21,4 @@ jobs:
1921
opencode-model: ${{ vars.OPENCODE_MODEL }}
2022
project-ids: ${{ vars.PROJECT_IDS }}
2123
token: ${{ secrets.PAT }}
22-
24+
bugbot-fix-verify-commands: ${{ vars.BUGBOT_AUTOFIX_VERIFY_COMMANDS }}

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,9 @@ inputs:
417417
bugbot-comment-limit:
418418
description: "Maximum number of potential-problem findings to publish as individual comments on the issue and PR. Extra findings are summarized in a single overflow comment."
419419
default: "20"
420+
bugbot-fix-verify-commands:
421+
description: "Comma-separated commands to run after bugbot autofix (e.g. npm run build, npm test, npm run lint). OpenCode runs these in its workspace; the runner can re-run them before commit. If empty, only OpenCode's run is used."
422+
default: ""
420423
runs:
421424
using: "node20"
422425
main: "build/github_action/index.js"

build/cli/index.js

Lines changed: 636 additions & 10 deletions
Large diffs are not rendered by default.

build/cli/src/data/model/ai.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export declare class Ai {
1212
private aiIncludeReasoning;
1313
private bugbotMinSeverity;
1414
private bugbotCommentLimit;
15-
constructor(opencodeServerUrl: string, opencodeModel: string, aiPullRequestDescription: boolean, aiMembersOnly: boolean, aiIgnoreFiles: string[], aiIncludeReasoning: boolean, bugbotMinSeverity: string, bugbotCommentLimit: number);
15+
private bugbotFixVerifyCommands;
16+
constructor(opencodeServerUrl: string, opencodeModel: string, aiPullRequestDescription: boolean, aiMembersOnly: boolean, aiIgnoreFiles: string[], aiIncludeReasoning: boolean, bugbotMinSeverity: string, bugbotCommentLimit: number, bugbotFixVerifyCommands?: string[]);
1617
getOpencodeServerUrl(): string;
1718
getOpencodeModel(): string;
1819
getAiPullRequestDescription(): boolean;
@@ -21,6 +22,7 @@ export declare class Ai {
2122
getAiIncludeReasoning(): boolean;
2223
getBugbotMinSeverity(): string;
2324
getBugbotCommentLimit(): number;
25+
getBugbotFixVerifyCommands(): string[];
2426
/**
2527
* Parse "provider/model-id" into { providerID, modelID } for OpenCode session.prompt.
2628
* Uses OPENCODE_DEFAULT_MODEL when no model is set (e.g. opencode/kimi-k2.5-free).

build/cli/src/data/model/pull_request.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ export declare class PullRequest {
2323
get commentBody(): string;
2424
get commentAuthor(): string;
2525
get commentUrl(): string;
26+
/** When the comment is a reply, the id of the parent review comment (for bugbot: include parent body in intent prompt). */
27+
get commentInReplyToId(): number | undefined;
2628
constructor(desiredAssigneesCount: number, desiredReviewersCount: number, mergeTimeout: number, inputs?: any | undefined);
2729
}

build/cli/src/data/repository/pull_request_repository.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ export declare class PullRequestRepository {
44
* Used to sync size/progress labels from the issue to PRs when they are updated on push.
55
*/
66
getOpenPullRequestNumbersByHeadBranch: (owner: string, repository: string, headBranch: string, token: string) => Promise<number[]>;
7+
/**
8+
* Returns the head branch of the first open PR that references the given issue number
9+
* (e.g. body contains "#123" or head ref contains "123" as in feature/123-...).
10+
* Used for issue_comment events where commit.branch is empty.
11+
*/
12+
getHeadBranchForIssue: (owner: string, repository: string, issueNumber: number, token: string) => Promise<string | undefined>;
713
isLinked: (pullRequestUrl: string) => Promise<boolean>;
814
updateBaseBranch: (owner: string, repository: string, pullRequestNumber: number, branch: string, token: string) => Promise<void>;
915
updateDescription: (owner: string, repository: string, pullRequestNumber: number, description: string, token: string) => Promise<void>;
@@ -48,6 +54,11 @@ export declare class PullRequestRepository {
4854
line?: number;
4955
node_id?: string;
5056
}>>;
57+
/**
58+
* Fetches a single PR review comment by id (e.g. parent comment when user replied in thread).
59+
* Returns the comment body or null if not found.
60+
*/
61+
getPullRequestReviewCommentBody: (owner: string, repository: string, _pullNumber: number, commentId: number, token: string) => Promise<string | null>;
5162
/**
5263
* Resolve a PR review thread (GraphQL only). Finds the thread that contains the given comment and marks it resolved.
5364
* Uses repository.pullRequest.reviewThreads because the field pullRequestReviewThread on PullRequestReviewComment was removed from the API.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Unit tests for buildBugbotFixIntentPrompt.
3+
*/
4+
export {};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Unit tests for buildBugbotFixPrompt.
3+
*/
4+
export {};

0 commit comments

Comments
 (0)