Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![GitHub Marketplace](https://img.shields.io/badge/marketplace/actions/copilot-github-with-super-powers?logo=github)](https://github.com/marketplace/actions/copilot-github-with-super-powers)
[![GitHub Marketplace](https://img.shields.io/badge/Copilot-Github_with_super_powers-white)](https://github.com/marketplace/actions/copilot-github-with-super-powers)
[![codecov](https://codecov.io/gh/vypdev/copilot/branch/master/graph/badge.svg)](https://codecov.io/gh/vypdev/copilot)
![Build](https://github.com/vypdev/copilot/actions/workflows/ci_check.yml/badge.svg)
![License](https://img.shields.io/github/license/vypdev/copilot)
Expand Down
3,800 changes: 2,199 additions & 1,601 deletions build/cli/index.js

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions build/cli/src/data/repository/branch_compare_repository.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Labels } from '../model/labels';
import { SizeThresholds } from '../model/size_thresholds';
export interface BranchComparisonFile {
filename: string;
status: string;
additions: number;
deletions: number;
changes: number;
blobUrl: string;
rawUrl: string;
contentsUrl: string;
patch: string | undefined;
}
export interface BranchComparisonCommit {
sha: string;
message: string;
author: {
name: string;
email: string;
date: string;
};
date: string;
}
export interface BranchComparison {
aheadBy: number;
behindBy: number;
totalCommits: number;
files: BranchComparisonFile[];
commits: BranchComparisonCommit[];
}
export interface SizeCategoryResult {
size: string;
githubSize: string;
reason: string;
}
/**
* Repository for comparing branches and computing size categories.
* Isolated to allow unit tests with mocked Octokit and pure size logic.
*/
export declare class BranchCompareRepository {
getChanges: (owner: string, repository: string, head: string, base: string, token: string) => Promise<BranchComparison>;
getSizeCategoryAndReason: (owner: string, repository: string, head: string, base: string, sizeThresholds: SizeThresholds, labels: Labels, token: string) => Promise<SizeCategoryResult>;
}
45 changes: 12 additions & 33 deletions build/cli/src/data/repository/branch_repository.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { Execution } from "../model/execution";
import { Execution } from '../model/execution';
import { Labels } from '../model/labels';
import { Result } from "../model/result";
import { Result } from '../model/result';
import { SizeThresholds } from '../model/size_thresholds';
/**
* Facade for branch-related operations. Delegates to focused repositories
* (GitCli, Workflow, Merge, BranchCompare) for testability.
*/
export declare class BranchRepository {
private readonly gitCliRepository;
private readonly workflowRepository;
private readonly mergeRepository;
private readonly branchCompareRepository;
fetchRemoteBranches: () => Promise<void>;
getLatestTag: () => Promise<string | undefined>;
getCommitTag: (latestTag: string | undefined) => Promise<string | undefined>;
Expand All @@ -27,35 +35,6 @@ export declare class BranchRepository {
getListOfBranches: (owner: string, repository: string, token: string) => Promise<string[]>;
executeWorkflow: (owner: string, repository: string, branch: string, workflow: string, inputs: Record<string, unknown>, token: string) => Promise<import("@octokit/plugin-paginate-rest/dist-types/types").OctokitResponse<never, 204>>;
mergeBranch: (owner: string, repository: string, head: string, base: string, timeout: number, token: string) => Promise<Result[]>;
getChanges: (owner: string, repository: string, head: string, base: string, token: string) => Promise<{
aheadBy: number;
behindBy: number;
totalCommits: number;
files: {
filename: string;
status: "modified" | "added" | "removed" | "renamed" | "copied" | "changed" | "unchanged";
additions: number;
deletions: number;
changes: number;
blobUrl: string;
rawUrl: string;
contentsUrl: string;
patch: string | undefined;
}[];
commits: {
sha: string;
message: string;
author: {
name?: string;
email?: string;
date?: string;
};
date: string;
}[];
}>;
getSizeCategoryAndReason: (owner: string, repository: string, head: string, base: string, sizeThresholds: SizeThresholds, labels: Labels, token: string) => Promise<{
size: string;
githubSize: string;
reason: string;
}>;
getChanges: (owner: string, repository: string, head: string, base: string, token: string) => Promise<import("./branch_compare_repository").BranchComparison>;
getSizeCategoryAndReason: (owner: string, repository: string, head: string, base: string, sizeThresholds: SizeThresholds, labels: Labels, token: string) => Promise<import("./branch_compare_repository").SizeCategoryResult>;
}
9 changes: 9 additions & 0 deletions build/cli/src/data/repository/git_cli_repository.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* Repository for Git operations executed via CLI (exec).
* Isolated to allow unit tests with mocked @actions/exec and @actions/core.
*/
export declare class GitCliRepository {
fetchRemoteBranches: () => Promise<void>;
getLatestTag: () => Promise<string | undefined>;
getCommitTag: (latestTag: string | undefined) => Promise<string | undefined>;
}
8 changes: 8 additions & 0 deletions build/cli/src/data/repository/merge_repository.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Result } from '../model/result';
/**
* Repository for merging branches (via PR or direct merge).
* Isolated to allow unit tests with mocked Octokit.
*/
export declare class MergeRepository {
mergeBranch: (owner: string, repository: string, head: string, base: string, timeout: number, token: string) => Promise<Result[]>;
}
1 change: 1 addition & 0 deletions build/cli/src/data/repository/workflow_repository.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { WorkflowRun } from "../model/workflow_run";
export declare class WorkflowRepository {
getWorkflows: (params: Execution) => Promise<WorkflowRun[]>;
getActivePreviousRuns: (params: Execution) => Promise<WorkflowRun[]>;
executeWorkflow: (owner: string, repository: string, branch: string, workflow: string, inputs: Record<string, unknown>, token: string) => Promise<import("@octokit/plugin-paginate-rest/dist-types/types").OctokitResponse<never, 204>>;
}
5 changes: 5 additions & 0 deletions build/cli/src/prompts/answer_issue_help.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type AnswerIssueHelpParams = {
description: string;
projectContextInstruction: string;
};
export declare function getAnswerIssueHelpPrompt(params: AnswerIssueHelpParams): string;
11 changes: 11 additions & 0 deletions build/cli/src/prompts/bugbot.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export type BugbotParams = {
projectContextInstruction: string;
owner: string;
repo: string;
headBranch: string;
baseBranch: string;
issueNumber: string;
ignoreBlock: string;
previousBlock: string;
};
export declare function getBugbotPrompt(params: BugbotParams): string;
13 changes: 13 additions & 0 deletions build/cli/src/prompts/bugbot_fix.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export type BugbotFixParams = {
projectContextInstruction: string;
owner: string;
repo: string;
headBranch: string;
baseBranch: string;
issueNumber: string;
prNumberLine: string;
findingsBlock: string;
userComment: string;
verifyBlock: string;
};
export declare function getBugbotFixPrompt(params: BugbotFixParams): string;
7 changes: 7 additions & 0 deletions build/cli/src/prompts/bugbot_fix_intent.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type BugbotFixIntentParams = {
projectContextInstruction: string;
findingsBlock: string;
parentBlock: string;
userComment: string;
};
export declare function getBugbotFixIntentPrompt(params: BugbotFixIntentParams): string;
6 changes: 6 additions & 0 deletions build/cli/src/prompts/check_comment_language.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type CheckCommentLanguageParams = {
locale: string;
commentBody: string;
};
export declare function getCheckCommentLanguagePrompt(params: CheckCommentLanguageParams): string;
export declare function getTranslateCommentPrompt(params: CheckCommentLanguageParams): string;
8 changes: 8 additions & 0 deletions build/cli/src/prompts/check_progress.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type CheckProgressParams = {
projectContextInstruction: string;
issueNumber: string;
baseBranch: string;
currentBranch: string;
issueDescription: string;
};
export declare function getCheckProgressPrompt(params: CheckProgressParams): string;
5 changes: 5 additions & 0 deletions build/cli/src/prompts/cli_do.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type CliDoParams = {
projectContextInstruction: string;
userPrompt: string;
};
export declare function getCliDoPrompt(params: CliDoParams): string;
5 changes: 5 additions & 0 deletions build/cli/src/prompts/fill.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* Replaces {{paramName}} placeholders in a template with values from params.
* Missing keys are left as {{paramName}}.
*/
export declare function fillTemplate(template: string, params: Record<string, string>): string;
68 changes: 68 additions & 0 deletions build/cli/src/prompts/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import type { AnswerIssueHelpParams } from './answer_issue_help';
import type { ThinkParams } from './think';
import type { UpdatePullRequestDescriptionParams } from './update_pull_request_description';
import type { UserRequestParams } from './user_request';
import type { RecommendStepsParams } from './recommend_steps';
import type { CheckProgressParams } from './check_progress';
import type { CheckCommentLanguageParams } from './check_comment_language';
import type { CliDoParams } from './cli_do';
import type { BugbotParams } from './bugbot';
import type { BugbotFixParams } from './bugbot_fix';
import type { BugbotFixIntentParams } from './bugbot_fix_intent';
export { fillTemplate } from './fill';
export { getAnswerIssueHelpPrompt } from './answer_issue_help';
export type { AnswerIssueHelpParams } from './answer_issue_help';
export { getThinkPrompt } from './think';
export type { ThinkParams } from './think';
export { getUpdatePullRequestDescriptionPrompt } from './update_pull_request_description';
export type { UpdatePullRequestDescriptionParams } from './update_pull_request_description';
export { getUserRequestPrompt } from './user_request';
export type { UserRequestParams } from './user_request';
export { getRecommendStepsPrompt } from './recommend_steps';
export type { RecommendStepsParams } from './recommend_steps';
export { getCheckProgressPrompt } from './check_progress';
export type { CheckProgressParams } from './check_progress';
export { getCheckCommentLanguagePrompt, getTranslateCommentPrompt, } from './check_comment_language';
export type { CheckCommentLanguageParams } from './check_comment_language';
export { getCliDoPrompt } from './cli_do';
export type { CliDoParams } from './cli_do';
export { getBugbotPrompt } from './bugbot';
export type { BugbotParams } from './bugbot';
export { getBugbotFixPrompt } from './bugbot_fix';
export type { BugbotFixParams } from './bugbot_fix';
export { getBugbotFixIntentPrompt } from './bugbot_fix_intent';
export type { BugbotFixIntentParams } from './bugbot_fix_intent';
/** Known prompt names for getPrompt() */
export declare const PROMPT_NAMES: {
readonly ANSWER_ISSUE_HELP: "answer_issue_help";
readonly THINK: "think";
readonly UPDATE_PULL_REQUEST_DESCRIPTION: "update_pull_request_description";
readonly USER_REQUEST: "user_request";
readonly RECOMMEND_STEPS: "recommend_steps";
readonly CHECK_PROGRESS: "check_progress";
readonly CHECK_COMMENT_LANGUAGE: "check_comment_language";
readonly TRANSLATE_COMMENT: "translate_comment";
readonly CLI_DO: "cli_do";
readonly BUGBOT: "bugbot";
readonly BUGBOT_FIX: "bugbot_fix";
readonly BUGBOT_FIX_INTENT: "bugbot_fix_intent";
};
export type PromptName = (typeof PROMPT_NAMES)[keyof typeof PROMPT_NAMES];
type PromptParamsMap = {
[PROMPT_NAMES.ANSWER_ISSUE_HELP]: AnswerIssueHelpParams;
[PROMPT_NAMES.THINK]: ThinkParams;
[PROMPT_NAMES.UPDATE_PULL_REQUEST_DESCRIPTION]: UpdatePullRequestDescriptionParams;
[PROMPT_NAMES.USER_REQUEST]: UserRequestParams;
[PROMPT_NAMES.RECOMMEND_STEPS]: RecommendStepsParams;
[PROMPT_NAMES.CHECK_PROGRESS]: CheckProgressParams;
[PROMPT_NAMES.CHECK_COMMENT_LANGUAGE]: CheckCommentLanguageParams;
[PROMPT_NAMES.TRANSLATE_COMMENT]: CheckCommentLanguageParams;
[PROMPT_NAMES.CLI_DO]: CliDoParams;
[PROMPT_NAMES.BUGBOT]: BugbotParams;
[PROMPT_NAMES.BUGBOT_FIX]: BugbotFixParams;
[PROMPT_NAMES.BUGBOT_FIX_INTENT]: BugbotFixIntentParams;
};
/**
* Returns a filled prompt by name. Params must match the prompt's expected keys.
*/
export declare function getPrompt(name: PromptName, params: PromptParamsMap[PromptName]): string;
6 changes: 6 additions & 0 deletions build/cli/src/prompts/recommend_steps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type RecommendStepsParams = {
projectContextInstruction: string;
issueNumber: string;
issueDescription: string;
};
export declare function getRecommendStepsPrompt(params: RecommendStepsParams): string;
6 changes: 6 additions & 0 deletions build/cli/src/prompts/think.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type ThinkParams = {
projectContextInstruction: string;
contextBlock: string;
question: string;
};
export declare function getThinkPrompt(params: ThinkParams): string;
8 changes: 8 additions & 0 deletions build/cli/src/prompts/update_pull_request_description.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type UpdatePullRequestDescriptionParams = {
projectContextInstruction: string;
baseBranch: string;
headBranch: string;
issueNumber: string;
issueDescription: string;
};
export declare function getUpdatePullRequestDescriptionPrompt(params: UpdatePullRequestDescriptionParams): string;
10 changes: 10 additions & 0 deletions build/cli/src/prompts/user_request.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type UserRequestParams = {
projectContextInstruction: string;
owner: string;
repo: string;
headBranch: string;
baseBranch: string;
issueNumber: string;
userComment: string;
};
export declare function getUserRequestPrompt(params: UserRequestParams): string;
6 changes: 0 additions & 6 deletions build/cli/src/usecase/actions/check_progress_use_case.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ export declare class CheckProgressUseCase implements ParamUseCase<Execution, Res
* HTTP-level retries are handled by AiRepository (OPENCODE_MAX_RETRIES).
*/
private fetchProgressAttempt;
/**
* Builds the progress prompt for the OpenCode agent. We do not send the diff from our side:
* we tell the agent the base (parent) branch and current branch so it can run `git diff`
* in the workspace and compute the full diff itself.
*/
private buildProgressPrompt;
/**
* Returns true if the reasoning text looks truncated (e.g. ends with ":" or trailing spaces,
* or no sentence-ending punctuation), so we can append a note in the comment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@ export declare class UpdatePullRequestDescriptionUseCase implements ParamUseCase
private issueRepository;
private projectRepository;
invoke(param: Execution): Promise<Result[]>;
/**
* Builds the PR description prompt. We do not send the diff from our side:
* we pass the base and head branch so the OpenCode agent can run `git diff`
* in the workspace. The agent must read the repo's PR template and fill it
* with the same structure (sections, headings, checkboxes).
*/
private buildPrDescriptionPrompt;
}
Loading