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

  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Send prompts, answer agent questions, and create, change, fork, revert, stop and group chats
  • Run other plugins' commands commands.runHighRuns commands of other plugins.Run the sidebar's New chat command from the title bar
  • Read chats chats.readMediumReads your transcripts and chat lists.Show workspaces, tasks, chats and transcripts, and follow them as agents work
  • Read files fs.readMediumReads files in the listed places.Suggest workspace files for @ mentionsPlaces: the open workspace
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw the chat grid, the title bar, and the Session panel with its rail buttonSlots: centertitlerailright

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

VersionPublishedPlugin APISizePermissionsStatus
0.2.9latestNov 21, 2026>=5 <6349 KB5 permissionsListed
0.2.8Nov 16, 2026>=5 <6348.6 KB5 permissionsListed
0.2.7Nov 11, 2026>=5 <6314.3 KB5 permissionsListed
0.2.6Nov 9, 2026>=5 <6306.2 KB5 permissionsListed
0.2.5Oct 27, 2026>=2 <4178.6 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.