@tencent-ai/agent-sdk 0.3.99 → 0.3.101

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 (471) hide show
  1. package/cli/CHANGELOG.md +50 -0
  2. package/cli/dist/codebuddy-headless.js +140 -131
  3. package/cli/dist/web-ui/assets/index-CIqmZV3y.js +440 -0
  4. package/cli/dist/web-ui/assets/index-Dt1puyHn.css +32 -0
  5. package/cli/dist/web-ui/docs/cn/cli/acp.md +152 -0
  6. package/cli/dist/web-ui/docs/cn/cli/agent-teams.md +327 -0
  7. package/cli/dist/web-ui/docs/cn/cli/bash-sandboxing.md +290 -0
  8. package/cli/dist/web-ui/docs/cn/cli/best-practices.md +554 -0
  9. package/cli/dist/web-ui/docs/cn/cli/channels-reference.md +293 -0
  10. package/cli/dist/web-ui/docs/cn/cli/channels.md +215 -0
  11. package/cli/dist/web-ui/docs/cn/cli/checkpointing.md +51 -0
  12. package/cli/dist/web-ui/docs/cn/cli/cli-reference.md +187 -0
  13. package/cli/dist/web-ui/docs/cn/cli/common-workflows.md +1013 -0
  14. package/cli/dist/web-ui/docs/cn/cli/costs.md +174 -0
  15. package/cli/dist/web-ui/docs/cn/cli/devcontainer.md +553 -0
  16. package/cli/dist/web-ui/docs/cn/cli/env-vars.md +326 -0
  17. package/cli/dist/web-ui/docs/cn/cli/gitlab-ci-cd.md +357 -0
  18. package/cli/dist/web-ui/docs/cn/cli/headless.md +258 -0
  19. package/cli/dist/web-ui/docs/cn/cli/hooks-guide.md +9 -0
  20. package/cli/dist/web-ui/docs/cn/cli/hooks.md +805 -0
  21. package/cli/dist/web-ui/docs/cn/cli/iam.md +530 -0
  22. package/cli/dist/web-ui/docs/cn/cli/ide-integrations.md +92 -0
  23. package/cli/dist/web-ui/docs/cn/cli/installation.md +291 -0
  24. package/cli/dist/web-ui/docs/cn/cli/interactive-mode.md +233 -0
  25. package/cli/dist/web-ui/docs/cn/cli/mcp.md +739 -0
  26. package/cli/dist/web-ui/docs/cn/cli/memory.md +436 -0
  27. package/cli/dist/web-ui/docs/cn/cli/models.md +356 -0
  28. package/cli/dist/web-ui/docs/cn/cli/overview.md +100 -0
  29. package/cli/dist/web-ui/docs/cn/cli/plugin-marketplaces.md +533 -0
  30. package/cli/dist/web-ui/docs/cn/cli/plugins-reference.md +774 -0
  31. package/cli/dist/web-ui/docs/cn/cli/plugins.md +689 -0
  32. package/cli/dist/web-ui/docs/cn/cli/quickstart.md +249 -0
  33. package/cli/dist/web-ui/docs/cn/cli/release-notes/README.md +200 -0
  34. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.0.md +23 -0
  35. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.10.1.md +5 -0
  36. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.11.0.md +24 -0
  37. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.12.0.md +21 -0
  38. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.13.0.md +20 -0
  39. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.0.md +22 -0
  40. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.14.1.md +8 -0
  41. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.0.md +18 -0
  42. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.15.1.md +11 -0
  43. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.16.0.md +20 -0
  44. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.17.0.md +29 -0
  45. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.18.0.md +17 -0
  46. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.0.md +11 -0
  47. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.1.md +14 -0
  48. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.19.2.md +11 -0
  49. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.0.md +23 -0
  50. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.20.1.md +15 -0
  51. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.21.0.md +13 -0
  52. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.22.0.md +16 -0
  53. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.0.md +20 -0
  54. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.2.md +5 -0
  55. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.3.md +5 -0
  56. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.4.md +15 -0
  57. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.23.5.md +11 -0
  58. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.24.0.md +17 -0
  59. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.0.md +18 -0
  60. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.25.1.md +21 -0
  61. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.26.0.md +18 -0
  62. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.0.md +16 -0
  63. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.1.md +16 -0
  64. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.2.md +7 -0
  65. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.27.3.md +15 -0
  66. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.0.md +26 -0
  67. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.28.1.md +5 -0
  68. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.29.0.md +35 -0
  69. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.3.1.md +16 -0
  70. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.0.md +19 -0
  71. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.30.1.md +5 -0
  72. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.0.md +51 -0
  73. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.1.md +11 -0
  74. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.31.2.md +16 -0
  75. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.32.0.md +19 -0
  76. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.0.md +28 -0
  77. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.33.1.md +7 -0
  78. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.36.3.md +17 -0
  79. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.0.md +15 -0
  80. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.1.md +15 -0
  81. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.10.md +5 -0
  82. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.11.md +8 -0
  83. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.12.md +14 -0
  84. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.13.md +11 -0
  85. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.14.md +24 -0
  86. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.15.md +11 -0
  87. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.16.md +9 -0
  88. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.17.md +5 -0
  89. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.18.md +9 -0
  90. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.19.md +5 -0
  91. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.2.md +28 -0
  92. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.20.md +8 -0
  93. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.3.md +22 -0
  94. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.4.md +19 -0
  95. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.5.md +5 -0
  96. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.6.md +5 -0
  97. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.7.md +5 -0
  98. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.8.md +5 -0
  99. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.37.9.md +8 -0
  100. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.0.md +22 -0
  101. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.1.md +6 -0
  102. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.38.2.md +9 -0
  103. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.39.0.md +18 -0
  104. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.4.0.md +19 -0
  105. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.0.md +20 -0
  106. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.40.1.md +6 -0
  107. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.0.md +15 -0
  108. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.1.md +6 -0
  109. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.2.md +5 -0
  110. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.3.md +8 -0
  111. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.4.md +5 -0
  112. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.5.md +10 -0
  113. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.6.md +9 -0
  114. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.7.md +14 -0
  115. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.41.8.md +18 -0
  116. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.0.md +39 -0
  117. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.1.md +8 -0
  118. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.42.3.md +18 -0
  119. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.0.md +27 -0
  120. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.43.1.md +27 -0
  121. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.0.md +11 -0
  122. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.44.1.md +22 -0
  123. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.0.md +34 -0
  124. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.45.1.md +7 -0
  125. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.46.0.md +12 -0
  126. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.47.0.md +20 -0
  127. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.0.md +32 -0
  128. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.48.1.md +11 -0
  129. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.0.md +26 -0
  130. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.1.md +14 -0
  131. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.2.md +39 -0
  132. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.3.md +7 -0
  133. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.5.md +11 -0
  134. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.6.md +9 -0
  135. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.49.7.md +7 -0
  136. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.5.0.md +24 -0
  137. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.0.md +25 -0
  138. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.1.md +9 -0
  139. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.2.md +11 -0
  140. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.3.md +5 -0
  141. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.4.md +17 -0
  142. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.5.md +16 -0
  143. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.6.md +15 -0
  144. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.50.7.md +15 -0
  145. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.0.md +24 -0
  146. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.1.md +17 -0
  147. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.51.2.md +5 -0
  148. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.0.md +30 -0
  149. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.1.md +28 -0
  150. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.2.md +12 -0
  151. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.3.md +13 -0
  152. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.4.md +27 -0
  153. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.5.md +21 -0
  154. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.52.6.md +7 -0
  155. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.53.0.md +29 -0
  156. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.54.0.md +26 -0
  157. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.0.md +21 -0
  158. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.55.1.md +13 -0
  159. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.0.md +20 -0
  160. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.56.1.md +5 -0
  161. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.0.md +32 -0
  162. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.57.1.md +10 -0
  163. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.58.0.md +34 -0
  164. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.59.0.md +28 -0
  165. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.0.md +5 -0
  166. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.6.1.md +10 -0
  167. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.60.0.md +20 -0
  168. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.0.md +29 -0
  169. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.1.md +5 -0
  170. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.2.md +6 -0
  171. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.61.3.md +13 -0
  172. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.0.md +21 -0
  173. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.62.1.md +11 -0
  174. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.0.md +19 -0
  175. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.1.md +5 -0
  176. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.2.md +7 -0
  177. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.3.md +6 -0
  178. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.4.md +8 -0
  179. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.63.5.md +6 -0
  180. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.0.md +37 -0
  181. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.1.md +6 -0
  182. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.64.2.md +11 -0
  183. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.0.md +19 -0
  184. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.65.1.md +11 -0
  185. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.0.md +15 -0
  186. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.1.md +14 -0
  187. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.66.2.md +5 -0
  188. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.67.0.md +33 -0
  189. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.68.0.md +28 -0
  190. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.7.0.md +16 -0
  191. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.0.md +18 -0
  192. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.1.md +17 -0
  193. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.2.md +5 -0
  194. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.3.md +14 -0
  195. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.4.md +9 -0
  196. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.5.md +5 -0
  197. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.8.6.md +14 -0
  198. package/cli/dist/web-ui/docs/cn/cli/release-notes/v2.9.0.md +5 -0
  199. package/cli/dist/web-ui/docs/cn/cli/remote-control.md +247 -0
  200. package/cli/dist/web-ui/docs/cn/cli/sandboxing.md +316 -0
  201. package/cli/dist/web-ui/docs/cn/cli/scheduled-tasks.md +161 -0
  202. package/cli/dist/web-ui/docs/cn/cli/sdk-custom-tools.md +1195 -0
  203. package/cli/dist/web-ui/docs/cn/cli/sdk-demos.md +347 -0
  204. package/cli/dist/web-ui/docs/cn/cli/sdk-hooks.md +803 -0
  205. package/cli/dist/web-ui/docs/cn/cli/sdk-mcp.md +643 -0
  206. package/cli/dist/web-ui/docs/cn/cli/sdk-permissions.md +501 -0
  207. package/cli/dist/web-ui/docs/cn/cli/sdk-python.md +783 -0
  208. package/cli/dist/web-ui/docs/cn/cli/sdk-sessions.md +332 -0
  209. package/cli/dist/web-ui/docs/cn/cli/sdk-typescript.md +759 -0
  210. package/cli/dist/web-ui/docs/cn/cli/sdk.md +1105 -0
  211. package/cli/dist/web-ui/docs/cn/cli/security.md +387 -0
  212. package/cli/dist/web-ui/docs/cn/cli/settings.md +602 -0
  213. package/cli/dist/web-ui/docs/cn/cli/skills.md +448 -0
  214. package/cli/dist/web-ui/docs/cn/cli/slash-commands.md +397 -0
  215. package/cli/dist/web-ui/docs/cn/cli/statusline.md +525 -0
  216. package/cli/dist/web-ui/docs/cn/cli/sub-agents.md +634 -0
  217. package/cli/dist/web-ui/docs/cn/cli/terminal-config.md +77 -0
  218. package/cli/dist/web-ui/docs/cn/cli/tools-reference.md +99 -0
  219. package/cli/dist/web-ui/docs/cn/cli/troubleshooting.md +190 -0
  220. package/cli/dist/web-ui/docs/cn/cli/web-ui.md +164 -0
  221. package/cli/dist/web-ui/docs/cn/cli/wecom-bot-setup.md +274 -0
  222. package/cli/dist/web-ui/docs/cn/cli/worktree.md +660 -0
  223. package/cli/dist/web-ui/docs/en/cli/acp.md +126 -0
  224. package/cli/dist/web-ui/docs/en/cli/agent-teams.md +327 -0
  225. package/cli/dist/web-ui/docs/en/cli/bash-sandboxing.md +290 -0
  226. package/cli/dist/web-ui/docs/en/cli/best-practices.md +554 -0
  227. package/cli/dist/web-ui/docs/en/cli/channels-reference.md +293 -0
  228. package/cli/dist/web-ui/docs/en/cli/channels.md +215 -0
  229. package/cli/dist/web-ui/docs/en/cli/checkpointing.md +53 -0
  230. package/cli/dist/web-ui/docs/en/cli/cli-reference.md +187 -0
  231. package/cli/dist/web-ui/docs/en/cli/common-workflows.md +1013 -0
  232. package/cli/dist/web-ui/docs/en/cli/costs.md +174 -0
  233. package/cli/dist/web-ui/docs/en/cli/devcontainer.md +553 -0
  234. package/cli/dist/web-ui/docs/en/cli/env-vars.md +326 -0
  235. package/cli/dist/web-ui/docs/en/cli/gitlab-ci-cd.md +357 -0
  236. package/cli/dist/web-ui/docs/en/cli/headless.md +258 -0
  237. package/cli/dist/web-ui/docs/en/cli/hooks-guide.md +9 -0
  238. package/cli/dist/web-ui/docs/en/cli/hooks.md +801 -0
  239. package/cli/dist/web-ui/docs/en/cli/iam.md +530 -0
  240. package/cli/dist/web-ui/docs/en/cli/ide-integrations.md +92 -0
  241. package/cli/dist/web-ui/docs/en/cli/installation.md +266 -0
  242. package/cli/dist/web-ui/docs/en/cli/interactive-mode.md +233 -0
  243. package/cli/dist/web-ui/docs/en/cli/mcp.md +739 -0
  244. package/cli/dist/web-ui/docs/en/cli/memory.md +436 -0
  245. package/cli/dist/web-ui/docs/en/cli/models.md +355 -0
  246. package/cli/dist/web-ui/docs/en/cli/overview.md +100 -0
  247. package/cli/dist/web-ui/docs/en/cli/plugin-marketplaces.md +534 -0
  248. package/cli/dist/web-ui/docs/en/cli/plugins-reference.md +774 -0
  249. package/cli/dist/web-ui/docs/en/cli/plugins.md +688 -0
  250. package/cli/dist/web-ui/docs/en/cli/quickstart.md +249 -0
  251. package/cli/dist/web-ui/docs/en/cli/release-notes/README.md +194 -0
  252. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.0.md +23 -0
  253. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.10.1.md +5 -0
  254. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.11.0.md +24 -0
  255. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.12.0.md +21 -0
  256. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.13.0.md +20 -0
  257. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.0.md +22 -0
  258. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.14.1.md +8 -0
  259. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.0.md +18 -0
  260. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.15.1.md +11 -0
  261. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.16.0.md +20 -0
  262. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.17.0.md +29 -0
  263. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.18.0.md +17 -0
  264. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.0.md +11 -0
  265. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.1.md +14 -0
  266. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.19.2.md +11 -0
  267. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.0.md +23 -0
  268. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.20.1.md +15 -0
  269. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.21.0.md +13 -0
  270. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.22.0.md +16 -0
  271. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.0.md +41 -0
  272. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.2.md +5 -0
  273. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.3.md +5 -0
  274. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.4.md +15 -0
  275. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.23.5.md +11 -0
  276. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.24.0.md +17 -0
  277. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.0.md +18 -0
  278. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.25.1.md +21 -0
  279. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.26.0.md +18 -0
  280. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.0.md +16 -0
  281. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.1.md +16 -0
  282. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.2.md +7 -0
  283. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.27.3.md +15 -0
  284. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.0.md +26 -0
  285. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.28.1.md +5 -0
  286. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.29.0.md +35 -0
  287. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.3.1.md +16 -0
  288. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.0.md +19 -0
  289. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.30.1.md +5 -0
  290. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.0.md +51 -0
  291. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.1.md +11 -0
  292. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.31.2.md +16 -0
  293. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.32.0.md +19 -0
  294. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.0.md +28 -0
  295. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.33.1.md +7 -0
  296. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.0.md +27 -0
  297. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.34.1.md +7 -0
  298. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.35.0.md +22 -0
  299. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.0.md +23 -0
  300. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.1.md +5 -0
  301. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.2.md +22 -0
  302. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.36.3.md +17 -0
  303. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.0.md +15 -0
  304. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.1.md +15 -0
  305. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.10.md +5 -0
  306. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.11.md +8 -0
  307. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.12.md +14 -0
  308. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.13.md +11 -0
  309. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.14.md +24 -0
  310. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.15.md +11 -0
  311. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.16.md +9 -0
  312. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.17.md +5 -0
  313. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.18.md +9 -0
  314. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.19.md +5 -0
  315. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.2.md +28 -0
  316. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.20.md +8 -0
  317. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.3.md +22 -0
  318. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.4.md +19 -0
  319. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.5.md +5 -0
  320. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.6.md +5 -0
  321. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.7.md +5 -0
  322. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.8.md +5 -0
  323. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.37.9.md +8 -0
  324. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.0.md +22 -0
  325. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.1.md +6 -0
  326. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.38.2.md +9 -0
  327. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.39.0.md +18 -0
  328. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.4.0.md +19 -0
  329. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.0.md +20 -0
  330. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.40.1.md +6 -0
  331. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.0.md +15 -0
  332. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.1.md +6 -0
  333. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.2.md +5 -0
  334. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.3.md +8 -0
  335. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.4.md +5 -0
  336. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.5.md +10 -0
  337. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.6.md +9 -0
  338. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.7.md +14 -0
  339. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.41.8.md +18 -0
  340. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.0.md +39 -0
  341. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.1.md +8 -0
  342. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.42.3.md +18 -0
  343. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.0.md +27 -0
  344. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.43.1.md +27 -0
  345. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.0.md +11 -0
  346. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.44.1.md +22 -0
  347. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.0.md +34 -0
  348. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.45.1.md +7 -0
  349. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.46.0.md +12 -0
  350. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.47.0.md +20 -0
  351. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.0.md +32 -0
  352. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.48.1.md +11 -0
  353. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.0.md +26 -0
  354. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.1.md +14 -0
  355. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.2.md +39 -0
  356. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.3.md +7 -0
  357. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.5.md +11 -0
  358. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.6.md +9 -0
  359. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.49.7.md +7 -0
  360. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.5.0.md +24 -0
  361. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.0.md +25 -0
  362. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.1.md +9 -0
  363. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.2.md +11 -0
  364. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.3.md +5 -0
  365. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.4.md +17 -0
  366. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.5.md +16 -0
  367. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.6.md +15 -0
  368. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.50.7.md +15 -0
  369. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.0.md +24 -0
  370. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.1.md +17 -0
  371. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.51.2.md +5 -0
  372. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.0.md +30 -0
  373. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.1.md +28 -0
  374. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.2.md +12 -0
  375. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.3.md +13 -0
  376. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.4.md +27 -0
  377. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.5.md +21 -0
  378. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.52.6.md +7 -0
  379. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.53.0.md +29 -0
  380. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.54.0.md +26 -0
  381. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.0.md +21 -0
  382. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.55.1.md +13 -0
  383. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.0.md +20 -0
  384. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.56.1.md +5 -0
  385. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.0.md +32 -0
  386. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.57.1.md +10 -0
  387. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.58.0.md +34 -0
  388. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.59.0.md +28 -0
  389. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.0.md +5 -0
  390. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.6.1.md +10 -0
  391. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.60.0.md +20 -0
  392. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.0.md +29 -0
  393. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.1.md +5 -0
  394. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.2.md +6 -0
  395. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.61.3.md +13 -0
  396. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.0.md +21 -0
  397. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.62.1.md +11 -0
  398. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.0.md +19 -0
  399. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.1.md +5 -0
  400. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.2.md +7 -0
  401. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.3.md +6 -0
  402. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.4.md +8 -0
  403. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.63.5.md +6 -0
  404. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.0.md +37 -0
  405. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.1.md +6 -0
  406. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.64.2.md +11 -0
  407. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.0.md +19 -0
  408. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.65.1.md +11 -0
  409. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.0.md +15 -0
  410. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.1.md +14 -0
  411. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.66.2.md +5 -0
  412. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.67.0.md +33 -0
  413. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.68.0.md +28 -0
  414. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.7.0.md +16 -0
  415. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.0.md +18 -0
  416. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.1.md +17 -0
  417. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.2.md +5 -0
  418. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.3.md +14 -0
  419. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.4.md +9 -0
  420. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.5.md +5 -0
  421. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.8.6.md +14 -0
  422. package/cli/dist/web-ui/docs/en/cli/release-notes/v2.9.0.md +5 -0
  423. package/cli/dist/web-ui/docs/en/cli/remote-control.md +247 -0
  424. package/cli/dist/web-ui/docs/en/cli/sandboxing.md +316 -0
  425. package/cli/dist/web-ui/docs/en/cli/scheduled-tasks.md +160 -0
  426. package/cli/dist/web-ui/docs/en/cli/sdk-custom-tools.md +1131 -0
  427. package/cli/dist/web-ui/docs/en/cli/sdk-demos.md +347 -0
  428. package/cli/dist/web-ui/docs/en/cli/sdk-hooks.md +813 -0
  429. package/cli/dist/web-ui/docs/en/cli/sdk-mcp.md +645 -0
  430. package/cli/dist/web-ui/docs/en/cli/sdk-permissions.md +461 -0
  431. package/cli/dist/web-ui/docs/en/cli/sdk-python.md +783 -0
  432. package/cli/dist/web-ui/docs/en/cli/sdk-sessions.md +340 -0
  433. package/cli/dist/web-ui/docs/en/cli/sdk-typescript.md +759 -0
  434. package/cli/dist/web-ui/docs/en/cli/sdk.md +1103 -0
  435. package/cli/dist/web-ui/docs/en/cli/security.md +387 -0
  436. package/cli/dist/web-ui/docs/en/cli/settings.md +602 -0
  437. package/cli/dist/web-ui/docs/en/cli/skills.md +448 -0
  438. package/cli/dist/web-ui/docs/en/cli/slash-commands.md +397 -0
  439. package/cli/dist/web-ui/docs/en/cli/statusline.md +525 -0
  440. package/cli/dist/web-ui/docs/en/cli/sub-agents.md +621 -0
  441. package/cli/dist/web-ui/docs/en/cli/terminal-config.md +77 -0
  442. package/cli/dist/web-ui/docs/en/cli/tools-reference.md +99 -0
  443. package/cli/dist/web-ui/docs/en/cli/troubleshooting.md +190 -0
  444. package/cli/dist/web-ui/docs/en/cli/web-ui.md +164 -0
  445. package/cli/dist/web-ui/docs/en/cli/wecom-bot-setup.md +274 -0
  446. package/cli/dist/web-ui/docs/en/cli/worktree.md +660 -0
  447. package/cli/dist/web-ui/docs/search-index-en.json +1 -0
  448. package/cli/dist/web-ui/docs/search-index-zh.json +1 -0
  449. package/cli/dist/web-ui/docs/sidebar-en.json +1 -0
  450. package/cli/dist/web-ui/docs/sidebar-zh.json +1 -0
  451. package/cli/dist/web-ui/index.html +2 -2
  452. package/cli/package.json +1 -1
  453. package/cli/product.cloudhosted.json +2 -2
  454. package/cli/product.internal.json +2 -2
  455. package/cli/product.ioa.json +2 -2
  456. package/cli/product.json +4 -3
  457. package/cli/product.selfhosted.json +2 -2
  458. package/lib/query.d.ts.map +1 -1
  459. package/lib/query.js +5 -1
  460. package/lib/query.js.map +1 -1
  461. package/lib/transport/index.d.ts +1 -1
  462. package/lib/transport/index.d.ts.map +1 -1
  463. package/lib/transport/process-transport.d.ts +1 -1
  464. package/lib/transport/process-transport.d.ts.map +1 -1
  465. package/lib/transport/process-transport.js +5 -1
  466. package/lib/transport/process-transport.js.map +1 -1
  467. package/lib/types.d.ts +3 -0
  468. package/lib/types.d.ts.map +1 -1
  469. package/package.json +1 -1
  470. package/cli/dist/web-ui/assets/index-BPT-qRRx.js +0 -411
  471. package/cli/dist/web-ui/assets/index-f_ibHSHw.css +0 -32
@@ -0,0 +1,805 @@
1
+ # Hook 参考指南
2
+
3
+ > **版本要求**:本文档针对 CodeBuddy Code v1.16.0 及以上版本中提供的 Claude Code Hooks 兼容实现。
4
+ > **功能状态**:Hook 功能当前处于 **Beta** 阶段,接口和行为可能在未来版本中调整。
5
+
6
+ Hook(钩子)允许你在 CodeBuddy Code 的会话生命周期内插入自定义脚本或命令,实现自动化校验、环境初始化、合规检查等高级能力。我们的实现完全兼容 Claude Code Hooks 规范,支持相同的事件类型、输入输出结构以及安全特性。
7
+
8
+
9
+ ## 配置
10
+
11
+ CodeBuddy Code hooks 存储在你的设置文件中:
12
+
13
+ | 作用域 | 文件路径 | 说明 |
14
+ | --- | --- | --- |
15
+ | 用户级 | `~/.codebuddy/settings.json` | 适用于所有项目 |
16
+ | 项目级 | `<项目根>/.codebuddy/settings.json` | 对项目成员共享的配置 |
17
+ | 项目本地 | `<项目根>/.codebuddy/settings.local.json` | 本地未提交配置 |
18
+ | 企业策略 | 集成发布的策略文件 | 受企业统一管理 |
19
+
20
+ **配置合并规则**:来自不同作用域的 hooks 会**合并**而非覆盖。同一事件的所有匹配 hooks 都会并行执行。
21
+
22
+ ## 结构
23
+
24
+ Hooks 按匹配器组织,每个匹配器可以有多个 hooks:
25
+
26
+ ```json
27
+ {
28
+ "hooks": {
29
+ "EventName": [
30
+ {
31
+ "matcher": "ToolPattern",
32
+ "hooks": [
33
+ {
34
+ "type": "command",
35
+ "command": "your-command-here"
36
+ }
37
+ ]
38
+ }
39
+ ]
40
+ }
41
+ }
42
+ ```
43
+
44
+ **关键字段:**
45
+
46
+ - **matcher**:用于匹配工具名称的正则表达式模式,区分大小写(仅适用于 PreToolUse 和 PostToolUse)
47
+ - 简单字符串匹配:`Write` 会匹配任何包含 "Write" 的工具名(如 `Write`、`NotebookWrite`)
48
+ - 精确匹配:使用 `^Write$` 仅匹配 Write 工具
49
+ - 多工具匹配:`Edit|Write` 或 `Web.*`
50
+ - 匹配所有工具:以下三种方式等效
51
+ - 使用 `*` 字符
52
+ - 使用空字符串 `""`
53
+ - 省略 matcher 字段
54
+ - **hooks**:当模式匹配时执行的 hooks 数组
55
+ - **type**: Hook 执行类型 - `"command"` 用于 shell 命令,或 `"prompt"` 用于基于 LLM 的评估
56
+ - **command**: (对于 type: `"command"`)要执行的 shell 命令(可以使用 `$CODEBUDDY_PROJECT_DIR` 环境变量)。在 macOS/Linux 上使用用户默认 shell(`$SHELL`)执行,在 Windows 上**强制使用 Git Bash** 执行(不支持 cmd.exe 或 PowerShell),因此命令需兼容 bash 语法
57
+ - **prompt**: (对于 type: `"prompt"`)发送给 LLM 进行评估的提示词(仅支持 `Stop`、`UserPromptSubmit`、`PreToolUse` 事件)
58
+ - **timeout**: (可选)hook 运行多长时间(以秒为单位)后取消该特定 hook
59
+
60
+ 对于不使用匹配器的事件(如 UserPromptSubmit、Stop 和 SubagentStop),你可以省略 matcher 字段:
61
+
62
+ ```json
63
+ {
64
+ "hooks": {
65
+ "UserPromptSubmit": [
66
+ {
67
+ "hooks": [
68
+ {
69
+ "type": "command",
70
+ "command": "python3 /path/to/prompt-validator.py"
71
+ }
72
+ ]
73
+ }
74
+ ]
75
+ }
76
+ }
77
+ ```
78
+
79
+ ## 项目特定的 Hook 脚本
80
+
81
+ 你可以使用环境变量 `CODEBUDDY_PROJECT_DIR`(仅在 CodeBuddy Code 生成 hook 命令时可用)来引用存储在项目中的脚本:
82
+
83
+ ```json
84
+ {
85
+ "hooks": {
86
+ "PostToolUse": [
87
+ {
88
+ "matcher": "Write|Edit",
89
+ "hooks": [
90
+ {
91
+ "type": "command",
92
+ "command": "\"$CODEBUDDY_PROJECT_DIR\"/.codebuddy/hooks/check-style.sh"
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ ```
100
+
101
+ > **提示**:如果你的 hook 脚本是 Python 文件,请显式使用 `python3` 来调用,而不是直接执行 `.py` 文件。因为在 Windows 上即使脚本包含 shebang 行(`#!/usr/bin/env python3`),Git Bash 也不一定能正确识别:
102
+ > ```json
103
+ > "command": "python3 \"$CODEBUDDY_PROJECT_DIR\"/.codebuddy/hooks/my_hook.py"
104
+ > ```
105
+
106
+ ## 插件 Hooks
107
+
108
+ 插件可以提供与用户和项目 hooks 无缝集成的 hooks。启用插件时,插件 hooks 会自动与你的配置合并。
109
+
110
+ **插件 hooks 的工作方式:**
111
+
112
+ - 插件 hooks 在插件的 `hooks/hooks.json` 文件中定义,或在 hooks 字段提供的自定义路径的文件中定义
113
+ - 当插件启用时,其 hooks 会与用户和项目 hooks 合并
114
+ - 来自不同来源的多个 hooks 可以响应同一事件
115
+ - 插件 hooks 使用 `${CODEBUDDY_PLUGIN_ROOT}` 环境变量来引用插件文件
116
+
117
+ 插件 hook 配置示例:
118
+
119
+ ```json
120
+ {
121
+ "description": "Automatic code formatting",
122
+ "hooks": {
123
+ "PostToolUse": [
124
+ {
125
+ "matcher": "Write|Edit",
126
+ "hooks": [
127
+ {
128
+ "type": "command",
129
+ "command": "${CODEBUDDY_PLUGIN_ROOT}/scripts/format.sh",
130
+ "timeout": 30
131
+ }
132
+ ]
133
+ }
134
+ ]
135
+ }
136
+ }
137
+ ```
138
+
139
+ ## 基于提示词的 Hooks
140
+
141
+ 除了 bash 命令 hooks(`type: "command"`),CodeBuddy Code 还支持基于提示词的 hooks(`type: "prompt"`),使用 LLM 来评估是否允许或阻止某个操作。
142
+
143
+ > **支持的事件**:目前仅支持 `Stop`、`UserPromptSubmit` 和 `PreToolUse` 三种事件。
144
+
145
+ ### 基于提示词的 hooks 如何工作
146
+
147
+ 基于提示词的 hooks 不是执行 bash 命令,而是:
148
+
149
+ 1. 将 hook 输入和你的提示词发送给快速 LLM(Haiku)
150
+ 2. LLM 使用包含决策的结构化 JSON 响应
151
+ 3. CodeBuddy Code 自动处理决策
152
+
153
+ ### 支持的事件
154
+
155
+ | 事件 | 用途 |
156
+ | --- | --- |
157
+ | `Stop` | 智能决定 CodeBuddy 是否应继续工作 |
158
+ | `UserPromptSubmit` | 使用 LLM 协助验证用户提示 |
159
+ | `PreToolUse` | 做出上下文感知的权限决策 |
160
+
161
+ ### 与 Command Hook 的比较
162
+
163
+ | 特性 | Command Hooks | Prompt Hooks |
164
+ | --- | --- | --- |
165
+ | **执行方式** | 运行 bash 脚本 | 查询 LLM |
166
+ | **决策逻辑** | 你在代码中实现 | LLM 评估上下文 |
167
+ | **设置复杂性** | 需要脚本文件 | 只需配置提示词 |
168
+ | **上下文感知** | 受脚本逻辑限制 | 自然语言理解 |
169
+ | **性能** | 快速(本地执行) | 较慢(API 调用) |
170
+ | **适用场景** | 确定性规则 | 上下文感知决策 |
171
+
172
+ ### 配置
173
+
174
+ ```json
175
+ {
176
+ "hooks": {
177
+ "Stop": [
178
+ {
179
+ "hooks": [
180
+ {
181
+ "type": "prompt",
182
+ "prompt": "Evaluate if CodeBuddy should stop: $ARGUMENTS. Check if all tasks are complete."
183
+ }
184
+ ]
185
+ }
186
+ ]
187
+ }
188
+ }
189
+ ```
190
+
191
+ **字段:**
192
+
193
+ - **type**:必须为 `"prompt"`
194
+ - **prompt**:发送给 LLM 的提示词文本
195
+ - 使用 `$ARGUMENTS` 作为 hook 输入 JSON 的占位符,会被直接替换
196
+ - 如果不存在 `$ARGUMENTS`,输入 JSON 会以 `\n\nARGUMENTS:\n{JSON}` 格式追加到提示词末尾
197
+ - **timeout**: (可选) 超时时间(秒)(默认: 30 秒)
198
+
199
+ ### 响应模式
200
+
201
+ LLM 必须使用包含以下内容的 JSON 响应:
202
+
203
+ ```jsonc
204
+ {
205
+ "ok": true | false,
206
+ "reason": "Explanation for the decision" // 当 ok 为 false 时必需
207
+ }
208
+ ```
209
+
210
+ **响应字段:**
211
+
212
+ - `ok`:`true` 允许操作,`false` 阻止操作
213
+ - `reason`:当 `ok` 为 `false` 时必需,显示给 CodeBuddy 的解释
214
+
215
+ ### 示例:智能 Stop Hook
216
+
217
+ ```json
218
+ {
219
+ "hooks": {
220
+ "Stop": [
221
+ {
222
+ "hooks": [
223
+ {
224
+ "type": "prompt",
225
+ "prompt": "You are evaluating whether CodeBuddy should stop working. Context: $ARGUMENTS\n\nAnalyze the conversation and determine if:\n1. All user-requested tasks are complete\n2. Any errors need to be addressed\n3. Follow-up work is needed\n\nRespond with JSON: {\"ok\": true} to allow stopping, or {\"ok\": false, \"reason\": \"your explanation\"} to continue working.",
226
+ "timeout": 30
227
+ }
228
+ ]
229
+ }
230
+ ]
231
+ }
232
+ }
233
+ ```
234
+
235
+ ### 示例:UserPromptSubmit 验证
236
+
237
+ ```json
238
+ {
239
+ "hooks": {
240
+ "UserPromptSubmit": [
241
+ {
242
+ "hooks": [
243
+ {
244
+ "type": "prompt",
245
+ "prompt": "Evaluate if this user prompt is safe and appropriate. Input: $ARGUMENTS\n\nCheck if:\n- The prompt contains sensitive information (passwords, secrets)\n- The request is clear and actionable\n- Any security concerns exist\n\nReturn: {\"ok\": true} to allow, or {\"ok\": false, \"reason\": \"explanation\"} to block."
246
+ }
247
+ ]
248
+ }
249
+ ]
250
+ }
251
+ }
252
+ ```
253
+
254
+ ### 示例:PreToolUse 权限决策
255
+
256
+ ```json
257
+ {
258
+ "hooks": {
259
+ "PreToolUse": [
260
+ {
261
+ "matcher": "Bash",
262
+ "hooks": [
263
+ {
264
+ "type": "prompt",
265
+ "prompt": "Evaluate if this bash command should be allowed. Input: $ARGUMENTS\n\nCheck if:\n- The command is safe and non-destructive\n- It doesn't access sensitive files or directories\n- It aligns with the user's stated goals\n\nReturn: {\"ok\": true} to allow, or {\"ok\": false, \"reason\": \"explanation\"} to deny."
266
+ }
267
+ ]
268
+ }
269
+ ]
270
+ }
271
+ }
272
+ ```
273
+
274
+ ### 最佳实践
275
+
276
+ - **在提示词中具体说明**:清楚描述你希望 LLM 评估的内容
277
+ - **包含决策标准**:列出 LLM 应考虑的因素
278
+ - **测试你的提示词**:验证 LLM 为你的用例做出正确的决策
279
+ - **设置适当的超时**:默认为 30 秒,如果需要可调整
280
+ - **用于复杂决策**:Command hooks 更适合简单的、确定性的规则
281
+
282
+ ## Hook 事件
283
+
284
+ ### 事件类型
285
+
286
+ | 事件 | 触发时机 | matcher 字段 | 典型场景 |
287
+ | --- | --- | --- | --- |
288
+ | `PreToolUse` | 工具执行前 | 支持(工具名) | 校验命令、二次审批、日志记录 |
289
+ | `PostToolUse` | 工具成功执行后 | 支持 | 自动格式化、补充上下文 |
290
+ | `Notification` | 权限请求或 60 秒无输入提醒 | 部分支持 | 桌面提示、IM 通知 |
291
+ | `UserPromptSubmit` | 用户提交消息时<br/>**注:不包括内部命令** | 不支持 | 内容审查、上下文注入 |
292
+ | `Stop` | 主代理响应结束时 | 不支持 | 要求继续执行、追加提醒 |
293
+ | `SubagentStop` | 子代理(TaskTool)结束时 | 不支持 | 子任务继续执行或补充说明 |
294
+ | `PreCompact` | 执行上下文压缩前 | 支持(`manual`/`auto`) | 保留关键信息、防止压缩 |
295
+ | `SessionStart` | 会话创建或恢复时 | 支持(`startup`/`resume`/`clear`/`compact`) | 环境初始化、变量注入 |
296
+ | `SessionEnd` | 会话结束时 | 支持(`clear`/`logout`/`prompt_input_exit`/`other`) | 清理资源、持久化日志 |
297
+
298
+ ### PreToolUse
299
+
300
+ 在 CodeBuddy 创建工具参数之后、处理工具调用之前运行。
301
+
302
+ **常见匹配器:**
303
+
304
+ - `Task` - 子代理任务
305
+ - `Bash` - Shell 命令
306
+ - `Glob` - 文件模式匹配
307
+ - `Grep` - 内容搜索
308
+ - `Read` - 文件读取
309
+ - `Edit` - 文件编辑
310
+ - `Write` - 文件写入
311
+ - `WebFetch`, `WebSearch` - Web 操作
312
+
313
+ ### PostToolUse
314
+
315
+ 在工具成功完成后立即运行。识别与 PreToolUse 相同的匹配器值。
316
+
317
+ ### Notification
318
+
319
+ 在 CodeBuddy Code 发送通知时运行。支持匹配器以按通知类型过滤。
320
+
321
+ **常见匹配器(部分支持):**
322
+
323
+ - `permission_prompt` - 来自 CodeBuddy Code 的权限请求
324
+ - `idle_prompt` - 当 CodeBuddy 等待用户输入时(空闲时间超过 60 秒后)
325
+ - `auth_success` - 身份验证成功通知
326
+ - `elicitation_dialog` - 当 CodeBuddy Code 需要 MCP 工具引导的输入时(暂未支持)
327
+
328
+ 示例:
329
+
330
+ ```json
331
+ {
332
+ "hooks": {
333
+ "Notification": [
334
+ {
335
+ "matcher": "permission_prompt",
336
+ "hooks": [
337
+ {
338
+ "type": "command",
339
+ "command": "/path/to/permission-alert.sh"
340
+ }
341
+ ]
342
+ },
343
+ {
344
+ "matcher": "idle_prompt",
345
+ "hooks": [
346
+ {
347
+ "type": "command",
348
+ "command": "/path/to/idle-notification.sh"
349
+ }
350
+ ]
351
+ }
352
+ ]
353
+ }
354
+ }
355
+ ```
356
+
357
+ ### UserPromptSubmit
358
+
359
+ 在用户提交提示词后、CodeBuddy 处理之前运行。这允许你根据提示词/对话添加额外的上下文、验证提示词或阻止某些类型的提示词。
360
+
361
+ ### Stop
362
+
363
+ 在主 CodeBuddy Code 代理完成响应时运行。如果停止是由于用户中断而发生的,则不会运行。
364
+
365
+ ### SubagentStop
366
+
367
+ 在 CodeBuddy Code 子代理(Agent 工具调用)完成响应时运行。
368
+
369
+ ### PreCompact
370
+
371
+ 在 CodeBuddy Code 即将运行压缩操作之前运行。
372
+
373
+ **匹配器:**
374
+
375
+ - `manual` - 从 `/compact` 调用
376
+ - `auto` - 从自动压缩调用(由于上下文窗口已满)
377
+
378
+ ### SessionStart
379
+
380
+ 在 CodeBuddy Code 启动新会话或恢复现有会话时运行。
381
+
382
+ **匹配器:**
383
+
384
+ - `startup` - 从启动调用
385
+ - `resume` - 从 `--resume`、`--continue` 或 `/resume` 调用
386
+ - `clear` - 从 `/clear` 调用
387
+ - `compact` - 从自动或手动压缩调用
388
+
389
+ ### SessionEnd
390
+
391
+ 在 CodeBuddy Code 会话结束时运行。用于清理任务、记录会话统计信息或保存会话状态。
392
+
393
+ **reason 字段将是以下之一:**
394
+
395
+ - `clear` - 使用 `/clear` 命令清除会话
396
+ - `logout` - 用户注销
397
+ - `prompt_input_exit` - 用户在提示词输入可见时退出
398
+ - `other` - 其他退出原因(包括正常退出)
399
+
400
+ ## Hook 输入
401
+
402
+ Hooks 通过 stdin 接收包含会话信息和事件特定数据的 JSON 数据:
403
+
404
+ ```jsonc
405
+ {
406
+ // 公共字段
407
+ "session_id": "string",
408
+ "transcript_path": "string", // 对话 JSON 的路径
409
+ "cwd": "string", // 调用 hook 时的当前工作目录
410
+ "permission_mode": "string", // 当前权限模式: "default"、"plan"、"acceptEdits" 或 "bypassPermissions"
411
+
412
+ // 事件特定字段
413
+ "hook_event_name": "string"
414
+ // ...
415
+ }
416
+ ```
417
+
418
+ ### PreToolUse 输入
419
+
420
+ ```json
421
+ {
422
+ "session_id": "abc123",
423
+ "transcript_path": "/Users/.../.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
424
+ "cwd": "/Users/...",
425
+ "permission_mode": "default",
426
+ "hook_event_name": "PreToolUse",
427
+ "tool_name": "Write",
428
+ "tool_input": {
429
+ "file_path": "/path/to/file.txt",
430
+ "content": "file content"
431
+ }
432
+ }
433
+ ```
434
+
435
+ ### PostToolUse 输入
436
+
437
+ ```json
438
+ {
439
+ "session_id": "abc123",
440
+ "transcript_path": "/Users/.../.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
441
+ "cwd": "/Users/...",
442
+ "permission_mode": "default",
443
+ "hook_event_name": "PostToolUse",
444
+ "tool_name": "Write",
445
+ "tool_input": {
446
+ "file_path": "/path/to/file.txt",
447
+ "content": "file content"
448
+ },
449
+ "tool_response": {
450
+ "filePath": "/path/to/file.txt",
451
+ "success": true
452
+ }
453
+ }
454
+ ```
455
+
456
+ ### Notification 输入
457
+
458
+ ```json
459
+ {
460
+ "session_id": "abc123",
461
+ "transcript_path": "/Users/.../.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
462
+ "cwd": "/Users/...",
463
+ "permission_mode": "default",
464
+ "hook_event_name": "Notification",
465
+ "message": "CodeBuddy needs your permission to use Bash",
466
+ "notification_type": "permission_prompt"
467
+ }
468
+ ```
469
+
470
+ ### UserPromptSubmit 输入
471
+
472
+ ```json
473
+ {
474
+ "session_id": "abc123",
475
+ "transcript_path": "/Users/.../.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
476
+ "cwd": "/Users/...",
477
+ "permission_mode": "default",
478
+ "hook_event_name": "UserPromptSubmit",
479
+ "prompt": "Write a function to calculate the factorial of a number"
480
+ }
481
+ ```
482
+
483
+ ### Stop 和 SubagentStop 输入
484
+
485
+ 当 CodeBuddy Code 已经由于 stop hook 的结果而继续时,`stop_hook_active` 为 true。
486
+
487
+ ```json
488
+ {
489
+ "session_id": "abc123",
490
+ "transcript_path": "/Users/xxx/.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
491
+ "permission_mode": "default",
492
+ "hook_event_name": "Stop",
493
+ "stop_hook_active": true
494
+ }
495
+ ```
496
+
497
+ ### PreCompact 输入
498
+
499
+ 对于手动触发,`custom_instructions` 来自用户传入 `/compact` 的内容。对于自动触发,`custom_instructions` 为空。
500
+
501
+ ```json
502
+ {
503
+ "session_id": "abc123",
504
+ "transcript_path": "/Users/xxx/.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
505
+ "permission_mode": "default",
506
+ "hook_event_name": "PreCompact",
507
+ "trigger": "manual",
508
+ "custom_instructions": ""
509
+ }
510
+ ```
511
+
512
+ ### SessionStart 输入
513
+
514
+ ```json
515
+ {
516
+ "session_id": "abc123",
517
+ "transcript_path": "/Users/xxx/.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
518
+ "permission_mode": "default",
519
+ "hook_event_name": "SessionStart",
520
+ "source": "startup"
521
+ }
522
+ ```
523
+
524
+ ### SessionEnd 输入
525
+
526
+ ```json
527
+ {
528
+ "session_id": "abc123",
529
+ "transcript_path": "/Users/xxx/.codebuddy/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
530
+ "cwd": "/Users/...",
531
+ "permission_mode": "default",
532
+ "hook_event_name": "SessionEnd",
533
+ "reason": "other"
534
+ }
535
+ ```
536
+
537
+ ## Hook 输出
538
+
539
+ Hooks 有两种方式将输出返回给 CodeBuddy Code。
540
+
541
+ ### 简单方式: 退出代码
542
+
543
+ Hooks 通过退出代码、stdout 和 stderr 传达状态:
544
+
545
+ - **退出代码 0**:成功。stdout 在 transcript 模式(CTRL-R)中显示给用户,但 UserPromptSubmit 和 SessionStart 除外,其中 stdout 会添加到上下文中。
546
+ - **退出代码 2**:阻塞错误。消息来源优先级:stdout(JSON 的 `reason`/`stopReason` 字段或纯文本)> stderr。即 **stderr 仅作为 fallback**,只有当 stdout 没有输出任何内容时才会传递给 CodeBuddy。因此调试日志可以安全地写入 stderr,不会污染给 Agent 的反馈消息。
547
+ - **其他退出代码**:非阻塞错误。stderr 显示给用户,执行继续。
548
+
549
+ #### 退出代码 2 的行为
550
+
551
+ > **注意**:下表中"显示消息"指的是按优先级从 stdout 或 stderr 获取的消息(参见上文 fallback 说明)。
552
+
553
+ | Hook 事件 | 行为 |
554
+ |------------|----------|
555
+ | PreToolUse | 阻止工具调用,向 CodeBuddy 显示消息 |
556
+ | PostToolUse | 向 CodeBuddy 显示消息(工具已运行,用于补充上下文) |
557
+ | Notification | N/A,仅向用户显示消息 |
558
+ | UserPromptSubmit | 阻止提示词处理,清除提示词,仅向用户显示消息 |
559
+ | Stop | 阻止停止,向 CodeBuddy 显示消息并继续对话 |
560
+ | SubagentStop | 阻止停止,向 CodeBuddy 子代理显示消息并继续执行 |
561
+ | PreCompact | 阻止压缩操作,仅向用户显示消息 |
562
+ | SessionStart | N/A,仅向用户显示消息 |
563
+ | SessionEnd | N/A,仅向用户显示消息 |
564
+
565
+ ### 高级方式: JSON 输出
566
+
567
+ Hooks 可以在 stdout 中返回结构化 JSON 以实现更复杂的控制。
568
+
569
+ #### 公共 JSON 字段
570
+
571
+ 所有 hook 类型都可以包含这些可选字段:
572
+
573
+ ```jsonc
574
+ {
575
+ "continue": true, // CodeBuddy 在 hook 执行后是否继续(默认: true)
576
+ "stopReason": "string", // 当 continue 为 false 时显示给 CodeBuddy 的消息
577
+ "reason": "string", // stopReason 的别名,两者等效
578
+
579
+ "suppressOutput": true, // 在 transcript 模式中隐藏 stdout(默认: false)
580
+ "systemMessage": "string" // 显示给用户的可选警告消息(不传给 Agent)
581
+ }
582
+ ```
583
+
584
+ **消息字段说明**:
585
+ - `stopReason` / `reason`:传递给 CodeBuddy Agent 的消息,用于解释为什么阻止操作
586
+ - `systemMessage`:仅显示给用户的警告信息,不会传给 Agent
587
+
588
+ #### PreToolUse 决策控制
589
+
590
+ PreToolUse hooks 可以控制工具调用是否继续。
591
+
592
+ ```jsonc
593
+ {
594
+ "hookSpecificOutput": {
595
+ "hookEventName": "PreToolUse",
596
+ "permissionDecision": "allow" | "deny" | "ask",
597
+ "permissionDecisionReason": "显示在权限对话框中的原因说明",
598
+ "modifiedInput": {
599
+ "field_to_modify": "new value"
600
+ }
601
+ }
602
+ }
603
+ ```
604
+
605
+ - `"allow"` 绕过权限系统,直接执行工具
606
+ - `"deny"` 阻止工具调用执行,`permissionDecisionReason` 会传递给 Agent
607
+ - `"ask"` 要求用户在 UI 中确认工具调用,`permissionDecisionReason` 会显示在确认对话框中
608
+ - `modifiedInput` 允许你在执行前修改工具的输入参数(部分字段覆盖)
609
+
610
+ #### PostToolUse 上下文注入
611
+
612
+ PostToolUse 在工具执行**完成后**触发,无法阻止已执行的操作,但可以向 Agent 注入额外上下文信息。
613
+
614
+ ```jsonc
615
+ {
616
+ "hookSpecificOutput": {
617
+ "hookEventName": "PostToolUse",
618
+ "additionalContext": "补充给 CodeBuddy 的额外信息,如代码规范检查结果"
619
+ }
620
+ }
621
+ ```
622
+
623
+ > **注意**:`decision: "block"` 字段已废弃。由于工具已执行完成,此时无法真正"阻止"操作。
624
+
625
+ #### UserPromptSubmit 决策控制
626
+
627
+ ```jsonc
628
+ {
629
+ "continue": false, // 设为 false 阻止提示词处理
630
+ "reason": "阻止原因(仅显示给用户)",
631
+ "hookSpecificOutput": {
632
+ "hookEventName": "UserPromptSubmit",
633
+ "additionalContext": "注入给 CodeBuddy 的额外上下文"
634
+ }
635
+ }
636
+ ```
637
+
638
+ > **注意**:`decision: "block"` 字段已废弃,请使用 `continue: false`。
639
+
640
+ #### Stop/SubagentStop 决策控制
641
+
642
+ ```jsonc
643
+ {
644
+ "continue": false, // 设为 false 阻止停止,让 Agent 继续工作
645
+ "reason": "告诉 Agent 为什么需要继续工作的原因"
646
+ }
647
+ ```
648
+
649
+ > **注意**:`decision: "block"` 字段已废弃,请使用 `continue: false`。
650
+
651
+ #### SessionStart 决策控制
652
+
653
+ ```jsonc
654
+ {
655
+ "hookSpecificOutput": {
656
+ "hookEventName": "SessionStart",
657
+ "additionalContext": "My additional context here"
658
+ }
659
+ }
660
+ ```
661
+
662
+ ## 使用 MCP 工具
663
+
664
+ CodeBuddy Code hooks 与模型上下文协议(MCP)工具无缝配合。
665
+
666
+ ### MCP 工具命名
667
+
668
+ MCP 工具遵循 `mcp__<server>__<tool>` 模式,例如:
669
+
670
+ - `mcp__memory__create_entities` - Memory 服务器的创建实体工具
671
+ - `mcp__filesystem__read_file` - Filesystem 服务器的读取文件工具
672
+ - `mcp__github__search_repositories` - GitHub 服务器的搜索工具
673
+
674
+ ### 为 MCP 工具配置 Hooks
675
+
676
+ 你可以针对特定的 MCP 工具或整个 MCP 服务器:
677
+
678
+ ```json
679
+ {
680
+ "hooks": {
681
+ "PreToolUse": [
682
+ {
683
+ "matcher": "mcp__memory__.*",
684
+ "hooks": [
685
+ {
686
+ "type": "command",
687
+ "command": "echo 'Memory operation initiated' >> ~/mcp-operations.log"
688
+ }
689
+ ]
690
+ },
691
+ {
692
+ "matcher": "mcp__.*__write.*",
693
+ "hooks": [
694
+ {
695
+ "type": "command",
696
+ "command": "python3 /home/user/scripts/validate-mcp-write.py"
697
+ }
698
+ ]
699
+ }
700
+ ]
701
+ }
702
+ }
703
+ ```
704
+
705
+ ## 安全注意事项
706
+
707
+ ### 免责声明
708
+
709
+ **使用风险自负**: CodeBuddy Code hooks 会在你的系统上自动执行任意 shell 命令。通过使用 hooks,你承认:
710
+
711
+ - 你对所配置的命令负全部责任
712
+ - Hooks 可以修改、删除或访问你的用户账户可以访问的任何文件
713
+ - 恶意或编写不当的 hooks 可能导致数据丢失或系统损坏
714
+ - Tencent Cloud 不提供任何保证,并对因使用 hooks 而导致的任何损害不承担任何责任
715
+ - 你应该在安全环境中彻底测试 hooks,然后再在生产环境中使用
716
+
717
+ ### 安全最佳实践
718
+
719
+ 1. **验证和清理输入** - 永远不要盲目信任输入数据
720
+ 2. **始终引用 shell 变量** - 使用 `"$VAR"` 而不是 `$VAR`
721
+ 3. **阻止路径遍历** - 检查文件路径中的 `..`
722
+ 4. **使用绝对路径** - 为脚本指定完整路径(对项目路径使用 `"$CODEBUDDY_PROJECT_DIR"`)
723
+ 5. **跳过敏感文件** - 避免 `.env`、`.git/`、密钥等
724
+
725
+ ### 配置安全
726
+
727
+ 直接编辑设置文件中的 hooks 不会立即生效。CodeBuddy Code:
728
+
729
+ 1. 在启动时捕获 hooks 的快照
730
+ 2. 在整个会话期间使用此快照
731
+ 3. 如果 hooks 在外部被修改,会发出警告
732
+ 4. 需要在 `/hooks` 菜单中审查才能应用更改
733
+
734
+ ## Hook 执行详情
735
+
736
+ - **超时**:默认 60 秒执行限制,可按命令配置
737
+ - **并行化**:所有匹配的 hooks 并行运行
738
+ - **去重**:多个相同的 hook 命令会自动去重
739
+ - **执行 Shell**:
740
+ - **macOS/Linux**:使用用户默认 shell(`$SHELL` 环境变量,通常为 bash 或 zsh),回退到 `/bin/sh`
741
+ - **Windows**:**强制使用 Git Bash**(不支持 cmd.exe 或 PowerShell)。如果未找到 Git Bash,会报错提示安装 [Git for Windows](https://git-scm.com/download/win)。可通过 `CODEBUDDY_CODE_GIT_BASH_PATH` 环境变量指定 bash.exe 路径
742
+ - 可通过 `CODEBUDDY_CODE_SHELL` 环境变量覆盖默认 shell(仅支持 POSIX shell:bash、zsh、sh)
743
+ - **环境**:在当前目录中使用 CodeBuddy Code 的环境运行
744
+ - `CODEBUDDY_PROJECT_DIR` 环境变量包含项目根目录的绝对路径
745
+ - **输入**:通过 stdin 的 JSON
746
+ - **输出**:
747
+ - PreToolUse/PostToolUse/Stop/SubagentStop:在 transcript 中显示进度(Ctrl-R)
748
+ - Notification/SessionEnd:仅记录到调试(`--debug`)
749
+ - UserPromptSubmit/SessionStart: stdout 作为上下文添加给 CodeBuddy
750
+
751
+ ## 调试
752
+
753
+ ### 基本故障排除
754
+
755
+ 如果你的 hooks 不工作:
756
+
757
+ 1. **检查配置** - 运行 `/hooks` 查看你的 hook 是否已注册
758
+ 2. **验证语法** - 确保你的 JSON 设置有效
759
+ 3. **测试命令** - 首先手动运行 hook 命令
760
+ 4. **检查权限** - 确保脚本可执行
761
+ 5. **查看日志** - 使用 `codebuddy --debug` 查看 hook 执行详情
762
+
763
+ **常见问题:**
764
+
765
+ - 引号未转义 - 在 JSON 字符串中使用 `\"`
766
+ - 错误的匹配器 - 检查工具名称是否完全匹配(区分大小写)
767
+ - 找不到命令 - 为脚本使用完整路径
768
+
769
+ ### 高级调试
770
+
771
+ 对于复杂的 hook 问题:
772
+
773
+ 1. **检查 hook 执行** - 使用 `codebuddy --debug` 查看详细的 hook 执行
774
+ 2. **验证 JSON 模式** - 使用外部工具测试 hook 输入/输出
775
+ 3. **检查环境变量** - 验证 CodeBuddy Code 的环境是否正确
776
+ 4. **测试边缘情况** - 尝试使用不寻常的文件路径或输入的 hooks
777
+ 5. **监控系统资源** - 检查 hook 执行期间的资源耗尽
778
+ 6. **使用结构化日志** - 在你的 hook 脚本中实现日志记录
779
+
780
+ ### 调试输出示例
781
+
782
+ **注:该功能暂未支持。**
783
+
784
+ 使用 `codebuddy --debug` 查看 hook 执行详情:
785
+
786
+ ```text
787
+ [DEBUG] Executing hooks for PostToolUse:Write
788
+ [DEBUG] Getting matching hook commands for PostToolUse with query: Write
789
+ [DEBUG] Found 1 hook matchers in settings
790
+ [DEBUG] Matched 1 hooks for query "Write"
791
+ [DEBUG] Found 1 hook commands to execute
792
+ [DEBUG] Executing hook command: <Your command> with timeout 60000ms
793
+ [DEBUG] Hook command completed with status 0: <Your stdout>
794
+ ```
795
+
796
+ 进度消息出现在 transcript 模式 (Ctrl-R) 中,显示:
797
+
798
+ - 正在运行哪个 hook
799
+ - 正在执行的命令
800
+ - 成功/失败状态
801
+ - 输出或错误消息
802
+
803
+ ---
804
+
805
+ 通过本文档,你可以了解 CodeBuddy Code 中的 Hook 机制及其配置方式。若需快速实践示例,请继续阅读 [Hook 入门指南](./hooks-guide.md)。