soulsync 1.0.0 → 1.0.4

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.
@@ -0,0 +1,199 @@
1
+ # SoulSync OpenClaw 插件故障排除指南
2
+
3
+ ## 常见问题及解决方案
4
+
5
+ ### 1. 安装时提示 "No module named 'src'"
6
+
7
+ **原因**: Python 路径问题
8
+
9
+ **解决**:
10
+ ```bash
11
+ # 方法1: 在插件目录运行
12
+ cd /path/to/openclaw/plugins/soulsync
13
+ export PYTHONPATH="${PYTHONPATH}:$(pwd)/src"
14
+ python3 src/main.py
15
+
16
+ # 方法2: 使用修复版 main_fixed.py
17
+ python3 src/main_fixed.py
18
+ ```
19
+
20
+ ### 2. OpenClaw 无法识别插件
21
+
22
+ **原因**: 插件目录结构不正确
23
+
24
+ **解决**:
25
+ ```bash
26
+ # 检查插件目录结构
27
+ ls -la ~/.openclaw/plugins/soulsync/
28
+
29
+ # 应该包含:
30
+ # - openclaw.plugin.json
31
+ # - src/
32
+ # - config.json
33
+
34
+ # 如果结构不对,重新复制
35
+ cp -r /path/to/soulsync/plugins/openclaw ~/.openclaw/plugins/soulsync
36
+ ```
37
+
38
+ ### 3. watchdog 安装失败
39
+
40
+ **原因**: 缺少系统依赖
41
+
42
+ **解决**:
43
+ ```bash
44
+ # Ubuntu/Debian
45
+ sudo apt-get update
46
+ sudo apt-get install -y python3-dev python3-pip
47
+
48
+ # 然后重新安装
49
+ pip3 install watchdog --user
50
+ ```
51
+
52
+ ### 4. 权限错误 Permission Denied
53
+
54
+ **解决**:
55
+ ```bash
56
+ # 修复权限
57
+ chmod -R 755 ~/.openclaw/plugins/soulsync
58
+
59
+ # 确保当前用户有写入权限
60
+ sudo chown -R $(whoami):$(whoami) ~/.openclaw/plugins/soulsync
61
+ ```
62
+
63
+ ### 5. WebSocket 连接失败
64
+
65
+ **原因**: 服务器地址配置错误或网络问题
66
+
67
+ **解决**:
68
+ ```bash
69
+ # 检查 config.json
70
+ cat ~/.openclaw/plugins/soulsync/config.json
71
+
72
+ # 测试服务器连通性
73
+ curl http://your-server:3000/health
74
+
75
+ # 检查防火墙
76
+ sudo ufw status
77
+ ```
78
+
79
+ ### 6. 文件监听不工作 (inotify 限制)
80
+
81
+ **解决**:
82
+ ```bash
83
+ # 增加 inotify 限制
84
+ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
85
+ sudo sysctl -p
86
+
87
+ # 验证
88
+ cat /proc/sys/fs/inotify/max_user_watches
89
+ ```
90
+
91
+ ### 7. Python 版本过低
92
+
93
+ **检查**:
94
+ ```bash
95
+ python3 --version # 需要 >= 3.7
96
+
97
+ # 如果版本过低,安装新版本
98
+ sudo apt-get install python3.8 python3.8-pip
99
+ ```
100
+
101
+ ## 调试步骤
102
+
103
+ ### Step 1: 运行诊断脚本
104
+ ```bash
105
+ cd ~/.openclaw/plugins/soulsync
106
+ python3 debug.py
107
+ ```
108
+
109
+ ### Step 2: 检查日志
110
+ ```bash
111
+ # 如果有日志文件
112
+ tail -f ~/.openclaw/logs/soulsync.log
113
+
114
+ # 或者直接运行看输出
115
+ python3 src/main_fixed.py 2>&1 | tee debug.log
116
+ ```
117
+
118
+ ### Step 3: 手动测试组件
119
+ ```bash
120
+ # 测试客户端
121
+ python3 -c "from src.client import OpenClawClient; print('Client OK')"
122
+
123
+ # 测试监听器
124
+ python3 -c "from src.watcher import OpenClawMultiWatcher; print('Watcher OK')"
125
+ ```
126
+
127
+ ## OpenClaw 特定问题
128
+
129
+ ### OpenClaw 插件加载失败
130
+
131
+ 1. **检查插件格式**:
132
+ ```bash
133
+ cat ~/.openclaw/plugins/soulsync/openclaw.plugin.json
134
+ ```
135
+
136
+ 2. **验证 JSON 格式**:
137
+ ```bash
138
+ python3 -m json.tool ~/.openclaw/plugins/soulsync/openclaw.plugin.json
139
+ ```
140
+
141
+ 3. **重启 OpenClaw**:
142
+ ```bash
143
+ # 找到 OpenClaw 进程并重启
144
+ pkill -f openclaw
145
+ # 然后重新启动 OpenClaw
146
+ ```
147
+
148
+ ### 插件版本不匹配
149
+
150
+ 检查 OpenClaw 版本:
151
+ ```bash
152
+ openclaw --version
153
+ ```
154
+
155
+ 查看插件兼容性:
156
+ ```bash
157
+ cat ~/.openclaw/plugins/soulsync/openclaw.plugin.json | grep version
158
+ ```
159
+
160
+ ## 获取帮助
161
+
162
+ 如果以上方法都无法解决问题:
163
+
164
+ 1. 运行诊断脚本并保存输出:
165
+ ```bash
166
+ python3 debug.py > diagnostic.log 2>&1
167
+ ```
168
+
169
+ 2. 收集以下信息:
170
+ - OpenClaw 版本
171
+ - Python 版本: `python3 --version`
172
+ - 操作系统: `uname -a`
173
+ - 插件目录结构: `tree ~/.openclaw/plugins/soulsync`
174
+ - 错误日志
175
+
176
+ 3. 提交 Issue 到 GitHub:
177
+ https://github.com/alanliuc-a11y/soulsync/issues
178
+
179
+ ## 快速修复命令
180
+
181
+ 一键修复常见问题:
182
+ ```bash
183
+ cd ~/.openclaw/plugins/soulsync
184
+
185
+ # 修复权限
186
+ chmod -R 755 .
187
+
188
+ # 安装依赖
189
+ pip3 install -r requirements.txt --user
190
+
191
+ # 创建工作目录
192
+ mkdir -p workspace/memory
193
+
194
+ # 运行诊断
195
+ python3 debug.py
196
+
197
+ # 启动插件
198
+ python3 src/main_fixed.py
199
+ ```
@@ -1,7 +1,7 @@
1
1
  {
2
- "cloud_url": "http://localhost:3000",
3
- "email": "",
4
- "password": "",
2
+ "cloud_url": "http://your-server:3000",
3
+ "email": "your-email@example.com",
4
+ "password": "your-password",
5
5
  "workspace": "./workspace",
6
6
  "memory_file": "MEMORY.md",
7
7
  "watch_files": [
package/debug.py ADDED
@@ -0,0 +1,221 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ SoulSync OpenClaw 插件调试工具
4
+ 用于检查安装环境和依赖
5
+ """
6
+
7
+ import sys
8
+ import os
9
+ import json
10
+ import importlib.util
11
+
12
+ def check_python_version():
13
+ """检查 Python 版本"""
14
+ print("=" * 50)
15
+ print("Python 版本检查")
16
+ print("=" * 50)
17
+ version = sys.version_info
18
+ print(f"Python 版本: {version.major}.{version.minor}.{version.micro}")
19
+ if version.major < 3 or (version.major == 3 and version.minor < 7):
20
+ print("❌ 需要 Python 3.7 或更高版本")
21
+ return False
22
+ print("✅ Python 版本符合要求")
23
+ return True
24
+
25
+ def check_dependencies():
26
+ """检查依赖包"""
27
+ print("\n" + "=" * 50)
28
+ print("依赖包检查")
29
+ print("=" * 50)
30
+
31
+ required = {
32
+ 'requests': 'requests>=2.28.0',
33
+ 'watchdog': 'watchdog>=3.0.0',
34
+ 'websocket': 'websocket-client>=1.6.0'
35
+ }
36
+
37
+ all_ok = True
38
+ for module, package in required.items():
39
+ try:
40
+ if module == 'websocket':
41
+ importlib.import_module('websocket')
42
+ else:
43
+ importlib.import_module(module)
44
+ print(f"✅ {package}")
45
+ except ImportError:
46
+ print(f"❌ {package} - 未安装")
47
+ all_ok = False
48
+
49
+ return all_ok
50
+
51
+ def check_file_structure():
52
+ """检查文件结构"""
53
+ print("\n" + "=" * 50)
54
+ print("文件结构检查")
55
+ print("=" * 50)
56
+
57
+ plugin_dir = os.path.dirname(os.path.abspath(__file__))
58
+ print(f"插件目录: {plugin_dir}")
59
+
60
+ required_files = [
61
+ 'openclaw.plugin.json',
62
+ 'config.json',
63
+ 'requirements.txt',
64
+ 'src/main.py',
65
+ 'src/__init__.py',
66
+ 'src/client.py',
67
+ 'src/watcher.py',
68
+ 'src/sync.py',
69
+ ]
70
+
71
+ all_ok = True
72
+ for file in required_files:
73
+ path = os.path.join(plugin_dir, file)
74
+ exists = os.path.exists(path)
75
+ status = "✅" if exists else "❌"
76
+ print(f"{status} {file}")
77
+ if not exists:
78
+ all_ok = False
79
+
80
+ return all_ok
81
+
82
+ def check_config():
83
+ """检查配置文件"""
84
+ print("\n" + "=" * 50)
85
+ print("配置文件检查")
86
+ print("=" * 50)
87
+
88
+ config_path = os.path.join(os.path.dirname(__file__), 'config.json')
89
+
90
+ if not os.path.exists(config_path):
91
+ print("❌ config.json 不存在")
92
+ return False
93
+
94
+ try:
95
+ with open(config_path, 'r', encoding='utf-8') as f:
96
+ config = json.load(f)
97
+
98
+ print("✅ config.json 格式正确")
99
+
100
+ # 检查必要字段
101
+ required_fields = ['cloud_url', 'email', 'password', 'workspace']
102
+ for field in required_fields:
103
+ value = config.get(field)
104
+ if value:
105
+ if field in ['email', 'password']:
106
+ print(f"✅ {field}: {'*' * len(str(value))}")
107
+ else:
108
+ print(f"✅ {field}: {value}")
109
+ else:
110
+ print(f"⚠️ {field}: 未配置")
111
+
112
+ return True
113
+ except json.JSONDecodeError as e:
114
+ print(f"❌ config.json 格式错误: {e}")
115
+ return False
116
+ except Exception as e:
117
+ print(f"❌ 读取 config.json 失败: {e}")
118
+ return False
119
+
120
+ def check_workspace():
121
+ """检查工作目录"""
122
+ print("\n" + "=" * 50)
123
+ print("工作目录检查")
124
+ print("=" * 50)
125
+
126
+ plugin_dir = os.path.dirname(os.path.abspath(__file__))
127
+ workspace = os.path.join(plugin_dir, 'workspace')
128
+
129
+ if os.path.exists(workspace):
130
+ print(f"✅ workspace 目录存在: {workspace}")
131
+
132
+ # 检查是否可写
133
+ if os.access(workspace, os.W_OK):
134
+ print("✅ workspace 目录可写")
135
+ else:
136
+ print("❌ workspace 目录不可写")
137
+ return False
138
+ else:
139
+ print(f"⚠️ workspace 目录不存在: {workspace}")
140
+ try:
141
+ os.makedirs(workspace, exist_ok=True)
142
+ print("✅ 已创建 workspace 目录")
143
+ except Exception as e:
144
+ print(f"❌ 创建 workspace 目录失败: {e}")
145
+ return False
146
+
147
+ return True
148
+
149
+ def test_import():
150
+ """测试导入主模块"""
151
+ print("\n" + "=" * 50)
152
+ print("模块导入测试")
153
+ print("=" * 50)
154
+
155
+ plugin_dir = os.path.dirname(os.path.abspath(__file__))
156
+ src_dir = os.path.join(plugin_dir, 'src')
157
+
158
+ if src_dir not in sys.path:
159
+ sys.path.insert(0, src_dir)
160
+
161
+ try:
162
+ from main import SoulSyncPlugin
163
+ print("✅ 成功导入 SoulSyncPlugin")
164
+ return True
165
+ except Exception as e:
166
+ print(f"❌ 导入失败: {e}")
167
+ import traceback
168
+ traceback.print_exc()
169
+ return False
170
+
171
+ def main():
172
+ """主函数"""
173
+ print("\n" + "=" * 50)
174
+ print("SoulSync OpenClaw 插件调试工具")
175
+ print("=" * 50 + "\n")
176
+
177
+ checks = [
178
+ ("Python 版本", check_python_version),
179
+ ("依赖包", check_dependencies),
180
+ ("文件结构", check_file_structure),
181
+ ("配置文件", check_config),
182
+ ("工作目录", check_workspace),
183
+ ("模块导入", test_import),
184
+ ]
185
+
186
+ results = []
187
+ for name, check_func in checks:
188
+ try:
189
+ result = check_func()
190
+ results.append((name, result))
191
+ except Exception as e:
192
+ print(f"\n❌ {name} 检查出错: {e}")
193
+ results.append((name, False))
194
+
195
+ # 总结
196
+ print("\n" + "=" * 50)
197
+ print("检查结果总结")
198
+ print("=" * 50)
199
+
200
+ for name, result in results:
201
+ status = "✅ 通过" if result else "❌ 失败"
202
+ print(f"{status} - {name}")
203
+
204
+ all_passed = all(result for _, result in results)
205
+
206
+ print("\n" + "=" * 50)
207
+ if all_passed:
208
+ print("🎉 所有检查通过!插件应该可以正常运行。")
209
+ print("\n运行命令: python3 src/main.py")
210
+ else:
211
+ print("⚠️ 部分检查未通过,请根据上方提示修复问题。")
212
+ print("\n常见问题解决:")
213
+ print("1. 安装依赖: pip3 install -r requirements.txt")
214
+ print("2. 修复权限: chmod -R 755 .")
215
+ print("3. 创建目录: mkdir -p workspace/memory")
216
+ print("=" * 50)
217
+
218
+ return 0 if all_passed else 1
219
+
220
+ if __name__ == '__main__':
221
+ sys.exit(main())
package/index.js ADDED
@@ -0,0 +1,54 @@
1
+ const { spawn } = require('child_process');
2
+ const path = require('path');
3
+
4
+ // 函数形式导出(推荐)
5
+ module.exports = function register(api) {
6
+ console.log('[SoulSync] Registering plugin...');
7
+
8
+ // 注册CLI命令:启动 SoulSync
9
+ api.registerCli(
10
+ ({ program }) => {
11
+ program
12
+ .command('soulsync:start')
13
+ .description('启动 SoulSync 同步服务')
14
+ .action(() => {
15
+ const pluginDir = path.dirname(__filename);
16
+ const pythonScript = path.join(pluginDir, 'src', 'main.py');
17
+ const pythonPath = process.env.PYTHON_PATH || 'python3';
18
+
19
+ console.log('[SoulSync] Starting Python service...');
20
+
21
+ const pythonProcess = spawn(pythonPath, [pythonScript], {
22
+ cwd: pluginDir,
23
+ env: {
24
+ ...process.env,
25
+ OPENCLAW_PLUGIN: 'true',
26
+ PLUGIN_DIR: pluginDir
27
+ },
28
+ stdio: 'inherit'
29
+ });
30
+
31
+ pythonProcess.on('close', (code) => {
32
+ console.log(`[SoulSync] Python process exited with code ${code}`);
33
+ });
34
+ });
35
+ },
36
+ { commands: ['soulsync:start'] }
37
+ );
38
+
39
+ // 注册CLI命令:停止 SoulSync
40
+ api.registerCli(
41
+ ({ program }) => {
42
+ program
43
+ .command('soulsync:stop')
44
+ .description('停止 SoulSync 同步服务')
45
+ .action(() => {
46
+ console.log('[SoulSync] Stop command received');
47
+ // 这里可以实现停止逻辑
48
+ });
49
+ },
50
+ { commands: ['soulsync:stop'] }
51
+ );
52
+
53
+ console.log('[SoulSync] Plugin registered successfully');
54
+ };
@@ -0,0 +1,18 @@
1
+ {
2
+ "id": "soulsync",
3
+ "name": "SoulSync",
4
+ "configSchema": {
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "cloud_url": { "type": "string" },
9
+ "email": { "type": "string" },
10
+ "password": { "type": "string" }
11
+ }
12
+ },
13
+ "uiHints": {
14
+ "cloud_url": { "label": "服务器地址", "placeholder": "http://localhost:3000" },
15
+ "email": { "label": "邮箱" },
16
+ "password": { "label": "密码", "sensitive": true }
17
+ }
18
+ }
package/package.json CHANGED
@@ -1,29 +1,15 @@
1
1
  {
2
2
  "name": "soulsync",
3
- "version": "1.0.0",
3
+ "version": "1.0.4",
4
4
  "description": "SoulSync plugin for OpenClaw - cross-bot memory synchronization",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
6
  "repository": {
10
7
  "type": "git",
11
- "url": "git+https://github.com/alanliuc-a11y/soulsync.git"
12
- },
13
- "keywords": [
14
- "openclaw",
15
- "openclaw-plugin",
16
- "bot-memory",
17
- "bot-soulsync"
18
- ],
19
- "author": "Alan Liu",
20
- "license": "MIT",
21
- "bugs": {
22
- "url": "https://github.com/alanliuc-a11y/soulsync/issues"
8
+ "url": "https://github.com/alanliuc-a11y/soulsync"
23
9
  },
24
- "homepage": "https://github.com/alanliuc-a11y/soulsync#readme",
25
- "openclaw": {
26
- "plugin": true,
27
- "type": "python"
28
- }
10
+ "openclaw": {
11
+ "extensions": [
12
+ "./index.js"
13
+ ]
14
+ }
29
15
  }
package/setup.sh ADDED
@@ -0,0 +1,91 @@
1
+ #!/bin/bash
2
+ # SoulSync OpenClaw 插件 Linux 安装脚本
3
+
4
+ set -e # 遇到错误立即退出
5
+
6
+ echo "======================================"
7
+ echo "SoulSync OpenClaw 插件安装脚本"
8
+ echo "======================================"
9
+ echo ""
10
+
11
+ # 获取脚本所在目录
12
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13
+ cd "$SCRIPT_DIR"
14
+
15
+ echo "插件目录: $SCRIPT_DIR"
16
+ echo ""
17
+
18
+ # 检查 Python
19
+ if ! command -v python3 &> /dev/null; then
20
+ echo "❌ 未找到 Python3"
21
+ echo "请安装 Python3: sudo apt-get install python3"
22
+ exit 1
23
+ fi
24
+
25
+ echo "✅ Python3 已安装: $(python3 --version)"
26
+
27
+ # 检查 pip
28
+ if ! command -v pip3 &> /dev/null; then
29
+ echo "❌ 未找到 pip3"
30
+ echo "请安装 pip3: sudo apt-get install python3-pip"
31
+ exit 1
32
+ fi
33
+
34
+ echo "✅ pip3 已安装"
35
+
36
+ # 安装依赖
37
+ echo ""
38
+ echo "正在安装 Python 依赖..."
39
+ pip3 install -r requirements.txt --user
40
+
41
+ echo "✅ 依赖安装完成"
42
+
43
+ # 创建必要的目录
44
+ echo ""
45
+ echo "创建工作目录..."
46
+ mkdir -p workspace/memory
47
+ echo "✅ 工作目录创建完成"
48
+
49
+ # 检查配置文件
50
+ echo ""
51
+ if [ ! -f "config.json" ]; then
52
+ echo "⚠️ config.json 不存在"
53
+ if [ -f "config.json.example" ]; then
54
+ cp config.json.example config.json
55
+ echo "✅ 已从模板创建 config.json"
56
+ echo "⚠️ 请编辑 config.json 配置你的账号信息"
57
+ else
58
+ echo "❌ 未找到配置文件模板"
59
+ exit 1
60
+ fi
61
+ else
62
+ echo "✅ config.json 已存在"
63
+ fi
64
+
65
+ # 检查权限
66
+ echo ""
67
+ echo "检查文件权限..."
68
+ chmod -R 755 "$SCRIPT_DIR"
69
+ chmod +x debug.py
70
+ if [ -f "setup.sh" ]; then
71
+ chmod +x setup.sh
72
+ fi
73
+ echo "✅ 权限设置完成"
74
+
75
+ # 运行调试检查
76
+ echo ""
77
+ echo "运行安装检查..."
78
+ python3 debug.py
79
+
80
+ echo ""
81
+ echo "======================================"
82
+ echo "安装完成!"
83
+ echo "======================================"
84
+ echo ""
85
+ echo "使用方法:"
86
+ echo "1. 编辑 config.json 配置你的账号"
87
+ echo "2. 运行插件: python3 src/main.py"
88
+ echo "3. 或使用修复版: python3 src/main_fixed.py"
89
+ echo ""
90
+ echo "调试命令: python3 debug.py"
91
+ echo ""
@@ -0,0 +1 @@
1
+ # SoulSync OpenClaw Plugin