remote-claude 0.2.0 → 0.2.2

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.
@@ -11,10 +11,27 @@
11
11
 
12
12
  import logging
13
13
  import re as _re
14
+ import pathlib as _pl
15
+ import json as _json
14
16
  from typing import Dict, Any, List, Optional
15
17
 
16
18
  _cb_logger = logging.getLogger('CardBuilder')
17
19
 
20
+ # 版本号:从 package.json 读取,import 时只读一次
21
+ try:
22
+ _pkg = _pl.Path(__file__).parent.parent / "package.json"
23
+ _VERSION = "v" + _json.loads(_pkg.read_text())["version"]
24
+ except Exception:
25
+ _VERSION = ""
26
+
27
+
28
+ def _build_header(title: str, template: str) -> dict:
29
+ """构建卡片 header,自动附加版本号副标题"""
30
+ h: dict = {"title": {"tag": "plain_text", "content": title}, "template": template}
31
+ if _VERSION:
32
+ h["subtitle"] = {"tag": "plain_text", "content": _VERSION}
33
+ return h
34
+
18
35
  # ANSI SGR 前景色码 → 飞书颜色
19
36
  # 飞书支持: blue, wathet, turquoise, green, yellow, orange, red, carmine, violet, purple, indigo, grey
20
37
  _SGR_FG_TO_LARK = {
@@ -725,10 +742,7 @@ def build_stream_card(
725
742
  return {
726
743
  "schema": "2.0",
727
744
  "config": {"wide_screen_mode": True, "enable_forward": True},
728
- "header": {
729
- "title": {"tag": "plain_text", "content": title},
730
- "template": template,
731
- },
745
+ "header": _build_header(title, template),
732
746
  "body": {"elements": elements},
733
747
  }
734
748
 
@@ -854,10 +868,7 @@ def build_status_card(connected: bool, session_name: Optional[str] = None) -> Di
854
868
  return {
855
869
  "schema": "2.0",
856
870
  "config": {"wide_screen_mode": True},
857
- "header": {
858
- "title": {"tag": "plain_text", "content": title},
859
- "template": template,
860
- },
871
+ "header": _build_header(title, template),
861
872
  "body": {"elements": [
862
873
  {"tag": "markdown", "content": content},
863
874
  {"tag": "hr"},
@@ -1032,7 +1043,7 @@ def build_dir_card(target, entries: List[Dict], sessions: List[Dict], tree: bool
1032
1043
  return {
1033
1044
  "schema": "2.0",
1034
1045
  "config": {"wide_screen_mode": True},
1035
- "header": {"title": {"tag": "plain_text", "content": title}, "template": "blue"},
1046
+ "header": _build_header(title, "blue"),
1036
1047
  "body": {"elements": elements}
1037
1048
  }
1038
1049
 
@@ -1064,10 +1075,7 @@ def build_help_card() -> Dict[str, Any]:
1064
1075
  return {
1065
1076
  "schema": "2.0",
1066
1077
  "config": {"wide_screen_mode": True},
1067
- "header": {
1068
- "title": {"tag": "plain_text", "content": "📖 Remote Claude 帮助"},
1069
- "template": "blue",
1070
- },
1078
+ "header": _build_header("📖 Remote Claude 帮助", "blue"),
1071
1079
  "body": {"elements": [
1072
1080
  {"tag": "markdown", "content": help_content},
1073
1081
  {"tag": "hr"},
@@ -1081,10 +1089,7 @@ def build_session_closed_card(session_name: str) -> Dict[str, Any]:
1081
1089
  return {
1082
1090
  "schema": "2.0",
1083
1091
  "config": {"wide_screen_mode": True},
1084
- "header": {
1085
- "title": {"tag": "plain_text", "content": "🔴 会话已关闭"},
1086
- "template": "red",
1087
- },
1092
+ "header": _build_header("🔴 会话已关闭", "red"),
1088
1093
  "body": {"elements": [
1089
1094
  {"tag": "markdown", "content": f"会话 **{session_name}** 已关闭,连接已自动断开。\n\n如需继续,请重新启动会话或连接到其他会话。"},
1090
1095
  {"tag": "hr"},
@@ -1160,9 +1165,6 @@ def build_menu_card(sessions: List[Dict], current_session: Optional[str] = None,
1160
1165
  return {
1161
1166
  "schema": "2.0",
1162
1167
  "config": {"wide_screen_mode": True},
1163
- "header": {
1164
- "title": {"tag": "plain_text", "content": "⚡ 快捷操作"},
1165
- "template": "turquoise",
1166
- },
1168
+ "header": _build_header("⚡ 快捷操作", "turquoise"),
1167
1169
  "body": {"elements": elements}
1168
1170
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "remote-claude",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "双端共享 Claude CLI 工具",
5
5
  "bin": {
6
6
  "remote-claude": "bin/remote-claude",
@@ -26,13 +26,22 @@
26
26
  "uv.lock",
27
27
  ".env.example"
28
28
  ],
29
- "os": ["darwin", "linux"],
29
+ "os": [
30
+ "darwin",
31
+ "linux"
32
+ ],
30
33
  "license": "MIT",
31
34
  "repository": {
32
35
  "type": "git",
33
36
  "url": "git+https://github.com/yuyangzi/remote_claude.git"
34
37
  },
35
- "keywords": ["claude", "cli", "terminal", "pty", "lark"],
38
+ "keywords": [
39
+ "claude",
40
+ "cli",
41
+ "terminal",
42
+ "pty",
43
+ "lark"
44
+ ],
36
45
  "engines": {
37
46
  "node": ">=16"
38
47
  },
package/remote_claude.py CHANGED
@@ -38,6 +38,13 @@ from utils.session import (
38
38
  # 获取脚本所在目录
39
39
  SCRIPT_DIR = Path(__file__).parent.absolute()
40
40
 
41
+ # 读取版本号(仅 import 时读取一次)
42
+ try:
43
+ import json as _json
44
+ _VERSION = _json.loads((SCRIPT_DIR / "package.json").read_text())["version"]
45
+ except Exception:
46
+ _VERSION = "unknown"
47
+
41
48
 
42
49
  def cmd_start(args):
43
50
  """启动新会话"""
@@ -326,6 +333,7 @@ def cmd_lark_status(args):
326
333
  print("飞书客户端状态")
327
334
  print("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
328
335
  print(f"状态: 运行中 ✓")
336
+ print(f"版本: v{_VERSION}")
329
337
  print(f"PID: {status['pid']}")
330
338
  print(f"启动时间: {status['start_time']}")
331
339
  print(f"运行时长: {status['uptime']}")
@@ -429,6 +437,12 @@ def main():
429
437
  """
430
438
  )
431
439
 
440
+ parser.add_argument(
441
+ "--version", "-V",
442
+ action="version",
443
+ version=f"remote-claude v{_VERSION}",
444
+ )
445
+
432
446
  subparsers = parser.add_subparsers(dest="command", help="命令")
433
447
 
434
448
  # start 命令