@veda-hq/niyam 0.7.14 → 0.7.16
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 +27 -9
- package/dist/agent.js +44 -2
- package/dist/board-audit.js +52 -4
- package/dist/doctor.js +2 -2
- package/dist/issue-types.js +1 -1
- package/dist/onboard.js +39 -7
- package/dist/owner-login.js +14 -8
- package/dist/release-tag.js +11 -5
- package/dist/run.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -740,9 +740,15 @@ an archive made on purpose from one made before the issue reopened. The
|
|
|
740
740
|
repository is the clone's here when none is named, and the Project is the
|
|
741
741
|
one `.github/niyam.json`'s `"project"` names, else "<repo> work". GitHub's
|
|
742
742
|
API shows a workflow's name and whether it is on, not the repository or
|
|
743
|
-
filter it adds from, so the audit says so. It
|
|
744
|
-
needs read access to the Project,
|
|
745
|
-
|
|
743
|
+
filter it adds from, so the audit says so. It reads with `GH_TOKEN`, which
|
|
744
|
+
needs read access to the Project, as an agent session has it. Without one,
|
|
745
|
+
as in the owner's terminal, it reads as the agent, with the token `machine`
|
|
746
|
+
keeps in the keychain: the agent the clone's settings name, or outside a
|
|
747
|
+
clone the one `machine` set up on this Mac. So it needs no `gh` signed in,
|
|
748
|
+
and never the owner's own token. With no such token, or several agents and
|
|
749
|
+
none named, it says so and reads nothing; so it does in a locked session,
|
|
750
|
+
whose `GH_TOKEN` is the lock's placeholder. It exits 0 when the board matches,
|
|
751
|
+
3 when something is to fix, and 1 when it could not check. A Claude cloud
|
|
746
752
|
session's GitHub proxy refuses GraphQL and an organisation's Projects
|
|
747
753
|
(veda-hq/niyam#399), so there it says it cannot run and checks nothing.
|
|
748
754
|
|
|
@@ -1749,13 +1755,13 @@ the app's client id and private key are the `npm` environment's
|
|
|
1749
1755
|
package is on npm as `@veda-hq/niyam`, with provenance, for a repository that
|
|
1750
1756
|
pins it as an exact version; it publishes from the `npm` environment, which
|
|
1751
1757
|
only `main` may deploy to. A tag on any other commit is not a release:
|
|
1752
|
-
`niyam upgrade` and `niyam onboard` ask GitHub's compare API
|
|
1753
|
-
|
|
1754
|
-
|
|
1758
|
+
`niyam upgrade` and `niyam onboard` ask GitHub's compare API whether the
|
|
1759
|
+
tag's commit is on `main`, and refuse one that is not, naming the tag and the
|
|
1760
|
+
commit. `upgrade` asks with no token; `onboard` asks with the agent's. Install the attached package on each machine with pnpm,
|
|
1755
1761
|
once; nothing is built on install:
|
|
1756
1762
|
|
|
1757
1763
|
```bash
|
|
1758
|
-
pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.
|
|
1764
|
+
pnpm add -g https://github.com/veda-hq/niyam/releases/download/v0.7.16/veda-hq-niyam-0.7.16.tgz
|
|
1759
1765
|
```
|
|
1760
1766
|
|
|
1761
1767
|
The package puts one command on `PATH`, `niyam`. Since P-57 a release
|
|
@@ -1791,8 +1797,20 @@ CLI running, refuses and says to run `niyam upgrade` first.
|
|
|
1791
1797
|
|
|
1792
1798
|
`onboard` pins the client's workflow to one version, the release of the CLI
|
|
1793
1799
|
that ran it, and writes `.github/niyam/cloud-setup.sh` at the same one. First
|
|
1794
|
-
it asks GitHub's compare API
|
|
1795
|
-
|
|
1800
|
+
it asks GitHub's compare API whether that release's tag is on `main`; when it
|
|
1801
|
+
is not, or GitHub cannot say, it refuses and changes nothing.
|
|
1802
|
+
|
|
1803
|
+
onboard reads GitHub's public API (the release tag, who the owner and the
|
|
1804
|
+
agent are, whether an organisation owns the repository) with the agent's
|
|
1805
|
+
stored token (#546). Those reads then count against the token's 5,000 an hour.
|
|
1806
|
+
With no token they would share the 60 an hour every request from the Mac's
|
|
1807
|
+
address gets. Until the run knows its agent, it uses the agent named on the
|
|
1808
|
+
command line, else the agent the settings name, else any agent `machine` set
|
|
1809
|
+
up on the Mac. It never uses the owner's sign-in for these reads. When GitHub
|
|
1810
|
+
refuses the token (HTTP 401, and only then), the read is asked again with
|
|
1811
|
+
none, within the time the first ask had. When GitHub refuses a read for its
|
|
1812
|
+
rate limit (403 or 429 with `x-ratelimit-remaining: 0`), onboard names the
|
|
1813
|
+
limit, and when it resets if GitHub sends a valid `x-ratelimit-reset`.
|
|
1796
1814
|
Each job writes the pin twice, `checks.yml@vX.Y.Z` and, two lines
|
|
1797
1815
|
below it under `with:`, `niyam-ref: vX.Y.Z`, the one input `checks.yml`
|
|
1798
1816
|
declares; GitHub refuses a caller that passes an input the called workflow
|
package/dist/agent.js
CHANGED
|
@@ -407,18 +407,60 @@ export function quote(value) {
|
|
|
407
407
|
export function readToken(sys, agent) {
|
|
408
408
|
return tokenStore(sys)?.read(sys, agent);
|
|
409
409
|
}
|
|
410
|
+
/**
|
|
411
|
+
* What GitHub's refusal says when it is its rate limit, a 403 or 429 with
|
|
412
|
+
* `x-ratelimit-remaining: 0`, whose limit ran out, with no token the 60 an
|
|
413
|
+
* hour every request from this address shares (#546), and when it resets,
|
|
414
|
+
* from `x-ratelimit-reset` in UTC epoch seconds. Undefined for any other
|
|
415
|
+
* answer. GitHub's REST docs, "Rate limits for the REST API", section
|
|
416
|
+
* "Exceeding the rate limit" (read 2026-11-22; the link is on #546's PR).
|
|
417
|
+
*/
|
|
418
|
+
export function rateLimited(answer, token) {
|
|
419
|
+
const headers = answer.headers ?? {};
|
|
420
|
+
if ((answer.status !== 403 && answer.status !== 429) || headers['x-ratelimit-remaining'] !== '0')
|
|
421
|
+
return undefined;
|
|
422
|
+
const reset = Number(headers['x-ratelimit-reset']);
|
|
423
|
+
const until = Number.isInteger(reset) && reset > 0 ? ` until ${new Date(reset * 1000).toISOString().slice(11, 16)} UTC` : '';
|
|
424
|
+
const whose = token ? "GitHub's rate limit for the token" : "GitHub's limit for requests with no token, 60 an hour from this address,";
|
|
425
|
+
return `${whose} has run out${until} (HTTP ${answer.status})`;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* A read of GitHub's public API asked with `token`, so it counts against the
|
|
429
|
+
* token's limit rather than the one this address shares with no token (#546),
|
|
430
|
+
* and asked again with none only when GitHub refuses the token (401): a
|
|
431
|
+
* public read is answered without one. A `timeoutMs` bounds both asks
|
|
432
|
+
* together, the second getting what the first left, and none left gives the
|
|
433
|
+
* 401. Gives the token the answer came with.
|
|
434
|
+
*/
|
|
435
|
+
export async function publicRead(sys, url, token, options = {}) {
|
|
436
|
+
if (!token)
|
|
437
|
+
return { answer: await sys.http(url, options), token: undefined };
|
|
438
|
+
const started = sys.now().getTime();
|
|
439
|
+
const answer = await sys.http(url, { ...options, token });
|
|
440
|
+
if (answer.status !== 401)
|
|
441
|
+
return { answer, token };
|
|
442
|
+
if (options.timeoutMs === undefined)
|
|
443
|
+
return { answer: await sys.http(url, options), token: undefined };
|
|
444
|
+
const left = options.timeoutMs - (sys.now().getTime() - started);
|
|
445
|
+
return left > 0 ? { answer: await sys.http(url, { ...options, timeoutMs: left }), token: undefined } : { answer, token };
|
|
446
|
+
}
|
|
410
447
|
/**
|
|
411
448
|
* An account's numeric id and its login as GitHub spells it, from the public
|
|
412
449
|
* API. Logins are case-insensitive; the stored token's item, the session file and
|
|
413
450
|
* commits all use GitHub's spelling, whatever case the login was typed in.
|
|
414
451
|
* A refusal or a passing failure (403, 429, 5xx) is asked again after each of
|
|
415
|
-
* ACCOUNT_WAITS_MS; only a 404 says the account does not exist
|
|
452
|
+
* ACCOUNT_WAITS_MS; only a 404 says the account does not exist, and a rate
|
|
453
|
+
* limit run out, which no wait of seconds fixes, is said at once.
|
|
416
454
|
*/
|
|
417
455
|
export async function account(sys, login, token) {
|
|
418
456
|
for (let tries = 0;; tries++) {
|
|
419
|
-
const {
|
|
457
|
+
const { answer, token: used } = await publicRead(sys, `${API}/users/${login}`, token);
|
|
458
|
+
const { status, json } = answer;
|
|
420
459
|
if (status === 404)
|
|
421
460
|
throw new Error(`GitHub has no account "${login}" (HTTP 404)`);
|
|
461
|
+
const limited = rateLimited(answer, used);
|
|
462
|
+
if (limited)
|
|
463
|
+
throw new Error(`GitHub did not answer who account "${login}" is: ${limited}`);
|
|
422
464
|
const wait = ACCOUNT_WAITS_MS[tries];
|
|
423
465
|
if ((status === 403 || status === 429 || status >= 500) && wait !== undefined) {
|
|
424
466
|
await sys.sleep(wait);
|
package/dist/board-audit.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { API, SETTINGS_PATH, repoAt } from './agent.js';
|
|
1
|
+
import { API, NO_TOKEN, SETTINGS_PATH, agentHere, agentsSetUp, hasSettings, isNoToken, loadSettings, readToken, repoAt, sameLogin } from './agent.js';
|
|
2
2
|
import { AUTO_ADD, AUTO_ADD_FILTER, graphql } from './board.js';
|
|
3
|
+
import { tokenStore, unsupported } from './token-store.js';
|
|
3
4
|
/** board-audit's options: the repository, and the Project's title. */
|
|
4
5
|
export function auditArgs(args) {
|
|
5
6
|
const parsed = {};
|
|
@@ -150,6 +151,55 @@ export function auditLines(audit, slug) {
|
|
|
150
151
|
lines.push(wrong > 0 ? `board-audit: ${wrong} to fix` : audit.archived.length > 0 ? 'board-audit: nothing to fix but the archived issues above' : 'board-audit: the board matches the repository');
|
|
151
152
|
return { lines, wrong };
|
|
152
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* The token the audit reads with: `GH_TOKEN`, as an agent session has it,
|
|
156
|
+
* else the agent's own, which `machine` keeps in this Mac's keychain. The
|
|
157
|
+
* audit only reads, and the agent's token can read the board, so the owner
|
|
158
|
+
* runs it in a terminal with no `gh` signed in. It never asks for the
|
|
159
|
+
* owner's own token, which `machine` signs out of `gh` (veda-hq/niyam#548).
|
|
160
|
+
*/
|
|
161
|
+
export function auditToken(sys) {
|
|
162
|
+
const given = sys.env.GH_TOKEN;
|
|
163
|
+
// A locked session's placeholder is no token, and the lock is never worked around with the keychain's.
|
|
164
|
+
if (isNoToken(given))
|
|
165
|
+
throw new Error(`board-audit has no token: GH_TOKEN is the lock's ${NO_TOKEN}, as in a session niyam has not given the agent identity, so nothing was read; run niyam doctor`);
|
|
166
|
+
if (given)
|
|
167
|
+
return given;
|
|
168
|
+
if (!tokenStore(sys))
|
|
169
|
+
throw new Error(`board-audit needs GH_TOKEN here, as an agent session has it: ${unsupported(sys)}`);
|
|
170
|
+
const agent = auditAgent(sys);
|
|
171
|
+
if ('problem' in agent)
|
|
172
|
+
throw new Error(`board-audit needs GH_TOKEN, as an agent session has it, or the agent's token from this Mac's keychain: ${agent.problem}`);
|
|
173
|
+
// The keychain item is under the login as `machine` spelled it, which the settings may spell in another case.
|
|
174
|
+
const login = agentsSetUp(sys).find((one) => sameLogin(one, agent.agent)) ?? agent.agent;
|
|
175
|
+
const token = readToken(sys, login);
|
|
176
|
+
if (!token)
|
|
177
|
+
throw new Error(`board-audit needs GH_TOKEN, as an agent session has it, or ${login}'s token from this Mac's keychain, which holds none; run niyam machine ${login}`);
|
|
178
|
+
return token;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* The agent whose token the audit reads with outside an agent session: in a
|
|
182
|
+
* clone with settings, the one they name that sessions here work as
|
|
183
|
+
* (`agentHere`); elsewhere, the one `machine` set up on this Mac. A clone
|
|
184
|
+
* without settings counts as elsewhere: the audit takes any repository by
|
|
185
|
+
* name, so it needs no client clone. Never a guess.
|
|
186
|
+
*/
|
|
187
|
+
function auditAgent(sys) {
|
|
188
|
+
const top = sys.exec('git', ['rev-parse', '--show-toplevel'], { cwd: sys.cwd });
|
|
189
|
+
const root = top.stdout.trim();
|
|
190
|
+
if (top.code === 0 && hasSettings(sys, root)) {
|
|
191
|
+
const here = agentHere(sys, loadSettings(sys, root).agents);
|
|
192
|
+
return 'problem' in here ? { problem: `${here.problem}; or run it in an agent session` } : here;
|
|
193
|
+
}
|
|
194
|
+
const setUp = agentsSetUp(sys);
|
|
195
|
+
if (setUp.length === 1)
|
|
196
|
+
return { agent: setUp[0] };
|
|
197
|
+
return {
|
|
198
|
+
problem: setUp.length === 0
|
|
199
|
+
? 'niyam machine has set up no agent on this Mac; run niyam machine <agent>, or run it in an agent session'
|
|
200
|
+
: `niyam machine has set up ${setUp.join(' and ')} on this Mac, and no ${SETTINGS_PATH} here names one; run it in a clone of the repository, or in an agent session`,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
153
203
|
/**
|
|
154
204
|
* `niyam board-audit [owner/repo] [--project <title>]`: lists where the
|
|
155
205
|
* repository and its work board disagree, changing nothing. The repository
|
|
@@ -165,9 +215,7 @@ export async function boardAudit(sys, io, args) {
|
|
|
165
215
|
return 1;
|
|
166
216
|
}
|
|
167
217
|
const parsed = auditArgs(args);
|
|
168
|
-
const token = sys
|
|
169
|
-
if (!token)
|
|
170
|
-
throw new Error('board-audit needs GH_TOKEN, with read access to the Project: run it in an agent session, or GH_TOKEN="$(gh auth token)" niyam board-audit');
|
|
218
|
+
const token = auditToken(sys);
|
|
171
219
|
const slug = parsed.slug ?? repoAt(sys).slug;
|
|
172
220
|
const title = parsed.project ?? (await settingsTitle(sys, token, slug)) ?? `${slug.split('/')[1]} work`;
|
|
173
221
|
const { lines, wrong } = auditLines(await auditBoard(sys, token, slug, title), slug);
|
package/dist/doctor.js
CHANGED
|
@@ -170,7 +170,7 @@ async function typesFindings(sys, token) {
|
|
|
170
170
|
const approvals = typeof named === 'number' ? named : undefined;
|
|
171
171
|
const org = slug.split('/')[0];
|
|
172
172
|
try {
|
|
173
|
-
return (await isOrganisation(sys, org)) ? [await typesDrift(sys, token, org, slug, approvals)] : [];
|
|
173
|
+
return (await isOrganisation(sys, org, token)) ? [await typesDrift(sys, token, org, slug, approvals)] : [];
|
|
174
174
|
}
|
|
175
175
|
catch (error) {
|
|
176
176
|
return [{ mark: '✗', text: `issue types: cannot ask GitHub (${message(error)})`, fix: 'niyam doctor again' }];
|
|
@@ -189,7 +189,7 @@ async function boardAppFindings(sys, token) {
|
|
|
189
189
|
return [];
|
|
190
190
|
const { slug } = here;
|
|
191
191
|
try {
|
|
192
|
-
if (!(await isOrganisation(sys, slug.split('/')[0])))
|
|
192
|
+
if (!(await isOrganisation(sys, slug.split('/')[0], token)))
|
|
193
193
|
return [];
|
|
194
194
|
const names = await secretNames(sys, slug, token);
|
|
195
195
|
if (names === undefined)
|
package/dist/issue-types.js
CHANGED
|
@@ -503,7 +503,7 @@ export async function issueType(sys, io) {
|
|
|
503
503
|
const event = JSON.parse(sys.read(eventPath));
|
|
504
504
|
const { approvals } = loadSettings(sys, sys.cwd);
|
|
505
505
|
if (name === 'schedule' && event.schedule === HOURLY) {
|
|
506
|
-
if (!(await isOrganisation(sys, slug.split('/')[0]))) {
|
|
506
|
+
if (!(await isOrganisation(sys, slug.split('/')[0], token))) {
|
|
507
507
|
io.out('issue-type: GitHub has issue types for organisations only; nothing to do');
|
|
508
508
|
return 0;
|
|
509
509
|
}
|
package/dist/onboard.js
CHANGED
|
@@ -1166,6 +1166,27 @@ export function claudeSettings(before, sarathiBefore) {
|
|
|
1166
1166
|
}
|
|
1167
1167
|
return { text, changes, labels, ...said };
|
|
1168
1168
|
}
|
|
1169
|
+
/** The agents the checkout's settings name; none when it has none, or settings onboard refuses later with the reason. */
|
|
1170
|
+
function settingsAgents(sys, root) {
|
|
1171
|
+
if (!sys.exists(`${root}/${SETTINGS_PATH}`))
|
|
1172
|
+
return [];
|
|
1173
|
+
try {
|
|
1174
|
+
return loadSettings(sys, root).agents;
|
|
1175
|
+
}
|
|
1176
|
+
catch {
|
|
1177
|
+
// fail-open: the settings branch reads them again and refuses them with the reason; here they only suggest a token.
|
|
1178
|
+
return [];
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
/** The token this Mac stores for the first of `agents` it has one for, or undefined. */
|
|
1182
|
+
function storedToken(sys, agents) {
|
|
1183
|
+
for (const agent of agents) {
|
|
1184
|
+
const token = readToken(sys, agent);
|
|
1185
|
+
if (token)
|
|
1186
|
+
return token;
|
|
1187
|
+
}
|
|
1188
|
+
return undefined;
|
|
1189
|
+
}
|
|
1169
1190
|
/** Who the run's sign-in is, the owner's likely login; undefined when it failed. */
|
|
1170
1191
|
async function signedInLogin(signIn) {
|
|
1171
1192
|
const signed = await signIn().catch(() => undefined);
|
|
@@ -1300,9 +1321,18 @@ export async function onboard(sys, io, args = []) {
|
|
|
1300
1321
|
const bar = paint.dim('│');
|
|
1301
1322
|
const say = (line) => io.out(`${bar} ${line}`);
|
|
1302
1323
|
const version = packageVersion();
|
|
1324
|
+
// The token onboard's public reads ask GitHub with, so they count against its limit and not the 60 an hour this
|
|
1325
|
+
// Mac's address shares with no token (#546), until the run knows its agent: the agent named, else the settings',
|
|
1326
|
+
// and only with neither any agent machine set up here. Never the owner's sign-in, whose scopes depend on whether an
|
|
1327
|
+
// organisation owns the repository.
|
|
1328
|
+
// The token's item is under the login as the session file spells it, whatever case it was typed or written in.
|
|
1329
|
+
const setUp = agentsSetUp(sys);
|
|
1330
|
+
const known = named[1] ? [named[1]] : settingsAgents(sys, root);
|
|
1331
|
+
const spelled = known.flatMap((login) => [login, ...setUp.filter((one) => one !== login && sameLogin(one, login))]);
|
|
1332
|
+
let readAs = storedToken(sys, known.length > 0 ? spelled : setUp);
|
|
1303
1333
|
// Whether an organisation owns the repository, asked of GitHub once in this run.
|
|
1304
1334
|
let organisation;
|
|
1305
|
-
const byOrganisation = () => (organisation ??= isOrganisation(sys, slug.split('/')[0]));
|
|
1335
|
+
const byOrganisation = () => (organisation ??= isOrganisation(sys, slug.split('/')[0], readAs));
|
|
1306
1336
|
const personal = `${slug} is owned by a personal account, and GitHub has issue types for organisations only`;
|
|
1307
1337
|
// The repository's files are changed only through the agent's pull request at the end: until then each
|
|
1308
1338
|
// change is held here, and read back from here, so the owner's checkout is never modified.
|
|
@@ -1339,7 +1369,7 @@ export async function onboard(sys, io, args = []) {
|
|
|
1339
1369
|
if (aheadHere !== undefined)
|
|
1340
1370
|
return refuseOlder(io, slug, aheadHere, version);
|
|
1341
1371
|
// The workflow and cloud-setup.sh pin this release: a tag off main is not one (P-61).
|
|
1342
|
-
const onMain = await tagOnMain(sys, version);
|
|
1372
|
+
const onMain = await tagOnMain(sys, version, readAs);
|
|
1343
1373
|
if ('problem' in onMain) {
|
|
1344
1374
|
io.err(`onboard: ${onMain.problem}; nothing changed`);
|
|
1345
1375
|
return 1;
|
|
@@ -1421,8 +1451,9 @@ export async function onboard(sys, io, args = []) {
|
|
|
1421
1451
|
notes.push(`- onboard signed in before showing its plan: ${SETTINGS_PATH} names several owners, and only the sign-in tells which one ran it.`);
|
|
1422
1452
|
}
|
|
1423
1453
|
// GitHub's spelling, which the keychain, the session file and commits use.
|
|
1424
|
-
owner = (await account(sys, chosenOwner)).login;
|
|
1425
|
-
agent = (await account(sys, here.agent)).login;
|
|
1454
|
+
owner = (await account(sys, chosenOwner, readAs)).login;
|
|
1455
|
+
agent = (await account(sys, here.agent, readAs)).login;
|
|
1456
|
+
readAs = readToken(sys, agent) ?? readAs;
|
|
1426
1457
|
// Before any change, so a refused --add leaves the settings as they were.
|
|
1427
1458
|
if (add && !features.includes(add) && NEEDS_ISSUE_TYPES.includes(add) && !(await byOrganisation())) {
|
|
1428
1459
|
io.err(`onboard: ${personal}, so ${add} cannot run here`);
|
|
@@ -1499,8 +1530,9 @@ export async function onboard(sys, io, args = []) {
|
|
|
1499
1530
|
if (!isLogin(login))
|
|
1500
1531
|
throw new Error(`"${login}" is not a GitHub login`);
|
|
1501
1532
|
}
|
|
1502
|
-
owner = (await account(sys, namedOwner)).login;
|
|
1503
|
-
agent = (await account(sys, namedAgent)).login;
|
|
1533
|
+
owner = (await account(sys, namedOwner, readAs)).login;
|
|
1534
|
+
agent = (await account(sys, namedAgent, readAs)).login;
|
|
1535
|
+
readAs = readToken(sys, agent) ?? readAs;
|
|
1504
1536
|
if (sameLogin(owner, agent)) {
|
|
1505
1537
|
io.err('onboard: the owner and the agent must be different accounts');
|
|
1506
1538
|
return 1;
|
|
@@ -1552,7 +1584,7 @@ export async function onboard(sys, io, args = []) {
|
|
|
1552
1584
|
io.err(`onboard: this Mac is not set up for ${agent} (${why}); run niyam machine ${agent}, then onboard again`);
|
|
1553
1585
|
return 1;
|
|
1554
1586
|
}
|
|
1555
|
-
const { id } = await account(sys, agent);
|
|
1587
|
+
const { id } = await account(sys, agent, token);
|
|
1556
1588
|
let reach = await access(sys, slug, token);
|
|
1557
1589
|
if (reach.kind === 'refused') {
|
|
1558
1590
|
io.err(`onboard: ${reach.reason}`);
|
package/dist/owner-login.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { API, sameLogin } from './agent.js';
|
|
1
|
+
import { API, publicRead, rateLimited, sameLogin } from './agent.js';
|
|
2
2
|
import { GITHUB_HOST } from './host.js';
|
|
3
3
|
/**
|
|
4
4
|
* The scopes beyond gh's own (repo, read:org, gist) that a run turning
|
|
@@ -10,13 +10,19 @@ export function ownerScopes(features, organisation) {
|
|
|
10
10
|
return [];
|
|
11
11
|
return organisation ? ['project', 'admin:org'] : ['project'];
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Whether GitHub names the account an organisation; throws when GitHub will
|
|
15
|
+
* not say, naming its rate limit when that is why. Asked with `token`, which
|
|
16
|
+
* every caller passes or says it has none of: with none, the read shares the
|
|
17
|
+
* 60 an hour every request from this address has (#546).
|
|
18
|
+
*/
|
|
19
|
+
export async function isOrganisation(sys, login, token) {
|
|
20
|
+
const { answer, token: used } = await publicRead(sys, `${API}/users/${login}`, token);
|
|
21
|
+
const type = answer.json?.type;
|
|
22
|
+
if (answer.status === 200 && typeof type === 'string')
|
|
23
|
+
return type === 'Organization';
|
|
24
|
+
const limited = rateLimited(answer, used);
|
|
25
|
+
throw new Error(`cannot tell whether ${login} is an organisation${limited ? `: ${limited}` : ` (HTTP ${answer.status})`}`);
|
|
20
26
|
}
|
|
21
27
|
/** gh's lines from a sign-in that tell the owner nothing they need: its sign-in tips and the setup it did in the temporary folder. */
|
|
22
28
|
const GH_CHATTER = [/Authentication complete/i, /git_protocol/, /Configured git protocol/i, /plain text/i, /Logged in as/i, /^Did you know/i, /^Tip\b/i];
|
package/dist/release-tag.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { API } from './agent.js';
|
|
1
|
+
import { API, publicRead, rateLimited } from './agent.js';
|
|
2
2
|
import { PRODUCT } from './names.js';
|
|
3
3
|
/** How long GitHub gets to compare a release tag with main. */
|
|
4
4
|
const COMPARE_MS = 15_000;
|
|
@@ -15,19 +15,25 @@ export const RELEASE_BRANCH = 'main';
|
|
|
15
15
|
* is on main. Both refs are written in full, so a branch named like the
|
|
16
16
|
* tag, or a tag named main, is never the one compared. Anything else is a
|
|
17
17
|
* refusal: a tag off main, no such tag, or no answer, each with its own
|
|
18
|
-
* words, so nothing is installed for want of one.
|
|
18
|
+
* words, so nothing is installed for want of one. `onboard` asks with the
|
|
19
|
+
* agent's token, so the compare does not share the 60 an hour this address
|
|
20
|
+
* has with no token (#546); a rate limit run out is named as one.
|
|
19
21
|
*/
|
|
20
|
-
export async function tagOnMain(sys, version) {
|
|
22
|
+
export async function tagOnMain(sys, version, token) {
|
|
21
23
|
const tag = `v${version}`;
|
|
22
|
-
let
|
|
24
|
+
let read;
|
|
23
25
|
try {
|
|
24
|
-
|
|
26
|
+
read = await publicRead(sys, `${API}/repos/${PRODUCT}/compare/refs/tags/${tag}...refs/heads/${RELEASE_BRANCH}?per_page=1`, token, { timeoutMs: COMPARE_MS });
|
|
25
27
|
}
|
|
26
28
|
catch (error) {
|
|
27
29
|
return { problem: `GitHub could not be asked whether the ${tag} tag is on ${RELEASE_BRANCH} (${error instanceof Error ? error.message : String(error)})` };
|
|
28
30
|
}
|
|
31
|
+
const { answer } = read;
|
|
29
32
|
if (answer.status === 404)
|
|
30
33
|
return { problem: `${PRODUCT} has no ${tag} tag that GitHub can compare with ${RELEASE_BRANCH}` };
|
|
34
|
+
const limited = rateLimited(answer, read.token);
|
|
35
|
+
if (limited)
|
|
36
|
+
return { problem: `GitHub could not say whether the ${tag} tag is on ${RELEASE_BRANCH}: ${limited}` };
|
|
31
37
|
if (answer.status !== 200)
|
|
32
38
|
return { problem: `GitHub answered HTTP ${answer.status} when asked whether the ${tag} tag is on ${RELEASE_BRANCH}` };
|
|
33
39
|
const json = answer.json;
|
package/dist/run.js
CHANGED
|
@@ -112,7 +112,8 @@ Commands:
|
|
|
112
112
|
board-audit [owner/repo] [--project <title>]
|
|
113
113
|
Read only: the open issues not on the work board, items whose Status disagrees with
|
|
114
114
|
their issue, and whether the auto-add workflows are on; exit 3 when something is to fix.
|
|
115
|
-
|
|
115
|
+
Reads with GH_TOKEN, else the agent's token from this Mac's keychain; cannot run in
|
|
116
|
+
a Claude cloud session, whose proxy refuses Projects
|
|
116
117
|
help Show this text
|
|
117
118
|
version Print the installed version
|
|
118
119
|
|