@tangjs/dsh-memory 0.0.0-stage → 1.0.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 +154 -0
- package/LICENSE +201 -0
- package/README.en.md +268 -0
- package/README.md +268 -2
- package/client/client.js +1607 -0
- package/cordis.patch.yml +7 -0
- package/docs/ACCEPTANCE.md +341 -0
- package/docs/DESIGN.md +87 -0
- package/docs/DETAIL.md +48 -0
- package/docs/SPIKE.md +20 -0
- package/docs/diagrams/memory-flow.html +1227 -0
- package/icon.svg +8 -0
- package/index.js +582 -0
- package/locale/en.json +50 -0
- package/locale/zh.json +50 -0
- package/package.json +77 -4
- package/screenshots/global-space.png +0 -0
- package/screenshots/guide.png +0 -0
- package/screenshots/memory-detail.png +0 -0
- package/screenshots/memory-flow.png +0 -0
- package/screenshots/memory-page.png +0 -0
- package/src/host/api.mjs +234 -0
- package/src/host/autoDream.mjs +946 -0
- package/src/host/config.mjs +131 -0
- package/src/host/digest.mjs +121 -0
- package/src/host/dream.mjs +385 -0
- package/src/host/dreamAgent.mjs +619 -0
- package/src/host/extract.mjs +813 -0
- package/src/host/memoryIndex.mjs +137 -0
- package/src/host/prompt.mjs +65 -0
- package/src/host/recall.mjs +456 -0
- package/src/host/score.mjs +76 -0
- package/src/host/store.mjs +498 -0
- package/src/host/tool.mjs +144 -0
|
@@ -0,0 +1,1227 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh-CN">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<link
|
|
7
|
+
rel="icon"
|
|
8
|
+
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%230b1424'/%3E%3Ccircle cx='16' cy='16' r='7' fill='none' stroke='%2338bdf8' stroke-width='2.4'/%3E%3C/svg%3E"
|
|
9
|
+
/>
|
|
10
|
+
<title>dsh-memory:多工作目录 / 多会话下的记忆提炼与消费</title>
|
|
11
|
+
<style>
|
|
12
|
+
:root {
|
|
13
|
+
--bg: #070d18;
|
|
14
|
+
--panel: #0f192a;
|
|
15
|
+
--panel2: #0b1422;
|
|
16
|
+
--line: #22314a;
|
|
17
|
+
--line2: #2c3f5e;
|
|
18
|
+
--text: #e8eefb;
|
|
19
|
+
--muted: #93a6c2;
|
|
20
|
+
--muted2: #6f83a1;
|
|
21
|
+
--cyan: #38bdf8;
|
|
22
|
+
--blue: #60a5fa;
|
|
23
|
+
--violet: #a78bfa;
|
|
24
|
+
--amber: #f5b942;
|
|
25
|
+
--green: #34d399;
|
|
26
|
+
--red: #f87171;
|
|
27
|
+
--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
28
|
+
}
|
|
29
|
+
* {
|
|
30
|
+
box-sizing: border-box;
|
|
31
|
+
}
|
|
32
|
+
html,
|
|
33
|
+
body {
|
|
34
|
+
margin: 0;
|
|
35
|
+
background:
|
|
36
|
+
radial-gradient(1100px 640px at 16% -12%, #15283f 0%, transparent 58%),
|
|
37
|
+
radial-gradient(900px 620px at 108% 6%, #1d1738 0%, transparent 55%),
|
|
38
|
+
var(--bg);
|
|
39
|
+
color: var(--text);
|
|
40
|
+
font-family:
|
|
41
|
+
-apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
|
|
42
|
+
sans-serif;
|
|
43
|
+
-webkit-font-smoothing: antialiased;
|
|
44
|
+
}
|
|
45
|
+
code,
|
|
46
|
+
.mono {
|
|
47
|
+
font-family: var(--mono);
|
|
48
|
+
}
|
|
49
|
+
.page {
|
|
50
|
+
max-width: 1528px;
|
|
51
|
+
margin: 0 auto;
|
|
52
|
+
padding: 26px 24px 64px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* header */
|
|
56
|
+
.head-top {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: flex-start;
|
|
59
|
+
justify-content: space-between;
|
|
60
|
+
gap: 24px;
|
|
61
|
+
}
|
|
62
|
+
.eyebrow {
|
|
63
|
+
font-size: 11.5px;
|
|
64
|
+
letter-spacing: 0.14em;
|
|
65
|
+
text-transform: uppercase;
|
|
66
|
+
color: var(--muted2);
|
|
67
|
+
font-family: var(--mono);
|
|
68
|
+
}
|
|
69
|
+
h1 {
|
|
70
|
+
margin: 8px 0 0;
|
|
71
|
+
font-size: 25px;
|
|
72
|
+
line-height: 1.34;
|
|
73
|
+
letter-spacing: -0.01em;
|
|
74
|
+
font-weight: 650;
|
|
75
|
+
}
|
|
76
|
+
h1 em {
|
|
77
|
+
font-style: normal;
|
|
78
|
+
color: var(--cyan);
|
|
79
|
+
}
|
|
80
|
+
.legend {
|
|
81
|
+
display: flex;
|
|
82
|
+
gap: 16px;
|
|
83
|
+
font-size: 11.5px;
|
|
84
|
+
color: var(--muted);
|
|
85
|
+
padding-top: 6px;
|
|
86
|
+
white-space: nowrap;
|
|
87
|
+
}
|
|
88
|
+
.legend span {
|
|
89
|
+
display: inline-flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
gap: 7px;
|
|
92
|
+
}
|
|
93
|
+
.lg {
|
|
94
|
+
display: inline-block;
|
|
95
|
+
width: 26px;
|
|
96
|
+
height: 0;
|
|
97
|
+
border-top: 2px solid var(--cyan);
|
|
98
|
+
}
|
|
99
|
+
.lg.dash {
|
|
100
|
+
border-top-style: dashed;
|
|
101
|
+
border-top-color: var(--violet);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.caption-box {
|
|
105
|
+
margin-top: 18px;
|
|
106
|
+
border: 1px solid var(--line);
|
|
107
|
+
border-radius: 14px;
|
|
108
|
+
background: linear-gradient(180deg, rgba(23, 36, 57, 0.92), rgba(12, 20, 33, 0.92));
|
|
109
|
+
padding: 14px 18px 15px;
|
|
110
|
+
min-height: 112px;
|
|
111
|
+
box-shadow: 0 22px 48px -34px #000;
|
|
112
|
+
}
|
|
113
|
+
.cap-head {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
gap: 11px;
|
|
117
|
+
}
|
|
118
|
+
.cap-no {
|
|
119
|
+
font-family: var(--mono);
|
|
120
|
+
font-size: 11px;
|
|
121
|
+
color: #061019;
|
|
122
|
+
background: var(--cyan);
|
|
123
|
+
border-radius: 999px;
|
|
124
|
+
padding: 2px 9px;
|
|
125
|
+
white-space: nowrap;
|
|
126
|
+
}
|
|
127
|
+
.cap-head h2 {
|
|
128
|
+
margin: 0;
|
|
129
|
+
font-size: 16.5px;
|
|
130
|
+
font-weight: 620;
|
|
131
|
+
letter-spacing: -0.005em;
|
|
132
|
+
}
|
|
133
|
+
.caption-box p {
|
|
134
|
+
margin: 9px 0 0;
|
|
135
|
+
color: #b8c7dd;
|
|
136
|
+
font-size: 13px;
|
|
137
|
+
line-height: 1.72;
|
|
138
|
+
min-height: 44px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.controls {
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
gap: 10px;
|
|
145
|
+
margin-top: 14px;
|
|
146
|
+
flex-wrap: wrap;
|
|
147
|
+
}
|
|
148
|
+
.controls button {
|
|
149
|
+
border: 1px solid var(--line2);
|
|
150
|
+
background: #111d31;
|
|
151
|
+
color: #cfe1f7;
|
|
152
|
+
border-radius: 9px;
|
|
153
|
+
padding: 7px 13px;
|
|
154
|
+
font-size: 12.5px;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
transition: 0.18s ease;
|
|
157
|
+
}
|
|
158
|
+
.controls button:hover {
|
|
159
|
+
border-color: #3c5a83;
|
|
160
|
+
background: #142340;
|
|
161
|
+
}
|
|
162
|
+
.controls button.primary {
|
|
163
|
+
background: rgba(56, 189, 248, 0.14);
|
|
164
|
+
border-color: rgba(56, 189, 248, 0.55);
|
|
165
|
+
color: #b9e8ff;
|
|
166
|
+
}
|
|
167
|
+
.dots {
|
|
168
|
+
display: flex;
|
|
169
|
+
gap: 6px;
|
|
170
|
+
margin-left: 8px;
|
|
171
|
+
}
|
|
172
|
+
.dot-btn {
|
|
173
|
+
width: 9px;
|
|
174
|
+
height: 9px;
|
|
175
|
+
border-radius: 50%;
|
|
176
|
+
border: 1px solid #37506f;
|
|
177
|
+
background: transparent;
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
padding: 0;
|
|
180
|
+
}
|
|
181
|
+
.dot-btn.on {
|
|
182
|
+
background: var(--cyan);
|
|
183
|
+
border-color: var(--cyan);
|
|
184
|
+
box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
|
|
185
|
+
}
|
|
186
|
+
.hint {
|
|
187
|
+
margin-left: auto;
|
|
188
|
+
font-size: 11.5px;
|
|
189
|
+
color: var(--muted2);
|
|
190
|
+
}
|
|
191
|
+
.toggles {
|
|
192
|
+
display: flex;
|
|
193
|
+
gap: 10px;
|
|
194
|
+
align-items: center;
|
|
195
|
+
margin-top: 12px;
|
|
196
|
+
flex-wrap: wrap;
|
|
197
|
+
font-size: 12px;
|
|
198
|
+
color: var(--muted);
|
|
199
|
+
}
|
|
200
|
+
.seg {
|
|
201
|
+
display: inline-flex;
|
|
202
|
+
border: 1px solid var(--line2);
|
|
203
|
+
border-radius: 999px;
|
|
204
|
+
overflow: hidden;
|
|
205
|
+
}
|
|
206
|
+
.seg button {
|
|
207
|
+
border: 0;
|
|
208
|
+
background: transparent;
|
|
209
|
+
color: var(--muted);
|
|
210
|
+
font-size: 11.5px;
|
|
211
|
+
padding: 5px 11px;
|
|
212
|
+
cursor: pointer;
|
|
213
|
+
}
|
|
214
|
+
.seg button.on {
|
|
215
|
+
background: rgba(56, 189, 248, 0.16);
|
|
216
|
+
color: #b9e8ff;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* stage */
|
|
220
|
+
.stage-wrap {
|
|
221
|
+
margin-top: 18px;
|
|
222
|
+
border: 1px solid var(--line);
|
|
223
|
+
border-radius: 16px;
|
|
224
|
+
background: linear-gradient(180deg, rgba(10, 18, 30, 0.6), rgba(8, 14, 24, 0.6));
|
|
225
|
+
padding: 8px;
|
|
226
|
+
overflow: auto;
|
|
227
|
+
}
|
|
228
|
+
#stage {
|
|
229
|
+
position: relative;
|
|
230
|
+
width: 1480px;
|
|
231
|
+
height: 1040px;
|
|
232
|
+
margin: 0 auto;
|
|
233
|
+
}
|
|
234
|
+
#wires {
|
|
235
|
+
position: absolute;
|
|
236
|
+
inset: 0;
|
|
237
|
+
width: 1480px;
|
|
238
|
+
height: 1040px;
|
|
239
|
+
pointer-events: none;
|
|
240
|
+
}
|
|
241
|
+
.wire {
|
|
242
|
+
fill: none;
|
|
243
|
+
stroke: var(--wc);
|
|
244
|
+
stroke-width: 1.7;
|
|
245
|
+
opacity: 0.26;
|
|
246
|
+
marker-end: url(#arrowDim);
|
|
247
|
+
transition:
|
|
248
|
+
opacity 0.35s ease,
|
|
249
|
+
stroke-width 0.35s ease,
|
|
250
|
+
filter 0.35s ease;
|
|
251
|
+
}
|
|
252
|
+
.wire.dashed {
|
|
253
|
+
stroke-dasharray: 5 6;
|
|
254
|
+
}
|
|
255
|
+
.wire.on {
|
|
256
|
+
opacity: 1;
|
|
257
|
+
stroke-width: 2.2;
|
|
258
|
+
marker-end: url(#arrowOn);
|
|
259
|
+
filter: drop-shadow(0 0 6px color-mix(in srgb, var(--wc) 55%, transparent));
|
|
260
|
+
}
|
|
261
|
+
.wire.on.dashed {
|
|
262
|
+
animation: flow 0.9s linear infinite;
|
|
263
|
+
}
|
|
264
|
+
@keyframes flow {
|
|
265
|
+
to {
|
|
266
|
+
stroke-dashoffset: -22;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
.wlabel {
|
|
270
|
+
fill: #7d92b2;
|
|
271
|
+
font-size: 10.5px;
|
|
272
|
+
font-family: var(--mono);
|
|
273
|
+
transition: fill 0.3s ease;
|
|
274
|
+
}
|
|
275
|
+
.wlabel.on {
|
|
276
|
+
fill: #d4ecff;
|
|
277
|
+
}
|
|
278
|
+
.cut {
|
|
279
|
+
fill: var(--red);
|
|
280
|
+
font-size: 15px;
|
|
281
|
+
font-weight: 700;
|
|
282
|
+
opacity: 0.75;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.panel {
|
|
286
|
+
position: absolute;
|
|
287
|
+
border: 1px solid var(--line);
|
|
288
|
+
border-radius: 13px;
|
|
289
|
+
background: linear-gradient(180deg, rgba(18, 29, 47, 0.96), rgba(11, 20, 33, 0.96));
|
|
290
|
+
padding: 11px 13px 12px;
|
|
291
|
+
transition: 0.35s ease;
|
|
292
|
+
box-shadow: 0 18px 40px -34px #000;
|
|
293
|
+
}
|
|
294
|
+
.panel.on {
|
|
295
|
+
border-color: rgba(56, 189, 248, 0.45);
|
|
296
|
+
box-shadow:
|
|
297
|
+
0 0 0 1px rgba(56, 189, 248, 0.18),
|
|
298
|
+
0 18px 44px -30px rgba(56, 189, 248, 0.35);
|
|
299
|
+
}
|
|
300
|
+
.ph {
|
|
301
|
+
display: flex;
|
|
302
|
+
align-items: center;
|
|
303
|
+
gap: 7px;
|
|
304
|
+
font-size: 11px;
|
|
305
|
+
color: var(--muted);
|
|
306
|
+
letter-spacing: 0.02em;
|
|
307
|
+
}
|
|
308
|
+
.ph b {
|
|
309
|
+
color: #d7e6fa;
|
|
310
|
+
font-weight: 600;
|
|
311
|
+
font-size: 11.5px;
|
|
312
|
+
}
|
|
313
|
+
.dot {
|
|
314
|
+
width: 7px;
|
|
315
|
+
height: 7px;
|
|
316
|
+
border-radius: 50%;
|
|
317
|
+
background: var(--cyan);
|
|
318
|
+
flex: none;
|
|
319
|
+
}
|
|
320
|
+
.dot.v {
|
|
321
|
+
background: var(--violet);
|
|
322
|
+
}
|
|
323
|
+
.dot.a {
|
|
324
|
+
background: var(--amber);
|
|
325
|
+
}
|
|
326
|
+
.dot.g {
|
|
327
|
+
background: var(--green);
|
|
328
|
+
}
|
|
329
|
+
.dot.b {
|
|
330
|
+
background: var(--blue);
|
|
331
|
+
}
|
|
332
|
+
.body {
|
|
333
|
+
margin-top: 9px;
|
|
334
|
+
font-size: 11.5px;
|
|
335
|
+
color: #a8bbd4;
|
|
336
|
+
line-height: 1.62;
|
|
337
|
+
}
|
|
338
|
+
.body b {
|
|
339
|
+
color: #e4effc;
|
|
340
|
+
font-weight: 600;
|
|
341
|
+
}
|
|
342
|
+
.mono-line {
|
|
343
|
+
font-family: var(--mono);
|
|
344
|
+
font-size: 10.5px;
|
|
345
|
+
color: #8fa7c7;
|
|
346
|
+
margin-top: 5px;
|
|
347
|
+
word-break: break-all;
|
|
348
|
+
}
|
|
349
|
+
.tag {
|
|
350
|
+
display: inline-block;
|
|
351
|
+
font-family: var(--mono);
|
|
352
|
+
font-size: 9.5px;
|
|
353
|
+
padding: 0 5px;
|
|
354
|
+
border-radius: 4px;
|
|
355
|
+
border: 1px solid #2d4363;
|
|
356
|
+
color: #9fb8d6;
|
|
357
|
+
margin-left: 5px;
|
|
358
|
+
vertical-align: 1px;
|
|
359
|
+
}
|
|
360
|
+
.tag.on {
|
|
361
|
+
border-color: rgba(52, 211, 153, 0.5);
|
|
362
|
+
color: #9ce8c8;
|
|
363
|
+
}
|
|
364
|
+
.tag.off {
|
|
365
|
+
border-color: #3a2b45;
|
|
366
|
+
color: #b48ecf;
|
|
367
|
+
}
|
|
368
|
+
.chips {
|
|
369
|
+
display: flex;
|
|
370
|
+
flex-direction: column;
|
|
371
|
+
gap: 5px;
|
|
372
|
+
margin-top: 8px;
|
|
373
|
+
}
|
|
374
|
+
.chip {
|
|
375
|
+
display: flex;
|
|
376
|
+
justify-content: space-between;
|
|
377
|
+
gap: 8px;
|
|
378
|
+
align-items: center;
|
|
379
|
+
font-family: var(--mono);
|
|
380
|
+
font-size: 10.5px;
|
|
381
|
+
color: #9db3cf;
|
|
382
|
+
background: rgba(15, 25, 42, 0.9);
|
|
383
|
+
border: 1px solid #1d2c44;
|
|
384
|
+
border-radius: 6px;
|
|
385
|
+
padding: 4px 7px;
|
|
386
|
+
}
|
|
387
|
+
.chip.cur {
|
|
388
|
+
border-color: rgba(56, 189, 248, 0.45);
|
|
389
|
+
color: #d8ecff;
|
|
390
|
+
background: rgba(20, 42, 66, 0.75);
|
|
391
|
+
}
|
|
392
|
+
.chip.sub {
|
|
393
|
+
opacity: 0.55;
|
|
394
|
+
}
|
|
395
|
+
.files {
|
|
396
|
+
margin-top: 8px;
|
|
397
|
+
display: flex;
|
|
398
|
+
flex-direction: column;
|
|
399
|
+
gap: 4px;
|
|
400
|
+
font-family: var(--mono);
|
|
401
|
+
font-size: 10.5px;
|
|
402
|
+
color: #a9bfd9;
|
|
403
|
+
}
|
|
404
|
+
.files div {
|
|
405
|
+
display: flex;
|
|
406
|
+
gap: 6px;
|
|
407
|
+
align-items: center;
|
|
408
|
+
}
|
|
409
|
+
.files i {
|
|
410
|
+
width: 3px;
|
|
411
|
+
height: 12px;
|
|
412
|
+
border-radius: 2px;
|
|
413
|
+
background: #37506f;
|
|
414
|
+
display: inline-block;
|
|
415
|
+
}
|
|
416
|
+
.files .fresh i {
|
|
417
|
+
background: var(--green);
|
|
418
|
+
}
|
|
419
|
+
.files .dim {
|
|
420
|
+
opacity: 0.45;
|
|
421
|
+
}
|
|
422
|
+
.turnstep {
|
|
423
|
+
display: flex;
|
|
424
|
+
gap: 8px;
|
|
425
|
+
margin-top: 7px;
|
|
426
|
+
font-size: 11.5px;
|
|
427
|
+
color: #a9bdd6;
|
|
428
|
+
align-items: flex-start;
|
|
429
|
+
transition: 0.3s ease;
|
|
430
|
+
border-radius: 7px;
|
|
431
|
+
padding: 3px 5px;
|
|
432
|
+
margin-left: -5px;
|
|
433
|
+
}
|
|
434
|
+
.turnstep .n {
|
|
435
|
+
font-family: var(--mono);
|
|
436
|
+
font-size: 9.5px;
|
|
437
|
+
color: #7f97b6;
|
|
438
|
+
border: 1px solid #2b405d;
|
|
439
|
+
border-radius: 4px;
|
|
440
|
+
padding: 0 4px;
|
|
441
|
+
flex: none;
|
|
442
|
+
margin-top: 1px;
|
|
443
|
+
}
|
|
444
|
+
.turnstep.on {
|
|
445
|
+
background: rgba(56, 189, 248, 0.1);
|
|
446
|
+
color: #e2f2ff;
|
|
447
|
+
}
|
|
448
|
+
.turnstep.on .n {
|
|
449
|
+
border-color: var(--cyan);
|
|
450
|
+
color: var(--cyan);
|
|
451
|
+
}
|
|
452
|
+
.bullets {
|
|
453
|
+
margin: 7px 0 0;
|
|
454
|
+
padding-left: 15px;
|
|
455
|
+
font-size: 11px;
|
|
456
|
+
color: #9fb3cc;
|
|
457
|
+
line-height: 1.66;
|
|
458
|
+
}
|
|
459
|
+
.bullets li {
|
|
460
|
+
margin-top: 2px;
|
|
461
|
+
}
|
|
462
|
+
.kv {
|
|
463
|
+
display: grid;
|
|
464
|
+
grid-template-columns: 74px 1fr;
|
|
465
|
+
gap: 3px 8px;
|
|
466
|
+
margin-top: 7px;
|
|
467
|
+
font-size: 11px;
|
|
468
|
+
color: #9fb3cc;
|
|
469
|
+
}
|
|
470
|
+
.kv span:nth-child(odd) {
|
|
471
|
+
color: #7288a7;
|
|
472
|
+
font-family: var(--mono);
|
|
473
|
+
font-size: 10px;
|
|
474
|
+
}
|
|
475
|
+
.loopnote {
|
|
476
|
+
margin-top: 12px;
|
|
477
|
+
border: 1px dashed #2c4463;
|
|
478
|
+
border-radius: 8px;
|
|
479
|
+
padding: 6px 8px;
|
|
480
|
+
font-size: 10.5px;
|
|
481
|
+
color: #86a0c0;
|
|
482
|
+
text-align: center;
|
|
483
|
+
}
|
|
484
|
+
.isolate {
|
|
485
|
+
margin-top: 8px;
|
|
486
|
+
font-size: 10.5px;
|
|
487
|
+
color: #b48ecf;
|
|
488
|
+
display: flex;
|
|
489
|
+
gap: 6px;
|
|
490
|
+
align-items: center;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/* below-stage sections */
|
|
494
|
+
section {
|
|
495
|
+
margin-top: 40px;
|
|
496
|
+
}
|
|
497
|
+
.sec-head {
|
|
498
|
+
display: flex;
|
|
499
|
+
align-items: baseline;
|
|
500
|
+
gap: 12px;
|
|
501
|
+
margin-bottom: 12px;
|
|
502
|
+
}
|
|
503
|
+
.sec-no {
|
|
504
|
+
font-family: var(--mono);
|
|
505
|
+
font-size: 11px;
|
|
506
|
+
color: var(--cyan);
|
|
507
|
+
letter-spacing: 0.1em;
|
|
508
|
+
}
|
|
509
|
+
h3 {
|
|
510
|
+
margin: 0;
|
|
511
|
+
font-size: 17px;
|
|
512
|
+
font-weight: 620;
|
|
513
|
+
}
|
|
514
|
+
.sec-sub {
|
|
515
|
+
margin: 4px 0 16px;
|
|
516
|
+
color: var(--muted);
|
|
517
|
+
font-size: 12.5px;
|
|
518
|
+
line-height: 1.7;
|
|
519
|
+
}
|
|
520
|
+
table {
|
|
521
|
+
width: 100%;
|
|
522
|
+
border-collapse: collapse;
|
|
523
|
+
font-size: 12.2px;
|
|
524
|
+
background: rgba(13, 22, 37, 0.7);
|
|
525
|
+
border: 1px solid var(--line);
|
|
526
|
+
border-radius: 12px;
|
|
527
|
+
overflow: hidden;
|
|
528
|
+
}
|
|
529
|
+
th,
|
|
530
|
+
td {
|
|
531
|
+
text-align: left;
|
|
532
|
+
padding: 9px 12px;
|
|
533
|
+
border-bottom: 1px solid #1b2940;
|
|
534
|
+
vertical-align: top;
|
|
535
|
+
}
|
|
536
|
+
th {
|
|
537
|
+
font-family: var(--mono);
|
|
538
|
+
font-size: 10.5px;
|
|
539
|
+
letter-spacing: 0.08em;
|
|
540
|
+
text-transform: uppercase;
|
|
541
|
+
color: var(--muted2);
|
|
542
|
+
background: rgba(16, 27, 45, 0.9);
|
|
543
|
+
font-weight: 500;
|
|
544
|
+
}
|
|
545
|
+
tr:last-child td {
|
|
546
|
+
border-bottom: 0;
|
|
547
|
+
}
|
|
548
|
+
td:first-child {
|
|
549
|
+
font-family: var(--mono);
|
|
550
|
+
font-size: 11.5px;
|
|
551
|
+
color: #a9c9ff;
|
|
552
|
+
white-space: nowrap;
|
|
553
|
+
}
|
|
554
|
+
.qa {
|
|
555
|
+
display: grid;
|
|
556
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
557
|
+
gap: 12px;
|
|
558
|
+
}
|
|
559
|
+
.q {
|
|
560
|
+
border: 1px solid var(--line);
|
|
561
|
+
border-radius: 12px;
|
|
562
|
+
padding: 12px 14px;
|
|
563
|
+
background: rgba(13, 22, 37, 0.7);
|
|
564
|
+
}
|
|
565
|
+
.q b {
|
|
566
|
+
display: block;
|
|
567
|
+
font-size: 12.8px;
|
|
568
|
+
color: #dcebfb;
|
|
569
|
+
margin-bottom: 6px;
|
|
570
|
+
}
|
|
571
|
+
.q p {
|
|
572
|
+
margin: 0;
|
|
573
|
+
font-size: 12px;
|
|
574
|
+
color: #9fb4cf;
|
|
575
|
+
line-height: 1.72;
|
|
576
|
+
}
|
|
577
|
+
.codes {
|
|
578
|
+
display: grid;
|
|
579
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
580
|
+
gap: 2px 22px;
|
|
581
|
+
font-size: 11.8px;
|
|
582
|
+
color: #9fb4cf;
|
|
583
|
+
}
|
|
584
|
+
.codes div {
|
|
585
|
+
display: flex;
|
|
586
|
+
justify-content: space-between;
|
|
587
|
+
gap: 12px;
|
|
588
|
+
padding: 6px 0;
|
|
589
|
+
border-bottom: 1px solid #17243a;
|
|
590
|
+
}
|
|
591
|
+
.codes span:first-child {
|
|
592
|
+
color: #cfe2f8;
|
|
593
|
+
}
|
|
594
|
+
.codes span:last-child {
|
|
595
|
+
font-family: var(--mono);
|
|
596
|
+
font-size: 10.5px;
|
|
597
|
+
color: #7c93b3;
|
|
598
|
+
text-align: right;
|
|
599
|
+
}
|
|
600
|
+
.fine {
|
|
601
|
+
margin-top: 34px;
|
|
602
|
+
color: var(--muted2);
|
|
603
|
+
font-size: 11px;
|
|
604
|
+
text-align: center;
|
|
605
|
+
}
|
|
606
|
+
@media (max-width: 900px) {
|
|
607
|
+
.head-top {
|
|
608
|
+
flex-direction: column;
|
|
609
|
+
}
|
|
610
|
+
.qa,
|
|
611
|
+
.codes {
|
|
612
|
+
grid-template-columns: 1fr;
|
|
613
|
+
}
|
|
614
|
+
h1 {
|
|
615
|
+
font-size: 21px;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
@media (prefers-reduced-motion: reduce) {
|
|
619
|
+
.wire.on.dashed {
|
|
620
|
+
animation: none;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
</style>
|
|
624
|
+
</head>
|
|
625
|
+
<body>
|
|
626
|
+
<div class="page">
|
|
627
|
+
<header>
|
|
628
|
+
<div class="head-top">
|
|
629
|
+
<div>
|
|
630
|
+
<div class="eyebrow">dsh-memory v0.4.1 · DSH 0.2.2-rc.5 · workspace-scoped notes</div>
|
|
631
|
+
<h1>不同工作目录、不同会话下,记忆是怎么被<em>提炼</em>和<em>消费</em>的</h1>
|
|
632
|
+
</div>
|
|
633
|
+
<div class="legend">
|
|
634
|
+
<span><i class="lg"></i>本步生效的数据流</span>
|
|
635
|
+
<span><i class="lg dash"></i>条件触发 / 回写</span>
|
|
636
|
+
</div>
|
|
637
|
+
</div>
|
|
638
|
+
|
|
639
|
+
<div class="caption-box">
|
|
640
|
+
<div class="cap-head">
|
|
641
|
+
<span class="cap-no" id="capNo">1 / 10</span>
|
|
642
|
+
<h2 id="capTitle">加载中…</h2>
|
|
643
|
+
</div>
|
|
644
|
+
<p id="capText"></p>
|
|
645
|
+
</div>
|
|
646
|
+
|
|
647
|
+
<div class="controls">
|
|
648
|
+
<button id="prev">◀ 上一步</button>
|
|
649
|
+
<button id="play" class="primary">暂停</button>
|
|
650
|
+
<button id="next">下一步 ▶</button>
|
|
651
|
+
<div class="dots" id="dots"></div>
|
|
652
|
+
<div class="hint">← → 切换 · 空格播放/暂停</div>
|
|
653
|
+
</div>
|
|
654
|
+
|
|
655
|
+
<div class="toggles">
|
|
656
|
+
<span>全局空间</span>
|
|
657
|
+
<div class="seg" id="globalSeg">
|
|
658
|
+
<button data-g="off" class="on">关闭(默认)</button><button data-g="on">开启</button>
|
|
659
|
+
</div>
|
|
660
|
+
<span>召回策略</span>
|
|
661
|
+
<div class="seg" id="strategySeg">
|
|
662
|
+
<button data-s="lexical" class="on">词法(默认)</button><button data-s="llm">LLM 选择器</button>
|
|
663
|
+
</div>
|
|
664
|
+
</div>
|
|
665
|
+
</header>
|
|
666
|
+
|
|
667
|
+
<div class="stage-wrap">
|
|
668
|
+
<div id="stage">
|
|
669
|
+
<svg id="wires" viewBox="0 0 1480 1040" aria-hidden="true">
|
|
670
|
+
<defs>
|
|
671
|
+
<marker id="arrowDim" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
|
672
|
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2a3d59" />
|
|
673
|
+
</marker>
|
|
674
|
+
<marker id="arrowOn" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse">
|
|
675
|
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="#9adcff" />
|
|
676
|
+
</marker>
|
|
677
|
+
</defs>
|
|
678
|
+
|
|
679
|
+
<path id="w-flow" class="wire" style="--wc: #60a5fa" d="M364 150 H402" />
|
|
680
|
+
<text id="l-flow" class="wlabel" x="383" y="142" text-anchor="middle">消息</text>
|
|
681
|
+
|
|
682
|
+
<path id="w-write" class="wire" style="--wc: #a78bfa" d="M567 548 V580" />
|
|
683
|
+
<path id="w-extract" class="wire" style="--wc: #a78bfa" d="M567 672 V704" />
|
|
684
|
+
|
|
685
|
+
<path id="w-merge" class="wire" style="--wc: #f5b942" d="M732 779 H756 Q764 779 764 771 V 221 Q764 213 772 213 H780" />
|
|
686
|
+
<text id="l-merge" class="wlabel" x="768" y="712" text-anchor="start">合并/去重</text>
|
|
687
|
+
|
|
688
|
+
<path id="w-tool" class="wire dashed" style="--wc: #60a5fa" d="M732 250 C 748 250 752 130 780 130" />
|
|
689
|
+
<text id="l-tool" class="wlabel" x="754" y="300" text-anchor="middle">工具写</text>
|
|
690
|
+
|
|
691
|
+
<path id="w-index" class="wire" style="--wc: #34d399" d="M1110 112 H1158" />
|
|
692
|
+
<text id="l-index" class="wlabel" x="1134" y="104" text-anchor="middle">索引</text>
|
|
693
|
+
|
|
694
|
+
<path id="w-index-inject" class="wire" style="--wc: #34d399" d="M1307 224 V258" />
|
|
695
|
+
<text id="l-idx-inj" class="wlabel" x="1312" y="244" text-anchor="start">一次/会话</text>
|
|
696
|
+
|
|
697
|
+
<path id="w-recall" class="wire" style="--wc: #34d399" d="M1110 210 H1130 Q1138 210 1138 218 V 292 Q1138 300 1146 300 H1158" />
|
|
698
|
+
<text id="l-recall" class="wlabel" x="1134" y="330" text-anchor="middle">正文</text>
|
|
699
|
+
|
|
700
|
+
<path id="w-global" class="wire dashed" style="--wc: #34d399" d="M1110 632 H1137 Q1145 632 1145 624 V 340 Q1145 332 1153 332 H1158" />
|
|
701
|
+
<text id="l-global" class="wlabel" x="1116" y="660" text-anchor="start">全局</text>
|
|
702
|
+
|
|
703
|
+
<path id="w-inject" class="wire" style="--wc: #34d399" d="M1307 462 V498" />
|
|
704
|
+
<text id="l-inject" class="wlabel" x="1312" y="483" text-anchor="start">注入</text>
|
|
705
|
+
|
|
706
|
+
<path id="w-next" class="wire dashed" style="--wc: #34d399" d="M1158 540 H1136 Q1128 540 1128 548 V 552 H 760 Q752 552 752 544 V 470 Q752 462 744 462 H732" />
|
|
707
|
+
<text id="l-next" class="wlabel" x="940" y="545" text-anchor="middle">下一回合直接用</text>
|
|
708
|
+
|
|
709
|
+
<path id="w-dream" class="wire" style="--wc: #f5b942" d="M1110 260 H1136 Q1144 260 1144 268 V 692 Q1144 700 1152 700 H1158" />
|
|
710
|
+
<text id="l-dream" class="wlabel" x="1138" y="676" text-anchor="middle">快照</text>
|
|
711
|
+
|
|
712
|
+
<path id="w-apply" class="wire dashed" style="--wc: #f5b942" d="M1158 740 H1149 Q1141 740 1141 732 V 300 Q1141 292 1133 292 H1110" />
|
|
713
|
+
<text id="l-apply" class="wlabel" x="1138" y="720" text-anchor="middle">回写</text>
|
|
714
|
+
|
|
715
|
+
<path id="w-isolate" class="wire dashed" style="--wc: #f87171" d="M1110 452 H1140" />
|
|
716
|
+
<text class="cut" x="1147" y="458">✕</text>
|
|
717
|
+
<text id="l-isolate" class="wlabel" x="1100" y="560" text-anchor="end">隔离</text>
|
|
718
|
+
|
|
719
|
+
<path id="w-page" class="wire dashed" style="--wc: #60a5fa" d="M1110 792 H1136 Q1144 792 1144 800 V 932 Q1144 940 1152 940 H1158" />
|
|
720
|
+
<text id="l-page" class="wlabel" x="1136" y="930" text-anchor="middle">页面</text>
|
|
721
|
+
</svg>
|
|
722
|
+
|
|
723
|
+
<div class="panel" id="n-wsA" style="left: 24px; top: 48px; width: 340px">
|
|
724
|
+
<div class="ph"><span class="dot b"></span><b>工作目录 A</b> · 一个 cwd 一个空间</div>
|
|
725
|
+
<div class="mono-line">~/GitHub/dsh-memory</div>
|
|
726
|
+
<div class="mono-line">spaceKey: dsh-memory-7f3c1a77</div>
|
|
727
|
+
<div class="chips">
|
|
728
|
+
<div class="chip cur"><span>sess_7f3a · 交互会话</span><span>3 turns</span></div>
|
|
729
|
+
<div class="chip"><span>sess_2c91 · 昨天的会话</span><span>2 turns</span></div>
|
|
730
|
+
<div class="chip sub"><span>sess_b41e · 子代理</span><span>不建库</span></div>
|
|
731
|
+
</div>
|
|
732
|
+
<div class="mono-line" style="margin-top: 8px">→ spaces/dsh-memory-7f3c1a77/</div>
|
|
733
|
+
</div>
|
|
734
|
+
|
|
735
|
+
<div class="panel" id="n-wsB" style="left: 24px; top: 322px; width: 340px; height: 176px">
|
|
736
|
+
<div class="ph"><span class="dot b"></span><b>工作目录 B</b> · 另一个仓库</div>
|
|
737
|
+
<div class="mono-line">~/GitHub/ZCode</div>
|
|
738
|
+
<div class="mono-line">spaceKey: zcode-9f3c1a77</div>
|
|
739
|
+
<div class="chips">
|
|
740
|
+
<div class="chip"><span>sess_5d20 · 交互会话</span><span>4 turns</span></div>
|
|
741
|
+
</div>
|
|
742
|
+
<div class="isolate">← 同名文件也不冲突,A 永远读不到这里</div>
|
|
743
|
+
</div>
|
|
744
|
+
|
|
745
|
+
<div class="panel" id="n-global" style="left: 24px; top: 522px; width: 340px; height: 132px">
|
|
746
|
+
<div class="ph"><span class="dot a"></span><b>全局空间</b> · _global</div>
|
|
747
|
+
<div class="mono-line">spaces/_global/</div>
|
|
748
|
+
<div class="body" id="globalBody">默认关闭。开启后所有工作区都能<b>读</b>它;写入要显式 <code>scope: "global"</code>。</div>
|
|
749
|
+
<div class="mono-line" id="globalState" style="color: #b48ecf">state: disabled</div>
|
|
750
|
+
</div>
|
|
751
|
+
|
|
752
|
+
<div class="panel" id="n-key" style="left: 24px; top: 690px; width: 340px; height: 118px">
|
|
753
|
+
<div class="ph"><span class="dot"></span><b>空间键怎么来的</b></div>
|
|
754
|
+
<div class="mono-line" style="margin-top: 8px">slug(basename(cwd)) + "-" + sha1(cwd)[:8]</div>
|
|
755
|
+
<div class="body">会话按 cwd 归库:同一目录的会话共享一个库;不同 worktree 是不同 cwd,各自一份记忆。目录改名会得到新键(旧库留在磁盘上)。</div>
|
|
756
|
+
</div>
|
|
757
|
+
|
|
758
|
+
<div class="panel" id="n-turn" style="left: 402px; top: 48px; width: 330px; height: 500px">
|
|
759
|
+
<div class="ph"><span class="dot"></span><b>当前回合</b> · sess_7f3a</div>
|
|
760
|
+
<div class="turnstep" id="t-user"><span class="n">01</span><span>用户输入 → 进入 inbox</span></div>
|
|
761
|
+
<div class="turnstep" id="t-index"><span class="n">02</span><span>pre-step:注入一次 <memory-index></span></div>
|
|
762
|
+
<div class="turnstep" id="t-recall"><span class="n">03</span><span>pre-step:召回 <memory-context></span></div>
|
|
763
|
+
<div class="turnstep" id="t-model"><span class="n">04</span><span>模型请求:system prompt 只有使用准则</span></div>
|
|
764
|
+
<div class="turnstep" id="t-tool"><span class="n">05</span><span>工具:<code>memory_note</code> / <code>memory_search</code> / 读文件</span></div>
|
|
765
|
+
<div class="turnstep" id="t-end"><span class="n">06</span><span>turn/end:轮末提炼钩子</span></div>
|
|
766
|
+
<div class="loopnote">下一回合 → 从 03 开始(索引已注入过,只召回正文)</div>
|
|
767
|
+
<div class="kv">
|
|
768
|
+
<span>注入形态</span><span>两条 user notice:索引 + 正文</span>
|
|
769
|
+
<span>去重</span><span>同一会话内不重复浮现</span>
|
|
770
|
+
<span>预算</span><span>索引 ≤2KB · 正文 ≤3 条 / ≤40KB</span>
|
|
771
|
+
</div>
|
|
772
|
+
</div>
|
|
773
|
+
|
|
774
|
+
<div class="panel" id="n-digest" style="left: 402px; top: 580px; width: 330px; height: 92px">
|
|
775
|
+
<div class="ph"><span class="dot v"></span><b>digest 有界窗口</b></div>
|
|
776
|
+
<div class="body">只折 <b>user / assistant 文本块</b>;工具输出、思考块不进。记录已提取到的 <code>seq</code> 游标。</div>
|
|
777
|
+
</div>
|
|
778
|
+
|
|
779
|
+
<div class="panel" id="n-extract" style="left: 402px; top: 704px; width: 330px; height: 150px">
|
|
780
|
+
<div class="ph"><span class="dot a"></span><b>轮末提炼</b> · 一次模型调用</div>
|
|
781
|
+
<ul class="bullets">
|
|
782
|
+
<li>只送游标之后、累计 ≥1500 字符的新对话(≤8K)</li>
|
|
783
|
+
<li>输出 <code>{upserts, deletes}</code> JSON;坏 JSON 整批丢弃</li>
|
|
784
|
+
<li>不产生子会话、不打断主对话</li>
|
|
785
|
+
</ul>
|
|
786
|
+
</div>
|
|
787
|
+
|
|
788
|
+
<div class="panel" id="n-storeA" style="left: 780px; top: 48px; width: 330px; height: 292px">
|
|
789
|
+
<div class="ph"><span class="dot a"></span><b>记忆库 A</b> · spaces/dsh-memory-7f3c1a77</div>
|
|
790
|
+
<div class="files">
|
|
791
|
+
<div class="fresh"><i></i>MEMORY.md <span class="tag on">索引</span></div>
|
|
792
|
+
<div class="fresh"><i></i>user_role.md</div>
|
|
793
|
+
<div class="fresh"><i></i>feedback_testing.md</div>
|
|
794
|
+
<div><i></i>project_release_freeze.md</div>
|
|
795
|
+
<div><i></i>reference_linear.md</div>
|
|
796
|
+
</div>
|
|
797
|
+
<div class="body" style="margin-top: 9px">
|
|
798
|
+
每条笔记一个 md(frontmatter + 正文);<b>MEMORY.md 是生成的目录</b>,每次写入/删除后重建。
|
|
799
|
+
</div>
|
|
800
|
+
<div class="mono-line">索引不含正文;正文由召回按需读取</div>
|
|
801
|
+
</div>
|
|
802
|
+
|
|
803
|
+
<div class="panel" id="n-storeB" style="left: 780px; top: 372px; width: 330px; height: 164px">
|
|
804
|
+
<div class="ph"><span class="dot a"></span><b>记忆库 B</b> · spaces/zcode-9f3c1a77</div>
|
|
805
|
+
<div class="files">
|
|
806
|
+
<div><i></i>MEMORY.md <span class="tag">索引</span></div>
|
|
807
|
+
<div><i></i>project_oncall.md</div>
|
|
808
|
+
<div><i></i>user_role.md <span class="tag">与 A 同名</span></div>
|
|
809
|
+
</div>
|
|
810
|
+
<div class="body">A 与 B 的库在磁盘上就是两个目录,同名文件互不影响。</div>
|
|
811
|
+
</div>
|
|
812
|
+
|
|
813
|
+
<div class="panel" id="n-storeG" style="left: 780px; top: 568px; width: 330px; height: 128px">
|
|
814
|
+
<div class="ph"><span class="dot a"></span><b>全局库</b> · spaces/_global</div>
|
|
815
|
+
<div class="files">
|
|
816
|
+
<div id="gfile" class="dim"><i></i>MEMORY.md / global_preferences.md</div>
|
|
817
|
+
</div>
|
|
818
|
+
<div class="body" id="gBody">默认关闭;开启后参与所有工作区的召回,条目会标 <code>[global]</code>。</div>
|
|
819
|
+
</div>
|
|
820
|
+
|
|
821
|
+
<div class="panel" id="n-state" style="left: 780px; top: 728px; width: 330px; height: 128px">
|
|
822
|
+
<div class="ph"><span class="dot v"></span><b>整理状态</b> · auto-dream.json</div>
|
|
823
|
+
<div class="mono-line">{"lastRunAt": "2026-11-27T21:40Z", "sessions": {...}}</div>
|
|
824
|
+
<div class="body">记录上次整理时间与期间见过的会话;原子写,损坏按空状态处理。</div>
|
|
825
|
+
</div>
|
|
826
|
+
|
|
827
|
+
<div class="panel" id="n-index" style="left: 1158px; top: 48px; width: 298px; height: 176px">
|
|
828
|
+
<div class="ph"><span class="dot g"></span><b>MEMORY.md 索引</b> · 生成</div>
|
|
829
|
+
<div class="body">由 frontmatter 生成,每次写入/删除后原子重建;只列 type / name / 描述 / 文件 / 日期。</div>
|
|
830
|
+
<div class="kv">
|
|
831
|
+
<span>注入</span><span>每会话一次 · ≤20 行 / ≤2000 字符</span>
|
|
832
|
+
<span>计费</span><span>与召回共用 40KB 会话预算</span>
|
|
833
|
+
<span>文件</span><span>≤100 条 / 单行 ≤240 / ≤12KB</span>
|
|
834
|
+
</div>
|
|
835
|
+
</div>
|
|
836
|
+
|
|
837
|
+
<div class="panel" id="n-recall" style="left: 1158px; top: 258px; width: 298px; height: 204px">
|
|
838
|
+
<div class="ph"><span class="dot g"></span><b>召回</b> · 正文</div>
|
|
839
|
+
<div class="body" id="recallBody">候选 = <b>本工作区</b>(+全局)。每会话先注入受限索引,再按词法 TF-IDF 取正文。</div>
|
|
840
|
+
<ul class="bullets">
|
|
841
|
+
<li>命中文件的正文按预算读取</li>
|
|
842
|
+
<li>超时(400ms / LLM 2000ms)跳过,不拖慢回合</li>
|
|
843
|
+
<li>选中内容渲染成 <code><memory-context></code>,已浮现不重复</li>
|
|
844
|
+
</ul>
|
|
845
|
+
</div>
|
|
846
|
+
|
|
847
|
+
<div class="panel" id="n-next" style="left: 1158px; top: 498px; width: 298px; height: 132px">
|
|
848
|
+
<div class="ph"><span class="dot g"></span><b>模型收到 / 下一次请求</b></div>
|
|
849
|
+
<div class="body">user 问题 + <code><memory-index></code>(一次)+ <code><memory-context></code>(按需)。system prompt 只有准则。</div>
|
|
850
|
+
<div class="mono-line" style="margin-top: 8px">下一轮召回跳过已浮现文件</div>
|
|
851
|
+
</div>
|
|
852
|
+
|
|
853
|
+
<div class="panel" id="n-dream" style="left: 1158px; top: 664px; width: 298px; height: 196px">
|
|
854
|
+
<div class="ph"><span class="dot a"></span><b>整理</b> · 自动 / 手动</div>
|
|
855
|
+
<div class="body"><b>自动</b>:24h + 5 会话门控 → 一次模型出操作计划。<br /><b>手动</b>:<code>/dream [focus]</code>。</div>
|
|
856
|
+
<ul class="bullets">
|
|
857
|
+
<li>永不删空;单次最多删 5 条</li>
|
|
858
|
+
<li>截断内容不重写;只认 prompt 内文件</li>
|
|
859
|
+
<li>失败/坏输出:什么都不改</li>
|
|
860
|
+
</ul>
|
|
861
|
+
</div>
|
|
862
|
+
|
|
863
|
+
<div class="panel" id="n-page" style="left: 1158px; top: 896px; width: 298px; height: 110px">
|
|
864
|
+
<div class="ph"><span class="dot b"></span><b>右侧栏「记忆」页</b></div>
|
|
865
|
+
<div class="body">空间 → 笔记时间线(顶部 <b>MEMORY.md 行</b>)→ 详情。索引只读渲染;<code>refresh=1</code> 可重读。</div>
|
|
866
|
+
</div>
|
|
867
|
+
</div>
|
|
868
|
+
</div>
|
|
869
|
+
|
|
870
|
+
<!-- ================= below ================= -->
|
|
871
|
+
<section>
|
|
872
|
+
<div class="sec-head"><span class="sec-no">01</span><h3>存储与预算:为什么它不会越用越慢</h3></div>
|
|
873
|
+
<p class="sec-sub">
|
|
874
|
+
记忆是纯文件,没有数据库与向量索引。所有“智能”都集中在两次模型调用(提取、可选召回)与确定性护栏里。
|
|
875
|
+
</p>
|
|
876
|
+
<table>
|
|
877
|
+
<thead>
|
|
878
|
+
<tr><th>对象</th><th>上限 / 规则</th><th>越界时</th></tr>
|
|
879
|
+
</thead>
|
|
880
|
+
<tbody>
|
|
881
|
+
<tr><td>单条笔记</td><td>渲染后 ≤ 8 KB(frontmatter 含在内)</td><td>写入直接报错,提示拆分</td></tr>
|
|
882
|
+
<tr><td>单空间</td><td>≤ 200 条笔记</td><td>拒绝新增,提示先整理</td></tr>
|
|
883
|
+
<tr><td>提取输入</td><td>只送新增对话,≤ 8000 字符;现有笔记清单 ≤ 2000 字符</td><td>从最旧内容截断</td></tr>
|
|
884
|
+
<tr><td>MEMORY.md 文件</td><td>≤ 100 条;单行 ≤ 240 字符;文件 ≤ 12 KB</td><td>截断并追加 “N more note(s) omitted”</td></tr>
|
|
885
|
+
<tr><td>索引注入</td><td>每会话一次;≤ 20 行 / ≤ 2000 字符;计入会话预算</td><td>超预算则不注入,本轮照常回答</td></tr>
|
|
886
|
+
<tr><td>召回注入</td><td>≤ 3 条;单条 ≤ 4 KB;与索引共用 ≤ 40 KB 会话预算</td><td>跳过或截断,不再注入</td></tr>
|
|
887
|
+
<tr><td>召回超时</td><td>词法 400 ms / LLM 选择器 2000 ms</td><td>本回合不注入,不影响回答</td></tr>
|
|
888
|
+
<tr><td>自动整理</td><td>一次看 ≤ 60 条、单条正文截 1200 字符、prompt ≤ 32 KB、最多删 5 条</td><td>超出的笔记本轮不参与</td></tr>
|
|
889
|
+
</tbody>
|
|
890
|
+
</table>
|
|
891
|
+
</section>
|
|
892
|
+
|
|
893
|
+
<section>
|
|
894
|
+
<div class="sec-head"><span class="sec-no">02</span><h3>安全护栏:无人值守也要可控</h3></div>
|
|
895
|
+
<div class="qa">
|
|
896
|
+
<div class="q"><b>不会把记忆删空</b><p>自动整理与手动整理都有“永不删空”约束;自动路径还会跳过“本轮刚重写过”和“内容被截断”的笔记,避免覆盖丢内容。</p></div>
|
|
897
|
+
<div class="q"><b>不会写到库外</b><p>路径穿越、符号链接、越界文件名在 store 与 HTTP API 两层拒绝;写入是临时文件 + rename,权限 0600。</p></div>
|
|
898
|
+
<div class="q"><b>不会污染别的项目</b><p>索引与召回候选都只来自当前会话的 spaceKey;只有显式开启且显式标记的全局条目例外。</p></div>
|
|
899
|
+
<div class="q"><b>不会拖垮回合</b><p>提取与自动整理都是 fire-and-forget;任何失败只写调试日志,不向对话抛错。召回超时就跳过。</p></div>
|
|
900
|
+
</div>
|
|
901
|
+
</section>
|
|
902
|
+
|
|
903
|
+
<section>
|
|
904
|
+
<div class="sec-head"><span class="sec-no">03</span><h3>配置项(都在 profile patch 里)</h3></div>
|
|
905
|
+
<table>
|
|
906
|
+
<thead><tr><th>键</th><th>默认</th><th>说明</th></tr></thead>
|
|
907
|
+
<tbody>
|
|
908
|
+
<tr><td>extract.enabled</td><td>true</td><td>轮末增量提取总开关</td></tr>
|
|
909
|
+
<tr><td>extract.minNewChars</td><td>1500</td><td>新增对话不足这个长度就不提取</td></tr>
|
|
910
|
+
<tr><td>extract.maxPerTurn</td><td>3</td><td>一次提取最多写几条</td></tr>
|
|
911
|
+
<tr><td>recall.strategy</td><td>lexical</td><td>lexical | llm(失败自动回退词法)</td></tr>
|
|
912
|
+
<tr><td>recall.topK / maxNoteBytes / sessionBudgetBytes</td><td>3 / 4096 / 40960</td><td>召回条数与字节预算</td></tr>
|
|
913
|
+
<tr><td>recall.timeoutMs / llmTimeoutMs</td><td>400 / 2000</td><td>词法与 LLM 选择器各自的截止时间</td></tr>
|
|
914
|
+
<tr><td>memoryMd.enabled / inject</td><td>true / true</td><td>是否维护 MEMORY.md、是否每会话注入一次</td></tr>
|
|
915
|
+
<tr><td>memoryMd.maxEntries / maxLineChars / maxChars</td><td>100 / 240 / 12000</td><td>索引文件的条数、单行与总字符上限</td></tr>
|
|
916
|
+
<tr><td>memoryMd.injectMaxEntries / injectMaxChars</td><td>20 / 2000</td><td>注入副本的条数与总字符上限(约 1–1.5k tokens)</td></tr>
|
|
917
|
+
<tr><td>dream.enabled / minHours / minSessions</td><td>true / 24 / 5</td><td>自动整理的开关与门控</td></tr>
|
|
918
|
+
<tr><td>dream.maxNotes / maxDeletes</td><td>60 / 5</td><td>单次整理的规模上限</td></tr>
|
|
919
|
+
<tr><td>spaces.global</td><td>false</td><td>是否启用 _global 共享空间</td></tr>
|
|
920
|
+
</tbody>
|
|
921
|
+
</table>
|
|
922
|
+
</section>
|
|
923
|
+
|
|
924
|
+
<section>
|
|
925
|
+
<div class="sec-head"><span class="sec-no">04</span><h3>几个设计取舍</h3></div>
|
|
926
|
+
<div class="qa">
|
|
927
|
+
<div class="q"><b>为什么不把笔记正文放进 system prompt?</b><p>提示词要逐字节稳定才能吃到 prompt cache;笔记每轮都可能变。所以准则进 system prompt;索引与相关正文各以一条用户消息注入。</p></div>
|
|
928
|
+
<div class="q"><b>MEMORY.md 和召回的正文是什么关系?</b><p>索引只给总览,每会话注入一次(默认 ≤20 行 / ≤2000 字符);正文仍由召回按相关度挑,两者共用 40KB 会话预算。</p></div>
|
|
929
|
+
<div class="q"><b>为什么提取不重试坏输出?</b><p>同一轮反复重试会放大成本并可能写脏数据。坏 JSON 整批丢弃、游标前进,下一轮只处理新增内容。</p></div>
|
|
930
|
+
<div class="q"><b>为什么全局空间默认关?</b><p>跨项目串味比“少记一点”更贵。默认隔离,需要共享时显式打开并显式标记。</p></div>
|
|
931
|
+
</div>
|
|
932
|
+
</section>
|
|
933
|
+
|
|
934
|
+
<section>
|
|
935
|
+
<div class="sec-head"><span class="sec-no">05</span><h3>代码地图</h3></div>
|
|
936
|
+
<div class="codes">
|
|
937
|
+
<div><span>空间键 / 笔记读写</span><span>src/host/store.mjs</span></div>
|
|
938
|
+
<div><span>增量提取与去重</span><span>src/host/extract.mjs</span></div>
|
|
939
|
+
<div><span>会话窗口</span><span>src/host/digest.mjs</span></div>
|
|
940
|
+
<div><span>召回(词法 / LLM)</span><span>src/host/recall.mjs</span></div>
|
|
941
|
+
<div><span>打分</span><span>src/host/score.mjs</span></div>
|
|
942
|
+
<div><span>自动整理</span><span>src/host/autoDream.mjs</span></div>
|
|
943
|
+
<div><span>MEMORY.md 索引</span><span>src/host/memoryIndex.mjs</span></div>
|
|
944
|
+
<div><span>手动 /dream 提示词</span><span>src/host/dream.mjs</span></div>
|
|
945
|
+
<div><span>只读 API</span><span>src/host/api.mjs</span></div>
|
|
946
|
+
<div><span>装配(工具/注入/钩子)</span><span>index.js</span></div>
|
|
947
|
+
<div><span>记忆页</span><span>client/client.js</span></div>
|
|
948
|
+
</div>
|
|
949
|
+
</section>
|
|
950
|
+
|
|
951
|
+
<div class="fine">
|
|
952
|
+
对应 dsh-memory v0.4.1 · 319 用例 / 317 pass · MEMORY.md 索引与注入已在真实 DSH 会话/页面验证
|
|
953
|
+
</div>
|
|
954
|
+
</div>
|
|
955
|
+
|
|
956
|
+
<script>
|
|
957
|
+
(function () {
|
|
958
|
+
'use strict'
|
|
959
|
+
|
|
960
|
+
var STEPS = [
|
|
961
|
+
{
|
|
962
|
+
title: '目录即分区:一个 cwd 一个 spaceKey',
|
|
963
|
+
text:
|
|
964
|
+
'工作目录 A(~/GitHub/dsh-memory)与 B(~/GitHub/ZCode)各有独立的 spaceKey(slug + 路径 hash8)。A 的会话只读写 spaces/dsh-memory-…/,B 只读写 spaces/zcode-…/;同名文件也互不影响。同一 cwd 的会话共享同一个空间;不同 worktree 是不同 cwd,各自一份。子代理会话不单独建库,也不计入整理门控。',
|
|
965
|
+
on: ['n-wsA', 'n-wsB', 'n-global', 'n-key'],
|
|
966
|
+
wires: [],
|
|
967
|
+
steps: []
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
title: '会话只贡献文本事件',
|
|
971
|
+
text:
|
|
972
|
+
'每轮对话把 user / assistant 文本写进 session/event。插件只保留一个有界 digest(工具输出、思考块不进),并记录已提取到的 seq 游标——这是后面“增量”的前提。',
|
|
973
|
+
on: ['n-wsA', 'n-turn', 'n-digest'],
|
|
974
|
+
wires: ['w-flow'],
|
|
975
|
+
steps: ['t-user']
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
title: '轮末提炼:增量、一次模型调用',
|
|
979
|
+
text:
|
|
980
|
+
'turn/end 触发提取;只送游标之后、累计 ≥1500 字符的新对话(≤8K)。用一次 ctx.llm.stream 让模型输出 {upserts,deletes} JSON;失败或坏 JSON 整批丢弃并前进游标,不重试同一轮,也不打断对话。',
|
|
981
|
+
on: ['n-turn', 'n-digest', 'n-extract'],
|
|
982
|
+
wires: ['w-write', 'w-extract'],
|
|
983
|
+
steps: ['t-end']
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
title: '清洗 + 去重:一个主题一个文件',
|
|
987
|
+
text:
|
|
988
|
+
'解析层剥掉模型可能抄进来的 [type]、时间戳、.md;写入层按 file → 同名 → 名字/描述相似度(Jaccard ≥0.45)命中已有笔记,用原 name 写回,保留 created;没命中才新建。',
|
|
989
|
+
on: ['n-extract', 'n-storeA'],
|
|
990
|
+
wires: ['w-merge'],
|
|
991
|
+
steps: []
|
|
992
|
+
},
|
|
993
|
+
{
|
|
994
|
+
title: '记忆库 = 正文 + 生成的 MEMORY.md',
|
|
995
|
+
text:
|
|
996
|
+
'每条笔记是一个 md(frontmatter + 正文);同一目录下还有一份生成的 MEMORY.md:每条笔记一行(type / name / 描述 / 文件 / 日期),写入或删除后原子重建,删空时移除,丢失时下次读取自动补建。它是目录,不是正文,也不计入笔记数。',
|
|
997
|
+
on: ['n-storeA', 'n-storeB', 'n-index'],
|
|
998
|
+
wires: ['w-index'],
|
|
999
|
+
steps: []
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
title: '消费①:开场只有使用准则',
|
|
1003
|
+
text:
|
|
1004
|
+
'新会话的 system prompt 里只有静态准则(类型、保存判据、漂移校验、MEMORY.md 的用法),不塞笔记正文:保持提示词稳定、prompt cache 不被击穿。',
|
|
1005
|
+
on: ['n-wsA', 'n-turn', 'n-next'],
|
|
1006
|
+
wires: [],
|
|
1007
|
+
steps: ['t-model']
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
title: '消费②:索引每会话注入一次',
|
|
1011
|
+
text:
|
|
1012
|
+
'会话第一次 pre-step 读 MEMORY.md 并注入一条 <memory-index>:默认 ≤20 行 / ≤2000 字符,按 updated 倒序,超出部分只留“还有 N 条,用 memory_search”。它和召回共用 40KB 会话预算;同一会话不会重复注入。',
|
|
1013
|
+
on: ['n-storeA', 'n-index', 'n-recall', 'n-next'],
|
|
1014
|
+
wires: ['w-index', 'w-index-inject', 'w-inject'],
|
|
1015
|
+
steps: ['t-index']
|
|
1016
|
+
},
|
|
1017
|
+
{
|
|
1018
|
+
title: '消费③:召回正文并按需取全文',
|
|
1019
|
+
text:
|
|
1020
|
+
'agent/pre-step 用本条用户消息做 query,从本工作区(+全局)的 frontmatter 候选里选(默认词法 TF-IDF,可切 LLM 选择器),读正文,≤3 条 / ≤4KB 一条;超时就跳过。选中内容作为 <memory-context> 追加,已浮现过的文件不重复。正文不够时再 memory_search / read / grep。',
|
|
1021
|
+
on: ['n-storeA', 'n-recall', 'n-next', 'n-turn'],
|
|
1022
|
+
wires: ['w-recall', 'w-inject', 'w-next'],
|
|
1023
|
+
steps: ['t-recall', 't-model']
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
title: '隔离与全局空间',
|
|
1027
|
+
text:
|
|
1028
|
+
'B 的库不会进入 A 的索引或召回;只有开启 spaces.global 后,A/B 才能都读到 _global(召回里标 [global]),写入要显式 scope: "global"。默认关闭,避免跨项目串味。',
|
|
1029
|
+
on: ['n-storeB', 'n-storeG', 'n-global', 'n-recall'],
|
|
1030
|
+
wires: ['w-isolate'],
|
|
1031
|
+
steps: []
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
title: '整理:自动 dream 与手动 /dream',
|
|
1035
|
+
text:
|
|
1036
|
+
'自动:轮末检查 24h + 5 个不同会话(状态在 auto-dream.json),通过后一次模型调用出 merges/deletes,本地校验后落地。手动 /dream 把四阶段提示词送进当前会话。两条路径都受“不删空 / 限量 / 不重写截断内容”约束。',
|
|
1037
|
+
on: ['n-storeA', 'n-state', 'n-dream'],
|
|
1038
|
+
wires: ['w-dream', 'w-apply'],
|
|
1039
|
+
steps: ['t-end']
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
title: '旁路:页面、工具、闭环',
|
|
1043
|
+
text:
|
|
1044
|
+
'右侧栏「记忆」页的空间 → 时间线 → 详情:列表顶部固定一行 MEMORY.md(带条数),点开只读渲染索引;笔记详情仍走 /api/note。模型也能 memory_search、读文件或 grep;memory_note 写回,索引随之更新。',
|
|
1045
|
+
on: ['n-storeA', 'n-page', 'n-turn', 'n-recall'],
|
|
1046
|
+
wires: ['w-page', 'w-tool'],
|
|
1047
|
+
steps: ['t-tool']
|
|
1048
|
+
}
|
|
1049
|
+
]
|
|
1050
|
+
|
|
1051
|
+
var state = { i: 0, playing: true, global: false, strategy: 'lexical' }
|
|
1052
|
+
var capNo = document.getElementById('capNo')
|
|
1053
|
+
var capTitle = document.getElementById('capTitle')
|
|
1054
|
+
var capText = document.getElementById('capText')
|
|
1055
|
+
var dots = document.getElementById('dots')
|
|
1056
|
+
var playBtn = document.getElementById('play')
|
|
1057
|
+
var timer = null
|
|
1058
|
+
|
|
1059
|
+
function wireIds() {
|
|
1060
|
+
return ['w-flow', 'w-write', 'w-extract', 'w-merge', 'w-tool', 'w-index', 'w-index-inject', 'w-recall', 'w-global', 'w-inject', 'w-next', 'w-dream', 'w-apply', 'w-isolate', 'w-page']
|
|
1061
|
+
}
|
|
1062
|
+
function allPanels() {
|
|
1063
|
+
return ['n-wsA', 'n-wsB', 'n-global', 'n-key', 'n-turn', 'n-digest', 'n-extract', 'n-storeA', 'n-storeB', 'n-storeG', 'n-state', 'n-index', 'n-recall', 'n-next', 'n-dream', 'n-page']
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
function clear() {
|
|
1067
|
+
allPanels().forEach(function (id) {
|
|
1068
|
+
var el = document.getElementById(id)
|
|
1069
|
+
if (el) el.classList.remove('on')
|
|
1070
|
+
})
|
|
1071
|
+
wireIds().forEach(function (id) {
|
|
1072
|
+
var el = document.getElementById(id)
|
|
1073
|
+
if (el) el.classList.remove('on')
|
|
1074
|
+
})
|
|
1075
|
+
;['l-flow', 'l-merge', 'l-tool', 'l-index', 'l-idx-inj', 'l-recall', 'l-global', 'l-inject', 'l-next', 'l-dream', 'l-apply', 'l-page'].forEach(function (id) {
|
|
1076
|
+
var el = document.getElementById(id)
|
|
1077
|
+
if (el) el.classList.remove('on')
|
|
1078
|
+
})
|
|
1079
|
+
;['t-user', 't-index', 't-recall', 't-model', 't-tool', 't-end'].forEach(function (id) {
|
|
1080
|
+
var el = document.getElementById(id)
|
|
1081
|
+
if (el) el.classList.remove('on')
|
|
1082
|
+
})
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
function render() {
|
|
1086
|
+
var step = STEPS[state.i]
|
|
1087
|
+
clear()
|
|
1088
|
+
capNo.textContent = state.i + 1 + ' / ' + STEPS.length
|
|
1089
|
+
capTitle.textContent = step.title
|
|
1090
|
+
var text = step.text
|
|
1091
|
+
if (state.strategy === 'llm' && state.i === 7) {
|
|
1092
|
+
text +=
|
|
1093
|
+
' 当前切换为 LLM 选择器:把候选的 name/description 交给当前会话模型挑选;超时、非法 JSON、编造 id 或空选都会静默回退词法。'
|
|
1094
|
+
}
|
|
1095
|
+
capText.textContent = text
|
|
1096
|
+
step.on.forEach(function (id) {
|
|
1097
|
+
var el = document.getElementById(id)
|
|
1098
|
+
if (el) el.classList.add('on')
|
|
1099
|
+
})
|
|
1100
|
+
step.wires.forEach(function (id) {
|
|
1101
|
+
var el = document.getElementById(id)
|
|
1102
|
+
if (el) el.classList.add('on')
|
|
1103
|
+
})
|
|
1104
|
+
step.steps.forEach(function (id) {
|
|
1105
|
+
var el = document.getElementById(id)
|
|
1106
|
+
if (el) el.classList.add('on')
|
|
1107
|
+
})
|
|
1108
|
+
// the global wire only lights up when the global space is enabled
|
|
1109
|
+
var gw = document.getElementById('w-global')
|
|
1110
|
+
if (gw) {
|
|
1111
|
+
var globalStep = state.i === 8
|
|
1112
|
+
gw.classList.toggle('on', globalStep && state.global)
|
|
1113
|
+
}
|
|
1114
|
+
var lg = document.getElementById('l-global')
|
|
1115
|
+
if (lg) lg.classList.toggle('on', state.i === 8 && state.global)
|
|
1116
|
+
var gs = document.getElementById('globalState')
|
|
1117
|
+
if (gs) {
|
|
1118
|
+
gs.textContent = 'state: ' + (state.global ? 'enabled' : 'disabled')
|
|
1119
|
+
gs.style.color = state.global ? '#9ce8c8' : '#b48ecf'
|
|
1120
|
+
}
|
|
1121
|
+
var gBody = document.getElementById('gBody')
|
|
1122
|
+
if (gBody) {
|
|
1123
|
+
gBody.innerHTML = state.global
|
|
1124
|
+
? '已开启:参与所有工作区召回,条目标 <code>[global]</code>;写入需显式 <code>scope: "global"</code>。'
|
|
1125
|
+
: '默认关闭;开启后参与所有工作区的召回,条目会标 <code>[global]</code>。'
|
|
1126
|
+
}
|
|
1127
|
+
var gfile = document.getElementById('gfile')
|
|
1128
|
+
if (gfile) gfile.classList.toggle('dim', !state.global)
|
|
1129
|
+
var recallBody = document.getElementById('recallBody')
|
|
1130
|
+
if (recallBody) {
|
|
1131
|
+
recallBody.innerHTML =
|
|
1132
|
+
state.strategy === 'llm'
|
|
1133
|
+
? '候选 = <b>本工作区</b>(+全局)。LLM 选择器:当前会话模型从 name/description 里挑 ≤topK,失败/超时自动回退词法。'
|
|
1134
|
+
: '候选 = <b>本工作区</b>(+全局)。默认词法 TF-IDF(拉丁词 + CJK 二元组),零额外调用。'
|
|
1135
|
+
}
|
|
1136
|
+
// dots
|
|
1137
|
+
dots.innerHTML = ''
|
|
1138
|
+
STEPS.forEach(function (_, idx) {
|
|
1139
|
+
var b = document.createElement('button')
|
|
1140
|
+
b.className = 'dot-btn' + (idx === state.i ? ' on' : '')
|
|
1141
|
+
b.setAttribute('aria-label', '第 ' + (idx + 1) + ' 步')
|
|
1142
|
+
b.addEventListener('click', function () {
|
|
1143
|
+
go(idx)
|
|
1144
|
+
})
|
|
1145
|
+
dots.appendChild(b)
|
|
1146
|
+
})
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
function go(i) {
|
|
1150
|
+
state.i = (i + STEPS.length) % STEPS.length
|
|
1151
|
+
render()
|
|
1152
|
+
}
|
|
1153
|
+
function next() {
|
|
1154
|
+
go(state.i + 1)
|
|
1155
|
+
}
|
|
1156
|
+
function prev() {
|
|
1157
|
+
go(state.i - 1)
|
|
1158
|
+
}
|
|
1159
|
+
function play() {
|
|
1160
|
+
state.playing = true
|
|
1161
|
+
playBtn.textContent = '暂停'
|
|
1162
|
+
stopTimer()
|
|
1163
|
+
timer = setInterval(next, 5200)
|
|
1164
|
+
}
|
|
1165
|
+
function pause() {
|
|
1166
|
+
state.playing = false
|
|
1167
|
+
playBtn.textContent = '播放'
|
|
1168
|
+
stopTimer()
|
|
1169
|
+
}
|
|
1170
|
+
function stopTimer() {
|
|
1171
|
+
if (timer !== null) {
|
|
1172
|
+
clearInterval(timer)
|
|
1173
|
+
timer = null
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
document.getElementById('next').addEventListener('click', function () {
|
|
1178
|
+
pause()
|
|
1179
|
+
next()
|
|
1180
|
+
})
|
|
1181
|
+
document.getElementById('prev').addEventListener('click', function () {
|
|
1182
|
+
pause()
|
|
1183
|
+
prev()
|
|
1184
|
+
})
|
|
1185
|
+
playBtn.addEventListener('click', function () {
|
|
1186
|
+
if (state.playing) pause()
|
|
1187
|
+
else play()
|
|
1188
|
+
})
|
|
1189
|
+
document.addEventListener('keydown', function (e) {
|
|
1190
|
+
if (e.key === 'ArrowRight') {
|
|
1191
|
+
pause()
|
|
1192
|
+
next()
|
|
1193
|
+
} else if (e.key === 'ArrowLeft') {
|
|
1194
|
+
pause()
|
|
1195
|
+
prev()
|
|
1196
|
+
} else if (e.key === ' ') {
|
|
1197
|
+
e.preventDefault()
|
|
1198
|
+
if (state.playing) pause()
|
|
1199
|
+
else play()
|
|
1200
|
+
}
|
|
1201
|
+
})
|
|
1202
|
+
|
|
1203
|
+
document.getElementById('globalSeg').addEventListener('click', function (e) {
|
|
1204
|
+
var b = e.target.closest('button')
|
|
1205
|
+
if (!b) return
|
|
1206
|
+
state.global = b.dataset.g === 'on'
|
|
1207
|
+
this.querySelectorAll('button').forEach(function (x) {
|
|
1208
|
+
x.classList.toggle('on', x === b)
|
|
1209
|
+
})
|
|
1210
|
+
render()
|
|
1211
|
+
})
|
|
1212
|
+
document.getElementById('strategySeg').addEventListener('click', function (e) {
|
|
1213
|
+
var b = e.target.closest('button')
|
|
1214
|
+
if (!b) return
|
|
1215
|
+
state.strategy = b.dataset.s
|
|
1216
|
+
this.querySelectorAll('button').forEach(function (x) {
|
|
1217
|
+
x.classList.toggle('on', x === b)
|
|
1218
|
+
})
|
|
1219
|
+
render()
|
|
1220
|
+
})
|
|
1221
|
+
|
|
1222
|
+
render()
|
|
1223
|
+
play()
|
|
1224
|
+
})()
|
|
1225
|
+
</script>
|
|
1226
|
+
</body>
|
|
1227
|
+
</html>
|