Official

claude

Claude Code agent provider: runs the Claude Code CLI headless for each account.

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/claude@0.2.6

Permissions in 0.2.6

  • Provide agents agents.provideMediumAdds agents to the app.Provide the Claude Code agent and pass its tool calls to plugin tools
  • Run named programs processMediumStarts the listed programs.Run the Claude Code CLI (sessions, sign-in, `claude update`), and ask the npm installation that owns it about a newer versionPrograms: claudenpm
  • Read files fs.readMediumReads files in the listed places.Read Claude Code's sessions, settings and skills (in ~/.claude, other accounts' ~/.claude-* folders, the shared skills and the folder you choose in Settings), the project's .claude folder, the administrator's skill policy, and once, what the previous provider keptPlaces: ~/.claude/**~/.claude*/**~/.agents/skills/**the open workspaceits own data folder/Library/Application Support/ClaudeCode/managed-settings.json/etc/claude-code/managed-settings.json${settings.configDir}
  • Environment variables envMediumReads the listed environment variables.Find Claude Code's configuration directory, and the launch settings you set in CLAUDE_* variables (extra arguments, MCP servers, setting sources, appended system prompt, extra folders)Variables: HOMECLAUDE_CONFIG_DIRCLAUDE_EXTRA_ARGSCLAUDE_MCP_CONFIGCLAUDE_STRICT_MCP_CONFIGCLAUDE_SETTING_SOURCESCLAUDE_APPEND_SYSTEM_PROMPTCLAUDE_ADD_DIRS

Files

options.ts12.4 KB
// Config options (the Rust `options.rs`). The model list, each model's
// effort levels, the slash commands and which toggles exist at all come
// from the CLI's `initialize` control response.
import * as wire from "./wire.ts";
import type { ConfigOption, ConfigChoice, SlashCommand, Values } from "./types.ts";
import { permissionMode } from "../sdk/agent.ts";

export const MODEL = "model";
export const EFFORT = "effort";
export const PERMISSION_MODE = permissionMode.OPTION_ID;
export const FAST_MODE = "fast_mode";
/// The value that means "leave this to Claude Code", so no flag is passed.
export const DEFAULT = "default";
/// Standing dynamic-workflow orchestration, at any effort level: the
/// session setting `ultracode` (`--settings` at launch,
/// `apply_flag_settings` live).
export const ULTRACODE = "ultracode";
/// The suffix that selects a model's 1M token context window. The current
/// models have it natively, but older CLIs still name `opus[1m]`.
const CONTEXT_1M = "[1m]";
/// The mark of the ultracode switch: Lucide's `rainbow`.
const ULTRACODE_ICON =
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 17a10 10 0 0 0-20 0"/><path d="M6 17a6 6 0 0 1 12 0"/><path d="M10 17a2 2 0 0 1 4 0"/></svg>';

/// The `--permission-mode` value for one of the four shared modes. Claude
/// has its own reviewer, so `auto` is a real mode. The mode is always
/// sent: the composer shows a mode, and it must be the one in force.
export function permissionFlag(mode: string) {
  switch (mode) {
    case permissionMode.AUTO_EDITS:
      return "acceptEdits";
    case permissionMode.AUTO:
      return "auto";
    case permissionMode.FULL:
      return "bypassPermissions";
    default:
      return "default";
  }
}

/// Why fast mode cannot serve, in words the user can act on. The reasons
/// the toggle itself clears, and the ones that pass on their own, give
/// nothing: "unavailable" next to the switch that turns it on is wrong.
export function fastModeNote(reason: string) {
  switch (reason) {
    case "not_first_party":
      return "Only an Anthropic account can use fast mode.";
    case "model_not_allowed":
      return "Your organization does not allow fast mode for this model.";
    case "free":
    case "extra_usage_disabled":
      return "Fast mode needs usage credits.";
    case "network_error":
      return "Fast mode could not be reached.";
    case "disabled_by_env":
      return "Fast mode is switched off on this machine.";
    default:
      return null;
  }
}

const EFFORT_NAMES: Record<string, string> = {
  low: "Low",
  medium: "Medium",
  high: "High",
  xhigh: "Extra high",
  max: "Max",
};

export function effortChoice(level: string): ConfigChoice {
  return { value: level, name: EFFORT_NAMES[level] ?? level };
}

/// The `apply_flag_settings` layer for an effort choice, which changes a
/// running session without a restart; `null` drops the layer's effort and
/// the CLI restores the model's default effort.
export function effortSettings(value: string | null | undefined) {
  return { effortLevel: value === DEFAULT || !value ? null : value };
}

/// A string option value, ignoring the "leave it to Claude Code"
/// placeholder.
export function selected(values: Values | null | undefined, id: string) {
  const value = values?.[id];
  return typeof value === "string" && value !== "" && value !== DEFAULT ? value : null;
}

/// A toggle value.
export function toggle(values: Values | null | undefined, id: string, fallback: boolean) {
  const value = values?.[id];
  return typeof value === "boolean" ? value : fallback;
}

const bare = (id: string) => (id.endsWith(CONTEXT_1M) ? id.slice(0, -CONTEXT_1M.length) : id);

/// The id a model the API names goes by among the Model choices: without the
/// `[1m]` context suffix and without the API's release date
/// (`claude-haiku-4-5-20251001` is `claude-haiku-4-5`). Tasks report their
/// model this way, and a choice whose value has a date lists this form as an
/// alias, so the chat names a subagent's model as the picker does.
export function modelId(id: string) {
  return bare(id).replace(/-\d{8}$/, "");
}

/// A model the picker offers.
interface Model {
  id: string;
  name: string;
  effort: string[];
  /// The CLI values that resolve to it, so a stored `opus` selects it.
  aliases: string[];
}

/// Commands the CLI lists in headless mode that do nothing there, as
/// CLI 2.1.316 answers them: `/fast` ("not available in the Agent SDK"),
/// `/focus` ("isn't available here yet"), `/agents` (removed), `/color`
/// (the terminal's prompt bar), `/mcp` ("use /mcp in the terminal"),
/// `/extra-usage` (an old name of `/usage-credits`), and the two that only
/// a server-launched session can run.
const HEADLESS_DEAD = new Set([
  "fast",
  "focus",
  "agents",
  "color",
  "mcp",
  "extra-usage",
  "__remote-workflow",
  "workflow-launch-exec",
]);

/// The parts of the `initialize` control response the plugin uses.
export class Catalog {
  models: wire.Model[];
  commands: wire.Command[];
  fastModeState: string | null;
  fastModeDisabledReason: string | null;
  workflowsOff: boolean;
  constructor({
    models = [],
    commands = [],
    fastModeState = null,
    fastModeDisabledReason = null,
    workflowsOff = false,
  }: {
    models?: wire.Model[];
    commands?: wire.Command[];
    fastModeState?: string | null;
    fastModeDisabledReason?: string | null;
    workflowsOff?: boolean;
  } = {}) {
    this.models = models;
    this.commands = commands;
    /// `off`, `cooldown` or `on`. Absent on a CLI without fast mode.
    this.fastModeState = fastModeState;
    this.fastModeDisabledReason = fastModeDisabledReason;
    /// The user's settings turn dynamic workflows off: no ultracode.
    this.workflowsOff = workflowsOff;
  }

  static fromResponse(response: wire.CatalogResponse) {
    const text = (key: string) => (typeof response?.[key] === "string" ? response[key] : null);
    return new Catalog({
      models: Array.isArray(response?.models) ? response.models : [],
      commands: Array.isArray(response?.commands) ? response.commands : [],
      fastModeState: text("fast_mode_state"),
      fastModeDisabledReason: text("fast_mode_disabled_reason"),
    });
  }

  slashCommands() {
    return this.commands
      .filter((command) => typeof command?.name === "string" && !HEADLESS_DEAD.has(command.name ?? ""))
      .map((command) => {
        const out: SlashCommand = {
          name: command.name ?? "",
          description: typeof command.description === "string" ? command.description : "",
          source: "agent",
        };
        if (typeof command.argumentHint === "string" && command.argumentHint) out.inputHint = command.argumentHint;
        return out;
      });
  }

  /// The current model of each family. The CLI lists them under its
  /// aliases (`default`, `opus`, `sonnet`, ...) with the model each one
  /// resolves to; the rows named by their own model id are the older
  /// models, which the picker leaves out. `chosen` is the model the chat
  /// runs, which is always offered: a CLI started with `--model
  /// claude-fable-5-2` lists that model by its id in place of its alias
  /// row, and leaving it out left the chat with no model to show.
  currentModels(chosen: string | null = null) {
    const rows = this.models.flatMap((row) =>
      typeof row?.value === "string" && typeof row.resolvedModel === "string"
        ? [{ ...row, value: row.value, id: bare(row.resolvedModel) }]
        : [],
    );
    const models: Model[] = [];
    for (const row of rows) {
      const older = bare(row.value) === row.id && (chosen === null || modelId(chosen) !== modelId(row.id));
      if (older || models.some((model) => model.id === row.id)) continue;
      const same = rows.filter((other) => other.id === row.id);
      models.push({
        id: row.id,
        // `default` is named "Default (recommended)", not by its model.
        name: same.find((other) => other.value !== DEFAULT && other.displayName)?.displayName ?? row.id,
        effort: same.find((other) => other.supportedEffortLevels?.length)?.supportedEffortLevels ?? [],
        aliases: [
          ...same.map((other) => other.value).filter((value) => value !== row.id),
          `${row.id}${CONTEXT_1M}`,
          ...(modelId(row.id) === row.id ? [] : [modelId(row.id)]),
        ],
      });
    }
    return models;
  }

  /// The model a new chat starts on: the one the CLI's `default` names.
  defaultModel() {
    const models = this.currentModels();
    const named = this.models.find((row) => row?.value === DEFAULT)?.resolvedModel;
    return (models.find((model) => typeof named === "string" && model.id === bare(named)) ?? models[0])?.id ?? DEFAULT;
  }

  /// Effort levels offered by any model, in the list's order.
  effortLevels(chosen: string | null = null) {
    const levels: string[] = [];
    for (const model of this.currentModels(chosen)) {
      for (const level of model.effort) if (!levels.includes(level)) levels.push(level);
    }
    return levels;
  }

  /// Whether any model the account can run declares a capability.
  anyModel(capability: "supportsFastMode") {
    return this.models.some((model) => model?.[capability] === true);
  }

  /// One choice per current model, named by version. The value is the
  /// model id, so a chat keeps its model when the CLI's aliases move on.
  modelChoices(chosen: string | null = null) {
    return this.currentModels(chosen).map((model) => {
      const choice: ConfigChoice = { value: model.id, name: model.name, aliases: model.aliases };
      const levels = model.effort.map(effortChoice);
      if (levels.length) choice.reasoningLevels = levels;
      return choice;
    });
  }

  /// The full option snapshot with `values` applied on top of the
  /// catalog's own defaults.
  options(values: Values = {}): ConfigOption[] {
    const chosen = (id: string, fallback: string) => (typeof values?.[id] === "string" ? values[id] : fallback);
    const model = selected(values, MODEL);
    const options: ConfigOption[] = [
      {
        id: MODEL,
        name: "Model",
        category: "model",
        kind: "select",
        value: chosen(MODEL, this.defaultModel()),
        choices: this.modelChoices(model),
      },
      {
        id: EFFORT,
        name: "Effort",
        description: "Reasoning effort.",
        category: "reasoning",
        kind: "select",
        value: chosen(EFFORT, DEFAULT),
        choices: [
          { value: DEFAULT, name: "Default", description: "Let Claude Code pick the effort for the model." },
          ...this.effortLevels(model).map(effortChoice),
        ],
      },
      // The CLI's own `current_permission_mode` is deliberately not
      // adopted: the host reads an unset option as Supervised, so a
      // session that silently ran looser would do more than the composer
      // says.
      permissionMode.option(permissionMode.selected(values, true), true),
    ];
    if (!this.workflowsOff) {
      options.push({
        id: ULTRACODE,
        name: "Ultracode",
        description: "Claude plans dynamic workflows: many agents in parallel.",
        category: "reasoning",
        kind: "toggle",
        value: toggle(values, ULTRACODE, false),
        choices: [],
        icon: ULTRACODE_ICON,
        // The CLI never persists it either: every workflow costs many
        // agents' worth of tokens, so each chat opts in again.
        transient: true,
      });
    }
    // Fast mode is only offered when the CLI proves it exists: a model that
    // declares the capability, and a CLI that reports its state at all.
    if (this.fastModeState !== null && this.anyModel("supportsFastMode")) {
      const option: ConfigOption = {
        id: FAST_MODE,
        name: "Fast mode",
        category: "speed",
        kind: "toggle",
        value: toggle(values, FAST_MODE, false),
        choices: [],
      };
      const note = this.fastModeDisabledReason !== null ? fastModeNote(this.fastModeDisabledReason) : null;
      if (note) option.description = note;
      options.push(option);
    }
    return options;
  }
}

/// The choice a stored value selects: the one with that value, or the one
/// that lists it as an alias (the host's `ConfigOption::choice_for`).
export function choiceFor(option: ConfigOption, value: string) {
  return (
    (option.choices ?? []).find((choice) => choice.value === value) ??
    (option.choices ?? []).find((choice) => (choice.aliases ?? []).includes(value)) ??
    null
  );
}

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.7latestNov 21, 2026>=5 <6207.5 KB4 permissionsListed
0.2.6Nov 16, 2026>=5 <6206 KB4 permissionsListed
0.2.5Nov 11, 2026>=5 <6168.3 KB4 permissionsListed
0.2.4Nov 9, 2026>=5 <6166.1 KB4 permissionsListed
0.2.3Oct 27, 2026>=2 <4151.6 KB4 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.