@nodii/dev 0.6.115 → 0.6.117
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/dist/cli.js +12 -3
- package/dist/core.js +1 -1
- package/dist/design.js +48 -4
- package/dist/figma.js +132 -4
- package/dist/flags.js +1 -0
- package/dist/starting.js +41 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -114,6 +114,7 @@ import {
|
|
|
114
114
|
import {
|
|
115
115
|
amendmentGuard,
|
|
116
116
|
amendLaneCommand,
|
|
117
|
+
foldLaneCommand,
|
|
117
118
|
laneAuthorityCommand,
|
|
118
119
|
coordinatorCommand,
|
|
119
120
|
gatherLaneCommand,
|
|
@@ -211,6 +212,9 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
211
212
|
# submit gate on the same body, as design check --change-set; never writes
|
|
212
213
|
# --lane-reads (submit, resubmit, --dry-run): Dev runs no job and answers on
|
|
213
214
|
# the request from your MCP and REST reads; it names any read it still needs
|
|
215
|
+
# reads over 8 MB go up to the set in chunks first (hub-310), and a chunk
|
|
216
|
+
# that drops is sent again; the dry run of a submit past 300 node ids
|
|
217
|
+
# runs in parts and reports once
|
|
214
218
|
# SUBMIT.json: { figmaVersion, writeUp, items: [{ figmaNodeId, change, context,
|
|
215
219
|
# variants: [{ nodeId, name, context, afterPngBase64 }] }] } (DEC-0204);
|
|
216
220
|
# a missing writeUp, context or variant name, or an item with no variants,
|
|
@@ -317,6 +321,10 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
317
321
|
lane amend <key> --objective|--scope|--rules TEXT --reason TEXT
|
|
318
322
|
# an --objective or --scope amendment needs the person's recorded
|
|
319
323
|
# scope_change first (MW1-12.5); a --rules amendment needs none
|
|
324
|
+
lane fold <key> --versions 3,4,5|3-9 --summary TEXT --reason TEXT
|
|
325
|
+
# folds superseded scope/rules amendments into one rules note, so a
|
|
326
|
+
# lane at its note cap (LANE_NOTES_FULL) takes amendments again;
|
|
327
|
+
# coordinator, staff or stepped-up operator (hub-306)
|
|
320
328
|
lane authority record <key> --kind scope_change|handover|deploy_go --quote TEXT --at ISO [--to-agent ID]
|
|
321
329
|
# a person's word, verbatim, with when they said it (MW1-12.5);
|
|
322
330
|
# recorded from their own sign-in, never from a lane's config
|
|
@@ -994,6 +1002,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
994
1002
|
return emit({ data: result.data }, json, result.text);
|
|
995
1003
|
}
|
|
996
1004
|
if (command === "lane" && action === "amend") return emitCommand(await amendLaneCommand(rest[0], f));
|
|
1005
|
+
if (command === "lane" && action === "fold") return emitCommand(await foldLaneCommand(rest[0], f));
|
|
997
1006
|
if (command === "lane" && action === "authority") return emitCommand(await laneAuthorityCommand(rest[0], rest[1], f));
|
|
998
1007
|
if (command === "lane" && action === "gather") {
|
|
999
1008
|
const result = await gatherLaneCommand(rest[0], f);
|
|
@@ -1338,10 +1347,10 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1338
1347
|
return emit(await figmaFilePublished(rest[0], await publishedBody(f)).catch((error) => { throw laneReadsRefusal(error); }), json, (p) => figmaFilePublishedText(p.data));
|
|
1339
1348
|
// --dry-run runs Dev's dry run of the submit gate (design check --change-set)
|
|
1340
1349
|
// on the same body, and never writes (CLI-18).
|
|
1341
|
-
const dryRun = async (id, text, file) => {
|
|
1350
|
+
const dryRun = async (id, text, file, { split = false } = {}) => {
|
|
1342
1351
|
const laneReads = f["lane-reads"] ? await readLaneReads(f["lane-reads"]) : undefined;
|
|
1343
1352
|
const result = await designCheckChangeSet(undefined, { "change-set": id, ...(text ? { file } : {}), ...(f["figma-version"] ? { "figma-version": f["figma-version"] } : {}), ...(f.sync ? { sync: true } : {}), ...(f.async ? { async: true } : {}) },
|
|
1344
|
-
{ read: async () => text, ...(laneReads ? { laneReads } : {}) }).catch((error) => { throw laneReadsRefusal(error); });
|
|
1353
|
+
{ read: async () => text, split, ...(laneReads ? { laneReads } : {}) }).catch((error) => { throw laneReadsRefusal(error); });
|
|
1345
1354
|
emit(result.payload, json, result.human);
|
|
1346
1355
|
if (result.exitCode) {
|
|
1347
1356
|
if (!json) console.error(`DS_CONFORMANCE_FAILED: ${result.payload.data.findings.length} finding(s)`);
|
|
@@ -1353,7 +1362,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1353
1362
|
// The same body checks as the real submit, which needs --file.
|
|
1354
1363
|
const text = f.file ? await readFile(f.file, "utf8") : null;
|
|
1355
1364
|
checkSubmitPayload(text ? JSON.parse(text) : { figmaVersion: f["figma-version"] }, f.file || "the submit (no --file)");
|
|
1356
|
-
return dryRun(rest[0], text, f.file);
|
|
1365
|
+
return dryRun(rest[0], text, f.file, { split: true });
|
|
1357
1366
|
}
|
|
1358
1367
|
if (action === "resubmit" && f["dry-run"]) {
|
|
1359
1368
|
if (!rest[0] || !rest[1]) throw new CliError("USAGE", "figma resubmit CHANGE_SET PAYLOAD.json --dry-run", 2);
|
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.117";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/design.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// library main.
|
|
9
9
|
import { readFile } from "node:fs/promises";
|
|
10
10
|
import { CliError, devRequest } from "./core.js";
|
|
11
|
-
import { conformanceLines, figmaConformance, figmaFileKey, submitMode, surfacesCheck } from "./figma.js";
|
|
11
|
+
import { conformanceLines, figmaConformance, figmaFileKey, laneReadsBody, submitMode, surfacesCheck } from "./figma.js";
|
|
12
12
|
import { checkConformance, neededMains, VERSION as CHECK_VERSION } from "./vendor/ds-conformance.mjs";
|
|
13
13
|
|
|
14
14
|
const FIGMA_API = "https://api.figma.com/v1";
|
|
@@ -439,13 +439,48 @@ export function designCheckText({ data }) {
|
|
|
439
439
|
return [...lines, ...conformanceLines(data)].join("\n");
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
+
// Dev's dry run checks at most this many node ids (an item and each of its
|
|
443
|
+
// variants count one each), refused CONFORMANCE_TOO_MANY_NODES past it.
|
|
444
|
+
export const DRY_RUN_MAX_NODES = 300;
|
|
445
|
+
const itemNodes = (item) => 1 + (item.variants?.length ?? 0);
|
|
446
|
+
/** A submit body's items in runs of at most `max` node ids; an item larger than that runs alone. */
|
|
447
|
+
export function dryRunGroups(items, max = DRY_RUN_MAX_NODES) {
|
|
448
|
+
const groups = [];
|
|
449
|
+
let group = [];
|
|
450
|
+
let nodes = 0;
|
|
451
|
+
for (const item of items) {
|
|
452
|
+
if (group.length > 0 && nodes + itemNodes(item) > max) {
|
|
453
|
+
groups.push(group);
|
|
454
|
+
group = [];
|
|
455
|
+
nodes = 0;
|
|
456
|
+
}
|
|
457
|
+
group.push(item);
|
|
458
|
+
nodes += itemNodes(item);
|
|
459
|
+
}
|
|
460
|
+
if (group.length > 0) groups.push(group);
|
|
461
|
+
return groups;
|
|
462
|
+
}
|
|
463
|
+
// The dry runs of a split body, as one report: it passes when every run passed.
|
|
464
|
+
function mergedReports(reports) {
|
|
465
|
+
const all = (key) => reports.flatMap((r) => r[key] ?? []);
|
|
466
|
+
const sum = (key) => reports.reduce((n, r) => n + (r.checked?.[key] ?? 0), 0);
|
|
467
|
+
return {
|
|
468
|
+
version: reports[0]?.version,
|
|
469
|
+
passed: reports.every((r) => Boolean(r.passed)),
|
|
470
|
+
checked: { roots: sum("roots"), mains: sum("mains"), images: sum("images"), libraryVersion: reports.find((r) => r.checked?.libraryVersion)?.checked.libraryVersion ?? null },
|
|
471
|
+
findings: all("findings"), staleOverrides: all("staleOverrides"), libraryUpdatePending: all("libraryUpdatePending"),
|
|
472
|
+
outOfScope: all("outOfScope"), outOfScopeNodes: reports.reduce((n, r) => n + (r.outOfScopeNodes ?? 0), 0), warnings: all("warnings"),
|
|
473
|
+
staleVersion: reports.find((r) => r.staleVersion)?.staleVersion ?? null,
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
|
|
442
477
|
/**
|
|
443
478
|
* `design check --change-set CS-1 [--file SUBMIT.json] [--figma-version V]`: Dev's own dry run of
|
|
444
479
|
* the submit gate on a change set (checkDesignConformance): the same checks
|
|
445
480
|
* plus the submit-time guards against the set's items: IMAGE_NOT_TRUECOLOR
|
|
446
481
|
* refuses; STALE_FIGMA_VERSION is a warning. Changes no state.
|
|
447
482
|
*/
|
|
448
|
-
export async function designCheckChangeSet(target, flags, { request = devRequest, send, progress, read = (f) => readFile(f, "utf8"), laneReads } = {}) {
|
|
483
|
+
export async function designCheckChangeSet(target, flags, { request = devRequest, send, progress, read = (f) => readFile(f, "utf8"), laneReads, split = false } = {}) {
|
|
449
484
|
const id = flags["change-set"];
|
|
450
485
|
// On the lane's reads Dev answers on the request, with no job (hub-295).
|
|
451
486
|
const sync = laneReads ? true : submitMode(flags);
|
|
@@ -465,10 +500,19 @@ export async function designCheckChangeSet(target, flags, { request = devRequest
|
|
|
465
500
|
if (!body || typeof body !== "object" || Array.isArray(body)) throw new CliError("USAGE", `${flags.file}: expected the submit body, a JSON object`, 2);
|
|
466
501
|
}
|
|
467
502
|
if (flags["figma-version"]) body = { ...body, figmaVersion: String(flags["figma-version"]) };
|
|
468
|
-
|
|
503
|
+
// hub-310: large reads go up once, in chunks, and every run names them.
|
|
504
|
+
if (laneReads) body = { ...body, ...(await laneReadsBody(id, laneReads, { request, ...(progress ? { progress } : {}) })) };
|
|
505
|
+
// A submit body past the dry run's node limit runs in parts, each under it;
|
|
506
|
+
// a re-submit's can't be split, since it must name every rejected item.
|
|
507
|
+
const groups = split && Array.isArray(body.items) ? dryRunGroups(body.items) : [];
|
|
469
508
|
let p;
|
|
470
509
|
try {
|
|
471
|
-
|
|
510
|
+
const run = (b) => figmaConformance(id, b, { request, sync, ...(send ? { send } : {}), ...(progress ? { progress } : {}) });
|
|
511
|
+
if (groups.length > 1) {
|
|
512
|
+
const reports = [];
|
|
513
|
+
for (const items of groups) reports.push((await run({ ...body, items })).data ?? {});
|
|
514
|
+
p = { data: mergedReports(reports) };
|
|
515
|
+
} else p = await run(body);
|
|
472
516
|
} catch (error) {
|
|
473
517
|
// A cold run reads every root and main from Figma and can outlast the
|
|
474
518
|
// edge's gateway (504, an HTML page). Dev keeps the mains it read for 5
|
package/dist/figma.js
CHANGED
|
@@ -369,7 +369,8 @@ export async function figmaResubmit(id, file, { request = devRequest, read = (f)
|
|
|
369
369
|
const body = assertContext(resubmitPayload(text, file), { resubmit: true, file });
|
|
370
370
|
try {
|
|
371
371
|
// On the lane's reads Dev answers on the request, with no job (hub-295).
|
|
372
|
-
|
|
372
|
+
const reads = await laneReadsBody(id, laneReads, { request, ...(options.progress ? { progress: options.progress } : {}) });
|
|
373
|
+
return await submitCall(id, "resubmit", { ...body, ...reads }, { request, ...options, ...(laneReads ? { sync: true } : {}) });
|
|
373
374
|
} catch (error) {
|
|
374
375
|
if (error?.code === "FIGMA_READS_NEEDED") throw laneReadsRefusal(error);
|
|
375
376
|
const say = RESUBMIT_REFUSALS[error?.code];
|
|
@@ -748,12 +749,13 @@ export function checkSubmitPayload(payload, file = "the submit body") {
|
|
|
748
749
|
return assertContext(payload, { file });
|
|
749
750
|
}
|
|
750
751
|
|
|
751
|
-
export async function figmaSubmit(id, payload, { request = devRequest, file = "the submit body", laneReads, ...options } = {}) {
|
|
752
|
+
export async function figmaSubmit(id, payload, { request = devRequest, file = "the submit body", laneReads, progress, ...options } = {}) {
|
|
752
753
|
checkSubmitPayload(payload, file);
|
|
753
754
|
// On the lane's reads Dev answers on the request, with no job (hub-295).
|
|
754
755
|
const sync = laneReads ? { sync: true } : {};
|
|
755
|
-
|
|
756
|
-
|
|
756
|
+
const reads = await laneReadsBody(id, laneReads, { request, ...(progress ? { progress } : {}) });
|
|
757
|
+
return changeSetCall(id, (method, path, body) => submitCall(id, "submit", body, { request, ...options, ...(progress ? { progress } : {}), ...sync }))(
|
|
758
|
+
"POST", `/api/v1/design/change-sets/${encode(id)}/submit`, { ...payload, ...reads }).catch((error) => {
|
|
757
759
|
throw laneReadsRefusal(error);
|
|
758
760
|
});
|
|
759
761
|
}
|
|
@@ -1027,6 +1029,132 @@ export const figmaWithdrawItemsText = (id, d = {}) => {
|
|
|
1027
1029
|
].join("\n");
|
|
1028
1030
|
};
|
|
1029
1031
|
|
|
1032
|
+
// hub-310 (hub-ee's design of 7 Nov): reads larger than this go up to
|
|
1033
|
+
// Dev in chunks of about this size, by id, so no submit body passes Dev's 32 MB
|
|
1034
|
+
// cap. Smaller reads still go inline. One read bigger than this goes up in
|
|
1035
|
+
// parts (laneReadsParts).
|
|
1036
|
+
export const LANE_READS_CHUNK_BYTES = 8 * 1024 * 1024;
|
|
1037
|
+
const jsonBytes = (value) => Buffer.byteLength(JSON.stringify(value));
|
|
1038
|
+
// The lists that hold the bulk of a lane's reads; everything else rides in the
|
|
1039
|
+
// first chunk.
|
|
1040
|
+
const CHUNKED_LISTS = ["nodes", "documents", "rest"];
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* The lane's reads as chunks of about `limit` bytes each, every one at the
|
|
1044
|
+
* reads' Figma version. The first carries the small parts (pages, gone, base,
|
|
1045
|
+
* publish, restReads); nodes, documents and REST answers are split entry by
|
|
1046
|
+
* entry. One entry larger than `limit` goes alone, in a chunk of just that
|
|
1047
|
+
* entry at the reads' version, which goes up in parts. Dev puts them back together.
|
|
1048
|
+
*/
|
|
1049
|
+
export function laneReadsChunks(reads, limit = LANE_READS_CHUNK_BYTES) {
|
|
1050
|
+
const { figmaVersion } = reads;
|
|
1051
|
+
const small = Object.fromEntries(Object.entries(reads).filter(([key]) => !CHUNKED_LISTS.includes(key)));
|
|
1052
|
+
const chunks = [];
|
|
1053
|
+
const alone = [];
|
|
1054
|
+
let chunk = { ...small, nodes: [] };
|
|
1055
|
+
let used = jsonBytes(chunk);
|
|
1056
|
+
let entries = 0;
|
|
1057
|
+
for (const list of CHUNKED_LISTS)
|
|
1058
|
+
for (const entry of reads[list] ?? []) {
|
|
1059
|
+
const bytes = jsonBytes(entry) + 1;
|
|
1060
|
+
// One entry bigger than a chunk goes in a chunk of its own, the same
|
|
1061
|
+
// bytes whatever else the reads hold: Dev then has it by its hash after
|
|
1062
|
+
// the first upload, and a later request sends it no more (hub-ee, 8 Nov:
|
|
1063
|
+
// the same library main once per set).
|
|
1064
|
+
if (bytes > limit) {
|
|
1065
|
+
alone.push({ figmaVersion, nodes: [], [list]: [entry] });
|
|
1066
|
+
continue;
|
|
1067
|
+
}
|
|
1068
|
+
if (entries > 0 && used + bytes > limit) {
|
|
1069
|
+
chunks.push(chunk);
|
|
1070
|
+
chunk = { figmaVersion, nodes: [] };
|
|
1071
|
+
used = jsonBytes(chunk);
|
|
1072
|
+
entries = 0;
|
|
1073
|
+
}
|
|
1074
|
+
(chunk[list] ??= []).push(entry);
|
|
1075
|
+
used += bytes;
|
|
1076
|
+
entries += 1;
|
|
1077
|
+
}
|
|
1078
|
+
chunks.push(chunk);
|
|
1079
|
+
return [...chunks, ...alone];
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// One part of a chunk that one read makes bigger than a chunk: about this many
|
|
1083
|
+
// of the chunk's bytes, base64 encoded, under Dev's 16 MB request cap.
|
|
1084
|
+
export const LANE_READS_PART_BYTES = 6 * 1024 * 1024;
|
|
1085
|
+
|
|
1086
|
+
/**
|
|
1087
|
+
* A chunk's JSON split by bytes into parts, each with the whole chunk's hash,
|
|
1088
|
+
* its index and the count, as POST /design/change-sets/:id/reads/parts takes
|
|
1089
|
+
* them (hub-310, hub-ee 8 Nov: the App Frame main alone is a 34.3 MB read).
|
|
1090
|
+
*/
|
|
1091
|
+
export function laneReadsParts(chunk, size = LANE_READS_PART_BYTES) {
|
|
1092
|
+
const bytes = Buffer.from(JSON.stringify(chunk));
|
|
1093
|
+
const sha256 = createHash("sha256").update(bytes).digest("hex");
|
|
1094
|
+
const count = Math.max(1, Math.ceil(bytes.length / size));
|
|
1095
|
+
return Array.from({ length: count }, (_, index) => ({
|
|
1096
|
+
sha256, index, count, data: bytes.subarray(index * size, (index + 1) * size).toString("base64"),
|
|
1097
|
+
}));
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* What a submit, re-submit or dry run sends for the lane's reads: inline when
|
|
1102
|
+
* they fit in one chunk, else uploaded chunk by chunk to the set and named by
|
|
1103
|
+
* `readIds`. A chunk that one read makes bigger than a chunk goes up in parts,
|
|
1104
|
+
* by bytes, and Dev puts it back together. Dev keeps a chunk by its content,
|
|
1105
|
+
* and a part by the chunk's hash and its index, so one sent again is the same
|
|
1106
|
+
* one: an upload that hits a gateway timeout or a dropped connection is sent
|
|
1107
|
+
* again, and a rerun after a failure sends only what it must.
|
|
1108
|
+
*/
|
|
1109
|
+
export async function laneReadsBody(id, laneReads, { request = devRequest, progress = stderrLine, limit = LANE_READS_CHUNK_BYTES, partBytes = LANE_READS_PART_BYTES, wait = delay, attempts = 4 } = {}) {
|
|
1110
|
+
if (!laneReads) return {};
|
|
1111
|
+
if (jsonBytes(laneReads) <= limit) return { laneReads };
|
|
1112
|
+
const chunks = laneReadsChunks(laneReads, limit);
|
|
1113
|
+
const path = `/api/v1/design/change-sets/${encode(id)}/reads`;
|
|
1114
|
+
const send = async (at, body) => {
|
|
1115
|
+
for (let attempt = 1; ; attempt += 1) {
|
|
1116
|
+
try {
|
|
1117
|
+
return await request("POST", at, body);
|
|
1118
|
+
} catch (error) {
|
|
1119
|
+
if (!TRANSIENT.has(error?.code) || attempt >= attempts) throw laneReadsUploadRefusal(error, id);
|
|
1120
|
+
await wait(attempt * 2_000);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
// The parts in order; Dev answers the chunk on the last one, or names the
|
|
1125
|
+
// parts it still needs, which go again. A chunk Dev already has from these
|
|
1126
|
+
// parts is answered on the first, and the rest aren't sent.
|
|
1127
|
+
const sendParts = async (chunk) => {
|
|
1128
|
+
const parts = laneReadsParts(chunk, partBytes);
|
|
1129
|
+
let todo = parts.map((_, i) => i);
|
|
1130
|
+
for (let round = 1; ; round += 1) {
|
|
1131
|
+
let answer;
|
|
1132
|
+
for (const i of todo) {
|
|
1133
|
+
answer = (await send(`${path}/parts`, parts[i])).data;
|
|
1134
|
+
if (answer?.chunk) return answer.chunk.id;
|
|
1135
|
+
}
|
|
1136
|
+
if (!answer?.missing?.length || round >= attempts)
|
|
1137
|
+
throw new CliError("LANE_READS_UPLOAD_INCOMPLETE", `Dev didn't put the ${parts.length} parts of one lane-reads chunk together for ${id}; run the command again (sent parts are kept).`, 1, answer);
|
|
1138
|
+
todo = answer.missing;
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
const readIds = [];
|
|
1142
|
+
for (const [index, chunk] of chunks.entries()) {
|
|
1143
|
+
readIds.push(jsonBytes(chunk) > limit ? await sendParts(chunk) : (await send(path, chunk)).data.id);
|
|
1144
|
+
progress(`lane reads: ${index + 1} of ${chunks.length} chunks uploaded to ${id}`);
|
|
1145
|
+
}
|
|
1146
|
+
return { readIds };
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function laneReadsUploadRefusal(error, id) {
|
|
1150
|
+
if (error?.code === "LANE_READS_TOO_LARGE")
|
|
1151
|
+
return new CliError(error.code, `${error.message}
|
|
1152
|
+
The lane-reads chunk is larger than Dev takes, even in parts; tell the Steward (hub-310).`, error.exitCode ?? 1, error.details);
|
|
1153
|
+
if (["HTTP_404", "NOT_FOUND", "ROUTE_NOT_FOUND"].includes(error?.code))
|
|
1154
|
+
return new CliError(error.code, `Dev doesn't take lane reads in chunks yet (POST /design/change-sets/${id}/reads): this nodii-dev needs Dev with the lane-reads upload (hub-310) deployed.`, error.exitCode ?? 1, error.details);
|
|
1155
|
+
return error;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1030
1158
|
// MW1-57.11: the lane reads Figma through the MCP in its own session, and sends
|
|
1031
1159
|
// what it read. Dev runs the same gates on that, with no job and no Figma call.
|
|
1032
1160
|
export async function readLaneReads(path, { read = readFile } = {}) {
|
package/dist/flags.js
CHANGED
|
@@ -28,6 +28,7 @@ export const COMMAND_FLAGS = {
|
|
|
28
28
|
"subagents", "notes", "narrowing-note", "narrowing-remainder", "heartbeat-seconds",
|
|
29
29
|
],
|
|
30
30
|
"lane amend": ["objective", "scope", "rules", "reason"],
|
|
31
|
+
"lane fold": ["versions", "summary", "reason"],
|
|
31
32
|
"lane authority": ["kind", "quote", "at", "to-agent"],
|
|
32
33
|
"lane start": ["key", "issue", "title", "kind", "side", "repo", "branch", "worktree", "step-limit"],
|
|
33
34
|
"lane step": ["side", "start", "done", "block", "not-applicable", "reason", "reason-code", "note", "review", "delta"],
|
package/dist/starting.js
CHANGED
|
@@ -723,9 +723,49 @@ const AMEND_REFUSALS = {
|
|
|
723
723
|
LANE_LAUNCH_NOT_FOUND: (key) => `${key} was not started with nodii-dev lane launch, so it has no launch contract to amend.`,
|
|
724
724
|
// MW1-12.5: an objective or scope amendment needs the person's own word.
|
|
725
725
|
SCOPE_CHANGE_AUTHORITY_REQUIRED: (key) => `An --objective or --scope amendment needs a person's recorded word first: they run nodii-dev lane authority record ${key} --kind scope_change --quote TEXT --at ISO-TIME from their own sign-in. A --rules amendment needs none.`,
|
|
726
|
+
// hub-306: Dev refuses the amendment that would cross the note cap.
|
|
727
|
+
LANE_NOTES_FULL: (key, details) =>
|
|
728
|
+
`${key} would have ${details?.notes ?? "too many"} notes; a lane holds at most ${details?.max ?? 100}. Nothing was recorded. Fold superseded amendments into one note first: nodii-dev lane fold ${key} --versions V,V,... --summary TEXT --reason TEXT (lane show ${key} lists the versions).`,
|
|
726
729
|
};
|
|
727
730
|
const ERROR_CODE = /^[A-Z][A-Z0-9_]*$/;
|
|
728
731
|
|
|
732
|
+
const FOLD_REFUSALS = {
|
|
733
|
+
LANE_NOT_FOUND: AMEND_REFUSALS.LANE_NOT_FOUND,
|
|
734
|
+
LANE_LAUNCH_NOT_FOUND: AMEND_REFUSALS.LANE_LAUNCH_NOT_FOUND,
|
|
735
|
+
COORDINATOR_REQUIRED: (key) => `Only the machine coordinator that launched ${key}, a staff person, or the operator with a TOTP step-up may fold its amendments.`,
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* hub-306: `lane fold <key> --versions 3,4,5 --summary TEXT --reason TEXT`
|
|
740
|
+
* replaces superseded scope or rules amendments with one rules note. The
|
|
741
|
+
* originals stay on the lane and in the audit log; the lane acks the new note.
|
|
742
|
+
*/
|
|
743
|
+
export async function foldLaneCommand(key, flags, { request = devRequest } = {}) {
|
|
744
|
+
if (!key) throw new CliError("USAGE", "lane fold needs <key>.", 2);
|
|
745
|
+
const raw = requireFlag(flags, "versions");
|
|
746
|
+
const versions = String(raw).split(",").map((part) => part.trim()).filter(Boolean).flatMap((part) => {
|
|
747
|
+
const range = /^(\d+)-(\d+)$/.exec(part);
|
|
748
|
+
if (!range) return [Number(part)];
|
|
749
|
+
const [from, to] = [Number(range[1]), Number(range[2])];
|
|
750
|
+
if (to < from || to - from > 500) return [Number.NaN];
|
|
751
|
+
return Array.from({ length: to - from + 1 }, (_, index) => from + index);
|
|
752
|
+
});
|
|
753
|
+
if (versions.length < 2 || versions.some((version) => !Number.isInteger(version) || version < 1))
|
|
754
|
+
throw new CliError("USAGE", "lane fold needs --versions with two or more amendment versions, as 3,4,5 or 3-9.", 2);
|
|
755
|
+
const summary = requireFlag(flags, "summary");
|
|
756
|
+
const reason = requireFlag(flags, "reason");
|
|
757
|
+
let payload;
|
|
758
|
+
try {
|
|
759
|
+
payload = await request("POST", `/api/v1/lanes/${encode(key)}/amendments/fold`, { versions, summary, reason, ...via });
|
|
760
|
+
} catch (error) {
|
|
761
|
+
const say = FOLD_REFUSALS[error?.code];
|
|
762
|
+
if (say) throw new CliError(error.code, say(key), error.exitCode ?? 1, error.details);
|
|
763
|
+
throw error;
|
|
764
|
+
}
|
|
765
|
+
const { amendment, folded, notes } = payload.data;
|
|
766
|
+
return { payload, human: `Folded ${folded.length} amendments of ${key} into amendment ${amendment.version}; the lane now has ${notes} notes. Its run acks the new note with lane gather --delta.` };
|
|
767
|
+
}
|
|
768
|
+
|
|
729
769
|
export async function amendLaneCommand(key, flags, { request = devRequest, now = Date.now, config = readConfig } = {}) {
|
|
730
770
|
if (!key) throw new CliError("USAGE", "lane amend needs <key>.", 2);
|
|
731
771
|
const change = Object.fromEntries([["objective", flags.objective], ["scope", flags.scope], ["rules", flags.rules]].filter(([, value]) => value));
|
|
@@ -736,7 +776,7 @@ export async function amendLaneCommand(key, flags, { request = devRequest, now =
|
|
|
736
776
|
payload = await request("POST", `/api/v1/lanes/${encode(key)}/amendments`, { change, reason, ...via });
|
|
737
777
|
} catch (error) {
|
|
738
778
|
const say = AMEND_REFUSALS[error?.code];
|
|
739
|
-
if (say) throw new CliError(error.code, say(key), error.exitCode ?? 1, error.details);
|
|
779
|
+
if (say) throw new CliError(error.code, say(key, error.details), error.exitCode ?? 1, error.details);
|
|
740
780
|
// A Dev before NODII-DEV-CLI-17 answered a recorded amendment with a 409
|
|
741
781
|
// whose code is the reason itself. Read the lane back for the row.
|
|
742
782
|
if (error?.code && !ERROR_CODE.test(error.code) && error.code === reason.trim()) {
|