sync-gbrain

AI 智能 社区 v1.0.0
解读按原文结构重写,命令、链接、术语均保留;右侧可核对作者原始 SKILL.md

sync-gbrain 是 gstack 「把代码 + 工件 + 记忆同步进 brain」的运行时入口。它跑得非常频繁——steady state 下增量 ~50ms,所以默认是无感的;只有 --full 才会触发 gbrain reindex-code(大仓 25–35 分钟),明令必须问过用户。

设计思路

作者把同步拆成 code → memory → brain-sync 三阶段,每阶段失败不致命——后续阶段照跑;状态写到 ~/.gstack/.gbrain-sync-state.json(tmp-file + atomic rename);并发用 ~/.gstack/.sync-gbrain.lock 锁(5 分钟 stale takeover)。

参数模式

  • /sync-gbrain——增量(默认;mtime fast-path)
  • /sync-gbrain --full——gbrain reindex-code 全量重建
  • /sync-gbrain --code-only / --no-memory / --no-brain-sync——分阶段开关
  • /sync-gbrain --dry-run——只预览,不写
  • /sync-gbrain --quiet——压制每阶段输出
  • 透传:未知 flag 直接交给 ~/.claude/skills/gstack/bin/gstack-gbrain-sync.ts

工作流

Step 1 State probegstack-gbrain-detect/setup-gbrain 是否跑过;split-engine 模型——code stage 永远本地 PGLite + 每个 worktree 一个 source;artifacts/memory 跟 setup 设的路径走(含 Path 4 远程 MCP)。gbrain_on_path=falsegbrain_config_exists=false 直接停并提示先跑 /setup-gbrain;per-repo gstack-gbrain-repo-policy getdeny 也停。Step 2 跑 orchestrator——透传用户 args,不要 paraphrase。Step 3 code-index 健康检查:用 source_idpage_count,0 且非 --no-code / 非 --full → AskUserQuestion 是否 --full 重建。Step 4 刷新 CLAUDE.md## GBrain Search Guidance 段。Step 5 Verdict block 落 idempotent doctor 输出。

历史教训

作者特意在文档里点出「一个 bug 修了」:之前的版本把远程 MCP(Path 4)用户整段跳过 code stage——错的。code stage 的 CLI(gbrain sources add / sync --strategy code / sources attach)目标永远是本地 gbrain CLI + DB,与 ~/.claude.json 是不是把 gbrain 注册成 remote HTTP MCP 无关。修正后 code 永远本地、artifacts 仍可跨机。

配套

setup-gbrain(前置安装)、open-gstack-browser(看 brain 数据)、learn(把会话记忆喂进 memory 阶段)、grill-with-docs(让领域语言基于 brain 中文档锚定)。

流狐档案 作者与许可取自来源;运行、权限和网络为流狐检测或估算
流狐分类
AI 智能
作者声明 Agent
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
作者 / 版本 / 许可
@garrytan · v1.0.0 · 未声明 license
流狐 Token 估算
较高消耗
流狐接入估算
需手动接入
是否需要外部 API Key
需要 · Vendor-specific
检测到的系统要求
macOS · Linux · Windows
底层运行要求
Bun
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
  • Shell 执行
检测到的网络行为
允许外网请求
安装命令数
无(仅作为资料)

档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。

需要注意: 未限定 allowed-tools,默认拥有全部工具权限。

输出预览 sync-gbrain.preview
# Writing Style (skip entirely if EXPLAINLEVEL: terse appears in the preamble echo OR the user's current message explicitly requests terse / no-explanations output)

- Gloss curated jargon on first use per skill invocation, even if the user pasted the term.
- Frame questions in outcome terms: what pain is avoided, what capability unlocks, what user experience changes.
- Use short sentences, concrete nouns, active voice.
- Close decisions with user impact: what the user sees, waits for, loses, or gains.
- User-turn override wins: if the current message asks for terse / no explanations / just the answer, skip this section.
- Terse mode (EXPLAIN_LEVEL: terse): no glosses, no outcome-framing layer, shorter responses.

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。