aico-cli 0.3.12 → 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.
@@ -13,7 +13,7 @@ import { join as join$1 } from 'node:path';
13
13
  import { join, dirname, basename } from 'pathe';
14
14
  import { fileURLToPath } from 'node:url';
15
15
 
16
- const version = "0.3.12";
16
+ const version = "0.3.13";
17
17
 
18
18
  function displayBanner(subtitle) {
19
19
  const defaultSubtitle = "\u4E00\u952E\u914D\u7F6E\u4F60\u7684\u5F00\u53D1\u73AF\u5883";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aico-cli",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
4
4
  "packageManager": "pnpm@9.15.9",
5
5
  "description": "AI CLI",
6
6
  "repository": {
@@ -0,0 +1,198 @@
1
+ # AICO 需求管理 Hook 系统
2
+
3
+ ## 📋 概述
4
+
5
+ 将原有的需求管理脚本重构为基于 Hook 触发的模块化系统,支持需求生命周期的全流程自动化处理。
6
+
7
+ ## 🏗️ 架构设计
8
+
9
+ ```
10
+ templates/hooks/
11
+ ├── hooks-config.json # Hook 配置中心
12
+ ├── requirement-processor.sh # 🔧 主要使用脚本
13
+ ├── requirement/ # Hook 机制
14
+ │ ├── common-utils.sh # 核心工具库
15
+ │ ├── pre-requirement-identifier.sh
16
+ │ ├── post-requirement-identifier.sh
17
+ │ ├── pre-requirement-aligner.sh
18
+ │ ├── post-requirement-aligner.sh
19
+ │ ├── pre-task-splitter-validator.sh
20
+ │ ├── post-task-splitter-validator.sh
21
+ │ ├── pre-task-executor.sh
22
+ │ ├── post-task-executor.sh
23
+ │ ├── pre-task-executor-validator.sh
24
+ │ └── post-task-executor-validator.sh
25
+ └── ../agents/aico/requirement/ # 🎯 原有核心逻辑
26
+ ├── crossplatform-utils.sh # 跨平台工具库
27
+ └── requirement-functions-crossplatform.sh # 需求分析算法
28
+ ```
29
+
30
+ ## 🚀 使用方法
31
+
32
+ ### 1. 基本需求处理(推荐)
33
+
34
+ ```bash
35
+ # 处理完整需求生命周期
36
+ ./templates/hooks/requirement-processor.sh "需要开发一个用户登录功能"
37
+
38
+ # 查看帮助
39
+ ./templates/hooks/requirement-processor.sh --help
40
+ ```
41
+
42
+ ### 2. 单独调用 Hook(高级用法)
43
+
44
+ ```bash
45
+ # 需求识别前置处理
46
+ ./templates/hooks/requirement/pre-requirement-identifier.sh "需求描述"
47
+
48
+ # 需求识别后置处理
49
+ ./templates/hooks/requirement/post-requirement-identifier.sh "需求描述" "共识文档路径"
50
+ ```
51
+
52
+ ### 3. 手动调用原有脚本(兼容性)
53
+
54
+ 原有的核心逻辑仍然保留,可以通过以下方式使用:
55
+
56
+ ```bash
57
+ # 使用原有的跨平台工具库
58
+ source templates/agents/aico/requirement/crossplatform-utils.sh
59
+
60
+ # 使用原有的需求分析函数
61
+ source templates/agents/aico/requirement/requirement-functions-crossplatform.sh
62
+ ```
63
+
64
+ ## 📊 脚本用途说明
65
+
66
+ ### ✅ 有用的脚本(保留)
67
+
68
+ | 脚本 | 用途 | 是否核心 |
69
+ |------|------|----------|
70
+ | `requirement-processor.sh` | 🎯 **主要使用脚本**,整合所有功能 | ✅ 是 |
71
+ | `common-utils.sh` | Hook 框架核心,日志、状态管理 | ✅ 是 |
72
+ | 10个 `pre/post` hook 脚本 | 生命周期各阶段的前后置处理 | ✅ 是 |
73
+ | `crossplatform-utils.sh` | 跨平台兼容性工具库 | ✅ 是 |
74
+ | `requirement-functions-crossplatform.sh` | 需求分析核心算法 | ✅ 是 |
75
+ | `hooks-config.json` | Hook 配置管理 | ✅ 是 |
76
+
77
+ ### ❌ 已删除的脚本(冗余)
78
+
79
+ | 原因 | 删除的脚本 |
80
+ |------|------------|
81
+ | 仅用于开发调试 | 所有 `test-*.sh` 脚本 |
82
+ | 被 Hook 机制替代 | `requirement-launcher.sh` |
83
+
84
+ ## 🔄 工作流程
85
+
86
+ ### 完整生命周期流程
87
+
88
+ 1. **需求识别阶段** (`requirement-identifier`)
89
+ - 前置 Hook: 环境检查、参数验证
90
+ - 核心逻辑: 需求分析、意图识别
91
+ - 后置 Hook: 状态更新、摘要生成
92
+
93
+ 2. **需求对齐阶段** (`requirement-aligner`)
94
+ - 前置 Hook: 技术栈分析、依赖检查
95
+ - 核心逻辑: 技术方案设计
96
+ - 后置 Hook: 对齐状态更新
97
+
98
+ 3. **任务拆分阶段** (`task-splitter-validator`)
99
+ - 前置 Hook: 任务复杂度分析
100
+ - 核心逻辑: 任务分解、优先级排序
101
+ - 后置 Hook: 拆分摘要生成
102
+
103
+ 4. **任务执行阶段** (`task-executor`)
104
+ - 前置 Hook: 执行环境检查
105
+ - 核心逻辑: 代码实现、单元测试
106
+ - 后置 Hook: 执行统计汇总
107
+
108
+ 5. **质量验证阶段** (`task-executor-validator`)
109
+ - 前置 Hook: 验证环境准备
110
+ - 核心逻辑: 质量检查、集成测试
111
+ - 后置 Hook: 验证报告生成
112
+
113
+ ## 🎯 最佳实践
114
+
115
+ ### 推荐使用方式
116
+
117
+ ```bash
118
+ # 日常使用 - 一步到位
119
+ ./templates/hooks/requirement-processor.sh "功能需求描述"
120
+
121
+ # 开发调试 - 分步执行
122
+ ./templates/hooks/requirement/pre-requirement-identifier.sh "需求"
123
+ # ... 检查前置处理结果 ...
124
+ ./templates/hooks/requirement/post-requirement-identifier.sh "需求" "文档"
125
+
126
+ # 自定义流程 - 组合使用
127
+ source templates/hooks/requirement/common-utils.sh
128
+ execute_hook "pre" "requirement-identifier" "自定义参数"
129
+ ```
130
+
131
+ ## 🛠️ 配置管理
132
+
133
+ 编辑 `hooks-config.json` 可以:
134
+
135
+ - 启用/禁用特定 Hook
136
+ - 设置超时时间
137
+ - 配置依赖关系
138
+ - 调整重试策略
139
+
140
+ ```json
141
+ {
142
+ "hooks": {
143
+ "requirement-identifier": {
144
+ "enabled": true,
145
+ "timeout": 30000,
146
+ "dependencies": []
147
+ }
148
+ }
149
+ }
150
+ ```
151
+
152
+ ## 🔧 扩展开发
153
+
154
+ ### 添加新的 Hook
155
+
156
+ 1. 在对应目录创建 `pre-stage-name.sh` 和 `post-stage-name.sh`
157
+ 2. 在 `hooks-config.json` 中添加配置
158
+ 3. 更新 `requirement-processor.sh` 中的流程调用
159
+
160
+ ### 自定义处理逻辑
161
+
162
+ 原有脚本的核心逻辑函数可以在 Hook 中直接调用:
163
+
164
+ ```bash
165
+ source ../agents/aico/requirement/requirement-functions-crossplatform.sh
166
+
167
+ # 在 Hook 中调用原有函数
168
+ analyze_requirement "$user_input"
169
+ generate_consensus_document
170
+ ```
171
+
172
+ ## ⚠️ 注意事项
173
+
174
+ 1. **依赖关系**: Hook 严格按照依赖顺序执行
175
+ 2. **状态管理**: 每个 Hook 会更新对应的状态文件
176
+ 3. **错误处理**: Hook 失败会中断整个流程
177
+ 4. **跨平台**: 保持与原有脚本的跨平台兼容性
178
+
179
+ ## 📚 迁移指南
180
+
181
+ 如果你之前使用 `requirement-launcher.sh`,现在可以这样迁移:
182
+
183
+ ### 旧方式
184
+ ```bash
185
+ ./templates/agents/aico/requirement/requirement-launcher.sh "需求描述"
186
+ ```
187
+
188
+ ### 新方式(推荐)
189
+ ```bash
190
+ ./templates/hooks/requirement-processor.sh "需求描述"
191
+ ```
192
+
193
+ 新方式的优势:
194
+ - ✅ 自动 Hook 触发
195
+ - ✅ 更好的状态管理
196
+ - ✅ 更强的错误处理
197
+ - ✅ 模块化架构
198
+ - ✅ 易于扩展
@@ -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,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 "$@"