@winston.wan/burn-your-money 2.1.2 → 2.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.
- package/README.md +17 -0
- package/bash.exe.stackdump +28 -0
- package/install.js +53 -243
- package/package.json +29 -33
- package/src/statusline.js +264 -0
- package/src/token-history.js +234 -0
- package/uninstall.js +2 -3
- package/bin/burn-your-money +0 -402
- package/fix-git-bash.ps1 +0 -154
- package/install.sh +0 -271
- package/src/statusline.sh +0 -250
- package/src/token-history.sh +0 -268
package/bin/burn-your-money
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# Burn Your Money CLI - 配置和查询工具
|
|
3
|
-
|
|
4
|
-
VERSION="2.0.0"
|
|
5
|
-
CONFIG_FILE="$HOME/.claude/burn-your-money-config.json"
|
|
6
|
-
|
|
7
|
-
# 设置 jq 命令路径(支持自定义安装的 jq)
|
|
8
|
-
if [ -n "$JQ_PATH" ]; then
|
|
9
|
-
JQ_CMD="$JQ_PATH"
|
|
10
|
-
elif [ -f "$HOME/.claude/bin/jq.exe" ]; then
|
|
11
|
-
JQ_CMD="$HOME/.claude/bin/jq.exe"
|
|
12
|
-
elif [ -f "$HOME/.claude/bin/jq" ]; then
|
|
13
|
-
JQ_CMD="$HOME/.claude/bin/jq"
|
|
14
|
-
else
|
|
15
|
-
JQ_CMD="jq"
|
|
16
|
-
fi
|
|
17
|
-
|
|
18
|
-
# 验证 jq 是否可用
|
|
19
|
-
if ! command -v "$JQ_CMD" >/dev/null 2>&1; then
|
|
20
|
-
echo "Error: jq not found. Please install jq first:"
|
|
21
|
-
echo " Windows: npm install -g @winston.wan/burn-your-money"
|
|
22
|
-
echo " macOS: brew install jq"
|
|
23
|
-
echo " Linux: sudo apt-get install jq"
|
|
24
|
-
exit 1
|
|
25
|
-
fi
|
|
26
|
-
|
|
27
|
-
# 颜色定义
|
|
28
|
-
RED='\033[0;31m'
|
|
29
|
-
GREEN='\033[0;32m'
|
|
30
|
-
YELLOW='\033[1;33m'
|
|
31
|
-
BLUE='\033[0;34m'
|
|
32
|
-
PURPLE='\033[0;35m'
|
|
33
|
-
CYAN='\033[0;36m'
|
|
34
|
-
NC='\033[0m'
|
|
35
|
-
|
|
36
|
-
# 显示帮助
|
|
37
|
-
show_help() {
|
|
38
|
-
cat << EOF
|
|
39
|
-
💸 Burn Your Money v${VERSION} - 看着你的钱包燃烧
|
|
40
|
-
|
|
41
|
-
用法:
|
|
42
|
-
burn-your-money <command> [options]
|
|
43
|
-
|
|
44
|
-
统计命令:
|
|
45
|
-
status 查看完整状态
|
|
46
|
-
today 查看今日统计
|
|
47
|
-
week 查看本周统计
|
|
48
|
-
month 查看本月统计
|
|
49
|
-
total 查看总计统计
|
|
50
|
-
chart 显示趋势图表
|
|
51
|
-
|
|
52
|
-
配置命令:
|
|
53
|
-
theme <name> 切换主题 (fire|ocean|forest|golden)
|
|
54
|
-
alert <amount> 设置每日费用警报
|
|
55
|
-
show-rate <on|off> 显示/隐藏燃烧速度
|
|
56
|
-
|
|
57
|
-
数据导出:
|
|
58
|
-
export csv 导出为 CSV 格式
|
|
59
|
-
export json 导出为 JSON 格式
|
|
60
|
-
|
|
61
|
-
其他:
|
|
62
|
-
install 安装/更新插件
|
|
63
|
-
version 显示版本信息
|
|
64
|
-
help 显示此帮助信息
|
|
65
|
-
|
|
66
|
-
示例:
|
|
67
|
-
burn-your-money status 查看完整状态
|
|
68
|
-
burn-your-money chart 显示趋势图
|
|
69
|
-
burn-your-money theme ocean 切换到海洋主题
|
|
70
|
-
burn-your-money alert 5.0 设置每日警报 $5
|
|
71
|
-
burn-your-money export csv > data.csv
|
|
72
|
-
|
|
73
|
-
GitHub: https://github.com/winston-wwzhen/burn-your-money
|
|
74
|
-
EOF
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
# 显示版本
|
|
78
|
-
show_version() {
|
|
79
|
-
echo "Burn Your Money v${VERSION}"
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
# 显示状态
|
|
83
|
-
cmd_status() {
|
|
84
|
-
echo -e "${PURPLE}💸 Burn Your Money 状态${NC}"
|
|
85
|
-
echo ""
|
|
86
|
-
|
|
87
|
-
# 检查安装状态
|
|
88
|
-
if [ -f "$HOME/.claude/statusline.sh" ]; then
|
|
89
|
-
echo -e "${GREEN}✓ 插件已安装${NC}"
|
|
90
|
-
echo ""
|
|
91
|
-
|
|
92
|
-
# 显示配置
|
|
93
|
-
if [ -f "$CONFIG_FILE" ]; then
|
|
94
|
-
echo "配置:"
|
|
95
|
-
local theme=$($JQ_CMD -r '.theme // "fire"' "$CONFIG_FILE")
|
|
96
|
-
local alert=$($JQ_CMD -r '.alert_daily // 10' "$CONFIG_FILE")
|
|
97
|
-
local show_rate=$($JQ_CMD -r '.show_burn_rate // true' "$CONFIG_FILE")
|
|
98
|
-
echo " 主题: $theme"
|
|
99
|
-
echo " 每日警报: \$$alert"
|
|
100
|
-
echo " 燃烧速度: $show_rate"
|
|
101
|
-
echo ""
|
|
102
|
-
fi
|
|
103
|
-
|
|
104
|
-
# 显示统计数据
|
|
105
|
-
local cache="$HOME/.claude/cache/history-cache.json"
|
|
106
|
-
if [ -f "$cache" ]; then
|
|
107
|
-
local today_t=$($JQ_CMD -r '.today_tokens // 0' "$cache")
|
|
108
|
-
local today_c=$($JQ_CMD -r '.today_cost // 0' "$cache")
|
|
109
|
-
local week_t=$($JQ_CMD -r '.week_tokens // 0' "$cache")
|
|
110
|
-
local week_c=$($JQ_CMD -r '.week_cost // 0' "$cache")
|
|
111
|
-
local total_t=$($JQ_CMD -r '.total_tokens_all // 0' "$cache")
|
|
112
|
-
local total_c=$($JQ_CMD -r '.total_cost // 0' "$cache")
|
|
113
|
-
echo "统计数据:"
|
|
114
|
-
echo -e " ${CYAN}今日${NC}: Token $today_t | 费用 \$$today_c"
|
|
115
|
-
echo -e " ${CYAN}本周${NC}: Token $week_t | 费用 \$$week_c"
|
|
116
|
-
echo -e " ${CYAN}总计${NC}: Token $total_t | 费用 \$$total_c"
|
|
117
|
-
fi
|
|
118
|
-
else
|
|
119
|
-
echo -e "${RED}✗ 插件未安装${NC}"
|
|
120
|
-
echo ""
|
|
121
|
-
echo "运行以下命令安装:"
|
|
122
|
-
echo " curl -fsSL https://raw.githubusercontent.com/winston-wwzhen/burn-your-money/main/install.sh | bash"
|
|
123
|
-
fi
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
# 切换主题
|
|
127
|
-
cmd_theme() {
|
|
128
|
-
local new_theme="$1"
|
|
129
|
-
|
|
130
|
-
if [ -z "$new_theme" ]; then
|
|
131
|
-
if [ -f "$CONFIG_FILE" ]; then
|
|
132
|
-
local current=$($JQ_CMD -r '.theme // "fire"' "$CONFIG_FILE")
|
|
133
|
-
echo "当前主题: $current"
|
|
134
|
-
else
|
|
135
|
-
echo "当前主题: fire (默认)"
|
|
136
|
-
fi
|
|
137
|
-
echo ""
|
|
138
|
-
echo "可用主题:"
|
|
139
|
-
echo " fire - 🔥 火焰红 (默认)"
|
|
140
|
-
echo " ocean - 🌊 海洋蓝"
|
|
141
|
-
echo " forest - 🌲 森林绿"
|
|
142
|
-
echo " golden - 💰 土豪金"
|
|
143
|
-
return
|
|
144
|
-
fi
|
|
145
|
-
|
|
146
|
-
# 验证主题
|
|
147
|
-
if [[ ! "$new_theme" =~ ^(fire|ocean|forest|golden)$ ]]; then
|
|
148
|
-
echo -e "${RED}错误: 无效的主题 '$new_theme'${NC}"
|
|
149
|
-
echo ""
|
|
150
|
-
echo "可用主题: fire, ocean, forest, golden"
|
|
151
|
-
exit 1
|
|
152
|
-
fi
|
|
153
|
-
|
|
154
|
-
# 更新配置
|
|
155
|
-
mkdir -p "$(dirname "$CONFIG_FILE")"
|
|
156
|
-
if [ -f "$CONFIG_FILE" ]; then
|
|
157
|
-
$JQ_CMD --arg theme "$new_theme" '.theme = $theme' "$CONFIG_FILE" > "$CONFIG_FILE.tmp"
|
|
158
|
-
mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
|
159
|
-
else
|
|
160
|
-
$JQ_CMD -n --arg theme "$new_theme" '{theme: $theme}' > "$CONFIG_FILE"
|
|
161
|
-
fi
|
|
162
|
-
|
|
163
|
-
echo -e "${GREEN}主题已切换到: $new_theme${NC}"
|
|
164
|
-
echo "重启 Claude Code 后生效"
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
# 设置警报
|
|
168
|
-
cmd_alert() {
|
|
169
|
-
local amount="$1"
|
|
170
|
-
|
|
171
|
-
if [ -z "$amount" ]; then
|
|
172
|
-
if [ -f "$CONFIG_FILE" ]; then
|
|
173
|
-
local current=$($JQ_CMD -r '.alert_daily // 10' "$CONFIG_FILE")
|
|
174
|
-
echo "当前每日警报: \$$current"
|
|
175
|
-
else
|
|
176
|
-
echo "当前每日警报: \$10 (默认)"
|
|
177
|
-
fi
|
|
178
|
-
echo ""
|
|
179
|
-
echo "用法: burn-your-money alert <金额>"
|
|
180
|
-
echo "示例: burn-your-money alert 5.0"
|
|
181
|
-
return
|
|
182
|
-
fi
|
|
183
|
-
|
|
184
|
-
# 验证金额
|
|
185
|
-
if ! awk "BEGIN {exit !($amount > 0)}"; then
|
|
186
|
-
echo -e "${RED}错误: 无效的金额 '$amount'${NC}"
|
|
187
|
-
exit 1
|
|
188
|
-
fi
|
|
189
|
-
|
|
190
|
-
# 更新配置
|
|
191
|
-
mkdir -p "$(dirname "$CONFIG_FILE")"
|
|
192
|
-
if [ -f "$CONFIG_FILE" ]; then
|
|
193
|
-
$JQ_CMD --arg amount "$amount" '.alert_daily = ($amount | tonumber)' "$CONFIG_FILE" > "$CONFIG_FILE.tmp"
|
|
194
|
-
mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
|
195
|
-
else
|
|
196
|
-
$JQ_CMD -n --arg amount "$amount" '{alert_daily: ($amount | tonumber)}' > "$CONFIG_FILE"
|
|
197
|
-
fi
|
|
198
|
-
|
|
199
|
-
echo -e "${GREEN}每日警报已设置: \$$amount${NC}"
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
# 切换燃烧速度显示
|
|
203
|
-
cmd_show_rate() {
|
|
204
|
-
local value="$1"
|
|
205
|
-
|
|
206
|
-
if [ -z "$value" ]; then
|
|
207
|
-
if [ -f "$CONFIG_FILE" ]; then
|
|
208
|
-
local current=$($JQ_CMD -r '.show_burn_rate // true' "$CONFIG_FILE")
|
|
209
|
-
echo "燃烧速度显示: $current"
|
|
210
|
-
else
|
|
211
|
-
echo "燃烧速度显示: true (默认)"
|
|
212
|
-
fi
|
|
213
|
-
return
|
|
214
|
-
fi
|
|
215
|
-
|
|
216
|
-
if [[ "$value" != "true" && "$value" != "false" && "$value" != "on" && "$value" != "off" ]]; then
|
|
217
|
-
echo -e "${RED}错误: 请使用 true/false 或 on/off${NC}"
|
|
218
|
-
exit 1
|
|
219
|
-
fi
|
|
220
|
-
|
|
221
|
-
local bool_value="$value"
|
|
222
|
-
[[ "$value" == "on" ]] && bool_value="true"
|
|
223
|
-
[[ "$value" == "off" ]] && bool_value="false"
|
|
224
|
-
|
|
225
|
-
mkdir -p "$(dirname "$CONFIG_FILE")"
|
|
226
|
-
if [ -f "$CONFIG_FILE" ]; then
|
|
227
|
-
$JQ_CMD --arg val "$bool_value" '.show_burn_rate = ($val | tonumber or ($val == "true"))' "$CONFIG_FILE" > "$CONFIG_FILE.tmp"
|
|
228
|
-
mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
|
|
229
|
-
else
|
|
230
|
-
$JQ_CMD -n --arg val "$bool_value" '{show_burn_rate: ($val == "true")}' > "$CONFIG_FILE"
|
|
231
|
-
fi
|
|
232
|
-
|
|
233
|
-
echo -e "${GREEN}燃烧速度显示: $bool_value${NC}"
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
# 显示今日统计
|
|
237
|
-
cmd_today() {
|
|
238
|
-
if [ -f "$HOME/.claude/scripts/token-history.sh" ]; then
|
|
239
|
-
echo -e "${RED}🔥 今日统计:${NC}"
|
|
240
|
-
local tokens=$($HOME/.claude/scripts/token-history.sh today_tokens)
|
|
241
|
-
local cost=$($HOME/.claude/scripts/token-history.sh today_cost)
|
|
242
|
-
echo " Token: $tokens"
|
|
243
|
-
echo " 费用: \$$cost"
|
|
244
|
-
else
|
|
245
|
-
echo -e "${RED}✗ Burn Your Money 未安装${NC}"
|
|
246
|
-
exit 1
|
|
247
|
-
fi
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
# 显示本周统计
|
|
251
|
-
cmd_week() {
|
|
252
|
-
if [ -f "$HOME/.claude/scripts/token-history.sh" ]; then
|
|
253
|
-
echo -e "${BLUE}📊 本周统计:${NC}"
|
|
254
|
-
local tokens=$($HOME/.claude/scripts/token-history.sh week_tokens)
|
|
255
|
-
local cost=$($HOME/.claude/scripts/token-history.sh week_cost)
|
|
256
|
-
echo " Token: $tokens"
|
|
257
|
-
echo " 费用: \$$cost"
|
|
258
|
-
else
|
|
259
|
-
echo -e "${RED}✗ Burn Your Money 未安装${NC}"
|
|
260
|
-
exit 1
|
|
261
|
-
fi
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
# 显示本月统计
|
|
265
|
-
cmd_month() {
|
|
266
|
-
if [ -f "$HOME/.claude/scripts/token-history.sh" ]; then
|
|
267
|
-
echo -e "${PURPLE}📅 本月统计:${NC}"
|
|
268
|
-
local tokens=$($HOME/.claude/scripts/token-history.sh month_tokens)
|
|
269
|
-
local cost=$($HOME/.claude/scripts/token-history.sh month_cost)
|
|
270
|
-
echo " Token: $tokens"
|
|
271
|
-
echo " 费用: \$$cost"
|
|
272
|
-
echo ""
|
|
273
|
-
|
|
274
|
-
local last_tokens=$($HOME/.claude/scripts/token-history.sh last_month_tokens)
|
|
275
|
-
local last_cost=$($HOME/.claude/scripts/token-history.sh last_month_cost)
|
|
276
|
-
echo -e "${CYAN}上月统计:${NC}"
|
|
277
|
-
echo " Token: $last_tokens"
|
|
278
|
-
echo " 费用: \$$last_cost"
|
|
279
|
-
|
|
280
|
-
# 对比
|
|
281
|
-
if [ "$last_tokens" -gt 0 ]; then
|
|
282
|
-
local change=$(awk "BEGIN {printf \"%.1f\", ($tokens - $last_tokens) / $last_tokens * 100}")
|
|
283
|
-
if awk "BEGIN {exit !($tokens > $last_tokens)}"; then
|
|
284
|
-
echo -e " ${RED}↑ 增加 ${change}%${NC}"
|
|
285
|
-
elif awk "BEGIN {exit !($tokens < $last_tokens)}"; then
|
|
286
|
-
echo -e " ${GREEN}↓ 减少 ${change}%${NC}"
|
|
287
|
-
else
|
|
288
|
-
echo " → 持平"
|
|
289
|
-
fi
|
|
290
|
-
fi
|
|
291
|
-
else
|
|
292
|
-
echo -e "${RED}✗ Burn Your Money 未安装${NC}"
|
|
293
|
-
exit 1
|
|
294
|
-
fi
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
# 显示总计统计
|
|
298
|
-
cmd_total() {
|
|
299
|
-
if [ -f "$HOME/.claude/scripts/token-history.sh" ]; then
|
|
300
|
-
local data=$($HOME/.claude/scripts/token-history.sh summary)
|
|
301
|
-
echo -e "${YELLOW}💀 总计统计:${NC}"
|
|
302
|
-
echo " Token: $(echo "$data" | $JQ_CMD -r '.total_tokens_all // 0')"
|
|
303
|
-
echo " 费用: \$(echo "$data" | $JQ_CMD -r '.total_cost // 0')"
|
|
304
|
-
else
|
|
305
|
-
echo -e "${RED}✗ Burn Your Money 未安装${NC}"
|
|
306
|
-
exit 1
|
|
307
|
-
fi
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
# 显示图表
|
|
311
|
-
cmd_chart() {
|
|
312
|
-
if [ -f "$HOME/.claude/scripts/token-history.sh" ]; then
|
|
313
|
-
$HOME/.claude/scripts/token-history.sh chart
|
|
314
|
-
else
|
|
315
|
-
echo -e "${RED}✗ Burn Your Money 未安装${NC}"
|
|
316
|
-
exit 1
|
|
317
|
-
fi
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
# 导出数据
|
|
321
|
-
cmd_export() {
|
|
322
|
-
local format="$1"
|
|
323
|
-
|
|
324
|
-
if [ -z "$format" ]; then
|
|
325
|
-
echo "用法: burn-your-money export <csv|json>"
|
|
326
|
-
exit 1
|
|
327
|
-
fi
|
|
328
|
-
|
|
329
|
-
if [ -f "$HOME/.claude/scripts/token-history.sh" ]; then
|
|
330
|
-
$HOME/.claude/scripts/token-history.sh export "$format"
|
|
331
|
-
else
|
|
332
|
-
echo -e "${RED}✗ Burn Your Money 未安装${NC}"
|
|
333
|
-
exit 1
|
|
334
|
-
fi
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
# 安装插件
|
|
338
|
-
cmd_install() {
|
|
339
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
340
|
-
if [ -f "$SCRIPT_DIR/../install.sh" ]; then
|
|
341
|
-
bash "$SCRIPT_DIR/../install.sh"
|
|
342
|
-
else
|
|
343
|
-
echo "找不到安装脚本"
|
|
344
|
-
exit 1
|
|
345
|
-
fi
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
# 主函数
|
|
349
|
-
main() {
|
|
350
|
-
local command="${1:-help}"
|
|
351
|
-
local arg="$2"
|
|
352
|
-
|
|
353
|
-
case "$command" in
|
|
354
|
-
status)
|
|
355
|
-
cmd_status
|
|
356
|
-
;;
|
|
357
|
-
today)
|
|
358
|
-
cmd_today
|
|
359
|
-
;;
|
|
360
|
-
week)
|
|
361
|
-
cmd_week
|
|
362
|
-
;;
|
|
363
|
-
month)
|
|
364
|
-
cmd_month
|
|
365
|
-
;;
|
|
366
|
-
total)
|
|
367
|
-
cmd_total
|
|
368
|
-
;;
|
|
369
|
-
chart)
|
|
370
|
-
cmd_chart
|
|
371
|
-
;;
|
|
372
|
-
theme)
|
|
373
|
-
cmd_theme "$arg"
|
|
374
|
-
;;
|
|
375
|
-
alert)
|
|
376
|
-
cmd_alert "$arg"
|
|
377
|
-
;;
|
|
378
|
-
show-rate)
|
|
379
|
-
cmd_show_rate "$arg"
|
|
380
|
-
;;
|
|
381
|
-
export)
|
|
382
|
-
cmd_export "$arg"
|
|
383
|
-
;;
|
|
384
|
-
install)
|
|
385
|
-
cmd_install
|
|
386
|
-
;;
|
|
387
|
-
version|--version|-v)
|
|
388
|
-
show_version
|
|
389
|
-
;;
|
|
390
|
-
help|--help|-h)
|
|
391
|
-
show_help
|
|
392
|
-
;;
|
|
393
|
-
*)
|
|
394
|
-
echo -e "${RED}未知命令: $command${NC}"
|
|
395
|
-
echo ""
|
|
396
|
-
show_help
|
|
397
|
-
exit 1
|
|
398
|
-
;;
|
|
399
|
-
esac
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
main "$@"
|
package/fix-git-bash.ps1
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env pwsh
|
|
2
|
-
<#
|
|
3
|
-
.SYNOPSIS
|
|
4
|
-
Fix Git Bash fork issues by adding exclusions to Windows Defender
|
|
5
|
-
|
|
6
|
-
.DESCRIPTION
|
|
7
|
-
This script adds Git Bash and Claude Code directories to Windows Defender
|
|
8
|
-
exclusion list to prevent fork() timeout errors.
|
|
9
|
-
|
|
10
|
-
.REQUIREMENTS
|
|
11
|
-
- Run as Administrator
|
|
12
|
-
- Windows 10/11 with Windows Defender
|
|
13
|
-
#>
|
|
14
|
-
|
|
15
|
-
Write-Host "`n=== Fix Git Bash Fork Issues ===" -ForegroundColor Cyan
|
|
16
|
-
Write-Host ""
|
|
17
|
-
|
|
18
|
-
# Check if running as Administrator
|
|
19
|
-
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
20
|
-
if (-not $isAdmin) {
|
|
21
|
-
Write-Host "ERROR: This script must be run as Administrator." -ForegroundColor Red
|
|
22
|
-
Write-Host ""
|
|
23
|
-
Write-Host "Please right-click PowerShell and select 'Run as Administrator'" -ForegroundColor Yellow
|
|
24
|
-
Write-Host "Then run: .\fix-git-bash.ps1" -ForegroundColor Yellow
|
|
25
|
-
exit 1
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Write-Host "[1/4] Detecting paths..." -ForegroundColor Cyan
|
|
29
|
-
|
|
30
|
-
# Detect Git installation path
|
|
31
|
-
$gitPaths = @(
|
|
32
|
-
"C:\Program Files\Git",
|
|
33
|
-
"C:\Program Files (x86)\Git",
|
|
34
|
-
"${env:ProgramFiles}\Git",
|
|
35
|
-
"${env:ProgramFiles(x86)}\Git"
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
$gitPath = $null
|
|
39
|
-
foreach ($path in $gitPaths) {
|
|
40
|
-
if (Test-Path $path) {
|
|
41
|
-
$gitPath = $path
|
|
42
|
-
break
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (-not $gitPath) {
|
|
47
|
-
Write-Host " WARNING: Git installation not found in standard locations" -ForegroundColor Yellow
|
|
48
|
-
Write-Host " You may need to manually add your Git path" -ForegroundColor Yellow
|
|
49
|
-
} else {
|
|
50
|
-
Write-Host " Found Git at: $gitPath" -ForegroundColor Green
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
# Detect Claude Code directory
|
|
54
|
-
$claudePath = "$env:USERPROFILE\.claude"
|
|
55
|
-
if (Test-Path $claudePath) {
|
|
56
|
-
Write-Host " Found Claude config at: $claudePath" -ForegroundColor Green
|
|
57
|
-
} else {
|
|
58
|
-
Write-Host " Claude config directory will be created at: $claudePath" -ForegroundColor Yellow
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
Write-Host ""
|
|
62
|
-
Write-Host "[2/4] Checking existing exclusions..." -ForegroundColor Cyan
|
|
63
|
-
|
|
64
|
-
# Get current exclusions
|
|
65
|
-
try {
|
|
66
|
-
$exclusions = Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
|
|
67
|
-
Write-Host " Current exclusions count: $($exclusions.Count)" -ForegroundColor Gray
|
|
68
|
-
} catch {
|
|
69
|
-
Write-Host " WARNING: Could not retrieve current exclusions" -ForegroundColor Yellow
|
|
70
|
-
$exclusions = @()
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
Write-Host ""
|
|
74
|
-
Write-Host "[3/4] Adding exclusions to Windows Defender..." -ForegroundColor Cyan
|
|
75
|
-
|
|
76
|
-
$added = 0
|
|
77
|
-
|
|
78
|
-
# Add Git path
|
|
79
|
-
if ($gitPath) {
|
|
80
|
-
if ($gitPath -notin $exclusions) {
|
|
81
|
-
try {
|
|
82
|
-
Add-MpPreference -ExclusionPath $gitPath -Force
|
|
83
|
-
Write-Host " Added: $gitPath" -ForegroundColor Green
|
|
84
|
-
$added++
|
|
85
|
-
} catch {
|
|
86
|
-
Write-Host " Failed to add: $gitPath" -ForegroundColor Red
|
|
87
|
-
Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Gray
|
|
88
|
-
}
|
|
89
|
-
} else {
|
|
90
|
-
Write-Host " Already excluded: $gitPath" -ForegroundColor Gray
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
# Add Claude Code directory
|
|
95
|
-
if ($claudePath -notin $exclusions) {
|
|
96
|
-
try {
|
|
97
|
-
Add-MpPreference -ExclusionPath $claudePath -Force
|
|
98
|
-
Write-Host " Added: $claudePath" -ForegroundColor Green
|
|
99
|
-
$added++
|
|
100
|
-
} catch {
|
|
101
|
-
Write-Host " Failed to add: $claudePath" -ForegroundColor Red
|
|
102
|
-
Write-Host " Error: $($_.Exception.Message)" -ForegroundColor Gray
|
|
103
|
-
}
|
|
104
|
-
} else {
|
|
105
|
-
Write-Host " Already excluded: $claudePath" -ForegroundColor Gray
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
# Optionally add temp directory (bash creates temp files)
|
|
109
|
-
$tempPath = $env:TEMP
|
|
110
|
-
if ($tempPath -notin $exclusions) {
|
|
111
|
-
try {
|
|
112
|
-
Add-MpPreference -ExclusionPath $tempPath -Force
|
|
113
|
-
Write-Host " Added: $tempPath" -ForegroundColor Green
|
|
114
|
-
$added++
|
|
115
|
-
} catch {
|
|
116
|
-
Write-Host " Failed to add: $tempPath" -ForegroundColor Red
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
Write-Host " Already excluded: $tempPath" -ForegroundColor Gray
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
Write-Host ""
|
|
123
|
-
Write-Host "[4/4] Cleanup..." -ForegroundColor Cyan
|
|
124
|
-
|
|
125
|
-
# Remove stackdump files if exist
|
|
126
|
-
$stackDump = Join-Path $PWD "bash.exe.stackdump"
|
|
127
|
-
if (Test-Path $stackDump) {
|
|
128
|
-
Remove-Item $stackDump -Force
|
|
129
|
-
Write-Host " Removed: bash.exe.stackdump" -ForegroundColor Green
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
Write-Host ""
|
|
133
|
-
Write-Host "=== Summary ===" -ForegroundColor Cyan
|
|
134
|
-
Write-Host " Exclusions added: $added" -ForegroundColor $(if ($added -gt 0) { "Green" } else { "Yellow" })
|
|
135
|
-
Write-Host ""
|
|
136
|
-
|
|
137
|
-
if ($added -gt 0) {
|
|
138
|
-
Write-Host "SUCCESS: Exclusions have been added to Windows Defender." -ForegroundColor Green
|
|
139
|
-
Write-Host ""
|
|
140
|
-
Write-Host "Next steps:" -ForegroundColor Yellow
|
|
141
|
-
Write-Host " 1. Restart Claude Code" -ForegroundColor White
|
|
142
|
-
Write-Host " 2. If issues persist, restart your computer" -ForegroundColor White
|
|
143
|
-
} else {
|
|
144
|
-
Write-Host "INFO: All paths were already excluded." -ForegroundColor Yellow
|
|
145
|
-
Write-Host ""
|
|
146
|
-
Write-Host "If you still see fork errors, try:" -ForegroundColor Yellow
|
|
147
|
-
Write-Host " 1. Restart your computer" -ForegroundColor White
|
|
148
|
-
Write-Host " 2. Temporarily disable Real-time protection to test" -ForegroundColor White
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
Write-Host ""
|
|
152
|
-
Write-Host "To verify exclusions, run:" -ForegroundColor Gray
|
|
153
|
-
Write-Host " Get-MpPreference | Select-Object -ExpandProperty ExclusionPath" -ForegroundColor White
|
|
154
|
-
Write-Host ""
|