一键导入
gbrain-integration-agent-name-lower
⚠️ DEPRECATED — gbrain replaced by SQLite FTS5 + Ollama embeddings (2026-07-05). Use recall()/remember() tools instead.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
⚠️ DEPRECATED — gbrain replaced by SQLite FTS5 + Ollama embeddings (2026-07-05). Use recall()/remember() tools instead.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
{{AGENT_NAME}} brain signal architecture — event bus, signal processor, awareness reporter, brain monitor
TDD-PDCA plan for building a self-replicating branching agent in {{AGENT_NAME}}. 단일 에이전트가 스스로 서브에이전트를 분기하고, 결과를 수렴시키는 구조.
Integrate {{AGENT_NAME}} with ACP (Agent Client Protocol) agents. Reverse-engineered from goose's Rust ACP provider implementation.
Maintain .{{AGENT_NAME_LOWER}} as an Obsidian vault — graph connectivity overhaul (P-layer mesh, skill clusters, SEO article web), broken link detection, backlink density verification via Obsidian CLI, filename deduplication, bidirectional linking, auto-generated orphan management, cron output graph bloat prevention, and Obsidian compatibility.
AI Trend Collection & Filtering — collect GitHub trending repos, score via 5-axis philosophy filter, evaluate, apply, and retire.
RSS 피드 모니터링 → SEO 기사 수집·분석·트렌드 리포트
| title | gbrain-integration-{{AGENT_NAME_LOWER}} |
| name | gbrain-integration-{{AGENT_NAME_LOWER}} |
| description | ⚠️ DEPRECATED — gbrain replaced by SQLite FTS5 + Ollama embeddings (2026-07-05). Use recall()/remember() tools instead. |
| type | skill |
| tags | ["gbrain","mcp","vault","search",{"[object Object]":null},"deprecated"] |
| links | ["[[mcp/native-mcp]]","[[mcp/mcporter]]","[[@action/skills/SKILL-INDEX]]","[[@identity/brain/rules]]"] |
Integrate GBrain (by Garry Tan) as an MCP server into {{AGENT_NAME}}/Hermes for hybrid search over the .{{AGENT_NAME_LOWER}} Obsidian vault.
brew install oven-sh/bun/bun git clone https://github.com/garrytan/gbrain.git ~/gbrain cd ~/gbrain && bun install bun run build:all bun link
export PATH="$HOME/.bun/bin:$PATH" gbrain init --pglite --embedding-model openai:mxbai-embed-large --embedding-dimensions 1536
Write to ~/.gbrain/config.json with embedding_disabled: true, provider_base_urls: { openai: "http://localhost:11434/v1" }
Note: embedding_disabled: true because Ollama's OpenAI-compatible endpoint is rejected by OpenAI client key validation. Vector search needs real key.
gbrain sources add {{AGENT_NAME_LOWER}} --path ~/.{{AGENT_NAME_LOWER}} --name "{{AGENT_NAME}} Vault" gbrain sources default {{AGENT_NAME_LOWER}} gbrain import ~/.{{AGENT_NAME_LOWER}}/P0-brainstem --source {{AGENT_NAME_LOWER}} --yes --no-embed gbrain extract links --yes
Add to config.yaml under mcp_servers: gbrain: command: ~/.bun/bin/gbrain args: ["serve"] env: OPENAI_API_KEY: "ollama-local"
Set env via Python to ensure proper YAML dict format:
import yaml
with open('/.{{AGENT_NAME_LOWER}}/config.yaml') as f:
d = yaml.safe_load(f)
d['mcp_servers']['gbrain']['env'] = {'OPENAI_API_KEY': 'ollama-local'}
with open('/.{{AGENT_NAME_LOWER}}/config.yaml', 'w') as f:
yaml.dump(d, f, default_flow_style=False, allow_unicode=True, sort_keys=False)
Verify gbrain is connected via the MCP tools (check gbrain get_stats or gbrain search "test query"). The MCP server is configured in ~/.config/opencode/opencode.jsonc.
gbrain search "test query"
Start a new agent session for MCP tools to be discovered.
Key tools: search (keyword FTS), query (hybrid), get_backlinks, traverse_graph (depth 1-10), get_page, find_orphans, get_stats
$ gbrain get_stats
✗ Connection failed (42142ms): MCP call timed out after 40.1s
Step 1 — Count running instances:
ps aux | grep "gbrain serve" | grep -v grep
If more than one process, you have a lock contention problem. PGLite is a single-writer database — multiple gbrain serve instances fight for the write lock and only one can respond.
Step 2 — Identify orphans vs legitimate:
for pid in $(ps aux | grep "gbrain serve" | grep -v grep | awk '{print $2}'); do
ppid=$(ps -o ppid= -p $pid 2>/dev/null | tr -d ' ')
pcmd=$(ps -o command= -p $ppid 2>/dev/null | head -1)
echo "gbrain PID $pid ← parent PID $ppid ($pcmd)"
done
Two types of parent:
{{AGENT_NAME_LOWER}}_cli.main gateway run --replace) — KEEP this onehermes binary, often already terminated) — KILL theseStep 3 — Fix:
# Kill orphans only (gateway's child stays)
kill <orphan-pid-1> <orphan-pid-2>
# Or if you want a clean restart: kill ALL, then gateway restarts its own
killall -m "gbrain serve"
# Verify by calling a gbrain tool directly (e.g. gbrain get_stats)
Expected: ✓ Connected (<1s), ✓ Tools discovered: 89
Same root cause as above — multiple gbrain processes competing. Run the diagnostic in step 1-2.
Running an MCP test or CLI session can spawn a temporary gbrain subprocess. If the session exits and the child is orphaned, it stays alive holding the PGLite lock, blocking the gateway's gbrain.
Root cause: MCP stdio transport does not always clean up child processes when the parent session exits. This is a known pattern with subprocess-based MCP servers — the runtime doesn't detect stdin closure and auto-exit.
A no-agent cron job runs every 15 minutes to detect and kill orphaned gbrain processes:
# [REMOVED 2026-07-05] Script: ~/.{{AGENT_NAME_LOWER}}/scripts/{{AGENT_NAME_LOWER}}_gbrain_watchdog.sh
# Cron: gbrain-watchdog (ID: 0fb33852686c)
The script detects gbrain processes whose parent PID is dead (not launchd-adopted) and kills them. Silent when nothing to clean; reports via cron delivery when cleanup happened.
Implementation notes:
ps -eo pid,ppid,comm — never ps aux for PPID detection (ps aux shows %CPU in column 3, not PPID)Run this to detect accumulated orphans:
orphans=0
for pid in $(ps aux | grep "gbrain serve" | grep -v grep | awk '{print $2}'); do
ppid=$(ps -o ppid= -p $pid 2>/dev/null | tr -d ' ')
pcmd=$(ps -o command= -p $ppid 2>/dev/null)
if ! echo "$pcmd" | grep -q "gateway run"; then
echo "ORPHAN: gbrain PID $pid (parent $ppid: $pcmd)"
orphans=$((orphans + 1))
fi
done
echo "Found $orphans orphan(s)"
⚠ Caveat: the ps aux approach works here because each PID is resolved individually via ps -o ppid= -p $pid — never parse the shared ps aux output to extract $3 as PPID. Column 3 of ps aux is %CPU, not PPID.
killall -m "gbrain serve"
# Gateway will re-spawn gbrain on its next MCP tool call
gbrain serve instances.embedding_disabled: true for local-only.~/.config/opencode/opencode.jsonc before starting the session.