@raolin2025/claude-code-node 2.6.8 → 2.6.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raolin2025/claude-code-node",
3
- "version": "2.6.8",
3
+ "version": "2.6.10",
4
4
  "description": "Node.js AI Code Agent CLI - Zero dependencies, pure JavaScript, security hardened, multi-channel notifications, Telegram & QQ Bot remote programming, rich media upload, multi-account management",
5
5
  "type": "module",
6
6
  "main": "src/core/index.js",
@@ -419,8 +419,11 @@ export class TelegramListener {
419
419
  if (reply) {
420
420
  // 如果回复很长,分多条发送
421
421
  await this._sendLongMessage(chatId, reply, { replyTo: msg.message_id })
422
+ return
422
423
  }
423
- return
424
+ // _handleCommand 返回 null = 未知命令(如 /stop、/resume 等)
425
+ // 需要转发给 cc-node 的 processInputLine 处理,不能吞掉。
426
+ // 落到下方普通消息分支继续转发。
424
427
  }
425
428
 
426
429
  // 处理普通消息 — 转发给 cc-node
package/src/core/cli.js CHANGED
@@ -281,6 +281,7 @@ Commands:
281
281
  /session — Show session info
282
282
  /sessions — List all sessions
283
283
  /clear — Clear conversation
284
+ /stop — Stop current AI work (when stuck/long)
284
285
  /config KEY — Show config value
285
286
  /budget — Show token budget
286
287
  /channel CMD — Manage notification channels (list|send|test)
@@ -315,6 +316,8 @@ const DETAILED_HELP = {
315
316
 
316
317
  clear: "/clear\n Clear the current conversation context.\n Starts a fresh session. Previous messages are not sent to the API anymore.\n\n Note: Does not delete saved sessions.",
317
318
 
319
+ stop: "/stop\n Stop the currently running AI work.\n Use when the AI appears stuck or takes too long to respond.\n Sends an abort signal to interrupt the current task.\n After stopping, you can issue a new command.",
320
+
318
321
  config: "/config [key]\n Without key: show the entire config as JSON.\n With a key path: show the value for that specific path.\n\n Example: /config\n Example: /config model",
319
322
 
320
323
  budget: "/budget\n Show token budget usage for the current session.\n Displays how many tokens have been used vs the limit.",
@@ -750,6 +753,15 @@ const systemPrompt = cliArgs.systemPrompt || DEFAULT_SYSTEM_PROMPT
750
753
  session = await sessionManager.create()
751
754
  console.log('Conversation cleared')
752
755
  break
756
+ case 'stop':
757
+ // 停止当前正在运行的 AI 工作(如卡死 / 长时间无响应时)
758
+ if (engine.state.isRunning) {
759
+ engine.abort()
760
+ console.log('⏹️ 已发送停止信号,正在中止当前工作...')
761
+ } else {
762
+ console.log('(当前没有正在运行的任务)')
763
+ }
764
+ break
753
765
  case 'config':
754
766
  if (rest[0]) {
755
767
  const val = config.get(rest.join(' '))
package/src/tools/bash.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * 对应原版: src/tools/BashTool/
4
4
  */
5
5
  import { spawn } from 'child_process'
6
+ import { existsSync } from 'node:fs'
6
7
  import { ToolDef } from '../types/index.js'
7
8
  import { checkBashSafety } from '../security/bash-guard.js'
8
9
 
@@ -51,8 +52,35 @@ Usage:
51
52
  }
52
53
 
53
54
  return new Promise((resolve, reject) => {
54
- const shell = process.env.SHELL || '/bin/bash'
55
- const proc = spawn(shell, ['-c', command], {
55
+ // 跨平台 shell 选择:
56
+ // - Windows: 优先用 Git Bash(如已安装),否则用 cmd.exe /c
57
+ // - 其他平台: 用 SHELL 环境变量或默认 /bin/bash
58
+ const isWindows = process.platform === 'win32'
59
+ let shell, shellArgs
60
+ if (isWindows) {
61
+ // 检测 Git Bash 是否可用
62
+ const gitBashCandidates = [
63
+ process.env.GIT_BASH,
64
+ 'C:\\Program Files\\Git\\bin\\bash.exe',
65
+ 'C:\\Program Files (x86)\\Git\\bin\\bash.exe',
66
+ ].filter(Boolean)
67
+ let gitBash = null
68
+ try {
69
+ gitBash = gitBashCandidates.find((p) => existsSync(p)) || null
70
+ } catch {}
71
+ if (gitBash) {
72
+ shell = gitBash
73
+ shellArgs = ['-c', command]
74
+ } else {
75
+ // 无 Git Bash → 用 cmd.exe
76
+ shell = process.env.ComSpec || 'cmd.exe'
77
+ shellArgs = ['/c', command]
78
+ }
79
+ } else {
80
+ shell = process.env.SHELL || '/bin/bash'
81
+ shellArgs = ['-c', command]
82
+ }
83
+ const proc = spawn(shell, shellArgs, {
56
84
  cwd,
57
85
  env: { ...process.env, ...extraEnv },
58
86
  stdio: ['pipe', 'pipe', 'pipe'],