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

Permissions in 0.3.1

  • 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

commit.test.ts7.6 KB
// The commit box against a fake host: an agent writes the message when asked or when the box is empty, typing takes
// over from it, Commit and Push pushes after the commit, and a command never runs beside another.
import assert from "node:assert/strict";
import { test } from "node:test";
import type { ModelAgent } from "divergence";
import activate from "./main.ts";
import { answer, fakeApi, held, untilAborted } from "./testing.ts";
import type { FakeOptions } from "./testing.ts";

const agents: ModelAgent[] = [
  {
    id: "agent",
    name: "Agent",
    icon: null,
    model: "big",
    effort: null,
    models: [
      { value: "big", name: "Big", group: null, efforts: [] },
      { value: "big-mini", name: "Big Mini", group: null, efforts: [{ value: "low", name: "Low" }] },
    ],
  },
];
const message = "fix(git): keep the message";

async function withPanel(options: FakeOptions, body: (fake: ReturnType<typeof fakeApi>) => Promise<void>) {
  const fake = fakeApi({ agents, ...options });
  const dispose = activate(fake.api);
  try {
    await fake.settle();
    await body(fake);
  } finally {
    await dispose();
  }
}
const commits = (fake: ReturnType<typeof fakeApi>) => fake.gitRuns().filter((args) => args[0] === "commit");

test("Commit with an empty box has the cheapest model write a message for the changes, and commits only when asked again", async () => {
  await withPanel(
    {
      prompt: async () => answer(`\`\`\`\n${message}\n\`\`\``),
      run: (args) => (args[0] === "diff" ? { stdout: "-old\n+new" } : undefined),
    },
    async (fake) => {
      fake.invoke("git-commit");
      await fake.settle();
      assert.equal(fake.prompts.length, 1);
      assert.deepEqual(
        {
          agentId: fake.prompts[0]?.agentId,
          model: fake.prompts[0]?.model,
          effort: fake.prompts[0]?.effort,
          workspaceId: fake.prompts[0]?.workspaceId,
        },
        { agentId: "agent", model: "big-mini", effort: "low", workspaceId: "w1" },
      );
      assert.match(fake.prompts[0]?.prompt ?? "", /M src\/a\.ts[\s\S]*-old\n\+new/);
      // Nothing is staged, so the message describes every change.
      assert.ok(fake.gitRuns().some((args) => args.join(" ") === "diff --no-color -M"));
      assert.equal(fake.node("git-message")?.["value"], message);
      assert.deepEqual(commits(fake), []);
      fake.invoke("git-commit");
      await fake.settle();
      assert.deepEqual(commits(fake), [["commit", "-q", "-m", message]]);
    },
  );
});

test("typing while the message is written stops the agent and keeps what was typed", async () => {
  const aborted = { value: false };
  await withPanel({ prompt: untilAborted(aborted) }, async (fake) => {
    fake.invoke("git-commit");
    await fake.settle();
    assert.equal(fake.node("git-message")?.["placeholder"], "Writing a commit message…");
    assert.equal(fake.node("git-commit")?.["disabled"], true);
    fake.invoke("git-message", "onChange", { value: "my own" });
    await fake.settle();
    assert.equal(aborted.value, true);
    assert.notEqual(fake.node("git-message")?.["placeholder"], "Writing a commit message…");
    assert.equal(fake.node("git-message")?.["value"], "my own");
    assert.deepEqual(fake.notices, []);
  });
});

test("a message the agent could not write says why and leaves the box as it was", async () => {
  const failed = { ...answer(""), status: "failed" as const, message: "the usage limit is reached" };
  await withPanel({ prompt: async () => failed }, async (fake) => {
    fake.invoke("git-commit");
    await fake.settle();
    assert.deepEqual(fake.notices, ["Could not write a commit message: the usage limit is reached"]);
    assert.equal(fake.node("git-message")?.["value"], "");
  });
  await withPanel({ agents: [] }, async (fake) => {
    fake.invoke("git-commit");
    await fake.settle();
    assert.deepEqual(fake.notices, ["Could not write a commit message: no agent is enabled; turn one on in Settings"]);
  });
});

test("Commit and Push pushes after the commit, and publishes a branch without an upstream", async () => {
  await withPanel({ status: { upstream: "origin/main" } }, async (fake) => {
    fake.invoke("git-message", "onChange", { value: message });
    await fake.settle();
    fake.invoke("git-commit-push");
    await fake.settle();
    assert.deepEqual(fake.gitRuns().slice(-3), [["add", "-A"], ["commit", "-q", "-m", message], ["push"]]);
  });
  await withPanel({ run: (args) => (args[0] === "remote" ? { stdout: "origin\n" } : undefined) }, async (fake) => {
    fake.invoke("git-message", "onChange", { value: message });
    await fake.settle();
    fake.invoke("git-commit-push");
    await fake.settle();
    assert.deepEqual(fake.gitRuns().slice(-2), [["remote"], ["push", "-u", "origin", "main"]]);
  });
});

test("Enter in the box waits for a running command, and a failed commit keeps what was typed meanwhile", async () => {
  const hold = held();
  const run = async (args: readonly string[]) => {
    if (args[0] !== "commit") return {};
    await hold.promise;
    return { code: 1, stderr: "the hook refused it" };
  };
  await withPanel({ run }, async (fake) => {
    fake.invoke("git-message", "onChange", { value: "first" });
    fake.invoke("git-commit");
    await fake.settle();
    fake.invoke("git-message", "onChange", { value: "second" });
    fake.invoke("git-message", "onSubmit");
    await fake.settle();
    assert.equal(commits(fake).length, 1);
    hold.release();
    await fake.settle();
    assert.deepEqual(fake.notices, ["the hook refused it"]);
    assert.equal(fake.node("git-message")?.["value"], "second");
  });
});

test("a command closes the … menu, so nothing in it runs beside the command", async () => {
  await withPanel({}, async (fake) => {
    fake.invoke("git-more");
    await fake.settle();
    assert.equal(fake.node("git-menu")?.["open"], true);
    fake.invoke("git-message", "onChange", { value: message });
    fake.invoke("git-message", "onSubmit");
    await fake.settle();
    assert.equal(fake.node("git-menu")?.["open"], false);
  });
});

test("Enter in the box with nothing to commit runs no git command", async () => {
  await withPanel({ status: { entries: [] } }, async (fake) => {
    fake.invoke("git-message", "onChange", { value: message });
    fake.invoke("git-message", "onSubmit");
    await fake.settle();
    assert.deepEqual(fake.gitRuns(), []);
    assert.deepEqual(fake.notices, []);
    assert.equal(fake.node("git-message")?.["value"], message);
  });
});

test("Push on a detached HEAD asks for a branch instead of pushing one named after it", async () => {
  const detached = { branch: "HEAD (no branch)", upstream: null, entries: [] };
  await withPanel({ status: detached }, async (fake) => {
    assert.match(String(fake.node("git-message")?.["placeholder"]), /a detached HEAD/);
    fake.invoke("git-menu-push");
    await fake.settle();
    assert.deepEqual(fake.gitRuns(), []);
    assert.deepEqual(fake.notices, ["Check out a branch to push."]);
  });
});

test("Undo Last Commit on the first commit says why instead of showing git's error", async () => {
  const run = (args: readonly string[]) => (args[0] === "rev-parse" ? { code: 1 } : undefined);
  await withPanel({ run }, async (fake) => {
    fake.invoke("git-menu-undo");
    await fake.settle();
    assert.deepEqual(fake.gitRuns(), [["rev-parse", "--verify", "-q", "HEAD~1"]]);
    assert.deepEqual(fake.notices, ["The last commit is the repository's first, so there is no commit to go back to."]);
  });
  await withPanel({}, async (fake) => {
    fake.invoke("git-menu-undo");
    await fake.settle();
    assert.deepEqual(fake.gitRuns().at(-1), ["reset", "--soft", "HEAD~1"]);
  });
});

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.