Freestyle Docs

Freestyle / Docs

Freestyle Git

Create and manage multi-tenant Git repositories for user- and agent-generated code.

Freestyle Git is hosted Git designed for products that manage code on behalf of users or AI agents. You can create repositories by API, grant scoped Git access, inspect repository contents, search code, attach automation triggers, and sync with GitHub.

Create A Repository

import { freestyle } from "freestyle";

const { repo } = await freestyle.git.repos.create();

console.log(repo.id);

Clone A Repository

Create an identity, grant repository access, and issue a token.

const { identity } = await freestyle.identities.create();

await identity.permissions.git.grant({
  permission: "write",
  repoId: repo.id,
});

const { token } = await identity.tokens.create();

console.log(
  `git clone https://x-access-token:${token}@git.freestyle.sh/${repo.id}`,
);

Use the token with native Git:

git clone https://x-access-token:<token>@git.freestyle.sh/<repo-id>

Read Files By API

const ref = freestyle.git.repos.ref({ repoId: repo.id });

const file = await ref.contents.get({ path: "README.md" });
const content = atob(file.content);

console.log(content);
esc