inkmap-mcp 0.3.7 → 0.3.10

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.
@@ -103,7 +103,7 @@ function sanitizeViewState(raw) {
103
103
  }
104
104
 
105
105
  // packages/vscode/src/extension.ts
106
- var import_node_child_process3 = require("node:child_process");
106
+ var import_node_child_process4 = require("node:child_process");
107
107
  var import_node_fs2 = require("node:fs");
108
108
  var import_promises4 = require("node:fs/promises");
109
109
  var import_node_os3 = require("node:os");
@@ -417,6 +417,48 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
417
417
  };
418
418
  poll();
419
419
  }
420
+ async function sendPendingTelemetry() {
421
+ if (disposed || !pendingEvents.size) return;
422
+ let origin;
423
+ try {
424
+ origin = billingOrigin(getOrigin());
425
+ } catch {
426
+ return;
427
+ }
428
+ if (process.env.INKMAP_ALLOW_TEST_TELEMETRY !== "1") {
429
+ if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT) return;
430
+ const customHome = process.env.INKMAP_HOME || "";
431
+ if (customHome && (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-"))) {
432
+ return;
433
+ }
434
+ }
435
+ const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
436
+ if (disposed || !id || !pendingEvents.size) return;
437
+ await (trial ??= startTrial());
438
+ const events = {};
439
+ for (const [k, v] of pendingEvents.entries()) events[k] = v;
440
+ pendingEvents.clear();
441
+ const tier = current.pro ? "pro" : (current.trialUntil ?? 0) > Date.now() ? "trial" : "expired";
442
+ const os = process.platform === "darwin" ? "mac" : process.platform === "win32" ? "win" : process.platform === "linux" ? "linux" : "other";
443
+ const hostName = detectedHost || inferNodeHost();
444
+ await fetch(origin + "/billing/v1/telemetry", {
445
+ method: "POST",
446
+ headers: { "content-type": "application/json" },
447
+ redirect: "error",
448
+ body: JSON.stringify({
449
+ product: PRODUCT.id,
450
+ installId: id,
451
+ host: hostName,
452
+ os,
453
+ version: "0.3.10",
454
+ locale: clientLocale(),
455
+ tier,
456
+ events
457
+ }),
458
+ signal: AbortSignal.timeout(5e3)
459
+ }).catch(() => {
460
+ });
461
+ }
420
462
  return {
421
463
  async state() {
422
464
  await (trial ??= startTrial());
@@ -703,51 +745,17 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
703
745
  if (telemetryTimer) return;
704
746
  telemetryTimer = setTimeout(() => {
705
747
  telemetryTimer = void 0;
706
- void (async () => {
707
- if (disposed || !pendingEvents.size) return;
708
- let origin;
709
- try {
710
- origin = billingOrigin(getOrigin());
711
- } catch {
712
- return;
713
- }
714
- if (process.env.INKMAP_ALLOW_TEST_TELEMETRY !== "1") {
715
- if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT) return;
716
- const customHome = process.env.INKMAP_HOME || "";
717
- if (customHome && (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-"))) {
718
- return;
719
- }
720
- }
721
- const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
722
- if (disposed || !id || !pendingEvents.size) return;
723
- await (trial ??= startTrial());
724
- const events = {};
725
- for (const [k, v] of pendingEvents.entries()) events[k] = v;
726
- pendingEvents.clear();
727
- const tier = current.pro ? "pro" : (current.trialUntil ?? 0) > Date.now() ? "trial" : "expired";
728
- const os = process.platform === "darwin" ? "mac" : process.platform === "win32" ? "win" : process.platform === "linux" ? "linux" : "other";
729
- const hostName = detectedHost || inferNodeHost();
730
- await fetch(origin + "/billing/v1/telemetry", {
731
- method: "POST",
732
- headers: { "content-type": "application/json" },
733
- redirect: "error",
734
- body: JSON.stringify({
735
- product: PRODUCT.id,
736
- installId: id,
737
- host: hostName,
738
- os,
739
- version: "0.3.7",
740
- locale: clientLocale(),
741
- tier,
742
- events
743
- }),
744
- signal: AbortSignal.timeout(5e3)
745
- }).catch(() => {
746
- });
747
- })();
748
+ void sendPendingTelemetry();
748
749
  }, 800);
749
750
  telemetryTimer.unref();
750
751
  },
752
+ async flushTelemetry() {
753
+ if (telemetryTimer) {
754
+ clearTimeout(telemetryTimer);
755
+ telemetryTimer = void 0;
756
+ }
757
+ await sendPendingTelemetry();
758
+ },
751
759
  dispose() {
752
760
  disposed = true;
753
761
  stopMagicPoll();
@@ -766,6 +774,8 @@ function inferNodeHost() {
766
774
  const app = (process.env.VSCODE_NLS_CONFIG || process.execPath || "").toLowerCase();
767
775
  if (app.includes("cursor")) return "cursor";
768
776
  if (app.includes("windsurf")) return "windsurf";
777
+ if (app.includes("trae")) return "trae";
778
+ if (app.includes("qoder")) return "qoder";
769
779
  return "vscode";
770
780
  }
771
781
  return "cli";
@@ -834,10 +844,11 @@ function adFeed(url) {
834
844
  }
835
845
 
836
846
  // packages/vscode/src/browser.ts
837
- var import_node_child_process2 = require("node:child_process");
847
+ var import_node_child_process3 = require("node:child_process");
838
848
  var vscode2 = __toESM(require("vscode"));
839
849
 
840
850
  // packages/cli/src/server.ts
851
+ var import_node_child_process2 = require("node:child_process");
841
852
  var import_node_crypto2 = require("node:crypto");
842
853
  var import_node_fs = require("node:fs");
843
854
  var import_promises2 = require("node:fs/promises");
@@ -993,11 +1004,33 @@ function within(root, rel) {
993
1004
  const full = (0, import_node_path2.normalize)((0, import_node_path2.join)(root, decodeURIComponent(rel)));
994
1005
  return full.startsWith(base) ? full : null;
995
1006
  }
1007
+ async function openBrowserWindow(url) {
1008
+ if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url)) return;
1009
+ const run = (cmd, args) => new Promise((done) => {
1010
+ const child = (0, import_node_child_process2.spawn)(cmd, args, { stdio: "ignore", detached: true });
1011
+ child.on("error", () => done(false));
1012
+ child.on("exit", (code) => done(code === 0));
1013
+ child.unref();
1014
+ });
1015
+ if (process.platform === "darwin") {
1016
+ if (await run("open", ["-a", "Google Chrome", url])) return;
1017
+ await run("open", [url]);
1018
+ return;
1019
+ }
1020
+ if (process.platform === "win32") {
1021
+ if (await run("cmd", ["/c", "start", "", "chrome", url])) return;
1022
+ await run("cmd", ["/c", "start", "", url]);
1023
+ return;
1024
+ }
1025
+ if (await run("google-chrome", [url])) return;
1026
+ await run("xdg-open", [url]);
1027
+ }
996
1028
  async function serve({ source: initialSource, webRoot, port = 4377, host = "127.0.0.1", log = () => {
997
1029
  }, license, ads, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, loginOnly = false, ideWorkspace = false, workspaceRoots = [] }) {
998
1030
  if (sidebar && host !== "127.0.0.1") throw new Error("The sidebar bridge requires loopback.");
999
1031
  const prefix = sidebar ? `/s/${(0, import_node_crypto2.randomBytes)(24).toString("hex")}/` : "/";
1000
1032
  let activeSource = initialSource;
1033
+ let browserCompanion = null;
1001
1034
  let bound;
1002
1035
  let current = await activeSource.read();
1003
1036
  let version = hash(current);
@@ -1230,6 +1263,42 @@ data: ${JSON.stringify(data)}
1230
1263
  if (typeof event === "string" && event) license?.track?.(event);
1231
1264
  return json(res, 200, { ok: true });
1232
1265
  }
1266
+ if (url.pathname === "/api/open-browser" && req.method === "POST") {
1267
+ if (!sameOriginPost()) return json(res, 403, { error: "forbidden" });
1268
+ if (license && !hasAccess(await license.state())) {
1269
+ return json(res, 402, { error: detectOsLocale() === "zh" ? "\u514D\u8D39\u8BD5\u7528\u5DF2\u5230\u671F\uFF0C\u8BF7\u5148\u89E3\u9501\u6216\u6062\u590D Pro\u3002" : "Trial expired. Unlock or restore Pro first." });
1270
+ }
1271
+ license?.track?.("feature_browser");
1272
+ if (!sidebar) {
1273
+ const directUrl = `http://${host}:${bound}/`;
1274
+ await openBrowserWindow(directUrl);
1275
+ return json(res, 200, { ok: true, url: directUrl });
1276
+ }
1277
+ if (!browserCompanion) {
1278
+ browserCompanion = (async () => {
1279
+ const src = activeSource.key ? await fileSource(activeSource.key) : activeSource;
1280
+ return serve({
1281
+ source: src,
1282
+ webRoot,
1283
+ host: "127.0.0.1",
1284
+ port: 0,
1285
+ license,
1286
+ ads,
1287
+ sidebar: false,
1288
+ loginOnly: false,
1289
+ workspaceRoots
1290
+ });
1291
+ })();
1292
+ browserCompanion.catch(() => {
1293
+ browserCompanion = null;
1294
+ });
1295
+ }
1296
+ const companion = await browserCompanion;
1297
+ if (activeSource.key) await companion.switchToFile?.(activeSource.key).catch(() => {
1298
+ });
1299
+ await openBrowserWindow(companion.url);
1300
+ return json(res, 200, { ok: true, url: companion.url });
1301
+ }
1233
1302
  if (url.pathname === "/api/checkout" && req.method === "POST") {
1234
1303
  if (!sameOriginPost()) return json(res, 403, { error: "forbidden" });
1235
1304
  const { mode, locale } = JSON.parse(await readBody(req));
@@ -1306,6 +1375,8 @@ data: ${JSON.stringify(data)}
1306
1375
  clearTimeout(pending);
1307
1376
  unwatch();
1308
1377
  unlisten();
1378
+ if (browserCompanion) void browserCompanion.then((s) => s.close()).catch(() => {
1379
+ });
1309
1380
  for (const res of clients) res.end();
1310
1381
  server.close(() => done());
1311
1382
  })
@@ -1419,7 +1490,9 @@ var zh = {
1419
1490
  removed: "\u5DF2\u9000\u51FA\u767B\u5F55\u3002",
1420
1491
  removeConfirm: "\u9000\u51FA\u5F53\u524D\u8D26\u53F7\uFF1F\u4E0B\u6B21\u767B\u5F55\u65F6\u4F1A\u81EA\u52A8\u540C\u6B65 Pro \u6743\u76CA\u3002",
1421
1492
  remove: "\u9000\u51FA\u767B\u5F55",
1422
- saveExport: "\u5BFC\u51FA"
1493
+ saveExport: "\u5BFC\u51FA",
1494
+ onboardingTip: "\u{1F4A1} Inkmap \u601D\u7EF4\u5BFC\u56FE\u5DF2\u5C31\u7EEA\uFF1A\u70B9\u51FB\u5373\u53EF\u5728\u53F3\u4FA7\u5E76\u6392\u6253\u5F00\u53EF\u53CC\u5411\u7F16\u8F91\u7684\u8111\u56FE\u4E0E\u6D41\u7A0B\u56FE",
1495
+ onboardingAction: "\u7ACB\u5373\u6253\u5F00\u601D\u7EF4\u5BFC\u56FE"
1423
1496
  };
1424
1497
  var en = {
1425
1498
  openMarkdownFirst: "Open a Markdown file first",
@@ -1439,7 +1512,9 @@ var en = {
1439
1512
  removed: "Signed out.",
1440
1513
  removeConfirm: "Sign out? Your Pro access will sync the next time you sign in.",
1441
1514
  remove: "Sign Out",
1442
- saveExport: "Export"
1515
+ saveExport: "Export",
1516
+ onboardingTip: "\u{1F4A1} Inkmap is ready: Open this Markdown file side-by-side as an interactive two-way mind map",
1517
+ onboardingAction: "Open Mind Map"
1443
1518
  };
1444
1519
  var isChinese = () => detectOsLocale() === "zh";
1445
1520
  function t(key, vars = {}) {
@@ -1512,7 +1587,7 @@ async function openUrl(url) {
1512
1587
  if (vscode2.workspace.getConfiguration("inkmap").get("browser", "chrome") !== "chrome") return fallback();
1513
1588
  const [cmd, args] = process.platform === "darwin" ? ["open", ["-a", "Google Chrome", url]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", "chrome", url]] : ["google-chrome", [url]];
1514
1589
  const ok = await new Promise((done) => {
1515
- const child = (0, import_node_child_process2.spawn)(cmd, args, { stdio: "ignore", detached: true });
1590
+ const child = (0, import_node_child_process3.spawn)(cmd, args, { stdio: "ignore", detached: true });
1516
1591
  child.on("error", () => done(false));
1517
1592
  child.on("exit", (code) => done(code === 0));
1518
1593
  child.unref();
@@ -1525,7 +1600,7 @@ var vscode3 = __toESM(require("vscode"));
1525
1600
  var KEY = "inkmap.billing.session";
1526
1601
  function extensionLicense(context) {
1527
1602
  const app = (vscode3.env.appName || "").toLowerCase();
1528
- const host = app.includes("cursor") ? "cursor" : app.includes("windsurf") ? "windsurf" : app.includes("antigravity") ? "antigravity" : "vscode";
1603
+ const host = app.includes("cursor") ? "cursor" : app.includes("windsurf") ? "windsurf" : app.includes("trae") ? "trae" : app.includes("qoder") ? "qoder" : app.includes("antigravity") ? "antigravity" : "vscode";
1529
1604
  return licenseService({
1530
1605
  read: () => Promise.resolve(context.secrets.get(KEY)),
1531
1606
  write: async (token) => {
@@ -1639,17 +1714,20 @@ var MindmapEditorProvider = class {
1639
1714
  revealTimer = setTimeout(() => post({ type: "reveal", line: e.selections[0].active.line }), REVEAL_DELAY);
1640
1715
  }),
1641
1716
  webview.onDidReceiveMessage(async (msg) => {
1642
- const accountAction = msg.type === "checkout" || msg.type === "orderPro" || msg.type === "openExternal" || msg.type === "signOut" || msg.type === "sendPhoneCode" || msg.type === "signInByPhone" || msg.type === "telemetry";
1717
+ const accountAction = msg.type === "checkout" || msg.type === "orderPro" || msg.type === "openExternal" || msg.type === "signOut" || msg.type === "sendPhoneCode" || msg.type === "signInByPhone" || msg.type === "openInBrowser" || msg.type === "telemetry";
1643
1718
  if (!accountAction && msg.type !== "ready" && msg.type !== "viewState" && msg.type !== "select" && !hasAccess(await this.license.state())) {
1644
1719
  if ("id" in msg) return post({ type: "error", id: msg.id, message: t("trialExpired") });
1645
1720
  return;
1646
1721
  }
1647
1722
  switch (msg.type) {
1648
1723
  case "ready": {
1724
+ void this.context.globalState?.update("inkmap.hasOpenedMap", true);
1649
1725
  this.license.track?.("doc_open");
1650
1726
  const [license, ads] = await Promise.all([this.license.state(), this.ads()]);
1651
1727
  return post({ type: "doc", doc: state(), license, ads, chat: await chatAvailable() });
1652
1728
  }
1729
+ case "openInBrowser":
1730
+ return vscode4.commands.executeCommand("inkmap.openInBrowser", document.uri);
1653
1731
  case "telemetry": {
1654
1732
  this.license.track?.(msg.event);
1655
1733
  return;
@@ -1971,7 +2049,7 @@ async function syncDeepSeekHarnessIfInstalled() {
1971
2049
  ].filter(Boolean);
1972
2050
  const dshBin = candidates.find((c) => (0, import_node_fs2.existsSync)(c));
1973
2051
  if (dshBin) {
1974
- const child = (0, import_node_child_process3.spawn)(dshBin, ["plugin", "--profile", "desktop", "add", spec], { stdio: "ignore", detached: true });
2052
+ const child = (0, import_node_child_process4.spawn)(dshBin, ["plugin", "--profile", "desktop", "add", spec], { stdio: "ignore", detached: true });
1975
2053
  child.unref();
1976
2054
  }
1977
2055
  } catch {
@@ -1981,6 +2059,7 @@ function activate(context) {
1981
2059
  void syncDeepSeekHarnessIfInstalled();
1982
2060
  const log = vscode5.window.createOutputChannel("Inkmap");
1983
2061
  const license = extensionLicense(context);
2062
+ license.track?.("plugin_activate");
1984
2063
  const ads = adFeed(PRODUCT.adFeedUrl);
1985
2064
  const browsers = new BrowserServers(context, vscode5.Uri.joinPath(context.extensionUri, "dist", "web").fsPath, log, license, ads);
1986
2065
  const withUri = (run) => (arg) => {
@@ -1994,13 +2073,28 @@ function activate(context) {
1994
2073
  preserveFocus: true
1995
2074
  })
1996
2075
  );
2076
+ const maybeOfferOnboarding = (editor) => {
2077
+ if (!editor || editor.document.languageId !== "markdown" || editor.document.uri.scheme !== "file") return;
2078
+ if (context.globalState.get("inkmap.hasOpenedMap") || context.globalState.get("inkmap.onboardingPrompted")) return;
2079
+ void context.globalState.update("inkmap.onboardingPrompted", true);
2080
+ license.track?.("onboarding_view");
2081
+ const docUri = editor.document.uri;
2082
+ void vscode5.window.showInformationMessage(t("onboardingTip"), t("onboardingAction")).then((pick) => {
2083
+ if (pick) {
2084
+ license.track?.("onboarding_open");
2085
+ void openToSide(docUri);
2086
+ }
2087
+ });
2088
+ };
1997
2089
  const editors = new MindmapEditorProvider(context, license, ads);
1998
2090
  chatAvailable().then((available) => vscode5.commands.executeCommand("setContext", "inkmap.chatAvailable", available));
2091
+ maybeOfferOnboarding(vscode5.window.activeTextEditor);
1999
2092
  context.subscriptions.push(
2000
2093
  log,
2001
2094
  license,
2002
2095
  browsers,
2003
2096
  startMcpTargetBridge(),
2097
+ vscode5.window.onDidChangeActiveTextEditor(maybeOfferOnboarding),
2004
2098
  vscode5.window.registerUriHandler({
2005
2099
  handleUri(uri) {
2006
2100
  if (uri.path === "/open") {
Binary file
@@ -2,7 +2,7 @@
2
2
  "name": "inkmap-vscode",
3
3
  "displayName": "%displayName%",
4
4
  "description": "%description%",
5
- "version": "0.3.7",
5
+ "version": "0.3.10",
6
6
  "publisher": "inkmap",
7
7
  "homepage": "https://zhiyuanv.com/software.html",
8
8
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
- "displayName": "Inkmap — Editable Markmap, Markdown Mind Map & Mermaid 思维导图",
3
- "description": "Editable Markmap alternative: Two-way Markdown mind map (.md) & Mermaid flowchart editor with XMind shortcuts, LaTeX, AI Chat & PNG/SVG/HTML export | 双向可编辑思维导图、脑图、流程图",
2
+ "displayName": "Inkmap — Editable Mindmap, Markmap, Markdown Mind Map & Mermaid 思维导图",
3
+ "description": "Editable Mindmap & Markmap alternative: Two-way Markdown mind map (.md) & Mermaid flowchart editor with XMind shortcuts, LaTeX, AI Chat & PNG/SVG/HTML export | 双向可编辑思维导图、脑图、流程图",
4
4
  "virtualWorkspaces": "Inkmap edits Markdown files on disk.",
5
5
  "editor.displayName": "Inkmap Mind Map",
6
6
  "command.open": "Open as Inkmap",
@@ -1,6 +1,6 @@
1
1
  {
2
- "displayName": "Inkmap 墨图 — 可编辑 Markmap / Markdown 思维导图 & Mermaid 流程图",
3
- "description": "比 Markmap 更好用的双向可编辑 Markdown (.md) 思维导图与脑图插件:直接改节点实时同步源文件,原生内嵌 Mermaid 流程图、LaTeX 公式、XMind 快捷键、AI 对话协同与高清 PNG/SVG/HTML 导出。",
2
+ "displayName": "Inkmap 墨图 — 可编辑 Mindmap / Markmap / Markdown 思维导图 & Mermaid 流程图",
3
+ "description": "比 Markmap 更好用的双向可编辑 Markdown (.md) 思维导图 (Mindmap / Mind Map) 与脑图插件:直接改节点实时同步源文件,原生内嵌 Mermaid 流程图、LaTeX 公式、XMind 快捷键、AI 对话协同与高清 PNG/SVG/HTML 导出。",
4
4
  "virtualWorkspaces": "Inkmap 需要编辑磁盘上的 Markdown 文件。",
5
5
  "editor.displayName": "Inkmap 思维导图",
6
6
  "command.open": "Open as Inkmap",