You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugfix-319-setup-crash-on-repository-with-no-issues: Refactor agent documentation by moving use case flows to a dedicated file and enhancing Bugbot details with key paths and configuration.
Copy file name to clipboardExpand all lines: _agent/docs/bugbot.md
+65-1Lines changed: 65 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,14 @@
1
1
---
2
2
name: Bugbot
3
-
description: Detailed technical reference for Bugbot (detection, markers, context, intent, autofix, do user request, permissions).
3
+
description: Detailed technical reference for Bugbot (detection, markers, context, intent, autofix, do user request, permissions)
4
4
---
5
5
6
6
# Bugbot – technical reference
7
7
8
8
Bugbot has two main modes: **detection** (on push or single action) and **fix/do** (on issue comment or PR review comment). All Bugbot code lives under `src/usecase/steps/commit/bugbot/` and `src/usecase/steps/commit/` (DetectPotentialProblemsUseCase, user_request_use_case).
9
9
10
+
---
11
+
10
12
## 1. Detection flow (push or single action)
11
13
12
14
**Entry:**`CommitUseCase` (on push) calls `DetectPotentialProblemsUseCase`; or `SingleActionUseCase` when action is `detect_potential_problems_action`.
@@ -21,6 +23,19 @@ Bugbot has two main modes: **detection** (on push or single action) and **fix/do
21
23
6.**Mark resolved:**`markFindingsResolved(execution, context, resolvedFindingIds, normalizedResolvedIds)` – for each existing finding in context whose id is in resolved set, update issue comment (and PR review comment if any) via `replaceMarkerInBody` to set `resolved:true`; if PR comment, call `resolveReviewThread` when applicable.
22
24
7.**Publish:**`publishFindings(execution, context, toPublish, overflowCount?, overflowTitles?)` – for each finding: add or update **issue comment** (always); add or update **PR review comment** only when `finding.file` is in `prContext.prFiles` (using `pathToFirstDiffLine` when finding has no line). Each comment body is built with `buildCommentBody(finding, resolved)` and includes the **marker**`<!-- copilot-bugbot finding_id:"id" resolved:false -->`. Overflow: one extra issue comment summarizing excess findings.
**Marker:** Hidden HTML comment in every finding comment (issue and PR):
@@ -31,6 +46,14 @@ Bugbot has two main modes: **detection** (on push or single action) and **fix/do
31
46
-**Build:**`buildMarker(findingId, resolved)`. IDs are sanitized (`sanitizeFindingIdForMarker`) so they cannot break HTML (no `-->`, `<`, `>`, newlines, etc.).
32
47
-**Update:**`replaceMarkerInBody(body, findingId, newResolved)` – used when marking a finding as resolved (same comment, body updated with `resolved:true`).
33
48
49
+
**Context (`BugbotContext`):**
50
+
51
+
-`existingByFindingId[id]`: `{ issueCommentId?, prCommentId?, prNumber?, resolved }` – from parsing all issue + PR comments for markers.
52
+
-`issueComments`: raw list from API (for body when building previousFindingsBlock / unresolvedFindingsWithBody).
53
+
-`openPrNumbers`, `previousFindingsBlock`, `prContext` (prHeadSha, prFiles, pathToFirstDiffLine), `unresolvedFindingsWithBody`: `{ id, fullBody }[]` for findings that are not resolved (body truncated to MAX_FINDING_BODY_LENGTH when loading).
**Entry:**`IssueCommentUseCase` or `PullRequestReviewCommentUseCase` (after language check).
@@ -62,3 +85,44 @@ Bugbot has two main modes: **detection** (on push or single action) and **fix/do
62
85
- If success: `runUserRequestCommitAndPush(execution, { branchOverride })` – same verify/checkout/add/commit/push with message `chore(#N): apply user request` or `chore: apply user request`.
63
86
64
87
5.**Think** (when no file-modifying action ran): `ThinkUseCase.invoke(param)` – answers the user (e.g. question).
88
+
89
+
**Key paths (fix/do):**
90
+
91
+
-`detect_bugbot_fix_intent_use_case.ts` – intent detection, branch resolution for issue_comment
92
+
-`build_bugbot_fix_intent_prompt.ts` – prompt for is_fix_request / is_do_request / target_finding_ids
-**bugbot-comment-limit:** Max individual finding comments per issue/PR (overflow gets one summary). Default 20. `getBugbotCommentLimit()`, `applyCommentLimit`.
108
+
-**bugbot-fix-verify-commands:** Comma-separated commands run after autofix (and do user request) before commit. `getBugbotFixVerifyCommands()`, parsed with shell-quote; max 20 executed. Stored in `Ai` model; read in `github_action.ts` / `local_action.ts`.
109
+
-**ai-ignore-files:** Exclude paths from detection (and from reporting). Used in buildBugbotPrompt and in filtering findings.
110
+
111
+
---
112
+
113
+
## 5. Constants and types
114
+
115
+
-`BUGBOT_MARKER_PREFIX`: `'copilot-bugbot'`
116
+
-`BUGBOT_MAX_COMMENTS`: 20 (default limit)
117
+
-`MAX_FINDING_BODY_LENGTH`: 12000 (truncation when loading context and in build_bugbot_fix_prompt)
118
+
-`MAX_VERIFY_COMMANDS`: 20 (in bugbot_autofix_commit)
-**User comment in prompts:**`sanitizeUserCommentForPrompt(raw)` – trim, escape backslashes, replace `"""`, truncate 4000 with no lone trailing backslash.
126
+
-**Finding body in prompts:**`truncateFindingBody(body, MAX_FINDING_BODY_LENGTH)` with suffix `[... truncated for length ...]` (used in load_bugbot_context and build_bugbot_fix_prompt).
127
+
-**Verify commands:** Parsed with shell-quote; no shell operators (;, |, etc.); max 20 run.
128
+
-**Path:**`isSafeFindingFilePath` (no null byte, no `..`, no absolute); PR review comment only if file in `prFiles`.
0 commit comments