@aiyiran/myclaw 1.0.172 → 1.0.174
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/create_agent.js +29 -41
- package/index.js +59 -31
- package/package.json +1 -1
- package/restrict.js +1 -1
- package/start.js +4 -12
package/create_agent.js
CHANGED
|
@@ -93,49 +93,37 @@ function buildBirthMessage() {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* 从当前 workspace 模板目录复制默认文件,替换 agentId
|
|
97
|
+
* SOUL.md 使用 inject-workspaceAndSoul.js 中的学习伙伴模板
|
|
97
98
|
*/
|
|
98
99
|
function defaultWorkspaceFiles(agentId) {
|
|
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
|
-
'- Role: OpenClaw agent\n' +
|
|
127
|
-
'- Vibe: practical, reliable, clear\n'
|
|
128
|
-
),
|
|
129
|
-
'HEARTBEAT.md': (
|
|
130
|
-
'# HEARTBEAT.md\n\n' +
|
|
131
|
-
'# Keep empty unless periodic checks are needed.\n'
|
|
132
|
-
),
|
|
133
|
-
'BOOTSTRAP.md': (
|
|
134
|
-
`# BOOTSTRAP.md\n\n` +
|
|
135
|
-
`You are a newly created OpenClaw agent named \`${agentId}\`.\n\n` +
|
|
136
|
-
'On first runs, learn your workspace files and begin helping.\n'
|
|
137
|
-
),
|
|
138
|
-
};
|
|
100
|
+
const templateDir = path.resolve(__dirname, '..');
|
|
101
|
+
const templateFiles = ['AGENTS.md', 'USER.md', 'IDENTITY.md', 'HEARTBEAT.md', 'BOOTSTRAP.md'];
|
|
102
|
+
const files = {};
|
|
103
|
+
|
|
104
|
+
// 从根 workspace 复制其他文件
|
|
105
|
+
for (const fn of templateFiles) {
|
|
106
|
+
const src = path.join(templateDir, fn);
|
|
107
|
+
if (fs.existsSync(src)) {
|
|
108
|
+
let content = fs.readFileSync(src, 'utf8');
|
|
109
|
+
content = content.replace(/yiranclaw/g, agentId);
|
|
110
|
+
files[fn] = content;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// SOUL.md 使用学生学习伙伴模板
|
|
115
|
+
const soulModule = require('./inject-workspaceAndSoul');
|
|
116
|
+
// 直接读取模块里的 SOUL_CONTENT(不依赖导出,直接读源文件更可靠)
|
|
117
|
+
const soulSrc = path.join(__dirname, 'inject-workspaceAndSoul.js');
|
|
118
|
+
if (fs.existsSync(soulSrc)) {
|
|
119
|
+
const raw = fs.readFileSync(soulSrc, 'utf8');
|
|
120
|
+
const match = raw.match(/const SOUL_CONTENT = `([\s\S]*?)`;/);
|
|
121
|
+
if (match) {
|
|
122
|
+
files['SOUL.md'] = match[1];
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return files;
|
|
139
127
|
}
|
|
140
128
|
|
|
141
129
|
// ============================================================================
|
package/index.js
CHANGED
|
@@ -454,39 +454,66 @@ pause >nul
|
|
|
454
454
|
const iconPath = path.join(myClawDir, 'openclaw.ico');
|
|
455
455
|
const iconUrl = 'https://cdn.yiranlaoshi.com/software/myclaw/openclaw.ico';
|
|
456
456
|
|
|
457
|
-
const
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
$
|
|
468
|
-
$sc
|
|
469
|
-
$sc.
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
$
|
|
473
|
-
|
|
474
|
-
$
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
$
|
|
479
|
-
$
|
|
480
|
-
$
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
457
|
+
const psFile = path.join(myClawDir, 'create-shortcuts.ps1');
|
|
458
|
+
const psContent = [
|
|
459
|
+
'$ErrorActionPreference = \'Continue\'',
|
|
460
|
+
'',
|
|
461
|
+
'# 下载图标(如不存在)',
|
|
462
|
+
'if (-not (Test-Path \'' + iconPath + '\')) {',
|
|
463
|
+
' try { Invoke-WebRequest -Uri \'' + iconUrl + '\' -OutFile \'' + iconPath + '\' -UseBasicParsing } catch {}',
|
|
464
|
+
'}',
|
|
465
|
+
'',
|
|
466
|
+
'# 创建 OpenClaw 启动快捷方式',
|
|
467
|
+
'$ws = New-Object -ComObject WScript.Shell',
|
|
468
|
+
'$sc = $ws.CreateShortcut(\'' + lnkPath + '\')',
|
|
469
|
+
'$sc.TargetPath = \'' + batPath + '\'',
|
|
470
|
+
'$sc.WorkingDirectory = \'' + myClawDir + '\'',
|
|
471
|
+
'$sc.WindowStyle = 1',
|
|
472
|
+
'$sc.IconLocation = \'' + iconPath + '\'',
|
|
473
|
+
'$sc.Description = \'OpenClaw\'',
|
|
474
|
+
'$sc.Save()',
|
|
475
|
+
'Write-Host \'[bat] OpenClaw shortcut created\'',
|
|
476
|
+
'',
|
|
477
|
+
'# 创建「我的私人龙虾」工作目录快捷方式(如不存在)',
|
|
478
|
+
'$workspaceLnk = \'' + desktopPath + '\\我的私人龙虾.lnk\'',
|
|
479
|
+
'if (-not (Test-Path $workspaceLnk)) {',
|
|
480
|
+
' $ws2 = New-Object -ComObject WScript.Shell',
|
|
481
|
+
' $sc2 = $ws2.CreateShortcut($workspaceLnk)',
|
|
482
|
+
' $sc2.TargetPath = \'\\\\wsl.localhost\\OpenClaw\\root\\.openclaw\\workspace\'',
|
|
483
|
+
' $sc2.WorkingDirectory = \'\\\\wsl.localhost\\OpenClaw\\root\\.openclaw\\workspace\'',
|
|
484
|
+
' $sc2.Description = \'OpenClaw Workspace\'',
|
|
485
|
+
' $sc2.IconLocation = \'C:\\Windows\\System32\\SHELL32.dll,4\'',
|
|
486
|
+
' $sc2.Save()',
|
|
487
|
+
' Write-Host \'[bat] workspace shortcut created\'',
|
|
488
|
+
'} else {',
|
|
489
|
+
' Write-Host \'[bat] workspace shortcut already exists\'',
|
|
490
|
+
'}',
|
|
491
|
+
'',
|
|
492
|
+
'# 刷新桌面',
|
|
493
|
+
'try {',
|
|
494
|
+
' Add-Type -TypeDefinition \'using System; using System.Runtime.InteropServices; public class ShellRefresh { [DllImport(\"shell32.dll\")] public static extern void SHChangeNotify(int e, int f, IntPtr i1, IntPtr i2); }\' -ErrorAction Stop',
|
|
495
|
+
' [ShellRefresh]::SHChangeNotify(0x08000000, 0, [IntPtr]::Zero, [IntPtr]::Zero)',
|
|
496
|
+
' Write-Host \'[bat] desktop refreshed\'',
|
|
497
|
+
'} catch {',
|
|
498
|
+
' Write-Host \'[bat] refresh skipped\'',
|
|
499
|
+
'}',
|
|
500
|
+
].join('\r\n');
|
|
501
|
+
|
|
502
|
+
// UTF-8 BOM + 写入
|
|
503
|
+
fs.writeFileSync(psFile, '\uFEFF' + psContent, 'utf8');
|
|
486
504
|
|
|
487
505
|
try {
|
|
488
506
|
const { execSync } = require('child_process');
|
|
489
|
-
execSync(
|
|
507
|
+
const psOutput = execSync('powershell -NoProfile -ExecutionPolicy Bypass -File "' + psFile + '"', {
|
|
508
|
+
encoding: 'utf8',
|
|
509
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
510
|
+
});
|
|
511
|
+
// 打印 PowerShell 的详细日志
|
|
512
|
+
if (psOutput) {
|
|
513
|
+
psOutput.trim().split('\n').forEach(line => {
|
|
514
|
+
if (line.trim()) console.log(' ' + line.trim());
|
|
515
|
+
});
|
|
516
|
+
}
|
|
490
517
|
|
|
491
518
|
console.log('');
|
|
492
519
|
console.log('[' + colors.green + '成功' + colors.nc + '] 桌面快捷方式已创建!');
|
|
@@ -1015,7 +1042,8 @@ const MENU_ITEMS = [
|
|
|
1015
1042
|
{ key: 'patch', label: '修复', cmd: 'mc patch', desc: '给 AI 助手装上新技能和好看的外衣', action: runPatch },
|
|
1016
1043
|
{ key: 'reinstall', label: '重装', cmd: 'mc longxia', desc: '出了大问题?把 AI 助手删了重新安装', action: runReinstall },
|
|
1017
1044
|
{ key: 'uninstall', label: '卸载', cmd: 'mc uninstall', desc: '卸载 MyClaw,恢复 npm 源地址', action: runUninstall },
|
|
1018
|
-
{ key: 'wsl2reinstall', label: 'WSL2虚拟机重装', cmd: 'mc wsl2 --remote', desc: '强制从网络重新下载并重装 WSL2 虚拟机(仅限 Windows)', action: () => {
|
|
1045
|
+
{ key: 'wsl2reinstall', label: 'WSL2虚拟机重装', cmd: 'mc wsl2 --remote --force-phase1', desc: '强制从网络重新下载并重装 WSL2 虚拟机(仅限 Windows)', action: () => {
|
|
1046
|
+
process.argv.push('--remote', '--force-phase1');
|
|
1019
1047
|
const wsl2 = require('./wsl2');
|
|
1020
1048
|
wsl2.run();
|
|
1021
1049
|
}},
|
package/package.json
CHANGED
package/restrict.js
CHANGED
|
@@ -111,7 +111,7 @@ function run() {
|
|
|
111
111
|
if (existing.includes('[automount]')) {
|
|
112
112
|
newContent = existing.replace(/\[automount\][^\[]*/, '[automount]\nenabled = false\n');
|
|
113
113
|
} else {
|
|
114
|
-
newContent = existing + (existing.endsWith('\n') ? '' : '\n') + '[automount]\nenabled = false\n';
|
|
114
|
+
newContent = existing + (existing.endsWith('\n') ? '' : '\n') + '[automount]\nenabled = false\n[interop]\nappendWindowsPath = false\n';
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
const script = [
|
package/start.js
CHANGED
|
@@ -68,18 +68,10 @@ function startWindows() {
|
|
|
68
68
|
|
|
69
69
|
// Step 2.5: 自动检测虚拟机屏蔽(safe)
|
|
70
70
|
console.log('[safe] 虚拟机屏蔽...');
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (conf.includes('enabled = false') || conf.includes('enabled=false')) {
|
|
76
|
-
console.log(' ' + C.g + '[已开启]' + C.nc);
|
|
77
|
-
} else {
|
|
78
|
-
console.log(' ' + C.y + '[未开启,正在启用...]' + C.nc);
|
|
79
|
-
try { execSync('myclaw safe', { stdio: 'inherit', timeout: 30000 }); } catch {}
|
|
80
|
-
}
|
|
81
|
-
} catch {
|
|
82
|
-
// wsl.conf 不存在,说明还没开启
|
|
71
|
+
const restrict = require('./restrict');
|
|
72
|
+
if (restrict.isAlreadySafe()) {
|
|
73
|
+
console.log(' ' + C.g + '[已开启]' + C.nc);
|
|
74
|
+
} else {
|
|
83
75
|
console.log(' ' + C.y + '[未开启,正在启用...]' + C.nc);
|
|
84
76
|
try { execSync('myclaw safe', { stdio: 'inherit', timeout: 30000 }); } catch {}
|
|
85
77
|
}
|