remote-claude 1.0.3 → 1.0.5

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/.env.example CHANGED
@@ -18,6 +18,10 @@ ALLOWED_USERS=ou_xxxxx,ou_yyyyy
18
18
  # 支持多词命令,如:ccr code、/usr/local/bin/claude
19
19
  # CLAUDE_COMMAND=claude
20
20
 
21
+ # Codex CLI 命令(可选,默认 codex)
22
+ # 支持多词命令,如:/usr/local/bin/codex
23
+ # CODEX_COMMAND=codex
24
+
21
25
  # 流式卡片配置(可选)
22
26
  # 单张卡片最多显示的 block 数量,超限自动冻结并创建新卡片(默认 50)
23
27
  # MAX_CARD_BLOCKS=50
package/README.md CHANGED
@@ -66,145 +66,21 @@ remote-claude attach <会话名>
66
66
 
67
67
  #### 4.1 配置飞书机器人
68
68
 
69
- 1. 登录[飞书开放平台](https://open.feishu.cn/),创建企业自建应用
70
- 2. 获取 **App ID** 和 **App Secret**
71
- 3. 用`cla`或`cl`启动一次claude(或用cx或cdx启动一次codex), 按照交互提示填入**App ID** 和 **App Secret**
72
- 4. [飞书开放平台]的企业自建应用页面`添加应用能力`(机器人能力)
73
- 5. 企业自建应用页面配置事件回调(如果第3步没启动成功这里配置不了):
74
- - `事件与回调` -> `事件配置` -> `订阅方式`右边的笔图标 -> `选择:使用长连接接收事件` -> `点击保存` -> `下面添加事件: 接收消息 v2.0 (im.message.receive_v1)`
75
- - `事件与回调` -> `回调配置` -> `订阅方式`右边的笔图标 -> `选择:使用长连接接收回调` -> `点击保存` -> `下面添加回调: 卡片回传交互 (card.action.trigger)`
76
- 6. 企业自建应用页面配置权限:
77
- - `权限管理` -> `批量导入/导出权限` -> 导入以下内容
78
- ```json
79
- {
80
- "scopes": {
81
- "tenant": [
82
- "base:app:read",
83
- "base:field:read",
84
- "base:form:read",
85
- "base:record:read",
86
- "base:record:retrieve",
87
- "base:table:read",
88
- "board:whiteboard:node:read",
89
- "calendar:calendar.free_busy:read",
90
- "cardkit:card:write",
91
- "contact:contact.base:readonly",
92
- "contact:user.employee_id:readonly",
93
- "contact:user.id:readonly",
94
- "docs:document.comment:read",
95
- "docs:document.content:read",
96
- "docs:document.media:download",
97
- "docs:document.media:upload",
98
- "docs:document:import",
99
- "docs:permission.member:auth",
100
- "docs:permission.member:create",
101
- "docs:permission.member:transfer",
102
- "docx:document.block:convert",
103
- "docx:document:create",
104
- "docx:document:readonly",
105
- "docx:document:write_only",
106
- "drive:drive.metadata:readonly",
107
- "drive:drive.search:readonly",
108
- "drive:drive:version:readonly",
109
- "drive:file:download",
110
- "drive:file:upload",
111
- "im:chat.members:read",
112
- "im:chat.members:write_only",
113
- "im:chat.tabs:read",
114
- "im:chat.tabs:write_only",
115
- "im:chat.top_notice:write_only",
116
- "im:chat:create",
117
- "im:chat:delete",
118
- "im:chat:operate_as_owner",
119
- "im:chat:read",
120
- "im:chat:update",
121
- "im:message.group_at_msg:readonly",
122
- "im:message.group_msg",
123
- "im:message.p2p_msg:readonly",
124
- "im:message.reactions:read",
125
- "im:message.reactions:write_only",
126
- "im:message.urgent",
127
- "im:message.urgent.status:write",
128
- "im:message:readonly",
129
- "im:message:recall",
130
- "im:message:send_as_bot",
131
- "im:message:update",
132
- "im:resource",
133
- "sheets:spreadsheet.meta:read",
134
- "sheets:spreadsheet.meta:write_only",
135
- "sheets:spreadsheet:create",
136
- "sheets:spreadsheet:read",
137
- "sheets:spreadsheet:write_only",
138
- "space:document:delete",
139
- "space:document:retrieve",
140
- "wiki:wiki:readonly"
141
- ],
142
- "user": [
143
- "base:app:read",
144
- "base:field:read",
145
- "base:record:read",
146
- "base:record:retrieve",
147
- "base:table:read",
148
- "calendar:calendar.event:create",
149
- "calendar:calendar.event:delete",
150
- "calendar:calendar.event:read",
151
- "calendar:calendar.event:reply",
152
- "calendar:calendar.event:update",
153
- "calendar:calendar.free_busy:read",
154
- "calendar:calendar:read",
155
- "cardkit:card:write",
156
- "contact:user.base:readonly",
157
- "contact:user.employee_id:readonly",
158
- "contact:user.id:readonly",
159
- "docs:document.comment:read",
160
- "docs:document.content:read",
161
- "docs:document.media:download",
162
- "docs:document.media:upload",
163
- "docx:document.block:convert",
164
- "docx:document:create",
165
- "docx:document:readonly",
166
- "docx:document:write_only",
167
- "im:chat.managers:write_only",
168
- "im:chat.members:read",
169
- "im:chat.members:write_only",
170
- "im:chat.tabs:read",
171
- "im:chat.tabs:write_only",
172
- "im:chat.top_notice:write_only",
173
- "im:chat:delete",
174
- "im:chat:read",
175
- "im:chat:update",
176
- "im:message.reactions:read",
177
- "im:message.reactions:write_only",
178
- "im:message:readonly",
179
- "im:message:recall",
180
- "im:message:update",
181
- "search:docs:read",
182
- "search:suite_dataset:readonly",
183
- "sheets:spreadsheet.meta:read",
184
- "sheets:spreadsheet.meta:write_only",
185
- "sheets:spreadsheet:create",
186
- "sheets:spreadsheet:read",
187
- "sheets:spreadsheet:write_only",
188
- "space:document:retrieve",
189
- "task:task:read",
190
- "task:task:readonly",
191
- "task:task:write",
192
- "task:task:writeonly",
193
- "task:tasklist:read",
194
- "task:tasklist:writeonly",
195
- "wiki:wiki:readonly"
196
- ]
197
- }
198
- }
69
+ 运行向导,按提示操作即可(约 5 分钟):
70
+
71
+ ```bash
72
+ remote-claude lark init
199
73
  ```
200
- 7. 企业自建应用页面: `创建版本` -> `发布到线上`
201
- 8. 至此,完成飞书机器人配置
202
74
 
203
- #### 4.2 通过飞书机器人操作claude/codex
75
+ 向导会自动完成:扫码创建企业自建应用、开通所需权限、配置事件回调、写入本地配置。
76
+
77
+ > **⚠ 向导最后一步会自动弹出发布页面**,按提示创建版本并发布后才能生效。
78
+ > 未发布的应用在飞书中无法被搜索到。
79
+
80
+ #### 4.2 通过飞书机器人操作 claude/codex
204
81
 
205
- 1. 从飞书搜索刚刚创建的飞书机器人(第一次搜比较慢,如果搜不到可能是忘记发布了)
206
- 2. 飞书中与机器人对话,可用命令:
207
- - `/menu` 展示菜单卡片,后续操作都操作这个卡片上的按钮即可
82
+ 1. 从飞书搜索刚创建的机器人(应用发布后才能搜到,发布约需 1 分钟生效)
83
+ 2. 飞书中与机器人对话,发送 `/menu` 展示菜单卡片,后续操作点卡片上的按钮即可
208
84
 
209
85
  ## 使用指南
210
86
 
package/bin/cdx CHANGED
@@ -16,5 +16,13 @@ fi
16
16
  # 检查飞书配置
17
17
  source "$SCRIPT_DIR/scripts/check-env.sh" "$SCRIPT_DIR"
18
18
 
19
+ # 会话名:第一个参数非 - 开头时作为自定义名,否则用 PWD_时间戳
20
+ if [ -n "$1" ] && [[ "$1" != -* ]]; then
21
+ SESSION_NAME="$1"
22
+ shift
23
+ else
24
+ SESSION_NAME="${PWD}_$(date +%m%d_%H%M%S)"
25
+ fi
26
+
19
27
  uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" lark start
20
- uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "${PWD}_$(date +%m%d_%H%M%S)" --cli codex -- "$@"
28
+ uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "$SESSION_NAME" --cli codex -- "$@"
package/bin/cl CHANGED
@@ -16,5 +16,13 @@ fi
16
16
  # 检查飞书配置
17
17
  source "$SCRIPT_DIR/scripts/check-env.sh" "$SCRIPT_DIR"
18
18
 
19
+ # 会话名:第一个参数非 - 开头时作为自定义名,否则用 PWD_时间戳
20
+ if [ -n "$1" ] && [[ "$1" != -* ]]; then
21
+ SESSION_NAME="$1"
22
+ shift
23
+ else
24
+ SESSION_NAME="${PWD}_$(date +%m%d_%H%M%S)"
25
+ fi
26
+
19
27
  uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" lark start
20
- uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "${PWD}_$(date +%m%d_%H%M%S)" -- --dangerously-skip-permissions --permission-mode=dontAsk "$@"
28
+ uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "$SESSION_NAME" -- --dangerously-skip-permissions --permission-mode=dontAsk "$@"
package/bin/cla CHANGED
@@ -16,5 +16,13 @@ fi
16
16
  # 检查飞书配置
17
17
  source "$SCRIPT_DIR/scripts/check-env.sh" "$SCRIPT_DIR"
18
18
 
19
+ # 会话名:第一个参数非 - 开头时作为自定义名,否则用 PWD_时间戳
20
+ if [ -n "$1" ] && [[ "$1" != -* ]]; then
21
+ SESSION_NAME="$1"
22
+ shift
23
+ else
24
+ SESSION_NAME="${PWD}_$(date +%m%d_%H%M%S)"
25
+ fi
26
+
19
27
  uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" lark start
20
- uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "${PWD}_$(date +%m%d_%H%M%S)" -- "$@"
28
+ uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "$SESSION_NAME" -- "$@"
package/bin/cx CHANGED
@@ -16,5 +16,13 @@ fi
16
16
  # 检查飞书配置
17
17
  source "$SCRIPT_DIR/scripts/check-env.sh" "$SCRIPT_DIR"
18
18
 
19
+ # 会话名:第一个参数非 - 开头时作为自定义名,否则用 PWD_时间戳
20
+ if [ -n "$1" ] && [[ "$1" != -* ]]; then
21
+ SESSION_NAME="$1"
22
+ shift
23
+ else
24
+ SESSION_NAME="${PWD}_$(date +%m%d_%H%M%S)"
25
+ fi
26
+
19
27
  uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" lark start
20
- uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "${PWD}_$(date +%m%d_%H%M%S)" --cli codex -- --dangerously-bypass-approvals-and-sandbox "$@"
28
+ uv run --project "$SCRIPT_DIR" python3 "$SCRIPT_DIR/remote_claude.py" start "$SESSION_NAME" --cli codex -- --dangerously-bypass-approvals-and-sandbox "$@"
package/bin/remote-claude CHANGED
@@ -17,25 +17,16 @@ fi
17
17
  if [ "$1" = "log" ]; then
18
18
  LOG_DIR="/tmp/remote-claude"
19
19
  if [ -n "$2" ]; then
20
- # 指定 session 名,/ . 替换为 _(与 _safe_filename 一致)
21
- SESSION_SAFE=$(echo "$2" | tr '/.' '__')
22
- LOG_FILE="$LOG_DIR/${SESSION_SAFE}_messages.log"
20
+ # 指定 session 名,/ . 空格替换为 _(与 _log_filename 一致)
21
+ SESSION_LOG=$(echo "$2" | tr '/. ' '___')
22
+ LOG_FILE="$LOG_DIR/${SESSION_LOG}_messages.log"
23
23
  else
24
- # 找最后启动的 session(按创建时间排序,排除 lark.pid)
25
- if [[ "$OSTYPE" == "darwin"* ]]; then
26
- # macOS: stat -f "%B" 返回创建时间(秒)
27
- LATEST_PID=$(ls "$LOG_DIR"/_*.pid 2>/dev/null | while read f; do
28
- stat -f "%B:%N" "$f" 2>/dev/null
29
- done | sort -rn | head -1 | cut -d: -f2)
30
- else
31
- # Linux: stat -c "%W" 返回创建时间(秒)
32
- LATEST_PID=$(ls "$LOG_DIR"/_*.pid 2>/dev/null | while read f; do
33
- stat -c "%W:%N" "$f" 2>/dev/null
34
- done | sort -rn | head -1 | cut -d: -f2)
35
- fi
36
- if [ -n "$LATEST_PID" ]; then
37
- SESSION_SAFE=$(basename "$LATEST_PID" .pid)
38
- LOG_FILE="$LOG_DIR/${SESSION_SAFE}_messages.log"
24
+ # 找最后启动的 session(按 .name 文件修改时间排序)
25
+ LATEST_NAME=$(ls -t "$LOG_DIR"/*.name 2>/dev/null | head -1)
26
+ if [ -n "$LATEST_NAME" ]; then
27
+ SESSION_NAME=$(cat "$LATEST_NAME" 2>/dev/null)
28
+ SESSION_LOG=$(echo "$SESSION_NAME" | tr '/. ' '___')
29
+ LOG_FILE="$LOG_DIR/${SESSION_LOG}_messages.log"
39
30
  fi
40
31
  fi
41
32
 
@@ -48,9 +39,4 @@ if [ "$1" = "log" ]; then
48
39
  exec tail -50f "$LOG_FILE"
49
40
  fi
50
41
 
51
- # lark 子命令:检查 .env 配置
52
- if [ "$1" = "lark" ]; then
53
- source "$INSTALL_DIR/scripts/check-env.sh" "$INSTALL_DIR"
54
- fi
55
-
56
42
  exec uv run --project "$INSTALL_DIR" python3 "$INSTALL_DIR/remote_claude.py" "$@"
package/client/client.py CHANGED
@@ -111,7 +111,7 @@ class RemoteClient:
111
111
  async def run(self):
112
112
  """运行客户端"""
113
113
  if not await self.connect():
114
- return
114
+ raise SystemExit(1)
115
115
 
116
116
  self.running = True
117
117
  _track_stats('terminal', 'connect', session_name=self.session_name)
package/init.sh CHANGED
@@ -26,6 +26,16 @@ print_error() {
26
26
  echo -e "${RED}✗${NC} $1"
27
27
  }
28
28
 
29
+ # 非交互 sudo:有免密 sudo 则执行(带 5 分钟超时),否则跳过
30
+ _sudo_or_skip() {
31
+ if sudo -n true 2>/dev/null; then
32
+ timeout 300 sudo "$@"
33
+ else
34
+ print_warning "sudo 需要密码,跳过: sudo $*"
35
+ return 1
36
+ fi
37
+ }
38
+
29
39
  print_header() {
30
40
  echo ""
31
41
  echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
@@ -200,96 +210,22 @@ check_tmux() {
200
210
  brew install tmux 2>/dev/null || true
201
211
  elif [[ "$OS" == "Linux" ]]; then
202
212
  if command -v apt-get &> /dev/null; then
203
- sudo apt-get update && sudo apt-get install -y tmux || true
213
+ _sudo_or_skip apt-get update && _sudo_or_skip apt-get install -y tmux || true
204
214
  elif command -v yum &> /dev/null; then
205
- sudo yum install -y tmux || true
215
+ _sudo_or_skip yum install -y tmux || true
206
216
  elif command -v pacman &> /dev/null; then
207
- sudo pacman -Sy --noconfirm tmux || true
217
+ _sudo_or_skip pacman -Sy --noconfirm tmux || true
208
218
  elif command -v apk &> /dev/null; then
209
- sudo apk add --no-cache tmux || true
219
+ _sudo_or_skip apk add --no-cache tmux || true
210
220
  elif command -v zypper &> /dev/null; then
211
- sudo zypper install -y tmux || true
221
+ _sudo_or_skip zypper install -y tmux || true
212
222
  else
213
- print_warning "无法识别包管理器,尝试从源码编译 tmux..."
214
- install_tmux_from_source
215
- return
223
+ print_warning "无法识别包管理器,请手动安装 tmux 或运行 remote-claude deps"
216
224
  fi
217
225
  fi
218
226
  print_success "tmux 安装成功"
219
227
  }
220
228
 
221
- install_tmux_from_source() {
222
- local TMUX_VERSION_TAG="3.6a"
223
- local TMUX_URL="https://github.com/tmux/tmux/releases/download/${TMUX_VERSION_TAG}/tmux-${TMUX_VERSION_TAG}.tar.gz"
224
-
225
- print_warning "包管理器版本不满足要求,尝试从源码编译 tmux ${TMUX_VERSION_TAG}..."
226
-
227
- # 安装编译依赖
228
- if [[ "$OS" == "Darwin" ]]; then
229
- brew install libevent ncurses pkg-config bison 2>/dev/null || true
230
- elif command -v apt-get &> /dev/null; then
231
- sudo apt-get install -y build-essential libevent-dev libncurses5-dev libncursesw5-dev bison pkg-config || true
232
- elif command -v yum &> /dev/null; then
233
- sudo yum groupinstall -y "Development Tools" || true
234
- sudo yum install -y libevent-devel ncurses-devel bison || true
235
- fi
236
-
237
- # 确定安装前缀
238
- local PREFIX="/usr/local"
239
- if ! sudo -n true 2>/dev/null; then
240
- print_warning "无 sudo 权限,将安装到 \$HOME/.local"
241
- PREFIX="$HOME/.local"
242
- fi
243
-
244
- # 创建临时目录,编译完成后清理
245
- local TMPDIR
246
- TMPDIR=$(mktemp -d)
247
- trap "rm -rf '$TMPDIR'" RETURN
248
-
249
- print_warning "下载 tmux-${TMUX_VERSION_TAG}.tar.gz..."
250
- if ! curl -fsSL "$TMUX_URL" -o "$TMPDIR/tmux.tar.gz"; then
251
- print_warning "下载失败,请检查网络或手动安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
252
- WARNINGS+=("tmux 源码下载失败,请手动安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+")
253
- return
254
- fi
255
-
256
- tar -xzf "$TMPDIR/tmux.tar.gz" -C "$TMPDIR"
257
- local SRC_DIR
258
- SRC_DIR=$(find "$TMPDIR" -maxdepth 1 -type d -name "tmux-*" | head -1)
259
-
260
- print_warning "编译 tmux(可能需要几分钟)..."
261
- if ! (cd "$SRC_DIR" && ./configure --prefix="$PREFIX" && make -j"$(nproc 2>/dev/null || echo 2)"); then
262
- print_warning "编译失败,请手动安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
263
- WARNINGS+=("tmux 源码编译失败,请手动安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+")
264
- return
265
- fi
266
-
267
- if [[ "$PREFIX" == "/usr/local" ]]; then
268
- sudo make -C "$SRC_DIR" install || { WARNINGS+=("tmux make install 失败,请手动安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"); return; }
269
- else
270
- make -C "$SRC_DIR" install || { WARNINGS+=("tmux make install 失败,请手动安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"); return; }
271
- # 若 $HOME/.local/bin 不在 PATH 中,自动写入 shell 配置
272
- if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
273
- export PATH="$HOME/.local/bin:$PATH"
274
- local _RC
275
- if [[ "$(basename "$SHELL")" == "zsh" ]]; then
276
- _RC="$HOME/.zshrc"
277
- else
278
- _RC="$HOME/.bashrc"
279
- fi
280
- local _PATH_LINE='export PATH="$HOME/.local/bin:$PATH"'
281
- if ! grep -qF "$HOME/.local/bin" "$_RC" 2>/dev/null; then
282
- echo "" >> "$_RC"
283
- echo "# remote-claude: tmux 路径" >> "$_RC"
284
- echo "$_PATH_LINE" >> "$_RC"
285
- print_success "已自动将 \$HOME/.local/bin 加入 PATH(写入 $_RC)"
286
- fi
287
- fi
288
- fi
289
-
290
- print_success "tmux ${TMUX_VERSION_TAG} 源码编译安装完成(前缀:${PREFIX})"
291
- }
292
-
293
229
  check_version() {
294
230
  # tmux -V 输出格式:tmux 3.6 或 tmux 3.4a
295
231
  local ver_str
@@ -310,30 +246,27 @@ check_tmux() {
310
246
  print_success "$TMUX_VERSION 已安装(满足 >= ${REQUIRED_MAJOR}.${REQUIRED_MINOR})"
311
247
  return
312
248
  else
313
- print_warning "$TMUX_VERSION 版本过低,需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR} 或更高,正在升级..."
249
+ print_warning "$TMUX_VERSION 版本过低,需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR} 或更高,尝试通过包管理器升级..."
314
250
  install_tmux
315
- # 升级后再次验证,版本仍不满足则走源码编译(跨平台)
316
- if ! check_version; then
317
- install_tmux_from_source
318
- if check_version; then
319
- print_success "tmux 已升级至 $(tmux -V)"
320
- else
321
- print_warning "源码编译后版本仍不满足要求($(tmux -V)),需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
322
- WARNINGS+=("tmux 版本不满足要求($(tmux -V)),需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+,请手动升级")
323
- fi
324
- else
251
+ if check_version; then
325
252
  print_success "tmux 已升级至 $(tmux -V)"
253
+ else
254
+ print_warning "包管理器安装后版本仍不满足要求($(tmux -V)),需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
255
+ print_info "请运行 'remote-claude deps' 从源码编译安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
256
+ WARNINGS+=("tmux 版本不满足要求($(tmux -V)),需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+,请运行 remote-claude deps 升级")
326
257
  fi
327
258
  fi
328
259
  else
329
260
  print_warning "未找到 tmux,正在安装..."
330
261
  install_tmux
331
- if ! check_version; then
332
- install_tmux_from_source
333
- if ! check_version; then
334
- print_warning "源码编译后版本仍不满足要求($(tmux -V)),需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
335
- WARNINGS+=("tmux 版本不满足要求($(tmux -V)),需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+,请手动升级")
336
- fi
262
+ if command -v tmux &> /dev/null && check_version; then
263
+ print_success "tmux 已安装: $(tmux -V)"
264
+ else
265
+ local _cur_ver=""
266
+ command -v tmux &> /dev/null && _cur_ver="(当前: $(tmux -V)"
267
+ print_warning "tmux 安装后版本仍不满足要求${_cur_ver},需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
268
+ print_info "请运行 'remote-claude deps' 从源码编译安装 tmux ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+"
269
+ WARNINGS+=("tmux 版本不满足要求,需要 ${REQUIRED_MAJOR}.${REQUIRED_MINOR}+,请运行 remote-claude deps 升级")
337
270
  fi
338
271
  fi
339
272
  }
@@ -771,6 +771,16 @@ def build_stream_card(
771
771
 
772
772
  # === 辅助卡片(保留不变)===
773
773
 
774
+ def _get_display_name(name: str, cwd: str = None) -> str:
775
+ """从会话名和 CWD 获取显示名。自定义会话名直接用,默认路径名取 CWD 末段。"""
776
+ is_default = bool(_re.search(r'_\d{4}_\d{6}$', name))
777
+ if not is_default:
778
+ return name
779
+ if cwd:
780
+ return cwd.rstrip("/").rsplit("/", 1)[-1] or name
781
+ return name
782
+
783
+
774
784
  def _build_session_list_elements(sessions: List[Dict], current_session: Optional[str], session_groups: Optional[Dict[str, str]], page: int = 0) -> List[Dict]:
775
785
  """构建会话列表元素(供 build_menu_card 复用)"""
776
786
  import os
@@ -794,10 +804,7 @@ def _build_session_list_elements(sessions: List[Dict], current_session: Optional
794
804
 
795
805
  status_icon = "🟢" if is_current else "⚪"
796
806
  current_label = "(当前)" if is_current else ""
797
- if cwd:
798
- short_name = cwd.rstrip("/").rsplit("/", 1)[-1] or name
799
- else:
800
- short_name = name
807
+ short_name = _get_display_name(name, cwd)
801
808
 
802
809
  # 构建4行内容:名字、cli类型、启动时间、目录
803
810
  lines = [f"{status_icon} **{short_name}**{current_label}"]
@@ -1029,22 +1036,44 @@ def build_dir_card(target, entries: List[Dict], sessions: List[Dict], tree: bool
1029
1036
  for sn, cid in session_groups.items():
1030
1037
  if sn == auto_session or sn.startswith(auto_session + "_"):
1031
1038
  matched_group_cid = cid
1032
- group_btn = {
1033
- "tag": "button",
1034
- "text": {"tag": "plain_text", "content": "进入群聊" if matched_group_cid else "创建群聊"},
1035
- "type": "default",
1036
- "behaviors": [{"type": "open_url",
1037
- "default_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}",
1038
- "android_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}",
1039
- "ios_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}",
1040
- "pc_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}"}]
1041
- if matched_group_cid else
1042
- [{"type": "callback", "value": {
1043
- "action": "dir_new_group",
1044
- "path": full_path,
1045
- "session_name": auto_session
1046
- }}]
1047
- }
1039
+ if matched_group_cid:
1040
+ action_btns = [
1041
+ {
1042
+ "tag": "button",
1043
+ "text": {"tag": "plain_text", "content": "进入群聊"},
1044
+ "type": "default",
1045
+ "behaviors": [{"type": "open_url",
1046
+ "default_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}",
1047
+ "android_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}",
1048
+ "ios_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}",
1049
+ "pc_url": f"https://applink.feishu.cn/client/chat/open?openChatId={matched_group_cid}"}]
1050
+ }
1051
+ ]
1052
+ else:
1053
+ action_btns = [
1054
+ {
1055
+ "tag": "button",
1056
+ "text": {"tag": "plain_text", "content": "Claude群聊"},
1057
+ "type": "primary",
1058
+ "behaviors": [{"type": "callback", "value": {
1059
+ "action": "dir_new_group",
1060
+ "path": full_path,
1061
+ "session_name": auto_session,
1062
+ "cli_type": "claude"
1063
+ }}]
1064
+ },
1065
+ {
1066
+ "tag": "button",
1067
+ "text": {"tag": "plain_text", "content": "Codex群聊"},
1068
+ "type": "default",
1069
+ "behaviors": [{"type": "callback", "value": {
1070
+ "action": "dir_new_group",
1071
+ "path": full_path,
1072
+ "session_name": auto_session,
1073
+ "cli_type": "codex"
1074
+ }}]
1075
+ }
1076
+ ]
1048
1077
  elements.append({
1049
1078
  "tag": "column_set",
1050
1079
  "flex_mode": "none",
@@ -1067,19 +1096,7 @@ def build_dir_card(target, entries: List[Dict], sessions: List[Dict], tree: bool
1067
1096
  "tag": "column",
1068
1097
  "width": "weighted",
1069
1098
  "weight": 2,
1070
- "elements": [
1071
- {
1072
- "tag": "button",
1073
- "text": {"tag": "plain_text", "content": "Claude"},
1074
- "type": "primary",
1075
- "behaviors": [{"type": "callback", "value": {
1076
- "action": "dir_start",
1077
- "path": full_path,
1078
- "session_name": auto_session
1079
- }}]
1080
- },
1081
- group_btn
1082
- ]
1099
+ "elements": action_btns
1083
1100
  }
1084
1101
  ]
1085
1102
  })
@@ -1152,6 +1169,9 @@ def build_help_card() -> Dict[str, Any]:
1152
1169
  **群聊协作**
1153
1170
  • `/new-group <会话名>` - 创建专属群聊,多人共用同一 Claude
1154
1171
 
1172
+ **按键控制**
1173
+ • `/press <按键>` - 发送按键到会话(如 `/press ctrl+c`、`/press esc`、`/press ctrl+f`)
1174
+
1155
1175
  **其他**
1156
1176
  • `/help` - 显示此帮助
1157
1177
  • `/menu` - 快捷操作面板"""