@nodii/dev 0.6.150 → 0.6.152

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 CHANGED
@@ -103,7 +103,8 @@ nodii-dev lane check KEY --gate 'pnpm typecheck' --gate 'pnpm lint' --gate 'nodi
103
103
  - The graph is read from source: static and dynamic imports, re-exports, `require`, `vi.mock`, `jest.mock` and `mock.module`, `new URL("./x", import.meta.url)`, the nearest tsconfig's `paths`, and workspace packages by name. A data file (SQL, JSON, a template) reaches the code that names it.
104
104
  - It fails closed. A manifest, lockfile, tsconfig, test or build config, a data file no source names, or a changed source file no test reaches selects the full suite (`full` lists why). Docs, `.github/` and the policy file select nothing.
105
105
  - Each package runs its tests with its own `test` script's runner and flags, and the selected files replace the script's paths. A script that is not one runner call (`bun run gate && bun test`) runs whole.
106
- - `lane check` refuses a full-suite gate (`GATE_FULL_SUITE`) unless `--full-suite` is passed.
106
+ - `lane check` refuses a full-suite gate (`GATE_FULL_SUITE`) unless `--full-suite` is passed. A whole suite also means one workspace's or project's whole suite (`npm test -w X`, `pnpm --filter X test`, `jest --selectProjects web`), a runner given no path (`node --test`, `npx playwright test`, `pytest`, `go test ./...`), and any of these inside `sh -c`. From a lane's own config, `--full-suite` is refused too (`FULL_SUITE_LANE_REFUSED`, hub-485).
107
+ - The review body carries the gates receipt (`gates`): each gate's command, exit code and commit for this head and base, so Dev can refuse a whole-suite gate itself (hub-485). A `gates` field in a hand-written review file is never sent.
107
108
 
108
109
  ## Heavy work: one machine-wide slot queue
109
110
 
@@ -593,7 +594,7 @@ nodii-dev lane resume KEY [--override --reason TEXT]
593
594
  # running run or a lane-agent heartbeat since the death
594
595
  # that is not yet old enough to be dead: one process per
595
596
  # lane (the coordinator's own heartbeats do not count)
596
- nodii-dev lane check KEY [--gate CMD ...] [--critical] [--max-iterations N]
597
+ nodii-dev lane check KEY [--gate CMD ...] [--critical] [--max-iterations N] [--picker agent]
597
598
  # from the lane's worktree: the rules, Figma and code checks (DEV-REV) over
598
599
  # the diff against origin/main, tracked and untracked; --gate runs the gates
599
600
  # in order first, else a green gates receipt for this head and diff
@@ -1552,6 +1553,12 @@ own runtime (headless, no tools) makes that pick from Dev's shortlist and the
1552
1553
  Delta gather is recorded as `picker: agent`; an answer that names no offered
1553
1554
  document, or one Dev did not offer, is refused and nothing is recorded.
1554
1555
 
1556
+ Use `lane check KEY --picker agent` when the lane requires agent-only Gather
1557
+ (CLI-143). This requests Dev's shortlist immediately and uses the lane's runtime
1558
+ to pick and record the Delta gather, without warming or attempting the local
1559
+ model. If the agent pick fails, the rules check is unavailable; it does not try
1560
+ the local model. Omitting the flag keeps the local-first behavior above.
1561
+
1555
1562
  `lane start` creates and starts a lane. It infers the repository (by short
1556
1563
  name, as Dev compares it), branch and worktree from git unless overridden, and resolves `--issue` keys to the UUIDs
1557
1564
  required by Dev. Lane keys are passed directly to every lane and Built
package/dist/cli.js CHANGED
@@ -478,7 +478,7 @@ Usage: nodii-dev <command> [options] [--json]
478
478
  # locked decision that settles it (MW4-27), deferred an open issue. Records the
479
479
  # round once nothing blocks; Dev checks each citation and refuses code-check
480
480
  # findings, blockers, and security, tenancy, PII and money findings (MW2-41)
481
- lane check <key> [--gate CMD ...] [--critical] [--max-iterations N]
481
+ lane check <key> [--gate CMD ...] [--critical] [--max-iterations N] [--picker agent]
482
482
  # from the lane's worktree: the rules, Figma and code checks over the
483
483
  # diff against origin/main (DEV-REV); --gate runs gates 1-5 in order
484
484
  # first (else a green gates receipt for this head is required); the
@@ -486,6 +486,7 @@ Usage: nodii-dev <command> [options] [--json]
486
486
  # fix blocking findings and rerun until CLEAN, STUCK or the cap
487
487
  # (default 5); then writes REVIEW.json in git's private dir and
488
488
  # records it as lane review; --critical runs the code check (MW2-38.1)
489
+ # --picker agent gathers through the lane runtime without a local model attempt
489
490
  lane reviews <key> # stored review history for the lane, with each run's checks
490
491
  lane freeze add <key> --section SECTION --file ITEM.json --reason TEXT
491
492
  lane freeze drop <key> --section SECTION --item ID --reason TEXT
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.150";
7
+ export const VERSION = "0.6.152";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/lanes.js CHANGED
@@ -19,7 +19,8 @@ import { SWAP_BOUNDARIES, componentsForScope, guidelineLookup, laneFigmaScope, l
19
19
  import { designCheck } from "./design.js";
20
20
  import { LANE_ENV_FIX, laneEnvProblem, laneEnvReport } from "./lane-env.js";
21
21
  import { closeoutLane } from "./closeout.js";
22
- import { GATES_RECEIPT, REVIEW_FILE, REVIEW_LAST, REVIEW_LOOP, checkLines, checkReviewChecks, citationText, diffDigest, findingId, laneDiff, privateStore, repoGeneratedPaths, runBody, runLaneCheck, runOutcome, treatChecks, treatable, worktreeCommitted } from "./review.js";
22
+ import { GATES_RECEIPT, REVIEW_FILE, REVIEW_LAST, REVIEW_LOOP, checkLines, checkReviewChecks, citationText, diffDigest, findingId, laneDiff, privateStore, repoGeneratedPaths, reviewGates, runBody, runLaneCheck, runOutcome, treatChecks, treatable, worktreeCommitted } from "./review.js";
23
+ import { isLaneConfig } from "./session-kind.js";
23
24
 
24
25
  const execFileAsync = promisify(execFile);
25
26
  const via = { via: "nodii-dev" };
@@ -139,7 +140,8 @@ function agentPickerFlags(flags) {
139
140
  export const deltaGatherFlags = (paths, pick) => ({
140
141
  delta: true,
141
142
  paths: paths.join(","),
142
- ...(pick ? { picker: "agent", shortlist: pick.shortlist, documents: pick.documents.join(",") } : {}),
143
+ ...(pick ? { picker: "agent" } : {}),
144
+ ...(pick?.shortlist ? { shortlist: pick.shortlist, documents: pick.documents.join(",") } : {}),
143
145
  });
144
146
 
145
147
  // hub-58: the reason is a fixed code (Dev stores its canonical text); a note may add context.
@@ -752,7 +754,11 @@ export async function laneCommand(action, args, flags, deps = {}) {
752
754
  }
753
755
  // MW2-45: `lane review` and a step's `--done --review` record through one path.
754
756
  // `lane check` hands its own body over, already shaped.
755
- const recordReview = async (reviewFlags = flags, prepared = null, ranGates = [], cwd = null) => {
757
+ // hub-401: the policy file names the full-suite script a gate may not run per lane.
758
+ const fullScriptOf = async (worktree) => checkDeps.fullScript ?? (worktree ? await readPolicy(worktree).then((policy) => policy?.tests?.full).catch(() => null) : null) ?? "test";
759
+ // RECEIPT: the stored gates receipt, when the caller has read it; otherwise it is read from this worktree.
760
+ // DIGEST: the digest of the content the caller checked; without it the worktree's diff is read.
761
+ const recordReview = async (reviewFlags = flags, prepared = null, receipt = undefined, cwd = null, digest = null) => {
756
762
  // The input is checked before git is read, so a bad call never touches the worktree.
757
763
  const notRequired = !prepared && reviewFlags["not-required"] ? notRequiredCitation(reviewFlags) : null;
758
764
  const filed = prepared ?? (notRequired ? null : await reviewBody(reviewFlags, read));
@@ -764,11 +770,20 @@ export async function laneCommand(action, args, flags, deps = {}) {
764
770
  `The review file covers base ${body.base ?? "(missing)"} and head ${body.head ?? "(missing)"}, but this worktree is base ${current.base} and head ${current.commit}. Review the current diff and write a new receipt.`,
765
771
  2,
766
772
  );
773
+ // hub-485: Dev reads the gates that ran from the review itself, and only from this tool's own
774
+ // receipt for this head and base: a `gates` field in a hand-written review file is never sent.
775
+ const worktree = cwd ?? (receipt === undefined ? await gitContext().then((context) => context.worktree).catch(() => null) : null);
776
+ const stored = receipt !== undefined ? receipt : worktree ? await (checkDeps.store ?? privateStore(worktree)).read(GATES_RECEIPT).catch(() => null) : null;
777
+ // The same content too: gates that ran before the worktree changed did not run on this review's content.
778
+ const sameContent = async () => worktree && stored.diff === (digest ?? diffDigest((await (checkDeps.diff ?? laneDiff)(worktree)).text));
779
+ const gates = stored?.commit === body.head && stored?.base === body.base && (await sameContent().catch(() => false)) ? reviewGates(stored) : null;
780
+ const { gates: _claimed, ...unclaimed } = body;
781
+ const sent = gates ? { ...unclaimed, gates } : unclaimed;
767
782
  // Signed and attached first: no proof on Dev, no passed review on Dev (S06-53).
768
- // Only gates this tool saw pass for this head: lane check hands over its gates receipt's commands.
783
+ // Only gates this tool saw pass for this head: the gates receipt's runs.
769
784
  // A --gate flag on lane review is a claim, not a run, so it signs nothing. Their scope, stack and
770
785
  // auth posture are unknown to this tool, so a test receipt comes from receipt write or the stack tool.
771
- const gatesRun = ranGates.map((command) => ({ command, exitCode: 0 }));
786
+ const gatesRun = (gates?.runs ?? []).map(({ command, exitCode }) => ({ command, exitCode }));
772
787
  // A body with checks carries no exitReason (Dev computes it), so the receipt
773
788
  // takes the outcome Dev will compute (NODII-DEV-CLI-66).
774
789
  const exitReason = body.exitReason ?? (body.checks?.length ? runOutcome(body.checks) : undefined);
@@ -779,7 +794,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
779
794
  review: { exitReason, base: body.base, head: body.head, findings: body.findings?.length ?? 0 },
780
795
  } });
781
796
  await attachReceipt?.();
782
- const payload = await request("POST", `/api/v1/lanes/${encode(id)}/review`, body);
797
+ const payload = await request("POST", `/api/v1/lanes/${encode(id)}/review`, sent);
783
798
  try { await reviewReceipt(); }
784
799
  catch (error) {
785
800
  throw new CliError("REVIEW_RECEIPT_FAILED", `${ref}: Dev recorded the review, but the local push receipt could not be written (${error?.message ?? error}). Re-run nodii-dev lane review ${ref} --file REVIEW.json from its worktree.`, 1);
@@ -823,7 +838,9 @@ export async function laneCommand(action, args, flags, deps = {}) {
823
838
  ...(checkDeps.picker ? { picker: checkDeps.picker } : {}),
824
839
  ...(checkDeps.now ? { now: checkDeps.now } : {}),
825
840
  // hub-401: the policy file names the full-suite script a gate may not run per lane.
826
- fullScript: checkDeps.fullScript ?? (await readPolicy(context.worktree).then((policy) => policy?.tests?.full).catch(() => null)) ?? "test",
841
+ fullScript: await fullScriptOf(context.worktree),
842
+ // hub-485: a lane's own config may not pass --full-suite.
843
+ laneAgent: checkDeps.laneAgent ?? isLaneConfig(),
827
844
  });
828
845
  // AGENT-HARNESS-61: an agent here without the lane's config gets no managed
829
846
  // hooks. Reported, never blocking: the check itself cannot fix a process.
@@ -852,8 +869,7 @@ export async function laneCommand(action, args, flags, deps = {}) {
852
869
  throw new CliError("REVIEW_WORKTREE_DIRTY", `${[...lines, `run: nothing recorded. ${committed ? "The worktree changed while the reviewers ran" : "The reviewed diff has uncommitted or untracked changes"}, and Dev records a review for commit ${run.body.head} only. Commit them (or drop them) and rerun nodii-dev lane check ${ref}; this round does not count.`].join("\n")}`, 1);
853
870
  const file = await store.write(REVIEW_FILE, run.body);
854
871
  const gates = await store.read(GATES_RECEIPT).catch(() => null);
855
- const ranGates = gates?.commit === run.body.head && gates?.base === run.body.base && Array.isArray(gates.commands) ? gates.commands : [];
856
- const payload = await recordReview(flags, run.body, ranGates, context.worktree);
872
+ const payload = await recordReview(flags, run.body, gates, context.worktree, run.digest);
857
873
  await run.saveLoop();
858
874
  const outcome = runOutcome(run.body.checks);
859
875
  return {
@@ -1129,9 +1145,8 @@ export async function laneCommand(action, args, flags, deps = {}) {
1129
1145
  }
1130
1146
  const body = runBody(checks, current);
1131
1147
  const gates = await store.read(GATES_RECEIPT).catch(() => null);
1132
- const ranGates = gates?.commit === body.head && gates?.base === body.base && Array.isArray(gates.commands) ? gates.commands : [];
1133
1148
  // Dev checks every citation; nothing is written here unless it records the run.
1134
- const payload = await recordReview(flags, body, ranGates, context.worktree);
1149
+ const payload = await recordReview(flags, body, gates, context.worktree, digest);
1135
1150
  const file = await store.write(REVIEW_FILE, body);
1136
1151
  // A check the treatment made CLEAN starts a new loop, as any CLEAN does.
1137
1152
  const loop = (await store.read(REVIEW_LOOP).catch(() => null)) ?? {};
package/dist/review.js CHANGED
@@ -105,35 +105,118 @@ export function selfSizedGate(command) {
105
105
  * hub-401: a gate that runs the repository's whole test suite. Per lane and per push only the affected
106
106
  * tests run (`nodii-dev test affected --run`); the full suite runs in the twice-daily CI and the release gate.
107
107
  * FULL_SCRIPT is the policy file's tests.full script.
108
+ *
109
+ * hub-485: Dev mirrors these rules on the gates receipt, so they are the contract, not a hint. A whole
110
+ * suite is also one workspace's or project's whole suite (`npm test -w X`, `pnpm --filter X test`,
111
+ * `jest --selectProjects web`), a direct runner call with no path (`node --test`, `npx playwright test`,
112
+ * `pytest`, `go test ./...`), a path that names the whole tree (`.`, `test/*.test.js`), and any of these
113
+ * inside `sh -c '…'`.
108
114
  */
109
115
  export function fullSuiteGate(command, fullScript = "test") {
110
116
  const text = String(command ?? "").trim();
111
- const scripts = new Set(["test", "t", fullScript]);
112
- for (const part of text.split(/&&|\|\||;/).map((x) => x.trim()).filter(Boolean)) {
113
- let words = part.split(/\s+/).filter((word) => !/^[A-Z_][A-Z0-9_]*=/.test(word) && !/^(?:[0-9]?>|\|)/.test(word));
114
- // `npx vitest`, `bunx jest`, `pnpm exec vitest run`: the tool they start.
117
+ // test:all and test:full are the full-suite scripts Dev's own check names too.
118
+ const scripts = new Set(["test", "t", "test:all", "test:full", fullScript]);
119
+ for (const part of shellCommands(text)) {
120
+ const nested = shellScript(part);
121
+ if (nested !== null) { if (fullSuiteGate(nested, fullScript)) return true; continue; }
122
+ let words = part.split(/\s+/).map((word) => word.replace(/^['"]+|['"]+$/g, "")).filter((word) => word && !/^[A-Z_][A-Z0-9_]*=/.test(word) && !/^(?:[0-9]?>|\|)/.test(word));
123
+ // `npx vitest`, `bunx jest`, `pnpm exec vitest run`, `python -m pytest`: the tool they start.
115
124
  for (;;) {
116
125
  const first = (words[0] ?? "").split("/").pop();
117
126
  if (["npx", "bunx", "pnpx"].includes(first)) words = words.slice(1).filter((word, i) => i > 0 || !word.startsWith("-"));
118
127
  else if (["npm", "pnpm", "yarn"].includes(first) && ["exec", "dlx"].includes(words.find((word, i) => i > 0 && !word.startsWith("-")))) words = words.slice(words.findIndex((word) => ["exec", "dlx"].includes(word)) + 1);
128
+ else if (/^python[0-9.]*$/.test(first) && words[1] === "-m") words = words.slice(2);
129
+ // `env CI=1 npm test`, `timeout 600 npm test`, `nice -n 10 jest`: the command they wrap.
130
+ else if (["env", "time", "nohup", "exec"].includes(first)) words = words.slice(1);
131
+ // `nodii-dev heavy run -- CMD`: the queue runs CMD.
132
+ else if (/^nodii-dev(?:\.js)?$/.test(first) && words[1] === "heavy" && words[2] === "run") words = words.slice(words.includes("--") ? words.indexOf("--") + 1 : 3);
133
+ else if (first === "timeout") { words = words.slice(1); while (words[0]?.startsWith("-")) words = words.slice(1); words = words.slice(1); }
134
+ else if (first === "nice") { words = words.slice(1); if (words[0] === "-n") words = words.slice(2); }
119
135
  else break;
120
136
  while (words[0]?.startsWith("-")) words = words.slice(1);
121
137
  }
122
138
  const [tool, ...args] = words;
123
139
  const name = (tool ?? "").split("/").pop();
124
- // Operands: not a flag, and not the value of one (`--timeout 30000`, `--config ./jest.config.mjs`).
125
- const operands = args.filter((word, i) => !word.startsWith("-") && !(i > 0 && (VALUE_FLAGS.has(args[i - 1]) || /^\d+$/.test(word))));
140
+ // A package manager's `-r` is --recursive, not node's --require: it takes no value.
141
+ const operands = operandsOf(args, { pm: ["npm", "pnpm", "yarn", "bun"].includes(name) });
142
+ // Paths that select something narrower than the whole tree.
143
+ const narrow = (list) => list.filter((word) => !broadPath(word));
126
144
  if (["npm", "pnpm", "yarn", "bun"].includes(name)) {
127
- const [sub, script] = operands;
128
- if (["run", "run-script"].includes(sub) && scripts.has(script) && operands.length === 2) return true;
129
- if (sub === "test" && name === "bun") { if (operands.length === 1) return true; continue; }
130
- if (scripts.has(sub) && operands.length === 1) return true;
145
+ // `yarn workspace web test`: the workspace's own whole suite.
146
+ const [sub, script] = name === "yarn" && operands[0] === "workspace" ? operands.slice(2) : operands;
147
+ const count = name === "yarn" && operands[0] === "workspace" ? operands.length - 2 : operands.length;
148
+ if (["run", "run-script"].includes(sub) && scripts.has(script) && count === 2) return true;
149
+ if (sub === "test" && name === "bun") { if (narrow(operands.slice(1)).length === 0) return true; continue; }
150
+ if (scripts.has(sub) && count === 1) return true;
131
151
  }
132
- if (["vitest", "jest"].includes(name) && operands.filter((word) => word !== "run").length === 0) return true;
152
+ if (name === "make" && operands.some((target) => scripts.has(target))) return true;
153
+ if (name === "turbo" && scripts.has(operands[0] === "run" ? operands[1] : operands[0])) return true;
154
+ if (["vitest", "jest"].includes(name) && !args.some((word) => CHANGED_FLAGS.has(word.split("=")[0])) && narrow(operands.filter((word) => !["run", "watch"].includes(word))).length === 0) return true;
155
+ if (name === "node" && args.includes("--test") && narrow(operands).every((word) => directory(word) && broadPath(`${word}/*`))) return true;
156
+ if (name === "playwright" && operands[0] === "test" && narrow(operands.slice(1)).length === 0) return true;
157
+ if (name === "pytest" && narrow(operands).length === 0) return true;
158
+ if (name === "go" && operands[0] === "test" && operands.slice(1).some((word) => word === "./..." || word === "...")) return true;
133
159
  }
134
160
  return false;
135
161
  }
136
162
 
163
+ /**
164
+ * The simple commands of a shell line: split on `&&`, `||`, `;` and `|` outside quotes, so
165
+ * `sh -c 'a && b' && sh -c 'npm test'` is two commands, each with its own script.
166
+ */
167
+ function shellCommands(text) {
168
+ const parts = [];
169
+ let current = "";
170
+ let quote = null;
171
+ for (let i = 0; i < text.length; i += 1) {
172
+ const char = text[i];
173
+ if (quote) { if (char === quote) quote = null; current += char; continue; }
174
+ if (char === "'" || char === '"') { quote = char; current += char; continue; }
175
+ const two = text.slice(i, i + 2);
176
+ if (two === "&&" || two === "||") { parts.push(current); current = ""; i += 1; continue; }
177
+ // A lone `|` is a pipe and a lone `&` runs in the background; `>&`, `&>` and `2>&1` stay with the
178
+ // command they redirect. A newline and a subshell's parentheses end a command too.
179
+ if (char === ";" || char === "\n" || char === "(" || char === ")" || (char === "|" && text[i - 1] !== ">") || (char === "&" && text[i - 1] !== ">" && text[i + 1] !== ">")) { parts.push(current); current = ""; continue; }
180
+ current += char;
181
+ }
182
+ parts.push(current);
183
+ return parts.map((part) => part.trim()).filter(Boolean);
184
+ }
185
+ // jest's and vitest's own changed-files modes already run only the tests a change reaches.
186
+ const CHANGED_FLAGS = new Set(["--onlyChanged", "-o", "--changedSince", "--findRelatedTests", "--changed", "--related"]);
187
+ // `sh -c 'npm test'`, `bash -lc "…"`: the script the shell runs, or null.
188
+ const shellScript = (text) => text.match(/^(?:\S*\/)?(?:ba|z|da)?sh\s+-[a-z]*c[a-z]*\s+(['"])([\s\S]*)\1$/)?.[2] ?? null;
189
+ // A package manager's own flags that take a value: the workspace, filter or directory it runs in.
190
+ const SCOPE_FLAGS = new Set(["--workspace", "-w", "--filter", "-F", "--dir", "-C", "--prefix", "--cwd"]);
191
+ // jest's --selectProjects takes every word after it, up to the next flag.
192
+ const VARIADIC_FLAGS = new Set(["--selectProjects"]);
193
+ /** Operands: not a flag, and not the value of one (`--timeout 30000`, `--config ./jest.config.mjs`, `--filter web`). */
194
+ function operandsOf(args, { pm = false } = {}) {
195
+ const operands = [];
196
+ let variadic = false;
197
+ for (const [i, word] of args.entries()) {
198
+ if (word.startsWith("-")) { variadic = VARIADIC_FLAGS.has(word); continue; }
199
+ // A path ends a project list: `--selectProjects web src/a.test.ts` names one file of web.
200
+ if (variadic && !(word.includes("/") || /\.[A-Za-z0-9]+$/.test(word))) continue;
201
+ variadic = false;
202
+ const previous = args[i - 1];
203
+ if (i > 0 && ((VALUE_FLAGS.has(previous) && !(pm && previous === "-r")) || SCOPE_FLAGS.has(previous) || /^\d+$/.test(word))) continue;
204
+ operands.push(word);
205
+ }
206
+ return operands;
207
+ }
208
+ // The top-level directories a repository keeps its tests or sources in: one of them alone is the whole tree.
209
+ const TEST_ROOTS = new Set(["src", "test", "tests", "__tests__", "spec", "specs", "e2e", "lib", "app", "apps", "packages"]);
210
+ // `.`, a top-level test root (`tests`, `src/`), or a glob whose fixed part is at most one directory
211
+ // (`test/*.test.js`, `**/*.spec.ts`): the whole tree. Any other bare word is a path or a name filter.
212
+ const broadPath = (word) => {
213
+ if (word === "." || word === "./" || TEST_ROOTS.has(word.replace(/^\.\//, "").replace(/\/+$/, ""))) return true;
214
+ if (!/[*?[{]/.test(word)) return false;
215
+ return word.split(/[*?[{]/)[0].split("/").filter((segment) => segment && segment !== ".").length <= 1;
216
+ };
217
+ // A word with no file extension, as `node --test test/` names a directory.
218
+ const directory = (word) => !/\.[A-Za-z0-9]+$/.test(word.replace(/\/+$/, ""));
219
+
137
220
  /** The content a receipt and a review cover: the diff itself, so uncommitted changes count too. */
138
221
  export const diffDigest = (text) => createHash("sha256").update(text).digest("hex");
139
222
 
@@ -143,18 +226,20 @@ export const diffDigest = (text) => createHash("sha256").update(text).digest("he
143
226
  * writes the receipt; without --gate only a receipt for this head, base and
144
227
  * diff counts. Returns the diff the receipt covers, which is the one reviewed.
145
228
  */
146
- export async function gatesReceipt(commands, { cwd, current, store, diff, run = runGate, now = () => new Date().toISOString() }) {
229
+ export async function gatesReceipt(commands, { cwd, current, store, diff, run = runGate, now = () => new Date().toISOString(), fullSuite = false }) {
147
230
  const changed = await diff(cwd);
148
231
  const digest = diffDigest(changed.text);
149
232
  if (commands.length) {
233
+ const runs = [];
150
234
  for (const command of commands) {
151
235
  const { code, tail } = await run(command, cwd);
236
+ runs.push({ command, exitCode: code });
152
237
  if (code !== 0)
153
238
  throw new CliError("GATES_NOT_GREEN", `Gate \`${command}\` exited ${code}; nothing was reviewed or recorded. Make it green and rerun lane check.${tail ? `\n${tail.trimEnd().split("\n").slice(-20).join("\n")}` : ""}`, 1, { command, exitCode: code });
154
239
  }
155
240
  if (diffDigest((await diff(cwd)).text) !== digest)
156
241
  throw new CliError("GATES_CHANGED_WORKTREE", "A gate changed the worktree, so the gates before it did not run on this content; nothing was reviewed or recorded. Keep or commit the change and rerun lane check.", 1);
157
- await store.write(GATES_RECEIPT, { commit: current.commit, base: current.base, diff: digest, commands, at: now() });
242
+ await store.write(GATES_RECEIPT, { commit: current.commit, base: current.base, diff: digest, commands, runs, fullSuite, at: now() });
158
243
  return changed;
159
244
  }
160
245
  const receipt = await store.read(GATES_RECEIPT);
@@ -163,6 +248,18 @@ export async function gatesReceipt(commands, { cwd, current, store, diff, run =
163
248
  return changed;
164
249
  }
165
250
 
251
+ /**
252
+ * hub-485: the gates receipt as Dev's review body carries it (`gates`), from the receipt stored for this
253
+ * head and base. Dev's object is strict and Dev classifies each command itself, so it carries only what
254
+ * Dev reads: base, the diff digest, and each run's command, exit code and commit. A receipt written
255
+ * before hub-485 has commands only, and each of them passed, or it was never written.
256
+ */
257
+ export function reviewGates(receipt) {
258
+ if (!receipt || !Array.isArray(receipt.runs ?? receipt.commands)) return null;
259
+ const runs = receipt.runs ?? receipt.commands.map((command) => ({ command, exitCode: 0 }));
260
+ return { base: receipt.base, diff: receipt.diff, runs: runs.map(({ command, exitCode }) => ({ command, exitCode, commit: receipt.commit })) };
261
+ }
262
+
166
263
  /**
167
264
  * A-037: the repo's generated-artifact prefixes, as Dev serves them on its
168
265
  * harness definition (`generatedPaths`, NODII-DEV-CLI-23). Dev is the only
@@ -545,12 +642,13 @@ async function inBatches(items, size, work) {
545
642
  * gather over the changed paths, each with its full text. Any gap is an
546
643
  * error: a partial set is never reviewed.
547
644
  */
548
- export async function ruleClauses(ref, { request, freeze, paths, deltaGather, agentPicker }) {
645
+ export async function ruleClauses(ref, { request, freeze, paths, deltaGather, agentPicker, gatherPicker }) {
549
646
  const mapped = [...(freeze?.clauseMap?.clauses ?? []), ...(freeze?.pinnedClauses ?? [])].map((x) => x.clauseId);
550
647
  if (!freeze?.clauseMap) throw new ReviewerError(UNAVAILABLE, `${ref} has no Clause map: its Freeze was never written by Gather. Run nodii-dev lane gather ${ref} first.`);
551
648
  if (paths.length > 5000) throw new ReviewerError(UNAVAILABLE, `the diff touches ${paths.length} paths; a Delta gather takes at most 5,000`);
552
649
  let delta;
553
- try { delta = await deltaGather(ref, paths); }
650
+ // CLI-143: an explicit agent pick requests the shortlist without warming a local model.
651
+ try { delta = await deltaGather(ref, paths, gatherPicker === "agent" ? { picker: "agent" } : undefined); }
554
652
  catch (error) { throw new ReviewerError(UNAVAILABLE, `the Delta gather over the changed paths failed (${error?.code ?? "ERROR"}: ${error?.message ?? error})`); }
555
653
  let data = delta?.payload?.data;
556
654
  // hub-58: no usable local picker on this Mac, so the lane's own runtime picks
@@ -558,7 +656,7 @@ export async function ruleClauses(ref, { request, freeze, paths, deltaGather, ag
558
656
  if (data?.recorded === false && data.shortlistId && data.triggers?.length && agentPicker) {
559
657
  let documents;
560
658
  try { documents = await agentPicker({ objective: data.objective, files: paths, triggers: data.triggers }); }
561
- catch (error) { throw new ReviewerError(UNAVAILABLE, `the local picker fell back (${data.fallback ?? "no local pick"}) and the agent pick failed (${error?.outcome ?? error?.code ?? "ERROR"}: ${error?.message ?? error})`); }
659
+ catch (error) { throw new ReviewerError(UNAVAILABLE, `${gatherPicker === "agent" ? "agent-only gather was requested" : `the local picker fell back (${data.fallback ?? "no local pick"})`} and the agent pick failed (${error?.outcome ?? error?.code ?? "ERROR"}: ${error?.message ?? error})`); }
562
660
  try { delta = await deltaGather(ref, paths, { shortlist: data.shortlistId, documents }); }
563
661
  catch (error) { throw new ReviewerError(UNAVAILABLE, `recording the agent's Delta gather pick failed (${error?.code ?? "ERROR"}: ${error?.message ?? error})`); }
564
662
  data = delta?.payload?.data;
@@ -975,17 +1073,22 @@ const errorCheck = (check, error, iterationCount, inputs) => ({ check, outcome:
975
1073
  * caller saves the round (saveLoop) once it is kept: still looping, or
976
1074
  * recorded; a run that records nothing leaves the loop where it was.
977
1075
  */
978
- export async function runLaneCheck(ref, flags, { request, lane, freeze, current, cwd, store, diff, deltaGather, catalog, designCheck, gate, reviewer = runReviewer, picker = pickByAgent, now, exceptions = exceptionFiles, templates = codeConnectUnits, fullScript = "test" }) {
1076
+ export async function runLaneCheck(ref, flags, { request, lane, freeze, current, cwd, store, diff, deltaGather, catalog, designCheck, gate, reviewer = runReviewer, picker = pickByAgent, now, exceptions = exceptionFiles, templates = codeConnectUnits, fullScript = "test", laneAgent = false }) {
1077
+ if (flags.picker !== undefined && flags.picker !== "agent")
1078
+ throw new CliError("USAGE", "--picker accepts only agent; omit it to use the local picker first.", 2);
979
1079
  const critical = flags.critical === true;
980
1080
  const maxIterations = flags["max-iterations"] === undefined ? MAX_ITERATIONS : Number(flags["max-iterations"]);
981
1081
  if (!Number.isInteger(maxIterations) || maxIterations < 1 || maxIterations > 100)
982
1082
  throw new CliError("USAGE", "--max-iterations needs a whole number from 1 to 100.", 2);
983
1083
  const gates = [flags.gate ?? []].flat();
984
1084
  if (gates.some((x) => typeof x !== "string" || !x.trim())) throw new CliError("USAGE", "--gate needs a command, e.g. --gate 'nodii-dev test affected --run'.", 2);
1085
+ // hub-485: the operator's hard rule (15 Nov): every lane runs only the tests its change reaches.
1086
+ if (flags["full-suite"] === true && laneAgent)
1087
+ throw new CliError("FULL_SUITE_LANE_REFUSED", `${ref}: a lane runs only the tests its change reaches, so --full-suite is refused from a lane's config (MW2-20; hub-485). Use --gate 'nodii-dev test affected --run' or name the test files. A whole suite runs in the scheduled CI (MW3-15) and the release gate; staff, a steward or the coordinator runs it when a release or the test infrastructure needs it.`, 2);
985
1088
  const whole = flags["full-suite"] === true ? [] : gates.filter((command) => fullSuiteGate(command, fullScript));
986
1089
  if (whole.length)
987
1090
  throw new CliError("GATE_FULL_SUITE", `Gate ${whole.map((command) => `\`${command}\``).join(", ")} runs the whole test suite. A lane runs only the tests its change reaches (MW2-20; hub-401): use --gate 'nodii-dev test affected --run', which also sizes the slot to the change. The full suite runs in the twice-daily CI and the release gate; pass --full-suite only when the change needs it (a release, or test infrastructure itself).`, 2, { gates: whole });
988
- const changed = await gatesReceipt(gates, { cwd, current, store, diff, run: gate, ...(now ? { now } : {}) });
1091
+ const changed = await gatesReceipt(gates, { cwd, current, store, diff, run: gate, fullSuite: flags["full-suite"] === true, ...(now ? { now } : {}) });
989
1092
  if (!changed.text.trim()) throw new CliError("LANE_DIFF_EMPTY", `${ref}: this worktree has no change against origin/main, so there is nothing to review.`, 1);
990
1093
  const runtime = lane.launch?.runtime === "codex" ? "codex" : "claude";
991
1094
  const runner = { runtime, model: lane.launch?.model, profile: lane.launch?.profile };
@@ -1011,7 +1114,7 @@ export async function runLaneCheck(ref, flags, { request, lane, freeze, current,
1011
1114
  let gathered = null;
1012
1115
  try {
1013
1116
  if (tooLarge) throw tooLarge;
1014
- gathered = await ruleClauses(ref, { request, freeze, paths: changed.paths, deltaGather, agentPicker: (input) => picker({ ...runner, ...input }) });
1117
+ gathered = await ruleClauses(ref, { request, freeze, paths: changed.paths, deltaGather, gatherPicker: flags.picker, agentPicker: (input) => picker({ ...runner, ...input }) });
1015
1118
  } catch (error) {
1016
1119
  if (!(error instanceof ReviewerError)) throw error;
1017
1120
  rules = errorCheck("rules", error, firstRound("rules"), { clauseIds: [], deltaGatherId: null, clauseMapGatherId: freeze?.clauseMap?.gatherId ?? null });
package/dist/surface.js CHANGED
@@ -32,7 +32,7 @@ import { CliError, VERSION, devRequest, readConfig } from "./core.js";
32
32
  import { createRenderer } from "./vendor/render-templates.mjs";
33
33
 
34
34
  /** Bumped whenever the emitted code changes shape for the same inputs. */
35
- export const GENERATOR_FORMAT = 17;
35
+ export const GENERATOR_FORMAT = 18;
36
36
  export const TREE_DIR = "docs/figma-ux-ds/figma/surface-trees";
37
37
  export const GENERATED_SUFFIX = ".surface.generated.tsx";
38
38
  /** Where every generated product page lives, as a git glob (NODII-DEV-CLI-77). */
@@ -840,6 +840,18 @@ function mark(ctx, scope, name, layer = ctx.layer) {
840
840
  return `__s${scopeIndex(ctx.scopes, scopeKey(scope, layer))}_${name}`;
841
841
  }
842
842
 
843
+ /**
844
+ * A prop the generator lifts that its DS component leaves optional, so the page
845
+ * may pass nothing: a tab's count (none drawn), a KPI's tone (neutral, or no
846
+ * dot) (hub-477). Marked as `mark` does, and counted optional unless a template
847
+ * that draws the same prop requires it.
848
+ */
849
+ function optionalMark(ctx, scope, name, layer = ctx.layer) {
850
+ const token = mark(ctx, scope, name, layer);
851
+ ctx.optionals?.optional.add(token);
852
+ return token;
853
+ }
854
+
843
855
  /**
844
856
  * Where a node sits in its view, the same in every view that draws it: its
845
857
  * layer names from the view's page down, a name its parent holds twice
@@ -1006,7 +1018,8 @@ function liftRecordData(code, node, ctx, path, scope = scopeName(node)) {
1006
1018
  let next = attrs;
1007
1019
  for (const attr of METRIC_VALUES) {
1008
1020
  const value = new RegExp(String.raw`\b${attr}=${LITERAL}`).exec(next);
1009
- if (value) next = next.replace(value[0], `${attr}={${lift(at, attr)}}`);
1021
+ // A tone the page leaves out is the component's own default (neutral, or no dot; hub-477).
1022
+ if (value) next = next.replace(value[0], `${attr}={${TONE_ATTR.has(attr) ? (lifted.push(attr), optionalMark(ctx, at, attr)) : lift(at, attr)}}`);
1010
1023
  }
1011
1024
  if (tag !== "MetricFilterCard") return next;
1012
1025
  const selected = `selected={${lift(at, "selected")}}`;
@@ -1269,11 +1282,7 @@ function handlerLabel(tag, attrs, after, node) {
1269
1282
  const UNNAMED_FRAME = /^(?:frame|group|auto ?layout|rectangle|container|slot)(?: \d+)?$/i;
1270
1283
  function handlerScope(node, ctx, path, inner, label, at) {
1271
1284
  const chain = ctx.chain ?? [];
1272
- const frames = [...chain.slice(1)].reverse().filter((c) => c.type !== "SLOT" && !c.instance && /[A-Za-z]/.test(c.name ?? ""));
1273
- // A frame named as the Surfaces name a place ("Row · Email domain allowlist") is that place.
1274
- const place = frames.map((c) => /\s·\s*(.*[A-Za-z].*)$/.exec(c.name)?.[1]).find(Boolean);
1275
- const named = frames.find((c) => !UNNAMED_FRAME.test(c.name.trim()))?.name;
1276
- const scope = inner ?? camelName(place ?? sectionHeading(node, chain) ?? titleBefore(node, chain) ?? named ?? "page");
1285
+ const scope = inner ?? placeOf(node, ctx);
1277
1286
  const name = `on${cap(label)}Click`;
1278
1287
  if (!ctx.handlers || !ctx.scopes) return { scope, name };
1279
1288
  const key = `${scope}|${name}`;
@@ -1284,6 +1293,22 @@ function handlerScope(node, ctx, path, inner, label, at) {
1284
1293
  return { scope, name: n ? `on${cap(label)}${n + 1}Click` : name };
1285
1294
  }
1286
1295
 
1296
+ /**
1297
+ * Where a part sits, as a name: the place its frame is named for ("Row · Email
1298
+ * domain allowlist"), else the heading of its section, else the title of the
1299
+ * part before it (a step's Section), else its nearest named frame (a Toolbar),
1300
+ * else the page. A button's handler and an unlabelled control are named by it.
1301
+ */
1302
+ function placeOf(node, ctx, { figures = true } = {}) {
1303
+ const chain = ctx.chain ?? [];
1304
+ const frames = [...chain.slice(1)].reverse().filter((c) => c.type !== "SLOT" && !c.instance && /[A-Za-z]/.test(c.name ?? ""));
1305
+ const place = frames.map((c) => /\s·\s*(.*[A-Za-z].*)$/.exec(c.name)?.[1]).find(Boolean);
1306
+ const named = frames.find((c) => !UNNAMED_FRAME.test(c.name.trim()))?.name;
1307
+ const text = place ?? sectionHeading(node, chain) ?? titleBefore(node, chain) ?? named ?? "page";
1308
+ // A control's place leaves out a count Figma drew ("Replies 7" → replies; hub-481).
1309
+ return figures ? camelName(text) : nameOf(text, text);
1310
+ }
1311
+
1287
1312
  /**
1288
1313
  * The title of the nearest DS part before `target` that has one (a step's
1289
1314
  * Section, in its "Card · Claim" frame), looking up its frames.
@@ -1366,8 +1391,67 @@ function textNextTo(node, ctx) {
1366
1391
  /** The form controls the page owns: a value it passes and a change it hears (NODII-DEV-CLI-82, -83). */
1367
1392
  const FIELD_CONTROLS = { Input: "onChange", Textarea: "onChange", SelectField: "onValueChange", RadioGroup: "onValueChange" };
1368
1393
 
1369
- /** The form controls whose template may wire them with generic names, and the change each hears (hub-481). */
1370
- const NAMED_CHANGE = { ...FIELD_CONTROLS, MultiSelect: "onValueChange", DateTimePicker: "onChange", DatePicker: "onValueChange", DateRangePicker: "onChange" };
1394
+ /**
1395
+ * The form controls whose template wires them with its own generic names
1396
+ * (`onChange={onChange}`, `onValueChange={setView}`, `onChange={setAmountMinor}`):
1397
+ * the change each hears, the attribute its value takes, the word its value is
1398
+ * named by (a field's `value`; a view switch's `view`, a page size's `pageSize`,
1399
+ * an amount's `amountMinor`), whether a change is named with that word too
1400
+ * (`onPayPeriodPageSizeChange`), and whether the field names it (else its
1401
+ * place: a view switch and a page size sit by the list they change) (hub-481).
1402
+ */
1403
+ const fieldControl = (change, value = "value", word = "value") => ({ change, value, word, byField: true, withWord: false });
1404
+ const placedControl = (word) => ({ change: "onValueChange", value: "value", word, byField: false, withWord: true });
1405
+ const NAMED_CHANGE = {
1406
+ ...Object.fromEntries(Object.entries(FIELD_CONTROLS).map(([tag, change]) => [tag, fieldControl(change)])),
1407
+ MultiSelect: fieldControl("onValueChange"),
1408
+ DateTimePicker: fieldControl("onChange"),
1409
+ DatePicker: fieldControl("onValueChange"),
1410
+ DateRangePicker: fieldControl("onChange"),
1411
+ TimePicker: fieldControl("onValueChange"),
1412
+ CurrencyInput: fieldControl("onChange", "valueMinor", "amountMinor"),
1413
+ SegmentedControl: placedControl("view"),
1414
+ PageSizeSelect: placedControl("pageSize"),
1415
+ };
1416
+ /** The controls the page names from the field the Input family's own scope (fieldScope) already reads. */
1417
+ const INPUT_FAMILY = /^(?:Input|Textarea|SelectField)$/;
1418
+ /** A template's own value identifier, and its own setter or bare handler. */
1419
+ const GENERIC_VALUE = String.raw`\{(?:value|date|range|time|view|pageSize|amountMinor)\}`;
1420
+ const GENERIC_CHANGE = String.raw`\{(?:onChange|onValueChange|set[A-Z][A-Za-z0-9]*)\}`;
1421
+ /** Figma's sample value a template writes as a literal: text, a number, an object, a Date. */
1422
+ const SAMPLE_LITERAL = String.raw`"(?:[^"\\\n]|\\.)*"|\{-?\d+(?:\.\d+)?\}|\{Number\("(?:[^"\\\n]|\\.)*"\)\}|\{\{[^{}]*\}\}|\{new Date\([^()]*\)\}`;
1423
+ /** A name made of a date or time format ("dd/mm/yyyy" → ddMmYyyy): a placeholder, never a field. */
1424
+ const FORMAT_NAME = /^(?:dd|mm|yyyy|yy|hh|ss)(?:Dd|Mm|Yyyy|Yy|Hh|Ss)*$/;
1425
+ /** A name that starts with a verb a show flag, a setter or a handler is named by (hub-478). */
1426
+ const VERB_NAME = /^(?:show|set|on)(?:[A-Z]|$)/;
1427
+
1428
+ /**
1429
+ * The label a control is drawn with: its own label or title when its template
1430
+ * draws it and it is not a format, else the text just before it in its frame,
1431
+ * else the text just before its frame (a picker in its own sizing frame, under
1432
+ * "Effective from *"). Null when it has none.
1433
+ */
1434
+ function controlLabel(node, ctx, code) {
1435
+ const props = node.instance?.props ?? {};
1436
+ const own = [props.label, props.title].find((v) => typeof v === "string" && code.includes(JSON.stringify(v)) && nameText(v));
1437
+ if (own && !FORMAT_NAME.test(nameOf(own))) return nameOf(own);
1438
+ const words = (n) => {
1439
+ if (!n || n.visible === false || n.instance) return null;
1440
+ if (n.type === "TEXT") return nameText(n.text) && !RECORD_TEXT(n.text) ? n.text : null;
1441
+ for (const c of n.children ?? []) {
1442
+ const found = words(c);
1443
+ if (found) return found;
1444
+ }
1445
+ return null;
1446
+ };
1447
+ const before = (parent, target) => {
1448
+ const shown = (parent?.children ?? []).filter((c) => c.visible !== false);
1449
+ const at = shown.indexOf(target);
1450
+ return at > 0 ? words(shown[at - 1]) : null;
1451
+ };
1452
+ const text = before(ctx.parent, node) ?? (ctx.grand ? before(ctx.grand, ctx.parent) : null);
1453
+ return text ? nameOf(text) : null;
1454
+ }
1371
1455
 
1372
1456
  /**
1373
1457
  * A control the template half-controls (`defaultValue="chart"` beside
@@ -1429,14 +1513,32 @@ function fieldScope(node, ctx, code) {
1429
1513
  * apart by their place (resolveScopes) (hub-481).
1430
1514
  */
1431
1515
  function liftFieldControls(code, node, ctx, lift, scope) {
1516
+ const top = /^<([A-Za-z]+)/.exec(code.replace(/^<Field\b[^>]*>\s*/, ""))?.[1];
1432
1517
  code = rewriteTags(code, Object.keys(NAMED_CHANGE).join("|"), (attrs, tag) => {
1433
- const handler = NAMED_CHANGE[tag];
1434
- const change = new RegExp(String.raw`(^|\s)${handler}=\{(?:onChange|onValueChange|set(?:Value|Date|Range))\}`).exec(attrs);
1518
+ const { change: handler, value: valueAttr, word, byField, withWord } = NAMED_CHANGE[tag];
1519
+ const change = new RegExp(String.raw`(^|\s)${handler}=${GENERIC_CHANGE}`).exec(attrs);
1435
1520
  if (!change) return attrs;
1436
- const named = attrs.replace(change[0], `${change[1]}${handler}={${lift(scope, `on${cap(scope)}Change`)}}`);
1437
- const sample = String.raw`|"(?:[^"\\\n]|\\.)*"|\{\{[^{}]*\}\}|\{new Date\([^()]*\)\}`;
1438
- const value = new RegExp(String.raw`(^|\s)value=(?:\{(?:value|date|range)\}${/^Date/.test(tag) ? sample : ""})`).exec(named);
1439
- return value ? named.replace(value[0], `${value[1]}value={${lift(scope, `${scope}Value`)}}`) : named;
1521
+ // The Input family keeps the scope fieldScope gave it. A control another part's template draws
1522
+ // (a pager's page size) is that part's, as its button is (nameHandlers). Any other control is
1523
+ // named by its label, else (a field) the scope it was given unless that is a format or only
1524
+ // its set's name, else where it sits.
1525
+ // A label that reads as a verb ("Show") would name a show flag or a setter (resolveScopes), never a field.
1526
+ const beside = INPUT_FAMILY.test(tag) || tag !== top ? null : controlLabel(node, ctx, code);
1527
+ const label = INPUT_FAMILY.test(tag) || tag !== top ? scope : beside && !VERB_NAME.test(beside) ? beside : null;
1528
+ const unnamed = FORMAT_NAME.test(scope) || scope === camelName(node.instance?.set ?? "");
1529
+ const place = () => placeOf(node, ctx, { figures: false });
1530
+ const at = label ?? (byField && !unnamed ? scope : place());
1531
+ const valueName = word === "value" ? `${at}Value` : joinName(at, word);
1532
+ const changeName = `on${cap(withWord ? joinName(at, word) : at)}Change`;
1533
+ const value = `${valueAttr}={${lift(at, valueName)}}`;
1534
+ let next = attrs.replace(change[0], `${change[1]}${handler}={${lift(at, changeName)}}`);
1535
+ const sample = INPUT_FAMILY.test(tag) ? "" : `|${SAMPLE_LITERAL}`;
1536
+ const drawn = new RegExp(String.raw`(^|\s)(?:${valueAttr}=(?:${GENERIC_VALUE}${sample})|defaultValue=${LITERAL})`).exec(next);
1537
+ if (drawn) return next.replace(drawn[0], `${drawn[1]}${value}`);
1538
+ if (new RegExp(String.raw`(^|\s)${valueAttr}=`).test(next)) return next;
1539
+ // A control drawn empty (a Time Picker with no time) takes the page's value too.
1540
+ const sep = next.includes("\n") ? `\n${new RegExp(String.raw`\n(\s*)${handler}=`).exec(next)?.[1] ?? " "}` : " ";
1541
+ return next.replace(new RegExp(String.raw`(^|\s)${handler}=`), (m, sp) => `${sp}${value}${sep}${handler}=`);
1440
1542
  });
1441
1543
  // A field's placeholder is the page's too: in a Surface it is the value the frame shows
1442
1544
  // ("Last 30 days", "K*** M***", "Sep 2026"), and a search box's copy names the list
@@ -1463,6 +1565,7 @@ function liftFieldControls(code, node, ctx, lift, scope) {
1463
1565
  /** A metric card's values that are Figma's sample, never copy (NODII-DEV-CLI-84). */
1464
1566
  // statusTone and tone are the KPI's state ("Unresolved" warning or danger), never the sample's dot (hub-477).
1465
1567
  const METRIC_VALUES = ["value", "caption", "changeAmount", "period", "statusTone", "tone"];
1568
+ const TONE_ATTR = new Set(["statusTone", "tone"]);
1466
1569
 
1467
1570
  /**
1468
1571
  * Each opening tag of `names` (a regex alternation) in `code`, its attributes
@@ -1530,7 +1633,7 @@ function resolveScopes(views, scopes, layers = new Map()) {
1530
1633
  // A setter, a handler and a show flag keep their verb first (`onSaveClick`, `showSsoAdd`, hub-478).
1531
1634
  const scoped = (scope, name) => {
1532
1635
  const m = /^(set|on|show)([A-Z]\w*)$/.exec(name);
1533
- return m ? `${m[1]}${cap(scope)}${m[2]}` : `${scope}${cap(name)}`;
1636
+ return m ? `${m[1]}${cap(scope)}${m[2]}` : toneName(scope, name) ?? joinName(scope, name);
1534
1637
  };
1535
1638
  // A prefix that tells two layers apart, a word it shares with the name said once.
1536
1639
  const prefixed = (prefix, name) => {
@@ -1578,6 +1681,15 @@ function resolveScopes(views, scopes, layers = new Map()) {
1578
1681
  }
1579
1682
 
1580
1683
  /** `scope` then `name` in camelCase, a word they share at the join said once (`recordSwitcherScope` + `ScopeValue`). */
1684
+ /**
1685
+ * A KPI tone named by a stat whose label ends in its own status or state
1686
+ * ("Status", "Policy status", "Review state") says it once: `statusTone`,
1687
+ * `policyStatusTone`, `reviewStateTone`, never `reviewStateStatusTone` (hub-477).
1688
+ */
1689
+ function toneName(scope, name) {
1690
+ return name === "statusTone" && /^(?:status|state)$|[a-z0-9](?:Status|State)$/.test(scope) ? `${scope}Tone` : null;
1691
+ }
1692
+
1581
1693
  function joinName(scope, name) {
1582
1694
  const head = name[0].toUpperCase() + name.slice(1);
1583
1695
  const last = /[A-Z][a-z0-9]*$|^[a-z][a-z0-9]*$/.exec(scope)?.[0] ?? "";
@@ -2299,7 +2411,7 @@ function tabStrip(run, ctx) {
2299
2411
  if (counted[i]) trigger = trigger.replace(counted[i], `{${mark(ctx, strip, joinName(camelName(values[i]), "tabLabel"), null)}}`);
2300
2412
  // A tab's count badge counts the viewer's action items: the page's, named by its tab, never
2301
2413
  // Figma's sample (`actionableCount={5}`) or one count every tab shares; its floor ("99+") too (hub-477).
2302
- const own = (prop) => `${prop}={${mark(ctx, strip, joinName(camelName(values[i]), prop), null)}}`;
2414
+ const own = (prop) => `${prop}={${optionalMark(ctx, strip, joinName(camelName(values[i]), prop), null)}}`;
2303
2415
  trigger = trigger.replace(/(<TabsTrigger\b[\s\S]*?)\bactionableCount=\{(?:\d+|(?:__s\d+_)?actionableCount)\}/, (_, head) => `${head}${own("actionableCount")}`);
2304
2416
  trigger = trigger.replace(/(<TabsTrigger\b[\s\S]*?)\bcountIsFloor(?=\s|>)/, (_, head) => `${head}${own("countIsFloor")}`);
2305
2417
  return shownWhen(`(${visible}?.includes(${JSON.stringify(values[i])}) ?? true)`, indent(trigger, 3), 2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.150",
3
+ "version": "0.6.152",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {