@aiyiran/myclaw 1.0.256 → 1.0.258

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.
@@ -237,8 +237,35 @@
237
237
 
238
238
  content.innerHTML = '<div style="text-align:center;padding:32px;color:#888;">加载中...</div>';
239
239
 
240
+ // Fork 按钮底部栏
241
+ var panelFooter = document.createElement('div');
242
+ panelFooter.style.cssText = [
243
+ 'padding: 8px 10px',
244
+ 'background: #252536',
245
+ 'border-top: 1px solid #3d3d5c',
246
+ 'flex-shrink: 0',
247
+ ].join(';');
248
+ var forkPanelBtn = document.createElement('div');
249
+ forkPanelBtn.textContent = '\uD83D\uDD00 fork\u4ED6\u4EBA\u4F5C\u54C1';
250
+ forkPanelBtn.style.cssText = [
251
+ 'cursor: pointer',
252
+ 'padding: 6px 10px',
253
+ 'border-radius: 4px',
254
+ 'font-size: 12px',
255
+ 'font-family: monospace',
256
+ 'color: #cdd6f4',
257
+ 'background: rgba(255,255,255,0.06)',
258
+ 'text-align: center',
259
+ 'transition: background 0.15s',
260
+ ].join(';');
261
+ forkPanelBtn.onmouseenter = function () { forkPanelBtn.style.background = 'rgba(255,255,255,0.14)'; };
262
+ forkPanelBtn.onmouseleave = function () { forkPanelBtn.style.background = 'rgba(255,255,255,0.06)'; };
263
+ forkPanelBtn.onclick = function () { openForkModal(); };
264
+ panelFooter.appendChild(forkPanelBtn);
265
+
240
266
  panel.appendChild(header);
241
267
  panel.appendChild(content);
268
+ panel.appendChild(panelFooter);
242
269
  document.body.appendChild(panel);
243
270
 
244
271
  // 立即拉一次,后续由轮询更新
@@ -348,6 +375,7 @@
348
375
  'flex-shrink: 0',
349
376
  ].join(';');
350
377
  tableHeader.innerHTML = [
378
+ '<span style="flex-shrink:0;width:44px;"></span>',
351
379
  '<span style="flex-shrink:0;width:70px;">更新时间</span>',
352
380
  '<span style="flex:1;">文件名</span>',
353
381
  ].join('');
@@ -412,6 +440,39 @@
412
440
  }
413
441
  }
414
442
 
443
+ // 复制相对路径按钮(最左侧)
444
+ var copyPathBtn = document.createElement('button');
445
+ copyPathBtn.textContent = '复制';
446
+ copyPathBtn.style.cssText = [
447
+ 'flex-shrink: 0',
448
+ 'width: 44px',
449
+ 'height: 28px',
450
+ 'background: #2d2d4a',
451
+ 'color: #a78bfa',
452
+ 'border: 1px solid #4a4a7a',
453
+ 'border-radius: 4px',
454
+ 'font-size: 11px',
455
+ 'font-family: monospace',
456
+ 'cursor: pointer',
457
+ 'transition: background 0.15s, color 0.15s',
458
+ ].join(';');
459
+ copyPathBtn.onmouseenter = function () { copyPathBtn.style.background = '#3d3d6a'; };
460
+ copyPathBtn.onmouseleave = function () { copyPathBtn.style.background = '#2d2d4a'; };
461
+ copyPathBtn.onclick = function (e) {
462
+ e.stopPropagation();
463
+ var relativePath = getWorkspaceId() + '/' + (asset.path || '');
464
+ navigator.clipboard.writeText(relativePath).then(function () {
465
+ copyPathBtn.textContent = '✓';
466
+ copyPathBtn.style.color = '#10b981';
467
+ copyPathBtn.style.borderColor = '#10b981';
468
+ setTimeout(function () {
469
+ copyPathBtn.textContent = '复制';
470
+ copyPathBtn.style.color = '#a78bfa';
471
+ copyPathBtn.style.borderColor = '#4a4a7a';
472
+ }, 1500);
473
+ });
474
+ };
475
+
415
476
  // 文件名(从 path 提取)+ 标记
416
477
  var fname = document.createElement('span');
417
478
  fname.style.cssText = 'flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:flex;align-items:center;gap:6px;';
@@ -430,29 +491,9 @@
430
491
  badge.textContent = '[有更新]';
431
492
  fname.appendChild(badge);
432
493
  }
433
-
434
- // 复制相对路径按钮
435
- var copyPathBtn = document.createElement('span');
436
- copyPathBtn.textContent = '[复制]';
437
- copyPathBtn.style.cssText = 'color:#6c6caa;font-size:10px;font-weight:bold;flex-shrink:0;cursor:pointer;transition:color 0.15s;';
438
- copyPathBtn.onmouseenter = function () { copyPathBtn.style.color = '#a78bfa'; };
439
- copyPathBtn.onmouseleave = function () { copyPathBtn.style.color = '#6c6caa'; };
440
- copyPathBtn.onclick = function (e) {
441
- e.stopPropagation();
442
- var relativePath = getWorkspaceId() + '/' + (asset.path || '');
443
- navigator.clipboard.writeText(relativePath).then(function () {
444
- copyPathBtn.textContent = '[已复制]';
445
- copyPathBtn.style.color = '#10b981';
446
- setTimeout(function () {
447
- copyPathBtn.textContent = '[复制]';
448
- copyPathBtn.style.color = '#6c6caa';
449
- }, 1500);
450
- });
451
- };
452
- fname.appendChild(copyPathBtn);
453
-
454
494
  fname.appendChild(nameSpan);
455
495
 
496
+ row.appendChild(copyPathBtn);
456
497
  row.appendChild(time);
457
498
  row.appendChild(fname);
458
499
  container.appendChild(row);
@@ -1505,6 +1546,179 @@
1505
1546
  if (modal) modal.remove();
1506
1547
  }
1507
1548
 
1549
+ // ═══ Fork 他人作品弹框 ═══
1550
+ function openForkModal() {
1551
+ if (document.querySelector('#myclaw-fork-modal')) return;
1552
+
1553
+ var overlay = document.createElement('div');
1554
+ overlay.id = 'myclaw-fork-modal';
1555
+ overlay.style.cssText = [
1556
+ 'position: fixed',
1557
+ 'top: 0',
1558
+ 'left: 0',
1559
+ 'width: 100vw',
1560
+ 'height: 100vh',
1561
+ 'background: rgba(0, 0, 0, 0.4)',
1562
+ 'z-index: 99999',
1563
+ 'display: flex',
1564
+ 'align-items: center',
1565
+ 'justify-content: center',
1566
+ 'animation: myclaw-fade-in 0.15s ease',
1567
+ ].join(';');
1568
+ overlay.onclick = function (e) { if (e.target === overlay) closeForkModal(); };
1569
+
1570
+ var box = document.createElement('div');
1571
+ box.style.cssText = [
1572
+ 'width: 480px',
1573
+ 'background: #1e1e2e',
1574
+ 'border-radius: 8px',
1575
+ 'overflow: hidden',
1576
+ 'display: flex',
1577
+ 'flex-direction: column',
1578
+ 'box-shadow: 0 8px 32px rgba(0,0,0,0.5)',
1579
+ ].join(';');
1580
+
1581
+ // 标题栏
1582
+ var forkHeader = document.createElement('div');
1583
+ forkHeader.style.cssText = [
1584
+ 'display: flex',
1585
+ 'align-items: center',
1586
+ 'justify-content: space-between',
1587
+ 'padding: 10px 14px',
1588
+ 'background: #2d2d3f',
1589
+ 'color: #cdd6f4',
1590
+ 'font-size: 13px',
1591
+ 'font-family: monospace',
1592
+ 'user-select: none',
1593
+ 'flex-shrink: 0',
1594
+ ].join(';');
1595
+ forkHeader.innerHTML = '<span>\uD83D\uDD00 Fork \u4ED6\u4EBA\u4F5C\u54C1</span>';
1596
+ var forkCloseBtn = document.createElement('span');
1597
+ forkCloseBtn.textContent = '\u2715';
1598
+ forkCloseBtn.style.cssText = 'cursor:pointer;padding:2px 6px;border-radius:3px;font-size:14px;transition:background 0.15s;';
1599
+ forkCloseBtn.onmouseenter = function () { forkCloseBtn.style.background = 'rgba(255,255,255,0.1)'; };
1600
+ forkCloseBtn.onmouseleave = function () { forkCloseBtn.style.background = 'none'; };
1601
+ forkCloseBtn.onclick = function () { closeForkModal(); };
1602
+ forkHeader.appendChild(forkCloseBtn);
1603
+
1604
+ // 表单
1605
+ var forkForm = document.createElement('div');
1606
+ forkForm.style.cssText = 'padding: 20px;display:flex;flex-direction:column;gap:10px;color:#cdd6f4;font-family:monospace;font-size:13px;';
1607
+
1608
+ var urlLabel = document.createElement('label');
1609
+ urlLabel.textContent = '\u4F5C\u54C1 URL';
1610
+ urlLabel.style.cssText = 'font-size:12px;color:#888;';
1611
+
1612
+ var urlInput = document.createElement('input');
1613
+ urlInput.type = 'text';
1614
+ urlInput.placeholder = 'https://cdn.yiranlaoshi.com/...';
1615
+ urlInput.style.cssText = [
1616
+ 'padding: 8px 10px',
1617
+ 'background: #252536',
1618
+ 'border: 1px solid #3d3d5c',
1619
+ 'border-radius: 4px',
1620
+ 'color: #cdd6f4',
1621
+ 'font-size: 13px',
1622
+ 'font-family: monospace',
1623
+ 'outline: none',
1624
+ ].join(';');
1625
+ urlInput.onfocus = function () { urlInput.style.borderColor = '#6c6caa'; };
1626
+ urlInput.onblur = function () { urlInput.style.borderColor = errVisible ? '#ff4444' : '#3d3d5c'; };
1627
+
1628
+ var errVisible = false;
1629
+ var errMsg = document.createElement('div');
1630
+ errMsg.style.cssText = 'font-size:12px;color:#ff4444;display:none;';
1631
+ errMsg.textContent = '\u8BF7\u8F93\u5165\u5B8C\u6574\u7684 URL\uFF08\u9700\u4EE5 http:// \u6216 https:// \u5F00\u5934\uFF09';
1632
+
1633
+ forkForm.appendChild(urlLabel);
1634
+ forkForm.appendChild(urlInput);
1635
+ forkForm.appendChild(errMsg);
1636
+
1637
+ // 确认按钮
1638
+ var forkSubmitBtn = document.createElement('button');
1639
+ forkSubmitBtn.textContent = '\u786E\u8BA4 Fork';
1640
+ forkSubmitBtn.style.cssText = [
1641
+ 'margin: 0 20px 20px',
1642
+ 'padding: 10px',
1643
+ 'background: #4a4a7a',
1644
+ 'border: none',
1645
+ 'border-radius: 4px',
1646
+ 'color: #cdd6f4',
1647
+ 'font-size: 13px',
1648
+ 'font-family: monospace',
1649
+ 'cursor: pointer',
1650
+ 'transition: background 0.15s',
1651
+ ].join(';');
1652
+ forkSubmitBtn.onmouseenter = function () { if (!forkSubmitBtn.disabled) forkSubmitBtn.style.background = '#5a5a9a'; };
1653
+ forkSubmitBtn.onmouseleave = function () { if (!forkSubmitBtn.disabled) forkSubmitBtn.style.background = '#4a4a7a'; };
1654
+
1655
+ forkSubmitBtn.onclick = function () {
1656
+ var url = urlInput.value.trim();
1657
+
1658
+ // 校验 URL 完整性
1659
+ var valid = false;
1660
+ try {
1661
+ var parsed = new URL(url);
1662
+ valid = parsed.protocol === 'http:' || parsed.protocol === 'https:';
1663
+ } catch (e) { valid = false; }
1664
+
1665
+ if (!valid) {
1666
+ urlInput.style.borderColor = '#ff4444';
1667
+ errMsg.style.display = 'block';
1668
+ errVisible = true;
1669
+ return;
1670
+ }
1671
+ urlInput.style.borderColor = '#3d3d5c';
1672
+ errMsg.style.display = 'none';
1673
+ errVisible = false;
1674
+
1675
+ forkSubmitBtn.disabled = true;
1676
+ forkSubmitBtn.textContent = '\u23F3 \u7B49\u5F85\u4E2D...';
1677
+ forkSubmitBtn.style.background = '#3a3a5a';
1678
+ forkSubmitBtn.style.cursor = 'default';
1679
+ urlInput.disabled = true;
1680
+
1681
+ fetch('https://claw.kekouen.cn/sync', {
1682
+ method: 'POST',
1683
+ headers: { 'Content-Type': 'application/json' },
1684
+ body: JSON.stringify({ url: url }),
1685
+ })
1686
+ .then(function (res) {
1687
+ if (!res.ok) throw new Error('HTTP ' + res.status);
1688
+ return res.json();
1689
+ })
1690
+ .then(function () {
1691
+ forkSubmitBtn.textContent = '\u2705 Fork \u6210\u529F\uFF01';
1692
+ forkSubmitBtn.style.background = '#10b981';
1693
+ setTimeout(function () { closeForkModal(); }, 2000);
1694
+ })
1695
+ .catch(function (err) {
1696
+ console.error('[myclaw-fork]', err);
1697
+ forkSubmitBtn.disabled = false;
1698
+ urlInput.disabled = false;
1699
+ forkSubmitBtn.textContent = '\u274C \u8BF7\u6C42\u5931\u8D25\uFF0C\u70B9\u51FB\u91CD\u8BD5';
1700
+ forkSubmitBtn.style.background = '#7a2a2a';
1701
+ forkSubmitBtn.style.cursor = 'pointer';
1702
+ setTimeout(function () {
1703
+ forkSubmitBtn.textContent = '\u786E\u8BA4 Fork';
1704
+ forkSubmitBtn.style.background = '#4a4a7a';
1705
+ }, 2500);
1706
+ });
1707
+ };
1708
+
1709
+ box.appendChild(forkHeader);
1710
+ box.appendChild(forkForm);
1711
+ box.appendChild(forkSubmitBtn);
1712
+ overlay.appendChild(box);
1713
+ document.body.appendChild(overlay);
1714
+ urlInput.focus();
1715
+ }
1716
+
1717
+ function closeForkModal() {
1718
+ var modal = document.querySelector('#myclaw-fork-modal');
1719
+ if (modal) modal.remove();
1720
+ }
1721
+
1508
1722
  // ═══ 注入样式 ═══
1509
1723
  function injectStyles() {
1510
1724
  if (document.querySelector('#myclaw-artifacts-styles')) return;
package/index.js CHANGED
@@ -206,6 +206,54 @@ function runReinstall() {
206
206
  console.log('');
207
207
  }
208
208
 
209
+ // ============================================================================
210
+ // Lock 4.2 — 卸载 openclaw 并锁定安装 2026.4.2
211
+ // ============================================================================
212
+
213
+ function runLock42() {
214
+ const bar = '────────────────────────────────────────';
215
+ const TARGET = '2026.4.2';
216
+
217
+ console.log('');
218
+ console.log(bar);
219
+ console.log(' 🔒 OpenClaw 版本锁定工具 (目标版本: ' + colors.green + TARGET + colors.nc + ')');
220
+ console.log(bar);
221
+ console.log('');
222
+
223
+ // 1. 卸载
224
+ console.log('[1/2] 🗑️ 卸载当前 openclaw...');
225
+ try {
226
+ execSync('npm uninstall -g openclaw', { stdio: 'inherit' });
227
+ console.log(' ' + colors.green + '✓ 卸载完成' + colors.nc);
228
+ } catch (err) {
229
+ console.log(' ' + colors.yellow + '⚠ 卸载跳过(可能未安装)' + colors.nc);
230
+ }
231
+ console.log('');
232
+
233
+ // 2. 安装指定版本
234
+ console.log('[2/2] 📦 安装 openclaw@' + TARGET + '...');
235
+ try {
236
+ execSync('npm install -g openclaw@' + TARGET, { stdio: 'inherit' });
237
+ console.log(' ' + colors.green + '✓ 安装完成' + colors.nc);
238
+ } catch (err) {
239
+ console.error(' ' + colors.red + '✗ 安装失败: ' + err.message + colors.nc);
240
+ process.exit(1);
241
+ }
242
+ console.log('');
243
+
244
+ // 验证
245
+ try {
246
+ const ver = execSync('openclaw --version', { encoding: 'utf8' }).trim();
247
+ console.log('[验证] ' + colors.green + ver + colors.nc);
248
+ } catch {}
249
+
250
+ console.log('');
251
+ console.log(bar);
252
+ console.log(colors.green + ' ✅ 已锁定到 openclaw@' + TARGET + colors.nc);
253
+ console.log(bar);
254
+ console.log('');
255
+ }
256
+
209
257
  // ============================================================================
210
258
  // 状态命令
211
259
  // ============================================================================
@@ -1261,10 +1309,17 @@ function showMachineMenu() {
1261
1309
  const selected = MACHINE_CONFIG[choice - 1];
1262
1310
  console.log('');
1263
1311
  console.log(colors.green + ' → 已选择: ' + selected.name + ' (' + selected.claw + ')' + colors.nc);
1264
- console.log(' ' + colors.dim + '→ 正在用 Chrome 打开...' + colors.nc);
1265
- const { execSync } = require('child_process');
1312
+ console.log(' ' + colors.dim + '→ 正在打开浏览器...' + colors.nc);
1313
+ const { exec } = require('child_process');
1266
1314
  const machineUrl = 'https://' + selected.claw + '.kekouen.cn?token=aiyiran';
1267
- execSync('open -a "Google Chrome" "' + machineUrl + '"', { stdio: 'ignore' });
1315
+ const platform = os.platform();
1316
+ if (platform === 'darwin') {
1317
+ exec('open -a "Google Chrome" "' + machineUrl + '"');
1318
+ } else if (platform === 'win32') {
1319
+ exec('start "" "' + machineUrl + '"', { shell: true });
1320
+ } else {
1321
+ exec('xdg-open "' + machineUrl + '"');
1322
+ }
1268
1323
  createDesktopShortcut(machineUrl);
1269
1324
  } else {
1270
1325
  console.log('[' + colors.red + '错误' + colors.nc + '] 无效选择');
@@ -1858,6 +1913,8 @@ if (!command) {
1858
1913
  console.log('🔄 正在重启 Gateway 使配置生效...');
1859
1914
  console.log('');
1860
1915
  runRestart();
1916
+ } else if (command === 'lock4.2') {
1917
+ runLock42();
1861
1918
  } else if (command === 'server') {
1862
1919
  runServer(args[1]); // args[1] 是可选的 name
1863
1920
  } else if (command === 'sync') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.256",
3
+ "version": "1.0.258",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -36,7 +36,7 @@
36
36
  {
37
37
  "id": "fashe1",
38
38
  "workspace": "workspace-fashe1",
39
- "strategy": "on",
39
+ "strategy": "auto",
40
40
  "description": "fashe1"
41
41
  }
42
42
  ],