22 lines · 932 B · TypeScript
RawDownload
import type { GitAction, GitState } from "@/lib/agent/contracts/git";import { safeJson } from "@/lib/agent/safe-json"; export async function loadGitState(cwd: string): Promise<GitState> {  const response = await fetch(`/api/agent/git?cwd=${encodeURIComponent(cwd)}`, {    cache: "no-store",  });  const payload = await safeJson<GitState & { error?: string }>(response);  if (!response.ok) throw new Error(payload.error || "Failed to load git state");  return payload;} export async function runGitAction(cwd: string, action: GitAction): Promise<GitState> {  const response = await fetch(`/api/agent/git?cwd=${encodeURIComponent(cwd)}`, {    method: "POST",    headers: { "Content-Type": "application/json" },    body: JSON.stringify(action),  });  const payload = await safeJson<GitState & { error?: string }>(response);  if (!response.ok) throw new Error(payload.error || "Git action failed");  return payload;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t