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
Files
prompts.test.ts3.5 KB
// The model that writes for the panel, the prompts it gets and how its answers are read.
import assert from "node:assert/strict";
import { test } from "node:test";
import type { ModelAgent } from "divergence";
import { cleanMessage, commitPrompt, pullPrompt, splitPull, writerModel } from "./prompts.ts";
import type { Entry } from "./status.ts";
const efforts = (...values: string[]) => values.map((value) => ({ value, name: value }));
const model = (value: string, name = value, levels = efforts("low", "high")) => ({
value,
name,
group: null,
efforts: levels,
});
const agent = (id: string, models: ReturnType<typeof model>[], current: string | null = null): ModelAgent => ({
id,
name: id,
icon: null,
model: current,
effort: null,
models,
});
test("the writer is the first small model in the host's order, at low effort", () => {
const agents = [
{ id: "broken", name: "Broken", icon: null, models: [], error: "not signed in" } as const,
agent("first", [model("big-5"), model("gemini-2.5-pro")]),
agent("second", [model("big-5"), model("big-5-mini", "Big 5 Mini", efforts("minimal", "low", "high"))]),
agent("third", [model("haiku", "Haiku")]),
];
assert.deepEqual(writerModel(agents), { agentId: "second", model: "big-5-mini", effort: "low" });
assert.deepEqual(writerModel([agent("one", [model("fast-flash", "Flash", efforts("high"))])]), {
agentId: "one",
model: "fast-flash",
});
});
test("without a small model the first agent writes with its own model, and with no agent nobody does", () => {
assert.deepEqual(writerModel([agent("one", [model("big"), model("bigger")], "bigger")]), {
agentId: "one",
effort: "low",
});
assert.deepEqual(writerModel([agent("one", [])]), { agentId: "one" });
assert.equal(writerModel([{ id: "x", name: "X", icon: null, models: [], error: "down" }]), null);
assert.equal(writerModel([]), null);
});
test("answers lose a code fence and trailing spaces; a pull request answer splits into title and body", () => {
assert.equal(
cleanMessage("```text\nfix(git): keep the message \n\nBody line \n```\n"),
"fix(git): keep the message\n\nBody line",
);
assert.equal(cleanMessage(" feat: add a thing "), "feat: add a thing");
assert.deepEqual(splitPull("Title: Add pull requests\n\n- Writes the title\n- Opens it"), {
title: "Add pull requests",
body: "- Writes the title\n- Opens it",
});
assert.deepEqual(splitPull("# Add pull requests"), { title: "Add pull requests", body: "" });
});
test("the prompts carry the files, the branch, the commits, and at most 40,000 characters of a diff", () => {
const files: Entry[] = [
{ path: "src/new.ts", origPath: "src/old.ts", staged: "R", unstaged: " ", letter: "R", side: "staged" },
{ path: "README.md", staged: "M", unstaged: " ", letter: "M", side: "staged" },
];
const prompt = commitPrompt({ branch: "feature", files, diff: "x".repeat(50_000) });
assert.match(prompt, /Conventional Commits/);
assert.match(prompt, /Branch: feature/);
assert.match(prompt, /R src\/old\.ts -> src\/new\.ts\nM README\.md/);
assert.ok(!prompt.includes("x".repeat(40_001)));
assert.match(prompt, /The rest is left out/);
assert.match(commitPrompt({ branch: null, files, diff: "" }), /Branch: \(detached\)[\s\S]*only new files/);
const pull = pullPrompt({ head: "feature", base: "main", commits: "* fix: one", stat: " a.ts | 2 +-" });
assert.match(pull, /Branch feature into main\./);
assert.match(pull, /\* fix: one[\s\S]*a\.ts \| 2 \+-/);
});
No comments yet.