Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh
38 linesCodeBlameRaw
1import type { ProviderKind } from "@g1t/contracts";
2
3/**
4 * Where each kind of integration is set up: alerts and trackers have setup
5 * pages under `-/integrations/<section>`, which the directory at
6 * `-/integrations` links into. AI providers are not integrations: they are
7 * the workspace's own AI settings, at `-/ai`.
8 */
9export type IntegrationsSection = "alerts" | "trackers";
10
11const SECTIONS: Record<ProviderKind, IntegrationsSection> = {
12 alerts: "alerts",
13 tracker: "trackers",
14};
15
16/** The page, under `-/`, a kind of integration is set up on. */
17export function providerPage(kind: ProviderKind): string {
18 return `integrations/${SECTIONS[kind]}`;
19}
20
21/** The kind of integration a section's page is for, or null when it is no section. */
22export function sectionKind(section: string | undefined): ProviderKind | null {
23 const found = (Object.keys(SECTIONS) as ProviderKind[]).find((kind) => SECTIONS[kind] === section);
24 return found ?? null;
25}
26
27/**
28 * Where an older link to the AI providers' page (`-/integrations/models`,
29 * or the directory's `?add=anthropic`) leads now: the workspace's AI page,
30 * keeping the query, and opening the form when it names a provider. Such
31 * links are out in the wild, so they keep working.
32 */
33export function aiPagePath(slug: string, search: string): string {
34 const query = new URLSearchParams(search);
35 query.delete("_routes");
36 const rest = query.toString();
37 return `/${slug}/-/ai${rest ? `?${rest}` : ""}${query.has("add") ? "#add" : ""}`;
38}