rush-ai 0.2.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.
@@ -0,0 +1,89 @@
1
+ ---
2
+ name: rush-task
3
+ description: "在 Claude Code 中创建 Rush Agent 任务并跟踪执行过程。当用户想让 Rush Agent(如 UI 生成、代码分析、文档撰写等)执行任务时使用此 Skill。"
4
+ version: 0.2.0
5
+ author: kanyun
6
+ tags:
7
+ - rush
8
+ - agent
9
+ - task
10
+ argument-hint: <prompt>
11
+ ---
12
+
13
+ # Rush Task — Agent 任务执行
14
+
15
+ 你可以通过 Rush MCP 工具来创建和管理 Agent 任务。
16
+
17
+ ## 前置条件
18
+
19
+ 在执行任何操作前,确认以下条件:
20
+ - MCP server "rush" 已连接(tools 列表中有 `rush_*` 开头的工具)
21
+ - 如果 MCP 工具不可用,提示用户运行 `rush-ai plugin doctor` 诊断问题
22
+
23
+ ## 使用流程
24
+
25
+ ### Step 1: 列出可用 Agent
26
+
27
+ 调用 `rush_agent_list` 获取当前可用的 Agent 列表。
28
+
29
+ **失败处理:**
30
+ - 如果返回鉴权错误(`Not authenticated`),提示用户运行 `rush-ai auth login`
31
+ - 如果连接失败或超时,提示用户运行 `rush-ai plugin doctor` 检查配置
32
+
33
+ ### Step 2: 选择 Agent
34
+
35
+ - 如果只有一个 Agent,直接使用
36
+ - 如果有多个 Agent,向用户展示列表(名称 + 能力描述),让用户选择
37
+ - 如果没有可用 Agent,告知用户当前无可用 Agent,建议联系管理员配置
38
+
39
+ ### Step 3: 执行任务(策略分流)
40
+
41
+ 根据任务复杂度选择执行策略:
42
+
43
+ **短任务(简单查询、快速操作):**
44
+ 使用 `rush_task_run` 同步执行,直接返回结果。
45
+ - 适用场景:用户明确说"快速"、"简单查询"、"查看状态"
46
+
47
+ **长任务(复杂生成、多步骤处理):**
48
+ 1. 调用 `rush_task_create` 创建异步任务
49
+ 2. 调用 `rush_task_watch` 跟踪进度(默认超时 5 分钟)
50
+ 3. 向用户实时展示进度信息
51
+ - 适用场景:用户要求"生成"、"创建"、"分析"、"重构"
52
+
53
+ **判断策略:**
54
+ - 用户明确说"快速"、"简单查询" → 短任务(`rush_task_run`)
55
+ - 用户要求"生成"、"创建"、"分析"等复杂操作 → 长任务(`rush_task_create`)
56
+ - 不确定时默认使用异步模式(`rush_task_create`)
57
+
58
+ ### Step 4: 获取结果
59
+
60
+ - 调用 `rush_task_result` 获取最终结果
61
+ - 如果任务失败,展示错误信息并建议:
62
+ - 修改 prompt 重试
63
+ - 检查 Agent 是否支持该类型任务
64
+ - 如果有输出文件,调用 `rush_task_files` 列出并展示:
65
+ - 代码文件(code):展示文件路径和内容摘要
66
+ - 图片文件(image):展示 URL 供用户查看
67
+ - 文档文件(document):展示内容
68
+
69
+ ### Step 5: 后续操作
70
+
71
+ - 用户可以基于结果继续对话("修改一下..."、"重新生成...")
72
+ - 继续操作时创建新任务,在 prompt 中引用之前的 task_id 提供上下文
73
+ - 用户可以随时用 `rush_task_cancel` 取消运行中的任务
74
+ - 用 `rush_task_list` 查看历史任务
75
+
76
+ ## 可用 MCP 工具参考
77
+
78
+ | 工具 | 用途 |
79
+ |------|------|
80
+ | `rush_agent_list` | 列出可用 Agent |
81
+ | `rush_agent_info` | 获取 Agent 详细信息 |
82
+ | `rush_task_run` | 同步执行任务(阻塞直到完成) |
83
+ | `rush_task_create` | 创建异步任务 |
84
+ | `rush_task_status` | 查询任务状态 |
85
+ | `rush_task_result` | 获取任务结果 |
86
+ | `rush_task_watch` | 实时跟踪任务进度(SSE) |
87
+ | `rush_task_list` | 列出历史任务 |
88
+ | `rush_task_files` | 列出任务输出文件 |
89
+ | `rush_task_cancel` | 取消运行中的任务 |
@@ -0,0 +1,140 @@
1
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { describe, expect, it } from 'vitest';
4
+
5
+ const COMMANDS_DIR = resolve(__dirname);
6
+
7
+ /**
8
+ * Slash command behavior tests.
9
+ *
10
+ * These .md files are Claude Code prompt templates — they define the AI's
11
+ * behavioral contract for each slash command. The tests validate:
12
+ * 1. All expected command files exist
13
+ * 2. Each command references the correct MCP tools
14
+ * 3. Each command defines error handling / recovery guidance
15
+ * 4. Each command follows the required structure (description + numbered steps)
16
+ */
17
+
18
+ const EXPECTED_COMMANDS = [
19
+ {
20
+ file: 'rush-task.md',
21
+ description: '/rush-task',
22
+ requiredTools: ['rush_agent_list', 'rush_task_run', 'rush_task_files'],
23
+ requiredRecovery: ['rush-ai auth login', 'rush-ai plugin doctor'],
24
+ },
25
+ {
26
+ file: 'rush-agent.md',
27
+ description: '/rush-agent',
28
+ requiredTools: ['rush_agent_list', 'rush_agent_info'],
29
+ requiredRecovery: ['rush-ai auth login', 'rush-ai plugin doctor'],
30
+ },
31
+ {
32
+ file: 'rush-files.md',
33
+ description: '/rush-files',
34
+ requiredTools: ['rush_task_files', 'rush_task_list'],
35
+ requiredRecovery: ['rush-ai auth login', 'rush-ai plugin doctor'],
36
+ },
37
+ ];
38
+
39
+ describe('slash command definitions', () => {
40
+ it('all expected command files exist', () => {
41
+ for (const cmd of EXPECTED_COMMANDS) {
42
+ const filePath = resolve(COMMANDS_DIR, cmd.file);
43
+ expect(existsSync(filePath), `${cmd.file} should exist`).toBe(true);
44
+ }
45
+ });
46
+
47
+ it('no unexpected command files', () => {
48
+ const mdFiles = readdirSync(COMMANDS_DIR).filter((f) =>
49
+ f.endsWith('.md')
50
+ );
51
+ const expectedFiles = EXPECTED_COMMANDS.map((c) => c.file);
52
+ for (const file of mdFiles) {
53
+ expect(expectedFiles, `unexpected command file: ${file}`).toContain(file);
54
+ }
55
+ });
56
+
57
+ for (const cmd of EXPECTED_COMMANDS) {
58
+ describe(cmd.description, () => {
59
+ const filePath = resolve(COMMANDS_DIR, cmd.file);
60
+ const content = existsSync(filePath)
61
+ ? readFileSync(filePath, 'utf-8')
62
+ : '';
63
+
64
+ it('has a description on the first line', () => {
65
+ const firstLine = content.split('\n')[0].trim();
66
+ expect(firstLine.length).toBeGreaterThan(0);
67
+ // First line should be descriptive text, not a heading or empty
68
+ expect(firstLine).not.toMatch(/^#/);
69
+ });
70
+
71
+ it('defines a numbered execution flow', () => {
72
+ // Must contain at least "1." and "2." steps
73
+ expect(content).toMatch(/^1\./m);
74
+ expect(content).toMatch(/^2\./m);
75
+ });
76
+
77
+ it('references required MCP tools', () => {
78
+ for (const tool of cmd.requiredTools) {
79
+ expect(
80
+ content,
81
+ `${cmd.file} should reference MCP tool: ${tool}`
82
+ ).toContain(tool);
83
+ }
84
+ });
85
+
86
+ it('includes error recovery guidance', () => {
87
+ for (const recovery of cmd.requiredRecovery) {
88
+ expect(
89
+ content,
90
+ `${cmd.file} should include recovery: ${recovery}`
91
+ ).toContain(recovery);
92
+ }
93
+ });
94
+ });
95
+ }
96
+ });
97
+
98
+ describe('/rush-agent specific behavior', () => {
99
+ const content = readFileSync(
100
+ resolve(COMMANDS_DIR, 'rush-agent.md'),
101
+ 'utf-8'
102
+ );
103
+
104
+ it('supports listing all agents (no argument)', () => {
105
+ expect(content).toContain('rush_agent_list');
106
+ expect(content).toMatch(/列表/);
107
+ });
108
+
109
+ it('supports querying a specific agent by name (with argument)', () => {
110
+ expect(content).toContain('rush_agent_info');
111
+ expect(content).toMatch(/\/rush-agent\s+\S+/);
112
+ });
113
+ });
114
+
115
+ describe('/rush-files specific behavior', () => {
116
+ const content = readFileSync(
117
+ resolve(COMMANDS_DIR, 'rush-files.md'),
118
+ 'utf-8'
119
+ );
120
+
121
+ it('supports direct task ID input', () => {
122
+ expect(content).toMatch(/\/rush-files\s+\S+/);
123
+ expect(content).toContain('task ID');
124
+ });
125
+
126
+ it('supports interactive task selection when no ID given', () => {
127
+ expect(content).toContain('rush_task_list');
128
+ expect(content).toMatch(/最近/);
129
+ });
130
+
131
+ it('defines file type categories for display', () => {
132
+ expect(content).toMatch(/代码文件|code/i);
133
+ expect(content).toMatch(/图片文件|image/i);
134
+ expect(content).toMatch(/文档文件|document/i);
135
+ });
136
+
137
+ it('handles empty file list scenario', () => {
138
+ expect(content).toMatch(/没有.*文件|no.*file/i);
139
+ });
140
+ });
@@ -0,0 +1,18 @@
1
+ 查看和选择可用的 Rush Agent。
2
+
3
+ 当用户调用 /rush-agent 时,按照以下流程执行:
4
+
5
+ 1. 确认 Rush MCP 工具可用(检查 `rush_agent_list` 等工具是否在 tools 列表中)
6
+ 2. 调用 `rush_agent_list` 获取所有可用 Agent
7
+ 3. 以列表形式展示每个 Agent 的:
8
+ - 名称(name)
9
+ - 描述(description)
10
+ - 支持的能力/技能(skills)
11
+ 4. 如果用户在命令中指定了 Agent 名称(如 `/rush-agent ui-generator`),调用 `rush_agent_info` 获取该 Agent 的详细信息并展示:
12
+ - 完整描述
13
+ - 支持的 skills 列表
14
+ - 可用的 MCP servers
15
+ - 使用示例
16
+ 5. 失败时给出修复建议:
17
+ - 鉴权错误 → `rush-ai auth login`
18
+ - 连接失败 → `rush-ai plugin doctor`
@@ -0,0 +1,19 @@
1
+ 获取并展示 Rush Agent 任务的输出文件。
2
+
3
+ 当用户调用 /rush-files 时,按照以下流程执行:
4
+
5
+ 1. 确认 Rush MCP 工具可用(检查 `rush_task_files` 等工具是否在 tools 列表中)
6
+ 2. 如果用户提供了 task ID(如 `/rush-files abc123`),直接使用该 ID
7
+ 3. 如果没有提供 task ID:
8
+ - 调用 `rush_task_list` 获取最近的任务列表
9
+ - 展示最近 5 个任务,让用户选择
10
+ 4. 调用 `rush_task_files` 获取指定任务的输出文件列表
11
+ 5. 按文件类型分类展示:
12
+ - **代码文件**(code):展示文件名、语言、内容摘要
13
+ - **图片文件**(image):展示文件名和 URL
14
+ - **文档文件**(document):展示文件名和内容预览
15
+ 6. 如果没有输出文件,告知用户该任务没有产出文件
16
+ 7. 失败时给出修复建议:
17
+ - 鉴权错误 → `rush-ai auth login`
18
+ - 任务不存在 → 检查 task ID 是否正确
19
+ - 连接失败 → `rush-ai plugin doctor`
@@ -0,0 +1,15 @@
1
+ 使用 Rush Agent 执行任务。
2
+
3
+ 当用户调用 /rush-task 时,按照以下流程执行:
4
+
5
+ 1. 确认 Rush MCP 工具可用(检查 `rush_agent_list` 等工具是否在 tools 列表中)
6
+ 2. 调用 `rush_agent_list` 列出可用 Agent
7
+ 3. 如果有多个 Agent,让用户选择;只有一个则直接使用
8
+ 4. 根据任务复杂度选择执行策略:
9
+ - 简单查询 → `rush_task_run`(同步)
10
+ - 复杂生成 → `rush_task_create` + `rush_task_watch`(异步)
11
+ 5. 展示执行结果
12
+ 6. 如有文件输出(代码、图片、文档),调用 `rush_task_files` 并展示
13
+ 7. 失败时给出明确的修复建议(`rush-ai auth login` / `rush-ai plugin doctor`)
14
+
15
+ 如果用户在命令中指定了参数(如 `/rush-task 生成登录页`),直接作为 prompt 使用,无需再次询问。
@@ -0,0 +1,24 @@
1
+ # Rush Agent 使用规则
2
+
3
+ 当项目中安装了 Rush plugin 且 MCP server "rush" 已连接时,遵循以下规则:
4
+
5
+ ## 何时使用 Rush Agent
6
+
7
+ - 用户明确要求使用 Rush Agent 执行任务
8
+ - 用户调用 `/rush-task` 命令
9
+ - 用户提到"让 Rush 来做"、"用 Agent 处理"等意图
10
+
11
+ ## 何时不使用 Rush Agent
12
+
13
+ - 用户要求本地操作(编辑文件、运行命令等)— 直接使用 Claude Code 本身能力
14
+ - 用户没有提到 Rush 或 Agent — 不要主动推荐
15
+
16
+ ## 错误恢复
17
+
18
+ 当 Rush MCP 工具调用失败时:
19
+
20
+ 1. **鉴权错误**(`Not authenticated`)→ 提示:`rush-ai auth login`
21
+ 2. **连接失败** → 提示:`rush-ai plugin doctor`
22
+ 3. **Agent 不存在** → 调用 `rush_agent_list` 列出可用 Agent
23
+ 4. **任务超时** → 建议用户检查网络或简化任务
24
+ 5. **任务失败** → 展示错误信息,建议修改 prompt 重试