cortico-world-memory-core 0.18.0 → 0.18.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.18.2
4
+
5
+ - **坏数据不再变成卡片**:读 `thoughts.jsonl` 时只认字符串。之前只判了 `!t.text`,
6
+ 手改坏的文件(或未来换字段)会让对象漏进去,变成一张正文是「独处时写下:[object Object]」的
7
+ 永久记忆。现在 `typeof t.text !== 'string'` 直接跳过,空字符串也跳过。
8
+ - 测试 28 加两条:坏数据不进库、空字符串不进库。
9
+ - 顺手修了测试 15 的时效 bug:它假设「现在」已经过了 `nightlyHour`,凌晨 0 点跑必挂。
10
+ 改成显式构造 02:30。
11
+
12
+ ## 0.18.1
13
+ ## 0.18.1
14
+
15
+ 「独处」独立成团后有自己的颜色了。
16
+
17
+ - 攒够 3 张的标签会从「自己」里分出去单独成团(星图本来就有这个逻辑),但**颜色一直跟着 kind 走**,
18
+ 和「自己」同色,看上去像没分开。现在给这类团单独配色:`独处 = 淡紫 #c9a2ff`。
19
+ - 图例补一行「独处 N」,只在 ≥3 张(真正独立成团)时出现,否则会和「自己」重复计数。
20
+ - **星点本身仍是 kind 的颜色**:星点回答「这是谁说的」,光晕回答「哪一类」。两者分开是有意的。
21
+
22
+ ## 0.18.0
3
23
  ## 0.18.0
4
24
 
5
25
  把她独处时想的东西,接进记忆和主动开口。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-memory-core",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "type": "module",
5
5
  "description": "四个工具写卡、查卡、改状态、排日程,改口不覆盖。每轮自动把 2 条相关旧记忆推到眼前,不用模型自己查;搜索分「对得上 / 可能沾边」两档。冷层收走三个月没想起的流水账,不删、可回暖。3D 星图一眼看完整个库。常驻约 1,000 token,本地不联网,MIT。\n\nQQ 交流群:745879632",
6
6
  "keywords": [
package/src/world.ts CHANGED
@@ -1445,12 +1445,13 @@ export class MemoryCoreWorld implements World {
1445
1445
  const out: { id: string; ts: string; text: string; importance: number }[] = [];
1446
1446
  for (const line of lines) {
1447
1447
  try {
1448
- const t = JSON.parse(line) as { id?: string; ts?: string; text?: string; importance?: number };
1449
- if (!t.text) continue;
1448
+ const t = JSON.parse(line) as { id?: string; ts?: string; text?: unknown; importance?: number };
1449
+ // 同上:非字符串一律跳过,别让它变成一张「[object Object]」的卡片
1450
+ if (typeof t.text !== 'string' || !t.text.trim()) continue;
1450
1451
  out.push({
1451
1452
  id: String(t.id ?? ''),
1452
1453
  ts: String(t.ts ?? ''),
1453
- text: String(t.text),
1454
+ text: t.text,
1454
1455
  importance: Number(t.importance) || 0,
1455
1456
  });
1456
1457
  } catch {
package/webui/app.js CHANGED
@@ -996,6 +996,8 @@ class Graph {
996
996
 
997
997
  const GALAXY_KIND = { fact: '事实', self: '自己', episode: '经历', promise: '承诺', note: '临时' };
998
998
  const GALAXY_COLOR = { fact: '#8ef0dc', self: '#9ab8ff', episode: '#ffc078', promise: '#ff9ec4', note: '#c3ccd8' };
999
+ /** 攒够 3 张就独立成团的标签,可以有自己的颜色。色相要和它的 kind 拉开,一眼能分。 */
1000
+ const GALAXY_TAG_COLOR = { 独处: '#c9a2ff' };
999
1001
  const GALAXY_CAM = 1900;
1000
1002
 
1001
1003
  /** 固定种子:同一批卡片每次布出来的星系一样。 */
@@ -1321,7 +1323,7 @@ class Galaxy {
1321
1323
  this.nodes.push(node);
1322
1324
  });
1323
1325
  g.hub = g.nodes.reduce((b, n) => (Number(n.card.weight) > Number(b.card.weight) ? n : b), g.nodes[0]);
1324
- g.color = GALAXY_COLOR[g.hub.card.kind] ?? '#c3ccd8';
1326
+ g.color = GALAXY_TAG_COLOR[g.name] ?? GALAXY_COLOR[g.hub.card.kind] ?? '#c3ccd8';
1325
1327
  g.rz = gauss() * RMAX * 0.04;
1326
1328
  }
1327
1329
 
@@ -1804,13 +1806,18 @@ function renderGalaxyLegend() {
1804
1806
  const host = $('#galaxy-legend');
1805
1807
  if (!host || !galaxy) return;
1806
1808
  const counts = galaxy.kindCounts ?? {};
1807
- host.innerHTML = Object.keys(GALAXY_KIND)
1809
+ const parts = Object.keys(GALAXY_KIND)
1808
1810
  .filter((k) => counts[k])
1809
1811
  .map(
1810
1812
  (k) =>
1811
1813
  `<span style="color:${GALAXY_COLOR[k]}"><i style="background:${GALAXY_COLOR[k]}"></i>${GALAXY_KIND[k]} ${counts[k]}</span>`,
1812
- )
1813
- .join('');
1814
+ );
1815
+ // 独立成团的标签单独列一行:它已经从「自己」里分出去了,混在一起会让人数不上
1816
+ for (const [tag, color] of Object.entries(GALAXY_TAG_COLOR)) {
1817
+ const n = cards().filter((c) => (c.tags ?? []).includes(tag)).length;
1818
+ if (n >= 3) parts.push(`<span style="color:${color}"><i style="background:${color}"></i>${tag} ${n}</span>`);
1819
+ }
1820
+ host.innerHTML = parts.join('');
1814
1821
  }
1815
1822
 
1816
1823
  let graph = null;