monoco-toolkit 0.3.12__py3-none-any.whl → 0.4.0__py3-none-any.whl

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.
Files changed (120) hide show
  1. monoco/core/automation/__init__.py +0 -11
  2. monoco/core/automation/handlers.py +108 -26
  3. monoco/core/config.py +28 -10
  4. monoco/core/daemon/__init__.py +5 -0
  5. monoco/core/daemon/pid.py +290 -0
  6. monoco/core/injection.py +86 -8
  7. monoco/core/integrations.py +0 -24
  8. monoco/core/router/__init__.py +1 -39
  9. monoco/core/router/action.py +3 -142
  10. monoco/core/scheduler/events.py +28 -2
  11. monoco/core/setup.py +9 -0
  12. monoco/core/sync.py +199 -4
  13. monoco/core/watcher/__init__.py +6 -0
  14. monoco/core/watcher/base.py +18 -1
  15. monoco/core/watcher/im.py +460 -0
  16. monoco/core/watcher/memo.py +40 -48
  17. monoco/daemon/app.py +3 -60
  18. monoco/daemon/commands.py +459 -25
  19. monoco/daemon/scheduler.py +1 -16
  20. monoco/daemon/services.py +15 -0
  21. monoco/features/agent/resources/en/AGENTS.md +14 -14
  22. monoco/features/agent/resources/en/skills/monoco_role_engineer/SKILL.md +101 -0
  23. monoco/features/agent/resources/en/skills/monoco_role_manager/SKILL.md +95 -0
  24. monoco/features/agent/resources/en/skills/monoco_role_planner/SKILL.md +177 -0
  25. monoco/features/agent/resources/en/skills/monoco_role_reviewer/SKILL.md +139 -0
  26. monoco/features/agent/resources/zh/skills/monoco_role_engineer/SKILL.md +101 -0
  27. monoco/features/agent/resources/zh/skills/monoco_role_manager/SKILL.md +95 -0
  28. monoco/features/agent/resources/zh/skills/monoco_role_planner/SKILL.md +177 -0
  29. monoco/features/agent/resources/zh/skills/monoco_role_reviewer/SKILL.md +139 -0
  30. monoco/features/hooks/__init__.py +61 -6
  31. monoco/features/hooks/commands.py +281 -271
  32. monoco/features/hooks/dispatchers/__init__.py +23 -0
  33. monoco/features/hooks/dispatchers/agent_dispatcher.py +486 -0
  34. monoco/features/hooks/dispatchers/git_dispatcher.py +478 -0
  35. monoco/features/hooks/manager.py +357 -0
  36. monoco/features/hooks/models.py +262 -0
  37. monoco/features/hooks/parser.py +322 -0
  38. monoco/features/hooks/universal_interceptor.py +503 -0
  39. monoco/features/im/__init__.py +67 -0
  40. monoco/features/im/core.py +782 -0
  41. monoco/features/im/models.py +311 -0
  42. monoco/features/issue/commands.py +65 -50
  43. monoco/features/issue/core.py +199 -99
  44. monoco/features/issue/domain_commands.py +0 -19
  45. monoco/features/issue/resources/en/AGENTS.md +17 -122
  46. monoco/features/issue/resources/hooks/agent/before-tool.sh +102 -0
  47. monoco/features/issue/resources/hooks/agent/session-start.sh +88 -0
  48. monoco/features/issue/resources/hooks/{post-checkout.sh → git/git-post-checkout.sh} +10 -9
  49. monoco/features/issue/resources/hooks/git/git-pre-commit.sh +31 -0
  50. monoco/features/issue/resources/hooks/{pre-push.sh → git/git-pre-push.sh} +7 -13
  51. monoco/features/issue/resources/zh/AGENTS.md +18 -123
  52. monoco/features/memo/cli.py +15 -64
  53. monoco/features/memo/core.py +6 -34
  54. monoco/features/memo/models.py +24 -15
  55. monoco/features/memo/resources/en/AGENTS.md +31 -0
  56. monoco/features/memo/resources/zh/AGENTS.md +28 -5
  57. monoco/main.py +5 -3
  58. {monoco_toolkit-0.3.12.dist-info → monoco_toolkit-0.4.0.dist-info}/METADATA +1 -1
  59. monoco_toolkit-0.4.0.dist-info/RECORD +170 -0
  60. monoco/core/automation/config.py +0 -338
  61. monoco/core/execution.py +0 -67
  62. monoco/core/executor/__init__.py +0 -38
  63. monoco/core/executor/agent_action.py +0 -254
  64. monoco/core/executor/git_action.py +0 -303
  65. monoco/core/executor/im_action.py +0 -309
  66. monoco/core/executor/pytest_action.py +0 -218
  67. monoco/core/router/router.py +0 -392
  68. monoco/features/agent/resources/atoms/atom-code-dev.yaml +0 -61
  69. monoco/features/agent/resources/atoms/atom-issue-lifecycle.yaml +0 -73
  70. monoco/features/agent/resources/atoms/atom-knowledge.yaml +0 -55
  71. monoco/features/agent/resources/atoms/atom-review.yaml +0 -60
  72. monoco/features/agent/resources/en/skills/monoco_atom_core/SKILL.md +0 -99
  73. monoco/features/agent/resources/en/skills/monoco_workflow_agent_engineer/SKILL.md +0 -94
  74. monoco/features/agent/resources/en/skills/monoco_workflow_agent_manager/SKILL.md +0 -93
  75. monoco/features/agent/resources/en/skills/monoco_workflow_agent_planner/SKILL.md +0 -85
  76. monoco/features/agent/resources/en/skills/monoco_workflow_agent_reviewer/SKILL.md +0 -114
  77. monoco/features/agent/resources/workflows/workflow-dev.yaml +0 -83
  78. monoco/features/agent/resources/workflows/workflow-issue-create.yaml +0 -72
  79. monoco/features/agent/resources/workflows/workflow-review.yaml +0 -94
  80. monoco/features/agent/resources/zh/roles/monoco_role_engineer.yaml +0 -49
  81. monoco/features/agent/resources/zh/roles/monoco_role_manager.yaml +0 -46
  82. monoco/features/agent/resources/zh/roles/monoco_role_planner.yaml +0 -46
  83. monoco/features/agent/resources/zh/roles/monoco_role_reviewer.yaml +0 -47
  84. monoco/features/agent/resources/zh/skills/monoco_atom_core/SKILL.md +0 -99
  85. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_engineer/SKILL.md +0 -94
  86. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_manager/SKILL.md +0 -88
  87. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_planner/SKILL.md +0 -259
  88. monoco/features/agent/resources/zh/skills/monoco_workflow_agent_reviewer/SKILL.md +0 -137
  89. monoco/features/artifact/resources/zh/skills/monoco_atom_artifact/SKILL.md +0 -278
  90. monoco/features/glossary/resources/en/skills/monoco_atom_glossary/SKILL.md +0 -35
  91. monoco/features/glossary/resources/zh/skills/monoco_atom_glossary/SKILL.md +0 -35
  92. monoco/features/hooks/adapter.py +0 -67
  93. monoco/features/hooks/core.py +0 -441
  94. monoco/features/i18n/resources/en/skills/monoco_atom_i18n/SKILL.md +0 -96
  95. monoco/features/i18n/resources/en/skills/monoco_workflow_i18n_scan/SKILL.md +0 -105
  96. monoco/features/i18n/resources/zh/skills/monoco_atom_i18n/SKILL.md +0 -96
  97. monoco/features/i18n/resources/zh/skills/monoco_workflow_i18n_scan/SKILL.md +0 -105
  98. monoco/features/issue/resources/en/skills/monoco_atom_issue/SKILL.md +0 -165
  99. monoco/features/issue/resources/en/skills/monoco_workflow_issue_creation/SKILL.md +0 -167
  100. monoco/features/issue/resources/en/skills/monoco_workflow_issue_development/SKILL.md +0 -224
  101. monoco/features/issue/resources/en/skills/monoco_workflow_issue_management/SKILL.md +0 -159
  102. monoco/features/issue/resources/en/skills/monoco_workflow_issue_refinement/SKILL.md +0 -203
  103. monoco/features/issue/resources/hooks/pre-commit.sh +0 -41
  104. monoco/features/issue/resources/zh/skills/monoco_atom_issue_lifecycle/SKILL.md +0 -190
  105. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_creation/SKILL.md +0 -167
  106. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_development/SKILL.md +0 -224
  107. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_management/SKILL.md +0 -159
  108. monoco/features/issue/resources/zh/skills/monoco_workflow_issue_refinement/SKILL.md +0 -203
  109. monoco/features/memo/resources/en/skills/monoco_atom_memo/SKILL.md +0 -77
  110. monoco/features/memo/resources/en/skills/monoco_workflow_note_processing/SKILL.md +0 -140
  111. monoco/features/memo/resources/zh/skills/monoco_atom_memo/SKILL.md +0 -77
  112. monoco/features/memo/resources/zh/skills/monoco_workflow_note_processing/SKILL.md +0 -140
  113. monoco/features/spike/resources/en/skills/monoco_atom_spike/SKILL.md +0 -76
  114. monoco/features/spike/resources/en/skills/monoco_workflow_research/SKILL.md +0 -121
  115. monoco/features/spike/resources/zh/skills/monoco_atom_spike/SKILL.md +0 -76
  116. monoco/features/spike/resources/zh/skills/monoco_workflow_research/SKILL.md +0 -121
  117. monoco_toolkit-0.3.12.dist-info/RECORD +0 -202
  118. {monoco_toolkit-0.3.12.dist-info → monoco_toolkit-0.4.0.dist-info}/WHEEL +0 -0
  119. {monoco_toolkit-0.3.12.dist-info → monoco_toolkit-0.4.0.dist-info}/entry_points.txt +0 -0
  120. {monoco_toolkit-0.3.12.dist-info → monoco_toolkit-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,278 +0,0 @@
1
- ---
2
- name: monoco_atom_artifact
3
- description: 多模态文档处理 Skill。指导 Agent 将 Office 文档转换为 PDF 并渲染为 WebP 图片,注册到 Monoco Artifact 系统。
4
- type: atom
5
- version: 1.0.0
6
- ---
7
-
8
- # Monoco Artifact: 多模态文档处理
9
-
10
- 本 Skill 指导 Agent 执行 Office 文档 → PDF → WebP 的完整转换流程,并将结果注册为 Monoco Artifact。
11
-
12
- ## 概述
13
-
14
- 多模态文档处理允许 Agent:
15
-
16
- 1. 将 Office 文档 (.docx, .xlsx, .pptx) 转换为 PDF
17
- 2. 将 PDF 页面渲染为 WebP 图片 (150 DPI)
18
- 3. 使用 Monoco CLI 注册转换产物为 Artifact
19
-
20
- ## 环境探测
21
-
22
- 在执行转换前,Agent 必须探测以下依赖:
23
-
24
- ### 1. LibreOffice (soffice)
25
-
26
- ```bash
27
- # 检查 soffice 是否可用
28
- which soffice
29
- soffice --version
30
-
31
- # 常见安装路径 (macOS)
32
- # /Applications/LibreOffice.app/Contents/MacOS/soffice
33
-
34
- # 常见安装路径 (Linux)
35
- # /usr/bin/soffice
36
- # /usr/lib/libreoffice/program/soffice
37
- ```
38
-
39
- **如果未安装**:
40
-
41
- - **macOS**: `brew install --cask libreoffice`
42
- - **Ubuntu/Debian**: `sudo apt-get install libreoffice`
43
- - **CentOS/RHEL**: `sudo yum install libreoffice`
44
-
45
- ### 2. Python 依赖
46
-
47
- ```bash
48
- # 检查 PyMuPDF (fitz)
49
- python3 -c "import fitz; print(fitz.__doc__)"
50
-
51
- # 安装依赖
52
- pip install pymupdf pillow
53
- ```
54
-
55
- ### 3. Monoco CLI
56
-
57
- ```bash
58
- # 验证 monoco 可用
59
- monoco --version
60
- ```
61
-
62
- ## 转换工作流
63
-
64
- ### 标准转换流程
65
-
66
- ```mermaid
67
- flowchart LR
68
- A[Office Doc] -->|soffice| B[PDF]
69
- B -->|fitz| C[WebP Images]
70
- C -->|monoco| D[Artifact Registry]
71
- ```
72
-
73
- ### 步骤 1: Office → PDF
74
-
75
- 使用 LibreOffice Headless 模式进行转换:
76
-
77
- ```bash
78
- # 基础转换
79
- soffice --headless --convert-to pdf --outdir /output/path /input/document.docx
80
-
81
- # 推荐参数 (高质量、安全模式)
82
- soffice \
83
- --headless \
84
- --convert-to pdf:writer_pdf_Export:ExportBookmarks=true \
85
- --outdir /output/path \
86
- /input/document.docx
87
- ```
88
-
89
- **参数说明**:
90
-
91
- - `--headless`: 无 GUI 模式,适合服务器/自动化环境
92
- - `--convert-to pdf`: 指定输出格式
93
- - `--outdir`: 输出目录
94
- - `ExportBookmarks=true`: 保留文档书签
95
-
96
- ### 步骤 2: PDF → WebP
97
-
98
- 使用 PyMuPDF (fitz) 渲染页面:
99
-
100
- ```python
101
- import fitz # PyMuPDF
102
- from pathlib import Path
103
-
104
- def pdf_to_webp(pdf_path: str, output_dir: str, dpi: int = 150) -> list[str]:
105
- """
106
- 将 PDF 页面渲染为 WebP 图片。
107
-
108
- Args:
109
- pdf_path: PDF 文件路径
110
- output_dir: 输出目录
111
- dpi: 渲染分辨率 (默认 150 DPI)
112
-
113
- Returns:
114
- 生成的 WebP 文件路径列表
115
- """
116
- doc = fitz.open(pdf_path)
117
- output_path = Path(output_dir)
118
- output_path.mkdir(parents=True, exist_ok=True)
119
-
120
- webp_files = []
121
- zoom = dpi / 72 # 72 DPI 是 PDF 默认分辨率
122
- mat = fitz.Matrix(zoom, zoom)
123
-
124
- for page_num in range(len(doc)):
125
- page = doc[page_num]
126
- pix = page.get_pixmap(matrix=mat)
127
-
128
- webp_file = output_path / f"page_{page_num + 1:03d}.webp"
129
- pix.save(str(webp_file))
130
- webp_files.append(str(webp_file))
131
-
132
- doc.close()
133
- return webp_files
134
- ```
135
-
136
- **DPI 选择指南**:
137
- | DPI | 用途 | 文件大小 |
138
- |-----|------|----------|
139
- | 72 | 预览/缩略图 | 小 |
140
- | 150 | 标准阅读 (推荐) | 中等 |
141
- | 300 | 高质量打印 | 大 |
142
-
143
- ### 步骤 3: 注册 Artifact
144
-
145
- 使用 Monoco CLI 注册产物:
146
-
147
- ```bash
148
- # 注册单个文件
149
- monoco artifact register \
150
- --file /path/to/page_001.webp \
151
- --type image/webp \
152
- --source-document original.docx \
153
- --page 1
154
-
155
- # 批量注册整个目录
156
- monoco artifact register-batch \
157
- --dir /path/to/webp/output \
158
- --pattern "*.webp" \
159
- --source-document original.docx
160
- ```
161
-
162
- > **注意**: 如果 `monoco artifact` 命令不可用,使用 `monoco project` 或文件元数据记录产物信息。
163
-
164
- ## 辅助脚本
165
-
166
- 项目提供 `scripts/doc-to-webp.py` 脚本简化转换流程:
167
-
168
- ```bash
169
- # 完整转换流程
170
- python scripts/doc-to-webp.py /path/to/document.docx --output ./artifacts --dpi 150
171
-
172
- # 仅转换特定页面
173
- python scripts/doc-to-webp.py document.docx --pages 1-5,10
174
-
175
- # 保留中间 PDF
176
- python scripts/doc-to-webp.py document.docx --keep-pdf
177
- ```
178
-
179
- ## 异常处理
180
-
181
- ### 常见问题排查
182
-
183
- #### 1. 字体缺失
184
-
185
- **症状**: PDF 中文字显示为方块或乱码
186
-
187
- **解决方案**:
188
-
189
- ```bash
190
- # macOS: 安装中文字体
191
- brew install font-noto-cjk
192
-
193
- # Linux: 安装文泉驿字体
194
- sudo apt-get install fonts-wqy-zenhei
195
-
196
- # 或使用 Docker 运行 (包含完整字体)
197
- docker run --rm -v $(pwd):/docs \
198
- linuxserver/libreoffice \
199
- soffice --headless --convert-to pdf /docs/input.docx
200
- ```
201
-
202
- #### 2. 转换锁死/超时
203
-
204
- **症状**: soffice 进程无响应
205
-
206
- **解决方案**:
207
-
208
- ```bash
209
- # 设置超时
210
- timeout 60 soffice --headless --convert-to pdf input.docx
211
-
212
- # 检查并清理僵尸进程
213
- pkill -9 soffice
214
- pkill -9 soffice.bin
215
- ```
216
-
217
- #### 3. PDF 渲染质量差
218
-
219
- **症状**: WebP 图片模糊或有锯齿
220
-
221
- **解决方案**:
222
-
223
- - 提高 DPI (建议 150-300)
224
- - 使用抗锯齿矩阵:
225
-
226
- ```python
227
- mat = fitz.Matrix(zoom, zoom).prerotate(0)
228
- pix = page.get_pixmap(matrix=mat, alpha=False)
229
- ```
230
-
231
- #### 4. 内存不足 (大文档)
232
-
233
- **症状**: 处理大 PDF 时内存溢出
234
-
235
- **解决方案**:
236
-
237
- ```python
238
- # 逐页处理,及时释放内存
239
- for page_num in range(len(doc)):
240
- page = doc[page_num]
241
- pix = page.get_pixmap(matrix=mat)
242
- pix.save(f"page_{page_num}.webp")
243
- pix = None # 显式释放
244
- page = None
245
- ```
246
-
247
- ## Agent 执行模板
248
-
249
- 当用户要求处理文档时,按以下步骤执行:
250
-
251
- ```
252
- 1. [探测] 检查 soffice 和 PyMuPDF 是否可用
253
- └─ 如果缺失 → 提示用户安装并提供命令
254
-
255
- 2. [转换] Office → PDF
256
- └─ 使用 soffice --headless --convert-to pdf
257
- └─ 验证 PDF 生成成功
258
-
259
- 3. [渲染] PDF → WebP
260
- └─ 使用 scripts/doc-to-webp.py 或内联代码
261
- └─ 默认 150 DPI,可根据需求调整
262
-
263
- 4. [注册] 调用 monoco 注册 Artifact
264
- └─ 记录 source-document 和 page 元数据
265
-
266
- 5. [汇报] 向用户展示:
267
- - 生成的文件列表
268
- - 文件大小统计
269
- - 任何警告或错误
270
- ```
271
-
272
- ## 最佳实践
273
-
274
- 1. **临时文件管理**: 使用 `tempfile.TemporaryDirectory` 管理中间文件
275
- 2. **错误重试**: 转换失败时自动重试 1-2 次
276
- 3. **并发控制**: 大文档处理时限制并发页面数
277
- 4. **元数据保留**: 始终记录原始文档名称和转换参数
278
- 5. **清理策略**: 转换完成后可选保留或删除中间 PDF
@@ -1,35 +0,0 @@
1
- ---
2
- name: monoco_atom_glossary
3
- description: Official Monoco Glossary and Operational Laws
4
- tags: [core, definition]
5
- type: atom
6
- version: 1.0.0
7
- ---
8
-
9
- # Monoco Glossary
10
-
11
- ## Core Architecture Metaphor: "Linux Distro"
12
-
13
- | Term | Definition | Metaphor |
14
- | :--------------- | :-------------------------------------------------------------------------------------------------- | :---------------------------------- |
15
- | **Monoco** | The Agent Operating System Distribution. Managed policy, workflow, and package system. | **Distro** (e.g., Ubuntu, Arch) |
16
- | **Kimi CLI** | The core runtime execution engine. Handles LLM interaction, tool execution, and process management. | **Kernel** (Linux Kernel) |
17
- | **Session** | An initialized instance of the Agent Kernel, managed by Monoco. Has state and context. | **Init System / Daemon** (systemd) |
18
- | **Issue** | An atomic unit of work with state (Open/Done) and strict lifecycle. | **Unit File** (systemd unit) |
19
- | **Skill** | A package of capabilities (tools, prompts, flows) that extends the Agent. | **Package** (apt/pacman package) |
20
- | **Context File** | Configuration files (e.g., `GEMINI.md`, `AGENTS.md`) defining environment rules and preferences. | **Config** (`/etc/config`) |
21
- | **Agent Client** | The user interface connecting to Monoco (CLI, VSCode, Zed). | **Desktop Environment** (GNOME/KDE) |
22
-
23
- ## Key Concepts
24
-
25
- ### Context File
26
-
27
- Files like `GEMINI.md` that provide the "Constitution" for the Agent. They define the role, scope, and behavioral policies of the Agent within a specific context (Root, Directory, Project).
28
-
29
- ### Headless
30
-
31
- Monoco is designed to run without a native GUI. It exposes its capabilities via standard protocols (LSP, ACP) to be consumed by various Clients (IDEs, Terminals).
32
-
33
- ### Universal Shell
34
-
35
- The concept that the CLI is the universal interface for all workflows. Monoco acts as an intelligent layer over the shell.
@@ -1,35 +0,0 @@
1
- ---
2
- name: monoco_atom_glossary
3
- description: Monoco 官方术语表和操作法则
4
- tags: [core, definition]
5
- type: atom
6
- version: 1.0.0
7
- ---
8
-
9
- # Monoco 术语表
10
-
11
- ## 核心架构隐喻: "Linux 发行版"
12
-
13
- | 术语 | 定义 | 隐喻 |
14
- | :--- | :--- | :--- |
15
- | **Monoco** | 智能体操作系统发行版。管理策略、工作流和包系统。 | **发行版** (如 Ubuntu, Arch) |
16
- | **Kimi CLI** | 核心运行时执行引擎。处理 LLM 交互、工具执行和进程管理。 | **内核** (Linux Kernel) |
17
- | **Session** | 由 Monoco 管理的智能体内核初始化实例。具有状态和上下文。 | **初始化系统/守护进程** (systemd) |
18
- | **Issue** | 具有状态(Open/Done)和严格生命周期的原子工作单元。 | **单元文件** (systemd unit) |
19
- | **Skill** | 扩展智能体功能的工具、提示词和流程包。 | **软件包** (apt/pacman package) |
20
- | **Context File** | 定义环境规则和行为偏好的配置文件(如 `GEMINI.md`, `AGENTS.md`)。 | **配置** (`/etc/config`) |
21
- | **Agent Client** | 连接 Monoco 的用户界面(CLI, VSCode, Zed)。 | **桌面环境** (GNOME/KDE) |
22
-
23
- ## 关键概念
24
-
25
- ### Context File
26
-
27
- 像 `GEMINI.md` 这样的文件,为智能体提供"宪法"。它们定义了特定上下文(根目录、目录、项目)中智能体的角色、范围和行为策略。
28
-
29
- ### Headless
30
-
31
- Monoco 设计为无需原生 GUI 即可运行。它通过标准协议(LSP, ACP)暴露其能力,供各种客户端(IDE、终端)使用。
32
-
33
- ### Universal Shell
34
-
35
- CLI 是所有工作流的通用接口的概念。Monoco 作为 shell 的智能层。
@@ -1,67 +0,0 @@
1
- """
2
- Feature adapter for Git Hooks management.
3
-
4
- Integrates with Monoco's feature loading system.
5
- """
6
-
7
- from pathlib import Path
8
- from typing import Dict
9
-
10
- from monoco.core.loader import FeatureModule, FeatureMetadata
11
- from monoco.core.feature import IntegrationData
12
-
13
- from .core import GitHooksManager, HookConfig
14
-
15
-
16
- class HooksFeature(FeatureModule):
17
- """Git Hooks management feature module."""
18
-
19
- @property
20
- def metadata(self) -> FeatureMetadata:
21
- return FeatureMetadata(
22
- name="hooks",
23
- version="1.0.0",
24
- description="Git hooks management for Monoco development workflow",
25
- dependencies=["core"],
26
- priority=5, # Load early to be available for other features
27
- )
28
-
29
- def _on_mount(self, context: "FeatureContext") -> None: # type: ignore
30
- """Initialize hooks feature with workspace context."""
31
- # Hooks are installed on-demand via CLI commands
32
- pass
33
-
34
- def integrate(self, root: Path, config: Dict) -> IntegrationData:
35
- """Provide integration data for agent environment."""
36
- # Read hooks-specific prompts if available
37
- base_dir = Path(__file__).parent / "resources"
38
- prompt_file = base_dir / "AGENTS.md"
39
-
40
- content = ""
41
- if prompt_file.exists():
42
- content = prompt_file.read_text(encoding="utf-8").strip()
43
-
44
- return IntegrationData(system_prompts={"Git Hooks": content})
45
-
46
- def create_manager(self, project_root: Path, config: Dict) -> GitHooksManager:
47
- """
48
- Create a GitHooksManager instance from configuration.
49
-
50
- Args:
51
- project_root: Project root directory
52
- config: Configuration dictionary (from workspace.yaml)
53
-
54
- Returns:
55
- Configured GitHooksManager instance
56
- """
57
- hooks_config = config.get("hooks", {})
58
- hook_config = HookConfig(
59
- enabled=hooks_config.get("enabled", True),
60
- enabled_features=hooks_config.get("features", {}),
61
- enabled_hooks=hooks_config.get("hooks", {
62
- "pre-commit": True,
63
- "pre-push": False,
64
- "post-checkout": False,
65
- }),
66
- )
67
- return GitHooksManager(project_root, hook_config)