@aiyiran/myclaw 1.0.157 → 1.0.160

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,7 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebSearch"
5
+ ]
6
+ }
7
+ }
package/index.js CHANGED
@@ -361,6 +361,11 @@ function runWsl2() {
361
361
  wsl2.run();
362
362
  }
363
363
 
364
+ function runRestrict() {
365
+ const restrict = require('./restrict');
366
+ restrict.run();
367
+ }
368
+
364
369
  async function runLaunch() {
365
370
  const launch = require('./launch');
366
371
  await launch.run();
@@ -1127,6 +1132,7 @@ function showHelp() {
1127
1132
  console.log(' open 打开浏览器控制台(自动带 token)');
1128
1133
  console.log(' fix 兜底修复(自动补装 WSL + Chrome,仅限 Windows)');
1129
1134
  console.log(' wsl2 WSL2 一键安装/修复 (仅限 Windows, 可选: --cli)');
1135
+ console.log(' restrict WSL2 权限封锁 (禁止自动挂载 Windows 盘符)');
1130
1136
  console.log(' bat 在桌面生成一键启动脚本 (仅限 Windows)');
1131
1137
  console.log(' list 查看注入资源管理列表(智能体/技能/配置)');
1132
1138
  console.log(' pull 从 ~/.openclaw 拉取最新资源到源目录(开发用)');
@@ -1137,6 +1143,7 @@ function showHelp() {
1137
1143
  console.log(' image 注入图像生成模型配置 (基于 vveai)');
1138
1144
  console.log(' token 设置 Gateway Token 为 aiyiran');
1139
1145
  console.log(' websearch 注入 Tavily 搜索插件配置');
1146
+ console.log(' soul 替换默认 workspace 的 SOUL.md 提示词');
1140
1147
  console.log(' restart 重启 OpenClaw Gateway');
1141
1148
  console.log(' help 显示帮助信息');
1142
1149
  console.log('');
@@ -1201,6 +1208,8 @@ if (!command) {
1201
1208
  runFix();
1202
1209
  } else if (command === 'wsl2') {
1203
1210
  runWsl2();
1211
+ } else if (command === 'restrict') {
1212
+ runRestrict();
1204
1213
  } else if (command === 'launch') {
1205
1214
  runLaunch();
1206
1215
  } else if (command === 'bat') {
@@ -1249,6 +1258,12 @@ if (!command) {
1249
1258
  console.log('🔄 正在重启 Gateway 使配置生效...');
1250
1259
  console.log('');
1251
1260
  runRestart();
1261
+ } else if (command === 'soul') {
1262
+ const soul = require('./inject-workspaceAndSoul');
1263
+ soul.run();
1264
+ console.log('🔄 正在重启 Gateway 使配置生效...');
1265
+ console.log('');
1266
+ runRestart();
1252
1267
  } else {
1253
1268
  console.error('[' + colors.red + '错误' + colors.nc + '] 未知命令: ' + command);
1254
1269
  showHelp();
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * inject-workspaceAndSoul.js
5
+ *
6
+ * 替换 ~/.openclaw/workspace/SOUL.md 的内容为面向小学生的学习伙伴提示词。
7
+ *
8
+ * 入口: myclaw soul
9
+ */
10
+
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+ const os = require('os');
14
+
15
+ const SOUL_CONTENT = `# 角色定义
16
+
17
+ 你是一个面向中国小学生的 AI 学习伙伴。
18
+
19
+ 你的目标不是替学生完成任务,而是帮助他们理解问题、建立思考能力,并在学习中获得成就感。
20
+
21
+ ---
22
+
23
+ # 核心性格
24
+
25
+ - 友善、有耐心、愿意鼓励学生
26
+ - 用简单、清晰、生活化的语言表达
27
+ - 擅长把复杂问题讲简单
28
+ - 不炫技,不使用复杂术语
29
+ - 更像一个会讲解的同学,而不是老师
30
+
31
+ ---
32
+
33
+ # 表达要求
34
+
35
+ - 优先使用短句,避免长段落
36
+ - 一次回答只讲一个重点
37
+ - 用词贴近小学生理解水平
38
+ - 尽量用举例、类比来解释
39
+ - 不使用复杂技术术语(除非必须,并且要解释)
40
+
41
+ ---
42
+
43
+ # 内容长度控制(非常重要)
44
+
45
+ 根据不同任务,控制输出长度:
46
+
47
+ ## 1)日常问答 / 提问解答
48
+ - 必须简短(优先 3~6 句)
49
+ - 只回答关键点,不展开过多内容
50
+
51
+ ## 2)教学引导 / 思路讲解
52
+ - 分步骤说明(最多 3 步)
53
+ - 每一步尽量一句话
54
+
55
+ ## 3)生成作品 / 内容(如代码、网页、作文)
56
+ - 可以详细,但结构必须清晰
57
+ - 必须加简单说明(让学生看得懂)
58
+
59
+ ---
60
+
61
+ # 教学原则(核心)
62
+
63
+ 你必须遵守以下教学原则:
64
+
65
+ ## ❌ 不直接给答案(除非明确要求)
66
+ 优先:
67
+ - 引导学生思考
68
+ - 提出提示(hint)
69
+ - 分解问题
70
+
71
+ ## ✅ 鼓励思考
72
+ 可以使用:
73
+ - "你可以先想一想……"
74
+ - "我们一步一步来"
75
+ - "你觉得这里应该怎么做?"
76
+
77
+ ## ✅ 正向反馈
78
+ - 认可学生的尝试
79
+ - 即使错误,也要鼓励
80
+
81
+ 例如:
82
+ - "这个思路很好,我们再优化一下"
83
+ - "已经很接近了!"
84
+
85
+ ---
86
+
87
+ # 错误处理方式
88
+
89
+ 当学生出错时:
90
+
91
+ 1. 不直接否定
92
+ 2. 指出问题所在(简单说明)
93
+ 3. 给一个小提示,而不是完整答案
94
+
95
+ ---
96
+
97
+ # 禁止行为
98
+
99
+ - ❌ 使用复杂专业术语堆砌
100
+ - ❌ 长篇大论解释
101
+ - ❌ 一次讲多个知识点
102
+ - ❌ 直接给出完整答案(除非用户明确要求)
103
+ - ❌ 打击或否定学生
104
+
105
+ ---
106
+
107
+ # 风格示例
108
+
109
+ ❌ 不推荐:
110
+ "该问题涉及哈希映射与时间复杂度优化……"
111
+
112
+ ✅ 推荐:
113
+ "我们可以用一个'小本子'来记住出现过的数字,这样查起来会更快~"
114
+
115
+ ---
116
+
117
+ # 目标
118
+
119
+ 你的最终目标是:
120
+
121
+ - 让学生听得懂
122
+ - 让学生愿意继续学
123
+ - 让学生自己能做出来
124
+ `;
125
+
126
+ function run() {
127
+ const soulPath = path.join(os.homedir(), '.openclaw', 'workspace', 'SOUL.md');
128
+
129
+ if (!fs.existsSync(soulPath)) {
130
+ console.log('❌ 未找到: ' + soulPath);
131
+ console.log(' 请确认 workspace 目录存在');
132
+ return;
133
+ }
134
+
135
+ fs.writeFileSync(soulPath, SOUL_CONTENT, 'utf8');
136
+ console.log('✅ SOUL.md 已更新: ' + soulPath);
137
+ }
138
+
139
+ module.exports = { run };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.157",
3
+ "version": "1.0.160",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -61,6 +61,11 @@
61
61
  "module": "./inject-minimax",
62
62
  "strategy": "auto",
63
63
  "description": "MiniMax 模型注入"
64
+ },
65
+ {
66
+ "module": "./inject-workspaceAndSoul",
67
+ "strategy": "on",
68
+ "description": "替换默认 workspace 的 SOUL.md 提示词"
64
69
  }
65
70
  ]
66
71
  }
package/restrict.js ADDED
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * ============================================================================
5
+ * MyClaw WSL2 权限封锁
6
+ * ============================================================================
7
+ *
8
+ * 功能:逐步封锁 WSL2 对 Windows 文件系统的访问权限
9
+ *
10
+ * 使用方法:
11
+ * myclaw restrict
12
+ * ============================================================================
13
+ */
14
+
15
+ const { execSync } = require('child_process');
16
+ const os = require('os');
17
+ const path = require('path');
18
+
19
+ // ============================================================================
20
+ // 配置
21
+ // ============================================================================
22
+
23
+ const isWindows = os.platform() === 'win32';
24
+
25
+ const C = isWindows
26
+ ? { r: '', g: '', y: '', b: '', nc: '' }
27
+ : { r: '\x1b[31m', g: '\x1b[32m', y: '\x1b[33m', b: '\x1b[34m', nc: '\x1b[0m' };
28
+
29
+ const SCRIPT_PATH = path.join(__dirname, 'scripts', 'restrict-wsl-access.sh');
30
+
31
+ // ============================================================================
32
+ // 工具函数
33
+ // ============================================================================
34
+
35
+ function printStep(msg) {
36
+ console.log(C.g + '===>' + C.nc + ' ' + msg);
37
+ }
38
+
39
+ function printInfo(msg) {
40
+ console.log(C.b + '[信息]' + C.nc + ' ' + msg);
41
+ }
42
+
43
+ function printSuccess(msg) {
44
+ console.log(C.g + '[成功]' + C.nc + ' ' + msg);
45
+ }
46
+
47
+ function printWarning(msg) {
48
+ console.log(C.y + '[警告]' + C.nc + ' ' + msg);
49
+ }
50
+
51
+ function printError(msg) {
52
+ console.error(C.r + '[错误]' + C.nc + ' ' + msg);
53
+ }
54
+
55
+ // 检查是否在 WSL 环境中
56
+ function isWSL() {
57
+ try {
58
+ const version = require('fs').readFileSync('/proc/version', 'utf8');
59
+ return /microsoft|wsl/i.test(version);
60
+ } catch {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ // 在 WSL 中执行脚本
66
+ function runInWSL(scriptPath) {
67
+ try {
68
+ const cmd = `bash "${scriptPath}"`;
69
+ execSync(cmd, { stdio: 'inherit' });
70
+ return true;
71
+ } catch (err) {
72
+ printError('执行失败: ' + err.message);
73
+ return false;
74
+ }
75
+ }
76
+
77
+ // ============================================================================
78
+ // 主函数
79
+ // ============================================================================
80
+
81
+ function run() {
82
+ console.log('');
83
+ console.log('========================================');
84
+ console.log(' MyClaw WSL2 权限封锁');
85
+ console.log('========================================');
86
+ console.log('');
87
+
88
+ // 如果在 Windows 上,提示需要在 WSL 中运行
89
+ if (isWindows) {
90
+ printWarning('此命令需要在 WSL2 环境中运行');
91
+ console.log('');
92
+ console.log('请按以下步骤操作:');
93
+ console.log(' 1. 打开 WSL2 终端(在 Windows Terminal 中选择 OpenClaw)');
94
+ console.log(' 2. 在 WSL2 终端中运行: ' + C.y + 'myclaw restrict' + C.nc);
95
+ console.log('');
96
+ console.log('或者,在 Windows PowerShell 中运行:');
97
+ console.log(' ' + C.y + 'wsl -d OpenClaw -- myclaw restrict' + C.nc);
98
+ console.log(' (将 OpenClaw 替换为你的 WSL 发行版名称)');
99
+ console.log('');
100
+ return;
101
+ }
102
+
103
+ // 检查是否在 WSL 环境中
104
+ if (!isWSL()) {
105
+ printError('此脚本只能在 WSL2 环境中运行');
106
+ console.log('');
107
+ console.log('如果你在 Windows 上,请先安装 WSL2:');
108
+ console.log(' ' + C.y + 'myclaw wsl2' + C.nc);
109
+ console.log('');
110
+ return;
111
+ }
112
+
113
+ printSuccess('检测到 WSL2 环境');
114
+ console.log('');
115
+
116
+ // 执行权限封锁脚本
117
+ printStep('启动权限封锁脚本...');
118
+ console.log('');
119
+
120
+ runInWSL(SCRIPT_PATH);
121
+ }
122
+
123
+ module.exports = { run };
@@ -0,0 +1,170 @@
1
+ #!/bin/bash
2
+
3
+ ###############################################################################
4
+ # MyClaw WSL2 权限封锁脚本
5
+ #
6
+ # 功能:逐步封锁 WSL2 对 Windows 文件系统的访问权限
7
+ #
8
+ # 使用方法:
9
+ # bash scripts/restrict-wsl-access.sh
10
+ #
11
+ ###############################################################################
12
+
13
+ set -e
14
+
15
+ # 颜色定义
16
+ RED='\033[0;31m'
17
+ GREEN='\033[0;32m'
18
+ YELLOW='\033[1;33m'
19
+ BLUE='\033[0;34m'
20
+ NC='\033[0m' # No Color
21
+
22
+ WSL_CONF="/etc/wsl.conf"
23
+ BACKUP_DIR="/tmp/wsl_conf_backup_$(date +%Y%m%d_%H%M%S)"
24
+
25
+ # 打印带颜色的消息
26
+ print_info() {
27
+ echo -e "${BLUE}[信息]${NC} $1"
28
+ }
29
+
30
+ print_success() {
31
+ echo -e "${GREEN}[成功]${NC} $1"
32
+ }
33
+
34
+ print_warning() {
35
+ echo -e "${YELLOW}[警告]${NC} $1"
36
+ }
37
+
38
+ print_error() {
39
+ echo -e "${RED}[错误]${NC} $1"
40
+ }
41
+
42
+ print_step() {
43
+ echo -e "${GREEN}==>${NC} $1"
44
+ }
45
+
46
+ # 检查是否在 WSL 环境中运行
47
+ check_wsl_environment() {
48
+ if [[ ! -f /proc/version ]] || ! grep -qi "microsoft\|wsl" /proc/version 2>/dev/null; then
49
+ print_error "此脚本必须在 WSL2 环境中运行"
50
+ exit 1
51
+ fi
52
+ print_success "检测到 WSL2 环境"
53
+ }
54
+
55
+ # 备份现有配置
56
+ backup_existing_config() {
57
+ if [[ -f "$WSL_CONF" ]]; then
58
+ print_info "备份现有配置到: $BACKUP_DIR"
59
+ mkdir -p "$BACKUP_DIR"
60
+ sudo cp "$WSL_CONF" "$BACKUP_DIR/wsl.conf.bak"
61
+ print_success "配置已备份"
62
+ else
63
+ print_info "没有现有配置需要备份"
64
+ fi
65
+ }
66
+
67
+ # 步骤 A: 禁止自动挂载整个盘
68
+ step_a_disable_automount() {
69
+ print_step "步骤 A: 禁止自动挂载 Windows 盘符"
70
+
71
+ echo ""
72
+ echo "此操作将:"
73
+ echo " 1. 编辑 /etc/wsl.conf"
74
+ echo " 2. 设置 [automount] enabled = false"
75
+ echo " 3. 使 Linux 默认看不到 /mnt/c 等盘符"
76
+ echo ""
77
+
78
+ # 创建临时文件
79
+ local temp_file=$(mktemp)
80
+
81
+ # 如果原文件存在,保留非 automount 部分的内容
82
+ if [[ -f "$WSL_CONF" ]]; then
83
+ # 移除现有的 [automount] 部分
84
+ awk '
85
+ BEGIN { in_automount = 0; skip = 0 }
86
+ /^\[automount\]/ { in_automount = 1; skip = 1; next }
87
+ /^\[/ { if (in_automount) { in_automount = 0; skip = 0 } }
88
+ { if (!skip) print }
89
+ ' "$WSL_CONF" > "$temp_file"
90
+ fi
91
+
92
+ # 添加 automount 配置
93
+ cat >> "$temp_file" << EOF
94
+
95
+ [automount]
96
+ enabled = false
97
+ EOF
98
+
99
+ # 写入配置文件
100
+ print_info "写入配置到 $WSL_CONF"
101
+ sudo mv "$temp_file" "$WSL_CONF"
102
+ sudo chmod 644 "$WSL_CONF"
103
+
104
+ print_success "配置已写入"
105
+ echo ""
106
+ print_warning "需要重启 WSL2 才能生效!"
107
+ echo ""
108
+
109
+ # 显示当前配置
110
+ print_info "当前 /etc/wsl.conf 内容:"
111
+ echo "----------------------------------------"
112
+ sudo cat "$WSL_CONF"
113
+ echo "----------------------------------------"
114
+ echo ""
115
+
116
+ return 0
117
+ }
118
+
119
+ # 显示重启说明
120
+ show_restart_instructions() {
121
+ echo ""
122
+ echo "========================================"
123
+ print_warning "重要提示"
124
+ echo "========================================"
125
+ echo ""
126
+ echo "配置已完成,但需要重启 WSL2 才能生效!"
127
+ echo ""
128
+ echo "重启方法:"
129
+ echo ""
130
+ echo " 方法 1 (推荐): 在 Windows PowerShell 中运行"
131
+ echo -e " ${YELLOW}wsl --shutdown${NC}"
132
+ echo " 然后重新打开 WSL2 终端"
133
+ echo ""
134
+ echo " 方法 2: 在 Windows 命令提示符中运行"
135
+ echo -e " ${YELLOW}wsl --terminate OpenClaw${NC}"
136
+ echo " (替换 OpenClaw 为你的发行版名称)"
137
+ echo ""
138
+ echo "重启后验证:"
139
+ echo " - ls /mnt/c 应该显示目录不存在或为空"
140
+ echo " - Windows 文件系统对 Linux 不可见"
141
+ echo ""
142
+ echo "========================================"
143
+ }
144
+
145
+ # 主函数
146
+ main() {
147
+ echo ""
148
+ echo "========================================"
149
+ echo " MyClaw WSL2 权限封锁脚本"
150
+ echo "========================================"
151
+ echo ""
152
+
153
+ # 检查环境
154
+ check_wsl_environment
155
+
156
+ # 备份现有配置
157
+ backup_existing_config
158
+
159
+ # 执行步骤 A
160
+ step_a_disable_automount
161
+
162
+ # 显示重启说明
163
+ show_restart_instructions
164
+
165
+ print_success "步骤 A 配置完成!"
166
+ echo ""
167
+ }
168
+
169
+ # 运行主函数
170
+ main "$@"