|
| 1 | +--- |
| 2 | +name: Architecture |
| 3 | +description: Project architecture, entry points, and use case flows. |
| 4 | +--- |
| 5 | + |
| 6 | +# Architecture & Key Paths |
| 7 | + |
| 8 | +## Entry and main flow |
| 9 | + |
| 10 | +1. **GitHub Action**: `src/actions/github_action.ts` reads inputs, builds `Execution`, calls `mainRun(execution)` from `common_action.ts`. |
| 11 | +2. **CLI**: `src/actions/local_action.ts` same flow with CLI/config inputs. |
| 12 | +3. **common_action.ts**: Sets up; calls `waitForPreviousRuns(execution)` (sequential workflow); then: |
| 13 | + - **Single action** → `SingleActionUseCase` |
| 14 | + - **Issue** → `IssueCommentUseCase` or `IssueUseCase` |
| 15 | + - **Pull request** → `PullRequestReviewCommentUseCase` or `PullRequestUseCase` |
| 16 | + - **Push** → `CommitUseCase` |
| 17 | + |
| 18 | +## Key paths |
| 19 | + |
| 20 | +| Area | Path | Purpose | |
| 21 | +|------|------|--------| |
| 22 | +| Action entry | `src/actions/github_action.ts` | Reads inputs, builds Execution | |
| 23 | +| CLI entry | `src/cli.ts` → `local_action.ts` | Same flow, local inputs | |
| 24 | +| Shared flow | `src/actions/common_action.ts` | mainRun, waitForPreviousRuns, dispatch to use cases | |
| 25 | +| Use cases | `src/usecase/` | issue_use_case, pull_request_use_case, commit_use_case, single_action_use_case | |
| 26 | +| Single actions | `src/usecase/actions/` | check_progress, detect_errors, recommend_steps, think, initial_setup, create_release, create_tag, publish_github_action, deployed_action | |
| 27 | +| Steps (issue) | `src/usecase/steps/issue/` | check_permissions, close_not_allowed_issue, assign_members, update_title, update_issue_type, link_issue_project, check_priority_issue_size, prepare_branches, remove_issue_branches, remove_not_needed_branches, label_deploy_added, label_deployed_added, move_issue_to_in_progress, answer_issue_help_use_case (question/help on open). On issue opened: RecommendStepsUseCase (non release/question/help) or AnswerIssueHelpUseCase (question/help). | |
| 28 | +| Steps (PR) | `src/usecase/steps/pull_request/` | update_title, assign_members (issue), assign_reviewers_to_issue, link_pr_project, link_pr_issue, sync_size_and_progress_from_issue, check_priority_pull_request_size, update_description (AI), close_issue_after_merging | |
| 29 | +| Steps (commit) | `src/usecase/steps/commit/` | notify commit, check size | |
| 30 | +| Steps (issue comment) | `src/usecase/steps/issue_comment/` | check_issue_comment_language (translation) | |
| 31 | +| Steps (PR review comment) | `src/usecase/steps/pull_request_review_comment/` | check_pull_request_comment_language (translation) | |
| 32 | +| Bugbot autofix & user request | `src/usecase/steps/commit/bugbot/` + `user_request_use_case.ts` | detect_bugbot_fix_intent_use_case (plan agent: is_fix_request, is_do_request, target_finding_ids), BugbotAutofixUseCase + runBugbotAutofixCommitAndPush (fix findings), DoUserRequestUseCase + runUserRequestCommitAndPush (generic “do this”). Permission: ProjectRepository.isActorAllowedToModifyFiles (org member or repo owner). | |
| 33 | +| Manager (content) | `src/manager/` | description handlers, configuration_handler, markdown_content_hotfix_handler (PR description, hotfix changelog content) | |
| 34 | +| Models | `src/data/model/` | Execution, Issue, PullRequest, SingleAction, etc. | |
| 35 | +| Repos | `src/data/repository/` | branch_repository, issue_repository, workflow_repository, ai_repository (OpenCode), file_repository, project_repository | |
| 36 | +| Config | `src/utils/constants.ts` | INPUT_KEYS, ACTIONS, defaults | |
| 37 | +| Metadata | `action.yml` | Action inputs and defaults | |
| 38 | + |
| 39 | +## Schematic overview of use case flows |
| 40 | + |
| 41 | +Entry point: `mainRun(execution)` in `src/actions/common_action.ts`. After `execution.setup()` and optionally `waitForPreviousRuns`, the dispatch is: |
| 42 | + |
| 43 | +``` |
| 44 | +mainRun |
| 45 | +├── runnedByToken && singleAction → SingleActionUseCase (only if validSingleAction) |
| 46 | +├── issueNumber === -1 → SingleActionUseCase (only if isSingleActionWithoutIssue) or skip |
| 47 | +├── welcome → log boxen and continue |
| 48 | +└── try: |
| 49 | + ├── isSingleAction → SingleActionUseCase |
| 50 | + ├── isIssue → issue.isIssueComment ? IssueCommentUseCase : IssueUseCase |
| 51 | + ├── isPullRequest → pullRequest.isPullRequestReviewComment ? PullRequestReviewCommentUseCase : PullRequestUseCase |
| 52 | + ├── isPush → CommitUseCase |
| 53 | + └── else → core.setFailed |
| 54 | +``` |
| 55 | + |
| 56 | +### 1. IssueUseCase (`on: issues`, not a comment) |
| 57 | + |
| 58 | +**Step order:** |
| 59 | + |
| 60 | +1. **CheckPermissionsUseCase** → if it fails (not allowed): CloseNotAllowedIssueUseCase and return. |
| 61 | +2. **RemoveIssueBranchesUseCase** (only if `cleanIssueBranches`). |
| 62 | +3. **AssignMemberToIssueUseCase** |
| 63 | +4. **UpdateTitleUseCase** |
| 64 | +5. **UpdateIssueTypeUseCase** |
| 65 | +6. **LinkIssueProjectUseCase** |
| 66 | +7. **CheckPriorityIssueSizeUseCase** |
| 67 | +8. **PrepareBranchesUseCase** (if `isBranched`) **or** **RemoveIssueBranchesUseCase** (if not). |
| 68 | +9. **RemoveNotNeededBranchesUseCase** |
| 69 | +10. **DeployAddedUseCase** (deploy label) |
| 70 | +11. **DeployedAddedUseCase** (deployed label) |
| 71 | +12. If **issue.opened**: |
| 72 | + - If not release and not question/help → **RecommendStepsUseCase** |
| 73 | + - If question or help → **AnswerIssueHelpUseCase** |
| 74 | + |
| 75 | +### 2. IssueCommentUseCase (`on: issue_comment`) |
| 76 | + |
| 77 | +**Step order:** |
| 78 | + |
| 79 | +1. **CheckIssueCommentLanguageUseCase** (translation) |
| 80 | +2. **DetectBugbotFixIntentUseCase** → payload: `isFixRequest`, `isDoRequest`, `targetFindingIds`, `context`, `branchOverride` |
| 81 | +3. **ProjectRepository.isActorAllowedToModifyFiles(owner, actor, token)** (permission to modify files) |
| 82 | +4. Branch A – **if runAutofix && allowed**: |
| 83 | + - **BugbotAutofixUseCase** → **runBugbotAutofixCommitAndPush** → if committed: **markFindingsResolved** |
| 84 | +5. Branch B – **if !runAutofix && canRunDoUserRequest && allowed**: |
| 85 | + - **DoUserRequestUseCase** → **runUserRequestCommitAndPush** |
| 86 | +6. **If no file-modifying action ran** → **ThinkUseCase** |
| 87 | + |
| 88 | +### 3. PullRequestReviewCommentUseCase (`on: pull_request_review_comment`) |
| 89 | + |
| 90 | +Same flow as **IssueCommentUseCase**, with: |
| 91 | + |
| 92 | +- CheckIssueCommentLanguageUseCase → **CheckPullRequestCommentLanguageUseCase** |
| 93 | +- User comment: `param.pullRequest.commentBody` |
| 94 | +- DetectBugbotFixIntentUseCase may use **parent comment** (commentInReplyToId) in the prompt. |
| 95 | + |
| 96 | +### 4. PullRequestUseCase (`on: pull_request`, not a review comment) |
| 97 | + |
| 98 | +**Branches by PR state:** |
| 99 | + |
| 100 | +- **pullRequest.isOpened**: |
| 101 | + 1. UpdateTitleUseCase |
| 102 | + 2. AssignMemberToIssueUseCase |
| 103 | + 3. AssignReviewersToIssueUseCase |
| 104 | + 4. LinkPullRequestProjectUseCase |
| 105 | + 5. LinkPullRequestIssueUseCase |
| 106 | + 6. SyncSizeAndProgressLabelsFromIssueToPrUseCase |
| 107 | + 7. CheckPriorityPullRequestSizeUseCase |
| 108 | + 8. If AI PR description: **UpdatePullRequestDescriptionUseCase** |
| 109 | + |
| 110 | +- **pullRequest.isSynchronize** (new pushes): |
| 111 | + - If AI PR description: **UpdatePullRequestDescriptionUseCase** |
| 112 | + |
| 113 | +- **pullRequest.isClosed && isMerged**: |
| 114 | + - **CloseIssueAfterMergingUseCase** |
| 115 | + |
| 116 | +### 5. CommitUseCase (`on: push`) |
| 117 | + |
| 118 | +**Precondition:** `param.commit.commits.length > 0` (if 0, return with no steps). |
| 119 | + |
| 120 | +**Order:** |
| 121 | + |
| 122 | +1. **NotifyNewCommitOnIssueUseCase** |
| 123 | +2. **CheckChangesIssueSizeUseCase** |
| 124 | +3. **CheckProgressUseCase** (OpenCode: progress + size labels on issue and PRs) |
| 125 | +4. **DetectPotentialProblemsUseCase** (Bugbot: detection, publish to issue/PR, resolved markers) |
| 126 | + |
| 127 | +### 6. SingleActionUseCase |
| 128 | + |
| 129 | +Invoked when: |
| 130 | +- `runnedByToken && isSingleAction && validSingleAction`, or |
| 131 | +- `issueNumber === -1 && isSingleAction && isSingleActionWithoutIssue`, or |
| 132 | +- `isSingleAction` in the main try block. |
| 133 | + |
| 134 | +**Dispatch by action (one per run):** |
| 135 | + |
| 136 | +| Action | Use case | |
| 137 | +|--------|----------| |
| 138 | +| `deployed_action` | DeployedActionUseCase | |
| 139 | +| `publish_github_action` | PublishGithubActionUseCase | |
| 140 | +| `create_release` | CreateReleaseUseCase | |
| 141 | +| `create_tag` | CreateTagUseCase | |
| 142 | +| `think_action` | ThinkUseCase | |
| 143 | +| `initial_setup` | InitialSetupUseCase | |
| 144 | +| `check_progress_action` | CheckProgressUseCase | |
| 145 | +| `detect_potential_problems_action` | DetectPotentialProblemsUseCase | |
| 146 | +| `recommend_steps_action` | RecommendStepsUseCase | |
0 commit comments