aico-cli 0.3.10 → 0.3.13
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/dist/chunks/simple-config.mjs +1 -13
- package/package.json +1 -1
- package/templates/agents/aico/plan/shell-scripting-expert.md +104 -0
- package/templates/commands/aico/requirement.md +6 -0
- package/templates/commands/base//344/273/243/347/240/201/345/256/241/346/237/245/346/231/272/350/203/275/344/275/223.md +322 -0
- package/templates/hooks/README.md +198 -0
- package/templates/hooks/hooks-config.json +47 -0
- package/templates/hooks/notify.sh +103 -0
- package/templates/hooks/requirement/common-utils.sh +186 -0
- package/templates/hooks/requirement/post-requirement-aligner.sh +61 -0
- package/templates/hooks/requirement/post-requirement-identifier.sh +58 -0
- package/templates/hooks/requirement/post-task-executor-validator.sh +96 -0
- package/templates/hooks/requirement/post-task-executor.sh +78 -0
- package/templates/hooks/requirement/post-task-splitter-validator.sh +73 -0
- package/templates/hooks/requirement/pre-requirement-aligner.sh +70 -0
- package/templates/hooks/requirement/pre-requirement-identifier.sh +61 -0
- package/templates/hooks/requirement/pre-task-executor-validator.sh +81 -0
- package/templates/hooks/requirement/pre-task-executor.sh +91 -0
- package/templates/hooks/requirement/pre-task-splitter-validator.sh +61 -0
- package/templates/hooks/requirement-processor.sh +180 -0
- package/templates/hooks/sounds/complete.wav +0 -0
- package/templates/hooks/sounds/input-needed.wav +0 -0
- package/templates/hooks/subagent-context-injector.sh +65 -0
- package/templates/personality.md +19 -48
- package/templates/settings.json +0 -1
- /package/templates/commands/base/{fix-error.md → bug/344/277/256/345/244/215/346/231/272/350/203/275/344/275/223.md"} +0 -0
- /package/templates/commands/{aico → base}//345/212/237/350/203/275/347/202/271/346/265/213/347/256/227.md" +0 -0
- /package/templates/commands/base/{tech-debt.md → /346/212/200/346/234/257/345/200/272/345/212/241/345/244/204/347/220/206/346/231/272/350/203/275/344/275/223.md"} +0 -0
- /package/templates/commands/base/{ultrathink.md → /347/273/223/346/236/204/345/214/226/346/200/235/347/273/264/346/216/242/350/256/250/346/231/272/350/203/275/344/275/223.md"} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"description": "需求管理生命周期 Hook 配置",
|
|
4
|
+
"hooks": {
|
|
5
|
+
"requirement-identifier": {
|
|
6
|
+
"pre": "requirement/pre-requirement-identifier.sh",
|
|
7
|
+
"post": "requirement/post-requirement-identifier.sh",
|
|
8
|
+
"dependencies": [],
|
|
9
|
+
"timeout": 30000,
|
|
10
|
+
"enabled": true
|
|
11
|
+
},
|
|
12
|
+
"requirement-aligner": {
|
|
13
|
+
"pre": "requirement/pre-requirement-aligner.sh",
|
|
14
|
+
"post": "requirement/post-requirement-aligner.sh",
|
|
15
|
+
"dependencies": ["requirement-identifier"],
|
|
16
|
+
"timeout": 30000,
|
|
17
|
+
"enabled": true
|
|
18
|
+
},
|
|
19
|
+
"task-splitter-validator": {
|
|
20
|
+
"pre": "requirement/pre-task-splitter-validator.sh",
|
|
21
|
+
"post": "requirement/post-task-splitter-validator.sh",
|
|
22
|
+
"dependencies": ["requirement-aligner"],
|
|
23
|
+
"timeout": 30000,
|
|
24
|
+
"enabled": true
|
|
25
|
+
},
|
|
26
|
+
"task-executor": {
|
|
27
|
+
"pre": "requirement/pre-task-executor.sh",
|
|
28
|
+
"post": "requirement/post-task-executor.sh",
|
|
29
|
+
"dependencies": ["task-splitter-validator"],
|
|
30
|
+
"timeout": 60000,
|
|
31
|
+
"enabled": true
|
|
32
|
+
},
|
|
33
|
+
"task-executor-validator": {
|
|
34
|
+
"pre": "requirement/pre-task-executor-validator.sh",
|
|
35
|
+
"post": "requirement/post-task-executor-validator.sh",
|
|
36
|
+
"dependencies": ["task-executor"],
|
|
37
|
+
"timeout": 30000,
|
|
38
|
+
"enabled": true
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"global": {
|
|
42
|
+
"maxRetries": 3,
|
|
43
|
+
"retryDelay": 1000,
|
|
44
|
+
"logLevel": "info",
|
|
45
|
+
"tempDir": "/tmp/aico-hooks"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Claude Code notification hook script
|
|
3
|
+
# Plays pleasant sounds when Claude needs input or completes tasks
|
|
4
|
+
|
|
5
|
+
# Get the directory where this script is located
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
7
|
+
SOUNDS_DIR="$SCRIPT_DIR/sounds"
|
|
8
|
+
|
|
9
|
+
# Function to play a sound file with cross-platform support
|
|
10
|
+
play_sound_file() {
|
|
11
|
+
local sound_file="$1"
|
|
12
|
+
|
|
13
|
+
# Check if file exists
|
|
14
|
+
if [[ ! -f "$sound_file" ]]; then
|
|
15
|
+
echo "Warning: Sound file not found: $sound_file" >&2
|
|
16
|
+
return 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
# Detect OS and use appropriate command-line audio player
|
|
20
|
+
local os_type="$(uname -s)"
|
|
21
|
+
|
|
22
|
+
case "$os_type" in
|
|
23
|
+
Darwin*) # macOS
|
|
24
|
+
if command -v afplay &> /dev/null; then
|
|
25
|
+
afplay "$sound_file" 2>/dev/null &
|
|
26
|
+
return 0 # Exit immediately after starting playback
|
|
27
|
+
fi
|
|
28
|
+
;;
|
|
29
|
+
|
|
30
|
+
Linux*) # Linux
|
|
31
|
+
# Try PulseAudio first (most common on modern desktop Linux)
|
|
32
|
+
if command -v paplay &> /dev/null; then
|
|
33
|
+
paplay "$sound_file" 2>/dev/null &
|
|
34
|
+
return 0 # Exit immediately after starting playback
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Try ALSA
|
|
38
|
+
if command -v aplay &> /dev/null; then
|
|
39
|
+
aplay -q "$sound_file" 2>/dev/null &
|
|
40
|
+
return 0 # Exit immediately after starting playback
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Try PipeWire (newer systems)
|
|
44
|
+
if command -v pw-play &> /dev/null; then
|
|
45
|
+
pw-play "$sound_file" 2>/dev/null &
|
|
46
|
+
return 0 # Exit immediately after starting playback
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Try sox play command
|
|
50
|
+
if command -v play &> /dev/null; then
|
|
51
|
+
play -q "$sound_file" 2>/dev/null &
|
|
52
|
+
return 0 # Exit immediately after starting playback
|
|
53
|
+
fi
|
|
54
|
+
;;
|
|
55
|
+
|
|
56
|
+
MINGW*|CYGWIN*|MSYS*) # Windows (Git Bash, WSL, etc.)
|
|
57
|
+
# Try PowerShell
|
|
58
|
+
if command -v powershell.exe &> /dev/null; then
|
|
59
|
+
# Use Windows Media Player COM object for better compatibility
|
|
60
|
+
# Run in background and exit immediately
|
|
61
|
+
powershell.exe -NoProfile -Command "
|
|
62
|
+
Start-Job -ScriptBlock {
|
|
63
|
+
\$player = New-Object -ComObject WMPlayer.OCX
|
|
64
|
+
\$player.URL = '$sound_file'
|
|
65
|
+
\$player.controls.play()
|
|
66
|
+
Start-Sleep -Milliseconds 1000
|
|
67
|
+
\$player.close()
|
|
68
|
+
}
|
|
69
|
+
" 2>/dev/null
|
|
70
|
+
return 0 # Exit immediately after starting playback
|
|
71
|
+
fi
|
|
72
|
+
;;
|
|
73
|
+
esac
|
|
74
|
+
|
|
75
|
+
# If we have ffplay (cross-platform)
|
|
76
|
+
if command -v ffplay &> /dev/null; then
|
|
77
|
+
ffplay -nodisp -autoexit -loglevel quiet "$sound_file" 2>/dev/null &
|
|
78
|
+
return 0 # Exit immediately after starting playback
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
# No audio player found - fail silently
|
|
82
|
+
return 1
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
# Main script logic
|
|
86
|
+
case "$1" in
|
|
87
|
+
"input")
|
|
88
|
+
play_sound_file "$SOUNDS_DIR/input-needed.wav"
|
|
89
|
+
;;
|
|
90
|
+
|
|
91
|
+
"complete")
|
|
92
|
+
play_sound_file "$SOUNDS_DIR/complete.wav"
|
|
93
|
+
;;
|
|
94
|
+
|
|
95
|
+
*)
|
|
96
|
+
echo "Usage: $0 {input|complete}" >&2
|
|
97
|
+
echo " input - Play sound when Claude needs user input" >&2
|
|
98
|
+
echo " complete - Play sound when Claude completes tasks" >&2
|
|
99
|
+
exit 1
|
|
100
|
+
;;
|
|
101
|
+
esac
|
|
102
|
+
|
|
103
|
+
exit 0
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 需求管理 Hook 通用工具库
|
|
3
|
+
|
|
4
|
+
# 加载跨平台基础工具
|
|
5
|
+
# 计算相对路径
|
|
6
|
+
HOOKS_DIR="$(dirname "$(dirname "${BASH_SOURCE[0]}")")"
|
|
7
|
+
CROSSPLATFORM_UTILS="$HOOKS_DIR/../agents/aico/requirement/crossplatform-utils.sh"
|
|
8
|
+
|
|
9
|
+
if [ -f "$CROSSPLATFORM_UTILS" ]; then
|
|
10
|
+
source "$CROSSPLATFORM_UTILS"
|
|
11
|
+
else
|
|
12
|
+
echo "⚠️ 跨平台工具库未找到: $CROSSPLATFORM_UTILS"
|
|
13
|
+
# 提供基本的兼容函数
|
|
14
|
+
get_timestamp() { date '+%Y-%m-%d %H:%M:%S'; }
|
|
15
|
+
safe_mkdir() { mkdir -p "$1"; }
|
|
16
|
+
safe_rmdir() { rm -rf "$1" 2>/dev/null || true; }
|
|
17
|
+
get_temp_dir() { echo "/tmp"; }
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Hook 日志函数
|
|
21
|
+
hook_log() {
|
|
22
|
+
local level="$1"
|
|
23
|
+
local message="$2"
|
|
24
|
+
local timestamp=$(get_timestamp)
|
|
25
|
+
|
|
26
|
+
case "$level" in
|
|
27
|
+
"INFO") echo "[INFO] $timestamp - $message" ;;
|
|
28
|
+
"WARN") echo "[WARN] $timestamp - $message" >&2 ;;
|
|
29
|
+
"ERROR") echo "[ERROR] $timestamp - $message" >&2 ;;
|
|
30
|
+
"DEBUG") echo "[DEBUG] $timestamp - $message" ;;
|
|
31
|
+
*) echo "[$level] $timestamp - $message" ;;
|
|
32
|
+
esac
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# 检查 Hook 前置条件
|
|
36
|
+
check_hook_prerequisites() {
|
|
37
|
+
local hook_name="$1"
|
|
38
|
+
local config_file="$HOOKS_DIR/hooks-config.json"
|
|
39
|
+
|
|
40
|
+
if [ ! -f "$config_file" ]; then
|
|
41
|
+
hook_log "WARN" "Hook 配置文件不存在: $config_file,跳过配置检查"
|
|
42
|
+
return 0
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# 检查 Hook 是否启用
|
|
46
|
+
if command -v jq >/dev/null 2>&1; then
|
|
47
|
+
local enabled=$(jq -r ".hooks.\"$hook_name\".enabled" "$config_file" 2>/dev/null)
|
|
48
|
+
if [ "$enabled" != "true" ]; then
|
|
49
|
+
hook_log "WARN" "Hook $hook_name 未启用,跳过执行"
|
|
50
|
+
return 2
|
|
51
|
+
fi
|
|
52
|
+
else
|
|
53
|
+
hook_log "DEBUG" "jq 命令不可用,跳过配置检查"
|
|
54
|
+
fi
|
|
55
|
+
|
|
56
|
+
return 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# 执行 Hook 脚本
|
|
60
|
+
execute_hook() {
|
|
61
|
+
local hook_type="$1" # pre 或 post
|
|
62
|
+
local hook_name="$2" # hook 名称
|
|
63
|
+
local hook_args="${@:3}" # 额外参数
|
|
64
|
+
|
|
65
|
+
local config_file="$HOOKS_DIR/hooks-config.json"
|
|
66
|
+
local hook_script=""
|
|
67
|
+
|
|
68
|
+
if [ -f "$config_file" ] && command -v jq >/dev/null 2>&1; then
|
|
69
|
+
hook_script=$(jq -r ".hooks.\"$hook_name\".\"$hook_type\"" "$config_file" 2>/dev/null)
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
# 如果没有配置文件或 jq 不可用,使用默认路径
|
|
73
|
+
if [ -z "$hook_script" ] || [ "$hook_script" = "null" ]; then
|
|
74
|
+
hook_script="requirement/$hook_type-$hook_name.sh"
|
|
75
|
+
hook_log "DEBUG" "使用默认 Hook 路径: $hook_script"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
local full_script_path="$HOOKS_DIR/$hook_script"
|
|
79
|
+
|
|
80
|
+
if [ ! -f "$full_script_path" ]; then
|
|
81
|
+
hook_log "ERROR" "Hook 脚本不存在: $full_script_path"
|
|
82
|
+
return 1
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
if [ ! -x "$full_script_path" ]; then
|
|
86
|
+
set_executable "$full_script_path"
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
hook_log "INFO" "执行 $hook_type hook: $hook_name"
|
|
90
|
+
|
|
91
|
+
# 执行 hook 脚本
|
|
92
|
+
if "$full_script_path" $hook_args; then
|
|
93
|
+
hook_log "INFO" "Hook $hook_name $hook_type 执行成功"
|
|
94
|
+
return 0
|
|
95
|
+
else
|
|
96
|
+
hook_log "ERROR" "Hook $hook_name $hook_type 执行失败"
|
|
97
|
+
return 1
|
|
98
|
+
fi
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
# 检查依赖关系
|
|
102
|
+
check_dependencies() {
|
|
103
|
+
local hook_name="$1"
|
|
104
|
+
local config_file="$(dirname "${BASH_SOURCE[0]}")/../../hooks-config.json"
|
|
105
|
+
|
|
106
|
+
local dependencies=$(jq -r ".hooks.\"$hook_name\".dependencies[]" "$config_file" 2>/dev/null)
|
|
107
|
+
|
|
108
|
+
for dep in $dependencies; do
|
|
109
|
+
if [ -n "$dep" ] && [ "$dep" != "null" ]; then
|
|
110
|
+
# 检查依赖的 hook 是否已成功执行
|
|
111
|
+
local dep_status_file="$(get_temp_dir)/aico-hooks/$dep.status"
|
|
112
|
+
if [ ! -f "$dep_status_file" ] || [ "$(cat "$dep_status_file")" != "success" ]; then
|
|
113
|
+
hook_log "ERROR" "依赖的 hook $dep 未成功执行"
|
|
114
|
+
return 1
|
|
115
|
+
fi
|
|
116
|
+
fi
|
|
117
|
+
done
|
|
118
|
+
|
|
119
|
+
return 0
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# 更新 Hook 状态
|
|
123
|
+
update_hook_status() {
|
|
124
|
+
local hook_name="$1"
|
|
125
|
+
local status="$2" # success 或 failed
|
|
126
|
+
|
|
127
|
+
local status_dir="$(get_temp_dir)/aico-hooks"
|
|
128
|
+
safe_mkdir "$status_dir"
|
|
129
|
+
|
|
130
|
+
echo "$status" > "$status_dir/$hook_name.status"
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# 获取 Hook 状态
|
|
134
|
+
get_hook_status() {
|
|
135
|
+
local hook_name="$1"
|
|
136
|
+
local status_file="$(get_temp_dir)/aico-hooks/$hook_name.status"
|
|
137
|
+
|
|
138
|
+
if [ -f "$status_file" ]; then
|
|
139
|
+
cat "$status_file"
|
|
140
|
+
else
|
|
141
|
+
echo "unknown"
|
|
142
|
+
fi
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
# 清理临时状态
|
|
146
|
+
cleanup_hook_status() {
|
|
147
|
+
local hook_name="$1"
|
|
148
|
+
local status_dir="$(get_temp_dir)/aico-hooks"
|
|
149
|
+
|
|
150
|
+
safe_rm "$status_dir/$hook_name.status"
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
# 验证需求文档状态
|
|
154
|
+
validate_requirement_status() {
|
|
155
|
+
local requirement_name="$1"
|
|
156
|
+
local expected_status="$2" # 如 "已确认"
|
|
157
|
+
|
|
158
|
+
local doc_dir=".aico/docs/$requirement_name"
|
|
159
|
+
local status_file="$doc_dir/状态"
|
|
160
|
+
|
|
161
|
+
if [ ! -f "$status_file" ]; then
|
|
162
|
+
hook_log "ERROR" "需求状态文件不存在: $status_file"
|
|
163
|
+
return 1
|
|
164
|
+
fi
|
|
165
|
+
|
|
166
|
+
local current_status=$(cat "$status_file")
|
|
167
|
+
if [ "$current_status" != "$expected_status" ]; then
|
|
168
|
+
hook_log "ERROR" "需求状态不匹配。期望: $expected_status, 实际: $current_status"
|
|
169
|
+
return 1
|
|
170
|
+
fi
|
|
171
|
+
|
|
172
|
+
return 0
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# 初始化 Hook 环境
|
|
176
|
+
init_hook_environment() {
|
|
177
|
+
export AICO_HOOKS_DIR="$(dirname "${BASH_SOURCE[0]}")/../.."
|
|
178
|
+
export AICO_HOOKS_TEMP_DIR="$(get_temp_dir)/aico-hooks"
|
|
179
|
+
|
|
180
|
+
safe_mkdir "$AICO_HOOKS_TEMP_DIR"
|
|
181
|
+
|
|
182
|
+
# 设置日志级别
|
|
183
|
+
if [ -z "$AICO_HOOKS_LOG_LEVEL" ]; then
|
|
184
|
+
export AICO_HOOKS_LOG_LEVEL="info"
|
|
185
|
+
fi
|
|
186
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 需求对齐阶段后置 Hook
|
|
3
|
+
|
|
4
|
+
# 加载通用工具库
|
|
5
|
+
source "$(dirname "${BASH_SOURCE[0]}")/common-utils.sh"
|
|
6
|
+
|
|
7
|
+
# 主函数
|
|
8
|
+
main() {
|
|
9
|
+
local consensus_doc_path="$1"
|
|
10
|
+
local technical_doc_path="$2"
|
|
11
|
+
|
|
12
|
+
hook_log "INFO" "开始执行需求对齐后置处理"
|
|
13
|
+
|
|
14
|
+
# 初始化环境
|
|
15
|
+
init_hook_environment
|
|
16
|
+
|
|
17
|
+
# 检查技术方案文档是否存在
|
|
18
|
+
if [ ! -f "$technical_doc_path" ]; then
|
|
19
|
+
hook_log "ERROR" "技术方案文档不存在: $technical_doc_path"
|
|
20
|
+
return 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# 更新需求状态
|
|
24
|
+
local doc_dir=$(dirname "$consensus_doc_path")
|
|
25
|
+
local req_name=$(basename "$doc_dir")
|
|
26
|
+
|
|
27
|
+
echo "待确认" > "$doc_dir/对齐状态"
|
|
28
|
+
hook_log "INFO" "技术对齐状态已设置为: 待确认"
|
|
29
|
+
|
|
30
|
+
# 记录处理完成时间
|
|
31
|
+
local completion_time=$(get_timestamp)
|
|
32
|
+
echo "$completion_time" > "$doc_dir/对齐完成时间"
|
|
33
|
+
|
|
34
|
+
# 生成技术对齐摘要
|
|
35
|
+
cat > "$doc_dir/对齐摘要.txt" << EOF
|
|
36
|
+
技术对齐完成摘要
|
|
37
|
+
================
|
|
38
|
+
需求名称: $req_name
|
|
39
|
+
对齐时间: $completion_time
|
|
40
|
+
技术方案: $technical_doc_path
|
|
41
|
+
状态: 待确认
|
|
42
|
+
|
|
43
|
+
涉及技术栈:
|
|
44
|
+
$(cat "$AICO_HOOKS_TEMP_DIR/tech-context.txt" 2>/dev/null || echo "未记录")
|
|
45
|
+
|
|
46
|
+
处理步骤:
|
|
47
|
+
1. ✅ 技术分析完成
|
|
48
|
+
2. ✅ 实施方案制定
|
|
49
|
+
3. ⏳ 等待用户确认
|
|
50
|
+
EOF
|
|
51
|
+
|
|
52
|
+
hook_log "INFO" "需求对齐后置处理完成"
|
|
53
|
+
|
|
54
|
+
# 更新 hook 状态
|
|
55
|
+
update_hook_status "requirement-aligner" "success"
|
|
56
|
+
|
|
57
|
+
return 0
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# 执行主函数
|
|
61
|
+
main "$@"
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 需求识别阶段后置 Hook
|
|
3
|
+
|
|
4
|
+
# 加载通用工具库
|
|
5
|
+
source "$(dirname "${BASH_SOURCE[0]}")/common-utils.sh"
|
|
6
|
+
|
|
7
|
+
# 主函数
|
|
8
|
+
main() {
|
|
9
|
+
local requirement_desc="$1"
|
|
10
|
+
local consensus_doc_path="$2"
|
|
11
|
+
|
|
12
|
+
hook_log "INFO" "开始执行需求识别后置处理"
|
|
13
|
+
|
|
14
|
+
# 初始化环境
|
|
15
|
+
init_hook_environment
|
|
16
|
+
|
|
17
|
+
# 检查共识文档是否存在
|
|
18
|
+
if [ ! -f "$consensus_doc_path" ]; then
|
|
19
|
+
hook_log "ERROR" "共识文档不存在: $consensus_doc_path"
|
|
20
|
+
return 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# 更新需求状态
|
|
24
|
+
local req_name=$(echo "$requirement_desc" | head -c 20 | tr ' ' '_' | tr -cd '[:alnum:]_-')
|
|
25
|
+
local doc_dir=".aico/docs/$req_name"
|
|
26
|
+
|
|
27
|
+
echo "待确认" > "$doc_dir/状态"
|
|
28
|
+
hook_log "INFO" "需求状态已设置为: 待确认"
|
|
29
|
+
|
|
30
|
+
# 记录处理完成时间
|
|
31
|
+
local completion_time=$(get_timestamp)
|
|
32
|
+
echo "$completion_time" > "$doc_dir/识别完成时间"
|
|
33
|
+
|
|
34
|
+
# 生成处理摘要
|
|
35
|
+
cat > "$doc_dir/识别摘要.txt" << EOF
|
|
36
|
+
需求识别完成摘要
|
|
37
|
+
================
|
|
38
|
+
需求描述: $requirement_desc
|
|
39
|
+
识别时间: $completion_time
|
|
40
|
+
共识文档: $consensus_doc_path
|
|
41
|
+
状态: 待确认
|
|
42
|
+
|
|
43
|
+
处理步骤:
|
|
44
|
+
1. ✅ 需求分析完成
|
|
45
|
+
2. ✅ 共识文档生成
|
|
46
|
+
3. ⏳ 等待用户确认
|
|
47
|
+
EOF
|
|
48
|
+
|
|
49
|
+
hook_log "INFO" "需求识别后置处理完成"
|
|
50
|
+
|
|
51
|
+
# 更新 hook 状态
|
|
52
|
+
update_hook_status "requirement-identifier" "success"
|
|
53
|
+
|
|
54
|
+
return 0
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# 执行主函数
|
|
58
|
+
main "$@"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 质量验证阶段后置 Hook
|
|
3
|
+
|
|
4
|
+
# 加载通用工具库
|
|
5
|
+
source "$(dirname "${BASH_SOURCE[0]}")/common-utils.sh"
|
|
6
|
+
|
|
7
|
+
# 主函数
|
|
8
|
+
main() {
|
|
9
|
+
local completion_report_path="$1"
|
|
10
|
+
local validation_report_path="$2"
|
|
11
|
+
|
|
12
|
+
hook_log "INFO" "开始执行质量验证后置处理"
|
|
13
|
+
|
|
14
|
+
# 初始化环境
|
|
15
|
+
init_hook_environment
|
|
16
|
+
|
|
17
|
+
# 检查验证报告文档是否存在
|
|
18
|
+
if [ ! -f "$validation_report_path" ]; then
|
|
19
|
+
hook_log "ERROR" "验证报告文档不存在: $validation_report_path"
|
|
20
|
+
return 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# 分析验证结果
|
|
24
|
+
local doc_dir=$(dirname "$completion_report_path")
|
|
25
|
+
local req_name=$(basename "$doc_dir")
|
|
26
|
+
|
|
27
|
+
# 统计验证结果
|
|
28
|
+
local passed_count=$(grep -c "✅\|通过" "$validation_report_path" 2>/dev/null || echo "0")
|
|
29
|
+
local failed_count=$(grep -c "❌\|失败" "$validation_report_path" 2>/dev/null || echo "0")
|
|
30
|
+
local total_count=$((passed_count + failed_count))
|
|
31
|
+
|
|
32
|
+
# 更新验证状态
|
|
33
|
+
if [ "$failed_count" -eq 0 ]; then
|
|
34
|
+
echo "验证通过" > "$doc_dir/验证状态"
|
|
35
|
+
hook_log "INFO" "所有验证项通过"
|
|
36
|
+
else
|
|
37
|
+
echo "验证未通过" > "$doc_dir/验证状态"
|
|
38
|
+
hook_log "WARN" "有 $failed_count 个验证项未通过"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# 记录验证完成时间
|
|
42
|
+
local completion_time=$(get_timestamp)
|
|
43
|
+
echo "$completion_time" > "$doc_dir/验证完成时间"
|
|
44
|
+
|
|
45
|
+
# 生成验证摘要
|
|
46
|
+
cat > "$doc_dir/验证摘要.txt" << EOF
|
|
47
|
+
质量验证完成摘要
|
|
48
|
+
================
|
|
49
|
+
需求名称: $req_name
|
|
50
|
+
验证时间: $completion_time
|
|
51
|
+
验证报告: $validation_report_path
|
|
52
|
+
总验证项: $total_count
|
|
53
|
+
通过项: $passed_count
|
|
54
|
+
未通过项: $failed_count
|
|
55
|
+
验证状态: $(if [ "$failed_count" -eq 0 ]; then echo "验证通过"; else echo "验证未通过"; fi)
|
|
56
|
+
|
|
57
|
+
验证统计:
|
|
58
|
+
- ✅ 通过: $passed_count
|
|
59
|
+
- ❌ 未通过: $failed_count
|
|
60
|
+
- 📊 总计: $total_count
|
|
61
|
+
|
|
62
|
+
质量评级: $(if [ "$failed_count" -eq 0 ]; then echo "优秀"; elif [ "$passed_count" -gt "$failed_count" ]; then echo "良好"; else echo "需改进"; fi)
|
|
63
|
+
|
|
64
|
+
处理步骤:
|
|
65
|
+
1. ✅ 质量验证完成
|
|
66
|
+
2. ✅ 验证报告生成
|
|
67
|
+
3. ✅ 质量评级确定
|
|
68
|
+
4. 🎯 需求生命周期完成
|
|
69
|
+
EOF
|
|
70
|
+
|
|
71
|
+
# 更新整体需求状态
|
|
72
|
+
if [ "$failed_count" -eq 0 ]; then
|
|
73
|
+
echo "已完成" > "$doc_dir/需求状态"
|
|
74
|
+
hook_log "INFO" "需求生命周期完成,质量评级: 优秀"
|
|
75
|
+
else
|
|
76
|
+
echo "部分完成" > "$doc_dir/需求状态"
|
|
77
|
+
hook_log "INFO" "需求生命周期完成,质量评级: $(if [ "$passed_count" -gt "$failed_count" ]; then echo "良好"; else echo "需改进"; fi)"
|
|
78
|
+
fi
|
|
79
|
+
|
|
80
|
+
hook_log "INFO" "质量验证后置处理完成,通过: $passed_count, 未通过: $failed_count"
|
|
81
|
+
|
|
82
|
+
# 更新 hook 状态
|
|
83
|
+
update_hook_status "task-executor-validator" "success"
|
|
84
|
+
|
|
85
|
+
# 清理临时状态文件
|
|
86
|
+
cleanup_hook_status "requirement-identifier"
|
|
87
|
+
cleanup_hook_status "requirement-aligner"
|
|
88
|
+
cleanup_hook_status "task-splitter-validator"
|
|
89
|
+
cleanup_hook_status "task-executor"
|
|
90
|
+
cleanup_hook_status "task-executor-validator"
|
|
91
|
+
|
|
92
|
+
return 0
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# 执行主函数
|
|
96
|
+
main "$@"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# 任务执行阶段后置 Hook
|
|
3
|
+
|
|
4
|
+
# 加载通用工具库
|
|
5
|
+
source "$(dirname "${BASH_SOURCE[0]}")/common-utils.sh"
|
|
6
|
+
|
|
7
|
+
# 主函数
|
|
8
|
+
main() {
|
|
9
|
+
local task_list_path="$1"
|
|
10
|
+
local completion_report_path="$2"
|
|
11
|
+
|
|
12
|
+
hook_log "INFO" "开始执行任务执行后置处理"
|
|
13
|
+
|
|
14
|
+
# 初始化环境
|
|
15
|
+
init_hook_environment
|
|
16
|
+
|
|
17
|
+
# 检查完成报告文档是否存在
|
|
18
|
+
if [ ! -f "$completion_report_path" ]; then
|
|
19
|
+
hook_log "ERROR" "完成报告文档不存在: $completion_report_path"
|
|
20
|
+
return 1
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# 分析执行结果
|
|
24
|
+
local doc_dir=$(dirname "$task_list_path")
|
|
25
|
+
local req_name=$(basename "$doc_dir")
|
|
26
|
+
|
|
27
|
+
# 统计成功/失败任务数
|
|
28
|
+
local success_count=$(grep -c "✅\|成功" "$completion_report_path" 2>/dev/null || echo "0")
|
|
29
|
+
local failed_count=$(grep -c "❌\|失败" "$completion_report_path" 2>/dev/null || echo "0")
|
|
30
|
+
local total_count=$((success_count + failed_count))
|
|
31
|
+
|
|
32
|
+
# 更新执行状态
|
|
33
|
+
if [ "$failed_count" -eq 0 ]; then
|
|
34
|
+
echo "全部完成" > "$doc_dir/执行状态"
|
|
35
|
+
hook_log "INFO" "所有任务执行成功"
|
|
36
|
+
else
|
|
37
|
+
echo "部分完成" > "$doc_dir/执行状态"
|
|
38
|
+
hook_log "WARN" "有 $failed_count 个任务执行失败"
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# 记录处理完成时间
|
|
42
|
+
local completion_time=$(get_timestamp)
|
|
43
|
+
echo "$completion_time" > "$doc_dir/执行完成时间"
|
|
44
|
+
|
|
45
|
+
# 生成执行摘要
|
|
46
|
+
cat > "$doc_dir/执行摘要.txt" << EOF
|
|
47
|
+
任务执行完成摘要
|
|
48
|
+
================
|
|
49
|
+
需求名称: $req_name
|
|
50
|
+
完成时间: $completion_time
|
|
51
|
+
完成报告: $completion_report_path
|
|
52
|
+
总任务数: $total_count
|
|
53
|
+
成功任务: $success_count
|
|
54
|
+
失败任务: $failed_count
|
|
55
|
+
执行状态: $(if [ "$failed_count" -eq 0 ]; then echo "全部完成"; else echo "部分完成"; fi)
|
|
56
|
+
|
|
57
|
+
执行统计:
|
|
58
|
+
- ✅ 成功: $success_count
|
|
59
|
+
- ❌ 失败: $failed_count
|
|
60
|
+
- ⏳ 总计: $total_count
|
|
61
|
+
|
|
62
|
+
处理步骤:
|
|
63
|
+
1. ✅ 任务执行完成
|
|
64
|
+
2. ✅ 结果统计汇总
|
|
65
|
+
3. ✅ 执行报告生成
|
|
66
|
+
4. 🔄 等待质量验证
|
|
67
|
+
EOF
|
|
68
|
+
|
|
69
|
+
hook_log "INFO" "任务执行后置处理完成,成功: $success_count, 失败: $failed_count"
|
|
70
|
+
|
|
71
|
+
# 更新 hook 状态
|
|
72
|
+
update_hook_status "task-executor" "success"
|
|
73
|
+
|
|
74
|
+
return 0
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# 执行主函数
|
|
78
|
+
main "$@"
|