1+ # !/usr/bin/env pwsh
2+
3+ # AI Agent Team CLI PowerShell版本
4+ # 使用方法: .\cli.ps1 [agent] [task]
5+ # 示例: .\cli.ps1 pm "设计用户认证系统"
6+
7+ param (
8+ [Parameter (Position = 0 )]
9+ [string ]$Agent ,
10+
11+ [Parameter (Position = 1 )]
12+ [string ]$Task = " "
13+ )
14+
15+ # 颜色定义
16+ $colors = @ {
17+ Red = " Red"
18+ Green = " Green"
19+ Yellow = " Yellow"
20+ Blue = " Blue"
21+ Magenta = " Magenta"
22+ Cyan = " Cyan"
23+ White = " White"
24+ }
25+
26+ # 智能体映射
27+ $agentMap = @ {
28+ " pm" = " product_manager"
29+ " product_manager" = " product_manager"
30+ " 产品经理" = " product_manager"
31+ " fe" = " frontend_dev"
32+ " frontend_dev" = " frontend_dev"
33+ " 前端开发" = " frontend_dev"
34+ " be" = " backend_dev"
35+ " backend_dev" = " backend_dev"
36+ " 后端开发" = " backend_dev"
37+ " qa" = " qa_engineer"
38+ " qa_engineer" = " qa_engineer"
39+ " 测试工程师" = " qa_engineer"
40+ " ops" = " devops_engineer"
41+ " devops_engineer" = " devops_engineer"
42+ " 运维工程师" = " devops_engineer"
43+ " tl" = " tech-leader"
44+ " tech_leader" = " tech-leader"
45+ " 技术负责人" = " tech-leader"
46+ }
47+
48+ # 显示Logo
49+ function Show-Logo {
50+ Write-Host @"
51+
52+ ╔══════════════════════════════════════════════════════════════╗
53+ ║ ║
54+ ║ 🤖 AI Agent Team CLI PowerShell 版本 ║
55+ ║ ║
56+ ║ 基于Claude Code的专业AI智能体团队系统 ║
57+ ║ ║
58+ ╚══════════════════════════════════════════════════════════════╝
59+
60+ "@ - ForegroundColor Cyan
61+ }
62+
63+ # 显示帮助
64+ function Show-Help {
65+ Write-Host " 使用方法:" - ForegroundColor Green
66+ Write-Host " .\cli.ps1 [智能体] [任务描述]" - ForegroundColor White
67+ Write-Host " "
68+ Write-Host " 智能体列表:" - ForegroundColor Green
69+ Write-Host " pm, product_manager, 产品经理 - 产品经理智能体" - ForegroundColor White
70+ Write-Host " fe, frontend_dev, 前端开发 - 前端开发智能体" - ForegroundColor White
71+ Write-Host " be, backend_dev, 后端开发 - 后端开发智能体" - ForegroundColor White
72+ Write-Host " qa, qa_engineer, 测试工程师 - QA工程师智能体" - ForegroundColor White
73+ Write-Host " ops, devops_engineer, 运维工程师 - DevOps工程师智能体" - ForegroundColor White
74+ Write-Host " tl, tech_leader, 技术负责人 - 技术负责人智能体" - ForegroundColor White
75+ Write-Host " "
76+ Write-Host " 快捷命令:" - ForegroundColor Green
77+ Write-Host " .\cli.ps1 pm '任务描述' - 调用产品经理" - ForegroundColor White
78+ Write-Host " .\cli.ps1 fe '任务描述' - 调用前端开发" - ForegroundColor White
79+ Write-Host " .\cli.ps1 be '任务描述' - 调用后端开发" - ForegroundColor White
80+ Write-Host " .\cli.ps1 qa '任务描述' - 调用QA工程师" - ForegroundColor White
81+ Write-Host " .\cli.ps1 ops '任务描述' - 调用DevOps工程师" - ForegroundColor White
82+ Write-Host " .\cli.ps1 tl '任务描述' - 调用技术负责人" - ForegroundColor White
83+ Write-Host " "
84+ Write-Host " 示例:" - ForegroundColor Green
85+ Write-Host " .\cli.ps1 pm '设计用户认证系统'" - ForegroundColor Yellow
86+ Write-Host " .\cli.ps1 fe '创建响应式登录页面'" - ForegroundColor Yellow
87+ Write-Host " .\cli.ps1 be '实现JWT认证API'" - ForegroundColor Yellow
88+ Write-Host " .\cli.ps1 qa '编写单元测试'" - ForegroundColor Yellow
89+ Write-Host " .\cli.ps1 ops '部署到生产环境'" - ForegroundColor Yellow
90+ Write-Host " .\cli.ps1 tl '评估系统架构'" - ForegroundColor Yellow
91+ }
92+
93+ # 执行Claude命令
94+ function Invoke-ClaudeCommand {
95+ param (
96+ [string ]$AgentName ,
97+ [string ]$TaskDesc
98+ )
99+
100+ Write-Host " 🚀 正在调用 $AgentName 智能体..." - ForegroundColor Yellow
101+ Write-Host " 📝 任务: $TaskDesc " - ForegroundColor Blue
102+ Write-Host " "
103+
104+ try {
105+ # 构建Claude命令
106+ $claudeCommand = " claude -p `" /agent $AgentName '$TaskDesc '`" "
107+
108+ # 执行命令
109+ Write-Host " 执行命令: $claudeCommand " - ForegroundColor Gray
110+ Invoke-Expression $claudeCommand
111+
112+ if ($LASTEXITCODE -eq 0 ) {
113+ Write-Host " "
114+ Write-Host " ✅ 任务执行完成" - ForegroundColor Green
115+ } else {
116+ Write-Host " "
117+ Write-Host " ❌ 任务执行失败 (退出码: $LASTEXITCODE )" - ForegroundColor Red
118+ }
119+ }
120+ catch {
121+ Write-Host " ❌ 执行过程中出现错误: $ ( $_.Exception.Message ) " - ForegroundColor Red
122+ }
123+ }
124+
125+ # 显示可用智能体
126+ function Show-AvailableAgents {
127+ $agentsDir = Join-Path $PSScriptRoot " .."
128+ $agentFiles = Get-ChildItem - Path $agentsDir - Filter " *.md" | Where-Object { $_.Name -ne " README.md" }
129+
130+ if ($agentFiles.Count -gt 0 ) {
131+ Write-Host " 🤖 可用智能体:" - ForegroundColor Green
132+ Write-Host " "
133+
134+ foreach ($file in $agentFiles ) {
135+ $agentName = $file.BaseName
136+ $content = Get-Content - Path $file.FullName - Raw
137+
138+ # 提取描述信息
139+ if ($content -match " #\s*([^\r\n]+)" ) {
140+ $title = $matches [1 ]
141+ } else {
142+ $title = $agentName
143+ }
144+
145+ if ($content -match " ##\s*专业能力\s*([^#]*?)(?=\s*##|$)" ) {
146+ $skills = $matches [1 ].Trim()
147+ # 简化显示
148+ if ($skills.Length -gt 50 ) {
149+ $skills = $skills.Substring (0 , 50 ) + " ..."
150+ }
151+ } else {
152+ $skills = " 专业AI智能体"
153+ }
154+
155+ Write-Host " • $agentName " - ForegroundColor Cyan
156+ Write-Host " $title " - ForegroundColor White
157+ Write-Host " $skills " - ForegroundColor Gray
158+ Write-Host " "
159+ }
160+ } else {
161+ Write-Host " ❌ 未找到智能体配置文件" - ForegroundColor Red
162+ Write-Host " 请检查 .claude/agents/ 目录是否存在 .md 文件" - ForegroundColor Yellow
163+ }
164+ }
165+
166+ # 主逻辑
167+ function Main {
168+ Show-Logo
169+
170+ if ([string ]::IsNullOrEmpty($Agent )) {
171+ Write-Host " "
172+ Write-Host " 请指定智能体和任务描述" - ForegroundColor Yellow
173+ Show-Help
174+ Write-Host " "
175+ Show-AvailableAgents
176+ return
177+ }
178+
179+ if ([string ]::IsNullOrEmpty($Task )) {
180+ Write-Host " "
181+ Write-Host " 请提供任务描述" - ForegroundColor Yellow
182+ Write-Host " "
183+ Write-Host " 使用方法: .\cli.ps1 [智能体] [任务描述]" - ForegroundColor White
184+ Write-Host " 示例: .\cli.ps1 pm '设计用户认证系统'" - ForegroundColor Yellow
185+ return
186+ }
187+
188+ # 映射智能体名称
189+ if ($agentMap.ContainsKey ($Agent.ToLower ())) {
190+ $resolvedAgent = $agentMap [$Agent.ToLower ()]
191+ } else {
192+ Write-Host " "
193+ Write-Host " ❌ 未知的智能体: $Agent " - ForegroundColor Red
194+ Write-Host " "
195+ Write-Host " 可用的智能体:" - ForegroundColor Green
196+ foreach ($key in $agentMap.Keys ) {
197+ Write-Host " • $key -> $ ( $agentMap [$key ]) " - ForegroundColor White
198+ }
199+ return
200+ }
201+
202+ # 执行命令
203+ Invoke-ClaudeCommand - AgentName $resolvedAgent - TaskDesc $Task
204+ }
205+
206+ # 检查Claude是否可用
207+ $claudeExists = Get-Command " claude" - ErrorAction SilentlyContinue
208+ if (-not $claudeExists ) {
209+ Write-Host " ❌ Claude Code未安装或不在PATH中" - ForegroundColor Red
210+ Write-Host " 请确保Claude Code已安装并添加到系统PATH" - ForegroundColor Yellow
211+ Write-Host " 安装地址: https://claude.ai/code" - ForegroundColor Cyan
212+ exit 1
213+ }
214+
215+ # 执行主函数
216+ Main
0 commit comments