inkmap-mcp 0.3.16 → 0.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles/antigravity/plugin.json +1 -1
- package/dist/bundles/antigravity/sidecars/inkmap/bridge.js +7 -4
- package/dist/bundles/antigravity/sidecars/inkmap/main.mjs +131 -82
- package/dist/bundles/antigravity/sidecars/inkmap/sidecar.json +1 -6
- package/dist/bundles/codex/inkmap-codex/.codex-plugin/plugin.json +1 -1
- package/dist/bundles/codex/inkmap-codex/plugin.json +1 -1
- package/dist/bundles/harness/host.js +129 -58
- package/dist/bundles/harness/package.json +1 -1
- package/dist/bundles/vscode/dist/extension.js +172 -60
- package/dist/bundles/vscode/package.json +6 -1
- package/dist/cli.cjs +268 -131
- package/dist/codex.html +722 -669
- package/dist/web/app.js +23270 -22557
- package/dist/web/index.html +44 -4
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inkmap",
|
|
3
3
|
"displayName": "Inkmap — Markdown Mind Map & Mermaid 思维导图",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.17",
|
|
5
5
|
"description": "Interactive two-way Markdown (.md, .markmap.md) mind map, mindmap, markmap, Mermaid flowchart, diagram, XMind outline & KaTeX editor: auto-opens in the Antigravity side pane with live file write-back. 在右侧面板实时双向编辑 Markdown 思维导图、脑图、流程图、大纲、架构图、组织结构图与鱼骨图。",
|
|
6
6
|
"logo": "assets/logo.svg",
|
|
7
7
|
"homepage": "https://zhiyuanv.com/software.html",
|
|
@@ -838,7 +838,9 @@
|
|
|
838
838
|
emitToEditor({ type: "reveal", line: startLine });
|
|
839
839
|
});
|
|
840
840
|
}
|
|
841
|
-
|
|
841
|
+
// Redrawing a diagram blocks typing, so an edit inside a mermaid block waits for a longer pause.
|
|
842
|
+
}, (fences => fences.length % 2 === 1 && /mermaid/i.test(fences[fences.length - 1]))(
|
|
843
|
+
nextMd.slice(0, startPos).match(/^\s*(?:`{3,}|~{3,}).*$/gm) || []) ? 900 : 320);
|
|
842
844
|
});
|
|
843
845
|
}
|
|
844
846
|
const resizer = document.getElementById("ag-md-resizer");
|
|
@@ -971,11 +973,12 @@
|
|
|
971
973
|
workspaceUris,
|
|
972
974
|
}),
|
|
973
975
|
});
|
|
974
|
-
|
|
976
|
+
// A save in flight wins; `targetSeq` stays behind so the next poll still reports the switch.
|
|
975
977
|
if (saving) return;
|
|
978
|
+
if (res.targetSeq) targetSeq = res.targetSeq;
|
|
976
979
|
if (res.switchedFile && res.doc) {
|
|
977
|
-
|
|
978
|
-
|
|
980
|
+
// Write edits still inside the debounce window to the file being left, as a manual switch does.
|
|
981
|
+
await flushPendingEdits().catch(() => {});
|
|
979
982
|
currentFile = res.switchedFile;
|
|
980
983
|
currentFileUri = res.currentFileUri;
|
|
981
984
|
currentVersion = res.doc.version;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/antigravity/src/main.mjs
|
|
2
|
-
import { execFile
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
3
|
import { createHash as createHash2 } from "node:crypto";
|
|
4
4
|
import { readFileSync, readdirSync } from "node:fs";
|
|
5
5
|
import { lstat as lstat3, readFile as readFile4, realpath as realpath3 } from "node:fs/promises";
|
|
@@ -59,10 +59,10 @@ import { execFileSync } from "node:child_process";
|
|
|
59
59
|
import { link, mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
60
60
|
import { randomUUID } from "node:crypto";
|
|
61
61
|
import { homedir, tmpdir } from "node:os";
|
|
62
|
-
import { dirname, join
|
|
62
|
+
import { dirname, join } from "node:path";
|
|
63
63
|
|
|
64
64
|
// packages/cli/dist/version.js
|
|
65
|
-
var INKMAP_VERSION = "0.3.
|
|
65
|
+
var INKMAP_VERSION = "0.3.17";
|
|
66
66
|
|
|
67
67
|
// packages/cli/dist/license.js
|
|
68
68
|
var ZH_LOCALE_RE = /^zh(?:[-_.]|$)/i;
|
|
@@ -73,6 +73,8 @@ var WAIT_SLOW_MS = 3e4;
|
|
|
73
73
|
var WAIT_FAST_FOR_MS = 30 * 6e4;
|
|
74
74
|
var WAIT_MAX_MS = 3 * 24 * 60 * 6e4;
|
|
75
75
|
var MAX_WAITING = 5;
|
|
76
|
+
var OFFLINE_PRO_GRACE_MS = 7 * 24 * 60 * 6e4;
|
|
77
|
+
var PRO_RECHECK_STAMP_MS = 12 * 60 * 6e4;
|
|
76
78
|
function isWaitingToken(value) {
|
|
77
79
|
const w = value;
|
|
78
80
|
return Boolean(w) && typeof w.origin === "string" && typeof w.token === "string" && /^[A-Za-z0-9_-]{43}$/.test(w.token) && typeof w.email === "string" && typeof w.since === "number" && typeof w.fastUntil === "number";
|
|
@@ -157,6 +159,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
157
159
|
let detectedHost = defaultHost;
|
|
158
160
|
const pendingEvents = /* @__PURE__ */ new Map();
|
|
159
161
|
let lastCheck = 0;
|
|
162
|
+
let retryAfter = 0;
|
|
160
163
|
let fastPollUntil = 0;
|
|
161
164
|
const expectPurchase = () => void (fastPollUntil = Date.now() + 15 * 6e4);
|
|
162
165
|
let flowCreation;
|
|
@@ -358,6 +361,24 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
358
361
|
timer = setTimeout(() => void refresh(), delay);
|
|
359
362
|
timer.unref();
|
|
360
363
|
}
|
|
364
|
+
async function rememberProCheck(token, active, account) {
|
|
365
|
+
await writeSession(async () => {
|
|
366
|
+
let record;
|
|
367
|
+
try {
|
|
368
|
+
record = JSON.parse(await storage.read() || "{}");
|
|
369
|
+
} catch {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (record.token !== token)
|
|
373
|
+
return;
|
|
374
|
+
const at = typeof record.proVerifiedAt === "number" ? record.proVerifiedAt : void 0;
|
|
375
|
+
if (active ? at !== void 0 && Date.now() - at < PRO_RECHECK_STAMP_MS && at <= Date.now() : at === void 0)
|
|
376
|
+
return;
|
|
377
|
+
const { proVerifiedAt: _at, proAccount: _account, ...rest } = record;
|
|
378
|
+
await storage.write(JSON.stringify(active ? { ...rest, proVerifiedAt: Date.now(), ...account && { proAccount: account } } : rest));
|
|
379
|
+
}).catch(() => {
|
|
380
|
+
});
|
|
381
|
+
}
|
|
361
382
|
function refresh() {
|
|
362
383
|
if (connection)
|
|
363
384
|
return connection;
|
|
@@ -365,6 +386,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
365
386
|
connection = (async () => {
|
|
366
387
|
let token;
|
|
367
388
|
let delay = 6e4;
|
|
389
|
+
let offlinePro;
|
|
368
390
|
try {
|
|
369
391
|
const origin = billingOrigin(getOrigin());
|
|
370
392
|
if (origin !== activeOrigin) {
|
|
@@ -381,6 +403,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
381
403
|
if (record.origin !== origin || typeof record.token !== "string")
|
|
382
404
|
return update(false);
|
|
383
405
|
token = record.token;
|
|
406
|
+
const verifiedAt = record.proVerifiedAt;
|
|
407
|
+
if (typeof verifiedAt === "number" && verifiedAt <= Date.now() && Date.now() - verifiedAt < OFFLINE_PRO_GRACE_MS) {
|
|
408
|
+
offlinePro = { ...typeof record.proAccount === "string" && { account: record.proAccount.slice(0, 64) } };
|
|
409
|
+
}
|
|
384
410
|
const response = await entitlement(origin, record.token);
|
|
385
411
|
if (version !== generation || disposed)
|
|
386
412
|
return;
|
|
@@ -400,9 +426,14 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
400
426
|
if (version !== generation || disposed)
|
|
401
427
|
return;
|
|
402
428
|
applyEntitlement(state);
|
|
403
|
-
|
|
429
|
+
void rememberProCheck(record.token, current.pro, current.account);
|
|
430
|
+
delay = state.active !== true && (state.pending === true || Date.now() < fastPollUntil) ? 2500 : 6e4;
|
|
404
431
|
} catch {
|
|
405
|
-
if (version === generation
|
|
432
|
+
if (version === generation)
|
|
433
|
+
retryAfter = Date.now() + (Date.now() < fastPollUntil ? 2e3 : 3e4);
|
|
434
|
+
if (version === generation && offlinePro)
|
|
435
|
+
update(true, true, offlinePro.account);
|
|
436
|
+
else if (version === generation && Date.now() - lastCheck > 15 * 6e4)
|
|
406
437
|
update(false);
|
|
407
438
|
} finally {
|
|
408
439
|
if (version === generation && token)
|
|
@@ -441,7 +472,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
441
472
|
clearTimeout(waitTimer);
|
|
442
473
|
if (disposed || !waiting.length)
|
|
443
474
|
return;
|
|
444
|
-
waitTimer = setTimeout(() => void checkWaiting(), delay);
|
|
475
|
+
waitTimer = setTimeout(() => void checkWaiting().catch(() => scheduleWait(WAIT_SLOW_MS)), delay);
|
|
445
476
|
waitTimer.unref();
|
|
446
477
|
}
|
|
447
478
|
async function checkWaiting() {
|
|
@@ -482,8 +513,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
482
513
|
await writeSession(async () => {
|
|
483
514
|
if (disposed || round !== waitRound || w.origin !== billingOrigin(getOrigin()))
|
|
484
515
|
return;
|
|
485
|
-
|
|
516
|
+
if (w.email)
|
|
517
|
+
lastSignIn = w.email.trim().slice(0, 254);
|
|
486
518
|
await storage.write(sessionRecord({ origin: w.origin, token: w.token }));
|
|
519
|
+
clearWaiting();
|
|
487
520
|
++generation;
|
|
488
521
|
activeOrigin = w.origin;
|
|
489
522
|
applyEntitlement(body);
|
|
@@ -520,6 +553,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
520
553
|
}
|
|
521
554
|
if (typeof record.token !== "string" || typeof record.origin !== "string")
|
|
522
555
|
return;
|
|
556
|
+
if (typeof record.checkoutUrl === "string")
|
|
557
|
+
return;
|
|
523
558
|
const response = await entitlement(record.origin, record.token).catch(() => null);
|
|
524
559
|
if (!response?.ok)
|
|
525
560
|
return;
|
|
@@ -552,13 +587,20 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
552
587
|
return;
|
|
553
588
|
}
|
|
554
589
|
if (process.env.INKMAP_ALLOW_TEST_TELEMETRY !== "1") {
|
|
555
|
-
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT)
|
|
556
|
-
return;
|
|
557
|
-
const customHome = process.env.INKMAP_HOME || "";
|
|
558
|
-
const sysTmp = tmpdir();
|
|
559
|
-
if (customHome && (customHome === sysTmp || customHome.startsWith(sysTmp + sep) || customHome.startsWith("/tmp/") || customHome.startsWith("/private/tmp/") || customHome.includes("/var/folders/") || customHome.includes("inkmap-npm-isolated-") || customHome.includes("inkmap-antigravity-mcp-") || customHome.includes("inkmap-local-editor-") || customHome.includes("inkmap-harness-"))) {
|
|
590
|
+
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT || process.env.VITEST || process.env.JEST_WORKER_ID || process.env.CI === "true" || process.env.CI === "1") {
|
|
560
591
|
return;
|
|
561
592
|
}
|
|
593
|
+
const norm = (p) => {
|
|
594
|
+
const clean = p.replace(/\\/g, "/");
|
|
595
|
+
return process.platform === "win32" ? clean.toLowerCase() : clean;
|
|
596
|
+
};
|
|
597
|
+
const sysTmp = norm(tmpdir()).replace(/\/+$/, "");
|
|
598
|
+
const homesToCheck = [process.env.INKMAP_HOME || "", homedir()].filter(Boolean).map(norm);
|
|
599
|
+
for (const h of homesToCheck) {
|
|
600
|
+
if (h === sysTmp || h.startsWith(sysTmp + "/") || h.startsWith("/tmp/") || h.startsWith("/private/tmp/") || h.includes("/var/folders/") || h.includes("/appdata/local/temp/") || h.includes("/temp/inkmap") || h.includes("inkmap-npm-isolated-") || h.includes("inkmap-antigravity-mcp-") || h.includes("inkmap-local-editor-") || h.includes("inkmap-harness-") || h.includes("inkmap-test-")) {
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
562
604
|
}
|
|
563
605
|
const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
|
|
564
606
|
if (disposed || !id || !pendingEvents.size)
|
|
@@ -592,8 +634,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
592
634
|
return {
|
|
593
635
|
async state() {
|
|
594
636
|
await (trial ??= startTrial());
|
|
595
|
-
const interval = !current.pro && Date.now() < fastPollUntil ?
|
|
596
|
-
if (Date.now() - lastCheck >= interval)
|
|
637
|
+
const interval = !current.pro && Date.now() < fastPollUntil ? 2e3 : 6e4;
|
|
638
|
+
if (Date.now() - lastCheck >= interval && Date.now() >= retryAfter)
|
|
597
639
|
await refresh();
|
|
598
640
|
await parkUnpaidSession();
|
|
599
641
|
return current;
|
|
@@ -662,7 +704,9 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
662
704
|
if (cachedOrder && cachedOrder.origin === origin && cachedOrder.locale === loc && Date.now() - cachedOrder.at < 8e3) {
|
|
663
705
|
const hit = cachedOrder.result;
|
|
664
706
|
cachedOrder = void 0;
|
|
665
|
-
|
|
707
|
+
if (current.pro)
|
|
708
|
+
return { status: "active", state: current };
|
|
709
|
+
schedule(hit.status === "qr" || hit.status === "redirect" ? 2500 : 6e4);
|
|
666
710
|
return hit;
|
|
667
711
|
}
|
|
668
712
|
const version = generation;
|
|
@@ -673,6 +717,17 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
673
717
|
record = JSON.parse(stored);
|
|
674
718
|
} catch {
|
|
675
719
|
}
|
|
720
|
+
if (record?.origin === origin && typeof record.token === "string") {
|
|
721
|
+
const rights = await entitlement(origin, record.token).catch(() => null);
|
|
722
|
+
if (rights?.ok) {
|
|
723
|
+
const ent = await rights.json().catch(() => null);
|
|
724
|
+
if (ent && ent.active === true) {
|
|
725
|
+
applyEntitlement(ent);
|
|
726
|
+
schedule(6e4);
|
|
727
|
+
return { status: "active", state: current };
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
}
|
|
676
731
|
const requestOrder = async (checkoutUrl, token, cookie, persist) => {
|
|
677
732
|
const res = await checkoutPost(checkoutUrl, "order", origin, {}, token, cookie, localeHint);
|
|
678
733
|
if (res.status === 401 || res.status === 403 || res.status === 404 || res.status === 410)
|
|
@@ -870,13 +925,16 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
870
925
|
if (version !== generation || disposed || origin !== billingOrigin(getOrigin()))
|
|
871
926
|
return phoneFailure();
|
|
872
927
|
clearWaiting();
|
|
928
|
+
const clean = phone.trim().slice(0, 254);
|
|
929
|
+
if (clean)
|
|
930
|
+
lastSignIn = clean;
|
|
873
931
|
await storage.write(sessionRecord({ origin, token, ...checkoutUrl && { checkoutUrl }, ...cookie && { cookie } }));
|
|
874
932
|
++generation;
|
|
875
933
|
activeOrigin = origin;
|
|
876
934
|
applyEntitlement(state);
|
|
877
935
|
if (cachedOrder?.result.status === "active")
|
|
878
936
|
cachedOrder.result.state = current;
|
|
879
|
-
schedule(cachedOrder?.result.status === "qr" ?
|
|
937
|
+
schedule(cachedOrder?.result.status === "qr" || cachedOrder?.result.status === "redirect" ? 2500 : 6e4);
|
|
880
938
|
return { ok: true, value: current };
|
|
881
939
|
});
|
|
882
940
|
} catch {
|
|
@@ -1029,19 +1087,51 @@ async function localTrialDeadline() {
|
|
|
1029
1087
|
return Number.isSafeInteger(started) && started > 0 && started <= Date.now() ? started + TRIAL_MS : void 0;
|
|
1030
1088
|
}
|
|
1031
1089
|
|
|
1032
|
-
// packages/cli/dist/
|
|
1090
|
+
// packages/cli/dist/open-browser.js
|
|
1033
1091
|
import { spawn } from "node:child_process";
|
|
1092
|
+
function run(cmd, args, launched = false) {
|
|
1093
|
+
return new Promise((done) => {
|
|
1094
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
1095
|
+
child.on("error", () => done(false));
|
|
1096
|
+
if (launched)
|
|
1097
|
+
child.on("spawn", () => done(true));
|
|
1098
|
+
else
|
|
1099
|
+
child.on("exit", (code) => done(code === 0));
|
|
1100
|
+
child.unref();
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1103
|
+
async function openBrowserWindow(url) {
|
|
1104
|
+
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url))
|
|
1105
|
+
return;
|
|
1106
|
+
if (process.platform === "darwin") {
|
|
1107
|
+
if (await run("open", ["-a", "Google Chrome", url]))
|
|
1108
|
+
return;
|
|
1109
|
+
await run("open", [url]);
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (process.platform === "win32") {
|
|
1113
|
+
if (await run("cmd", ["/c", "start", "", "chrome", url]))
|
|
1114
|
+
return;
|
|
1115
|
+
await run("cmd", ["/c", "start", "", url]);
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
if (await run("google-chrome", [url], true))
|
|
1119
|
+
return;
|
|
1120
|
+
await run("xdg-open", [url], true);
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
// packages/cli/dist/server.js
|
|
1034
1124
|
import { createHash, randomBytes } from "node:crypto";
|
|
1035
1125
|
import { watch } from "node:fs";
|
|
1036
1126
|
import { lstat as lstat2, mkdir as mkdir2, readFile as readFile3, realpath as realpath2, rename as rename2, rm as rm2, stat, writeFile as writeFile2 } from "node:fs/promises";
|
|
1037
1127
|
import { createServer } from "node:http";
|
|
1038
1128
|
import { homedir as homedir3 } from "node:os";
|
|
1039
|
-
import { basename as basename2, delimiter as delimiter2, dirname as dirname3, extname, join as join3, normalize, relative as relative2, resolve as resolve2, sep as
|
|
1129
|
+
import { basename as basename2, delimiter as delimiter2, dirname as dirname3, extname, join as join3, normalize, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
|
|
1040
1130
|
|
|
1041
1131
|
// packages/cli/dist/workspace-fs.js
|
|
1042
1132
|
import { lstat, readdir, readFile as readFile2, realpath } from "node:fs/promises";
|
|
1043
1133
|
import { homedir as homedir2 } from "node:os";
|
|
1044
|
-
import { basename, delimiter, dirname as dirname2, isAbsolute, join as join2, posix, relative, resolve, sep
|
|
1134
|
+
import { basename, delimiter, dirname as dirname2, isAbsolute, join as join2, posix, relative, resolve, sep, win32 } from "node:path";
|
|
1045
1135
|
import { fileURLToPath } from "node:url";
|
|
1046
1136
|
var say = (zh, en) => detectOsLocale() === "zh" ? zh : en;
|
|
1047
1137
|
var MAX_MARKDOWN_BYTES = 5 * 1024 * 1024;
|
|
@@ -1072,22 +1162,21 @@ function insideOrEqual(root, target) {
|
|
|
1072
1162
|
if (root === target)
|
|
1073
1163
|
return true;
|
|
1074
1164
|
const rel = relative(root, target);
|
|
1075
|
-
return Boolean(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." +
|
|
1165
|
+
return Boolean(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." + sep));
|
|
1076
1166
|
}
|
|
1077
1167
|
function hasHiddenSegment(root, target) {
|
|
1078
1168
|
const rel = relative(root, target);
|
|
1079
1169
|
if (!rel || rel === ".")
|
|
1080
1170
|
return false;
|
|
1081
|
-
return rel.split(
|
|
1171
|
+
return rel.split(sep).some((part) => part.startsWith("."));
|
|
1082
1172
|
}
|
|
1083
1173
|
async function hasSymlinkUnderRoot(realRoot, rawTarget) {
|
|
1084
1174
|
let cur = rawTarget;
|
|
1085
1175
|
while (cur && cur !== dirname2(cur)) {
|
|
1086
|
-
const st = await lstat(cur);
|
|
1087
|
-
if (st.isSymbolicLink())
|
|
1088
|
-
return true;
|
|
1089
1176
|
if (await realpath(cur) === realRoot)
|
|
1090
1177
|
return false;
|
|
1178
|
+
if ((await lstat(cur)).isSymbolicLink())
|
|
1179
|
+
return true;
|
|
1091
1180
|
cur = dirname2(cur);
|
|
1092
1181
|
}
|
|
1093
1182
|
return false;
|
|
@@ -1386,13 +1475,18 @@ async function fileSource(file, log = () => {
|
|
|
1386
1475
|
log(`\u5DF2\u5199\u56DE ${path}`);
|
|
1387
1476
|
},
|
|
1388
1477
|
watch(onChange) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1478
|
+
try {
|
|
1479
|
+
const watcher = watch(dir, (_, changed) => {
|
|
1480
|
+
if (!changed || changed === basename2(path))
|
|
1481
|
+
onChange();
|
|
1482
|
+
});
|
|
1483
|
+
watcher.on("error", () => {
|
|
1484
|
+
});
|
|
1485
|
+
return () => watcher.close();
|
|
1486
|
+
} catch {
|
|
1487
|
+
return () => {
|
|
1488
|
+
};
|
|
1489
|
+
}
|
|
1396
1490
|
},
|
|
1397
1491
|
readView: () => readDiskViewState(path),
|
|
1398
1492
|
writeView: (state) => writeDiskViewState(path, state)
|
|
@@ -1406,37 +1500,12 @@ function within(root, rel, allowAbsoluteInRoot = false) {
|
|
|
1406
1500
|
return null;
|
|
1407
1501
|
}
|
|
1408
1502
|
const resolvedRoot = resolve2(root);
|
|
1409
|
-
const base = resolvedRoot.endsWith(
|
|
1503
|
+
const base = resolvedRoot.endsWith(sep2) ? resolvedRoot : resolvedRoot + sep2;
|
|
1410
1504
|
const full = allowAbsoluteInRoot && /^(?:[\\/]|[A-Za-z]:[\\/])/.test(decoded) ? normalize(decoded) : normalize(join3(resolvedRoot, decoded));
|
|
1411
1505
|
return full.startsWith(base) ? full : null;
|
|
1412
1506
|
}
|
|
1413
|
-
async function openBrowserWindow(url) {
|
|
1414
|
-
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url))
|
|
1415
|
-
return;
|
|
1416
|
-
const run = (cmd, args) => new Promise((done) => {
|
|
1417
|
-
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
1418
|
-
child.on("error", () => done(false));
|
|
1419
|
-
child.on("exit", (code) => done(code === 0));
|
|
1420
|
-
child.unref();
|
|
1421
|
-
});
|
|
1422
|
-
if (process.platform === "darwin") {
|
|
1423
|
-
if (await run("open", ["-a", "Google Chrome", url]))
|
|
1424
|
-
return;
|
|
1425
|
-
await run("open", [url]);
|
|
1426
|
-
return;
|
|
1427
|
-
}
|
|
1428
|
-
if (process.platform === "win32") {
|
|
1429
|
-
if (await run("cmd", ["/c", "start", "", "chrome", url]))
|
|
1430
|
-
return;
|
|
1431
|
-
await run("cmd", ["/c", "start", "", url]);
|
|
1432
|
-
return;
|
|
1433
|
-
}
|
|
1434
|
-
if (await run("google-chrome", [url]))
|
|
1435
|
-
return;
|
|
1436
|
-
await run("xdg-open", [url]);
|
|
1437
|
-
}
|
|
1438
1507
|
async function serve({ source: initialSource, webRoot, port = 4377, host = "127.0.0.1", log = () => {
|
|
1439
|
-
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false,
|
|
1508
|
+
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, workspaceRoots = [], confineToWorkspaceRoots = false, openSource = (path) => fileSource(path, log), allowPurchase = true }) {
|
|
1440
1509
|
if (sidebar && host !== "127.0.0.1")
|
|
1441
1510
|
throw new Error("The sidebar bridge requires loopback.");
|
|
1442
1511
|
const prefix = sidebar ? `/s/${randomBytes(24).toString("hex")}/` : "/";
|
|
@@ -1655,7 +1724,6 @@ data: ${JSON.stringify(data)}
|
|
|
1655
1724
|
if (url.pathname === "/api/capabilities" && req.method === "GET") {
|
|
1656
1725
|
return json(res, 200, {
|
|
1657
1726
|
purchase: canPurchase,
|
|
1658
|
-
...ideWorkspace && { ideWorkspace: true },
|
|
1659
1727
|
...sidebarAccountNavigation && { accountNavigation: "host" }
|
|
1660
1728
|
});
|
|
1661
1729
|
}
|
|
@@ -1676,6 +1744,8 @@ data: ${JSON.stringify(data)}
|
|
|
1676
1744
|
const { md, baseVersion } = JSON.parse(await readBody(req));
|
|
1677
1745
|
if (typeof md !== "string")
|
|
1678
1746
|
return json(res, 400, { error: zh() ? "md \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3002" : "md must be a string." });
|
|
1747
|
+
if (Buffer.byteLength(md) > MAX_MARKDOWN_BYTES)
|
|
1748
|
+
return json(res, 413, { error: zh() ? "\u6587\u6863\u8FC7\u5927\u3002" : "Document too large." });
|
|
1679
1749
|
if (!hasAccess(await license?.state() ?? { pro: false }))
|
|
1680
1750
|
return json(res, 403, { error: "Inkmap trial expired" });
|
|
1681
1751
|
return await serialized(async () => {
|
|
@@ -1707,7 +1777,7 @@ data: ${JSON.stringify(data)}
|
|
|
1707
1777
|
if (!sameOriginWrite())
|
|
1708
1778
|
return json(res, 403, { error: "forbidden" });
|
|
1709
1779
|
const { event } = JSON.parse(await readBody(req));
|
|
1710
|
-
if (typeof event === "string" && event)
|
|
1780
|
+
if (typeof event === "string" && /^[a-z][a-z0-9_]{0,39}$/.test(event))
|
|
1711
1781
|
license?.track?.(event);
|
|
1712
1782
|
return json(res, 200, { ok: true });
|
|
1713
1783
|
}
|
|
@@ -1902,27 +1972,6 @@ function openExternalUrl(url) {
|
|
|
1902
1972
|
execFile(cmd, args, () => {
|
|
1903
1973
|
});
|
|
1904
1974
|
}
|
|
1905
|
-
async function openBrowserWindow2(url) {
|
|
1906
|
-
if (process.env.INKMAP_NO_OPEN === "1" || typeof url !== "string" || !/^http:\/\/127\.0\.0\.1:[0-9]+\//.test(url)) return;
|
|
1907
|
-
const run = (cmd, args) => new Promise((done) => {
|
|
1908
|
-
const child = spawn2(cmd, args, { stdio: "ignore", detached: true });
|
|
1909
|
-
child.on("error", () => done(false));
|
|
1910
|
-
child.on("exit", (code) => done(code === 0));
|
|
1911
|
-
child.unref();
|
|
1912
|
-
});
|
|
1913
|
-
if (process.platform === "darwin") {
|
|
1914
|
-
if (await run("open", ["-a", "Google Chrome", url])) return;
|
|
1915
|
-
await run("open", [url]);
|
|
1916
|
-
return;
|
|
1917
|
-
}
|
|
1918
|
-
if (process.platform === "win32") {
|
|
1919
|
-
if (await run("cmd", ["/c", "start", "", "chrome", url])) return;
|
|
1920
|
-
await run("cmd", ["/c", "start", "", url]);
|
|
1921
|
-
return;
|
|
1922
|
-
}
|
|
1923
|
-
if (await run("google-chrome", [url])) return;
|
|
1924
|
-
await run("xdg-open", [url]);
|
|
1925
|
-
}
|
|
1926
1975
|
function createAntigravitySidecar({
|
|
1927
1976
|
app,
|
|
1928
1977
|
webRoot = defaultWebRoot,
|
|
@@ -2174,7 +2223,7 @@ function createAntigravitySidecar({
|
|
|
2174
2223
|
const served = await browserServed;
|
|
2175
2224
|
await served.switchToFile?.(targetFile, { trustCaller: true }).catch(() => {
|
|
2176
2225
|
});
|
|
2177
|
-
await
|
|
2226
|
+
await openBrowserWindow(served.url);
|
|
2178
2227
|
return { ok: true, url: served.url };
|
|
2179
2228
|
}), "POST");
|
|
2180
2229
|
app.api("/api/view", (data) => serialized(async () => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"args": ["main.mjs"],
|
|
4
4
|
"restart_policy": "always",
|
|
5
5
|
"display_name": "Inkmap",
|
|
6
|
-
"description": "Interactive mind map editor for local Markdown (.md, .markmap.md) outlines with live file write-back in the Antigravity auxiliary pane
|
|
6
|
+
"description": "Interactive mind map editor for local Markdown (.md, .markmap.md) outlines with live file write-back in the Antigravity auxiliary pane.",
|
|
7
7
|
"has_web_ui": true,
|
|
8
8
|
"agent_permissions": {
|
|
9
9
|
"allows_user_interactions": false
|
|
@@ -15,11 +15,6 @@
|
|
|
15
15
|
"path": "/",
|
|
16
16
|
"entrypoint": "SIDECAR_UI_ENTRYPOINT_AUX_PANE",
|
|
17
17
|
"title": "Inkmap"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"path": "/?view=sidebar",
|
|
21
|
-
"entrypoint": "SIDECAR_UI_ENTRYPOINT_SIDEBAR",
|
|
22
|
-
"title": "Inkmap"
|
|
23
18
|
}
|
|
24
19
|
]
|
|
25
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inkmap-codex",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Interactive two-way Markdown mind map (markmap), Mermaid flowchart & XMind outline editor | 双向编辑 Markdown 思维导图、脑图、流程图与大纲",
|
|
5
5
|
"homepage": "https://zhiyuanv.com/software.html",
|
|
6
6
|
"repository": "https://github.com/zhiyuanvision-lang/InkMap",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "inkmap-codex",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.17",
|
|
5
5
|
"description": "Interactive two-way Markdown mind map (markmap), Mermaid flowchart & XMind outline editor | 双向编辑 Markdown 思维导图、脑图、流程图与大纲",
|
|
6
6
|
"homepage": "https://zhiyuanv.com/software.html",
|
|
7
7
|
"repository": "https://github.com/zhiyuanvision-lang/InkMap",
|