@fanchao8609/agent_brain_sync 1.5.0 → 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.
- package/package.json +1 -1
- package/src/store.js +25 -9
package/package.json
CHANGED
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 { homedir } from 'node:os';
|
|
6
|
-
import { requireBrain, findBrainRoot, brainPath } from './index.js';
|
|
6
|
+
import { requireBrain, findBrainRoot, brainPath, BRAIN_DIR } from './index.js';
|
|
7
7
|
import { addTask, upsertTask, boardText, readTodo, ensureTodo, todoTemplate, today, localStamp, setBreakpoint, moveBlocked, insertDoneGrouped, idOfTaskLine, archiveDoneInText, renderArchivePage, renderArchiveBody } from './todo.js';
|
|
8
8
|
import { editFile, SKIP } from './lock.js';
|
|
9
9
|
import { appendWrapup, strandedFor, wrapupLogPath } from './wrapup.js';
|
|
@@ -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,
|
|
171
|
-
|
|
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
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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 "..." 记, 不收工具动作流水) ----------
|
|
@@ -593,8 +599,8 @@ export async function cmdLint({ dir }) {
|
|
|
593
599
|
issues.push(`UNRESOLVED-CONFLICT: ${pg.rel}`);
|
|
594
600
|
}
|
|
595
601
|
if (['concepts', 'entities', 'syntheses'].includes(pg.dir)) {
|
|
596
|
-
if (pg.lines >
|
|
597
|
-
issues.push(`OVER-SIZE: ${pg.rel} (${pg.lines}L/${pg.bytes}B >
|
|
602
|
+
if (pg.lines > PAGE_MAX_LINES || pg.bytes > PAGE_MAX_BYTES) {
|
|
603
|
+
issues.push(`OVER-SIZE: ${pg.rel} (${pg.lines}L/${pg.bytes}B > ${PAGE_MAX_LINES}L/${PAGE_MAX_BYTES / 1024}KB; 拆或外链)`);
|
|
598
604
|
}
|
|
599
605
|
}
|
|
600
606
|
if (pg.dir !== 'sources' && !pg.indexed) {
|
|
@@ -639,6 +645,14 @@ export async function cmdLint({ dir }) {
|
|
|
639
645
|
|
|
640
646
|
const PAGE_DIRS = ['entities', 'concepts', 'sources', 'syntheses', 'sessions'];
|
|
641
647
|
|
|
648
|
+
// concept/entity/synthesis 页的容量上限,超出提示"拆或外链"。
|
|
649
|
+
// 曾为 150L/5120B —— 实测偏紧:跨 4 项目 68 页里仅 2 页超限,且都只超一点
|
|
650
|
+
// (5463B / 5440B);为满足它还把一页从 5319B 压到 4972B(内容受损、收益为零)。
|
|
651
|
+
// 放宽到 8KB:当前最大页 5463B,留约 50% 余量,但不至于失去"该拆了"的信号。
|
|
652
|
+
// 提成常量避免检查条件与提示文本各写一份而漂移。
|
|
653
|
+
const PAGE_MAX_LINES = 150;
|
|
654
|
+
const PAGE_MAX_BYTES = 8 * 1024;
|
|
655
|
+
|
|
642
656
|
async function listPages(vault) {
|
|
643
657
|
let indexText = '';
|
|
644
658
|
try {
|
|
@@ -661,7 +675,9 @@ async function listPages(vault) {
|
|
|
661
675
|
const links = [...new Set([...body.matchAll(/\[\[([^\]]+)\]\]/g)].map((m) => m[1].split('|')[0]))];
|
|
662
676
|
pages.push({
|
|
663
677
|
dir: d,
|
|
664
|
-
|
|
678
|
+
// 带上 .brain/ 前缀:这串会原样出现在 lint 提示里,用户会拿它去找文件。
|
|
679
|
+
// 坑: 曾经只给 vault 相对路径(concepts/x.md),用户到项目根找 concepts/ 找不到。
|
|
680
|
+
rel: `${BRAIN_DIR}/${d}/${f}`,
|
|
665
681
|
slug: f.replace(/\.md$/, ''),
|
|
666
682
|
body,
|
|
667
683
|
frontmatter: fm ? fm[1] : '',
|