mimi-seed 0.15.3 → 0.15.5

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.
Files changed (2) hide show
  1. package/dist/index.js +127 -29
  2. 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 ~/.claude/.claude.json\uC5D0\uC11C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.`,
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.",
@@ -1161,37 +1163,94 @@ var M6 = catalog(
1161
1163
  configLine: (cfg) => ` \uC124\uC815: ${cfg}`,
1162
1164
  markerLine: (marker) => ` \uC2DD\uBCC4\uC790: ${marker}`,
1163
1165
  noProcess: "\u26A0 \uC2E4\uD589 \uC911\uC778 \uD504\uB85C\uC138\uC2A4\uB97C \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.",
1164
- noProcessHint: " \uC774\uBBF8 \uC885\uB8CC\uB410\uAC70\uB098, Claude Code\uAC00 \uC544\uC9C1 \uC11C\uBC84\uB97C \uC2DC\uC791\uD558\uC9C0 \uC54A\uC740 \uC0C1\uD0DC\uC77C \uC218 \uC788\uC2B5\uB2C8\uB2E4.",
1165
- killed: (server, n) => `\u2713 ${server} \uC885\uB8CC\uB428 (${n}\uAC1C \uD504\uB85C\uC138\uC2A4)`,
1166
- killedHint: " Claude Code\uAC00 \uB2E4\uC74C \uB3C4\uAD6C \uD638\uCD9C \uC2DC \uC790\uB3D9\uC73C\uB85C \uC7AC\uC5F0\uACB0\uD569\uB2C8\uB2E4.",
1167
- verify: " \uC5F0\uACB0 \uD655\uC778: Claude Code\uC5D0\uC11C /mcp \uC2E4\uD589"
1166
+ codexNoProcessHint: " Codex\uC758 stdio transport\uAC00 \uC774\uBBF8 \uB2EB\uD614\uC2B5\uB2C8\uB2E4. \uC774 \uBA54\uC2DC\uC9C0\uB9CC\uC73C\uB85C \uC778\uC99D \uC2E4\uD328\uB97C \uB73B\uD558\uC9C0 \uC54A\uC73C\uBA70, \uC774 CLI\uC5D0\uC11C \uD604\uC7AC thread\uC5D0 \uB2E4\uC2DC \uBD99\uC77C \uC218 \uC5C6\uC2B5\uB2C8\uB2E4.",
1167
+ codexKilledHint: " \uD604\uC7AC Codex thread\uB294 \uC885\uB8CC\uD55C stdio \uC11C\uBC84\uC5D0 \uB2E4\uC2DC \uBD99\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uC0C8 thread\uB97C \uC2DC\uC791\uD558\uAC70\uB098 Codex\uB97C \uB2E4\uC2DC \uC5EC\uC138\uC694.",
1168
+ codexVerify: " \uD655\uC778: \uC0C8 Codex thread\uC5D0\uC11C mimi_seed_status \uD638\uCD9C",
1169
+ claudeNoProcessHint: " \uC774\uBBF8 \uC885\uB8CC\uB410\uAC70\uB098, Claude Code\uAC00 \uC544\uC9C1 \uC11C\uBC84\uB97C \uC2DC\uC791\uD558\uC9C0 \uC54A\uC740 \uC0C1\uD0DC\uC77C \uC218 \uC788\uC2B5\uB2C8\uB2E4.",
1170
+ claudeKilledHint: " Claude Code\uAC00 \uB2E4\uC74C \uB3C4\uAD6C \uD638\uCD9C \uC2DC \uC790\uB3D9\uC73C\uB85C \uC7AC\uC5F0\uACB0\uD569\uB2C8\uB2E4.",
1171
+ claudeVerify: " \uC5F0\uACB0 \uD655\uC778: Claude Code\uC5D0\uC11C /mcp \uC2E4\uD589",
1172
+ genericNoProcessHint: " stdio transport\uAC00 \uC774\uBBF8 \uB2EB\uD614\uC744 \uC218 \uC788\uC2B5\uB2C8\uB2E4. MCP \uD074\uB77C\uC774\uC5B8\uD2B8\uB97C \uB2E4\uC2DC \uC5F4\uC5B4 \uC5F0\uACB0\uD558\uC138\uC694.",
1173
+ genericKilledHint: " stdio \uC11C\uBC84\uB294 MCP \uD074\uB77C\uC774\uC5B8\uD2B8\uAC00 \uC18C\uC720\uD569\uB2C8\uB2E4. \uD074\uB77C\uC774\uC5B8\uD2B8\uB97C \uB2E4\uC2DC \uC5F4\uC5B4 \uC5F0\uACB0\uD558\uC138\uC694.",
1174
+ genericVerify: " \uC5F0\uACB0 \uD655\uC778: \uC0C8 \uC138\uC158\uC5D0\uC11C mimi_seed_status \uD638\uCD9C",
1175
+ unknownWriteOutcome: " \uC9C1\uC804 \uD638\uCD9C\uC774 \uC5C5\uB85C\uB4DC\xB7\uAC8C\uC2DC \uAC19\uC740 \uC4F0\uAE30\uC600\uB2E4\uBA74 \uACB0\uACFC\uAC00 \uBD88\uBA85\uC77C \uC218 \uC788\uC2B5\uB2C8\uB2E4. \uB300\uC0C1 \uC11C\uBE44\uC2A4\uC5D0\uC11C \uC2E4\uC81C \uBC18\uC601 \uC5EC\uBD80\uB97C \uD655\uC778\uD55C \uB4A4 \uC7AC\uC2DC\uB3C4\uD558\uC138\uC694.",
1176
+ killed: (server, n) => `\u2713 ${server} \uC885\uB8CC\uB428 (${n}\uAC1C \uD504\uB85C\uC138\uC2A4)`
1168
1177
  },
1169
1178
  {
1170
1179
  killedPid: (pid) => ` PID ${pid} killed`,
1171
1180
  title: (server) => `Restarting MCP server: ${server}`,
1172
1181
  none: "(none)",
1173
1182
  registered: (list) => ` Registered servers: ${list}`,
1174
- notFound: (server) => `Could not find the '${server}' server in ~/.claude/.claude.json.`,
1183
+ notFound: (server) => `Could not find the '${server}' server in any MCP config.`,
1184
+ searched: (paths) => ` Looked in: ${paths}`,
1185
+ noConfig: "(no config found)",
1175
1186
  httpServer: (server) => `'${server}' is an HTTP/SSE server. It does not need a process restart.`,
1176
1187
  httpHint: " Run /mcp in Claude Code to check the connection.",
1177
1188
  noMarker: "Could not find a process marker (script path).",
1178
1189
  configLine: (cfg) => ` Config: ${cfg}`,
1179
1190
  markerLine: (marker) => ` Marker: ${marker}`,
1180
1191
  noProcess: "\u26A0 No running process found.",
1181
- noProcessHint: " It may have already exited, or Claude Code may not have started the server yet.",
1182
- killed: (server, n) => `\u2713 ${server} killed (${n} process(es))`,
1183
- killedHint: " Claude Code will reconnect automatically on the next tool call.",
1184
- verify: " Verify the connection: run /mcp in Claude Code"
1192
+ codexNoProcessHint: " The Codex stdio transport is already closed. This message alone does not prove an auth failure, and this CLI cannot reattach the current thread.",
1193
+ codexKilledHint: " The current Codex thread cannot reattach to the terminated stdio server. Start a new thread or reopen Codex.",
1194
+ codexVerify: " Verify: call mimi_seed_status in a new Codex thread",
1195
+ claudeNoProcessHint: " It may have already exited, or Claude Code may not have started the server yet.",
1196
+ claudeKilledHint: " Claude Code will reconnect automatically on the next tool call.",
1197
+ claudeVerify: " Verify the connection: run /mcp in Claude Code",
1198
+ genericNoProcessHint: " The stdio transport may already be closed. Reopen the MCP client to reconnect.",
1199
+ genericKilledHint: " The MCP client owns the stdio server. Reopen the client to reconnect.",
1200
+ genericVerify: " Verify: call mimi_seed_status in a new session",
1201
+ unknownWriteOutcome: " If the previous call was a write such as an upload or publish, its outcome may be unknown. Check the target service before retrying.",
1202
+ killed: (server, n) => `\u2713 ${server} killed (${n} process(es))`
1185
1203
  }
1186
1204
  );
1187
- function readClaudeJson() {
1188
- const p = path.join(os.homedir(), ".claude.json");
1205
+ function readJson(filePath) {
1189
1206
  try {
1190
- return JSON.parse(fs.readFileSync(p, "utf8"));
1207
+ return JSON.parse(fs.readFileSync(filePath, "utf8"));
1191
1208
  } catch {
1192
1209
  return {};
1193
1210
  }
1194
1211
  }
1212
+ var BUILTIN_MIMI_SEED_SERVER = {
1213
+ command: "npx",
1214
+ args: ["-y", "@yoonion/mimi-seed-mcp"]
1215
+ };
1216
+ function detectMcpClient(env = process.env) {
1217
+ if (env.CODEX_THREAD_ID || env.CODEX_CI || env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE) return "codex";
1218
+ if (env.CLAUDECODE || env.CLAUDE_CODE || env.CLAUDE_CODE_ENTRYPOINT) return "claude-code";
1219
+ return "unknown";
1220
+ }
1221
+ function recoveryMessages(client, killed) {
1222
+ const m = M6();
1223
+ if (client === "codex") {
1224
+ return { hint: killed ? m.codexKilledHint : m.codexNoProcessHint, verify: m.codexVerify };
1225
+ }
1226
+ if (client === "claude-code") {
1227
+ return { hint: killed ? m.claudeKilledHint : m.claudeNoProcessHint, verify: m.claudeVerify };
1228
+ }
1229
+ return { hint: killed ? m.genericKilledHint : m.genericNoProcessHint, verify: m.genericVerify };
1230
+ }
1231
+ function resolveServerConfig(servers, serverName) {
1232
+ const configured = servers[serverName];
1233
+ if (configured) return configured;
1234
+ return serverName === "mimi-seed" ? BUILTIN_MIMI_SEED_SERVER : void 0;
1235
+ }
1236
+ function collectServers() {
1237
+ const servers = {};
1238
+ const sources = [];
1239
+ const add = (map, source) => {
1240
+ if (!map || typeof map !== "object") return;
1241
+ const entries = Object.entries(map);
1242
+ if (entries.length === 0) return;
1243
+ sources.push(source);
1244
+ for (const [name, cfg] of entries) if (!(name in servers)) servers[name] = cfg;
1245
+ };
1246
+ const projectDir = process.cwd();
1247
+ add(readJson(path.join(projectDir, ".mcp.json")).mcpServers, ".mcp.json");
1248
+ const home = readJson(path.join(os.homedir(), ".claude.json"));
1249
+ const projects = home.projects;
1250
+ add(projects?.[projectDir]?.mcpServers, "~/.claude.json (projects)");
1251
+ add(home.mcpServers, "~/.claude.json");
1252
+ return { servers, sources };
1253
+ }
1195
1254
  function findProcessMarker(cfg) {
1196
1255
  const args = cfg.args;
1197
1256
  if (!args) return null;
@@ -1202,10 +1261,41 @@ function findProcessMarker(cfg) {
1202
1261
  const meaningful = args.filter((a) => !a.startsWith("-") && a !== "/c" && a !== "npx" && a !== "cmd");
1203
1262
  return meaningful.at(-1) ?? null;
1204
1263
  }
1205
- function killByMarker(marker) {
1264
+ function candidateMarkers(cfg) {
1265
+ const primary = findProcessMarker(cfg);
1266
+ if (!primary) return [];
1267
+ const base = primary.split("/").pop();
1268
+ return base && base !== primary ? [primary, base] : [primary];
1269
+ }
1270
+ function findPids(markers) {
1271
+ let out;
1272
+ try {
1273
+ out = execSync2("ps -eo pid=,args=", { encoding: "utf8", stdio: ["pipe", "pipe", "pipe"] });
1274
+ } catch {
1275
+ return [];
1276
+ }
1277
+ const skip = /* @__PURE__ */ new Set([process.pid, process.ppid]);
1278
+ const pids = [];
1279
+ for (const line of out.split("\n")) {
1280
+ const m = /^\s*(\d+)\s+(.*)$/.exec(line);
1281
+ if (!m) continue;
1282
+ const pid = Number(m[1]);
1283
+ if (skip.has(pid)) continue;
1284
+ const argv = m[2].split(/\s+/).filter(Boolean);
1285
+ const exeBase = path.basename(argv[0] ?? "");
1286
+ const rest = argv.slice(1);
1287
+ const hit = markers.some((marker) => {
1288
+ const base = path.basename(marker);
1289
+ return exeBase === base || rest.includes(marker) || rest.some((a) => path.basename(a) === base);
1290
+ });
1291
+ if (hit) pids.push(pid);
1292
+ }
1293
+ return pids;
1294
+ }
1295
+ function killByMarkers(markers) {
1206
1296
  const isWin = os.platform() === "win32";
1207
1297
  if (isWin) {
1208
- const escaped = marker.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
1298
+ const escaped = markers[0].replace(/\\/g, "\\\\").replace(/'/g, "\\'");
1209
1299
  let pids;
1210
1300
  try {
1211
1301
  const out = execSync2(
@@ -1227,24 +1317,29 @@ function killByMarker(marker) {
1227
1317
  }
1228
1318
  return { killed };
1229
1319
  } else {
1230
- try {
1231
- execSync2(`pkill -f "${marker}"`, { stdio: "pipe" });
1232
- return { killed: 1 };
1233
- } catch {
1234
- return { killed: 0 };
1320
+ let killed = 0;
1321
+ for (const pid of findPids(markers)) {
1322
+ try {
1323
+ process.kill(pid, "SIGTERM");
1324
+ log3(kleur7.dim(M6().killedPid(String(pid))));
1325
+ killed += 1;
1326
+ } catch {
1327
+ }
1235
1328
  }
1329
+ return { killed };
1236
1330
  }
1237
1331
  }
1238
1332
  async function cmdRestart(args) {
1239
1333
  const serverName = args[0] ?? "mimi-seed";
1240
1334
  log3(kleur7.bold(M6().title(serverName)));
1241
1335
  log3("");
1242
- const d = readClaudeJson();
1243
- const servers = d.mcpServers;
1244
- const cfg = servers?.[serverName];
1336
+ const { servers, sources } = collectServers();
1337
+ const cfg = resolveServerConfig(servers, serverName);
1245
1338
  if (!cfg) {
1246
- const available = servers ? Object.keys(servers).join(", ") : M6().none;
1339
+ const names = Object.keys(servers);
1340
+ const available = names.length ? names.join(", ") : M6().none;
1247
1341
  log3(kleur7.red(M6().notFound(serverName)));
1342
+ log3(kleur7.dim(M6().searched(sources.length ? sources.join(", ") : M6().noConfig)));
1248
1343
  log3(kleur7.dim(M6().registered(available)));
1249
1344
  process.exit(1);
1250
1345
  }
@@ -1253,24 +1348,27 @@ async function cmdRestart(args) {
1253
1348
  log3(kleur7.dim(M6().httpHint));
1254
1349
  return;
1255
1350
  }
1256
- const marker = findProcessMarker(cfg);
1351
+ const markers = candidateMarkers(cfg);
1352
+ const marker = markers[0] ?? null;
1257
1353
  if (!marker) {
1258
1354
  log3(kleur7.yellow(M6().noMarker));
1259
1355
  log3(kleur7.dim(M6().configLine(JSON.stringify(cfg))));
1260
1356
  process.exit(1);
1261
1357
  }
1262
1358
  log3(kleur7.dim(M6().markerLine(marker)));
1263
- const { killed } = killByMarker(marker);
1359
+ const { killed } = killByMarkers(markers);
1360
+ const recovery = recoveryMessages(detectMcpClient(), killed > 0);
1264
1361
  if (killed === 0) {
1265
1362
  log3(kleur7.yellow(M6().noProcess));
1266
- log3(kleur7.dim(M6().noProcessHint));
1363
+ log3(kleur7.dim(recovery.hint));
1364
+ log3(kleur7.yellow(M6().unknownWriteOutcome));
1267
1365
  } else {
1268
1366
  log3("");
1269
1367
  log3(kleur7.green(M6().killed(serverName, killed)));
1270
- log3(kleur7.dim(M6().killedHint));
1368
+ log3(kleur7.dim(recovery.hint));
1271
1369
  }
1272
1370
  log3("");
1273
- log3(kleur7.cyan(M6().verify));
1371
+ log3(kleur7.cyan(recovery.verify));
1274
1372
  }
1275
1373
 
1276
1374
  // src/mcp-config.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mimi-seed",
3
- "version": "0.15.3",
3
+ "version": "0.15.5",
4
4
  "description": "Mimi Seed CLI \u2014 Claude Code\uc640 Codex\uc5d0\uc11c \uc571 \ucd9c\uc2dc \uc6b4\uc601\uc744 \uad00\ub9ac\ud569\ub2c8\ub2e4.",
5
5
  "bin": {
6
6
  "mimi-seed": "dist/index.js"