inkmap-mcp 0.3.15 → 0.3.17
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/bundles/antigravity/plugin.json +1 -1
- package/dist/bundles/antigravity/sidecars/inkmap/bridge.js +7 -4
- package/dist/bundles/antigravity/sidecars/inkmap/main.mjs +131 -82
- package/dist/bundles/antigravity/sidecars/inkmap/sidecar.json +1 -6
- package/dist/bundles/codex/inkmap-codex/.codex-plugin/plugin.json +1 -1
- package/dist/bundles/codex/inkmap-codex/plugin.json +1 -1
- package/dist/bundles/harness/README.md +3 -3
- package/dist/bundles/harness/README.zh.md +3 -3
- package/dist/bundles/harness/client.js +8 -6
- package/dist/bundles/harness/host.js +131 -59
- package/dist/bundles/harness/package.json +2 -2
- package/dist/bundles/vscode/dist/extension.js +172 -60
- package/dist/bundles/vscode/package.json +6 -1
- package/dist/cli.cjs +268 -131
- package/dist/codex.html +722 -669
- package/dist/web/app.js +23270 -22557
- package/dist/web/index.html +44 -4
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -411,13 +411,13 @@ ${line}---
|
|
|
411
411
|
else {
|
|
412
412
|
const section = norm.match(SETTINGS_SECTION);
|
|
413
413
|
if (!section)
|
|
414
|
-
updated = norm.replace(/---\n$/, `inkmap:
|
|
414
|
+
updated = norm.replace(/---\n$/, () => `inkmap:
|
|
415
415
|
${line}---
|
|
416
416
|
`);
|
|
417
417
|
else {
|
|
418
418
|
const keyLine = new RegExp(`^[ \\t]+${key}:.*\\n`, "m");
|
|
419
|
-
const body = keyLine.test(section[1]) ? section[1].replace(keyLine, line) : section[1] + line;
|
|
420
|
-
updated = norm.replace(SETTINGS_SECTION, `inkmap:
|
|
419
|
+
const body = keyLine.test(section[1]) ? section[1].replace(keyLine, () => line) : section[1] + line;
|
|
420
|
+
updated = norm.replace(SETTINGS_SECTION, () => `inkmap:
|
|
421
421
|
${body}`);
|
|
422
422
|
}
|
|
423
423
|
}
|
|
@@ -466,7 +466,7 @@ var INKMAP_VERSION;
|
|
|
466
466
|
var init_version = __esm({
|
|
467
467
|
"packages/cli/dist/version.js"() {
|
|
468
468
|
"use strict";
|
|
469
|
-
INKMAP_VERSION = "0.3.
|
|
469
|
+
INKMAP_VERSION = "0.3.17";
|
|
470
470
|
}
|
|
471
471
|
});
|
|
472
472
|
|
|
@@ -561,6 +561,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
561
561
|
let detectedHost = defaultHost;
|
|
562
562
|
const pendingEvents = /* @__PURE__ */ new Map();
|
|
563
563
|
let lastCheck = 0;
|
|
564
|
+
let retryAfter = 0;
|
|
564
565
|
let fastPollUntil = 0;
|
|
565
566
|
const expectPurchase = () => void (fastPollUntil = Date.now() + 15 * 6e4);
|
|
566
567
|
let flowCreation;
|
|
@@ -762,6 +763,24 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
762
763
|
timer = setTimeout(() => void refresh(), delay);
|
|
763
764
|
timer.unref();
|
|
764
765
|
}
|
|
766
|
+
async function rememberProCheck(token, active, account) {
|
|
767
|
+
await writeSession(async () => {
|
|
768
|
+
let record2;
|
|
769
|
+
try {
|
|
770
|
+
record2 = JSON.parse(await storage.read() || "{}");
|
|
771
|
+
} catch {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
if (record2.token !== token)
|
|
775
|
+
return;
|
|
776
|
+
const at = typeof record2.proVerifiedAt === "number" ? record2.proVerifiedAt : void 0;
|
|
777
|
+
if (active ? at !== void 0 && Date.now() - at < PRO_RECHECK_STAMP_MS && at <= Date.now() : at === void 0)
|
|
778
|
+
return;
|
|
779
|
+
const { proVerifiedAt: _at, proAccount: _account, ...rest } = record2;
|
|
780
|
+
await storage.write(JSON.stringify(active ? { ...rest, proVerifiedAt: Date.now(), ...account && { proAccount: account } } : rest));
|
|
781
|
+
}).catch(() => {
|
|
782
|
+
});
|
|
783
|
+
}
|
|
765
784
|
function refresh() {
|
|
766
785
|
if (connection)
|
|
767
786
|
return connection;
|
|
@@ -769,6 +788,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
769
788
|
connection = (async () => {
|
|
770
789
|
let token;
|
|
771
790
|
let delay = 6e4;
|
|
791
|
+
let offlinePro;
|
|
772
792
|
try {
|
|
773
793
|
const origin = billingOrigin(getOrigin());
|
|
774
794
|
if (origin !== activeOrigin) {
|
|
@@ -785,6 +805,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
785
805
|
if (record2.origin !== origin || typeof record2.token !== "string")
|
|
786
806
|
return update(false);
|
|
787
807
|
token = record2.token;
|
|
808
|
+
const verifiedAt = record2.proVerifiedAt;
|
|
809
|
+
if (typeof verifiedAt === "number" && verifiedAt <= Date.now() && Date.now() - verifiedAt < OFFLINE_PRO_GRACE_MS) {
|
|
810
|
+
offlinePro = { ...typeof record2.proAccount === "string" && { account: record2.proAccount.slice(0, 64) } };
|
|
811
|
+
}
|
|
788
812
|
const response = await entitlement(origin, record2.token);
|
|
789
813
|
if (version2 !== generation || disposed)
|
|
790
814
|
return;
|
|
@@ -804,9 +828,14 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
804
828
|
if (version2 !== generation || disposed)
|
|
805
829
|
return;
|
|
806
830
|
applyEntitlement(state);
|
|
807
|
-
|
|
831
|
+
void rememberProCheck(record2.token, current.pro, current.account);
|
|
832
|
+
delay = state.active !== true && (state.pending === true || Date.now() < fastPollUntil) ? 2500 : 6e4;
|
|
808
833
|
} catch {
|
|
809
|
-
if (version2 === generation
|
|
834
|
+
if (version2 === generation)
|
|
835
|
+
retryAfter = Date.now() + (Date.now() < fastPollUntil ? 2e3 : 3e4);
|
|
836
|
+
if (version2 === generation && offlinePro)
|
|
837
|
+
update(true, true, offlinePro.account);
|
|
838
|
+
else if (version2 === generation && Date.now() - lastCheck > 15 * 6e4)
|
|
810
839
|
update(false);
|
|
811
840
|
} finally {
|
|
812
841
|
if (version2 === generation && token)
|
|
@@ -845,7 +874,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
845
874
|
clearTimeout(waitTimer);
|
|
846
875
|
if (disposed || !waiting.length)
|
|
847
876
|
return;
|
|
848
|
-
waitTimer = setTimeout(() => void checkWaiting(), delay);
|
|
877
|
+
waitTimer = setTimeout(() => void checkWaiting().catch(() => scheduleWait(WAIT_SLOW_MS)), delay);
|
|
849
878
|
waitTimer.unref();
|
|
850
879
|
}
|
|
851
880
|
async function checkWaiting() {
|
|
@@ -886,8 +915,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
886
915
|
await writeSession(async () => {
|
|
887
916
|
if (disposed || round !== waitRound || w2.origin !== billingOrigin(getOrigin()))
|
|
888
917
|
return;
|
|
889
|
-
|
|
918
|
+
if (w2.email)
|
|
919
|
+
lastSignIn = w2.email.trim().slice(0, 254);
|
|
890
920
|
await storage.write(sessionRecord({ origin: w2.origin, token: w2.token }));
|
|
921
|
+
clearWaiting();
|
|
891
922
|
++generation;
|
|
892
923
|
activeOrigin = w2.origin;
|
|
893
924
|
applyEntitlement(body);
|
|
@@ -924,6 +955,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
924
955
|
}
|
|
925
956
|
if (typeof record2.token !== "string" || typeof record2.origin !== "string")
|
|
926
957
|
return;
|
|
958
|
+
if (typeof record2.checkoutUrl === "string")
|
|
959
|
+
return;
|
|
927
960
|
const response = await entitlement(record2.origin, record2.token).catch(() => null);
|
|
928
961
|
if (!response?.ok)
|
|
929
962
|
return;
|
|
@@ -956,13 +989,20 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
956
989
|
return;
|
|
957
990
|
}
|
|
958
991
|
if (process.env.INKMAP_ALLOW_TEST_TELEMETRY !== "1") {
|
|
959
|
-
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT)
|
|
960
|
-
return;
|
|
961
|
-
const customHome = process.env.INKMAP_HOME || "";
|
|
962
|
-
const sysTmp = (0, import_node_os.tmpdir)();
|
|
963
|
-
if (customHome && (customHome === sysTmp || customHome.startsWith(sysTmp + import_node_path.sep) || customHome.startsWith("/tmp/") || customHome.startsWith("/private/tmp/") || customHome.includes("/var/folders/") || customHome.includes("inkmap-npm-isolated-") || customHome.includes("inkmap-antigravity-mcp-") || customHome.includes("inkmap-local-editor-") || customHome.includes("inkmap-harness-"))) {
|
|
992
|
+
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT || process.env.VITEST || process.env.JEST_WORKER_ID || process.env.CI === "true" || process.env.CI === "1") {
|
|
964
993
|
return;
|
|
965
994
|
}
|
|
995
|
+
const norm = (p2) => {
|
|
996
|
+
const clean = p2.replace(/\\/g, "/");
|
|
997
|
+
return process.platform === "win32" ? clean.toLowerCase() : clean;
|
|
998
|
+
};
|
|
999
|
+
const sysTmp = norm((0, import_node_os.tmpdir)()).replace(/\/+$/, "");
|
|
1000
|
+
const homesToCheck = [process.env.INKMAP_HOME || "", (0, import_node_os.homedir)()].filter(Boolean).map(norm);
|
|
1001
|
+
for (const h2 of homesToCheck) {
|
|
1002
|
+
if (h2 === sysTmp || h2.startsWith(sysTmp + "/") || h2.startsWith("/tmp/") || h2.startsWith("/private/tmp/") || h2.includes("/var/folders/") || h2.includes("/appdata/local/temp/") || h2.includes("/temp/inkmap") || h2.includes("inkmap-npm-isolated-") || h2.includes("inkmap-antigravity-mcp-") || h2.includes("inkmap-local-editor-") || h2.includes("inkmap-harness-") || h2.includes("inkmap-test-")) {
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
966
1006
|
}
|
|
967
1007
|
const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
|
|
968
1008
|
if (disposed || !id || !pendingEvents.size)
|
|
@@ -996,8 +1036,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
996
1036
|
return {
|
|
997
1037
|
async state() {
|
|
998
1038
|
await (trial ??= startTrial());
|
|
999
|
-
const interval = !current.pro && Date.now() < fastPollUntil ?
|
|
1000
|
-
if (Date.now() - lastCheck >= interval)
|
|
1039
|
+
const interval = !current.pro && Date.now() < fastPollUntil ? 2e3 : 6e4;
|
|
1040
|
+
if (Date.now() - lastCheck >= interval && Date.now() >= retryAfter)
|
|
1001
1041
|
await refresh();
|
|
1002
1042
|
await parkUnpaidSession();
|
|
1003
1043
|
return current;
|
|
@@ -1066,7 +1106,9 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
1066
1106
|
if (cachedOrder && cachedOrder.origin === origin && cachedOrder.locale === loc && Date.now() - cachedOrder.at < 8e3) {
|
|
1067
1107
|
const hit = cachedOrder.result;
|
|
1068
1108
|
cachedOrder = void 0;
|
|
1069
|
-
|
|
1109
|
+
if (current.pro)
|
|
1110
|
+
return { status: "active", state: current };
|
|
1111
|
+
schedule(hit.status === "qr" || hit.status === "redirect" ? 2500 : 6e4);
|
|
1070
1112
|
return hit;
|
|
1071
1113
|
}
|
|
1072
1114
|
const version2 = generation;
|
|
@@ -1077,6 +1119,17 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
1077
1119
|
record2 = JSON.parse(stored);
|
|
1078
1120
|
} catch {
|
|
1079
1121
|
}
|
|
1122
|
+
if (record2?.origin === origin && typeof record2.token === "string") {
|
|
1123
|
+
const rights = await entitlement(origin, record2.token).catch(() => null);
|
|
1124
|
+
if (rights?.ok) {
|
|
1125
|
+
const ent = await rights.json().catch(() => null);
|
|
1126
|
+
if (ent && ent.active === true) {
|
|
1127
|
+
applyEntitlement(ent);
|
|
1128
|
+
schedule(6e4);
|
|
1129
|
+
return { status: "active", state: current };
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1080
1133
|
const requestOrder = async (checkoutUrl, token, cookie, persist) => {
|
|
1081
1134
|
const res = await checkoutPost(checkoutUrl, "order", origin, {}, token, cookie, localeHint);
|
|
1082
1135
|
if (res.status === 401 || res.status === 403 || res.status === 404 || res.status === 410)
|
|
@@ -1274,13 +1327,16 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
1274
1327
|
if (version2 !== generation || disposed || origin !== billingOrigin(getOrigin()))
|
|
1275
1328
|
return phoneFailure();
|
|
1276
1329
|
clearWaiting();
|
|
1330
|
+
const clean = phone.trim().slice(0, 254);
|
|
1331
|
+
if (clean)
|
|
1332
|
+
lastSignIn = clean;
|
|
1277
1333
|
await storage.write(sessionRecord({ origin, token, ...checkoutUrl && { checkoutUrl }, ...cookie && { cookie } }));
|
|
1278
1334
|
++generation;
|
|
1279
1335
|
activeOrigin = origin;
|
|
1280
1336
|
applyEntitlement(state);
|
|
1281
1337
|
if (cachedOrder?.result.status === "active")
|
|
1282
1338
|
cachedOrder.result.state = current;
|
|
1283
|
-
schedule(cachedOrder?.result.status === "qr" ?
|
|
1339
|
+
schedule(cachedOrder?.result.status === "qr" || cachedOrder?.result.status === "redirect" ? 2500 : 6e4);
|
|
1284
1340
|
return { ok: true, value: current };
|
|
1285
1341
|
});
|
|
1286
1342
|
} catch {
|
|
@@ -1431,7 +1487,7 @@ async function localTrialDeadline() {
|
|
|
1431
1487
|
const started = Number(value);
|
|
1432
1488
|
return Number.isSafeInteger(started) && started > 0 && started <= Date.now() ? started + TRIAL_MS : void 0;
|
|
1433
1489
|
}
|
|
1434
|
-
var import_node_child_process, import_promises, import_node_crypto, import_node_os, import_node_path, ZH_LOCALE_RE, EN_LOCALE_RE, cachedOsLocale, WAIT_FAST_MS, WAIT_SLOW_MS, WAIT_FAST_FOR_MS, WAIT_MAX_MS, MAX_WAITING, DOMESTIC_TIME_ZONE, posixLocale, PASSIVE_TELEMETRY_EVENTS;
|
|
1490
|
+
var import_node_child_process, import_promises, import_node_crypto, import_node_os, import_node_path, ZH_LOCALE_RE, EN_LOCALE_RE, cachedOsLocale, WAIT_FAST_MS, WAIT_SLOW_MS, WAIT_FAST_FOR_MS, WAIT_MAX_MS, MAX_WAITING, OFFLINE_PRO_GRACE_MS, PRO_RECHECK_STAMP_MS, DOMESTIC_TIME_ZONE, posixLocale, PASSIVE_TELEMETRY_EVENTS;
|
|
1435
1491
|
var init_license = __esm({
|
|
1436
1492
|
"packages/cli/dist/license.js"() {
|
|
1437
1493
|
"use strict";
|
|
@@ -1449,12 +1505,59 @@ var init_license = __esm({
|
|
|
1449
1505
|
WAIT_FAST_FOR_MS = 30 * 6e4;
|
|
1450
1506
|
WAIT_MAX_MS = 3 * 24 * 60 * 6e4;
|
|
1451
1507
|
MAX_WAITING = 5;
|
|
1508
|
+
OFFLINE_PRO_GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
1509
|
+
PRO_RECHECK_STAMP_MS = 12 * 60 * 6e4;
|
|
1452
1510
|
DOMESTIC_TIME_ZONE = /^(Asia\/(Shanghai|Chongqing|Chungking|Harbin|Urumqi|Beijing)|PRC)$/i;
|
|
1453
1511
|
posixLocale = (env) => (env.LC_ALL || env.LC_MESSAGES || env.LANG || "").trim();
|
|
1454
1512
|
PASSIVE_TELEMETRY_EVENTS = /* @__PURE__ */ new Set(["plugin_activate", "plugin_install", "onboarding_view"]);
|
|
1455
1513
|
}
|
|
1456
1514
|
});
|
|
1457
1515
|
|
|
1516
|
+
// packages/cli/dist/open-browser.js
|
|
1517
|
+
function run(cmd, args, launched = false) {
|
|
1518
|
+
return new Promise((done) => {
|
|
1519
|
+
const child = (0, import_node_child_process2.spawn)(cmd, args, { stdio: "ignore", detached: true });
|
|
1520
|
+
child.on("error", () => done(false));
|
|
1521
|
+
if (launched)
|
|
1522
|
+
child.on("spawn", () => done(true));
|
|
1523
|
+
else
|
|
1524
|
+
child.on("exit", (code) => done(code === 0));
|
|
1525
|
+
child.unref();
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
function openSystemBrowser(url2) {
|
|
1529
|
+
if (process.env.INKMAP_NO_OPEN === "1")
|
|
1530
|
+
return;
|
|
1531
|
+
const [cmd, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
1532
|
+
void run(cmd, args, true);
|
|
1533
|
+
}
|
|
1534
|
+
async function openBrowserWindow(url2) {
|
|
1535
|
+
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url2))
|
|
1536
|
+
return;
|
|
1537
|
+
if (process.platform === "darwin") {
|
|
1538
|
+
if (await run("open", ["-a", "Google Chrome", url2]))
|
|
1539
|
+
return;
|
|
1540
|
+
await run("open", [url2]);
|
|
1541
|
+
return;
|
|
1542
|
+
}
|
|
1543
|
+
if (process.platform === "win32") {
|
|
1544
|
+
if (await run("cmd", ["/c", "start", "", "chrome", url2]))
|
|
1545
|
+
return;
|
|
1546
|
+
await run("cmd", ["/c", "start", "", url2]);
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
if (await run("google-chrome", [url2], true))
|
|
1550
|
+
return;
|
|
1551
|
+
await run("xdg-open", [url2], true);
|
|
1552
|
+
}
|
|
1553
|
+
var import_node_child_process2;
|
|
1554
|
+
var init_open_browser = __esm({
|
|
1555
|
+
"packages/cli/dist/open-browser.js"() {
|
|
1556
|
+
"use strict";
|
|
1557
|
+
import_node_child_process2 = require("node:child_process");
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
|
|
1458
1561
|
// packages/cli/dist/workspace-fs.js
|
|
1459
1562
|
function insideOrEqual(root, target) {
|
|
1460
1563
|
if (root === target)
|
|
@@ -1471,11 +1574,10 @@ function hasHiddenSegment(root, target) {
|
|
|
1471
1574
|
async function hasSymlinkUnderRoot(realRoot, rawTarget) {
|
|
1472
1575
|
let cur = rawTarget;
|
|
1473
1576
|
while (cur && cur !== (0, import_node_path2.dirname)(cur)) {
|
|
1474
|
-
const st = await (0, import_promises2.lstat)(cur);
|
|
1475
|
-
if (st.isSymbolicLink())
|
|
1476
|
-
return true;
|
|
1477
1577
|
if (await (0, import_promises2.realpath)(cur) === realRoot)
|
|
1478
1578
|
return false;
|
|
1579
|
+
if ((await (0, import_promises2.lstat)(cur)).isSymbolicLink())
|
|
1580
|
+
return true;
|
|
1479
1581
|
cur = (0, import_node_path2.dirname)(cur);
|
|
1480
1582
|
}
|
|
1481
1583
|
return false;
|
|
@@ -1782,13 +1884,18 @@ async function fileSource(file2, log = () => {
|
|
|
1782
1884
|
log(`\u5DF2\u5199\u56DE ${path}`);
|
|
1783
1885
|
},
|
|
1784
1886
|
watch(onChange) {
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1887
|
+
try {
|
|
1888
|
+
const watcher = (0, import_node_fs.watch)(dir, (_2, changed) => {
|
|
1889
|
+
if (!changed || changed === (0, import_node_path3.basename)(path))
|
|
1890
|
+
onChange();
|
|
1891
|
+
});
|
|
1892
|
+
watcher.on("error", () => {
|
|
1893
|
+
});
|
|
1894
|
+
return () => watcher.close();
|
|
1895
|
+
} catch {
|
|
1896
|
+
return () => {
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1792
1899
|
},
|
|
1793
1900
|
readView: () => readDiskViewState(path),
|
|
1794
1901
|
writeView: (state) => writeDiskViewState(path, state)
|
|
@@ -1806,33 +1913,8 @@ function within(root, rel, allowAbsoluteInRoot = false) {
|
|
|
1806
1913
|
const full = allowAbsoluteInRoot && /^(?:[\\/]|[A-Za-z]:[\\/])/.test(decoded) ? (0, import_node_path3.normalize)(decoded) : (0, import_node_path3.normalize)((0, import_node_path3.join)(resolvedRoot, decoded));
|
|
1807
1914
|
return full.startsWith(base) ? full : null;
|
|
1808
1915
|
}
|
|
1809
|
-
async function openBrowserWindow(url2) {
|
|
1810
|
-
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url2))
|
|
1811
|
-
return;
|
|
1812
|
-
const run = (cmd, args) => new Promise((done) => {
|
|
1813
|
-
const child = (0, import_node_child_process2.spawn)(cmd, args, { stdio: "ignore", detached: true });
|
|
1814
|
-
child.on("error", () => done(false));
|
|
1815
|
-
child.on("exit", (code) => done(code === 0));
|
|
1816
|
-
child.unref();
|
|
1817
|
-
});
|
|
1818
|
-
if (process.platform === "darwin") {
|
|
1819
|
-
if (await run("open", ["-a", "Google Chrome", url2]))
|
|
1820
|
-
return;
|
|
1821
|
-
await run("open", [url2]);
|
|
1822
|
-
return;
|
|
1823
|
-
}
|
|
1824
|
-
if (process.platform === "win32") {
|
|
1825
|
-
if (await run("cmd", ["/c", "start", "", "chrome", url2]))
|
|
1826
|
-
return;
|
|
1827
|
-
await run("cmd", ["/c", "start", "", url2]);
|
|
1828
|
-
return;
|
|
1829
|
-
}
|
|
1830
|
-
if (await run("google-chrome", [url2]))
|
|
1831
|
-
return;
|
|
1832
|
-
await run("xdg-open", [url2]);
|
|
1833
|
-
}
|
|
1834
1916
|
async function serve({ source: initialSource, webRoot, port = 4377, host = "127.0.0.1", log = () => {
|
|
1835
|
-
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false,
|
|
1917
|
+
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, workspaceRoots = [], confineToWorkspaceRoots = false, openSource = (path) => fileSource(path, log), allowPurchase = true }) {
|
|
1836
1918
|
if (sidebar && host !== "127.0.0.1")
|
|
1837
1919
|
throw new Error("The sidebar bridge requires loopback.");
|
|
1838
1920
|
const prefix = sidebar ? `/s/${(0, import_node_crypto2.randomBytes)(24).toString("hex")}/` : "/";
|
|
@@ -2051,7 +2133,6 @@ data: ${JSON.stringify(data)}
|
|
|
2051
2133
|
if (url2.pathname === "/api/capabilities" && req.method === "GET") {
|
|
2052
2134
|
return json2(res, 200, {
|
|
2053
2135
|
purchase: canPurchase,
|
|
2054
|
-
...ideWorkspace && { ideWorkspace: true },
|
|
2055
2136
|
...sidebarAccountNavigation && { accountNavigation: "host" }
|
|
2056
2137
|
});
|
|
2057
2138
|
}
|
|
@@ -2072,6 +2153,8 @@ data: ${JSON.stringify(data)}
|
|
|
2072
2153
|
const { md, baseVersion } = JSON.parse(await readBody(req));
|
|
2073
2154
|
if (typeof md !== "string")
|
|
2074
2155
|
return json2(res, 400, { error: zh() ? "md \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3002" : "md must be a string." });
|
|
2156
|
+
if (Buffer.byteLength(md) > MAX_MARKDOWN_BYTES)
|
|
2157
|
+
return json2(res, 413, { error: zh() ? "\u6587\u6863\u8FC7\u5927\u3002" : "Document too large." });
|
|
2075
2158
|
if (!hasAccess(await license?.state() ?? { pro: false }))
|
|
2076
2159
|
return json2(res, 403, { error: "Inkmap trial expired" });
|
|
2077
2160
|
return await serialized(async () => {
|
|
@@ -2103,7 +2186,7 @@ data: ${JSON.stringify(data)}
|
|
|
2103
2186
|
if (!sameOriginWrite())
|
|
2104
2187
|
return json2(res, 403, { error: "forbidden" });
|
|
2105
2188
|
const { event } = JSON.parse(await readBody(req));
|
|
2106
|
-
if (typeof event === "string" && event)
|
|
2189
|
+
if (typeof event === "string" && /^[a-z][a-z0-9_]{0,39}$/.test(event))
|
|
2107
2190
|
license?.track?.(event);
|
|
2108
2191
|
return json2(res, 200, { ok: true });
|
|
2109
2192
|
}
|
|
@@ -2260,12 +2343,11 @@ data: ${JSON.stringify(data)}
|
|
|
2260
2343
|
})
|
|
2261
2344
|
};
|
|
2262
2345
|
}
|
|
2263
|
-
var
|
|
2346
|
+
var import_node_crypto2, import_node_fs, import_promises3, import_node_http, import_node_os3, import_node_path3, MAX_BODY, TYPES, HttpError, LOOPBACK_HOST, hash;
|
|
2264
2347
|
var init_server = __esm({
|
|
2265
2348
|
"packages/cli/dist/server.js"() {
|
|
2266
2349
|
"use strict";
|
|
2267
2350
|
init_dist();
|
|
2268
|
-
import_node_child_process2 = require("node:child_process");
|
|
2269
2351
|
import_node_crypto2 = require("node:crypto");
|
|
2270
2352
|
import_node_fs = require("node:fs");
|
|
2271
2353
|
import_promises3 = require("node:fs/promises");
|
|
@@ -2273,6 +2355,7 @@ var init_server = __esm({
|
|
|
2273
2355
|
import_node_os3 = require("node:os");
|
|
2274
2356
|
import_node_path3 = require("node:path");
|
|
2275
2357
|
init_license();
|
|
2358
|
+
init_open_browser();
|
|
2276
2359
|
init_workspace_fs();
|
|
2277
2360
|
MAX_BODY = 20 * 1024 * 1024;
|
|
2278
2361
|
TYPES = {
|
|
@@ -23652,7 +23735,7 @@ function visit(schema, fnOrHandlers) {
|
|
|
23652
23735
|
return h2 ? h2(node2, rewritten) : node2;
|
|
23653
23736
|
};
|
|
23654
23737
|
const cache = /* @__PURE__ */ new Map();
|
|
23655
|
-
function
|
|
23738
|
+
function run2(s) {
|
|
23656
23739
|
const cached2 = cache.get(s);
|
|
23657
23740
|
if (cached2 === RESOLVING) {
|
|
23658
23741
|
return new $ZodLazy({
|
|
@@ -23678,21 +23761,21 @@ function visit(schema, fnOrHandlers) {
|
|
|
23678
23761
|
let changed = false;
|
|
23679
23762
|
const newShape = {};
|
|
23680
23763
|
for (const k2 of keys) {
|
|
23681
|
-
const mapped =
|
|
23764
|
+
const mapped = run2(oldShape[k2]);
|
|
23682
23765
|
if (mapped !== oldShape[k2])
|
|
23683
23766
|
changed = true;
|
|
23684
23767
|
newShape[k2] = mapped;
|
|
23685
23768
|
}
|
|
23686
23769
|
let newCatchall = def.catchall;
|
|
23687
23770
|
if (def.catchall) {
|
|
23688
|
-
newCatchall =
|
|
23771
|
+
newCatchall = run2(def.catchall);
|
|
23689
23772
|
if (newCatchall !== def.catchall)
|
|
23690
23773
|
changed = true;
|
|
23691
23774
|
}
|
|
23692
23775
|
return changed ? clone(s, { ...def, shape: newShape, catchall: newCatchall }) : s;
|
|
23693
23776
|
}
|
|
23694
23777
|
case "array": {
|
|
23695
|
-
const mapped =
|
|
23778
|
+
const mapped = run2(def.element);
|
|
23696
23779
|
return mapped === def.element ? s : clone(s, { ...def, element: mapped });
|
|
23697
23780
|
}
|
|
23698
23781
|
case "tuple": {
|
|
@@ -23700,14 +23783,14 @@ function visit(schema, fnOrHandlers) {
|
|
|
23700
23783
|
let changed = false;
|
|
23701
23784
|
const newItems = [];
|
|
23702
23785
|
for (const item of oldItems) {
|
|
23703
|
-
const mapped =
|
|
23786
|
+
const mapped = run2(item);
|
|
23704
23787
|
if (mapped !== item)
|
|
23705
23788
|
changed = true;
|
|
23706
23789
|
newItems.push(mapped);
|
|
23707
23790
|
}
|
|
23708
23791
|
let newRest = def.rest;
|
|
23709
23792
|
if (def.rest) {
|
|
23710
|
-
newRest =
|
|
23793
|
+
newRest = run2(def.rest);
|
|
23711
23794
|
if (newRest !== def.rest)
|
|
23712
23795
|
changed = true;
|
|
23713
23796
|
}
|
|
@@ -23715,12 +23798,12 @@ function visit(schema, fnOrHandlers) {
|
|
|
23715
23798
|
}
|
|
23716
23799
|
case "record":
|
|
23717
23800
|
case "map": {
|
|
23718
|
-
const newKey =
|
|
23719
|
-
const newVal =
|
|
23801
|
+
const newKey = run2(def.keyType);
|
|
23802
|
+
const newVal = run2(def.valueType);
|
|
23720
23803
|
return newKey === def.keyType && newVal === def.valueType ? s : clone(s, { ...def, keyType: newKey, valueType: newVal });
|
|
23721
23804
|
}
|
|
23722
23805
|
case "set": {
|
|
23723
|
-
const newVal =
|
|
23806
|
+
const newVal = run2(def.valueType);
|
|
23724
23807
|
return newVal === def.valueType ? s : clone(s, { ...def, valueType: newVal });
|
|
23725
23808
|
}
|
|
23726
23809
|
case "union": {
|
|
@@ -23728,7 +23811,7 @@ function visit(schema, fnOrHandlers) {
|
|
|
23728
23811
|
let changed = false;
|
|
23729
23812
|
const newOptions = [];
|
|
23730
23813
|
for (const opt of oldOptions) {
|
|
23731
|
-
const mapped =
|
|
23814
|
+
const mapped = run2(opt);
|
|
23732
23815
|
if (mapped !== opt)
|
|
23733
23816
|
changed = true;
|
|
23734
23817
|
newOptions.push(mapped);
|
|
@@ -23736,8 +23819,8 @@ function visit(schema, fnOrHandlers) {
|
|
|
23736
23819
|
return changed ? clone(s, { ...def, options: newOptions }) : s;
|
|
23737
23820
|
}
|
|
23738
23821
|
case "intersection": {
|
|
23739
|
-
const newLeft =
|
|
23740
|
-
const newRight =
|
|
23822
|
+
const newLeft = run2(def.left);
|
|
23823
|
+
const newRight = run2(def.right);
|
|
23741
23824
|
return newLeft === def.left && newRight === def.right ? s : clone(s, { ...def, left: newLeft, right: newRight });
|
|
23742
23825
|
}
|
|
23743
23826
|
case "optional":
|
|
@@ -23749,23 +23832,23 @@ function visit(schema, fnOrHandlers) {
|
|
|
23749
23832
|
case "nonoptional":
|
|
23750
23833
|
case "promise":
|
|
23751
23834
|
case "success": {
|
|
23752
|
-
const newInner =
|
|
23835
|
+
const newInner = run2(def.innerType);
|
|
23753
23836
|
return newInner === def.innerType ? s : clone(s, { ...def, innerType: newInner });
|
|
23754
23837
|
}
|
|
23755
23838
|
case "pipe": {
|
|
23756
|
-
const newIn =
|
|
23757
|
-
const newOut =
|
|
23839
|
+
const newIn = run2(def.in);
|
|
23840
|
+
const newOut = run2(def.out);
|
|
23758
23841
|
return newIn === def.in && newOut === def.out ? s : clone(s, { ...def, in: newIn, out: newOut });
|
|
23759
23842
|
}
|
|
23760
23843
|
case "function": {
|
|
23761
|
-
const newInput =
|
|
23762
|
-
const newOutput =
|
|
23844
|
+
const newInput = run2(def.input);
|
|
23845
|
+
const newOutput = run2(def.output);
|
|
23763
23846
|
return newInput === def.input && newOutput === def.output ? s : clone(s, { ...def, input: newInput, output: newOutput });
|
|
23764
23847
|
}
|
|
23765
23848
|
case "lazy": {
|
|
23766
23849
|
const original = def.getter;
|
|
23767
23850
|
const { _cachedInner, ...rest } = def;
|
|
23768
|
-
return clone(s, { ...rest, getter: () =>
|
|
23851
|
+
return clone(s, { ...rest, getter: () => run2(original()) });
|
|
23769
23852
|
}
|
|
23770
23853
|
// A leaf by choice: `parts` are regex fragments, not data positions.
|
|
23771
23854
|
case "template_literal":
|
|
@@ -23796,7 +23879,7 @@ function visit(schema, fnOrHandlers) {
|
|
|
23796
23879
|
}
|
|
23797
23880
|
}
|
|
23798
23881
|
}
|
|
23799
|
-
return
|
|
23882
|
+
return run2(schema);
|
|
23800
23883
|
}
|
|
23801
23884
|
var RESOLVING;
|
|
23802
23885
|
var init_visit = __esm({
|
|
@@ -40490,15 +40573,6 @@ __export(codex_exports, {
|
|
|
40490
40573
|
function resolveWebRoot() {
|
|
40491
40574
|
return WEB_ROOT_CANDIDATES.find((dir) => (0, import_node_fs2.existsSync)((0, import_node_path5.join)(dir, "index.html"))) ?? null;
|
|
40492
40575
|
}
|
|
40493
|
-
function openSystemBrowser(url2) {
|
|
40494
|
-
if (process.env.INKMAP_NO_OPEN === "1")
|
|
40495
|
-
return;
|
|
40496
|
-
const [cmd, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
40497
|
-
const child = (0, import_node_child_process3.spawn)(cmd, args, { stdio: "ignore", detached: true });
|
|
40498
|
-
child.on("error", () => {
|
|
40499
|
-
});
|
|
40500
|
-
child.unref();
|
|
40501
|
-
}
|
|
40502
40576
|
async function validatedMarkdownFile(path) {
|
|
40503
40577
|
if (!path || !/\.md$/i.test(path))
|
|
40504
40578
|
throw new Error(say("\u8BF7\u9009\u62E9 .md \u6216 .markmap.md \u6587\u4EF6\u3002", "Choose a .md or .markmap.md file."));
|
|
@@ -40619,8 +40693,7 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
40619
40693
|
webRoot,
|
|
40620
40694
|
port: 0,
|
|
40621
40695
|
license: browserBilling,
|
|
40622
|
-
sidebar: false
|
|
40623
|
-
ideWorkspace: false
|
|
40696
|
+
sidebar: false
|
|
40624
40697
|
});
|
|
40625
40698
|
})();
|
|
40626
40699
|
fallbackEditors.set("__workspace__", pending);
|
|
@@ -40859,16 +40932,20 @@ async function serveCodex() {
|
|
|
40859
40932
|
server.server.onclose = () => {
|
|
40860
40933
|
void dispose();
|
|
40861
40934
|
};
|
|
40935
|
+
const shutdown = () => void dispose().finally(() => process.exit(0));
|
|
40936
|
+
process.stdin.once("end", shutdown);
|
|
40937
|
+
process.stdin.once("close", shutdown);
|
|
40938
|
+
process.once("SIGTERM", shutdown);
|
|
40939
|
+
process.once("SIGINT", shutdown);
|
|
40862
40940
|
await server.connect(transport);
|
|
40863
40941
|
}
|
|
40864
|
-
var
|
|
40942
|
+
var import_node_fs2, import_promises5, import_node_os4, import_node_path5, import_node_url3, UI, HTML, WEB_ROOT_CANDIDATES, INLINE_DOC_LIMIT, appOnly;
|
|
40865
40943
|
var init_codex = __esm({
|
|
40866
40944
|
"packages/cli/dist/codex.js"() {
|
|
40867
40945
|
"use strict";
|
|
40868
40946
|
init_mcp();
|
|
40869
40947
|
init_stdio2();
|
|
40870
40948
|
init_server4();
|
|
40871
|
-
import_node_child_process3 = require("node:child_process");
|
|
40872
40949
|
import_node_fs2 = require("node:fs");
|
|
40873
40950
|
import_promises5 = require("node:fs/promises");
|
|
40874
40951
|
import_node_os4 = require("node:os");
|
|
@@ -40878,6 +40955,7 @@ var init_codex = __esm({
|
|
|
40878
40955
|
init_dist();
|
|
40879
40956
|
init_license();
|
|
40880
40957
|
init_mcp_files();
|
|
40958
|
+
init_open_browser();
|
|
40881
40959
|
init_version();
|
|
40882
40960
|
init_workspace_fs();
|
|
40883
40961
|
init_server();
|
|
@@ -40905,14 +40983,14 @@ function probeCliCommand(cmd, args = ["--version"]) {
|
|
|
40905
40983
|
try {
|
|
40906
40984
|
if (process.platform === "win32" && !cmd.toLowerCase().endsWith(".exe")) {
|
|
40907
40985
|
const commandLine = `"${[cmd, ...args].map(quoteWinArg).join(" ")}"`;
|
|
40908
|
-
const res = (0,
|
|
40986
|
+
const res = (0, import_node_child_process3.spawnSync)("cmd.exe", ["/d", "/s", "/c", commandLine], {
|
|
40909
40987
|
stdio: "ignore",
|
|
40910
40988
|
windowsVerbatimArguments: true,
|
|
40911
40989
|
windowsHide: true
|
|
40912
40990
|
});
|
|
40913
40991
|
return res.status === 0;
|
|
40914
40992
|
}
|
|
40915
|
-
return (0,
|
|
40993
|
+
return (0, import_node_child_process3.spawnSync)(cmd, args, { stdio: "ignore" }).status === 0;
|
|
40916
40994
|
} catch {
|
|
40917
40995
|
return false;
|
|
40918
40996
|
}
|
|
@@ -40920,7 +40998,7 @@ function probeCliCommand(cmd, args = ["--version"]) {
|
|
|
40920
40998
|
function execCliSync(cmd, args, options = {}) {
|
|
40921
40999
|
if (process.platform === "win32" && !cmd.toLowerCase().endsWith(".exe")) {
|
|
40922
41000
|
const commandLine = `"${[cmd, ...args].map(quoteWinArg).join(" ")}"`;
|
|
40923
|
-
const res = (0,
|
|
41001
|
+
const res = (0, import_node_child_process3.spawnSync)("cmd.exe", ["/d", "/s", "/c", commandLine], {
|
|
40924
41002
|
...options,
|
|
40925
41003
|
encoding: options.encoding ?? "utf8",
|
|
40926
41004
|
stdio: options.stdio ?? "pipe",
|
|
@@ -40934,7 +41012,7 @@ function execCliSync(cmd, args, options = {}) {
|
|
|
40934
41012
|
}
|
|
40935
41013
|
return String(res.stdout ?? "");
|
|
40936
41014
|
}
|
|
40937
|
-
return (0,
|
|
41015
|
+
return (0, import_node_child_process3.execFileSync)(cmd, args, options) ?? "";
|
|
40938
41016
|
}
|
|
40939
41017
|
function crc32(buf) {
|
|
40940
41018
|
let c = 4294967295;
|
|
@@ -41015,6 +41093,12 @@ function normalizeTarget(raw) {
|
|
|
41015
41093
|
return "cursor";
|
|
41016
41094
|
if (key === "vscode" || key === "code" || key === "vs-code")
|
|
41017
41095
|
return "vscode";
|
|
41096
|
+
if (key === "trae")
|
|
41097
|
+
return "trae";
|
|
41098
|
+
if (key === "windsurf")
|
|
41099
|
+
return "windsurf";
|
|
41100
|
+
if (key === "vscodium" || key === "codium")
|
|
41101
|
+
return "vscodium";
|
|
41018
41102
|
if (key === "antigravity" || key === "agy")
|
|
41019
41103
|
return "antigravity";
|
|
41020
41104
|
if (key === "codex" || key === "chatgpt")
|
|
@@ -41045,8 +41129,9 @@ function getClaudeDesktopDir() {
|
|
|
41045
41129
|
function getCursorDir() {
|
|
41046
41130
|
return process.env.INKMAP_CURSOR_CONFIG_DIR || (0, import_node_path6.join)((0, import_node_os5.homedir)(), ".cursor");
|
|
41047
41131
|
}
|
|
41048
|
-
function
|
|
41049
|
-
|
|
41132
|
+
function getEditorDir(editor) {
|
|
41133
|
+
const { env, dir } = EXTENSION_EDITORS[editor];
|
|
41134
|
+
return process.env[env] || (0, import_node_path6.join)((0, import_node_os5.homedir)(), dir);
|
|
41050
41135
|
}
|
|
41051
41136
|
function getClaudeCodeConfigPath() {
|
|
41052
41137
|
return process.env.INKMAP_CLAUDE_CODE_CONFIG || (0, import_node_path6.join)((0, import_node_os5.homedir)(), ".claude.json");
|
|
@@ -41054,11 +41139,39 @@ function getClaudeCodeConfigPath() {
|
|
|
41054
41139
|
function getAntigravityConfigDir() {
|
|
41055
41140
|
return process.env.ANTIGRAVITY_CONFIG_DIR || (0, import_node_path6.join)((0, import_node_os5.homedir)(), ".gemini", "config");
|
|
41056
41141
|
}
|
|
41142
|
+
function editorPathMarkers(editor) {
|
|
41143
|
+
if (editor === "cursor")
|
|
41144
|
+
return ["cursor.app", "cursor"];
|
|
41145
|
+
const { macApp, winDir } = EXTENSION_EDITORS[editor];
|
|
41146
|
+
return [macApp.toLowerCase(), winDir.toLowerCase()];
|
|
41147
|
+
}
|
|
41148
|
+
function resolveCommandOnPath(cmd) {
|
|
41149
|
+
const exts = process.platform === "win32" ? ["", ".cmd", ".exe", ".bat"] : [""];
|
|
41150
|
+
for (const dir of (process.env.PATH || "").split(import_node_path6.delimiter).filter(Boolean)) {
|
|
41151
|
+
for (const ext of exts) {
|
|
41152
|
+
const candidate = (0, import_node_path6.join)(dir, cmd + ext);
|
|
41153
|
+
try {
|
|
41154
|
+
if ((0, import_node_fs3.statSync)(candidate).isFile())
|
|
41155
|
+
return (0, import_node_fs3.realpathSync)(candidate);
|
|
41156
|
+
} catch {
|
|
41157
|
+
}
|
|
41158
|
+
}
|
|
41159
|
+
}
|
|
41160
|
+
return null;
|
|
41161
|
+
}
|
|
41162
|
+
function pathCommandBelongsTo(cmd, editor) {
|
|
41163
|
+
if (!probeCliCommand(cmd))
|
|
41164
|
+
return false;
|
|
41165
|
+
const real = resolveCommandOnPath(cmd);
|
|
41166
|
+
if (!real)
|
|
41167
|
+
return true;
|
|
41168
|
+
const segments = real.toLowerCase().split(/[\\/]+/);
|
|
41169
|
+
const others = ["cursor", ...EXTENSION_EDITOR_KEYS].filter((e) => e !== editor);
|
|
41170
|
+
return !others.some((other) => editorPathMarkers(other).some((marker) => segments.includes(marker)));
|
|
41171
|
+
}
|
|
41057
41172
|
function findCursorCommand() {
|
|
41058
41173
|
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
41059
41174
|
return null;
|
|
41060
|
-
if (probeCliCommand("cursor"))
|
|
41061
|
-
return "cursor";
|
|
41062
41175
|
if (process.platform === "darwin") {
|
|
41063
41176
|
for (const dir of ["/Applications", (0, import_node_path6.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
41064
41177
|
const cmd = (0, import_node_path6.join)(dir, "Cursor.app/Contents/Resources/app/bin/cursor");
|
|
@@ -41071,26 +41184,32 @@ function findCursorCommand() {
|
|
|
41071
41184
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41072
41185
|
return cmd;
|
|
41073
41186
|
}
|
|
41074
|
-
return null;
|
|
41187
|
+
return pathCommandBelongsTo("cursor", "cursor") ? "cursor" : null;
|
|
41075
41188
|
}
|
|
41076
|
-
function
|
|
41189
|
+
function findEditorCommand(editor) {
|
|
41077
41190
|
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
41078
41191
|
return null;
|
|
41079
|
-
|
|
41080
|
-
return "code";
|
|
41192
|
+
const { cli, macApp, winDir } = EXTENSION_EDITORS[editor];
|
|
41081
41193
|
if (process.platform === "darwin") {
|
|
41082
41194
|
for (const dir of ["/Applications", (0, import_node_path6.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
41083
|
-
const cmd = (0, import_node_path6.join)(dir, "
|
|
41195
|
+
const cmd = (0, import_node_path6.join)(dir, macApp, "Contents", "Resources", "app", "bin", cli);
|
|
41084
41196
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41085
41197
|
return cmd;
|
|
41086
41198
|
}
|
|
41087
41199
|
} else if (process.platform === "win32") {
|
|
41088
41200
|
const localApp = process.env.LOCALAPPDATA || (0, import_node_path6.join)((0, import_node_os5.homedir)(), "AppData", "Local");
|
|
41089
|
-
const cmd = (0, import_node_path6.join)(localApp, "Programs",
|
|
41201
|
+
const cmd = (0, import_node_path6.join)(localApp, "Programs", winDir, "bin", `${cli}.cmd`);
|
|
41090
41202
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41091
41203
|
return cmd;
|
|
41092
41204
|
}
|
|
41093
|
-
return null;
|
|
41205
|
+
return pathCommandBelongsTo(cli, editor) ? cli : null;
|
|
41206
|
+
}
|
|
41207
|
+
function isEditorInstalled(editor) {
|
|
41208
|
+
if (process.env.INKMAP_ISOLATED_DETECT) {
|
|
41209
|
+
const dir = process.env[EXTENSION_EDITORS[editor].env];
|
|
41210
|
+
return Boolean(dir && (0, import_node_fs3.existsSync)(dir));
|
|
41211
|
+
}
|
|
41212
|
+
return (0, import_node_fs3.existsSync)(getEditorDir(editor)) || Boolean(findEditorCommand(editor));
|
|
41094
41213
|
}
|
|
41095
41214
|
function findCodexCommand() {
|
|
41096
41215
|
if (process.env.INKMAP_CODEX_BIN) {
|
|
@@ -41145,6 +41264,10 @@ function detectInstalledTargets() {
|
|
|
41145
41264
|
if ((0, import_node_fs3.existsSync)(getCursorDir()) || Boolean(findCursorCommand())) {
|
|
41146
41265
|
found.push("cursor");
|
|
41147
41266
|
}
|
|
41267
|
+
for (const editor of EXTENSION_EDITOR_KEYS) {
|
|
41268
|
+
if (isEditorInstalled(editor))
|
|
41269
|
+
found.push(editor);
|
|
41270
|
+
}
|
|
41148
41271
|
const agyDir = getAntigravityConfigDir();
|
|
41149
41272
|
if ((0, import_node_fs3.existsSync)(agyDir) || !process.env.ANTIGRAVITY_CONFIG_DIR && (0, import_node_fs3.existsSync)((0, import_node_path6.join)((0, import_node_os5.homedir)(), ".gemini", "antigravity"))) {
|
|
41150
41273
|
found.push("antigravity");
|
|
@@ -41178,9 +41301,16 @@ function readJsonObject(filePath) {
|
|
|
41178
41301
|
}
|
|
41179
41302
|
function writeJsonAtomic(filePath, data) {
|
|
41180
41303
|
(0, import_node_fs3.mkdirSync)((0, import_node_path6.dirname)(filePath), { recursive: true });
|
|
41181
|
-
|
|
41182
|
-
|
|
41183
|
-
|
|
41304
|
+
let target = filePath;
|
|
41305
|
+
let mode = 384;
|
|
41306
|
+
try {
|
|
41307
|
+
target = (0, import_node_fs3.realpathSync)(filePath);
|
|
41308
|
+
mode = (0, import_node_fs3.statSync)(target).mode & 511;
|
|
41309
|
+
} catch {
|
|
41310
|
+
}
|
|
41311
|
+
const tmp = `${target}.${process.pid}.${Date.now()}.tmp`;
|
|
41312
|
+
(0, import_node_fs3.writeFileSync)(tmp, JSON.stringify(data, null, 2) + "\n", { encoding: "utf8", mode });
|
|
41313
|
+
(0, import_node_fs3.renameSync)(tmp, target);
|
|
41184
41314
|
}
|
|
41185
41315
|
function stageStandaloneMcpApp() {
|
|
41186
41316
|
const appDir = (0, import_node_path6.join)(getInkmapHome(), "mcp-app");
|
|
@@ -41269,7 +41399,9 @@ function installIdeExtension(editorDir, cliCmd) {
|
|
|
41269
41399
|
(0, import_node_fs3.writeFileSync)(vsixPath, buildZipBuffer(entries));
|
|
41270
41400
|
try {
|
|
41271
41401
|
execCliSync(cliCmd, ["--install-extension", vsixPath, "--force"], { stdio: "pipe" });
|
|
41272
|
-
|
|
41402
|
+
const installed = (0, import_node_path6.join)(editorDir, "extensions", `inkmap.inkmap-vscode-${version2}`);
|
|
41403
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path6.join)(installed, "package.json")))
|
|
41404
|
+
return installed;
|
|
41273
41405
|
} catch {
|
|
41274
41406
|
}
|
|
41275
41407
|
}
|
|
@@ -41604,10 +41736,9 @@ async function runInstall(options = {}) {
|
|
|
41604
41736
|
const log = options.log ?? ((msg) => console.log(msg));
|
|
41605
41737
|
const workspaces = options.workspaces ?? [];
|
|
41606
41738
|
const explicitTargets = options.targets && options.targets.length > 0 ? options.targets : null;
|
|
41607
|
-
const targets = explicitTargets ?? detectInstalledTargets();
|
|
41608
41739
|
const result = { installed: [], removed: [] };
|
|
41609
41740
|
if (options.uninstall) {
|
|
41610
|
-
const toRemove = explicitTargets ?? ["claude", "claude-code", "cursor",
|
|
41741
|
+
const toRemove = explicitTargets ?? ["claude", "claude-code", "cursor", ...EXTENSION_EDITOR_KEYS, "antigravity", "codex", "deepseek"];
|
|
41611
41742
|
for (const target of toRemove) {
|
|
41612
41743
|
if (target === "claude") {
|
|
41613
41744
|
const cfg = (0, import_node_path6.join)(getClaudeDesktopDir(), "claude_desktop_config.json");
|
|
@@ -41623,9 +41754,9 @@ async function runInstall(options = {}) {
|
|
|
41623
41754
|
const removedExt = uninstallIdeExtension(getCursorDir(), findCursorCommand());
|
|
41624
41755
|
if (removedMcp || removedExt)
|
|
41625
41756
|
result.removed.push({ target, location: cfg });
|
|
41626
|
-
} else if (target
|
|
41627
|
-
if (uninstallIdeExtension(
|
|
41628
|
-
result.removed.push({ target, location: (0, import_node_path6.join)(
|
|
41757
|
+
} else if (isExtensionEditor(target)) {
|
|
41758
|
+
if (uninstallIdeExtension(getEditorDir(target), findEditorCommand(target))) {
|
|
41759
|
+
result.removed.push({ target, location: (0, import_node_path6.join)(getEditorDir(target), "extensions") });
|
|
41629
41760
|
}
|
|
41630
41761
|
} else if (target === "antigravity") {
|
|
41631
41762
|
const dir = (0, import_node_path6.join)(getAntigravityConfigDir(), "plugins", "inkmap");
|
|
@@ -41680,6 +41811,7 @@ async function runInstall(options = {}) {
|
|
|
41680
41811
|
return result;
|
|
41681
41812
|
}
|
|
41682
41813
|
const { serverScript, appDir } = stageStandaloneMcpApp();
|
|
41814
|
+
const targets = explicitTargets ?? detectInstalledTargets();
|
|
41683
41815
|
const zhLocale = isChineseTerminalLocale();
|
|
41684
41816
|
if (targets.length === 0) {
|
|
41685
41817
|
log(`[inkmap] \u5DF2\u5C06 MCP App \u6838\u5FC3\u6587\u4EF6\u5C31\u7EEA\u5230: ${appDir}`);
|
|
@@ -41687,7 +41819,7 @@ async function runInstall(options = {}) {
|
|
|
41687
41819
|
log(" npx -y inkmap-mcp@latest install claude # Claude Desktop (macOS / Windows / Ubuntu)");
|
|
41688
41820
|
log(" npx -y inkmap-mcp@latest install claude-code # Claude Code CLI");
|
|
41689
41821
|
log(" npx -y inkmap-mcp@latest install cursor # Cursor (MCP + \u53F3\u4FA7\u539F\u751F\u7F16\u8F91\u5668\u6807\u7B7E)");
|
|
41690
|
-
log(" npx -y inkmap-mcp@latest install vscode # VS Code (\u539F\u751F\u7F16\u8F91\u5668\u6269\u5C55)");
|
|
41822
|
+
log(" npx -y inkmap-mcp@latest install vscode # VS Code / trae / windsurf / vscodium (\u539F\u751F\u7F16\u8F91\u5668\u6269\u5C55)");
|
|
41691
41823
|
log(" npx -y inkmap-mcp@latest install antigravity # Google Antigravity");
|
|
41692
41824
|
log(" npx -y inkmap-mcp@latest install codex # OpenAI Codex Desktop");
|
|
41693
41825
|
log(" npx -y inkmap-mcp@latest install deepseek # DeepSeek Harness");
|
|
@@ -41726,13 +41858,14 @@ async function runInstall(options = {}) {
|
|
|
41726
41858
|
location: extLoc ? `${cfg} + ${extLoc}` : cfg,
|
|
41727
41859
|
note: zhLocale ? "\u5DF2\u540C\u65F6\u5B89\u88C5 MCP \u670D\u52A1\u4E0E\u53F3\u4FA7\u4E3B\u7F16\u8F91\u533A\u5BFC\u56FE\u6269\u5C55\uFF08Reload Window \u540E\u5BF9\u8BDD\u53EF\u76F4\u63A5\u6253\u5F00\u53F3\u4FA7\u5BFC\u56FE\u6807\u7B7E\uFF09" : "Installed both MCP server and native right-pane mind map extension (Reload Window to activate)"
|
|
41728
41860
|
});
|
|
41729
|
-
} else if (target
|
|
41730
|
-
const
|
|
41861
|
+
} else if (isExtensionEditor(target)) {
|
|
41862
|
+
const { label } = EXTENSION_EDITORS[target];
|
|
41863
|
+
const extLoc = installIdeExtension(getEditorDir(target), findEditorCommand(target));
|
|
41731
41864
|
if (extLoc) {
|
|
41732
41865
|
result.installed.push({
|
|
41733
41866
|
target,
|
|
41734
41867
|
location: extLoc,
|
|
41735
|
-
note: zhLocale ?
|
|
41868
|
+
note: zhLocale ? `\u5DF2\u5728 ${label} \u5B89\u88C5\u539F\u751F Inkmap \u601D\u7EF4\u5BFC\u56FE\u7F16\u8F91\u5668\u6269\u5C55\uFF08Reload Window \u540E\u751F\u6548\uFF09` : `Installed native Inkmap mind map editor extension in ${label} (Reload Window to activate)`
|
|
41736
41869
|
});
|
|
41737
41870
|
}
|
|
41738
41871
|
} else if (target === "antigravity") {
|
|
@@ -41805,7 +41938,7 @@ async function runInstall(options = {}) {
|
|
|
41805
41938
|
log(" Qoder, WorkBuddy, Claude Desktop, Claude Code, OpenAI Codex, Google Antigravity & Trae!");
|
|
41806
41939
|
log("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
41807
41940
|
}
|
|
41808
|
-
if (
|
|
41941
|
+
if (result.installed.length > 0) {
|
|
41809
41942
|
try {
|
|
41810
41943
|
const { fileSessionStorage: fileSessionStorage2, licenseService: licenseService2 } = await Promise.resolve().then(() => (init_license(), license_exports));
|
|
41811
41944
|
const { YUNFAN_BILLING_ORIGIN: YUNFAN_BILLING_ORIGIN2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
@@ -41835,6 +41968,9 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
41835
41968
|
claude-code Claude Code CLI (~/.claude.json)
|
|
41836
41969
|
cursor Cursor (MCP + \u53F3\u4FA7\u4E3B\u7F16\u8F91\u533A\u539F\u751F\u5BFC\u56FE\u6269\u5C55)
|
|
41837
41970
|
vscode VS Code (\u539F\u751F\u5BFC\u56FE\u7F16\u8F91\u5668\u6269\u5C55)
|
|
41971
|
+
trae Trae (\u539F\u751F\u5BFC\u56FE\u7F16\u8F91\u5668\u6269\u5C55)
|
|
41972
|
+
windsurf Windsurf (\u539F\u751F\u5BFC\u56FE\u7F16\u8F91\u5668\u6269\u5C55)
|
|
41973
|
+
vscodium VSCodium (\u539F\u751F\u5BFC\u56FE\u7F16\u8F91\u5668\u6269\u5C55)
|
|
41838
41974
|
antigravity Google Antigravity (~/.gemini/config/plugins/inkmap)
|
|
41839
41975
|
codex OpenAI Codex Desktop
|
|
41840
41976
|
deepseek DeepSeek Harness (~/.dsh/profiles/desktop)
|
|
@@ -41857,7 +41993,7 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
41857
41993
|
}
|
|
41858
41994
|
const normalized = normalizeTarget(arg);
|
|
41859
41995
|
if (!normalized) {
|
|
41860
|
-
throw new Error(`\u672A\u77E5\u5BA2\u6237\u7AEF\u76EE\u6807: ${arg}\uFF08\u652F\u6301: claude, claude-code, cursor, vscode, antigravity, codex, deepseek, all\uFF09`);
|
|
41996
|
+
throw new Error(`\u672A\u77E5\u5BA2\u6237\u7AEF\u76EE\u6807: ${arg}\uFF08\u652F\u6301: claude, claude-code, cursor, vscode, trae, windsurf, vscodium, antigravity, codex, deepseek, all\uFF09`);
|
|
41861
41997
|
}
|
|
41862
41998
|
if (normalized === "all") {
|
|
41863
41999
|
explicitAll = true;
|
|
@@ -41871,17 +42007,25 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
41871
42007
|
uninstall
|
|
41872
42008
|
});
|
|
41873
42009
|
}
|
|
41874
|
-
var
|
|
42010
|
+
var import_node_child_process3, import_node_fs3, import_node_os5, import_node_path6, import_node_url4, import_node_zlib, EXTENSION_EDITORS, EXTENSION_EDITOR_KEYS, isExtensionEditor, DIST_DIR, PKG_ROOT, SERVER_WRAPPER, CRC_TABLE;
|
|
41875
42011
|
var init_install = __esm({
|
|
41876
42012
|
"packages/cli/dist/install.js"() {
|
|
41877
42013
|
"use strict";
|
|
41878
|
-
|
|
42014
|
+
import_node_child_process3 = require("node:child_process");
|
|
41879
42015
|
import_node_fs3 = require("node:fs");
|
|
41880
42016
|
import_node_os5 = require("node:os");
|
|
41881
42017
|
import_node_path6 = require("node:path");
|
|
41882
42018
|
import_node_url4 = require("node:url");
|
|
41883
42019
|
import_node_zlib = require("node:zlib");
|
|
41884
42020
|
init_license();
|
|
42021
|
+
EXTENSION_EDITORS = {
|
|
42022
|
+
vscode: { label: "VS Code", dir: ".vscode", env: "INKMAP_VSCODE_CONFIG_DIR", cli: "code", macApp: "Visual Studio Code.app", winDir: "Microsoft VS Code" },
|
|
42023
|
+
trae: { label: "Trae", dir: ".trae", env: "INKMAP_TRAE_CONFIG_DIR", cli: "trae", macApp: "Trae.app", winDir: "Trae" },
|
|
42024
|
+
windsurf: { label: "Windsurf", dir: ".windsurf", env: "INKMAP_WINDSURF_CONFIG_DIR", cli: "windsurf", macApp: "Windsurf.app", winDir: "Windsurf" },
|
|
42025
|
+
vscodium: { label: "VSCodium", dir: ".vscode-oss", env: "INKMAP_VSCODIUM_CONFIG_DIR", cli: "codium", macApp: "VSCodium.app", winDir: "VSCodium" }
|
|
42026
|
+
};
|
|
42027
|
+
EXTENSION_EDITOR_KEYS = Object.keys(EXTENSION_EDITORS);
|
|
42028
|
+
isExtensionEditor = (target) => target in EXTENSION_EDITORS;
|
|
41885
42029
|
DIST_DIR = (0, import_node_path6.dirname)((0, import_node_url4.fileURLToPath)(inkmapModuleUrl));
|
|
41886
42030
|
PKG_ROOT = (0, import_node_path6.resolve)(DIST_DIR, "..");
|
|
41887
42031
|
SERVER_WRAPPER = `#!/usr/bin/env node
|
|
@@ -41911,11 +42055,11 @@ __export(index_exports, {
|
|
|
41911
42055
|
main: () => main
|
|
41912
42056
|
});
|
|
41913
42057
|
module.exports = __toCommonJS(index_exports);
|
|
41914
|
-
var import_node_child_process5 = require("node:child_process");
|
|
41915
42058
|
var import_node_path7 = require("node:path");
|
|
41916
42059
|
var import_node_url5 = require("node:url");
|
|
41917
42060
|
init_dist();
|
|
41918
42061
|
init_license();
|
|
42062
|
+
init_open_browser();
|
|
41919
42063
|
init_server();
|
|
41920
42064
|
init_version();
|
|
41921
42065
|
var WEB_ROOT = (0, import_node_url5.fileURLToPath)(new URL("./web/", inkmapModuleUrl));
|
|
@@ -41930,13 +42074,6 @@ var USAGE = `Inkmap v${INKMAP_VERSION} \u2014 Markdown \u4EA4\u4E92\u601D\u7EF4\
|
|
|
41930
42074
|
\u4EE5\u6807\u51C6 MCP App (stdio) \u6A21\u5F0F\u542F\u52A8\u670D\u52A1
|
|
41931
42075
|
npx -y inkmap-mcp@latest <\u6587\u4EF6.md> [--port \u7AEF\u53E3] [--no-open] [--sidebar [--sidebar-purchase]]
|
|
41932
42076
|
\u5728\u672C\u5730\u6D4F\u89C8\u5668\u4E2D\u4EE5\u601D\u7EF4\u5BFC\u56FE\u6253\u5F00\u5E76\u5B9E\u65F6\u53CC\u5411\u7F16\u8F91 Markdown \u6587\u4EF6`;
|
|
41933
|
-
function openBrowser(url2) {
|
|
41934
|
-
const [cmd, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
41935
|
-
const child = (0, import_node_child_process5.spawn)(cmd, args, { stdio: "ignore", detached: true });
|
|
41936
|
-
child.on("error", () => {
|
|
41937
|
-
});
|
|
41938
|
-
child.unref();
|
|
41939
|
-
}
|
|
41940
42077
|
function appendEnvWorkspaces(dirs) {
|
|
41941
42078
|
if (dirs.length === 0)
|
|
41942
42079
|
return;
|
|
@@ -42031,7 +42168,7 @@ ${USAGE}`);
|
|
|
42031
42168
|
console.log(`[inkmap] \u6B63\u5728\u7F16\u8F91 ${file2}`);
|
|
42032
42169
|
console.log(`[inkmap] ${served.url} \uFF08Ctrl+C \u9000\u51FA\uFF09`);
|
|
42033
42170
|
if (open2 && !sidebar)
|
|
42034
|
-
|
|
42171
|
+
openSystemBrowser(served.url);
|
|
42035
42172
|
const stop = () => {
|
|
42036
42173
|
license.dispose();
|
|
42037
42174
|
return served.close().then(() => process.exit(0));
|