duojie-helper 0.2.21 → 0.2.23

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.
@@ -1,99 +1,99 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import os from 'os';
4
- import chalk from 'chalk';
5
- import { API_CONFIG } from '../index.js';
6
-
7
- /**
8
- * 获取 Cursor 配置路径
9
- */
10
- function getCursorConfigPaths() {
11
- const home = os.homedir();
12
- const platform = os.platform();
13
-
14
- let configDir;
15
- if (platform === 'win32') {
16
- configDir = path.join(process.env.APPDATA || home, 'Cursor', 'User');
17
- } else if (platform === 'darwin') {
18
- configDir = path.join(home, 'Library', 'Application Support', 'Cursor', 'User');
19
- } else {
20
- configDir = path.join(home, '.config', 'Cursor', 'User');
21
- }
22
-
23
- return {
24
- configDir,
25
- settingsFile: path.join(configDir, 'settings.json'),
26
- };
27
- }
28
-
29
- /**
30
- * 配置 Cursor
31
- * Cursor 需要通过 UI 手动配置自定义模型(需要高级会员)
32
- */
33
- export async function configureCursor(apiKey) {
34
- const baseUrl = API_CONFIG.baseUrl;
35
-
36
- // 生成配置说明
37
- const instructions = `
38
- ${chalk.yellow('Cursor 需要在编辑器中手动配置:')}
39
-
40
- ${chalk.red('⚠️ 注意: 需要 Cursor Pro 或更高级订阅才能使用自定义模型')}
41
-
42
- ${chalk.cyan('步骤 1:')} 打开 Cursor,进入 Settings → Models
43
- ${chalk.cyan('步骤 2:')} 点击 "Add Custom Model"
44
- ${chalk.cyan('步骤 3:')} 填入以下配置:
45
-
46
- ${chalk.green('Protocol:')} OpenAI
47
- ${chalk.green('OpenAI API Key:')} ${apiKey}
48
- ${chalk.green('Override OpenAI Base URL:')} ${baseUrl}
49
- ${chalk.green('Model Name:')} 输入模型名称(注意大小写)
50
- 例如: gpt-5.2
51
- 或: claude-sonnet-4-6
52
-
53
- ${chalk.cyan('步骤 4:')} 点击保存,然后在模型列表中选择刚添加的模型
54
-
55
- ${chalk.cyan('可选配置:')}
56
- ${chalk.green('Max Tokens:')} 16384(推荐)
57
-
58
- ${chalk.gray('提示: 如果遇到 "The model does not work with your current plan" 错误,')}
59
- ${chalk.gray(' 说明您的 Cursor 订阅不支持自定义模型')}
60
- `;
61
-
62
- return {
63
- success: true,
64
- manual: true,
65
- message: '需要手动配置(需 Cursor Pro)',
66
- instructions: instructions,
67
- configInfo: {
68
- protocol: 'OpenAI',
69
- baseUrl: baseUrl,
70
- apiKey: apiKey,
71
- }
72
- };
73
- }
74
-
75
- /**
76
- * 检查 Cursor 配置状态
77
- */
78
- configureCursor.checkStatus = async function() {
79
- const paths = getCursorConfigPaths();
80
-
81
- if (await fs.pathExists(paths.configDir)) {
82
- return {
83
- configured: true,
84
- message: 'Cursor 已安装(配置状态需在 Cursor 中查看)',
85
- };
86
- }
87
-
88
- return { configured: false };
89
- };
90
-
91
- /**
92
- * 撤销 Cursor 配置
93
- */
94
- configureCursor.revoke = async function() {
95
- // Cursor 自定义模型配置在内部数据库,无法通过文件操作撤销
96
- console.log(chalk.yellow('Cursor 配置需要在 Cursor Settings → Models 中手动删除'));
97
- };
98
-
99
- export default configureCursor;
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import os from 'os';
4
+ import chalk from 'chalk';
5
+ import { API_CONFIG } from '../index.js';
6
+
7
+ /**
8
+ * 获取 Cursor 配置路径
9
+ */
10
+ function getCursorConfigPaths() {
11
+ const home = os.homedir();
12
+ const platform = os.platform();
13
+
14
+ let configDir;
15
+ if (platform === 'win32') {
16
+ configDir = path.join(process.env.APPDATA || home, 'Cursor', 'User');
17
+ } else if (platform === 'darwin') {
18
+ configDir = path.join(home, 'Library', 'Application Support', 'Cursor', 'User');
19
+ } else {
20
+ configDir = path.join(home, '.config', 'Cursor', 'User');
21
+ }
22
+
23
+ return {
24
+ configDir,
25
+ settingsFile: path.join(configDir, 'settings.json'),
26
+ };
27
+ }
28
+
29
+ /**
30
+ * 配置 Cursor
31
+ * Cursor 需要通过 UI 手动配置自定义模型(需要高级会员)
32
+ */
33
+ export async function configureCursor(apiKey) {
34
+ const baseUrl = API_CONFIG.baseUrl;
35
+
36
+ // 生成配置说明
37
+ const instructions = `
38
+ ${chalk.yellow('Cursor 需要在编辑器中手动配置:')}
39
+
40
+ ${chalk.red('⚠️ 注意: 需要 Cursor Pro 或更高级订阅才能使用自定义模型')}
41
+
42
+ ${chalk.cyan('步骤 1:')} 打开 Cursor,进入 Settings → Models
43
+ ${chalk.cyan('步骤 2:')} 点击 "Add Custom Model"
44
+ ${chalk.cyan('步骤 3:')} 填入以下配置:
45
+
46
+ ${chalk.green('Protocol:')} OpenAI
47
+ ${chalk.green('OpenAI API Key:')} ${apiKey}
48
+ ${chalk.green('Override OpenAI Base URL:')} ${baseUrl}
49
+ ${chalk.green('Model Name:')} 输入模型名称(注意大小写)
50
+ 例如: gpt-5.2
51
+ 或: claude-sonnet-4-6
52
+
53
+ ${chalk.cyan('步骤 4:')} 点击保存,然后在模型列表中选择刚添加的模型
54
+
55
+ ${chalk.cyan('可选配置:')}
56
+ ${chalk.green('Max Tokens:')} 16384(推荐)
57
+
58
+ ${chalk.gray('提示: 如果遇到 "The model does not work with your current plan" 错误,')}
59
+ ${chalk.gray(' 说明您的 Cursor 订阅不支持自定义模型')}
60
+ `;
61
+
62
+ return {
63
+ success: true,
64
+ manual: true,
65
+ message: '需要手动配置(需 Cursor Pro)',
66
+ instructions: instructions,
67
+ configInfo: {
68
+ protocol: 'OpenAI',
69
+ baseUrl: baseUrl,
70
+ apiKey: apiKey,
71
+ }
72
+ };
73
+ }
74
+
75
+ /**
76
+ * 检查 Cursor 配置状态
77
+ */
78
+ configureCursor.checkStatus = async function() {
79
+ const paths = getCursorConfigPaths();
80
+
81
+ if (await fs.pathExists(paths.configDir)) {
82
+ return {
83
+ configured: true,
84
+ message: 'Cursor 已安装(配置状态需在 Cursor 中查看)',
85
+ };
86
+ }
87
+
88
+ return { configured: false };
89
+ };
90
+
91
+ /**
92
+ * 撤销 Cursor 配置
93
+ */
94
+ configureCursor.revoke = async function() {
95
+ // Cursor 自定义模型配置在内部数据库,无法通过文件操作撤销
96
+ console.log(chalk.yellow('Cursor 配置需要在 Cursor Settings → Models 中手动删除'));
97
+ };
98
+
99
+ export default configureCursor;