-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.mjs
More file actions
101 lines (87 loc) · 2.73 KB
/
Copy pathindex.mjs
File metadata and controls
101 lines (87 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env node
/**
* Thinking Words - Claude Code 思考词组切换工具
* 主入口文件
*/
import { commands } from './src/commands.js';
const CONFIG = {
CLAUDE_DIR: process.env.HOME ? `${process.env.HOME}/.claude` : `${process.cwd()}/.claude`,
SETTINGS_FILE: 'settings.json',
CUSTOM_PRESETS_FILE: 'spinner-presets.json',
STATS_FILE: 'thinking-words-stats.json',
AUTO_FILE: 'thinking-words-auto.json',
EXPORT_FILE: 'thinking-words-export.json'
};
function getConfigPath(filename) {
return `${CONFIG.CLAUDE_DIR}/${filename}`;
}
function getFile(path) {
try {
const fs = await import('fs');
if (fs.existsSync(path)) {
const data = fs.readFileSync(path, 'utf-8');
return JSON.parse(data);
}
} catch (e) {
console.error(`Error reading file ${path}:`, e.message);
}
return null;
}
function saveFile(path, data) {
try {
const fs = await import('fs');
fs.writeFileSync(path, JSON.stringify(data, null, 2), 'utf-8');
return true;
} catch (e) {
console.error(`Error writing file ${path}:`, e.message);
return false;
}
}
async function main() {
const args = process.argv.slice(2);
const [command, ...params] = args;
console.log('Thinking Words 思考词组切换工具');
console.log('=================================\n');
if (!command || command === 'help') {
showHelp();
return;
}
const handler = commands[command];
if (!handler) {
console.error(`未知命令: ${command}`);
showHelp();
return;
}
await handler(params, {
getConfigPath,
getFile,
saveFile,
CONFIG
});
}
function showHelp() {
console.log(`使用方式:
/thinking-words 随机切换预设
/thinking-words classical 切换到指定预设
/thinking-words list 列出所有预设
/thinking-words show 查看当前配置
/thinking-words add <name> <words>... 添加自定义预设
/thinking-words remove <name> 删除自定义预设
/thinking-words mix <preset1> <preset2>... 混合预设
/thinking-words preview <preset> 预览预设
/thinking-words export [path] 导出配置
/thinking-words import <path> 导入配置
/thinking-words stats 查看使用统计
/thinking-words recommend 智能推荐
/thinking-words default 恢复默认
/thinking-words auto 查看自动切换配置
/thinking-words auto on 启用自动切换
/thinking-words auto off 关闭自动切换
/thinking-words auto set <time> <preset> 修改自动切换配置
可用预设: default, classical, simple, cute, japanese, cyberpunk, wuxia, programmer, emoji, minimal, time-based
`);
}
main().catch(err => {
console.error('Error:', err);
process.exit(1);
});