@nodii/dev 0.6.3 → 0.6.4

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 CHANGED
@@ -45,7 +45,9 @@ asks you to run `nodii-dev login`.
45
45
  `nodii-dev` is only the Dev control CLI. The local-stack CLI is `./nodii-stack`,
46
46
  run from the `nodii-local-stack` checkout (renamed per operator ruling G3-6,
47
47
  with no alias under the old name). Typing one of its verbs here, such as
48
- `nodii-dev doctor`, fails and names the `./nodii-stack` command instead.
48
+ `nodii-dev provenance`, fails and names the `./nodii-stack` command instead.
49
+ `nodii-dev doctor` is this CLI's own preflight (below); `./nodii-stack doctor`
50
+ checks the local stack.
49
51
 
50
52
  Every command accepts `--json`; without it, output is formatted for humans.
51
53
  Dev failures print Dev's error code to stderr and exit non-zero.
@@ -57,6 +59,7 @@ nodii-dev login [--no-browser] [--scope KEYS]
57
59
  nodii-dev logout
58
60
  nodii-dev whoami # OAuth identity plus the registered agent
59
61
  nodii-dev config show
62
+ nodii-dev doctor [--json] # preflight: everything a lane needs, read-only
60
63
 
61
64
  nodii-dev api list [--tag TAG] [--json]
62
65
  nodii-dev api OPERATION_ID [--param name=value ...] [--body @file|-|JSON]
@@ -252,10 +255,32 @@ source documents moved, and each file created, updated or removed. It
252
255
  removes only files, blocks and hook entries it wrote, and it refuses (writing
253
256
  nothing) when one of its files was edited by hand.
254
257
 
258
+ ## Preflight: `doctor`
259
+
260
+ Run `nodii-dev doctor` from the lane's worktree, with the lane agent's config,
261
+ before `lane start`. It only reads, and prints one line per check: `OK`,
262
+ `MISSING` (with the command that fixes it) or `CANNOT CHECK` (with why). It
263
+ exits 0 only when every check is `OK`. `--json` returns the same checks as
264
+ `{ data: { ok, configPath, configSource, checks: [{ key, status, message, fix?, ... }] } }`.
265
+
266
+ | Check | What it reads |
267
+ | --- | --- |
268
+ | `config` | Which config file is in use: `NODII_DEV_CONFIG_PATH` or the default `~/.config/nodii-dev/config.json`, and whether it is an OAuth login. |
269
+ | `signed_in` | The refresh credential in the keychain, and an access token from it. When nodii-auth rejects the sign-in, it says whether the grant **expired**, was **revoked** or was **replaced**, if the server named which (otherwise it says the server did not). A rejected credential is reported, never cleared. |
270
+ | `agent` | The agent on this config (`agentId`), as Dev reads it back. |
271
+ | `permissions` | The sign-in's permissions against what lane commands need (`devops.issues`, `lanes`, `agents` `.read`/`.write`, `devops.machines.manage`, `devops.decisions.read`/`.write`/`.lock` for Figma locks, `devops.rulebook.read`). Each missing key is listed, with whether the installation has not consented to it or no role grants it. |
272
+ | `machine` | The machine this agent is assigned to and its coordinator. No machine means `lane start` would fail with `MACHINE_REQUIRED`. |
273
+ | `repo` | Whether the repository in this directory is the agent's home repository or granted to it. Repositories are compared by short name (`nodii-clis`, not `owner/nodii-clis`), as Dev compares them. Dev does not let an OAuth agent read its own grants yet (requested in Dev), so a repository other than the home one is `CANNOT CHECK`. |
274
+ | `lane_limit` | The agent's active lanes against its lane limit. A full limit is `OK` when a lane on this branch holds the slot. |
275
+
276
+ Doctor may refresh the access token, as any command does. The permission table
277
+ is kept by hand from Dev's route policy until Dev's OpenAPI names each
278
+ operation's permission (requested in Dev).
279
+
255
280
  ## Build lanes and repository setup
256
281
 
257
- `lane start` creates and starts a lane. It infers the repository, branch and
258
- worktree from git unless overridden, and resolves `--issue` keys to the UUIDs
282
+ `lane start` creates and starts a lane. It infers the repository (by short
283
+ name, as Dev compares it), branch and worktree from git unless overridden, and resolves `--issue` keys to the UUIDs
259
284
  required by Dev. Lane keys are passed directly to every lane and Built
260
285
  acknowledgement route. `next` reads the lane's generated
261
286
  API steps and prints the exact next `lane step` command. Server refusals,
package/dist/cli.js CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  import { heartbeatCurrentLane, postHook, preHook, settingsSnippet, workflowSuggestion } from "./hooks.js";
26
26
  import { setupCommand } from "./setup.js";
27
27
  import { harnessCommand } from "./harness.js";
28
+ import { doctorCommand } from "./doctor.js";
28
29
  import { docsCommand, rulebookCommand } from "./upload.js";
29
30
  import { changeSetCommand, guidelineCommand } from "./guidelines.js";
30
31
  import {
@@ -54,6 +55,7 @@ const HELP = `nodii-dev ${VERSION}
54
55
  Usage: nodii-dev <command> [options] [--json]
55
56
 
56
57
  login | logout | whoami | config show
58
+ doctor [--json] # preflight: sign-in, agent, permissions, machine, repo, lane slots
57
59
  agent register --name NAME | agent heartbeat
58
60
  issues list|show|create|update|claim|release
59
61
  inbox list|show
@@ -101,7 +103,8 @@ Run a command with --help or see the package README for all flags.`;
101
103
 
102
104
  // Verbs of the local-stack CLI, which shared this name until it became
103
105
  // ./nodii-stack (operator G3-6, no alias). Named here only to point there.
104
- const STACK_VERBS = new Set(["up", "down", "doctor", "sync", "seed", "wipe", "reset", "rebuild", "restart", "smoke", "urls", "peek", "trace", "stats", "bootstrap", "provenance", "stale", "status", "logs", "world", "totp", "token", "bench"]);
106
+ // `doctor` is not one of them: `nodii-dev doctor` is this CLI's own preflight.
107
+ const STACK_VERBS = new Set(["up", "down", "sync", "seed", "wipe", "reset", "rebuild", "restart", "smoke", "urls", "peek", "trace", "stats", "bootstrap", "provenance", "stale", "status", "logs", "world", "totp", "token", "bench"]);
105
108
 
106
109
  async function stdinText() {
107
110
  let value = "";
@@ -272,6 +275,13 @@ export async function main(argv = process.argv.slice(2)) {
272
275
  }
273
276
  const emitCommand = async (result) => emit(result.payload, json, result.human);
274
277
  if (command === "setup") return emitCommand(await setupCommand(f));
278
+ if (command === "doctor") {
279
+ if (action) throw new CliError("USAGE", `doctor takes no arguments, got: ${[action, ...rest].join(" ")}`, 2);
280
+ const result = await doctorCommand();
281
+ emit(result.payload, json, result.human);
282
+ if (result.exitCode) process.exitCode = result.exitCode;
283
+ return;
284
+ }
275
285
  if (command === "harness" && ["install", "update"].includes(action)) {
276
286
  // `--include-drafts` is a switch: `--include-drafts false` would leave `false` here and turn drafts on.
277
287
  if (rest.length) throw new CliError("USAGE", `harness ${action} takes no arguments, got: ${rest.join(" ")}. Write a flag value as --include-drafts=false.`, 2);
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ import { chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
4
4
  import { homedir, platform } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
6
 
7
- export const VERSION = "0.6.3";
7
+ export const VERSION = "0.6.4";
8
8
  export const configPath = () =>
9
9
  process.env.NODII_DEV_CONFIG_PATH ??
10
10
  join(homedir(), ".config/nodii-dev/config.json");
package/dist/doctor.js ADDED
@@ -0,0 +1,235 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { devRequest, encode, isOAuthConfig, query, setAuthProvider } from "./core.js";
5
+ import { OAuthAuthProvider, decodeClaims, loadRefreshToken } from "./oauth.js";
6
+ import { inferGitContext, repoName } from "./lanes.js";
7
+
8
+ /**
9
+ * What a lane's commands need, in Dev's route policy (staffRuleFor in Dev's
10
+ * src/lib/auth/staff-policy.ts): an area's reads need `.read` and its writes
11
+ * `.write`; every machine route needs `machines.manage`; Figma file locks live
12
+ * in the decisions area, and releasing one needs `decisions.lock`. Dev's
13
+ * OpenAPI does not name the permission per operation, so this table is kept
14
+ * by hand.
15
+ */
16
+ export const LANE_PERMISSIONS = [
17
+ { key: "devops.issues.read", for: "issues list|show" },
18
+ { key: "devops.issues.write", for: "issues create|update|claim|release, api transitionIssue" },
19
+ { key: "devops.lanes.read", for: "lane show|list, next" },
20
+ { key: "devops.lanes.write", for: "lane start|step|evidence|heartbeat|review|land|verify" },
21
+ { key: "devops.agents.read", for: "whoami, reading this agent" },
22
+ { key: "devops.agents.write", for: "agent register|heartbeat" },
23
+ { key: "devops.machines.manage", for: "machine show (this agent's machine and coordinator)" },
24
+ { key: "devops.decisions.read", for: "figma check" },
25
+ { key: "devops.decisions.write", for: "figma lock|log-write|submit|apply|published|abandon" },
26
+ { key: "devops.decisions.lock", for: "figma release" },
27
+ { key: "devops.rulebook.read", for: "rulebook show" },
28
+ ];
29
+
30
+ // Lane statuses that hold one of the agent's lane slots (Dev's ACTIVE set).
31
+ const ACTIVE = new Set(["queued", "building", "built", "review", "on_main"]);
32
+ const LABEL = { ok: "OK", missing: "MISSING", cannot_check: "CANNOT CHECK" };
33
+
34
+ const ok = (key, message, extra = {}) => ({ key, status: "ok", message, ...extra });
35
+ const missing = (key, message, fix, extra = {}) => ({ key, status: "missing", message, ...(fix ? { fix } : {}), ...extra });
36
+ const cannot = (key, message, extra = {}) => ({ key, status: "cannot_check", message: `cannot check: ${message}`, ...extra });
37
+ const devReason = (error) => [error.code, error.details?.reason].filter(Boolean).join(" ") + (error.message ? `: ${error.message}` : "");
38
+
39
+ /** expired, revoked, replaced, or unspecified — only what nodii-auth said. */
40
+ export function grantReason(grant = {}) {
41
+ if (grant.error === "expired_token") return "expired";
42
+ if (grant.error === "token_revoked") return "revoked";
43
+ const said = String(grant.description ?? "").toLowerCase();
44
+ if (/revok/.test(said)) return "revoked";
45
+ if (/expir/.test(said)) return "expired";
46
+ if (/reuse|replay|rotat|replac|supersed/.test(said)) return "replaced";
47
+ return "unspecified";
48
+ }
49
+
50
+ async function readConfigFile(path) {
51
+ let raw;
52
+ try {
53
+ raw = await readFile(path, "utf8");
54
+ } catch (error) {
55
+ if (error?.code === "ENOENT") return null;
56
+ return { unreadable: error?.code ?? String(error) };
57
+ }
58
+ try { return JSON.parse(raw); } catch { return {}; }
59
+ }
60
+
61
+ /** A provider that never clears a rejected credential: doctor only looks. */
62
+ export function lookingProvider(options = {}) {
63
+ const provider = new OAuthAuthProvider({ ...options, deleteToken: async () => {}, deleteAccess: async () => {} });
64
+ setAuthProvider(provider);
65
+ return provider;
66
+ }
67
+
68
+ async function allLanes(request, agentId) {
69
+ const lanes = [];
70
+ let cursor;
71
+ do {
72
+ const page = await request("GET", `/api/v1/lanes${query({ agent: agentId, cursor, limit: 200 })}`);
73
+ lanes.push(...(page.data ?? []));
74
+ cursor = page.nextCursor ?? undefined;
75
+ } while (cursor);
76
+ return lanes;
77
+ }
78
+
79
+ /**
80
+ * `nodii-dev doctor`: read-only preflight of everything a lane needs, so a
81
+ * missing permission, machine or grant shows before the lane starts.
82
+ */
83
+ export async function doctorCommand(deps = {}) {
84
+ const env = deps.env ?? process.env;
85
+ const path = env.NODII_DEV_CONFIG_PATH ?? (deps.defaultConfigPath ?? (() => join(homedir(), ".config/nodii-dev/config.json")))();
86
+ const configSource = env.NODII_DEV_CONFIG_PATH ? "NODII_DEV_CONFIG_PATH" : "default";
87
+ const request = deps.request ?? devRequest;
88
+ const prefix = env.NODII_DEV_CONFIG_PATH ? `NODII_DEV_CONFIG_PATH=${env.NODII_DEV_CONFIG_PATH} ` : "";
89
+ const loginFix = `${prefix}nodii-dev login`;
90
+ const checks = [];
91
+
92
+ // 1. Config, and which file.
93
+ const config = await (deps.readConfigFile ?? readConfigFile)(path);
94
+ const configOk = isOAuthConfig(config);
95
+ if (config === null) checks.push(missing("config", `no config at ${path} (${configSource})`, loginFix));
96
+ else if (config.unreadable) checks.push(missing("config", `cannot read ${path} (${config.unreadable})`, `check the file's permissions, or ${loginFix}`));
97
+ else if (!configOk) checks.push(missing("config", `${path} is not an OAuth login (written before 0.5.0, or not valid JSON)`, loginFix));
98
+ else checks.push(ok("config", `${path} (${configSource})`));
99
+
100
+ // 2. Signed in: a stored credential, and an access token from it.
101
+ let claims = null;
102
+ if (!configOk) checks.push(missing("signed_in", "not signed in", loginFix));
103
+ else {
104
+ let stored = false;
105
+ try {
106
+ await (deps.loadRefreshToken ?? loadRefreshToken)(config.clientId);
107
+ stored = true;
108
+ } catch {
109
+ checks.push(missing("signed_in", "no stored sign-in credential for this app in the keychain", loginFix));
110
+ }
111
+ if (stored) {
112
+ try {
113
+ const token = await (deps.accessToken ?? (() => lookingProvider().accessToken()))();
114
+ claims = (deps.decodeClaims ?? decodeClaims)(token);
115
+ const minutes = Number.isFinite(claims.exp) ? Math.max(0, Math.floor((claims.exp * 1000 - Date.now()) / 60_000)) : null;
116
+ checks.push(ok("signed_in", `as person ${claims.sub ?? config.person} through installation ${config.installationId ?? "unknown"}${minutes === null ? "" : `; access token valid ${minutes} min`}`,
117
+ { person: claims.sub ?? config.person, installationId: config.installationId ?? null }));
118
+ } catch (error) {
119
+ if (error?.code === "OAUTH_LOGIN_REQUIRED" && error.details?.grant) {
120
+ const reason = grantReason(error.details.grant);
121
+ const why = reason === "unspecified"
122
+ ? `nodii-auth rejected the sign-in (${error.details.grant.error ?? "invalid_grant"}) and did not say whether it expired, was revoked or was replaced`
123
+ : `nodii-auth rejected the sign-in: ${reason}`;
124
+ checks.push(missing("signed_in", why, loginFix, { reason }));
125
+ } else if (error?.code === "OAUTH_LOGIN_REQUIRED") checks.push(missing("signed_in", "no stored sign-in credential for this app in the keychain", loginFix));
126
+ else if (error?.code === "OAUTH_REFRESH_FAILED") checks.push(missing("signed_in", error.message, loginFix));
127
+ else checks.push(cannot("signed_in", `${error?.code ?? "ERROR"}: ${error?.message ?? error}`));
128
+ }
129
+ }
130
+ }
131
+ const signedIn = claims !== null;
132
+
133
+ // 3. Agent registered on this config and recognised by Dev.
134
+ let agent = null;
135
+ const registerFix = `${prefix}nodii-dev agent register --name NAME`;
136
+ if (!signedIn) checks.push(cannot("agent", "needs a sign-in"));
137
+ else if (!config.agentId) checks.push(missing("agent", `no agent registered on ${path}`, registerFix));
138
+ else {
139
+ try {
140
+ agent = (await request("GET", `/api/v1/agents/${encode(config.agentId)}`)).data;
141
+ if (agent.status === "disconnected") {
142
+ checks.push(missing("agent", `agent ${agent.name} (${agent.id}) is disconnected`, registerFix));
143
+ agent = null;
144
+ } else checks.push(ok("agent", `${agent.name} (${agent.id}), ${agent.status}, role ${agent.role}`, { agentId: agent.id, name: agent.name }));
145
+ } catch (error) {
146
+ checks.push(missing("agent", `Dev does not recognise agent ${config.agentId} (${devReason(error)})`, registerFix));
147
+ }
148
+ }
149
+
150
+ // 4. Permissions: the installation's consent and the person's roles, as the token carries them.
151
+ if (!signedIn) checks.push(cannot("permissions", "needs a sign-in"));
152
+ else if (!Array.isArray(claims.permissions)) checks.push(cannot("permissions", "the access token carries no permissions claim"));
153
+ else {
154
+ const granted = new Set(claims.permissions);
155
+ const consented = new Set(Array.isArray(claims.grant_scope) ? claims.grant_scope : claims.permissions);
156
+ const gaps = LANE_PERMISSIONS.filter((x) => !granted.has(x.key)).map((x) => ({ key: x.key, for: x.for, why: consented.has(x.key) ? "no_role" : "not_consented" }));
157
+ if (!gaps.length) checks.push(ok("permissions", `all ${LANE_PERMISSIONS.length} permissions a lane needs are granted`, { missing: [] }));
158
+ else {
159
+ const text = gaps.map((x) => `${x.key} (${x.why === "not_consented" ? "installation has not consented" : "consented, but no role grants it"}; for ${x.for})`).join(", ");
160
+ const fixes = [
161
+ ...(gaps.some((x) => x.why === "not_consented") ? [`re-consent the nodii-dev installation, then ${loginFix}`] : []),
162
+ ...(gaps.some((x) => x.why === "no_role") ? ["ask a Dev admin for a role that grants the missing keys, then sign in again"] : []),
163
+ ];
164
+ checks.push(missing("permissions", `missing ${text}`, fixes.join("; "), { missing: gaps }));
165
+ }
166
+ }
167
+
168
+ // 5. Machine and its coordinator.
169
+ if (!agent) checks.push(cannot("machine", "needs a registered agent"));
170
+ else if (!agent.machineId)
171
+ checks.push(missing("machine", "this agent is not assigned to a machine; lane start fails with MACHINE_REQUIRED",
172
+ `ask the machine's coordinator: nodii-dev machine assign <machine> ${agent.id} --home-repo <repo>`));
173
+ else {
174
+ try {
175
+ const machine = (await request("GET", `/api/v1/machines/${encode(agent.machineId)}`)).data;
176
+ const coordinator = (machine.agents ?? []).find((x) => x.id === machine.coordinatorAgentId);
177
+ checks.push(ok("machine", `${machine.name} (${machine.id}); coordinator ${machine.coordinatorAgentId ? `${coordinator?.name ?? "agent"} (${machine.coordinatorAgentId})` : "none set"}`,
178
+ { machineId: machine.id, machineName: machine.name, coordinatorAgentId: machine.coordinatorAgentId ?? null, coordinatorName: coordinator?.name ?? null }));
179
+ } catch (error) {
180
+ checks.push(cannot("machine", `assigned to ${agent.machineId}, but getMachine failed (${devReason(error)})`, { machineId: agent.machineId }));
181
+ }
182
+ }
183
+
184
+ // 6. Home repo or a grant for the repository in this directory, by short name.
185
+ let context = null;
186
+ if (!agent) checks.push(cannot("repo", "needs a registered agent"));
187
+ else {
188
+ try {
189
+ context = await (deps.gitContext ?? inferGitContext)();
190
+ } catch (error) {
191
+ checks.push(cannot("repo", `${error?.code === "GIT_REQUIRED" ? "not in a git worktree on a branch" : (error?.message ?? error)}; run doctor from the lane's worktree`));
192
+ }
193
+ if (context) {
194
+ const repo = repoName(context.repo);
195
+ if (agent.homeRepo && repoName(agent.homeRepo) === repo) checks.push(ok("repo", `${repo} is this agent's home repository`, { repo, homeRepo: agent.homeRepo }));
196
+ else {
197
+ try {
198
+ const grants = (await request("GET", `/api/v1/agents/${encode(agent.id)}/repo-grants`)).data ?? [];
199
+ if (grants.some((x) => !x.revokedAt && repoName(x.repo) === repo)) checks.push(ok("repo", `${repo} is granted to this agent (home ${agent.homeRepo ?? "none"})`, { repo, homeRepo: agent.homeRepo ?? null }));
200
+ else checks.push(missing("repo", `${repo} is neither the home repository (${agent.homeRepo ?? "none"}) nor granted; lane start fails with REPO_NOT_GRANTED`,
201
+ `nodii-dev agent grant ${agent.id} ${repo}`, { repo, homeRepo: agent.homeRepo ?? null }));
202
+ } catch (error) {
203
+ checks.push(cannot("repo", `${repo} is not the home repository (${agent.homeRepo ?? "none"}), and listAgentRepoGrants failed (${devReason(error)})`, { repo, homeRepo: agent.homeRepo ?? null }));
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ // 7. Lane limit: a free slot, or a lane on this branch already holding one.
210
+ if (!agent) checks.push(cannot("lane_limit", "needs a registered agent"));
211
+ else {
212
+ try {
213
+ const active = (await allLanes(request, agent.id)).filter((x) => ACTIVE.has(x.status));
214
+ const limit = agent.laneLimit ?? 1;
215
+ const here = (x) => x.branch === context.branch && (!Array.isArray(x.repos) || x.repos.map(repoName).includes(repoName(context.repo)));
216
+ const mine = context && active.find(here);
217
+ const keys = active.map((x) => x.key).join(", ");
218
+ const extra = { active: active.length, limit, lanes: active.map((x) => x.key) };
219
+ if (active.length < limit) checks.push(ok("lane_limit", `${active.length} of ${limit} lane slots in use${keys ? ` (${keys})` : ""}`, extra));
220
+ else if (mine) checks.push(ok("lane_limit", `${active.length} of ${limit} lane slots in use; ${mine.key} on this branch holds one`, extra));
221
+ else checks.push(missing("lane_limit", `${active.length} of ${limit} lane slots in use (${keys}); lane start fails with LANE_LIMIT_REACHED`,
222
+ `land or stop a lane, or ask the coordinator: nodii-dev agent lane-limit ${agent.id} <n>`, extra));
223
+ } catch (error) {
224
+ checks.push(cannot("lane_limit", `listLanes failed (${devReason(error)})`));
225
+ }
226
+ }
227
+
228
+ const ready = checks.every((x) => x.status === "ok");
229
+ const width = Math.max(...checks.map((x) => x.key.length));
230
+ const human = (p) => [
231
+ ...p.data.checks.map((x) => `${LABEL[x.status].padEnd(12)} ${x.key.padEnd(width)} ${x.message}${x.fix ? ` — fix: ${x.fix}` : ""}`),
232
+ p.data.ok ? "Ready for a lane." : `Not ready: ${p.data.checks.filter((x) => x.status !== "ok").map((x) => x.key).join(", ")}.`,
233
+ ].join("\n");
234
+ return { payload: { data: { ok: ready, configPath: path, configSource, checks } }, human, exitCode: ready ? 0 : 1 };
235
+ }
package/dist/lanes.js CHANGED
@@ -18,15 +18,21 @@ async function git(...args) {
18
18
  }
19
19
  }
20
20
 
21
+ /**
22
+ * A repository as Dev names it: the short name. Dev compares a lane's repos
23
+ * exactly against the agent's home repo and grants, which are short names, so
24
+ * `owner/name` from the remote was refused as REPO_NOT_GRANTED.
25
+ */
26
+ export const repoName = (remoteOrPath) => String(remoteOrPath).replace(/\/+$/, "").replace(/\.git$/, "").split(/[/:]/).filter(Boolean).at(-1);
27
+
21
28
  export async function inferGitContext() {
22
29
  const worktree = await git("rev-parse", "--show-toplevel");
23
30
  const branch = await git("branch", "--show-current");
24
31
  let repo;
25
32
  try {
26
- const remote = await git("remote", "get-url", "origin");
27
- repo = remote.replace(/\.git$/, "").replace(/^git@[^:]+:/, "").replace(/^https?:\/\/[^/]+\//, "");
33
+ repo = repoName(await git("remote", "get-url", "origin"));
28
34
  } catch {
29
- repo = worktree.split("/").filter(Boolean).at(-1);
35
+ repo = repoName(worktree);
30
36
  }
31
37
  return { repo, branch: need(branch, "Detached HEAD: pass --branch."), worktree };
32
38
  }
package/dist/oauth.js CHANGED
@@ -440,7 +440,10 @@ export class OAuthAuthProvider {
440
440
  await this.deleteToken(config.clientId);
441
441
  await this.deleteAccess(config.clientId);
442
442
  }
443
- throw new CliError("OAUTH_LOGIN_REQUIRED", `nodii-auth no longer accepts this sign-in (invalid_grant: expired, revoked or replayed)${cleared ? " and the saved credential was cleared" : ""}; run \`nodii-dev login\` again.`, 2);
443
+ // What the server said, so `doctor` can name expired, revoked or replaced.
444
+ const said = (key) => (typeof result.body[key] === "string" ? result.body[key] : undefined);
445
+ const grant = Object.fromEntries([["error", said("error")], ["description", said("error_description")]].filter(([, v]) => v !== undefined));
446
+ throw new CliError("OAUTH_LOGIN_REQUIRED", `nodii-auth no longer accepts this sign-in (invalid_grant: expired, revoked or replayed)${cleared ? " and the saved credential was cleared" : ""}; run \`nodii-dev login\` again.`, 2, { grant });
444
447
  }
445
448
  if (kind === "retry")
446
449
  throw new CliError("OAUTH_REFRESH_UNAVAILABLE", `Could not refresh the sign-in (${describe(result)}) after ${attempts} attempt${attempts === 1 ? "" : "s"}; the saved credential was kept. Retry the command shortly.`, 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nodii/dev",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Agent CLI for Nodii Dev, reached through the platform edge",
5
5
  "type": "module",
6
6
  "bin": {