@nolto/cli 0.23.1 → 0.24.0

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.
Files changed (3) hide show
  1. package/README.md +45 -6
  2. package/dist/index.js +119 -24
  3. package/package.json +4 -4
package/README.md CHANGED
@@ -35,6 +35,11 @@ For browser-based authentication without the rest of the repository setup:
35
35
  nolto login
36
36
  ```
37
37
 
38
+ `nolto login` prints a URL and a confirmation code (`XXXX-XXXX`). Open the URL in a
39
+ browser, type the code shown in your terminal, and approve. The URL does not contain
40
+ the code. Approve only a login you started yourself; reject any code or link someone
41
+ else sent you.
42
+
38
43
  ## Commands
39
44
 
40
45
  ### Setup and Authentication
@@ -42,9 +47,29 @@ nolto login
42
47
  ```bash
43
48
  nolto init [--force] # Interactive project and repository setup
44
49
  nolto login [--force] # Authenticate in the browser and save the API token
45
- nolto whoami # Show resolved auth/config state and project count
50
+ nolto logout # Revoke the saved API token and remove it from the config file
51
+ nolto whoami # Show resolved auth/config state, token expiry and project count
46
52
  ```
47
53
 
54
+ A token issued by `nolto login` expires after 90 days and is not extended; when it
55
+ expires (HTTP 401), run `nolto login` again. `nolto whoami` shows the expiry date
56
+ and, within 7 days of it, a reminder. The memory hook (`nolto memory pull --hook`)
57
+ also tells you to run `nolto login` on a 401.
58
+
59
+ `nolto logout` asks the server to revoke the saved token (`POST /api/me/token/revoke`),
60
+ then removes only `token` from the config file (`baseUrl` stays) and clears the
61
+ memory caches. If the server cannot be reached, does not have the route yet (404),
62
+ or answers 401, the local token is still removed, a warning says to confirm the
63
+ revocation under "API トークン" in the web app, and the exit code is 0. A token
64
+ from `NOLTO_TOKEN` cannot be removed by the CLI: unset the variable and revoke the
65
+ token in the web app. Logout revokes at the `baseUrl` saved in the config file
66
+ (`https://nolto.app` when absent), not at `NOLTO_BASE_URL`.
67
+
68
+ `nolto login` saves the token together with the base URL it actually used
69
+ (`--base-url`, `NOLTO_BASE_URL` or the default). That base URL is where the token was
70
+ issued. After `nolto login --base-url <staging>`, a plain `nolto ...` also goes to
71
+ staging.
72
+
48
73
  ### Repository Binding
49
74
 
50
75
  To add a second repository to an existing project, run `nolto init` or
@@ -256,7 +281,7 @@ List output is one line per issue plus `n / total (page p)`. View includes body
256
281
  |---|---|
257
282
  | 0 | Success |
258
283
  | 2 | Invalid input, recognized API 404, HTTP 422 (details shown), secret_detected (possible secret; message shown), internal_references (confirmation required), or roadmap cache/sync failure after creation |
259
- | 3 | HTTP 401/403; token_scope/token_project includes a token settings hint |
284
+ | 3 | HTTP 401/403; token_scope/token_project includes a token settings hint; the config token was issued for another base URL (`token_origin_mismatch`) |
260
285
  | 4 | Plan / quota limit (HTTP 402) or rate limit (HTTP 429); resolve or wait before retrying. Token writes: 60/minute; wait Retry-After seconds before retrying. |
261
286
  | 5 | Network/generic HTTP errors, including a 404 without an API error string |
262
287
 
@@ -294,6 +319,20 @@ Environment variables:
294
319
  | `NOLTO_BASE_URL` | Base URL (default: `https://nolto.app`) |
295
320
  | `NOLTO_PROJECT` | Default project ID fallback |
296
321
 
322
+ A token in the config file is only sent to the base URL saved with it. Pointing
323
+ `NOLTO_BASE_URL` or `--base-url` at another host does not send that token: the command
324
+ exits 3 (JSON error `code`: `token_origin_mismatch`) and says to run
325
+ `nolto login --base-url <that host>` or to use `NOLTO_TOKEN`. A config file without
326
+ `baseUrl` counts as issued by `https://nolto.app`. A token from `NOLTO_TOKEN` or
327
+ `--token` is not checked; you choose where it goes. `nolto memory pull --hook` prints
328
+ the same guidance instead of failing. `login`, `logout`, `update` and `merge-file` skip the check.
329
+
330
+ The base URL must be `https://`; `http://` is accepted only for `localhost`,
331
+ `127.0.0.1` and `[::1]`. Anything else exits 2, whether it comes from a flag, the
332
+ environment or the config file. The Base URL typed into the `nolto init` prompt gets the
333
+ same check, and `nolto init` does not offer to keep the config token for a different
334
+ origin.
335
+
297
336
  Repository binding (`nolto.json`):
298
337
 
299
338
  ```json
@@ -322,10 +361,10 @@ Errors are written to stderr:
322
361
  ```json
323
362
  {
324
363
  "error": {
325
- "message": "Unauthorized",
364
+ "message": "token の期限が切れたか、失効しています。`nolto login` を実行してください",
326
365
  "exitCode": 3,
327
366
  "status": 401,
328
- "hint": "Run `nolto init` to configure a token, or set the NOLTO_TOKEN environment variable."
367
+ "hint": "token を設定していないときは `nolto init`、環境変数 NOLTO_TOKEN の token は新しいものに差し替えてください。"
329
368
  }
330
369
  }
331
370
  ```
@@ -338,8 +377,8 @@ Issue validation and API 404 with an error string exit 2; 422 includes details.
338
377
  |---|---|
339
378
  | 0 | Success |
340
379
  | 1 | Roadmap differences found (`nolto diff`) or unexpected command failure |
341
- | 2 | Local input or file validation error |
342
- | 3 | Authentication or authorization error |
380
+ | 2 | Local input or file validation error (including a base URL that is not `https://` or localhost `http://`) |
381
+ | 3 | Authentication or authorization error (including `token_origin_mismatch`) |
343
382
  | 4 | Action needed before retrying: roadmap sync conflict, expired base revision, unsynced local changes blocking `nolto pull` / `nolto init` / `nolto link` / `nolto roadmap` task updates (resolve with `nolto pull` / `nolto roadmap sync`, then retry), rate limit response (HTTP 429, including the `nolto link --rebind` cooldown), or plan / quota limit (HTTP 402). API token writes: 60/minute; server message and Retry-After are displayed. |
344
383
  | 5 | Network, DNS, or server error |
345
384
 
package/dist/index.js CHANGED
@@ -26,6 +26,13 @@ var CliError = class extends Error {
26
26
  detail;
27
27
  retryAfter;
28
28
  };
29
+ var TOKEN_EXPIRED_MESSAGE = "token \u306E\u671F\u9650\u304C\u5207\u308C\u305F\u304B\u3001\u5931\u52B9\u3057\u3066\u3044\u307E\u3059\u3002`nolto login` \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044";
30
+ function tokenOriginMismatchMessage(m) {
31
+ return `\u8A2D\u5B9A\u306E token \u306F ${m.issuedBy} \u3067\u767A\u884C\u3055\u308C\u305F\u3082\u306E\u3067\u3059\u3002${m.sentTo} \u306B\u306F\u9001\u308A\u307E\u305B\u3093\u3002\`nolto login --base-url ${m.sentTo}\` \u3067\u53D6\u308A\u76F4\u3059\u304B\u3001\`NOLTO_TOKEN\` \u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002`;
32
+ }
33
+ function tokenOriginMismatchError(m) {
34
+ return new CliError(tokenOriginMismatchMessage(m), 3, void 0, void 0, "token_origin_mismatch");
35
+ }
29
36
  function projectRequiredError() {
30
37
  return new CliError(
31
38
  "\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u304C\u6C7A\u307E\u308A\u307E\u305B\u3093\u3002nolto.json \u306E\u3042\u308B\u30EA\u30DD\u30B8\u30C8\u30EA(\u304B\u3001\u305D\u306E\u4E0B)\u3067\u5B9F\u884C\u3059\u308B\u304B\u3001--project <id> / NOLTO_PROJECT \u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
@@ -40,9 +47,9 @@ function mapHttpStatusToCliError(status, opts = {}) {
40
47
  if (status === 401) {
41
48
  const detail = opts.wwwAuthenticate ? ` (${opts.wwwAuthenticate})` : "";
42
49
  return new CliError(
43
- `Unauthorized${detail}`,
50
+ `${TOKEN_EXPIRED_MESSAGE}${detail}`,
44
51
  3,
45
- "Run `nolto init` to configure a token, or set the NOLTO_TOKEN environment variable.",
52
+ "token \u3092\u8A2D\u5B9A\u3057\u3066\u3044\u306A\u3044\u3068\u304D\u306F `nolto init`\u3001\u74B0\u5883\u5909\u6570 NOLTO_TOKEN \u306E token \u306F\u65B0\u3057\u3044\u3082\u306E\u306B\u5DEE\u3057\u66FF\u3048\u3066\u304F\u3060\u3055\u3044\u3002",
46
53
  status,
47
54
  opts.serverError,
48
55
  opts.body
@@ -519,10 +526,10 @@ var configSchema = z.object({
519
526
  token: z.string().min(1).optional(),
520
527
  baseUrl: z.string().url().optional(),
521
528
  // NF-165 で廃止。読まない。
522
- defaultProjectId: z.string().uuid().optional()
529
+ defaultProjectId: z.guid().optional()
523
530
  }).strict();
524
531
  var repoBindingSchema = z.object({
525
- projectId: z.string().uuid(),
532
+ projectId: z.guid(),
526
533
  roadmapSlug: z.string().regex(/^[a-z0-9][a-z0-9._-]*$/).optional()
527
534
  }).passthrough();
528
535
  async function loadRepoBinding(filePath) {
@@ -666,6 +673,21 @@ function resolveProjectId(args) {
666
673
  }
667
674
  return { projectId: void 0, projectSource: "none" };
668
675
  }
676
+ function originOf(url) {
677
+ return new URL(url).origin;
678
+ }
679
+ function validateBaseUrl(url) {
680
+ let parsed;
681
+ try {
682
+ parsed = new URL(url);
683
+ } catch {
684
+ throw new CliError(`Invalid base URL: ${url}`, 2);
685
+ }
686
+ const localhost = parsed.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(parsed.hostname);
687
+ if (parsed.protocol !== "https:" && !localhost) {
688
+ throw new CliError(`Base URL must use https:// (http:// is allowed only for localhost): ${url}`, 2);
689
+ }
690
+ }
669
691
  function resolveSettings(args) {
670
692
  const { flags, env, file, repoBinding } = args;
671
693
  let token;
@@ -694,6 +716,17 @@ function resolveSettings(args) {
694
716
  } else {
695
717
  baseUrl = DEFAULT_BASE_URL;
696
718
  }
719
+ validateBaseUrl(baseUrl);
720
+ let tokenOriginMismatch;
721
+ if (tokenSource === "file") {
722
+ const issuedBy = originOf(file?.baseUrl ?? DEFAULT_BASE_URL);
723
+ const sentTo = originOf(baseUrl);
724
+ if (issuedBy !== sentTo) {
725
+ tokenOriginMismatch = { issuedBy, sentTo };
726
+ token = void 0;
727
+ tokenSource = "none";
728
+ }
729
+ }
697
730
  const { projectId, projectSource } = resolveProjectId({
698
731
  flagProject: flags.project,
699
732
  envProject: env["NOLTO_PROJECT"],
@@ -703,6 +736,7 @@ function resolveSettings(args) {
703
736
  token,
704
737
  baseUrl,
705
738
  projectId,
739
+ ...tokenOriginMismatch ? { tokenOriginMismatch } : {},
706
740
  source: { token: tokenSource, baseUrl: baseUrlSource, project: projectSource }
707
741
  };
708
742
  }
@@ -1647,7 +1681,7 @@ import path8 from "path";
1647
1681
  import { z as z3 } from "zod";
1648
1682
  var registrySchema = z3.object({
1649
1683
  schemaVersion: z3.literal(1),
1650
- repos: z3.array(z3.object({ root: z3.string().min(1), projectId: z3.string().uuid().optional() }).passthrough())
1684
+ repos: z3.array(z3.object({ root: z3.string().min(1), projectId: z3.guid().optional() }).passthrough())
1651
1685
  }).passthrough();
1652
1686
  function getRegistryPath(env) {
1653
1687
  return path8.join(getConfigDir(env), "registry.json");
@@ -3709,7 +3743,9 @@ function register5(program, deps) {
3709
3743
  if (configureGlobal) {
3710
3744
  const rawUrl = await rl.question(`Base URL [${DEFAULT_BASE_URL}]: `);
3711
3745
  baseUrl = rawUrl.trim() || DEFAULT_BASE_URL;
3712
- const currentToken = deps.settings.token;
3746
+ validateBaseUrl(baseUrl);
3747
+ const issuedElsewhere = deps.settings.source.token === "file" && originOf(baseUrl) !== originOf(deps.settings.baseUrl);
3748
+ const currentToken = issuedElsewhere ? void 0 : deps.settings.token;
3713
3749
  const tokenPrompt = currentToken != null ? "API token [press Enter to keep current token]: " : "API token: ";
3714
3750
  const enteredToken = await promptHidden(rl, tokenPrompt);
3715
3751
  token = enteredToken.length > 0 ? enteredToken : currentToken ?? "";
@@ -4005,11 +4041,11 @@ function register6(program, deps) {
4005
4041
  throw err;
4006
4042
  }
4007
4043
  writeOut("\n");
4008
- writeOut("Open the following URL in your browser to log in:\n\n");
4044
+ writeOut("Open the following URL in your browser and enter the confirmation code shown below:\n\n");
4009
4045
  writeOut(` ${startResp.verification_url}
4010
4046
 
4011
4047
  `);
4012
- writeOut(`Your confirmation code: ${startResp.user_code}
4048
+ writeOut(` Confirmation code: ${startResp.user_code}
4013
4049
 
4014
4050
  `);
4015
4051
  writeOut("Waiting for browser confirmation...\n");
@@ -4020,9 +4056,8 @@ function register6(program, deps) {
4020
4056
  expiresIn: startResp.expires_in,
4021
4057
  baseUrl: settings.baseUrl
4022
4058
  });
4023
- const existingConfig = await loadConfigFile(configPath).catch(() => null);
4024
4059
  const newConfig = {
4025
- baseUrl: existingConfig?.baseUrl,
4060
+ baseUrl: settings.baseUrl,
4026
4061
  token
4027
4062
  };
4028
4063
  await clearMemoryCaches(configPath);
@@ -4042,8 +4077,50 @@ function register6(program, deps) {
4042
4077
  );
4043
4078
  }
4044
4079
 
4045
- // src/commands/whoami.ts
4080
+ // src/commands/logout.ts
4046
4081
  function register7(program, deps) {
4082
+ program.command("logout").description("Revoke the saved API token and remove it from the config file.").action(async () => {
4083
+ const { configPath, settings, output } = deps;
4084
+ const existing = await loadConfigFile(configPath).catch(() => null);
4085
+ const fileToken = existing?.token;
4086
+ const envToken = settings.source.token === "env";
4087
+ let revoked = false;
4088
+ if (fileToken) {
4089
+ try {
4090
+ const issuedBy = existing?.baseUrl ?? DEFAULT_BASE_URL;
4091
+ validateBaseUrl(issuedBy);
4092
+ const http = createHttpClient({ baseUrl: issuedBy, version: deps.version, token: fileToken });
4093
+ await http.post("/api/me/token/revoke", {});
4094
+ revoked = true;
4095
+ } catch {
4096
+ }
4097
+ await clearMemoryCaches(configPath);
4098
+ await saveConfigFile(configPath, { baseUrl: existing?.baseUrl });
4099
+ }
4100
+ if (output.mode === "json") {
4101
+ printResult({ ok: true, revoked, removed: fileToken != null, envToken }, "json");
4102
+ return;
4103
+ }
4104
+ if (fileToken == null) writeOut("\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u306B\u4FDD\u5B58\u3055\u308C\u305F token \u306F\u3042\u308A\u307E\u305B\u3093\u3002\n");
4105
+ else if (revoked) writeOut("token \u3092\u5931\u52B9\u3057\u3001\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u304B\u3089\u6D88\u3057\u307E\u3057\u305F\u3002\n");
4106
+ else writeErr("Warning: \u624B\u5143\u306E token \u306F\u6D88\u3057\u307E\u3057\u305F\u3002\u30B5\u30FC\u30D0\u30FC\u3067\u306E\u5931\u52B9\u3092\u78BA\u304B\u3081\u308B\u306B\u306F\u3001\u753B\u9762\u306E\u300EAPI \u30C8\u30FC\u30AF\u30F3\u300F\u3092\u958B\u3044\u3066\u304F\u3060\u3055\u3044\n");
4107
+ if (envToken) writeOut("\u74B0\u5883\u5909\u6570 NOLTO_TOKEN \u306E token \u306F\u6D88\u305B\u307E\u305B\u3093\u3002\u74B0\u5883\u5909\u6570\u3092\u5916\u3057\u3001\u753B\u9762\u306E\u300EAPI \u30C8\u30FC\u30AF\u30F3\u300F\u3067\u5931\u52B9\u3057\u3066\u304F\u3060\u3055\u3044\u3002\n");
4108
+ });
4109
+ }
4110
+
4111
+ // src/commands/whoami.ts
4112
+ var EXPIRY_WARNING_MS = 7 * 24 * 60 * 60 * 1e3;
4113
+ function tokenExpiry(expiresAt) {
4114
+ if (!expiresAt) return void 0;
4115
+ const at = new Date(expiresAt);
4116
+ if (Number.isNaN(at.getTime())) return void 0;
4117
+ const pad = (n) => String(n).padStart(2, "0");
4118
+ return {
4119
+ date: `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`,
4120
+ soon: at.getTime() - Date.now() <= EXPIRY_WARNING_MS
4121
+ };
4122
+ }
4123
+ function register8(program, deps) {
4047
4124
  program.command("whoami").description("Show the current authentication and configuration state.").action(async () => {
4048
4125
  const { settings, output, configPath } = deps;
4049
4126
  const mode2 = output.mode;
@@ -4068,6 +4145,7 @@ function register7(program, deps) {
4068
4145
  } catch {
4069
4146
  }
4070
4147
  }
4148
+ const expiry = tokenExpiry(tokenInfo?.expiresAt);
4071
4149
  const projectBindingPath = deps.repoBinding?.path ?? deps.projectBindingPath ?? null;
4072
4150
  if (mode2 === "json") {
4073
4151
  printResult(
@@ -4081,7 +4159,8 @@ function register7(program, deps) {
4081
4159
  projectSource: settings.source.project,
4082
4160
  projectBindingPath: projectBindingPath ?? null,
4083
4161
  projects: projectCount ?? null,
4084
- ...tokenInfo ? { tokenScopes: tokenInfo.scopes, tokenProject: tokenInfo.projectId } : {}
4162
+ ...tokenInfo ? { tokenScopes: tokenInfo.scopes, tokenProject: tokenInfo.projectId } : {},
4163
+ ...tokenInfo?.expiresAt !== void 0 ? { tokenExpiresAt: tokenInfo.expiresAt } : {}
4085
4164
  },
4086
4165
  mode2
4087
4166
  );
@@ -4097,11 +4176,16 @@ function register7(program, deps) {
4097
4176
  ];
4098
4177
  if (tokenInfo) {
4099
4178
  lines.push(["scopes", tokenInfo.scopes === null ? "full" : tokenInfo.scopes.join(", ")], ["tokenProject", tokenInfo.projectId ?? "all"]);
4179
+ if (tokenInfo.expiresAt !== void 0) lines.push(["expires", expiry?.date ?? "none"]);
4100
4180
  }
4101
4181
  const legacyConfig = await loadConfigFile(configPath).catch(() => null);
4102
4182
  const maxKey = lines.reduce((m, [k]) => Math.max(m, k.length), 0);
4103
4183
  for (const [key, val] of lines) {
4104
4184
  writeOut(`${key.padEnd(maxKey)}: ${val}
4185
+ `);
4186
+ }
4187
+ if (expiry?.soon) {
4188
+ writeOut(`token \u306E\u671F\u9650\u306F ${expiry.date} \u3067\u3059\u3002\`nolto login\` \u3067\u53D6\u308A\u76F4\u305B\u307E\u3059
4105
4189
  `);
4106
4190
  }
4107
4191
  if (legacyConfig?.defaultProjectId) {
@@ -4213,7 +4297,7 @@ function formatRoadmapDiff(slug, entries) {
4213
4297
  }
4214
4298
 
4215
4299
  // src/commands/diff.ts
4216
- function register8(program, deps) {
4300
+ function register9(program, deps) {
4217
4301
  program.command("diff [slug]").description("Compare local roadmaps with the server without changing either side.").action(async (requestedSlug) => {
4218
4302
  const { projectId } = await resolveRoadmapReadContext(deps);
4219
4303
  const list = await deps.http.get(
@@ -4280,7 +4364,7 @@ function register8(program, deps) {
4280
4364
  // src/commands/roadmap.ts
4281
4365
  import { readFile as readFile14 } from "fs/promises";
4282
4366
  import { existsSync as existsSync6 } from "fs";
4283
- function register9(program, deps) {
4367
+ function register10(program, deps) {
4284
4368
  const roadmap = program.command("roadmap").description("Read and update server roadmaps through the local cache.");
4285
4369
  roadmap.command("schema").description("Print the roadmap schema reference").action(async () => {
4286
4370
  const bundled = new URL("./roadmap-schema-reference.md", import.meta.url);
@@ -4705,7 +4789,7 @@ async function stopServiceWith(deps) {
4705
4789
  }
4706
4790
 
4707
4791
  // src/commands/watch.ts
4708
- function register10(program, deps) {
4792
+ function register11(program, deps) {
4709
4793
  const watch = program.command("watch").description("Watch every registered repository's roadmap + plan files and sync on change.").option("--debounce <ms>", "Debounce window in milliseconds", "2000").option("--install-service", "Install and start a background service (systemd user unit on Linux, launchd agent on macOS) instead of watching").option("--uninstall-service", "Stop and remove the background service instead of watching").action(async (opts) => {
4710
4794
  if (opts.installService && opts.uninstallService) {
4711
4795
  throw new CliError("--install-service and --uninstall-service cannot be used together.", 2);
@@ -5176,7 +5260,7 @@ async function updateCli(opts = {}) {
5176
5260
  }
5177
5261
 
5178
5262
  // src/commands/update.ts
5179
- function register11(program, deps) {
5263
+ function register12(program, deps) {
5180
5264
  program.command("update").description("Update @nolto/cli to the latest version and restart the watch service if installed").action(async () => {
5181
5265
  const mode2 = deps.output.mode;
5182
5266
  const result = await updateCli({ quiet: mode2 === "json" });
@@ -5442,7 +5526,7 @@ async function readRoadmap(filePath) {
5442
5526
  }
5443
5527
  return parsed;
5444
5528
  }
5445
- function register12(program) {
5529
+ function register13(program) {
5446
5530
  program.command("merge-file <ours> <theirs>").description(
5447
5531
  'Structurally merge roadmap files for Git.\ngit config merge.nolto-roadmap.driver "nolto merge-file %A %B --base %O"'
5448
5532
  ).option("--base <path>", "Common ancestor roadmap file").option("--output <path>", "Write the result here (defaults to <ours>)").action(async (oursPath, theirsPath, opts) => {
@@ -5580,6 +5664,10 @@ async function pull2(deps, opts) {
5580
5664
  if (opts.hook && !explicitProject && !(deps.repoBinding?.path ?? deps.projectBindingPath)) {
5581
5665
  return;
5582
5666
  }
5667
+ if (opts.hook && deps.settings.tokenOriginMismatch) {
5668
+ process.stdout.write(hookOutput(opts.hook, terminalLine(tokenOriginMismatchMessage(deps.settings.tokenOriginMismatch))));
5669
+ return;
5670
+ }
5583
5671
  if (opts.hook && !deps.settings.token) {
5584
5672
  process.stdout.write(hookOutput(opts.hook, "nolto login \u3092\u5B9F\u884C\u3057\u3066\u304F\u3060\u3055\u3044"));
5585
5673
  return;
@@ -5640,7 +5728,8 @@ async function pull2(deps, opts) {
5640
5728
  } catch (error) {
5641
5729
  if (!opts.hook) throw error;
5642
5730
  let text = pullHint;
5643
- if (ctx?.cache.meta.pulledAt) {
5731
+ if (error instanceof CliError && error.status === 401) text = TOKEN_EXPIRED_MESSAGE;
5732
+ else if (ctx?.cache.meta.pulledAt) {
5644
5733
  try {
5645
5734
  const age = Math.max(0, Math.floor((Date.now() - Date.parse(ctx.cache.meta.pulledAt)) / 6e4));
5646
5735
  text = `(\u6700\u7D42\u540C\u671F ${Number.isFinite(age) ? age : "\u4E0D\u660E"} \u5206\u524D\u3002\u4ECA\u56DE\u306F\u540C\u671F\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F)
@@ -5661,7 +5750,7 @@ async function inputText(file) {
5661
5750
  for await (const chunk of process.stdin) text += chunk;
5662
5751
  return text;
5663
5752
  }
5664
- function register13(program, deps) {
5753
+ function register14(program, deps) {
5665
5754
  const memory = program.command("memory").description("Read and write project memory.");
5666
5755
  memory.command("pull").option("--hook [agent]", "SessionStart output; always exit 0").option("--scope <csv>").action((opts) => pull2(deps, opts));
5667
5756
  memory.command("context").action(async () => {
@@ -5846,29 +5935,35 @@ function buildProgram(deps) {
5846
5935
  const writeErr2 = (_msg) => {
5847
5936
  };
5848
5937
  const program = new Command("nolto").version(deps.version, "-V, --version", "Print version number").exitOverride().configureOutput({ writeErr: writeErr2 }).description("Nolto CLI \u2014 sync repository roadmaps with Nolto.").option("--token <value>", "API token (overrides env/file)").option("--base-url <url>", "Nolto base URL (default: https://nolto.app)").option("--project <projectId>", "Project ID (overrides env/repo)").option("--json", "Output as JSON");
5849
- register13(program, deps);
5938
+ register14(program, deps);
5850
5939
  register4(program, deps);
5851
5940
  register5(program, deps);
5852
5941
  register6(program, deps);
5853
5942
  register7(program, deps);
5943
+ register8(program, deps);
5854
5944
  register(program, deps);
5855
5945
  register3(program, deps);
5856
- register8(program, deps);
5857
- register2(program, deps);
5858
5946
  register9(program, deps);
5947
+ register2(program, deps);
5859
5948
  register10(program, deps);
5860
5949
  register11(program, deps);
5861
- register12(program);
5950
+ register12(program, deps);
5951
+ register13(program);
5862
5952
  program.action(() => {
5863
5953
  program.help();
5864
5954
  });
5865
5955
  program.hook("preAction", (_thisCommand, actionCommand) => {
5866
5956
  if (actionCommand.parent?.name() === "memory" && actionCommand.name() === "pull" && actionCommand.opts().hook) return;
5867
5957
  const bindingError = deps.repoBinding?.error;
5868
- const bindingExemptCommands = ["init", "link", "update", "merge-file"];
5958
+ const bindingExemptCommands = ["init", "link", "update", "merge-file", "logout"];
5869
5959
  if (bindingError != null && !(actionCommand.parent === program && bindingExemptCommands.includes(actionCommand.name()))) {
5870
5960
  throw bindingError;
5871
5961
  }
5962
+ const tokenOriginExemptCommands = ["login", "logout", "update", "merge-file"];
5963
+ const mismatch = deps.settings.tokenOriginMismatch;
5964
+ if (mismatch != null && !(actionCommand.parent === program && tokenOriginExemptCommands.includes(actionCommand.name()))) {
5965
+ throw tokenOriginMismatchError(mismatch);
5966
+ }
5872
5967
  });
5873
5968
  return program;
5874
5969
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nolto/cli",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "description": "CLI for syncing repository roadmaps with Nolto.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,14 +38,14 @@
38
38
  "dependencies": {
39
39
  "chokidar": "^4.0.3",
40
40
  "commander": "^14.0.0",
41
- "zod": "^3.24.1"
41
+ "zod": "^4.6.7"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@nolto/roadmap-schema": "0.1.0",
45
45
  "@types/node": "^22.20.4",
46
+ "@vitest/coverage-v8": "^4.1.7",
46
47
  "tsup": "^8.3.5",
47
48
  "typescript": "^5.7.2",
48
- "vitest": "^4.1.7",
49
- "@vitest/coverage-v8": "^4.1.7"
49
+ "vitest": "^4.1.7"
50
50
  }
51
51
  }