@geminilight/mindos 0.5.13 → 0.5.14
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/app/app/api/restart/route.ts +5 -4
- package/app/app/api/sync/route.ts +4 -3
- package/bin/cli.js +4 -0
- package/bin/lib/sync.js +3 -1
- package/package.json +1 -1
|
@@ -5,8 +5,8 @@ import { resolve } from 'node:path';
|
|
|
5
5
|
|
|
6
6
|
export async function POST() {
|
|
7
7
|
try {
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
const cliPath = process.env.MINDOS_CLI_PATH || resolve(process.cwd(), '..', 'bin', 'cli.js');
|
|
9
|
+
const nodeBin = process.env.MINDOS_NODE_BIN || process.execPath;
|
|
10
10
|
// Use 'restart' (stop all → wait for ports free → start) instead of bare
|
|
11
11
|
// 'start' which would fail assertPortFree because the current process and
|
|
12
12
|
// its MCP child are still holding the ports.
|
|
@@ -28,7 +28,7 @@ export async function POST() {
|
|
|
28
28
|
delete childEnv.WEB_PASSWORD;
|
|
29
29
|
if (oldWebPort) childEnv.MINDOS_OLD_WEB_PORT = oldWebPort;
|
|
30
30
|
if (oldMcpPort) childEnv.MINDOS_OLD_MCP_PORT = oldMcpPort;
|
|
31
|
-
const child = spawn(
|
|
31
|
+
const child = spawn(nodeBin, [cliPath, 'restart'], {
|
|
32
32
|
detached: true,
|
|
33
33
|
stdio: 'ignore',
|
|
34
34
|
env: childEnv,
|
|
@@ -41,6 +41,7 @@ export async function POST() {
|
|
|
41
41
|
setTimeout(() => process.exit(0), 1500);
|
|
42
42
|
return NextResponse.json({ ok: true });
|
|
43
43
|
} catch (err) {
|
|
44
|
-
|
|
44
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
45
|
+
return NextResponse.json({ error: message }, { status: 500 });
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -37,16 +37,17 @@ function isGitRepo(dir: string) {
|
|
|
37
37
|
return existsSync(join(dir, '.git'));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
/** Resolve path to bin/cli.js
|
|
40
|
+
/** Resolve path to bin/cli.js — prefer env var set by CLI launcher, fall back to cwd. */
|
|
41
41
|
function getCliPath() {
|
|
42
|
-
return resolve(process.cwd(), '..', 'bin', 'cli' + '.js');
|
|
42
|
+
return process.env.MINDOS_CLI_PATH || resolve(process.cwd(), '..', 'bin', 'cli' + '.js');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** Run CLI command via execFile — avoids shell injection by passing args as array */
|
|
46
46
|
function runCli(args: string[], timeoutMs = 30000): Promise<void> {
|
|
47
47
|
const cliPath = getCliPath();
|
|
48
|
+
const nodeBin = process.env.MINDOS_NODE_BIN || process.execPath;
|
|
48
49
|
return new Promise((res, rej) => {
|
|
49
|
-
execFile(
|
|
50
|
+
execFile(nodeBin, [cliPath, ...args], { timeout: timeoutMs }, (err, _stdout, stderr) => {
|
|
50
51
|
if (err) rej(new Error(stderr?.trim() || err.message));
|
|
51
52
|
else res();
|
|
52
53
|
});
|
package/bin/cli.js
CHANGED
|
@@ -197,6 +197,8 @@ const commands = {
|
|
|
197
197
|
// ── dev ────────────────────────────────────────────────────────────────────
|
|
198
198
|
dev: async () => {
|
|
199
199
|
loadConfig();
|
|
200
|
+
process.env.MINDOS_CLI_PATH = resolve(ROOT, 'bin', 'cli.js');
|
|
201
|
+
process.env.MINDOS_NODE_BIN = process.execPath;
|
|
200
202
|
const webPort = process.env.MINDOS_WEB_PORT || '3456';
|
|
201
203
|
const mcpPort = process.env.MINDOS_MCP_PORT || '8781';
|
|
202
204
|
await assertPortFree(Number(webPort), 'web');
|
|
@@ -283,6 +285,8 @@ const commands = {
|
|
|
283
285
|
await assertPortFree(Number(webPort), 'web');
|
|
284
286
|
await assertPortFree(Number(mcpPort), 'mcp');
|
|
285
287
|
}
|
|
288
|
+
process.env.MINDOS_CLI_PATH = resolve(ROOT, 'bin', 'cli.js');
|
|
289
|
+
process.env.MINDOS_NODE_BIN = process.execPath;
|
|
286
290
|
ensureAppDeps();
|
|
287
291
|
if (needsBuild()) {
|
|
288
292
|
console.log(yellow('Building MindOS (first run or new version detected)...\n'));
|
package/bin/lib/sync.js
CHANGED
|
@@ -286,7 +286,9 @@ export async function initSync(mindRoot, opts = {}) {
|
|
|
286
286
|
// 5. Test connection
|
|
287
287
|
if (!nonInteractive) console.log(dim('Testing connection...'));
|
|
288
288
|
try {
|
|
289
|
-
|
|
289
|
+
// `git ls-remote --exit-code origin` returns non-zero for an empty remote,
|
|
290
|
+
// which breaks first-time setup against a freshly created repository.
|
|
291
|
+
execFileSync('git', ['ls-remote', 'origin'], { cwd: mindRoot, stdio: 'pipe', timeout: 15000 });
|
|
290
292
|
if (!nonInteractive) console.log(green('✔ Connection successful'));
|
|
291
293
|
} catch (lsErr) {
|
|
292
294
|
const detail = lsErr.stderr ? lsErr.stderr.toString().trim() : '';
|
package/package.json
CHANGED