inkmap-mcp 0.2.5 → 0.2.8
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 +863 -200
- 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) {
|
|
@@ -38853,7 +39063,11 @@ function K3(Z, $, J, X) {
|
|
|
38853
39063
|
function N3(Z, $, J, X, V) {
|
|
38854
39064
|
return Z.registerResource($, J, { mimeType: p, ...X }, V);
|
|
38855
39065
|
}
|
|
38856
|
-
|
|
39066
|
+
function Y3(Z) {
|
|
39067
|
+
if (!Z) return;
|
|
39068
|
+
return Z.extensions?.[TQ];
|
|
39069
|
+
}
|
|
39070
|
+
var r, v, K, QQ, ZQ, $Q, I, P, w, JQ, Y, j, XQ, H, _, A, f, u, E, VQ, O, DQ, d, h, LQ, WQ, BQ, R, m, GQ, dQ, KQ, NQ, YQ, U, T, k, jQ, FQ, M, C, p, TQ;
|
|
38857
39071
|
var init_server4 = __esm({
|
|
38858
39072
|
"node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.js"() {
|
|
38859
39073
|
init_protocol();
|
|
@@ -38945,6 +39159,7 @@ container holding the app. Specify either width or maxWidth, and either height o
|
|
|
38945
39159
|
M = external_exports.object({ protocolVersion: external_exports.string().describe('Negotiated protocol version string (e.g., "2025-11-21").'), hostInfo: ImplementationSchema.describe("Host application identification and version."), hostCapabilities: d.describe("Features and capabilities provided by the host."), hostContext: T.describe("Rich context about the host environment.") }).passthrough();
|
|
38946
39160
|
C = "ui/resourceUri";
|
|
38947
39161
|
p = "text/html;profile=mcp-app";
|
|
39162
|
+
TQ = "io.modelcontextprotocol/ui";
|
|
38948
39163
|
}
|
|
38949
39164
|
});
|
|
38950
39165
|
|
|
@@ -39004,7 +39219,7 @@ async function findGitRoot(filePath) {
|
|
|
39004
39219
|
}
|
|
39005
39220
|
return (0, import_node_path3.dirname)(filePath);
|
|
39006
39221
|
}
|
|
39007
|
-
async function writeTargetSelection(filePath, workspaceDir) {
|
|
39222
|
+
async function writeTargetSelection(filePath, workspaceDir, extra) {
|
|
39008
39223
|
const real = await (0, import_promises3.realpath)(filePath);
|
|
39009
39224
|
const info = await (0, import_promises3.lstat)(real);
|
|
39010
39225
|
if (!info.isFile() || info.size > MAX_BYTES || !/\.md$/i.test(real)) {
|
|
@@ -39017,7 +39232,8 @@ async function writeTargetSelection(filePath, workspaceDir) {
|
|
|
39017
39232
|
file: real,
|
|
39018
39233
|
workspace,
|
|
39019
39234
|
seq: Date.now(),
|
|
39020
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
39235
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
39236
|
+
...extra?.openInEditorPane && { openInEditorPane: true }
|
|
39021
39237
|
};
|
|
39022
39238
|
const tmp = `${statePath}.${process.pid}.${Date.now()}`;
|
|
39023
39239
|
try {
|
|
@@ -39276,7 +39492,9 @@ function createMcpWorkspaceManager() {
|
|
|
39276
39492
|
if (options.path?.trim()) {
|
|
39277
39493
|
explicitFile = await assertAllowedFile(options.path, extraUris, Boolean(options.fromModel));
|
|
39278
39494
|
if (options.fromModel) {
|
|
39279
|
-
const saved = await writeTargetSelection(explicitFile, options.workspace
|
|
39495
|
+
const saved = await writeTargetSelection(explicitFile, options.workspace, {
|
|
39496
|
+
openInEditorPane: options.openInEditorPane
|
|
39497
|
+
});
|
|
39280
39498
|
internalSeq = Math.max(internalSeq, saved.seq);
|
|
39281
39499
|
} else {
|
|
39282
39500
|
internalSeq = Math.max(internalSeq + 1, Date.now());
|
|
@@ -39292,6 +39510,10 @@ function createMcpWorkspaceManager() {
|
|
|
39292
39510
|
const activeGroup = files.filter((f2) => f2.group === "active");
|
|
39293
39511
|
chosen = (activeGroup[0] || files[0])?.path || null;
|
|
39294
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
|
+
}
|
|
39295
39517
|
if (!chosen) {
|
|
39296
39518
|
return {
|
|
39297
39519
|
files,
|
|
@@ -39430,21 +39652,120 @@ __export(codex_exports, {
|
|
|
39430
39652
|
createInkmapMcpServer: () => createInkmapMcpServer,
|
|
39431
39653
|
serveCodex: () => serveCodex
|
|
39432
39654
|
});
|
|
39655
|
+
function openSystemBrowser(url2) {
|
|
39656
|
+
if (process.env.INKMAP_NO_OPEN === "1")
|
|
39657
|
+
return;
|
|
39658
|
+
const [cmd, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
39659
|
+
(0, import_node_child_process.spawn)(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
39660
|
+
}
|
|
39433
39661
|
async function createInkmapMcpServer(options = {}) {
|
|
39434
|
-
const
|
|
39662
|
+
const loadHtml = async () => options.html ?? await (0, import_promises4.readFile)(HTML, "utf8").catch((error62) => {
|
|
39435
39663
|
if (error62.code === "ENOENT") {
|
|
39436
39664
|
throw new Error("MCP App editor assets are missing. Run npm run build:sidebars.");
|
|
39437
39665
|
}
|
|
39438
39666
|
throw error62;
|
|
39439
39667
|
});
|
|
39668
|
+
await loadHtml();
|
|
39440
39669
|
const billingOrigin2 = options.billingOrigin ?? (() => process.env.INKMAP_BILLING_ORIGIN || YUNFAN_BILLING_ORIGIN);
|
|
39441
39670
|
const billing = licenseService(fileSessionStorage(), billingOrigin2, { loginOnly: true });
|
|
39671
|
+
let browserBilling;
|
|
39672
|
+
const fallbackEditors = /* @__PURE__ */ new Map();
|
|
39673
|
+
const ads = adFeed(PRODUCT.adFeedUrl);
|
|
39442
39674
|
const workspaces = createMcpWorkspaceManager();
|
|
39443
|
-
const server = new McpServer({ name: "inkmap", version: "0.2.
|
|
39675
|
+
const server = new McpServer({ name: "inkmap", version: "0.2.8" });
|
|
39676
|
+
function isAntigravityHost() {
|
|
39677
|
+
const clientName = server.server.getClientVersion()?.name ?? "";
|
|
39678
|
+
if (/antigravity/i.test(clientName))
|
|
39679
|
+
return true;
|
|
39680
|
+
if (/[/\\]plugins[/\\]inkmap[/\\]/.test(process.argv[1] ?? ""))
|
|
39681
|
+
return true;
|
|
39682
|
+
return false;
|
|
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
|
+
}
|
|
39704
|
+
function hostSupportsEmbeddedUi() {
|
|
39705
|
+
if (Y3(server.server.getClientCapabilities()))
|
|
39706
|
+
return true;
|
|
39707
|
+
if (isAntigravityHost())
|
|
39708
|
+
return true;
|
|
39709
|
+
return false;
|
|
39710
|
+
}
|
|
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) {
|
|
39730
|
+
if (!(0, import_node_fs2.existsSync)(WEB_ROOT))
|
|
39731
|
+
return void 0;
|
|
39732
|
+
let pending = fallbackEditors.get("__workspace__");
|
|
39733
|
+
if (!pending) {
|
|
39734
|
+
pending = (async () => {
|
|
39735
|
+
const source = await fileSource(filePath);
|
|
39736
|
+
return serve({
|
|
39737
|
+
source,
|
|
39738
|
+
webRoot: WEB_ROOT,
|
|
39739
|
+
port: 0,
|
|
39740
|
+
license: billing,
|
|
39741
|
+
ads: async () => [],
|
|
39742
|
+
sidebar: false,
|
|
39743
|
+
loginOnly: true,
|
|
39744
|
+
ideWorkspace: true
|
|
39745
|
+
});
|
|
39746
|
+
})();
|
|
39747
|
+
fallbackEditors.set("__workspace__", pending);
|
|
39748
|
+
pending.catch(() => fallbackEditors.delete("__workspace__"));
|
|
39749
|
+
}
|
|
39750
|
+
const served = await pending;
|
|
39751
|
+
await served.switchToFile?.(filePath).catch(() => {
|
|
39752
|
+
});
|
|
39753
|
+
if (launchSystemBrowser) {
|
|
39754
|
+
openSystemBrowser(served.url);
|
|
39755
|
+
}
|
|
39756
|
+
return served.url;
|
|
39757
|
+
}
|
|
39758
|
+
async function disposeAll() {
|
|
39759
|
+
billing.dispose();
|
|
39760
|
+
browserBilling?.dispose();
|
|
39761
|
+
const editors = [...fallbackEditors.values()];
|
|
39762
|
+
fallbackEditors.clear();
|
|
39763
|
+
await Promise.allSettled(editors.map(async (p2) => (await p2).close()));
|
|
39764
|
+
}
|
|
39444
39765
|
N3(server, "Inkmap Markdown editor", UI, {
|
|
39445
39766
|
_meta: { ui: { prefersBorder: false } }
|
|
39446
39767
|
}, async () => ({
|
|
39447
|
-
contents: [{ uri: UI, mimeType: p, text:
|
|
39768
|
+
contents: [{ uri: UI, mimeType: p, text: await loadHtml() }]
|
|
39448
39769
|
}));
|
|
39449
39770
|
K3(server, "inkmap_open_markdown", {
|
|
39450
39771
|
title: "Inkmap Mind Map",
|
|
@@ -39458,7 +39779,7 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39458
39779
|
}, async () => ({ content: [] }));
|
|
39459
39780
|
K3(server, "inkmap_open", {
|
|
39460
39781
|
title: "Inkmap",
|
|
39461
|
-
description: "Open and edit a local Markdown (.md, .markmap.md) outline as an interactive Inkmap mind map
|
|
39782
|
+
description: "Open and edit a local Markdown (.md, .markmap.md) outline as an interactive Inkmap mind map.",
|
|
39462
39783
|
inputSchema: {
|
|
39463
39784
|
path: external_exports.string().optional().describe("Absolute or workspace-relative path to a .md or .markmap.md file. Omit to open the active or most recent Markdown outline."),
|
|
39464
39785
|
workspace: external_exports.string().optional().describe("Optional workspace root directory path.")
|
|
@@ -39474,12 +39795,23 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39474
39795
|
}
|
|
39475
39796
|
}
|
|
39476
39797
|
}, async ({ path, workspace }) => {
|
|
39798
|
+
const cursorHost = isCursorHost();
|
|
39799
|
+
const openInRightEditor = hasIdeEditorExtension() || cursorHost;
|
|
39477
39800
|
const [opened, license] = await Promise.all([
|
|
39478
|
-
workspaces.open({ path, workspace, fromModel: true }),
|
|
39801
|
+
workspaces.open({ path, workspace, fromModel: true, openInEditorPane: openInRightEditor }),
|
|
39479
39802
|
billing.state()
|
|
39480
39803
|
]);
|
|
39804
|
+
let ackedByExtension = false;
|
|
39805
|
+
if (openInRightEditor && opened.currentFile && opened.targetSeq) {
|
|
39806
|
+
ackedByExtension = await waitForEditorBridgeAck(opened.targetSeq, 260);
|
|
39807
|
+
}
|
|
39808
|
+
let editorUrl;
|
|
39809
|
+
if (opened.currentFile && (cursorHost || !openInRightEditor && !hostSupportsEmbeddedUi())) {
|
|
39810
|
+
const shouldLaunchSystemBrowser = !cursorHost && !openInRightEditor && !hostSupportsEmbeddedUi();
|
|
39811
|
+
editorUrl = await openFallbackBrowserEditor(opened.currentFile, shouldLaunchSystemBrowser).catch(() => void 0);
|
|
39812
|
+
}
|
|
39481
39813
|
const includeDoc = Buffer.byteLength(opened.doc.md, "utf8") <= INLINE_DOC_LIMIT;
|
|
39482
|
-
const summary = 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.";
|
|
39483
39815
|
return {
|
|
39484
39816
|
content: [{ type: "text", text: summary }],
|
|
39485
39817
|
structuredContent: {
|
|
@@ -39489,6 +39821,8 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39489
39821
|
currentFileUri: opened.currentFileUri,
|
|
39490
39822
|
targetSeq: opened.targetSeq,
|
|
39491
39823
|
license: { ...license },
|
|
39824
|
+
...openInRightEditor && { openedInEditorPane: true },
|
|
39825
|
+
...editorUrl && { editorUrl },
|
|
39492
39826
|
...includeDoc && { doc: opened.doc }
|
|
39493
39827
|
}
|
|
39494
39828
|
};
|
|
@@ -39559,6 +39893,39 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39559
39893
|
const saved = await workspaces.saveView({ file: file2, state });
|
|
39560
39894
|
return { content: [], structuredContent: { ...saved } };
|
|
39561
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
|
+
});
|
|
39562
39929
|
server.registerTool("inkmap_access", {
|
|
39563
39930
|
title: "Check Inkmap access",
|
|
39564
39931
|
annotations: { readOnlyHint: true },
|
|
@@ -39589,28 +39956,37 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39589
39956
|
await billing.deactivate();
|
|
39590
39957
|
return { content: [] };
|
|
39591
39958
|
});
|
|
39592
|
-
return { server, billing, workspaces };
|
|
39959
|
+
return { server, billing, workspaces, dispose: disposeAll };
|
|
39593
39960
|
}
|
|
39594
39961
|
async function serveCodex() {
|
|
39595
|
-
const { server,
|
|
39962
|
+
const { server, dispose } = await createInkmapMcpServer();
|
|
39596
39963
|
const transport = new StdioServerTransport();
|
|
39597
|
-
server.server.onclose = () =>
|
|
39964
|
+
server.server.onclose = () => {
|
|
39965
|
+
void dispose();
|
|
39966
|
+
};
|
|
39598
39967
|
await server.connect(transport);
|
|
39599
39968
|
}
|
|
39600
|
-
var import_promises4, UI, HTML, 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;
|
|
39601
39970
|
var init_codex = __esm({
|
|
39602
39971
|
"packages/cli/dist/codex.js"() {
|
|
39603
39972
|
"use strict";
|
|
39604
39973
|
init_mcp();
|
|
39605
39974
|
init_stdio2();
|
|
39606
39975
|
init_server4();
|
|
39976
|
+
import_node_child_process = require("node:child_process");
|
|
39977
|
+
import_node_fs2 = require("node:fs");
|
|
39607
39978
|
import_promises4 = require("node:fs/promises");
|
|
39979
|
+
import_node_os4 = require("node:os");
|
|
39980
|
+
import_node_path4 = require("node:path");
|
|
39981
|
+
import_node_url2 = require("node:url");
|
|
39608
39982
|
init_zod();
|
|
39609
39983
|
init_dist();
|
|
39610
39984
|
init_license();
|
|
39611
39985
|
init_mcp_files();
|
|
39986
|
+
init_server();
|
|
39612
39987
|
UI = "ui://inkmap/markdown.html";
|
|
39613
39988
|
HTML = new URL("./codex.html", inkmapModuleUrl);
|
|
39989
|
+
WEB_ROOT = (0, import_node_url2.fileURLToPath)(new URL("./web/", inkmapModuleUrl));
|
|
39614
39990
|
INLINE_DOC_LIMIT = 256 * 1024;
|
|
39615
39991
|
appOnly = { ui: { visibility: ["app"] } };
|
|
39616
39992
|
}
|
|
@@ -39622,6 +39998,73 @@ __export(install_exports, {
|
|
|
39622
39998
|
runInstall: () => runInstall,
|
|
39623
39999
|
runInstallCli: () => runInstallCli
|
|
39624
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
|
+
}
|
|
39625
40068
|
function normalizeTarget(raw) {
|
|
39626
40069
|
const key = raw.trim().toLowerCase();
|
|
39627
40070
|
if (key === "all")
|
|
@@ -39632,47 +40075,110 @@ function normalizeTarget(raw) {
|
|
|
39632
40075
|
return "claude-code";
|
|
39633
40076
|
if (key === "cursor")
|
|
39634
40077
|
return "cursor";
|
|
40078
|
+
if (key === "vscode" || key === "code" || key === "vs-code")
|
|
40079
|
+
return "vscode";
|
|
39635
40080
|
if (key === "antigravity" || key === "agy")
|
|
39636
40081
|
return "antigravity";
|
|
39637
40082
|
if (key === "codex" || key === "chatgpt")
|
|
39638
40083
|
return "codex";
|
|
39639
40084
|
return null;
|
|
39640
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
|
+
}
|
|
39641
40106
|
function getInkmapHome() {
|
|
39642
|
-
return process.env.INKMAP_HOME || (0,
|
|
40107
|
+
return process.env.INKMAP_HOME || (0, import_node_path5.join)((0, import_node_os5.homedir)(), ".inkmap");
|
|
39643
40108
|
}
|
|
39644
40109
|
function getClaudeDesktopDir() {
|
|
39645
40110
|
if (process.env.INKMAP_CLAUDE_CONFIG_DIR)
|
|
39646
40111
|
return process.env.INKMAP_CLAUDE_CONFIG_DIR;
|
|
39647
40112
|
if (process.platform === "darwin") {
|
|
39648
|
-
return (0,
|
|
40113
|
+
return (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Library", "Application Support", "Claude");
|
|
39649
40114
|
}
|
|
39650
40115
|
if (process.platform === "win32") {
|
|
39651
|
-
const appData = process.env.APPDATA || (0,
|
|
39652
|
-
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");
|
|
39653
40118
|
}
|
|
39654
|
-
const xdg = process.env.XDG_CONFIG_HOME || (0,
|
|
39655
|
-
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");
|
|
39656
40121
|
}
|
|
39657
40122
|
function getCursorDir() {
|
|
39658
|
-
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");
|
|
39659
40127
|
}
|
|
39660
40128
|
function getClaudeCodeConfigPath() {
|
|
39661
|
-
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");
|
|
39662
40130
|
}
|
|
39663
40131
|
function getAntigravityConfigDir() {
|
|
39664
|
-
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;
|
|
39665
40171
|
}
|
|
39666
40172
|
function findCodexCommand() {
|
|
39667
40173
|
if (process.env.INKMAP_CODEX_BIN) {
|
|
39668
|
-
return (0,
|
|
40174
|
+
return (0, import_node_fs3.existsSync)(process.env.INKMAP_CODEX_BIN) ? process.env.INKMAP_CODEX_BIN : null;
|
|
39669
40175
|
}
|
|
39670
|
-
if ((0,
|
|
40176
|
+
if ((0, import_node_child_process2.spawnSync)("codex", ["--version"], { stdio: "ignore" }).status === 0)
|
|
39671
40177
|
return "codex";
|
|
39672
40178
|
if (process.platform === "darwin") {
|
|
39673
|
-
for (const dir of ["/Applications", (0,
|
|
39674
|
-
const cmd = (0,
|
|
39675
|
-
if ((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");
|
|
40181
|
+
if ((0, import_node_fs3.existsSync)(cmd))
|
|
39676
40182
|
return cmd;
|
|
39677
40183
|
}
|
|
39678
40184
|
}
|
|
@@ -39681,31 +40187,31 @@ function findCodexCommand() {
|
|
|
39681
40187
|
function detectInstalledTargets() {
|
|
39682
40188
|
const found = [];
|
|
39683
40189
|
const claudeDir = getClaudeDesktopDir();
|
|
39684
|
-
if ((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")))) {
|
|
39685
40191
|
found.push("claude");
|
|
39686
40192
|
}
|
|
39687
40193
|
const claudeCodeCfg = getClaudeCodeConfigPath();
|
|
39688
|
-
if ((0,
|
|
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) {
|
|
39689
40195
|
found.push("claude-code");
|
|
39690
40196
|
}
|
|
39691
|
-
if ((0,
|
|
40197
|
+
if ((0, import_node_fs3.existsSync)(getCursorDir()) || Boolean(findCursorCommand())) {
|
|
39692
40198
|
found.push("cursor");
|
|
39693
40199
|
}
|
|
39694
40200
|
const agyDir = getAntigravityConfigDir();
|
|
39695
|
-
if ((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"))) {
|
|
39696
40202
|
found.push("antigravity");
|
|
39697
40203
|
}
|
|
39698
40204
|
if (!process.env.INKMAP_ISOLATED_DETECT && findCodexCommand()) {
|
|
39699
40205
|
found.push("codex");
|
|
39700
|
-
} else if (process.env.INKMAP_CODEX_BIN && (0,
|
|
40206
|
+
} else if (process.env.INKMAP_CODEX_BIN && (0, import_node_fs3.existsSync)(process.env.INKMAP_CODEX_BIN)) {
|
|
39701
40207
|
found.push("codex");
|
|
39702
40208
|
}
|
|
39703
40209
|
return found;
|
|
39704
40210
|
}
|
|
39705
40211
|
function readJsonObject(filePath) {
|
|
39706
|
-
if (!(0,
|
|
40212
|
+
if (!(0, import_node_fs3.existsSync)(filePath))
|
|
39707
40213
|
return {};
|
|
39708
|
-
const raw = (0,
|
|
40214
|
+
const raw = (0, import_node_fs3.readFileSync)(filePath, "utf8").trim();
|
|
39709
40215
|
if (!raw)
|
|
39710
40216
|
return {};
|
|
39711
40217
|
let parsed;
|
|
@@ -39720,50 +40226,142 @@ function readJsonObject(filePath) {
|
|
|
39720
40226
|
return parsed;
|
|
39721
40227
|
}
|
|
39722
40228
|
function writeJsonAtomic(filePath, data) {
|
|
39723
|
-
(0,
|
|
40229
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path5.dirname)(filePath), { recursive: true });
|
|
39724
40230
|
const tmp = `${filePath}.${process.pid}.${Date.now()}.tmp`;
|
|
39725
|
-
(0,
|
|
39726
|
-
(0,
|
|
40231
|
+
(0, import_node_fs3.writeFileSync)(tmp, JSON.stringify(data, null, 2) + "\n", "utf8");
|
|
40232
|
+
(0, import_node_fs3.renameSync)(tmp, filePath);
|
|
39727
40233
|
}
|
|
39728
40234
|
function stageStandaloneMcpApp() {
|
|
39729
|
-
const appDir = (0,
|
|
39730
|
-
(0,
|
|
39731
|
-
const bundledCli = (0,
|
|
39732
|
-
const bundledHtml = (0,
|
|
39733
|
-
const
|
|
39734
|
-
|
|
39735
|
-
|
|
39736
|
-
(0,
|
|
39737
|
-
(0,
|
|
40235
|
+
const appDir = (0, import_node_path5.join)(getInkmapHome(), "mcp-app");
|
|
40236
|
+
(0, import_node_fs3.mkdirSync)(appDir, { recursive: true });
|
|
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");
|
|
40241
|
+
if ((0, import_node_fs3.existsSync)(bundledCli) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
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"));
|
|
40244
|
+
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
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 });
|
|
40247
|
+
}
|
|
40248
|
+
(0, import_node_fs3.writeFileSync)((0, import_node_path5.join)(appDir, "server.cjs"), SERVER_WRAPPER, { mode: 493 });
|
|
39738
40249
|
for (const notice of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
39739
|
-
const src = (0,
|
|
39740
|
-
if ((0,
|
|
39741
|
-
(0,
|
|
40250
|
+
const src = (0, import_node_path5.join)(PKG_ROOT, notice);
|
|
40251
|
+
if ((0, import_node_fs3.existsSync)(src))
|
|
40252
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(appDir, notice));
|
|
39742
40253
|
}
|
|
39743
|
-
return { serverScript: (0,
|
|
40254
|
+
return { serverScript: (0, import_node_path5.join)(appDir, "server.cjs"), appDir };
|
|
39744
40255
|
}
|
|
39745
|
-
if ((0,
|
|
39746
|
-
(0,
|
|
39747
|
-
(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");
|
|
40260
|
+
if ((0, import_node_fs3.existsSync)(sidecarWeb)) {
|
|
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 });
|
|
40263
|
+
}
|
|
39748
40264
|
for (const notice of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
39749
|
-
const src = (0,
|
|
39750
|
-
if ((0,
|
|
39751
|
-
(0,
|
|
40265
|
+
const src = (0, import_node_path5.join)(monorepoAntigravity, notice);
|
|
40266
|
+
if ((0, import_node_fs3.existsSync)(src))
|
|
40267
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(appDir, notice));
|
|
39752
40268
|
}
|
|
39753
|
-
return { serverScript: (0,
|
|
40269
|
+
return { serverScript: (0, import_node_path5.join)(appDir, "server.cjs"), appDir };
|
|
39754
40270
|
}
|
|
39755
|
-
const devBin = (0,
|
|
39756
|
-
if ((0,
|
|
40271
|
+
const devBin = (0, import_node_path5.join)(PKG_ROOT, "bin", "inkmap.js");
|
|
40272
|
+
if ((0, import_node_fs3.existsSync)(devBin) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
39757
40273
|
return { serverScript: devBin, appDir };
|
|
39758
40274
|
}
|
|
39759
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.");
|
|
39760
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
|
+
}
|
|
39761
40359
|
function buildMcpEntry(serverScript, workspaces, existingEntry, withTypeStdio = false) {
|
|
39762
40360
|
const isDirectServer = serverScript.endsWith("server.cjs");
|
|
39763
40361
|
const args = isDirectServer ? [serverScript] : [serverScript, "mcp"];
|
|
39764
40362
|
const prevEnv = existingEntry && typeof existingEntry === "object" && !Array.isArray(existingEntry) && typeof existingEntry.env === "object" ? { ...existingEntry.env } : {};
|
|
39765
40363
|
if (workspaces.length > 0) {
|
|
39766
|
-
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);
|
|
39767
40365
|
}
|
|
39768
40366
|
const entry = {};
|
|
39769
40367
|
if (withTypeStdio)
|
|
@@ -39783,7 +40381,7 @@ function upsertMcpJsonConfig(filePath, serverScript, workspaces, withTypeStdio =
|
|
|
39783
40381
|
writeJsonAtomic(filePath, root);
|
|
39784
40382
|
}
|
|
39785
40383
|
function removeMcpJsonConfig(filePath) {
|
|
39786
|
-
if (!(0,
|
|
40384
|
+
if (!(0, import_node_fs3.existsSync)(filePath))
|
|
39787
40385
|
return false;
|
|
39788
40386
|
const root = readJsonObject(filePath);
|
|
39789
40387
|
if (!root.mcpServers || typeof root.mcpServers !== "object" || Array.isArray(root.mcpServers))
|
|
@@ -39814,30 +40412,30 @@ async function refreshAntigravityMcp() {
|
|
|
39814
40412
|
}
|
|
39815
40413
|
}
|
|
39816
40414
|
async function installAntigravityPlugin() {
|
|
39817
|
-
const pluginsDir = (0,
|
|
39818
|
-
const destination = (0,
|
|
39819
|
-
const bundledAgy = (0,
|
|
39820
|
-
const bundledCli = (0,
|
|
39821
|
-
const bundledHtml = (0,
|
|
39822
|
-
const bundledWeb = (0,
|
|
39823
|
-
const monorepoAgy = (0,
|
|
39824
|
-
(0,
|
|
39825
|
-
(0,
|
|
39826
|
-
if ((0,
|
|
39827
|
-
(0,
|
|
39828
|
-
(0,
|
|
39829
|
-
(0,
|
|
39830
|
-
(0,
|
|
39831
|
-
if ((0,
|
|
39832
|
-
(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");
|
|
40422
|
+
(0, import_node_fs3.mkdirSync)(pluginsDir, { recursive: true });
|
|
40423
|
+
(0, import_node_fs3.rmSync)(destination, { recursive: true, force: true });
|
|
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)) {
|
|
40425
|
+
(0, import_node_fs3.cpSync)(bundledAgy, destination, { recursive: true });
|
|
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 });
|
|
40429
|
+
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
40430
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path5.join)(destination, "sidecars", "inkmap", "web"), { recursive: true });
|
|
39833
40431
|
}
|
|
39834
40432
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md", "README.md"]) {
|
|
39835
|
-
const src = (0,
|
|
39836
|
-
if ((0,
|
|
39837
|
-
(0,
|
|
40433
|
+
const src = (0, import_node_path5.join)(PKG_ROOT, doc);
|
|
40434
|
+
if ((0, import_node_fs3.existsSync)(src))
|
|
40435
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(destination, doc));
|
|
39838
40436
|
}
|
|
39839
|
-
} else if ((0,
|
|
39840
|
-
(0,
|
|
40437
|
+
} else if ((0, import_node_fs3.existsSync)((0, import_node_path5.join)(monorepoAgy, "plugin.json"))) {
|
|
40438
|
+
(0, import_node_fs3.cpSync)(monorepoAgy, destination, { recursive: true });
|
|
39841
40439
|
} else {
|
|
39842
40440
|
throw new Error("\u672A\u627E\u5230 Antigravity \u63D2\u4EF6\u8D44\u6E90 / Antigravity plugin bundle not found.");
|
|
39843
40441
|
}
|
|
@@ -39849,38 +40447,38 @@ function installCodexPlugin() {
|
|
|
39849
40447
|
if (!codex) {
|
|
39850
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.");
|
|
39851
40449
|
}
|
|
39852
|
-
const bundledCodex = (0,
|
|
39853
|
-
const bundledCli = (0,
|
|
39854
|
-
const bundledHtml = (0,
|
|
39855
|
-
const monorepoCodexRoot = (0,
|
|
39856
|
-
const destination = (0,
|
|
39857
|
-
(0,
|
|
39858
|
-
const marketplaceRoot = (0,
|
|
39859
|
-
if ((0,
|
|
39860
|
-
(0,
|
|
39861
|
-
const pluginDir = (0,
|
|
39862
|
-
(0,
|
|
39863
|
-
(0,
|
|
39864
|
-
(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");
|
|
40455
|
+
(0, import_node_fs3.mkdirSync)(destination, { recursive: true });
|
|
40456
|
+
const marketplaceRoot = (0, import_node_fs3.realpathSync)(destination);
|
|
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)) {
|
|
40458
|
+
(0, import_node_fs3.cpSync)(bundledCodex, marketplaceRoot, { recursive: true });
|
|
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 });
|
|
39865
40463
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
39866
|
-
const src = (0,
|
|
39867
|
-
if ((0,
|
|
39868
|
-
(0,
|
|
40464
|
+
const src = (0, import_node_path5.join)(PKG_ROOT, doc);
|
|
40465
|
+
if ((0, import_node_fs3.existsSync)(src))
|
|
40466
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path5.join)(pluginDir, doc));
|
|
39869
40467
|
}
|
|
39870
|
-
} else if ((0,
|
|
39871
|
-
(0,
|
|
39872
|
-
(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 });
|
|
39873
40471
|
} else {
|
|
39874
40472
|
throw new Error("\u672A\u627E\u5230 Codex \u63D2\u4EF6\u8D44\u6E90 / Codex plugin bundle not found.");
|
|
39875
40473
|
}
|
|
39876
40474
|
const marketplaceName = "inkmap-local";
|
|
39877
|
-
const rawList = (0,
|
|
40475
|
+
const rawList = (0, import_node_child_process2.execFileSync)(codex, ["plugin", "marketplace", "list", "--json"], { encoding: "utf8" });
|
|
39878
40476
|
const { marketplaces = [] } = JSON.parse(rawList);
|
|
39879
40477
|
const existing = marketplaces.find((entry) => entry.name === marketplaceName);
|
|
39880
40478
|
if (!existing) {
|
|
39881
|
-
(0,
|
|
40479
|
+
(0, import_node_child_process2.execFileSync)(codex, ["plugin", "marketplace", "add", marketplaceRoot], { stdio: "pipe" });
|
|
39882
40480
|
}
|
|
39883
|
-
(0,
|
|
40481
|
+
(0, import_node_child_process2.execFileSync)(codex, ["plugin", "add", `inkmap-codex@${marketplaceName}`], { stdio: "pipe" });
|
|
39884
40482
|
return {
|
|
39885
40483
|
location: marketplaceRoot,
|
|
39886
40484
|
note: "\u91CD\u542F ChatGPT Desktop \u540E\uFF0C\u5728 Codex \u6A21\u5F0F\u70B9\u51FB .md \u6587\u4EF6\u6253\u5F00\u83DC\u5355\u9009\u62E9 Inkmap Mind Map"
|
|
@@ -39893,10 +40491,10 @@ async function runInstall(options = {}) {
|
|
|
39893
40491
|
const targets = explicitTargets ?? detectInstalledTargets();
|
|
39894
40492
|
const result = { installed: [], removed: [] };
|
|
39895
40493
|
if (options.uninstall) {
|
|
39896
|
-
const toRemove = explicitTargets ?? ["claude", "claude-code", "cursor", "antigravity", "codex"];
|
|
40494
|
+
const toRemove = explicitTargets ?? ["claude", "claude-code", "cursor", "vscode", "antigravity", "codex"];
|
|
39897
40495
|
for (const target of toRemove) {
|
|
39898
40496
|
if (target === "claude") {
|
|
39899
|
-
const cfg = (0,
|
|
40497
|
+
const cfg = (0, import_node_path5.join)(getClaudeDesktopDir(), "claude_desktop_config.json");
|
|
39900
40498
|
if (removeMcpJsonConfig(cfg))
|
|
39901
40499
|
result.removed.push({ target, location: cfg });
|
|
39902
40500
|
} else if (target === "claude-code") {
|
|
@@ -39904,26 +40502,32 @@ async function runInstall(options = {}) {
|
|
|
39904
40502
|
if (removeMcpJsonConfig(cfg))
|
|
39905
40503
|
result.removed.push({ target, location: cfg });
|
|
39906
40504
|
} else if (target === "cursor") {
|
|
39907
|
-
const cfg = (0,
|
|
39908
|
-
|
|
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)
|
|
39909
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
|
+
}
|
|
39910
40514
|
} else if (target === "antigravity") {
|
|
39911
|
-
const dir = (0,
|
|
39912
|
-
if ((0,
|
|
39913
|
-
(0,
|
|
40515
|
+
const dir = (0, import_node_path5.join)(getAntigravityConfigDir(), "plugins", "inkmap");
|
|
40516
|
+
if ((0, import_node_fs3.existsSync)(dir)) {
|
|
40517
|
+
(0, import_node_fs3.rmSync)(dir, { recursive: true, force: true });
|
|
39914
40518
|
await refreshAntigravityMcp();
|
|
39915
40519
|
result.removed.push({ target, location: dir });
|
|
39916
40520
|
}
|
|
39917
40521
|
} else if (target === "codex") {
|
|
39918
|
-
const dir = (0,
|
|
39919
|
-
if ((0,
|
|
39920
|
-
(0,
|
|
40522
|
+
const dir = (0, import_node_path5.join)(getInkmapHome(), "codex-marketplace");
|
|
40523
|
+
if ((0, import_node_fs3.existsSync)(dir)) {
|
|
40524
|
+
(0, import_node_fs3.rmSync)(dir, { recursive: true, force: true });
|
|
39921
40525
|
result.removed.push({ target, location: dir });
|
|
39922
40526
|
}
|
|
39923
40527
|
}
|
|
39924
40528
|
}
|
|
39925
40529
|
if (!explicitTargets) {
|
|
39926
|
-
(0,
|
|
40530
|
+
(0, import_node_fs3.rmSync)((0, import_node_path5.join)(getInkmapHome(), "mcp-app"), { recursive: true, force: true });
|
|
39927
40531
|
}
|
|
39928
40532
|
if (result.removed.length === 0) {
|
|
39929
40533
|
log("[inkmap] \u672A\u53D1\u73B0\u5DF2\u5B89\u88C5\u7684 Inkmap \u5BA2\u6237\u7AEF\u914D\u7F6E / No installed Inkmap client configs found.");
|
|
@@ -39940,14 +40544,15 @@ async function runInstall(options = {}) {
|
|
|
39940
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");
|
|
39941
40545
|
log(" npx -y inkmap-mcp@latest install claude # Claude Desktop (macOS / Windows / Ubuntu)");
|
|
39942
40546
|
log(" npx -y inkmap-mcp@latest install claude-code # Claude Code CLI");
|
|
39943
|
-
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)");
|
|
39944
40549
|
log(" npx -y inkmap-mcp@latest install antigravity # Google Antigravity");
|
|
39945
40550
|
log(" npx -y inkmap-mcp@latest install codex # OpenAI Codex Desktop");
|
|
39946
40551
|
return result;
|
|
39947
40552
|
}
|
|
39948
40553
|
for (const target of targets) {
|
|
39949
40554
|
if (target === "claude") {
|
|
39950
|
-
const cfg = (0,
|
|
40555
|
+
const cfg = (0, import_node_path5.join)(getClaudeDesktopDir(), "claude_desktop_config.json");
|
|
39951
40556
|
upsertMcpJsonConfig(cfg, serverScript, workspaces, false);
|
|
39952
40557
|
result.installed.push({
|
|
39953
40558
|
target,
|
|
@@ -39963,13 +40568,30 @@ async function runInstall(options = {}) {
|
|
|
39963
40568
|
note: "\u5728 Claude Code \u4E2D\u5DF2\u6CE8\u518C\u5168\u5C40 inkmap MCP \u670D\u52A1"
|
|
39964
40569
|
});
|
|
39965
40570
|
} else if (target === "cursor") {
|
|
39966
|
-
const cfg = (0,
|
|
40571
|
+
const cfg = (0, import_node_path5.join)(getCursorDir(), "mcp.json");
|
|
39967
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
|
+
}
|
|
39968
40581
|
result.installed.push({
|
|
39969
40582
|
target,
|
|
39970
|
-
location: cfg,
|
|
39971
|
-
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"
|
|
39972
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
|
+
}
|
|
39973
40595
|
} else if (target === "antigravity") {
|
|
39974
40596
|
const loc = await installAntigravityPlugin();
|
|
39975
40597
|
result.installed.push({
|
|
@@ -39992,11 +40614,40 @@ async function runInstall(options = {}) {
|
|
|
39992
40614
|
}
|
|
39993
40615
|
}
|
|
39994
40616
|
}
|
|
39995
|
-
|
|
39996
|
-
|
|
39997
|
-
log(`
|
|
39998
|
-
|
|
39999
|
-
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");
|
|
40000
40651
|
}
|
|
40001
40652
|
return result;
|
|
40002
40653
|
}
|
|
@@ -40015,7 +40666,8 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
40015
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
|
|
40016
40667
|
claude Claude Desktop (Ubuntu / macOS / Windows)
|
|
40017
40668
|
claude-code Claude Code CLI (~/.claude.json)
|
|
40018
|
-
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)
|
|
40019
40671
|
antigravity Google Antigravity (~/.gemini/config/plugins/inkmap)
|
|
40020
40672
|
codex OpenAI Codex Desktop
|
|
40021
40673
|
|
|
@@ -40027,17 +40679,17 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
40027
40679
|
const val = argv[++i];
|
|
40028
40680
|
if (!val)
|
|
40029
40681
|
throw new Error("--workspace \u9700\u8981\u63D0\u4F9B\u76EE\u5F55\u8DEF\u5F84 / --workspace requires a directory path");
|
|
40030
|
-
workspaces.push(...val.split(
|
|
40682
|
+
workspaces.push(...val.split(import_node_path5.delimiter).filter(Boolean));
|
|
40031
40683
|
continue;
|
|
40032
40684
|
}
|
|
40033
40685
|
if (arg.startsWith("--workspace=")) {
|
|
40034
40686
|
const val = arg.slice("--workspace=".length);
|
|
40035
|
-
workspaces.push(...val.split(
|
|
40687
|
+
workspaces.push(...val.split(import_node_path5.delimiter).filter(Boolean));
|
|
40036
40688
|
continue;
|
|
40037
40689
|
}
|
|
40038
40690
|
const normalized = normalizeTarget(arg);
|
|
40039
40691
|
if (!normalized) {
|
|
40040
|
-
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`);
|
|
40041
40693
|
}
|
|
40042
40694
|
if (normalized === "all") {
|
|
40043
40695
|
explicitAll = true;
|
|
@@ -40051,17 +40703,18 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
40051
40703
|
uninstall
|
|
40052
40704
|
});
|
|
40053
40705
|
}
|
|
40054
|
-
var
|
|
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;
|
|
40055
40707
|
var init_install = __esm({
|
|
40056
40708
|
"packages/cli/dist/install.js"() {
|
|
40057
40709
|
"use strict";
|
|
40058
|
-
|
|
40059
|
-
|
|
40060
|
-
|
|
40061
|
-
|
|
40062
|
-
|
|
40063
|
-
|
|
40064
|
-
|
|
40710
|
+
import_node_child_process2 = require("node:child_process");
|
|
40711
|
+
import_node_fs3 = require("node:fs");
|
|
40712
|
+
import_node_os5 = require("node:os");
|
|
40713
|
+
import_node_path5 = require("node:path");
|
|
40714
|
+
import_node_url3 = require("node:url");
|
|
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, "..");
|
|
40065
40718
|
SERVER_WRAPPER = `#!/usr/bin/env node
|
|
40066
40719
|
"use strict";
|
|
40067
40720
|
require("./cli.cjs").main(["mcp", ...process.argv.slice(2)]).catch(err => {
|
|
@@ -40069,6 +40722,16 @@ require("./cli.cjs").main(["mcp", ...process.argv.slice(2)]).catch(err => {
|
|
|
40069
40722
|
process.exit(1);
|
|
40070
40723
|
});
|
|
40071
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
|
+
})();
|
|
40072
40735
|
}
|
|
40073
40736
|
});
|
|
40074
40737
|
|
|
@@ -40079,14 +40742,14 @@ __export(index_exports, {
|
|
|
40079
40742
|
main: () => main
|
|
40080
40743
|
});
|
|
40081
40744
|
module.exports = __toCommonJS(index_exports);
|
|
40082
|
-
var
|
|
40083
|
-
var
|
|
40084
|
-
var
|
|
40745
|
+
var import_node_child_process3 = require("node:child_process");
|
|
40746
|
+
var import_node_path6 = require("node:path");
|
|
40747
|
+
var import_node_url4 = require("node:url");
|
|
40085
40748
|
init_dist();
|
|
40086
40749
|
init_license();
|
|
40087
40750
|
init_server();
|
|
40088
|
-
var INKMAP_VERSION = "0.2.
|
|
40089
|
-
var
|
|
40751
|
+
var INKMAP_VERSION = "0.2.8";
|
|
40752
|
+
var WEB_ROOT2 = (0, import_node_url4.fileURLToPath)(new URL("./web/", inkmapModuleUrl));
|
|
40090
40753
|
var USAGE = `Inkmap v${INKMAP_VERSION} \u2014 Markdown \u4EA4\u4E92\u601D\u7EF4\u5BFC\u56FE\u7F16\u8F91\u5668 & MCP App
|
|
40091
40754
|
|
|
40092
40755
|
\u7528\u6CD5 / Usage\uFF1A
|
|
@@ -40100,14 +40763,14 @@ var USAGE = `Inkmap v${INKMAP_VERSION} \u2014 Markdown \u4EA4\u4E92\u601D\u7EF4\
|
|
|
40100
40763
|
\u5728\u672C\u5730\u6D4F\u89C8\u5668\u4E2D\u4EE5\u601D\u7EF4\u5BFC\u56FE\u6253\u5F00\u5E76\u5B9E\u65F6\u53CC\u5411\u7F16\u8F91 Markdown \u6587\u4EF6`;
|
|
40101
40764
|
function openBrowser(url2) {
|
|
40102
40765
|
const [cmd, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
40103
|
-
(0,
|
|
40766
|
+
(0, import_node_child_process3.spawn)(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
40104
40767
|
}
|
|
40105
40768
|
function appendEnvWorkspaces(dirs) {
|
|
40106
40769
|
if (dirs.length === 0)
|
|
40107
40770
|
return;
|
|
40108
|
-
const resolved = dirs.map((d2) => (0,
|
|
40109
|
-
const current = (process.env.INKMAP_WORKSPACES || "").split(
|
|
40110
|
-
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);
|
|
40111
40774
|
}
|
|
40112
40775
|
async function main(argv) {
|
|
40113
40776
|
if (argv.length === 0 && !process.stdin.isTTY) {
|
|
@@ -40134,9 +40797,9 @@ async function main(argv) {
|
|
|
40134
40797
|
const val = argv[++i];
|
|
40135
40798
|
if (!val)
|
|
40136
40799
|
throw new Error("--workspace \u9700\u8981\u76EE\u5F55\u8DEF\u5F84");
|
|
40137
|
-
extraWorkspaces.push(...val.split(
|
|
40800
|
+
extraWorkspaces.push(...val.split(import_node_path6.delimiter).filter(Boolean));
|
|
40138
40801
|
} else if (arg.startsWith("--workspace=")) {
|
|
40139
|
-
extraWorkspaces.push(...arg.slice("--workspace=".length).split(
|
|
40802
|
+
extraWorkspaces.push(...arg.slice("--workspace=".length).split(import_node_path6.delimiter).filter(Boolean));
|
|
40140
40803
|
} else if (arg === "-h" || arg === "--help") {
|
|
40141
40804
|
console.log(USAGE);
|
|
40142
40805
|
return;
|
|
@@ -40186,7 +40849,7 @@ ${USAGE}`);
|
|
|
40186
40849
|
const license = licenseService(fileSessionStorage(), () => process.env.INKMAP_BILLING_ORIGIN || YUNFAN_BILLING_ORIGIN);
|
|
40187
40850
|
const served = await serve({
|
|
40188
40851
|
source: await fileSource(file2, log),
|
|
40189
|
-
webRoot:
|
|
40852
|
+
webRoot: WEB_ROOT2,
|
|
40190
40853
|
port: port ?? (sidebar ? 0 : void 0),
|
|
40191
40854
|
log,
|
|
40192
40855
|
license,
|