@fanchao8609/agent_brain_sync 1.5.1 → 1.5.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/package.json +1 -1
  2. package/src/store.js +11 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanchao8609/agent_brain_sync",
3
- "version": "1.5.1",
3
+ "version": "1.5.2",
4
4
  "description": "agent-brain-sync: 跨会话 AI 编码记忆 — hook 纯触发 + CLI/MCP 读写 .brain markdown 图谱, 防并发写保护。",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/store.js CHANGED
@@ -167,8 +167,8 @@ export async function cmdLoad({ dir }) {
167
167
  '--- Todo 看板 (todo.md) ---',
168
168
  todo.trim() || '(todo.md 为空)',
169
169
  '',
170
- '--- 最近动作 (log.md, 末尾 5 条) ---',
171
- tailLines(log, 5) || '(log.md 为空)',
170
+ '--- 最近动作 (log.md, 最新 5 条) ---',
171
+ recentLogLines(log, 5) || '(log.md 为空)',
172
172
  ];
173
173
  if (stranded.length) {
174
174
  const rows = stranded.map((t) => {
@@ -336,9 +336,15 @@ async function readIfExists(p) {
336
336
  try { return (await fs.readFile(p, 'utf8')).trim(); } catch { return ''; }
337
337
  }
338
338
 
339
- function tailLines(text, n) {
340
- const lines = text.split('\n').filter((l) => l.trim());
341
- return lines.slice(-n).join('\n');
339
+ /** log.md 是"新在上"(cmdLog 把新行插在标题后)——取**最新** n 条,只认 `## [` 条目行。
340
+ * 坑: 曾用 tailLines 取末尾 → 拿到的永远是最旧几条,而标签写着"最近动作",
341
+ * 于是"开机读状态"最该看的一节长期显示两天前的旧记录(今天的新条目从未显示)。 */
342
+ function recentLogLines(text, n) {
343
+ return String(text || '')
344
+ .split('\n')
345
+ .filter((l) => /^##\s*\[/.test(l))
346
+ .slice(0, n)
347
+ .join('\n');
342
348
  }
343
349
 
344
350
  // ---------- log: 追加工作成果沉淀摘要(用户/AI 主动 abs log "..." 记, 不收工具动作流水) ----------