@wu529778790/open-im 0.2.9 → 0.2.11
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/dist/config.js +23 -3
- package/dist/session/session-manager.js +13 -7
- package/dist/shared/utils.js +20 -5
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -52,7 +52,7 @@ export function loadConfig() {
|
|
|
52
52
|
? parseInt(process.env.CLAUDE_TIMEOUT_MS, 10) || 600000
|
|
53
53
|
: file.claudeTimeoutMs ?? 600000;
|
|
54
54
|
if (aiCommand === 'claude') {
|
|
55
|
-
if (isAbsolute(claudeCliPath) || claudeCliPath.includes('/')) {
|
|
55
|
+
if (isAbsolute(claudeCliPath) || claudeCliPath.includes('/') || claudeCliPath.includes('\\')) {
|
|
56
56
|
try {
|
|
57
57
|
accessSync(claudeCliPath, constants.F_OK | constants.X_OK);
|
|
58
58
|
}
|
|
@@ -61,11 +61,31 @@ export function loadConfig() {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
|
+
// 检查命令是否存在(Windows 用 where,Unix 用 which)
|
|
65
|
+
const checkCommand = process.platform === 'win32' ? 'where' : 'which';
|
|
64
66
|
try {
|
|
65
|
-
execFileSync(
|
|
67
|
+
execFileSync(checkCommand, [claudeCliPath], { stdio: 'pipe' });
|
|
66
68
|
}
|
|
67
69
|
catch {
|
|
68
|
-
|
|
70
|
+
const installGuide = [
|
|
71
|
+
'',
|
|
72
|
+
'━━━ Claude CLI 未安装 ━━━',
|
|
73
|
+
'',
|
|
74
|
+
'open-im 需要 Claude Code CLI 才能运行。',
|
|
75
|
+
'',
|
|
76
|
+
'安装方法:',
|
|
77
|
+
'',
|
|
78
|
+
' npm install -g @anthropic-ai/claude-code',
|
|
79
|
+
'',
|
|
80
|
+
'或者:',
|
|
81
|
+
' 1. 访问 https://claude.ai/download',
|
|
82
|
+
' 2. 下载并安装 Claude Code',
|
|
83
|
+
'',
|
|
84
|
+
'安装后重新运行:',
|
|
85
|
+
' open-im run',
|
|
86
|
+
'',
|
|
87
|
+
].join('\n');
|
|
88
|
+
throw new Error(installGuide);
|
|
69
89
|
}
|
|
70
90
|
}
|
|
71
91
|
}
|
|
@@ -159,14 +159,20 @@ export class SessionManager {
|
|
|
159
159
|
const drivePathMatch = targetDir.match(/^([a-zA-Z]):(.*)$/);
|
|
160
160
|
if (drivePathMatch) {
|
|
161
161
|
const [, drive, rest] = drivePathMatch;
|
|
162
|
-
//
|
|
163
|
-
// 如果 rest
|
|
164
|
-
|
|
165
|
-
|
|
162
|
+
// 使用 resolve 确保路径格式正确
|
|
163
|
+
// 如果 rest 为空,则是驱动器根目录
|
|
164
|
+
// 如果 rest 不为空,resolve 会正确处理斜杠
|
|
165
|
+
const driveRoot = `${drive}:`;
|
|
166
|
+
if (rest === '') {
|
|
167
|
+
resolved = driveRoot;
|
|
168
|
+
}
|
|
169
|
+
else if (rest.startsWith('/') || rest.startsWith('\\')) {
|
|
170
|
+
// 已是绝对路径,直接使用
|
|
171
|
+
resolved = `${drive}${rest}`;
|
|
166
172
|
}
|
|
167
173
|
else {
|
|
168
|
-
//
|
|
169
|
-
resolved =
|
|
174
|
+
// 相对于驱动器根目录的路径,使用 resolve 处理
|
|
175
|
+
resolved = resolve(driveRoot, rest);
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
178
|
else if (targetDir === '~' || targetDir.startsWith('~/')) {
|
|
@@ -175,7 +181,7 @@ export class SessionManager {
|
|
|
175
181
|
resolved = join(home, targetDir.slice(1));
|
|
176
182
|
}
|
|
177
183
|
else if (targetDir.startsWith('/') || (targetDir.length >= 3 && targetDir[1] === ':' && (targetDir[2] === '\\' || targetDir[2] === '/'))) {
|
|
178
|
-
//
|
|
184
|
+
// 绝对路径(包括 Windows 绝对路径)
|
|
179
185
|
resolved = targetDir;
|
|
180
186
|
}
|
|
181
187
|
else {
|
package/dist/shared/utils.js
CHANGED
|
@@ -56,10 +56,25 @@ export function formatToolCallNotification(toolName, toolInput) {
|
|
|
56
56
|
detail = ` → ${toolInput.file_path}`;
|
|
57
57
|
return `${emoji} ${toolName}${detail}`;
|
|
58
58
|
}
|
|
59
|
+
// 使用提示池,每轮显示不同的技巧
|
|
60
|
+
const USAGE_TIPS = [
|
|
61
|
+
'💡 提示:用 `/new` 开始全新会话',
|
|
62
|
+
'💡 可以用 `/cd <路径>` 切换工作目录',
|
|
63
|
+
'💡 用 `/pwd` 查看当前目录',
|
|
64
|
+
'💡 用 `/status` 查看运行状态',
|
|
65
|
+
'💡 支持发送图片让 AI 分析',
|
|
66
|
+
'💡 支持多行代码输入',
|
|
67
|
+
'⚠️ 上下文较长,建议 /new 开始新会话',
|
|
68
|
+
];
|
|
59
69
|
export function getContextWarning(totalTurns) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
// 第 6 轮开始显示提示
|
|
71
|
+
if (totalTurns < 6)
|
|
72
|
+
return null;
|
|
73
|
+
// 第 13 轮后一直显示警告
|
|
74
|
+
if (totalTurns >= 13) {
|
|
75
|
+
return USAGE_TIPS[USAGE_TIPS.length - 1];
|
|
76
|
+
}
|
|
77
|
+
// 根据轮数循环显示提示
|
|
78
|
+
const tipIndex = (totalTurns - 6) % USAGE_TIPS.length;
|
|
79
|
+
return USAGE_TIPS[tipIndex];
|
|
65
80
|
}
|