@ywfe/openclaw-plugin-caryscloud-im 0.0.12 → 0.0.13

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.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/install.sh +51 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -47,9 +47,9 @@ chmod +x install.sh
47
47
 
48
48
  安装脚本会自动:
49
49
  - ✅ 检查 OpenClaw CLI 是否已安装
50
- - ✅ 卸载旧版本插件(如果存在)
51
- - ✅ 清理旧的频道配置
50
+ - ✅ 清理旧的插件配置和目录
52
51
  - ✅ 安装最新版本插件
52
+ - ✅ 添加插件到允许列表
53
53
  - ✅ 启动交互式配置向导
54
54
 
55
55
  #### 方式 2:手动安装
package/install.sh CHANGED
@@ -31,6 +31,7 @@ print_step() {
31
31
 
32
32
  PLUGIN_NAME="@ywfe/openclaw-plugin-caryscloud-im"
33
33
  PLUGIN_ID="openclaw-plugin-caryscloud-im"
34
+ OPENCLAW_CONFIG_FILE="$HOME/.openclaw/openclaw.json"
34
35
 
35
36
  echo ""
36
37
  print_info "OpenClaw CarysCloud IM Plugin 一键安装"
@@ -45,33 +46,43 @@ fi
45
46
  print_success "找到 OpenClaw CLI"
46
47
  echo ""
47
48
 
48
- print_step "检查插件是否已安装..."
49
- if openclaw plugins list 2>/dev/null | grep -q "$PLUGIN_ID"; then
50
- print_warning "检测到已安装的插件,正在卸载..."
51
- openclaw plugins uninstall "$PLUGIN_ID" || true
52
-
53
- OPENCLAW_CONFIG_FILE="$HOME/.openclaw/openclaw.json"
54
- if [ -f "$OPENCLAW_CONFIG_FILE" ]; then
55
- print_step "清理旧的频道配置..."
56
- node -e "
49
+ print_step "清理无效的插件配置..."
50
+ if [ -f "$OPENCLAW_CONFIG_FILE" ]; then
51
+ node -e "
57
52
  const fs = require('fs');
58
53
  const configFile = '$OPENCLAW_CONFIG_FILE';
59
54
  try {
60
55
  const content = fs.readFileSync(configFile, 'utf8');
61
56
  const config = JSON.parse(content);
57
+
58
+ // 清理无效的 plugins.allow
59
+ if (config.plugins && config.plugins.allow) {
60
+ const idx = config.plugins.allow.indexOf('$PLUGIN_ID');
61
+ if (idx > -1) {
62
+ config.plugins.allow.splice(idx, 1);
63
+ console.log('已从 plugins.allow 中移除 $PLUGIN_ID');
64
+ }
65
+ }
66
+
67
+ // 清理频道配置
62
68
  if (config.channels && config.channels['caryscloud-im']) {
63
69
  delete config.channels['caryscloud-im'];
64
- fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
65
70
  console.log('已删除旧的 caryscloud-im 频道配置');
66
71
  }
72
+
73
+ fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
74
+ console.log('配置清理完成');
67
75
  } catch (e) {
68
- console.error('清理配置失败:', e.message);
76
+ console.error('配置清理失败:', e.message);
69
77
  }
70
78
  "
71
- fi
72
-
73
- print_success "旧版本已卸载"
74
- echo ""
79
+ fi
80
+
81
+ PLUGIN_DIR="$HOME/.openclaw/extensions/openclaw-plugin-caryscloud-im"
82
+ if [ -d "$PLUGIN_DIR" ]; then
83
+ print_step "删除旧的插件目录..."
84
+ rm -rf "$PLUGIN_DIR"
85
+ print_success "已删除旧的插件目录"
75
86
  fi
76
87
 
77
88
  print_step "安装插件: $PLUGIN_NAME"
@@ -84,11 +95,35 @@ if [ $INSTALL_EXIT_CODE -eq 0 ]; then
84
95
  print_success "插件安装成功!"
85
96
  echo ""
86
97
 
98
+ print_step "配置 OpenClaw 允许加载插件..."
99
+ node -e "
100
+ const fs = require('fs');
101
+ const configFile = '$HOME/.openclaw/openclaw.json';
102
+ try {
103
+ const content = fs.readFileSync(configFile, 'utf8');
104
+ const config = JSON.parse(content);
105
+ if (!config.plugins) config.plugins = {};
106
+ if (!config.plugins.allow) config.plugins.allow = [];
107
+ if (!config.plugins.allow.includes('$PLUGIN_ID')) {
108
+ config.plugins.allow.push('$PLUGIN_ID');
109
+ }
110
+ fs.writeFileSync(configFile, JSON.stringify(config, null, 2));
111
+ console.log('已添加插件到允许列表');
112
+ } catch (e) {
113
+ console.error('配置失败:', e.message);
114
+ }
115
+ "
116
+ echo ""
117
+
87
118
  print_step "启动频道配置向导..."
88
119
  echo ""
89
120
  sleep 1
90
121
 
91
- openclaw channels add
122
+ if [ -t 0 ]; then
123
+ openclaw channels add
124
+ else
125
+ openclaw channels add < /dev/tty
126
+ fi
92
127
 
93
128
  echo ""
94
129
  print_success "=========================================="
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ywfe/openclaw-plugin-caryscloud-im",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "CarysCloud IM channel plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",