Developer

Git API

Read git status, log, branches, and diffs for a project via ctx.sdk.git.

ctx.sdk.git runs read-only git operations against a project: working-tree status, commit log, branches, and diffs. Each call takes the target projectId.

Scope required: git:read

Usage

import { defineMethod } from "@rightplace/applet-sdk/v2";

export default defineMethod("repoOverview", async (ctx, { projectId }) => {
  const status = await ctx.sdk.git.status({ projectId });
  const log = await ctx.sdk.git.log({ projectId, limit: 20 });
  const branches = await ctx.sdk.git.branches({ projectId });
  const diff = await ctx.sdk.git.diff({ projectId, ref: "main" });
  return { status, log, branches, diff };
});

Manifest

Declare the scope in applet.json:

{
  "scopes": ["git:read"]
}

Notes

  • ctx.sdk.git.status({ projectId }) returns the working-tree status for the project.
  • ctx.sdk.git.log({ projectId, limit }) returns recent commits; limit caps the count.
  • ctx.sdk.git.branches({ projectId }) lists the project’s branches.
  • ctx.sdk.git.diff({ projectId, ref }) returns a diff against the given ref.
  • This surface is read-only. It cannot stage, commit, branch, checkout, push, or pull.