Tools
Prompt Logger
OpenClaw plugin for logging prompts and LLM outputs for debugging
Install
pnpm add openclaw-prompt-logger
README
# 📦 OpenClaw Prompt Logger
[](https://opensource.org/licenses/MIT)
[](https://github.com/openclaw/openclaw)
一个 OpenClaw 插件,用于在调用大模型前后打印提示和输出,方便调试。
## 🚀 功能
- **Before Prompt Build**: 在构建 prompt 之前打印上下文和 prompt 内容
- **Agent End**: 在 Agent 运行结束时打印运行状态、时长和错误信息
- **LLM Output**: 在 LLM 输出时打印模型信息、assistant 文本和 token 使用情况
## 📦 安装
### 方法 1:手动安装
将插件复制到 OpenClaw 的 `extensions` 目录:
```bash
cd /path/to/openclaw/extensions
git clone https://github.com/weiwei5297/openclaw-prompt-logger.git
```
然后在 OpenClaw 中启用插件:
```bash
cd /path/to/openclaw
pnpm openclaw plugins enable prompt-logger
pnpm openclaw gateway restart
```
### 方法 2:使用包管理器
```bash
cd /path/to/openclaw/extensions
pnpm add openclaw-prompt-logger
```
## 🛠️ 开发
### 运行测试
```bash
pnpm test
```
### 运行测试(监听模式)
```bash
pnpm test:watch
```
### 修改 Hook 逻辑
编辑 `prompt-logger.ts` 文件来修改日志格式或添加新的日志信息。
## 📁 文件结构
```
extensions/prompt-logger/
├── index.ts # 插件入口,注册 hook
├── prompt-logger.ts # Hook 处理函数实现
├── prompt-logger.test.ts # 单元测试
├── openclaw.plugin.json # 插件配置
├── package.json # NPM 包配置
└── README.md # 项目文档
```
## 🔧 配置
插件目前使用默认配置,无需额外设置。如需自定义,可以修改 `openclaw.plugin.json`。
## 🤝 贡献
欢迎提交 Issue 和 Pull Request!
1. Fork 本仓库
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
4. 推送到分支 (`git push origin feature/AmazingFeature`)
5. 开启一个 Pull Request
## 📄 许可证
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情。
## 🙏 致谢
- [OpenClaw](https://github.com/openclaw/openclaw) - 优秀的开源大模型应用框架
## 📧 联系
- GitHub: [@weiwei5297](https://github.com/weiwei5297)
- Issue: [https://github.com/weiwei5297/openclaw-prompt-logger/issues](https://github.com/weiwei5297/openclaw-prompt-logger/issues)
---
<div align="center">
<sub>Powered by OpenClaw & TypeScript</sub>
</div>
tools
Comments
Sign in to leave a comment