@nodii/dev 0.6.178 → 0.6.179
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 +5 -1
- package/dist/core.js +1 -1
- package/dist/lane-supervisor.js +23 -7
- package/dist/nudges.js +2 -2
- package/dist/receipt.js +7 -1
- package/dist/surface.js +67 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -987,7 +987,11 @@ check not recorded. Continue the Task: STEP.` BLOCKED is not an exit
|
|
|
987
987
|
only a typed human gate lets the stop through. The gates
|
|
988
988
|
are a wait on an operator question (`Q-n`), a decision (`DEC-n`), a release or
|
|
989
989
|
launch day; a wait on a `steward-*` lane; or a latest heartbeat typed
|
|
990
|
-
`WAITING: human-gate totp|steward|spend: WHAT THE PERSON MUST DO`.
|
|
990
|
+
`WAITING: human-gate totp|steward|coordinator|spend: WHAT THE PERSON MUST DO`.
|
|
991
|
+
`coordinator` is for a coordinator-only step that leeway may not reach, such
|
|
992
|
+
as uploading an operator-approved lock-change decision (MW1 1.33, DEC-0508).
|
|
993
|
+
When a launched run ends on it, the supervisor reports the end to the machine's
|
|
994
|
+
coordinator as a lane message (MW1-12.11). Any other
|
|
991
995
|
blocker, such as a blocked step, a PR, an issue, another lane, or an untyped
|
|
992
996
|
BLOCKED or WAITING note, holds the stop. The answer then names the blocker and
|
|
993
997
|
says to claim it with `lane leeway` (MW1-12.6), fix it with the lane's
|
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.179";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/lane-supervisor.js
CHANGED
|
@@ -6,7 +6,7 @@ import { dirname, join } from "node:path";
|
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
import { profilePath, recordExhaustedAccount } from "./accounts.js";
|
|
8
8
|
import { CliError, devRequest, encode } from "./core.js";
|
|
9
|
-
import { inboxForContinuation } from "./lane-messages.js";
|
|
9
|
+
import { inboxForContinuation, laneMessageCommand } from "./lane-messages.js";
|
|
10
10
|
import { laneSwitchOn } from "./lane-switches.js";
|
|
11
11
|
import { redactRunText } from "./runs.js";
|
|
12
12
|
import { processStartedAt, saveWatchedRun, watchdogRunDir } from "./watchdog.js";
|
|
@@ -277,12 +277,13 @@ export function laneBlockedReason(lane) {
|
|
|
277
277
|
// NODII-DEV-CLI-191: only a typed human gate ends a lane's run. A wait on
|
|
278
278
|
// an operator question, a decision, a release (the steward judges it) or launch
|
|
279
279
|
// day, a wait on a steward lane, or a latest heartbeat typed
|
|
280
|
-
// `WAITING: human-gate totp|steward|spend:
|
|
280
|
+
// `WAITING: human-gate totp|steward|coordinator|spend: ...` (coordinator:
|
|
281
|
+
// MW1 1.33, DEC-0508, a coordinator-only step leeway may not reach). Every other blocker (a blocked
|
|
281
282
|
// step, a PR, an issue, another lane, an untyped BLOCKED or WAITING note) is
|
|
282
283
|
// the lane's to claim and fix.
|
|
283
284
|
const HUMAN_GATE_WAITS = new Set(["question", "decision", "release", "launch_day"]);
|
|
284
|
-
const HUMAN_GATE_NOTE = /^\s*(?:BLOCKED|WAITING)\s*:?\s*human[- ]gate\s*\(?\s*(totp|steward|spend)\b/i;
|
|
285
|
-
export const HUMAN_GATE_COMMAND = (laneKey) => `nodii-dev lane heartbeat ${laneKey} --note "WAITING: human-gate totp|steward|spend: <what the person must do>"`;
|
|
285
|
+
const HUMAN_GATE_NOTE = /^\s*(?:BLOCKED|WAITING)\s*:?\s*human[- ]gate\s*\(?\s*(totp|steward|coordinator|spend)\b/i;
|
|
286
|
+
export const HUMAN_GATE_COMMAND = (laneKey) => `nodii-dev lane heartbeat ${laneKey} --note "WAITING: human-gate totp|steward|coordinator|spend: <what the person must do>"`;
|
|
286
287
|
|
|
287
288
|
const latestNote = (lane) => String((lane?.events ?? [])
|
|
288
289
|
.filter((event) => event.type === "heartbeat" && event.metadata?.source !== "hook" && String(event.metadata?.note ?? "").trim())
|
|
@@ -303,6 +304,12 @@ export function subagentBudgetLine(quota, env = process.env) {
|
|
|
303
304
|
return `You have ${n} subagent slot${n === 1 ? "" : "s"} (the Agent tool; MW1-38.15). Fan independent work out to them as MW1-11 says.`;
|
|
304
305
|
}
|
|
305
306
|
|
|
307
|
+
/** The latest heartbeat note when it types the coordinator gate (MW1-12.10, DEC-0508), or null. */
|
|
308
|
+
export function coordinatorGateNote(lane) {
|
|
309
|
+
const note = latestNote(lane);
|
|
310
|
+
return HUMAN_GATE_NOTE.exec(note)?.[1]?.toLowerCase() === "coordinator" ? note.slice(0, 500) : null;
|
|
311
|
+
}
|
|
312
|
+
|
|
306
313
|
/** The typed human gate that ends a lane's run, or null (NODII-DEV-CLI-191). */
|
|
307
314
|
export function laneHumanGate(lane) {
|
|
308
315
|
for (const wait of lane?.waits ?? []) {
|
|
@@ -343,6 +350,10 @@ export function continueTaskMessage(laneKey, lane, env = process.env) {
|
|
|
343
350
|
return `Lane ${laneKey}: done check not recorded. Continue the Task: ${step}.`;
|
|
344
351
|
}
|
|
345
352
|
|
|
353
|
+
/** A lane message to this machine's coordinator, recorded on the ended run's own lane issue (MW1-12.11). */
|
|
354
|
+
const messageCoordinator = (laneKey, body, { env = process.env } = {}) =>
|
|
355
|
+
laneMessageCommand(["coordinator"], { body }, { env: { ...env, NODII_DEV_LANE_KEY: laneKey } });
|
|
356
|
+
|
|
346
357
|
/**
|
|
347
358
|
* The lane's Dev status and whether its done check is recorded. Unreadable
|
|
348
359
|
* reads as unfinished.
|
|
@@ -350,9 +361,9 @@ export function continueTaskMessage(laneKey, lane, env = process.env) {
|
|
|
350
361
|
async function laneProgress(request, laneKey) {
|
|
351
362
|
try {
|
|
352
363
|
const lane = (await request("GET", `/api/v1/lanes/${encode(laneKey)}`)).data;
|
|
353
|
-
return { status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane) };
|
|
364
|
+
return { status: lane?.status ?? null, finished: doneCheckRecorded(lane), blocked: laneBlockedReason(lane), finishEvidence: laneFinishEvidence(lane), coordinatorGate: coordinatorGateNote(lane) };
|
|
354
365
|
} catch {
|
|
355
|
-
return { status: null, finished: false, blocked: null, finishEvidence: null };
|
|
366
|
+
return { status: null, finished: false, blocked: null, finishEvidence: null, coordinatorGate: null };
|
|
356
367
|
}
|
|
357
368
|
}
|
|
358
369
|
|
|
@@ -396,9 +407,10 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
396
407
|
markTerminal = markWatchedTerminal,
|
|
397
408
|
now = () => new Date(),
|
|
398
409
|
markExhausted = recordExhaustedAccount,
|
|
410
|
+
tellCoordinator = messageCoordinator,
|
|
399
411
|
} = {}) {
|
|
400
412
|
const worktree = await inspect(worktrees);
|
|
401
|
-
const { status, finished, blocked, finishEvidence } = await laneProgress(request, laneKey);
|
|
413
|
+
const { status, finished, blocked, finishEvidence, coordinatorGate } = await laneProgress(request, laneKey);
|
|
402
414
|
const clean = exitCode === 0 && !signal;
|
|
403
415
|
const exitRef = signal ? `signal ${signal}` : String(exitCode ?? -1);
|
|
404
416
|
const exited = signal ? `was ended by ${signal}` : `exited with code ${exitCode ?? -1}`;
|
|
@@ -469,6 +481,10 @@ export async function reportLaneExit({ runId, laneKey, exitCode, signal, worktre
|
|
|
469
481
|
const laneFinish = finished && clean && !blocked && worktree.state === "clean" && finishEvidence
|
|
470
482
|
? await finishLane(request, laneKey, `The lane's done check was recorded and its process exited 0 with its worktree ${worktree.state}; recorded by the lane supervisor on exit.`, finishEvidence)
|
|
471
483
|
: null;
|
|
484
|
+
// MW1-12.10 (DEC-0508): a run that ends on a coordinator-only step is
|
|
485
|
+
// reported to the coordinator. A report that fails changes nothing else.
|
|
486
|
+
if (outcome === "blocked" && coordinatorGate)
|
|
487
|
+
await tellCoordinator(laneKey, `Lane ${laneKey}'s run ended on a coordinator-only step (MW1-12.10, DEC-0508): ${coordinatorGate}. The lane resumes when that step is done.`).catch(() => {});
|
|
472
488
|
await markTerminal(runId).catch(() => {});
|
|
473
489
|
return { outcome, exitCode: exitCode ?? null, signal: signal ?? null, worktree: worktree.state, laneStatus: status, ...(laneFinish ? { laneFinish } : {}), ...(accountFailure ? { accountFailure } : {}) };
|
|
474
490
|
}
|
package/dist/nudges.js
CHANGED
|
@@ -684,8 +684,8 @@ export async function transcriptToolUses(path) {
|
|
|
684
684
|
* NODII-DEV-CLI-8 (hub-58, gate for AGENT-HARNESS-13): a lane session may not
|
|
685
685
|
* stop before its done check is recorded. NODII-DEV-CLI-191: BLOCKED is not an
|
|
686
686
|
* exit. A blocker the lane can claim and fix holds the stop; only a typed
|
|
687
|
-
* human gate (`laneHumanGate`: operator TOTP, a steward-only step,
|
|
688
|
-
* operator question or decision) lets it through. The lane is read fresh: the
|
|
687
|
+
* human gate (`laneHumanGate`: operator TOTP, a steward-only step, a
|
|
688
|
+
* coordinator-only step, spend, an operator question or decision) lets it through. The lane is read fresh: the
|
|
689
689
|
* lane this hook call just read from Dev by key (`context.laneDetail`), else
|
|
690
690
|
* one slim read here (hub-528). An unreadable lane lets the stop through.
|
|
691
691
|
* The no-progress guard: a stop held NODII_DEV_STOP_STALL_LIMIT (2) times in a
|
package/dist/receipt.js
CHANGED
|
@@ -146,12 +146,18 @@ const SECRET_FLAG = new RegExp(String.raw`(^|\s)(--?[\w-]*(?:token|secret|pass|p
|
|
|
146
146
|
const URL_USER_INFO = /(\b[a-z][a-z0-9+.-]*:\/\/)[^/\s:@]*(?::[^/\s@]*)?@/gi;
|
|
147
147
|
const AUTH_SCHEME = /\b(bearer|basic|token)\s+[A-Za-z0-9._~+/=-]{8,}/gi;
|
|
148
148
|
const TOKEN_SHAPED = /\b(?:gh[pousr]_[A-Za-z0-9]{10,}|github_pat_\w{10,}|sk-[\w-]{10,}|xox[abprs]-[\w-]{10,}|AKIA[0-9A-Z]{12,}|eyJ[\w-]{8,}\.[\w-]{8,}\.[\w-]*|[A-Fa-f0-9]{32,}|[A-Za-z0-9+/_-]{40,}={0,2})\b/g;
|
|
149
|
+
// NODII-DEV-CLI-213: a long repository path (`packages/dev/test/some-long-name`)
|
|
150
|
+
// fills the 40-character class too. A match is a path, not a token, when it has
|
|
151
|
+
// a slash and every segment between slashes is a lowercase word (letters, digits,
|
|
152
|
+
// `.`, `_` or `-`, with a letter). Random base64 is mixed case, so it still redacts.
|
|
153
|
+
const PATH_SEGMENT = /^[a-z0-9._-]*[a-z][a-z0-9._-]*$/;
|
|
154
|
+
const pathShaped = (match) => match.includes("/") && match.split("/").every((segment) => PATH_SEGMENT.test(segment));
|
|
149
155
|
export const redactCommand = (command) => String(command)
|
|
150
156
|
.replace(URL_USER_INFO, "$1<redacted>@")
|
|
151
157
|
.replace(SECRET_FLAG, "$1$2 <redacted>")
|
|
152
158
|
.replace(ANY_ASSIGNMENT, "$1$2=<redacted>")
|
|
153
159
|
.replace(AUTH_SCHEME, "$1 <redacted>")
|
|
154
|
-
.replace(TOKEN_SHAPED, "<redacted>");
|
|
160
|
+
.replace(TOKEN_SHAPED, (match) => (pathShaped(match) ? match : "<redacted>"));
|
|
155
161
|
|
|
156
162
|
const many = (value) => (value === undefined ? [] : [value].flat().map(String));
|
|
157
163
|
const ranAt = () => new Date().toISOString();
|
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 = 40;
|
|
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). */
|
|
@@ -616,7 +616,7 @@ export function emitSurface(tree, row, ds) {
|
|
|
616
616
|
const shapes = new Map();
|
|
617
617
|
// The marked identifiers a template lists as optional, and the ones it doesn't (DESIGN-SYSTEM-507).
|
|
618
618
|
const optionals = { optional: new Set(), required: new Set() };
|
|
619
|
-
const views = tree.variants.map((variant) => {
|
|
619
|
+
const views = graftAbsentSlots(tree.variants).map((variant) => {
|
|
620
620
|
let state = variant.state;
|
|
621
621
|
while (used.has(state)) state += "-x";
|
|
622
622
|
used.add(state);
|
|
@@ -779,9 +779,23 @@ function scopeName(node, code = "", ctx = null) {
|
|
|
779
779
|
const own = [props.label, props.title].find(named);
|
|
780
780
|
const at = own ? placeInView(node, ctx) : null;
|
|
781
781
|
if (at) return camelName(`${node.instance.set} ${at}`);
|
|
782
|
+
// A layer named after its own sample (`PiiText · Asha Rao`) names the record, not the part:
|
|
783
|
+
// in a slot it takes its owner's label (`Created by`), else its set's name.
|
|
784
|
+
if (!own && sampleNamed(node)) {
|
|
785
|
+
const ownerProps = ctx?.slotOwner?.instance?.props ?? ctx?.slotOwner?.props ?? {};
|
|
786
|
+
const label = [ownerProps.label, ownerProps.title].find(named);
|
|
787
|
+
return nameOf(label ?? node.instance?.set ?? "", node.instance?.set ?? "");
|
|
788
|
+
}
|
|
782
789
|
return nameOf(own ?? node.name ?? "", node.instance?.set ?? node.name ?? "");
|
|
783
790
|
}
|
|
784
791
|
|
|
792
|
+
/** A layer whose name after `·` repeats one of its own text values: the designer's sample, not a name. */
|
|
793
|
+
function sampleNamed(node) {
|
|
794
|
+
const suffix = /·\s*(.+)$/.exec(node.name ?? "")?.[1]?.trim();
|
|
795
|
+
if (!suffix) return false;
|
|
796
|
+
return Object.values(node.instance?.props ?? {}).some((v) => typeof v === "string" && v.trim() === suffix);
|
|
797
|
+
}
|
|
798
|
+
|
|
785
799
|
/** Where an instance stands among the instances of its set in its view (1, 2, …), when the view holds two or more; else null. */
|
|
786
800
|
function placeInView(node, ctx) {
|
|
787
801
|
const root = ctx?.chain?.[0];
|
|
@@ -923,6 +937,53 @@ function optionalMark(ctx, scope, name, layer = ctx.layer) {
|
|
|
923
937
|
* numbered (`Frame`, `Frame#1`). The view's own name is left out, so the same
|
|
924
938
|
* layer in another state view is the same layer, one prop (hub-468).
|
|
925
939
|
*/
|
|
940
|
+
/**
|
|
941
|
+
* Figma leaves a slot out of an instance whose variant does not show it (a
|
|
942
|
+
* `pane=hidden` Detail Page has no `right pane` SLOT), but the template still
|
|
943
|
+
* reads it, so that view drew the slot empty and named its controls apart from
|
|
944
|
+
* the open view's (NODII-DEV-CLI-188). Fill such a slot from the same
|
|
945
|
+
* instance in another view, the default view's first, matched by layer path
|
|
946
|
+
* and component set. Only the slots listed in GRAFTED_SLOTS: other parts leave
|
|
947
|
+
* a slot out on purpose (a Loading view's Data Table Toolbar has no `table`).
|
|
948
|
+
* A slot drawn empty stays empty. The saved tree is never changed: this works
|
|
949
|
+
* on a copy.
|
|
950
|
+
*/
|
|
951
|
+
const GRAFTED_SLOTS = new Map([["Detail Page", new Set(["right pane"])]]);
|
|
952
|
+
function graftAbsentSlots(variants) {
|
|
953
|
+
const walk = (node, path, visit) => {
|
|
954
|
+
visit(node, path);
|
|
955
|
+
const seen = new Map();
|
|
956
|
+
for (const child of node.children ?? []) {
|
|
957
|
+
const at = seen.get(child.name) ?? 0;
|
|
958
|
+
seen.set(child.name, at + 1);
|
|
959
|
+
walk(child, `${path} › ${child.name}${at ? `#${at}` : ""}`, visit);
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
const keyOf = (node, path) => (node.type === "INSTANCE" && node.instance?.remote && GRAFTED_SLOTS.has(node.instance.set) ? `${node.instance.set}@${path}` : null);
|
|
963
|
+
const ordered = [...variants].sort((a, b) => (b.state === "default") - (a.state === "default"));
|
|
964
|
+
const drawn = new Map();
|
|
965
|
+
for (const variant of ordered) {
|
|
966
|
+
walk(variant.root, "", (node, path) => {
|
|
967
|
+
const key = keyOf(node, path);
|
|
968
|
+
if (!key) return;
|
|
969
|
+
const slots = drawn.get(key) ?? new Map();
|
|
970
|
+
for (const child of node.children ?? []) if (child.type === "SLOT" && GRAFTED_SLOTS.get(node.instance.set).has(child.slot) && !slots.has(child.slot)) slots.set(child.slot, child);
|
|
971
|
+
drawn.set(key, slots);
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
if (![...drawn.values()].some((slots) => slots.size)) return variants;
|
|
975
|
+
return variants.map((variant) => {
|
|
976
|
+
const copy = structuredClone(variant);
|
|
977
|
+
walk(copy.root, "", (node, path) => {
|
|
978
|
+
const slots = drawn.get(keyOf(node, path));
|
|
979
|
+
if (!slots?.size) return;
|
|
980
|
+
const own = new Set((node.children ?? []).filter((c) => c.type === "SLOT").map((c) => c.slot));
|
|
981
|
+
for (const [name, slot] of slots) if (!own.has(name)) node.children = [...(node.children ?? []), structuredClone(slot)];
|
|
982
|
+
});
|
|
983
|
+
return copy;
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
|
|
926
987
|
function layerOf(node, ctx) {
|
|
927
988
|
if (ctx.root) return "";
|
|
928
989
|
const same = (ctx.parent?.children ?? []).filter((c) => c.name === node.name);
|
|
@@ -1316,7 +1377,8 @@ function showCondition(code, node, ctx, path) {
|
|
|
1316
1377
|
* are (tabStrip).
|
|
1317
1378
|
*/
|
|
1318
1379
|
function hideable(code) {
|
|
1319
|
-
|
|
1380
|
+
// A parent template may include a child Alert that was already processed (NODII-DEV-CLI-209).
|
|
1381
|
+
let out = code.replace(/(?<!!== false && \()<AlertAction>([\s\S]*?)<\/AlertAction>/g, (block, inner) => {
|
|
1320
1382
|
const flagOf = (part) => {
|
|
1321
1383
|
const own = /\bonClick=\{(__s\d+)_on([A-Z]\w*)Click\}/.exec(part);
|
|
1322
1384
|
return own ? `${own[1]}_show${own[2]}` : null;
|
|
@@ -1330,7 +1392,7 @@ function hideable(code) {
|
|
|
1330
1392
|
let held = inner;
|
|
1331
1393
|
for (const b of buttons.reverse()) {
|
|
1332
1394
|
const flag = flagOf(b.code);
|
|
1333
|
-
if (flag) held = `${held.slice(0, b.at)}{${flag} !== false && (${b.code})}${held.slice(b.at + b.code.length)}`;
|
|
1395
|
+
if (flag && !held.slice(0, b.at).endsWith(" !== false && (")) held = `${held.slice(0, b.at)}{${flag} !== false && (${b.code})}${held.slice(b.at + b.code.length)}`;
|
|
1334
1396
|
}
|
|
1335
1397
|
return `<AlertAction>${held}</AlertAction>`;
|
|
1336
1398
|
});
|
|
@@ -2384,7 +2446,7 @@ function emitNode(node, ctx) {
|
|
|
2384
2446
|
return comment(`unmapped: slot ${JSON.stringify(prop)} has no auto layout`);
|
|
2385
2447
|
}
|
|
2386
2448
|
const textOwner = TEXT_PROPERTY_PARTS.has(node.instance.set) ? node.instance.set : ctx.textOwner;
|
|
2387
|
-
const slotCtx = { ...ctx, depth: 0, parent: slotNode, grand: null, path: `${path} › ${prop}`, root: false, textOwner, inTable: false, inSlot: true, chain: slotNode ? [...chain, slotNode] : chain, layer: `${ctx.layer}${nestedPath.map(part => ` › ${part}`).join("")} › ${prop}` };
|
|
2449
|
+
const slotCtx = { ...ctx, depth: 0, parent: slotNode, grand: null, path: `${path} › ${prop}`, root: false, textOwner, slotOwner: owner, inTable: false, inSlot: true, chain: slotNode ? [...chain, slotNode] : chain, layer: `${ctx.layer}${nestedPath.map(part => ` › ${part}`).join("")} › ${prop}` };
|
|
2388
2450
|
const inner = emitChildren(slotNode?.children ?? [], (c) => emitNode(c, slotCtx), slotCtx);
|
|
2389
2451
|
return inner.length === 0 ? "<></>" : inner.length === 1 ? inner[0] : `<>\n${inner.map((x) => indent(x, 1)).join("\n")}\n</>`;
|
|
2390
2452
|
};
|