@fanchao8609/agent_brain_sync 1.28.3 → 1.28.4
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/hooks/abs-rounded-editor/index.ts +7 -50
- package/hooks/abs.omp.ts +4 -3
- package/hooks/abs.pi.ts +4 -5
- package/package.json +1 -1
|
@@ -18,28 +18,13 @@
|
|
|
18
18
|
* 注意:自动补全菜单行排在底边之下、且自带内容宽度,不套竖线(否则菜单被框住会错位)。
|
|
19
19
|
*/
|
|
20
20
|
import { CustomEditor } from '@earendil-works/pi-coding-agent'
|
|
21
|
-
import { readFile } from 'node:fs/promises'
|
|
22
|
-
import { homedir } from 'node:os'
|
|
23
|
-
import { join } from 'node:path'
|
|
24
21
|
import { buildStatus, roundBorder, shortenModel, thinkingColorToken } from './format.ts'
|
|
25
|
-
// 昵称池跟 todo 面板共用一份 —— 2026-11-07 用户要求把「作者名 · 随机语」从面板
|
|
26
|
-
// 搬到输入框左下角,两边必须用同一个池才叫「搬」。
|
|
27
|
-
// 为何用 ../abs.ts:安装后两者分别在 ~/.pi/agent/extensions/abs.ts 与
|
|
28
|
-
// extensions/abs-rounded-editor/index.ts,相对路径稳定。
|
|
29
|
-
// 代价:删掉 abs.ts 会让本扩展导入失败 —— 可接受,因为 abs.ts 是主扩展,
|
|
30
|
-
// 输入框样式是它的附属;单独删主扩展就不是合法使用形态了。
|
|
31
|
-
import { pickNickname } from '../abs.ts'
|
|
32
22
|
|
|
33
23
|
const SIDE = '│'
|
|
34
24
|
|
|
35
25
|
/** 右上角状态文本,如 `8.0%/1.0M deepseek-v4.1-flash`。render() 拿不到 ctx,故由事件回调维护。 */
|
|
36
26
|
let statusLabel = ''
|
|
37
27
|
|
|
38
|
-
/** 左下角标签:`fanchao · 昵称`(2026-11-07 用户要求从面板搬到这里)。
|
|
39
|
-
* session_start 时算一次 —— 不能每帧抽,否则每帧重绘就是个疯狂滚动的老虎机。
|
|
40
|
-
* 空串 = 不显示(无用户名也无昵称时)。 */
|
|
41
|
-
let cornerLabel = ''
|
|
42
|
-
|
|
43
28
|
/** 当前推理强度(off/minimal/low/medium/high/xhigh/max)。render() 拿不到 ctx,同样这里存。
|
|
44
29
|
* 用途:输入文字随推理强度变色(2026-11-06 用户需求)。 */
|
|
45
30
|
let effortLevel = ''
|
|
@@ -83,40 +68,15 @@ export class RoundedEditor extends CustomEditor {
|
|
|
83
68
|
// 输入框内容是用户手打的纯文本,行内不会有 reset 把后半行冲掉。
|
|
84
69
|
out.push(wrap(SIDE) + (effortFg ? effortFg(body) : body) + wrap(SIDE))
|
|
85
70
|
}
|
|
86
|
-
//
|
|
87
|
-
|
|
71
|
+
// 下边框(2026-11-07 还原:左下角的 fanchao·昵称已去掉 —— 用户嫌难看,
|
|
72
|
+
// 回 todo 面板标题;roundBorder 的 leftLabel 参数保留备用)。
|
|
73
|
+
out.push(roundBorder(lines[bottomIdx], wrap, '╰', '╯'))
|
|
88
74
|
// 自动补全行原样透传(不套竖线)。
|
|
89
75
|
for (let i = bottomIdx + 1; i < lines.length; i++) out.push(lines[i])
|
|
90
76
|
return out
|
|
91
77
|
}
|
|
92
78
|
}
|
|
93
79
|
|
|
94
|
-
/** 读出作者名:与 abs.pi.ts 的 currentUser 同规则(ABS_USER > ~/.abs/config.json)。
|
|
95
|
-
* 不在该文件导出 currentUser 是因为它依赖更多模块级状态,且本处只需这两行。 */
|
|
96
|
-
async function readUser(): Promise<string> {
|
|
97
|
-
const env = String(process.env.ABS_USER || '').trim()
|
|
98
|
-
if (env) return env
|
|
99
|
-
try {
|
|
100
|
-
const dir = process.env.ABS_CONFIG_DIR || join(homedir(), '.abs')
|
|
101
|
-
const raw = await readFile(join(dir, 'config.json'), 'utf8')
|
|
102
|
-
const u = JSON.parse(raw).user
|
|
103
|
-
return typeof u === 'string' ? u.trim() : ''
|
|
104
|
-
} catch {
|
|
105
|
-
return ''
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/** 算出左下角标签:`fanchao · 昵称`。缺哪段就省哪段,都为空格返回空串(不画)。 */
|
|
110
|
-
async function refreshCornerLabel(): Promise<void> {
|
|
111
|
-
try {
|
|
112
|
-
const who = await readUser()
|
|
113
|
-
const nick = pickNickname()
|
|
114
|
-
cornerLabel = [who, nick].filter(Boolean).join(' · ')
|
|
115
|
-
} catch {
|
|
116
|
-
cornerLabel = ''
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
80
|
/** 刷新右上角状态文本(每次渲染前由事件与定时器调用)。 */
|
|
121
81
|
function refreshStatus(ctx: any): void {
|
|
122
82
|
try {
|
|
@@ -142,11 +102,6 @@ export default function piRoundedEditor(pi: any): void {
|
|
|
142
102
|
// 主题 getter(带 fg 的那个)—— 见 themeGetter 注释。
|
|
143
103
|
themeGetter = () => ctx.ui?.theme
|
|
144
104
|
refreshStatus(ctx)
|
|
145
|
-
// 左下角标签:每次会话开一次(含 reload/new/resume),会话内固定不变。
|
|
146
|
-
// 与面板旧的昵称行为一致 —— 用户要的是「搬过去」,不是改规则。
|
|
147
|
-
refreshCornerLabel()
|
|
148
|
-
.then(() => ctx.ui?.requestRender?.())
|
|
149
|
-
.catch(() => {})
|
|
150
105
|
// 第四个参数 embedWorkingStatus: true —— working 状态进上边框,不再单独占一行。
|
|
151
106
|
ctx.ui.setEditorComponent(
|
|
152
107
|
(tui: any, theme: any, keybindings: any) =>
|
|
@@ -156,8 +111,10 @@ export default function piRoundedEditor(pi: any): void {
|
|
|
156
111
|
ctx.ui.setFooter?.(() => ({ render: () => [], invalidate() {} }))
|
|
157
112
|
})
|
|
158
113
|
|
|
159
|
-
// 切模型时更新右上角名字(/model、Ctrl+P 都走这个事件)。
|
|
160
|
-
|
|
114
|
+
// 切模型时更新右上角名字(/model、Ctrl+P、cycle 都走这个事件)。
|
|
115
|
+
// ★ pi 实际发的事件名是 model_select(dist/core/agent-session.js _emitModelSelect),
|
|
116
|
+
// 之前监听的 model_changed 在 pi 里不存在,刷新从未触发 —— 2026-11-07 修复。
|
|
117
|
+
pi.on('model_select', (_event: any, ctx: any) => {
|
|
161
118
|
refreshStatus(ctx)
|
|
162
119
|
ctx?.ui?.requestRender?.()
|
|
163
120
|
})
|
package/hooks/abs.omp.ts
CHANGED
|
@@ -571,9 +571,10 @@ export function renderPanelLines(
|
|
|
571
571
|
const flow = off ? 'dim' : 'muted'
|
|
572
572
|
const lines: string[] = []
|
|
573
573
|
// 上描边行已删除(2026-11-04 与 pi 版同步,用户要求「去掉上边框」)。首行现在是标题行。
|
|
574
|
-
//
|
|
575
|
-
//
|
|
576
|
-
const
|
|
574
|
+
// 标题带着作者名与昵称(2026-11-07 用户要求还原):曾搬到输入框左下角,
|
|
575
|
+
// 用户实测「在输入框这里很难看」,又搬回来。
|
|
576
|
+
const whoPart = who ? who + (nickname ? ` · ${nickname}` : '') : nickname
|
|
577
|
+
const title = whoPart ? `Todo (${data.total}) — ${whoPart}` : `Todo (${data.total})`
|
|
577
578
|
// 标题顶最左(2026-11-04 用户)。旧代码空看板时多缩 1 格,2026-11-06 与 pi 版同步删去 ——
|
|
578
579
|
// 空看板已整块不显示(见 refreshTodoPanel)。
|
|
579
580
|
lines.push(clipToWidth(fg(main, title), width))
|
package/hooks/abs.pi.ts
CHANGED
|
@@ -1017,11 +1017,10 @@ export function renderPanelLines(
|
|
|
1017
1017
|
// 历史:那行曾用 `thinkingOff` 对齐 pi 输入框描边色(排查三轮才定色)。
|
|
1018
1018
|
// 首行现在是标题行。
|
|
1019
1019
|
//
|
|
1020
|
-
//
|
|
1021
|
-
//
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
const title = `Todo (${data.total})`
|
|
1020
|
+
// 标题带着作者名与昵称(2026-11-07 用户要求还原):曾搬到输入框左下角,
|
|
1021
|
+
// 用户实测「在输入框这里很难看」,又搬回来 —— 前因:9d628ba 那次搬出去,本次搬回来。
|
|
1022
|
+
const whoPart = who ? who + (nickname ? ` · ${nickname}` : '') : nickname
|
|
1023
|
+
const title = whoPart ? `Todo (${data.total}) — ${whoPart}` : `Todo (${data.total})`
|
|
1025
1024
|
// 标题也顶最左(2026-11-04 用户)。旧代码曾在空看板时多缩 1 格,2026-11-06 空看板
|
|
1026
1025
|
// 已整块不显示(见 refreshTodoPanel),那个分支没意义了。
|
|
1027
1026
|
lines.push(clipToWidth(fg(main, title), width))
|