Skip to main content
Use the repository SDKs to manage Tensorlake Git repositories from application code: create repositories, inspect branches and refs, mint Git credentials, push a local worktree, and run server-side merges. Use tl fs for mounted workspace workflows such as mount, snapshot, sync, and promote.

Install and Configure

The SDKs use a Tensorlake API key from the environment.
pip install tensorlake

export TENSORLAKE_API_KEY=tlk_...
PATs are CLI-only. Use an API key with the SDKs.

Create and List Repositories

RepositoryClient is the entry point for repository operations.
from tensorlake import RepositoryClient

with RepositoryClient.from_env() as repos:
    repo = repos.create("agent-outputs", default_branch="main")
    print(repo.url)

    for item in repos.list():
        print(item.name, item.default_branch, item.status)
Later examples assume repos is a RepositoryClient created with from_env() or await fromEnv().

Inspect Branches and Refs

Use info when you want the repository URL, branches, and refs in one call.
from tensorlake import RepositoryClient

repos = RepositoryClient.from_env()
info = repos.info("agent-outputs")

print(info.url)
for branch in info.branches:
    print(branch.name, branch.oid)

Get a Git Credential

Most SDK methods mint short-lived Git credentials automatically. Call credential only when you need to hand a token to git, CI, or another HTTP client.
credential = repos.credential("agent-outputs")

print(credential.git_username)  # always "t"
print(credential.token)         # use as the Git HTTP password

Push a Local Worktree

push_worktree creates one commit from a local directory and updates a branch. It skips .git and honors .gitignore.
report = repos.push_worktree(
    "agent-outputs",
    root=".",
    branch="main",
    message="sync generated output",
)

print(report.commit)
print(report.ref_name)
Pass expect_oid in Python or expectOid in TypeScript when you want the push to fail if the branch moved.

Merge Branches

Use merge to merge one branch or commit into another without cloning the repository. Preflight first when you want to see whether a merge is clean:
report = repos.merge(
    "agent-outputs",
    "main",
    "feature",
    preflight=True,
    deep=True,
)

if report.clean:
    landed = repos.merge(
        "agent-outputs",
        "main",
        "feature",
        message="merge feature into main",
    )
    print(landed.commit)
else:
    for conflict in report.conflicts:
        print(conflict.kind, conflict.path)
By default, a conflicted commit-mode merge publishes nothing and returns a report with clean: false and no commit. Use materialize when you want conflicted files to land with standard Git diff3 markers:
report = repos.merge(
    "agent-outputs",
    "main",
    "feature",
    materialize=True,
    message="merge feature into main",
)

if report.commit and not report.clean:
    record = repos.commit_conflicts("agent-outputs", report.commit)
    for path in (record.paths if record else []):
        print(path.kind, path.path)

API Surface

TaskPythonTypeScript
Create a repositorycreate(repo, default_branch=None)create(repo, { defaultBranch })
List repositorieslist()list()
Delete a repositorydelete(repo)delete(repo)
Fork a repositoryfork(repo, base_repo)fork(repo, baseRepo)
Archive or restorearchive(repo), restore(repo)archive(repo), restore(repo)
Repository URLurl(repo)url(repo)
Branches and refsinfo(repo), branches(repo), refs(repo)info(repo), branches(repo), refs(repo)
Delete a branchdelete_branch(repo, branch)deleteBranch(repo, branch)
Operation historyoperations(repo)operations(repo)
Git credentialcredential(repo=None)credential(repo)
Push local filespush_worktree(repo, root, branch, message, expect_oid=None)pushWorktree(repo, { path, branch, message, expectOid })
Push job statuscommit_status(repo, job_id)commitStatus(repo, jobId)
Merge branchesmerge(repo, ours, theirs, ...)merge(repo, ours, theirs, options)
Conflict recordscommit_conflicts(repo, commit)commitConflicts(repo, commit)

Next Steps

Git Workflows

Use the same repositories with ordinary git clone, git push, and git fetch.

Generated Code

Store code, docs, and assets produced by coding agents at repository scale.

Merging Changes

Learn the merge behavior behind SDK and CLI merge operations.