@nodii/dev 0.6.77 → 0.6.79
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 +35 -3
- package/dist/closeout.js +238 -0
- package/dist/core.js +2 -2
- package/dist/devops-openapi.json +1 -1
- package/dist/figma-scope.js +71 -2
- package/dist/figma.js +32 -0
- package/dist/flags.js +8 -3
- package/dist/governor.js +15 -6
- package/dist/lanes.js +172 -10
- package/dist/review.js +20 -13
- package/dist/safety.js +28 -1
- package/dist/surface.js +34 -5
- package/dist/watchdog.js +15 -1
- package/package.json +1 -1
package/dist/figma-scope.js
CHANGED
|
@@ -290,12 +290,74 @@ export const SWAP_BOUNDARIES = (key = "<key>") => `\`nodii-dev lane freeze swap
|
|
|
290
290
|
|
|
291
291
|
const outside = (message, details) => new CliError("FIGMA_OUTSIDE_LANE_SCOPE", `${message} Change the scope only with ${SWAP_BOUNDARIES()}, or ask the coordinator to amend the lane.`, 2, details);
|
|
292
292
|
|
|
293
|
+
const setLookups = new Map();
|
|
294
|
+
export const clearComponentSetLookups = () => setLookups.clear();
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* A published component set as Figma lists it under its key: { key, fileKey,
|
|
298
|
+
* nodeId, name }, or null when Figma has no set with that key. One REST read
|
|
299
|
+
* per key per process, because the CLI cannot call the Figma MCP; it is only
|
|
300
|
+
* made for a key the DS catalog does not list as a Surface (a DS component
|
|
301
|
+
* set, NODII-DEV-CLI-70).
|
|
302
|
+
*/
|
|
303
|
+
export function figmaComponentSet(key, { env = process.env, figmaGet } = {}) {
|
|
304
|
+
if (!setLookups.has(key)) {
|
|
305
|
+
const lookup = (async () => {
|
|
306
|
+
let get = figmaGet;
|
|
307
|
+
if (!get) {
|
|
308
|
+
const token = env.FIGMA_PAT || env.FIGMA_TOKEN;
|
|
309
|
+
if (!token)
|
|
310
|
+
throw new CliError("FIGMA_TOKEN_REQUIRED", `Component set ${key} is not a Surface in the DS catalog, so nodii-dev reads which node it is from Figma: set FIGMA_PAT (or FIGMA_TOKEN) in this shell's environment.`, 2);
|
|
311
|
+
const { figmaClient } = await import("./design.js");
|
|
312
|
+
get = figmaClient(token, { attempts: 3, timeoutMs: 20_000 });
|
|
313
|
+
}
|
|
314
|
+
try {
|
|
315
|
+
const meta = (await get(`/component_sets/${encodeURIComponent(key)}`))?.meta;
|
|
316
|
+
return meta?.node_id && meta?.file_key ? { key, fileKey: meta.file_key, nodeId: meta.node_id, name: meta.name ?? null } : null;
|
|
317
|
+
} catch (error) {
|
|
318
|
+
if (error?.code === "FIGMA_NOT_FOUND") return null;
|
|
319
|
+
throw error;
|
|
320
|
+
}
|
|
321
|
+
})();
|
|
322
|
+
// A failed read is not remembered; the next caller asks again.
|
|
323
|
+
lookup.catch(() => setLookups.delete(key));
|
|
324
|
+
setLookups.set(key, lookup);
|
|
325
|
+
}
|
|
326
|
+
return setLookups.get(key);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* What each published set key in a file names (MW8-20): a Surface's nodes and
|
|
331
|
+
* state frames from the DS catalog; else, through `lookupSet`, the set Figma
|
|
332
|
+
* publishes under that key (a DS component set, NODII-DEV-CLI-70), its own
|
|
333
|
+
* node as the one frame. `onlyIfNeeded(resolvedSoFar)` returning false skips
|
|
334
|
+
* the Figma reads. A key that names nothing in this file is refused.
|
|
335
|
+
*/
|
|
336
|
+
export async function componentSetsIn(fileKey, keys, { surfaces = [], lookupSet = figmaComponentSet, onlyIfNeeded } = {}) {
|
|
337
|
+
const sets = new Map();
|
|
338
|
+
for (const key of keys) {
|
|
339
|
+
const surface = surfaces.find((item) => item.componentSetKey === key && item.fileKey === fileKey);
|
|
340
|
+
if (surface) sets.set(key, { key, fileKey, name: surface.name, nodeIds: surface.nodeIds, frames: surface.frames ?? surface.nodeIds.map((nodeId) => ({ nodeId, state: "default" })) });
|
|
341
|
+
}
|
|
342
|
+
const rest = keys.filter((key) => !sets.has(key));
|
|
343
|
+
if (!rest.length || (onlyIfNeeded && !onlyIfNeeded(sets))) return sets;
|
|
344
|
+
for (const key of rest) {
|
|
345
|
+
const set = await lookupSet(key);
|
|
346
|
+
if (!set)
|
|
347
|
+
throw new CliError("FIGMA_KEY_UNKNOWN", `${key} is neither a Surface in the DS catalog nor a component set Figma publishes.`, 1, { fileKey, key });
|
|
348
|
+
if (set.fileKey !== fileKey)
|
|
349
|
+
throw new CliError("FIGMA_KEY_UNKNOWN", `${key}${set.name ? ` (${set.name})` : ""} is in file ${set.fileKey}, not ${fileKey}.`, 1, { fileKey, key, setFileKey: set.fileKey });
|
|
350
|
+
sets.set(key, { key, fileKey, name: set.name, nodeIds: [set.nodeId], frames: [{ nodeId: set.nodeId, state: "default" }] });
|
|
351
|
+
}
|
|
352
|
+
return sets;
|
|
353
|
+
}
|
|
354
|
+
|
|
293
355
|
/**
|
|
294
356
|
* Refuse a Figma lock (lockScopes = the scopes asked for; [] = whole file) or a
|
|
295
357
|
* write (lockScopes = null) outside the lane's scope. `scope` null = the lane
|
|
296
358
|
* declared none, so nothing is bounded here.
|
|
297
359
|
*/
|
|
298
|
-
export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalog = loadDsCatalog } = {}) {
|
|
360
|
+
export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalog = loadDsCatalog, lookupSet = figmaComponentSet } = {}) {
|
|
299
361
|
if (scope === null) return { checked: false };
|
|
300
362
|
const file = scope.find((item) => item.fileKey === fileKey);
|
|
301
363
|
if (!file)
|
|
@@ -304,7 +366,14 @@ export async function assertWithinLaneScope(scope, fileKey, lockScopes, { catalo
|
|
|
304
366
|
const wide = lockScopes.length ? lockScopes.filter((item) => item.kind !== "component") : [{ kind: "file" }];
|
|
305
367
|
if (wide.length)
|
|
306
368
|
throw outside(`This lane may lock only its component sets in ${fileKey}, not ${wide.map((item) => item.kind).join(", ")}.`, { fileKey, scope: file });
|
|
307
|
-
|
|
369
|
+
// Surfaces first; Figma is read for a DS set's key only when a node is still unaccounted for.
|
|
370
|
+
const allowedBy = (sets) => new Set([...sets.values()].flatMap((set) => set.nodeIds));
|
|
371
|
+
const sets = await componentSetsIn(fileKey, file.componentSets, {
|
|
372
|
+
surfaces: await catalog(),
|
|
373
|
+
lookupSet,
|
|
374
|
+
onlyIfNeeded: (found) => lockScopes.some((item) => !allowedBy(found).has(item.nodeId)),
|
|
375
|
+
});
|
|
376
|
+
const allowed = allowedBy(sets);
|
|
308
377
|
const stray = lockScopes.filter((item) => !allowed.has(item.nodeId));
|
|
309
378
|
if (stray.length)
|
|
310
379
|
throw outside(`${stray.map((item) => item.nodeId).join(", ")} in ${fileKey} is not one of this lane's component sets (${file.componentSets.join(", ")}).`, { fileKey, scope: file, nodeIds: stray.map((item) => item.nodeId) });
|
package/dist/figma.js
CHANGED
|
@@ -346,6 +346,38 @@ const BEFORE_CONTEXT = "submitted before 31 Oct";
|
|
|
346
346
|
const variantLine = (v) =>
|
|
347
347
|
` variant ${v.figmaNodeId} ${v.name ?? `(no name: ${BEFORE_CONTEXT})`} (${[v.beforeImageId && "before", v.afterImageId && "after"].filter(Boolean).join(", ") || "no images"})${v.context ? `: ${v.context}` : ""}`;
|
|
348
348
|
|
|
349
|
+
/**
|
|
350
|
+
* hub-260: change sets in dependency order. Each file's sets are actioned in
|
|
351
|
+
* their order (file_sequence); by default only the review queue (in review or
|
|
352
|
+
* applying), `--actionable` only the sets an operator can act on now, `--all`
|
|
353
|
+
* every state.
|
|
354
|
+
*/
|
|
355
|
+
export async function figmaChangeSetList(flags = {}, { request = devRequest } = {}) {
|
|
356
|
+
const params = new URLSearchParams({ sort: "dependency", limit: String(flags.limit ?? 200) });
|
|
357
|
+
if (flags.file) params.set("fileKey", figmaFileKey(flags.file));
|
|
358
|
+
if (flags.actionable) params.set("actionable", "true");
|
|
359
|
+
if (!flags.all) for (const state of ["in_review", "applying"]) params.append("state", state);
|
|
360
|
+
return request("GET", `/api/v1/design/change-sets?${params}`);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** One line per set: its place on its file, whether it can be acted on now, and what it waits behind. */
|
|
364
|
+
export function figmaChangeSetListText(rows = [], total = rows.length) {
|
|
365
|
+
if (!rows.length) return "No change sets.";
|
|
366
|
+
const lines = [];
|
|
367
|
+
let file = null;
|
|
368
|
+
for (const cs of rows) {
|
|
369
|
+
if (cs.fileKey !== file) {
|
|
370
|
+
file = cs.fileKey;
|
|
371
|
+
lines.push(`${cs.file?.name ?? cs.fileKey} (${cs.fileKey})`);
|
|
372
|
+
}
|
|
373
|
+
const place = cs.fileSequence ? `#${cs.fileSequence}` : "-";
|
|
374
|
+
const now = cs.actionable ? "NEXT" : cs.blockedBy ? `waits behind ${cs.blockedBy}` : "";
|
|
375
|
+
lines.push(` ${place}\t${cs.id}\t${cs.state}\t${cs.title}${now ? `\t${now}` : ""}`);
|
|
376
|
+
}
|
|
377
|
+
if (total > rows.length) lines.push(`(${rows.length} of ${total} shown; narrow with --file or --actionable, or pass --limit)`);
|
|
378
|
+
return lines.join("\n");
|
|
379
|
+
}
|
|
380
|
+
|
|
349
381
|
/**
|
|
350
382
|
* One change set as lines: its write-up, and its items' round, decision, comment,
|
|
351
383
|
* the previous round's decision and comment, context and variants. An item with
|
package/dist/flags.js
CHANGED
|
@@ -36,12 +36,15 @@ export const COMMAND_FLAGS = {
|
|
|
36
36
|
"sync pending": ["discard", "reason"],
|
|
37
37
|
"lane done-check": ["evidence"],
|
|
38
38
|
"lane cap": ["confirm-raise", "reason"],
|
|
39
|
-
"lane heartbeat": ["note"],
|
|
39
|
+
"lane heartbeat": ["note", "waiting-on"],
|
|
40
|
+
"lane waits": ["machine"],
|
|
40
41
|
"lane resume": ["override", "reason", "host-lost", "min-free-gb", "stagger-seconds", "profile", "class"],
|
|
41
42
|
"lane transfer": ["reason", "to-agent"],
|
|
42
|
-
"lane stop": ["reason"],
|
|
43
|
+
"lane stop": ["reason", "sweeper", "no-closeout"],
|
|
44
|
+
"lane closeout": ["reason"],
|
|
45
|
+
"lane repo": ["repo", "branch", "worktree", "read-only", "reason"],
|
|
43
46
|
// hub-232: the honest close-out and the governor.
|
|
44
|
-
"lane close": ["delivered-by", "reason"],
|
|
47
|
+
"lane close": ["delivered-by", "reason", "sweeper", "no-closeout"],
|
|
45
48
|
"governor show": ["machine-id"],
|
|
46
49
|
"governor override": ["machine-id", "quote", "said-at", "reason", "minutes"],
|
|
47
50
|
"governor overrides": ["machine-id"],
|
|
@@ -61,6 +64,8 @@ export const COMMAND_FLAGS = {
|
|
|
61
64
|
"figma resubmit": [...SUBMIT_MODE, "dry-run"],
|
|
62
65
|
"figma withdraw": ["items", "reason"],
|
|
63
66
|
"figma abandon": ["file"],
|
|
67
|
+
// hub-260: list takes these; show takes none.
|
|
68
|
+
"figma changeset": ["file", "actionable", "all", "limit"],
|
|
64
69
|
"figma apply": ["file", "figma-version"],
|
|
65
70
|
"figma lock": ["title", "scope"],
|
|
66
71
|
"surface generate": ["write", "check", "fetch", "all", "module", "type", "figma-version", "report"],
|
package/dist/governor.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// before it reaches Dev, gives the honest close-out and records the operator's
|
|
5
5
|
// override. The managed hooks call the two hook entry points at the bottom.
|
|
6
6
|
import { CliError, devRequest, encode, query, readConfig, requireFlag } from "./core.js";
|
|
7
|
+
import { holdsLine, laneCloseout } from "./lanes.js";
|
|
7
8
|
|
|
8
9
|
export const GOVERNOR_REFUSALS = ["GOVERNOR_STUCK", "READY_BACKLOG"];
|
|
9
10
|
|
|
@@ -167,21 +168,29 @@ export async function governorCommand(action, flags, { request = devRequest, con
|
|
|
167
168
|
* REF adds proof the work is on dev, checked and recorded. Staff may stop on
|
|
168
169
|
* that proof alone (MW1-28).
|
|
169
170
|
*/
|
|
170
|
-
export async function laneClose(key, flags, { request = devRequest } = {}) {
|
|
171
|
+
export async function laneClose(key, flags, { request = devRequest, closeout = laneCloseout } = {}) {
|
|
171
172
|
if (!key) throw new CliError("USAGE", "lane close needs <key>.", 2);
|
|
172
173
|
const reason = requireFlag(flags, "reason");
|
|
173
174
|
if (flags["delivered-by"] !== undefined && !String(flags["delivered-by"]).trim())
|
|
174
175
|
throw new CliError("USAGE", "--delivered-by needs a verified PR URL, an on_dev lane key or a done issue key; leave it out to close a finished lane (MW1-28.2).", 2);
|
|
175
176
|
const deliveredBy = flags["delivered-by"] === undefined ? undefined : String(flags["delivered-by"]).trim();
|
|
176
|
-
const body =
|
|
177
|
+
const body = {
|
|
178
|
+
...(deliveredBy === undefined ? {} : { deliveredBy }),
|
|
179
|
+
reason,
|
|
180
|
+
...(flags.sweeper ? { sweeper: String(flags.sweeper) } : {}),
|
|
181
|
+
via: "nodii-dev",
|
|
182
|
+
};
|
|
177
183
|
const result = (await request("POST", `/api/v1/lanes/${encode(key)}/close`, body)).data;
|
|
184
|
+
// hub-244: Dev released the holds; the machine half runs here.
|
|
185
|
+
const local = flags["no-closeout"] ? null : await closeout(key, reason, { request });
|
|
178
186
|
const kind = result.deliveredBy?.kind ?? "unknown";
|
|
179
187
|
const proof = kind === "finished" ? "its own finished record (MW1-28.2)" : `${kind} ${result.deliveredBy?.ref ?? ""}`.trim();
|
|
180
188
|
const unmerged = result.unmergedOwnPrs?.length ? ` Its own unmerged PRs (close or merge them): ${result.unmergedOwnPrs.join(", ")}.` : "";
|
|
189
|
+
const head = result.closed
|
|
190
|
+
? `${key} closed out, delivered by ${proof}. Its steps are left as they were.${unmerged}`
|
|
191
|
+
: `${key} was already ${result.lane.status}; recorded that ${proof} delivered it.${unmerged}`;
|
|
181
192
|
return {
|
|
182
|
-
data: result,
|
|
183
|
-
text: result.
|
|
184
|
-
? `${key} closed out, delivered by ${proof}. Its steps are left as they were.${unmerged}`
|
|
185
|
-
: `${key} was already ${result.lane.status}; recorded that ${proof} delivered it.${unmerged}`,
|
|
193
|
+
data: { ...result, ...(local ? { closeout: local.repositories } : {}) },
|
|
194
|
+
text: [head, holdsLine(result.holdsReleased), local?.text].filter(Boolean).join("\n"),
|
|
186
195
|
};
|
|
187
196
|
}
|
package/dist/lanes.js
CHANGED
|
@@ -16,6 +16,7 @@ import { assertNothingPending, devDown, queuePending, receiptEvidenceBody, signe
|
|
|
16
16
|
import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, loadDsCatalog } from "./figma-scope.js";
|
|
17
17
|
import { designCheck } from "./design.js";
|
|
18
18
|
import { LANE_ENV_FIX, laneEnvProblem, laneEnvReport } from "./lane-env.js";
|
|
19
|
+
import { closeoutLane } from "./closeout.js";
|
|
19
20
|
import { GATES_RECEIPT, REVIEW_FILE, checkLines, checkReviewChecks, diffDigest, laneDiff, privateStore, repoGeneratedPaths, runLaneCheck, runOutcome, worktreeCommitted } from "./review.js";
|
|
20
21
|
|
|
21
22
|
const execFileAsync = promisify(execFile);
|
|
@@ -60,7 +61,49 @@ export async function inferGitContext() {
|
|
|
60
61
|
|
|
61
62
|
// `building` is the lane's phase, not a process: say when nothing healthy is running (MW1-36).
|
|
62
63
|
const laneLiveness = (x) => x.liveness && x.liveness !== "active" ? `\t${x.liveness.toUpperCase()}` : "";
|
|
63
|
-
|
|
64
|
+
// hub-246: a lane others wait on shows its effective priority and count.
|
|
65
|
+
const lanePriority = (x) => (x.waitCount ? `\tpriority ${x.effectivePriority} (${x.waitCount} waiting)` : "");
|
|
66
|
+
const laneWaitsText = (x) => (x.waits?.length ? `\twaits on ${x.waits.map(waitText).join(", ")}` : "");
|
|
67
|
+
const waitText = (w) => `${w.blockerLaneKey && w.blockerLaneKey !== w.targetRef ? `${w.blockerLaneKey} (${w.targetRef})` : w.targetRef}${w.chain ? ` [chain: ${w.chain.why} ${w.chain.headLaneKey}]` : ""}`;
|
|
68
|
+
const laneLine = (x) => `${x.key}\t${x.status}\t${x.kind}/${x.side}\t${x.title}${x.stuck ? "\tSTUCK" : ""}${laneLiveness(x)}${lanePriority(x)}${laneWaitsText(x)}`;
|
|
69
|
+
|
|
70
|
+
/** What a heartbeat changed in the lane's waits. */
|
|
71
|
+
export function heartbeatText(ref, payload, sentWaits = false) {
|
|
72
|
+
const waits = payload?.waits;
|
|
73
|
+
// A Dev without hub-246 answers with no `waits` key at all and ignores the flag.
|
|
74
|
+
if (sentWaits && waits === undefined)
|
|
75
|
+
return `${ref}: heartbeat recorded, but this Dev does not record --waiting-on yet (needs the hub-246 deploy); the wait was not stored.`;
|
|
76
|
+
if (!waits) return `${ref}: heartbeat recorded.`;
|
|
77
|
+
const lines = [`${ref}: heartbeat recorded.`];
|
|
78
|
+
for (const change of waits.changes ?? [])
|
|
79
|
+
lines.push(change.change === "new" ? ` now waits on ${change.targetRef}` : ` no longer waits on ${change.targetRef} (${change.clearReason})`);
|
|
80
|
+
for (const drop of waits.dropped ?? []) lines.push(` not a wait: ${drop.ref}: ${drop.why}`);
|
|
81
|
+
if (waits.notices) lines.push(` coordinator notified (${waits.notices} notice${waits.notices === 1 ? "" : "s"})`);
|
|
82
|
+
const current = payload.data?.waits ?? [];
|
|
83
|
+
if (current.length) lines.push(` waiting on: ${current.map(waitText).join(", ")}`);
|
|
84
|
+
return lines.join("\n");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The wait board (GET /lanes/waits) as text: blockers first, then what holds lanes outside the graph. */
|
|
88
|
+
export function waitBoardText(board) {
|
|
89
|
+
const lines = [];
|
|
90
|
+
const blockers = board?.blockers ?? [];
|
|
91
|
+
if (blockers.length) {
|
|
92
|
+
lines.push("Lanes others wait on (highest effective priority first):");
|
|
93
|
+
for (const b of blockers)
|
|
94
|
+
lines.push(` ${b.key}\tpriority ${b.effectivePriority} (own ${b.ownPriority} + ${b.waitCount} waiting)\t${b.status}${b.stuck ? " STUCK" : ""}${b.liveness === "orphan" ? " ORPHANED" : ""}\twaited on by ${(b.directWaiters ?? []).join(", ")}${b.chain ? `\tCHAIN: fix ${b.chain.headLaneKey} (${b.chain.why}) first` : ""}`);
|
|
95
|
+
} else lines.push("No lane waits on another lane.");
|
|
96
|
+
const targets = (title, rows) => {
|
|
97
|
+
if (!rows?.length) return;
|
|
98
|
+
lines.push(title);
|
|
99
|
+
for (const row of rows) lines.push(` ${row.targetRef}\tholds ${row.lanes} lane${row.lanes === 1 ? "" : "s"}: ${(row.laneKeys ?? []).join(", ")}`);
|
|
100
|
+
};
|
|
101
|
+
targets("Operator questions:", board?.operatorQuestions);
|
|
102
|
+
targets("Launch day:", board?.launchDay?.lanes ? [board.launchDay] : []);
|
|
103
|
+
targets("Decisions:", board?.decisions);
|
|
104
|
+
targets("PRs and releases with no lane found:", board?.untraced);
|
|
105
|
+
return lines.join("\n");
|
|
106
|
+
}
|
|
64
107
|
// GATHER-NA: a step the coordinator ruled not applicable is never shown as done.
|
|
65
108
|
const stepState = (s) => s.state === "not_applicable" ? `not applicable: ${s.notApplicableReason ?? "(no reason recorded)"}` : s.state;
|
|
66
109
|
const detailText = (x) => [laneLine(x), ...(x.steps ?? []).map((s) => ` ${s.side}\t${stepState(s)}\t${s.stepKey}\t${s.label}`)].join("\n");
|
|
@@ -407,9 +450,17 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
407
450
|
}
|
|
408
451
|
if (action === "list") {
|
|
409
452
|
const c = flags.mine ? await config() : null;
|
|
410
|
-
|
|
453
|
+
if (flags.sort !== undefined && !["created", "priority"].includes(flags.sort))
|
|
454
|
+
throw new CliError("USAGE", "lane list --sort takes created or priority", 2);
|
|
455
|
+
const payload = await request("GET", `/api/v1/lanes${query({ kind: flags.kind, status: flags.status, machine: flags.machine, agent: flags.mine ? c.agentId : flags.agent, "waiting-on": flags["waiting-on"], stuck: flags.stuck, sort: flags.sort, cursor: flags.cursor, limit: flags.limit })}`);
|
|
411
456
|
return { payload, human: (p) => p.data.map(laneLine).join("\n") || "No lanes." };
|
|
412
457
|
}
|
|
458
|
+
// hub-246: the wait graph, for the coordinator and the operator.
|
|
459
|
+
if (action === "waits") {
|
|
460
|
+
if (args[0]) throw new CliError("USAGE", "lane waits takes no <key>; pass --machine ID to narrow it to one machine.", 2);
|
|
461
|
+
const payload = await request("GET", `/api/v1/lanes/waits${query({ machine: flags.machine })}`);
|
|
462
|
+
return { payload, human: (p) => waitBoardText(p.data) };
|
|
463
|
+
}
|
|
413
464
|
if (action === "start") {
|
|
414
465
|
// `--key` names the lane; the positional is then the issue (NODII-DEV-CLI-13).
|
|
415
466
|
if (flags.key !== undefined && (typeof flags.key !== "string" || !flags.key.trim()))
|
|
@@ -523,12 +574,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
523
574
|
throw new CliError("GATHER_PATHS_UNAVAILABLE", "Gather could not read every recorded worktree. Repair the lane boundary or make its repositories available before continuing.", 1);
|
|
524
575
|
const paths = flags.paths ? list(flags.paths) : [...new Set([...recordedPaths, ...driftPaths])];
|
|
525
576
|
if (paths.length > 5000) throw new CliError("GATHER_SCOPE_TOO_LARGE", `Gather found ${paths.length} paths; Dev accepts at most 5,000. Narrow the lane's recorded scope before continuing.`, 1);
|
|
526
|
-
const
|
|
527
|
-
...(lane.repositories ?? []).map((repository) => repository.repo),
|
|
528
|
-
...(lane.freeze?.boundaries?.repos ?? []).map((repository) => repository.repo),
|
|
529
|
-
...(Array.isArray(lane.repos) ? lane.repos.map((repo) => typeof repo === "string" ? repo : repo.repo) : []),
|
|
530
|
-
];
|
|
531
|
-
const repos = [...new Set(repoRefs.filter(Boolean).map(repoName))];
|
|
577
|
+
const repos = shortlistRepos(lane);
|
|
532
578
|
// The Figma scope (published keys) pulls in the DS components its
|
|
533
579
|
// Surfaces are built from, so their guidelines and U-docs apply.
|
|
534
580
|
// null = no declared Figma scope (kept undeclared); [] = declared "no Figma".
|
|
@@ -858,7 +904,12 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
858
904
|
return { payload, human: `${ref}: done check recorded. The lane's run ends finished when its process exits.` };
|
|
859
905
|
}
|
|
860
906
|
if (action === "heartbeat") {
|
|
861
|
-
|
|
907
|
+
// hub-246: --waiting-on is repeatable; it replaces the lane's waits.
|
|
908
|
+
const waitingOn = flags["waiting-on"] === undefined ? [] : [flags["waiting-on"]].flat();
|
|
909
|
+
if (waitingOn.some((value) => typeof value !== "string" || !value.trim()))
|
|
910
|
+
throw new CliError("USAGE", "lane heartbeat --waiting-on needs a lane key, owner/repo#n, Q-nnn, DEC-nnnn, release:<pkg> or launch-day", 2);
|
|
911
|
+
const payload = await request("POST", `/api/v1/lanes/${encode(id)}/heartbeat`, { ...(flags.note !== undefined ? { note: flags.note } : {}), ...(waitingOn.length ? { waitingOn } : {}), ...via });
|
|
912
|
+
return { payload, human: (p) => heartbeatText(ref, p, waitingOn.length > 0) };
|
|
862
913
|
}
|
|
863
914
|
if (action === "subagent-quota") {
|
|
864
915
|
const raw = need(args[1], "lane subagent-quota needs <key> <n>");
|
|
@@ -1006,7 +1057,23 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1006
1057
|
const payload = await request("POST", `/api/v1/lanes/${encode(id)}/${action}`, { reason: requireFlag(flags, "reason"), ...via });
|
|
1007
1058
|
return { payload, human: `${ref}: ${action}d.` };
|
|
1008
1059
|
}
|
|
1009
|
-
if (action === "stop")
|
|
1060
|
+
if (action === "stop") {
|
|
1061
|
+
const reason = requireFlag(flags, "reason");
|
|
1062
|
+
// Dev first: a stop it refuses changes nothing on this machine (hub-244).
|
|
1063
|
+
const payload = await request("POST", `/api/v1/lanes/${encode(id)}/stop`, { reason, ...(flags.sweeper ? { sweeper: String(flags.sweeper) } : {}), ...via });
|
|
1064
|
+
const closeout = flags["no-closeout"] ? null : await laneCloseout(ref, reason, { request, config, closeout: deps.closeout });
|
|
1065
|
+
return {
|
|
1066
|
+
payload: { ...payload, ...(closeout ? { closeout: closeout.repositories } : {}) },
|
|
1067
|
+
human: [`${ref}: stopped.`, holdsLine(payload?.holdsReleased), closeout?.text].filter(Boolean).join("\n"),
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1070
|
+
if (action === "closeout") {
|
|
1071
|
+
const lane = (await request("GET", `/api/v1/lanes/${encode(id)}`)).data;
|
|
1072
|
+
if (!["stopped", "non_issue", "on_dev"].includes(lane.status))
|
|
1073
|
+
throw new CliError("LANE_NOT_ENDED", `${ref} is ${lane.status}; lane closeout runs for an ended lane. Stop it with nodii-dev lane stop ${ref} --reason TEXT.`, 1);
|
|
1074
|
+
const closeout = await laneCloseout(ref, requireFlag(flags, "reason"), { request, config, closeout: deps.closeout, lane });
|
|
1075
|
+
return { payload: { data: closeout.repositories }, human: closeout.text };
|
|
1076
|
+
}
|
|
1010
1077
|
if (action === "non-issue") {
|
|
1011
1078
|
const body = await nonIssueBody(flags, async () => commitsOf((await request("GET", `/api/v1/lanes/${encode(id)}`)).data));
|
|
1012
1079
|
const payload = await request("POST", `/api/v1/lanes/${encode(id)}/non-issue`, body);
|
|
@@ -1018,6 +1085,101 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1018
1085
|
throw new CliError("USAGE", `Unknown lane action: ${action}`, 2);
|
|
1019
1086
|
}
|
|
1020
1087
|
|
|
1088
|
+
/**
|
|
1089
|
+
* `nodii-dev lane repo add <key> --repo NAME --branch BRANCH --worktree PATH
|
|
1090
|
+
* [--read-only] --reason TEXT` (hub-257): the lane's machine
|
|
1091
|
+
* coordinator or staff adds a repository to a running lane. Dev changes the
|
|
1092
|
+
* lane's repositories and its Freeze boundaries together, so they cannot
|
|
1093
|
+
* diverge; it also repairs a lane where they already have.
|
|
1094
|
+
*/
|
|
1095
|
+
export async function laneRepoCommand(sub, args, flags, { request = devRequest } = {}) {
|
|
1096
|
+
if (sub !== "add") throw new CliError("USAGE", "lane repo add <key> --repo NAME --branch BRANCH --worktree PATH [--read-only] --reason TEXT", 2);
|
|
1097
|
+
const key = args[0];
|
|
1098
|
+
if (!key) throw new CliError("USAGE", "lane repo add needs <key>.", 2);
|
|
1099
|
+
const repo = String(requireFlag(flags, "repo"));
|
|
1100
|
+
const reason = requireFlag(flags, "reason");
|
|
1101
|
+
const entry = {
|
|
1102
|
+
repo,
|
|
1103
|
+
...(flags.branch ? { branch: String(flags.branch) } : {}),
|
|
1104
|
+
...(flags.worktree ? { worktree: String(flags.worktree) } : {}),
|
|
1105
|
+
...(flags["read-only"] ? { readOnly: true } : {}),
|
|
1106
|
+
};
|
|
1107
|
+
const current = (await request("GET", `/api/v1/lanes/${encode(key)}/freeze`)).data;
|
|
1108
|
+
if (!current?.freeze) {
|
|
1109
|
+
// No Freeze yet: only the repositories change; the first Gather builds the
|
|
1110
|
+
// boundaries from them.
|
|
1111
|
+
const payload = await request("POST", `/api/v1/lanes/${encode(key)}/repositories`, { ...entry, reason, ...via });
|
|
1112
|
+
const { repos = [] } = payload?.data ?? {};
|
|
1113
|
+
return { payload, human: `${key}: repositories now ${repos.join(", ")} (no Freeze yet; the first Gather builds it from these).` };
|
|
1114
|
+
}
|
|
1115
|
+
// With a Freeze, a boundaries swap: Dev writes it through to the lane's
|
|
1116
|
+
// repositories in the same step (hub-257), and the edge routes it today.
|
|
1117
|
+
const lane = (await request("GET", `/api/v1/lanes/${encode(key)}`)).data ?? {};
|
|
1118
|
+
const merged = [...current.freeze.boundaries.repos];
|
|
1119
|
+
// A repository Dev's record holds and the Freeze lacks comes along too.
|
|
1120
|
+
for (const known of lane.repositories ?? [])
|
|
1121
|
+
if (!merged.some((x) => x.repo === known.repo))
|
|
1122
|
+
merged.push(Object.fromEntries(Object.entries({ repo: known.repo, branch: known.branch, worktree: known.worktree, ownedPaths: known.ownedPaths?.length ? known.ownedPaths : undefined, readOnly: known.readOnly || undefined }).filter(([, v]) => v !== undefined)));
|
|
1123
|
+
const at = merged.findIndex((x) => x.repo === repo);
|
|
1124
|
+
if (at >= 0) {
|
|
1125
|
+
const { readOnly: _was, ...kept } = merged[at];
|
|
1126
|
+
merged[at] = { ...kept, ...entry };
|
|
1127
|
+
} else merged.push(entry);
|
|
1128
|
+
const payload = await request("POST", `/api/v1/lanes/${encode(key)}/freeze/swap`, {
|
|
1129
|
+
section: "boundaries",
|
|
1130
|
+
expectedVersion: current.version,
|
|
1131
|
+
reason,
|
|
1132
|
+
value: { ...current.freeze.boundaries, repos: merged },
|
|
1133
|
+
...via,
|
|
1134
|
+
});
|
|
1135
|
+
return {
|
|
1136
|
+
payload,
|
|
1137
|
+
human: `${key}: repositories now ${merged.map((x) => x.repo).join(", ")}; Freeze v${payload?.data?.version ?? "?"} lists the same.`,
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* The repositories a Gather shortlist answers (hub-257). Dev checks a
|
|
1143
|
+
* shortlist against the lane's own repos field, so it is built from that
|
|
1144
|
+
* field alone: a repository only the Freeze or the repository list names
|
|
1145
|
+
* would fail every pick (GATHER_SHORTLIST_MISMATCH). A record from before the
|
|
1146
|
+
* field falls back to the repositories and the Freeze.
|
|
1147
|
+
*/
|
|
1148
|
+
export function shortlistRepos(lane) {
|
|
1149
|
+
const refs = Array.isArray(lane.repos) && lane.repos.length
|
|
1150
|
+
? lane.repos.map((repo) => typeof repo === "string" ? repo : repo.repo)
|
|
1151
|
+
: [
|
|
1152
|
+
...(lane.repositories ?? []).map((repository) => repository.repo),
|
|
1153
|
+
...(lane.freeze?.boundaries?.repos ?? []).map((repository) => repository.repo),
|
|
1154
|
+
];
|
|
1155
|
+
return [...new Set(refs.filter(Boolean))];
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/** What Dev released in a lane's end, in one line (hub-244). */
|
|
1159
|
+
export function holdsLine(released) {
|
|
1160
|
+
if (!released) return null;
|
|
1161
|
+
const { abandoned = [], moved = [], kept = [] } = released.changeSets ?? {};
|
|
1162
|
+
const parts = [];
|
|
1163
|
+
if (released.issueClaims?.length) parts.push(`issue claims released: ${released.issueClaims.join(", ")}`);
|
|
1164
|
+
if (abandoned.length) parts.push(`change sets abandoned: ${abandoned.map((x) => x.id).join(", ")}`);
|
|
1165
|
+
if (moved.length) parts.push(`moved: ${moved.map((x) => `${x.id} to ${x.toLane}`).join(", ")}`);
|
|
1166
|
+
if (kept.length) parts.push(`kept with operator decisions (listed on the issue and to the coordinator): ${kept.map((x) => `${x.id} (${x.state})`).join(", ")}`);
|
|
1167
|
+
if (released.agentShared) parts.push("the agent runs another lane, so its change sets stayed");
|
|
1168
|
+
if (released.sweeperRefused) parts.push(`sweeper refused: ${released.sweeperRefused}`);
|
|
1169
|
+
return `Dev released: ${parts.length ? parts.join("; ") : "nothing held"}.`;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* The machine half of a lane's end (closeout.js): push, Stopped PR, test
|
|
1174
|
+
* stacks, worktree. Runs only after Dev accepted the end.
|
|
1175
|
+
*/
|
|
1176
|
+
export async function laneCloseout(ref, reason, { request = devRequest, config = readConfig, closeout = closeoutLane, lane } = {}) {
|
|
1177
|
+
const record = lane ?? (await request("GET", `/api/v1/lanes/${encode(ref)}`)).data;
|
|
1178
|
+
let onBehalfOf;
|
|
1179
|
+
try { onBehalfOf = (await config())?.person; } catch { onBehalfOf = undefined; }
|
|
1180
|
+
return closeout(record, { reason, request, onBehalfOf });
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1021
1183
|
/**
|
|
1022
1184
|
* The files a lane touches, for path-tagged rules (M05-32): its branch and
|
|
1023
1185
|
* working-tree changes against origin/main, plus untracked files, read from
|
package/dist/review.js
CHANGED
|
@@ -10,6 +10,7 @@ import { dirname, join } from "node:path";
|
|
|
10
10
|
import { promisify } from "node:util";
|
|
11
11
|
import { CliError, encode } from "./core.js";
|
|
12
12
|
import { pickerPrompt } from "./gather.js";
|
|
13
|
+
import { componentSetsIn, figmaComponentSet } from "./figma-scope.js";
|
|
13
14
|
import { gitPrivatePath } from "./safety.js";
|
|
14
15
|
|
|
15
16
|
const execFileAsync = promisify(execFile);
|
|
@@ -412,19 +413,25 @@ export const frameUrl = (fileKey, nodeId) => `https://www.figma.com/design/${fil
|
|
|
412
413
|
|
|
413
414
|
/**
|
|
414
415
|
* The frames in the Freeze's Figma boundary: each component set's state
|
|
415
|
-
* nodes from the DS catalog (its main node as "default" when it has none)
|
|
416
|
-
* a
|
|
416
|
+
* nodes from the DS catalog (its main node as "default" when it has none),
|
|
417
|
+
* or, for a DS component set, its own node as Figma publishes it under the
|
|
418
|
+
* key (NODII-DEV-CLI-70); a whole-file boundary is the whole file.
|
|
417
419
|
*/
|
|
418
|
-
export function boundaryFrames(figma,
|
|
419
|
-
|
|
420
|
+
export async function boundaryFrames(figma, { catalog, lookupSet = figmaComponentSet } = {}) {
|
|
421
|
+
const surfaces = figma.some((file) => file.componentSetKeys?.length) ? await catalog() : [];
|
|
422
|
+
const frames = [];
|
|
423
|
+
for (const file of figma) {
|
|
420
424
|
const keys = file.componentSetKeys ?? [];
|
|
421
|
-
if (!keys.length)
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
425
|
+
if (!keys.length) { frames.push({ fileKey: file.fileKey, nodeId: null, state: "default" }); continue; }
|
|
426
|
+
let sets;
|
|
427
|
+
try { sets = await componentSetsIn(file.fileKey, keys, { surfaces, lookupSet }); }
|
|
428
|
+
catch (error) {
|
|
429
|
+
if (error?.code === "FIGMA_KEY_UNKNOWN") throw new ReviewerError("CRASH", `the Freeze's Figma boundary: ${error.message}`);
|
|
430
|
+
throw error;
|
|
431
|
+
}
|
|
432
|
+
for (const key of keys) for (const frame of sets.get(key).frames) frames.push({ fileKey: file.fileKey, ...frame });
|
|
433
|
+
}
|
|
434
|
+
return frames;
|
|
428
435
|
}
|
|
429
436
|
|
|
430
437
|
/**
|
|
@@ -519,13 +526,13 @@ export async function swapFor(swaps, { fileKey, nodeId }, readSet) {
|
|
|
519
526
|
* Without a Swap in Dev whose change set holds the node (swapFor), or when
|
|
520
527
|
* Dev's Swaps or change sets can't be read, the missing node stays a finding.
|
|
521
528
|
*/
|
|
522
|
-
export async function figmaFindings(figma, { catalog, check, changeSets = {}, swaps, readSet }) {
|
|
529
|
+
export async function figmaFindings(figma, { catalog, check, changeSets = {}, swaps, readSet, lookupSet }) {
|
|
523
530
|
const scopedFrames = Object.entries(changeSets).flatMap(([fileKey, scoped]) => scoped.nodes.map((nodeId) => {
|
|
524
531
|
const item = scoped.items?.find((x) => x.nodeId === nodeId);
|
|
525
532
|
return { fileKey, nodeId, state: "default", ...(item ? { changeSet: item.changeSet } : {}) };
|
|
526
533
|
}));
|
|
527
534
|
const rest = figma.filter((file) => !changeSets[file.fileKey]);
|
|
528
|
-
const frames = [...scopedFrames, ...boundaryFrames(rest,
|
|
535
|
+
const frames = [...scopedFrames, ...(await boundaryFrames(rest, { catalog, ...(lookupSet ? { lookupSet } : {}) }))];
|
|
529
536
|
const findings = [];
|
|
530
537
|
const removed = [];
|
|
531
538
|
const versions = new Set();
|
package/dist/safety.js
CHANGED
|
@@ -239,7 +239,34 @@ async function generatedFile(path, context) {
|
|
|
239
239
|
const p = cleanPath(path);
|
|
240
240
|
if (generatedByPath(p) || context.generatedPaths.some((x) => globPattern(x).test(p))) return true;
|
|
241
241
|
const text = await optional(resolve(context.root, p));
|
|
242
|
-
return text !== null &&
|
|
242
|
+
return text !== null && generatedHeader(text);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// A line comment: `//`, `#`, `--` or `;`.
|
|
246
|
+
const LINE_COMMENT = /^\s*(?:\/\/|#|--|;)/;
|
|
247
|
+
// The opening of a block comment: `/*` or `<!--`.
|
|
248
|
+
const BLOCK_OPEN = /^\s*(?:\/\*|<!--)/;
|
|
249
|
+
const BLOCK_CLOSE = /\*\/|-->/;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Whether a file declares itself generated in its header: the leading comment
|
|
253
|
+
* block (at most its first 12 lines, after a shebang and blank lines). A marker
|
|
254
|
+
* further down, in a string, a regex or later prose, does not count, so a
|
|
255
|
+
* generator that emits a "Do not edit" header is not itself generated
|
|
256
|
+
* (NODII-DEV-CLI-68).
|
|
257
|
+
*/
|
|
258
|
+
export function generatedHeader(text) {
|
|
259
|
+
const header = [];
|
|
260
|
+
let inBlock = false;
|
|
261
|
+
for (const [at, line] of String(text).slice(0, 4096).split(/\r?\n/).entries()) {
|
|
262
|
+
if (header.length >= 12) break;
|
|
263
|
+
if (!inBlock && (!line.trim() || (at === 0 && line.startsWith("#!")))) continue;
|
|
264
|
+
if (inBlock) inBlock = !BLOCK_CLOSE.test(line);
|
|
265
|
+
else if (BLOCK_OPEN.test(line)) inBlock = !BLOCK_CLOSE.test(line.replace(BLOCK_OPEN, ""));
|
|
266
|
+
else if (!LINE_COMMENT.test(line)) break;
|
|
267
|
+
header.push(line);
|
|
268
|
+
}
|
|
269
|
+
return GENERATED_MARK.test(header.join("\n"));
|
|
243
270
|
}
|
|
244
271
|
|
|
245
272
|
function exactDeployGrant(context) {
|
package/dist/surface.js
CHANGED
|
@@ -31,7 +31,7 @@ import { CliError } from "./core.js";
|
|
|
31
31
|
import { createRenderer } from "./vendor/render-templates.mjs";
|
|
32
32
|
|
|
33
33
|
/** Bumped whenever the emitted code changes shape for the same inputs. */
|
|
34
|
-
export const GENERATOR_FORMAT =
|
|
34
|
+
export const GENERATOR_FORMAT = 5;
|
|
35
35
|
export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
|
|
36
36
|
export const GENERATED_SUFFIX = ".surface.generated.tsx";
|
|
37
37
|
const CATALOG_PATH = "packages/blocks/src/product-pages/catalog.ts";
|
|
@@ -482,14 +482,31 @@ const propType = (d) => {
|
|
|
482
482
|
|
|
483
483
|
const indent = (code, depth) => code.split("\n").map((line) => (line ? `${" ".repeat(depth)}${line}` : line)).join("\n");
|
|
484
484
|
|
|
485
|
+
// A part this narrow or narrower keeps its Figma width at every page width: an
|
|
486
|
+
// icon, an avatar, a switch, a separator. Anything wider is content that reflows.
|
|
487
|
+
export const INTRINSIC_MAX_PX = 48;
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
* A node's size as the page's layout classes (never a component prop: a
|
|
491
|
+
* template reads only component properties, U07-19). Width is responsive at
|
|
492
|
+
* page level: the root fills the page (w-full), not the Figma frame's width; a
|
|
493
|
+
* FIXED part wider than INTRINSIC_MAX_PX keeps its Figma width only as an
|
|
494
|
+
* upper bound (max-w-full, and in a row it may shrink: min-w-0 instead of
|
|
495
|
+
* shrink-0), so the page reflows below the Figma width; an intrinsic part keeps
|
|
496
|
+
* its width and does not shrink. FILL, HUG, FIXED heights and min/max widths
|
|
497
|
+
* are as Figma sets them. A child of a frame with no auto layout is never
|
|
498
|
+
* positioned absolutely: that frame is refused (see emitNode); only a child
|
|
499
|
+
* Figma itself marks absolute is.
|
|
500
|
+
*/
|
|
485
501
|
function sizeClasses(node, parent, root) {
|
|
486
502
|
const out = [];
|
|
487
503
|
const [h, v] = node.sizing ?? ["FIXED", "FIXED"];
|
|
488
504
|
const pm = parent?.layout?.mode;
|
|
489
505
|
if (node.absolute) out.push("absolute", `left-${step(node.x ?? 0)}`, `top-${step(node.y ?? 0)}`);
|
|
490
|
-
else if (parent && !pm && node.x !== undefined) out.push("absolute", `left-${step(node.x)}`, `top-${step(node.y)}`);
|
|
491
506
|
if (node.width === undefined) return out;
|
|
492
|
-
if (root
|
|
507
|
+
if (root) out.push("w-full");
|
|
508
|
+
else if (h === "FIXED" && node.width <= INTRINSIC_MAX_PX) out.push(`w-${step(node.width)}`, ...(pm === "HORIZONTAL" ? ["shrink-0"] : []));
|
|
509
|
+
else if (h === "FIXED") out.push(`w-${step(node.width)}`, ...(node.maxWidth ? [] : ["max-w-full"]), ...(pm === "HORIZONTAL" && !node.minWidth ? ["min-w-0"] : []));
|
|
493
510
|
else if (h === "FILL") out.push(...(pm === "HORIZONTAL" ? ["min-w-0", "flex-1"] : pm === "VERTICAL" ? ["self-stretch"] : ["w-full"]));
|
|
494
511
|
if (!root && v === "FIXED") out.push(`h-${step(node.height)}`, ...(pm === "VERTICAL" ? ["shrink-0"] : []));
|
|
495
512
|
else if (!root && v === "FILL") out.push(...(pm === "VERTICAL" ? ["min-h-0", "flex-1"] : pm === "HORIZONTAL" ? ["self-stretch"] : ["h-full"]));
|
|
@@ -500,8 +517,10 @@ function sizeClasses(node, parent, root) {
|
|
|
500
517
|
|
|
501
518
|
function layoutClasses(node) {
|
|
502
519
|
const l = node.layout;
|
|
503
|
-
|
|
504
|
-
const
|
|
520
|
+
// A child Figma marks absolute is placed against this frame.
|
|
521
|
+
const anchor = (node.children ?? []).some((c) => c.visible !== false && c.absolute) ? ["relative"] : [];
|
|
522
|
+
if (!l) return anchor;
|
|
523
|
+
const out = [...anchor];
|
|
505
524
|
if (l.mode === "GRID") {
|
|
506
525
|
out.push("grid");
|
|
507
526
|
if (l.columns) out.push(`grid-cols-${l.columns}`);
|
|
@@ -568,6 +587,10 @@ function emitNode(node, ctx) {
|
|
|
568
587
|
);
|
|
569
588
|
const slotContent = (prop) => {
|
|
570
589
|
const slotNode = (node.children ?? []).find((c) => c.type === "SLOT" && c.slot === prop);
|
|
590
|
+
if (slotNode && !slotNode.layout && (slotNode.children ?? []).filter((c) => c.visible !== false && !c.absolute).length > 1) {
|
|
591
|
+
note(`${path} › ${prop}`, "layout", `slot ${prop} has no auto layout`);
|
|
592
|
+
return comment(`unmapped: slot ${JSON.stringify(prop)} has no auto layout`);
|
|
593
|
+
}
|
|
571
594
|
const inner = (slotNode?.children ?? []).map((c) => emitNode(c, { ...ctx, depth: 0, parent: slotNode, path: `${path} › ${prop}`, root: false })).filter((x) => x !== null);
|
|
572
595
|
return inner.length === 0 ? "<></>" : inner.length === 1 ? inner[0] : `<>\n${inner.map((x) => indent(x, 1)).join("\n")}\n</>`;
|
|
573
596
|
};
|
|
@@ -613,6 +636,12 @@ function emitNode(node, ctx) {
|
|
|
613
636
|
const painted = Boolean(node.fills?.length || node.strokes?.length || node.radius || node.effects);
|
|
614
637
|
if (painted)
|
|
615
638
|
note(path, "frame", `${node.instance ? `local component ${describe(node)}` : node.type.toLowerCase()} draws its own ${[node.fills?.length && "fill", node.strokes?.length && "stroke", node.radius && "radius", node.effects && `effect ${node.effects}`].filter(Boolean).join(", ")}`);
|
|
639
|
+
// A frame that holds layers without auto layout has no flex or grid to
|
|
640
|
+
// become: it is refused and reported, never drawn by absolute positions.
|
|
641
|
+
if (!node.layout && (node.children ?? []).some((c) => c.visible !== false && !c.absolute)) {
|
|
642
|
+
note(path, "layout", `${node.instance ? `local component ${describe(node)}` : node.type.toLowerCase()} has no auto layout`);
|
|
643
|
+
return indent(comment(`unmapped: ${node.type.toLowerCase()} ${JSON.stringify(node.name)} has no auto layout`), depth);
|
|
644
|
+
}
|
|
616
645
|
const classes = cls([...sizeClasses(node, parent, root), ...layoutClasses(node), node.clips ? "overflow-hidden" : null]);
|
|
617
646
|
const kids = (node.children ?? []).map(child).filter((x) => x !== null);
|
|
618
647
|
const open = `<div${classes ? ` className="${classes}"` : ""}`;
|