@nodii/dev 0.6.213 → 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 +4 -0
- package/dist/core.js +1 -1
- 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);
|
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");
|
|
@@ -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
|
+
}
|