src/agents/)的开发工作流。
类型检查和 lint
- 默认本地门禁:
pnpm check(typecheck、lint、policy guards) - 构建门禁:当更改可能影响构建输出、打包或懒加载/模块边界时,运行
pnpm build - 完整的预推送门禁:
pnpm build && pnpm check && pnpm check:test-types && pnpm test
运行 Agent Runtime 测试
运行 agent runtime 单元测试套件:agent-tools*、agent-settings 和
agent-tool-definition-adapter* 套件。
Live 测试不包含在单元测试配置中;请通过 live
wrapper 运行它们(会设置 OPENCLAW_LIVE_TEST=1,并且需要提供方凭据):
手动测试
- 在开发模式下运行 Gateway(通过
OPENCLAW_SKIP_CHANNELS=1跳过频道连接):pnpm gateway:dev - 通过 Gateway 触发一次 agent 轮次:
pnpm openclaw agent --message "Hello" --thinking low - 使用 TUI 进行交互式调试:
pnpm tui
read 或 exec 操作,这样你就可以观察
工具流式传输和负载处理。
清理并重置状态
状态保存在 OpenClaw 状态目录中:默认情况下为~/.openclaw,或者当设置了 $OPENCLAW_STATE_DIR 时为该路径。相对于该目录的路径如下:
删除这些路径即可完全重置。更精简的重置方式:
- 仅会话:不要删除
agents/<agentId>/agent/openclaw-agent.sqlite;会话行与其他每个代理的状态一起保存在那里。使用/new或/reset为单个聊天开始一个新会话,并使用openclaw sessions cleanup进行会话维护。 - 保留认证:保留
agents/<agentId>/agent/openclaw-agent.sqlite和credentials/。
auth-profiles.json 文件在运行时不再读取;
openclaw doctor --fix 会将它们导入到 SQLite 存储中。