Official
chat
Built-in chat 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/chat@0.2.6
Permissions in 0.2.6
Files
app-commands.test.ts5.5 KB
// The app's own slash commands open the chat's settings menu or the title
// field from anywhere in the prompt, and run in place of an agent's.
import assert from "node:assert/strict";
import test from "node:test";
import * as Effect from "effect/Effect";
import type { ConfigOption } from "divergence";
import { InputLedger, withController } from "./testing.ts";
import { acceptPicked, onChange } from "./composer.ts";
import { entries } from "./picker.ts";
import { removeRange } from "./segments.ts";
import { rename, runAppCommand, startRename } from "./app-commands.ts";
import type { Controller } from "./controller.ts";
class OptionsLedger extends InputLedger {
updates: unknown[] = [];
options: ConfigOption[] = [];
override async call(method: string, raw: unknown): Promise<unknown> {
if (method === "host/chats.update") {
this.updates.push(raw);
return {};
}
if (method === "host/chats.set_option") {
const { optionId, value } = raw as { optionId: string; value: string };
this.options = this.options.map((option) => (option.id === optionId ? { ...option, value } : option));
return { options: this.options };
}
return super.call(method, raw);
}
}
const model: ConfigOption = {
id: "model",
name: "Model",
category: "model",
kind: "select",
value: "opus",
choices: [
{ value: "opus", name: "Opus 5.5" },
{ value: "sonnet", name: "Sonnet 5.5" },
],
};
/// The controller's focus requests, as `[id, option]`.
function focuses(c: Controller) {
const seen: [string, string | undefined][] = [];
c.views.focus = (id: string, option?: string) =>
Effect.sync(() => {
seen.push([id, option]);
});
return seen;
}
test("taking an app command from the middle of the text drops its word and opens the menu at that setting", async () => {
const ledger = new OptionsLedger();
ledger.options = [model];
await withController(ledger, (c) =>
Effect.gen(function* () {
const seen = focuses(c);
const composer = c.composer("c1");
composer.options = [model];
// The agent's own /model is the one that would change its session
// behind the menu: the app's runs instead, listed once.
composer.commands = [{ name: "model", description: "Set the AI model" }];
yield* onChange(c, "c1", "fix the login /mo and test it", { caret: 17, tokens: [] });
assert.equal(composer.picker?.kind, "slash");
assert.deepEqual(
entries(c, composer).map((entry) => [entry.label, entry.app]),
[["model", "model"]],
);
assert.equal(yield* acceptPicked(c, "c1"), true);
assert.equal(composer.text, "fix the login and test it");
assert.deepEqual(composer.place, { text: composer.text, at: 14 }, "the caret stays where the word was");
assert.deepEqual(seen, [["models-c1-agent", "model"]]);
}),
);
});
test("a / at the start lists the app's commands first, then the agent's without the ones the app answers", async () => {
await withController(new OptionsLedger(), (c) =>
Effect.gen(function* () {
const composer = c.composer("c1");
composer.options = [model];
composer.commands = [
{ name: "model", description: "Set the AI model" },
{ name: "mount", description: "Mount a model folder" },
];
yield* onChange(c, "c1", "/mo", { caret: 3, tokens: [] });
assert.deepEqual(
entries(c, composer).map((entry) => `${entry.app ? "app" : "agent"}:${entry.label}`),
["app:model", "agent:mount"],
);
// Without a reasoning option there is no /effort to offer.
yield* onChange(c, "c1", "/eff", { caret: 4, tokens: [] });
assert.deepEqual(entries(c, composer), []);
}),
);
});
test("a sent /model with a name sets it, and one the agent does not have says so and opens the menu", async () => {
const ledger = new OptionsLedger();
ledger.options = [model];
await withController(ledger, (c) =>
Effect.gen(function* () {
const seen = focuses(c);
c.composer("c1").options = [model];
yield* runAppCommand(c, "c1", "model", "son");
assert.equal(ledger.options[0]?.value, "sonnet");
assert.deepEqual(seen, [], "a name that matches needs no menu");
yield* runAppCommand(c, "c1", "model", "haiku");
assert.match(ledger.notices[0] ?? "", /No model matches “haiku”/);
assert.deepEqual(seen, [["models-c1-agent", "model"]]);
yield* runAppCommand(c, "c1", "effort");
assert.match(ledger.notices[1] ?? "", /Agent has no effort setting/);
}),
);
});
test("/rename opens the title as a field; Enter saves it, a blank one as New Chat", async () => {
const ledger = new OptionsLedger();
await withController(ledger, (c) =>
Effect.gen(function* () {
const seen = focuses(c);
yield* startRename(c, "c1");
assert.deepEqual(c.state.renaming, { chatId: "c1", text: c.titleOf(c.state.chats.c1!) });
assert.deepEqual(seen, [["title-rename-c1", undefined]]);
yield* rename(c, "c1", " ");
assert.equal(c.state.renaming, null);
yield* runAppCommand(c, "c1", "rename", "Fix the login");
assert.deepEqual(ledger.updates, [
{ chatId: "c1", title: "New Chat" },
{ chatId: "c1", title: "Fix the login" },
]);
}),
);
});
test("taking a word out leaves one space between its neighbours", () => {
assert.deepEqual(removeRange("fix /mo now", [], { start: 4, end: 7 }), { text: "fix now", segments: [], caret: 4 });
assert.equal(removeRange("/mo", [], { start: 0, end: 3 }).text, "");
assert.equal(removeRange("fix it /mo", [], { start: 7, end: 10 }).text, "fix it ");
});Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.9latest | Nov 21, 2026 | >=5 <6 | 349 KB | 5 permissions | Listed |
| 0.2.8 | Nov 16, 2026 | >=5 <6 | 348.6 KB | 5 permissions | Listed |
| 0.2.7 | Nov 11, 2026 | >=5 <6 | 314.3 KB | 5 permissions | Listed |
| 0.2.6 | Nov 9, 2026 | >=5 <6 | 306.2 KB | 5 permissions | Listed |
| 0.2.5 | Oct 27, 2026 | >=2 <4 | 178.6 KB | 5 permissions | Listed |
No comments yet.