@nodii/dev 0.6.85 → 0.6.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/cli.js +3 -1
- package/dist/core.js +1 -1
- package/dist/figma.js +48 -5
- package/dist/hooks.js +14 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -342,6 +342,18 @@ submitted before 31 Oct 2026 has none of these: the CLI says
|
|
|
342
342
|
`--json` also gives the replaced rows (`previousRounds`) and the write log.
|
|
343
343
|
Guideline change sets are `design changeset show`.
|
|
344
344
|
|
|
345
|
+
**Submit evidence (hub-258).** `figma submit` and `figma resubmit` add
|
|
346
|
+
an `evidence` object to the body: `baseVersion` from the change set,
|
|
347
|
+
`finishVersion` from the body's `figmaVersion`, and `nodes`, each variant with an
|
|
348
|
+
inline after PNG and that PNG's sha256. The CLI reads only the body and the change
|
|
349
|
+
set, never the file. A node you wrote beyond the items and variants is yours to
|
|
350
|
+
declare, in the body's `evidence.nodes` as `{ "nodeId": "1:9" }`: the CLI never
|
|
351
|
+
fills it from the set's write log. A submit that can't read the set stops there,
|
|
352
|
+
with nothing sent. Dev refuses a wrong version or hash with `EVIDENCE_MISMATCH`,
|
|
353
|
+
and a logged write that is no declared node, or inside none, with
|
|
354
|
+
`WRITE_OUTSIDE_DECLARED`. The CLI refuses a malformed `evidence` with `USAGE`, and
|
|
355
|
+
one node declared with two different after images with `EVIDENCE_MISMATCH`.
|
|
356
|
+
|
|
345
357
|
**Change-set context (DEC-0204).** A submit tells the reviewer what they are
|
|
346
358
|
looking at. `figma submit CHANGE_SET --file SUBMIT.json` takes:
|
|
347
359
|
|
package/dist/cli.js
CHANGED
|
@@ -187,7 +187,9 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
187
187
|
# variants: [{ nodeId, name, context, afterPngBase64 }] }] } (DEC-0204);
|
|
188
188
|
# a missing writeUp, context or variant name, or an item with no variants,
|
|
189
189
|
# is refused before Dev is called (writeUp <= 2000, context <= 500, name <= 120;
|
|
190
|
-
# never a bare node id)
|
|
190
|
+
# never a bare node id). The CLI adds evidence { baseVersion, finishVersion,
|
|
191
|
+
# nodes: [{ nodeId, afterSha256 }] }: list any node written beyond the variants
|
|
192
|
+
# in the body's evidence.nodes, or Dev refuses WRITE_OUTSIDE_DECLARED
|
|
191
193
|
figma checked CHANGE_SET --unused-properties --stale-placeholders --dialog-body # the hand checks the submit nudge asks for
|
|
192
194
|
# submit, resubmit and design check --change-set run as a job in Dev
|
|
193
195
|
# and poll it (a large set outlasts the edge's timeout); --sync waits
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.86";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/figma.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { readFile } from "node:fs/promises";
|
|
2
3
|
import { setTimeout as delay } from "node:timers/promises";
|
|
3
4
|
import { CliError, devAsyncRequest, devRequest, encode } from "./core.js";
|
|
@@ -122,7 +123,20 @@ const noVariantLines = (items = []) =>
|
|
|
122
123
|
items.map((i) => ` ${itemLabel(i)} has no variants; add at least one { nodeId, name, context } (an empty item reaches review with nothing to see)`);
|
|
123
124
|
|
|
124
125
|
/** Refuses, before any call to Dev, a submit or re-submit body that Dev would refuse for its context (DEV-DSN-25). */
|
|
126
|
+
/** The evidence a lane states in its body has the shape Dev's gate takes (hub-258). */
|
|
127
|
+
function assertEvidenceShape(evidence, file) {
|
|
128
|
+
if (evidence === undefined) return;
|
|
129
|
+
const bad = (why) => new CliError("USAGE", `${file}: evidence ${why}; nothing was sent`, 2);
|
|
130
|
+
if (!evidence || typeof evidence !== "object" || Array.isArray(evidence)) throw bad("must be an object");
|
|
131
|
+
if (evidence.nodes !== undefined && !Array.isArray(evidence.nodes)) throw bad("nodes must be a list of { nodeId, afterSha256? }");
|
|
132
|
+
(evidence.nodes ?? []).forEach((node, n) => {
|
|
133
|
+
if (typeof node?.nodeId !== "string" || !node.nodeId) throw bad(`nodes[${n}] needs nodeId`);
|
|
134
|
+
if (node.afterSha256 !== undefined && !/^[0-9a-f]{64}$/.test(node.afterSha256)) throw bad(`nodes[${n}] afterSha256 must be a lowercase hex sha256`);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
125
138
|
export function assertContext(body, { resubmit = false, file = "the payload" } = {}) {
|
|
139
|
+
assertEvidenceShape(body.evidence, file);
|
|
126
140
|
const { items, problems } = contextProblems(body, { resubmit });
|
|
127
141
|
if (items.length)
|
|
128
142
|
throw new CliError(
|
|
@@ -298,15 +312,44 @@ async function afterGatewayTimeout(id, kind, before, error, { sync, request, pro
|
|
|
298
312
|
);
|
|
299
313
|
}
|
|
300
314
|
|
|
315
|
+
/** The sha256 Dev stores for an inline PNG: the hash of its decoded bytes. */
|
|
316
|
+
const pngSha256 = (base64) => createHash("sha256").update(Buffer.from(base64, "base64")).digest("hex");
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* What a submit declares to Dev's gate (hub-258, option A): the base version, the
|
|
320
|
+
* finish version, and the declared nodes with the hash of each after PNG. It reads
|
|
321
|
+
* only the body and the set, never the file. Nodes the lane wrote beyond its items
|
|
322
|
+
* and variants come from the body's evidence.nodes. They never come from the set's
|
|
323
|
+
* write log: that would declare every logged write and empty WRITE_OUTSIDE_DECLARED.
|
|
324
|
+
*/
|
|
325
|
+
export function submitEvidence(body, set) {
|
|
326
|
+
const nodes = new Map();
|
|
327
|
+
const declare = (nodeId, afterSha256) => {
|
|
328
|
+
const known = nodes.get(nodeId);
|
|
329
|
+
if (known && afterSha256 && known.afterSha256 && known.afterSha256 !== afterSha256)
|
|
330
|
+
throw new CliError("EVIDENCE_MISMATCH", `Node ${nodeId} is declared with two different after images: ${known.afterSha256} and ${afterSha256}. Send the one PNG the Figma MCP's get_screenshot returned for it.`, 1, { nodeId, hashes: [known.afterSha256, afterSha256] });
|
|
331
|
+
if (!known || afterSha256) nodes.set(nodeId, { nodeId, ...(afterSha256 ? { afterSha256 } : {}) });
|
|
332
|
+
};
|
|
333
|
+
for (const item of body.items ?? [])
|
|
334
|
+
for (const variant of item.variants ?? [])
|
|
335
|
+
if (variant.afterPngBase64) declare(variant.nodeId, pngSha256(variant.afterPngBase64));
|
|
336
|
+
for (const node of body.evidence?.nodes ?? []) declare(node.nodeId, node.afterSha256);
|
|
337
|
+
const stated = body.evidence ?? {};
|
|
338
|
+
return {
|
|
339
|
+
baseVersion: stated.baseVersion !== undefined ? stated.baseVersion : (set?.baseVersion ?? null),
|
|
340
|
+
finishVersion: stated.finishVersion ?? body.figmaVersion,
|
|
341
|
+
nodes: [...nodes.values()],
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
301
345
|
/** A submit or re-submit, async unless `sync`; a gateway timeout is checked against the set, not resent. */
|
|
302
346
|
async function submitCall(id, kind, body, { sync = false, request = devRequest, progress = stderrLine, ...job } = {}) {
|
|
303
347
|
const path = `/api/v1/design/change-sets/${encode(id)}/${kind}`;
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
} catch {}
|
|
348
|
+
// The set's base goes in the evidence, so a submit that can't read it doesn't start.
|
|
349
|
+
const before = (await request("GET", `/api/v1/design/change-sets/${encode(id)}`)).data;
|
|
350
|
+
const sent = { ...body, evidence: submitEvidence(body, before) };
|
|
308
351
|
try {
|
|
309
|
-
return sync ? await request("POST", path,
|
|
352
|
+
return sync ? await request("POST", path, sent) : await changeSetJob("POST", path, sent, { changeSetId: id, kind, request, progress, ...job });
|
|
310
353
|
} catch (error) {
|
|
311
354
|
if (!GATEWAY.has(error?.code)) throw error;
|
|
312
355
|
return afterGatewayTimeout(id, kind, before, error, { sync, request, progress });
|
package/dist/hooks.js
CHANGED
|
@@ -230,7 +230,7 @@ export const heartbeatSettingsSnippet = () => {
|
|
|
230
230
|
};
|
|
231
231
|
|
|
232
232
|
/** One rate-limited heartbeat for the worktree a hook fired in. The stamp is written first, so parallel tool calls send one. */
|
|
233
|
-
export async function heartbeatFromHook(payload, { request = devRequest, now = Date.now, minIntervalMs = HEARTBEAT_MIN_INTERVAL_MS } = {}) {
|
|
233
|
+
export async function heartbeatFromHook(payload, { request = devRequest, now = Date.now, minIntervalMs = HEARTBEAT_MIN_INTERVAL_MS, env = process.env } = {}) {
|
|
234
234
|
const cwd = payload?.cwd ?? process.cwd();
|
|
235
235
|
let stamp;
|
|
236
236
|
try { stamp = (await execFileAsync("git", ["rev-parse", "--path-format=absolute", "--git-path", HEARTBEAT_STAMP], { cwd, encoding: "utf8" })).stdout.trim(); }
|
|
@@ -240,21 +240,27 @@ export async function heartbeatFromHook(payload, { request = devRequest, now = D
|
|
|
240
240
|
// A stamp from the future (a clock change) must not silence the lane.
|
|
241
241
|
if (at >= last && at - last < minIntervalMs) return { heartbeated: false, reason: "rate limited" };
|
|
242
242
|
await writeFile(stamp, String(at));
|
|
243
|
-
return heartbeatCurrentLane(request, { cwd });
|
|
243
|
+
return heartbeatCurrentLane(request, { cwd, env });
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
export async function heartbeatCurrentLane(request = devRequest, { cwd = process.cwd() } = {}) {
|
|
246
|
+
export async function heartbeatCurrentLane(request = devRequest, { cwd = process.cwd(), env = process.env } = {}) {
|
|
247
247
|
let branch;
|
|
248
248
|
try { branch = (await execFileAsync("git", ["branch", "--show-current"], { cwd, encoding: "utf8" })).stdout.trim(); }
|
|
249
249
|
catch { return { heartbeated: false, reason: "not a git worktree" }; }
|
|
250
250
|
if (!branch) return { heartbeated: false, reason: "detached HEAD" };
|
|
251
251
|
try {
|
|
252
252
|
const markerPath = (await execFileAsync("git", ["rev-parse", "--path-format=absolute", "--git-path", "nodii-lane.json"], { cwd, encoding: "utf8" })).stdout.trim();
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
253
|
+
// A launched run names its lane in NODII_DEV_LANE_KEY. Older worktrees have
|
|
254
|
+
// no marker, and the branch lookup below only sees the newest 200 lanes, so
|
|
255
|
+
// a lane older than that page would never beat without this (AGENT-HARNESS-86).
|
|
256
|
+
const marker = await readFile(markerPath, "utf8").then(JSON.parse).catch(() => null);
|
|
257
|
+
const laneKey = marker?.laneKey ?? env.NODII_DEV_LANE_KEY;
|
|
258
|
+
if (laneKey) {
|
|
259
|
+
const lane = (await request("GET", `/api/v1/lanes/${encodeURIComponent(laneKey)}`)).data;
|
|
260
|
+
if (lane.repositories?.some((repository) => repository.branch === branch)) {
|
|
261
|
+
await request("POST", `/api/v1/lanes/${encodeURIComponent(lane.id)}/heartbeat`, { via: "nodii-dev" });
|
|
262
|
+
return { heartbeated: true, key: lane.key };
|
|
263
|
+
}
|
|
258
264
|
}
|
|
259
265
|
} catch {}
|
|
260
266
|
const lanes = (await request("GET", "/api/v1/lanes?limit=200")).data ?? [];
|