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.3

Permissions in 0.3.3

  • 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

views/controls.tsx5.8 KB
// The commit box (message field, primary action), branch picker and repository menu trees.
// HTM whitespace is significant; keep these templates out of Prettier's HTML formatter.
import type { GitStatus } from "divergence";
import type { EffectViewContext } from "divergence/effect";
import type { Git } from "../controller.ts";
import { branchOptions, MENU, onBranch, primaryAction } from "../status.ts";
import type { Groups } from "../status.ts";
import { column, fill, row, panelRow, menuCard, POPOVER_TOGGLE } from "./layout.ts";

export function controls(ctx: EffectViewContext<object>, actions: Git["Service"]) {
  const { state } = actions;
  // The message box. Commit with it empty has an agent write the message; typing stays open
  // while the agent writes, and replaces what it was writing.
  function messageField(status: GitStatus) {
    const branch = !status.branch ? "this branch" : onBranch(status) ? `"${status.branch}"` : "a detached HEAD";
    return (
      <input id="git-message" multiline submitOnEnter value={state.message} placeholder={state.writing ? "Writing a commit message…" : `Message (⏎ to commit on ${branch})`} onChange={(e: { value: string }) => {
                    ctx.run(actions.typed(e.value));
                    ctx.update();
                  }} onSubmit={() => ctx.run(actions.commit())} />
    );
  }

  function primaryButton(status: GitStatus, total: number) {
    const disabled = !!state.busy;
    if (primaryAction(status, total) === "commit") {
      // An empty box asks an agent for a message, so only an agent already writing one holds the buttons.
      const waiting = disabled || (state.writing && !state.message.trim());
      const commit = <button id="git-commit" icon="check" label="Commit" variant="accent" disabled={waiting} onClick={() => ctx.run(actions.commit())} />;
      if (!onBranch(status)) return commit;
      return (
        <div {...row} gap="small">
          <div {...column} {...fill}>{commit}</div>
          <div {...column} {...fill}><button id="git-commit-push" icon="arrow-up" label="Commit and Push" disabled={waiting} onClick={() => ctx.run(actions.commitAndPush())} /></div>
        </div>
      );
    }
    if (primaryAction(status, total) === "publish") {
      return <button id="git-publish" icon="cloud-upload" label="Publish Branch" variant="accent" disabled={disabled} onClick={() => ctx.run(actions.publish())} />;
    }
    if (primaryAction(status, total) === "sync") {
      const counts = [status.behind ? `${status.behind}↓` : null, status.ahead ? `${status.ahead}↑` : null]
        .filter(Boolean)
        .join(" ");
      return <button id="git-sync" icon="refresh-cw" label={`Sync Changes ${counts}`} variant="accent" disabled={disabled} onClick={() => ctx.run(actions.sync())} />;
    }
    return <button id="git-commit" icon="check" label="Commit" variant="accent" disabled />;
  }

  function branchPicker(status: GitStatus) {
    const { query: q, shown, create } = branchOptions(state.branches, state.branchQuery);
    const items = [
      ...(create
        ? [
            {
              id: "git-branch-create",
              label: `Create branch "${q}"`,
              icon: "plus",
              onClick: () => ctx.run(actions.checkout(q, true)),
            },
          ]
        : []),
      ...shown.map((b) => ({
        id: `git-branch-${b}`,
        label: b,
        icon: "git-branch",
        selected: b === status.branch,
        onClick: () => ctx.run(actions.checkout(b, false)),
      })),
    ];
    return (
      <popover id="git-branch-popover" open={state.branchOpen} align="start" width={280} onToggle={(e: { open: boolean }) => ctx.run(actions.openBranches(e.open))} onDismiss={() => {
          state.branchOpen = false;
          ctx.update();
        }}>
        <div {...panelRow} id="git-branch" onPress={POPOVER_TOGGLE ? undefined : () => ctx.run(actions.openBranches(!state.branchOpen))}>
              <icon name="git-branch" small tone="muted" />
              <text style="body" size="xs" tone="muted" truncate>{status.branch ?? "(no branch)"}</text>
            </div>
        <div {...menuCard}>
              <input id="git-branch-query" value={state.branchQuery} placeholder="Switch to or create a branch" onChange={(e: { value: string }) => {
                            state.branchQuery = e.value;
                            ctx.update();
                          }} onSubmit={() => {
                            if (create) ctx.run(actions.checkout(q, true));
                            else if (shown[0]) ctx.run(actions.checkout(shown[0], false));
                          }} />
              <div {...column} gap="small" padding="small" maxHeight={280} overflowY="scroll">
                    {items.length ? <list id="git-branch-list" items={items} /> : <text style="muted">No branches.</text>}
                  </div>
            </div>
      </popover>
    );
  }

  function setMenu(open: boolean) {
    state.menuOpen = open;
    ctx.update();
  }

  function menu(status: GitStatus, g: Groups) {
    const items = MENU.map((item) => ({
      id: `git-menu-${item.action}`,
      label: item.label,
      icon: item.icon,
      onClick: () => {
        setMenu(false);
        ctx.run(actions.menuAction(item.action, status, g));
      },
    }));
    return (
      <popover id="git-menu" open={state.menuOpen} align="end" width={240} onToggle={state.busy ? undefined : (e: { open: boolean }) => setMenu(e.open)} onDismiss={() => setMenu(false)}>
        <button id="git-more" icon="ellipsis" variant="ghost" small tooltip="More actions" disabled={!!state.busy} onClick={POPOVER_TOGGLE ? undefined : () => setMenu(!state.menuOpen)} />
        <div {...menuCard}><list id="git-menu-list" items={items} /></div>
      </popover>
    );
  }

  return { messageField, primaryButton, branchPicker, menu };
}

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.