deepseek-plastic-memory 3.4.0 → 3.4.2

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.
Files changed (2) hide show
  1. package/index.js +41 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -217,6 +217,31 @@ function clearClassifyTask() {
217
217
  try { rmSync(CLASSIFY_FILE, { force: true }); return true } catch { return false }
218
218
  }
219
219
 
220
+ function readAllMemoriesText() {
221
+ try {
222
+ const j = JSON.parse(readFileSync(join(ROOT, 'folders.json'), 'utf8').replace(/^\uFEFF/, ''))
223
+ const folders = Array.isArray(j.folders) ? j.folders : []
224
+ const lines = []
225
+ for (const f of folders) {
226
+ const file = join(ROOT, f.k, 'notes.md')
227
+ if (!existsSync(file)) continue
228
+ const rows = readFileSync(file, 'utf8').replace(/^\uFEFF/, '').split('\n').filter(Boolean)
229
+ if (!rows.length) continue
230
+ lines.push('## ' + (f.parent ? f.parent + '>' : '') + f.name + ' (' + f.k + ')')
231
+ for (const row of rows) {
232
+ const [id, , flag, ...rest] = row.split('|')
233
+ const mark = flag === '*' ? ' [重要]' : flag === '✓' ? ' [完成]' : ''
234
+ lines.push((id || '') + mark + ' ' + rest.join('|'))
235
+ }
236
+ lines.push('')
237
+ }
238
+ const txt = lines.join('\n').trim()
239
+ return txt.length > 200000 ? txt.slice(0, 200000) + '\n…(已截断)' : txt
240
+ } catch {
241
+ return ''
242
+ }
243
+ }
244
+
220
245
  function readIdentity() {
221
246
  try {
222
247
  return readFileSync(IDENTITY_FILE, 'utf8').replace(/^\uFEFF/, '').trim()
@@ -244,6 +269,22 @@ export function apply(ctx) {
244
269
  }
245
270
  }
246
271
 
272
+ // 全量记忆:每次会话都带上,模型不用再去挑分区
273
+ try {
274
+ const dump = readAllMemoriesText()
275
+ const sp = ctx.systemPrompt
276
+ if (sp && typeof sp.section === 'function' && dump && dump !== '(空)') {
277
+ sp.section({
278
+ name: 'plastic-memory:all',
279
+ order: 149,
280
+ interpolate: false,
281
+ text: ['【可塑性记忆 · 全量】下面是这台机器上的全部记忆(已按分区排好):', '', dump].join('\n'),
282
+ })
283
+ }
284
+ } catch (e) {
285
+ // 读不到就静默跳过,别影响对话
286
+ }
287
+
247
288
  const classifyTask = readClassifyTask()
248
289
  if (classifyTask) {
249
290
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepseek-plastic-memory",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "DeepSeek 可塑性记忆:给 DSH 用的分区式长期记忆,带遗忘曲线",
5
5
  "type": "module",
6
6
  "main": "index.js",