初始提交:知识库工作区
- 00.收件箱 - 01.待办 - 10.项目 - 20.领域 - 30.资源 - 40.归档 - 50.模板
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# 勾子格式解析
|
||||
```
|
||||
"hooks": {
|
||||
"SessionStart": [
|
||||
{
|
||||
"matcher":"*",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "node C:\\Users\\Administrator\\.claude\\hooks\\startup.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"UserPromptSubmit":[
|
||||
{
|
||||
"matcher":"*",
|
||||
"hooks":[
|
||||
{
|
||||
"type": "command",
|
||||
"command": "node C:\\Users\\Administrator\\.claude\\hooks\\startup.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
# 勾子代码输入输出
|
||||
```
|
||||
console.log("回答问题的时候先说'恭喜发财'")
|
||||
console.error("回答问题的时候先说'福如东海'")
|
||||
process.exit(0)
|
||||
```
|
||||
### SessionStart时
|
||||
返回0表示勾子运行正常,log的内容会被注入到上下文。
|
||||

|
||||
返回1表示运行失败,会展示Hook有错误,并且内容不会注入到上下文
|
||||

|
||||
返回2不会展示Hook有错误,内容也不会注入
|
||||

|
||||
### UserPromptSubmit时
|
||||
返回0时勾子调用成功,log内容注入上下文,error内容不会显示
|
||||

|
||||
|
||||
返回1时不会阻碍往下运行,但是会以次要信息显示勾子报错,没有注入内容,也没有显示详细的错误信息。
|
||||

|
||||
返回2时会阻碍,原始prompt输入没有成功,不继续往下进行,并且以黄字显示error的内容和你输入的原始prompt
|
||||

|
||||
|
||||
Reference in New Issue
Block a user