mingdao-harness 0.1.55 → 0.1.57
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/README.md +2 -1
- package/package.json +1 -1
- package/src/cli.js +2 -0
- package/src/commands/desktop.js +42 -0
package/README.md
CHANGED
|
@@ -85,7 +85,8 @@ cd MingDao-Harness && bash install.sh
|
|
|
85
85
|
### 桌面版(Electron)
|
|
86
86
|
|
|
87
87
|
```bash
|
|
88
|
-
|
|
88
|
+
mingdao desktop # 任意目录启动桌面版(首次运行会提示安装 Electron,带镜像指引)
|
|
89
|
+
npm run desktop # 等价写法(需在仓库目录内)
|
|
89
90
|
```
|
|
90
91
|
|
|
91
92
|
- 内置服务零端口暴露(127.0.0.1 随机端口 + 一次性令牌)、系统托盘常驻、窗口状态记忆、
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -86,6 +86,7 @@ const HELP_LINES = [
|
|
|
86
86
|
[' mingdao update [--check] 一键自更新(git 安装形态;--check 只对比版本)', null],
|
|
87
87
|
[' mingdao rollback 回滚到上次 update 之前的提交', null],
|
|
88
88
|
[' mingdao audit [数量] 查看工具调用审计日志(默认最近 20 条)', null],
|
|
89
|
+
[' mingdao desktop 启动桌面版(Electron,任意目录可用,托盘常驻)', null],
|
|
89
90
|
[' mingdao --help / --version 帮助 / 版本', null],
|
|
90
91
|
['', null],
|
|
91
92
|
['凭证管理(API Key 独立存储,绝不写入 config.json / 仓库)', C.bold + C.yellow],
|
|
@@ -302,6 +303,7 @@ async function main() {
|
|
|
302
303
|
['sync', 'sync'],
|
|
303
304
|
['skill', 'skill'], ['web', 'skill'], ['sessions', 'skill'],
|
|
304
305
|
['key', 'key'],
|
|
306
|
+
['desktop', 'desktop'],
|
|
305
307
|
];
|
|
306
308
|
const hit = dispatchTable.find(([name]) => name === opts.prompt[0]);
|
|
307
309
|
if (hit) {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// 命令族:mingdao desktop —— 任意目录启动 Electron 桌面版
|
|
2
|
+
// 定位仓库 → 检查 desktop/node_modules 里的 electron → 拉起;缺依赖给出镜像安装指引。
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { findRepoRoot } from '../update.js';
|
|
7
|
+
|
|
8
|
+
export async function handleDesktop(args) {
|
|
9
|
+
const repo = findRepoRoot();
|
|
10
|
+
if (!repo) {
|
|
11
|
+
console.log('mingdao desktop 需要「仓库安装形态」(npm 全局安装不含桌面壳)。');
|
|
12
|
+
console.log(' 方案一(推荐):下载三平台安装包(GitHub Releases 或 CI 产物,带自动更新);');
|
|
13
|
+
console.log(' 方案二:git clone 任一平台仓库后,在仓库目录运行 mingdao desktop。');
|
|
14
|
+
console.log(' 克隆地址:https://gitee.com/MingDaoTCM/MingDao-harness · https://gitcode.com/MingDaoTCM/MingDao-Harness');
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
const desktopDir = path.join(repo, 'desktop');
|
|
19
|
+
if (!fs.existsSync(path.join(desktopDir, 'main.js'))) {
|
|
20
|
+
console.log('[错误] 仓库缺少 desktop/ 目录(版本过旧?先运行 mingdao update)。');
|
|
21
|
+
process.exitCode = 1;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
const isWin = process.platform === 'win32';
|
|
25
|
+
const localBin = path.join(desktopDir, 'node_modules', '.bin', isWin ? 'electron.cmd' : 'electron');
|
|
26
|
+
if (!fs.existsSync(localBin)) {
|
|
27
|
+
console.log('[提示] 首次运行需要安装 Electron(约 120MB,仅桌面版构建依赖,运行时仍零依赖):');
|
|
28
|
+
console.log(` cd "${desktopDir}"`);
|
|
29
|
+
console.log(' npm install');
|
|
30
|
+
console.log(' 国内网络先执行:export ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/(Windows 用 set)');
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
console.log('正在启动 明道 MingDao 桌面版…(窗口弹出即成功;托盘常驻,关闭窗口 = 最小化到托盘)');
|
|
35
|
+
const child = spawn(localBin, [desktopDir], { cwd: desktopDir, stdio: 'ignore', detached: true });
|
|
36
|
+
child.on('error', (err) => {
|
|
37
|
+
console.log('[错误] 启动 Electron 失败:' + (err?.message || err));
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
});
|
|
40
|
+
child.unref(); // CLI 退出后应用继续运行
|
|
41
|
+
return true;
|
|
42
|
+
}
|