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.
@@ -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 "$@"
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env bash
2
+ # 任务拆分阶段后置 Hook
3
+
4
+ # 加载通用工具库
5
+ source "$(dirname "${BASH_SOURCE[0]}")/common-utils.sh"
6
+
7
+ # 主函数
8
+ main() {
9
+ local technical_doc_path="$1"
10
+ local task_list_path="$2"
11
+
12
+ hook_log "INFO" "开始执行任务拆分后置处理"
13
+
14
+ # 初始化环境
15
+ init_hook_environment
16
+
17
+ # 检查任务清单文档是否存在
18
+ if [ ! -f "$task_list_path" ]; then
19
+ hook_log "ERROR" "任务清单文档不存在: $task_list_path"
20
+ return 1
21
+ fi
22
+
23
+ # 分析任务清单
24
+ local task_count=$(grep -c "^-\|^\d\+\." "$task_list_path" 2>/dev/null || echo "0")
25
+ local estimated_time=""
26
+
27
+ if [ "$task_count" -gt 0 ]; then
28
+ # 简单估算:每个任务约2-4小时
29
+ local total_hours=$((task_count * 3))
30
+ estimated_time="约 ${total_hours} 小时"
31
+ else
32
+ estimated_time="待评估"
33
+ fi
34
+
35
+ # 更新需求状态
36
+ local doc_dir=$(dirname "$technical_doc_path")
37
+ local req_name=$(basename "$doc_dir")
38
+
39
+ echo "待确认" > "$doc_dir/拆分状态"
40
+ hook_log "INFO" "任务拆分状态已设置为: 待确认"
41
+
42
+ # 记录处理完成时间
43
+ local completion_time=$(get_timestamp)
44
+ echo "$completion_time" > "$doc_dir/拆分完成时间"
45
+
46
+ # 生成任务拆分摘要
47
+ cat > "$doc_dir/拆分摘要.txt" << EOF
48
+ 任务拆分完成摘要
49
+ ================
50
+ 需求名称: $req_name
51
+ 拆分时间: $completion_time
52
+ 任务清单: $task_list_path
53
+ 任务数量: $task_count
54
+ 预估时间: $estimated_time
55
+ 状态: 待确认
56
+
57
+ 处理步骤:
58
+ 1. ✅ 任务分解完成
59
+ 2. ✅ 优先级排序
60
+ 3. ✅ 依赖关系分析
61
+ 4. ⏳ 等待用户确认
62
+ EOF
63
+
64
+ hook_log "INFO" "任务拆分后置处理完成,共识别 $task_count 个任务"
65
+
66
+ # 更新 hook 状态
67
+ update_hook_status "task-splitter-validator" "success"
68
+
69
+ return 0
70
+ }
71
+
72
+ # 执行主函数
73
+ main "$@"
@@ -0,0 +1,70 @@
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
+
11
+ hook_log "INFO" "开始执行需求对齐前置检查"
12
+
13
+ # 初始化环境
14
+ init_hook_environment
15
+
16
+ # 检查前置条件
17
+ if ! check_hook_prerequisites "requirement-aligner"; then
18
+ return 1
19
+ fi
20
+
21
+ # 检查依赖
22
+ if ! check_dependencies "requirement-aligner"; then
23
+ return 1
24
+ fi
25
+
26
+ # 验证共识文档
27
+ if [ ! -f "$consensus_doc_path" ]; then
28
+ hook_log "ERROR" "共识文档不存在: $consensus_doc_path"
29
+ return 1
30
+ fi
31
+
32
+ # 检查需求状态是否为"已确认"
33
+ local doc_dir=$(dirname "$consensus_doc_path")
34
+ if ! validate_requirement_status "$(basename "$doc_dir")" "已确认"; then
35
+ hook_log "ERROR" "需求状态不是'已确认',无法进行技术对齐"
36
+ return 1
37
+ fi
38
+
39
+ # 检查项目代码库
40
+ if [ ! -d "src" ] && [ ! -d "lib" ]; then
41
+ hook_log "WARN" "未找到标准代码目录(src/lib),可能影响技术分析准确性"
42
+ fi
43
+
44
+ # 检查技术栈配置文件
45
+ local tech_stack=""
46
+ if [ -f "package.json" ]; then
47
+ tech_stack="Node.js"
48
+ elif [ -f "requirements.txt" ]; then
49
+ tech_stack="Python"
50
+ elif [ -f "pom.xml" ]; then
51
+ tech_stack="Java"
52
+ else
53
+ hook_log "WARN" "未识别到明确的技术栈配置文件"
54
+ fi
55
+
56
+ hook_log "INFO" "检测到技术栈: ${tech_stack:-未知}"
57
+
58
+ # 保存技术分析上下文
59
+ cat > "$AICO_HOOKS_TEMP_DIR/tech-context.txt" << EOF
60
+ 技术栈: $tech_stack
61
+ 代码目录: $(if [ -d "src" ]; then echo "src"; elif [ -d "lib" ]; then echo "lib"; else echo "无"; fi)
62
+ 配置文件: $(if [ -f "package.json" ]; then echo "package.json"; elif [ -f "requirements.txt" ]; then echo "requirements.txt"; elif [ -f "pom.xml" ]; then echo "pom.xml"; else echo "无"; fi)
63
+ EOF
64
+
65
+ hook_log "INFO" "需求对齐前置检查完成"
66
+ return 0
67
+ }
68
+
69
+ # 执行主函数
70
+ main "$@"
@@ -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 requirement_desc="$1"
10
+
11
+ hook_log "INFO" "开始执行需求识别前置检查"
12
+
13
+ # 初始化环境
14
+ init_hook_environment
15
+
16
+ # 检查前置条件
17
+ if ! check_hook_prerequisites "requirement-identifier"; then
18
+ return 1
19
+ fi
20
+
21
+ # 检查依赖
22
+ if ! check_dependencies "requirement-identifier"; then
23
+ return 1
24
+ fi
25
+
26
+ # 验证输入参数
27
+ if [ -z "$requirement_desc" ]; then
28
+ hook_log "ERROR" "需求描述不能为空"
29
+ return 1
30
+ fi
31
+
32
+ # 检查项目环境
33
+ if [ ! -f "CLAUDE.md" ]; then
34
+ hook_log "WARN" "未找到 CLAUDE.md 文件,可能影响需求分析准确性"
35
+ fi
36
+
37
+ # 创建需求文档目录
38
+ local req_name=$(echo "$requirement_desc" | head -c 20 | tr ' ' '_' | tr -cd '[:alnum:]_-')
39
+ local doc_dir=".aico/docs/$req_name"
40
+
41
+ if [ -d "$doc_dir" ]; then
42
+ hook_log "INFO" "需求目录已存在: $doc_dir"
43
+
44
+ # 检查是否已有共识文档
45
+ if [ -f "$doc_dir/共识文档.md" ]; then
46
+ hook_log "INFO" "发现现有共识文档,将进行更新"
47
+ fi
48
+ else
49
+ safe_mkdir "$doc_dir"
50
+ hook_log "INFO" "创建需求文档目录: $doc_dir"
51
+ fi
52
+
53
+ # 保存需求描述到临时文件
54
+ echo "$requirement_desc" > "$AICO_HOOKS_TEMP_DIR/requirement-desc.txt"
55
+
56
+ hook_log "INFO" "需求识别前置检查完成"
57
+ return 0
58
+ }
59
+
60
+ # 执行主函数
61
+ main "$@"
@@ -0,0 +1,81 @@
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
+
11
+ hook_log "INFO" "开始执行质量验证前置检查"
12
+
13
+ # 初始化环境
14
+ init_hook_environment
15
+
16
+ # 检查前置条件
17
+ if ! check_hook_prerequisites "task-executor-validator"; then
18
+ return 1
19
+ fi
20
+
21
+ # 检查依赖
22
+ if ! check_dependencies "task-executor-validator"; then
23
+ return 1
24
+ fi
25
+
26
+ # 验证完成报告文档
27
+ if [ ! -f "$completion_report_path" ]; then
28
+ hook_log "ERROR" "完成报告文档不存在: $completion_report_path"
29
+ return 1
30
+ fi
31
+
32
+ # 检查执行状态
33
+ local doc_dir=$(dirname "$completion_report_path")
34
+ local req_name=$(basename "$doc_dir")
35
+
36
+ if [ ! -f "$doc_dir/执行状态" ]; then
37
+ hook_log "ERROR" "执行状态文件不存在"
38
+ return 1
39
+ fi
40
+
41
+ local execution_status=$(cat "$doc_dir/执行状态")
42
+
43
+ # 分析执行结果
44
+ local success_count=$(grep -c "✅\|成功" "$completion_report_path" 2>/dev/null || echo "0")
45
+ local failed_count=$(grep -c "❌\|失败" "$completion_report_path" 2>/dev/null || echo "0")
46
+ local total_count=$((success_count + failed_count))
47
+
48
+ # 准备验证上下文
49
+ cat > "$AICO_HOOKS_TEMP_DIR/validation-context.txt" << EOF
50
+ 完成报告路径: $completion_report_path
51
+ 执行状态: $execution_status
52
+ 成功任务: $success_count
53
+ 失败任务: $failed_count
54
+ 总任务数: $total_count
55
+ 需求名称: $req_name
56
+ EOF
57
+
58
+ # 检查测试环境
59
+ local test_env=""
60
+ if [ -d "test" ] || [ -d "tests" ] || [ -d "src/__tests__" ]; then
61
+ test_env="已配置"
62
+ # 检查测试框架
63
+ if [ -f "package.json" ] && grep -q "jest\|mocha\|vitest" "package.json"; then
64
+ test_env="JavaScript测试框架"
65
+ elif [ -f "requirements.txt" ] && grep -q "pytest\|unittest" "requirements.txt"; then
66
+ test_env="Python测试框架"
67
+ elif [ -f "pom.xml" ] && grep -q "junit\|testng" "pom.xml"; then
68
+ test_env="Java测试框架"
69
+ fi
70
+ else
71
+ test_env="未配置"
72
+ fi
73
+
74
+ hook_log "INFO" "测试环境: $test_env"
75
+ hook_log "INFO" "质量验证前置检查完成,将验证 $total_count 个任务的执行质量"
76
+
77
+ return 0
78
+ }
79
+
80
+ # 执行主函数
81
+ main "$@"
@@ -0,0 +1,91 @@
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
+
11
+ hook_log "INFO" "开始执行任务执行前置检查"
12
+
13
+ # 初始化环境
14
+ init_hook_environment
15
+
16
+ # 检查前置条件
17
+ if ! check_hook_prerequisites "task-executor"; then
18
+ return 1
19
+ fi
20
+
21
+ # 检查依赖
22
+ if ! check_dependencies "task-executor"; then
23
+ return 1
24
+ fi
25
+
26
+ # 验证任务清单文档
27
+ if [ ! -f "$task_list_path" ]; then
28
+ hook_log "ERROR" "任务清单文档不存在: $task_list_path"
29
+ return 1
30
+ fi
31
+
32
+ # 检查任务拆分状态是否为"已确认"
33
+ local doc_dir=$(dirname "$task_list_path")
34
+ local req_name=$(basename "$doc_dir")
35
+
36
+ if [ ! -f "$doc_dir/拆分状态" ] || [ "$(cat "$doc_dir/拆分状态")" != "已确认" ]; then
37
+ hook_log "ERROR" "任务拆分状态不是'已确认',无法开始执行"
38
+ return 1
39
+ fi
40
+
41
+ # 分析任务清单
42
+ local task_count=$(grep -c "^-\|^\d\+\." "$task_list_path" 2>/dev/null || echo "0")
43
+
44
+ if [ "$task_count" -eq 0 ]; then
45
+ hook_log "WARN" "任务清单为空或格式不正确"
46
+ fi
47
+
48
+ # 检查执行环境
49
+ local execution_env=""
50
+ if [ -f "package.json" ]; then
51
+ execution_env="Node.js"
52
+ # 检查 npm/pnpm/yarn 可用性
53
+ if command_exists "npm"; then
54
+ execution_env="$execution_env (npm)"
55
+ elif command_exists "pnpm"; then
56
+ execution_env="$execution_env (pnpm)"
57
+ elif command_exists "yarn"; then
58
+ execution_env="$execution_env (yarn)"
59
+ fi
60
+ elif [ -f "requirements.txt" ]; then
61
+ execution_env="Python"
62
+ if command_exists "pip"; then
63
+ execution_env="$execution_env (pip)"
64
+ fi
65
+ elif [ -f "pom.xml" ]; then
66
+ execution_env="Java"
67
+ if command_exists "mvn"; then
68
+ execution_env="$execution_env (Maven)"
69
+ fi
70
+ else
71
+ execution_env="Shell/通用"
72
+ fi
73
+
74
+ # 保存执行上下文
75
+ cat > "$AICO_HOOKS_TEMP_DIR/execution-context.txt" << EOF
76
+ 任务清单路径: $task_list_path
77
+ 任务数量: $task_count
78
+ 执行环境: $execution_env
79
+ 需求名称: $req_name
80
+ 开始时间: $(get_timestamp)
81
+ EOF
82
+
83
+ # 创建执行日志目录
84
+ safe_mkdir "$doc_dir/执行日志"
85
+
86
+ hook_log "INFO" "任务执行前置检查完成,将在 $execution_env 环境中执行 $task_count 个任务"
87
+ return 0
88
+ }
89
+
90
+ # 执行主函数
91
+ main "$@"
@@ -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 technical_doc_path="$1"
10
+
11
+ hook_log "INFO" "开始执行任务拆分前置检查"
12
+
13
+ # 初始化环境
14
+ init_hook_environment
15
+
16
+ # 检查前置条件
17
+ if ! check_hook_prerequisites "task-splitter-validator"; then
18
+ return 1
19
+ fi
20
+
21
+ # 检查依赖
22
+ if ! check_dependencies "task-splitter-validator"; then
23
+ return 1
24
+ fi
25
+
26
+ # 验证技术方案文档
27
+ if [ ! -f "$technical_doc_path" ]; then
28
+ hook_log "ERROR" "技术方案文档不存在: $technical_doc_path"
29
+ return 1
30
+ fi
31
+
32
+ # 检查技术方案状态是否为"已确认"
33
+ local doc_dir=$(dirname "$technical_doc_path")
34
+ local req_name=$(basename "$doc_dir")
35
+
36
+ if [ ! -f "$doc_dir/对齐状态" ] || [ "$(cat "$doc_dir/对齐状态")" != "已确认" ]; then
37
+ hook_log "ERROR" "技术方案状态不是'已确认',无法进行任务拆分"
38
+ return 1
39
+ fi
40
+
41
+ # 分析任务复杂度
42
+ local tech_content=$(safe_read_file "$technical_doc_path" 100)
43
+ local task_count=$(echo "$tech_content" | grep -c "###\|##\|-" || echo "0")
44
+
45
+ if [ "$task_count" -lt 3 ]; then
46
+ hook_log "WARN" "技术方案内容较少,可能需要更详细的任务分解"
47
+ fi
48
+
49
+ # 保存任务分析上下文
50
+ cat > "$AICO_HOOKS_TEMP_DIR/task-analysis.txt" << EOF
51
+ 技术方案路径: $technical_doc_path
52
+ 预估任务数量: $task_count
53
+ 需求名称: $req_name
54
+ EOF
55
+
56
+ hook_log "INFO" "任务拆分前置检查完成,预估任务数: $task_count"
57
+ return 0
58
+ }
59
+
60
+ # 执行主函数
61
+ main "$@"
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env bash
2
+ # 需求处理器 - 集成原有脚本逻辑与 Hook 机制
3
+
4
+ # 加载 Hook 工具库
5
+ source "$(dirname "${BASH_SOURCE[0]}")/requirement/common-utils.sh"
6
+
7
+ # 加载原有的需求分析函数库
8
+ ORIGINAL_FUNCTIONS="$(dirname "${BASH_SOURCE[0]}")/../agents/aico/requirement/requirement-functions-crossplatform.sh"
9
+ if [ -f "$ORIGINAL_FUNCTIONS" ]; then
10
+ source "$ORIGINAL_FUNCTIONS"
11
+ fi
12
+
13
+ # 大行完整需求处理流程
14
+ execute_requirement_lifecycle() {
15
+ local user_input="$1"
16
+
17
+ hook_log "INFO" "开始需求生命周期处理: $user_input"
18
+ init_hook_environment
19
+
20
+ # 阶段1: 需求识别
21
+ hook_log "INFO" "=== 🎯 需求识别阶段 ==="
22
+
23
+ # 调用前置 Hook
24
+ if ! execute_hook "pre" "requirement-identifier" "$user_input"; then
25
+ hook_log "ERROR" "需求识别前置处理失败"
26
+ return 1
27
+ fi
28
+
29
+ # 执行核心需求分析逻辑
30
+ if command -v main_workflow >/dev/null 2>&1; then
31
+ main_workflow "$user_input"
32
+ else
33
+ # 如果没有原函数,使用简化逻辑
34
+ detect_platform
35
+ analyze_requirement "$user_input"
36
+ fi
37
+
38
+ # 生成共识文档路径
39
+ local req_name=$(echo "$user_input" | head -c 20 | tr ' ' '_' | tr -cd '[:alnum:]_-')
40
+ local doc_dir=".aico/docs/$req_name"
41
+ local consensus_doc="$doc_dir/共识文档.md"
42
+
43
+ # 创建共识文档
44
+ if ! [ -f "$consensus_doc" ]; then
45
+ mkdir -p "$doc_dir"
46
+ cat > "$consensus_doc" << EOF
47
+ # 需求共识文档 - $req_name
48
+
49
+ **状态**: 待确认
50
+ **创建时间**: $(get_timestamp)
51
+ **原始需求**: $user_input
52
+
53
+ ## 🎯 需求理解
54
+ 基于您的描述,我理解您需要:
55
+ $(echo "$user_input")
56
+
57
+ ## 📋 工程分析
58
+ - **意图类型**: ${INTENT_TYPE:-自动识别}
59
+ - **项目类型**: $(if [ -d "src" ] || [ -d "lib" ]; then echo "现有项目"; else echo "新项目"; fi)
60
+
61
+ ## ✨ 下一步
62
+ 请确认此需求理解是否准确,确认后我将继续进行技术方案设计。
63
+ EOF
64
+ fi
65
+
66
+ # 调用后置 Hook
67
+ if ! execute_hook "post" "requirement-identifier" "$user_input" "$consensus_doc"; then
68
+ hook_log "ERROR" "需求识别后置处理失败"
69
+ return 1
70
+ fi
71
+
72
+ hook_log "INFO" "需求识别阶段完成,等待用户确认..."
73
+ return 0
74
+ }
75
+
76
+ # 需求对齐阶段
77
+ execute_requirement_alignment() {
78
+ local consensus_doc="$1"
79
+
80
+ hook_log "INFO" "=== 🔄 需求对齐阶段 ==="
81
+
82
+ # 调用前置 Hook
83
+ if ! execute_hook "pre" "requirement-aligner" "$consensus_doc"; then
84
+ return 1
85
+ fi
86
+
87
+ # 生成技术方案
88
+ local doc_dir=$(dirname "$consensus_doc")
89
+ local tech_doc="$doc_dir/技术对齐方案文档.md"
90
+
91
+ if ! [ -f "$tech_doc" ]; then
92
+ cat > "$tech_doc" << EOF
93
+ # 技术对齐方案文档
94
+
95
+ **状态**: 待确认
96
+ **创建时间**: $(get_timestamp)
97
+ **基于共识**: $consensus_doc
98
+
99
+ ## 🔧 技术实现方案
100
+
101
+ ### 架构设计
102
+ - 采用**模块化设计**,保持与现有架构的一致性
103
+ - 遵循**SOLID原则**,确保代码的可维护性
104
+
105
+ ### 实施步骤
106
+ 1. **需求确认** ✅
107
+ 2. **技术实现** 🔄
108
+ 3. **测试验证** ⏳
109
+ 4. **部署上线** ⏳
110
+
111
+ ### 风险评估
112
+ - **技术风险**: 低 - 基于成熟技术栈
113
+ - **时间风险**: 中 - 需要充分测试
114
+ - **资源风险**: 低 - 利用现有资源
115
+
116
+ 请确认此技术方案是否可行,确认后我将进行任务分解。
117
+ EOF
118
+ fi
119
+
120
+ # 调用后置 Hook
121
+ if ! execute_hook "post" "requirement-aligner" "$consensus_doc" "$tech_doc"; then
122
+ return 1
123
+ fi
124
+
125
+ hook_log "INFO" "需求对齐阶段完成"
126
+ return 0
127
+ }
128
+
129
+ # 显示使用帮助
130
+ show_usage() {
131
+ cat << EOF
132
+
133
+ 🚀 AICO 需求生命周期处理器
134
+
135
+ 使用方法:
136
+ $0 "用户需求描述" # 完整生命周期处理
137
+ $0 --align "共识文档路径" # 仅执行需求对齐阶段
138
+ $0 --help # 显示帮助信息
139
+
140
+ 示例:
141
+ $0 "需要开发一个用户登录功能"
142
+ $0 --align ".aico/docs/user_login/共识文档.md"
143
+
144
+ 功能特性:
145
+ ✅ 自动 Hook 触发
146
+ ✅ 状态自动管理
147
+ ✅ 错误处理和重试
148
+ ✅ 跨平台兼容
149
+
150
+ EOF
151
+ }
152
+
153
+ # 主函数
154
+ main() {
155
+ case "$1" in
156
+ --help|-h)
157
+ show_usage
158
+ exit 0
159
+ ;;
160
+ --align)
161
+ if [ -z "$2" ]; then
162
+ hook_log "ERROR" "请提供共识文档路径"
163
+ exit 1
164
+ fi
165
+ execute_requirement_alignment "$2"
166
+ ;;
167
+ "")
168
+ hook_log "ERROR" "请提供需求描述或使用 --help 查看帮助"
169
+ exit 1
170
+ ;;
171
+ *)
172
+ execute_requirement_lifecycle "$*"
173
+ ;;
174
+ esac
175
+ }
176
+
177
+ # 执行主函数
178
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
179
+ main "$@"
180
+ fi