flagon-io/g1t

public

Git for AI scale: a forge for thousands of agents working on the same code at once.

g1t/packages/contracts/src/names.ts

28 lines1,167 bytesCodeBlame
// Namespaces follow GitHub's rules (no leading, trailing or doubled hyphens),
// so "--" can never appear inside one.
const NAMESPACE = /^[a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38}$/;
const REPO_NAME = /^[a-z0-9._-]{1,100}$/;

/** Routes and reserved words that may not be registered as usernames. */
const RESERVED = new Set([
  "api", "mcp", "login", "logout", "register", "new", "settings", "search",
  "admin", "auth", "integrations", "pulls", "issues", "verify", "forgot", "reset", "device", "workspaces", "u", "oauth", "assets", "avatars", "docs", "explore", "g1t", "about", "pricing",
  // Trust pages on g1t.sh, and names kept for them.
  "policies", "security", "support", "status", "terms", "privacy", "help", "blog",
  // Invite links, and the waitlist.
  "invite", "invites", "waitlist",
]);

export function isValidNamespace(value: string): boolean {
  return NAMESPACE.test(value) && !RESERVED.has(value);
}

export function isValidRepoName(value: string): boolean {
  return (
    REPO_NAME.test(value) &&
    !value.startsWith(".") &&
    !value.endsWith(".git") &&
    // `/<workspace>/-/…` holds the workspace's own pages.
    value !== "-"
  );
}