aico-cli 0.3.20 → 0.4.0

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.
Files changed (47) hide show
  1. package/dist/chunks/simple-config.mjs +1 -1
  2. package/package.json +1 -1
  3. package/templates/agents/aico/requirement/WINDOWS_USAGE.md +478 -0
  4. package/templates/agents/aico/requirement/crossplatform-utils.ps1 +465 -0
  5. package/templates/agents/aico/requirement/requirement-aligner.md +47 -0
  6. package/templates/agents/aico/requirement/requirement-functions-crossplatform.ps1 +458 -0
  7. package/templates/agents/aico/requirement/requirement-identifier.md +43 -4
  8. package/templates/agents/aico/requirement/requirement-launcher.ps1 +223 -0
  9. package/templates/agents/aico/requirement/task-executor-validator.md +42 -0
  10. package/templates/agents/aico/requirement/task-executor.md +44 -0
  11. package/templates/agents/aico/requirement/task-splitter-validator.md +44 -2
  12. package/templates/agents/aico/requirement/test-crossplatform.ps1 +506 -0
  13. package/templates/hooks/claude-code-hooks.json +69 -0
  14. package/templates/hooks/notify.ps1 +1 -27
  15. package/templates/hooks/notify.sh +0 -23
  16. package/templates/hooks/scripts/Notification/bash/desktop-notifier.sh +63 -0
  17. package/templates/hooks/scripts/Notification/powershell/desktop-notifier.ps1 +67 -0
  18. package/templates/hooks/scripts/PostToolUse/bash/code-formatter.sh +73 -0
  19. package/templates/hooks/scripts/PostToolUse/powershell/code-formatter.ps1 +90 -0
  20. package/templates/hooks/scripts/PreToolUse/bash/command-logger.sh +38 -0
  21. package/templates/hooks/scripts/PreToolUse/bash/file-protection.sh +55 -0
  22. package/templates/hooks/scripts/PreToolUse/powershell/command-logger.ps1 +34 -0
  23. package/templates/hooks/scripts/PreToolUse/powershell/file-protection.ps1 +46 -0
  24. package/templates/hooks/scripts/Stop/bash/session-summary.sh +83 -0
  25. package/templates/hooks/scripts/Stop/powershell/session-summary.ps1 +95 -0
  26. package/templates/hooks/scripts/UserPromptSubmit/bash/input-notifier.sh +58 -0
  27. package/templates/hooks/scripts/UserPromptSubmit/powershell/input-notifier.ps1 +57 -0
  28. package/templates/hooks/utils/crossplatform-detector.ps1 +117 -0
  29. package/templates/hooks/utils/crossplatform-detector.sh +111 -0
  30. package/templates/personality.md +3 -3
  31. package/templates/settings.json +4 -4
  32. package/templates/agents/aico/requirement/PLATFORM_COMPATIBILITY.md +0 -219
  33. package/templates/hooks/claude-code-hook-config.json +0 -35
  34. package/templates/hooks/hooks-config.json +0 -47
  35. package/templates/hooks/requirement/common-utils.sh +0 -186
  36. package/templates/hooks/requirement/hook-utils.ps1 +0 -365
  37. package/templates/hooks/requirement/post-requirement-aligner.sh +0 -61
  38. package/templates/hooks/requirement/post-requirement-identifier.sh +0 -58
  39. package/templates/hooks/requirement/post-task-executor-validator.sh +0 -96
  40. package/templates/hooks/requirement/post-task-executor.sh +0 -78
  41. package/templates/hooks/requirement/post-task-splitter-validator.sh +0 -73
  42. package/templates/hooks/requirement/pre-requirement-aligner.sh +0 -70
  43. package/templates/hooks/requirement/pre-requirement-identifier.sh +0 -61
  44. package/templates/hooks/requirement/pre-task-executor-validator.sh +0 -81
  45. package/templates/hooks/requirement/pre-task-executor.sh +0 -91
  46. package/templates/hooks/requirement/pre-task-splitter-validator.sh +0 -61
  47. package/templates/test-windows-compatibility.ps1 +0 -476
@@ -1,219 +0,0 @@
1
- # 🌐 跨平台兼容性指南
2
-
3
- ## 支持的操作系统
4
-
5
- ### ✅ 完全支持
6
- - **Windows 10/11** (通过以下环境)
7
- - Git Bash (推荐)
8
- - Cygwin
9
- - WSL (Windows Subsystem for Linux)
10
- - MSYS2
11
-
12
- - **macOS** (10.15+)
13
- - 原生终端
14
- - iTerm2
15
- - 任何兼容的终端环境
16
-
17
- - **Linux** (主流发行版)
18
- - Ubuntu/Debian
19
- - CentOS/RHEL
20
- - Fedora
21
- - Arch Linux
22
- - 其他基于 GNU/Linux 的系统
23
-
24
- ## 🛠️ 环境要求
25
-
26
- ### 基本依赖
27
- 所有平台都需要以下基本工具:
28
- - `bash` (版本 4.0+)
29
- - `coreutils` (包含基本 Unix 命令)
30
- - `grep`
31
- - `sed`
32
- - `head`/`tail`
33
- - `mkdir`/`cat`/`echo`
34
-
35
- ### Windows 特定设置
36
-
37
- #### 选项1: Git for Windows (推荐)
38
- ```bash
39
- # 1. 下载安装 Git for Windows
40
- # https://git-scm.com/download/win
41
-
42
- # 2. 启动 Git Bash
43
- # 3. 导航到脚本目录
44
- cd /c/path/to/your/project
45
-
46
- # 4. 运行脚本
47
- ./requirement-launcher.sh "您的需求"
48
- ```
49
-
50
- #### 选项2: WSL (Windows Subsystem for Linux)
51
- ```bash
52
- # 1. 启用 WSL
53
- wsl --install
54
-
55
- # 2. 安装 Ubuntu
56
- wsl --install -d Ubuntu
57
-
58
- # 3. 启动 WSL
59
- wsl
60
-
61
- # 4. 安装必要工具
62
- sudo apt update && sudo apt install git bash
63
-
64
- # 5. 运行脚本
65
- ./requirement-launcher.sh "您的需求"
66
- ```
67
-
68
- #### 选项3: Cygwin
69
- ```bash
70
- # 1. 安装 Cygwin
71
- # https://www.cygwin.com/
72
-
73
- # 2. 确保安装以下包:
74
- # - bash
75
- # - coreutils
76
- # - grep
77
- # - sed
78
-
79
- # 3. 运行脚本
80
- ./requirement-launcher.sh "您的需求"
81
- ```
82
-
83
- ### macOS 设置
84
- ```bash
85
- # 确保已安装 Xcode Command Line Tools
86
- xcode-select --install
87
-
88
- # 或者使用 Homebrew 安装最新工具
89
- /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
90
- brew install coreutils
91
-
92
- # 运行脚本
93
- ./requirement-launcher.sh "您的需求"
94
- ```
95
-
96
- ### Linux 设置
97
- ```bash
98
- # Ubuntu/Debian
99
- sudo apt update && sudo apt install bash coreutils
100
-
101
- # CentOS/RHEL
102
- sudo yum install bash coreutils
103
-
104
- # Fedora
105
- sudo dnf install bash coreutils
106
-
107
- # 运行脚本
108
- ./requirement-launcher.sh "您的需求"
109
- ```
110
-
111
- ## 📁 文件结构
112
-
113
- ```
114
- agents/aico/requirement/
115
- ├── requirement-functions-crossplatform.sh # 跨平台主函数库
116
- ├── requirement-launcher.sh # 跨平台启动器
117
- ├── requirement-functions.sh # 原版函数库 (Unix only)
118
- ├── PLATFORM_COMPATIBILITY.md # 本文件
119
- └── *.md # 其他文档文件
120
- ```
121
-
122
- ## 🔧 技术实现细节
123
-
124
- ### 平台检测
125
- 脚本会自动检测运行环境:
126
- - `Darwin` → macOS
127
- - `Linux` → Linux
128
- - `CYGWIN*|MINGW*|MSYS*` → Windows
129
-
130
- ### 路径处理
131
- - **Windows**: 自动处理路径分隔符 (`/` → `\\`)
132
- - **临时目录**: 使用平台适当的临时目录
133
- - **家目录**: 自动识别 Windows (`%USERPROFILE%`) 和 Unix (`$HOME`)
134
-
135
- ### 命令兼容性
136
- - 使用 `command -v` 代替 `which`
137
- - 提供命令回退机制
138
- - 统一的错误处理
139
-
140
- ## 🚀 快速开始
141
-
142
- ### 所有平台通用命令
143
- ```bash
144
- # 1. 确保脚本有执行权限
145
- chmod +x requirement-launcher.sh
146
- chmod +x requirement-functions-crossplatform.sh
147
-
148
- # 2. 运行需求识别
149
- ./requirement-launcher.sh "需要开发用户登录功能"
150
-
151
- # 3. 或者直接使用函数库
152
- source requirement-functions-crossplatform.sh
153
- main_workflow "需要修复页面加载性能问题"
154
- ```
155
-
156
- ### Windows 特定示例
157
- ```bash
158
- # 在 Git Bash 中:
159
- cd /c/Users/YourName/project
160
- ./requirement-launcher.sh "创建新的API接口"
161
-
162
- # 在 PowerShell 中启动 Git Bash:
163
- Start-Process "C:\\Program Files\\Git\\git-bash.exe" -ArgumentList "-c", "cd /c/path/to/project && ./requirement-launcher.sh '您的需求'"
164
- ```
165
-
166
- ## 🧪 测试验证
167
-
168
- ### 基本功能测试
169
- ```bash
170
- # 测试平台检测
171
- ./requirement-launcher.sh "测试平台兼容性"
172
-
173
- # 测试需求分析
174
- ./requirement-launcher.sh "需要添加数据导出功能"
175
-
176
- # 测试文档生成
177
- ./requirement-launcher.sh "创建用户管理模块"
178
- ```
179
-
180
- ### 跨平台一致性验证
181
- 确保在所有平台上产生相同的结果:
182
- - 相同的需求识别结果
183
- - 相同的文档输出格式
184
- - 相同的状态管理行为
185
-
186
- ## ⚠️ 已知限制
187
-
188
- 1. **Windows 原生 CMD/PowerShell**: 不支持,必须使用兼容环境
189
- 2. **非常旧的系统**: 可能需要手动安装更新版本的 bash
190
- 3. **特殊字符处理**: 某些特殊字符在不同 shell 中可能有不同行为
191
- 4. **文件权限**: Windows 和 Unix 文件权限模型不同
192
-
193
- ## 🔄 更新和维护
194
-
195
- ### 添加新平台支持
196
- 1. 在 `detect_platform()` 中添加新的平台检测
197
- 2. 在相应的平台分支中添加特殊处理逻辑
198
- 3. 更新测试用例
199
- 4. 更新本文档
200
-
201
- ### 维护跨平台兼容性
202
- - 避免使用平台特定的命令
203
- - 使用 POSIX 兼容的语法
204
- - 提供适当的回退机制
205
- - 定期在不同平台上测试
206
-
207
- ## 📞 技术支持
208
-
209
- 如果遇到平台兼容性问题:
210
-
211
- 1. 检查 `detect_platform` 函数的输出
212
- 2. 验证基本依赖是否安装
213
- 3. 查看具体的错误信息
214
- 4. 参考对应平台的设置指南
215
-
216
- ---
217
-
218
- **最后更新**: $(date '+%Y-%m-%d')
219
- **兼容性状态**: ✅ 生产环境就绪
@@ -1,35 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/claude-code-settings.json",
3
- "hooks": {
4
- "UserPromptSubmit": [
5
- {
6
- "hooks": [
7
- {
8
- "type": "command",
9
- "command": "~/.claude/hooks/notify.sh input"
10
- }
11
- ]
12
- }
13
- ],
14
- "Stop": [
15
- {
16
- "hooks": [
17
- {
18
- "type": "command",
19
- "command": "~/.claude/hooks/notify.sh complete"
20
- }
21
- ]
22
- }
23
- ],
24
- "Notification": [
25
- {
26
- "hooks": [
27
- {
28
- "type": "command",
29
- "command": "~/.claude/hooks/notify.sh complete"
30
- }
31
- ]
32
- }
33
- ]
34
- }
35
- }
@@ -1,47 +0,0 @@
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
- }
@@ -1,186 +0,0 @@
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
- }