hook-deployer 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hook_deployer-1.0.0/LICENSE +21 -0
- hook_deployer-1.0.0/MANIFEST.in +7 -0
- hook_deployer-1.0.0/PKG-INFO +394 -0
- hook_deployer-1.0.0/README.md +371 -0
- hook_deployer-1.0.0/core/__init__.py +3 -0
- hook_deployer-1.0.0/core/exceptions.py +57 -0
- hook_deployer-1.0.0/core/hook_manager.py +55 -0
- hook_deployer-1.0.0/core/installer.py +199 -0
- hook_deployer-1.0.0/core/logger.py +109 -0
- hook_deployer-1.0.0/core/plugin_base.py +57 -0
- hook_deployer-1.0.0/hook_deployer.egg-info/PKG-INFO +394 -0
- hook_deployer-1.0.0/hook_deployer.egg-info/SOURCES.txt +34 -0
- hook_deployer-1.0.0/hook_deployer.egg-info/dependency_links.txt +1 -0
- hook_deployer-1.0.0/hook_deployer.egg-info/entry_points.txt +2 -0
- hook_deployer-1.0.0/hook_deployer.egg-info/not-zip-safe +1 -0
- hook_deployer-1.0.0/hook_deployer.egg-info/requires.txt +5 -0
- hook_deployer-1.0.0/hook_deployer.egg-info/top_level.txt +3 -0
- hook_deployer-1.0.0/plugins/__init__.py +5 -0
- hook_deployer-1.0.0/plugins/openclaw/__init__.py +5 -0
- hook_deployer-1.0.0/plugins/openclaw/plugin.py +143 -0
- hook_deployer-1.0.0/plugins/session_end/__init__.py +5 -0
- hook_deployer-1.0.0/plugins/session_end/plugin.py +140 -0
- hook_deployer-1.0.0/pyproject.toml +31 -0
- hook_deployer-1.0.0/requirements.txt +1 -0
- hook_deployer-1.0.0/setup.cfg +4 -0
- hook_deployer-1.0.0/setup.py +55 -0
- hook_deployer-1.0.0/tests/__init__.py +1 -0
- hook_deployer-1.0.0/tests/test_bootstrap.py +183 -0
- hook_deployer-1.0.0/tests/test_exceptions.py +59 -0
- hook_deployer-1.0.0/tests/test_hook_manager.py +62 -0
- hook_deployer-1.0.0/tests/test_installer.py +110 -0
- hook_deployer-1.0.0/tests/test_integration.py +214 -0
- hook_deployer-1.0.0/tests/test_logger.py +61 -0
- hook_deployer-1.0.0/tests/test_openclaw_plugin.py +81 -0
- hook_deployer-1.0.0/tests/test_plugin_base.py +63 -0
- hook_deployer-1.0.0/tests/test_session_end_plugin.py +76 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hook Deployer Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hook-deployer
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: AI 对话历史自动存档工具
|
|
5
|
+
Home-page: https://github.com/openclaw/hook-deployer
|
|
6
|
+
Author: Hook Deployer Team
|
|
7
|
+
Author-email: Hook Deployer Team <contact@hook-deployer.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/openclaw/hook-deployer
|
|
10
|
+
Project-URL: Bug Reports, https://github.com/openclaw/hook-deployer/issues
|
|
11
|
+
Project-URL: Source, https://github.com/openclaw/hook-deployer
|
|
12
|
+
Requires-Python: >=3.8
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: click>=8.0.0
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: home-page
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
Dynamic: requires-python
|
|
23
|
+
|
|
24
|
+
# Hook Deployer
|
|
25
|
+
|
|
26
|
+
> AI 对话历史自动存档工具
|
|
27
|
+
|
|
28
|
+
Hook Deployer 是一个 Python 命令行工具,可以自动为你的项目配置 Claude Code、Cursor、CodeBuddy、OpenClaw 等开发工具的 Hook,在每次对话结束时自动保存完整的对话历史记录。
|
|
29
|
+
|
|
30
|
+
## ✨ 特性
|
|
31
|
+
|
|
32
|
+
* 🚀 **零配置**: 一条命令完成所有 IDE 的 Hook 部署
|
|
33
|
+
* 🔌 **多 IDE 兼容**: 支持 Claude Code、Cursor、CodeBuddy、OpenClaw 等主流工具
|
|
34
|
+
* 📝 **历史可追溯**: 每次对话独立存档,便于检索和分析
|
|
35
|
+
* 🎯 **插件化架构**: 微内核设计,易于扩展新功能
|
|
36
|
+
* 🔄 **自举测试**: 支持使用 hook-deployer 保存自身对话历史
|
|
37
|
+
|
|
38
|
+
## 📦 安装
|
|
39
|
+
|
|
40
|
+
### 从 PyPI 安装(推荐)
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install hook-deployer
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 从源码安装
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone https://github.com/yourusername/hook-deployer.git
|
|
50
|
+
cd hook-deployer
|
|
51
|
+
pip install -e .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 🚀 快速开始
|
|
55
|
+
|
|
56
|
+
### 1. 安装 Hook
|
|
57
|
+
|
|
58
|
+
在项目根目录执行:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
hook-deployer install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
这将自动检测项目中使用的 IDE 并配置对应的 Hook。
|
|
65
|
+
|
|
66
|
+
### 2. 指定输出目录
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
hook-deployer install --output-dir .ai-history
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. 强制重新安装
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
hook-deployer install --force
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 4. 查看详细日志
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
hook-deployer install --verbose
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 📋 命令
|
|
85
|
+
|
|
86
|
+
### install
|
|
87
|
+
|
|
88
|
+
安装 Hook 脚本到当前项目。
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
hook-deployer install [OPTIONS]
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**选项:**
|
|
95
|
+
|
|
96
|
+
* `--output-dir <路径>`: 对话历史存储目录(默认: `.ai-conversations`)
|
|
97
|
+
* `--force`: 强制覆盖已存在的配置
|
|
98
|
+
* `--verbose, -v`: 显示详细日志
|
|
99
|
+
|
|
100
|
+
### uninstall
|
|
101
|
+
|
|
102
|
+
移除当前项目的 Hook 配置。
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
hook-deployer uninstall [OPTIONS]
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**选项:**
|
|
109
|
+
|
|
110
|
+
* `--verbose, -v`: 显示详细日志
|
|
111
|
+
|
|
112
|
+
### list
|
|
113
|
+
|
|
114
|
+
列出当前项目的 IDE 和 Hook 状态。
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
hook-deployer list [OPTIONS]
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**选项:**
|
|
121
|
+
|
|
122
|
+
* `--verbose, -v`: 显示详细日志
|
|
123
|
+
|
|
124
|
+
### config
|
|
125
|
+
|
|
126
|
+
查看或修改当前项目的 Hook 配置。
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
hook-deployer config [OPTIONS]
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**选项:**
|
|
133
|
+
|
|
134
|
+
* `--key <配置项>`: 配置项名称
|
|
135
|
+
* `--value <值>`: 配置项值
|
|
136
|
+
* `--verbose, -v`: 显示详细日志
|
|
137
|
+
|
|
138
|
+
**示例:**
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# 查看完整配置
|
|
142
|
+
hook-deployer config
|
|
143
|
+
|
|
144
|
+
# 查看特定配置项
|
|
145
|
+
hook-deployer config --key version
|
|
146
|
+
|
|
147
|
+
# 更新配置项
|
|
148
|
+
hook-deployer config --key version --value 2.0.0
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## 📁 对话历史格式
|
|
152
|
+
|
|
153
|
+
对话历史以 Markdown 格式保存到指定目录,文件名格式为:`YYYYMMDD_HHMMSS_sessionId.md`
|
|
154
|
+
|
|
155
|
+
### Claude Code / Cursor / CodeBuddy 格式
|
|
156
|
+
|
|
157
|
+
```markdown
|
|
158
|
+
# 对话历史
|
|
159
|
+
|
|
160
|
+
**时间**: 2026-03-01T15:30:22+08:00
|
|
161
|
+
**工具**: Claude Code
|
|
162
|
+
**工作目录**: /path/to/project
|
|
163
|
+
**会话 ID**: abc123
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 对话内容
|
|
168
|
+
|
|
169
|
+
[此处为完整对话文本]
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### OpenClaw 格式
|
|
173
|
+
|
|
174
|
+
```markdown
|
|
175
|
+
# OpenClaw 对话历史
|
|
176
|
+
|
|
177
|
+
**时间**: 2026-03-01T15:30:22+08:00
|
|
178
|
+
**会话 ID**: ou_a7a583dc5002d3ae942f07a63e465a0d
|
|
179
|
+
**渠道**: feishu
|
|
180
|
+
**提供方**: feishu
|
|
181
|
+
**聊天 ID**: user:ou_a7a583dc5002d3ae942f07a63e465a0d
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## 用户消息
|
|
186
|
+
|
|
187
|
+
用户输入的消息内容...
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## AI 响应
|
|
192
|
+
|
|
193
|
+
AI 的响应内容...
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## 完整对话历史
|
|
198
|
+
|
|
199
|
+
完整的对话历史内容...
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
*由 hook-deployer 自动保存*
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## 🏗️ 架构
|
|
207
|
+
|
|
208
|
+
Hook Deployer 采用微内核 + 插件化架构:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
hook-deployer/
|
|
212
|
+
├── core/ # 核心引擎
|
|
213
|
+
│ ├── hook_manager.py # Hook 生命周期管理
|
|
214
|
+
│ └── installer.py # IDE 配置安装器
|
|
215
|
+
├── plugins/ # 插件目录
|
|
216
|
+
│ ├── session_end/ # SessionEnd 插件
|
|
217
|
+
│ └── openclaw/ # OpenClaw 插件
|
|
218
|
+
└── cli.py # CLI 入口
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### 支持的 IDE
|
|
222
|
+
|
|
223
|
+
| IDE / 工具 | Hook 事件 | 状态 |
|
|
224
|
+
|-----------|----------|------|
|
|
225
|
+
| Claude Code | SessionEnd | ✅ |
|
|
226
|
+
| Cursor | sessionEnd | ✅ |
|
|
227
|
+
| CodeBuddy | onSessionEnd | ✅ |
|
|
228
|
+
| OpenClaw | OpenClawSessionEnd | ✅ |
|
|
229
|
+
| Cline | session_end | 🚧 |
|
|
230
|
+
|
|
231
|
+
## 🔧 开发
|
|
232
|
+
|
|
233
|
+
### 本地开发
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
# 克隆仓库
|
|
237
|
+
git clone https://github.com/yourusername/hook-deployer.git
|
|
238
|
+
cd hook-deployer
|
|
239
|
+
|
|
240
|
+
# 安装依赖
|
|
241
|
+
pip install -e .
|
|
242
|
+
|
|
243
|
+
# 运行测试
|
|
244
|
+
pytest
|
|
245
|
+
|
|
246
|
+
# 运行自举测试
|
|
247
|
+
pytest tests/test_bootstrap.py -v
|
|
248
|
+
|
|
249
|
+
# 运行测试覆盖率
|
|
250
|
+
pytest --cov=core --cov=plugins --cov=cli --cov-report=term-missing
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### OpenClaw 支持
|
|
254
|
+
|
|
255
|
+
hook-deployer 现在完全支持 OpenClaw 对话历史自动保存。详细信息请查看 [OpenClaw 支持文档](./OPENCLAW_SUPPORT.md)。
|
|
256
|
+
|
|
257
|
+
### 添加新插件
|
|
258
|
+
|
|
259
|
+
1. 在 `plugins/` 目录下创建新插件目录
|
|
260
|
+
2. 实现 `HookPlugin` 接口
|
|
261
|
+
3. 在 `cli.py` 中注册插件
|
|
262
|
+
|
|
263
|
+
示例:
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
from core.plugin_base import HookPlugin
|
|
267
|
+
from pathlib import Path
|
|
268
|
+
from typing import List, Dict
|
|
269
|
+
|
|
270
|
+
class MyPlugin(HookPlugin):
|
|
271
|
+
@property
|
|
272
|
+
def event_name(self) -> str:
|
|
273
|
+
return "MyEvent"
|
|
274
|
+
|
|
275
|
+
@property
|
|
276
|
+
def supported_ides(self) -> List[str]:
|
|
277
|
+
return ["claude", "cursor"]
|
|
278
|
+
|
|
279
|
+
def generate_script(self, output_dir: Path) -> Path:
|
|
280
|
+
# 生成脚本逻辑
|
|
281
|
+
pass
|
|
282
|
+
|
|
283
|
+
def get_config(self, ide: str, script_path: Path) -> Dict:
|
|
284
|
+
# 返回 IDE 配置
|
|
285
|
+
pass
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## 🧪 测试
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
# 运行所有测试
|
|
292
|
+
pytest
|
|
293
|
+
|
|
294
|
+
# 运行特定测试文件
|
|
295
|
+
pytest tests/test_openclaw_plugin.py
|
|
296
|
+
|
|
297
|
+
# 运行自举测试
|
|
298
|
+
pytest tests/test_bootstrap.py -v
|
|
299
|
+
|
|
300
|
+
# 生成测试覆盖率报告
|
|
301
|
+
pytest --cov=core --cov=plugins --cov=cli --cov-report=html
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**测试结果:**
|
|
305
|
+
|
|
306
|
+
- 总测试数: 45
|
|
307
|
+
- 通过: 45 ✅
|
|
308
|
+
- 失败: 0
|
|
309
|
+
- 覆盖率: 81%
|
|
310
|
+
|
|
311
|
+
## 📖 使用场景
|
|
312
|
+
|
|
313
|
+
### 1. 个人知识库
|
|
314
|
+
|
|
315
|
+
自动保存所有与 AI 的对话,构建个人知识库,便于后续回顾和学习。
|
|
316
|
+
|
|
317
|
+
### 2. 团队协作
|
|
318
|
+
|
|
319
|
+
团队成员共享对话历史,便于知识共享和团队学习。
|
|
320
|
+
|
|
321
|
+
### 3. 模型训练
|
|
322
|
+
|
|
323
|
+
收集大量真实对话数据,用于模型微调或数据分析。
|
|
324
|
+
|
|
325
|
+
### 4. 合规审计
|
|
326
|
+
|
|
327
|
+
保存所有 AI 对话记录,满足合规和审计要求。
|
|
328
|
+
|
|
329
|
+
## 🔧 配置
|
|
330
|
+
|
|
331
|
+
### 项目配置文件
|
|
332
|
+
|
|
333
|
+
Hook Deployer 在项目根目录创建 `.hook-deployer/config.json` 配置文件:
|
|
334
|
+
|
|
335
|
+
```json
|
|
336
|
+
{
|
|
337
|
+
"version": "1.0.0",
|
|
338
|
+
"output_dir": ".ai-conversations",
|
|
339
|
+
"enabled_ides": ["claude", "cursor"],
|
|
340
|
+
"hook_scripts": {
|
|
341
|
+
"claude": ".ai-conversations/session-end.sh",
|
|
342
|
+
"cursor": ".ai-conversations/session-end.sh"
|
|
343
|
+
},
|
|
344
|
+
"installed_at": "2026-03-01T05:00:00Z"
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### 环境变量
|
|
349
|
+
|
|
350
|
+
- `HOOK_DEPLOYER_LOG_LEVEL`: 日志级别(DEBUG, INFO, WARNING, ERROR, CRITICAL)
|
|
351
|
+
- `HOOK_DEPLOYER_OUTPUT_DIR`: 默认输出目录
|
|
352
|
+
|
|
353
|
+
## 🤝 贡献
|
|
354
|
+
|
|
355
|
+
欢迎提交 Issue 和 Pull Request!
|
|
356
|
+
|
|
357
|
+
1. Fork 本仓库
|
|
358
|
+
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
|
|
359
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
360
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
361
|
+
5. 开启 Pull Request
|
|
362
|
+
|
|
363
|
+
### 开发指南
|
|
364
|
+
|
|
365
|
+
- 遵循现有代码风格
|
|
366
|
+
- 添加测试覆盖新功能
|
|
367
|
+
- 更新相关文档
|
|
368
|
+
- 确保所有测试通过
|
|
369
|
+
|
|
370
|
+
## 📄 许可证
|
|
371
|
+
|
|
372
|
+
本项目采用 MIT 许可证 - 详见 [LICENSE](LICENSE) 文件
|
|
373
|
+
|
|
374
|
+
## 🔗 相关链接
|
|
375
|
+
|
|
376
|
+
* [Claude Code Hooks 文档](https://docs.anthropic.com/claude/code/hooks)
|
|
377
|
+
* [Cursor Hooks 文档](https://cursor.sh/docs/hooks)
|
|
378
|
+
* [CodeBuddy 自定义脚本](https://codebuddy.dev/docs/hooks)
|
|
379
|
+
* [OpenClaw 支持文档](./OPENCLAW_SUPPORT.md)
|
|
380
|
+
* [产品需求文档](./PRD.md)
|
|
381
|
+
* [架构设计文档](./ARCHITECTURE.md)
|
|
382
|
+
* [QA 测试用例](./docs/QA_TEST_CASES.md)
|
|
383
|
+
|
|
384
|
+
## 📝 变更日志
|
|
385
|
+
|
|
386
|
+
详见 [CHANGELOG.md](./docs/CHANGELOG.md)
|
|
387
|
+
|
|
388
|
+
## 🙏 致谢
|
|
389
|
+
|
|
390
|
+
感谢所有为本项目做出贡献的开发者!
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
**Made with ❤️ by Hook Deployer Team**
|