Official

git

Built-in git UI (JavaScript UI plugin).

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/git@0.3.2

Permissions in 0.3.2

  • Run git commands git.writeHighRuns any git command.Stage, commit, switch branches and sync with the remote
  • Use your agents' models models.useHighRuns prompts through the agents you enabled.Write commit messages and pull requests with the cheapest model of your agents, on your own account
  • Read chats chats.readMediumReads your transcripts and chat lists.Refresh when an agent finishes a turn
  • Run named programs processMediumStarts the listed programs.Find and open the branch's pull request with the GitHub CLIPrograms: gh
  • Read git status and diffs git.readLowReads git status and diffs.Show the repository's status and diffs, and follow its changes
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Show the source control button and panelSlots: railright

Files

controller.ts4.3 KB
// Own one repository status reader and one panel state in the plugin scope.
// Changes during a read coalesce into one follow-up read, just as before conversion.
// Each status the panel shows also tells the pull request lookup which branch is on screen.
import * as Context from "effect/Context";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Stream from "effect/Stream";
import { Host, Plugin, Services } from "divergence/effect";
import type { ViewHandle } from "divergence";
import type { Tabs } from "../tabs/contract.ts";
import { makeActions } from "./actions.ts";
import { makePulls } from "./pulls.ts";
import { initialState } from "./status.ts";
import { makeWriter } from "./writer.ts";

const makeGit = Effect.fn("Git.make")(function* () {
  const host = yield* Host;
  const plugin = yield* Plugin;
  const services = yield* Services;
  const scope = yield* Effect.scope;
  const state = initialState();
  const views: ViewHandle[] = [];
  const redraw = () => {
    for (const view of views) view.update();
  };
  let loading = false;
  let again = false;
  // Typed by hand: the pull request lookup it feeds is built from actions that refresh in turn.
  const refresh: () => Effect.Effect<void> = Effect.fn("Git.refresh")(function* () {
    if (!state.workspaceId) return;
    if (loading) {
      again = true;
      return;
    }
    do {
      const workspaceId = state.workspaceId;
      if (!workspaceId) return;
      loading = true;
      yield* host.call("host/git.status", { workspaceId }).pipe(
        Effect.tap((status) =>
          Effect.gen(function* () {
            if (workspaceId !== state.workspaceId) return;
            Object.assign(state, { status, error: null });
            yield* pulls.follow(workspaceId, status);
          }),
        ),
        Effect.catchTag(["HostCallFailed", "NeedsReview", "PermissionNotGranted"], (error) =>
          Effect.sync(() => {
            if (workspaceId === state.workspaceId) state.error = error.message;
          }),
        ),
        Effect.ensuring(
          Effect.sync(() => {
            loading = false;
          }),
        ),
      );
      redraw();
      if (!again) return;
      again = false;
    } while (true);
  });
  const show = Effect.fn("Git.show")(function* (workspaceId: string | undefined) {
    if (!workspaceId || workspaceId === state.workspaceId) return;
    Object.assign(state, { workspaceId, status: null, error: null, confirm: null, menuOpen: false, branchOpen: false });
    // What an agent was writing and the pull request belong to the workspace the user left.
    yield* actions.stopWriting;
    yield* pulls.reset;
    redraw();
    // Older hosts lack watch; preserve their turn-finished/manual-refresh fallback.
    const watch: unknown = plugin.api.host.git.watch;
    if (typeof watch === "function")
      yield* Effect.forkIn(
        host
          .call("host/git.watch", { workspaceId })
          .pipe(
            Effect.catchTag(["HostCallFailed", "NeedsReview", "PermissionNotGranted"], (error) =>
              Effect.sync(() => console.warn(`git watch failed: ${error.message}`)),
            ),
          ),
        scope,
        { startImmediately: true },
      );
    yield* refresh();
  });
  const writer = yield* makeWriter();
  const actions = yield* makeActions(state, writer, refresh, redraw);
  const pulls = yield* makePulls(state, writer, actions.git, redraw);
  /** The Refresh button: the status, and the pull request gh knows of. */
  const reload = Effect.gen(function* () {
    yield* pulls.recheck;
    yield* refresh();
  });
  // Diffs and files need the tabs plugin; without it they stay closed, as
  // the shared request they replaced would have had no reader.
  yield* services.when<typeof Tabs>("divergence/tabs").pipe(
    Stream.runForEach((option) =>
      Effect.sync(() => {
        state.tabs = option._tag === "Some" ? option.value : undefined;
      }),
    ),
    Effect.forkIn(scope, { startImmediately: true }),
  );
  return {
    state,
    views,
    refresh,
    reload,
    show,
    ...actions,
    createPull: pulls.create,
    editPull: pulls.edit,
    cancelPull: pulls.cancel,
    openPull: pulls.open,
    openPullLink: pulls.openLink,
  };
});

export class Git extends Context.Service<Git, Effect.Success<ReturnType<typeof makeGit>>>()("git/Git") {
  static readonly layer = Layer.effect(Git, makeGit());
}

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.3.3latestNov 21, 2026>=5 <630.8 KB6 permissionsListed
0.3.2Nov 16, 2026>=5 <630.4 KB6 permissionsListed
0.3.1Nov 11, 2026>=5 <630.2 KB6 permissionsListed
0.3.0Nov 9, 2026>=5 <629.2 KB6 permissionsListed
0.2.1Oct 27, 2026>=2 <413.6 KB4 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.