pulse-coder-cli 0.0.1-alpha.1 → 0.0.1-alpha.4
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.
- package/README.md +2 -2
- package/dist/index.cjs +469 -0
- package/package.json +9 -6
- package/.pulse-coder/agents/code-reviewer.md +0 -36
- package/.pulse-coder/agents/doc-generator.md +0 -37
- package/.pulse-coder/agents/test-writer.md +0 -38
- package/.pulse-coder/mcp.json +0 -8
- package/.pulse-coder/skills/branch-naming/SKILL.md +0 -427
- package/.pulse-coder/skills/code-review/SKILL.md +0 -56
- package/.pulse-coder/skills/deep-research/SKILL.md +0 -124
- package/.pulse-coder/skills/git-workflow/SKILL.md +0 -93
- package/.pulse-coder/skills/mr-generator/README.md +0 -96
- package/.pulse-coder/skills/mr-generator/SKILL.md +0 -113
- package/.pulse-coder/skills/mr-generator/mr-generate.sh +0 -342
- package/.pulse-coder/skills/refactor/SKILL.md +0 -63
- package/dist/index.js +0 -599
- package/dist/index.js.map +0 -1
- package/src/index.ts +0 -321
- package/src/input-manager.ts +0 -113
- package/src/session-commands.ts +0 -142
- package/src/session.ts +0 -171
- package/tsconfig.json +0 -9
- package/tsup.config.ts +0 -12
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# MR Generator - 自动生成 MR 标题和描述
|
|
4
|
-
# 基于当前分支与远程 master 的 diff 分析
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
# 配置
|
|
9
|
-
TARGET_BRANCH="origin/master"
|
|
10
|
-
PREVIEW_MODE=false
|
|
11
|
-
|
|
12
|
-
# 颜色定义
|
|
13
|
-
GREEN='\033[0;32m'
|
|
14
|
-
BLUE='\033[0;34m'
|
|
15
|
-
YELLOW='\033[1;33m'
|
|
16
|
-
RED='\033[0;31m'
|
|
17
|
-
NC='\033[0m'
|
|
18
|
-
|
|
19
|
-
# 解析参数
|
|
20
|
-
while [[ $# -gt 0 ]]; do
|
|
21
|
-
case $1 in
|
|
22
|
-
--target)
|
|
23
|
-
TARGET_BRANCH="$2"
|
|
24
|
-
shift 2
|
|
25
|
-
;;
|
|
26
|
-
--preview)
|
|
27
|
-
PREVIEW_MODE=true
|
|
28
|
-
shift
|
|
29
|
-
;;
|
|
30
|
-
-h|--help)
|
|
31
|
-
echo "Usage: $0 [--target branch] [--preview]"
|
|
32
|
-
echo "Generate MR title and description based on branch diff"
|
|
33
|
-
echo ""
|
|
34
|
-
echo "Options:"
|
|
35
|
-
echo " --target branch Target branch to compare against (default: origin/master)"
|
|
36
|
-
echo " --preview Show preview mode with additional info"
|
|
37
|
-
echo " -h, --help Show this help message"
|
|
38
|
-
exit 0
|
|
39
|
-
;;
|
|
40
|
-
*)
|
|
41
|
-
echo "❌ Unknown option: $1"
|
|
42
|
-
exit 1
|
|
43
|
-
;;
|
|
44
|
-
esac
|
|
45
|
-
done
|
|
46
|
-
|
|
47
|
-
# 获取当前分支
|
|
48
|
-
current_branch=$(git branch --show-current)
|
|
49
|
-
if [[ "$current_branch" == "master" || "$current_branch" == "main" ]]; then
|
|
50
|
-
echo "❌ Cannot create MR from master branch"
|
|
51
|
-
exit 1
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
# 确保远程分支是最新的
|
|
55
|
-
echo -e "${BLUE}Fetching latest changes...${NC}"
|
|
56
|
-
git fetch origin
|
|
57
|
-
|
|
58
|
-
# 检查目标分支是否存在
|
|
59
|
-
if ! git ls-remote --heads origin "${TARGET_BRANCH#origin/}" | grep -q "refs/heads/"; then
|
|
60
|
-
echo "❌ Target branch $TARGET_BRANCH does not exist"
|
|
61
|
-
exit 1
|
|
62
|
-
fi
|
|
63
|
-
|
|
64
|
-
# 获取 diff 统计和变更类型
|
|
65
|
-
diff_stats=$(git diff --stat "$TARGET_BRANCH"...HEAD 2>/dev/null || echo "")
|
|
66
|
-
if [[ -z "$diff_stats" ]]; then
|
|
67
|
-
echo "❌ No changes detected between $current_branch and $TARGET_BRANCH"
|
|
68
|
-
exit 1
|
|
69
|
-
fi
|
|
70
|
-
|
|
71
|
-
# 获取变更文件列表和状态
|
|
72
|
-
changed_files=$(git diff --name-only "$TARGET_BRANCH"...HEAD)
|
|
73
|
-
file_count=$(echo "$changed_files" | wc -l | tr -d ' ')
|
|
74
|
-
|
|
75
|
-
# 获取文件状态统计
|
|
76
|
-
added_files=$(git diff --name-status "$TARGET_BRANCH"...HEAD | grep "^A" | wc -l | tr -d ' ')
|
|
77
|
-
modified_files=$(git diff --name-status "$TARGET_BRANCH"...HEAD | grep "^M" | wc -l | tr -d ' ')
|
|
78
|
-
deleted_files=$(git diff --name-status "$TARGET_BRANCH"...HEAD | grep "^D" | wc -l | tr -d ' ')
|
|
79
|
-
|
|
80
|
-
# 分析变更类型
|
|
81
|
-
analyze_change_type() {
|
|
82
|
-
local files="$1"
|
|
83
|
-
|
|
84
|
-
# 检查文件类型分布
|
|
85
|
-
local has_src=$(echo "$files" | grep -c "src/" || echo 0)
|
|
86
|
-
local has_test=$(echo "$files" | grep -c "test\|spec" || echo 0)
|
|
87
|
-
local has_docs=$(echo "$files" | grep -c "\.md\|README\|docs/" || echo 0)
|
|
88
|
-
local has_config=$(echo "$files" | grep -c "\.json\|\.yml\|\.yaml\|\.config" || echo 0)
|
|
89
|
-
local has_fix=$(git log --oneline "$TARGET_BRANCH"...HEAD | grep -ic "fix\|bug\|repair\|resolve" || echo 0)
|
|
90
|
-
local has_feature=$(git log --oneline "$TARGET_BRANCH"...HEAD | grep -ic "feat\|feature\|add\|implement" || echo 0)
|
|
91
|
-
|
|
92
|
-
# 基于文件状态判断
|
|
93
|
-
if [[ $added_files -gt 0 && $modified_files -eq 0 && $deleted_files -eq 0 ]]; then
|
|
94
|
-
echo "add"
|
|
95
|
-
elif [[ $deleted_files -gt 0 ]]; then
|
|
96
|
-
echo "remove"
|
|
97
|
-
elif [[ $has_fix -gt 0 ]]; then
|
|
98
|
-
echo "fix"
|
|
99
|
-
elif [[ $has_feature -gt 0 ]]; then
|
|
100
|
-
echo "feature"
|
|
101
|
-
elif [[ $has_test -gt $(($file_count / 2)) ]]; then
|
|
102
|
-
echo "test"
|
|
103
|
-
elif [[ $has_docs -gt $(($file_count / 2)) ]]; then
|
|
104
|
-
echo "docs"
|
|
105
|
-
elif [[ $has_config -gt 0 ]]; then
|
|
106
|
-
echo "config"
|
|
107
|
-
else
|
|
108
|
-
echo "update"
|
|
109
|
-
fi
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
# 提取主要模块
|
|
113
|
-
extract_main_module() {
|
|
114
|
-
local files="$1"
|
|
115
|
-
|
|
116
|
-
# 找出最常见的目录/模块
|
|
117
|
-
local module=$(echo "$files" | sed 's|\(.*\)/.*|\1|' | sort | uniq -c | sort -nr | head -1 | awk '{print $2}' | sed 's|packages/cli/||' | sed 's|src/||' | sed 's|lib/||' | sed 's|components/||' | sed 's|pages/||' | sed 's|\.coder/skills/||')
|
|
118
|
-
|
|
119
|
-
# 如果没有目录,从文件名提取
|
|
120
|
-
if [[ -z "$module" || "$module" == "." ]]; then
|
|
121
|
-
local first_file=$(echo "$files" | head -1 | sed 's|.*/||' | sed 's/\..*$//')
|
|
122
|
-
module=$(echo "$first_file" | tr '_' ' ' | tr '-' ' ')
|
|
123
|
-
fi
|
|
124
|
-
|
|
125
|
-
# 转换为简洁描述
|
|
126
|
-
echo "$module" | sed 's/$/ module/' | sed 's/src module/source/' | sed 's/config module/configuration/' | sed 's/test module/testing/' | sed 's/api/API/' | sed 's/ui/UI/' | sed 's/auth/authentication/' | sed 's/validation/validation/' | sed 's/utils/utilities/' | sed 's/services/service layer/' | sed 's/ [Mm]odule$//' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//'
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
# 生成标题
|
|
130
|
-
generate_title() {
|
|
131
|
-
local change_type="$1"
|
|
132
|
-
local module="$2"
|
|
133
|
-
|
|
134
|
-
case "$change_type" in
|
|
135
|
-
"add")
|
|
136
|
-
echo "Add ${module}"
|
|
137
|
-
;;
|
|
138
|
-
"remove")
|
|
139
|
-
echo "Remove ${module}"
|
|
140
|
-
;;
|
|
141
|
-
"fix")
|
|
142
|
-
echo "Fix ${module} issue"
|
|
143
|
-
;;
|
|
144
|
-
"test")
|
|
145
|
-
echo "Add tests for ${module}"
|
|
146
|
-
;;
|
|
147
|
-
"docs")
|
|
148
|
-
echo "Update ${module} documentation"
|
|
149
|
-
;;
|
|
150
|
-
"config")
|
|
151
|
-
echo "Update ${module} configuration"
|
|
152
|
-
;;
|
|
153
|
-
"feature")
|
|
154
|
-
echo "Add ${module} functionality"
|
|
155
|
-
;;
|
|
156
|
-
"update")
|
|
157
|
-
echo "Update ${module}"
|
|
158
|
-
;;
|
|
159
|
-
*)
|
|
160
|
-
echo "Update ${module}"
|
|
161
|
-
;;
|
|
162
|
-
esac
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
# 生成更智能的描述点
|
|
166
|
-
generate_description_points() {
|
|
167
|
-
local change_type="$1"
|
|
168
|
-
local files="$2"
|
|
169
|
-
|
|
170
|
-
local points=()
|
|
171
|
-
|
|
172
|
-
# 基于文件状态和类型生成描述
|
|
173
|
-
local file_statuses=$(git diff --name-status "$TARGET_BRANCH"...HEAD)
|
|
174
|
-
|
|
175
|
-
while IFS= read -r line; do
|
|
176
|
-
local status=$(echo "$line" | awk '{print $1}')
|
|
177
|
-
local file=$(echo "$line" | awk '{print $2}')
|
|
178
|
-
local basename=$(basename "$file" | sed 's/\..*$//')
|
|
179
|
-
local dirname=$(dirname "$file")
|
|
180
|
-
|
|
181
|
-
case "$status" in
|
|
182
|
-
"A")
|
|
183
|
-
case "$file" in
|
|
184
|
-
*.sh)
|
|
185
|
-
points+=("Add ${basename} script for automation")
|
|
186
|
-
;;
|
|
187
|
-
*.md|*.txt)
|
|
188
|
-
points+=("Add ${basename} documentation")
|
|
189
|
-
;;
|
|
190
|
-
*.js|*.ts|*.py|*.go|*.java|*.cpp|*.c)
|
|
191
|
-
points+=("Implement ${basename} functionality")
|
|
192
|
-
;;
|
|
193
|
-
*.json|*.yml|*.yaml|toml)
|
|
194
|
-
points+=("Add ${basename} configuration")
|
|
195
|
-
;;
|
|
196
|
-
*.test.js|*.spec.js|*.test.ts|*.spec.ts)
|
|
197
|
-
points+=("Add test suite for ${basename%.*}")
|
|
198
|
-
;;
|
|
199
|
-
*)
|
|
200
|
-
points+=("Add ${basename}")
|
|
201
|
-
;;
|
|
202
|
-
esac
|
|
203
|
-
;;
|
|
204
|
-
"M")
|
|
205
|
-
case "$file" in
|
|
206
|
-
*.js|*.ts|*.py|*.go)
|
|
207
|
-
if [[ "$change_type" == "fix" ]]; then
|
|
208
|
-
points+=("Fix ${basename} logic")
|
|
209
|
-
else
|
|
210
|
-
points+=("Improve ${basename} implementation")
|
|
211
|
-
fi
|
|
212
|
-
;;
|
|
213
|
-
*.test.js|*.spec.js|*.test.ts|*.spec.ts)
|
|
214
|
-
points+=("Update tests for ${basename%.*}")
|
|
215
|
-
;;
|
|
216
|
-
*.md|*.txt)
|
|
217
|
-
points+=("Update documentation")
|
|
218
|
-
;;
|
|
219
|
-
*.json|*.yml|*.yaml)
|
|
220
|
-
points+=("Update configuration")
|
|
221
|
-
;;
|
|
222
|
-
*.css|*.scss|*.less)
|
|
223
|
-
points+=("Improve styling")
|
|
224
|
-
;;
|
|
225
|
-
*)
|
|
226
|
-
points+=("Update ${basename}")
|
|
227
|
-
;;
|
|
228
|
-
esac
|
|
229
|
-
;;
|
|
230
|
-
"D")
|
|
231
|
-
points+=("Remove ${basename}")
|
|
232
|
-
;;
|
|
233
|
-
esac
|
|
234
|
-
done <<< "$file_statuses"
|
|
235
|
-
|
|
236
|
-
# 去重并保持顺序,最多3个点
|
|
237
|
-
printf '%s\n' "${points[@]}" | awk '!seen[$0]++' | head -3
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
# 生成完整描述
|
|
241
|
-
generate_description() {
|
|
242
|
-
local change_type="$1"
|
|
243
|
-
local module="$2"
|
|
244
|
-
local files="$3"
|
|
245
|
-
|
|
246
|
-
local summary=""
|
|
247
|
-
case "$change_type" in
|
|
248
|
-
"add")
|
|
249
|
-
summary="Add comprehensive ${module} functionality"
|
|
250
|
-
;;
|
|
251
|
-
"remove")
|
|
252
|
-
summary="Remove ${module} from codebase"
|
|
253
|
-
;;
|
|
254
|
-
"fix")
|
|
255
|
-
summary="Resolve ${module} issues and improve stability"
|
|
256
|
-
;;
|
|
257
|
-
"test")
|
|
258
|
-
summary="Enhance test coverage for ${module}"
|
|
259
|
-
;;
|
|
260
|
-
"docs")
|
|
261
|
-
summary="Improve ${module} documentation"
|
|
262
|
-
;;
|
|
263
|
-
"config")
|
|
264
|
-
summary="Update ${module} configuration"
|
|
265
|
-
;;
|
|
266
|
-
"feature")
|
|
267
|
-
summary="Implement ${module} functionality"
|
|
268
|
-
;;
|
|
269
|
-
"update")
|
|
270
|
-
summary="Update ${module} implementation"
|
|
271
|
-
;;
|
|
272
|
-
*)
|
|
273
|
-
summary="Update ${module}"
|
|
274
|
-
;;
|
|
275
|
-
esac
|
|
276
|
-
|
|
277
|
-
local points=$(generate_description_points "$change_type" "$files")
|
|
278
|
-
|
|
279
|
-
echo "$summary"
|
|
280
|
-
echo ""
|
|
281
|
-
echo "$points" | sed 's/^/- /'
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
# 检查是否有 Jira ticket
|
|
285
|
-
get_jira_ticket() {
|
|
286
|
-
local ticket=$(git log --oneline "$TARGET_BRANCH"...HEAD | grep -o "[A-Z][A-Z0-9]*-[0-9]*" | head -1 || echo "")
|
|
287
|
-
echo "$ticket"
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
# 生成详细统计信息
|
|
291
|
-
generate_stats() {
|
|
292
|
-
local files="$1"
|
|
293
|
-
local total_lines=$(git diff --stat "$TARGET_BRANCH"...HEAD | tail -1 | awk '{print $1+$3}' || echo "0")
|
|
294
|
-
|
|
295
|
-
echo "Files changed: $file_count"
|
|
296
|
-
[[ $added_files -gt 0 ]] && echo "Files added: $added_files"
|
|
297
|
-
[[ $modified_files -gt 0 ]] && echo "Files modified: $modified_files"
|
|
298
|
-
[[ $deleted_files -gt 0 ]] && echo "Files deleted: $deleted_files"
|
|
299
|
-
[[ $total_lines -gt 0 ]] && echo "Lines changed: ±$total_lines"
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
# 主逻辑
|
|
303
|
-
main() {
|
|
304
|
-
echo -e "${BLUE}Analyzing changes between $current_branch and $TARGET_BRANCH...${NC}"
|
|
305
|
-
|
|
306
|
-
# 分析变更
|
|
307
|
-
change_type=$(analyze_change_type "$changed_files")
|
|
308
|
-
main_module=$(extract_main_module "$changed_files")
|
|
309
|
-
jira_ticket=$(get_jira_ticket)
|
|
310
|
-
|
|
311
|
-
# 生成标题
|
|
312
|
-
title=$(generate_title "$change_type" "$main_module")
|
|
313
|
-
|
|
314
|
-
# 如果有 Jira ticket,添加到标题
|
|
315
|
-
if [[ -n "$jira_ticket" ]]; then
|
|
316
|
-
title="$jira_ticket: $title"
|
|
317
|
-
fi
|
|
318
|
-
|
|
319
|
-
# 截断标题到50字符以内
|
|
320
|
-
if [[ ${#title} -gt 50 ]]; then
|
|
321
|
-
title="${title:0:47}..."
|
|
322
|
-
fi
|
|
323
|
-
|
|
324
|
-
# 生成描述
|
|
325
|
-
description=$(generate_description "$change_type" "$main_module" "$changed_files")
|
|
326
|
-
|
|
327
|
-
# 输出结果
|
|
328
|
-
if [[ "$PREVIEW_MODE" == true ]]; then
|
|
329
|
-
echo -e "${GREEN}=== MR Preview ===${NC}"
|
|
330
|
-
echo "Source: $current_branch"
|
|
331
|
-
echo "Target: $TARGET_BRANCH"
|
|
332
|
-
generate_stats "$changed_files"
|
|
333
|
-
echo ""
|
|
334
|
-
fi
|
|
335
|
-
|
|
336
|
-
echo "$title"
|
|
337
|
-
echo ""
|
|
338
|
-
echo "$description"
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
# 运行主程序
|
|
342
|
-
main
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: refactor
|
|
3
|
-
description: Refactor code to improve structure, readability, and maintainability without changing behavior
|
|
4
|
-
version: 1.0.0
|
|
5
|
-
author: Pulse Coder Team
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Code Refactoring Skill
|
|
9
|
-
|
|
10
|
-
This skill guides systematic code refactoring while preserving functionality.
|
|
11
|
-
|
|
12
|
-
## Refactoring Principles
|
|
13
|
-
|
|
14
|
-
### Extract Method/Function
|
|
15
|
-
- Break down large functions into smaller, focused ones
|
|
16
|
-
- Name functions based on their purpose
|
|
17
|
-
- Each function should do one thing well
|
|
18
|
-
|
|
19
|
-
### Simplify Conditionals
|
|
20
|
-
- Replace complex conditions with well-named functions
|
|
21
|
-
- Use early returns to reduce nesting
|
|
22
|
-
- Consider guard clauses
|
|
23
|
-
|
|
24
|
-
### Remove Duplication
|
|
25
|
-
- Identify repeated code patterns
|
|
26
|
-
- Extract common logic into reusable functions
|
|
27
|
-
- Use abstraction wisely (avoid premature optimization)
|
|
28
|
-
|
|
29
|
-
### Improve Naming
|
|
30
|
-
- Use descriptive, meaningful names
|
|
31
|
-
- Follow language conventions
|
|
32
|
-
- Avoid abbreviations unless widely known
|
|
33
|
-
|
|
34
|
-
### Organize Code
|
|
35
|
-
- Group related functionality
|
|
36
|
-
- Separate concerns
|
|
37
|
-
- Follow single responsibility principle
|
|
38
|
-
|
|
39
|
-
## Refactoring Workflow
|
|
40
|
-
|
|
41
|
-
1. **Understand First**: Read and understand the existing code
|
|
42
|
-
2. **Ensure Tests**: Make sure tests exist or write them
|
|
43
|
-
3. **Small Steps**: Make incremental changes
|
|
44
|
-
4. **Test After Each Step**: Verify functionality is preserved
|
|
45
|
-
5. **Review**: Check if the code is clearer than before
|
|
46
|
-
|
|
47
|
-
## Common Refactoring Patterns
|
|
48
|
-
|
|
49
|
-
- Extract Method
|
|
50
|
-
- Extract Variable
|
|
51
|
-
- Inline Method/Variable
|
|
52
|
-
- Replace Magic Number with Named Constant
|
|
53
|
-
- Replace Conditional with Polymorphism
|
|
54
|
-
- Move Method/Field
|
|
55
|
-
- Rename Method/Variable
|
|
56
|
-
|
|
57
|
-
## Safety Guidelines
|
|
58
|
-
|
|
59
|
-
- Never change behavior while refactoring
|
|
60
|
-
- Keep refactoring separate from feature work
|
|
61
|
-
- Run tests after each change
|
|
62
|
-
- Use version control to track changes
|
|
63
|
-
- Consider reverting if complexity increases
|