@nodii/dev 0.6.179 → 0.6.181
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 +8 -4
- package/dist/cli.js +2 -1
- package/dist/coordinator-gather.js +2 -2
- package/dist/coordinator-watch.js +40 -12
- package/dist/core.js +1 -1
- package/dist/figma.js +1 -1
- package/dist/gather.js +2 -1
- package/dist/lane-supervisor.js +5 -1
- package/dist/lanes.js +2 -0
- package/dist/resume-gate.js +5 -0
- package/dist/surface.js +57 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -197,7 +197,7 @@ nodii-dev figma publish FILE --sets CS-1,CS-2 [--dry-run]
|
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
- **Board.** "Waiting on" comes from Dev's real state: the lane's status, the change sets it holds (state, pending items, file order), Dev's wait records, the heavy-slot queue and `answered.md`. It never comes from the lane's note, which is shown as written in its own column. A question counts as the operator's only when it is an open item on the sheet. `--write` puts "What's running" on the status page `docs/open/<sheet>-status.md` and only the lanes that wait on the operator on the sheet, because MW4-31 keeps status off the sheet. It works in the worktree `nodii-infra/.claude/worktrees/<sheet>-board` and merges through a PR. First it copies every answer the operator typed in their checkout, verbatim, into `answered.md` and into the sheet. Then it fast-forwards the operator's checkout, and only when nothing else there differs from main. An empty board, or one that drops by more than half, is refused (`--force` once you have checked Dev). Priority domains are coordinator configuration in `~/.config/nodii-dev/coordinator/settings.json` (`domains`); a lane outside them is listed under "Other lanes".
|
|
200
|
-
- **Watch.** Jobs and intervals: board 15 min, apply-watch 3, publish-watch 10, real-stuck 30, complexity 30, orphan-slots 10, keepalive 10. Everything goes to one log, `coordinator-watch.log`, under `~/Library/Logs/nodii-dev/` on macOS and `~/.local/state/nodii-dev/logs/` on Linux. On Linux the memory guard on a resume reads `MemAvailable` from `/proc/meminfo`. Alerts go to `~/.config/nodii-dev/coordinator/alerts.log` and open the coordinator's next session. A job is paused by `~/.config/nodii-dev/coordinator/hold-<job>`. A resume tries the lane's own account first. On an account refusal it tries the accounts listed in `settings.json` `keepaliveProfiles` (`[{ "profile": "/abs/path", "class": "short" }]`), because the account roster is the operator's call (MW1-38.3). The watch never stops a process it did not start (K02-15). It reports an orphaned slot instead.
|
|
200
|
+
- **Watch.** Jobs and intervals: board 15 min, apply-watch 3, publish-watch 10, real-stuck 30, complexity 30, orphan-slots 10, keepalive 10. Everything goes to one log, `coordinator-watch.log`, under `~/Library/Logs/nodii-dev/` on macOS and `~/.local/state/nodii-dev/logs/` on Linux. On Linux the memory guard on a resume reads `MemAvailable` from `/proc/meminfo`. Alerts go to `~/.config/nodii-dev/coordinator/alerts.log` and open the coordinator's next session. A job is paused by `~/.config/nodii-dev/coordinator/hold-<job>`. A resume tries the lane's own account first. On an account refusal it tries the accounts listed in `settings.json` `keepaliveProfiles` (`[{ "profile": "/abs/path", "class": "short" }]`), because the account roster is the operator's call (MW1-38.3). The watch never stops a process it did not start (K02-15). It reports an orphaned slot instead. Keepalive resumes a blocked lane, or any down lane with waits of its own whatever Dev reports as its liveness, only through `lane resume --if-changed` (MW1-102): a lane whose blockers have not changed, or could not be read, stays down, and does not use up the run's resumes. Each resume's log line names the change that let it through. A down lane with no waits (an orphan) resumes as before. At `NODII_DEV_RESUME_IF_CHANGED=0`, keepalive resumes a blocked lane at most once an hour. When the installed `@nodii/dev` is not the version the daemon started with, the daemon logs it and exits, and launchd (`KeepAlive`) or systemd (`Restart=always`) starts it again on the new code.
|
|
201
201
|
- **publish-watch** stays off until the coordinator sets `"publishWatch": true` in `settings.json`. MW8-7 still names the operator as publisher until hub-429 lands. It needs a Figma token to read the new version. It reads the token from `FIGMA_PAT` (or `FIGMA_TOKEN`) in the daemon's own environment first, then from the macOS keychain (`security add-generic-password -s nodii-dev-figma-pat -a "$USER" -w`). The plist that `coordinator watch install` writes carries no token, so the keychain is the usual source; a token someone adds to the plist's environment would be used before it. It never reads a file. On Linux the job answers "macOS only", so nothing there reads a Secret Service for the token.
|
|
202
202
|
- **Chrome.** `chrome start` adopts the Chrome already serving the port, or starts one on the profile, and records the endpoint on Dev's machine record (`hostFacts.sharedChrome`; coordinator or staff only). Every command opens its own background tab and closes only that tab (K02-16, K02-17). `chrome signin` refuses anything but a `tech-*` tenant and a yopmail test identity. It signs in within its own tab and opens `--open PATH` if given. Then it signs out (the app's logout, then that origin's storage and cookies cleared), so no session or token outlives it (MW3-40.2). It never prints or stores a credential, tries each tenant at most once an hour, skips a tenant another tab has open, and rests a tenant after a failed sign-in until `--clear-rest`.
|
|
203
203
|
- **figma publish** refuses a set that is not `awaiting_publish`. It ticks exactly the approved components of the named sets in Figma's Publish library dialog and unticks every other row. It stops if a row won't settle or if it saw fewer rows than the dialog counts. It records a set in Dev only when all of the set's components were published.
|
|
@@ -710,7 +710,10 @@ nodii-dev lane resume KEY --if-changed
|
|
|
710
710
|
# blocking lane's status (Dev), its leeways and its latest
|
|
711
711
|
# amendment. Heartbeat notes never count. Unchanged prints
|
|
712
712
|
# BLOCKERS_UNCHANGED and exits 0; the fingerprint is kept in
|
|
713
|
-
# runs/resume-fingerprints.json. A
|
|
713
|
+
# runs/resume-fingerprints.json. A blocker that could not
|
|
714
|
+
# be read (gh or Dev failed) is no change: it prints
|
|
715
|
+
# BLOCKERS_UNREADABLE, exits 0 and records nothing. A
|
|
716
|
+
# resume carries the gate's reason as data.resumeGate. A superseded lane (every
|
|
714
717
|
# issue it holds closed) is refused as LANE_DEAD with the
|
|
715
718
|
# evidence; nothing stops it here (the coordinator ends it by
|
|
716
719
|
# the MW1-28 exit that fits). A
|
|
@@ -1770,8 +1773,9 @@ supervisor appends its report line to `process.log`.
|
|
|
1770
1773
|
|
|
1771
1774
|
**Account failures (NODII-DEV-CLI-191).** When the newest line the runtime
|
|
1772
1775
|
itself wrote (not a tool's output) names a usage limit (`Claude AI usage limit
|
|
1773
|
-
reached|EPOCH`, `You've hit your limit
|
|
1774
|
-
|
|
1776
|
+
reached|EPOCH`, `You've hit your limit` or `You've hit your weekly limit`, a
|
|
1777
|
+
result record whose `api_error` is `usage_limit_reached`, `5-hour limit reached
|
|
1778
|
+
∙ resets 3pm`, a weekly limit, Codex's `You've hit your usage limit ... try again at|in ...`),
|
|
1775
1779
|
an auth failure (`OAuth token has expired`, `401`, `authentication_error`,
|
|
1776
1780
|
`Invalid API key`, `Please run /login`) or a network one (Cloudflare,
|
|
1777
1781
|
`cf-ray`, `ECONNRESET`, `ETIMEDOUT`, `fetch failed`, `529 Overloaded`), the
|
package/dist/cli.js
CHANGED
|
@@ -600,7 +600,8 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
600
600
|
# NODII-DEV-CLI-191: resume only when what blocks the lane changed since its
|
|
601
601
|
# last resume (a PR's state, head or merge; an issue's status; a blocking
|
|
602
602
|
# lane's status; a leeway; an amendment), else print BLOCKERS_UNCHANGED and
|
|
603
|
-
# exit 0. A
|
|
603
|
+
# exit 0. A blocker that could not be read is no change: BLOCKERS_UNREADABLE,
|
|
604
|
+
# exit 0, nothing recorded. A superseded lane (every issue it holds closed) is refused as
|
|
604
605
|
# LANE_DEAD with the evidence; nothing stops it here: the coordinator ends it
|
|
605
606
|
# by the MW1-28 exit that fits.
|
|
606
607
|
# A lane whose work is landed (MW1-30.1) before deploy is refused as
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CliError, devRequest, encode, readConfig } from "./core.js";
|
|
2
|
-
import { agentFallbackReason, coordinatorGatherPayload, gatherDeadline, gatherText, pickDocuments, pickerModelName, warmPicker, withPickLock } from "./gather.js";
|
|
2
|
+
import { GATHER_TIMEOUT_MS, agentFallbackReason, coordinatorGatherPayload, gatherDeadline, gatherText, pickDocuments, pickerModelName, warmPicker, withPickLock } from "./gather.js";
|
|
3
3
|
import { findCoordinatorRun } from "./starting.js";
|
|
4
4
|
|
|
5
5
|
const list = (value) => String(value ?? "").split(",").map((item) => item.trim()).filter(Boolean);
|
|
@@ -14,7 +14,7 @@ export async function coordinatorGather(flags, {
|
|
|
14
14
|
const documents = list(flags.documents);
|
|
15
15
|
if (Boolean(flags.shortlist) !== Boolean(documents.length) || (flags.shortlist && flags.picker !== "agent"))
|
|
16
16
|
throw new CliError("USAGE", "Record an agent pick with --picker agent --shortlist ID --documents CODE[,CODE].", 2);
|
|
17
|
-
const deadline = gatherDeadline();
|
|
17
|
+
const deadline = gatherDeadline(GATHER_TIMEOUT_MS);
|
|
18
18
|
const timed = (method, path, body) => request(method, path, body, { signal: deadline.signal });
|
|
19
19
|
try {
|
|
20
20
|
const current = await config();
|
|
@@ -22,7 +22,8 @@ import { appendFile, mkdir, readFile, rename, rm, writeFile } from "node:fs/prom
|
|
|
22
22
|
import { homedir, loadavg, platform } from "node:os";
|
|
23
23
|
import { dirname, join, resolve } from "node:path";
|
|
24
24
|
import { promisify } from "node:util";
|
|
25
|
-
import { CliError, configPath, devRequest, encode, readConfig } from "./core.js";
|
|
25
|
+
import { CliError, VERSION, configPath, devRequest, encode, readConfig } from "./core.js";
|
|
26
|
+
import { laneSwitchOn } from "./lane-switches.js";
|
|
26
27
|
import {
|
|
27
28
|
DEFAULT_DOMAINS, boardCommand, coordinatorHome, heavyQueue, laneDomain, laneProcesses, liveChangeSets, machineLanes, readCoordinatorSettings,
|
|
28
29
|
} from "./coordinator-board.js";
|
|
@@ -274,18 +275,25 @@ async function keepaliveJob(ctx) {
|
|
|
274
275
|
const alive = await ctx.processes();
|
|
275
276
|
const state = ctx.jobState;
|
|
276
277
|
state.blockedResumedAt ??= {};
|
|
278
|
+
const gated = laneSwitchOn("resumeIfChanged", ctx.env ?? process.env);
|
|
277
279
|
const down = lanes.filter((lane) => alive.get(lane.key) === false || (!alive.has(lane.key) && ["orphan", "dead"].includes(lane.liveness)))
|
|
278
280
|
.sort((a, b) => Number(!laneDomain(a.key, domains)) - Number(!laneDomain(b.key, domains)) || a.key.localeCompare(b.key));
|
|
279
281
|
const resumed = [];
|
|
280
282
|
const skipped = [];
|
|
281
283
|
for (const lane of down) {
|
|
282
284
|
if (resumed.length >= (settings.keepaliveMaxPerRun ?? 3)) { skipped.push(`${lane.key} (next run)`); continue; }
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
+
// MW1-102 (NODII-DEV-CLI-191): a blocked lane resumes only when what
|
|
286
|
+
// blocks it changed (`lane resume --if-changed`), never on a timer. At
|
|
287
|
+
// NODII_DEV_RESUME_IF_CHANGED=0 it is resumed at most once an hour, as before.
|
|
288
|
+
// A lane with waits of its own is gated whatever its liveness: Dev reports
|
|
289
|
+
// `ended` for a lane whose runs failed, and it still waits on its blockers.
|
|
290
|
+
// (`waitCount` counts the lanes waiting on this one, not its own waits.)
|
|
291
|
+
const ifChanged = gated && (lane.liveness === "blocked" || (lane.waits?.length ?? 0) > 0);
|
|
292
|
+
if (lane.liveness === "blocked" && !gated) {
|
|
285
293
|
const last = state.blockedResumedAt[lane.key] ?? 0;
|
|
286
294
|
if (ctx.now() - last < 60 * MIN) { skipped.push(`${lane.key} (blocked, resumed within the hour)`); continue; }
|
|
287
295
|
}
|
|
288
|
-
const why = await ctx.tryResume(lane.key, { priority: Boolean(laneDomain(lane.key, domains)) });
|
|
296
|
+
const why = await ctx.tryResume(lane.key, { priority: Boolean(laneDomain(lane.key, domains)), ifChanged });
|
|
289
297
|
if (why === "resumed") {
|
|
290
298
|
resumed.push(lane.key);
|
|
291
299
|
if (lane.liveness === "blocked") state.blockedResumedAt[lane.key] = ctx.now();
|
|
@@ -320,7 +328,7 @@ export async function figmaPatFromKeychain(execute) {
|
|
|
320
328
|
catch { return null; }
|
|
321
329
|
}
|
|
322
330
|
|
|
323
|
-
export function watchContext({ home = homedir(), request = devRequest, config = readConfig, execute = execFile, now = Date.now, sleep = delay, log, jobState = {}, os = platform() } = {}) {
|
|
331
|
+
export function watchContext({ home = homedir(), request = devRequest, config = readConfig, execute = execFile, now = Date.now, sleep = delay, log, jobState = {}, os = platform(), resume = async (key, flags) => (await import("./lanes.js")).laneCommand("resume", [key], flags), guardsFor = () => machineGuards({ execute, os }) } = {}) {
|
|
324
332
|
let machine = null;
|
|
325
333
|
let processesCache = null;
|
|
326
334
|
let guardsCache = null;
|
|
@@ -330,28 +338,35 @@ export function watchContext({ home = homedir(), request = devRequest, config =
|
|
|
330
338
|
machineId: async () => (machine ??= await governorMachineId({}, { request, config })),
|
|
331
339
|
processes: async () => (processesCache ??= await laneProcesses()),
|
|
332
340
|
heavy: () => heavyQueue({ execute, os }),
|
|
333
|
-
guards: async () => (guardsCache ??= await
|
|
341
|
+
guards: async () => (guardsCache ??= await guardsFor()),
|
|
334
342
|
amend: async (key, rules, reason) => {
|
|
335
343
|
const { amendLaneCommand } = await import("./starting.js");
|
|
336
344
|
await amendLaneCommand(key, { rules, reason });
|
|
337
345
|
await log?.(`amend ${key}: ${reason}`);
|
|
338
346
|
},
|
|
339
|
-
tryResume: async (key, { priority }) => {
|
|
347
|
+
tryResume: async (key, { priority, ifChanged = false }) => {
|
|
340
348
|
const hold = await exists(holdPath(home, "keepalive"));
|
|
341
349
|
const verdict = resumeAllowed(await ctx.guards(), { priority, hold });
|
|
342
350
|
if (!verdict.ok) return `not resumed: ${verdict.reason}`;
|
|
343
|
-
const { laneCommand } = await import("./lanes.js");
|
|
344
351
|
// The lane's own account first; on an account refusal, the coordinator's
|
|
345
352
|
// allowed lane accounts in order (settings.keepaliveProfiles: the account
|
|
346
353
|
// roster is the operator's call, MW1-38.3, so it is configuration).
|
|
347
354
|
const settings = await readCoordinatorSettings(home);
|
|
348
|
-
const
|
|
355
|
+
const gate = ifChanged ? { "if-changed": true } : {};
|
|
356
|
+
const attempts = [{ ...gate }, ...(settings.keepaliveProfiles ?? []).map((p) => ({ ...gate, profile: p.profile, class: p.class ?? "short" }))];
|
|
349
357
|
let last = "LANE_RESUME_FAILED";
|
|
350
358
|
for (const flags of attempts) {
|
|
351
359
|
try {
|
|
352
|
-
await
|
|
360
|
+
const out = await resume(key, flags);
|
|
361
|
+
// MW1-102: the gate left the lane down (BLOCKERS_UNCHANGED, LANE_DEAD,
|
|
362
|
+
// LANDED_NOT_DONE). That is an answer, not an account refusal.
|
|
363
|
+
if (out?.payload?.data?.resumed === false) {
|
|
364
|
+
await log?.(`not resumed ${key}: ${out.payload.data.code}`);
|
|
365
|
+
return `not resumed (${out.payload.data.code})`;
|
|
366
|
+
}
|
|
353
367
|
guardsCache = null;
|
|
354
|
-
|
|
368
|
+
const why = out?.payload?.data?.resumeGate?.reason;
|
|
369
|
+
await log?.(`resumed ${key}${flags.profile ? ` on ${flags.profile}` : ""}${why ? ` (${why})` : ""}`);
|
|
355
370
|
return "resumed";
|
|
356
371
|
} catch (error) {
|
|
357
372
|
last = error?.code ?? "LANE_RESUME_FAILED";
|
|
@@ -437,7 +452,12 @@ async function pidAlive(pid) {
|
|
|
437
452
|
}
|
|
438
453
|
|
|
439
454
|
/** The daemon loop. One instance per machine; jobs run one at a time, each on its interval. */
|
|
440
|
-
|
|
455
|
+
/** The @nodii/dev version installed on disk now, which a long-running daemon may not be running. */
|
|
456
|
+
export async function installedPackageVersion(read = readFile) {
|
|
457
|
+
try { return JSON.parse(await read(new URL("../package.json", import.meta.url), "utf8")).version ?? null; } catch { return null; }
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export async function watchRun({ home = homedir(), tickMs = 30_000, sleep = delay, now = Date.now, run = runJob, forever = true, installed = installedPackageVersion } = {}) {
|
|
441
461
|
const prior = Number((await readFile(pidPath(home), "utf8").catch(() => "")).trim());
|
|
442
462
|
if (prior && prior !== process.pid && (await pidAlive(prior)))
|
|
443
463
|
throw new CliError("WATCH_ALREADY_RUNNING", `coordinator watch is already running (pid ${prior}).`, 1);
|
|
@@ -448,6 +468,14 @@ export async function watchRun({ home = homedir(), tickMs = 30_000, sleep = dela
|
|
|
448
468
|
process.once("SIGTERM", stop);
|
|
449
469
|
try {
|
|
450
470
|
do {
|
|
471
|
+
// NODII-DEV-CLI-191: a daemon keeps the code it started with. When a new
|
|
472
|
+
// @nodii/dev is installed it exits, and its supervisor (launchd KeepAlive,
|
|
473
|
+
// systemd Restart) starts it again on the new code.
|
|
474
|
+
const onDisk = await installed().catch(() => null);
|
|
475
|
+
if (onDisk && onDisk !== VERSION) {
|
|
476
|
+
await watchLog(`watch: @nodii/dev ${onDisk} is installed and this daemon runs ${VERSION}; exiting so it restarts on the new code`, { home });
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
451
479
|
const state = await readJson(statePath(home), { jobs: {} });
|
|
452
480
|
for (const job of Object.keys(JOBS)) {
|
|
453
481
|
const next = Date.parse(state.jobs?.[job]?.nextAt ?? 0);
|
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.181";
|
|
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
|
@@ -1211,7 +1211,7 @@ export async function laneReadsBody(id, laneReads, { request = devRequest, progr
|
|
|
1211
1211
|
function laneReadsUploadRefusal(error, id) {
|
|
1212
1212
|
if (error?.code === "LANE_READS_TOO_LARGE")
|
|
1213
1213
|
return new CliError(error.code, `${error.message}
|
|
1214
|
-
|
|
1214
|
+
One read here is larger than Dev takes, even in parts, and the cap stays (hub-448). If Dev asked for a whole page or scope root at the set's base, that Dev predates per-node base reads (hub-569): wait for it on dev, then submit again and send the nodes it asks for. Otherwise file a Dev issue naming the read.`, error.exitCode ?? 1, error.details);
|
|
1215
1215
|
if (["HTTP_404", "NOT_FOUND", "ROUTE_NOT_FOUND"].includes(error?.code))
|
|
1216
1216
|
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);
|
|
1217
1217
|
return error;
|
package/dist/gather.js
CHANGED
|
@@ -210,7 +210,8 @@ export async function warmPicker(options = {}) {
|
|
|
210
210
|
* pick, which has its own budgets (warm-up, then the first pick), so a cold
|
|
211
211
|
* model never spends the requests' time.
|
|
212
212
|
*/
|
|
213
|
-
|
|
213
|
+
// NODII-DEV-CLI-159: a deadline built with no length fired at once; the default is the Gather timeout.
|
|
214
|
+
export function gatherDeadline(ms = GATHER_TIMEOUT_MS) {
|
|
214
215
|
const controller = new AbortController();
|
|
215
216
|
let remaining = ms;
|
|
216
217
|
let since = Date.now();
|
package/dist/lane-supervisor.js
CHANGED
|
@@ -80,7 +80,11 @@ async function readTail(path, bytes = LOG_TAIL_BYTES) {
|
|
|
80
80
|
// same account. The runtime's own lines name the failure.
|
|
81
81
|
const USAGE_LIMIT = [
|
|
82
82
|
/Claude AI usage limit reached/i,
|
|
83
|
-
|
|
83
|
+
// "usage", "weekly", "session", "Opus": Claude and Codex name the limit
|
|
84
|
+
// differently and add names, so any one or two words may stand before it.
|
|
85
|
+
/\byou(?:'|’)ve hit your (?:[\w-]+ ){0,2}limit\b/i,
|
|
86
|
+
// Claude's result record carries the error's own code whatever its words say.
|
|
87
|
+
/"api_error"\s*:\s*"usage_limit_reached"/,
|
|
84
88
|
/\b(?:5-hour|five-hour|session|weekly|opus|sonnet)\b[^\n]{0,40}\blimit reached\b/i,
|
|
85
89
|
/\busage limit (?:reached|exceeded)\b/i,
|
|
86
90
|
];
|
package/dist/lanes.js
CHANGED
|
@@ -1179,6 +1179,8 @@ export async function laneCommand(action, args, flags, deps = {}) {
|
|
|
1179
1179
|
);
|
|
1180
1180
|
const launched = await launchReserved(payload);
|
|
1181
1181
|
await gate?.record?.().catch(() => {});
|
|
1182
|
+
// Why the gate let it through, so the watcher's log can say so.
|
|
1183
|
+
if (gate && payload?.data) payload.data.resumeGate = { reason: gate.reason };
|
|
1182
1184
|
return {
|
|
1183
1185
|
payload,
|
|
1184
1186
|
human: (response) => {
|
package/dist/resume-gate.js
CHANGED
|
@@ -140,6 +140,11 @@ export async function resumeGate(lane, { store, ...readers }) {
|
|
|
140
140
|
if (dead?.kind === "landed")
|
|
141
141
|
return { resume: false, code: "LANDED_NOT_DONE", dead, reason: `${lane.key}'s work is on main (${dead.evidence.join("; ")}), and landed is not done (MW1-28): move it to deploy and the dev check (\`nodii-dev lane step ${lane.key} --side SIDE --done build_test\`), then resume it for those steps` };
|
|
142
142
|
const now = await blockerFingerprint(lane, readers);
|
|
143
|
+
// A read that failed (gh under load, Dev down) says nothing about the
|
|
144
|
+
// blocker: its error text is not a change, and nothing is recorded.
|
|
145
|
+
const unreadable = now.parts.filter((part) => /: unreadable \(/.test(part));
|
|
146
|
+
if (unreadable.length)
|
|
147
|
+
return { resume: false, code: "BLOCKERS_UNREADABLE", reason: `a blocker of ${lane.key} could not be read, so whether it changed is unknown: ${unreadable.join("; ")}`, parts: now.parts };
|
|
143
148
|
const before = await store.get(lane.key);
|
|
144
149
|
const record = () => store.set(lane.key, { fingerprint: now.fingerprint, parts: now.parts, at: new Date().toISOString() });
|
|
145
150
|
if (!before) return { resume: true, reason: "no fingerprint recorded yet", parts: now.parts, record };
|
package/dist/surface.js
CHANGED
|
@@ -34,7 +34,7 @@ import { MIN_FIGMA_INTERVAL_MS, figmaRest } from "./figma-rest.js";
|
|
|
34
34
|
import { createRenderer } from "./vendor/render-templates.mjs";
|
|
35
35
|
|
|
36
36
|
/** Bumped whenever the emitted code changes shape for the same inputs. */
|
|
37
|
-
export const GENERATOR_FORMAT =
|
|
37
|
+
export const GENERATOR_FORMAT = 41;
|
|
38
38
|
export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
|
|
39
39
|
export const GENERATED_SUFFIX = ".surface.generated.tsx";
|
|
40
40
|
/** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
|
|
@@ -1066,7 +1066,9 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
1066
1066
|
const name = value && !/^tab(?:-\d+)?$/.test(value) ? camelName(value) : nameOf(label ? JSON.parse(label[1]) : "", value || "tab");
|
|
1067
1067
|
const own = (prop) => {
|
|
1068
1068
|
lifted.push(prop);
|
|
1069
|
-
|
|
1069
|
+
// Scoped by the tab's own name, not its place: one tab drawn second in one view's strip and
|
|
1070
|
+
// third in another's is one prop, and a scope never puts a space or `-` in a name (hub-568).
|
|
1071
|
+
return `${prop}={${optionalMark(ctx, camelName(`${scope} ${name}`), joinName(name, prop))}}`;
|
|
1070
1072
|
};
|
|
1071
1073
|
return attrs
|
|
1072
1074
|
.replace(/\bactionableCount=\{(?:\d+|actionableCount)\}/, () => own("actionableCount"))
|
|
@@ -1121,10 +1123,14 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
|
|
|
1121
1123
|
return depth === 0 ? `value={${lift(factScope, "value")}}` : value;
|
|
1122
1124
|
});
|
|
1123
1125
|
});
|
|
1124
|
-
|
|
1126
|
+
// Two pills one part draws (a Setup Walkthrough step's requirement and status) are two
|
|
1127
|
+
// values: each takes the name of the attribute that holds it (NODII-DEV-CLI-222).
|
|
1128
|
+
const pills = (out.match(/<StatusPill\b/g) ?? []).length;
|
|
1129
|
+
out = out.replace(/<StatusPill\b([^>]*?)(\/?)>/g, (all, attrs, close, at, whole) => {
|
|
1125
1130
|
const label = new RegExp(String.raw`\blabel=${LITERAL}`).exec(attrs);
|
|
1126
1131
|
if (!label) return all;
|
|
1127
|
-
const
|
|
1132
|
+
const holder = pills > 1 ? /\b([a-z][A-Za-z0-9]*)=\{\s*$/.exec(whole.slice(0, at))?.[1] : null;
|
|
1133
|
+
const scope = holder ? joinName(positionScope(node, ctx, "status"), holder) : positionScope(node, ctx, "status");
|
|
1128
1134
|
const tone = new RegExp(String.raw`\btone=${LITERAL}`).exec(attrs);
|
|
1129
1135
|
let next = attrs.replace(label[0], `label={${lift(scope, "label")}}`);
|
|
1130
1136
|
next = tone ? next.replace(tone[0], `tone={${lift(scope, "tone")}}`) : next.replace(`label={`, `tone={${lift(scope, "tone")}} label={`);
|
|
@@ -1989,6 +1995,10 @@ function dataProps(views, propsType) {
|
|
|
1989
1995
|
entry(o.list).list = true;
|
|
1990
1996
|
view.uses.add(o.list);
|
|
1991
1997
|
}
|
|
1998
|
+
for (const m of body.matchAll(/row\.kind === "group"/g)) {
|
|
1999
|
+
const list = listAt(openers, m.index, "row");
|
|
2000
|
+
if (list) member(entry(list), "kind").set("\u0000kind", { raw: '"group" | "row"' });
|
|
2001
|
+
}
|
|
1992
2002
|
for (const m of body.matchAll(/row\.kind === "branch"/g)) {
|
|
1993
2003
|
const list = listAt(openers, m.index, "row");
|
|
1994
2004
|
if (list) member(entry(list), "kind").set("\u0000kind", { raw: '"branch" | "leaf"' });
|
|
@@ -2771,8 +2781,8 @@ function tabStrip(run, ctx) {
|
|
|
2771
2781
|
* PiiText's is offered, so a row can never force a value visible (U05; cli-140).
|
|
2772
2782
|
*/
|
|
2773
2783
|
const PII_KINDS = new Set(["name", "email", "phone", "address", "dob", "document", "text"]);
|
|
2774
|
-
const PII_ROW_FIELD = `{ ${["maskHint?", "model", "relation", "value"].map((k) => `${k}: ComponentProps<typeof PiiText>[${JSON.stringify(k.replace("?", ""))}]`).join("; ")} }`;
|
|
2775
|
-
const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind
|
|
2784
|
+
const PII_ROW_FIELD = `{ ${["kind?", "maskHint?", "model", "relation", "value"].map((k) => `${k}: ComponentProps<typeof PiiText>[${JSON.stringify(k.replace("?", ""))}]`).join("; ")} }`;
|
|
2785
|
+
const PII_ROW_READ = /<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=/g;
|
|
2776
2786
|
|
|
2777
2787
|
/**
|
|
2778
2788
|
* One list's rows are one type across the views and tables that share it. A column that is
|
|
@@ -2794,7 +2804,7 @@ function mixedPiiExpressions(body) {
|
|
|
2794
2804
|
|
|
2795
2805
|
function settlePiiColumns(views, unmapped) {
|
|
2796
2806
|
const NODE_READ = /(^|>)\s*\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\}/gm;
|
|
2797
|
-
const PII_CELL = />\n[ \t]*(?:<div\b[^>]*>\s*)*<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=
|
|
2807
|
+
const PII_CELL = />\n[ \t]*(?:<div\b[^>]*>\s*)*<PiiText value=\{([a-z][A-Za-z0-9]*)\.([A-Za-z][A-Za-z0-9]*)\.value\} kind=[^\n]*\/>\s*(?:<\/div>\s*)*<\/TableCell>/g;
|
|
2798
2808
|
const reads = new Map();
|
|
2799
2809
|
const count = (view, openers, at, param, key, how) => {
|
|
2800
2810
|
const list = listAt(openers, at, param);
|
|
@@ -2943,7 +2953,9 @@ function piiCellText({ cell, code }, ref) {
|
|
|
2943
2953
|
const size = /\ssize="\w+"/.exec(attrs)?.[0] ?? "";
|
|
2944
2954
|
// Repeated people are a bulk disclosure surface even inside a record page or
|
|
2945
2955
|
// a permissive ambient provider. Keep the served self relation unchanged.
|
|
2946
|
-
|
|
2956
|
+
// The kind is the record's (a contact column lists emails and phones): the row may say
|
|
2957
|
+
// its own, and the kind Figma drew is the default (NODII-DEV-CLI-223).
|
|
2958
|
+
return `${before}<PiiText value={${ref}.value} kind={${ref}.kind ?? "${kind}"} model={${ref}.model} relation={${ref}.relation} maskHint={${ref}.maskHint} surface="bulk"${size} />${after}`;
|
|
2947
2959
|
}
|
|
2948
2960
|
|
|
2949
2961
|
/** A non-person alternative must be plain text or a plain Badge, never arbitrary JSX. */
|
|
@@ -2991,6 +3003,7 @@ const tablePart = (tag) => (/^Table[A-Za-z]*Head$/.test(tag ?? "") ? "head" : /^
|
|
|
2991
3003
|
const SKELETON_ROWS = "TableSkeletonRows";
|
|
2992
3004
|
/** Row kinds while a table is parsed: every cell loading, or loading cells mixed with others. */
|
|
2993
3005
|
const LOADING = "loading";
|
|
3006
|
+
const GROUP = Symbol("group");
|
|
2994
3007
|
const MIXED = "mixed";
|
|
2995
3008
|
const isSkeleton = (code) => new RegExp(`^<${SKELETON_ROWS}\\b`).test(code ?? "");
|
|
2996
3009
|
/**
|
|
@@ -3195,9 +3208,19 @@ function tableOf(node, ctx) {
|
|
|
3195
3208
|
// has columns, becomes one TableSkeletonRows (U07-34.15.3). Any other row of loading
|
|
3196
3209
|
// cells (mixed with other cells, beside rows that are not loading, or not spanning the
|
|
3197
3210
|
// header) is reported and marked, never guessed (MW8-17.3).
|
|
3211
|
+
// A one-cell head row after the real header and before more body rows is a group band
|
|
3212
|
+
// (`group/Account security · 6 messages`): a row of the body that heads the rows after it,
|
|
3213
|
+
// never the table's header (NODII-DEV-CLI-222).
|
|
3214
|
+
const realHead = parsed.findIndex((p) => p.kind === "head" && p.cells.length > 1);
|
|
3215
|
+
if (realHead >= 0) {
|
|
3216
|
+
for (let i = realHead + 1; i < parsed.length; i++) {
|
|
3217
|
+
const p = parsed[i];
|
|
3218
|
+
if (p.kind === "head" && p.cells.length === 1 && parsed.slice(i + 1).some((q) => q.kind && q.kind !== "head" && q.kind !== GROUP)) p.kind = GROUP;
|
|
3219
|
+
}
|
|
3220
|
+
}
|
|
3198
3221
|
const headRow = parsed.filter((p) => p.kind === "head").at(-1) ?? null;
|
|
3199
3222
|
const loadingRows = parsed.filter((p) => p.kind === LOADING);
|
|
3200
|
-
const bodyRows = parsed.filter((p) => p.kind !== "head");
|
|
3223
|
+
const bodyRows = parsed.filter((p) => p.kind !== "head" && p.kind !== GROUP);
|
|
3201
3224
|
// The column count is the real header's: with no header row there is none to take.
|
|
3202
3225
|
const columnCount = headRow?.cells.length ?? 0;
|
|
3203
3226
|
const skeleton = headRow !== null && loadingRows.length > 0 && loadingRows.length === bodyRows.length && loadingRows.every((p) => p.cells.length === columnCount);
|
|
@@ -3270,6 +3293,7 @@ function tableOf(node, ctx) {
|
|
|
3270
3293
|
// by its header (NODII-DEV-CLI-82). Rows that differ in their cells, or a row the generator
|
|
3271
3294
|
// couldn't recognise, stay as drawn.
|
|
3272
3295
|
const dataRows = parsed.filter((p) => p.kind === "body");
|
|
3296
|
+
const groupRows = parsed.filter((p) => p.kind === GROUP);
|
|
3273
3297
|
// Each column's key: its header copy, numbered when two columns share it. It names the
|
|
3274
3298
|
// column in the lifted rows and scopes its head's handler (NODII-DEV-CLI-84).
|
|
3275
3299
|
const columnKeys = (count) => {
|
|
@@ -3359,7 +3383,7 @@ function tableOf(node, ctx) {
|
|
|
3359
3383
|
const kinds = people.map((p) => piiTreeKind(p.cells[i].cell));
|
|
3360
3384
|
const why = kinds.some((kind) => !PII_KINDS.has(kind))
|
|
3361
3385
|
? `column ${key} has no recognised PiiText kind in one or more body rows`
|
|
3362
|
-
:
|
|
3386
|
+
: null;
|
|
3363
3387
|
if (why) {
|
|
3364
3388
|
ctx.note(ctx.path, "table", `${why}: left unmapped (MW8-17.3; cli-140)`);
|
|
3365
3389
|
invalidPii.set(i, why);
|
|
@@ -3408,16 +3432,35 @@ function tableOf(node, ctx) {
|
|
|
3408
3432
|
}
|
|
3409
3433
|
return indent(`${open}{row.${keys[i]}}${close}`, depth + 4);
|
|
3410
3434
|
});
|
|
3411
|
-
|
|
3412
|
-
indent(`{${rowsName}.map((row) => (`, depth + 2),
|
|
3435
|
+
const dataRow = [
|
|
3413
3436
|
indent(`<TableRow key={row.id}${selection} onClick={${inert}?.(row) ? undefined : ${getClick} ? ${getClick}(row) : ${rowClick} && (() => ${rowClick}(row))}>`, depth + 3),
|
|
3414
3437
|
...cells,
|
|
3415
3438
|
indent("</TableRow>", depth + 3),
|
|
3439
|
+
];
|
|
3440
|
+
if (!groupRows.length) return [indent(`{${rowsName}.map((row) => (`, depth + 2), ...dataRow, indent("))}", depth + 2)];
|
|
3441
|
+
// The groups are rows of the same list, in drawn order: `{ kind: "group", label }` heads
|
|
3442
|
+
// the rows after it, drawn as its band's own head across every column (NODII-DEV-CLI-222).
|
|
3443
|
+
let labelKey = "label";
|
|
3444
|
+
while (keys.includes(labelKey)) labelKey = `group${labelKey[0].toUpperCase()}${labelKey.slice(1)}`;
|
|
3445
|
+
const band = groupRows[0].cells[0];
|
|
3446
|
+
const bandCode = emitNode(band.cell, { ...ctx, depth: 0, parent: null, path: `${ctx.path} › ${groupRows[0].row.name}`, root: false, bare: true, inTable: true, scopes: null, note: () => {} }).trim();
|
|
3447
|
+
const bandOpen = bandCode.slice(0, openTagEnd(bandCode) + 1).replace(/\s*\/>$/, ">").replace(/\s+width=\{[^}]*\}|\s+width="[^"]*"/, "").replace(/^<(\w+)/, `<$1 colSpan={${keys.length}} scope="colgroup"`);
|
|
3448
|
+
const bandTag = /^<([A-Za-z]+)/.exec(bandCode)[1];
|
|
3449
|
+
ctx.note(ctx.path, LIFTED, `${groupRows.length} group band${groupRows.length === 1 ? "" : "s"} lifted with the rows: { kind: "group", ${labelKey} } (NODII-DEV-CLI-222)`);
|
|
3450
|
+
return [
|
|
3451
|
+
indent(`{${rowsName}.map((row) => (`, depth + 2),
|
|
3452
|
+
indent('row.kind === "group" ? (', depth + 3),
|
|
3453
|
+
indent("<TableRow key={row.id}>", depth + 4),
|
|
3454
|
+
indent(`${bandOpen}{row.${labelKey}}</${bandTag}>`, depth + 5),
|
|
3455
|
+
indent("</TableRow>", depth + 4),
|
|
3456
|
+
indent(") : (", depth + 3),
|
|
3457
|
+
...dataRow.map((line) => indent(line, 1)),
|
|
3458
|
+
indent(")", depth + 3),
|
|
3416
3459
|
indent("))}", depth + 2),
|
|
3417
3460
|
];
|
|
3418
3461
|
};
|
|
3419
3462
|
const section = (kind, tag) => {
|
|
3420
|
-
const list = parsed.filter((p) => p.kind === kind);
|
|
3463
|
+
const list = parsed.filter((p) => p.kind === kind || (kind === "body" && p.kind === GROUP));
|
|
3421
3464
|
if (!list.length) return [];
|
|
3422
3465
|
return [
|
|
3423
3466
|
indent(`<${tag}>`, depth + 1),
|
|
@@ -3425,7 +3468,7 @@ function tableOf(node, ctx) {
|
|
|
3425
3468
|
? [skeletonRows()]
|
|
3426
3469
|
: kind === "body" && liftable
|
|
3427
3470
|
? liftedRows()
|
|
3428
|
-
: list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? liftHeading(controlSort(cellCode(c, p.row, depth + 3, headKeys[i]), headKeys[i]), headKeys[i]) : cellCode(c, p.row, depth + 3, null))), indent("</TableRow>", depth + 2)]))),
|
|
3471
|
+
: list.flatMap((p) => (p.unrecognised ? [indent(comment(p.unrecognised), depth + 2)] : [indent("<TableRow>", depth + 2), ...p.cells.map((c, i) => (p === headRow ? liftHeading(controlSort(cellCode(c, p.row, depth + 3, headKeys[i]), headKeys[i]), headKeys[i]) : p.kind === GROUP && columnCount ? cellCode(c, p.row, depth + 3, null).replace(/^(\s*<\w+)(?:\s+width=(?:\{[^}]*\}|"[^"]*"))?/, `$1 colSpan={${columnCount}} scope="colgroup"`) : cellCode(c, p.row, depth + 3, null))), indent("</TableRow>", depth + 2)]))),
|
|
3429
3472
|
indent(`</${tag}>`, depth + 1),
|
|
3430
3473
|
];
|
|
3431
3474
|
};
|