genetics-mcp 2.16.3 → 2.16.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.
- package/genetics.mjs +22 -5
- package/package.json +1 -1
package/genetics.mjs
CHANGED
|
@@ -109,7 +109,15 @@ Object.assign(cfg, Object.fromEntries(
|
|
|
109
109
|
|
|
110
110
|
// **기본 주소를 두지 않는다.** 값을 박아 두면 출하물이 "그 서버를 아는 클라이언트" 가 되고,
|
|
111
111
|
// 공개 배포 시 운영 엔드포인트가 그대로 공개된다. 주소는 쓰는 쪽이 정한다.
|
|
112
|
-
|
|
112
|
+
// 로그인 자격이 이미 주소를 들고 있으면(`credentials.json` 의 `base`) 그것을 쓴다 —
|
|
113
|
+
// 사람이 승인한 그 서버다. 출하 기본값이 아니다.
|
|
114
|
+
const BASE = (cfg.GENETICS_API_BASE || '').replace(/\/$/, '')
|
|
115
|
+
|| (() => {
|
|
116
|
+
try {
|
|
117
|
+
const p = cfg0.GENETICS_CRED || path.join(path.dirname(ENV_FILE), 'credentials.json');
|
|
118
|
+
return String(JSON.parse(fs.readFileSync(p, 'utf8')).base || '').replace(/\/$/, '');
|
|
119
|
+
} catch { return ''; }
|
|
120
|
+
})();
|
|
113
121
|
const KEY = cfg.GENETICS_API_KEY || '';
|
|
114
122
|
|
|
115
123
|
/* ── 자격은 두 갈래다 ────────────────────────────────────────────────────
|
|
@@ -1323,9 +1331,16 @@ function cursorActiveFromLedger() {
|
|
|
1323
1331
|
const dir = process.env.GCELL_STATE_DIR || path.join(os.homedir(), '.config', 'genetics', 'cell');
|
|
1324
1332
|
let cwd = process.cwd();
|
|
1325
1333
|
try { cwd = fs.realpathSync(cwd); } catch { /* 없으면 준 값 */ }
|
|
1334
|
+
let home = os.homedir();
|
|
1335
|
+
try { home = fs.realpathSync(home); } catch { /* */ }
|
|
1336
|
+
// 전역 `npx genetics-mcp` 헬퍼는 cwd 가 집 또는 `/` 다(2026-08-31 pid 28342 실측).
|
|
1337
|
+
// 그때는 뿌리 일치가 원천적으로 불가능하니, 6시간 안 장부 중 **가장 최근 훅**을 쓴다.
|
|
1338
|
+
// 창이 여럿이면 마지막에 훅이 돈 대화다 — 지금 도구를 부른 창과 같다.
|
|
1339
|
+
const vague = !cwd || cwd === '/' || cwd === home;
|
|
1326
1340
|
let names;
|
|
1327
1341
|
try { names = fs.readdirSync(dir); } catch { return { id: '', folder: '' }; }
|
|
1328
|
-
|
|
1342
|
+
const matched = [];
|
|
1343
|
+
const recent = [];
|
|
1329
1344
|
for (const name of names) {
|
|
1330
1345
|
if (!name.startsWith('active-cursor-') || !name.endsWith('.json')) continue;
|
|
1331
1346
|
let v;
|
|
@@ -1335,10 +1350,12 @@ function cursorActiveFromLedger() {
|
|
|
1335
1350
|
if (!root || !/^[0-9a-f-]{36}$/i.test(id)) continue;
|
|
1336
1351
|
const at = Number(v.at || 0);
|
|
1337
1352
|
if (at && (Date.now() / 1000) - at > 6 * 3600) continue;
|
|
1338
|
-
|
|
1339
|
-
|
|
1353
|
+
const row = { id, folder: root, at };
|
|
1354
|
+
recent.push(row);
|
|
1355
|
+
if (cwd === root || cwd.startsWith(root + path.sep)) matched.push(row);
|
|
1340
1356
|
}
|
|
1341
|
-
|
|
1357
|
+
const pick = (rows) => rows.sort((a, b) => b.at - a.at)[0] || null;
|
|
1358
|
+
return pick(matched) || (vague ? pick(recent) : null) || { id: '', folder: '' };
|
|
1342
1359
|
}
|
|
1343
1360
|
|
|
1344
1361
|
/* ── Cursor 신원 ──────────────────────────────────────────────────────────
|