Skip to content
Open
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
10 changes: 9 additions & 1 deletion src/server/api/routers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const githubRouter = createTRPCRouter({
}) => {
const [repoOwner, repoName] = repo?.split("/") ?? [];
const issueText = `${title} ${body}`;
const skipBuild = body.includes("--skip-build");
if (!repoOwner || !repoName || !issueText?.length) {
throw new TRPCError({
code: "BAD_REQUEST",
Expand Down Expand Up @@ -71,7 +72,7 @@ export const githubRouter = createTRPCRouter({
if (extractedIssue.filesToCreate?.length && !title.includes("=>")) {
newTitle += ` => ${extractedIssue.filesToCreate[0]}`;
}
return { title: newTitle, body };
return { title: newTitle, body, skipBuild };
},
),
createIssue: protectedProcedure
Expand All @@ -80,6 +81,7 @@ export const githubRouter = createTRPCRouter({
repo: z.string(),
title: z.string(),
body: z.string().optional(),
skipBuild: z.boolean().optional(),
}),
)
.mutation(
Expand Down Expand Up @@ -107,6 +109,7 @@ export const githubRouter = createTRPCRouter({
repo: repoName,
title,
body,
labels: body?.includes("--skip-build") ? ["skip-build"] : undefined,
});

return { id };
Expand All @@ -119,6 +122,7 @@ export const githubRouter = createTRPCRouter({
id: z.number(),
title: z.string().optional(),
body: z.string().optional(),
skipBuild: z.boolean().optional(),
}),
)
.mutation(
Expand All @@ -145,6 +149,7 @@ export const githubRouter = createTRPCRouter({
issue_number: id,
title,
body,
labels: body?.includes("--skip-build") ? ["skip-build"] : undefined,
});

return { id };
Expand All @@ -159,6 +164,7 @@ export const githubRouter = createTRPCRouter({
newOrExistingFile: z.enum(["new", "existing"]).optional().nullable(),
title: z.string(),
body: z.string(),
skipBuild: z.boolean().optional(),
});

// Type for the expected issue details parsed from the text block
Expand All @@ -180,6 +186,7 @@ export const githubRouter = createTRPCRouter({
" newOrExistingFile: z.enum(['new', 'existing']), // Indicate whether the task is to create a new file or edit an existing file.\n" +
" title: z.string(), // The title of the GitHub issue. If this is a new file, you MUST follow the format: 'Create new file => /path/to/file/new_filename.ext'.\n" +
" body: z.string(), // Copy the ENTIRED DETAILED GitHub issue body as the description. Use Markdown.\n" +
" skipBuild: z.boolean().optional(), // Indicate whether to skip the build process.\n" +
"});\n" +
"REMEMBER: The title MUST be in the format 'Create new file => /path/to/file/new_filename.ext' if this is a new file task.\n" +
"Please provide ONLY an object with the title and description based on the GitHub issue text provided. If there is any extra information or if you do not provide an object that is parsable and passes Zod schema validation for the IssueSchema schema, the system will crash.\n";
Expand All @@ -195,6 +202,7 @@ export const githubRouter = createTRPCRouter({

// Add the @jacob-ai-bot tag to the issue body
issueData.body += `\n\n${AT_MENTION}`;
issueData.skipBuild = issueData.body.includes("--skip-build");

return issueData;
} catch (error) {
Expand Down
6 changes: 5 additions & 1 deletion src/server/code/checkAndCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface CheckAndCommitOptions extends BaseEventData {
newPrReviewers?: string[];
creatingStory?: boolean;
buildErrorAttemptNumber?: number;
skipBuild?: boolean;
}

export async function checkAndCommit({
Expand All @@ -57,17 +58,20 @@ export async function checkAndCommit({
newPrReviewers,
creatingStory,
buildErrorAttemptNumber,
skipBuild,
...baseEventData
}: CheckAndCommitOptions) {
let buildErrorMessage: string | undefined;

try {
await runBuildCheck({
if (!skipBuild) {
await runBuildCheck({
...baseEventData,
path: rootPath,
afterModifications: true,
repoSettings,
});
}
} catch (error) {
const { message } = error as Error;
buildErrorMessage = message;
Expand Down
2 changes: 2 additions & 0 deletions src/server/code/editFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export async function editFiles(params: EditFilesParams) {
const snapshotUrl = getSnapshotUrl(issue.body);
// When we start processing PRs, need to handle appending additionalComments
const issueBody = issue.body ? `\n${issue.body}` : "";
const skipBuild = issueBody.includes("--skip-build");
const issueText = `${issue.title}${issueBody}`;

const extractedIssueTemplateParams = {
Expand Down Expand Up @@ -167,6 +168,7 @@ export async function editFiles(params: EditFilesParams) {
newPrBody: `## Summary:\n\n${issue.body}\n\n## Plan:\n\n${
extractedIssue.stepsToAddressIssue ?? ""
}`,
skipBuild,
newPrReviewers: issue.assignees.map((assignee) => assignee.login),
});
}
11 changes: 9 additions & 2 deletions src/server/github/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,26 @@ interface SimpleRepository {
export async function getIssue(
repository: SimpleRepository,
token: string,
issue_number: number,
issue_number: number
) {
const octokit = new Octokit({
auth: token,
log: console,
userAgent: "jacob",
});

return octokit.issues.get({
const { data } = await octokit.issues.get({
owner: repository.owner.login,
repo: repository.name,
issue_number,
});

const skipBuild = data.body?.includes("--skip-build") ?? false;

return {
...data,
skipBuild,
};
}

export async function createRepoInstalledIssue(
Expand Down
9 changes: 9 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,12 @@ export interface Research {
answer: string;
issueId: number;
}

export interface BuildOptions {
skipBuild: boolean;
}

export interface CheckAndCommitOptions extends BuildOptions {
// Existing properties...
// Add any other existing properties from the CheckAndCommitOptions interface
}