Diffs client
Read and accept an exact published coding generation through the source client.
Availability: Source client
The private workspace CLI source exports HostedDancerClient.diffs. This is a source interface for an already authorized coding task, not a published npm SDK. A diff is a canonical candidate generation record, not patch bytes.
import { HostedDancerClient } from "@happycatlabs/dancer-cli/hosted";
const dancer = new HostedDancerClient({ apiUrl: process.env.DANCER_API_URL! });
const diff = await dancer.diffs.get({ diffId: "<64-hex-diff-id>" });
if (diff) {
console.log(diff.diffId, diff.parentDiffId, diff.expectedVersion);
}
get returns null for an absent generation. After independent review, accept takes the exact diffId, parentDiffId, and expectedVersion. It does not select the latest candidate or refresh a stale version. Server review and accepted-head checks still govern acceptance. A successful accept remains separate from merge, deployment, and live proof.
The maintained executable example is included below from the source file used by the repository test. Run it only in an already bound managed coding task with its DANCER_API_URL set.
import { HostedDancerClient } from "@happycatlabs/dancer-cli/hosted";
import type { DancerDiff } from "@happycatlabs/dancer-cli/diffs";
const [command, diffId = "", parentDiffId = "", version] = process.argv.slice(2);
if (command === "--help" || command === undefined) {
console.log(
"get <64-hex-diff-id> | accept <64-hex-diff-id> <64-hex-parent-id-or-null> <expected-version>",
);
} else {
const apiUrl = process.env.DANCER_API_URL;
if (apiUrl === undefined) throw new Error("DANCER_API_URL is required.");
if (command === "accept" && (version === undefined || version.trim() === "")) {
throw new Error("accept requires an explicit expected-version argument.");
}
const dancer = new HostedDancerClient({ apiUrl });
if (command === "get") {
const diff: DancerDiff | null = await dancer.diffs.get({ diffId });
console.log(JSON.stringify(diff));
} else if (command === "accept") {
console.log(
JSON.stringify(
await dancer.diffs.accept({
diffId,
parentDiffId: parentDiffId === "null" ? null : parentDiffId,
expectedVersion: Number(version),
}),
),
);
} else {
throw new Error("Unknown Diffs example command. Run with --help.");
}
}