@fanchao8609/agent_brain_sync 1.6.0 → 1.6.1

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 +26 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fanchao8609/agent_brain_sync",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
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
@@ -3,7 +3,7 @@
3
3
  import { promises as fs } from 'node:fs';
4
4
  import { join, resolve, dirname } from 'node:path';
5
5
  import { requireBrain, brainPath, absLogDir, BRAIN_DIR } from './index.js';
6
- import { requireUser, atTag } from './userconfig.js';
6
+ import { requireUser, atTag, getUser } from './userconfig.js';
7
7
  import { addTask, upsertTask, boardText, readTodo, ensureTodo, todoTemplate, today, localStamp, setBreakpoint, moveBlocked, insertDoneGrouped, idOfTaskLine, archiveDoneInText, renderArchivePage, renderArchiveBody, DONE_KINDS, withDoneKind, doneKindOf } from './todo.js';
8
8
  import { editFile, SKIP } from './lock.js';
9
9
  import { appendWrapup, strandedFor } from './wrapup.js';
@@ -35,7 +35,11 @@ async function createSkeleton(root, brain) {
35
35
  await fs.writeFile(join(brain, 'index.md'), indexTemplate(), 'utf8');
36
36
  await fs.writeFile(join(brain, 'log.md'), logTemplate(), 'utf8');
37
37
  await fs.writeFile(join(brain, 'todo.md'), todoTemplate(), 'utf8');
38
- return `✓ 已建图谱 ${brain}\n (模板见 SKILL.md「文件标准」)`;
38
+ // 建完就提示设姓名 —— 否则用户一路到第一次 todo add 才撞墙,
39
+ // 中间 init/load 都不提,根本不知道该设。
40
+ const who = await getUser();
41
+ const hint = who ? '' : `\n ⚠ 尚未设置使用者姓名,写操作(todo add/log/note)会先报错。\n 请先设置: abs config set user <你的名字>`;
42
+ return `✓ 已建图谱 ${brain}\n (模板见 SKILL.md「文件标准」)${hint}`;
39
43
  }
40
44
 
41
45
  /** 结构体检:6 目录 + 3 文件逐一核对。ok=false 时 problems 列出缺失项。 */
@@ -163,6 +167,17 @@ export async function cmdLoad({ dir }) {
163
167
  const stranded = await strandedFor(root);
164
168
  const sections = [
165
169
  `📂 abs → 项目: ${root}`,
170
+ ];
171
+ // 未设姓名时开场就提醒 —— load 是开机第一屏,不在这里提,
172
+ // 用户要撞到第一次写操作才知道(init/load 一路沉默)。
173
+ if (!(await getUser())) {
174
+ sections.push(
175
+ '⚠ 尚未设置使用者姓名(写操作会先报错)',
176
+ '→ abs config set user <你的名字> (或临时: ABS_USER=<名字> abs ...)',
177
+ ''
178
+ );
179
+ }
180
+ sections.push(
166
181
  '--- 当前路线 (index.md) ---',
167
182
  index || '(index.md 为空)',
168
183
  '',
@@ -171,15 +186,15 @@ export async function cmdLoad({ dir }) {
171
186
  '',
172
187
  '--- 最近动作 (log.md, 最新 5 条) ---',
173
188
  recentLogLines(log, 5) || '(log.md 为空)',
174
- ];
189
+ );
175
190
  if (stranded.length) {
176
191
  const rows = stranded.map((t) => {
177
192
  const bp = t.bp.length ? `\n ${t.bp.map((b) => `↳ 断点: ${b}`).join('\n ')}` : '';
178
193
  return ` - ${t.body}${bp}`;
179
194
  });
195
+ // 插在项目行之后、其它内容之前
180
196
  sections.splice(
181
- 0, 1,
182
- `📂 abs → 项目: ${root}`,
197
+ 1, 0,
183
198
  '⏳ 上会话滞留(未 done,先对账)',
184
199
  rows.join('\n'),
185
200
  '→ 完成: abs todo done <id>;未完: abs todo note <id> --note 断点',
@@ -319,7 +334,12 @@ export async function cmdTeardownCheck({ dir, payload }) {
319
334
  await fs.writeFile(mark, stamp).catch(() => {});
320
335
 
321
336
  const msg = [
322
- '[abs 收尾提醒] 本会话改过文件但 .brain/ 今天还没有记录。请立即走收尾循环:',
337
+ // 未设姓名时把设置指令插到第0条 —— 否则后续 todo add/log/note 全会被守卫拦下,
338
+ // 而收尾提醒本身不提这事,使用者只会看到一连串报错。
339
+ (await getUser() ? [] : [
340
+ '0) 本机尚未设置使用者姓名 —— 先跑 abs config set user <你的名字>,否则下面 2/3/4 都会被拦下;',
341
+ ]),
342
+ '[abs 收尾提醒] 本会话改过文件但 .brain/ 今天还没有记录。请立即走收尾循环:',
323
343
  '1) 跑 abs load 看 Today 还有哪些未完成;',
324
344
  '2) 实际做完漏登记的 abs todo done <id>,做到一半的 abs todo note <id> --note "断点";',
325
345
  '3) 值得留的经验 abs note "..."(宁少勿滥,能从代码 grep 到的不记);',