@nodii/dev 0.6.131 → 0.6.133
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 +28 -0
- package/dist/cdp.js +138 -0
- package/dist/chrome.js +359 -0
- package/dist/cli.js +44 -1
- package/dist/coordinator-board.js +490 -0
- package/dist/coordinator-watch.js +564 -0
- package/dist/core.js +1 -1
- package/dist/figma-publish.js +207 -0
- package/dist/governor.js +3 -1
- package/dist/surface.js +207 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -132,6 +132,28 @@ nodii-dev heavy status
|
|
|
132
132
|
- It can't be skipped. In a lane, the safety hook (`hook safety-pre`) refuses an unqueued heavy command and prints the same command with `nodii-dev heavy run --` in front of each heavy part. `lane check --gate` and `receipt write --run` queue every gate themselves, `lane check` runs each reviewer under a slot (its timeout starts once the slot is granted), and `lane closeout` pushes through the landing reserve.
|
|
133
133
|
- `[TOOL GAP hub-86]` MW5-19 places this helper as the `heavy-slot` util. It ships here until the util pipeline exists.
|
|
134
134
|
|
|
135
|
+
## The coordinator's board, watch and shared Chrome (hub-405)
|
|
136
|
+
|
|
137
|
+
The machine's coordinator runs these. The clauses that make them procedure are drafted in `docs/reports/2026-11-13-coordinator-watch-rules-draft.md` for the coordinator to upload. Until then the draft is not a rule (P-1.3).
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
nodii-dev coordinator board # print "What needs you" and "What's running" from Dev
|
|
141
|
+
nodii-dev coordinator board --write --sheet 6b # running -> docs/open/6b-status.md, waiting on you -> 6b.md (MW4-31)
|
|
142
|
+
nodii-dev coordinator watch install # launchd com.nodii.coordinator-watch (harness install does this on the coordinator)
|
|
143
|
+
nodii-dev coordinator watch status # each job: health, last run, result
|
|
144
|
+
nodii-dev coordinator watch once publish-watch # one job now, in the foreground
|
|
145
|
+
nodii-dev coordinator watch alerts [--all]
|
|
146
|
+
nodii-dev chrome start | status # the one shared Chrome, DevTools on :9333
|
|
147
|
+
nodii-dev chrome signin tech-two-systems [--open /app/hr] # tech-* only; signs out when done (MW3-40.2)
|
|
148
|
+
nodii-dev figma publish FILE --sets CS-1,CS-2 [--dry-run]
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
- **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".
|
|
152
|
+
- **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, `~/Library/Logs/nodii-dev/coordinator-watch.log`. 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.
|
|
153
|
+
- **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 `FIGMA_PAT` from the keychain (`security add-generic-password -s nodii-dev-figma-pat -a "$USER" -w`), never from the plist or a file.
|
|
154
|
+
- **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`.
|
|
155
|
+
- **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.
|
|
156
|
+
|
|
135
157
|
## Receipts
|
|
136
158
|
|
|
137
159
|
A gate that lets work move writes a signed receipt (STD-22, K04-27, S06-53 to S06-56). `lane check` and `lane review` write and attach a `review` receipt listing the `--gate` commands and the review checks, and stop if they cannot. A `test` receipt needs what those commands cannot see (scope, stack, auth posture), so it comes from `receipt write` or the stack tool's `test --receipt`. A receipt must name the lane it is attached to. Anything else uses:
|
|
@@ -966,6 +988,12 @@ product-page catalog names the Surface by its published component-set key
|
|
|
966
988
|
`surface generate --all --check` with a pinned `@nodii/dev`; `--all`
|
|
967
989
|
without `--fetch` covers the Surfaces that have a committed tree or a
|
|
968
990
|
generated file and lists the rest as not generated yet.
|
|
991
|
+
- **Generated pages with no catalog row.** The catalog is the one lookup
|
|
992
|
+
(MW8-17.1), so a committed `*.surface.generated.tsx` that no catalog row
|
|
993
|
+
names can't be regenerated or compared. `--all` names each one (`--json`:
|
|
994
|
+
`data.generatedWithoutCatalogRow`, narrowed by `--module`) and leaves the
|
|
995
|
+
exit code alone. Its component-set key answers `SURFACE_NOT_IN_CATALOG` with
|
|
996
|
+
the file's path.
|
|
969
997
|
- **Unpublished Surfaces.** `--all --fetch` skips a Surface whose component set
|
|
970
998
|
is not among its file's published sets, names it as not published (`--json`:
|
|
971
999
|
`data.unpublished`), and still generates and scores the rest. A Surface named
|
package/dist/cdp.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// A small Chrome DevTools Protocol client for the machine's shared Chrome
|
|
2
|
+
// (K02-16, MW3-39). It only ever works in tabs it opened itself and closes only
|
|
3
|
+
// those (K02-17): there is no call here that lists, navigates or closes another
|
|
4
|
+
// session's tab, and nothing that closes the browser.
|
|
5
|
+
import { CliError } from "./core.js";
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_CDP_PORT = 9333;
|
|
8
|
+
|
|
9
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
|
+
|
|
11
|
+
/** The browser's /json/version, or null when nothing answers on the port. */
|
|
12
|
+
export async function cdpVersion(port = DEFAULT_CDP_PORT, { fetchImpl = fetch, timeoutMs = 3000 } = {}) {
|
|
13
|
+
try {
|
|
14
|
+
const response = await fetchImpl(`http://127.0.0.1:${port}/json/version`, { signal: AbortSignal.timeout(timeoutMs) });
|
|
15
|
+
if (!response.ok) return null;
|
|
16
|
+
return await response.json();
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** How many page tabs are open (a count only: this client never touches them). */
|
|
23
|
+
export async function cdpPageCount(port = DEFAULT_CDP_PORT, { fetchImpl = fetch } = {}) {
|
|
24
|
+
try {
|
|
25
|
+
const response = await fetchImpl(`http://127.0.0.1:${port}/json/list`, { signal: AbortSignal.timeout(3000) });
|
|
26
|
+
const tabs = await response.json();
|
|
27
|
+
return Array.isArray(tabs) ? tabs.filter((tab) => tab.type === "page").length : null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Page tabs whose URL starts with an origin: read-only, so a sign-in can see another tab already holds the session. */
|
|
34
|
+
export async function cdpPagesOn(origin, port = DEFAULT_CDP_PORT, { fetchImpl = fetch } = {}) {
|
|
35
|
+
try {
|
|
36
|
+
const response = await fetchImpl(`http://127.0.0.1:${port}/json/list`, { signal: AbortSignal.timeout(3000) });
|
|
37
|
+
const tabs = await response.json();
|
|
38
|
+
return Array.isArray(tabs) ? tabs.filter((tab) => tab.type === "page" && String(tab.url).startsWith(origin)).length : 0;
|
|
39
|
+
} catch {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Connects to the browser endpoint. The returned session opens its own tabs;
|
|
46
|
+
* close() closes every tab it opened and then the socket, never the browser.
|
|
47
|
+
*/
|
|
48
|
+
export async function cdpConnect(port = DEFAULT_CDP_PORT, { fetchImpl = fetch, WebSocketImpl = globalThis.WebSocket, commandTimeoutMs = 60_000 } = {}) {
|
|
49
|
+
const version = await cdpVersion(port, { fetchImpl });
|
|
50
|
+
if (!version?.webSocketDebuggerUrl)
|
|
51
|
+
throw new CliError("CHROME_NOT_RUNNING", `Nothing answers on the shared Chrome's DevTools port ${port}. Run nodii-dev chrome start.`, 1);
|
|
52
|
+
if (!WebSocketImpl) throw new CliError("CHROME_CDP_UNAVAILABLE", "This runtime has no WebSocket; run nodii-dev on Node 22+ or Bun.", 1);
|
|
53
|
+
const ws = new WebSocketImpl(version.webSocketDebuggerUrl);
|
|
54
|
+
await new Promise((resolve, reject) => {
|
|
55
|
+
ws.addEventListener("open", resolve, { once: true });
|
|
56
|
+
ws.addEventListener("error", () => reject(new CliError("CHROME_CDP_UNAVAILABLE", `Could not open the DevTools socket on port ${port}.`, 1)), { once: true });
|
|
57
|
+
});
|
|
58
|
+
let id = 0;
|
|
59
|
+
const pending = new Map();
|
|
60
|
+
ws.addEventListener("message", (event) => {
|
|
61
|
+
let message;
|
|
62
|
+
try { message = JSON.parse(String(event.data)); } catch { return; }
|
|
63
|
+
if (message.id && pending.has(message.id)) {
|
|
64
|
+
const { resolve, reject, timer } = pending.get(message.id);
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
pending.delete(message.id);
|
|
67
|
+
if (message.error) reject(new CliError("CHROME_CDP_ERROR", message.error.message ?? "DevTools error", 1));
|
|
68
|
+
else resolve(message.result ?? {});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
const send = (method, params = {}, sessionId) =>
|
|
72
|
+
new Promise((resolve, reject) => {
|
|
73
|
+
const n = ++id;
|
|
74
|
+
const timer = setTimeout(() => {
|
|
75
|
+
pending.delete(n);
|
|
76
|
+
reject(new CliError("CHROME_CDP_TIMEOUT", `DevTools did not answer ${method} within ${Math.round(commandTimeoutMs / 1000)} s.`, 1));
|
|
77
|
+
}, commandTimeoutMs);
|
|
78
|
+
pending.set(n, { resolve, reject, timer });
|
|
79
|
+
ws.send(JSON.stringify({ id: n, method, params, ...(sessionId ? { sessionId } : {}) }));
|
|
80
|
+
});
|
|
81
|
+
const opened = new Set();
|
|
82
|
+
|
|
83
|
+
/** Opens a background tab of our own and attaches to it. */
|
|
84
|
+
async function openTab(url) {
|
|
85
|
+
const { targetId } = await send("Target.createTarget", { url, background: true });
|
|
86
|
+
opened.add(targetId);
|
|
87
|
+
const { sessionId } = await send("Target.attachToTarget", { targetId, flatten: true });
|
|
88
|
+
const evaluate = async (expression) => {
|
|
89
|
+
const result = await send("Runtime.evaluate", { expression, returnByValue: true, awaitPromise: true }, sessionId);
|
|
90
|
+
return result?.result?.value;
|
|
91
|
+
};
|
|
92
|
+
// Values reach the page as call arguments, never spliced into source, so a
|
|
93
|
+
// credential is never part of a logged expression.
|
|
94
|
+
const call = async (functionDeclaration, args = []) => {
|
|
95
|
+
const doc = await send("Runtime.evaluate", { expression: "document" }, sessionId);
|
|
96
|
+
const result = await send("Runtime.callFunctionOn", {
|
|
97
|
+
functionDeclaration,
|
|
98
|
+
objectId: doc.result.objectId,
|
|
99
|
+
arguments: args.map((value) => ({ value })),
|
|
100
|
+
returnByValue: true,
|
|
101
|
+
awaitPromise: true,
|
|
102
|
+
}, sessionId);
|
|
103
|
+
return result?.result?.value;
|
|
104
|
+
};
|
|
105
|
+
const waitFor = async (expression, seconds, { sleep = delay } = {}) => {
|
|
106
|
+
for (let i = 0; i < seconds; i++) {
|
|
107
|
+
if (await evaluate(expression).catch(() => false)) return true;
|
|
108
|
+
await sleep(1000);
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
};
|
|
112
|
+
const key = async (keyName, { modifiers = 0, code, keyCode } = {}) => {
|
|
113
|
+
for (const type of ["keyDown", "keyUp"])
|
|
114
|
+
await send("Input.dispatchKeyEvent", { type, key: keyName, code: code ?? keyName, modifiers, ...(keyCode ? { windowsVirtualKeyCode: keyCode } : {}) }, sessionId);
|
|
115
|
+
};
|
|
116
|
+
const close = async () => {
|
|
117
|
+
if (!opened.has(targetId)) return;
|
|
118
|
+
opened.delete(targetId);
|
|
119
|
+
await send("Target.closeTarget", { targetId }).catch(() => {});
|
|
120
|
+
};
|
|
121
|
+
return { targetId, sessionId, evaluate, call, waitFor, key, close, send: (method, params) => send(method, params, sessionId) };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async function withTab(url, fn) {
|
|
125
|
+
const tab = await openTab(url);
|
|
126
|
+
try { return await fn(tab); } finally { await tab.close(); }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async function close() {
|
|
130
|
+
for (const targetId of [...opened]) await send("Target.closeTarget", { targetId }).catch(() => {});
|
|
131
|
+
opened.clear();
|
|
132
|
+
for (const { reject, timer } of pending.values()) { clearTimeout(timer); reject(new CliError("CHROME_CDP_CLOSED", "The DevTools session closed.", 1)); }
|
|
133
|
+
pending.clear();
|
|
134
|
+
try { ws.close(); } catch {}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return { version, openTab, withTab, close };
|
|
138
|
+
}
|
package/dist/chrome.js
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
// nodii-dev chrome: the machine's one shared, signed-in Chrome (K02-16, MW3-39).
|
|
2
|
+
//
|
|
3
|
+
// chrome start [--profile DIR] [--port N] one profile, DevTools on a fixed port; idempotent
|
|
4
|
+
// chrome status is it up, which profile, how many tabs, who signed in
|
|
5
|
+
// chrome signin TENANT... [--open PATH] tech-* test tenants on dev only (MW3-40.2): signs in,
|
|
6
|
+
// opens PATH if given, then signs out and clears the origin
|
|
7
|
+
//
|
|
8
|
+
// The browser is started once and never closed by this tool. Every action here
|
|
9
|
+
// opens its own background tab and closes only that tab (K02-17). Sign-in
|
|
10
|
+
// credentials go from the test-login file straight into the page as call
|
|
11
|
+
// arguments: they are never printed, logged or written anywhere (MW3-40.2, S13).
|
|
12
|
+
import { execFile as execFileCallback, spawn } from "node:child_process";
|
|
13
|
+
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { dirname, join, resolve } from "node:path";
|
|
16
|
+
import { promisify } from "node:util";
|
|
17
|
+
import { CliError, devRequest, encode, readConfig } from "./core.js";
|
|
18
|
+
import { DEFAULT_CDP_PORT, cdpConnect, cdpPageCount, cdpPagesOn, cdpVersion } from "./cdp.js";
|
|
19
|
+
import { governorMachineId } from "./governor.js";
|
|
20
|
+
|
|
21
|
+
const execFile = promisify(execFileCallback);
|
|
22
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
23
|
+
|
|
24
|
+
export const chromeHome = (home = homedir()) => join(home, ".config", "nodii-dev", "chrome");
|
|
25
|
+
const settingsPath = (home) => join(chromeHome(home), "settings.json");
|
|
26
|
+
const signinStatePath = (home) => join(chromeHome(home), "signin.json");
|
|
27
|
+
export const TEST_LOGINS = (home = homedir()) => join(home, ".config", "nodii-resources", "test-tenant-logins.json");
|
|
28
|
+
export const CHROME_APP = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
|
|
29
|
+
export const DEV_TENANT_DOMAIN = "nucleus-cloud.in";
|
|
30
|
+
// MW3-40.2: dev tech-* test tenants only. Never Platform, a customer, UAT or Prod.
|
|
31
|
+
export const TECH_TENANT = /^tech-[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
32
|
+
// One attempt per tenant per hour: repeated failures can lock a test account.
|
|
33
|
+
export const SIGNIN_RETRY_MS = 60 * 60_000;
|
|
34
|
+
|
|
35
|
+
async function readJson(path, fallback) {
|
|
36
|
+
try { return JSON.parse(await readFile(path, "utf8")); }
|
|
37
|
+
catch (error) { if (error?.code === "ENOENT") return fallback; throw error; }
|
|
38
|
+
}
|
|
39
|
+
async function writeJson(path, value) {
|
|
40
|
+
await mkdir(dirname(path), { recursive: true, mode: 0o700 });
|
|
41
|
+
const tmp = `${path}.tmp-${process.pid}`;
|
|
42
|
+
await writeFile(tmp, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
|
|
43
|
+
await rename(tmp, path);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const readChromeSettings = (home = homedir()) => readJson(settingsPath(home), {});
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The DevTools port to connect to: the endpoint the machine's coordinator
|
|
50
|
+
* published on Dev's machine record (K02-16), else this machine's saved
|
|
51
|
+
* setting, else 9333.
|
|
52
|
+
*/
|
|
53
|
+
export async function sharedChromePort({ home = homedir(), request = devRequest, config = readConfig } = {}) {
|
|
54
|
+
try {
|
|
55
|
+
const machineId = await governorMachineId({}, { request, config });
|
|
56
|
+
const machine = (await request("GET", `/api/v1/machines/${encode(machineId)}`)).data;
|
|
57
|
+
const port = Number(String(machine?.hostFacts?.sharedChrome?.cdp ?? "").match(/^http:\/\/(?:127\.0\.0\.1|localhost):(\d+)\/?$/)?.[1]);
|
|
58
|
+
if (Number.isInteger(port)) return port;
|
|
59
|
+
} catch {}
|
|
60
|
+
return Number((await readChromeSettings(home)).port ?? DEFAULT_CDP_PORT);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The Chrome processes' command lines that carry a --user-data-dir (main and helpers). */
|
|
64
|
+
async function chromeCommandLines({ execute = execFile } = {}) {
|
|
65
|
+
try {
|
|
66
|
+
const { stdout } = await execute("ps", ["-axo", "pid=,command="], { maxBuffer: 32 * 1024 * 1024 });
|
|
67
|
+
return stdout.split("\n").filter((line) => /Google Chrome/.test(line) && /--user-data-dir=/.test(line));
|
|
68
|
+
} catch {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The profile directory of the Chrome that serves this DevTools port, read from its own command line. */
|
|
74
|
+
export function profileFromCommandLines(lines, port) {
|
|
75
|
+
for (const line of lines) {
|
|
76
|
+
if (!line.includes(`--remote-debugging-port=${port}`)) continue;
|
|
77
|
+
const match = line.match(/--user-data-dir=(.+?)(?= --|$)/);
|
|
78
|
+
if (match) return match[1].trim();
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Whether a Chrome already runs on a profile, with or without a DevTools port. */
|
|
84
|
+
export function profileInUse(lines, profile) {
|
|
85
|
+
return lines.some((line) => line.includes(`--user-data-dir=${profile}`) && !/--type=/.test(line));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Publishes the endpoint on Dev's machine record (K02-16: sessions connect at the
|
|
90
|
+
* endpoint the machine's coordinator publishes). Dev keeps host facts as one
|
|
91
|
+
* object, so the current facts go back with the endpoint merged in.
|
|
92
|
+
*/
|
|
93
|
+
export async function publishEndpoint(endpoint, { request = devRequest, config = readConfig } = {}) {
|
|
94
|
+
let machineId;
|
|
95
|
+
try { machineId = await governorMachineId({}, { request, config }); }
|
|
96
|
+
catch (error) { return { published: false, reason: error?.message ?? "this agent has no machine in Dev" }; }
|
|
97
|
+
const machine = (await request("GET", `/api/v1/machines/${encode(machineId)}`)).data;
|
|
98
|
+
if (machine?.hostFacts?.sharedChrome?.cdp === endpoint) return { published: true, unchanged: true, machine: machine.name };
|
|
99
|
+
try {
|
|
100
|
+
await request("POST", `/api/v1/machines/${encode(machineId)}/report`, {
|
|
101
|
+
hostFacts: { ...(machine.hostFacts ?? {}), sharedChrome: { cdp: endpoint, publishedAt: new Date().toISOString() } },
|
|
102
|
+
memoryFacts: machine.memoryFacts ?? {},
|
|
103
|
+
heavySlotTotal: machine.heavySlotTotal,
|
|
104
|
+
});
|
|
105
|
+
return { published: true, machine: machine.name };
|
|
106
|
+
} catch (error) {
|
|
107
|
+
// Only the machine's coordinator or staff may report; anyone else still gets a browser.
|
|
108
|
+
return { published: false, reason: `${error?.code ?? "MACHINE_REPORT_FAILED"}: ${error?.message ?? error}` };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function chromeStart(flags = {}, {
|
|
113
|
+
home = homedir(), execute = execFile, spawnImpl = spawn, version = cdpVersion, sleep = delay, publish = publishEndpoint, startTimeoutMs = 30_000,
|
|
114
|
+
} = {}) {
|
|
115
|
+
const saved = await readChromeSettings(home);
|
|
116
|
+
const port = Number(flags.port ?? saved.port ?? DEFAULT_CDP_PORT);
|
|
117
|
+
if (!Number.isInteger(port) || port < 1024 || port > 65535) throw new CliError("USAGE", "chrome start --port must be 1024..65535.", 2);
|
|
118
|
+
const lines = await chromeCommandLines({ execute });
|
|
119
|
+
const live = await version(port);
|
|
120
|
+
let profile;
|
|
121
|
+
let started = false;
|
|
122
|
+
if (live) {
|
|
123
|
+
// Idempotent: a Chrome already serves the port. Adopt it, and refuse only a
|
|
124
|
+
// --profile that names a different directory.
|
|
125
|
+
profile = profileFromCommandLines(lines, port) ?? saved.profile ?? null;
|
|
126
|
+
if (flags.profile && profile && resolve(flags.profile) !== profile)
|
|
127
|
+
throw new CliError("CHROME_OTHER_PROFILE", `Port ${port} is served by a Chrome on ${profile}, not ${resolve(flags.profile)}. There is one shared profile per machine (K02-16).`, 1);
|
|
128
|
+
} else {
|
|
129
|
+
profile = resolve(flags.profile ?? saved.profile ?? join(chromeHome(home), "profile"));
|
|
130
|
+
if (profileInUse(lines, profile))
|
|
131
|
+
throw new CliError("CHROME_PROFILE_IN_USE", `A Chrome already runs on ${profile} without DevTools on port ${port}. It was not started by nodii-dev chrome start; quit that window yourself, then run chrome start again.`, 1);
|
|
132
|
+
await mkdir(profile, { recursive: true, mode: 0o700 });
|
|
133
|
+
const child = spawnImpl(flags.chrome ?? saved.chrome ?? CHROME_APP, [
|
|
134
|
+
`--user-data-dir=${profile}`, `--remote-debugging-port=${port}`, "--no-first-run", "--no-default-browser-check",
|
|
135
|
+
], { detached: true, stdio: "ignore" });
|
|
136
|
+
child.unref?.();
|
|
137
|
+
const until = Date.now() + startTimeoutMs;
|
|
138
|
+
while (!(await version(port))) {
|
|
139
|
+
if (Date.now() > until) throw new CliError("CHROME_START_FAILED", `Chrome did not open DevTools on port ${port} within ${Math.round(startTimeoutMs / 1000)} s.`, 1);
|
|
140
|
+
await sleep(500);
|
|
141
|
+
}
|
|
142
|
+
started = true;
|
|
143
|
+
}
|
|
144
|
+
await writeJson(settingsPath(home), { ...saved, port, ...(profile ? { profile } : {}) });
|
|
145
|
+
const endpoint = `http://127.0.0.1:${port}`;
|
|
146
|
+
const published = flags["no-publish"] ? { published: false, reason: "--no-publish" } : await publish(endpoint).catch((error) => ({ published: false, reason: error?.message ?? String(error) }));
|
|
147
|
+
return { started, adopted: !started, port, endpoint, profile, published };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export async function chromeStatus({ home = homedir(), version = cdpVersion, pages = cdpPageCount } = {}) {
|
|
151
|
+
const saved = await readChromeSettings(home);
|
|
152
|
+
const port = Number(saved.port ?? DEFAULT_CDP_PORT);
|
|
153
|
+
const live = await version(port);
|
|
154
|
+
const signin = await readJson(signinStatePath(home), { tenants: {} });
|
|
155
|
+
return {
|
|
156
|
+
up: Boolean(live),
|
|
157
|
+
port,
|
|
158
|
+
endpoint: `http://127.0.0.1:${port}`,
|
|
159
|
+
profile: saved.profile ?? null,
|
|
160
|
+
browser: live?.Browser ?? null,
|
|
161
|
+
tabs: live ? await pages(port) : null,
|
|
162
|
+
tenants: Object.fromEntries(Object.entries(signin.tenants ?? {}).map(([tenant, t]) => [tenant, { result: t.result, at: t.at, ...(t.rested ? { rested: true } : {}) }])),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Refuses anything MW3-40.2 does not allow before a tab is opened or a credential read. */
|
|
167
|
+
export function assertTechTenant(tenant) {
|
|
168
|
+
if (!TECH_TENANT.test(tenant))
|
|
169
|
+
throw new CliError("CHROME_SIGNIN_REFUSED", `${tenant} is not a dev tech-* test tenant. Agents sign in only to tech-* tenants on dev (MW3-40.2): never Platform, a customer or partner tenant, UAT, Prod or the operator's account.`, 2);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** The test login for a tenant, refused unless it is that tenant's yopmail test identity (MW3-40.2). */
|
|
173
|
+
export function testLogin(logins, tenant) {
|
|
174
|
+
const cred = logins?.[tenant];
|
|
175
|
+
if (!cred?.email || !cred?.password) return null;
|
|
176
|
+
if (!/@yopmail\.com$/i.test(cred.email))
|
|
177
|
+
throw new CliError("CHROME_SIGNIN_REFUSED", `The test login on file for ${tenant} is not a yopmail test identity; agents never sign in as a real person (MW3-40.2).`, 2);
|
|
178
|
+
return cred;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const LOGIN_FILL = `function(e,p){const s=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'value').set;
|
|
182
|
+
const em=document.querySelector('input[type=email]'), pw=document.querySelector('input[type=password]');
|
|
183
|
+
if(!em||!pw) return false;
|
|
184
|
+
s.call(em,e); em.dispatchEvent(new Event('input',{bubbles:true}));
|
|
185
|
+
s.call(pw,p); pw.dispatchEvent(new Event('input',{bubbles:true}));
|
|
186
|
+
const b=[...document.querySelectorAll('button[type=submit],button')].find(x=>/sign in|log in|continue/i.test(x.textContent||''));
|
|
187
|
+
(b||pw.form?.querySelector('button'))?.click(); return true;}`;
|
|
188
|
+
const OTP_FILL = `function(c){const s=Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,'value').set;
|
|
189
|
+
const ins=[...document.querySelectorAll('input')].filter(i=>i.type!=='hidden');
|
|
190
|
+
if(ins.length===1){s.call(ins[0],c);ins[0].dispatchEvent(new Event('input',{bubbles:true}));}
|
|
191
|
+
else{ins.slice(0,6).forEach((i,k)=>{s.call(i,c[k]||'');i.dispatchEvent(new Event('input',{bubbles:true}));});}
|
|
192
|
+
const b=[...document.querySelectorAll('button')].find(x=>/verify|continue|sign in|submit/i.test(x.textContent||''));b?.click();return true;}`;
|
|
193
|
+
const YOPMAIL_CODE = "(()=>{const f=document.querySelector('#ifmail');const t=(f&&f.contentDocument&&f.contentDocument.body&&f.contentDocument.body.innerText)||'';const m=t.match(/\\b(\\d{6})\\b/);return m?m[1]:null})()";
|
|
194
|
+
|
|
195
|
+
/** The newest 6-digit code in a yopmail inbox, read in a tab of our own. */
|
|
196
|
+
async function readYopmailCode(cdp, box, { sleep }) {
|
|
197
|
+
return cdp.withTab(`https://yopmail.com/en/?login=${encodeURIComponent(box)}`, async (tab) => {
|
|
198
|
+
await sleep(6000);
|
|
199
|
+
return (await tab.evaluate(YOPMAIL_CODE)) ?? null;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// The app keeps its rotating refresh token in localStorage under this key
|
|
204
|
+
// (nodii-frontend src/lib/auth/session-token.ts) and revokes it at /api/v1/auth/logout.
|
|
205
|
+
const SIGN_OUT = `async function(){const k='nodii-session-refresh:v2';let revoked=false;
|
|
206
|
+
try{const t=localStorage.getItem(k);if(t){const r=await fetch('/api/v1/auth/logout',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({refreshToken:t})});revoked=r.ok;}}catch(e){}
|
|
207
|
+
try{localStorage.removeItem(k);localStorage.removeItem('nodii-session-refresh:v1');sessionStorage.clear();}catch(e){}
|
|
208
|
+
return revoked;}`;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Signs the tab out and leaves nothing of the session in the shared profile
|
|
212
|
+
* (MW3-40.2: no password or token kept beyond the session; sign out when done):
|
|
213
|
+
* the app's own logout, then this origin's storage and cookies cleared.
|
|
214
|
+
*/
|
|
215
|
+
export async function signOutTab(tab, origin) {
|
|
216
|
+
const revoked = await tab.call(SIGN_OUT, []).catch(() => false);
|
|
217
|
+
await tab.send("Storage.clearDataForOrigin", { origin, storageTypes: "local_storage,session_storage,cookies,indexeddb" }).catch(() => {});
|
|
218
|
+
return revoked ? "signed out" : "signed out (local session cleared; server revoke not confirmed)";
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* One tenant's sign-in in a background tab of our own: sign in, optionally
|
|
223
|
+
* open one page while signed in, then sign out (MW3-40.2). The result never
|
|
224
|
+
* contains the email, password or code.
|
|
225
|
+
*/
|
|
226
|
+
export async function signInTenant(cdp, tenant, cred, { sleep = delay, otpAttempts = 6, open } = {}) {
|
|
227
|
+
const host = `${tenant}.${DEV_TENANT_DOMAIN}`;
|
|
228
|
+
const origin = `https://${host}`;
|
|
229
|
+
return cdp.withTab(`${origin}/app`, async (tab) => {
|
|
230
|
+
const outcome = await signInIn(tab, cdp, host, cred, { sleep, otpAttempts });
|
|
231
|
+
if (!outcome.ok) {
|
|
232
|
+
await signOutTab(tab, origin);
|
|
233
|
+
return outcome;
|
|
234
|
+
}
|
|
235
|
+
let opened = "";
|
|
236
|
+
if (open) {
|
|
237
|
+
await tab.send("Page.navigate", { url: `${origin}${open.startsWith("/") ? open : `/${open}`}` }).catch(() => {});
|
|
238
|
+
await sleep(6000);
|
|
239
|
+
const path = await tab.evaluate("location.pathname").catch(() => "?");
|
|
240
|
+
opened = String(path).startsWith("/auth/") ? `; ${open} sent it back to ${path}` : `; opened ${path}`;
|
|
241
|
+
}
|
|
242
|
+
const out = await signOutTab(tab, origin);
|
|
243
|
+
return { ...outcome, result: `${outcome.result}${opened}; ${out}` };
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function signInIn(tab, cdp, host, cred, { sleep, otpAttempts }) {
|
|
248
|
+
await sleep(4000);
|
|
249
|
+
const onLogin = await tab.waitFor("location.pathname.startsWith('/auth/login')", 8, { sleep });
|
|
250
|
+
if (!onLogin) return { ok: true, result: "signed in (session alive)" };
|
|
251
|
+
// Credentials go only to the tenant's own host (K02-22, MW3-40.2).
|
|
252
|
+
if ((await tab.evaluate("location.host")) !== host) return { ok: false, result: "sign-in page is not on the tenant's host; nothing typed" };
|
|
253
|
+
const ready = await tab.waitFor("!!document.querySelector('input[type=email]') && !!document.querySelector('input[type=password]')", 20, { sleep });
|
|
254
|
+
if (!ready) return { ok: false, result: "sign-in form not found" };
|
|
255
|
+
// The inbox's newest code before we ask for one, so an old code is never typed.
|
|
256
|
+
const box = cred.email.split("@")[0];
|
|
257
|
+
const before = await readYopmailCode(cdp, box, { sleep }).catch(() => null);
|
|
258
|
+
await tab.call(LOGIN_FILL, [cred.email, cred.password]);
|
|
259
|
+
const left = await tab.waitFor("!location.pathname.startsWith('/auth/login')", 30, { sleep });
|
|
260
|
+
if (!left) {
|
|
261
|
+
const err = await tab.evaluate("(document.querySelector('[role=alert]')?.textContent||'').slice(0,120)").catch(() => "");
|
|
262
|
+
return { ok: false, failed: true, result: `sign-in FAILED${err ? `: ${err}` : ""}` };
|
|
263
|
+
}
|
|
264
|
+
if (await tab.evaluate("location.pathname.startsWith('/auth/otp')")) {
|
|
265
|
+
let code = null;
|
|
266
|
+
for (let attempt = 0; attempt < otpAttempts && !code; attempt++) {
|
|
267
|
+
await sleep(attempt === 0 ? 8000 : 10_000);
|
|
268
|
+
const seen = await readYopmailCode(cdp, box, { sleep }).catch(() => null);
|
|
269
|
+
if (seen && seen !== before) code = seen;
|
|
270
|
+
}
|
|
271
|
+
if (!code) return { ok: false, result: "email OTP: no new code reached the yopmail inbox" };
|
|
272
|
+
await tab.call(OTP_FILL, [code]);
|
|
273
|
+
const done = await tab.waitFor("!location.pathname.startsWith('/auth/')", 30, { sleep });
|
|
274
|
+
return done ? { ok: true, result: "signed in (with email OTP)" } : { ok: false, failed: true, result: "email OTP: code entered but still on /auth" };
|
|
275
|
+
}
|
|
276
|
+
return { ok: true, result: "signed in" };
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export async function chromeSignin(tenants, flags = {}, {
|
|
280
|
+
home = homedir(), connect = cdpConnect, pagesOn = cdpPagesOn, signIn = signInTenant, now = Date.now, readLogins, portOf,
|
|
281
|
+
} = {}) {
|
|
282
|
+
if (!tenants.length) throw new CliError("USAGE", "chrome signin TENANT... (dev tech-* test tenants only)", 2);
|
|
283
|
+
for (const tenant of tenants) assertTechTenant(tenant);
|
|
284
|
+
const state = await readJson(signinStatePath(home), { tenants: {} });
|
|
285
|
+
state.tenants ??= {};
|
|
286
|
+
if (flags["clear-rest"]) {
|
|
287
|
+
for (const tenant of tenants) if (state.tenants[tenant]) delete state.tenants[tenant].rested;
|
|
288
|
+
await writeJson(signinStatePath(home), state);
|
|
289
|
+
return { cleared: tenants };
|
|
290
|
+
}
|
|
291
|
+
const logins = readLogins ? await readLogins() : await readJson(TEST_LOGINS(home), {});
|
|
292
|
+
const port = await (portOf ?? (() => sharedChromePort({ home })))();
|
|
293
|
+
const cdp = await connect(port);
|
|
294
|
+
const results = [];
|
|
295
|
+
try {
|
|
296
|
+
for (const tenant of tenants) {
|
|
297
|
+
const prior = state.tenants[tenant] ?? {};
|
|
298
|
+
let outcome;
|
|
299
|
+
if (prior.rested) outcome = { ok: false, result: "rested after a failed sign-in (lockout risk); a person checks the account, then: chrome signin --clear-rest " + tenant };
|
|
300
|
+
else if (prior.attemptedAt && now() - Date.parse(prior.attemptedAt) < SIGNIN_RETRY_MS && !prior.ok)
|
|
301
|
+
outcome = { ok: false, result: "already tried this hour; not retried (lockout risk)" };
|
|
302
|
+
else if ((await pagesOn(`https://${tenant}.${DEV_TENANT_DOMAIN}`, port)) > 0)
|
|
303
|
+
// A second refresh at once can trip refresh-token reuse and revoke the session.
|
|
304
|
+
outcome = { ok: true, result: "skipped: another tab has this tenant open" };
|
|
305
|
+
else {
|
|
306
|
+
const cred = testLogin(logins, tenant);
|
|
307
|
+
if (!cred) outcome = { ok: false, result: "no test login on file" };
|
|
308
|
+
else {
|
|
309
|
+
try { outcome = await signIn(cdp, tenant, cred, { open: typeof flags.open === "string" ? flags.open : undefined }); }
|
|
310
|
+
catch (error) { outcome = { ok: false, result: `error: ${String(error?.message ?? error).slice(0, 100)}` }; }
|
|
311
|
+
state.tenants[tenant] = { ...prior, attemptedAt: new Date(now()).toISOString() };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
state.tenants[tenant] = {
|
|
315
|
+
...state.tenants[tenant],
|
|
316
|
+
ok: outcome.ok,
|
|
317
|
+
result: outcome.result,
|
|
318
|
+
at: new Date(now()).toISOString(),
|
|
319
|
+
...(outcome.failed ? { rested: true } : {}),
|
|
320
|
+
};
|
|
321
|
+
results.push({ tenant, ok: outcome.ok, result: outcome.result });
|
|
322
|
+
}
|
|
323
|
+
} finally {
|
|
324
|
+
await cdp.close();
|
|
325
|
+
await writeJson(signinStatePath(home), state);
|
|
326
|
+
}
|
|
327
|
+
return { results };
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export async function chromeCommand(action, rest, flags, deps = {}) {
|
|
331
|
+
if (action === "start") {
|
|
332
|
+
const data = await chromeStart(flags, deps);
|
|
333
|
+
return {
|
|
334
|
+
payload: { data },
|
|
335
|
+
human: [
|
|
336
|
+
data.started ? `Started the shared Chrome on ${data.endpoint} with profile ${data.profile}.` : `The shared Chrome is already up on ${data.endpoint}${data.profile ? ` (profile ${data.profile})` : ""}; adopted it.`,
|
|
337
|
+
data.published.published ? `Endpoint on Dev's machine record${data.published.unchanged ? " (unchanged)" : ""}.` : `Endpoint not published to Dev: ${data.published.reason}.`,
|
|
338
|
+
].join("\n"),
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
if (action === "status") {
|
|
342
|
+
const data = await chromeStatus(deps);
|
|
343
|
+
return {
|
|
344
|
+
payload: { data },
|
|
345
|
+
human: [
|
|
346
|
+
data.up ? `up: ${data.browser} on ${data.endpoint}, ${data.tabs ?? "?"} tab(s)` : `DOWN: nothing on ${data.endpoint}; run nodii-dev chrome start`,
|
|
347
|
+
`profile: ${data.profile ?? "(not recorded; run chrome start)"}`,
|
|
348
|
+
...Object.entries(data.tenants).map(([tenant, t]) => `${tenant}: ${t.result} (${t.at})${t.rested ? " [rested]" : ""}`),
|
|
349
|
+
].join("\n"),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
if (action === "signin") {
|
|
353
|
+
const data = await chromeSignin(rest, flags, deps);
|
|
354
|
+
if (data.cleared) return { payload: { data }, human: `Cleared the rest on ${data.cleared.join(", ")}.` };
|
|
355
|
+
if (data.results.some((r) => !r.ok)) process.exitCode = 1;
|
|
356
|
+
return { payload: { data }, human: data.results.map((r) => `${r.tenant}: ${r.result}`).join("\n") };
|
|
357
|
+
}
|
|
358
|
+
throw new CliError("USAGE", "chrome start [--profile DIR] [--port N] | chrome status | chrome signin TENANT... [--open PATH] [--clear-rest]", 2);
|
|
359
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -309,6 +309,25 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
309
309
|
gather timings [--model M] [--last N] # this Mac's lane Gather picks: warm-up and first-pick p50/p95
|
|
310
310
|
# (each lane gather logs one; the first pick has 120 s once warm)
|
|
311
311
|
|
|
312
|
+
coordinator board [--write] [--infra PATH] [--sheet NAME] [--force]
|
|
313
|
+
# the sheet's "What's running" and "What needs you" from Dev's real state
|
|
314
|
+
# (lanes, change sets, heavy slots, answered.md); --write merges running into
|
|
315
|
+
# docs/open/<sheet>-status.md and waiting-on-you into <sheet>.md (MW4-31),
|
|
316
|
+
# from a nodii-infra worktree, harvesting typed answers first
|
|
317
|
+
coordinator watch run|install|status|once JOB|alerts [--all]
|
|
318
|
+
# the coordinator's supervised daemon (launchd: com.nodii.coordinator-watch):
|
|
319
|
+
# board, apply-watch, publish-watch, real-stuck, complexity, orphan slots,
|
|
320
|
+
# keepalive; one log, and status shows each job's health
|
|
321
|
+
chrome start [--profile DIR] [--port N] | chrome status
|
|
322
|
+
# the machine's one shared Chrome, DevTools on a fixed port (9333); start is
|
|
323
|
+
# idempotent and publishes the endpoint on Dev's machine record (K02-16)
|
|
324
|
+
chrome signin TENANT... [--clear-rest]
|
|
325
|
+
# dev tech-* test tenants only (MW3-40.2), email OTP from the yopmail inbox;
|
|
326
|
+
# one try per tenant per hour, a failed tenant rests until --clear-rest
|
|
327
|
+
figma publish FILE_KEY --sets CS-1,CS-2 [--dry-run]
|
|
328
|
+
# the library publish dialog through the shared Chrome: ticks only the
|
|
329
|
+
# components of finished sets (awaiting_publish), unticks the rest, reports
|
|
330
|
+
# what it can't map, publishes and records it (figma published)
|
|
312
331
|
coordinator start --machine NAME [--account RUNTIME:PROFILE ...]
|
|
313
332
|
# register this machine's one watched coordinator; refuses a live second;
|
|
314
333
|
# registers each --account and reports every account's usage; a background
|
|
@@ -960,7 +979,21 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
960
979
|
if (command === "harness" && ["install", "update", "check"].includes(action)) {
|
|
961
980
|
// `--include-drafts` is a switch: `--include-drafts false` would leave `false` here and turn drafts on.
|
|
962
981
|
if (rest.length) throw new CliError("USAGE", `harness ${action} takes no arguments, got: ${rest.join(" ")}. Write a flag value as --include-drafts=false.`, 2);
|
|
963
|
-
|
|
982
|
+
const result = await harnessCommand(action, f, { installManaged: installManagedLatest });
|
|
983
|
+
// hub-405: on the machine's coordinator, install also loads coordinator watch.
|
|
984
|
+
if (action !== "check" && !f["dry-run"] && !f.check) {
|
|
985
|
+
const { coordinatorWatchForHarness } = await import("./coordinator-watch.js");
|
|
986
|
+
const watch = await coordinatorWatchForHarness();
|
|
987
|
+
if (watch) {
|
|
988
|
+
const human = result.human;
|
|
989
|
+
return emitCommand({
|
|
990
|
+
...result,
|
|
991
|
+
payload: { ...result.payload, coordinatorWatch: watch },
|
|
992
|
+
human: (p) => [typeof human === "function" ? human(p) : human, watch.line].filter(Boolean).join("\n"),
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return emitCommand(result);
|
|
964
997
|
}
|
|
965
998
|
if (command === "repo" && ["policy", "lint"].includes(action)) return emitCommand(await repoCommand(action, rest, f));
|
|
966
999
|
if (command === "test") return emitCommand(await testCommand(action, rest, f, { readPolicy }));
|
|
@@ -1024,6 +1057,9 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1024
1057
|
if (action !== "generate") throw new CliError("USAGE", SURFACE_USAGE, 2);
|
|
1025
1058
|
return emitCommand(await surfaceCommand(action, rest, f));
|
|
1026
1059
|
}
|
|
1060
|
+
if (command === "chrome") return emitCommand(await (await import("./chrome.js")).chromeCommand(action, rest, f));
|
|
1061
|
+
if (command === "coordinator" && ["board", "watch"].includes(action))
|
|
1062
|
+
return emitCommand(await (await import("./coordinator-watch.js")).coordinatorWatchCommand(action, rest, f));
|
|
1027
1063
|
if (command === "coordinator") return emitCommand(await coordinatorCommand(action, f, { installWatchdog }));
|
|
1028
1064
|
if (command === "steward") return emitCommand(await stewardCommand(action, rest, f));
|
|
1029
1065
|
if (command === "lane" && action === "launch") return emitCommand(await launchLaneCommand(rest[0], f));
|
|
@@ -1364,6 +1400,13 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1364
1400
|
);
|
|
1365
1401
|
}
|
|
1366
1402
|
if (command === "figma") {
|
|
1403
|
+
if (action === "publish") {
|
|
1404
|
+
if (rest.length !== 1) throw new CliError("USAGE", "figma publish FILE_KEY --sets CS-1,CS-2 [--dry-run]", 2);
|
|
1405
|
+
const { figmaPublish, figmaPublishText } = await import("./figma-publish.js");
|
|
1406
|
+
const data = await figmaPublish(rest[0], f);
|
|
1407
|
+
if (data.unmapped.length || data.notRecorded.length) process.exitCode = 1;
|
|
1408
|
+
return emit({ data }, json, (p) => figmaPublishText(p.data));
|
|
1409
|
+
}
|
|
1367
1410
|
if (action === "lock")
|
|
1368
1411
|
return emit(await figmaLock(rest[0], requireFlag(f, "title"), { scopes: scopesFrom(f), ...(f["lane-reads"] ? { laneReads: await readLaneReads(f["lane-reads"]) } : {}) }).catch((error) => { throw laneReadsRefusal(error); }), json, (p) => figmaLockText(p.data));
|
|
1369
1412
|
if (action === "scope") {
|