dsh-engramory 1.3.1 → 1.4.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/README.en.md +22 -7
- package/README.md +6 -2
- package/client.js +162 -10
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -44,7 +44,17 @@ it). In dsh's desktop app you can also search for `dsh-engramory` on the Plugins
|
|
|
44
44
|
dsh plugin --profile <name> add dsh-engramory
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
-
To uninstall, use `remove` instead of `add`.
|
|
47
|
+
To uninstall, use `remove` instead of `add`.
|
|
48
|
+
|
|
49
|
+
**Name the version to upgrade**, as in `dsh plugin --profile <name> add
|
|
50
|
+
dsh-engramory@1.4.0`: by name alone, pnpm 11 (the desktop app's own included) by default
|
|
51
|
+
installs only a version published at least 24 hours ago. The desktop app's Plugins page has no *Update*
|
|
52
|
+
for a plugin from outside dsh: uninstall it, search for `dsh-engramory@<version>` and
|
|
53
|
+
install that, then quit dsh from the tray and open it again. Your memory and settings stay.
|
|
54
|
+
*Check for updates* at the foot of the memory page finds the latest version and lists
|
|
55
|
+
these steps.
|
|
56
|
+
|
|
57
|
+
Compatible dsh releases are listed in
|
|
48
58
|
`dsh.compatibility.dshReleases` in [`package.json`](https://github.com/tinqiao-oss/engramory/blob/master/adapters/dsh/plugin/package.json); an unlisted release
|
|
49
59
|
is unverified.
|
|
50
60
|
|
|
@@ -146,9 +156,10 @@ owner, so a program forwarding other people's messages must leave it out.
|
|
|
146
156
|
mode, memory access and the index cap. Saving goes through dsh's own profile editor,
|
|
147
157
|
which writes your profile's `cordis.patch.yml` and reloads the plugin. Only you, signed
|
|
148
158
|
in, can call it, so an agent cannot use it to switch social mode off.
|
|
149
|
-
- **Memory page:** *Memory* in the sidebar. A banner at the top
|
|
150
|
-
stores and archived files are listed and when
|
|
151
|
-
(companion mode, and memory access once it is on)
|
|
159
|
+
- **Memory page:** *Memory* in the sidebar. A banner at the top, the plugin's version
|
|
160
|
+
beside its title, says how many notes, stores and archived files are listed and when
|
|
161
|
+
they were read, with the switches (companion mode, and memory access once it is on)
|
|
162
|
+
that save as you flip them. Below it,
|
|
152
163
|
tabs by note type and a filter by name, over the global store and each workspace's
|
|
153
164
|
project store (with an absolute `indexPath`, that store alone; with a relative one,
|
|
154
165
|
none). Each note is a row: a mark for its type, its name, its type and size; a plan's
|
|
@@ -167,9 +178,13 @@ owner, so a program forwarding other people's messages must leave it out.
|
|
|
167
178
|
rather than counting that as nothing. Read-only, never a note's text; a name, *Open
|
|
168
179
|
the index* and *Open the folder* open on the machine dsh runs on; a machine with no
|
|
169
180
|
desktop (a headless server, a session over SSH) shows none of them. A short *How to use
|
|
170
|
-
it* follows, open while there is no memory yet. At the foot,
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
it* follows, open while there is no memory yet. At the foot, the plugin's version and
|
|
182
|
+
*Check for updates*: only when clicked, it asks npm (npmmirror when npm cannot be
|
|
183
|
+
reached) for the latest version number, with nothing from your memory, and lists the
|
|
184
|
+
steps that upgrade to a newer one, the version named. The plugin goes online at no other
|
|
185
|
+
time. Below that, where to send feedback: a new GitHub issue (its body pre-filled with
|
|
186
|
+
the plugin's version and the OS family, no path and no note), or an email, with a button
|
|
187
|
+
that copies the address.
|
|
173
188
|
|
|
174
189
|
## Configuration
|
|
175
190
|
|
package/README.md
CHANGED
|
@@ -24,7 +24,11 @@
|
|
|
24
24
|
dsh plugin --profile <名字> add dsh-engramory
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
卸载把 `add` 换成 `remove
|
|
27
|
+
卸载把 `add` 换成 `remove`。
|
|
28
|
+
|
|
29
|
+
**升级要写上版本号**,比如 `dsh plugin --profile <名字> add dsh-engramory@1.4.0`:只写名字时,pnpm 11(桌面版自带的也是)默认只装发布满 24 小时的版本。桌面版的插件页对第三方插件没有「更新」按钮:先卸载,再搜 `dsh-engramory@<版本>` 安装,装完从托盘退出 dsh 再打开。记忆库和设置都会保留。记忆页底部的「检查更新」能查到最新版本号,并列出这几步。
|
|
30
|
+
|
|
31
|
+
兼容的 dsh 版本见 [`package.json`](https://github.com/tinqiao-oss/engramory/blob/master/adapters/dsh/plugin/package.json) 里的 `dsh.compatibility.dshReleases`,没列出的版本未经验证。
|
|
28
32
|
|
|
29
33
|
**记忆存在哪:**
|
|
30
34
|
|
|
@@ -77,7 +81,7 @@ agent.followup(createUserMessage({
|
|
|
77
81
|

|
|
78
82
|
|
|
79
83
|
- **设置页**:dsh 的「插件」页里点开「Engramory 记忆」,能改大肥鱼模式、记忆权限和索引上限。保存走 dsh 自己的配置服务,写进你 profile 的 `cordis.patch.yml` 并重新加载插件。这个接口只有登录了的你能调,AI 没法调用它关掉社交模式。
|
|
80
|
-
-
|
|
84
|
+
- **记忆页**:左侧栏「记忆」。最上面一条横幅:标题旁是插件版本;列出了多少笔记、几个记忆库、多少归档,什么时候读的,还有两个开关(大肥鱼模式,打开后还有记忆权限),拨了就保存。下面按笔记类型分标签、可按名字筛选,列出全局库和各工作区的项目库(设了绝对路径的 `indexPath` 时只列那一个,相对路径则列不出)。每条笔记一行:类型图标、名字、类型和大小;约定那一行标出日期和还有几天(日期已过的写「待确认」,只是提醒,不会自动归档),超过 12 KB 的标「偏大,建议拆分」,不在索引里的也会标出。每个库名旁边是索引用量(进度条按两项上限里离得近的那个画)和「打开索引」「打开文件夹」。体检发现的问题集中列在库下面:索引里指向不存在的文件、不在索引里的笔记(AI 回忆从索引开始,除非别的笔记链到它们,否则通常找不到)、没写类型的笔记、超过 12 KB 的笔记、索引超上限;旁边的「复制整理指令」复制一段给 AI 的整理要求,粘贴进对话即可,插件本身不改任何文件。体检只按文件名和索引里的链接判断,不顺着符号链接走;索引超上限、要核对的太多或有文件读不了时不做,完整检查仍用 `engramory_doctor.py`。列表被截断或有库读不了时会注明,不把没列到的算成零。只读,不显示正文;点名字、「打开索引」「打开文件夹」都在运行 dsh 的那台机器上打开;没有桌面的机器(无界面服务器、SSH 连过去的)不显示这些按钮。下面有一段「怎么用」,还没有记忆时自动展开。页底是插件版本和「检查更新」:点了才向 npm(连不上再试 npmmirror)查最新版本号,请求里不带记忆内容;有新版就列出写上版本号的升级步骤。插件别的时候不访问外网。再下面是反馈入口:到 GitHub 提 issue(正文预先写好插件版本和系统类型,不带路径和笔记),或发邮件,地址可以一键复制。
|
|
81
85
|
|
|
82
86
|
## 配置
|
|
83
87
|
|
package/client.js
CHANGED
|
@@ -30,12 +30,21 @@ window.__ModuleLoader__.load({
|
|
|
30
30
|
const SETTINGS_API = 'api/engramory/settings'
|
|
31
31
|
const MEMORY_API = 'api/engramory/memory'
|
|
32
32
|
/** This plugin's version, for the feedback footer; a test keeps it equal to package.json's. */
|
|
33
|
-
const VERSION = '1.
|
|
33
|
+
const VERSION = '1.4.0'
|
|
34
34
|
/** Where feedback goes: a new issue on the repository, or the project's mailbox. Opening
|
|
35
35
|
* the link is the browser's (the desktop app hands it to the system's); the footer submits
|
|
36
36
|
* nothing by itself. */
|
|
37
37
|
const ISSUES = 'https://github.com/tinqiao-oss/engramory/issues/new'
|
|
38
38
|
const EMAIL = 'engramory@agent.qq.com'
|
|
39
|
+
/** Where "Check for updates" asks for the latest version, in turn: npm's own registry, then
|
|
40
|
+
* npmmirror, its mirror in China, for when npm cannot be reached. Asked on that click only. */
|
|
41
|
+
const REGISTRIES = [['npm', 'https://registry.npmjs.org'], ['npmmirror', 'https://registry.npmmirror.com']]
|
|
42
|
+
/** Where to look when neither answers, and what a newer version changed. */
|
|
43
|
+
const NPM_PAGE = 'https://www.npmjs.com/package/dsh-engramory?activeTab=versions'
|
|
44
|
+
const RELEASE = 'https://github.com/tinqiao-oss/engramory/releases/tag/v'
|
|
45
|
+
/** A version as SemVer writes one: three numbers without leading zeros, then maybe a prerelease
|
|
46
|
+
* tag and build metadata, each in dot-separated identifiers (a numeric one without leading zeros). */
|
|
47
|
+
const SEMVER = /^(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/
|
|
39
48
|
/** The how-to's lines, in order. */
|
|
40
49
|
const HOW_TO = ['howToSay', 'howToRecall', 'howToEdit', 'howToMove', 'howToSocial']
|
|
41
50
|
/** A note past this is almost always a timeline under one slug (SKILL.md: "A note has a size
|
|
@@ -135,7 +144,24 @@ window.__ModuleLoader__.load({
|
|
|
135
144
|
copy: '复制',
|
|
136
145
|
copied: '已复制',
|
|
137
146
|
copyFailed: '复制不了,请手动选中上面的地址。',
|
|
138
|
-
feedbackNote: '邮件会由 AI 助手协助整理,issue
|
|
147
|
+
feedbackNote: '邮件会由 AI 助手协助整理,issue 是公开的,两处都别把记忆内容原样贴上去。',
|
|
148
|
+
versionLine: '插件版本 {version}',
|
|
149
|
+
checkUpdate: '检查更新',
|
|
150
|
+
checking: '正在检查…',
|
|
151
|
+
updateNewer: '有新版本 {latest}(你装的是 {current})',
|
|
152
|
+
updateNotes: '看这一版改了什么',
|
|
153
|
+
updateHow: '升级时要写上版本号(只写名字的话,pnpm 默认不装发布不满 24 小时的版本):',
|
|
154
|
+
updateDesktop: '桌面版:在「插件」页卸载「Engramory 记忆」,再搜索安装',
|
|
155
|
+
updateCli: '命令行:',
|
|
156
|
+
updateProfile: '<名字>',
|
|
157
|
+
updateAfter: '装完重启 dsh(桌面版从托盘退出再打开)。记忆和设置都会保留。',
|
|
158
|
+
updateCurrent: '已是最新版本:{source} 上最新的就是 {latest}。',
|
|
159
|
+
updateAhead: '你装的 {current} 比 {source} 上最新的 {latest} 还新。',
|
|
160
|
+
updateMirror: 'npm 没有给出版本号,这是镜像 npmmirror 的结果,它有时比 npm 晚几分钟同步。',
|
|
161
|
+
updateFailed: '查不到最新版本:npm 和 npmmirror 都没有给出版本号。可以到网页上看:',
|
|
162
|
+
updateNpm: 'npm 上的版本列表',
|
|
163
|
+
copySpecFailed: '复制不了,请手动选中上面的版本号。',
|
|
164
|
+
updateNote: '检查更新会向 npm(连不上再试 npmmirror)查最新版本号,请求里不带任何记忆内容;不点就不联网。',
|
|
139
165
|
issueBody: '(写下遇到的问题或建议)\n\n---\ndsh-engramory {version}\n打开这个页面的电脑:{os}\ndsh 版本:',
|
|
140
166
|
statNote: '条记忆',
|
|
141
167
|
statNotes: '条记忆',
|
|
@@ -260,7 +286,24 @@ window.__ModuleLoader__.load({
|
|
|
260
286
|
copy: 'Copy',
|
|
261
287
|
copied: 'Copied',
|
|
262
288
|
copyFailed: 'Could not copy; select the address above by hand.',
|
|
263
|
-
feedbackNote: 'Emails are sorted with the help of an AI assistant, and issues are public: do not paste your memory notes into either.
|
|
289
|
+
feedbackNote: 'Emails are sorted with the help of an AI assistant, and issues are public: do not paste your memory notes into either.',
|
|
290
|
+
versionLine: 'Plugin version {version}',
|
|
291
|
+
checkUpdate: 'Check for updates',
|
|
292
|
+
checking: 'Checking…',
|
|
293
|
+
updateNewer: 'Version {latest} is out (you have {current})',
|
|
294
|
+
updateNotes: 'What changed',
|
|
295
|
+
updateHow: 'Name the version when you upgrade: by name alone, pnpm by default does not install a version published less than 24 hours ago.',
|
|
296
|
+
updateDesktop: 'Desktop app: on the Plugins page, uninstall Engramory memory, then search for and install',
|
|
297
|
+
updateCli: 'Command line: ',
|
|
298
|
+
updateProfile: '<name>',
|
|
299
|
+
updateAfter: 'Then restart dsh (in the desktop app, quit from the tray and open it again). Your memory and settings stay.',
|
|
300
|
+
updateCurrent: 'You have the latest version: the latest on {source} is {latest}.',
|
|
301
|
+
updateAhead: 'The {current} you have is newer than the latest on {source}, {latest}.',
|
|
302
|
+
updateMirror: 'npm gave no version, so this is from its mirror npmmirror, which can be a few minutes behind npm.',
|
|
303
|
+
updateFailed: 'Could not find the latest version: neither npm nor npmmirror gave one. The versions are listed on npm\'s site: ',
|
|
304
|
+
updateNpm: 'dsh-engramory on npm',
|
|
305
|
+
copySpecFailed: 'Could not copy; select the version above by hand.',
|
|
306
|
+
updateNote: 'Checking asks npm (or npmmirror, when npm cannot be reached) for the latest version number; nothing from your memory goes with it. Nothing is asked until you click.',
|
|
264
307
|
issueBody: '(What happened, or your idea)\n\n---\ndsh-engramory {version}\nComputer this page was opened on: {os}\ndsh version: ',
|
|
265
308
|
statNote: 'note',
|
|
266
309
|
statNotes: 'notes',
|
|
@@ -341,6 +384,7 @@ window.__ModuleLoader__.load({
|
|
|
341
384
|
.eng-brand{display:flex;align-items:center;gap:14px;}
|
|
342
385
|
.eng-logo{border-radius:12px;box-shadow:0 0 0 1px rgba(110,231,200,.35);}
|
|
343
386
|
.eng-hero-title{margin:0;font-size:21px;font-weight:600;line-height:28px;letter-spacing:.01em;}
|
|
387
|
+
.eng-hero-version{margin-left:10px;font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:13px;font-weight:400;letter-spacing:0;color:rgba(232,243,240,.6);}
|
|
344
388
|
.eng-stats{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 0;}
|
|
345
389
|
.eng-stat{display:inline-flex;align-items:baseline;gap:6px;}
|
|
346
390
|
.eng-stat+.eng-stat{margin-left:18px;padding-left:18px;border-left:1px solid rgba(232,243,240,.18);}
|
|
@@ -439,6 +483,14 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
439
483
|
.eng-link:hover{opacity:.8;}
|
|
440
484
|
.eng-email{margin:0 8px 0 2px;font-family:var(--ds-font-family-code,ui-monospace,monospace);user-select:all;color:var(--dsw-alias-label-primary);}
|
|
441
485
|
.eng-feedback-note{color:var(--dsw-alias-label-tertiary);}
|
|
486
|
+
.eng-version,.eng-update{display:flex;flex-direction:column;gap:2px;}
|
|
487
|
+
.eng-update{margin:2px 0 6px;}
|
|
488
|
+
.eng-version>p>.eng-btn{margin-left:8px;}
|
|
489
|
+
.eng-update-new{margin-right:8px;font-weight:500;color:var(--dsw-alias-label-primary);}
|
|
490
|
+
.eng-update ul{margin:0;padding-left:18px;}
|
|
491
|
+
.eng-update li{margin:0;}
|
|
492
|
+
.eng-update li .eng-btn{margin-left:6px;}
|
|
493
|
+
.eng-code{margin:0 2px 0 6px;font-family:var(--ds-font-family-code,ui-monospace,monospace);user-select:all;color:var(--dsw-alias-label-primary);}
|
|
442
494
|
.eng-name:focus-visible,.eng-row:focus-visible,.eng-btn:focus-visible,.eng-tab:focus-visible,.eng-link:focus-visible,.eng-howto>summary:focus-visible,.eng-archive>summary:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary));outline-offset:1px;}
|
|
443
495
|
`
|
|
444
496
|
|
|
@@ -821,6 +873,7 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
821
873
|
book: [['path', { d: 'M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z' }], ['path', { d: 'M4 19V5' }]],
|
|
822
874
|
issue: [['path', { d: 'M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z' }]],
|
|
823
875
|
mail: [['rect', { x: 3, y: 5, width: 18, height: 14, rx: 2 }], ['path', { d: 'm3 7 9 6 9-6' }]],
|
|
876
|
+
package: [['path', { d: 'M12 3 4 7v10l8 4 8-4V7z' }], ['path', { d: 'm4 7 8 4 8-4M12 11v10' }]],
|
|
824
877
|
user: [['circle', { cx: 12, cy: 8.6, r: 3.6 }], ['path', { d: 'M5 19.5c1.2-3.3 3.9-5 7-5s5.8 1.7 7 5z' }]],
|
|
825
878
|
feedback: [['path', { d: 'M4.5 6.5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H11l-4 3v-3h-.5a2 2 0 0 1-2-2z' }],
|
|
826
879
|
['path', { d: 'm9 10.3 2 2 4-4' }]],
|
|
@@ -852,10 +905,10 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
852
905
|
minute: '2-digit' })
|
|
853
906
|
|
|
854
907
|
/**
|
|
855
|
-
* The banner atop the memory page, in the project's own colours on any theme: its name
|
|
856
|
-
* listing in three numbers as read at `at` with a refresh beside the
|
|
857
|
-
* settings that matter most in a panel of their own. Numbers only once there
|
|
858
|
-
* with something to count.
|
|
908
|
+
* The banner atop the memory page, in the project's own colours on any theme: its name with
|
|
909
|
+
* the plugin's version, the listing in three numbers as read at `at` with a refresh beside the
|
|
910
|
+
* time, and the two settings that matter most in a panel of their own. Numbers only once there
|
|
911
|
+
* is a listing with something to count.
|
|
859
912
|
*/
|
|
860
913
|
function Hero({ data, at, refresh, t }) {
|
|
861
914
|
const counted = data !== undefined && (data.stores.length > 0 || data.unreadable > 0)
|
|
@@ -864,7 +917,8 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
864
917
|
const stat = (n, label) => h('div', { className: 'eng-stat', key: label }, h('b', null, String(n)), h('span', null, label))
|
|
865
918
|
return h('header', { className: 'eng-hero' },
|
|
866
919
|
h('div', { className: 'eng-hero-main' },
|
|
867
|
-
h('div', { className: 'eng-brand' }, h(Logo), h('h1', { className: 'eng-hero-title' }, t('panelTitle')
|
|
920
|
+
h('div', { className: 'eng-brand' }, h(Logo), h('h1', { className: 'eng-hero-title' }, t('panelTitle'),
|
|
921
|
+
h('span', { className: 'eng-hero-version' }, `v${VERSION}`))),
|
|
868
922
|
counted ? h('div', { className: 'eng-stats' },
|
|
869
923
|
stat(notes, t(notes === 1 ? 'statNote' : 'statNotes')),
|
|
870
924
|
stat(data.stores.length, t(data.stores.length === 1 ? 'statStore' : 'statStores')),
|
|
@@ -1060,10 +1114,107 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1060
1114
|
: /linux/i.test(platform) ? 'Linux' : 'unknown'
|
|
1061
1115
|
}
|
|
1062
1116
|
|
|
1117
|
+
/** The latest version on npm and the registry that said so, asked of each in turn until one
|
|
1118
|
+
* answers with a version; undefined when none does. Each gets 8 seconds, body included, and no cookie or
|
|
1119
|
+
* referrer goes with the request: the package's name is all it asks about. */
|
|
1120
|
+
async function latestVersion() {
|
|
1121
|
+
for (const [source, registry] of REGISTRIES) {
|
|
1122
|
+
const deadline = new AbortController()
|
|
1123
|
+
const timer = setTimeout(() => deadline.abort(), 8000)
|
|
1124
|
+
try {
|
|
1125
|
+
const response = await fetch(`${registry}/${PACKAGE}/latest`, { cache: 'no-store', credentials: 'omit',
|
|
1126
|
+
referrerPolicy: 'no-referrer', signal: deadline.signal, headers: { accept: 'application/json' } })
|
|
1127
|
+
const version = response.ok ? (await response.json())?.version : undefined
|
|
1128
|
+
if (typeof version === 'string' && version.length <= 64 && SEMVER.test(version)) return { version, source }
|
|
1129
|
+
} catch {
|
|
1130
|
+
// unreachable, refused, too slow or not JSON: the next registry
|
|
1131
|
+
} finally {
|
|
1132
|
+
clearTimeout(timer)
|
|
1133
|
+
// a body left unread (an error's) or half read is let go, not left streaming
|
|
1134
|
+
deadline.abort()
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
return undefined
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
/** -1, 0 or 1 as version `a` is older than, the same as or newer than `b` (both SEMVER): by
|
|
1141
|
+
* the three numbers, then a prerelease before its release. Two prereleases of one release
|
|
1142
|
+
* count as the same; this package publishes none to npm's `latest`. */
|
|
1143
|
+
function compareVersions(a, b) {
|
|
1144
|
+
const x = SEMVER.exec(a)
|
|
1145
|
+
const y = SEMVER.exec(b)
|
|
1146
|
+
for (let i = 1; i <= 3; i++) {
|
|
1147
|
+
if (Number(x[i]) !== Number(y[i])) return Number(x[i]) < Number(y[i]) ? -1 : 1
|
|
1148
|
+
}
|
|
1149
|
+
return x[4] === y[4] || (x[4] !== undefined && y[4] !== undefined) ? 0 : x[4] === undefined ? 1 : -1
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/**
|
|
1153
|
+
* The installed version and, on a click and only then, how it stands against the latest on
|
|
1154
|
+
* npm. A newer one comes with the steps that install it, the version named: by name alone,
|
|
1155
|
+
* pnpm (the desktop's, and the CLI's from pnpm 11) takes only a version a day old. dsh has no
|
|
1156
|
+
* update for a plugin outside its own catalog, so the desktop's way is uninstall and install.
|
|
1157
|
+
*/
|
|
1158
|
+
function UpdateCheck({ t }) {
|
|
1159
|
+
const [check, setCheck] = useState({ phase: 'idle' })
|
|
1160
|
+
const [copy, setCopy] = useState('copy')
|
|
1161
|
+
const alive = useRef(true)
|
|
1162
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1163
|
+
const run = async () => {
|
|
1164
|
+
setCheck({ phase: 'checking' })
|
|
1165
|
+
setCopy('copy')
|
|
1166
|
+
const found = await latestVersion()
|
|
1167
|
+
if (!alive.current) return
|
|
1168
|
+
setCheck(found === undefined ? { phase: 'failed' } : { phase: 'done', latest: found.version,
|
|
1169
|
+
source: found.source, order: compareVersions(found.version, VERSION) })
|
|
1170
|
+
}
|
|
1171
|
+
const spec = `${PACKAGE}@${check.latest}`
|
|
1172
|
+
const copySpec = async () => {
|
|
1173
|
+
const done = await copyText(spec)
|
|
1174
|
+
if (alive.current) setCopy(done ? 'copied' : 'copyFailed')
|
|
1175
|
+
}
|
|
1176
|
+
const external = (href, text) => h('a', { className: 'eng-link', href, target: '_blank', rel: 'noopener noreferrer' }, text)
|
|
1177
|
+
let result = null
|
|
1178
|
+
if (check.phase === 'failed') {
|
|
1179
|
+
result = h('p', { role: 'status' }, t('updateFailed'), external(NPM_PAGE, t('updateNpm')))
|
|
1180
|
+
} else if (check.phase === 'done' && check.order <= 0) {
|
|
1181
|
+
result = h('p', { role: 'status' },
|
|
1182
|
+
check.order === 0 ? t('updateCurrent', { latest: check.latest, source: check.source })
|
|
1183
|
+
: t('updateAhead', { latest: check.latest, current: VERSION, source: check.source }))
|
|
1184
|
+
} else if (check.phase === 'done') {
|
|
1185
|
+
result = h('div', { className: 'eng-update', role: 'status' },
|
|
1186
|
+
h('p', null,
|
|
1187
|
+
h('span', { className: 'eng-update-new' }, t('updateNewer', { latest: check.latest, current: VERSION })),
|
|
1188
|
+
external(`${RELEASE}${check.latest}`, t('updateNotes'))),
|
|
1189
|
+
h('p', null, t('updateHow')),
|
|
1190
|
+
h('ul', null,
|
|
1191
|
+
h('li', null, t('updateDesktop'), h('code', { className: 'eng-code' }, spec),
|
|
1192
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-small', onClick: copySpec },
|
|
1193
|
+
t(copy === 'copied' ? 'copied' : 'copy'))),
|
|
1194
|
+
h('li', null, t('updateCli'),
|
|
1195
|
+
h('code', { className: 'eng-code' }, `dsh plugin --profile ${t('updateProfile')} add ${spec}`))),
|
|
1196
|
+
copy === 'copyFailed' ? h('p', { className: 'eng-feedback-note' }, t('copySpecFailed')) : null,
|
|
1197
|
+
h('p', null, t('updateAfter')))
|
|
1198
|
+
}
|
|
1199
|
+
// a mirror's word, which may trail npm's, is said to be one
|
|
1200
|
+
const mirrored = check.phase === 'done' && check.source !== 'npm'
|
|
1201
|
+
? h('p', { className: 'eng-feedback-note' }, t('updateMirror')) : null
|
|
1202
|
+
return h('div', { className: 'eng-version' },
|
|
1203
|
+
h('p', null,
|
|
1204
|
+
icon('package', 14),
|
|
1205
|
+
t('versionLine', { version: VERSION }),
|
|
1206
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-small', disabled: check.phase === 'checking',
|
|
1207
|
+
onClick: run }, t(check.phase === 'checking' ? 'checking' : 'checkUpdate'))),
|
|
1208
|
+
result,
|
|
1209
|
+
mirrored,
|
|
1210
|
+
h('p', { className: 'eng-feedback-note' }, t('updateNote')))
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1063
1213
|
/**
|
|
1064
1214
|
* Where to report a problem or send an idea: a new issue, its body started with the
|
|
1065
1215
|
* plugin's version and the OS (no path, no note), or the mailbox, whose address the
|
|
1066
|
-
* button copies — the desktop app opens only web links, not `mailto:`.
|
|
1216
|
+
* button copies — the desktop app opens only web links, not `mailto:`. Above them, the
|
|
1217
|
+
* version and the check for a newer one.
|
|
1067
1218
|
*/
|
|
1068
1219
|
function Feedback({ t }) {
|
|
1069
1220
|
const [copy, setCopy] = useState('copy')
|
|
@@ -1075,6 +1226,7 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1075
1226
|
}
|
|
1076
1227
|
const href = `${ISSUES}?body=${encodeURIComponent(t('issueBody', { version: VERSION, os: osName() }))}`
|
|
1077
1228
|
return h('footer', { className: 'eng-feedback' },
|
|
1229
|
+
h(UpdateCheck, { t }),
|
|
1078
1230
|
h('p', null,
|
|
1079
1231
|
icon('issue', 14),
|
|
1080
1232
|
t('feedbackLead'),
|
|
@@ -1084,7 +1236,7 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1084
1236
|
h('button', { type: 'button', className: 'eng-btn eng-btn-small', onClick: copyAddress },
|
|
1085
1237
|
t(copy === 'copied' ? 'copied' : 'copy'))),
|
|
1086
1238
|
copy === 'copyFailed' ? h('p', { className: 'eng-feedback-note', role: 'status' }, t('copyFailed')) : null,
|
|
1087
|
-
h('p', { className: 'eng-feedback-note' }, t('feedbackNote'
|
|
1239
|
+
h('p', { className: 'eng-feedback-note' }, t('feedbackNote')))
|
|
1088
1240
|
}
|
|
1089
1241
|
|
|
1090
1242
|
/**
|