@alanzhao/dsh-memory-lite 0.3.2 → 0.3.4
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/lib/client.js +115 -20
- package/package.json +3 -2
package/lib/client.js
CHANGED
|
@@ -22,6 +22,12 @@ window.__ModuleLoader__.load({
|
|
|
22
22
|
const { jsx, jsxs } = require('react/jsx-runtime');
|
|
23
23
|
const { useCallback, useEffect, useState } = require('react');
|
|
24
24
|
|
|
25
|
+
let Tooltip = null;
|
|
26
|
+
try {
|
|
27
|
+
const primitives = require('@deepseek-ai/dsh-client-ui-primitives');
|
|
28
|
+
if (primitives && primitives.Tooltip) Tooltip = primitives.Tooltip;
|
|
29
|
+
} catch (_) {}
|
|
30
|
+
|
|
25
31
|
const POLL_MS = 10000;
|
|
26
32
|
const LABEL = 'memory-lite';
|
|
27
33
|
const NS = 'dsh-memory-lite';
|
|
@@ -94,20 +100,35 @@ window.__ModuleLoader__.load({
|
|
|
94
100
|
|
|
95
101
|
// The header utilities row is horizontal; match the 32px capsule chrome
|
|
96
102
|
// of the built-in "Session log" button so the pair reads as one cluster.
|
|
97
|
-
|
|
103
|
+
const capsule = jsx('div', {
|
|
98
104
|
style: {
|
|
99
105
|
display: 'inline-flex', alignItems: 'center', gap: 6,
|
|
100
106
|
height: 32, padding: '0 12px', boxSizing: 'border-box',
|
|
101
107
|
borderRadius: 18, border: '1px solid var(--dsw-alias-border-l2)',
|
|
102
108
|
background: 'transparent', cursor: 'default', flexShrink: 0,
|
|
103
|
-
whiteSpace: 'nowrap',
|
|
109
|
+
whiteSpace: 'nowrap', WebkitAppRegion: 'no-drag',
|
|
104
110
|
},
|
|
105
111
|
title,
|
|
106
|
-
children: [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
children: [
|
|
113
|
+
jsx('span', {
|
|
114
|
+
style: { fontSize: 12, lineHeight: '20px', color: 'var(--dsw-alias-label-tertiary)' },
|
|
115
|
+
title,
|
|
116
|
+
children: LABEL,
|
|
117
|
+
}),
|
|
118
|
+
dot,
|
|
119
|
+
],
|
|
110
120
|
});
|
|
121
|
+
|
|
122
|
+
if (Tooltip) {
|
|
123
|
+
return jsx(Tooltip, {
|
|
124
|
+
label: title,
|
|
125
|
+
side: 'bottom',
|
|
126
|
+
delayMs: 300,
|
|
127
|
+
children: capsule,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return capsule;
|
|
111
132
|
}
|
|
112
133
|
|
|
113
134
|
// ---- settings page (方案 A §16) ----
|
|
@@ -508,6 +529,7 @@ window.__ModuleLoader__.load({
|
|
|
508
529
|
const snapshot = scope ? scope.getSnapshot() : null;
|
|
509
530
|
const value = snapshot && snapshot.status === 'ready' ? snapshot.value : undefined;
|
|
510
531
|
const writable = snapshot ? snapshot.writable : false;
|
|
532
|
+
const loading = !snapshot || snapshot.status === 'loading';
|
|
511
533
|
|
|
512
534
|
// The route the effort dropdown belongs to: the staged edit wins, then
|
|
513
535
|
// the stored value. '' = 跟随全局默认, which useModelOptions resolves to
|
|
@@ -523,7 +545,22 @@ window.__ModuleLoader__.load({
|
|
|
523
545
|
|
|
524
546
|
useEffect(() => {
|
|
525
547
|
if (!scope) return undefined;
|
|
526
|
-
|
|
548
|
+
const unsub = scope.subscribe(() => { force((n) => n + 1); });
|
|
549
|
+
let timer = null;
|
|
550
|
+
const cur = scope.getSnapshot ? scope.getSnapshot() : null;
|
|
551
|
+
if (!cur || cur.status === 'loading' || cur.status === 'unavailable') {
|
|
552
|
+
timer = setInterval(() => {
|
|
553
|
+
const next = scope.getSnapshot ? scope.getSnapshot() : null;
|
|
554
|
+
if (next && (next.status === 'ready' || next.writable)) {
|
|
555
|
+
force((n) => n + 1);
|
|
556
|
+
if (timer) { clearInterval(timer); timer = null; }
|
|
557
|
+
}
|
|
558
|
+
}, 200);
|
|
559
|
+
}
|
|
560
|
+
return () => {
|
|
561
|
+
unsub();
|
|
562
|
+
if (timer) clearInterval(timer);
|
|
563
|
+
};
|
|
527
564
|
}, [scope]);
|
|
528
565
|
|
|
529
566
|
const setField = (key, val) => {
|
|
@@ -677,6 +714,10 @@ window.__ModuleLoader__.load({
|
|
|
677
714
|
failed ? jsx('span', { style: { fontSize: 12, color: 'var(--dsw-alias-state-error-primary)' }, children: '保存失败' }) : null,
|
|
678
715
|
]});
|
|
679
716
|
|
|
717
|
+
if (loading) {
|
|
718
|
+
return jsx('div', { style: { fontSize: 13, color: 'var(--dsw-alias-label-tertiary)' }, children: '正在加载设置…' });
|
|
719
|
+
}
|
|
720
|
+
|
|
680
721
|
if (!writable) {
|
|
681
722
|
return jsx('div', { style: { fontSize: 13, color: 'var(--dsw-alias-label-tertiary)' }, children: '设置文档不可写(只读环境)。' });
|
|
682
723
|
}
|
|
@@ -735,16 +776,8 @@ window.__ModuleLoader__.load({
|
|
|
735
776
|
// dynamically inside resolveScope to preserve dual-engine compatibility.
|
|
736
777
|
const inject = ['connection', 'slots'];
|
|
737
778
|
|
|
738
|
-
function
|
|
739
|
-
return
|
|
740
|
-
getSnapshot: () => ({ status: 'unavailable', value: {}, revision: 0, writable: false }),
|
|
741
|
-
subscribe: () => () => {},
|
|
742
|
-
mutate: async () => false,
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function resolveScope(ctx, defaultId, fallbackId) {
|
|
747
|
-
if (!ctx || typeof ctx.get !== 'function') return createFallbackScope();
|
|
779
|
+
function resolveDirectScope(ctx, defaultId, fallbackId) {
|
|
780
|
+
if (!ctx || typeof ctx.get !== 'function') return null;
|
|
748
781
|
|
|
749
782
|
// Branch 1: dsh >= 0.1.7 (configForms)
|
|
750
783
|
const configForms = ctx.get('configForms');
|
|
@@ -768,7 +801,62 @@ window.__ModuleLoader__.load({
|
|
|
768
801
|
return settingsScope.bind({ namespace: fallbackId || defaultId });
|
|
769
802
|
}
|
|
770
803
|
|
|
771
|
-
return
|
|
804
|
+
return null;
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
function createLazyScope(ctx, defaultId, fallbackId) {
|
|
808
|
+
let target = resolveDirectScope(ctx, defaultId, fallbackId);
|
|
809
|
+
const listeners = new Set();
|
|
810
|
+
let unsubTarget = null;
|
|
811
|
+
|
|
812
|
+
function ensureTarget() {
|
|
813
|
+
if (!target) {
|
|
814
|
+
target = resolveDirectScope(ctx, defaultId, fallbackId);
|
|
815
|
+
if (target && typeof target.subscribe === 'function' && listeners.size > 0 && !unsubTarget) {
|
|
816
|
+
unsubTarget = target.subscribe((snap) => {
|
|
817
|
+
for (const l of listeners) l(snap);
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
return target;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
return {
|
|
825
|
+
getSnapshot: () => {
|
|
826
|
+
const t = ensureTarget();
|
|
827
|
+
if (t && typeof t.getSnapshot === 'function') {
|
|
828
|
+
return t.getSnapshot();
|
|
829
|
+
}
|
|
830
|
+
return { status: 'loading', value: {}, revision: 0, writable: true };
|
|
831
|
+
},
|
|
832
|
+
subscribe: (cb) => {
|
|
833
|
+
listeners.add(cb);
|
|
834
|
+
const t = ensureTarget();
|
|
835
|
+
if (t && typeof t.subscribe === 'function' && !unsubTarget) {
|
|
836
|
+
unsubTarget = t.subscribe((snap) => {
|
|
837
|
+
for (const l of listeners) l(snap);
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
return () => {
|
|
841
|
+
listeners.delete(cb);
|
|
842
|
+
if (listeners.size === 0 && unsubTarget) {
|
|
843
|
+
unsubTarget();
|
|
844
|
+
unsubTarget = null;
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
},
|
|
848
|
+
mutate: async (ops, expectedRevision) => {
|
|
849
|
+
const t = ensureTarget();
|
|
850
|
+
if (t && typeof t.mutate === 'function') {
|
|
851
|
+
return t.mutate(ops, expectedRevision);
|
|
852
|
+
}
|
|
853
|
+
throw new Error('settings scope not ready');
|
|
854
|
+
},
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
function resolveScope(ctx, defaultId, fallbackId) {
|
|
859
|
+
return createLazyScope(ctx, defaultId, fallbackId);
|
|
772
860
|
}
|
|
773
861
|
|
|
774
862
|
function apply(ctx, config) {
|
|
@@ -783,7 +871,10 @@ window.__ModuleLoader__.load({
|
|
|
783
871
|
// -20 < open-in-app (-10): the status pill sits left of the
|
|
784
872
|
// workspace open-in-app split button (Finder/VSCode/Xcode).
|
|
785
873
|
order: -20,
|
|
786
|
-
inject: () => ({
|
|
874
|
+
inject: () => ({
|
|
875
|
+
connection: ctx.get('connection') || connection,
|
|
876
|
+
scope: resolveScope(ctx, 'memory-lite', NS),
|
|
877
|
+
}),
|
|
787
878
|
},
|
|
788
879
|
StatusDot,
|
|
789
880
|
));
|
|
@@ -794,7 +885,11 @@ window.__ModuleLoader__.load({
|
|
|
794
885
|
id: 'memory-lite',
|
|
795
886
|
order: 100,
|
|
796
887
|
label: () => 'memory-lite',
|
|
797
|
-
inject: () => ({
|
|
888
|
+
inject: () => ({
|
|
889
|
+
connection: ctx.get('connection') || connection,
|
|
890
|
+
scope: resolveScope(ctx, 'memory-lite', NS),
|
|
891
|
+
agentDefaultScope: resolveScope(ctx, 'agent-default-model'),
|
|
892
|
+
}),
|
|
798
893
|
},
|
|
799
894
|
SettingsPage,
|
|
800
895
|
));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alanzhao/dsh-memory-lite",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Lightweight zero-dependency memory plugin for DeepSeek Harness: Markdown-file memory store, L0 catalog injection, and 5 model-facing tools.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"@deepseek-ai/dsh-client-runtime",
|
|
43
43
|
"@deepseek-ai/dsh-client-connection",
|
|
44
44
|
"@deepseek-ai/dsh-client-locale",
|
|
45
|
-
"@deepseek-ai/dsh-client-ui-settings"
|
|
45
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-primitives"
|
|
46
47
|
],
|
|
47
48
|
"platform": "web"
|
|
48
49
|
}
|