@nodii/dev 0.6.212 → 0.6.214
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 +15 -0
- package/dist/cli.js +8 -4
- package/dist/core.js +1 -1
- package/dist/design.js +47 -11
- package/dist/github-token.js +71 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -248,6 +248,20 @@ nodii-dev figma publish FILE --sets CS-1,CS-2 [--dry-run]
|
|
|
248
248
|
- **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`.
|
|
249
249
|
- **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.
|
|
250
250
|
|
|
251
|
+
## GitHub reads: the research token
|
|
252
|
+
|
|
253
|
+
`nodii-dev github research-token` prints a 1-hour installation token for the read-only GitHub App `nodii-research-readonly` (Actions, Contents, Pull requests, Metadata and the organization's self-hosted runners, all read-only). The App's tokens have their own API allowance (7,650 calls an hour), separate from the shared account's 5,000 that every lane and the coordinator spend. On 25 Nov 2026 one research scan used that whole allowance and blocked every session for 30 minutes.
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
GH_TOKEN=$(nodii-dev github research-token) gh api 'repos/cognion-nucleus/nodii-auth/actions/runs?per_page=100'
|
|
257
|
+
nodii-dev github research-token --json # {"token": "ghs_...", "expiresAt": "..."}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
- **Where the key lives.** AWS Secrets Manager, `nodii/dev/github-research-app` (nodii-infra `envs/dev/github_research_app.tf`), so any machine signed in to AWS can mint a token. Set `NODII_AWS_PROFILE` to pick an AWS profile.
|
|
261
|
+
- **What it can't do.** Write anything: GitHub refuses with "Resource not accessible by integration".
|
|
262
|
+
- **When to use it.** Bulk reads: run and job history, scans across many repos, reports. It's an optional utility; no rule requires it yet.
|
|
263
|
+
- **Errors.** `RESEARCH_SECRET_UNREADABLE` means this machine isn't signed in to AWS. `RESEARCH_SECRET_INCOMPLETE` means the secret is missing a field. `RESEARCH_TOKEN_REFUSED` means GitHub turned the App down, and the message carries its HTTP status.
|
|
264
|
+
|
|
251
265
|
## Receipts
|
|
252
266
|
|
|
253
267
|
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:
|
|
@@ -273,6 +287,7 @@ nodii-dev logout
|
|
|
273
287
|
nodii-dev whoami # OAuth identity plus the registered agent
|
|
274
288
|
nodii-dev config show
|
|
275
289
|
nodii-dev doctor [--figma-file KEY] [--json] # preflight: Dev, hooks, local Ollama + Gather model, optional Figma
|
|
290
|
+
nodii-dev github research-token [--json] # a 1-hour read-only GitHub token with its own rate limit (below)
|
|
276
291
|
|
|
277
292
|
nodii-dev api list [--tag TAG] [--json]
|
|
278
293
|
nodii-dev api OPERATION_ID [--param name=value ...] [--body @file|-|JSON]
|
package/dist/cli.js
CHANGED
|
@@ -37,6 +37,7 @@ import { SUBMIT_CHECK_FLAGS, changedPaths, nudgeStop, recordGathered, recordGuid
|
|
|
37
37
|
import { isLaneConfig, promptTurnText, sessionStartText, stewardCommand } from "./session-kind.js";
|
|
38
38
|
import { rulingCommand } from "./rulings.js";
|
|
39
39
|
import { doctorCommand } from "./doctor.js";
|
|
40
|
+
import { githubCommand } from "./github-token.js";
|
|
40
41
|
import { installManagedLatest, managedStatus } from "./managed-version.js";
|
|
41
42
|
import { dispatchManagedClaudeHook, dispatchManagedHook } from "./managed-hooks.js";
|
|
42
43
|
import { governorCommand, laneClose } from "./governor.js";
|
|
@@ -166,6 +167,8 @@ Usage: nodii-dev <command> [options] [--json]
|
|
|
166
167
|
login [--force] | logout | whoami | config show
|
|
167
168
|
# login says so when the machine is already signed in; --force
|
|
168
169
|
# replaces that one sign-in (never from a lane)
|
|
170
|
+
github research-token [--json] # a 1-hour read-only GitHub token from the research App (own rate limit);
|
|
171
|
+
# GH_TOKEN=$(nodii-dev github research-token) gh api ... for bulk reads
|
|
169
172
|
doctor [--figma-file KEY] [--json] # preflight: sign-in, agent, permissions, machine, repo, lane slots,
|
|
170
173
|
# local Ollama + pinned Gather model, the Figma token, the coordinator watch daemon (for a
|
|
171
174
|
# coordinator), whether a clean environment finds the lane runtime, and optional Figma registration
|
|
@@ -1313,6 +1316,7 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1313
1316
|
if (result.exitCode) process.exitCode = result.exitCode;
|
|
1314
1317
|
};
|
|
1315
1318
|
if (command === "setup") return emitCommand(await setupCommand(f));
|
|
1319
|
+
if (command === "github") return emitCommand(await githubCommand(action, rest, f));
|
|
1316
1320
|
if (command === "doctor") {
|
|
1317
1321
|
if (action) throw new CliError("USAGE", `doctor takes no arguments, got: ${[action, ...rest].join(" ")}`, 2);
|
|
1318
1322
|
if (f["figma-file"] === true) throw new CliError("USAGE", "--figma-file needs a file key or figma.com link", 2);
|
|
@@ -1794,10 +1798,10 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1794
1798
|
return emit(await figmaFilePublished(rest[0], await publishedBody(f)).catch((error) => { throw laneReadsRefusal(error); }), json, (p) => figmaFilePublishedText(p.data));
|
|
1795
1799
|
// --dry-run runs Dev's dry run of the submit gate (design check --change-set)
|
|
1796
1800
|
// on the same body, and never writes (CLI-18).
|
|
1797
|
-
const dryRun = async (id, text, file, { split = false } = {}) => {
|
|
1801
|
+
const dryRun = async (id, text, file, { split = false, command } = {}) => {
|
|
1798
1802
|
const laneReads = f["lane-reads"] ? await readLaneReads(f["lane-reads"]) : undefined;
|
|
1799
1803
|
const result = await designCheckChangeSet(undefined, { "change-set": id, ...(text ? { file } : {}), ...(f["figma-version"] ? { "figma-version": f["figma-version"] } : {}), ...(f.sync ? { sync: true } : {}), ...(f.async ? { async: true } : {}) },
|
|
1800
|
-
{ read: async () => text, split, ...(laneReads ? { laneReads } : {}), ...(f["code-pr"] !== undefined ? { codePr: f["code-pr"] } : {}) }).catch((error) => { throw laneReadsRefusal(error); });
|
|
1804
|
+
{ read: async () => text, split, command, ...(laneReads ? { laneReads } : {}), ...(f["code-pr"] !== undefined ? { codePr: f["code-pr"] } : {}) }).catch((error) => { throw laneReadsRefusal(error); });
|
|
1801
1805
|
emit(result.payload, json, result.human);
|
|
1802
1806
|
if (result.exitCode) {
|
|
1803
1807
|
if (!json) console.error(`DS_CONFORMANCE_FAILED: ${result.payload.data.findings.length} finding(s)`);
|
|
@@ -1809,13 +1813,13 @@ export async function main(argv = process.argv.slice(2)) {
|
|
|
1809
1813
|
// The same body checks as the real submit, which needs --file.
|
|
1810
1814
|
const text = f.file ? await readFile(f.file, "utf8") : null;
|
|
1811
1815
|
checkSubmitPayload(text ? JSON.parse(text) : { figmaVersion: f["figma-version"] }, f.file || "the submit (no --file)");
|
|
1812
|
-
return dryRun(rest[0], text, f.file, { split: true });
|
|
1816
|
+
return dryRun(rest[0], text, f.file, { split: true, command: "submit" });
|
|
1813
1817
|
}
|
|
1814
1818
|
if (action === "resubmit" && f["dry-run"]) {
|
|
1815
1819
|
if (!rest[0] || !rest[1]) throw new CliError("USAGE", "figma resubmit CHANGE_SET PAYLOAD.json --dry-run", 2);
|
|
1816
1820
|
const text = await readFile(rest[1], "utf8");
|
|
1817
1821
|
assertContext(resubmitPayload(text, rest[1]), { resubmit: true, file: rest[1] });
|
|
1818
|
-
return dryRun(rest[0], text, rest[1]);
|
|
1822
|
+
return dryRun(rest[0], text, rest[1], { command: "resubmit" });
|
|
1819
1823
|
}
|
|
1820
1824
|
if (action === "submit") {
|
|
1821
1825
|
const payload = f.file ? JSON.parse(await readFile(f.file, "utf8")) : { figmaVersion: requireFlag(f, "figma-version") };
|
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ import { chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "node:fs/pr
|
|
|
4
4
|
import { homedir, platform } from "node:os";
|
|
5
5
|
import { basename, dirname, join } from "node:path";
|
|
6
6
|
|
|
7
|
-
export const VERSION = "0.6.
|
|
7
|
+
export const VERSION = "0.6.214";
|
|
8
8
|
export const configPath = () =>
|
|
9
9
|
process.env.NODII_DEV_CONFIG_PATH ??
|
|
10
10
|
join(homedir(), ".config/nodii-dev/config.json");
|
package/dist/design.js
CHANGED
|
@@ -149,6 +149,20 @@ const PUBLISH_LABEL = "Components published";
|
|
|
149
149
|
const VERSION_PAGES = 5;
|
|
150
150
|
const KEY_LOOKUPS_AT_ONCE = 3;
|
|
151
151
|
|
|
152
|
+
async function versionHistoryReads(figmaGet, path) {
|
|
153
|
+
const reads = [];
|
|
154
|
+
let at = `/${path}?page_size=100`;
|
|
155
|
+
for (let page = 0; page < VERSION_PAGES && at; page++) {
|
|
156
|
+
const body = await figmaGet(at);
|
|
157
|
+
reads.push({ path: at.slice(1), body });
|
|
158
|
+
const older = body?.pagination?.prev_page;
|
|
159
|
+
if (typeof older !== "string" || !older.startsWith(`${FIGMA_API}/${path}`)) break;
|
|
160
|
+
const next = new URL(older);
|
|
161
|
+
at = next.origin === new URL(FIGMA_API).origin && next.pathname === `/v1/${path}` ? `${next.pathname.slice(3)}${next.search}` : null;
|
|
162
|
+
}
|
|
163
|
+
return reads;
|
|
164
|
+
}
|
|
165
|
+
|
|
152
166
|
/**
|
|
153
167
|
* A library's newest "Components published" version (DEC-0047): what a
|
|
154
168
|
* consuming file can have. Null when none is in its recent history; its
|
|
@@ -468,7 +482,7 @@ function mergedReports(reports) {
|
|
|
468
482
|
* plus the submit-time guards against the set's items: IMAGE_NOT_TRUECOLOR
|
|
469
483
|
* refuses; STALE_FIGMA_VERSION is a warning. Changes no state.
|
|
470
484
|
*/
|
|
471
|
-
export async function designCheckChangeSet(target, flags, { request = devRequest, send, progress, read = (f) => readFile(f, "utf8"), laneReads, split = false, codePr } = {}) {
|
|
485
|
+
export async function designCheckChangeSet(target, flags, { request = devRequest, send, progress, read = (f) => readFile(f, "utf8"), laneReads, split = false, codePr, command, env = process.env, figmaGet, laneReadsLimit } = {}) {
|
|
472
486
|
const id = flags["change-set"];
|
|
473
487
|
// On the lane's reads too Dev runs the dry run as a job (hub-448); --sync sends the plain call.
|
|
474
488
|
const sync = submitMode(flags);
|
|
@@ -488,22 +502,44 @@ export async function designCheckChangeSet(target, flags, { request = devRequest
|
|
|
488
502
|
if (!body || typeof body !== "object" || Array.isArray(body)) throw new CliError("USAGE", `${flags.file}: expected the submit body, a JSON object`, 2);
|
|
489
503
|
}
|
|
490
504
|
if (flags["figma-version"]) body = { ...body, figmaVersion: String(flags["figma-version"]) };
|
|
505
|
+
if (command) body = { ...body, command };
|
|
491
506
|
// hub-558: images go up one by one and the body names them; --code-pr rides in the body.
|
|
492
507
|
body = withCodePr(body, codePr, { ...(progress ? { progress } : {}) });
|
|
493
508
|
body = await uploadSubmitImages(id, body, { request, ...(progress ? { progress } : {}) });
|
|
494
|
-
//
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
509
|
+
// Upload a large read corpus once. A versions negotiation below keeps its
|
|
510
|
+
// readIds and adds only one small inline REST supplement.
|
|
511
|
+
const storedReads = laneReads
|
|
512
|
+
? await laneReadsBody(id, laneReads, { request, ...(progress ? { progress } : {}), ...(laneReadsLimit ? { limit: laneReadsLimit } : {}) })
|
|
513
|
+
: {};
|
|
514
|
+
let versionReads = [];
|
|
515
|
+
const withReads = () => {
|
|
516
|
+
if (!versionReads.length) return { ...body, ...storedReads };
|
|
517
|
+
if (storedReads.laneReads)
|
|
518
|
+
return { ...body, laneReads: { ...storedReads.laneReads, rest: [...(storedReads.laneReads.rest ?? []).filter((entry) => !versionReads.some((read) => read.path === entry.path)), ...versionReads] } };
|
|
519
|
+
return { ...body, ...storedReads, laneReads: { figmaVersion: laneReads.figmaVersion, nodes: [], rest: versionReads } };
|
|
520
|
+
};
|
|
499
521
|
let p;
|
|
500
522
|
try {
|
|
501
|
-
const run = (
|
|
502
|
-
|
|
523
|
+
const run = (sent) => figmaConformance(id, sent, { request, sync, ...(send ? { send } : {}), ...(progress ? { progress } : {}) });
|
|
524
|
+
const runAll = async () => {
|
|
525
|
+
const sent = withReads();
|
|
526
|
+
// A submit body past the dry run's node limit runs in parts, each under it;
|
|
527
|
+
// a re-submit's can't be split, since it must name every rejected item.
|
|
528
|
+
const groups = split && Array.isArray(sent.items) ? dryRunGroups(sent.items) : [];
|
|
529
|
+
if (groups.length <= 1) return run(sent);
|
|
503
530
|
const reports = [];
|
|
504
|
-
for (const items of groups) reports.push((await run({ ...
|
|
505
|
-
|
|
506
|
-
}
|
|
531
|
+
for (const items of groups) reports.push((await run({ ...sent, items })).data ?? {});
|
|
532
|
+
return { data: mergedReports(reports) };
|
|
533
|
+
};
|
|
534
|
+
try {
|
|
535
|
+
p = await runAll();
|
|
536
|
+
} catch (error) {
|
|
537
|
+
const path = String(error?.details?.path ?? "").replace(/^\/+/, "");
|
|
538
|
+
if (!laneReads || error?.code !== "FIGMA_READS_NEEDED" || !/^files\/[^/]+\/versions$/.test(path)) throw error;
|
|
539
|
+
const get = figmaGet ?? figmaClient(figmaToken(env));
|
|
540
|
+
versionReads = await versionHistoryReads(get, path);
|
|
541
|
+
p = await runAll();
|
|
542
|
+
}
|
|
507
543
|
} catch (error) {
|
|
508
544
|
// A cold run reads every root and main from Figma and can outlast the
|
|
509
545
|
// edge's gateway (504, an HTML page). Dev keeps the mains it read for 5
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// `nodii-dev github research-token`: a short-lived GitHub token for bulk reads.
|
|
2
|
+
//
|
|
3
|
+
// Research, reports and history scans used to run on the shared account, whose
|
|
4
|
+
// 5,000/h API limit every lane and the coordinator share. On 25 Nov 2026 one
|
|
5
|
+
// scan drove it to 0 for 30 minutes and blocked all of them. The operator then
|
|
6
|
+
// created a read-only GitHub App (nodii-research-readonly: Actions, Contents,
|
|
7
|
+
// Pull requests, Metadata, org Self-hosted runners, all read) whose
|
|
8
|
+
// installation tokens have their own limit, and ruled: "make the key a github
|
|
9
|
+
// variable you can do without me. or make it an AWS variable." The key lives in
|
|
10
|
+
// AWS Secrets Manager (nodii-infra envs/dev/github_research_app.tf).
|
|
11
|
+
//
|
|
12
|
+
// GH_TOKEN=$(nodii-dev github research-token) gh api 'repos/...'
|
|
13
|
+
import { createSign } from "node:crypto";
|
|
14
|
+
import { execFile } from "node:child_process";
|
|
15
|
+
import { promisify } from "node:util";
|
|
16
|
+
import { CliError } from "./core.js";
|
|
17
|
+
|
|
18
|
+
export const RESEARCH_SECRET_ID = "nodii/dev/github-research-app";
|
|
19
|
+
export const RESEARCH_SECRET_REGION = "ap-south-1";
|
|
20
|
+
|
|
21
|
+
const b64url = (buf) => Buffer.from(buf).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
22
|
+
|
|
23
|
+
/** The App's credentials from Secrets Manager, via the AWS CLI (NODII_AWS_PROFILE picks a profile). */
|
|
24
|
+
export async function readResearchSecret({ run = promisify(execFile), env = process.env } = {}) {
|
|
25
|
+
const args = ["secretsmanager", "get-secret-value", "--secret-id", RESEARCH_SECRET_ID, "--region", RESEARCH_SECRET_REGION, "--query", "SecretString", "--output", "text"];
|
|
26
|
+
if (env.NODII_AWS_PROFILE) args.push("--profile", env.NODII_AWS_PROFILE);
|
|
27
|
+
let stdout;
|
|
28
|
+
try {
|
|
29
|
+
({ stdout } = await run("aws", args));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
throw new CliError("RESEARCH_SECRET_UNREADABLE", `Could not read ${RESEARCH_SECRET_ID} from AWS Secrets Manager: ${String(error.stderr || error.message).trim()}. Sign in to AWS on this machine (or set NODII_AWS_PROFILE) and try again.`, 1);
|
|
32
|
+
}
|
|
33
|
+
return JSON.parse(stdout);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A GitHub App JWT (RS256), valid 9 minutes, backdated 60 s for clock skew. */
|
|
37
|
+
export function appJwt(appId, privateKeyPem, nowSeconds = Math.floor(Date.now() / 1000)) {
|
|
38
|
+
const header = b64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
|
39
|
+
const payload = b64url(JSON.stringify({ iat: nowSeconds - 60, exp: nowSeconds + 540, iss: String(appId) }));
|
|
40
|
+
const signer = createSign("RSA-SHA256");
|
|
41
|
+
signer.update(`${header}.${payload}`);
|
|
42
|
+
return `${header}.${payload}.${b64url(signer.sign(privateKeyPem))}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Mint a 1-hour installation token. Returns { token, expiresAt }. */
|
|
46
|
+
export async function researchToken({ readSecret = readResearchSecret, fetchImpl = fetch, now } = {}) {
|
|
47
|
+
const secret = await readSecret();
|
|
48
|
+
for (const field of ["app_id", "installation_id", "key_base64"]) {
|
|
49
|
+
if (!secret?.[field]) throw new CliError("RESEARCH_SECRET_INCOMPLETE", `${RESEARCH_SECRET_ID} has no ${field}; write the App credentials into it (see nodii-infra envs/dev/github_research_app.tf).`, 1);
|
|
50
|
+
}
|
|
51
|
+
const pem = Buffer.from(secret.key_base64, "base64").toString("utf8");
|
|
52
|
+
const jwt = appJwt(secret.app_id, pem, now);
|
|
53
|
+
const response = await fetchImpl(`https://api.github.com/app/installations/${secret.installation_id}/access_tokens`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: { Authorization: `Bearer ${jwt}`, Accept: "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28" },
|
|
56
|
+
});
|
|
57
|
+
const body = await response.json().catch(() => ({}));
|
|
58
|
+
if (!response.ok || !body.token) {
|
|
59
|
+
throw new CliError("RESEARCH_TOKEN_REFUSED", `GitHub refused the research App token (HTTP ${response.status}): ${body.message ?? "no message"}`, 1);
|
|
60
|
+
}
|
|
61
|
+
return { token: body.token, expiresAt: body.expires_at };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** CLI entry: human output is the bare token, so `GH_TOKEN=$(nodii-dev github research-token)` works. */
|
|
65
|
+
export async function githubCommand(action, rest, _flags, deps = {}) {
|
|
66
|
+
if (action !== "research-token" || rest.length) {
|
|
67
|
+
throw new CliError("USAGE", "usage: nodii-dev github research-token [--json]", 2);
|
|
68
|
+
}
|
|
69
|
+
const { token, expiresAt } = await researchToken(deps);
|
|
70
|
+
return { payload: { token, expiresAt }, human: token };
|
|
71
|
+
}
|