dsh-inbox-bridge 2.17.1 → 2.18.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.18.0
2
+
3
+ - 归档不再让你去终端登录:把「消息清理」切到归档,插件自己弹出登录窗口;会话失效而选项仍在归档上时,下一次归档失败会再开一次(signInCooldownMs 默认 6 小时,防打扰)。
4
+ - 卡片里还没登录时会写「归档还没登录 GitHub」,旁边是「打开登录窗口」按钮。
5
+ - scripts/clear-inbox.mjs --check 只回答「登录了没」(没登录退出码 2);没有 cookie 库时不启动浏览器。
6
+ - 归档起的是独立进程,宿主的轮询不会被一个二十分钟的登录挡住。
1
7
  ## 2.17.1
2
8
 
3
9
  - 安全告警改成每个来源一条:一个依赖就可能带二十条开着的告警,逐条报告会把队列淹掉、把一次修复变成二十条通知。现在一条里写明条数、严重度分布和涉及的两三个包名,修完最后一条自动收口。
package/README.en.md CHANGED
@@ -91,7 +91,7 @@ To see what it can actually see: `node scripts/inbox-bridge.mjs doctor` walks th
91
91
  | `delivery` | `quiet` | `quiet` queues only; `wakeup` may start a turn while the session is idle |
92
92
  | `wakeOn` | empty | roles allowed to wake under `wakeup`; empty never wakes |
93
93
  | `clear` | `repo` | mark read after a poll: `repo` / `off`. Only the subscribed repositories, never the whole account |
94
- | `sweep` | off | archive the inbox into Done on turns that found something; needs a one-time browser sign-in |
94
+ | `sweep` | off | archive the inbox into Done on turns that found something; the plugin opens a sign-in window when one is missing |
95
95
 
96
96
  The panel's "message clearing" choice sets both: **off** (neither), **read** (clear the blue dot), **archive** (mark read and move to Done).
97
97
 
@@ -101,7 +101,7 @@ Full configuration, CLI and state files: [configuration](docs/configuration.md).
101
101
 
102
102
  - **Read-only.** It does not merge, comment, or change anything.
103
103
  - **No turn by default.** Only `delivery: wakeup` with a matching `wakeOn` role, enough idle time, and room in both budgets may start one; any gate that fails falls back to queueing.
104
- - **Done archiving needs one browser sign-in.** GitHub has no archive API; `scripts/clear-inbox.mjs` drives a local Chromium-based browser (Edge, Chrome or Chromium) and needs a single `--login`.
104
+ - **Done archiving needs one browser sign-in, but you do not type a command for it.** GitHub has no archive API; `scripts/clear-inbox.mjs` drives a local Chromium-based browser (Edge, Chrome or Chromium). Switching "message clearing" to archive opens the sign-in window by itself, and it opens again if the session expires.
105
105
  - **State is local.** It lives under `.work/` in the working directory and is not synced across machines.
106
106
 
107
107
  ## Further reading
package/README.md CHANGED
@@ -91,7 +91,7 @@ dsh plugin add dsh-inbox-bridge
91
91
  | `delivery` | `quiet` | `quiet` 只入队;`wakeup` 可在会话空闲时主动开启一轮 |
92
92
  | `wakeOn` | 空 | `wakeup` 下允许唤醒的角色白名单;为空则永不唤醒 |
93
93
  | `clear` | `repo` | 将订阅仓库里读过的通知标为已读:`repo` / `off`。只清订阅的仓库,不动整个账号 |
94
- | `sweep` | 关 | 有发现的回合把收件箱归档到 Done,需要先登录一次浏览器 |
94
+ | `sweep` | 关 | 有发现的回合把收件箱归档到 Done;缺登录时插件自己弹窗口让你登录一次 |
95
95
 
96
96
  面板里的「消息清理」一档同时管这两件事:**关闭**(都不做)、**已读**(清蓝点)、**归档**(标已读并存进 Done)。
97
97
 
@@ -101,7 +101,7 @@ dsh plugin add dsh-inbox-bridge
101
101
 
102
102
  - **只读。** 不合并、不评论、不修改仓库。
103
103
  - **默认不主动开启对话。** 只有显式设置 `delivery: wakeup` 且命中 `wakeOn`、会话足够空闲、两个预算都还有余额时才会;任何一道门不过,就退回只排队。
104
- - **Done 归档依赖一次浏览器登录。** GitHub 没有归档 API,`scripts/clear-inbox.mjs` 通过本机浏览器(Edge / Chrome / Chromium)完成,需要执行一次 `--login`。
104
+ - **Done 归档依赖一次浏览器登录,但不用你敲命令。** GitHub 没有归档 API,`scripts/clear-inbox.mjs` 通过本机浏览器(Edge / Chrome / Chromium)完成。把「消息清理」切到归档,插件会自己弹出登录窗口;会话失效时会再弹一次。
105
105
  - **状态在本机。** 存放在工作目录的 `.work/` 下,不跨机器同步。
106
106
 
107
107
  ## 更多
package/client.js CHANGED
@@ -128,6 +128,10 @@ window.__ModuleLoader__.load({
128
128
  readTip: "把通知标为已读,清掉圆点;不进 Done。",
129
129
  done: "归档",
130
130
  doneTip: "标为已读并移入 Done。归档需要一次浏览器登录。",
131
+ signInNeeded: "归档还没登录 GitHub,事件不会进 Done。",
132
+ signInWaiting: "已打开登录窗口,登录后自动生效。",
133
+ signInOpen: "打开登录窗口",
134
+ signInTip: "在插件自己的浏览器配置里登录一次;之后归档会自动运行,失效时会再打开这个窗口。",
131
135
  subscribe: "订阅仓库",
132
136
  subscribeTip: "此会话关注的 GitHub 仓库;事件只按这里的仓库投递。",
133
137
  typeRepo: "owner/repo 或链接",
@@ -180,6 +184,10 @@ window.__ModuleLoader__.load({
180
184
  readTip: "Clear the unread dot without moving the thread to Done.",
181
185
  done: "done",
182
186
  doneTip: "Mark read and move the thread to Done. Archiving needs a one-time browser sign-in.",
187
+ signInNeeded: "Archiving is not signed in yet, so nothing reaches Done.",
188
+ signInWaiting: "The sign-in window is open; archiving resumes when you finish.",
189
+ signInOpen: "open sign-in",
190
+ signInTip: "Sign in once in this plugin's own browser profile; afterwards archiving runs on its own and reopens this window if the session expires.",
183
191
  subscribe: "repositories",
184
192
  subscribeTip: "The repositories this session follows; events are delivered only for them.",
185
193
  typeRepo: "owner/repo or link",
@@ -417,6 +425,23 @@ window.__ModuleLoader__.load({
417
425
  warnValue: {
418
426
  color: "var(--dsw-alias-label-warning, var(--dsw-alias-label-secondary))",
419
427
  },
428
+ signInRow: {
429
+ display: "flex",
430
+ alignItems: "center",
431
+ justifyContent: "space-between",
432
+ gap: "8px",
433
+ marginTop: "2px",
434
+ paddingLeft: "2px",
435
+ },
436
+ signInText: {
437
+ color: "var(--dsw-alias-label-warning, var(--dsw-alias-label-secondary))",
438
+ fontSize: "11px",
439
+ lineHeight: "18px",
440
+ minWidth: 0,
441
+ overflow: "hidden",
442
+ textOverflow: "ellipsis",
443
+ whiteSpace: "nowrap",
444
+ },
420
445
  metaValue: {
421
446
  color: "var(--dsw-alias-label-secondary)",
422
447
  textAlign: "right",
@@ -768,6 +793,33 @@ window.__ModuleLoader__.load({
768
793
  "clean",
769
794
  ),
770
795
  ),
796
+ // Archiving is a page action in GitHub, so it needs a browser session in
797
+ // the plugin's own profile. Say that here, and open the window from here —
798
+ // the operator should not have to run a command to make the mode work.
799
+ cleanLevel === "done" && status.signIn?.signedIn !== true
800
+ ? h(
801
+ "div",
802
+ { style: styles.signInRow },
803
+ h(
804
+ "span",
805
+ { style: styles.signInText },
806
+ status.signIn?.open ? pick.signInWaiting : pick.signInNeeded,
807
+ ),
808
+ status.signIn?.open
809
+ ? null
810
+ : h(
811
+ "button",
812
+ {
813
+ type: "button",
814
+ disabled: busy,
815
+ title: pick.signInTip,
816
+ onClick: () => void send("signin", "1"),
817
+ style: styles.seg,
818
+ },
819
+ pick.signInOpen,
820
+ ),
821
+ )
822
+ : null,
771
823
  h(
772
824
  "div",
773
825
  { style: styles.controlRow },
@@ -34,6 +34,16 @@ DSH 的插件配置里,一个 `dsh-inbox-bridge` 条目即可;等价写法
34
34
  { "delivery": "wakeup", "wakeOn": ["reviewer"], "repos": ["owner/one", "owner/two"] }
35
35
  ```
36
36
 
37
+ ### 归档需要一次登录
38
+
39
+ GitHub 的 Done 只有网页端点,所以归档要用插件自己的浏览器配置(`.work/browser-profile`)登录一次。这件事不用你去终端敲命令:
40
+
41
+ - 在卡片上把「消息清理」切到 **归档**,插件立刻弹出一个登录窗口;登录完它就自己归档。
42
+ - 之后会话失效,而选项还停在归档上——下一次归档失败时,插件自己再弹一次窗口(两次之间至少隔 `signInCooldownMs`)。
43
+ - 还没登录时卡片里会写着一行「归档还没登录 GitHub」,旁边有「打开登录窗口」按钮。
44
+
45
+ 窗口是独立进程,宿主的轮询不会被它挡住。命令行里 `scripts/clear-inbox.mjs --check` 只回答「登录了没」(没登录时退出码 2),`--login` 打开窗口等你登录,`--dry-run` 只报数量。
46
+
37
47
  ## 全部配置项
38
48
 
39
49
  | 键 | 默认 | 作用 |
@@ -56,7 +66,8 @@ DSH 的插件配置里,一个 `dsh-inbox-bridge` 条目即可;等价写法
56
66
  | `identity` | `{ kind: "user" }` | 用哪个身份读 GitHub,见下 |
57
67
  | `roles` | `[]` | 只接收这些角色的事件;空 = 全收 |
58
68
  | `clear` | `"repo"` | 把这一轮读过的通知线程标为已读:`repo` 只清订阅的仓库,`off` 不碰收件箱。整个账号不在范围内——清别人的仓库属于人的决定,不是后台轮询的决定。旧配置里的 `"all"` 按 `"repo"` 载入。GitHub 没有「完成」API,所以清的是未读角标,历史仍在收件箱里 |
59
- | `sweep` | `null` | 抓到东西后把收件箱归档进 Done:`{ args: ["scripts/clear-inbox.mjs"], when: "events" }`。`when: "events"` 只在有发现的回合跑,`"always"` 每轮都跑。需要先 `scripts/clear-inbox.mjs --login` 登录一次 |
69
+ | `sweep` | `null` | 抓到东西后把收件箱归档进 Done:`{ args: ["scripts/clear-inbox.mjs"], when: "events" }`。`when: "events"` 只在有发现的回合跑,`"always"` 每轮都跑。归档要有插件的浏览器配置里的一次登录;没有就让面板替你打开窗口,见下 |
70
+ | `signInCooldownMs` | `21600000`(6 小时) | 归档缺登录时,两次「替你打开登录窗口」之间至少隔多久。长到不打扰,短到会话失效后的下一个事件还能恢复 |
60
71
  | `debug` | `false` | 把每个边界事件写进 `plugin.log`,用来排查「没轮询」还是「轮询了没结果」 |
61
72
  | `poll` | 插件自带 CLI 的 `poll` | 换掉抓取命令:`{ command, args }`,只要能输出约定的 JSON,来源可以不是 GitHub |
62
73
  | `ack` | 插件自带 CLI 的 `ack` | 同上,换掉收口命令 |
@@ -94,7 +105,7 @@ node scripts/inbox-bridge.mjs poll # 立刻抓一次
94
105
  node scripts/inbox-bridge.mjs ack --done -- <key> # 划掉一条,并停止提醒
95
106
  node scripts/inbox-bridge.mjs ack --all-delivered --done # 把所有 delivered 一次划掉
96
107
  node scripts/inbox-bridge.mjs doctor # 逐项自检:身份、仓库可读性、上次轮询、队列、归档登录
97
- node scripts/inbox-bridge.mjs explain <key> # 某件事走到哪一步了,为什么没到你眼前 # 把所有 delivered 一次划掉
108
+ node scripts/inbox-bridge.mjs explain <key> # 某件事走到哪一步了,为什么没到你眼前
98
109
  ```
99
110
 
100
111
  `ack` 不带 `--done` 只把它们标成 delivered,意思是「给过了但还没处理」——6 小时后会再提。经 `npm run` 转发时,`--done` 必须写在 `--` 之后,否则被 npm 吞掉。
@@ -52,6 +52,7 @@ DSH 插件 (index.js) 调度与投递:什么时候去取、取回来给
52
52
  - 它不写回任何状态,也不替你 ack;读的就是 `scripts/inbox-bridge.mjs status` 那份事实。
53
53
  - 客户端代码是在页面里执行的:更新插件后要**重新打开一次应用**(桌面版没有刷新键),胶囊才会重新装上;在那之前它会先消失(不是坏了,是没有执行者)。
54
54
  - 卡片里的三组开关(提醒方式、消息清理、订阅)也走同源路由:`GET /inbox-bridge/prefs?token=…&set=…&value=…`。改动写进插件自己的覆盖层 `<cwd>/.work/inbox-bridge/prefs.json`,然后重新读一遍状态——显示的就是下一次轮询真要执行的东西,不做乐观更新。token 每次进程启动重新生成,随状态一起下发,防止别的本地页面替你改设置。
55
+ - 「消息清理」选到归档时,插件会把缺的那次登录替你补上:它自己起一个可见的浏览器窗口等你在插件的浏览器配置里登录,登录完归档接着跑。会话失效而选项还停在归档上时,下一次归档失败会再开一次窗口(至少间隔 `signInCooldownMs`);还没登录时卡片里会写「归档还没登录 GitHub」,旁边是「打开登录窗口」。
55
56
  - 页面第一次挂载时会往 `GET /inbox-bridge/client-log?m=…` 报一行容器尺寸,写进 `plugin.log`(`client: …`)。宿主的资源只应答 GET/HEAD,POST 会变成 405,所以诊断改走查询串。它只在排查「为什么浮层位置不对」时有用,平常不用管。
56
57
 
57
58
  ## 「跟我有关」怎么判断
package/docs/index.json CHANGED
@@ -50,12 +50,12 @@
50
50
  },
51
51
  "versions": [
52
52
  {
53
- "version": "2.17.1",
54
- "publishTimestamp": 1794913490,
53
+ "version": "2.18.0",
54
+ "publishTimestamp": 1794914970,
55
55
  "source": {
56
56
  "type": "git",
57
57
  "url": "https://github.com/c3115644151/dsh-inbox-bridge",
58
- "commit": "d2191625a4e1c02b1e4d5e1b79fa8e8d8198f6e5"
58
+ "commit": "bc5558499c2936c2c92cf8d452804e53189be719"
59
59
  },
60
60
  "engines": {
61
61
  "dsh": ">=0.1.0"
package/index.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * run goes idle. Does not own: fetching the source (the configured poller does)
18
18
  * or the meaning of "handled" (the ack command decides).
19
19
  */
20
- import { execFile, execFileSync } from "node:child_process";
20
+ import { execFile, execFileSync, spawn } from "node:child_process";
21
21
  import { randomUUID } from "node:crypto";
22
22
  import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
23
23
  import { dirname, join } from "node:path";
@@ -208,6 +208,12 @@ const DEFAULTS = Object.freeze({
208
208
  * `when: "events"` (default) only runs it on a turn that found something.
209
209
  */
210
210
  sweep: null,
211
+ /**
212
+ * How long to wait before the sign-in window may open again after it was left
213
+ * unsigned. Six hours: long enough not to interrupt, short enough that
214
+ * archiving comes back on the next event after a session expires.
215
+ */
216
+ signInCooldownMs: 6 * 60 * 60 * 1000,
211
217
  /**
212
218
  * Which GitHub identity the poller reads as. `kind: "user"` uses the ambient
213
219
  * `gh` login; `kind: "app"` needs a token (`token` or `tokenEnv`) and has no
@@ -369,6 +375,11 @@ export function apply(ctx, config) {
369
375
  // and shows which choices came from it rather than from the profile.
370
376
  token: uiToken,
371
377
  overlay: Object.keys(prefs),
378
+ signIn: {
379
+ signedIn: signIn.signedIn,
380
+ open: signIn.open,
381
+ attemptedAt: signIn.attemptedAt ? new Date(signIn.attemptedAt).toISOString() : null,
382
+ },
372
383
  sweepOn: Boolean(options.sweep),
373
384
  sessionId,
374
385
  };
@@ -436,6 +447,70 @@ export function apply(ctx, config) {
436
447
  // Archiving the notification inbox ("Done") has no API: it is a page action.
437
448
  // A configured sweep command does it through a browser, and this is where the
438
449
  // plugin calls it. `when: "events"` keeps a quiet turn at zero extra cost.
450
+ // Archiving needs a browser session, and a browser session expires. The
451
+ // operator should never have to run a command in a terminal to fix that:
452
+ // choosing the archive mode — or the archive finding no sign-in on its own —
453
+ // opens the window that asks for it.
454
+ const signIn = { signedIn: null, open: false, attemptedAt: 0 };
455
+
456
+ const sweepScript = () => {
457
+ const args = options.sweep?.args ?? [];
458
+ const script = args.find((arg) => String(arg).endsWith(".mjs"));
459
+ return typeof script === "string" ? script : null;
460
+ };
461
+
462
+ const minutesSince = (at) => Math.max(1, Math.round((Date.now() - at) / 60_000));
463
+
464
+ const openSignIn = (reason) => {
465
+ const script = sweepScript();
466
+ if (!script) return false;
467
+ if (signIn.open) {
468
+ log("sign-in window is already open");
469
+ return false;
470
+ }
471
+ if (signIn.attemptedAt && Date.now() - signIn.attemptedAt < options.signInCooldownMs) {
472
+ log(
473
+ `sign-in window not reopened: one was opened ${minutesSince(signIn.attemptedAt)} minutes ago`,
474
+ );
475
+ return false;
476
+ }
477
+ signIn.attemptedAt = Date.now();
478
+ signIn.open = true;
479
+ signIn.signedIn = false;
480
+ try {
481
+ const child = spawn(process.execPath, [script, "--login", "--json"], {
482
+ cwd: options.cwd,
483
+ env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
484
+ // Detached so a twenty-minute sign-in never holds a poll open; visible
485
+ // because there has to be a window to sign in.
486
+ detached: true,
487
+ windowsHide: false,
488
+ stdio: "ignore",
489
+ });
490
+ child.once("exit", () => {
491
+ signIn.open = false;
492
+ });
493
+ child.unref?.();
494
+ } catch (error) {
495
+ signIn.open = false;
496
+ log(`could not open the sign-in window: ${describe(error)}`);
497
+ return false;
498
+ }
499
+ log(`opened the sign-in window (${reason}); archiving resumes once you sign in`);
500
+ return true;
501
+ };
502
+
503
+ const checkSignIn = async () => {
504
+ const script = sweepScript();
505
+ if (!script) return;
506
+ try {
507
+ await runCommand({ command: "node", args: [script, "--check", "--json"] }, options);
508
+ signIn.signedIn = true;
509
+ } catch (error) {
510
+ if (error?.exitCode === 2) signIn.signedIn = false;
511
+ }
512
+ };
513
+
439
514
  const sweepInbox = async (freshCount) => {
440
515
  if (!options.sweep) return;
441
516
  if (options.sweep.when === "events" && freshCount === 0) return;
@@ -443,13 +518,15 @@ export function apply(ctx, config) {
443
518
  try {
444
519
  const stdout = await runCommand(options.sweep, options);
445
520
  const line = String(stdout ?? "").trim().split(/\r?\n/u).pop() ?? "";
521
+ signIn.signedIn = true;
446
522
  log(`swept the notification inbox: ${line || "done"} (${Date.now() - began}ms)`);
447
523
  } catch (error) {
448
524
  if (error?.exitCode === 2) {
449
- const script = (options.sweep.args ?? []).find((arg) => String(arg).endsWith(".mjs"));
450
- log(
451
- `sweep needs a one-time sign-in: node "${script ?? "scripts/clear-inbox.mjs"}" --login`,
452
- );
525
+ // The command says "sign-in required"; raise the window rather than
526
+ // asking the operator to copy a command out of the log.
527
+ signIn.signedIn = false;
528
+ log("the archive needs a browser sign-in");
529
+ openSignIn("the archive found no sign-in");
453
530
  } else {
454
531
  log(`sweep failed: ${describe(error)}`);
455
532
  }
@@ -616,6 +693,9 @@ export function apply(ctx, config) {
616
693
  `wakeOn ${options.wakeOn.join(",")} is idle: delivery is ${options.delivery}, so those roles only queue`,
617
694
  );
618
695
  }
696
+ // Archiving only works with a browser session; find out once at start whether
697
+ // there is one, so the panel can say so before the first event arrives.
698
+ if (options.sweep) void checkSignIn();
619
699
 
620
700
  // A turn is the only thing that makes the inbox worth reading: poll when one
621
701
  // starts, re-poll while a long one runs, poll once more when it ends. An idle
@@ -776,10 +856,20 @@ export function apply(ctx, config) {
776
856
  sessionId,
777
857
  sessionRepo,
778
858
  });
859
+ if (action === "signin") {
860
+ // Not a setting: open the window that archiving needs.
861
+ const opened = openSignIn("you asked for it in the panel");
862
+ return reply(200, { ok: true, opened, status: uiPayload(sessionId) });
863
+ }
779
864
  if (next === null) {
780
865
  return reply(400, { ok: false, error: `unknown setting: ${action || "-"}` });
781
866
  }
782
867
  applyPrefs(next);
868
+ // Choosing the archive mode is also the request for a sign-in when
869
+ // there is none: the mode does nothing without one.
870
+ const wantsArchive =
871
+ (action === "clean" && value === "done") || (action === "archive" && value === "on");
872
+ if (wantsArchive && signIn.signedIn !== true) openSignIn("archive was turned on");
783
873
  } catch (error) {
784
874
  return reply(400, { ok: false, error: describe(error) });
785
875
  }
@@ -1065,9 +1155,16 @@ export function mergeConfig(config) {
1065
1155
  }
1066
1156
  sweepSpec = { command: sweep.command ?? "node", args: sweep.args ?? [], when };
1067
1157
  }
1158
+ const signInCooldownMs = given.signInCooldownMs ?? DEFAULTS.signInCooldownMs;
1159
+ if (!Number.isInteger(signInCooldownMs) || signInCooldownMs < 0) {
1160
+ throw new Error(
1161
+ `inbox-bridge: \`signInCooldownMs\` must be a non-negative integer, got ${JSON.stringify(signInCooldownMs)}`,
1162
+ );
1163
+ }
1068
1164
  return {
1069
1165
  ...DEFAULTS,
1070
1166
  ...given,
1167
+ signInCooldownMs,
1071
1168
  repo,
1072
1169
  repos: watched,
1073
1170
  delivery,
@@ -1288,6 +1385,7 @@ export function buildUiPayload({
1288
1385
  recent = new Map(),
1289
1386
  now = Date.now(),
1290
1387
  session = null,
1388
+ signIn = null,
1291
1389
  }) {
1292
1390
  const configured = options.repos?.length > 0 ? options.repos : options.repo ? [options.repo] : [];
1293
1391
  // A session sees exactly what a poll would deliver to it: the repositories it
@@ -1344,6 +1442,7 @@ export function buildUiPayload({
1344
1442
  delivery: options.delivery ?? DEFAULTS.delivery,
1345
1443
  clear: options.clear ?? DEFAULTS.clear,
1346
1444
  sweep: options.sweep?.when ?? null,
1445
+ signIn: signIn ?? { signedIn: null, open: false, attemptedAt: null },
1347
1446
  intervalMs: options.intervalMs ?? DEFAULTS.intervalMs,
1348
1447
  queue: counts,
1349
1448
  events: events.slice(0, 20),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-inbox-bridge",
3
- "version": "2.17.1",
3
+ "version": "2.18.0",
4
4
  "displayName": "GitHub inbox",
5
5
  "description": "DSH 插件:让 agent 像维护者一样盯着你的仓库——按会话订阅仓库,取回与你有关、需要你处理的事件(失败的 CI、待评审的 PR、指派给你的 issue、@你的评论、开着的安全告警),在自己的回合送进上下文;会话空闲又遇到要紧的事时也能主动开一轮,让 agent 自己去修、去审、去接。",
6
6
  "type": "module",
@@ -65,6 +65,7 @@ function parseArgs(argv = []) {
65
65
  if (argument === "--json") options.json = true;
66
66
  else if (argument === "--login") options.login = true;
67
67
  else if (argument === "--dry-run") options.dryRun = true;
68
+ else if (argument === "--check") options.check = true;
68
69
  else if (argument === "--keep-open") options.keepOpen = true;
69
70
  else if (argument === "--port") options.expectPort = true;
70
71
  else if (options.expectPort) {
@@ -172,6 +173,7 @@ async function main(argv) {
172
173
  "",
173
174
  " --json machine-readable summary",
174
175
  " --dry-run report how many threads would be archived",
176
+ " --check only say whether this profile is signed in (exit 2 if not)",
175
177
  " --login open a visible window so you can sign in once",
176
178
  " --keep-open leave the browser running after the sweep",
177
179
  " --port N DevTools port (default 9333)",
@@ -182,6 +184,13 @@ async function main(argv) {
182
184
 
183
185
  const root = process.cwd();
184
186
  const profileDir = resolve(root, PROFILE_REL);
187
+ // A profile with no cookie database has never been signed in. Answering that
188
+ // here keeps `--check` from launching a browser just to learn it is useless.
189
+ if (options.check && !existsSync(join(profileDir, "Default", "Cookies"))) {
190
+ if (options.json) console.log(JSON.stringify({ ok: false, reason: "sign-in-required" }));
191
+ else console.log("not signed in: archiving cannot run yet");
192
+ return 2;
193
+ }
185
194
  mkdirSync(profileDir, { recursive: true });
186
195
  const browser = findBrowser();
187
196
  const base = `http://127.0.0.1:${options.port}`;
@@ -285,6 +294,17 @@ async function main(argv) {
285
294
  return 0;
286
295
  }
287
296
 
297
+ // `--check` answers one question and touches nothing: is this profile
298
+ // signed in? The panel and `doctor` need that without archiving anything.
299
+ if (options.check) {
300
+ const rows = await read(
301
+ `document.querySelectorAll('input[type=checkbox][name="notification_ids[]"]').length`,
302
+ );
303
+ if (options.json) console.log(JSON.stringify({ ok: true, signedIn: true, rows }));
304
+ else console.log("signed in: archiving can run");
305
+ return 0;
306
+ }
307
+
288
308
  const result = await read(SWEEP);
289
309
  const summary = { ok: true, ...result };
290
310
  if (options.json) console.log(JSON.stringify(summary));