@fanchao8609/agent_brain_sync 0.5.0 → 1.0.0
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 +6 -5
package/package.json
CHANGED
package/src/install.js
CHANGED
|
@@ -318,16 +318,16 @@ const server = async ({ client, directory }) => {
|
|
|
318
318
|
return
|
|
319
319
|
}
|
|
320
320
|
if (type !== "session.idle") return // idle = 每轮结束, 不记日志(太吵), 只做收尾判定
|
|
321
|
+
const cwd = directory || process.cwd()
|
|
322
|
+
const brain = await findBrain(cwd)
|
|
321
323
|
// 可观测性: 首次 idle 无条件留一行痕(否则无法区分“事件没触发”与“被守卫拦下”)
|
|
322
324
|
if (!idleSeen) {
|
|
323
325
|
idleSeen = true
|
|
324
|
-
await logHook(
|
|
326
|
+
await logHook(\`session.idle:seen cwd=\${cwd} brain=\${brain || 'none'}\`)
|
|
325
327
|
}
|
|
326
328
|
if (nudged || !wroteFiles) return
|
|
327
329
|
const sessionID = event.properties && event.properties.sessionID
|
|
328
330
|
if (!sessionID) return
|
|
329
|
-
const cwd = directory || process.cwd()
|
|
330
|
-
const brain = await findBrain(cwd)
|
|
331
331
|
if (!brain) return // 无图谱=不在这项目沉淀, 不打扰
|
|
332
332
|
if (await loggedToday(brain)) return // 今天已收尾过
|
|
333
333
|
nudged = true
|
|
@@ -448,13 +448,14 @@ export default function absPiHook(pi: ExtensionAPI): void {
|
|
|
448
448
|
pi.on("agent_end", async (event: any, ctx: any) => {
|
|
449
449
|
if (teardownNudged) return
|
|
450
450
|
const cwd = (ctx && ctx.cwd) || process.cwd()
|
|
451
|
+
const brain = await findBrain(cwd)
|
|
451
452
|
// 可观测性: 本会话首次 agent_end 无条件留一行痕。
|
|
452
453
|
// 没有它就无法区分三种状态: ①事件没触发 ②触发了但被守卫拦下 ③真注入了。
|
|
453
454
|
if (!agentEndSeen) {
|
|
454
455
|
agentEndSeen = true
|
|
455
|
-
|
|
456
|
+
// 带上 cwd 与命中的 brain —— 否则事后无法解释“为何这条 nudge 会出现”
|
|
457
|
+
await logHook(\`agent_end:seen cwd=\${cwd} brain=\${brain || 'none'}\`).catch(() => {})
|
|
456
458
|
}
|
|
457
|
-
const brain = await findBrain(cwd)
|
|
458
459
|
if (!brain) return // 无图谱=不在这项目沉淀, 不打扰
|
|
459
460
|
if (!hasWriteWork(event?.messages ? collectToolResults(event.messages) : [])) return
|
|
460
461
|
if (await loggedToday(brain)) return // 今天已收尾过
|