cortico-world-memory-core 0.22.0 → 0.23.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 +13 -0
- package/package.json +2 -2
- package/src/store.ts +2 -0
- package/src/world.ts +40 -0
- package/webui/app.js +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.23.0
|
|
4
|
+
|
|
5
|
+
> 墓碑对齐需要自我意识 **0.10.0** 及以上;旧版不写墓碑,只是不会自动撤卡。
|
|
6
|
+
|
|
7
|
+
**能直接删了,退休不再是唯一出口。**
|
|
8
|
+
|
|
9
|
+
- 详情栏「退休」旁边加了「彻底删除」:二次确认 + 10 秒撤销,和回收站里是同一套。
|
|
10
|
+
在用的卡不用先退休、再去回收站找。
|
|
11
|
+
- 从自我意识收下想法时记 `srcThoughtId`。她删掉那条想法后,墓碑写在
|
|
12
|
+
`../self-awareness/deleted-thoughts.jsonl`,这边下一次周期清理会撤回对应卡片。
|
|
13
|
+
只认带来源 id 的新卡片;更早的没有 id,手动删。
|
|
14
|
+
- 测试新增 `tools/test-delete.ts` 2 项:按墓碑撤回、无关卡片不动。
|
|
15
|
+
|
|
3
16
|
## 0.22.0
|
|
4
17
|
|
|
5
18
|
> 需要自我意识 **0.9.0** 及以上,才有人写冲动;单独升级这一边不会报错,只是没有可读的东西。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-memory-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "四个工具写卡、查卡、改状态、排日程,改口不覆盖。每轮自动把 2 条相关旧记忆推到眼前,不用模型自己查;搜索分「对得上 / 可能沾边」两档。冷层收走三个月没想起的流水账,不删、可回暖。3D 星图一眼看完整个库。常驻约 1,000 token,本地不联网,MIT。\n\nQQ 交流群:745879632",
|
|
6
6
|
"keywords": [
|
|
@@ -73,6 +73,6 @@
|
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
|
-
"test": "node --experimental-transform-types --no-warnings tools/test-store.ts && node --experimental-transform-types --no-warnings tools/test-world.ts && node --experimental-transform-types --no-warnings tools/test-capture.ts && node --experimental-transform-types --no-warnings tools/test-upgrade.ts && node --experimental-transform-types --no-warnings tools/test-urge.ts && node --experimental-transform-types --no-warnings tools/test-site-auth.ts && node --experimental-transform-types --no-warnings tools/audit-webui.ts"
|
|
76
|
+
"test": "node --experimental-transform-types --no-warnings tools/test-store.ts && node --experimental-transform-types --no-warnings tools/test-world.ts && node --experimental-transform-types --no-warnings tools/test-capture.ts && node --experimental-transform-types --no-warnings tools/test-upgrade.ts && node --experimental-transform-types --no-warnings tools/test-urge.ts && node --experimental-transform-types --no-warnings tools/test-delete.ts && node --experimental-transform-types --no-warnings tools/test-site-auth.ts && node --experimental-transform-types --no-warnings tools/audit-webui.ts"
|
|
77
77
|
}
|
|
78
78
|
}
|
package/src/store.ts
CHANGED
|
@@ -31,6 +31,8 @@ export interface Card {
|
|
|
31
31
|
/** 缺省视为 active:老数据没有这个字段,读的时候补上。 */
|
|
32
32
|
status?: CardStatus;
|
|
33
33
|
retiredAt?: string;
|
|
34
|
+
/** 从自我意识收下来时,记下那条想法的 id:她删了想法,这张卡要跟着撤。 */
|
|
35
|
+
srcThoughtId?: string;
|
|
34
36
|
/** 谁让它退休的:'merge' | 'purge' | 'stale' | 接替它的卡片 id。 */
|
|
35
37
|
retiredBy?: string;
|
|
36
38
|
/** 它接替了哪些卡(编辑留版本、closes 关旧记录时写)。 */
|
package/src/world.ts
CHANGED
|
@@ -1163,6 +1163,7 @@ export class MemoryCoreWorld implements World {
|
|
|
1163
1163
|
Boolean(this.cfg().captureBackfill)
|
|
1164
1164
|
&& (Number(this.state.watermarkVersion ?? 0) < CAPTURE_WATERMARK_VERSION || !this.state.backfillDoneAt),
|
|
1165
1165
|
);
|
|
1166
|
+
this.pruneDeletedThoughts();
|
|
1166
1167
|
this.absorbThoughts(now);
|
|
1167
1168
|
await this.maybeContext(now);
|
|
1168
1169
|
await this.maybePreactivate(now);
|
|
@@ -1497,6 +1498,44 @@ export class MemoryCoreWorld implements World {
|
|
|
1497
1498
|
* 文本前面加「独处时写下」——不然它会以卡片的身份进上下文,被当成此刻的想法,
|
|
1498
1499
|
* 那又变成替她认领了。
|
|
1499
1500
|
*/
|
|
1501
|
+
/**
|
|
1502
|
+
* 她删掉的想法,墓碑写在 `deleted-thoughts.jsonl`。
|
|
1503
|
+
* 由那条想法收成的卡片要一起清掉——不然时间线里没了,星图上还挂着。
|
|
1504
|
+
* 只认带 srcThoughtId 的新卡片;老卡片没有来源 id,只能手动删。
|
|
1505
|
+
*/
|
|
1506
|
+
private pruneDeletedThoughts(): void {
|
|
1507
|
+
const file = join(this.dataDir, '..', 'self-awareness', 'deleted-thoughts.jsonl');
|
|
1508
|
+
if (!existsSync(file)) return;
|
|
1509
|
+
const ids = new Set<string>();
|
|
1510
|
+
try {
|
|
1511
|
+
for (const line of readFileSync(file, 'utf8').split('\n')) {
|
|
1512
|
+
const s = line.trim();
|
|
1513
|
+
if (!s) continue;
|
|
1514
|
+
try {
|
|
1515
|
+
const o = JSON.parse(s) as { id?: unknown };
|
|
1516
|
+
if (typeof o.id === 'string' && o.id) ids.add(o.id);
|
|
1517
|
+
} catch {
|
|
1518
|
+
// 坏行跳过
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
} catch {
|
|
1522
|
+
return;
|
|
1523
|
+
}
|
|
1524
|
+
if (!ids.size) return;
|
|
1525
|
+
const victims = this.store
|
|
1526
|
+
.all()
|
|
1527
|
+
.filter((c) => c.srcThoughtId && ids.has(c.srcThoughtId))
|
|
1528
|
+
.map((c) => c.id);
|
|
1529
|
+
if (victims.length) {
|
|
1530
|
+
this.store.purge(victims);
|
|
1531
|
+
try {
|
|
1532
|
+
this.host?.log?.info?.('[memory-core] 她删了想法,跟着撤回卡片', { count: victims.length });
|
|
1533
|
+
} catch {
|
|
1534
|
+
// ignore
|
|
1535
|
+
}
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1500
1539
|
private absorbThoughts(now: Date): void {
|
|
1501
1540
|
if (this.cfg().absorbSelfThought === false) return;
|
|
1502
1541
|
const done = new Set(this.state.absorbedThoughtIds ?? []);
|
|
@@ -1517,6 +1556,7 @@ export class MemoryCoreWorld implements World {
|
|
|
1517
1556
|
tags: ['独处'],
|
|
1518
1557
|
source: 'self-awareness',
|
|
1519
1558
|
origin: 'tool',
|
|
1559
|
+
srcThoughtId: t.id,
|
|
1520
1560
|
});
|
|
1521
1561
|
added += 1;
|
|
1522
1562
|
}
|
package/webui/app.js
CHANGED
|
@@ -2355,6 +2355,7 @@ function renderInspector() {
|
|
|
2355
2355
|
? `<button class="btn tiny" id="btn-restore">恢复这条</button>`
|
|
2356
2356
|
: `<button class="btn tiny" id="btn-retire">退休</button>`
|
|
2357
2357
|
}
|
|
2358
|
+
<button class="btn tiny danger" id="btn-purge">彻底删除</button>
|
|
2358
2359
|
</div>
|
|
2359
2360
|
${lineageHtml(card)}
|
|
2360
2361
|
${
|
|
@@ -2391,7 +2392,14 @@ function renderInspector() {
|
|
|
2391
2392
|
toast('复制失败,浏览器不给剪贴板权限', true);
|
|
2392
2393
|
}
|
|
2393
2394
|
});
|
|
2394
|
-
//
|
|
2395
|
+
// 详情栏也能直接删:二次确认 + 10 秒撤销,和回收站里是同一套
|
|
2396
|
+
const purgeBtn = $('#btn-purge');
|
|
2397
|
+
if (purgeBtn) {
|
|
2398
|
+
purgeBtn.addEventListener('click', async () => {
|
|
2399
|
+
const n = await purgeWithUndo([card.id]);
|
|
2400
|
+
if (n) await load();
|
|
2401
|
+
});
|
|
2402
|
+
}
|
|
2395
2403
|
const retireBtn = $('#btn-retire');
|
|
2396
2404
|
if (retireBtn) {
|
|
2397
2405
|
retireBtn.addEventListener('click', async () => {
|