Official
acp
ACP agents from the ACP registry (Gemini, Cursor, Droid, Kilo, pi, ...), Oh My Pi, and your own entries (custom.json in the plugin's data folder). Agents are discovered at runtime.
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/acp@0.2.1
Permissions in 0.2.1
Take care. This plugin asks for permissions that can do anything your account can. The app asks you to hold Enable for two seconds or to type the plugin's name before it turns on.
Files
maintenance.ts5.3 KB
// Whether an ACP agent's program is out of date, and how to update it.
//
// The registry names each agent's newest version. An agent the plugin
// starts through a package runner (`npx -y pkg@1.2.3`, `uvx pkg==1.2.3`)
// already runs the pinned version the registry lists, so it never falls
// behind. An agent the user installed is updated by the installer that
// owns its binary, proven from the binary's real path as the other
// providers do (`../sdk/maintenance.ts`). With no provable owner, the
// program's own `update` command, when its help lists one, is offered to
// run in a terminal.
import * as Effect from "effect/Effect";
import type { AgentMaintenance } from "divergence/protocol";
import { isNewer, latestBrewEffect, latestNpmEffect, LOOKUP_TIMEOUT } from "../sdk/maintenance.ts";
import { runProcess } from "../sdk/effect.ts";
import type { Entry, Launch } from "./registry.ts";
export type Owner =
| { manager: "runner" }
| { manager: "npm"; prefix: string; pkg: string }
| { manager: "homebrew"; name: string; cask: boolean }
| { manager: "uv"; tool: string }
| { manager: "" };
const RUNNERS = new Set(["npx", "uvx"]);
function base(path: string) {
const tail = path.replace(/\\/g, "/").split("/").pop() ?? "";
return tail.replace(/\.(cmd|exe)$/i, "");
}
/// Who owns the program `launch` starts, from where its binary really is.
export function ownerOf(launch: Launch, realPath: string | null): Owner {
if (RUNNERS.has(base(launch.program))) return { manager: "runner" };
const path = String(realPath ?? launch.program).replace(/\\/g, "/");
const at = path.lastIndexOf("/lib/node_modules/");
const pkg = at < 0 ? null : /^(?:@[^/]+\/)?[^/]+(?=\/)/.exec(path.slice(at + "/lib/node_modules/".length))?.[0];
const prefix = path.slice(0, Math.max(at, 0));
// A `node_modules` above the package is a project's dependency, never
// a global install.
if (pkg && !prefix.includes("/node_modules/")) return { manager: "npm", prefix: prefix || "/", pkg };
const brew = /\/(Cellar|Caskroom)\/([^/]+)\//.exec(path);
if (brew?.[2]) return { manager: "homebrew", name: brew[2], cask: brew[1] === "Caskroom" };
const uv = /\/uv\/tools\/([^/]+)\//.exec(path);
if (uv?.[1]) return { manager: "uv", tool: uv[1] };
return { manager: "" };
}
/// The program and arguments that install `latest` for `owner`, or `null`
/// when no installer owns the binary provably.
export function updatePlan(owner: Owner, latest: string | null): { program: string; args: string[] } | null {
switch (owner.manager) {
case "npm":
return {
program: "npm",
args: [
"install",
"-g",
"--prefix",
owner.prefix,
// npm no longer runs install scripts by default and still exits
// 0, so a package that downloads its binary would not update.
`--allow-scripts=${owner.pkg}`,
`${owner.pkg}@${latest ?? "latest"}`,
],
};
case "homebrew":
return { program: "brew", args: owner.cask ? ["upgrade", "--cask", owner.name] : ["upgrade", owner.name] };
case "uv":
return { program: "uv", args: ["tool", "upgrade", owner.tool] };
default:
return null;
}
}
/// The subcommand a program's help lists for updating itself, if any:
/// a line of its command list that starts with the word.
export function updateSubcommand(help: string): string | null {
const found = /^\s+(self-update|update|upgrade)(?=[\s,]|$)/m.exec(help);
return found?.[1] ?? null;
}
function quote(text: string) {
return /^[\w@%+=:,./-]+$/.test(text) ? text : `'${text.replace(/'/g, `'\\''`)}'`;
}
/// The newest version the owner can deliver: its own registry's for npm
/// and Homebrew (a cask trails the ACP registry by hours), else the ACP
/// registry's.
const latestFor = Effect.fn("Acp.latestFor")(function* (owner: Owner, entry: Entry) {
if (owner.manager === "npm") return yield* latestNpmEffect(owner.pkg, owner.prefix);
if (owner.manager === "homebrew") return yield* latestBrewEffect(owner.name);
return entry.version;
});
/// The `--help` of a program, empty when it does not answer in time.
const helpOf = Effect.fn("Acp.helpOf")(function* (program: string) {
const result = yield* runProcess(program, ["--help"], { timeout: LOOKUP_TIMEOUT }).pipe(
Effect.scoped,
Effect.catch(() => Effect.succeed(null)),
);
return result ? `${result.stdout}\n${result.stderr}` : "";
});
/// The maintenance block of the agent's `AgentInfo`, or `null` for an
/// agent that cannot fall behind (one a package runner starts, or one the
/// registry does not version).
export const describe = Effect.fn("Acp.describe")(function* (
entry: Entry,
launch: Launch,
realPath: string | null,
installedVersion: string | null,
) {
if (entry.source.kind !== "registry" || !installedVersion) return null;
const owner = ownerOf(launch, realPath);
if (owner.manager === "runner") return null;
const latest = yield* latestFor(owner, entry);
const plan = updatePlan(owner, latest);
const out: AgentMaintenance = { installedVersion, canUpdate: plan !== null };
if (owner.manager) out.manager = owner.manager;
if (!latest || !isNewer(installedVersion, latest)) return out;
out.latestVersion = latest;
if (!plan) {
const word = updateSubcommand(yield* helpOf(launch.program));
if (word) out.command = `${quote(launch.program)} ${word}`;
}
return out;
});Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.5latest | Nov 21, 2026 | >=5 <6 | 134 KB | 6 permissions | Listed |
| 0.2.4 | Nov 16, 2026 | >=5 <6 | 132.8 KB | 6 permissions | Listed |
| 0.2.3 | Nov 11, 2026 | >=5 <6 | 108.9 KB | 6 permissions | Listed |
| 0.2.2 | Nov 9, 2026 | >=5 <6 | 105.6 KB | 6 permissions | Listed |
| 0.2.1 | Oct 27, 2026 | >=2 <4 | 105.3 KB | 6 permissions | Listed |
No comments yet.