@tencent-ai/codebuddy-code 2.67.0 → 2.68.0-next.19b562c.20260330
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.
- package/CHANGELOG.md +26 -0
- package/dist/codebuddy-headless.js +58 -58
- package/dist/codebuddy.js +120 -79
- package/dist/web-ui/assets/{index-BPT-qRRx.js → index-Cl0stqCM.js} +145 -116
- package/dist/web-ui/assets/index-Dt1puyHn.css +32 -0
- package/dist/web-ui/docs/cn/cli/acp.md +152 -0
- package/dist/web-ui/docs/cn/cli/agent-teams.md +327 -0
- package/dist/web-ui/docs/cn/cli/bash-sandboxing.md +290 -0
- package/dist/web-ui/docs/cn/cli/best-practices.md +554 -0
- package/dist/web-ui/docs/cn/cli/channels-reference.md +293 -0
- package/dist/web-ui/docs/cn/cli/channels.md +215 -0
- package/dist/web-ui/docs/cn/cli/checkpointing.md +51 -0
- package/dist/web-ui/docs/cn/cli/cli-reference.md +187 -0
- package/dist/web-ui/docs/cn/cli/common-workflows.md +1013 -0
- package/dist/web-ui/docs/cn/cli/costs.md +174 -0
- package/dist/web-ui/docs/cn/cli/devcontainer.md +553 -0
- package/dist/web-ui/docs/cn/cli/env-vars.md +326 -0
- package/dist/web-ui/docs/cn/cli/gitlab-ci-cd.md +357 -0
- package/dist/web-ui/docs/cn/cli/headless.md +258 -0
- package/dist/web-ui/docs/cn/cli/hooks-guide.md +9 -0
- package/dist/web-ui/docs/cn/cli/hooks.md +805 -0
- package/dist/web-ui/docs/cn/cli/iam.md +530 -0
- package/dist/web-ui/docs/cn/cli/ide-integrations.md +92 -0
- package/dist/web-ui/docs/cn/cli/installation.md +291 -0
- package/dist/web-ui/docs/cn/cli/interactive-mode.md +233 -0
- package/dist/web-ui/docs/cn/cli/mcp.md +739 -0
- package/dist/web-ui/docs/cn/cli/memory.md +436 -0
- package/dist/web-ui/docs/cn/cli/models.md +356 -0
- package/dist/web-ui/docs/cn/cli/overview.md +100 -0
- package/dist/web-ui/docs/cn/cli/plugin-marketplaces.md +533 -0
- package/dist/web-ui/docs/cn/cli/plugins-reference.md +774 -0
- package/dist/web-ui/docs/cn/cli/plugins.md +689 -0
- package/dist/web-ui/docs/cn/cli/quickstart.md +249 -0
- package/dist/web-ui/docs/cn/cli/release-notes/README.md +199 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.10.0.md +23 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.10.1.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.11.0.md +24 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.12.0.md +21 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.13.0.md +20 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.14.0.md +22 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.14.1.md +8 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.15.0.md +18 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.15.1.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.16.0.md +20 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.17.0.md +29 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.18.0.md +17 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.19.0.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.19.1.md +14 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.19.2.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.20.0.md +23 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.20.1.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.21.0.md +13 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.22.0.md +16 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.23.0.md +20 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.23.2.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.23.3.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.23.4.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.23.5.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.24.0.md +17 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.25.0.md +18 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.25.1.md +21 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.26.0.md +18 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.27.0.md +16 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.27.1.md +16 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.27.2.md +7 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.27.3.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.28.0.md +26 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.28.1.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.29.0.md +35 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.3.1.md +16 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.30.0.md +19 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.30.1.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.31.0.md +51 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.31.1.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.31.2.md +16 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.32.0.md +19 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.33.0.md +28 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.33.1.md +7 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.36.3.md +17 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.0.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.1.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.10.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.11.md +8 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.12.md +14 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.13.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.14.md +24 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.15.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.16.md +9 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.17.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.18.md +9 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.19.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.2.md +28 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.20.md +8 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.3.md +22 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.4.md +19 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.5.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.6.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.7.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.8.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.37.9.md +8 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.38.0.md +22 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.38.1.md +6 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.38.2.md +9 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.39.0.md +18 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.4.0.md +19 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.40.0.md +20 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.40.1.md +6 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.0.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.1.md +6 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.2.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.3.md +8 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.4.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.5.md +10 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.6.md +9 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.7.md +14 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.41.8.md +18 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.42.0.md +39 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.42.1.md +8 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.42.3.md +18 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.43.0.md +27 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.43.1.md +27 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.44.0.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.44.1.md +22 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.45.0.md +34 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.45.1.md +7 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.46.0.md +12 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.47.0.md +20 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.48.0.md +32 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.48.1.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.49.0.md +26 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.49.1.md +14 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.49.2.md +39 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.49.3.md +7 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.49.5.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.49.6.md +9 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.49.7.md +7 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.5.0.md +24 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.0.md +25 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.1.md +9 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.2.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.3.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.4.md +17 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.5.md +16 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.6.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.50.7.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.51.0.md +24 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.51.1.md +17 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.51.2.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.52.0.md +30 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.52.1.md +28 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.52.2.md +12 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.52.3.md +13 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.52.4.md +27 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.52.5.md +21 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.52.6.md +7 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.53.0.md +29 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.54.0.md +26 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.55.0.md +21 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.55.1.md +13 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.56.0.md +20 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.56.1.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.57.0.md +32 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.57.1.md +10 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.58.0.md +34 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.59.0.md +28 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.6.0.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.6.1.md +10 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.60.0.md +20 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.61.0.md +29 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.61.1.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.61.2.md +6 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.61.3.md +13 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.62.0.md +21 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.62.1.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.63.0.md +19 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.63.1.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.63.2.md +7 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.63.3.md +6 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.63.4.md +8 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.63.5.md +6 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.64.0.md +37 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.64.1.md +6 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.64.2.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.65.0.md +19 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.65.1.md +11 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.66.0.md +15 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.66.1.md +14 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.66.2.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.67.0.md +33 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.7.0.md +16 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.8.0.md +18 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.8.1.md +17 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.8.2.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.8.3.md +14 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.8.4.md +9 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.8.5.md +5 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.8.6.md +14 -0
- package/dist/web-ui/docs/cn/cli/release-notes/v2.9.0.md +5 -0
- package/dist/web-ui/docs/cn/cli/remote-control.md +247 -0
- package/dist/web-ui/docs/cn/cli/sandboxing.md +316 -0
- package/dist/web-ui/docs/cn/cli/scheduled-tasks.md +161 -0
- package/dist/web-ui/docs/cn/cli/sdk-custom-tools.md +1195 -0
- package/dist/web-ui/docs/cn/cli/sdk-demos.md +347 -0
- package/dist/web-ui/docs/cn/cli/sdk-hooks.md +803 -0
- package/dist/web-ui/docs/cn/cli/sdk-mcp.md +643 -0
- package/dist/web-ui/docs/cn/cli/sdk-permissions.md +501 -0
- package/dist/web-ui/docs/cn/cli/sdk-python.md +783 -0
- package/dist/web-ui/docs/cn/cli/sdk-sessions.md +332 -0
- package/dist/web-ui/docs/cn/cli/sdk-typescript.md +759 -0
- package/dist/web-ui/docs/cn/cli/sdk.md +1105 -0
- package/dist/web-ui/docs/cn/cli/security.md +387 -0
- package/dist/web-ui/docs/cn/cli/settings.md +602 -0
- package/dist/web-ui/docs/cn/cli/skills.md +448 -0
- package/dist/web-ui/docs/cn/cli/slash-commands.md +397 -0
- package/dist/web-ui/docs/cn/cli/statusline.md +525 -0
- package/dist/web-ui/docs/cn/cli/sub-agents.md +634 -0
- package/dist/web-ui/docs/cn/cli/terminal-config.md +77 -0
- package/dist/web-ui/docs/cn/cli/tools-reference.md +99 -0
- package/dist/web-ui/docs/cn/cli/troubleshooting.md +190 -0
- package/dist/web-ui/docs/cn/cli/web-ui.md +164 -0
- package/dist/web-ui/docs/cn/cli/wecom-bot-setup.md +274 -0
- package/dist/web-ui/docs/cn/cli/worktree.md +660 -0
- package/dist/web-ui/docs/en/cli/acp.md +126 -0
- package/dist/web-ui/docs/en/cli/agent-teams.md +327 -0
- package/dist/web-ui/docs/en/cli/bash-sandboxing.md +357 -0
- package/dist/web-ui/docs/en/cli/best-practices.md +554 -0
- package/dist/web-ui/docs/en/cli/channels-reference.md +293 -0
- package/dist/web-ui/docs/en/cli/channels.md +215 -0
- package/dist/web-ui/docs/en/cli/checkpointing.md +53 -0
- package/dist/web-ui/docs/en/cli/cli-reference.md +187 -0
- package/dist/web-ui/docs/en/cli/common-workflows.md +1011 -0
- package/dist/web-ui/docs/en/cli/costs.md +174 -0
- package/dist/web-ui/docs/en/cli/devcontainer.md +553 -0
- package/dist/web-ui/docs/en/cli/env-vars.md +326 -0
- package/dist/web-ui/docs/en/cli/gitlab-ci-cd.md +357 -0
- package/dist/web-ui/docs/en/cli/headless.md +258 -0
- package/dist/web-ui/docs/en/cli/hooks-guide.md +9 -0
- package/dist/web-ui/docs/en/cli/hooks.md +801 -0
- package/dist/web-ui/docs/en/cli/iam.md +526 -0
- package/dist/web-ui/docs/en/cli/ide-integrations.md +92 -0
- package/dist/web-ui/docs/en/cli/installation.md +266 -0
- package/dist/web-ui/docs/en/cli/interactive-mode.md +233 -0
- package/dist/web-ui/docs/en/cli/mcp.md +739 -0
- package/dist/web-ui/docs/en/cli/memory.md +436 -0
- package/dist/web-ui/docs/en/cli/models.md +355 -0
- package/dist/web-ui/docs/en/cli/overview.md +100 -0
- package/dist/web-ui/docs/en/cli/plugin-marketplaces.md +534 -0
- package/dist/web-ui/docs/en/cli/plugins-reference.md +774 -0
- package/dist/web-ui/docs/en/cli/plugins.md +688 -0
- package/dist/web-ui/docs/en/cli/quickstart.md +249 -0
- package/dist/web-ui/docs/en/cli/release-notes/README.md +193 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.10.0.md +23 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.10.1.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.11.0.md +24 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.12.0.md +21 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.13.0.md +20 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.14.0.md +22 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.14.1.md +8 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.15.0.md +18 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.15.1.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.16.0.md +20 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.17.0.md +29 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.18.0.md +17 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.19.0.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.19.1.md +14 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.19.2.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.20.0.md +23 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.20.1.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.21.0.md +13 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.22.0.md +16 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.23.0.md +41 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.23.2.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.23.3.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.23.4.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.23.5.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.24.0.md +17 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.25.0.md +18 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.25.1.md +21 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.26.0.md +18 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.27.0.md +16 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.27.1.md +16 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.27.2.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.27.3.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.28.0.md +26 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.28.1.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.29.0.md +35 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.3.1.md +16 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.30.0.md +19 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.30.1.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.31.0.md +51 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.31.1.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.31.2.md +16 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.32.0.md +19 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.33.0.md +28 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.33.1.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.34.0.md +27 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.34.1.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.35.0.md +22 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.36.0.md +23 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.36.1.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.36.2.md +22 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.36.3.md +17 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.0.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.1.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.10.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.11.md +8 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.12.md +14 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.13.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.14.md +24 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.15.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.16.md +9 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.17.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.18.md +9 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.19.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.2.md +28 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.20.md +8 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.3.md +22 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.4.md +19 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.5.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.6.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.7.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.8.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.37.9.md +8 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.38.0.md +22 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.38.1.md +6 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.38.2.md +9 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.39.0.md +18 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.4.0.md +19 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.40.0.md +20 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.40.1.md +6 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.0.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.1.md +6 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.2.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.3.md +8 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.4.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.5.md +10 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.6.md +9 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.7.md +14 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.41.8.md +18 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.42.0.md +39 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.42.1.md +8 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.42.3.md +18 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.43.0.md +27 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.43.1.md +27 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.44.0.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.44.1.md +22 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.45.0.md +34 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.45.1.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.46.0.md +12 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.47.0.md +20 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.48.0.md +32 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.48.1.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.49.0.md +26 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.49.1.md +14 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.49.2.md +39 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.49.3.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.49.5.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.49.6.md +9 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.49.7.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.5.0.md +24 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.0.md +25 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.1.md +9 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.2.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.3.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.4.md +17 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.5.md +16 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.6.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.50.7.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.51.0.md +24 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.51.1.md +17 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.51.2.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.52.0.md +30 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.52.1.md +28 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.52.2.md +12 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.52.3.md +13 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.52.4.md +27 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.52.5.md +21 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.52.6.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.53.0.md +29 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.54.0.md +26 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.55.0.md +21 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.55.1.md +13 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.56.0.md +20 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.56.1.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.57.0.md +32 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.57.1.md +10 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.58.0.md +34 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.59.0.md +28 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.6.0.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.6.1.md +10 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.60.0.md +20 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.61.0.md +29 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.61.1.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.61.2.md +6 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.61.3.md +13 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.62.0.md +21 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.62.1.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.63.0.md +19 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.63.1.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.63.2.md +7 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.63.3.md +6 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.63.4.md +8 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.63.5.md +6 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.64.0.md +37 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.64.1.md +6 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.64.2.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.65.0.md +19 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.65.1.md +11 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.66.0.md +15 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.66.1.md +14 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.66.2.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.67.0.md +33 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.7.0.md +16 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.8.0.md +18 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.8.1.md +17 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.8.2.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.8.3.md +14 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.8.4.md +9 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.8.5.md +5 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.8.6.md +14 -0
- package/dist/web-ui/docs/en/cli/release-notes/v2.9.0.md +5 -0
- package/dist/web-ui/docs/en/cli/remote-control.md +247 -0
- package/dist/web-ui/docs/en/cli/sandboxing.md +316 -0
- package/dist/web-ui/docs/en/cli/scheduled-tasks.md +160 -0
- package/dist/web-ui/docs/en/cli/sdk-custom-tools.md +1131 -0
- package/dist/web-ui/docs/en/cli/sdk-demos.md +347 -0
- package/dist/web-ui/docs/en/cli/sdk-hooks.md +813 -0
- package/dist/web-ui/docs/en/cli/sdk-mcp.md +645 -0
- package/dist/web-ui/docs/en/cli/sdk-permissions.md +461 -0
- package/dist/web-ui/docs/en/cli/sdk-python.md +797 -0
- package/dist/web-ui/docs/en/cli/sdk-sessions.md +340 -0
- package/dist/web-ui/docs/en/cli/sdk-typescript.md +770 -0
- package/dist/web-ui/docs/en/cli/sdk.md +1103 -0
- package/dist/web-ui/docs/en/cli/security.md +388 -0
- package/dist/web-ui/docs/en/cli/settings.md +602 -0
- package/dist/web-ui/docs/en/cli/skills.md +448 -0
- package/dist/web-ui/docs/en/cli/slash-commands.md +397 -0
- package/dist/web-ui/docs/en/cli/statusline.md +525 -0
- package/dist/web-ui/docs/en/cli/sub-agents.md +621 -0
- package/dist/web-ui/docs/en/cli/terminal-config.md +77 -0
- package/dist/web-ui/docs/en/cli/tools-reference.md +99 -0
- package/dist/web-ui/docs/en/cli/troubleshooting.md +190 -0
- package/dist/web-ui/docs/en/cli/web-ui.md +164 -0
- package/dist/web-ui/docs/en/cli/wecom-bot-setup.md +274 -0
- package/dist/web-ui/docs/en/cli/worktree.md +660 -0
- package/dist/web-ui/docs/search-index-en.json +1 -0
- package/dist/web-ui/docs/search-index-zh.json +1 -0
- package/dist/web-ui/docs/sidebar-en.json +1 -0
- package/dist/web-ui/docs/sidebar-zh.json +1 -0
- package/dist/web-ui/index.html +2 -2
- package/package.json +3 -2
- package/product.cloudhosted.json +2 -2
- package/product.internal.json +2 -2
- package/product.ioa.json +2 -2
- package/product.json +3 -3
- package/product.selfhosted.json +2 -2
- package/dist/web-ui/assets/index-f_ibHSHw.css +0 -32
|
@@ -0,0 +1,813 @@
|
|
|
1
|
+
# SDK Hook System
|
|
2
|
+
|
|
3
|
+
> **Version Requirements**: This documentation is for CodeBuddy Agent SDK v0.1.0 and above.
|
|
4
|
+
|
|
5
|
+
This document explains how to use the Hook system in the SDK to insert custom logic before and after tool execution.
|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Overview](#overview)
|
|
10
|
+
- [Hook Configuration](#hook-configuration)
|
|
11
|
+
- [Event Types](#event-types)
|
|
12
|
+
- [Hook Input](#hook-input)
|
|
13
|
+
- [Hook Output](#hook-output)
|
|
14
|
+
- [Examples](#examples)
|
|
15
|
+
- [Related Documentation](#related-documentation)
|
|
16
|
+
|
|
17
|
+
## Overview
|
|
18
|
+
|
|
19
|
+
Hooks allow you to insert custom logic during CodeBuddy's session lifecycle, enabling:
|
|
20
|
+
|
|
21
|
+
- Validation and interception before tool calls
|
|
22
|
+
- Logging after tool execution
|
|
23
|
+
- Review of user-submitted content
|
|
24
|
+
- Initialization and cleanup at session start/end
|
|
25
|
+
- Custom workflows for `worktree` creation and cleanup
|
|
26
|
+
|
|
27
|
+
### Supported Events
|
|
28
|
+
|
|
29
|
+
| Event | Trigger Timing |
|
|
30
|
+
|-------|----------------|
|
|
31
|
+
| `PreToolUse` | Before tool execution |
|
|
32
|
+
| `PostToolUse` | After successful tool execution |
|
|
33
|
+
| `UserPromptSubmit` | When user submits a message |
|
|
34
|
+
| `Stop` | When main Agent response ends |
|
|
35
|
+
| `SubagentStop` | When sub-agent ends |
|
|
36
|
+
| `PreCompact` | Before context compression |
|
|
37
|
+
| `WorktreeCreate` | When creating an isolated `worktree` |
|
|
38
|
+
| `WorktreeRemove` | When deleting an isolated `worktree` |
|
|
39
|
+
| `unstable_Checkpoint` | When a checkpoint is automatically created after file modifications |
|
|
40
|
+
|
|
41
|
+
## Hook Configuration
|
|
42
|
+
|
|
43
|
+
Configure hooks through the `hooks` option. Each event can have multiple matchers, and each matcher can have multiple hook callbacks.
|
|
44
|
+
|
|
45
|
+
### Basic Structure
|
|
46
|
+
|
|
47
|
+
::: code-group
|
|
48
|
+
|
|
49
|
+
```typescript [TypeScript]
|
|
50
|
+
import { query } from '@tencent-ai/agent-sdk';
|
|
51
|
+
|
|
52
|
+
const q = query({
|
|
53
|
+
prompt: 'Help me analyze the code',
|
|
54
|
+
options: {
|
|
55
|
+
model: 'deepseek-v3.1',
|
|
56
|
+
hooks: {
|
|
57
|
+
PreToolUse: [
|
|
58
|
+
{
|
|
59
|
+
matcher: 'Bash', // Only match Bash tool
|
|
60
|
+
hooks: [
|
|
61
|
+
async (input, toolUseId, ctx) => {
|
|
62
|
+
console.log('About to execute:', input);
|
|
63
|
+
return { continue: true };
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
timeout: 5000 // Timeout in milliseconds
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```python [Python]
|
|
75
|
+
from codebuddy_agent_sdk import query, CodeBuddyAgentOptions, HookMatcher
|
|
76
|
+
|
|
77
|
+
async def pre_tool_hook(input_data, tool_use_id, context):
|
|
78
|
+
print(f"About to execute: {input_data}")
|
|
79
|
+
return {"continue_": True}
|
|
80
|
+
|
|
81
|
+
options = CodeBuddyAgentOptions(
|
|
82
|
+
model="deepseek-v3.1",
|
|
83
|
+
hooks={
|
|
84
|
+
"PreToolUse": [
|
|
85
|
+
HookMatcher(
|
|
86
|
+
matcher="Bash", # Only match Bash tool
|
|
87
|
+
hooks=[pre_tool_hook],
|
|
88
|
+
timeout=5.0 # Timeout in seconds
|
|
89
|
+
)
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
async for msg in query(prompt="Help me analyze the code", options=options):
|
|
95
|
+
print(msg)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
### HookMatcher Structure
|
|
101
|
+
|
|
102
|
+
| Field | Type | Description |
|
|
103
|
+
|-------|------|-------------|
|
|
104
|
+
| `matcher` | `string` | Match pattern, supports regex. `*` or empty string matches all |
|
|
105
|
+
| `hooks` | `HookCallback[]` | Array of callback functions |
|
|
106
|
+
| `timeout` | `number` | Timeout (milliseconds in TypeScript, seconds in Python) |
|
|
107
|
+
|
|
108
|
+
### Matcher Patterns
|
|
109
|
+
|
|
110
|
+
- **Exact match**: `"Bash"` only matches Bash tool
|
|
111
|
+
- **Regex match**: `"Edit|Write"` matches Edit or Write
|
|
112
|
+
- **Wildcard**: `"*"` or `""` matches all tools
|
|
113
|
+
- **Prefix match**: `"mcp__.*"` matches all MCP tools
|
|
114
|
+
|
|
115
|
+
## Event Types
|
|
116
|
+
|
|
117
|
+
### PreToolUse
|
|
118
|
+
|
|
119
|
+
Triggered before tool execution, can block execution or modify input.
|
|
120
|
+
|
|
121
|
+
::: code-group
|
|
122
|
+
|
|
123
|
+
```typescript [TypeScript]
|
|
124
|
+
hooks: {
|
|
125
|
+
PreToolUse: [{
|
|
126
|
+
matcher: 'Bash',
|
|
127
|
+
hooks: [
|
|
128
|
+
async (input, toolUseId, ctx) => {
|
|
129
|
+
const command = input.command as string;
|
|
130
|
+
|
|
131
|
+
// Block dangerous commands
|
|
132
|
+
if (command.includes('rm -rf')) {
|
|
133
|
+
return {
|
|
134
|
+
decision: 'block',
|
|
135
|
+
reason: 'Dangerous command blocked'
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return { continue: true };
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}]
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```python [Python]
|
|
147
|
+
async def pre_bash_hook(input_data, tool_use_id, context):
|
|
148
|
+
command = input_data.get("command", "")
|
|
149
|
+
|
|
150
|
+
# Block dangerous commands
|
|
151
|
+
if "rm -rf" in command:
|
|
152
|
+
return {
|
|
153
|
+
"decision": "block",
|
|
154
|
+
"reason": "Dangerous command blocked"
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return {"continue_": True}
|
|
158
|
+
|
|
159
|
+
hooks = {
|
|
160
|
+
"PreToolUse": [
|
|
161
|
+
HookMatcher(matcher="Bash", hooks=[pre_bash_hook])
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
:::
|
|
167
|
+
|
|
168
|
+
### PostToolUse
|
|
169
|
+
|
|
170
|
+
Triggered after successful tool execution, can add extra context.
|
|
171
|
+
|
|
172
|
+
::: code-group
|
|
173
|
+
|
|
174
|
+
```typescript [TypeScript]
|
|
175
|
+
hooks: {
|
|
176
|
+
PostToolUse: [{
|
|
177
|
+
matcher: 'Write|Edit',
|
|
178
|
+
hooks: [
|
|
179
|
+
async (input, toolUseId) => {
|
|
180
|
+
console.log(`File modified: ${input.file_path}`);
|
|
181
|
+
// Log file changes
|
|
182
|
+
await logFileChange(input.file_path);
|
|
183
|
+
return { continue: true };
|
|
184
|
+
}
|
|
185
|
+
]
|
|
186
|
+
}]
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
```python [Python]
|
|
191
|
+
async def post_write_hook(input_data, tool_use_id, context):
|
|
192
|
+
print(f"File modified: {input_data.get('file_path')}")
|
|
193
|
+
# Log file changes
|
|
194
|
+
await log_file_change(input_data.get("file_path"))
|
|
195
|
+
return {"continue_": True}
|
|
196
|
+
|
|
197
|
+
hooks = {
|
|
198
|
+
"PostToolUse": [
|
|
199
|
+
HookMatcher(matcher="Write|Edit", hooks=[post_write_hook])
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
:::
|
|
205
|
+
|
|
206
|
+
### UserPromptSubmit
|
|
207
|
+
|
|
208
|
+
Triggered when user submits a message, can add context or block processing.
|
|
209
|
+
|
|
210
|
+
::: code-group
|
|
211
|
+
|
|
212
|
+
```typescript [TypeScript]
|
|
213
|
+
hooks: {
|
|
214
|
+
UserPromptSubmit: [{
|
|
215
|
+
hooks: [
|
|
216
|
+
async (input) => {
|
|
217
|
+
const prompt = input.prompt as string;
|
|
218
|
+
|
|
219
|
+
// Sensitive word check
|
|
220
|
+
if (containsSensitiveWords(prompt)) {
|
|
221
|
+
return {
|
|
222
|
+
decision: 'block',
|
|
223
|
+
reason: 'Message contains sensitive content'
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return { continue: true };
|
|
228
|
+
}
|
|
229
|
+
]
|
|
230
|
+
}]
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
```python [Python]
|
|
235
|
+
async def prompt_check_hook(input_data, tool_use_id, context):
|
|
236
|
+
prompt = input_data.get("prompt", "")
|
|
237
|
+
|
|
238
|
+
# Sensitive word check
|
|
239
|
+
if contains_sensitive_words(prompt):
|
|
240
|
+
return {
|
|
241
|
+
"decision": "block",
|
|
242
|
+
"reason": "Message contains sensitive content"
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return {"continue_": True}
|
|
246
|
+
|
|
247
|
+
hooks = {
|
|
248
|
+
"UserPromptSubmit": [
|
|
249
|
+
HookMatcher(hooks=[prompt_check_hook])
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
:::
|
|
255
|
+
|
|
256
|
+
### Stop / SubagentStop
|
|
257
|
+
|
|
258
|
+
Triggered when Agent response ends, can block stopping and request continuation.
|
|
259
|
+
|
|
260
|
+
::: code-group
|
|
261
|
+
|
|
262
|
+
```typescript [TypeScript]
|
|
263
|
+
hooks: {
|
|
264
|
+
Stop: [{
|
|
265
|
+
hooks: [
|
|
266
|
+
async (input) => {
|
|
267
|
+
// Check if task is truly complete
|
|
268
|
+
if (!isTaskComplete()) {
|
|
269
|
+
return {
|
|
270
|
+
decision: 'block',
|
|
271
|
+
reason: 'Task incomplete, please continue'
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
return { continue: true };
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
}]
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
```python [Python]
|
|
282
|
+
async def stop_hook(input_data, tool_use_id, context):
|
|
283
|
+
# Check if task is truly complete
|
|
284
|
+
if not is_task_complete():
|
|
285
|
+
return {
|
|
286
|
+
"decision": "block",
|
|
287
|
+
"reason": "Task incomplete, please continue"
|
|
288
|
+
}
|
|
289
|
+
return {"continue_": True}
|
|
290
|
+
|
|
291
|
+
hooks = {
|
|
292
|
+
"Stop": [HookMatcher(hooks=[stop_hook])]
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
:::
|
|
297
|
+
|
|
298
|
+
### unstable_Checkpoint (Experimental)
|
|
299
|
+
|
|
300
|
+
Automatically triggered after file modifications (when Write/Edit/MultiEdit tools execute successfully), providing file snapshots and change statistics.
|
|
301
|
+
|
|
302
|
+
::: warning Experimental API
|
|
303
|
+
This Hook is an experimental feature. The API may change in future versions.
|
|
304
|
+
:::
|
|
305
|
+
|
|
306
|
+
::: code-group
|
|
307
|
+
|
|
308
|
+
```typescript [TypeScript]
|
|
309
|
+
import type { CheckpointHookInput } from '@tencent-ai/agent-sdk';
|
|
310
|
+
|
|
311
|
+
hooks: {
|
|
312
|
+
unstable_Checkpoint: [{
|
|
313
|
+
hooks: [
|
|
314
|
+
async (input) => {
|
|
315
|
+
const checkpointInput = input as CheckpointHookInput;
|
|
316
|
+
const checkpoint = checkpointInput.checkpoint;
|
|
317
|
+
|
|
318
|
+
console.log('File change checkpoint:', {
|
|
319
|
+
id: checkpoint.id,
|
|
320
|
+
label: checkpoint.label,
|
|
321
|
+
files: checkpoint.fileChangeStats?.files,
|
|
322
|
+
additions: checkpoint.fileChangeStats?.additions,
|
|
323
|
+
deletions: checkpoint.fileChangeStats?.deletions
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
// Access file snapshots
|
|
327
|
+
for (const [filePath, version] of Object.entries(checkpoint.fileSnapshots)) {
|
|
328
|
+
console.log(` ${filePath} - version ${version.version}`);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return { continue: true };
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
}]
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
```python [Python]
|
|
339
|
+
async def checkpoint_hook(input_data, tool_use_id, context):
|
|
340
|
+
checkpoint = input_data.get("checkpoint", {})
|
|
341
|
+
|
|
342
|
+
file_change_stats = checkpoint.get("fileChangeStats", {})
|
|
343
|
+
print(f"File change checkpoint:")
|
|
344
|
+
print(f" ID: {checkpoint.get('id')}")
|
|
345
|
+
print(f" Label: {checkpoint.get('label')}")
|
|
346
|
+
print(f" Files: {file_change_stats.get('files', [])}")
|
|
347
|
+
print(f" Additions: +{file_change_stats.get('additions', 0)} lines")
|
|
348
|
+
print(f" Deletions: -{file_change_stats.get('deletions', 0)} lines")
|
|
349
|
+
|
|
350
|
+
# Access file snapshots
|
|
351
|
+
for file_path, version in checkpoint.get("fileSnapshots", {}).items():
|
|
352
|
+
print(f" {file_path} - version {version.get('version')}")
|
|
353
|
+
|
|
354
|
+
return {"continue_": True}
|
|
355
|
+
|
|
356
|
+
hooks = {
|
|
357
|
+
"unstable_Checkpoint": [HookMatcher(hooks=[checkpoint_hook])]
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
:::
|
|
362
|
+
|
|
363
|
+
**Checkpoint Data Structure**:
|
|
364
|
+
|
|
365
|
+
- `id`: Unique checkpoint identifier
|
|
366
|
+
- `label`: Human-readable label (typically the user prompt)
|
|
367
|
+
- `createdAt`: Creation timestamp
|
|
368
|
+
- `fileSnapshots`: Mapping of file paths to version information
|
|
369
|
+
- `filePath`: Absolute file path
|
|
370
|
+
- `version`: Version number
|
|
371
|
+
- `backupFileName`: Backup file name
|
|
372
|
+
- `backupTime`: Backup timestamp
|
|
373
|
+
- `fileChangeStats`: File change statistics
|
|
374
|
+
- `files`: List of changed file paths
|
|
375
|
+
- `additions`: Number of lines added
|
|
376
|
+
- `deletions`: Number of lines deleted
|
|
377
|
+
|
|
378
|
+
## Hook Input
|
|
379
|
+
|
|
380
|
+
The input structure received by hook callbacks varies by event type.
|
|
381
|
+
|
|
382
|
+
### Common Fields
|
|
383
|
+
|
|
384
|
+
```json
|
|
385
|
+
{
|
|
386
|
+
"session_id": "abc123",
|
|
387
|
+
"cwd": "/path/to/project",
|
|
388
|
+
"permission_mode": "default",
|
|
389
|
+
"hook_event_name": "PreToolUse"
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### PreToolUse / PostToolUse Input
|
|
394
|
+
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"tool_name": "Bash",
|
|
398
|
+
"tool_input": {
|
|
399
|
+
"command": "ls -la"
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### UserPromptSubmit Input
|
|
405
|
+
|
|
406
|
+
```json
|
|
407
|
+
{
|
|
408
|
+
"prompt": "Help me write a function"
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
### Stop / SubagentStop Input
|
|
413
|
+
|
|
414
|
+
```json
|
|
415
|
+
{
|
|
416
|
+
"stop_hook_active": false
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**WorktreeCreate Input Example**:
|
|
421
|
+
|
|
422
|
+
```json
|
|
423
|
+
{
|
|
424
|
+
"hook_event_name": "WorktreeCreate",
|
|
425
|
+
"session_id": "abc123",
|
|
426
|
+
"cwd": "/path/to/project",
|
|
427
|
+
"transcript_path": "/path/to/transcript.jsonl",
|
|
428
|
+
"name": "feature-auth"
|
|
429
|
+
}
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
**WorktreeRemove Input Example**:
|
|
433
|
+
|
|
434
|
+
```json
|
|
435
|
+
{
|
|
436
|
+
"hook_event_name": "WorktreeRemove",
|
|
437
|
+
"session_id": "abc123",
|
|
438
|
+
"cwd": "/path/to/project",
|
|
439
|
+
"transcript_path": "/path/to/transcript.jsonl",
|
|
440
|
+
"worktree_path": "/tmp/codebuddy-worktrees/feature-auth"
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### unstable_Checkpoint Input
|
|
445
|
+
|
|
446
|
+
```json
|
|
447
|
+
{
|
|
448
|
+
"checkpoint": {
|
|
449
|
+
"id": "ckpt_abc123",
|
|
450
|
+
"label": "Help me write a function",
|
|
451
|
+
"createdAt": 1705920000000,
|
|
452
|
+
"fileSnapshots": {
|
|
453
|
+
"/path/to/file.ts": {
|
|
454
|
+
"filePath": "/path/to/file.ts",
|
|
455
|
+
"version": 1,
|
|
456
|
+
"backupFileName": "file.ts.v1.backup",
|
|
457
|
+
"backupTime": 1705920000000
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
"fileChangeStats": {
|
|
461
|
+
"files": ["/path/to/file.ts"],
|
|
462
|
+
"additions": 10,
|
|
463
|
+
"deletions": 2
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
## Hook Output
|
|
470
|
+
|
|
471
|
+
The output returned by hook callbacks controls subsequent behavior.
|
|
472
|
+
|
|
473
|
+
### Basic Output Fields
|
|
474
|
+
|
|
475
|
+
| Field | Type | Description |
|
|
476
|
+
|-------|------|-------------|
|
|
477
|
+
| `continue` / `continue_` | `boolean` | Whether to continue execution (default true) |
|
|
478
|
+
| `decision` | `'block'` | Set to `'block'` to prevent operation |
|
|
479
|
+
| `reason` | `string` | Reason for blocking |
|
|
480
|
+
| `stopReason` | `string` | Stop message displayed when `continue` is false |
|
|
481
|
+
| `suppressOutput` | `boolean` | Hide output |
|
|
482
|
+
|
|
483
|
+
### PreToolUse Special Output
|
|
484
|
+
|
|
485
|
+
Can modify tool input:
|
|
486
|
+
|
|
487
|
+
::: code-group
|
|
488
|
+
|
|
489
|
+
```typescript [TypeScript]
|
|
490
|
+
return {
|
|
491
|
+
continue: true,
|
|
492
|
+
hookSpecificOutput: {
|
|
493
|
+
hookEventName: 'PreToolUse',
|
|
494
|
+
updatedInput: {
|
|
495
|
+
command: `echo "Security check passed" && ${input.command}`
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
};
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
```python [Python]
|
|
502
|
+
return {
|
|
503
|
+
"continue_": True,
|
|
504
|
+
"hookSpecificOutput": {
|
|
505
|
+
"hookEventName": "PreToolUse",
|
|
506
|
+
"updatedInput": {
|
|
507
|
+
"command": f'echo "Security check passed" && {input_data["command"]}'
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
:::
|
|
514
|
+
|
|
515
|
+
## Examples
|
|
516
|
+
|
|
517
|
+
### Complete Example: Bash Command Auditing
|
|
518
|
+
|
|
519
|
+
::: code-group
|
|
520
|
+
|
|
521
|
+
```typescript [TypeScript]
|
|
522
|
+
import { query } from '@tencent-ai/agent-sdk';
|
|
523
|
+
import * as fs from 'fs';
|
|
524
|
+
|
|
525
|
+
const logFile = '/tmp/bash-audit.log';
|
|
526
|
+
|
|
527
|
+
const q = query({
|
|
528
|
+
prompt: 'Help me clean temporary files',
|
|
529
|
+
options: {
|
|
530
|
+
model: 'deepseek-v3.1',
|
|
531
|
+
hooks: {
|
|
532
|
+
PreToolUse: [{
|
|
533
|
+
matcher: 'Bash',
|
|
534
|
+
hooks: [
|
|
535
|
+
async (input, toolUseId) => {
|
|
536
|
+
const command = input.command as string;
|
|
537
|
+
const timestamp = new Date().toISOString();
|
|
538
|
+
|
|
539
|
+
// Log command
|
|
540
|
+
fs.appendFileSync(logFile, `${timestamp} [PRE] ${command}\n`);
|
|
541
|
+
|
|
542
|
+
// Dangerous command check
|
|
543
|
+
const dangerous = ['rm -rf /', 'mkfs', ':(){:|:&};:'];
|
|
544
|
+
for (const d of dangerous) {
|
|
545
|
+
if (command.includes(d)) {
|
|
546
|
+
return {
|
|
547
|
+
decision: 'block',
|
|
548
|
+
reason: `Dangerous command blocked: ${d}`
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
return { continue: true };
|
|
554
|
+
}
|
|
555
|
+
]
|
|
556
|
+
}],
|
|
557
|
+
PostToolUse: [{
|
|
558
|
+
matcher: 'Bash',
|
|
559
|
+
hooks: [
|
|
560
|
+
async (input, toolUseId) => {
|
|
561
|
+
const command = input.command as string;
|
|
562
|
+
const timestamp = new Date().toISOString();
|
|
563
|
+
|
|
564
|
+
// Log completion
|
|
565
|
+
fs.appendFileSync(logFile, `${timestamp} [POST] ${command} - Complete\n`);
|
|
566
|
+
|
|
567
|
+
return { continue: true };
|
|
568
|
+
}
|
|
569
|
+
]
|
|
570
|
+
}]
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
for await (const message of q) {
|
|
576
|
+
console.log(message);
|
|
577
|
+
}
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
```python [Python]
|
|
581
|
+
import asyncio
|
|
582
|
+
from datetime import datetime
|
|
583
|
+
from codebuddy_agent_sdk import query, CodeBuddyAgentOptions, HookMatcher
|
|
584
|
+
|
|
585
|
+
log_file = "/tmp/bash-audit.log"
|
|
586
|
+
|
|
587
|
+
async def pre_bash_hook(input_data, tool_use_id, context):
|
|
588
|
+
command = input_data.get("command", "")
|
|
589
|
+
timestamp = datetime.now().isoformat()
|
|
590
|
+
|
|
591
|
+
# Log command
|
|
592
|
+
with open(log_file, "a") as f:
|
|
593
|
+
f.write(f"{timestamp} [PRE] {command}\n")
|
|
594
|
+
|
|
595
|
+
# Dangerous command check
|
|
596
|
+
dangerous = ["rm -rf /", "mkfs", ":(){:|:&};:"]
|
|
597
|
+
for d in dangerous:
|
|
598
|
+
if d in command:
|
|
599
|
+
return {
|
|
600
|
+
"decision": "block",
|
|
601
|
+
"reason": f"Dangerous command blocked: {d}"
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
return {"continue_": True}
|
|
605
|
+
|
|
606
|
+
async def post_bash_hook(input_data, tool_use_id, context):
|
|
607
|
+
command = input_data.get("command", "")
|
|
608
|
+
timestamp = datetime.now().isoformat()
|
|
609
|
+
|
|
610
|
+
# Log completion
|
|
611
|
+
with open(log_file, "a") as f:
|
|
612
|
+
f.write(f"{timestamp} [POST] {command} - Complete\n")
|
|
613
|
+
|
|
614
|
+
return {"continue_": True}
|
|
615
|
+
|
|
616
|
+
async def main():
|
|
617
|
+
options = CodeBuddyAgentOptions(
|
|
618
|
+
model="deepseek-v3.1",
|
|
619
|
+
hooks={
|
|
620
|
+
"PreToolUse": [
|
|
621
|
+
HookMatcher(matcher="Bash", hooks=[pre_bash_hook])
|
|
622
|
+
],
|
|
623
|
+
"PostToolUse": [
|
|
624
|
+
HookMatcher(matcher="Bash", hooks=[post_bash_hook])
|
|
625
|
+
]
|
|
626
|
+
}
|
|
627
|
+
)
|
|
628
|
+
|
|
629
|
+
async for message in query(prompt="Help me clean temporary files", options=options):
|
|
630
|
+
print(message)
|
|
631
|
+
|
|
632
|
+
asyncio.run(main())
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
:::
|
|
636
|
+
|
|
637
|
+
### Example: Limiting File Modification Scope
|
|
638
|
+
|
|
639
|
+
::: code-group
|
|
640
|
+
|
|
641
|
+
```typescript [TypeScript]
|
|
642
|
+
hooks: {
|
|
643
|
+
PreToolUse: [{
|
|
644
|
+
matcher: 'Write|Edit',
|
|
645
|
+
hooks: [
|
|
646
|
+
async (input) => {
|
|
647
|
+
const filePath = input.file_path as string;
|
|
648
|
+
|
|
649
|
+
// Only allow modifying src directory
|
|
650
|
+
if (!filePath.startsWith('/path/to/project/src/')) {
|
|
651
|
+
return {
|
|
652
|
+
decision: 'block',
|
|
653
|
+
reason: `Not allowed to modify files outside src directory: ${filePath}`
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// Prohibit modifying config files
|
|
658
|
+
if (filePath.endsWith('.env') || filePath.includes('.git/')) {
|
|
659
|
+
return {
|
|
660
|
+
decision: 'block',
|
|
661
|
+
reason: 'Not allowed to modify sensitive files'
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
return { continue: true };
|
|
666
|
+
}
|
|
667
|
+
]
|
|
668
|
+
}]
|
|
669
|
+
}
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
```python [Python]
|
|
673
|
+
async def file_scope_hook(input_data, tool_use_id, context):
|
|
674
|
+
file_path = input_data.get("file_path", "")
|
|
675
|
+
|
|
676
|
+
# Only allow modifying src directory
|
|
677
|
+
if not file_path.startswith("/path/to/project/src/"):
|
|
678
|
+
return {
|
|
679
|
+
"decision": "block",
|
|
680
|
+
"reason": f"Not allowed to modify files outside src directory: {file_path}"
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
# Prohibit modifying config files
|
|
684
|
+
if file_path.endswith(".env") or ".git/" in file_path:
|
|
685
|
+
return {
|
|
686
|
+
"decision": "block",
|
|
687
|
+
"reason": "Not allowed to modify sensitive files"
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
return {"continue_": True}
|
|
691
|
+
|
|
692
|
+
hooks = {
|
|
693
|
+
"PreToolUse": [
|
|
694
|
+
HookMatcher(matcher="Write|Edit", hooks=[file_scope_hook])
|
|
695
|
+
]
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
:::
|
|
700
|
+
|
|
701
|
+
### Example: File Change Tracking (Checkpoint Hook)
|
|
702
|
+
|
|
703
|
+
::: code-group
|
|
704
|
+
|
|
705
|
+
```typescript [TypeScript]
|
|
706
|
+
import { query, type CheckpointHookInput } from '@tencent-ai/agent-sdk';
|
|
707
|
+
import * as fs from 'fs';
|
|
708
|
+
|
|
709
|
+
const changeLog = '/tmp/file-changes.log';
|
|
710
|
+
|
|
711
|
+
const q = query({
|
|
712
|
+
prompt: 'Refactor src/utils.ts',
|
|
713
|
+
options: {
|
|
714
|
+
model: 'deepseek-v3.1',
|
|
715
|
+
hooks: {
|
|
716
|
+
unstable_Checkpoint: [{
|
|
717
|
+
hooks: [
|
|
718
|
+
async (input) => {
|
|
719
|
+
const checkpointInput = input as CheckpointHookInput;
|
|
720
|
+
const checkpoint = checkpointInput.checkpoint;
|
|
721
|
+
const stats = checkpoint.fileChangeStats;
|
|
722
|
+
|
|
723
|
+
if (!stats) return { continue: true };
|
|
724
|
+
|
|
725
|
+
// Log file changes
|
|
726
|
+
const timestamp = new Date().toISOString();
|
|
727
|
+
const logEntry = `
|
|
728
|
+
[${timestamp}] Checkpoint ${checkpoint.id}
|
|
729
|
+
Label: ${checkpoint.label}
|
|
730
|
+
Files: ${stats.files.join(', ')}
|
|
731
|
+
Changes: +${stats.additions}/-${stats.deletions}
|
|
732
|
+
Snapshots: ${Object.keys(checkpoint.fileSnapshots).length} files
|
|
733
|
+
`;
|
|
734
|
+
|
|
735
|
+
fs.appendFileSync(changeLog, logEntry);
|
|
736
|
+
|
|
737
|
+
// Warn if changes are too large
|
|
738
|
+
if (stats.additions + stats.deletions > 100) {
|
|
739
|
+
console.warn('⚠️ Large amount of code changes, review recommended');
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
return { continue: true };
|
|
743
|
+
}
|
|
744
|
+
]
|
|
745
|
+
}]
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
|
|
750
|
+
for await (const message of q) {
|
|
751
|
+
console.log(message);
|
|
752
|
+
}
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
```python [Python]
|
|
756
|
+
import asyncio
|
|
757
|
+
from datetime import datetime
|
|
758
|
+
from codebuddy_agent_sdk import query, CodeBuddyAgentOptions, HookMatcher
|
|
759
|
+
|
|
760
|
+
change_log = "/tmp/file-changes.log"
|
|
761
|
+
|
|
762
|
+
async def checkpoint_tracker(input_data, tool_use_id, context):
|
|
763
|
+
checkpoint = input_data.get("checkpoint", {})
|
|
764
|
+
stats = checkpoint.get("fileChangeStats")
|
|
765
|
+
|
|
766
|
+
if not stats:
|
|
767
|
+
return {"continue_": True}
|
|
768
|
+
|
|
769
|
+
# Log file changes
|
|
770
|
+
timestamp = datetime.now().isoformat()
|
|
771
|
+
log_entry = f"""
|
|
772
|
+
[{timestamp}] Checkpoint {checkpoint.get('id')}
|
|
773
|
+
Label: {checkpoint.get('label')}
|
|
774
|
+
Files: {', '.join(stats.get('files', []))}
|
|
775
|
+
Changes: +{stats.get('additions', 0)}/-{stats.get('deletions', 0)}
|
|
776
|
+
Snapshots: {len(checkpoint.get('fileSnapshots', {}))} files
|
|
777
|
+
"""
|
|
778
|
+
|
|
779
|
+
with open(change_log, "a") as f:
|
|
780
|
+
f.write(log_entry)
|
|
781
|
+
|
|
782
|
+
# Warn if changes are too large
|
|
783
|
+
total_changes = stats.get("additions", 0) + stats.get("deletions", 0)
|
|
784
|
+
if total_changes > 100:
|
|
785
|
+
print("⚠️ Large amount of code changes, review recommended")
|
|
786
|
+
|
|
787
|
+
return {"continue_": True}
|
|
788
|
+
|
|
789
|
+
async def main():
|
|
790
|
+
options = CodeBuddyAgentOptions(
|
|
791
|
+
model="deepseek-v3.1",
|
|
792
|
+
hooks={
|
|
793
|
+
"unstable_Checkpoint": [
|
|
794
|
+
HookMatcher(hooks=[checkpoint_tracker])
|
|
795
|
+
]
|
|
796
|
+
}
|
|
797
|
+
)
|
|
798
|
+
|
|
799
|
+
async for message in query(prompt="Refactor src/utils.ts", options=options):
|
|
800
|
+
print(message)
|
|
801
|
+
|
|
802
|
+
asyncio.run(main())
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
:::
|
|
806
|
+
|
|
807
|
+
## Related Documentation
|
|
808
|
+
|
|
809
|
+
- [SDK Overview](sdk.md) - Quick start and usage examples
|
|
810
|
+
- [SDK Permission Control](sdk-permissions.md) - canUseTool callback
|
|
811
|
+
- [Hook Reference Guide](hooks.md) - Complete CLI Hook reference
|
|
812
|
+
- [TypeScript SDK Reference](sdk-typescript.md) - Complete API reference
|
|
813
|
+
- [Python SDK Reference](sdk-python.md) - Complete API reference
|