@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 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('which', [claudeCliPath], { stdio: 'pipe' });
67
+ execFileSync(checkCommand, [claudeCliPath], { stdio: 'pipe' });
66
68
  }
67
69
  catch {
68
- throw new Error(`Claude CLI 在 PATH 中未找到: ${claudeCliPath}`);
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
- // 如果 rest 为空或以 \ 或 / 开头,则是驱动器根目录的绝对路径
163
- // 如果 rest 不为空且不以 \ 或 / 开头,则是驱动器当前目录的相对路径
164
- if (rest === '' || rest.startsWith('/') || rest.startsWith('\\')) {
165
- resolved = `${drive}:${rest}`;
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 = `${drive}:${rest}`;
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 {
@@ -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
- if (totalTurns >= 12)
61
- return '⚠️ 上下文较长,建议 /new 开始新会话';
62
- if (totalTurns >= 8)
63
- return `💡 对话已 ${totalTurns} 轮,可用 /compact 压缩`;
64
- return null;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, Cursor)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",