Skip to content

Commit 835f3c4

Browse files
feat(api): add defaultBranch, isFork, and isArchived to /api/repos response
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1d57be3 commit 835f3c4

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

packages/mcp/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ server.tool(
211211
name: repo.repoName,
212212
url: repo.webUrl,
213213
pushedAt: repo.pushedAt,
214+
defaultBranch: repo.defaultBranch,
215+
isFork: repo.isFork,
216+
isArchived: repo.isArchived,
214217
})),
215218
totalCount: result.totalCount,
216219
})

packages/mcp/src/schemas.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ export const repositoryQuerySchema = z.object({
155155
imageUrl: z.string().optional(),
156156
indexedAt: z.coerce.date().optional(),
157157
pushedAt: z.coerce.date().optional(),
158+
defaultBranch: z.string().optional(),
159+
isFork: z.boolean(),
160+
isArchived: z.boolean(),
158161
});
159162

160163
export const listReposResponseSchema = repositoryQuerySchema.array();

packages/web/src/actions.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import InviteUserEmail from "./emails/inviteUserEmail";
2828
import JoinRequestApprovedEmail from "./emails/joinRequestApprovedEmail";
2929
import JoinRequestSubmittedEmail from "./emails/joinRequestSubmittedEmail";
3030
import { AGENTIC_SEARCH_TUTORIAL_DISMISSED_COOKIE_NAME, MOBILE_UNSUPPORTED_SPLASH_SCREEN_DISMISSED_COOKIE_NAME, SINGLE_TENANT_ORG_DOMAIN, SOURCEBOT_GUEST_USER_ID, SOURCEBOT_SUPPORT_EMAIL } from "./lib/constants";
31-
import { orgDomainSchema, orgNameSchema, repositoryQuerySchema } from "./lib/schemas";
32-
import { ApiKeyPayload, TenancyMode } from "./lib/types";
31+
import { orgDomainSchema, orgNameSchema } from "./lib/schemas";
32+
import { ApiKeyPayload, RepositoryQuery, TenancyMode } from "./lib/types";
3333
import { withAuthV2, withOptionalAuthV2 } from "./withAuthV2";
3434
import { getBrowsePath } from "./app/[domain]/browse/hooks/utils";
3535

@@ -479,7 +479,7 @@ export const getRepos = async ({
479479

480480
const baseUrl = env.AUTH_URL;
481481

482-
return repos.map((repo) => repositoryQuerySchema.parse({
482+
return repos.map((repo) => ({
483483
codeHostType: repo.external_codeHostType,
484484
repoId: repo.id,
485485
repoName: repo.name,
@@ -494,7 +494,10 @@ export const getRepos = async ({
494494
imageUrl: repo.imageUrl ?? undefined,
495495
indexedAt: repo.indexedAt ?? undefined,
496496
pushedAt: repo.pushedAt ?? undefined,
497-
}))
497+
defaultBranch: repo.defaultBranch ?? undefined,
498+
isFork: repo.isFork,
499+
isArchived: repo.isArchived,
500+
} satisfies RepositoryQuery))
498501
}));
499502

500503
/**

packages/web/src/app/api/(server)/repos/listReposApi.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { sew } from "@/actions";
2-
import { repositoryQuerySchema } from "@/lib/schemas";
3-
import { ListReposQueryParams } from "@/lib/types";
2+
import { ListReposQueryParams, RepositoryQuery } from "@/lib/types";
43
import { withOptionalAuthV2 } from "@/withAuthV2";
54
import { getBrowsePath } from "@/app/[domain]/browse/hooks/utils";
65
import { env } from "@sourcebot/shared";
@@ -34,7 +33,7 @@ export const listRepos = async ({ query, page, perPage, sort, direction }: ListR
3433
]);
3534

3635
return {
37-
data: repos.map((repo) => repositoryQuerySchema.parse({
36+
data: repos.map((repo) => ({
3837
codeHostType: repo.external_codeHostType,
3938
repoId: repo.id,
4039
repoName: repo.name,
@@ -49,7 +48,10 @@ export const listRepos = async ({ query, page, perPage, sort, direction }: ListR
4948
imageUrl: repo.imageUrl ?? undefined,
5049
indexedAt: repo.indexedAt ?? undefined,
5150
pushedAt: repo.pushedAt ?? undefined,
52-
})),
51+
defaultBranch: repo.defaultBranch ?? undefined,
52+
isFork: repo.isFork,
53+
isArchived: repo.isArchived,
54+
} satisfies RepositoryQuery)),
5355
totalCount,
5456
};
5557
})

packages/web/src/lib/schemas.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ export const repositoryQuerySchema = z.object({
2222
imageUrl: z.string().optional(),
2323
indexedAt: z.coerce.date().optional(),
2424
pushedAt: z.coerce.date().optional(),
25+
defaultBranch: z.string().optional(),
26+
isFork: z.boolean(),
27+
isArchived: z.boolean(),
2528
});
2629

2730
export const searchContextQuerySchema = z.object({

0 commit comments

Comments
 (0)