@aiyiran/myclaw 1.0.172 → 1.0.173
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 +16 -41
- package/index.js +57 -30
- package/package.json +1 -1
package/create_agent.js
CHANGED
|
@@ -93,49 +93,24 @@ function buildBirthMessage() {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
*
|
|
96
|
+
* 从当前 workspace 模板目录复制默认文件,替换 agentId
|
|
97
97
|
*/
|
|
98
98
|
function defaultWorkspaceFiles(agentId) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
`You are \`${agentId}\`.\n\n` +
|
|
115
|
-
'Be useful, calm, direct, and trustworthy.\n' +
|
|
116
|
-
'Use the default OpenClaw behavior unless the user asks for something special.\n'
|
|
117
|
-
),
|
|
118
|
-
'USER.md': (
|
|
119
|
-
'# USER.md\n\n' +
|
|
120
|
-
'- Timezone: Asia/Shanghai\n\n' +
|
|
121
|
-
'Build understanding gradually and respectfully.\n'
|
|
122
|
-
),
|
|
123
|
-
'IDENTITY.md': (
|
|
124
|
-
'# IDENTITY.md\n\n' +
|
|
125
|
-
`- Name: ${agentId}\n` +
|
|
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
|
-
};
|
|
99
|
+
const templateDir = path.resolve(__dirname, '..');
|
|
100
|
+
const templateFiles = ['AGENTS.md', 'SOUL.md', 'USER.md', 'IDENTITY.md', 'HEARTBEAT.md', 'BOOTSTRAP.md'];
|
|
101
|
+
const files = {};
|
|
102
|
+
|
|
103
|
+
for (const fn of templateFiles) {
|
|
104
|
+
const src = path.join(templateDir, fn);
|
|
105
|
+
if (fs.existsSync(src)) {
|
|
106
|
+
let content = fs.readFileSync(src, 'utf8');
|
|
107
|
+
// 把模板中的 yiranclaw(或当前 workspace 名)替换为新 agentId
|
|
108
|
+
content = content.replace(/yiranclaw/g, agentId);
|
|
109
|
+
files[fn] = content;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return files;
|
|
139
114
|
}
|
|
140
115
|
|
|
141
116
|
// ============================================================================
|
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 + '] 桌面快捷方式已创建!');
|