inkmap-mcp 0.2.6 → 0.2.9
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/README.md +23 -3
- package/dist/bundles/antigravity/sidecars/inkmap/bridge.js +647 -80
- package/dist/bundles/antigravity/sidecars/inkmap/main.mjs +62 -36
- 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/vscode/dist/extension.js +1764 -0
- package/dist/bundles/vscode/images/icon.png +0 -0
- package/dist/bundles/vscode/package.json +243 -0
- package/dist/bundles/vscode/package.nls.json +19 -0
- package/dist/bundles/vscode/package.nls.zh-cn.json +19 -0
- package/dist/cli.cjs +753 -172
- package/dist/codex.html +948 -651
- package/dist/web/app.css +1 -1
- package/dist/web/app.js +26429 -25897
- package/dist/web/index.html +44 -5
- package/package.json +10 -2
- package/server.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -158,8 +158,28 @@ function licenseService(storage, getOrigin, { loginOnly = false } = {}) {
|
|
|
158
158
|
}
|
|
159
159
|
function maskPhone(phone) {
|
|
160
160
|
const clean = phone.trim();
|
|
161
|
+
const at = clean.indexOf("@");
|
|
162
|
+
if (at > 0 && at < clean.length - 1) {
|
|
163
|
+
const local = [...clean.slice(0, at)];
|
|
164
|
+
const domain2 = clean.slice(at + 1);
|
|
165
|
+
return `${local.length <= 1 ? "***" : local[0] + "***"}@${domain2}`.slice(0, 64);
|
|
166
|
+
}
|
|
161
167
|
return /^1\d{10}$/.test(clean) ? `${clean.slice(0, 3)}****${clean.slice(7)}` : clean.slice(0, 32);
|
|
162
168
|
}
|
|
169
|
+
function clientLocale() {
|
|
170
|
+
const raw = (process.env.INKMAP_LOCALE || process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || "").trim();
|
|
171
|
+
if (/^zh\b/i.test(raw))
|
|
172
|
+
return "zh";
|
|
173
|
+
if (/^en\b/i.test(process.env.INKMAP_LOCALE || ""))
|
|
174
|
+
return "en";
|
|
175
|
+
try {
|
|
176
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
|
|
177
|
+
if (/^Asia\/(Shanghai|Chongqing|Harbin|Urumqi)$/i.test(tz))
|
|
178
|
+
return "zh";
|
|
179
|
+
} catch {
|
|
180
|
+
}
|
|
181
|
+
return "en";
|
|
182
|
+
}
|
|
163
183
|
function writeSession(operation) {
|
|
164
184
|
const next = pendingWrite.then(operation);
|
|
165
185
|
pendingWrite = next.then(() => {
|
|
@@ -204,11 +224,16 @@ function licenseService(storage, getOrigin, { loginOnly = false } = {}) {
|
|
|
204
224
|
});
|
|
205
225
|
}
|
|
206
226
|
function phoneRequest(origin, action, phone, code) {
|
|
227
|
+
const isEmail = phone.includes("@");
|
|
228
|
+
const locale = clientLocale();
|
|
207
229
|
return fetch(origin + "/billing/v1/phone-sign-in/" + action, {
|
|
208
230
|
method: "POST",
|
|
209
|
-
headers: {
|
|
231
|
+
headers: {
|
|
232
|
+
"content-type": "application/json",
|
|
233
|
+
"accept-language": locale === "zh" ? "zh-CN,zh;q=0.9" : "en-US,en;q=0.9"
|
|
234
|
+
},
|
|
210
235
|
redirect: "error",
|
|
211
|
-
body: JSON.stringify({ product: PRODUCT.id, phone, code }),
|
|
236
|
+
body: JSON.stringify({ product: PRODUCT.id, phone, ...isEmail && { email: phone, locale }, code }),
|
|
212
237
|
signal: AbortSignal.timeout(12e3)
|
|
213
238
|
});
|
|
214
239
|
}
|
|
@@ -457,8 +482,10 @@ function licenseService(storage, getOrigin, { loginOnly = false } = {}) {
|
|
|
457
482
|
return { status: "needsPhone" };
|
|
458
483
|
},
|
|
459
484
|
async sendPhoneCode(phone) {
|
|
460
|
-
if (typeof phone !== "string" || !phone.trim() || phone.length >
|
|
485
|
+
if (typeof phone !== "string" || !phone.trim() || phone.length > 254)
|
|
461
486
|
return phoneFailure(400);
|
|
487
|
+
const isEmail = phone.includes("@");
|
|
488
|
+
const locale = clientLocale();
|
|
462
489
|
try {
|
|
463
490
|
const origin = billingOrigin(getOrigin());
|
|
464
491
|
if (!loginOnly) {
|
|
@@ -466,10 +493,12 @@ function licenseService(storage, getOrigin, { loginOnly = false } = {}) {
|
|
|
466
493
|
if (!pendingCheckout || pendingCheckout.origin !== origin) {
|
|
467
494
|
pendingCheckout = await createCheckoutFlow(origin);
|
|
468
495
|
}
|
|
469
|
-
|
|
496
|
+
const sendAction = isEmail ? "email/send" : "sms";
|
|
497
|
+
const sendBody = isEmail ? { email: phone, locale } : { phone };
|
|
498
|
+
let smsRes = await checkoutPost(pendingCheckout.url, sendAction, origin, sendBody, pendingCheckout.token, pendingCheckout.cookie);
|
|
470
499
|
if (smsRes.status === 410 || smsRes.status === 404) {
|
|
471
500
|
pendingCheckout = await createCheckoutFlow(origin);
|
|
472
|
-
smsRes = await checkoutPost(pendingCheckout.url,
|
|
501
|
+
smsRes = await checkoutPost(pendingCheckout.url, sendAction, origin, sendBody, pendingCheckout.token, pendingCheckout.cookie);
|
|
473
502
|
}
|
|
474
503
|
pendingCheckout.cookie = mergeCookies(pendingCheckout.cookie, smsRes);
|
|
475
504
|
return smsRes.status === 204 ? { ok: true, value: void 0 } : phoneFailure(smsRes.status);
|
|
@@ -484,8 +513,9 @@ function licenseService(storage, getOrigin, { loginOnly = false } = {}) {
|
|
|
484
513
|
}
|
|
485
514
|
},
|
|
486
515
|
async signInByPhone(phone, code) {
|
|
487
|
-
if (typeof phone !== "string" || !phone.trim() || phone.length >
|
|
516
|
+
if (typeof phone !== "string" || !phone.trim() || phone.length > 254 || typeof code !== "string" || !/^\d{6}$/.test(code))
|
|
488
517
|
return phoneFailure(400);
|
|
518
|
+
const isEmail = phone.includes("@");
|
|
489
519
|
const version2 = generation;
|
|
490
520
|
try {
|
|
491
521
|
const origin = billingOrigin(getOrigin());
|
|
@@ -493,7 +523,9 @@ function licenseService(storage, getOrigin, { loginOnly = false } = {}) {
|
|
|
493
523
|
let checkoutUrl;
|
|
494
524
|
let cookie;
|
|
495
525
|
if (pendingCheckout && pendingCheckout.origin === origin && !loginOnly) {
|
|
496
|
-
const
|
|
526
|
+
const verifyAction = isEmail ? "email/verify" : "login";
|
|
527
|
+
const verifyBody = isEmail ? { email: phone, code } : { phone, code };
|
|
528
|
+
const loginRes = await checkoutPost(pendingCheckout.url, verifyAction, origin, verifyBody, pendingCheckout.token, pendingCheckout.cookie);
|
|
497
529
|
if (!loginRes.ok) {
|
|
498
530
|
if (loginRes.status === 410 || loginRes.status === 404)
|
|
499
531
|
pendingCheckout = void 0;
|
|
@@ -685,6 +717,68 @@ var init_license = __esm({
|
|
|
685
717
|
});
|
|
686
718
|
|
|
687
719
|
// packages/cli/dist/server.js
|
|
720
|
+
function insideRoot(root, target) {
|
|
721
|
+
if (root === target)
|
|
722
|
+
return true;
|
|
723
|
+
const rel = (0, import_node_path2.relative)(root, target);
|
|
724
|
+
return Boolean(rel && !(0, import_node_path2.isAbsolute)(rel) && rel !== ".." && !rel.startsWith(".." + import_node_path2.sep));
|
|
725
|
+
}
|
|
726
|
+
async function findProjectRoot(filePath) {
|
|
727
|
+
let cur = (0, import_node_path2.dirname)(filePath);
|
|
728
|
+
const home = await (0, import_promises2.realpath)((0, import_node_os2.homedir)()).catch(() => (0, import_node_os2.homedir)());
|
|
729
|
+
while (cur && cur !== (0, import_node_path2.dirname)(cur) && cur !== home) {
|
|
730
|
+
try {
|
|
731
|
+
await (0, import_promises2.lstat)((0, import_node_path2.join)(cur, ".git"));
|
|
732
|
+
return cur;
|
|
733
|
+
} catch {
|
|
734
|
+
}
|
|
735
|
+
cur = (0, import_node_path2.dirname)(cur);
|
|
736
|
+
}
|
|
737
|
+
return (0, import_node_path2.dirname)(filePath);
|
|
738
|
+
}
|
|
739
|
+
async function scanProjectMarkdownFiles(rootDir, maxFiles = 200, maxDepth = 4) {
|
|
740
|
+
const found = [];
|
|
741
|
+
async function walk(dir, depth) {
|
|
742
|
+
if (depth > maxDepth || found.length >= maxFiles)
|
|
743
|
+
return;
|
|
744
|
+
let entries;
|
|
745
|
+
try {
|
|
746
|
+
entries = await (0, import_promises2.readdir)(dir, { withFileTypes: true });
|
|
747
|
+
} catch {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
for (const entry of entries) {
|
|
751
|
+
if (found.length >= maxFiles)
|
|
752
|
+
break;
|
|
753
|
+
if (entry.name.startsWith("."))
|
|
754
|
+
continue;
|
|
755
|
+
const full = (0, import_node_path2.join)(dir, entry.name);
|
|
756
|
+
if (entry.isDirectory()) {
|
|
757
|
+
if (!SKIP_SCAN_DIRS.has(entry.name))
|
|
758
|
+
await walk(full, depth + 1);
|
|
759
|
+
} else if (entry.isFile() && /\.md$/i.test(entry.name)) {
|
|
760
|
+
try {
|
|
761
|
+
const st = await (0, import_promises2.lstat)(full);
|
|
762
|
+
if (st.isFile() && st.size <= 5 * 1024 * 1024) {
|
|
763
|
+
const real = await (0, import_promises2.realpath)(full);
|
|
764
|
+
if (real === full && insideRoot(rootDir, real))
|
|
765
|
+
found.push(real);
|
|
766
|
+
}
|
|
767
|
+
} catch {
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
await walk(rootDir, 0);
|
|
773
|
+
found.sort((a, b) => {
|
|
774
|
+
const aM = /\.markmap\.md$/i.test(a) ? 0 : 1;
|
|
775
|
+
const bM = /\.markmap\.md$/i.test(b) ? 0 : 1;
|
|
776
|
+
if (aM !== bM)
|
|
777
|
+
return aM - bM;
|
|
778
|
+
return a.localeCompare(b);
|
|
779
|
+
});
|
|
780
|
+
return found;
|
|
781
|
+
}
|
|
688
782
|
function docName(path) {
|
|
689
783
|
return (0, import_node_path2.basename)(path).replace(/\.md$/i, "").replace(/\.markmap$/i, "");
|
|
690
784
|
}
|
|
@@ -742,17 +836,25 @@ function within(root, rel) {
|
|
|
742
836
|
const full = (0, import_node_path2.normalize)((0, import_node_path2.join)(root, decodeURIComponent(rel)));
|
|
743
837
|
return full.startsWith(base) ? full : null;
|
|
744
838
|
}
|
|
745
|
-
async function serve({ source, webRoot, port = 4377, host = "127.0.0.1", log = () => {
|
|
746
|
-
}, license, ads, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false }) {
|
|
839
|
+
async function serve({ source: initialSource, webRoot, port = 4377, host = "127.0.0.1", log = () => {
|
|
840
|
+
}, license, ads, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, loginOnly = false, ideWorkspace = false }) {
|
|
747
841
|
if (sidebar && host !== "127.0.0.1")
|
|
748
842
|
throw new Error("The sidebar bridge requires loopback.");
|
|
749
843
|
const prefix = sidebar ? `/s/${(0, import_node_crypto2.randomBytes)(24).toString("hex")}/` : "/";
|
|
844
|
+
let activeSource = initialSource;
|
|
750
845
|
let bound;
|
|
751
|
-
let current = await
|
|
846
|
+
let current = await activeSource.read();
|
|
752
847
|
let version2 = hash(current);
|
|
753
|
-
let viewState = await
|
|
848
|
+
let viewState = await activeSource.readView?.();
|
|
754
849
|
const clients = /* @__PURE__ */ new Set();
|
|
755
|
-
const
|
|
850
|
+
const canPurchase = !loginOnly && (!sidebar || sidebarPurchase);
|
|
851
|
+
const docState = () => ({
|
|
852
|
+
name: activeSource.name,
|
|
853
|
+
md: current,
|
|
854
|
+
version: version2,
|
|
855
|
+
...activeSource.key && { currentFile: activeSource.key },
|
|
856
|
+
...viewState && { viewState }
|
|
857
|
+
});
|
|
756
858
|
const send = (event, data) => {
|
|
757
859
|
const payload = `event: ${event}
|
|
758
860
|
data: ${JSON.stringify(data)}
|
|
@@ -772,7 +874,7 @@ data: ${JSON.stringify(data)}
|
|
|
772
874
|
return result;
|
|
773
875
|
}
|
|
774
876
|
async function refresh() {
|
|
775
|
-
const text = await
|
|
877
|
+
const text = await activeSource.read();
|
|
776
878
|
if (hash(text) === version2)
|
|
777
879
|
return;
|
|
778
880
|
current = text;
|
|
@@ -780,13 +882,82 @@ data: ${JSON.stringify(data)}
|
|
|
780
882
|
broadcast();
|
|
781
883
|
}
|
|
782
884
|
let pending;
|
|
783
|
-
|
|
885
|
+
let unwatch = activeSource.watch(() => {
|
|
784
886
|
clearTimeout(pending);
|
|
785
887
|
pending = setTimeout(async () => {
|
|
786
888
|
void serialized(refresh).catch(() => {
|
|
787
889
|
});
|
|
788
890
|
}, 80);
|
|
789
891
|
});
|
|
892
|
+
async function collectWorkspaceFiles() {
|
|
893
|
+
const roots = /* @__PURE__ */ new Map();
|
|
894
|
+
if (activeSource.key) {
|
|
895
|
+
const realKey = await (0, import_promises2.realpath)(activeSource.key).catch(() => activeSource.key);
|
|
896
|
+
const projRoot = await (0, import_promises2.realpath)(await findProjectRoot(realKey)).catch(() => (0, import_node_path2.dirname)(realKey));
|
|
897
|
+
roots.set(projRoot, { path: projRoot, name: (0, import_node_path2.basename)(projRoot), active: true });
|
|
898
|
+
}
|
|
899
|
+
const envRoots = (process.env.INKMAP_WORKSPACES || "").split(import_node_path2.delimiter).filter(Boolean);
|
|
900
|
+
for (const raw of envRoots) {
|
|
901
|
+
const real = await (0, import_promises2.realpath)((0, import_node_path2.resolve)(raw)).catch(() => null);
|
|
902
|
+
if (real && !roots.has(real)) {
|
|
903
|
+
roots.set(real, { path: real, name: (0, import_node_path2.basename)(real), active: roots.size === 0 });
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
const items = [];
|
|
907
|
+
const seen = /* @__PURE__ */ new Set();
|
|
908
|
+
for (const root of roots.values()) {
|
|
909
|
+
const files = await scanProjectMarkdownFiles(root.path);
|
|
910
|
+
for (const f2 of files) {
|
|
911
|
+
if (seen.has(f2))
|
|
912
|
+
continue;
|
|
913
|
+
seen.add(f2);
|
|
914
|
+
const rel = (0, import_node_path2.relative)(root.path, f2);
|
|
915
|
+
items.push({
|
|
916
|
+
path: f2,
|
|
917
|
+
label: `${root.name} / ${rel}`,
|
|
918
|
+
group: root.active ? "active" : "project"
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
if (activeSource.key && !seen.has(activeSource.key)) {
|
|
923
|
+
items.unshift({
|
|
924
|
+
path: activeSource.key,
|
|
925
|
+
label: `${(0, import_node_path2.basename)(activeSource.dir)} / ${(0, import_node_path2.basename)(activeSource.key)}`,
|
|
926
|
+
group: "active"
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
return { roots: [...roots.values()], files: items };
|
|
930
|
+
}
|
|
931
|
+
async function switchSourceToFile(candidatePath) {
|
|
932
|
+
if (!candidatePath || typeof candidatePath !== "string" || !/\.md$/i.test(candidatePath)) {
|
|
933
|
+
throw new Error("\u8BF7\u9009\u62E9 .md \u6216 .markmap.md \u6587\u4EF6\u3002");
|
|
934
|
+
}
|
|
935
|
+
const realTarget = await (0, import_promises2.realpath)((0, import_node_path2.resolve)(candidatePath));
|
|
936
|
+
const st = await (0, import_promises2.lstat)(realTarget);
|
|
937
|
+
if (!st.isFile() || st.size > 5 * 1024 * 1024) {
|
|
938
|
+
throw new Error("\u8BF7\u9009\u62E9 5 MiB \u4EE5\u5185\u7684 Markdown \u6587\u4EF6\u3002");
|
|
939
|
+
}
|
|
940
|
+
const { roots } = await collectWorkspaceFiles();
|
|
941
|
+
if (roots.length > 0 && !roots.some((r2) => insideRoot(r2.path, realTarget))) {
|
|
942
|
+
throw new Error("\u8BE5\u6587\u4EF6\u4E0D\u5728\u5F53\u524D\u9879\u76EE\u5DE5\u4F5C\u533A\u5185\u3002");
|
|
943
|
+
}
|
|
944
|
+
if (activeSource.key === realTarget)
|
|
945
|
+
return;
|
|
946
|
+
clearTimeout(pending);
|
|
947
|
+
unwatch();
|
|
948
|
+
activeSource = await fileSource(realTarget, log);
|
|
949
|
+
current = await activeSource.read();
|
|
950
|
+
version2 = hash(current);
|
|
951
|
+
viewState = await activeSource.readView?.();
|
|
952
|
+
unwatch = activeSource.watch(() => {
|
|
953
|
+
clearTimeout(pending);
|
|
954
|
+
pending = setTimeout(async () => {
|
|
955
|
+
void serialized(refresh).catch(() => {
|
|
956
|
+
});
|
|
957
|
+
}, 80);
|
|
958
|
+
});
|
|
959
|
+
broadcast();
|
|
960
|
+
}
|
|
790
961
|
const json2 = (res, status, body) => {
|
|
791
962
|
res.writeHead(status, { "content-type": "application/json; charset=utf-8", "cache-control": "no-store" });
|
|
792
963
|
res.end(JSON.stringify(body));
|
|
@@ -832,19 +1003,27 @@ data: ${JSON.stringify(data)}
|
|
|
832
1003
|
url2.pathname = "/" + url2.pathname.slice(prefix.length);
|
|
833
1004
|
}
|
|
834
1005
|
if (url2.pathname === "/api/doc" && req.method === "GET") {
|
|
835
|
-
viewState = await
|
|
1006
|
+
viewState = await activeSource.readView?.() ?? viewState;
|
|
836
1007
|
if (sidebar)
|
|
837
1008
|
await serialized(refresh);
|
|
838
1009
|
return json2(res, 200, docState());
|
|
839
1010
|
}
|
|
1011
|
+
if (url2.pathname === "/api/files" && req.method === "GET") {
|
|
1012
|
+
const { files } = await collectWorkspaceFiles();
|
|
1013
|
+
return json2(res, 200, { currentFile: activeSource.key ?? null, files });
|
|
1014
|
+
}
|
|
840
1015
|
if (url2.pathname === "/api/capabilities" && req.method === "GET") {
|
|
841
|
-
return json2(res, 200, {
|
|
1016
|
+
return json2(res, 200, {
|
|
1017
|
+
purchase: canPurchase,
|
|
1018
|
+
...ideWorkspace && { ideWorkspace: true },
|
|
1019
|
+
...sidebarAccountNavigation && { accountNavigation: "host" }
|
|
1020
|
+
});
|
|
842
1021
|
}
|
|
843
1022
|
if (url2.pathname === "/api/view" && req.method === "PUT") {
|
|
844
1023
|
const cleaned = sanitizeViewState(JSON.parse(await readBody(req)));
|
|
845
1024
|
if (cleaned) {
|
|
846
1025
|
viewState = cleaned;
|
|
847
|
-
await
|
|
1026
|
+
await activeSource.writeView?.(cleaned).catch(() => {
|
|
848
1027
|
});
|
|
849
1028
|
}
|
|
850
1029
|
return json2(res, 200, { ok: true });
|
|
@@ -860,7 +1039,7 @@ data: ${JSON.stringify(data)}
|
|
|
860
1039
|
if (baseVersion !== version2)
|
|
861
1040
|
return json2(res, 409, docState());
|
|
862
1041
|
if (md !== current) {
|
|
863
|
-
await
|
|
1042
|
+
await activeSource.write(md);
|
|
864
1043
|
current = md;
|
|
865
1044
|
version2 = hash(md);
|
|
866
1045
|
if (sidebar)
|
|
@@ -877,13 +1056,21 @@ data: ${JSON.stringify(data)}
|
|
|
877
1056
|
const local = reqHost && /^(127\.0\.0\.1|localhost|\[::1\]):[0-9]+$/.test(reqHost);
|
|
878
1057
|
return Boolean(local && origin === "http://" + reqHost && req.headers["content-type"] === "application/json");
|
|
879
1058
|
};
|
|
1059
|
+
if (url2.pathname === "/api/open" && req.method === "POST") {
|
|
1060
|
+
if (!sameOriginPost())
|
|
1061
|
+
return json2(res, 403, { error: "forbidden" });
|
|
1062
|
+
const { file: file2 } = JSON.parse(await readBody(req));
|
|
1063
|
+
await serialized(() => switchSourceToFile(String(file2 ?? "")));
|
|
1064
|
+
const { files } = await collectWorkspaceFiles();
|
|
1065
|
+
return json2(res, 200, { currentFile: activeSource.key ?? null, files, doc: docState() });
|
|
1066
|
+
}
|
|
880
1067
|
if (url2.pathname === "/api/checkout" && req.method === "POST") {
|
|
881
1068
|
if (!sameOriginPost())
|
|
882
1069
|
return json2(res, 403, { error: "forbidden" });
|
|
883
1070
|
const { mode } = JSON.parse(await readBody(req));
|
|
884
1071
|
if (mode !== "buy" && mode !== "restore")
|
|
885
1072
|
return json2(res, 400, { error: "invalid checkout mode" });
|
|
886
|
-
if (
|
|
1073
|
+
if (!canPurchase && mode === "buy")
|
|
887
1074
|
return json2(res, 403, { error: "forbidden" });
|
|
888
1075
|
if (!license)
|
|
889
1076
|
return json2(res, 503, { error: "Inkmap checkout is unavailable." });
|
|
@@ -892,7 +1079,7 @@ data: ${JSON.stringify(data)}
|
|
|
892
1079
|
if (url2.pathname === "/api/order-pro" && req.method === "POST") {
|
|
893
1080
|
if (!sameOriginPost())
|
|
894
1081
|
return json2(res, 403, { error: "forbidden" });
|
|
895
|
-
if (
|
|
1082
|
+
if (!canPurchase)
|
|
896
1083
|
return json2(res, 403, { error: "forbidden" });
|
|
897
1084
|
if (!license)
|
|
898
1085
|
return json2(res, 503, { error: "Inkmap checkout is unavailable." });
|
|
@@ -934,9 +1121,9 @@ data: ${JSON.stringify(data)}
|
|
|
934
1121
|
if (url2.pathname === "/favicon.ico")
|
|
935
1122
|
return void res.writeHead(204).end();
|
|
936
1123
|
if (url2.pathname.startsWith("/doc-assets/")) {
|
|
937
|
-
let asset = within(
|
|
1124
|
+
let asset = within(activeSource.dir, url2.pathname.slice("/doc-assets/".length));
|
|
938
1125
|
if (sidebar && asset) {
|
|
939
|
-
const root = await (0, import_promises2.realpath)(
|
|
1126
|
+
const root = await (0, import_promises2.realpath)(activeSource.dir);
|
|
940
1127
|
asset = await (0, import_promises2.realpath)(asset).catch(() => null);
|
|
941
1128
|
if (asset && (!asset.startsWith(root + import_node_path2.sep) || !/\.(?:png|jpe?g|gif|webp)$/i.test(asset)))
|
|
942
1129
|
asset = null;
|
|
@@ -964,6 +1151,7 @@ data: ${JSON.stringify(data)}
|
|
|
964
1151
|
}
|
|
965
1152
|
return {
|
|
966
1153
|
url: `http://${host}:${bound}${prefix}`,
|
|
1154
|
+
switchToFile: (filePath) => serialized(() => switchSourceToFile(filePath)),
|
|
967
1155
|
close: () => new Promise((done) => {
|
|
968
1156
|
clearTimeout(pending);
|
|
969
1157
|
unwatch();
|
|
@@ -974,7 +1162,7 @@ data: ${JSON.stringify(data)}
|
|
|
974
1162
|
})
|
|
975
1163
|
};
|
|
976
1164
|
}
|
|
977
|
-
var import_node_crypto2, import_node_fs, import_promises2, import_node_http, import_node_os2, import_node_path2, MAX_BODY, TYPES, hash;
|
|
1165
|
+
var import_node_crypto2, import_node_fs, import_promises2, import_node_http, import_node_os2, import_node_path2, SKIP_SCAN_DIRS, MAX_BODY, TYPES, hash;
|
|
978
1166
|
var init_server = __esm({
|
|
979
1167
|
"packages/cli/dist/server.js"() {
|
|
980
1168
|
"use strict";
|
|
@@ -985,6 +1173,28 @@ var init_server = __esm({
|
|
|
985
1173
|
import_node_http = require("node:http");
|
|
986
1174
|
import_node_os2 = require("node:os");
|
|
987
1175
|
import_node_path2 = require("node:path");
|
|
1176
|
+
SKIP_SCAN_DIRS = /* @__PURE__ */ new Set([
|
|
1177
|
+
".git",
|
|
1178
|
+
".hg",
|
|
1179
|
+
".svn",
|
|
1180
|
+
"node_modules",
|
|
1181
|
+
"dist",
|
|
1182
|
+
"dist-codex",
|
|
1183
|
+
"dist-workbuddy",
|
|
1184
|
+
"build",
|
|
1185
|
+
"out",
|
|
1186
|
+
".next",
|
|
1187
|
+
".nuxt",
|
|
1188
|
+
".agents",
|
|
1189
|
+
".agent",
|
|
1190
|
+
".gemini",
|
|
1191
|
+
".codex",
|
|
1192
|
+
".venv",
|
|
1193
|
+
"venv",
|
|
1194
|
+
"target",
|
|
1195
|
+
"coverage",
|
|
1196
|
+
".tmp"
|
|
1197
|
+
]);
|
|
988
1198
|
MAX_BODY = 20 * 1024 * 1024;
|
|
989
1199
|
TYPES = {
|
|
990
1200
|
".html": "text/html; charset=utf-8",
|
|
@@ -6451,8 +6661,8 @@ var init_regexes = __esm({
|
|
|
6451
6661
|
_emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
|
|
6452
6662
|
ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
6453
6663
|
ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
6454
|
-
mac = (
|
|
6455
|
-
const escapedDelim = escapeRegex(
|
|
6664
|
+
mac = (delimiter5) => {
|
|
6665
|
+
const escapedDelim = escapeRegex(delimiter5 ?? ":");
|
|
6456
6666
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
6457
6667
|
};
|
|
6458
6668
|
cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -33699,50 +33909,50 @@ var require_fast_uri = __commonJS({
|
|
|
33699
33909
|
schemelessOptions.skipEscape = true;
|
|
33700
33910
|
return serialize(resolved, schemelessOptions);
|
|
33701
33911
|
}
|
|
33702
|
-
function resolveComponent(base,
|
|
33912
|
+
function resolveComponent(base, relative3, options, skipNormalization) {
|
|
33703
33913
|
const target = {};
|
|
33704
33914
|
if (!skipNormalization) {
|
|
33705
33915
|
base = parse3(serialize(base, options), options);
|
|
33706
|
-
|
|
33916
|
+
relative3 = parse3(serialize(relative3, options), options);
|
|
33707
33917
|
}
|
|
33708
33918
|
options = options || {};
|
|
33709
|
-
if (!options.tolerant &&
|
|
33710
|
-
target.scheme =
|
|
33711
|
-
target.userinfo =
|
|
33712
|
-
target.host =
|
|
33713
|
-
target.port =
|
|
33714
|
-
target.path = removeDotSegments(
|
|
33715
|
-
target.query =
|
|
33919
|
+
if (!options.tolerant && relative3.scheme) {
|
|
33920
|
+
target.scheme = relative3.scheme;
|
|
33921
|
+
target.userinfo = relative3.userinfo;
|
|
33922
|
+
target.host = relative3.host;
|
|
33923
|
+
target.port = relative3.port;
|
|
33924
|
+
target.path = removeDotSegments(relative3.path || "");
|
|
33925
|
+
target.query = relative3.query;
|
|
33716
33926
|
} else {
|
|
33717
|
-
if (
|
|
33718
|
-
target.userinfo =
|
|
33719
|
-
target.host =
|
|
33720
|
-
target.port =
|
|
33721
|
-
target.path = removeDotSegments(
|
|
33722
|
-
target.query =
|
|
33927
|
+
if (relative3.userinfo !== void 0 || relative3.host !== void 0 || relative3.port !== void 0) {
|
|
33928
|
+
target.userinfo = relative3.userinfo;
|
|
33929
|
+
target.host = relative3.host;
|
|
33930
|
+
target.port = relative3.port;
|
|
33931
|
+
target.path = removeDotSegments(relative3.path || "");
|
|
33932
|
+
target.query = relative3.query;
|
|
33723
33933
|
} else {
|
|
33724
|
-
if (!
|
|
33934
|
+
if (!relative3.path) {
|
|
33725
33935
|
target.path = base.path;
|
|
33726
|
-
if (
|
|
33727
|
-
target.query =
|
|
33936
|
+
if (relative3.query !== void 0) {
|
|
33937
|
+
target.query = relative3.query;
|
|
33728
33938
|
} else {
|
|
33729
33939
|
target.query = base.query;
|
|
33730
33940
|
}
|
|
33731
33941
|
} else {
|
|
33732
|
-
if (
|
|
33733
|
-
target.path = removeDotSegments(
|
|
33942
|
+
if (relative3.path[0] === "/") {
|
|
33943
|
+
target.path = removeDotSegments(relative3.path);
|
|
33734
33944
|
} else {
|
|
33735
33945
|
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
33736
33946
|
if (baseHasAuthority && !base.path) {
|
|
33737
|
-
target.path = "/" +
|
|
33947
|
+
target.path = "/" + relative3.path;
|
|
33738
33948
|
} else if (!base.path) {
|
|
33739
|
-
target.path =
|
|
33949
|
+
target.path = relative3.path;
|
|
33740
33950
|
} else {
|
|
33741
|
-
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) +
|
|
33951
|
+
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative3.path;
|
|
33742
33952
|
}
|
|
33743
33953
|
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
33744
33954
|
}
|
|
33745
|
-
target.query =
|
|
33955
|
+
target.query = relative3.query;
|
|
33746
33956
|
}
|
|
33747
33957
|
target.userinfo = base.userinfo;
|
|
33748
33958
|
target.host = base.host;
|
|
@@ -33750,7 +33960,7 @@ var require_fast_uri = __commonJS({
|
|
|
33750
33960
|
}
|
|
33751
33961
|
target.scheme = base.scheme;
|
|
33752
33962
|
}
|
|
33753
|
-
target.fragment =
|
|
33963
|
+
target.fragment = relative3.fragment;
|
|
33754
33964
|
return target;
|
|
33755
33965
|
}
|
|
33756
33966
|
function equal(uriA, uriB, options) {
|
|
@@ -39009,7 +39219,7 @@ async function findGitRoot(filePath) {
|
|
|
39009
39219
|
}
|
|
39010
39220
|
return (0, import_node_path3.dirname)(filePath);
|
|
39011
39221
|
}
|
|
39012
|
-
async function writeTargetSelection(filePath, workspaceDir) {
|
|
39222
|
+
async function writeTargetSelection(filePath, workspaceDir, extra) {
|
|
39013
39223
|
const real = await (0, import_promises3.realpath)(filePath);
|
|
39014
39224
|
const info = await (0, import_promises3.lstat)(real);
|
|
39015
39225
|
if (!info.isFile() || info.size > MAX_BYTES || !/\.md$/i.test(real)) {
|
|
@@ -39022,7 +39232,8 @@ async function writeTargetSelection(filePath, workspaceDir) {
|
|
|
39022
39232
|
file: real,
|
|
39023
39233
|
workspace,
|
|
39024
39234
|
seq: Date.now(),
|
|
39025
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
39235
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
39236
|
+
...extra?.openInEditorPane && { openInEditorPane: true }
|
|
39026
39237
|
};
|
|
39027
39238
|
const tmp = `${statePath}.${process.pid}.${Date.now()}`;
|
|
39028
39239
|
try {
|
|
@@ -39281,7 +39492,9 @@ function createMcpWorkspaceManager() {
|
|
|
39281
39492
|
if (options.path?.trim()) {
|
|
39282
39493
|
explicitFile = await assertAllowedFile(options.path, extraUris, Boolean(options.fromModel));
|
|
39283
39494
|
if (options.fromModel) {
|
|
39284
|
-
const saved = await writeTargetSelection(explicitFile, options.workspace
|
|
39495
|
+
const saved = await writeTargetSelection(explicitFile, options.workspace, {
|
|
39496
|
+
openInEditorPane: options.openInEditorPane
|
|
39497
|
+
});
|
|
39285
39498
|
internalSeq = Math.max(internalSeq, saved.seq);
|
|
39286
39499
|
} else {
|
|
39287
39500
|
internalSeq = Math.max(internalSeq + 1, Date.now());
|
|
@@ -39297,6 +39510,10 @@ function createMcpWorkspaceManager() {
|
|
|
39297
39510
|
const activeGroup = files.filter((f2) => f2.group === "active");
|
|
39298
39511
|
chosen = (activeGroup[0] || files[0])?.path || null;
|
|
39299
39512
|
}
|
|
39513
|
+
if (chosen && !explicitFile && options.fromModel && options.openInEditorPane) {
|
|
39514
|
+
const saved = await writeTargetSelection(chosen, options.workspace, { openInEditorPane: true });
|
|
39515
|
+
internalSeq = Math.max(internalSeq, saved.seq);
|
|
39516
|
+
}
|
|
39300
39517
|
if (!chosen) {
|
|
39301
39518
|
return {
|
|
39302
39519
|
files,
|
|
@@ -39442,19 +39659,20 @@ function openSystemBrowser(url2) {
|
|
|
39442
39659
|
(0, import_node_child_process.spawn)(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
39443
39660
|
}
|
|
39444
39661
|
async function createInkmapMcpServer(options = {}) {
|
|
39445
|
-
const
|
|
39662
|
+
const loadHtml = async () => options.html ?? await (0, import_promises4.readFile)(HTML, "utf8").catch((error62) => {
|
|
39446
39663
|
if (error62.code === "ENOENT") {
|
|
39447
39664
|
throw new Error("MCP App editor assets are missing. Run npm run build:sidebars.");
|
|
39448
39665
|
}
|
|
39449
39666
|
throw error62;
|
|
39450
39667
|
});
|
|
39668
|
+
await loadHtml();
|
|
39451
39669
|
const billingOrigin2 = options.billingOrigin ?? (() => process.env.INKMAP_BILLING_ORIGIN || YUNFAN_BILLING_ORIGIN);
|
|
39452
39670
|
const billing = licenseService(fileSessionStorage(), billingOrigin2, { loginOnly: true });
|
|
39453
39671
|
let browserBilling;
|
|
39454
39672
|
const fallbackEditors = /* @__PURE__ */ new Map();
|
|
39455
39673
|
const ads = adFeed(PRODUCT.adFeedUrl);
|
|
39456
39674
|
const workspaces = createMcpWorkspaceManager();
|
|
39457
|
-
const server = new McpServer({ name: "inkmap", version: "0.2.
|
|
39675
|
+
const server = new McpServer({ name: "inkmap", version: "0.2.8" });
|
|
39458
39676
|
function isAntigravityHost() {
|
|
39459
39677
|
const clientName = server.server.getClientVersion()?.name ?? "";
|
|
39460
39678
|
if (/antigravity/i.test(clientName))
|
|
@@ -39463,6 +39681,26 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39463
39681
|
return true;
|
|
39464
39682
|
return false;
|
|
39465
39683
|
}
|
|
39684
|
+
function isCursorHost() {
|
|
39685
|
+
const clientName = server.server.getClientVersion()?.name ?? "";
|
|
39686
|
+
return /cursor/i.test(clientName);
|
|
39687
|
+
}
|
|
39688
|
+
function hasIdeEditorExtension() {
|
|
39689
|
+
const clientName = server.server.getClientVersion()?.name ?? "";
|
|
39690
|
+
let extDir = null;
|
|
39691
|
+
if (/cursor/i.test(clientName)) {
|
|
39692
|
+
extDir = (0, import_node_path4.join)(process.env.INKMAP_CURSOR_CONFIG_DIR || (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".cursor"), "extensions");
|
|
39693
|
+
} else if (/visual studio code|vscode/i.test(clientName)) {
|
|
39694
|
+
extDir = (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".vscode", "extensions");
|
|
39695
|
+
}
|
|
39696
|
+
if (!extDir || !(0, import_node_fs2.existsSync)(extDir))
|
|
39697
|
+
return false;
|
|
39698
|
+
try {
|
|
39699
|
+
return (0, import_node_fs2.readdirSync)(extDir).some((entry) => entry.toLowerCase().startsWith("inkmap.inkmap-vscode"));
|
|
39700
|
+
} catch {
|
|
39701
|
+
return false;
|
|
39702
|
+
}
|
|
39703
|
+
}
|
|
39466
39704
|
function hostSupportsEmbeddedUi() {
|
|
39467
39705
|
if (Y3(server.server.getClientCapabilities()))
|
|
39468
39706
|
return true;
|
|
@@ -39470,28 +39708,51 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39470
39708
|
return true;
|
|
39471
39709
|
return false;
|
|
39472
39710
|
}
|
|
39473
|
-
async function
|
|
39711
|
+
async function waitForEditorBridgeAck(seq, timeoutMs = 280) {
|
|
39712
|
+
if (!seq)
|
|
39713
|
+
return false;
|
|
39714
|
+
const inkmapDir = process.env.INKMAP_HOME || (0, import_node_path4.join)((0, import_node_os4.homedir)(), ".inkmap");
|
|
39715
|
+
const ackPath = (0, import_node_path4.join)(inkmapDir, "antigravity-target-ack.json");
|
|
39716
|
+
const deadline = Date.now() + timeoutMs;
|
|
39717
|
+
while (Date.now() < deadline) {
|
|
39718
|
+
try {
|
|
39719
|
+
const raw = JSON.parse(await (0, import_promises4.readFile)(ackPath, "utf8"));
|
|
39720
|
+
if (raw && raw.ok === true && Number(raw.seq) >= seq) {
|
|
39721
|
+
return true;
|
|
39722
|
+
}
|
|
39723
|
+
} catch {
|
|
39724
|
+
}
|
|
39725
|
+
await new Promise((r2) => setTimeout(r2, 45));
|
|
39726
|
+
}
|
|
39727
|
+
return false;
|
|
39728
|
+
}
|
|
39729
|
+
async function openFallbackBrowserEditor(filePath, launchSystemBrowser = true) {
|
|
39474
39730
|
if (!(0, import_node_fs2.existsSync)(WEB_ROOT))
|
|
39475
39731
|
return void 0;
|
|
39476
|
-
let pending = fallbackEditors.get(
|
|
39732
|
+
let pending = fallbackEditors.get("__workspace__");
|
|
39477
39733
|
if (!pending) {
|
|
39478
|
-
browserBilling ??= licenseService(fileSessionStorage(), billingOrigin2);
|
|
39479
39734
|
pending = (async () => {
|
|
39480
39735
|
const source = await fileSource(filePath);
|
|
39481
39736
|
return serve({
|
|
39482
39737
|
source,
|
|
39483
39738
|
webRoot: WEB_ROOT,
|
|
39484
39739
|
port: 0,
|
|
39485
|
-
license:
|
|
39486
|
-
ads,
|
|
39487
|
-
sidebar: false
|
|
39740
|
+
license: billing,
|
|
39741
|
+
ads: async () => [],
|
|
39742
|
+
sidebar: false,
|
|
39743
|
+
loginOnly: true,
|
|
39744
|
+
ideWorkspace: true
|
|
39488
39745
|
});
|
|
39489
39746
|
})();
|
|
39490
|
-
fallbackEditors.set(
|
|
39491
|
-
pending.catch(() => fallbackEditors.delete(
|
|
39747
|
+
fallbackEditors.set("__workspace__", pending);
|
|
39748
|
+
pending.catch(() => fallbackEditors.delete("__workspace__"));
|
|
39492
39749
|
}
|
|
39493
39750
|
const served = await pending;
|
|
39494
|
-
|
|
39751
|
+
await served.switchToFile?.(filePath).catch(() => {
|
|
39752
|
+
});
|
|
39753
|
+
if (launchSystemBrowser) {
|
|
39754
|
+
openSystemBrowser(served.url);
|
|
39755
|
+
}
|
|
39495
39756
|
return served.url;
|
|
39496
39757
|
}
|
|
39497
39758
|
async function disposeAll() {
|
|
@@ -39504,7 +39765,7 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39504
39765
|
N3(server, "Inkmap Markdown editor", UI, {
|
|
39505
39766
|
_meta: { ui: { prefersBorder: false } }
|
|
39506
39767
|
}, async () => ({
|
|
39507
|
-
contents: [{ uri: UI, mimeType: p, text:
|
|
39768
|
+
contents: [{ uri: UI, mimeType: p, text: await loadHtml() }]
|
|
39508
39769
|
}));
|
|
39509
39770
|
K3(server, "inkmap_open_markdown", {
|
|
39510
39771
|
title: "Inkmap Mind Map",
|
|
@@ -39534,16 +39795,23 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39534
39795
|
}
|
|
39535
39796
|
}
|
|
39536
39797
|
}, async ({ path, workspace }) => {
|
|
39798
|
+
const cursorHost = isCursorHost();
|
|
39799
|
+
const openInRightEditor = hasIdeEditorExtension() || cursorHost;
|
|
39537
39800
|
const [opened, license] = await Promise.all([
|
|
39538
|
-
workspaces.open({ path, workspace, fromModel: true }),
|
|
39801
|
+
workspaces.open({ path, workspace, fromModel: true, openInEditorPane: openInRightEditor }),
|
|
39539
39802
|
billing.state()
|
|
39540
39803
|
]);
|
|
39804
|
+
let ackedByExtension = false;
|
|
39805
|
+
if (openInRightEditor && opened.currentFile && opened.targetSeq) {
|
|
39806
|
+
ackedByExtension = await waitForEditorBridgeAck(opened.targetSeq, 260);
|
|
39807
|
+
}
|
|
39541
39808
|
let editorUrl;
|
|
39542
|
-
if (opened.currentFile && !hostSupportsEmbeddedUi()) {
|
|
39543
|
-
|
|
39809
|
+
if (opened.currentFile && (cursorHost || !openInRightEditor && !hostSupportsEmbeddedUi())) {
|
|
39810
|
+
const shouldLaunchSystemBrowser = !cursorHost && !openInRightEditor && !hostSupportsEmbeddedUi();
|
|
39811
|
+
editorUrl = await openFallbackBrowserEditor(opened.currentFile, shouldLaunchSystemBrowser).catch(() => void 0);
|
|
39544
39812
|
}
|
|
39545
39813
|
const includeDoc = Buffer.byteLength(opened.doc.md, "utf8") <= INLINE_DOC_LIMIT;
|
|
39546
|
-
const summary = editorUrl ? `Opened ${opened.currentFile} in Inkmap interactive mind map at ${editorUrl} (live two-way synced with your Markdown file).` : opened.currentFile ? `Opened ${opened.currentFile} in Inkmap mind map.` : "Opened Inkmap mind map panel.";
|
|
39814
|
+
const summary = ackedByExtension && opened.currentFile ? `Opened ${opened.currentFile} in the editor pane as an Inkmap mind map.` : cursorHost && editorUrl && opened.currentFile ? `Opened ${opened.currentFile} in Inkmap at ${editorUrl}. IMPORTANT: Call the open_resource tool from cursor-app-control with uri "${editorUrl}" so the mind map opens directly in the right-hand editor pane.` : editorUrl ? `Opened ${opened.currentFile} in Inkmap interactive mind map at ${editorUrl} (live two-way synced with your Markdown file).` : opened.currentFile ? `Opened ${opened.currentFile} in Inkmap mind map.` : "Opened Inkmap mind map panel.";
|
|
39547
39815
|
return {
|
|
39548
39816
|
content: [{ type: "text", text: summary }],
|
|
39549
39817
|
structuredContent: {
|
|
@@ -39553,6 +39821,7 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39553
39821
|
currentFileUri: opened.currentFileUri,
|
|
39554
39822
|
targetSeq: opened.targetSeq,
|
|
39555
39823
|
license: { ...license },
|
|
39824
|
+
...openInRightEditor && { openedInEditorPane: true },
|
|
39556
39825
|
...editorUrl && { editorUrl },
|
|
39557
39826
|
...includeDoc && { doc: opened.doc }
|
|
39558
39827
|
}
|
|
@@ -39624,6 +39893,39 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39624
39893
|
const saved = await workspaces.saveView({ file: file2, state });
|
|
39625
39894
|
return { content: [], structuredContent: { ...saved } };
|
|
39626
39895
|
});
|
|
39896
|
+
server.registerTool("inkmap_open_browser", {
|
|
39897
|
+
title: "Open current Markdown mind map in standalone browser window",
|
|
39898
|
+
inputSchema: {
|
|
39899
|
+
file: external_exports.string().optional()
|
|
39900
|
+
},
|
|
39901
|
+
annotations: { readOnlyHint: true },
|
|
39902
|
+
_meta: appOnly
|
|
39903
|
+
}, async ({ file: file2 }) => {
|
|
39904
|
+
const opened = await workspaces.open({ path: file2, fromModel: false });
|
|
39905
|
+
if (!opened.currentFile)
|
|
39906
|
+
throw new Error("\u672A\u9009\u62E9 Markdown \u6587\u4EF6\u3002");
|
|
39907
|
+
const url2 = await openFallbackBrowserEditor(opened.currentFile);
|
|
39908
|
+
return { content: [], structuredContent: { url: url2 ?? "" } };
|
|
39909
|
+
});
|
|
39910
|
+
server.registerTool("inkmap_focus_editor", {
|
|
39911
|
+
title: "Focus or reopen Markdown mind map in IDE editor pane",
|
|
39912
|
+
inputSchema: {
|
|
39913
|
+
file: external_exports.string().optional()
|
|
39914
|
+
},
|
|
39915
|
+
annotations: { readOnlyHint: true },
|
|
39916
|
+
_meta: appOnly
|
|
39917
|
+
}, async ({ file: file2 }) => {
|
|
39918
|
+
const opened = await workspaces.open({ path: file2, fromModel: false });
|
|
39919
|
+
if (!opened.currentFile)
|
|
39920
|
+
throw new Error("\u672A\u9009\u62E9 Markdown \u6587\u4EF6\u3002");
|
|
39921
|
+
const payload = await writeTargetSelection(opened.currentFile, void 0, { openInEditorPane: true });
|
|
39922
|
+
const acked = await waitForEditorBridgeAck(payload.seq, 280);
|
|
39923
|
+
if (acked) {
|
|
39924
|
+
return { content: [], structuredContent: { ok: true, handledBy: "extension" } };
|
|
39925
|
+
}
|
|
39926
|
+
const url2 = await openFallbackBrowserEditor(opened.currentFile, false);
|
|
39927
|
+
return { content: [], structuredContent: { ok: true, handledBy: "glass", url: url2 ?? "" } };
|
|
39928
|
+
});
|
|
39627
39929
|
server.registerTool("inkmap_access", {
|
|
39628
39930
|
title: "Check Inkmap access",
|
|
39629
39931
|
annotations: { readOnlyHint: true },
|
|
@@ -39664,7 +39966,7 @@ async function serveCodex() {
|
|
|
39664
39966
|
};
|
|
39665
39967
|
await server.connect(transport);
|
|
39666
39968
|
}
|
|
39667
|
-
var import_node_child_process, import_node_fs2, import_promises4, import_node_url2, UI, HTML, WEB_ROOT, INLINE_DOC_LIMIT, appOnly;
|
|
39969
|
+
var import_node_child_process, import_node_fs2, import_promises4, import_node_os4, import_node_path4, import_node_url2, UI, HTML, WEB_ROOT, INLINE_DOC_LIMIT, appOnly;
|
|
39668
39970
|
var init_codex = __esm({
|
|
39669
39971
|
"packages/cli/dist/codex.js"() {
|
|
39670
39972
|
"use strict";
|
|
@@ -39674,6 +39976,8 @@ var init_codex = __esm({
|
|
|
39674
39976
|
import_node_child_process = require("node:child_process");
|
|
39675
39977
|
import_node_fs2 = require("node:fs");
|
|
39676
39978
|
import_promises4 = require("node:fs/promises");
|
|
39979
|
+
import_node_os4 = require("node:os");
|
|
39980
|
+
import_node_path4 = require("node:path");
|
|
39677
39981
|
import_node_url2 = require("node:url");
|
|
39678
39982
|
init_zod();
|
|
39679
39983
|
init_dist();
|
|
@@ -39694,6 +39998,73 @@ __export(install_exports, {
|
|
|
39694
39998
|
runInstall: () => runInstall,
|
|
39695
39999
|
runInstallCli: () => runInstallCli
|
|
39696
40000
|
});
|
|
40001
|
+
function crc32(buf) {
|
|
40002
|
+
let c = 4294967295;
|
|
40003
|
+
for (let i = 0; i < buf.length; i++) {
|
|
40004
|
+
c = CRC_TABLE[(c ^ buf[i]) & 255] ^ c >>> 8;
|
|
40005
|
+
}
|
|
40006
|
+
return (c ^ 4294967295) >>> 0;
|
|
40007
|
+
}
|
|
40008
|
+
function buildZipBuffer(entries) {
|
|
40009
|
+
const localParts = [];
|
|
40010
|
+
const centralParts = [];
|
|
40011
|
+
let offset = 0;
|
|
40012
|
+
for (const entry of entries) {
|
|
40013
|
+
const nameBuf = Buffer.from(entry.name.replace(/\\/g, "/"), "utf8");
|
|
40014
|
+
const raw = entry.data;
|
|
40015
|
+
const compressed = (0, import_node_zlib.deflateRawSync)(raw, { level: 6 });
|
|
40016
|
+
const useDeflate = compressed.length < raw.length;
|
|
40017
|
+
const payload = useDeflate ? compressed : raw;
|
|
40018
|
+
const method = useDeflate ? 8 : 0;
|
|
40019
|
+
const crc = crc32(raw);
|
|
40020
|
+
const local = Buffer.alloc(30 + nameBuf.length);
|
|
40021
|
+
local.writeUInt32LE(67324752, 0);
|
|
40022
|
+
local.writeUInt16LE(20, 4);
|
|
40023
|
+
local.writeUInt16LE(2048, 6);
|
|
40024
|
+
local.writeUInt16LE(method, 8);
|
|
40025
|
+
local.writeUInt16LE(0, 10);
|
|
40026
|
+
local.writeUInt16LE(22896, 12);
|
|
40027
|
+
local.writeUInt32LE(crc, 14);
|
|
40028
|
+
local.writeUInt32LE(payload.length, 18);
|
|
40029
|
+
local.writeUInt32LE(raw.length, 22);
|
|
40030
|
+
local.writeUInt16LE(nameBuf.length, 26);
|
|
40031
|
+
local.writeUInt16LE(0, 28);
|
|
40032
|
+
nameBuf.copy(local, 30);
|
|
40033
|
+
const central = Buffer.alloc(46 + nameBuf.length);
|
|
40034
|
+
central.writeUInt32LE(33639248, 0);
|
|
40035
|
+
central.writeUInt16LE(20, 4);
|
|
40036
|
+
central.writeUInt16LE(20, 6);
|
|
40037
|
+
central.writeUInt16LE(2048, 8);
|
|
40038
|
+
central.writeUInt16LE(method, 10);
|
|
40039
|
+
central.writeUInt16LE(0, 12);
|
|
40040
|
+
central.writeUInt16LE(22896, 14);
|
|
40041
|
+
central.writeUInt32LE(crc, 16);
|
|
40042
|
+
central.writeUInt32LE(payload.length, 20);
|
|
40043
|
+
central.writeUInt32LE(raw.length, 24);
|
|
40044
|
+
central.writeUInt16LE(nameBuf.length, 28);
|
|
40045
|
+
central.writeUInt16LE(0, 30);
|
|
40046
|
+
central.writeUInt16LE(0, 32);
|
|
40047
|
+
central.writeUInt16LE(0, 34);
|
|
40048
|
+
central.writeUInt16LE(0, 36);
|
|
40049
|
+
central.writeUInt32LE(0, 38);
|
|
40050
|
+
central.writeUInt32LE(offset, 42);
|
|
40051
|
+
nameBuf.copy(central, 46);
|
|
40052
|
+
localParts.push(local, payload);
|
|
40053
|
+
centralParts.push(central);
|
|
40054
|
+
offset += local.length + payload.length;
|
|
40055
|
+
}
|
|
40056
|
+
const centralBuf = Buffer.concat(centralParts);
|
|
40057
|
+
const eocd = Buffer.alloc(22);
|
|
40058
|
+
eocd.writeUInt32LE(101010256, 0);
|
|
40059
|
+
eocd.writeUInt16LE(0, 4);
|
|
40060
|
+
eocd.writeUInt16LE(0, 6);
|
|
40061
|
+
eocd.writeUInt16LE(entries.length, 8);
|
|
40062
|
+
eocd.writeUInt16LE(entries.length, 10);
|
|
40063
|
+
eocd.writeUInt32LE(centralBuf.length, 12);
|
|
40064
|
+
eocd.writeUInt32LE(offset, 16);
|
|
40065
|
+
eocd.writeUInt16LE(0, 20);
|
|
40066
|
+
return Buffer.concat([...localParts, centralBuf, eocd]);
|
|
40067
|
+
}
|
|
39697
40068
|
function normalizeTarget(raw) {
|
|
39698
40069
|
const key = raw.trim().toLowerCase();
|
|
39699
40070
|
if (key === "all")
|
|
@@ -39704,36 +40075,99 @@ function normalizeTarget(raw) {
|
|
|
39704
40075
|
return "claude-code";
|
|
39705
40076
|
if (key === "cursor")
|
|
39706
40077
|
return "cursor";
|
|
40078
|
+
if (key === "vscode" || key === "code" || key === "vs-code")
|
|
40079
|
+
return "vscode";
|
|
39707
40080
|
if (key === "antigravity" || key === "agy")
|
|
39708
40081
|
return "antigravity";
|
|
39709
40082
|
if (key === "codex" || key === "chatgpt")
|
|
39710
40083
|
return "codex";
|
|
39711
40084
|
return null;
|
|
39712
40085
|
}
|
|
40086
|
+
function isChineseTerminalLocale() {
|
|
40087
|
+
const explicit = (process.env.INKMAP_LOCALE || "").toLowerCase();
|
|
40088
|
+
if (explicit.startsWith("zh"))
|
|
40089
|
+
return true;
|
|
40090
|
+
if (explicit.startsWith("en"))
|
|
40091
|
+
return false;
|
|
40092
|
+
const envLang = (process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || "").toLowerCase();
|
|
40093
|
+
if (envLang.startsWith("zh"))
|
|
40094
|
+
return true;
|
|
40095
|
+
try {
|
|
40096
|
+
const loc = Intl.DateTimeFormat().resolvedOptions().locale || "";
|
|
40097
|
+
if (/^zh\b/i.test(loc))
|
|
40098
|
+
return true;
|
|
40099
|
+
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone || "";
|
|
40100
|
+
if (/^Asia\/(Shanghai|Chongqing|Harbin|Urumqi)$/i.test(tz))
|
|
40101
|
+
return true;
|
|
40102
|
+
} catch {
|
|
40103
|
+
}
|
|
40104
|
+
return false;
|
|
40105
|
+
}
|
|
39713
40106
|
function getInkmapHome() {
|
|
39714
|
-
return process.env.INKMAP_HOME || (0,
|
|
40107
|
+
return process.env.INKMAP_HOME || (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".inkmap");
|
|
39715
40108
|
}
|
|
39716
40109
|
function getClaudeDesktopDir() {
|
|
39717
40110
|
if (process.env.INKMAP_CLAUDE_CONFIG_DIR)
|
|
39718
40111
|
return process.env.INKMAP_CLAUDE_CONFIG_DIR;
|
|
39719
40112
|
if (process.platform === "darwin") {
|
|
39720
|
-
return (0,
|
|
40113
|
+
return (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Library", "Application Support", "Claude");
|
|
39721
40114
|
}
|
|
39722
40115
|
if (process.platform === "win32") {
|
|
39723
|
-
const appData = process.env.APPDATA || (0,
|
|
39724
|
-
return (0,
|
|
40116
|
+
const appData = process.env.APPDATA || (0, import_node_path5.join)((0, import_node_os5.homedir)(), "AppData", "Roaming");
|
|
40117
|
+
return (0, import_node_path5.join)(appData, "Claude");
|
|
39725
40118
|
}
|
|
39726
|
-
const xdg = process.env.XDG_CONFIG_HOME || (0,
|
|
39727
|
-
return (0,
|
|
40119
|
+
const xdg = process.env.XDG_CONFIG_HOME || (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".config");
|
|
40120
|
+
return (0, import_node_path5.join)(xdg, "Claude");
|
|
39728
40121
|
}
|
|
39729
40122
|
function getCursorDir() {
|
|
39730
|
-
return process.env.INKMAP_CURSOR_CONFIG_DIR || (0,
|
|
40123
|
+
return process.env.INKMAP_CURSOR_CONFIG_DIR || (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".cursor");
|
|
40124
|
+
}
|
|
40125
|
+
function getVscodeDir() {
|
|
40126
|
+
return process.env.INKMAP_VSCODE_CONFIG_DIR || (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".vscode");
|
|
39731
40127
|
}
|
|
39732
40128
|
function getClaudeCodeConfigPath() {
|
|
39733
|
-
return process.env.INKMAP_CLAUDE_CODE_CONFIG || (0,
|
|
40129
|
+
return process.env.INKMAP_CLAUDE_CODE_CONFIG || (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".claude.json");
|
|
39734
40130
|
}
|
|
39735
40131
|
function getAntigravityConfigDir() {
|
|
39736
|
-
return process.env.ANTIGRAVITY_CONFIG_DIR || (0,
|
|
40132
|
+
return process.env.ANTIGRAVITY_CONFIG_DIR || (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".gemini", "config");
|
|
40133
|
+
}
|
|
40134
|
+
function findCursorCommand() {
|
|
40135
|
+
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
40136
|
+
return null;
|
|
40137
|
+
if ((0, import_node_child_process2.spawnSync)("cursor", ["--version"], { stdio: "ignore" }).status === 0)
|
|
40138
|
+
return "cursor";
|
|
40139
|
+
if (process.platform === "darwin") {
|
|
40140
|
+
for (const dir of ["/Applications", (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
40141
|
+
const cmd = (0, import_node_path5.join)(dir, "Cursor.app/Contents/Resources/app/bin/cursor");
|
|
40142
|
+
if ((0, import_node_fs3.existsSync)(cmd))
|
|
40143
|
+
return cmd;
|
|
40144
|
+
}
|
|
40145
|
+
} else if (process.platform === "win32") {
|
|
40146
|
+
const localApp = process.env.LOCALAPPDATA || (0, import_node_path5.join)((0, import_node_os5.homedir)(), "AppData", "Local");
|
|
40147
|
+
const cmd = (0, import_node_path5.join)(localApp, "Programs", "cursor", "resources", "app", "bin", "cursor.cmd");
|
|
40148
|
+
if ((0, import_node_fs3.existsSync)(cmd))
|
|
40149
|
+
return cmd;
|
|
40150
|
+
}
|
|
40151
|
+
return null;
|
|
40152
|
+
}
|
|
40153
|
+
function findVscodeCommand() {
|
|
40154
|
+
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
40155
|
+
return null;
|
|
40156
|
+
if ((0, import_node_child_process2.spawnSync)("code", ["--version"], { stdio: "ignore" }).status === 0)
|
|
40157
|
+
return "code";
|
|
40158
|
+
if (process.platform === "darwin") {
|
|
40159
|
+
for (const dir of ["/Applications", (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
40160
|
+
const cmd = (0, import_node_path5.join)(dir, "Visual Studio Code.app/Contents/Resources/app/bin/code");
|
|
40161
|
+
if ((0, import_node_fs3.existsSync)(cmd))
|
|
40162
|
+
return cmd;
|
|
40163
|
+
}
|
|
40164
|
+
} else if (process.platform === "win32") {
|
|
40165
|
+
const localApp = process.env.LOCALAPPDATA || (0, import_node_path5.join)((0, import_node_os5.homedir)(), "AppData", "Local");
|
|
40166
|
+
const cmd = (0, import_node_path5.join)(localApp, "Programs", "Microsoft VS Code", "bin", "code.cmd");
|
|
40167
|
+
if ((0, import_node_fs3.existsSync)(cmd))
|
|
40168
|
+
return cmd;
|
|
40169
|
+
}
|
|
40170
|
+
return null;
|
|
39737
40171
|
}
|
|
39738
40172
|
function findCodexCommand() {
|
|
39739
40173
|
if (process.env.INKMAP_CODEX_BIN) {
|
|
@@ -39742,8 +40176,8 @@ function findCodexCommand() {
|
|
|
39742
40176
|
if ((0, import_node_child_process2.spawnSync)("codex", ["--version"], { stdio: "ignore" }).status === 0)
|
|
39743
40177
|
return "codex";
|
|
39744
40178
|
if (process.platform === "darwin") {
|
|
39745
|
-
for (const dir of ["/Applications", (0,
|
|
39746
|
-
const cmd = (0,
|
|
40179
|
+
for (const dir of ["/Applications", (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
40180
|
+
const cmd = (0, import_node_path5.join)(dir, "ChatGPT.app/Contents/Resources/codex-cli/bin/codex");
|
|
39747
40181
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
39748
40182
|
return cmd;
|
|
39749
40183
|
}
|
|
@@ -39753,18 +40187,18 @@ function findCodexCommand() {
|
|
|
39753
40187
|
function detectInstalledTargets() {
|
|
39754
40188
|
const found = [];
|
|
39755
40189
|
const claudeDir = getClaudeDesktopDir();
|
|
39756
|
-
if ((0, import_node_fs3.existsSync)(claudeDir) || process.platform === "darwin" && ((0, import_node_fs3.existsSync)("/Applications/Claude.app") || (0, import_node_fs3.existsSync)((0,
|
|
40190
|
+
if ((0, import_node_fs3.existsSync)(claudeDir) || process.platform === "darwin" && ((0, import_node_fs3.existsSync)("/Applications/Claude.app") || (0, import_node_fs3.existsSync)((0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications", "Claude.app")))) {
|
|
39757
40191
|
found.push("claude");
|
|
39758
40192
|
}
|
|
39759
40193
|
const claudeCodeCfg = getClaudeCodeConfigPath();
|
|
39760
40194
|
if ((0, import_node_fs3.existsSync)(claudeCodeCfg) || !process.env.INKMAP_ISOLATED_DETECT && (0, import_node_child_process2.spawnSync)("claude", ["--version"], { stdio: "ignore" }).status === 0) {
|
|
39761
40195
|
found.push("claude-code");
|
|
39762
40196
|
}
|
|
39763
|
-
if ((0, import_node_fs3.existsSync)(getCursorDir())) {
|
|
40197
|
+
if ((0, import_node_fs3.existsSync)(getCursorDir()) || Boolean(findCursorCommand())) {
|
|
39764
40198
|
found.push("cursor");
|
|
39765
40199
|
}
|
|
39766
40200
|
const agyDir = getAntigravityConfigDir();
|
|
39767
|
-
if ((0, import_node_fs3.existsSync)(agyDir) || !process.env.ANTIGRAVITY_CONFIG_DIR && (0, import_node_fs3.existsSync)((0,
|
|
40201
|
+
if ((0, import_node_fs3.existsSync)(agyDir) || !process.env.ANTIGRAVITY_CONFIG_DIR && (0, import_node_fs3.existsSync)((0, import_node_path5.join)((0, import_node_os5.homedir)(), ".gemini", "antigravity"))) {
|
|
39768
40202
|
found.push("antigravity");
|
|
39769
40203
|
}
|
|
39770
40204
|
if (!process.env.INKMAP_ISOLATED_DETECT && findCodexCommand()) {
|
|
@@ -39792,60 +40226,142 @@ function readJsonObject(filePath) {
|
|
|
39792
40226
|
return parsed;
|
|
39793
40227
|
}
|
|
39794
40228
|
function writeJsonAtomic(filePath, data) {
|
|
39795
|
-
(0, import_node_fs3.mkdirSync)((0,
|
|
40229
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path5.dirname)(filePath), { recursive: true });
|
|
39796
40230
|
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
39797
40231
|
(0, import_node_fs3.writeFileSync)(tmp, JSON.stringify(data, null, 2) + "\n", "utf8");
|
|
39798
40232
|
(0, import_node_fs3.renameSync)(tmp, filePath);
|
|
39799
40233
|
}
|
|
39800
40234
|
function stageStandaloneMcpApp() {
|
|
39801
|
-
const appDir = (0,
|
|
40235
|
+
const appDir = (0, import_node_path5.join)(getInkmapHome(), "mcp-app");
|
|
39802
40236
|
(0, import_node_fs3.mkdirSync)(appDir, { recursive: true });
|
|
39803
|
-
const bundledCli = (0,
|
|
39804
|
-
const bundledHtml = (0,
|
|
39805
|
-
const bundledWeb = (0,
|
|
39806
|
-
const monorepoAntigravity = (0,
|
|
40237
|
+
const bundledCli = (0, import_node_path5.join)(DIST_DIR, "cli.cjs");
|
|
40238
|
+
const bundledHtml = (0, import_node_path5.join)(DIST_DIR, "codex.html");
|
|
40239
|
+
const bundledWeb = (0, import_node_path5.join)(DIST_DIR, "web");
|
|
40240
|
+
const monorepoAntigravity = (0, import_node_path5.resolve)(PKG_ROOT, "..", "..", "dist", "sidebars", "inkmap-antigravity", "inkmap");
|
|
39807
40241
|
if ((0, import_node_fs3.existsSync)(bundledCli) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
39808
|
-
(0, import_node_fs3.cpSync)(bundledCli, (0,
|
|
39809
|
-
(0, import_node_fs3.cpSync)(bundledHtml, (0,
|
|
40242
|
+
(0, import_node_fs3.cpSync)(bundledCli, (0, import_node_path5.join)(appDir, "cli.cjs"));
|
|
40243
|
+
(0, import_node_fs3.cpSync)(bundledHtml, (0, import_node_path5.join)(appDir, "codex.html"));
|
|
39810
40244
|
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
39811
|
-
(0, import_node_fs3.rmSync)((0,
|
|
39812
|
-
(0, import_node_fs3.cpSync)(bundledWeb, (0,
|
|
40245
|
+
(0, import_node_fs3.rmSync)((0, import_node_path5.join)(appDir, "web"), { recursive: true, force: true });
|
|
40246
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path5.join)(appDir, "web"), { recursive: true });
|
|
39813
40247
|
}
|
|
39814
|
-
(0, import_node_fs3.writeFileSync)((0,
|
|
40248
|
+
(0, import_node_fs3.writeFileSync)((0, import_node_path5.join)(appDir, "server.cjs"), SERVER_WRAPPER, { mode: 493 });
|
|
39815
40249
|
for (const notice of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
39816
|
-
const src = (0,
|
|
40250
|
+
const src = (0, import_node_path5.join)(PKG_ROOT, notice);
|
|
39817
40251
|
if ((0, import_node_fs3.existsSync)(src))
|
|
39818
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
40252
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(appDir, notice));
|
|
39819
40253
|
}
|
|
39820
|
-
return { serverScript: (0,
|
|
40254
|
+
return { serverScript: (0, import_node_path5.join)(appDir, "server.cjs"), appDir };
|
|
39821
40255
|
}
|
|
39822
|
-
if ((0, import_node_fs3.existsSync)((0,
|
|
39823
|
-
(0, import_node_fs3.cpSync)((0,
|
|
39824
|
-
(0, import_node_fs3.cpSync)((0,
|
|
39825
|
-
const sidecarWeb = (0,
|
|
40256
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path5.join)(monorepoAntigravity, "server.cjs")) && (0, import_node_fs3.existsSync)((0, import_node_path5.join)(monorepoAntigravity, "codex.html"))) {
|
|
40257
|
+
(0, import_node_fs3.cpSync)((0, import_node_path5.join)(monorepoAntigravity, "server.cjs"), (0, import_node_path5.join)(appDir, "server.cjs"));
|
|
40258
|
+
(0, import_node_fs3.cpSync)((0, import_node_path5.join)(monorepoAntigravity, "codex.html"), (0, import_node_path5.join)(appDir, "codex.html"));
|
|
40259
|
+
const sidecarWeb = (0, import_node_path5.join)(monorepoAntigravity, "sidecars", "inkmap", "web");
|
|
39826
40260
|
if ((0, import_node_fs3.existsSync)(sidecarWeb)) {
|
|
39827
|
-
(0, import_node_fs3.rmSync)((0,
|
|
39828
|
-
(0, import_node_fs3.cpSync)(sidecarWeb, (0,
|
|
40261
|
+
(0, import_node_fs3.rmSync)((0, import_node_path5.join)(appDir, "web"), { recursive: true, force: true });
|
|
40262
|
+
(0, import_node_fs3.cpSync)(sidecarWeb, (0, import_node_path5.join)(appDir, "web"), { recursive: true });
|
|
39829
40263
|
}
|
|
39830
40264
|
for (const notice of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
39831
|
-
const src = (0,
|
|
40265
|
+
const src = (0, import_node_path5.join)(monorepoAntigravity, notice);
|
|
39832
40266
|
if ((0, import_node_fs3.existsSync)(src))
|
|
39833
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
40267
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(appDir, notice));
|
|
39834
40268
|
}
|
|
39835
|
-
return { serverScript: (0,
|
|
40269
|
+
return { serverScript: (0, import_node_path5.join)(appDir, "server.cjs"), appDir };
|
|
39836
40270
|
}
|
|
39837
|
-
const devBin = (0,
|
|
40271
|
+
const devBin = (0, import_node_path5.join)(PKG_ROOT, "bin", "inkmap.js");
|
|
39838
40272
|
if ((0, import_node_fs3.existsSync)(devBin) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
39839
40273
|
return { serverScript: devBin, appDir };
|
|
39840
40274
|
}
|
|
39841
40275
|
throw new Error("\u672A\u627E\u5230\u5DF2\u6784\u5EFA\u7684 MCP App \u8D44\u6E90\uFF08codex.html\uFF09\u3002/ Built MCP App assets are missing.");
|
|
39842
40276
|
}
|
|
40277
|
+
function installIdeExtension(editorDir, cliCmd) {
|
|
40278
|
+
const vscodeBundle = (0, import_node_path5.join)(DIST_DIR, "bundles", "vscode");
|
|
40279
|
+
const bundledWeb = (0, import_node_path5.join)(DIST_DIR, "web");
|
|
40280
|
+
if (!(0, import_node_fs3.existsSync)((0, import_node_path5.join)(vscodeBundle, "package.json")) || !(0, import_node_fs3.existsSync)((0, import_node_path5.join)(vscodeBundle, "dist", "extension.js"))) {
|
|
40281
|
+
return null;
|
|
40282
|
+
}
|
|
40283
|
+
const extPkg = JSON.parse((0, import_node_fs3.readFileSync)((0, import_node_path5.join)(vscodeBundle, "package.json"), "utf8"));
|
|
40284
|
+
const version2 = extPkg.version || "0.2.8";
|
|
40285
|
+
const staging = (0, import_node_fs3.mkdtempSync)((0, import_node_path5.join)((0, import_node_os5.tmpdir)(), "inkmap-vsix-"));
|
|
40286
|
+
try {
|
|
40287
|
+
const extStaging = (0, import_node_path5.join)(staging, "extension");
|
|
40288
|
+
(0, import_node_fs3.cpSync)(vscodeBundle, extStaging, { recursive: true });
|
|
40289
|
+
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
40290
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path5.join)(extStaging, "dist", "web"), { recursive: true });
|
|
40291
|
+
}
|
|
40292
|
+
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md", "README.md"]) {
|
|
40293
|
+
const src = (0, import_node_path5.join)(PKG_ROOT, doc);
|
|
40294
|
+
if ((0, import_node_fs3.existsSync)(src))
|
|
40295
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(extStaging, doc));
|
|
40296
|
+
}
|
|
40297
|
+
if (cliCmd) {
|
|
40298
|
+
const contentTypesXml = `<?xml version="1.0" encoding="utf-8"?>
|
|
40299
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension=".css" ContentType="text/css"/><Default Extension=".html" ContentType="text/html"/><Default Extension=".js" ContentType="application/javascript"/><Default Extension=".json" ContentType="application/json"/><Default Extension=".md" ContentType="text/markdown"/><Default Extension=".png" ContentType="image/png"/><Default Extension=".vsixmanifest" ContentType="text/xml"/></Types>`;
|
|
40300
|
+
const vsixManifest = `<?xml version="1.0" encoding="utf-8"?>
|
|
40301
|
+
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011"><Metadata><Identity Language="en-US" Id="inkmap-vscode" Version="${version2}" Publisher="inkmap" /><DisplayName>Inkmap \u2014 Markdown Mind Map</DisplayName><Description xml:space="preserve">Edit Markdown mind maps with two-way sync.</Description><Categories>Visualization,Education,Other</Categories><Properties><Property Id="Microsoft.VisualStudio.Code.Engine" Value="^1.90.0" /><Property Id="Microsoft.VisualStudio.Code.ExtensionKind" Value="ui,workspace" /><Property Id="Microsoft.VisualStudio.Code.ExecutesCode" Value="true" /></Properties><License>extension/LICENSE.md</License><Icon>extension/images/icon.png</Icon></Metadata><Installation><InstallationTarget Id="Microsoft.VisualStudio.Code"/></Installation><Dependencies/><Assets><Asset Type="Microsoft.VisualStudio.Code.Manifest" Path="extension/package.json" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.Details" Path="extension/README.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Content.License" Path="extension/LICENSE.md" Addressable="true" /><Asset Type="Microsoft.VisualStudio.Services.Icons.Default" Path="extension/images/icon.png" Addressable="true" /></Assets></PackageManifest>`;
|
|
40302
|
+
const entries = [
|
|
40303
|
+
{ name: "[Content_Types].xml", data: Buffer.from(contentTypesXml, "utf8") },
|
|
40304
|
+
{ name: "extension.vsixmanifest", data: Buffer.from(vsixManifest, "utf8") }
|
|
40305
|
+
];
|
|
40306
|
+
const walk = (dir, prefix) => {
|
|
40307
|
+
for (const item of (0, import_node_fs3.readdirSync)(dir, { withFileTypes: true })) {
|
|
40308
|
+
const full = (0, import_node_path5.join)(dir, item.name);
|
|
40309
|
+
const rel = `${prefix}/${item.name}`;
|
|
40310
|
+
if (item.isDirectory())
|
|
40311
|
+
walk(full, rel);
|
|
40312
|
+
else if (item.isFile())
|
|
40313
|
+
entries.push({ name: rel, data: (0, import_node_fs3.readFileSync)(full) });
|
|
40314
|
+
}
|
|
40315
|
+
};
|
|
40316
|
+
walk(extStaging, "extension");
|
|
40317
|
+
const vsixPath = (0, import_node_path5.join)(staging, `inkmap-${version2}.vsix`);
|
|
40318
|
+
(0, import_node_fs3.writeFileSync)(vsixPath, buildZipBuffer(entries));
|
|
40319
|
+
try {
|
|
40320
|
+
(0, import_node_child_process2.execFileSync)(cliCmd, ["--install-extension", vsixPath, "--force"], { stdio: "pipe" });
|
|
40321
|
+
return (0, import_node_path5.join)(editorDir, "extensions", `inkmap.inkmap-vscode-${version2}`);
|
|
40322
|
+
} catch {
|
|
40323
|
+
}
|
|
40324
|
+
}
|
|
40325
|
+
const extRoot = (0, import_node_path5.join)(editorDir, "extensions");
|
|
40326
|
+
(0, import_node_fs3.mkdirSync)(extRoot, { recursive: true });
|
|
40327
|
+
for (const old of (0, import_node_fs3.readdirSync)(extRoot)) {
|
|
40328
|
+
if (old.toLowerCase().startsWith("inkmap.inkmap-vscode")) {
|
|
40329
|
+
(0, import_node_fs3.rmSync)((0, import_node_path5.join)(extRoot, old), { recursive: true, force: true });
|
|
40330
|
+
}
|
|
40331
|
+
}
|
|
40332
|
+
const dest = (0, import_node_path5.join)(extRoot, `inkmap.inkmap-vscode-${version2}`);
|
|
40333
|
+
(0, import_node_fs3.cpSync)(extStaging, dest, { recursive: true });
|
|
40334
|
+
return dest;
|
|
40335
|
+
} finally {
|
|
40336
|
+
(0, import_node_fs3.rmSync)(staging, { recursive: true, force: true });
|
|
40337
|
+
}
|
|
40338
|
+
}
|
|
40339
|
+
function uninstallIdeExtension(editorDir, cliCmd) {
|
|
40340
|
+
let removed = false;
|
|
40341
|
+
if (cliCmd) {
|
|
40342
|
+
try {
|
|
40343
|
+
(0, import_node_child_process2.execFileSync)(cliCmd, ["--uninstall-extension", "inkmap.inkmap-vscode"], { stdio: "pipe" });
|
|
40344
|
+
removed = true;
|
|
40345
|
+
} catch {
|
|
40346
|
+
}
|
|
40347
|
+
}
|
|
40348
|
+
const extRoot = (0, import_node_path5.join)(editorDir, "extensions");
|
|
40349
|
+
if ((0, import_node_fs3.existsSync)(extRoot)) {
|
|
40350
|
+
for (const entry of (0, import_node_fs3.readdirSync)(extRoot)) {
|
|
40351
|
+
if (entry.toLowerCase().startsWith("inkmap.inkmap-vscode")) {
|
|
40352
|
+
(0, import_node_fs3.rmSync)((0, import_node_path5.join)(extRoot, entry), { recursive: true, force: true });
|
|
40353
|
+
removed = true;
|
|
40354
|
+
}
|
|
40355
|
+
}
|
|
40356
|
+
}
|
|
40357
|
+
return removed;
|
|
40358
|
+
}
|
|
39843
40359
|
function buildMcpEntry(serverScript, workspaces, existingEntry, withTypeStdio = false) {
|
|
39844
40360
|
const isDirectServer = serverScript.endsWith("server.cjs");
|
|
39845
40361
|
const args = isDirectServer ? [serverScript] : [serverScript, "mcp"];
|
|
39846
40362
|
const prevEnv = existingEntry && typeof existingEntry === "object" && !Array.isArray(existingEntry) && typeof existingEntry.env === "object" ? { ...existingEntry.env } : {};
|
|
39847
40363
|
if (workspaces.length > 0) {
|
|
39848
|
-
prevEnv.INKMAP_WORKSPACES = workspaces.map((w2) => (0,
|
|
40364
|
+
prevEnv.INKMAP_WORKSPACES = workspaces.map((w2) => (0, import_node_path5.resolve)(w2)).join(import_node_path5.delimiter);
|
|
39849
40365
|
}
|
|
39850
40366
|
const entry = {};
|
|
39851
40367
|
if (withTypeStdio)
|
|
@@ -39896,29 +40412,29 @@ async function refreshAntigravityMcp() {
|
|
|
39896
40412
|
}
|
|
39897
40413
|
}
|
|
39898
40414
|
async function installAntigravityPlugin() {
|
|
39899
|
-
const pluginsDir = (0,
|
|
39900
|
-
const destination = (0,
|
|
39901
|
-
const bundledAgy = (0,
|
|
39902
|
-
const bundledCli = (0,
|
|
39903
|
-
const bundledHtml = (0,
|
|
39904
|
-
const bundledWeb = (0,
|
|
39905
|
-
const monorepoAgy = (0,
|
|
40415
|
+
const pluginsDir = (0, import_node_path5.join)(getAntigravityConfigDir(), "plugins");
|
|
40416
|
+
const destination = (0, import_node_path5.join)(pluginsDir, "inkmap");
|
|
40417
|
+
const bundledAgy = (0, import_node_path5.join)(DIST_DIR, "bundles", "antigravity");
|
|
40418
|
+
const bundledCli = (0, import_node_path5.join)(DIST_DIR, "cli.cjs");
|
|
40419
|
+
const bundledHtml = (0, import_node_path5.join)(DIST_DIR, "codex.html");
|
|
40420
|
+
const bundledWeb = (0, import_node_path5.join)(DIST_DIR, "web");
|
|
40421
|
+
const monorepoAgy = (0, import_node_path5.resolve)(PKG_ROOT, "..", "..", "dist", "sidebars", "inkmap-antigravity", "inkmap");
|
|
39906
40422
|
(0, import_node_fs3.mkdirSync)(pluginsDir, { recursive: true });
|
|
39907
40423
|
(0, import_node_fs3.rmSync)(destination, { recursive: true, force: true });
|
|
39908
|
-
if ((0, import_node_fs3.existsSync)((0,
|
|
40424
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path5.join)(bundledAgy, "plugin.json")) && (0, import_node_fs3.existsSync)(bundledCli) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
39909
40425
|
(0, import_node_fs3.cpSync)(bundledAgy, destination, { recursive: true });
|
|
39910
|
-
(0, import_node_fs3.cpSync)(bundledCli, (0,
|
|
39911
|
-
(0, import_node_fs3.cpSync)(bundledHtml, (0,
|
|
39912
|
-
(0, import_node_fs3.writeFileSync)((0,
|
|
40426
|
+
(0, import_node_fs3.cpSync)(bundledCli, (0, import_node_path5.join)(destination, "cli.cjs"));
|
|
40427
|
+
(0, import_node_fs3.cpSync)(bundledHtml, (0, import_node_path5.join)(destination, "codex.html"));
|
|
40428
|
+
(0, import_node_fs3.writeFileSync)((0, import_node_path5.join)(destination, "server.cjs"), SERVER_WRAPPER, { mode: 493 });
|
|
39913
40429
|
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
39914
|
-
(0, import_node_fs3.cpSync)(bundledWeb, (0,
|
|
40430
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path5.join)(destination, "sidecars", "inkmap", "web"), { recursive: true });
|
|
39915
40431
|
}
|
|
39916
40432
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md", "README.md"]) {
|
|
39917
|
-
const src = (0,
|
|
40433
|
+
const src = (0, import_node_path5.join)(PKG_ROOT, doc);
|
|
39918
40434
|
if ((0, import_node_fs3.existsSync)(src))
|
|
39919
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
40435
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(destination, doc));
|
|
39920
40436
|
}
|
|
39921
|
-
} else if ((0, import_node_fs3.existsSync)((0,
|
|
40437
|
+
} else if ((0, import_node_fs3.existsSync)((0, import_node_path5.join)(monorepoAgy, "plugin.json"))) {
|
|
39922
40438
|
(0, import_node_fs3.cpSync)(monorepoAgy, destination, { recursive: true });
|
|
39923
40439
|
} else {
|
|
39924
40440
|
throw new Error("\u672A\u627E\u5230 Antigravity \u63D2\u4EF6\u8D44\u6E90 / Antigravity plugin bundle not found.");
|
|
@@ -39931,27 +40447,27 @@ function installCodexPlugin() {
|
|
|
39931
40447
|
if (!codex) {
|
|
39932
40448
|
throw new Error("\u672A\u68C0\u6D4B\u5230 codex \u547D\u4EE4\uFF0C\u8BF7\u5148\u5B89\u88C5 ChatGPT Desktop \u6216 Codex CLI / Codex CLI not found.");
|
|
39933
40449
|
}
|
|
39934
|
-
const bundledCodex = (0,
|
|
39935
|
-
const bundledCli = (0,
|
|
39936
|
-
const bundledHtml = (0,
|
|
39937
|
-
const monorepoCodexRoot = (0,
|
|
39938
|
-
const destination = (0,
|
|
40450
|
+
const bundledCodex = (0, import_node_path5.join)(DIST_DIR, "bundles", "codex");
|
|
40451
|
+
const bundledCli = (0, import_node_path5.join)(DIST_DIR, "cli.cjs");
|
|
40452
|
+
const bundledHtml = (0, import_node_path5.join)(DIST_DIR, "codex.html");
|
|
40453
|
+
const monorepoCodexRoot = (0, import_node_path5.resolve)(PKG_ROOT, "..", "..", "dist", "sidebars");
|
|
40454
|
+
const destination = (0, import_node_path5.join)(getInkmapHome(), "codex-marketplace");
|
|
39939
40455
|
(0, import_node_fs3.mkdirSync)(destination, { recursive: true });
|
|
39940
40456
|
const marketplaceRoot = (0, import_node_fs3.realpathSync)(destination);
|
|
39941
|
-
if ((0, import_node_fs3.existsSync)((0,
|
|
40457
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path5.join)(bundledCodex, ".agents")) && (0, import_node_fs3.existsSync)(bundledCli) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
39942
40458
|
(0, import_node_fs3.cpSync)(bundledCodex, marketplaceRoot, { recursive: true });
|
|
39943
|
-
const pluginDir = (0,
|
|
39944
|
-
(0, import_node_fs3.cpSync)(bundledCli, (0,
|
|
39945
|
-
(0, import_node_fs3.cpSync)(bundledHtml, (0,
|
|
39946
|
-
(0, import_node_fs3.writeFileSync)((0,
|
|
40459
|
+
const pluginDir = (0, import_node_path5.join)(marketplaceRoot, "inkmap-codex");
|
|
40460
|
+
(0, import_node_fs3.cpSync)(bundledCli, (0, import_node_path5.join)(pluginDir, "cli.cjs"));
|
|
40461
|
+
(0, import_node_fs3.cpSync)(bundledHtml, (0, import_node_path5.join)(pluginDir, "codex.html"));
|
|
40462
|
+
(0, import_node_fs3.writeFileSync)((0, import_node_path5.join)(pluginDir, "server.cjs"), SERVER_WRAPPER, { mode: 493 });
|
|
39947
40463
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
39948
|
-
const src = (0,
|
|
40464
|
+
const src = (0, import_node_path5.join)(PKG_ROOT, doc);
|
|
39949
40465
|
if ((0, import_node_fs3.existsSync)(src))
|
|
39950
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
40466
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(pluginDir, doc));
|
|
39951
40467
|
}
|
|
39952
|
-
} else if ((0, import_node_fs3.existsSync)((0,
|
|
39953
|
-
(0, import_node_fs3.cpSync)((0,
|
|
39954
|
-
(0, import_node_fs3.cpSync)((0,
|
|
40468
|
+
} else if ((0, import_node_fs3.existsSync)((0, import_node_path5.join)(monorepoCodexRoot, "inkmap-codex")) && (0, import_node_fs3.existsSync)((0, import_node_path5.join)(monorepoCodexRoot, ".agents"))) {
|
|
40469
|
+
(0, import_node_fs3.cpSync)((0, import_node_path5.join)(monorepoCodexRoot, ".agents"), (0, import_node_path5.join)(marketplaceRoot, ".agents"), { recursive: true });
|
|
40470
|
+
(0, import_node_fs3.cpSync)((0, import_node_path5.join)(monorepoCodexRoot, "inkmap-codex"), (0, import_node_path5.join)(marketplaceRoot, "inkmap-codex"), { recursive: true });
|
|
39955
40471
|
} else {
|
|
39956
40472
|
throw new Error("\u672A\u627E\u5230 Codex \u63D2\u4EF6\u8D44\u6E90 / Codex plugin bundle not found.");
|
|
39957
40473
|
}
|
|
@@ -39975,10 +40491,10 @@ async function runInstall(options = {}) {
|
|
|
39975
40491
|
const targets = explicitTargets ?? detectInstalledTargets();
|
|
39976
40492
|
const result = { installed: [], removed: [] };
|
|
39977
40493
|
if (options.uninstall) {
|
|
39978
|
-
const toRemove = explicitTargets ?? ["claude", "claude-code", "cursor", "antigravity", "codex"];
|
|
40494
|
+
const toRemove = explicitTargets ?? ["claude", "claude-code", "cursor", "vscode", "antigravity", "codex"];
|
|
39979
40495
|
for (const target of toRemove) {
|
|
39980
40496
|
if (target === "claude") {
|
|
39981
|
-
const cfg = (0,
|
|
40497
|
+
const cfg = (0, import_node_path5.join)(getClaudeDesktopDir(), "claude_desktop_config.json");
|
|
39982
40498
|
if (removeMcpJsonConfig(cfg))
|
|
39983
40499
|
result.removed.push({ target, location: cfg });
|
|
39984
40500
|
} else if (target === "claude-code") {
|
|
@@ -39986,18 +40502,24 @@ async function runInstall(options = {}) {
|
|
|
39986
40502
|
if (removeMcpJsonConfig(cfg))
|
|
39987
40503
|
result.removed.push({ target, location: cfg });
|
|
39988
40504
|
} else if (target === "cursor") {
|
|
39989
|
-
const cfg = (0,
|
|
39990
|
-
|
|
40505
|
+
const cfg = (0, import_node_path5.join)(getCursorDir(), "mcp.json");
|
|
40506
|
+
const removedMcp = removeMcpJsonConfig(cfg);
|
|
40507
|
+
const removedExt = uninstallIdeExtension(getCursorDir(), findCursorCommand());
|
|
40508
|
+
if (removedMcp || removedExt)
|
|
39991
40509
|
result.removed.push({ target, location: cfg });
|
|
40510
|
+
} else if (target === "vscode") {
|
|
40511
|
+
if (uninstallIdeExtension(getVscodeDir(), findVscodeCommand())) {
|
|
40512
|
+
result.removed.push({ target, location: (0, import_node_path5.join)(getVscodeDir(), "extensions") });
|
|
40513
|
+
}
|
|
39992
40514
|
} else if (target === "antigravity") {
|
|
39993
|
-
const dir = (0,
|
|
40515
|
+
const dir = (0, import_node_path5.join)(getAntigravityConfigDir(), "plugins", "inkmap");
|
|
39994
40516
|
if ((0, import_node_fs3.existsSync)(dir)) {
|
|
39995
40517
|
(0, import_node_fs3.rmSync)(dir, { recursive: true, force: true });
|
|
39996
40518
|
await refreshAntigravityMcp();
|
|
39997
40519
|
result.removed.push({ target, location: dir });
|
|
39998
40520
|
}
|
|
39999
40521
|
} else if (target === "codex") {
|
|
40000
|
-
const dir = (0,
|
|
40522
|
+
const dir = (0, import_node_path5.join)(getInkmapHome(), "codex-marketplace");
|
|
40001
40523
|
if ((0, import_node_fs3.existsSync)(dir)) {
|
|
40002
40524
|
(0, import_node_fs3.rmSync)(dir, { recursive: true, force: true });
|
|
40003
40525
|
result.removed.push({ target, location: dir });
|
|
@@ -40005,7 +40527,7 @@ async function runInstall(options = {}) {
|
|
|
40005
40527
|
}
|
|
40006
40528
|
}
|
|
40007
40529
|
if (!explicitTargets) {
|
|
40008
|
-
(0, import_node_fs3.rmSync)((0,
|
|
40530
|
+
(0, import_node_fs3.rmSync)((0, import_node_path5.join)(getInkmapHome(), "mcp-app"), { recursive: true, force: true });
|
|
40009
40531
|
}
|
|
40010
40532
|
if (result.removed.length === 0) {
|
|
40011
40533
|
log("[inkmap] \u672A\u53D1\u73B0\u5DF2\u5B89\u88C5\u7684 Inkmap \u5BA2\u6237\u7AEF\u914D\u7F6E / No installed Inkmap client configs found.");
|
|
@@ -40022,14 +40544,15 @@ async function runInstall(options = {}) {
|
|
|
40022
40544
|
log("[inkmap] \u672A\u5728\u9ED8\u8BA4\u76EE\u5F55\u68C0\u6D4B\u5230\u5DF2\u5B89\u88C5\u7684 AI \u5BA2\u6237\u7AEF\uFF0C\u53EF\u6307\u5B9A\u5BA2\u6237\u7AEF\u540D\u79F0\u5F3A\u5236\u751F\u6210\u914D\u7F6E\uFF1A");
|
|
40023
40545
|
log(" npx -y inkmap-mcp@latest install claude # Claude Desktop (macOS / Windows / Ubuntu)");
|
|
40024
40546
|
log(" npx -y inkmap-mcp@latest install claude-code # Claude Code CLI");
|
|
40025
|
-
log(" npx -y inkmap-mcp@latest install cursor # Cursor");
|
|
40547
|
+
log(" npx -y inkmap-mcp@latest install cursor # Cursor (MCP + \u53F3\u4FA7\u539F\u751F\u7F16\u8F91\u5668\u6807\u7B7E)");
|
|
40548
|
+
log(" npx -y inkmap-mcp@latest install vscode # VS Code (\u539F\u751F\u7F16\u8F91\u5668\u6269\u5C55)");
|
|
40026
40549
|
log(" npx -y inkmap-mcp@latest install antigravity # Google Antigravity");
|
|
40027
40550
|
log(" npx -y inkmap-mcp@latest install codex # OpenAI Codex Desktop");
|
|
40028
40551
|
return result;
|
|
40029
40552
|
}
|
|
40030
40553
|
for (const target of targets) {
|
|
40031
40554
|
if (target === "claude") {
|
|
40032
|
-
const cfg = (0,
|
|
40555
|
+
const cfg = (0, import_node_path5.join)(getClaudeDesktopDir(), "claude_desktop_config.json");
|
|
40033
40556
|
upsertMcpJsonConfig(cfg, serverScript, workspaces, false);
|
|
40034
40557
|
result.installed.push({
|
|
40035
40558
|
target,
|
|
@@ -40045,13 +40568,30 @@ async function runInstall(options = {}) {
|
|
|
40045
40568
|
note: "\u5728 Claude Code \u4E2D\u5DF2\u6CE8\u518C\u5168\u5C40 inkmap MCP \u670D\u52A1"
|
|
40046
40569
|
});
|
|
40047
40570
|
} else if (target === "cursor") {
|
|
40048
|
-
const cfg = (0,
|
|
40571
|
+
const cfg = (0, import_node_path5.join)(getCursorDir(), "mcp.json");
|
|
40049
40572
|
upsertMcpJsonConfig(cfg, serverScript, workspaces, false);
|
|
40573
|
+
const extLoc = installIdeExtension(getCursorDir(), findCursorCommand());
|
|
40574
|
+
const cursorServerDir = (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".cursor-server");
|
|
40575
|
+
if ((0, import_node_fs3.existsSync)(cursorServerDir)) {
|
|
40576
|
+
try {
|
|
40577
|
+
installIdeExtension(cursorServerDir, null);
|
|
40578
|
+
} catch {
|
|
40579
|
+
}
|
|
40580
|
+
}
|
|
40050
40581
|
result.installed.push({
|
|
40051
40582
|
target,
|
|
40052
|
-
location: cfg,
|
|
40053
|
-
note: "\
|
|
40583
|
+
location: extLoc ? `${cfg} + ${extLoc}` : cfg,
|
|
40584
|
+
note: "\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"
|
|
40054
40585
|
});
|
|
40586
|
+
} else if (target === "vscode") {
|
|
40587
|
+
const extLoc = installIdeExtension(getVscodeDir(), findVscodeCommand());
|
|
40588
|
+
if (extLoc) {
|
|
40589
|
+
result.installed.push({
|
|
40590
|
+
target,
|
|
40591
|
+
location: extLoc,
|
|
40592
|
+
note: "\u5DF2\u5728 VS Code \u5B89\u88C5\u539F\u751F Inkmap \u601D\u7EF4\u5BFC\u56FE\u7F16\u8F91\u5668\u6269\u5C55"
|
|
40593
|
+
});
|
|
40594
|
+
}
|
|
40055
40595
|
} else if (target === "antigravity") {
|
|
40056
40596
|
const loc = await installAntigravityPlugin();
|
|
40057
40597
|
result.installed.push({
|
|
@@ -40074,11 +40614,40 @@ async function runInstall(options = {}) {
|
|
|
40074
40614
|
}
|
|
40075
40615
|
}
|
|
40076
40616
|
}
|
|
40077
|
-
|
|
40078
|
-
|
|
40079
|
-
log(`
|
|
40080
|
-
|
|
40081
|
-
log(`
|
|
40617
|
+
const zhLocale = isChineseTerminalLocale();
|
|
40618
|
+
if (zhLocale) {
|
|
40619
|
+
log(`[inkmap] \u5B89\u88C5\u5B8C\u6210\uFF08Node: ${process.execPath}\uFF09\uFF1A`);
|
|
40620
|
+
for (const item of result.installed) {
|
|
40621
|
+
log(` \u2713 ${item.target.padEnd(12)} -> ${item.location}`);
|
|
40622
|
+
if (item.note)
|
|
40623
|
+
log(` ${item.note}`);
|
|
40624
|
+
}
|
|
40625
|
+
log("");
|
|
40626
|
+
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");
|
|
40627
|
+
log("\u{1F381} 7 \u5929\u514D\u8D39\u8BD5\u7528\u4E0E Inkmap Pro \u7EC8\u8EAB\u4F1A\u5458\u5F00\u901A\uFF1A");
|
|
40628
|
+
log(" \u2022 \u9996\u6B21\u4F7F\u7528\u4EAB 7 \u5929\u5168\u529F\u80FD\u514D\u8D39\u8BD5\u7528\uFF08\u65E0\u9700\u767B\u5F55\uFF09");
|
|
40629
|
+
log(" \u2022 \u5F00\u901A Pro \u7EC8\u8EAB\u7248\uFF08\xA529.90 \u5FAE\u4FE1\u652F\u4ED8\u4E00\u6B21\u4E70\u65AD\uFF0C\u514D\u8D39\u5305\u542B\u540E\u7EED\u5168\u90E8\u66F4\u65B0\uFF09\uFF1A");
|
|
40630
|
+
log(" \u{1F449} \u5B98\u65B9\u7F51\u7AD9\u5F00\u901A: https://zhiyuanv.com/software.html#inkmap-pricing");
|
|
40631
|
+
log(" \u{1F449} \u6216\u7EC8\u7AEF\u72EC\u7ACB\u6253\u5F00: npx -y inkmap-mcp@latest \u4F60\u7684\u6587\u6863.md \uFF08\u53F3\u4E0A\u89D2\u70B9\u51FB\u300C\u8D2D\u4E70 Pro\u300D\uFF09");
|
|
40632
|
+
log(" \u2022 \u8DE8\u7AEF\u540C\u6B65\uFF1A\u5728\u5B98\u7F51\u8D2D\u4E70\u540E\uFF0C\u5728\u4EFB\u610F\u5BA2\u6237\u7AEF\uFF08Cursor / Claude / Codex / Antigravity / VS Code\uFF09");
|
|
40633
|
+
log(" \u5BFC\u56FE\u53F3\u4E0A\u89D2\u70B9\u51FB\u300C\u767B\u5F55\u300D\u8F93\u5165\u540C\u4E00\u90AE\u7BB1\u9A8C\u8BC1\uFF0CPro \u7EC8\u8EAB\u6743\u76CA\u5373\u523B\u81EA\u52A8\u540C\u6B65\u6FC0\u6D3B\uFF01");
|
|
40634
|
+
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");
|
|
40635
|
+
} else {
|
|
40636
|
+
log(`[inkmap] Installation complete (Node: ${process.execPath}):`);
|
|
40637
|
+
for (const item of result.installed) {
|
|
40638
|
+
log(` \u2713 ${item.target.padEnd(12)} -> ${item.location}`);
|
|
40639
|
+
}
|
|
40640
|
+
log("");
|
|
40641
|
+
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");
|
|
40642
|
+
log("\u{1F381} 7-Day Free Trial & Inkmap Pro Lifetime License:");
|
|
40643
|
+
log(" \u2022 Enjoy a 7-day full-featured free trial from first use (no sign-in required)");
|
|
40644
|
+
log(" \u2022 Upgrade to Inkmap Pro Lifetime (US$15.00 one-time purchase, all future updates included):");
|
|
40645
|
+
log(" \u{1F449} Official Website: https://zhiyuanv.com/software.html?lang=en#inkmap-pricing");
|
|
40646
|
+
log(" \u{1F449} Or run standalone in browser: npx -y inkmap-mcp@latest notes.md (click 'Buy Pro')");
|
|
40647
|
+
log(" \u2022 Cross-Client Sync: After purchasing on the website, click 'Sign in' in the top-right");
|
|
40648
|
+
log(" corner inside Claude, Codex, Cursor, Antigravity, or VS Code with the same email");
|
|
40649
|
+
log(" account to sync your Lifetime Pro access automatically!");
|
|
40650
|
+
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");
|
|
40082
40651
|
}
|
|
40083
40652
|
return result;
|
|
40084
40653
|
}
|
|
@@ -40097,7 +40666,8 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
40097
40666
|
(\u9ED8\u8BA4\u7701\u7565) \u81EA\u52A8\u68C0\u6D4B\u672C\u673A\u5DF2\u5B89\u88C5\u7684\u5BA2\u6237\u7AEF\u5E76\u4E00\u952E\u914D\u7F6E / Auto-detect installed clients
|
|
40098
40667
|
claude Claude Desktop (Ubuntu / macOS / Windows)
|
|
40099
40668
|
claude-code Claude Code CLI (~/.claude.json)
|
|
40100
|
-
cursor Cursor (
|
|
40669
|
+
cursor Cursor (MCP + \u53F3\u4FA7\u4E3B\u7F16\u8F91\u533A\u539F\u751F\u5BFC\u56FE\u6269\u5C55)
|
|
40670
|
+
vscode VS Code (\u539F\u751F\u5BFC\u56FE\u7F16\u8F91\u5668\u6269\u5C55)
|
|
40101
40671
|
antigravity Google Antigravity (~/.gemini/config/plugins/inkmap)
|
|
40102
40672
|
codex OpenAI Codex Desktop
|
|
40103
40673
|
|
|
@@ -40109,17 +40679,17 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
40109
40679
|
const val = argv[++i];
|
|
40110
40680
|
if (!val)
|
|
40111
40681
|
throw new Error("--workspace \u9700\u8981\u63D0\u4F9B\u76EE\u5F55\u8DEF\u5F84 / --workspace requires a directory path");
|
|
40112
|
-
workspaces.push(...val.split(
|
|
40682
|
+
workspaces.push(...val.split(import_node_path5.delimiter).filter(Boolean));
|
|
40113
40683
|
continue;
|
|
40114
40684
|
}
|
|
40115
40685
|
if (arg.startsWith("--workspace=")) {
|
|
40116
40686
|
const val = arg.slice("--workspace=".length);
|
|
40117
|
-
workspaces.push(...val.split(
|
|
40687
|
+
workspaces.push(...val.split(import_node_path5.delimiter).filter(Boolean));
|
|
40118
40688
|
continue;
|
|
40119
40689
|
}
|
|
40120
40690
|
const normalized = normalizeTarget(arg);
|
|
40121
40691
|
if (!normalized) {
|
|
40122
|
-
throw new Error(`\u672A\u77E5\u5BA2\u6237\u7AEF\u76EE\u6807: ${arg}\uFF08\u652F\u6301: claude, claude-code, cursor, antigravity, codex, all\uFF09`);
|
|
40692
|
+
throw new Error(`\u672A\u77E5\u5BA2\u6237\u7AEF\u76EE\u6807: ${arg}\uFF08\u652F\u6301: claude, claude-code, cursor, vscode, antigravity, codex, all\uFF09`);
|
|
40123
40693
|
}
|
|
40124
40694
|
if (normalized === "all") {
|
|
40125
40695
|
explicitAll = true;
|
|
@@ -40133,17 +40703,18 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
40133
40703
|
uninstall
|
|
40134
40704
|
});
|
|
40135
40705
|
}
|
|
40136
|
-
var import_node_child_process2, import_node_fs3,
|
|
40706
|
+
var import_node_child_process2, import_node_fs3, import_node_os5, import_node_path5, import_node_url3, import_node_zlib, DIST_DIR, PKG_ROOT, SERVER_WRAPPER, CRC_TABLE;
|
|
40137
40707
|
var init_install = __esm({
|
|
40138
40708
|
"packages/cli/dist/install.js"() {
|
|
40139
40709
|
"use strict";
|
|
40140
40710
|
import_node_child_process2 = require("node:child_process");
|
|
40141
40711
|
import_node_fs3 = require("node:fs");
|
|
40142
|
-
|
|
40143
|
-
|
|
40712
|
+
import_node_os5 = require("node:os");
|
|
40713
|
+
import_node_path5 = require("node:path");
|
|
40144
40714
|
import_node_url3 = require("node:url");
|
|
40145
|
-
|
|
40146
|
-
|
|
40715
|
+
import_node_zlib = require("node:zlib");
|
|
40716
|
+
DIST_DIR = (0, import_node_path5.dirname)((0, import_node_url3.fileURLToPath)(inkmapModuleUrl));
|
|
40717
|
+
PKG_ROOT = (0, import_node_path5.resolve)(DIST_DIR, "..");
|
|
40147
40718
|
SERVER_WRAPPER = `#!/usr/bin/env node
|
|
40148
40719
|
"use strict";
|
|
40149
40720
|
require("./cli.cjs").main(["mcp", ...process.argv.slice(2)]).catch(err => {
|
|
@@ -40151,6 +40722,16 @@ require("./cli.cjs").main(["mcp", ...process.argv.slice(2)]).catch(err => {
|
|
|
40151
40722
|
process.exit(1);
|
|
40152
40723
|
});
|
|
40153
40724
|
`;
|
|
40725
|
+
CRC_TABLE = (() => {
|
|
40726
|
+
const table = new Uint32Array(256);
|
|
40727
|
+
for (let i = 0; i < 256; i++) {
|
|
40728
|
+
let c = i;
|
|
40729
|
+
for (let k2 = 0; k2 < 8; k2++)
|
|
40730
|
+
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
|
|
40731
|
+
table[i] = c >>> 0;
|
|
40732
|
+
}
|
|
40733
|
+
return table;
|
|
40734
|
+
})();
|
|
40154
40735
|
}
|
|
40155
40736
|
});
|
|
40156
40737
|
|
|
@@ -40162,12 +40743,12 @@ __export(index_exports, {
|
|
|
40162
40743
|
});
|
|
40163
40744
|
module.exports = __toCommonJS(index_exports);
|
|
40164
40745
|
var import_node_child_process3 = require("node:child_process");
|
|
40165
|
-
var
|
|
40746
|
+
var import_node_path6 = require("node:path");
|
|
40166
40747
|
var import_node_url4 = require("node:url");
|
|
40167
40748
|
init_dist();
|
|
40168
40749
|
init_license();
|
|
40169
40750
|
init_server();
|
|
40170
|
-
var INKMAP_VERSION = "0.2.
|
|
40751
|
+
var INKMAP_VERSION = "0.2.8";
|
|
40171
40752
|
var WEB_ROOT2 = (0, import_node_url4.fileURLToPath)(new URL("./web/", inkmapModuleUrl));
|
|
40172
40753
|
var USAGE = `Inkmap v${INKMAP_VERSION} \u2014 Markdown \u4EA4\u4E92\u601D\u7EF4\u5BFC\u56FE\u7F16\u8F91\u5668 & MCP App
|
|
40173
40754
|
|
|
@@ -40187,9 +40768,9 @@ function openBrowser(url2) {
|
|
|
40187
40768
|
function appendEnvWorkspaces(dirs) {
|
|
40188
40769
|
if (dirs.length === 0)
|
|
40189
40770
|
return;
|
|
40190
|
-
const resolved = dirs.map((d2) => (0,
|
|
40191
|
-
const current = (process.env.INKMAP_WORKSPACES || "").split(
|
|
40192
|
-
process.env.INKMAP_WORKSPACES = [.../* @__PURE__ */ new Set([...current, ...resolved])].join(
|
|
40771
|
+
const resolved = dirs.map((d2) => (0, import_node_path6.resolve)(d2));
|
|
40772
|
+
const current = (process.env.INKMAP_WORKSPACES || "").split(import_node_path6.delimiter).filter(Boolean);
|
|
40773
|
+
process.env.INKMAP_WORKSPACES = [.../* @__PURE__ */ new Set([...current, ...resolved])].join(import_node_path6.delimiter);
|
|
40193
40774
|
}
|
|
40194
40775
|
async function main(argv) {
|
|
40195
40776
|
if (argv.length === 0 && !process.stdin.isTTY) {
|
|
@@ -40216,9 +40797,9 @@ async function main(argv) {
|
|
|
40216
40797
|
const val = argv[++i];
|
|
40217
40798
|
if (!val)
|
|
40218
40799
|
throw new Error("--workspace \u9700\u8981\u76EE\u5F55\u8DEF\u5F84");
|
|
40219
|
-
extraWorkspaces.push(...val.split(
|
|
40800
|
+
extraWorkspaces.push(...val.split(import_node_path6.delimiter).filter(Boolean));
|
|
40220
40801
|
} else if (arg.startsWith("--workspace=")) {
|
|
40221
|
-
extraWorkspaces.push(...arg.slice("--workspace=".length).split(
|
|
40802
|
+
extraWorkspaces.push(...arg.slice("--workspace=".length).split(import_node_path6.delimiter).filter(Boolean));
|
|
40222
40803
|
} else if (arg === "-h" || arg === "--help") {
|
|
40223
40804
|
console.log(USAGE);
|
|
40224
40805
|
return;
|