mimi-seed 0.15.2 → 0.15.4
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/dist/index.js +76 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1153,7 +1153,9 @@ var M6 = catalog(
|
|
|
1153
1153
|
killedPid: (pid) => ` PID ${pid} \uC885\uB8CC`,
|
|
1154
1154
|
title: (server) => `MCP \uC11C\uBC84 \uC7AC\uC2DC\uC791: ${server}`,
|
|
1155
1155
|
none: "(\uC5C6\uC74C)",
|
|
1156
|
-
notFound: (server) => `'${server}' \uC11C\uBC84\uB97C
|
|
1156
|
+
notFound: (server) => `'${server}' \uC11C\uBC84\uB97C MCP \uC124\uC815\uC5D0\uC11C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.`,
|
|
1157
|
+
searched: (paths) => ` \uCC3E\uC544\uBCF8 \uACF3: ${paths}`,
|
|
1158
|
+
noConfig: "(\uC124\uC815 \uC5C6\uC74C)",
|
|
1157
1159
|
registered: (list) => ` \uB4F1\uB85D\uB41C \uC11C\uBC84: ${list}`,
|
|
1158
1160
|
httpServer: (server) => `'${server}'\uB294 HTTP/SSE \uC11C\uBC84\uC785\uB2C8\uB2E4. \uD504\uB85C\uC138\uC2A4 \uC7AC\uC2DC\uC791\uC774 \uD544\uC694\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.`,
|
|
1159
1161
|
httpHint: " Claude Code\uC5D0\uC11C /mcp \uB97C \uC2E4\uD589\uD574 \uC5F0\uACB0 \uC0C1\uD0DC\uB97C \uD655\uC778\uD558\uC138\uC694.",
|
|
@@ -1171,7 +1173,9 @@ var M6 = catalog(
|
|
|
1171
1173
|
title: (server) => `Restarting MCP server: ${server}`,
|
|
1172
1174
|
none: "(none)",
|
|
1173
1175
|
registered: (list) => ` Registered servers: ${list}`,
|
|
1174
|
-
notFound: (server) => `Could not find the '${server}' server in
|
|
1176
|
+
notFound: (server) => `Could not find the '${server}' server in any MCP config.`,
|
|
1177
|
+
searched: (paths) => ` Looked in: ${paths}`,
|
|
1178
|
+
noConfig: "(no config found)",
|
|
1175
1179
|
httpServer: (server) => `'${server}' is an HTTP/SSE server. It does not need a process restart.`,
|
|
1176
1180
|
httpHint: " Run /mcp in Claude Code to check the connection.",
|
|
1177
1181
|
noMarker: "Could not find a process marker (script path).",
|
|
@@ -1184,14 +1188,31 @@ var M6 = catalog(
|
|
|
1184
1188
|
verify: " Verify the connection: run /mcp in Claude Code"
|
|
1185
1189
|
}
|
|
1186
1190
|
);
|
|
1187
|
-
function
|
|
1188
|
-
const p = path.join(os.homedir(), ".claude.json");
|
|
1191
|
+
function readJson(filePath) {
|
|
1189
1192
|
try {
|
|
1190
|
-
return JSON.parse(fs.readFileSync(
|
|
1193
|
+
return JSON.parse(fs.readFileSync(filePath, "utf8"));
|
|
1191
1194
|
} catch {
|
|
1192
1195
|
return {};
|
|
1193
1196
|
}
|
|
1194
1197
|
}
|
|
1198
|
+
function collectServers() {
|
|
1199
|
+
const servers = {};
|
|
1200
|
+
const sources = [];
|
|
1201
|
+
const add = (map, source) => {
|
|
1202
|
+
if (!map || typeof map !== "object") return;
|
|
1203
|
+
const entries = Object.entries(map);
|
|
1204
|
+
if (entries.length === 0) return;
|
|
1205
|
+
sources.push(source);
|
|
1206
|
+
for (const [name, cfg] of entries) if (!(name in servers)) servers[name] = cfg;
|
|
1207
|
+
};
|
|
1208
|
+
const projectDir = process.cwd();
|
|
1209
|
+
add(readJson(path.join(projectDir, ".mcp.json")).mcpServers, ".mcp.json");
|
|
1210
|
+
const home = readJson(path.join(os.homedir(), ".claude.json"));
|
|
1211
|
+
const projects = home.projects;
|
|
1212
|
+
add(projects?.[projectDir]?.mcpServers, "~/.claude.json (projects)");
|
|
1213
|
+
add(home.mcpServers, "~/.claude.json");
|
|
1214
|
+
return { servers, sources };
|
|
1215
|
+
}
|
|
1195
1216
|
function findProcessMarker(cfg) {
|
|
1196
1217
|
const args = cfg.args;
|
|
1197
1218
|
if (!args) return null;
|
|
@@ -1202,10 +1223,41 @@ function findProcessMarker(cfg) {
|
|
|
1202
1223
|
const meaningful = args.filter((a) => !a.startsWith("-") && a !== "/c" && a !== "npx" && a !== "cmd");
|
|
1203
1224
|
return meaningful.at(-1) ?? null;
|
|
1204
1225
|
}
|
|
1205
|
-
function
|
|
1226
|
+
function candidateMarkers(cfg) {
|
|
1227
|
+
const primary = findProcessMarker(cfg);
|
|
1228
|
+
if (!primary) return [];
|
|
1229
|
+
const base = primary.split("/").pop();
|
|
1230
|
+
return base && base !== primary ? [primary, base] : [primary];
|
|
1231
|
+
}
|
|
1232
|
+
function findPids(markers) {
|
|
1233
|
+
let out;
|
|
1234
|
+
try {
|
|
1235
|
+
out = execSync2("ps -eo pid=,args=", { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
|
|
1236
|
+
} catch {
|
|
1237
|
+
return [];
|
|
1238
|
+
}
|
|
1239
|
+
const skip = /* @__PURE__ */ new Set([process.pid, process.ppid]);
|
|
1240
|
+
const pids = [];
|
|
1241
|
+
for (const line of out.split("\n")) {
|
|
1242
|
+
const m = /^\s*(\d+)\s+(.*)$/.exec(line);
|
|
1243
|
+
if (!m) continue;
|
|
1244
|
+
const pid = Number(m[1]);
|
|
1245
|
+
if (skip.has(pid)) continue;
|
|
1246
|
+
const argv = m[2].split(/\s+/).filter(Boolean);
|
|
1247
|
+
const exeBase = path.basename(argv[0] ?? "");
|
|
1248
|
+
const rest = argv.slice(1);
|
|
1249
|
+
const hit = markers.some((marker) => {
|
|
1250
|
+
const base = path.basename(marker);
|
|
1251
|
+
return exeBase === base || rest.includes(marker) || rest.some((a) => path.basename(a) === base);
|
|
1252
|
+
});
|
|
1253
|
+
if (hit) pids.push(pid);
|
|
1254
|
+
}
|
|
1255
|
+
return pids;
|
|
1256
|
+
}
|
|
1257
|
+
function killByMarkers(markers) {
|
|
1206
1258
|
const isWin = os.platform() === "win32";
|
|
1207
1259
|
if (isWin) {
|
|
1208
|
-
const escaped =
|
|
1260
|
+
const escaped = markers[0].replace(/\\/g, "\\\\").replace(/'/g, "\\'");
|
|
1209
1261
|
let pids;
|
|
1210
1262
|
try {
|
|
1211
1263
|
const out = execSync2(
|
|
@@ -1227,24 +1279,29 @@ function killByMarker(marker) {
|
|
|
1227
1279
|
}
|
|
1228
1280
|
return { killed };
|
|
1229
1281
|
} else {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1282
|
+
let killed = 0;
|
|
1283
|
+
for (const pid of findPids(markers)) {
|
|
1284
|
+
try {
|
|
1285
|
+
process.kill(pid, "SIGTERM");
|
|
1286
|
+
log3(kleur7.dim(M6().killedPid(String(pid))));
|
|
1287
|
+
killed += 1;
|
|
1288
|
+
} catch {
|
|
1289
|
+
}
|
|
1235
1290
|
}
|
|
1291
|
+
return { killed };
|
|
1236
1292
|
}
|
|
1237
1293
|
}
|
|
1238
1294
|
async function cmdRestart(args) {
|
|
1239
1295
|
const serverName = args[0] ?? "mimi-seed";
|
|
1240
1296
|
log3(kleur7.bold(M6().title(serverName)));
|
|
1241
1297
|
log3("");
|
|
1242
|
-
const
|
|
1243
|
-
const
|
|
1244
|
-
const cfg = servers?.[serverName];
|
|
1298
|
+
const { servers, sources } = collectServers();
|
|
1299
|
+
const cfg = servers[serverName];
|
|
1245
1300
|
if (!cfg) {
|
|
1246
|
-
const
|
|
1301
|
+
const names = Object.keys(servers);
|
|
1302
|
+
const available = names.length ? names.join(", ") : M6().none;
|
|
1247
1303
|
log3(kleur7.red(M6().notFound(serverName)));
|
|
1304
|
+
log3(kleur7.dim(M6().searched(sources.length ? sources.join(", ") : M6().noConfig)));
|
|
1248
1305
|
log3(kleur7.dim(M6().registered(available)));
|
|
1249
1306
|
process.exit(1);
|
|
1250
1307
|
}
|
|
@@ -1253,14 +1310,15 @@ async function cmdRestart(args) {
|
|
|
1253
1310
|
log3(kleur7.dim(M6().httpHint));
|
|
1254
1311
|
return;
|
|
1255
1312
|
}
|
|
1256
|
-
const
|
|
1313
|
+
const markers = candidateMarkers(cfg);
|
|
1314
|
+
const marker = markers[0] ?? null;
|
|
1257
1315
|
if (!marker) {
|
|
1258
1316
|
log3(kleur7.yellow(M6().noMarker));
|
|
1259
1317
|
log3(kleur7.dim(M6().configLine(JSON.stringify(cfg))));
|
|
1260
1318
|
process.exit(1);
|
|
1261
1319
|
}
|
|
1262
1320
|
log3(kleur7.dim(M6().markerLine(marker)));
|
|
1263
|
-
const { killed } =
|
|
1321
|
+
const { killed } = killByMarkers(markers);
|
|
1264
1322
|
if (killed === 0) {
|
|
1265
1323
|
log3(kleur7.yellow(M6().noProcess));
|
|
1266
1324
|
log3(kleur7.dim(M6().noProcessHint));
|
package/package.json
CHANGED