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

prompts.ts4.2 KB
// What the plugin asks an agent to write, the model it asks, and how it reads the answers.
// Pure, so the choice of model and the parsing are tested without a host.
import type { ModelAgent, ModelChoice } from "divergence";
import type { Entry } from "./status.ts";

// Words that name the small, cheap tier of a model family across vendors.
const SMALL = new Set(["mini", "nano", "haiku", "flash", "lite", "small"]);
const words = (text: string) => text.toLowerCase().split(/[^a-z0-9]+/);
const isSmall = (model: ModelChoice) => [...words(model.value), ...words(model.name)].some((word) => SMALL.has(word));
// A commit message needs little thought: low effort where the model offers it.
const low = (model: ModelChoice | undefined) =>
  model?.efforts.some((effort) => effort.value === "low") ? { effort: "low" } : {};

export interface WriterModel {
  readonly agentId: string;
  readonly model?: string;
  readonly effort?: string;
}

/** The cheapest model among the enabled agents: the first small model in the host's order, else the first agent's own
 * default. `null` when no agent could list its models. */
export function writerModel(agents: readonly ModelAgent[]): WriterModel | null {
  const ready = agents.filter((agent): agent is Exclude<ModelAgent, { error: string }> => !("error" in agent));
  for (const agent of ready) {
    const model = agent.models.find(isSmall);
    if (model) return { agentId: agent.id, model: model.value, ...low(model) };
  }
  const agent = ready[0];
  if (!agent) return null;
  return { agentId: agent.id, ...low(agent.models.find((model) => model.value === agent.model)) };
}

// At most this much of a diff goes into a prompt, about ten thousand tokens.
const DIFF_LIMIT = 40_000;
const limit = (text: string) =>
  text.length > DIFF_LIMIT ? `${text.slice(0, DIFF_LIMIT)}\n[The rest is left out because it is long.]` : text;
const ONLY_THE_TEXT =
  "Do not run tools or read files, since everything you need is below, and answer with the text alone, without quotes, code fences or comments.";

export function commitPrompt(input: { branch: string | null; files: readonly Entry[]; diff: string }): string {
  const files = input.files.map((file) => `${file.letter} ${file.origPath ? `${file.origPath} -> ` : ""}${file.path}`);
  return [
    "Write the git commit message for the changes below.",
    "Use the Conventional Commits form: a subject line `type(scope): summary`, where the type is feat, fix, refactor, perf, docs, test, build, ci, style or chore, the scope is optional, and the summary is in the imperative mood, at most 72 characters long and without a full stop. Add a body only when the subject cannot carry the change: a blank line, then at most three short lines.",
    ONLY_THE_TEXT,
    "",
    `Branch: ${input.branch ?? "(detached)"}`,
    "",
    "Files:",
    ...files,
    "",
    "Diff:",
    limit(input.diff) || "(only new files, listed above)",
  ].join("\n");
}

export function pullPrompt(input: { head: string; base: string; commits: string; stat: string }): string {
  return [
    "Write the title and the description of a GitHub pull request for the commits below.",
    "The title is one line of at most 72 characters that says what the change does. The description is Markdown: a few short bullet points on what changed and why.",
    "Put the title on the first line, then a blank line, then the description.",
    ONLY_THE_TEXT,
    "",
    `Branch ${input.head} into ${input.base}.`,
    "",
    "Commits:",
    limit(input.commits),
    "",
    "Files changed:",
    limit(input.stat),
  ].join("\n");
}

/** The answer without a code fence around it or trailing spaces. */
export function cleanMessage(text: string): string {
  const trimmed = text.trim();
  const fenced = /^```[^\n]*\n([\s\S]*?)\n?```$/.exec(trimmed)?.[1] ?? trimmed;
  return fenced
    .split("\n")
    .map((line) => line.trimEnd())
    .join("\n")
    .trim();
}

/** A pull request answer as its title (the first line, without a heading mark or a `Title:` label) and description. */
export function splitPull(text: string): { title: string; body: string } {
  const [first = "", ...rest] = cleanMessage(text).split("\n");
  const title = first
    .replace(/^#+\s*/, "")
    .replace(/^title:\s*/i, "")
    .trim();
  return { title, body: rest.join("\n").trim() };
}

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.