aico-cli 0.3.17 → 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 (56) hide show
  1. package/dist/chunks/simple-config.mjs +7 -11
  2. package/dist/cli.mjs +0 -11
  3. package/package.json +1 -1
  4. package/templates/agents/aico/requirement/WINDOWS_USAGE.md +478 -0
  5. package/templates/agents/aico/requirement/crossplatform-utils.ps1 +465 -0
  6. package/templates/agents/aico/requirement/requirement-aligner.md +47 -0
  7. package/templates/agents/aico/requirement/requirement-functions-crossplatform.ps1 +458 -0
  8. package/templates/agents/aico/requirement/requirement-identifier.md +43 -4
  9. package/templates/agents/aico/requirement/requirement-launcher.ps1 +223 -0
  10. package/templates/agents/aico/requirement/task-executor-validator.md +42 -0
  11. package/templates/agents/aico/requirement/task-executor.md +44 -0
  12. package/templates/agents/aico/requirement/task-splitter-validator.md +44 -2
  13. package/templates/agents/aico/requirement/test-crossplatform.ps1 +506 -0
  14. package/templates/agents/base/frontend-designer.md +193 -0
  15. package/templates/commands/git/cleanBranches.md +102 -0
  16. package/templates/commands/git/commit.md +93 -0
  17. package/templates/commands/git/rollback.md +90 -0
  18. package/templates/commands/git/worktree.md +276 -0
  19. package/templates/hooks/claude-code-hooks.json +69 -0
  20. package/templates/hooks/notify.ps1 +82 -0
  21. package/templates/hooks/notify.sh +0 -23
  22. package/templates/hooks/pre-requirement-identifier.ps1 +160 -0
  23. package/templates/hooks/scripts/Notification/bash/desktop-notifier.sh +63 -0
  24. package/templates/hooks/scripts/Notification/powershell/desktop-notifier.ps1 +67 -0
  25. package/templates/hooks/scripts/PostToolUse/bash/code-formatter.sh +73 -0
  26. package/templates/hooks/scripts/PostToolUse/powershell/code-formatter.ps1 +90 -0
  27. package/templates/hooks/scripts/PreToolUse/bash/command-logger.sh +38 -0
  28. package/templates/hooks/scripts/PreToolUse/bash/file-protection.sh +55 -0
  29. package/templates/hooks/scripts/PreToolUse/powershell/command-logger.ps1 +34 -0
  30. package/templates/hooks/scripts/PreToolUse/powershell/file-protection.ps1 +46 -0
  31. package/templates/hooks/scripts/Stop/bash/session-summary.sh +83 -0
  32. package/templates/hooks/scripts/Stop/powershell/session-summary.ps1 +95 -0
  33. package/templates/hooks/scripts/UserPromptSubmit/bash/input-notifier.sh +58 -0
  34. package/templates/hooks/scripts/UserPromptSubmit/powershell/input-notifier.ps1 +57 -0
  35. package/templates/hooks/utils/crossplatform-detector.ps1 +117 -0
  36. package/templates/hooks/utils/crossplatform-detector.sh +111 -0
  37. package/templates/personality.md +3 -3
  38. package/templates/settings.json +4 -4
  39. package/templates/utils/platform-launcher.ps1 +333 -0
  40. package/templates/windows-bootstrap.ps1 +390 -0
  41. package/templates/agents/aico/requirement/PLATFORM_COMPATIBILITY.md +0 -219
  42. package/templates/commands/aico/workflow.md +0 -229
  43. package/templates/hooks/claude-code-hook-config.json +0 -35
  44. package/templates/hooks/hooks-config.json +0 -47
  45. package/templates/hooks/notify.log +0 -81
  46. package/templates/hooks/requirement/common-utils.sh +0 -186
  47. package/templates/hooks/requirement/post-requirement-aligner.sh +0 -61
  48. package/templates/hooks/requirement/post-requirement-identifier.sh +0 -58
  49. package/templates/hooks/requirement/post-task-executor-validator.sh +0 -96
  50. package/templates/hooks/requirement/post-task-executor.sh +0 -78
  51. package/templates/hooks/requirement/post-task-splitter-validator.sh +0 -73
  52. package/templates/hooks/requirement/pre-requirement-aligner.sh +0 -70
  53. package/templates/hooks/requirement/pre-requirement-identifier.sh +0 -61
  54. package/templates/hooks/requirement/pre-task-executor-validator.sh +0 -81
  55. package/templates/hooks/requirement/pre-task-executor.sh +0 -91
  56. package/templates/hooks/requirement/pre-task-splitter-validator.sh +0 -61
@@ -0,0 +1,390 @@
1
+ # AICO CLI Windows PowerShell 启动引导脚本
2
+ # 提供 .sh 脚本的完整 PowerShell 兼容实现
3
+
4
+ param(
5
+ [Parameter(Mandatory=$true, Position=0)]
6
+ [string]$Command,
7
+
8
+ [Parameter(Position=1, ValueFromRemainingArguments=$true)]
9
+ [string[]]$Arguments = @()
10
+ )
11
+
12
+ # 全局路径配置
13
+ $AICO_ROOT = Split-Path -Parent $PSScriptRoot
14
+ $AICO_TEMPLATES = Join-Path $AICO_ROOT "templates"
15
+ $AICO_UTILS = Join-Path $AICO_TEMPLATES "utils"
16
+ $AICO_HOOKS = Join-Path $AICO_TEMPLATES "hooks"
17
+ $AICO_AGENTS = Join-Path $AICO_TEMPLATES "agents"
18
+
19
+ # 版本信息
20
+ $SCRIPT_VERSION = "1.0.0"
21
+ $SCRIPT_BUILD = "2025-01-16"
22
+
23
+ # 控制台输出美化
24
+ function Write-AicoBanner {
25
+ Write-Host @"
26
+ ╔═══════════════════════════════════════════════════════════════════════════════════════╗
27
+ ║ ║
28
+ ║ 🚀 AICO CLI - PowerShell 跨平台兼容层 ║
29
+ ║ 版本: $SCRIPT_VERSION | 构建: $SCRIPT_BUILD ║
30
+ ║ Windows PowerShell 环境专用 ║
31
+ ║ ║
32
+ ╚═══════════════════════════════════════════════════════════════════════════════════════╝
33
+ "@ -ForegroundColor Cyan
34
+ }
35
+
36
+ # 日志函数
37
+ function Write-AicoLog {
38
+ param(
39
+ [string]$Message,
40
+ [ValidateSet("INFO", "WARN", "ERROR", "DEBUG")]
41
+ [string]$Level = "INFO",
42
+ [string]$Source = "windows-bootstrap"
43
+ )
44
+
45
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
46
+ $entry = "[$Level] [$Source] $timestamp - $Message"
47
+
48
+ switch ($Level) {
49
+ "WARN" { Write-Host $entry -ForegroundColor Yellow }
50
+ "ERROR" { Write-Host $entry -ForegroundColor Red }
51
+ "DEBUG" { Write-Host $entry -ForegroundColor Gray }
52
+ default { Write-Host $entry -ForegroundColor White }
53
+ }
54
+
55
+ # 文件日志
56
+ $logFile = Join-Path $env:USERPROFILE ".claude\aico-windows.log"
57
+ $logDir = Split-Path -Parent $logFile
58
+ if (!(Test-Path $logDir)) {
59
+ New-Item -ItemType Directory -Path $logDir -Force | Out-Null
60
+ }
61
+ Add-Content -Path $logFile -Value $entry -Force
62
+ }
63
+
64
+ # 平台检测与兼容性检查
65
+ function Test-PlatformCompatibility {
66
+ $os = [System.Environment]::OSVersion
67
+ $isWindows = $os.Platform -eq "Win32NT"
68
+ $hasWSL = Test-Path "C:\Windows\System32\wsl.exe"
69
+ $hasGitBash = Test-Path "C:\Program Files\Git\bin\bash.exe"
70
+
71
+ $compat = @{
72
+ IsWindows = $isWindows
73
+ HasWSL = $hasWSL
74
+ HasGitBash = $hasGitBash
75
+ PowerShellVersion = $PSVersionTable.PSVersion.ToString()
76
+ IsAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
77
+ }
78
+
79
+ return $compat
80
+ }
81
+
82
+ # 路径转换工具
83
+ function Convert-ToWindowsPath {
84
+ param([string]$UnixPath)
85
+
86
+ # Git Bash/Cygwin 路径转换
87
+ if ($UnixPath -match '^/([a-zA-Z])/(.*)') {
88
+ $drive = $Matches[1].ToUpper()
89
+ $path = $Matches[2] -replace '/', '\'
90
+ return "${drive}:\${path}"
91
+ }
92
+
93
+ # 已经是 Windows 路径
94
+ if ($UnixPath -match '^[a-zA-Z]:\') {
95
+ return $UnixPath
96
+ }
97
+
98
+ # 相对路径
99
+ return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($UnixPath)
100
+ }
101
+
102
+ # .sh 脚本 PowerShell 适配器
103
+ function Invoke-BashScriptAdapter {
104
+ param(
105
+ [string]$ScriptPath,
106
+ [string[]]$ScriptArgs = @()
107
+ )
108
+
109
+ if (!(Test-Path $ScriptPath)) {
110
+ Write-AicoLog -Level "ERROR" -Message "脚本文件不存在: $ScriptPath"
111
+ return $false
112
+ }
113
+
114
+ # 查找对应的 PowerShell 版本
115
+ $psScript = $ScriptPath -replace '\.sh$', '.ps1'
116
+ if (Test-Path $psScript) {
117
+ Write-AicoLog -Level "INFO" -Message "发现 PowerShell 版本: $psScript"
118
+ try {
119
+ & $psScript @ScriptArgs
120
+ return $LASTEXITCODE -eq 0
121
+ }
122
+ catch {
123
+ Write-AicoLog -Level "ERROR" -Message "PowerShell 脚本执行失败: $($_.Exception.Message)"
124
+ return $false
125
+ }
126
+ }
127
+
128
+ # 如果没有 PS 版本,使用通用适配器
129
+ Write-AicoLog -Level "WARN" -Message "未找到 PowerShell 版本,使用通用适配器"
130
+ return Invoke-GenericBashAdapter -ScriptPath $ScriptPath -Args $ScriptArgs
131
+ }
132
+
133
+ # 通用 Bash 适配器
134
+ function Invoke-GenericBashAdapter {
135
+ param([string]$ScriptPath, [string[]]$Args)
136
+
137
+ try {
138
+ # 读取脚本内容分析
139
+ $content = Get-Content $ScriptPath -Raw
140
+
141
+ # 基本模式识别
142
+ if ($content -match 'notify\.sh') {
143
+
144
+ return Invoke-NotifyAdapter -Content $content -Args $Args
145
+ }
146
+ elseif ($content -match 'task-manager') {
147
+ return Invoke-TaskManagerAdapter -Content $content -Args $Args
148
+ }
149
+ elseif ($content -match 'requirement') {
150
+ return Invoke-RequirementAdapter -Content $content -Args $Args
151
+ }
152
+ else {
153
+ Write-AicoLog -Level "WARN" -Message "未知脚本类型,尝试调用 PowerShell 通用启动器"
154
+ $launcher = Join-Path $AICO_UTILS "platform-launcher.ps1"
155
+ if (Test-Path $launcher) {
156
+ & $launcher -ScriptType "generic" -Arguments @($ScriptPath) + $Args
157
+ return $LASTEXITCODE -eq 0
158
+ }
159
+ return $false
160
+ }
161
+ }
162
+ catch {
163
+ Write-AicoLog -Level "ERROR" -Message "通用适配失败: $($_.Exception.Message)"
164
+ return $false
165
+ }
166
+ }
167
+
168
+ # 通知系统适配器
169
+ function Invoke-NotifyAdapter {
170
+ param([string]$Content, [string[]]$Args)
171
+
172
+ Write-AicoLog -Level "INFO" -Message "调用通知系统适配器"
173
+
174
+ if ($Args.Count -gt 0) {
175
+ $eventType = $Args[0]
176
+ $notifyScript = Join-Path $AICO_HOOKS "notify.ps1"
177
+
178
+ if (Test-Path $notifyScript) {
179
+ & $notifyScript -EventType $eventType
180
+ return $LASTEXITCODE -eq 0
181
+ } else {
182
+ # 备用方案:使用系统提示
183
+ switch ($eventType) {
184
+ "input" {
185
+ [System.Console]::Beep(1000, 200)
186
+ Write-Host "🎯 Claude Code: 需要您的输入" -ForegroundColor Yellow
187
+ }
188
+ "complete" {
189
+ [System.Console]::Beep(2000, 100)
190
+ Write-Host "✅ Claude Code: 任务完成" -ForegroundColor Green
191
+ }
192
+ }
193
+ return $true
194
+ }
195
+ }
196
+
197
+ return $false
198
+ }
199
+
200
+ # 任务管理适配器
201
+ function Invoke-TaskManagerAdapter {
202
+ param([string]$Content, [string[]]$Args)
203
+
204
+ Write-AicoLog -Level "INFO" -Message "调用任务管理适配器"
205
+
206
+ if ($Args.Count -ge 2) {
207
+ $command = $Args[0]
208
+ $taskListPath = Convert-ToWindowsPath $Args[1]
209
+ $taskId = if ($Args.Count -ge 3) { $Args[2] } else { "" }
210
+
211
+ $taskManager = Join-Path $AICO_UTILS "task-manager.ps1"
212
+ if (Test-Path $taskManager) {
213
+ & $taskManager $command $taskListPath $taskId
214
+ return $LASTEXITCODE -eq 0
215
+ } else {
216
+ Write-AicoLog -Level "ERROR" -Message "任务管理器 PowerShell 版本未找到"
217
+ return $false
218
+ }
219
+ }
220
+
221
+ return $false
222
+ }
223
+
224
+ # 需求管理适配器
225
+ function Invoke-RequirementAdapter {
226
+ param([string]$Content, [string[]]$Args)
227
+
228
+ Write-AicoLog -Level "INFO" -Message "调用需求管理适配器"
229
+
230
+ # 需求管理相关脚本的统一处理
231
+ if ($Content -match 'requirement.*processor') {
232
+ # 需求处理器
233
+ if ($Args.Count -gt 0) {
234
+ $userInput = $Args -join " "
235
+ Write-AicoLog -Level "INFO" -Message "处理需求: $userInput"
236
+ Write-Host "🎯 需求识别完成,等待技术方案生成..." -ForegroundColor Green
237
+ return $true
238
+ }
239
+ }
240
+
241
+ return $true # 大多数需求管理脚本是信息收集,返回成功
242
+ }
243
+
244
+ # 命令分发
245
+ function Invoke-AicoCommand {
246
+ param([string]$Cmd, [string[]]$Args)
247
+
248
+ Write-AicoLog -Level "DEBUG" -Message "执行命令: $Cmd 参数: $($Args -join ' ')"
249
+
250
+ switch ($Cmd.ToLower()) {
251
+ "notify" {
252
+ return Invoke-NotifyAdapter -Content "" -Args $Args
253
+ }
254
+
255
+ "task-manager" {
256
+ return Invoke-TaskManagerAdapter -Content "" -Args $Args
257
+ }
258
+
259
+ { $_ -in @("requirement", "hooks", "pre-requirement", "post-requirement") } {
260
+ return Invoke-RequirementAdapter -Content $Cmd -Args $Args
261
+ }
262
+
263
+ "platform-info" {
264
+ $compat = Test-PlatformCompatibility
265
+ Write-Host "平台兼容性信息:"
266
+ $compat | ConvertTo-Json -Depth 3 | Write-Host
267
+ return $true
268
+ }
269
+
270
+ "test-connection" {
271
+ Write-AicoLog -Level "INFO" -Message "测试与 PowerShell 环境的连接..."
272
+
273
+ # 测试音频
274
+ try {
275
+ [Console]::Beep(1000, 100)
276
+ Write-Host "🔊 音频测试通过" -ForegroundColor Green
277
+ } catch {
278
+ Write-Host "⚠️ 音频测试失败" -ForegroundColor Yellow
279
+ }
280
+
281
+ # 测试路径访问
282
+ try {
283
+ Test-Path $AICO_HOOKS
284
+ Test-Path $AICO_UTILS
285
+ Write-Host "📁 路径访问测试通过" -ForegroundColor Green
286
+ } catch {
287
+ Write-Host "❌ 路径访问测试失败" -ForegroundColor Red
288
+ }
289
+
290
+ return $true
291
+ }
292
+
293
+ "help" {
294
+ Show-Usage
295
+ return $true
296
+ }
297
+
298
+ default {
299
+ # 尝试作为脚本文件执行
300
+ $scriptPath = Join-Path $AICO_HOOKS "$Cmd.ps1"
301
+ if (Test-Path $scriptPath) {
302
+ try {
303
+ & $scriptPath @Args
304
+ return $LASTEXITCODE -eq 0
305
+ }
306
+ catch {
307
+ Write-AicoLog -Level "ERROR" -Message "直接脚本执行失败: $($_.Exception.Message)"
308
+ return $false
309
+ }
310
+ }
311
+
312
+ # 最后尝试 Bash 适配器
313
+ $bashScript = Join-Path $AICO_HOOKS "$Cmd.sh"
314
+ if (Test-Path $bashScript) {
315
+ return Invoke-BashScriptAdapter -ScriptPath $bashScript -ScriptArgs $Args
316
+ }
317
+
318
+ Write-AicoLog -Level "ERROR" -Message "未知命令或脚本: $Cmd"
319
+ return $false
320
+ }
321
+ }
322
+ }
323
+
324
+ function Show-Usage {
325
+ Write-Host @"
326
+ 🚀 AICO CLI Windows PowerShell 启动器
327
+
328
+ 📋 可用命令:
329
+ notify [input|complete] - 触发通知系统
330
+ task-manager <command> - 任务管理操作
331
+ requirement <user-input> - 处理用户需求
332
+ platform-info - 显示平台兼容性信息
333
+ test-connection - 连接性测试
334
+ <script-name> [args...] - 执行特定脚本
335
+
336
+ 🔧 PowerShell 脚本兼容性:
337
+ ✓ 原生 PowerShell 脚本
338
+ ✓ 增强的Bash脚本适配器
339
+ ✓ 跨平台路径转换
340
+ ✓ Windows音频系统集成
341
+
342
+ 💡 使用示例:
343
+ .\windows-bootstrap.ps1 notify input
344
+ .\windows-bootstrap.ps1 requirement "开发用户登录功能"
345
+ .\windows-bootstrap.ps1 platform-info
346
+ .\windows-bootstrap.ps1 notify complete
347
+
348
+ 🎯 文件位置:
349
+ 日志文件: $env:USERPROFILE\.claude\aico-windows.log
350
+ 临时数据: $env:TEMP\aico-hooks\
351
+ "@ -ForegroundColor Cyan
352
+ }
353
+
354
+ # 主函数
355
+ function Main {
356
+ Write-AicoBanner
357
+ Write-AicoLog -Level "INFO" -Message "AICO Windows Bootstrap 启动"
358
+
359
+ # 平台兼容性检查
360
+ $compat = Test-PlatformCompatibility
361
+ Write-AicoLog -Level "DEBUG" -Message "平台信息: $($compat | ConvertTo-Json -Compress)"
362
+
363
+ if (!$compat.IsWindows) {
364
+ Write-AicoLog -Level "ERROR" -Message "非 Windows 环境,此脚本专用于 Windows"
365
+ return 1
366
+ }
367
+
368
+ Write-AicoLog -Level "INFO" -Message "执行命令: $Command 参数: $($Arguments -join ' ')"
369
+
370
+ # 执行命令
371
+ $result = Invoke-AicoCommand -Cmd $Command -Args $Arguments
372
+
373
+ if ($result) {
374
+ Write-AicoLog -Level "SUCCESS" -Message "命令执行成功: $Command"
375
+ return 0
376
+ } else {
377
+ Write-AicoLog -Level "ERROR" -Message "命令执行失败: $Command"
378
+ return 1
379
+ }
380
+ }
381
+
382
+ # 入口点
383
+ try {
384
+ exit (Main)
385
+ }
386
+ catch {
387
+ Write-AicoLog -Level "ERROR" -Message "引导程序异常: $($_.Exception.Message)"
388
+ Write-Host "❌ 引导程序异常,查看日志获取详情: $env:USERPROFILE\.claude\aico-windows.log" -ForegroundColor Red
389
+ exit 1
390
+ }
@@ -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
- **兼容性状态**: ✅ 生产环境就绪