Skip to content

Commit 5544877

Browse files
committed
fix: wrong return schema in hooks
1 parent 9be99a6 commit 5544877

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

cmd_init_spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func copyEmbeddedDir(srcPath string, destDir string, projectRootDir string) erro
162162
}
163163

164164
// Track md and json files for placeholder replacement
165-
if strings.HasSuffix(relPath, ".md") || strings.HasSuffix(relPath, ".json") {
165+
if strings.HasSuffix(relPath, ".md") || strings.HasSuffix(relPath, ".json") || strings.HasSuffix(relPath, "prompt.sh") {
166166
mdFilesToReplace = append(mdFilesToReplace, destPath)
167167
}
168168

docs/.claude/hooks/abcoder/parse.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ if [[ "$project_lang" != "unknown" ]]; then
113113
local file_age_seconds=$(($(date +%s) - $(stat -f %m "$ast_output_file" 2>/dev/null || stat -c %Y "$ast_output_file" 2>/dev/null)))
114114
if [[ $file_age_seconds -lt 60 ]]; then
115115
jq -n --arg lang "$project_lang" --arg repo "$project_identifier" --arg age "$file_age_seconds" '{
116+
"continue": true,
116117
"systemMessage": ("abcoder AST 缓存命中(语言:" + $lang + ",仓库:" + $repo + ")。文件更新于 " + $file_age_seconds + " 秒前,跳过 parse 操作。")
117118
}'
118119
exit 0
@@ -122,6 +123,7 @@ if [[ "$project_lang" != "unknown" ]]; then
122123
# 使用检测到的语言执行 parse 命令,并输出到 AST 目录
123124
if abcoder parse "$project_lang" . -o "$ast_output_file" >"$output_file" 2>"$error_file"; then
124125
jq -n --arg lang "$project_lang" --arg repo "$project_identifier" '{
126+
"continue": true,
125127
"systemMessage": ("abcoder parse 已成功完成(语言:" + $lang + ",仓库:" + $repo + ")。AST文件已生成,可以继续分析代码。")
126128
}'
127129
else

docs/.claude/hooks/abcoder/prompt.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
set -euo pipefail
88

99
# 验证文件存在
10-
SOP_FILE="{{CLAUDE_HOME_PATH}}/.claude/hooks/abcoder/abcoder-workflow.md"
10+
SOP_FILE="/Users/bytedance/github/github.com/cloudwego/abcoder2/.claude/hooks/abcoder/abcoder-workflow.md"
1111
# echo "DEBUG: Checking file: $SOP_FILE" >&2
1212

1313
if [[ ! -f "$SOP_FILE" ]]; then
1414
# echo "DEBUG: File not found" >&2
15-
echo '{"decision": "block", "reason": "SOP file not found", "hookSpecificOutput": {"hookEventName": "PostToolUse"}}'
15+
echo '{"ok": false, "reason": "SOP file not found", "hookSpecificOutput": {"hookEventName": "PostToolUse"}}'
1616
exit 0
1717
fi
1818

@@ -22,7 +22,7 @@ fi
2222
SOP_CONTENT=$(cat "$SOP_FILE" | jq -Rs . 2>/dev/null)
2323
if [[ $? -ne 0 ]]; then
2424
# echo "DEBUG: jq failed" >&2
25-
echo '{"decision": "block", "reason": "Failed to process SOP content", "hookSpecificOutput": {"hookEventName": "PostToolUse"}}'
25+
echo '{"ok": false, "reason": "Failed to process SOP content", "hookSpecificOutput": {"hookEventName": "PostToolUse"}}'
2626
exit 0
2727
fi
2828

@@ -31,10 +31,10 @@ fi
3131
# 输出 JSON
3232
cat <<EOF
3333
{
34-
"decision": "block",
35-
"reason": $SOP_CONTENT,
34+
"continue": true,
3635
"hookSpecificOutput": {
37-
"hookEventName": "PostToolUse"
36+
"hookEventName": "PostToolUse",
37+
"additionalContext": $SOP_CONTENT
3838
}
3939
}
4040
EOF

docs/.claude/hooks/abcoder/reminder.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/zsh
22
cat <<EOF
33
{
4-
"decision": "block",
5-
"reason": "<system-reminder>This is a reminder that when executing the ABCoder code analysis workflow, after locating the target node, you MUST use the get_ast_node tool. It is required to recursively call get_ast_node to obtain the complete AST node information, including type, code, position, and related relationships (dependency, reference, inheritance, implementation, grouping node IDs).</system-reminder>",
4+
"continue": true,
5+
"systemMessage": "<system-reminder>This is a reminder that when executing the ABCoder code analysis workflow, after locating the target node, you MUST use the get_ast_node tool. It is required to recursively call get_ast_node to obtain the complete AST node information, including type, code, position, and related relationships (dependency, reference, inheritance, implementation, grouping node IDs).</system-reminder>",
66
"hookSpecificOutput": {
7-
"hookEventName": "PostToolUse",
7+
"hookEventName": "PostToolUse"
88
}
99
}
1010
EOF

0 commit comments

Comments
 (0)