inkmap-mcp 0.3.17 → 0.3.19

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.
@@ -57,6 +57,52 @@ function hasAccess(state, now = Date.now()) {
57
57
  return state.pro || (state.trialUntil ?? 0) > now;
58
58
  }
59
59
 
60
+ // packages/core/dist/images.js
61
+ var MAX_IMAGE_BYTES = 10 * 1024 * 1024;
62
+ var startsWith = (bytes, signature, offset = 0) => [...signature].every((char, i) => bytes[offset + i] === char.charCodeAt(0));
63
+ function sniffImage(bytes) {
64
+ if (startsWith(bytes, "\x89PNG\r\n\n"))
65
+ return "png";
66
+ if (startsWith(bytes, "\xFF\xD8\xFF"))
67
+ return "jpg";
68
+ if (startsWith(bytes, "GIF87a") || startsWith(bytes, "GIF89a"))
69
+ return "gif";
70
+ if (startsWith(bytes, "RIFF") && startsWith(bytes, "WEBP", 8))
71
+ return "webp";
72
+ return void 0;
73
+ }
74
+ function decodeImageDataUrl(dataUrl) {
75
+ const match = typeof dataUrl === "string" ? /^data:[\w.+/-]*;base64,([A-Za-z0-9+/]*={0,2})$/.exec(dataUrl) : null;
76
+ if (!match)
77
+ return { problem: "type" };
78
+ if (match[1].length * 3 / 4 - 2 > MAX_IMAGE_BYTES)
79
+ return { problem: "size" };
80
+ let binary;
81
+ try {
82
+ binary = atob(match[1]);
83
+ } catch {
84
+ return { problem: "type" };
85
+ }
86
+ if (binary.length > MAX_IMAGE_BYTES)
87
+ return { problem: "size" };
88
+ const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
89
+ const extension = sniffImage(bytes);
90
+ return extension ? { bytes, extension } : { problem: "type" };
91
+ }
92
+ function imageFolderName(documentFileName) {
93
+ const stem = documentFileName.replace(/\.(?:md|markdown)$/i, "").trim();
94
+ return `${/^\.*$/.test(stem) ? "images" : stem}.assets`;
95
+ }
96
+ function imageFileName(when, extension, attempt = 1) {
97
+ const two = (n) => String(n).padStart(2, "0");
98
+ const stamp = `${when.getFullYear()}${two(when.getMonth() + 1)}${two(when.getDate())}-${two(when.getHours())}${two(when.getMinutes())}${two(when.getSeconds())}`;
99
+ return `image-${stamp}${attempt > 1 ? `-${attempt}` : ""}.${extension}`;
100
+ }
101
+ function imageLinkPath(folder, file) {
102
+ const encode = (part) => part.replace(/[%\s()<>#?[\]\\"]/g, (char) => encodeURIComponent(char).replace(/\(/g, "%28").replace(/\)/g, "%29"));
103
+ return `${encode(folder)}/${encode(file)}`;
104
+ }
105
+
60
106
  // packages/core/dist/index.js
61
107
  function sanitizeViewState(raw) {
62
108
  if (!raw || typeof raw !== "object")
@@ -85,9 +131,9 @@ function sanitizeViewState(raw) {
85
131
  // packages/vscode/src/extension.ts
86
132
  var import_node_child_process4 = require("node:child_process");
87
133
  var import_node_fs2 = require("node:fs");
88
- var import_promises5 = require("node:fs/promises");
134
+ var import_promises6 = require("node:fs/promises");
89
135
  var import_node_os4 = require("node:os");
90
- var import_node_path4 = require("node:path");
136
+ var import_node_path5 = require("node:path");
91
137
  var vscode5 = __toESM(require("vscode"));
92
138
 
93
139
  // packages/vscode/src/browser.ts
@@ -97,11 +143,20 @@ var vscode2 = __toESM(require("vscode"));
97
143
  // packages/cli/src/server.ts
98
144
  var import_node_crypto2 = require("node:crypto");
99
145
  var import_node_fs = require("node:fs");
100
- var import_promises3 = require("node:fs/promises");
146
+ var import_promises4 = require("node:fs/promises");
101
147
  var import_node_http = require("node:http");
102
148
  var import_node_os3 = require("node:os");
149
+ var import_node_path4 = require("node:path");
150
+
151
+ // packages/cli/src/image-assets.ts
152
+ var import_promises3 = require("node:fs/promises");
103
153
  var import_node_path3 = require("node:path");
104
154
 
155
+ // packages/cli/src/workspace-fs.ts
156
+ var import_promises2 = require("node:fs/promises");
157
+ var import_node_os2 = require("node:os");
158
+ var import_node_path2 = require("node:path");
159
+
105
160
  // packages/cli/src/license.ts
106
161
  var import_node_child_process = require("node:child_process");
107
162
  var import_promises = require("node:fs/promises");
@@ -110,7 +165,7 @@ var import_node_os = require("node:os");
110
165
  var import_node_path = require("node:path");
111
166
 
112
167
  // packages/cli/src/version.ts
113
- var INKMAP_VERSION = "0.3.17";
168
+ var INKMAP_VERSION = "0.3.19";
114
169
 
115
170
  // packages/cli/src/license.ts
116
171
  var ZH_LOCALE_RE = /^zh(?:[-_.]|$)/i;
@@ -188,7 +243,7 @@ function billingOrigin(raw) {
188
243
  }
189
244
  return url.origin;
190
245
  }
191
- function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHost = "", waitPollMs = WAIT_FAST_MS } = {}) {
246
+ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHost = "", waitPollMs = WAIT_FAST_MS, reviewPrompt = true } = {}) {
192
247
  const listeners = /* @__PURE__ */ new Set();
193
248
  let current = { pro: false };
194
249
  let trial;
@@ -199,6 +254,20 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
199
254
  let sentAppOpen = false;
200
255
  let detectedHost = defaultHost;
201
256
  const pendingEvents = /* @__PURE__ */ new Map();
257
+ let reviewDue = false;
258
+ let reviewCounting = Promise.resolve();
259
+ const countForReview = (event, count) => {
260
+ reviewCounting = reviewCounting.then(async () => {
261
+ if (disposed || reviewDue) return;
262
+ const usage = await readReviewUsage();
263
+ if (usage.done) return;
264
+ if (event === "doc_open") usage.opens += count;
265
+ else usage.edits += count;
266
+ await writeReviewUsage(usage);
267
+ if (usage.opens >= REVIEW_MIN_OPENS && usage.edits >= REVIEW_MIN_EDITS) reviewDue = true;
268
+ }).catch(() => {
269
+ });
270
+ };
202
271
  let lastCheck = 0;
203
272
  let retryAfter = 0;
204
273
  let fastPollUntil = 0;
@@ -626,11 +695,21 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
626
695
  });
627
696
  }
628
697
  return {
629
- async state() {
698
+ async state(options) {
630
699
  await (trial ??= startTrial());
631
700
  const interval = !current.pro && Date.now() < fastPollUntil ? 2e3 : 6e4;
632
701
  if (Date.now() - lastCheck >= interval && Date.now() >= retryAfter) await refresh();
633
702
  await parkUnpaidSession();
703
+ await reviewCounting;
704
+ if (options?.forUi && reviewDue && hasAccess(current)) {
705
+ reviewDue = false;
706
+ const usage = await readReviewUsage().catch(() => void 0);
707
+ if (usage && !usage.done) {
708
+ await writeReviewUsage({ ...usage, done: true }).catch(() => {
709
+ });
710
+ return { ...current, reviewPrompt: true };
711
+ }
712
+ }
634
713
  return current;
635
714
  },
636
715
  async connect(mode, localeHint) {
@@ -946,6 +1025,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
946
1025
  if (event !== "app_open") {
947
1026
  pendingEvents.set(event, Math.min(1e3, (pendingEvents.get(event) ?? 0) + count));
948
1027
  }
1028
+ if (reviewPrompt && !process.env.CI && (event === "doc_open" || event === "doc_edit")) countForReview(event, count);
949
1029
  if (telemetryTimer) return;
950
1030
  telemetryTimer = setTimeout(() => {
951
1031
  telemetryTimer = void 0;
@@ -1009,6 +1089,25 @@ async function atomicCreateIfMissing(path2, initialContent) {
1009
1089
  return await (0, import_promises.readFile)(path2, "utf8");
1010
1090
  }
1011
1091
  }
1092
+ var REVIEW_MIN_OPENS = 5;
1093
+ var REVIEW_MIN_EDITS = 3;
1094
+ var reviewUsagePath = () => (0, import_node_path.join)(process.env.INKMAP_HOME || (0, import_node_path.join)((0, import_node_os.homedir)(), ".inkmap"), "review-prompt");
1095
+ async function readReviewUsage() {
1096
+ const count = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
1097
+ try {
1098
+ const raw = JSON.parse(await (0, import_promises.readFile)(reviewUsagePath(), "utf8"));
1099
+ return { opens: count(raw.opens), edits: count(raw.edits), done: raw.done === true };
1100
+ } catch {
1101
+ return { opens: 0, edits: 0, done: false };
1102
+ }
1103
+ }
1104
+ async function writeReviewUsage(usage) {
1105
+ const path2 = reviewUsagePath();
1106
+ await (0, import_promises.mkdir)((0, import_node_path.dirname)(path2), { recursive: true, mode: 448 });
1107
+ const temporary = path2 + "." + (0, import_node_crypto.randomUUID)();
1108
+ await (0, import_promises.writeFile)(temporary, JSON.stringify(usage), { mode: 384 });
1109
+ await (0, import_promises.rename)(temporary, path2);
1110
+ }
1012
1111
  async function localInstallId() {
1013
1112
  const path2 = (0, import_node_path.join)(process.env.INKMAP_HOME || (0, import_node_path.join)((0, import_node_os.homedir)(), ".inkmap"), "install-id");
1014
1113
  const generated = "inst_" + (0, import_node_crypto.randomUUID)().replace(/-/g, "").slice(0, 24);
@@ -1022,37 +1121,8 @@ async function localTrialDeadline() {
1022
1121
  return Number.isSafeInteger(started) && started > 0 && started <= Date.now() ? started + TRIAL_MS : void 0;
1023
1122
  }
1024
1123
 
1025
- // packages/cli/src/open-browser.ts
1026
- var import_node_child_process2 = require("node:child_process");
1027
- function run(cmd, args, launched = false) {
1028
- return new Promise((done) => {
1029
- const child = (0, import_node_child_process2.spawn)(cmd, args, { stdio: "ignore", detached: true });
1030
- child.on("error", () => done(false));
1031
- if (launched) child.on("spawn", () => done(true));
1032
- else child.on("exit", (code) => done(code === 0));
1033
- child.unref();
1034
- });
1035
- }
1036
- async function openBrowserWindow(url) {
1037
- if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url)) return;
1038
- if (process.platform === "darwin") {
1039
- if (await run("open", ["-a", "Google Chrome", url])) return;
1040
- await run("open", [url]);
1041
- return;
1042
- }
1043
- if (process.platform === "win32") {
1044
- if (await run("cmd", ["/c", "start", "", "chrome", url])) return;
1045
- await run("cmd", ["/c", "start", "", url]);
1046
- return;
1047
- }
1048
- if (await run("google-chrome", [url], true)) return;
1049
- await run("xdg-open", [url], true);
1050
- }
1051
-
1052
1124
  // packages/cli/src/workspace-fs.ts
1053
- var import_promises2 = require("node:fs/promises");
1054
- var import_node_os2 = require("node:os");
1055
- var import_node_path2 = require("node:path");
1125
+ var say = (zh2, en2) => detectOsLocale() === "zh" ? zh2 : en2;
1056
1126
  var MAX_MARKDOWN_BYTES = 5 * 1024 * 1024;
1057
1127
  var SKIP_SCAN_DIRS = /* @__PURE__ */ new Set([
1058
1128
  ".git",
@@ -1138,6 +1208,53 @@ async function scanMarkdownFiles(rootDir, { maxFiles = 200, maxDepth = 4, byRece
1138
1208
  return found;
1139
1209
  }
1140
1210
 
1211
+ // packages/cli/src/image-assets.ts
1212
+ async function saveImageAsset(documentDir, documentFileName, image, when = /* @__PURE__ */ new Date()) {
1213
+ const folder = imageFolderName(documentFileName);
1214
+ const target = (0, import_node_path3.join)(documentDir, folder);
1215
+ await (0, import_promises3.mkdir)(target, { recursive: true });
1216
+ if (!insideOrEqual(await (0, import_promises3.realpath)(documentDir), await (0, import_promises3.realpath)(target))) {
1217
+ throw new Error(say("\u56FE\u7247\u76EE\u5F55\u6307\u5411\u6587\u6863\u76EE\u5F55\u4E4B\u5916\uFF0C\u672A\u4FDD\u5B58\u56FE\u7247\u3002", "The pictures folder leads outside the document's folder, so nothing was saved."));
1218
+ }
1219
+ for (let attempt = 1; attempt <= 100; attempt++) {
1220
+ const name = imageFileName(when, image.extension, attempt);
1221
+ try {
1222
+ await (0, import_promises3.writeFile)((0, import_node_path3.join)(target, name), image.bytes, { flag: "wx" });
1223
+ return imageLinkPath(folder, name);
1224
+ } catch (error) {
1225
+ if (error.code !== "EEXIST") throw error;
1226
+ }
1227
+ }
1228
+ throw new Error(say("\u65E0\u6CD5\u4E3A\u56FE\u7247\u751F\u6210\u65B0\u7684\u6587\u4EF6\u540D\u3002", "Could not find a free file name for the picture."));
1229
+ }
1230
+
1231
+ // packages/cli/src/open-browser.ts
1232
+ var import_node_child_process2 = require("node:child_process");
1233
+ function run(cmd, args, launched = false) {
1234
+ return new Promise((done) => {
1235
+ const child = (0, import_node_child_process2.spawn)(cmd, args, { stdio: "ignore", detached: true });
1236
+ child.on("error", () => done(false));
1237
+ if (launched) child.on("spawn", () => done(true));
1238
+ else child.on("exit", (code) => done(code === 0));
1239
+ child.unref();
1240
+ });
1241
+ }
1242
+ async function openBrowserWindow(url) {
1243
+ if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url)) return;
1244
+ if (process.platform === "darwin") {
1245
+ if (await run("open", ["-a", "Google Chrome", url])) return;
1246
+ await run("open", [url]);
1247
+ return;
1248
+ }
1249
+ if (process.platform === "win32") {
1250
+ if (await run("cmd", ["/c", "start", "", "chrome", url])) return;
1251
+ await run("cmd", ["/c", "start", "", url]);
1252
+ return;
1253
+ }
1254
+ if (await run("google-chrome", [url], true)) return;
1255
+ await run("xdg-open", [url], true);
1256
+ }
1257
+
1141
1258
  // packages/cli/src/server.ts
1142
1259
  var MAX_BODY = 20 * 1024 * 1024;
1143
1260
  var TYPES = {
@@ -1167,49 +1284,49 @@ var HttpError = class extends Error {
1167
1284
  var LOOPBACK_HOST = /^(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+$/i;
1168
1285
  var hash = (s) => (0, import_node_crypto2.createHash)("sha1").update(s).digest("hex");
1169
1286
  function docName(path2) {
1170
- return (0, import_node_path3.basename)(path2).replace(/\.md$/i, "").replace(/\.markmap$/i, "");
1287
+ return (0, import_node_path4.basename)(path2).replace(/\.md$/i, "").replace(/\.markmap$/i, "");
1171
1288
  }
1172
1289
  function viewStateFile(key) {
1173
- const base = process.env.INKMAP_HOME || (0, import_node_path3.join)((0, import_node_os3.homedir)(), ".inkmap");
1174
- return (0, import_node_path3.join)(base, "view-state", hash(key) + ".json");
1290
+ const base = process.env.INKMAP_HOME || (0, import_node_path4.join)((0, import_node_os3.homedir)(), ".inkmap");
1291
+ return (0, import_node_path4.join)(base, "view-state", hash(key) + ".json");
1175
1292
  }
1176
1293
  async function readDiskViewState(key) {
1177
1294
  try {
1178
- return sanitizeViewState(JSON.parse(await (0, import_promises3.readFile)(viewStateFile(key), "utf8")));
1295
+ return sanitizeViewState(JSON.parse(await (0, import_promises4.readFile)(viewStateFile(key), "utf8")));
1179
1296
  } catch {
1180
1297
  return void 0;
1181
1298
  }
1182
1299
  }
1183
1300
  async function writeDiskViewState(key, state) {
1184
1301
  const target = viewStateFile(key);
1185
- await (0, import_promises3.mkdir)((0, import_node_path3.dirname)(target), { recursive: true, mode: 448 });
1302
+ await (0, import_promises4.mkdir)((0, import_node_path4.dirname)(target), { recursive: true, mode: 448 });
1186
1303
  const temp = `${target}.${process.pid}.${Date.now()}`;
1187
1304
  try {
1188
- await (0, import_promises3.writeFile)(temp, JSON.stringify(state), { mode: 384 });
1189
- await (0, import_promises3.rename)(temp, target);
1305
+ await (0, import_promises4.writeFile)(temp, JSON.stringify(state), { mode: 384 });
1306
+ await (0, import_promises4.rename)(temp, target);
1190
1307
  } finally {
1191
- await (0, import_promises3.rm)(temp, { force: true }).catch(() => {
1308
+ await (0, import_promises4.rm)(temp, { force: true }).catch(() => {
1192
1309
  });
1193
1310
  }
1194
1311
  }
1195
1312
  async function fileSource(file, log = () => {
1196
1313
  }) {
1197
- const path2 = await (0, import_promises3.realpath)((0, import_node_path3.resolve)(file)).catch(() => (0, import_node_path3.resolve)(file));
1198
- if (!(await (0, import_promises3.stat)(path2)).isFile()) throw new Error(`\u4E0D\u662F\u6587\u4EF6\uFF1A${path2}`);
1199
- const dir = (0, import_node_path3.dirname)(path2);
1314
+ const path2 = await (0, import_promises4.realpath)((0, import_node_path4.resolve)(file)).catch(() => (0, import_node_path4.resolve)(file));
1315
+ if (!(await (0, import_promises4.stat)(path2)).isFile()) throw new Error(`\u4E0D\u662F\u6587\u4EF6\uFF1A${path2}`);
1316
+ const dir = (0, import_node_path4.dirname)(path2);
1200
1317
  return {
1201
1318
  name: docName(path2),
1202
1319
  key: path2,
1203
1320
  dir,
1204
- read: () => (0, import_promises3.readFile)(path2, "utf8"),
1321
+ read: () => (0, import_promises4.readFile)(path2, "utf8"),
1205
1322
  async write(md) {
1206
- await (0, import_promises3.writeFile)(path2, md, "utf8");
1323
+ await (0, import_promises4.writeFile)(path2, md, "utf8");
1207
1324
  log(`\u5DF2\u5199\u56DE ${path2}`);
1208
1325
  },
1209
1326
  watch(onChange) {
1210
1327
  try {
1211
1328
  const watcher = (0, import_node_fs.watch)(dir, (_, changed) => {
1212
- if (!changed || changed === (0, import_node_path3.basename)(path2)) onChange();
1329
+ if (!changed || changed === (0, import_node_path4.basename)(path2)) onChange();
1213
1330
  });
1214
1331
  watcher.on("error", () => {
1215
1332
  });
@@ -1230,9 +1347,9 @@ function within(root, rel, allowAbsoluteInRoot = false) {
1230
1347
  } catch {
1231
1348
  return null;
1232
1349
  }
1233
- const resolvedRoot = (0, import_node_path3.resolve)(root);
1234
- const base = resolvedRoot.endsWith(import_node_path3.sep) ? resolvedRoot : resolvedRoot + import_node_path3.sep;
1235
- 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));
1350
+ const resolvedRoot = (0, import_node_path4.resolve)(root);
1351
+ const base = resolvedRoot.endsWith(import_node_path4.sep) ? resolvedRoot : resolvedRoot + import_node_path4.sep;
1352
+ const full = allowAbsoluteInRoot && /^(?:[\\/]|[A-Za-z]:[\\/])/.test(decoded) ? (0, import_node_path4.normalize)(decoded) : (0, import_node_path4.normalize)((0, import_node_path4.join)(resolvedRoot, decoded));
1236
1353
  return full.startsWith(base) ? full : null;
1237
1354
  }
1238
1355
  async function serve({
@@ -1301,19 +1418,19 @@ data: ${JSON.stringify(data)}
1301
1418
  }), 80);
1302
1419
  };
1303
1420
  let unwatch = activeSource.watch(scheduleRefresh);
1304
- const canonicalActiveKey = async () => activeSource.key ? await (0, import_promises3.realpath)(activeSource.key).catch(() => activeSource.key) : void 0;
1421
+ const canonicalActiveKey = async () => activeSource.key ? await (0, import_promises4.realpath)(activeSource.key).catch(() => activeSource.key) : void 0;
1305
1422
  async function collectWorkspaceFiles() {
1306
1423
  const roots = /* @__PURE__ */ new Map();
1307
1424
  if (activeSource.key && !confineToWorkspaceRoots) {
1308
- const realKey = await (0, import_promises3.realpath)(activeSource.key).catch(() => activeSource.key);
1309
- const projRoot = await (0, import_promises3.realpath)(await findProjectRoot(realKey)).catch(() => (0, import_node_path3.dirname)(realKey));
1310
- roots.set(projRoot, { path: projRoot, name: (0, import_node_path3.basename)(projRoot), active: true });
1425
+ const realKey = await (0, import_promises4.realpath)(activeSource.key).catch(() => activeSource.key);
1426
+ const projRoot = await (0, import_promises4.realpath)(await findProjectRoot(realKey)).catch(() => (0, import_node_path4.dirname)(realKey));
1427
+ roots.set(projRoot, { path: projRoot, name: (0, import_node_path4.basename)(projRoot), active: true });
1311
1428
  }
1312
- const envRoots = [...workspaceRoots, ...(process.env.INKMAP_WORKSPACES || "").split(import_node_path3.delimiter)].filter(Boolean);
1429
+ const envRoots = [...workspaceRoots, ...(process.env.INKMAP_WORKSPACES || "").split(import_node_path4.delimiter)].filter(Boolean);
1313
1430
  for (const raw of envRoots) {
1314
- const real = await (0, import_promises3.realpath)((0, import_node_path3.resolve)(raw)).catch(() => null);
1431
+ const real = await (0, import_promises4.realpath)((0, import_node_path4.resolve)(raw)).catch(() => null);
1315
1432
  if (real && !roots.has(real)) {
1316
- roots.set(real, { path: real, name: (0, import_node_path3.basename)(real), active: roots.size === 0 });
1433
+ roots.set(real, { path: real, name: (0, import_node_path4.basename)(real), active: roots.size === 0 });
1317
1434
  }
1318
1435
  }
1319
1436
  const items = [];
@@ -1323,7 +1440,7 @@ data: ${JSON.stringify(data)}
1323
1440
  for (const f of files) {
1324
1441
  if (seen.has(f)) continue;
1325
1442
  seen.add(f);
1326
- const rel = (0, import_node_path3.relative)(root.path, f);
1443
+ const rel = (0, import_node_path4.relative)(root.path, f);
1327
1444
  items.push({
1328
1445
  path: f,
1329
1446
  label: `${root.name} / ${rel}`,
@@ -1335,7 +1452,7 @@ data: ${JSON.stringify(data)}
1335
1452
  if (activeSource.key && activeReal && !seen.has(activeReal)) {
1336
1453
  items.unshift({
1337
1454
  path: activeSource.key,
1338
- label: `${(0, import_node_path3.basename)(activeSource.dir)} / ${(0, import_node_path3.basename)(activeSource.key)}`,
1455
+ label: `${(0, import_node_path4.basename)(activeSource.dir)} / ${(0, import_node_path4.basename)(activeSource.key)}`,
1339
1456
  group: "active"
1340
1457
  });
1341
1458
  }
@@ -1345,10 +1462,10 @@ data: ${JSON.stringify(data)}
1345
1462
  async function switchSourceToFile(candidatePath, trustCaller = false) {
1346
1463
  const notMarkdown = () => new HttpError(400, zh2() ? "\u8BF7\u9009\u62E9 .md \u6216 .markmap.md \u6587\u4EF6\u3002" : "Choose a .md or .markmap.md file.");
1347
1464
  if (!candidatePath || typeof candidatePath !== "string" || !/\.md$/i.test(candidatePath)) throw notMarkdown();
1348
- const resolvedCandidate = (0, import_node_path3.resolve)(candidatePath);
1349
- const rawStat = await (0, import_promises3.lstat)(resolvedCandidate).catch(() => null);
1350
- const realTarget = await (0, import_promises3.realpath)(resolvedCandidate).catch(() => null);
1351
- const targetStat = realTarget ? await (0, import_promises3.stat)(realTarget).catch(() => null) : null;
1465
+ const resolvedCandidate = (0, import_node_path4.resolve)(candidatePath);
1466
+ const rawStat = await (0, import_promises4.lstat)(resolvedCandidate).catch(() => null);
1467
+ const realTarget = await (0, import_promises4.realpath)(resolvedCandidate).catch(() => null);
1468
+ const targetStat = realTarget ? await (0, import_promises4.stat)(realTarget).catch(() => null) : null;
1352
1469
  if (!rawStat || rawStat.isSymbolicLink() && !trustCaller || !realTarget || !targetStat?.isFile() || targetStat.size > MAX_MARKDOWN_BYTES) {
1353
1470
  throw new HttpError(403, zh2() ? "\u8BF7\u9009\u62E9 5 MiB \u4EE5\u5185\u7684\u666E\u901A Markdown \u6587\u4EF6\u3002" : "Choose a regular Markdown file up to 5 MiB.");
1354
1471
  }
@@ -1396,10 +1513,10 @@ data: ${JSON.stringify(data)}
1396
1513
  const sendFile = async (res, full) => {
1397
1514
  if (!full) return json(res, 403, { error: "forbidden" });
1398
1515
  try {
1399
- const ext = (0, import_node_path3.extname)(full).toLowerCase();
1516
+ const ext = (0, import_node_path4.extname)(full).toLowerCase();
1400
1517
  if (ext === ".html") {
1401
1518
  const osLoc = detectOsLocale();
1402
- const htmlText = (await (0, import_promises3.readFile)(full, "utf8")).replace(
1519
+ const htmlText = (await (0, import_promises4.readFile)(full, "utf8")).replace(
1403
1520
  /<html\b([^>]*)>/i,
1404
1521
  () => `<html lang="${osLoc === "zh" ? "zh-CN" : "en"}" data-os-locale="${osLoc}">`
1405
1522
  );
@@ -1407,7 +1524,7 @@ data: ${JSON.stringify(data)}
1407
1524
  res.end(htmlText, "utf8");
1408
1525
  return;
1409
1526
  }
1410
- const body = await (0, import_promises3.readFile)(full);
1527
+ const body = await (0, import_promises4.readFile)(full);
1411
1528
  const headers = {
1412
1529
  "content-type": TYPES[ext] ?? "application/octet-stream",
1413
1530
  "cache-control": sidebar ? "no-store" : "no-cache"
@@ -1493,7 +1610,19 @@ data: ${JSON.stringify(data)}
1493
1610
  return json(res, 200, { version });
1494
1611
  });
1495
1612
  }
1496
- if (url.pathname === "/api/license" && req.method === "GET") return json(res, 200, await license?.state() ?? { pro: false });
1613
+ if (url.pathname === "/api/image" && req.method === "POST") {
1614
+ if (!sameOriginWrite()) return json(res, 403, { error: "forbidden" });
1615
+ const image = decodeImageDataUrl(JSON.parse(await readBody(req)).dataUrl);
1616
+ if ("problem" in image) {
1617
+ return json(res, image.problem === "size" ? 413 : 415, { error: image.problem });
1618
+ }
1619
+ if (!hasAccess(await license?.state() ?? { pro: false })) return json(res, 403, { error: "Inkmap trial expired" });
1620
+ return await serialized(async () => {
1621
+ const name = activeSource.key ? (0, import_node_path4.basename)(activeSource.key) : activeSource.name;
1622
+ return json(res, 200, { path: await saveImageAsset(activeSource.dir, name, image) });
1623
+ });
1624
+ }
1625
+ if (url.pathname === "/api/license" && req.method === "GET") return json(res, 200, await license?.state({ forUi: true }) ?? { pro: false });
1497
1626
  if (url.pathname === "/api/open" && req.method === "POST") {
1498
1627
  if (!sameOriginWrite()) return json(res, 403, { error: "forbidden" });
1499
1628
  const { file } = JSON.parse(await readBody(req));
@@ -1588,8 +1717,8 @@ data: ${JSON.stringify(data)}
1588
1717
  if (url.pathname.startsWith("/doc-assets/")) {
1589
1718
  let asset = within(activeSource.dir, url.pathname.slice("/doc-assets/".length), true);
1590
1719
  if (asset) {
1591
- const root = await (0, import_promises3.realpath)(activeSource.dir).catch(() => null);
1592
- asset = await (0, import_promises3.realpath)(asset).catch(() => null);
1720
+ const root = await (0, import_promises4.realpath)(activeSource.dir).catch(() => null);
1721
+ asset = await (0, import_promises4.realpath)(asset).catch(() => null);
1593
1722
  const allowedExt = sidebar ? /\.(?:png|jpe?g|gif|webp|avif|bmp|ico)$/i : /\.(?:png|jpe?g|gif|webp|avif|bmp|ico|svg)$/i;
1594
1723
  if (!root || !asset || !insideOrEqual(root, asset) || !allowedExt.test(asset)) asset = null;
1595
1724
  }
@@ -1738,6 +1867,8 @@ var zh = {
1738
1867
  trialExpired: "7 \u5929\u8BD5\u7528\u5DF2\u7ED3\u675F\u3002\u8BF7\u8D2D\u4E70 Pro\uFF0C\u6216\u767B\u5F55\u5DF2\u8D2D\u4E70 Pro \u7684\u8D26\u53F7\u3002",
1739
1868
  checkoutFailed: "\u65E0\u6CD5\u6253\u5F00\u8D2D\u4E70\u9875\u9762\u3002",
1740
1869
  saveExport: "\u5BFC\u51FA",
1870
+ saveBeforeImage: "\u8BF7\u5148\u4FDD\u5B58\u8FD9\u4E2A\u6587\u6863\uFF0C\u518D\u7C98\u8D34\u56FE\u7247\u3002",
1871
+ saveFailedImage: "\u65E0\u6CD5\u4E3A\u56FE\u7247\u751F\u6210\u65B0\u7684\u6587\u4EF6\u540D\u3002",
1741
1872
  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",
1742
1873
  onboardingAction: "\u7ACB\u5373\u6253\u5F00\u601D\u7EF4\u5BFC\u56FE",
1743
1874
  welcomeTip: "\u{1F4A1} Inkmap \u601D\u7EF4\u5BFC\u56FE\u5DF2\u5B89\u88C5\uFF1A\u4E00\u952E\u6253\u5F00\u793A\u4F8B\u8111\u56FE\u4F53\u9A8C\u53CC\u5411\u7F16\u8F91\uFF0C\u6216\u5728\u4EFB\u610F .md \u6587\u4EF6\u70B9\u51FB\u53F3\u4E0B\u89D2\u300C\u601D\u7EF4\u5BFC\u56FE\u300D",
@@ -1788,6 +1919,8 @@ var en = {
1788
1919
  trialExpired: "Your 7-day trial has ended. Buy Pro or sign in to an account that has Pro.",
1789
1920
  checkoutFailed: "Could not open checkout.",
1790
1921
  saveExport: "Export",
1922
+ saveBeforeImage: "Save this document first, then paste the picture.",
1923
+ saveFailedImage: "Could not find a free file name for the picture.",
1791
1924
  onboardingTip: "\u{1F4A1} Inkmap is ready: Open this Markdown file side-by-side as an interactive two-way mind map",
1792
1925
  onboardingAction: "Open Mind Map",
1793
1926
  welcomeTip: "\u{1F4A1} Inkmap Mind Map is installed: Try the interactive welcome mind map, or click \u201CMind Map\u201D in the status bar on any .md file",
@@ -1929,7 +2062,7 @@ function extensionLicense(context) {
1929
2062
  if (token) await context.secrets.store(KEY, token);
1930
2063
  else await context.secrets.delete(KEY);
1931
2064
  }
1932
- }, () => vscode3.workspace.getConfiguration("inkmap").get("billingOrigin") || process.env.INKMAP_BILLING_ORIGIN || "" || YUNFAN_BILLING_ORIGIN, { host });
2065
+ }, () => vscode3.workspace.getConfiguration("inkmap").get("billingOrigin") || process.env.INKMAP_BILLING_ORIGIN || "" || YUNFAN_BILLING_ORIGIN, { host, reviewPrompt: false });
1933
2066
  }
1934
2067
  async function openCheckout(license, mode, localeHint) {
1935
2068
  const url = await license.connect(mode, localeHint);
@@ -1938,7 +2071,7 @@ async function openCheckout(license, mode, localeHint) {
1938
2071
 
1939
2072
  // packages/vscode/src/mindmapEditor.ts
1940
2073
  var import_node_crypto3 = require("node:crypto");
1941
- var import_promises4 = require("node:fs/promises");
2074
+ var import_promises5 = require("node:fs/promises");
1942
2075
  var vscode4 = __toESM(require("vscode"));
1943
2076
 
1944
2077
  // packages/vscode/src/html.ts
@@ -2108,6 +2241,12 @@ var MindmapEditorProvider = class {
2108
2241
  this.maybeOfferReview(edits);
2109
2242
  return post({ type: "saved", id: msg.id, version: String(document.version) });
2110
2243
  }
2244
+ case "saveImage":
2245
+ try {
2246
+ return post({ type: "imageSaved", id: msg.id, path: await saveImage(document, msg.dataUrl) });
2247
+ } catch (error) {
2248
+ return post({ type: "error", id: msg.id, message: error instanceof Error ? error.message : String(error) });
2249
+ }
2111
2250
  case "undo":
2112
2251
  case "redo":
2113
2252
  return vscode4.commands.executeCommand(msg.type);
@@ -2205,6 +2344,25 @@ var MindmapEditorProvider = class {
2205
2344
  });
2206
2345
  }
2207
2346
  };
2347
+ async function saveImage(document, dataUrl) {
2348
+ const image = decodeImageDataUrl(dataUrl);
2349
+ if ("problem" in image) throw new Error(image.problem);
2350
+ if (document.uri.scheme === "untitled") throw new Error(t("saveBeforeImage"));
2351
+ const fileName = document.uri.path.slice(document.uri.path.lastIndexOf("/") + 1);
2352
+ const folder = imageFolderName(fileName);
2353
+ const directory = vscode4.Uri.joinPath(document.uri, "..", folder);
2354
+ await vscode4.workspace.fs.createDirectory(directory);
2355
+ const now = /* @__PURE__ */ new Date();
2356
+ for (let attempt = 1; attempt <= 100; attempt++) {
2357
+ const name = imageFileName(now, image.extension, attempt);
2358
+ const target = vscode4.Uri.joinPath(directory, name);
2359
+ const taken = await vscode4.workspace.fs.stat(target).then(() => true, () => false);
2360
+ if (taken) continue;
2361
+ await vscode4.workspace.fs.writeFile(target, image.bytes);
2362
+ return imageLinkPath(folder, name);
2363
+ }
2364
+ throw new Error(t("saveFailedImage"));
2365
+ }
2208
2366
  async function saveDataUrl(name, dataUrl, dir) {
2209
2367
  const match = dataUrl.match(/^data:([^;,]+)?(;base64)?,(.*)$/s);
2210
2368
  if (!match) return false;
@@ -2220,7 +2378,7 @@ async function saveDataUrl(name, dataUrl, dir) {
2220
2378
  return true;
2221
2379
  }
2222
2380
  async function editorHtml(webview, webRoot, assets) {
2223
- return webviewHtml(await (0, import_promises4.readFile)(vscode4.Uri.joinPath(webRoot, "index.html").fsPath, "utf8"), {
2381
+ return webviewHtml(await (0, import_promises5.readFile)(vscode4.Uri.joinPath(webRoot, "index.html").fsPath, "utf8"), {
2224
2382
  webBase: webview.asWebviewUri(webRoot).toString(),
2225
2383
  assetBase: assets ? webview.asWebviewUri(assets).toString() + "/" : "",
2226
2384
  cspSource: webview.cspSource,
@@ -2232,14 +2390,14 @@ async function editorHtml(webview, webRoot, assets) {
2232
2390
  // packages/vscode/src/extension.ts
2233
2391
  function insideOrEqual2(root, target) {
2234
2392
  if (root === target) return true;
2235
- const rel = (0, import_node_path4.relative)(root, target);
2236
- return Boolean(rel && !(0, import_node_path4.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(".." + import_node_path4.sep));
2393
+ const rel = (0, import_node_path5.relative)(root, target);
2394
+ return Boolean(rel && !(0, import_node_path5.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(".." + import_node_path5.sep));
2237
2395
  }
2238
2396
  function resolveEditorUri(filePath) {
2239
2397
  for (const folder of vscode5.workspace.workspaceFolders ?? []) {
2240
2398
  const folderPath = folder.uri.fsPath || folder.uri.path;
2241
2399
  if (folderPath && insideOrEqual2(folderPath, filePath)) {
2242
- const rel = (0, import_node_path4.relative)(folderPath, filePath).split(import_node_path4.sep).join("/");
2400
+ const rel = (0, import_node_path5.relative)(folderPath, filePath).split(import_node_path5.sep).join("/");
2243
2401
  return rel ? vscode5.Uri.joinPath(folder.uri, rel) : folder.uri;
2244
2402
  }
2245
2403
  }
@@ -2257,7 +2415,7 @@ function findColumnForFile(fileUri) {
2257
2415
  if (input?.uri && (input.uri.fsPath === targetFs || input.uri.path === targetFs)) {
2258
2416
  return group.viewColumn;
2259
2417
  }
2260
- if (tab.label && targetFs.endsWith(import_node_path4.sep + tab.label.replace(/^Preview\s+/i, ""))) {
2418
+ if (tab.label && targetFs.endsWith(import_node_path5.sep + tab.label.replace(/^Preview\s+/i, ""))) {
2261
2419
  return group.viewColumn;
2262
2420
  }
2263
2421
  }
@@ -2293,15 +2451,15 @@ async function openFileInEditorPane(filePath) {
2293
2451
  });
2294
2452
  }
2295
2453
  function startMcpTargetBridge() {
2296
- const inkmapDir = process.env.INKMAP_HOME || (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".inkmap");
2297
- const targetPath = (0, import_node_path4.join)(inkmapDir, "antigravity-target.json");
2298
- const ackPath = (0, import_node_path4.join)(inkmapDir, "antigravity-target-ack.json");
2454
+ const inkmapDir = process.env.INKMAP_HOME || (0, import_node_path5.join)((0, import_node_os4.homedir)(), ".inkmap");
2455
+ const targetPath = (0, import_node_path5.join)(inkmapDir, "antigravity-target.json");
2456
+ const ackPath = (0, import_node_path5.join)(inkmapDir, "antigravity-target-ack.json");
2299
2457
  let lastSeq = Date.now() - 1e4;
2300
2458
  let debounceTimer;
2301
2459
  let disposed = false;
2302
2460
  const syncInitialSeq = async () => {
2303
2461
  try {
2304
- const raw = JSON.parse(await (0, import_promises5.readFile)(targetPath, "utf8"));
2462
+ const raw = JSON.parse(await (0, import_promises6.readFile)(targetPath, "utf8"));
2305
2463
  if (typeof raw?.seq === "number" && raw.seq < Date.now() - 8e3) {
2306
2464
  lastSeq = raw.seq;
2307
2465
  }
@@ -2311,7 +2469,7 @@ function startMcpTargetBridge() {
2311
2469
  };
2312
2470
  const alreadyAcked = async (seq) => {
2313
2471
  try {
2314
- const ack = JSON.parse(await (0, import_promises5.readFile)(ackPath, "utf8"));
2472
+ const ack = JSON.parse(await (0, import_promises6.readFile)(ackPath, "utf8"));
2315
2473
  return Boolean(ack && ack.ok === true && Number(ack.seq) >= seq);
2316
2474
  } catch {
2317
2475
  return false;
@@ -2321,7 +2479,7 @@ function startMcpTargetBridge() {
2321
2479
  if (disposed) return;
2322
2480
  let claimedSeq = 0;
2323
2481
  try {
2324
- const raw = JSON.parse(await (0, import_promises5.readFile)(targetPath, "utf8"));
2482
+ const raw = JSON.parse(await (0, import_promises6.readFile)(targetPath, "utf8"));
2325
2483
  if (!raw || raw.openInEditorPane !== true) return;
2326
2484
  const seq = Number(raw.seq) || 0;
2327
2485
  if (seq <= lastSeq || typeof raw.file !== "string" || !/\.md$/i.test(raw.file)) return;
@@ -2329,16 +2487,16 @@ function startMcpTargetBridge() {
2329
2487
  lastSeq = seq;
2330
2488
  return;
2331
2489
  }
2332
- const info = await (0, import_promises5.lstat)(raw.file).catch(() => null);
2490
+ const info = await (0, import_promises6.lstat)(raw.file).catch(() => null);
2333
2491
  if (!info || info.isSymbolicLink() || !info.isFile() || info.size > 5 * 1024 * 1024) return;
2334
- const realTarget = await (0, import_promises5.realpath)(raw.file).catch(() => raw.file);
2492
+ const realTarget = await (0, import_promises6.realpath)(raw.file).catch(() => raw.file);
2335
2493
  if (!/\.md$/i.test(realTarget)) return;
2336
2494
  const folders = vscode5.workspace.workspaceFolders ?? [];
2337
2495
  let matchesFolder = false;
2338
2496
  for (const folder of folders) {
2339
2497
  const folderPath = folder.uri.fsPath || folder.uri.path;
2340
2498
  if (!folderPath) continue;
2341
- const realFolder = await (0, import_promises5.realpath)(folderPath).catch(() => folderPath);
2499
+ const realFolder = await (0, import_promises6.realpath)(folderPath).catch(() => folderPath);
2342
2500
  if (insideOrEqual2(realFolder, realTarget)) {
2343
2501
  matchesFolder = true;
2344
2502
  break;
@@ -2357,7 +2515,7 @@ function startMcpTargetBridge() {
2357
2515
  const editorUrl = localEditorUrl(raw.editorUrl);
2358
2516
  if (editorUrl) await openUrlInEditorPane(editorUrl);
2359
2517
  else await openFileInEditorPane(realTarget);
2360
- await (0, import_promises5.writeFile)(ackPath, JSON.stringify({
2518
+ await (0, import_promises6.writeFile)(ackPath, JSON.stringify({
2361
2519
  seq,
2362
2520
  file: realTarget,
2363
2521
  ok: true,
@@ -2366,7 +2524,7 @@ function startMcpTargetBridge() {
2366
2524
  });
2367
2525
  } catch (err) {
2368
2526
  if (!claimedSeq) return;
2369
- await (0, import_promises5.writeFile)(ackPath, JSON.stringify({
2527
+ await (0, import_promises6.writeFile)(ackPath, JSON.stringify({
2370
2528
  seq: claimedSeq,
2371
2529
  ok: false,
2372
2530
  error: String(err instanceof Error ? err.message : err),
@@ -2407,13 +2565,13 @@ function startMcpTargetBridge() {
2407
2565
  var HARNESS_INDEX_URL = "https://zhiyuanv.com/dsh-index.json";
2408
2566
  var HARNESS_MARKET_BUNDLE = "@deepseek-ai/dsh-experimental-plugin-market-bundle";
2409
2567
  var HARNESS_PROMPTED = "inkmap.deepseekHarnessPrompted";
2410
- var harnessProfileDir = () => (0, import_node_path4.join)(process.env.DSH_HOME || (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".dsh"), "profiles", "desktop");
2568
+ var harnessProfileDir = () => (0, import_node_path5.join)(process.env.DSH_HOME || (0, import_node_path5.join)((0, import_node_os4.homedir)(), ".dsh"), "profiles", "desktop");
2411
2569
  async function readHarnessProfile(dir) {
2412
- const patchPath = (0, import_node_path4.join)(dir, "cordis.patch.yml");
2413
- const patch = (0, import_node_fs2.existsSync)(patchPath) ? await (0, import_promises5.readFile)(patchPath, "utf8").catch(() => "") : "";
2570
+ const patchPath = (0, import_node_path5.join)(dir, "cordis.patch.yml");
2571
+ const patch = (0, import_node_fs2.existsSync)(patchPath) ? await (0, import_promises6.readFile)(patchPath, "utf8").catch(() => "") : "";
2414
2572
  let pkg;
2415
2573
  try {
2416
- pkg = JSON.parse(await (0, import_promises5.readFile)((0, import_node_path4.join)(dir, "package.json"), "utf8"));
2574
+ pkg = JSON.parse(await (0, import_promises6.readFile)((0, import_node_path5.join)(dir, "package.json"), "utf8"));
2417
2575
  } catch {
2418
2576
  }
2419
2577
  const bundles = pkg?.dsh?.profile?.bundles;
@@ -2430,8 +2588,8 @@ var harnessSetUp = (profile) => !profile.needsIndex && !profile.needsBundle && !
2430
2588
  function harnessCli() {
2431
2589
  return [
2432
2590
  process.platform === "darwin" ? "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh" : "",
2433
- process.platform === "darwin" ? (0, import_node_path4.join)((0, import_node_os4.homedir)(), "Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh") : "",
2434
- process.platform === "win32" ? (0, import_node_path4.join)(process.env.LOCALAPPDATA || (0, import_node_path4.join)((0, import_node_os4.homedir)(), "AppData", "Local"), "Programs", "DeepSeek Harness", "resources", "runtime", "cli", "bin", "dsh.cmd") : ""
2591
+ process.platform === "darwin" ? (0, import_node_path5.join)((0, import_node_os4.homedir)(), "Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh") : "",
2592
+ process.platform === "win32" ? (0, import_node_path5.join)(process.env.LOCALAPPDATA || (0, import_node_path5.join)((0, import_node_os4.homedir)(), "AppData", "Local"), "Programs", "DeepSeek Harness", "resources", "runtime", "cli", "bin", "dsh.cmd") : ""
2435
2593
  ].find((candidate) => candidate && (0, import_node_fs2.existsSync)(candidate));
2436
2594
  }
2437
2595
  function runHarnessCli(cli, args) {
@@ -2467,17 +2625,17 @@ async function installIntoHarness(profile) {
2467
2625
  `;
2468
2626
  const trimmed = profile.patch.trim();
2469
2627
  const next = !trimmed || trimmed === "[]" ? snippet : profile.patch.replace(/\n*$/, "\n\n") + snippet;
2470
- await (0, import_promises5.writeFile)((0, import_node_path4.join)(profile.dir, "cordis.patch.yml"), next, "utf8");
2628
+ await (0, import_promises6.writeFile)((0, import_node_path5.join)(profile.dir, "cordis.patch.yml"), next, "utf8");
2471
2629
  }
2472
2630
  if (profile.needsBundle && profile.pkg?.dsh?.profile?.bundles) {
2473
2631
  profile.pkg.dsh.profile.bundles.push(HARNESS_MARKET_BUNDLE);
2474
- await (0, import_promises5.writeFile)((0, import_node_path4.join)(profile.dir, "package.json"), JSON.stringify(profile.pkg, null, 2) + "\n", "utf8");
2632
+ await (0, import_promises6.writeFile)((0, import_node_path5.join)(profile.dir, "package.json"), JSON.stringify(profile.pkg, null, 2) + "\n", "utf8");
2475
2633
  }
2476
2634
  if (!profile.needsPlugin) return "installed";
2477
2635
  const cli = harnessCli();
2478
2636
  if (!cli) return "configured";
2479
- const staged = (0, import_node_path4.join)(process.env.INKMAP_HOME || (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".inkmap"), "dsh-inkmap");
2480
- await runHarnessCli(cli, ["plugin", "--profile", "desktop", "add", (0, import_node_fs2.existsSync)((0, import_node_path4.join)(staged, "package.json")) ? staged : "dsh-inkmap"]);
2637
+ const staged = (0, import_node_path5.join)(process.env.INKMAP_HOME || (0, import_node_path5.join)((0, import_node_os4.homedir)(), ".inkmap"), "dsh-inkmap");
2638
+ await runHarnessCli(cli, ["plugin", "--profile", "desktop", "add", (0, import_node_fs2.existsSync)((0, import_node_path5.join)(staged, "package.json")) ? staged : "dsh-inkmap"]);
2481
2639
  return "installed";
2482
2640
  }
2483
2641
  async function installInDeepSeekHarness() {
@@ -2525,10 +2683,10 @@ function activate(context) {
2525
2683
  })
2526
2684
  );
2527
2685
  const openDemo = async () => {
2528
- const dir = context.globalStorageUri?.fsPath || (0, import_node_path4.join)((0, import_node_os4.tmpdir)(), "inkmap-welcome");
2686
+ const dir = context.globalStorageUri?.fsPath || (0, import_node_path5.join)((0, import_node_os4.tmpdir)(), "inkmap-welcome");
2529
2687
  (0, import_node_fs2.mkdirSync)(dir, { recursive: true });
2530
- const demoPath = (0, import_node_path4.join)(dir, "Inkmap-Welcome.md");
2531
- if (!(0, import_node_fs2.existsSync)(demoPath)) await (0, import_promises5.writeFile)(demoPath, t("welcomeDoc"), "utf8");
2688
+ const demoPath = (0, import_node_path5.join)(dir, "Inkmap-Welcome.md");
2689
+ if (!(0, import_node_fs2.existsSync)(demoPath)) await (0, import_promises6.writeFile)(demoPath, t("welcomeDoc"), "utf8");
2532
2690
  await vscode5.commands.executeCommand("vscode.openWith", vscode5.Uri.file(demoPath), MindmapEditorProvider.viewType, {
2533
2691
  viewColumn: vscode5.ViewColumn.Active,
2534
2692
  preserveFocus: false
@@ -2629,8 +2787,8 @@ function activate(context) {
2629
2787
  async handleUri(uri) {
2630
2788
  if (uri.path === "/open") {
2631
2789
  const target = new URLSearchParams(uri.query).get("path")?.trim();
2632
- if (!target || !(0, import_node_path4.isAbsolute)(target) || !/\.md$/i.test(target)) return;
2633
- const info = await (0, import_promises5.lstat)(target).catch(() => null);
2790
+ if (!target || !(0, import_node_path5.isAbsolute)(target) || !/\.md$/i.test(target)) return;
2791
+ const info = await (0, import_promises6.lstat)(target).catch(() => null);
2634
2792
  if (!info || info.isSymbolicLink() || !info.isFile() || info.size > 5 * 1024 * 1024) return;
2635
2793
  await openFileInEditorPane(target).catch(() => {
2636
2794
  });