@aiyiran/myclaw 1.0.238 → 1.0.239

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": "@aiyiran/myclaw",
3
- "version": "1.0.238",
3
+ "version": "1.0.239",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import sys
3
3
  import argparse
4
+ import platform
4
5
  from datetime import datetime, timezone, timedelta
5
6
  import json
6
7
  import time
@@ -8,6 +9,12 @@ from watchdog.observers import Observer
8
9
  from watchdog.events import FileSystemEventHandler
9
10
  from qiniu import Auth, put_file_v2, CdnManager
10
11
 
12
+ # 跨平台获取 openclaw 目录
13
+ def get_openclaw_path():
14
+ if platform.system() == 'Windows' or os.path.exists('/root/.openclaw'):
15
+ return '/root/.openclaw'
16
+ return os.path.expanduser('~/.openclaw')
17
+
11
18
  claw = os.environ.get("CLAW_NAME", "claw")
12
19
 
13
20
  BASE_URL = f"https://cdn.yiranlaoshi.com/{claw}"
@@ -71,7 +78,8 @@ def get_type(file_path):
71
78
 
72
79
 
73
80
  def init_config(workspace_id, file_path, method="add"):
74
- file = f"/root/.openclaw/{workspace_id}/.myclaw/__MY_ARTIFACTS__.json"
81
+ base_path = get_openclaw_path()
82
+ file = f"{base_path}/{workspace_id}/.myclaw/__MY_ARTIFACTS__.json"
75
83
 
76
84
  # 确保目录存在
77
85
  os.makedirs(os.path.dirname(file), exist_ok=True)
@@ -197,7 +205,8 @@ def file_gen(path, method):
197
205
 
198
206
  def sync_all(workspace_id):
199
207
  """全量同步指定 workspace 下所有文件"""
200
- workspace_path = f"/root/.openclaw/{workspace_id}"
208
+ base_path = get_openclaw_path()
209
+ workspace_path = f"{base_path}/{workspace_id}"
201
210
 
202
211
  if not os.path.exists(workspace_path):
203
212
  print(f"[错误] workspace 不存在: {workspace_path}")
@@ -264,7 +273,8 @@ if __name__ == "__main__":
264
273
  parser.add_argument("--agent", help="启动前先全量同步指定 workspace")
265
274
  args = parser.parse_args()
266
275
 
267
- path = "/root/.openclaw"
276
+ base_path = get_openclaw_path()
277
+ path = base_path
268
278
 
269
279
  # 如果指定了 --agent,先全量同步
270
280
  if args.agent: