@nodii/dev 0.6.179 → 0.6.180
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 +1 -1
- package/dist/coordinator-gather.js +2 -2
- package/dist/coordinator-watch.js +35 -11
- package/dist/core.js +1 -1
- package/dist/gather.js +2 -1
- 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 only through `lane resume --if-changed` (MW1-102): a lane whose blockers have not changed stays down, and does not use up the run's resumes. A down lane that is not blocked (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.
|
|
@@ -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,22 @@ 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
|
+
const ifChanged = lane.liveness === "blocked" && gated;
|
|
289
|
+
if (lane.liveness === "blocked" && !gated) {
|
|
285
290
|
const last = state.blockedResumedAt[lane.key] ?? 0;
|
|
286
291
|
if (ctx.now() - last < 60 * MIN) { skipped.push(`${lane.key} (blocked, resumed within the hour)`); continue; }
|
|
287
292
|
}
|
|
288
|
-
const why = await ctx.tryResume(lane.key, { priority: Boolean(laneDomain(lane.key, domains)) });
|
|
293
|
+
const why = await ctx.tryResume(lane.key, { priority: Boolean(laneDomain(lane.key, domains)), ifChanged });
|
|
289
294
|
if (why === "resumed") {
|
|
290
295
|
resumed.push(lane.key);
|
|
291
296
|
if (lane.liveness === "blocked") state.blockedResumedAt[lane.key] = ctx.now();
|
|
@@ -320,7 +325,7 @@ export async function figmaPatFromKeychain(execute) {
|
|
|
320
325
|
catch { return null; }
|
|
321
326
|
}
|
|
322
327
|
|
|
323
|
-
export function watchContext({ home = homedir(), request = devRequest, config = readConfig, execute = execFile, now = Date.now, sleep = delay, log, jobState = {}, os = platform() } = {}) {
|
|
328
|
+
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
329
|
let machine = null;
|
|
325
330
|
let processesCache = null;
|
|
326
331
|
let guardsCache = null;
|
|
@@ -330,26 +335,32 @@ export function watchContext({ home = homedir(), request = devRequest, config =
|
|
|
330
335
|
machineId: async () => (machine ??= await governorMachineId({}, { request, config })),
|
|
331
336
|
processes: async () => (processesCache ??= await laneProcesses()),
|
|
332
337
|
heavy: () => heavyQueue({ execute, os }),
|
|
333
|
-
guards: async () => (guardsCache ??= await
|
|
338
|
+
guards: async () => (guardsCache ??= await guardsFor()),
|
|
334
339
|
amend: async (key, rules, reason) => {
|
|
335
340
|
const { amendLaneCommand } = await import("./starting.js");
|
|
336
341
|
await amendLaneCommand(key, { rules, reason });
|
|
337
342
|
await log?.(`amend ${key}: ${reason}`);
|
|
338
343
|
},
|
|
339
|
-
tryResume: async (key, { priority }) => {
|
|
344
|
+
tryResume: async (key, { priority, ifChanged = false }) => {
|
|
340
345
|
const hold = await exists(holdPath(home, "keepalive"));
|
|
341
346
|
const verdict = resumeAllowed(await ctx.guards(), { priority, hold });
|
|
342
347
|
if (!verdict.ok) return `not resumed: ${verdict.reason}`;
|
|
343
|
-
const { laneCommand } = await import("./lanes.js");
|
|
344
348
|
// The lane's own account first; on an account refusal, the coordinator's
|
|
345
349
|
// allowed lane accounts in order (settings.keepaliveProfiles: the account
|
|
346
350
|
// roster is the operator's call, MW1-38.3, so it is configuration).
|
|
347
351
|
const settings = await readCoordinatorSettings(home);
|
|
348
|
-
const
|
|
352
|
+
const gate = ifChanged ? { "if-changed": true } : {};
|
|
353
|
+
const attempts = [{ ...gate }, ...(settings.keepaliveProfiles ?? []).map((p) => ({ ...gate, profile: p.profile, class: p.class ?? "short" }))];
|
|
349
354
|
let last = "LANE_RESUME_FAILED";
|
|
350
355
|
for (const flags of attempts) {
|
|
351
356
|
try {
|
|
352
|
-
await
|
|
357
|
+
const out = await resume(key, flags);
|
|
358
|
+
// MW1-102: the gate left the lane down (BLOCKERS_UNCHANGED, LANE_DEAD,
|
|
359
|
+
// LANDED_NOT_DONE). That is an answer, not an account refusal.
|
|
360
|
+
if (out?.payload?.data?.resumed === false) {
|
|
361
|
+
await log?.(`not resumed ${key}: ${out.payload.data.code}`);
|
|
362
|
+
return `not resumed (${out.payload.data.code})`;
|
|
363
|
+
}
|
|
353
364
|
guardsCache = null;
|
|
354
365
|
await log?.(`resumed ${key}${flags.profile ? ` on ${flags.profile}` : ""}`);
|
|
355
366
|
return "resumed";
|
|
@@ -437,7 +448,12 @@ async function pidAlive(pid) {
|
|
|
437
448
|
}
|
|
438
449
|
|
|
439
450
|
/** The daemon loop. One instance per machine; jobs run one at a time, each on its interval. */
|
|
440
|
-
|
|
451
|
+
/** The @nodii/dev version installed on disk now, which a long-running daemon may not be running. */
|
|
452
|
+
export async function installedPackageVersion(read = readFile) {
|
|
453
|
+
try { return JSON.parse(await read(new URL("../package.json", import.meta.url), "utf8")).version ?? null; } catch { return null; }
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export async function watchRun({ home = homedir(), tickMs = 30_000, sleep = delay, now = Date.now, run = runJob, forever = true, installed = installedPackageVersion } = {}) {
|
|
441
457
|
const prior = Number((await readFile(pidPath(home), "utf8").catch(() => "")).trim());
|
|
442
458
|
if (prior && prior !== process.pid && (await pidAlive(prior)))
|
|
443
459
|
throw new CliError("WATCH_ALREADY_RUNNING", `coordinator watch is already running (pid ${prior}).`, 1);
|
|
@@ -448,6 +464,14 @@ export async function watchRun({ home = homedir(), tickMs = 30_000, sleep = dela
|
|
|
448
464
|
process.once("SIGTERM", stop);
|
|
449
465
|
try {
|
|
450
466
|
do {
|
|
467
|
+
// NODII-DEV-CLI-191: a daemon keeps the code it started with. When a new
|
|
468
|
+
// @nodii/dev is installed it exits, and its supervisor (launchd KeepAlive,
|
|
469
|
+
// systemd Restart) starts it again on the new code.
|
|
470
|
+
const onDisk = await installed().catch(() => null);
|
|
471
|
+
if (onDisk && onDisk !== VERSION) {
|
|
472
|
+
await watchLog(`watch: @nodii/dev ${onDisk} is installed and this daemon runs ${VERSION}; exiting so it restarts on the new code`, { home });
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
451
475
|
const state = await readJson(statePath(home), { jobs: {} });
|
|
452
476
|
for (const job of Object.keys(JOBS)) {
|
|
453
477
|
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.180";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
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();
|