@fanchao8609/agent_brain_sync 1.5.1 → 1.5.3
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/install.js +17 -1
- package/src/store.js +11 -5
package/package.json
CHANGED
package/src/install.js
CHANGED
|
@@ -598,8 +598,17 @@ async function installPi({ withMcp, withSkill, log }) {
|
|
|
598
598
|
const p = join(dir, 'abs.ts');
|
|
599
599
|
await atomicWrite(p, piPluginSource()); // Pi 用专用模板, 语法与 OpenCode 不同构
|
|
600
600
|
steps.push(`✓ hook(ts extension) → ${p}`);
|
|
601
|
+
// MCP → ~/.pi/agent/mcp.json 的 mcpServers (stdio)
|
|
602
|
+
// 曾经只打印「走 extension 内桥接」而没有任何桥接代码 —— 靠 mcp-adapter 的
|
|
603
|
+
// hostConfigDiscovery 间接读到 claude 注册才"看起来能用"; 没有 claude 宿主的机器上直接缺失。
|
|
601
604
|
if (withMcp) {
|
|
602
|
-
|
|
605
|
+
const mcpP = join(hostConfigRoot('pi'), 'agent', 'mcp.json');
|
|
606
|
+
await backup(mcpP);
|
|
607
|
+
const cfg = await readJson(mcpP);
|
|
608
|
+
cfg.mcpServers = cfg.mcpServers || {};
|
|
609
|
+
cfg.mcpServers['abs'] = { type: 'stdio', command: process.execPath, args: [mcpEntryPath()] };
|
|
610
|
+
await atomicWrite(mcpP, JSON.stringify(cfg, null, 2));
|
|
611
|
+
steps.push(`✓ MCP → ${mcpP} (mcpServers.abs, stdio)`);
|
|
603
612
|
}
|
|
604
613
|
if (withSkill) {
|
|
605
614
|
const target = join(hostSkillDir('pi'), 'SKILL.md');
|
|
@@ -615,6 +624,13 @@ async function uninstallPi() {
|
|
|
615
624
|
steps.push(`✓ extension 已删除`);
|
|
616
625
|
await fs.rm(hostSkillDir('pi'), { recursive: true, force: true });
|
|
617
626
|
steps.push(`✓ skill 已删除`);
|
|
627
|
+
const mcpP = join(hostConfigRoot('pi'), 'agent', 'mcp.json');
|
|
628
|
+
const cfg = await readJson(mcpP);
|
|
629
|
+
if (cfg.mcpServers && cfg.mcpServers.abs) {
|
|
630
|
+
delete cfg.mcpServers.abs;
|
|
631
|
+
await atomicWrite(mcpP, JSON.stringify(cfg, null, 2));
|
|
632
|
+
steps.push(`✓ MCP 已从 ${mcpP} 移除`);
|
|
633
|
+
}
|
|
618
634
|
return steps;
|
|
619
635
|
}
|
|
620
636
|
|
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,
|
|
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 "..." 记, 不收工具动作流水) ----------
|