smoke-test
它能做什么
这项技能对你的 GBrain 设置运行一组健康测试,例如数据库、命令行工具和后台工作进程。适合想在重启后确认一切正常运行的人。
适用场景
- ✓当你重启电脑或容器,想确认知识库可以正常运行的时候。
- ✓当你的知识库似乎出了问题,想快速检查一下的时候。
- ✓当你想在标准测试之外添加自己的健康检查时。
技能链接
https://github.com/garrytan/gbrain/blob/master/plugin/skills/smoke-test/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我刚重启了电脑。请对我的知识库运行健康测试,并修复其中任何小的故障。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会运行八项核心检查,修复有限的本地问题,例如受损的数据库索引,并报告它无法修复的内容。后台工作进程只会被报告状态,不会被自动启动。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Smoke Test Skillpack
Run
gbrain smoke-testafter any machine or container restart, or whenever something seems broken.
Contract
This skill guarantees:
- 8 core tests verify gbrain health after restart (plus OpenClaw services when present; skipped otherwise)
- Bounded local failures are auto-fixed before reporting; worker repair is explicit because process topology and shell-job policy are operator choices
- User-extensible via
~/.gbrain/smoke-tests.d/*.shdrop-in scripts - Results logged to
/tmp/gbrain-smoke-test.log - Exit code = number of unfixed failures (0 = all pass)
Built-in Tests
| # | Test | Auto-Fix |
|---|---|---|
| 1 | Bun runtime | Install from bun.sh |
| 2 | GBrain CLI loads | Reinstall deps |
| 3 | GBrain database (engine identity via gbrain engine status --json, then doctor --json's connection check) |
gbrain db-repair --yes, re-test |
| 4 | GBrain worker process | — (native supervisor status + duplicate detection) |
| 5 | OpenClaw Codex plugin (Zod CJS); skips if OpenClaw absent | npm install zod@4 --force |
| 6 | OpenClaw gateway; skips if OpenClaw absent | — (may not be started yet) |
| 7 | Embedding API key | — (check .env) |
| 8 | Brain repo exists | — |
Usage
CLI
gbrain smoke-test
This is the invocation for all installs; it resolves the test script from the installed package.
From any startup script or login hook
gbrain smoke-test >> /tmp/bootstrap.log 2>&1
From OpenClaw bootstrap (OpenClaw deployments only)
Add to your ensure-services.sh or equivalent:
bash /path/to/gbrain/scripts/smoke-test.sh >> /tmp/bootstrap.log 2>&1
From an agent
exec: gbrain smoke-test
Contributor note: inside a gbrain repo checkout you can also run the script
directly with bash scripts/smoke-test.sh.
Adding Custom Tests
Create executable scripts in ~/.gbrain/smoke-tests.d/:
# ~/.gbrain/smoke-tests.d/check-redis.sh
#!/bin/bash
redis-cli ping | grep -q PONG
Rules:
- Exit 0 = pass, non-zero = fail
- Filename becomes the test name (e.g.
check-redisfromcheck-redis.sh) - Keep tests fast (< 10s each)
- Tests run in alphabetical order
Adding Built-in Tests (gbrain contributors)
This section is for contributors working in the gbrain source repo. Plugin
installs ship the script read-only and upgrades overwrite it; if you just want
extra checks, use the ~/.gbrain/smoke-tests.d/ drop-in scripts above.
Edit scripts/smoke-test.sh. Follow this pattern:
# ── N. [Service Name] ──────────────────────────────────────
if [test condition]; then
pass "[Service Name]"
else
# Auto-fix attempt
[fix command]
if [re-test condition]; then
fixed "[What was fixed]"
pass "[Service Name] (after fix)"
else
fail "[Service Name] — [error detail]"
fi
fi
Design rules:
- Test first — never fix without confirming broken
- Re-test after fix — verify the fix worked
- Timeout everything —
timeout Non any command that could hang - Use helpers —
pass(),fail(),fixed(),skip() - Idempotent fixes — safe to run repeatedly
- Skip gracefully —
skip()when a prerequisite is missing, don't fail
Environment Variables
| Var | Default | Description |
|---|---|---|
GBRAIN_SMOKE_LOG |
/tmp/gbrain-smoke-test.log |
Log file path |
GBRAIN_DIR_OVERRIDE |
(auto-detect) | Force gbrain install path |
GBRAIN_BUN_PATH |
(auto-detect) | Force Bun binary path |
GBRAIN_DATABASE_URL |
(from .env) | Database connection URL |
GBRAIN_SMOKE_WORKER_PID_FILE |
/tmp/gbrain-worker.pid |
Legacy bare-worker PID path |
OPENCLAW_GATEWAY_PORT |
18789 |
Gateway port to test |
GBRAIN_BRAIN_PATH |
(deployment-specific) | Brain repo path. Container deployments default to /data/brain; set it to your brain repo path otherwise. Test 8 skips (not fails) when unset. |
Known Issues & Their Auto-Fixes
Codex Zod core.cjs Missing (discovered 2026-04-23)
(OpenClaw gateway deployments only: this concerns OpenClaw's Codex ACP plugin, not the OpenAI Codex CLI.)
- Symptom:
Cannot find module './core.cjs'→ all Codex ACP sessions fail - Cause: Zod v4 npm package ships without
core.cjsin some installs - Auto-fix:
npm install zod@4 --forcein the codex extension's zod dir - Persistence: Does NOT survive container restart (gateway reinstalls deps)
- This is why smoke tests must run on every rest
常见问题
它会启动后台服务吗?
不会。它只报告工作进程的状态,不会自行启动守护进程。
我能添加自己的检查吗?
能。额外的测试脚本可以放在一个文件夹中,与标准测试一起运行。
结果记录在哪里?
结果会写入日志文件,退出代码会显示仍有多少问题未被修复。
详情
作者的原始描述
Health smoke tests + auto-fix for gbrain installs (and OpenClaw services when present). Run after machine/container restarts or whenever something seems broken. Tests critical services, auto-fixes bounded local issues, and reports worker topology without starting daemons. Extensible via user-defined test scripts in ~/.gbrain/smoke-tests.d/*.sh.
repo: garrytan/gbrain
热度
- GitHub 星标
- 31k
- 排名
- #9315
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …