Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 0.9.9

- Updating a diff from its directory no longer starts a second diff when the
agent names the same parent again; only another parent or `newBit` starts a
new bit. Every update carries the diff's parent, so its lineage is kept.
- `bind` (and the new `bind_directory` tool) points a directory at the
connected creator's draft that was never published, instead of refusing it
as not ready. The next upload replaces that draft.
- `publish_directory` describes `newBit`, `parentBitId` and `parentVersionId`,
and says how to update a bit or a diff.
- Skills synced from Control: the helper and connector references say a diff
names its parent in its first upload and later uploads update the same diff.

## 0.9.8

- Skills synced from Control: a bit can read its own post's comments and
Expand Down
2 changes: 1 addition & 1 deletion directory/differ/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "differ",
"version": "0.9.8",
"version": "0.9.9",
"description": "Make, publish and diff interactive bits on Differ.",
"author": {
"name": "Sky Valley",
Expand Down
4 changes: 2 additions & 2 deletions directory/differ/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "differ",
"version": "0.9.8",
"version": "0.9.9",
"description": "Make, publish and diff interactive bits on Differ.",
"author": {
"name": "Sky Valley",
Expand Down Expand Up @@ -95,7 +95,7 @@
"commerce_description": "Differ does not sell anything or take payments."
},
"publication": {
"release_notes": "Differ 0.9.8: make, publish and diff bits; publish as a guest or connect a Differ account."
"release_notes": "Differ 0.9.9: make, publish and diff bits; publish as a guest or connect a Differ account."
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions directory/differ/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "differ",
"version": "0.9.8",
"version": "0.9.9",
"description": "Make, publish and diff interactive bits on Differ.",
"author": {
"name": "Sky Valley",
Expand Down Expand Up @@ -97,7 +97,7 @@
"commerce_description": "Differ does not sell anything or take payments."
},
"publication": {
"release_notes": "Differ 0.9.8: make, publish and diff bits; publish as a guest or connect a Differ account."
"release_notes": "Differ 0.9.9: make, publish and diff bits; publish as a guest or connect a Differ account."
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions directory/differ/skills.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
},
{
"uri": "skill://publish-content/references/connector.md",
"digest": "sha256:66278e88045fca08dcd72c4e19bd34a7e59e0e76d76fbaabbb1e9992ed1e9ff1",
"size": 4085
"digest": "sha256:b4f12b6cf2ba086c7bfb24f241dfbe7c5870ffded6381a3879b6a17d446ba983",
"size": 4255
},
{
"uri": "skill://publish-content/references/helper.md",
"digest": "sha256:b04642ea900279eecfb77a96ef2f8cbd2f7bdd6fd92a657106fe13cfff45c19a",
"size": 3777
"digest": "sha256:6631806722986e0584ad22ed2e589c47bbea9111111c2843ef81474bdb152a42",
"size": 4132
},
{
"uri": "skill://publish-content/references/participation.md",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ it first; it then replaces their live place at once.

`get_bit` reads a bit's public state and version identifiers; it grants
no editing or claiming rights. For a diff, add `parentBitId` and
`parentVersionId` to the publishing request, with the maker's own caption.
`parentVersionId` to the first publishing request, with the maker's own
caption. Later uploads of that diff send its own bit `id` and the last
`versionId` you uploaded as `expectedVersionId`; the parent may be left out,
since the diff keeps it.
8 changes: 7 additions & 1 deletion directory/differ/skills/publish-content/references/helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@ never in Git or uploaded assets. On uncertainty run `publication_status` /
`status DIR`, then retry unchanged. Never delete pending state to retry.
Conflicts require comparing the current bit (`get_bit` / `get-bit ID`);
`bind DIR --bit ID` deliberately rebases after review. `--new` starts an
unrelated bit only when requested. A diff of someone's bit names its parent:
unrelated bit only when requested. A diff of someone's bit names its parent
in its first upload:
`publish APP --caption CAPTION --parent-bit ID --parent-version ID`.
Every later upload from the same directory updates that diff, draft or live:
plain `publish APP` / `publish_directory` with only the directory (naming the
same parent again also updates it, never starts a second diff). To update a
draft from another directory, `bind DIR --bit ID` first; it works for a draft
that was never published.
36 changes: 32 additions & 4 deletions helper/client.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { lstatSync, readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync } from 'node:fs';
import { lstatSync, readdirSync, readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync, rmSync } from 'node:fs';
import { join, resolve, dirname, relative } from 'node:path';
import { createServer } from 'node:http';
import { randomUUID, randomBytes } from 'node:crypto';
Expand Down Expand Up @@ -119,6 +119,10 @@ export async function bind(directory, bitId) {
try {
const state = stateFor(directory, config, true);
if (state.pending) throw problem('pending_publication', 'Reconcile the pending publication first.', 'Run status.');
const current = await publicState(config, bitId);
// A creator's draft that was never published has no public version to
// name: bind as its creator, and the next upload replaces that draft.
if (!current.bit && current.claimed) return bindDraft(directory, config, state, bitId);
const bit = await getBit(bitId);
if (state.bit && state.bit.id !== bit.id) {
state.previous = [...(state.previous ?? []), { bit: state.bit, receipt: state.receipt, lastInput: state.lastInput }];
Expand All @@ -131,6 +135,22 @@ export async function bind(directory, bitId) {
return { bound: true, bitId: bit.id, expectedVersionId: bit.currentVersionId, recovery: 'Local files were not changed. Publish only after deliberately reconciling this draft with the current bit.' };
} finally { unlock(); }
}
async function bindDraft(directory, config, state, bitId) {
const me = await account(config);
if (!me) throw problem('connection_required', 'This bit is a draft that was never published; only its creator can update it.', 'Connect as its creator, then bind again. To make your own version instead, publish a diff of a published bit.');
if (state.bit?.id !== bitId) {
if (state.bit) state.previous = [...(state.previous ?? []), { bit: state.bit, receipt: state.receipt, lastInput: state.lastInput }];
// Control checks the upload is the creator's; the source stays the draft's own.
state.bit = { id: bitId, mode: 'connected', accountHandle: me.handle };
}
state.receipt = { bitId, versionId: null };
delete state.lastInput;
atomic(statePath(directory), state);
// differ-bit.json names a published version; a draft has none yet, so the
// next upload writes it.
rmSync(join(directory, bindingName), { force: true });
return { bound: true, bitId, draft: true, expectedVersionId: null, recovery: 'Local files were not changed. The next publish replaces this draft; it stays unpublished until the creator publishes it in Differ.' };
}
// The bearer decides who a publication acts for: the connected creator for its
// own drafts and for guest bits it has since claimed, otherwise the guest
// upload pass. A claimed bit is the account's when Control names its handle.
Expand Down Expand Up @@ -183,14 +203,21 @@ async function publishCreator(config, state, directory, artifact, caption, { new
if (recovered.state === 'succeeded') return { ...recovered, recovered: true, recovery: 'Recovered the previous upload. Run publish again only if more edits were requested.' };
if (state.pending.artifactId !== artifact.artifactId || state.pending.caption !== caption || !!state.pending.publish !== now) throw problem('pending_changed', 'Pending publication belongs to different content.', 'Restore the pending content/caption and retry; never discard uncertain state.');
}
if (!state.pending && (newBit || parentBitId)) {
// A diff's directory keeps updating that diff: naming its own parent again
// is an update, and an update names the parent the diff was made from.
// Only --new or another parent starts another bit.
const saved = state.bit?.parent ?? (state.lastInput?.parentBitId ? { bitId: state.lastInput.parentBitId, versionId: state.lastInput.parentVersionId } : undefined);
const sameDiff = !!(parentBitId && saved && saved.bitId === parentBitId && saved.versionId === parentVersionId);
const fork = !state.pending && (newBit || (parentBitId && !sameDiff));
if (fork) {
state.previous = [...(state.previous ?? []), { bit: state.bit, receipt: state.receipt, lastInput: state.lastInput }];
delete state.bit; delete state.receipt; delete state.lastInput;
}
if (!state.bit) {
if (state.receipt && !me) throw problem('ownership_required', 'A public bit binding does not grant editing rights.', 'Use the original private workspace or connect the owner. To make your own, create a diff.');
state.bit = { id: state.receipt?.bitId ?? randomUUID(), mode: me ? 'connected' : 'guest',
...(me ? { accountHandle: me.handle } : { ownerProof: randomBytes(32).toString('hex') }) };
...(me ? { accountHandle: me.handle } : { ownerProof: randomBytes(32).toString('hex') }),
...(parentBitId ? { parent: { bitId: parentBitId, versionId: parentVersionId } } : {}) };
atomic(statePath(directory), state);
}
if (state.bit.mode === 'guest' && !state.bit.uploadToken) {
Expand All @@ -203,8 +230,9 @@ async function publishCreator(config, state, directory, artifact, caption, { new
// that is now to be published.
if (!state.pending && state.receipt?.artifactId === artifact.artifactId && state.lastInput?.caption === caption && !(now && state.receipt.draft)) return creatorStatus(config, state, directory, me);
const bearer = await bearerFor(config, state, me);
const parent = parentBitId ? { bitId: parentBitId, versionId: parentVersionId } : state.bit.parent ?? (fork ? undefined : saved);
const input = state.pending ?? { requestId: randomUUID(), artifactId: artifact.artifactId, caption,
expectedVersionId: state.receipt?.versionId ?? null, ...(parentBitId ? { parentBitId, parentVersionId } : {}), ...(now ? { publish: true } : {}) };
expectedVersionId: state.receipt?.versionId ?? null, ...(parent ? { parentBitId: parent.bitId, parentVersionId: parent.versionId } : {}), ...(now ? { publish: true } : {}) };
state.pending = input; atomic(statePath(directory), state);
let receipt;
try { receipt = await request(config.url, `/v1/publishing/bits/${state.bit.id}/versions`, { bearer, body: draft(input, artifact.files) }); }
Expand Down
8 changes: 6 additions & 2 deletions helper/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ async function mcp() {
server.registerTool('publisher_status', { description: 'Check publishing service access, account, and limits. No publication.', inputSchema: {}, annotations }, wrap(doctor));
server.registerTool('check_content', { description: 'Validate local static files without uploading or publishing. Reports shared participation as unverified: read the participation reference and examples and rehearse with the real runtime. Does not test authorization, live updates or browser behavior.', inputSchema: { directory }, annotations }, wrap(({ directory }) => check(directory)));
server.registerTool('publish_directory', {
description: 'Upload content when the human asks. Works as a guest without sign-in, or as the deliberately connected creator. A new directory creates a bit; its saved identity uploads a new version of that bit. Connected uploads are drafts: when the receipt has draft:true, say it is not published yet and show its url, where the maker previews it, confirms its caption and publishes it. For guests show the url, private claim link, expiry and unclaimed notice; never hide them or block publishing to demand sign-in.',
description: 'Upload content when the human asks. Works as a guest without sign-in, or as the deliberately connected creator. A new directory creates a bit; its saved identity uploads a new version of that bit, or replaces its draft, so to update a bit or a diff call it again with the same directory. To update a draft made from another directory, run bind with its bit id first. Connected uploads are drafts: when the receipt has draft:true, say it is not published yet and show its url, where the maker previews it, confirms its caption and publishes it. For guests show the url, private claim link, expiry and unclaimed notice; never hide them or block publishing to demand sign-in.',
inputSchema: { directory,
caption: z.string().optional().describe("The maker's own words shown over the bit: 1–200 characters, at most 3 line breaks, checked before upload. Suggest it and let the maker confirm it; they confirm it again in Differ before the bit goes public. Defaults to the caption differ-bit.json saved for this bit."),
newBit: z.boolean().optional(), parentBitId: z.string().uuid().optional(), parentVersionId: z.string().uuid().optional(),
newBit: z.boolean().optional().describe('true only when the human asked for a separate, unrelated bit from this directory. Omit it to update the bit this directory already published or drafted.'),
parentBitId: z.string().uuid().optional().describe("For a diff's first upload: the source bit's id, with parentVersionId. Later uploads from the same directory update that diff whether or not you name it again; another parent starts another diff."),
parentVersionId: z.string().uuid().optional().describe("For a diff's first upload: the source bit's exact version id."),
publish: z.boolean().optional().describe('Connected creators only: true only when the human explicitly asked to publish now without previewing, with the caption they confirmed. Otherwise omit it, and the upload waits as a draft.') },
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true },
}, wrap(({ directory, caption, ...options }) => publish(directory, caption, options)));
Expand All @@ -46,6 +48,8 @@ async function mcp() {
server.registerTool('connection_status', { description: 'Check the saved connection with Differ, or finish connecting after the human approves the connection link. Respect retryAfter; do not poll in a tight loop.', inputSchema: {}, annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false } }, wrap(connectionStatus));
server.registerTool('disconnect_account', { description: 'Only when the human requests it, revoke this agent connection and explicitly return future publishing to guest mode. Existing bits keep their ownership.', inputSchema: {}, annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false } }, wrap(disconnect));
server.registerTool('publication_status', { description: 'Recover a pending publication or verify the saved receipt for a local directory.', inputSchema: { directory }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false } }, wrap(({ directory }) => status(directory)));
server.registerTool('bind_directory', { description: "Point a directory at an existing bit, or at the connected creator's draft that was never published, so the next publish_directory updates it. Only after the human asked to update that bit and you compared it; local files are not changed.",
inputSchema: { directory, bitId: z.string().uuid() }, annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false } }, wrap(({ directory, bitId }) => bind(directory, bitId)));
server.registerTool('get_bit', { description: 'Inspect a remote bit and its versions before conflict recovery or diffing.', inputSchema: { bitId: z.string().uuid() }, annotations }, wrap(({ bitId }) => getBit(bitId)));
server.registerTool('image_candidate', { description: 'Create a separate WebP candidate using installed cwebp. Never replaces source or adopts visual quality automatically.', inputSchema: { source: z.string(), output: z.string(), quality: z.number().min(0).max(100).optional() }, annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false } }, wrap(({ source, output, quality }) => imageCandidate(source, output, quality)));
server.registerTool('inspect_video', { description: 'Read recording dimensions, codec, duration and encoded frame rate using installed ffprobe. Not proof of smooth motion or good composition.', inputSchema: { file: z.string() }, annotations }, wrap(({ file }) => inspectVideo(file)));
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "differ-plugin",
"version": "0.9.8",
"version": "0.9.9",
"private": true,
"type": "module",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion plugins/differ/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "differ",
"version": "0.9.8",
"version": "0.9.9",
"description": "Make, publish and diff interactive bits on Differ.",
"author": {
"name": "Sky Valley",
Expand Down
2 changes: 1 addition & 1 deletion plugins/differ/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "differ",
"version": "0.9.8",
"version": "0.9.9",
"description": "Make, publish and diff interactive bits on Differ.",
"author": {
"name": "Sky Valley",
Expand Down
2 changes: 1 addition & 1 deletion plugins/differ/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "differ",
"version": "0.9.8",
"version": "0.9.9",
"description": "Make, publish and diff interactive bits on Differ.",
"author": {
"name": "Sky Valley",
Expand Down
Loading
Loading