@authinex/dsh-plugin 0.1.2 → 0.1.3

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
@@ -55,6 +55,8 @@ dsh plugin --profile <你的 profile> add @authinex/dsh-plugin
55
55
 
56
56
  > 刚发布完可能提示「未找到相关插件」——这是 npm 元数据还没扩散,等几分钟再试。
57
57
 
58
+ > 刚发布不到 24 小时的版本会被 pnpm 的供应链策略(`minimumReleaseAge`)暂缓,直接装会拿到上一个版本。要新版本就装精确版本号 `@authinex/dsh-plugin@x.y.z`;插件页会先卸掉当前版本再装。
59
+
58
60
  ## 绑定
59
61
 
60
62
  左侧「插件」→ 点这一行右侧的「Configure」,页面上有两个输入框:
@@ -81,7 +83,7 @@ dsh plugin --profile <你的 profile> add @authinex/dsh-plugin
81
83
 
82
84
  ## 更新
83
85
 
84
- 点「检查更新」取清单,有新版本时卡片会给出新版本号、版本说明和校验值。
86
+ 点「检查更新」先取服务端清单;服务端没配更新源(清单 404)时,退回 npm 的 `latest` 标签比较版本,这时只能发现版本号,安装仍让 DeepSeek 的安装器按 `@authinex/dsh-plugin@x.y.z` 去 npm 取。
85
87
 
86
88
  点「更新到 x.y.z」并确认,插件会调用 DeepSeek 自己的安装器装新版本。装完重启智能问答生效,绑定和账号都不动。
87
89
 
package/lib/client.js CHANGED
@@ -328,6 +328,9 @@ async function api(path, init) {
328
328
  return {};
329
329
  }
330
330
  }
331
+ function dwell(ms = 450) {
332
+ return new Promise((resolve) => setTimeout(resolve, ms));
333
+ }
331
334
  function tagTone(state) {
332
335
  if (state === "ready") return "success";
333
336
  if (state === "read_only") return "info";
@@ -352,6 +355,7 @@ function AuthinexPanel() {
352
355
  const [confirmUnbind, setConfirmUnbind] = (0, import_react.useState)(false);
353
356
  const [confirmUpdate, setConfirmUpdate] = (0, import_react.useState)(false);
354
357
  const [restart, setRestart] = (0, import_react.useState)(false);
358
+ const [feedback, setFeedback] = (0, import_react.useState)("");
355
359
  const model = (0, import_react.useMemo)(() => viewModel(state || void 0), [state]);
356
360
  const applyState = (0, import_react.useCallback)((next) => {
357
361
  setState(next);
@@ -359,8 +363,10 @@ function AuthinexPanel() {
359
363
  const read = (0, import_react.useCallback)(async () => {
360
364
  try {
361
365
  applyState(await api("/authinex-ds/state"));
366
+ return true;
362
367
  } catch {
363
368
  setState({ phase: "unreachable" });
369
+ return false;
364
370
  } finally {
365
371
  setLoaded(true);
366
372
  }
@@ -375,10 +381,14 @@ function AuthinexPanel() {
375
381
  setBusy(label);
376
382
  setNotice("");
377
383
  setLocalError("");
384
+ setFeedback("");
378
385
  try {
379
386
  await work();
380
387
  } catch {
381
388
  setState({ phase: "unreachable" });
389
+ if (label === "refresh") setNotice("没有刷新到");
390
+ if (label === "update") setNotice("没有查到更新");
391
+ if (label === "refresh" || label === "update") setFeedback("error");
382
392
  } finally {
383
393
  setBusy("");
384
394
  }
@@ -464,11 +474,28 @@ function AuthinexPanel() {
464
474
  }
465
475
  });
466
476
  };
477
+ const onRefresh = () => {
478
+ void run("refresh", async () => {
479
+ const [ok] = await Promise.all([read(), dwell()]);
480
+ if (!ok) {
481
+ setFeedback("error");
482
+ setNotice("没有刷新到");
483
+ return;
484
+ }
485
+ setFeedback("ok");
486
+ setNotice("已刷新");
487
+ });
488
+ };
467
489
  const onCheckUpdate = () => {
468
490
  void run("update", async () => {
469
- const body = await api("/authinex-ds/update/check", { method: "POST" });
491
+ const [body] = await Promise.all([
492
+ api("/authinex-ds/update/check", { method: "POST" }),
493
+ dwell()
494
+ ]);
470
495
  applyState(body);
471
- setNotice(String(body.updateMessage || "没有查到更新"));
496
+ const text = String(body.updateMessage || "没有查到更新");
497
+ setNotice(text);
498
+ setFeedback(text.includes("没有") ? "warn" : "ok");
472
499
  });
473
500
  };
474
501
  const onApplyUpdate = () => {
@@ -483,6 +510,8 @@ function AuthinexPanel() {
483
510
  const message = localError || notice || model.message;
484
511
  const messageError = localError !== "" || model.phase === "invalid" || model.phase === "revoked" || model.phase === "unreachable";
485
512
  const disabled = busy !== "";
513
+ const pending = busy === "refresh" ? "正在刷新…" : busy === "update" ? "正在检查更新…" : "";
514
+ const messageClass = feedback === "ok" ? "axds-ok" : feedback === "warn" ? "axds-notice" : messageError || feedback === "error" ? "axds-error" : "axds-muted";
486
515
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", { className: "axds", "aria-label": "AuthineX 助手", children: [
487
516
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", { className: "axds-head", children: [
488
517
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.StateDot, { state: model.tone }),
@@ -490,9 +519,7 @@ function AuthinexPanel() {
490
519
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-title", children: "AuthineX 助手" }),
491
520
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-sub", children: loaded ? model.headline : "正在读取状态…" })
492
521
  ] }),
493
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-head-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: () => {
494
- void read();
495
- }, children: "刷新" }) })
522
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "axds-head-actions", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: onRefresh, children: busy === "refresh" ? "刷新中" : "刷新" }) })
496
523
  ] }),
497
524
  model.retryAfterSec > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "axds-notice", children: [
498
525
  "请等待 ",
@@ -506,7 +533,10 @@ function AuthinexPanel() {
506
533
  model.minVersion,
507
534
  "。请先更新插件。"
508
535
  ] }) : null,
509
- message ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: messageError ? "axds-error" : "axds-muted", children: message }) : null,
536
+ pending ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "axds-pending", role: "status", children: [
537
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "axds-spin", "aria-hidden": "true" }),
538
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: pending })
539
+ ] }, "pending") : message ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: messageClass, role: "status", children: message }, message) : null,
510
540
  showForm ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { className: "axds-card", onSubmit: onBind, children: [
511
541
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "axds-field", children: [
512
542
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "访问地址" }),
@@ -672,7 +702,7 @@ function AuthinexPanel() {
672
702
  ] }) : null,
673
703
  restart ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "axds-notice", children: "已装好,重启智能问答后新版本才生效。" }) : null,
674
704
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "axds-row", children: [
675
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: onCheckUpdate, children: "检查更新" }),
705
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", disabled, onClick: onCheckUpdate, children: busy === "update" ? "检查中" : "检查更新" }),
676
706
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Button, { size: "sm", variant: "outline", disabled, onClick: () => {
677
707
  setConfirmUnbind(true);
678
708
  }, children: "解除绑定" }),
@@ -714,6 +744,13 @@ var CSS = `
714
744
  .axds-notice{color:var(--dsw-alias-state-warn-label);font-size:12px}
715
745
  .axds-error{color:var(--dsw-alias-state-error-primary);font-size:12px}
716
746
  .axds-ok{color:var(--dsw-alias-state-success-primary);font-size:12px}
747
+ /* 状态行换了内容时淡入一下,否则点「刷新」像什么都没发生。 */
748
+ .axds-pending,.axds-ok,.axds-notice,.axds-error{animation:axds-fade .18s ease-out both}
749
+ @keyframes axds-fade{from{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}
750
+ @media (prefers-reduced-motion:reduce){.axds-pending,.axds-ok,.axds-notice,.axds-error{animation:none}}
751
+ .axds-pending{display:flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary);font-size:12px}
752
+ .axds-spin{width:14px;height:14px;border-radius:50%;border:2px solid var(--dsw-alias-border-l1);border-top-color:var(--dsw-alias-label-primary);animation:axds-spin .7s linear infinite;flex:none}
753
+ @keyframes axds-spin{to{transform:rotate(360deg)}}
717
754
  .axds-bind{display:flex;gap:8px;align-items:center}
718
755
  /* Input 原子自带边框、圆角与 focus-within;这里只让它占满一行,别再叠一层。 */
719
756
  .axds-input{display:flex;width:100%;box-sizing:border-box;height:36px}
package/lib/index.js CHANGED
@@ -215,8 +215,9 @@ var ROW_ID = "authinex-ds-plugin";
215
215
  var ROW_KEY = `${PACKAGE_NAME}#${ROW_ID}`;
216
216
 
217
217
  // src/controller.ts
218
- var VERSION = true ? "0.1.2" : "0.1.0";
218
+ var VERSION = true ? "0.1.3" : "0.1.0";
219
219
  var CREDENTIAL_REF = "AUTHINEX_DS_DEVICE";
220
+ var NPM_LATEST_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
220
221
  var ALLOWED_DETAILS = /* @__PURE__ */ new Set([
221
222
  "密钥无效",
222
223
  "尝试次数过多,请稍后再试",
@@ -762,11 +763,34 @@ ${description}`;
762
763
  return null;
763
764
  }
764
765
  }
766
+ async function fetchNpmLatest() {
767
+ try {
768
+ const response = await fetchImpl(NPM_LATEST_URL, {
769
+ method: "GET",
770
+ headers: { accept: "application/json" },
771
+ timeout: 1e4
772
+ });
773
+ if (!response.ok) return null;
774
+ const data = JSON.parse(await response.text());
775
+ const found = String(data.version || "").trim();
776
+ if (!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(found)) return null;
777
+ return {
778
+ version: found,
779
+ sha: "",
780
+ notes: "服务端没有更新清单,按 npm 上的最新版本比较",
781
+ artifact: "",
782
+ size: 0,
783
+ available: versionBelow(version, found)
784
+ };
785
+ } catch {
786
+ return null;
787
+ }
788
+ }
765
789
  async function checkUpdate() {
766
790
  if (memory.busy) return { ok: false, message: BUSY, state: snapshot() };
767
791
  const base = normalizeEndpoint(memory.endpoint);
768
- if (!base) return { ok: false, message: PHRASES.unreachable, state: snapshot() };
769
- const found = await fetchManifest();
792
+ if (!base || !memory.token) return { ok: false, message: PHRASES.unreachable, state: snapshot() };
793
+ const found = await fetchManifest() || await fetchNpmLatest();
770
794
  if (!found) {
771
795
  memory.update = null;
772
796
  return { ok: false, message: "没有查到更新", state: snapshot() };
@@ -774,9 +798,13 @@ ${description}`;
774
798
  memory.update = found;
775
799
  return { ok: true, message: found.available ? `发现新版本 ${found.version}` : "已经是最新版本", state: snapshot() };
776
800
  }
801
+ async function discoverUpdate() {
802
+ if (memory.update?.available) return memory.update;
803
+ return await fetchManifest() || await fetchNpmLatest();
804
+ }
777
805
  async function applyUpdate() {
778
806
  if (memory.busy) return { ok: false, message: BUSY };
779
- const found = memory.update?.available ? memory.update : await fetchManifest();
807
+ const found = await discoverUpdate();
780
808
  if (!found) return { ok: false, message: "没有查到更新" };
781
809
  memory.update = found;
782
810
  if (!found.available) return { ok: false, message: "已经是最新版本" };
@@ -797,10 +825,13 @@ ${description}`;
797
825
  if (memory.busy) return { ok: false, message: BUSY };
798
826
  const base = normalizeEndpoint(memory.endpoint);
799
827
  if (!base || !memory.token) return { ok: false, message: PHRASES.unreachable };
800
- const found = memory.update?.available ? memory.update : await fetchManifest();
828
+ const found = await discoverUpdate();
801
829
  if (!found) return { ok: false, message: "没有查到更新" };
802
830
  memory.update = found;
803
831
  if (!found.available) return { ok: false, message: "已经是最新版本" };
832
+ if (!found.artifact) {
833
+ return { ok: false, message: "这次只查到 npm 上的版本号,没有可下载的更新包,请到插件页更新" };
834
+ }
804
835
  if (!/^authinex-dsh-plugin-[0-9A-Za-z.+-]+\.(tgz|tar\.gz)$/.test(found.artifact)) {
805
836
  return { ok: false, message: "更新包名不合法,已放弃这次更新" };
806
837
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authinex/dsh-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "DeepSeek 里的 AuthineX 插件:问知识库、查工单、检索源码、只读定位,并用本人账号建单",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -34,6 +34,7 @@
34
34
  "typecheck": "tsc --noEmit",
35
35
  "test": "tsc --noEmit && node scripts/build.mjs && node --test test/*.test.mjs",
36
36
  "prepublishOnly": "npm test",
37
+ "release": "node scripts/publish.mjs",
37
38
  "preview": "node scripts/preview.mjs"
38
39
  },
39
40
  "publishConfig": {