brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
workbuddy-context-handoff给 WorkBuddy(桌面端 CodeBuddy Code 运行时)配置基于 hooks 的上下文 handoff 门禁 —— 上下文占用达阈值时自动强制产出 handoff 文档,新会话自动注入继续干活。也用于排查 WorkBuddy hooks / 上下文压缩阈值 / transcript 用量相关问题。触发场景:上下文到 N% 自动生成 handoff、交接文档、新会话续接、hooks 怎么配、为什么自动压缩了、上下文用量怎么算、context handoff、auto compact。注意:本技能的平台路径与 hook 事件名是 WorkBuddy 专有,不适用于其它 agent 运行时。
Independent GitHub snapshot · Automated classification · Original documentation governs
在 WorkBuddy 桌面端搭一条"上下文快满 -> 强制产出 handoff 文档 -> 新会话自动续接"的流水线。
{"continue": false, "reason": "..."} 强制模型先写 handoff。~/.workbuddy/settings.json 或项目级
<proj>/.workbuddy/settings.json),先备份,再读现有 hooks 键。~/.workbuddy/hooks/:handoff-trigger.mjs(Stop)、
handoff-resume.mjs(SessionStart)、run-hook.sh。各文件职责与防死循环要求见
references/hook-implementation.md。hooks 键,不要整体覆盖):"hooks": {
"Stop": [
{ "hooks": [ { "type": "command", "command": "<abs>/run-hook.sh <abs>/handoff-trigger.mjs", "timeout": 15 } ] }
],
"SessionStart": [
{ "matcher": "startup|clear",
"hooks": [ { "type": "command", "command": "<abs>/run-hook.sh <abs>/handoff-resume.mjs", "timeout": 15 } ] }
]
}
JSON.parse 解析整个 settings 文件,确认其余键未丢。echo '<payload json>' | /bin/bash -lc '<command>',
再跑一轮真实会话确认 handoff 产出与注入都发生。hooks/state/ 与 handoffs/ 下的测试文件。hookSpecificOutput.additionalContext 是唯一能进新会话上下文的位置。PreCompact 不能当
handoff 触发器(stdout 只进压缩指令,exit 2 只给用户看消息)。CODEBUDDY_PRE_MESSAGE_COMPACT_PCT=80;确认能到目标比例后,再调
handoff.config.json 里的 handoff 阈值。handoff.config.json.contextWindow 留 null 时依次取
settings.autoCompactWindow -> CODEBUDDY_AUTO_COMPACT_WINDOW -> 200000。references/runtime-facts.md。references/hook-implementation.md。## Troubleshooting。~/.workbuddy/settings.json 前先备份;改完必须 JSON.parse 校验,并确认其余键未丢。exit 0,否则会卡住对话。stop_hook_active===true 直接 return,并用
state/<sid>.fired 去重。sha1(cwd).slice(0,12) 分项目,不要依赖 app 的 cwd-slug(不同版本大小写规则不一致)。hooks/state/ 与 handoffs/ 下的测试产物。exit 0)> "一定要触发 handoff"。stop_hook_active 检查 + 每 session 一次)> 尽量多触发。grep app.asar 搜不到目标字符串 -> 不要反复 grep;改用
npx @electron/asar extract <asar> <dir> 后再 grep。JSON.parse 失败 -> 立即还原备份,不要继续追加改动。交付前逐项确认:
~/.workbuddy/settings.json 已备份,且 JSON.parse 通过、其余键未丢。exit 0。stop_hook_active 与 state/<sid>.fired 双重防死循环。startup|clear,且 source==="compact" 时跳过。hooks/state/ 与 handoffs/ 下的测试产物已清理。## Verification 全部勾选,且用户能在真实会话里看到 handoff 产出与注入。hooks 段;handoffs/ 下带 <file>.consumed 标记的文件;
state/<sid>.fired 标记;一轮实测会话的前后对比。按需加载,不要预先全读:
references/runtime-facts.md — 需要确认 hook 事件名、matcher 语义、hook 入参、transcript 路径
或内置压缩阈值常量时读。references/hook-implementation.md — 要写或修改 handoff-trigger.mjs / handoff-resume.mjs /
run-hook.sh 时读。~/.workbuddy/settings.json JSON 合法、命令用绝对路径、脚本可执行。
手动复现:echo '<payload json>' | /bin/bash -lc '<command>'。CODEBUDDY_PRE_MESSAGE_COMPACT_PCT=80,或降低 handoff 阈值。npx @electron/asar extract <asar> <dir>(3-4s,约 800MB)解包后再 grep。