dsh-nextsteps 1.4.6 → 1.4.7
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/client.js +4 -10
- package/index.js +1 -5
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -10,6 +10,8 @@ window.__ModuleLoader__.load({
|
|
|
10
10
|
const MAX_FOLLOWUPS = 6;
|
|
11
11
|
const PROMPT_TRUNCATE = 60;
|
|
12
12
|
const CLICKED_KEY = 'dsh-nextsteps.clicked';
|
|
13
|
+
const UPDATE_KEY = 'dsh-nextsteps.updated';
|
|
14
|
+
const remembered = () => { try { return localStorage.getItem(UPDATE_KEY); } catch { return null; } };
|
|
13
15
|
|
|
14
16
|
|
|
15
17
|
const CSS = `
|
|
@@ -371,14 +373,6 @@ window.__ModuleLoader__.load({
|
|
|
371
373
|
let pluginSettings = { lang: 'auto', maxFollowups: 3, showHeader: true };
|
|
372
374
|
let updateManager = undefined;
|
|
373
375
|
|
|
374
|
-
function compareVersions(a, b) {
|
|
375
|
-
const pa = String(a ?? '').replace(/^v/, '').split('.').map((part) => Number(part) || 0);
|
|
376
|
-
const pb = String(b ?? '').replace(/^v/, '').split('.').map((part) => Number(part) || 0);
|
|
377
|
-
for (let index = 0; index < Math.max(pa.length, pb.length); index += 1) {
|
|
378
|
-
if ((pa[index] ?? 0) !== (pb[index] ?? 0)) return (pa[index] ?? 0) < (pb[index] ?? 0) ? -1 : 1;
|
|
379
|
-
}
|
|
380
|
-
return 0;
|
|
381
|
-
}
|
|
382
376
|
let pluginVersion;
|
|
383
377
|
|
|
384
378
|
async function responseJson(response) {
|
|
@@ -565,8 +559,7 @@ window.__ModuleLoader__.load({
|
|
|
565
559
|
const response = await fetch(UPDATE_ROUTE, { cache: 'no-store' });
|
|
566
560
|
const info = await responseJson(response);
|
|
567
561
|
if (!response.ok || info === null || typeof info !== 'object' || info.error !== undefined) throw new Error(info?.error ?? 'HTTP ' + response.status);
|
|
568
|
-
const
|
|
569
|
-
const status = installedNewer ? 'restart' : info.newer !== true ? 'current' : info.managed ? 'available' : 'manual';
|
|
562
|
+
const status = info.newer !== true ? 'current' : remembered() === info.latest ? 'restart' : info.managed ? 'available' : 'manual';
|
|
570
563
|
setUpdate({ status, info });
|
|
571
564
|
} catch (error) {
|
|
572
565
|
setUpdate((previous) => previous.status === 'restart' ? previous : { status: 'error', info: previous.info, error: String(error?.message ?? error) });
|
|
@@ -592,6 +585,7 @@ window.__ModuleLoader__.load({
|
|
|
592
585
|
const live = result?.application === 'applied';
|
|
593
586
|
if (!live && result?.application !== 'restart-required' && result?.version !== info.latest) throw new Error(firstLine());
|
|
594
587
|
if (result?.application === 'failed') console.warn(`dsh-nextsteps: ${info.latest} is installed; dsh could not start it before a restart: ${firstLine()}`);
|
|
588
|
+
try { localStorage.setItem(UPDATE_KEY, info.latest); } catch { }
|
|
595
589
|
setUpdate(live
|
|
596
590
|
? { status: 'current', info: { ...info, current: info.latest, newer: false } }
|
|
597
591
|
: { status: 'restart', info });
|
package/index.js
CHANGED
|
@@ -172,10 +172,6 @@ function nextstepsSectionText() {
|
|
|
172
172
|
].join('\n');
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
function onDiskVersion() {
|
|
176
|
-
try { return JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version ?? null; } catch { return null; }
|
|
177
|
-
}
|
|
178
|
-
|
|
179
175
|
const PLUGIN_REV = 'sf-2';
|
|
180
176
|
|
|
181
177
|
function toolSpec(settings = { lang: 'auto', maxFollowups: 3, model: '' }) {
|
|
@@ -453,7 +449,7 @@ async function apply(ctx) {
|
|
|
453
449
|
fetch: async (request) => {
|
|
454
450
|
try {
|
|
455
451
|
const info = await checkUpdate(fetch, PACKAGE, request.signal);
|
|
456
|
-
return json({ ...info, installed:
|
|
452
|
+
return json({ ...info, installed: undefined });
|
|
457
453
|
} catch (error) {
|
|
458
454
|
return json({ error: String(error?.message ?? error) }, 502);
|
|
459
455
|
}
|