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.4
Permissions in 0.2.4
Files
fingerprint.ts5.1 KB
// What a history read saw of Claude Code's files, so that a later read of
// the same session can tell from `stat` and `list` alone that nothing
// changed (`ClaudeAgent.readSession`). A transcript can be hundreds of
// megabytes of JSON lines; its metadata is a few host calls.
import * as Effect from "effect/Effect";
import type { FsEntry, FsStat } from "divergence";
import type { Files } from "./files.ts";
import { mapLimit } from "./files.ts";
/// One path a read used: a file's metadata or, for a folder it listed, the
/// listing (every entry with its size and time). `seen` is `null` when the
/// path was not there.
interface Probe {
path: string;
list: boolean;
seen: string | null;
}
/// The paths one read of a transcript used, the transcript itself first.
export interface Fingerprint {
probes: Probe[];
}
const statText = (stat: FsStat | null) => (stat === null ? null : `${stat.kind} ${stat.size} ${stat.modified}`);
const listingText = (entries: readonly FsEntry[] | null) =>
entries === null ? null : JSON.stringify(entries.map((entry) => [entry.name, entry.kind, entry.size, entry.modified]));
/// Metadata that cannot show a change: a link (it is not followed, so the
/// file behind it can change unseen), or no modification time.
const opaque = (stat: FsStat) => stat.kind === "symlink" || stat.kind === "other" || typeof stat.modified !== "number";
/// `files` for one read, noting what the read uses. A file is looked at
/// just before it is read, unless a listing of its folder already gave its
/// size and time; either way the note is no later than the read, so a write
/// during the read shows as a change next time. A note that cannot prove
/// anything (a link, no time, a read that found what the note did not, or
/// the reverse) leaves the read without a fingerprint.
export function recordReads(files: Files) {
const probes = new Map<string, Probe>();
const folders = new Map<string, Set<string> | null>();
let sound = true;
const note = (probe: Probe) => {
const key = `${probe.list ? "list" : "stat"}:${probe.path}`;
const known = probes.get(key);
if (!known) probes.set(key, probe);
else if (known.seen !== probe.seen) sound = false; // It changed during the read.
};
const noteStat = (path: string, stat: FsStat | null) => {
if (stat && opaque(stat)) sound = false;
note({ path, list: false, seen: statText(stat) });
};
/// Whether `path` was there just before the read of it.
const lookAt = Effect.fnUntraced(function* (path: string) {
const at = path.lastIndexOf("/");
const folder = folders.get(path.slice(0, at));
if (folder !== undefined) return folder?.has(path.slice(at + 1)) ?? false;
const stat = yield* files.stat(path);
noteStat(path, stat);
return stat !== null;
});
const tracked: Files = {
text: Effect.fn("Claude.files.text")(function* (path: string) {
const there = yield* lookAt(path);
const text = yield* files.text(path);
if ((text !== null) !== there) sound = false;
return text;
}),
bytes: Effect.fn("Claude.files.bytes")(function* (path: string) {
const there = yield* lookAt(path);
const bytes = yield* files.bytes(path);
if ((bytes !== null) !== there) sound = false;
return bytes;
}),
range: Effect.fn("Claude.files.range")(function* (path: string, offset: number, length: number) {
const there = yield* lookAt(path);
const bytes = yield* files.range(path, offset, length);
if ((bytes !== null) !== there) sound = false;
return bytes;
}),
list: Effect.fn("Claude.files.list")(function* (path: string) {
const entries = yield* files.list(path);
if (entries?.some(opaque)) sound = false;
if (!folders.has(path)) folders.set(path, entries && new Set(entries.map((entry) => entry.name)));
note({ path, list: true, seen: listingText(entries) });
return entries;
}),
stat: Effect.fn("Claude.files.stat")(function* (path: string) {
const stat = yield* files.stat(path);
noteStat(path, stat);
return stat;
}),
};
/// The fingerprint of a completed read of the transcript at `path`, or
/// `null` when what the read saw cannot prove a later read unchanged.
const fingerprint = (path: string): Fingerprint | null => {
const main = probes.get(`stat:${path}`);
if (!sound || !main || main.seen === null) return null;
return { probes: [main, ...[...probes.values()].filter((probe) => probe !== main)] };
};
return { files: tracked, fingerprint };
}
/// Whether every path behind `fingerprint` looks as it did. A path that
/// cannot be looked at now, or that changed in any way, is a change.
export const unchanged = Effect.fn("Claude.unchanged")(function* (files: Files, fingerprint: Fingerprint) {
const look = (probe: Probe) =>
probe.list ? Effect.map(files.list(probe.path), listingText) : Effect.map(files.stat(probe.path), statText);
const [main, ...rest] = fingerprint.probes;
// The transcript is what changes most: one call when it did.
if (!main || (yield* look(main)) !== main.seen) return false;
const now = yield* mapLimit(rest, 8, look);
return rest.every((probe, at) => now[at] === probe.seen);
});Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.7latest | Nov 21, 2026 | >=5 <6 | 207.5 KB | 4 permissions | Listed |
| 0.2.6 | Nov 16, 2026 | >=5 <6 | 206 KB | 4 permissions | Listed |
| 0.2.5 | Nov 11, 2026 | >=5 <6 | 168.3 KB | 4 permissions | Listed |
| 0.2.4 | Nov 9, 2026 | >=5 <6 | 166.1 KB | 4 permissions | Listed |
| 0.2.3 | Oct 27, 2026 | >=2 <4 | 151.6 KB | 4 permissions | Listed |
No comments yet.