inkmap-mcp 0.3.16 → 0.3.18
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 +185 -86
- 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 +182 -61
- package/dist/bundles/harness/package.json +1 -1
- package/dist/bundles/vscode/dist/extension.js +220 -64
- package/dist/bundles/vscode/package.json +6 -1
- package/dist/cli.cjs +322 -135
- package/dist/codex.html +727 -674
- package/dist/web/app.js +24259 -23521
- 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.18",
|
|
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.18";
|
|
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";
|
|
@@ -145,7 +147,7 @@ function billingOrigin(raw) {
|
|
|
145
147
|
}
|
|
146
148
|
return url.origin;
|
|
147
149
|
}
|
|
148
|
-
function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHost = "", waitPollMs = WAIT_FAST_MS } = {}) {
|
|
150
|
+
function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHost = "", waitPollMs = WAIT_FAST_MS, reviewPrompt = true } = {}) {
|
|
149
151
|
const listeners = /* @__PURE__ */ new Set();
|
|
150
152
|
let current = { pro: false };
|
|
151
153
|
let trial;
|
|
@@ -156,7 +158,27 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
156
158
|
let sentAppOpen = false;
|
|
157
159
|
let detectedHost = defaultHost;
|
|
158
160
|
const pendingEvents = /* @__PURE__ */ new Map();
|
|
161
|
+
let reviewDue = false;
|
|
162
|
+
let reviewCounting = Promise.resolve();
|
|
163
|
+
const countForReview = (event, count) => {
|
|
164
|
+
reviewCounting = reviewCounting.then(async () => {
|
|
165
|
+
if (disposed || reviewDue)
|
|
166
|
+
return;
|
|
167
|
+
const usage = await readReviewUsage();
|
|
168
|
+
if (usage.done)
|
|
169
|
+
return;
|
|
170
|
+
if (event === "doc_open")
|
|
171
|
+
usage.opens += count;
|
|
172
|
+
else
|
|
173
|
+
usage.edits += count;
|
|
174
|
+
await writeReviewUsage(usage);
|
|
175
|
+
if (usage.opens >= REVIEW_MIN_OPENS && usage.edits >= REVIEW_MIN_EDITS)
|
|
176
|
+
reviewDue = true;
|
|
177
|
+
}).catch(() => {
|
|
178
|
+
});
|
|
179
|
+
};
|
|
159
180
|
let lastCheck = 0;
|
|
181
|
+
let retryAfter = 0;
|
|
160
182
|
let fastPollUntil = 0;
|
|
161
183
|
const expectPurchase = () => void (fastPollUntil = Date.now() + 15 * 6e4);
|
|
162
184
|
let flowCreation;
|
|
@@ -358,6 +380,24 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
358
380
|
timer = setTimeout(() => void refresh(), delay);
|
|
359
381
|
timer.unref();
|
|
360
382
|
}
|
|
383
|
+
async function rememberProCheck(token, active, account) {
|
|
384
|
+
await writeSession(async () => {
|
|
385
|
+
let record;
|
|
386
|
+
try {
|
|
387
|
+
record = JSON.parse(await storage.read() || "{}");
|
|
388
|
+
} catch {
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
if (record.token !== token)
|
|
392
|
+
return;
|
|
393
|
+
const at = typeof record.proVerifiedAt === "number" ? record.proVerifiedAt : void 0;
|
|
394
|
+
if (active ? at !== void 0 && Date.now() - at < PRO_RECHECK_STAMP_MS && at <= Date.now() : at === void 0)
|
|
395
|
+
return;
|
|
396
|
+
const { proVerifiedAt: _at, proAccount: _account, ...rest } = record;
|
|
397
|
+
await storage.write(JSON.stringify(active ? { ...rest, proVerifiedAt: Date.now(), ...account && { proAccount: account } } : rest));
|
|
398
|
+
}).catch(() => {
|
|
399
|
+
});
|
|
400
|
+
}
|
|
361
401
|
function refresh() {
|
|
362
402
|
if (connection)
|
|
363
403
|
return connection;
|
|
@@ -365,6 +405,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
365
405
|
connection = (async () => {
|
|
366
406
|
let token;
|
|
367
407
|
let delay = 6e4;
|
|
408
|
+
let offlinePro;
|
|
368
409
|
try {
|
|
369
410
|
const origin = billingOrigin(getOrigin());
|
|
370
411
|
if (origin !== activeOrigin) {
|
|
@@ -381,6 +422,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
381
422
|
if (record.origin !== origin || typeof record.token !== "string")
|
|
382
423
|
return update(false);
|
|
383
424
|
token = record.token;
|
|
425
|
+
const verifiedAt = record.proVerifiedAt;
|
|
426
|
+
if (typeof verifiedAt === "number" && verifiedAt <= Date.now() && Date.now() - verifiedAt < OFFLINE_PRO_GRACE_MS) {
|
|
427
|
+
offlinePro = { ...typeof record.proAccount === "string" && { account: record.proAccount.slice(0, 64) } };
|
|
428
|
+
}
|
|
384
429
|
const response = await entitlement(origin, record.token);
|
|
385
430
|
if (version !== generation || disposed)
|
|
386
431
|
return;
|
|
@@ -400,9 +445,14 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
400
445
|
if (version !== generation || disposed)
|
|
401
446
|
return;
|
|
402
447
|
applyEntitlement(state);
|
|
403
|
-
|
|
448
|
+
void rememberProCheck(record.token, current.pro, current.account);
|
|
449
|
+
delay = state.active !== true && (state.pending === true || Date.now() < fastPollUntil) ? 2500 : 6e4;
|
|
404
450
|
} catch {
|
|
405
|
-
if (version === generation
|
|
451
|
+
if (version === generation)
|
|
452
|
+
retryAfter = Date.now() + (Date.now() < fastPollUntil ? 2e3 : 3e4);
|
|
453
|
+
if (version === generation && offlinePro)
|
|
454
|
+
update(true, true, offlinePro.account);
|
|
455
|
+
else if (version === generation && Date.now() - lastCheck > 15 * 6e4)
|
|
406
456
|
update(false);
|
|
407
457
|
} finally {
|
|
408
458
|
if (version === generation && token)
|
|
@@ -441,7 +491,7 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
441
491
|
clearTimeout(waitTimer);
|
|
442
492
|
if (disposed || !waiting.length)
|
|
443
493
|
return;
|
|
444
|
-
waitTimer = setTimeout(() => void checkWaiting(), delay);
|
|
494
|
+
waitTimer = setTimeout(() => void checkWaiting().catch(() => scheduleWait(WAIT_SLOW_MS)), delay);
|
|
445
495
|
waitTimer.unref();
|
|
446
496
|
}
|
|
447
497
|
async function checkWaiting() {
|
|
@@ -482,8 +532,10 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
482
532
|
await writeSession(async () => {
|
|
483
533
|
if (disposed || round !== waitRound || w.origin !== billingOrigin(getOrigin()))
|
|
484
534
|
return;
|
|
485
|
-
|
|
535
|
+
if (w.email)
|
|
536
|
+
lastSignIn = w.email.trim().slice(0, 254);
|
|
486
537
|
await storage.write(sessionRecord({ origin: w.origin, token: w.token }));
|
|
538
|
+
clearWaiting();
|
|
487
539
|
++generation;
|
|
488
540
|
activeOrigin = w.origin;
|
|
489
541
|
applyEntitlement(body);
|
|
@@ -520,6 +572,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
520
572
|
}
|
|
521
573
|
if (typeof record.token !== "string" || typeof record.origin !== "string")
|
|
522
574
|
return;
|
|
575
|
+
if (typeof record.checkoutUrl === "string")
|
|
576
|
+
return;
|
|
523
577
|
const response = await entitlement(record.origin, record.token).catch(() => null);
|
|
524
578
|
if (!response?.ok)
|
|
525
579
|
return;
|
|
@@ -552,13 +606,20 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
552
606
|
return;
|
|
553
607
|
}
|
|
554
608
|
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-"))) {
|
|
609
|
+
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
610
|
return;
|
|
561
611
|
}
|
|
612
|
+
const norm = (p) => {
|
|
613
|
+
const clean = p.replace(/\\/g, "/");
|
|
614
|
+
return process.platform === "win32" ? clean.toLowerCase() : clean;
|
|
615
|
+
};
|
|
616
|
+
const sysTmp = norm(tmpdir()).replace(/\/+$/, "");
|
|
617
|
+
const homesToCheck = [process.env.INKMAP_HOME || "", homedir()].filter(Boolean).map(norm);
|
|
618
|
+
for (const h of homesToCheck) {
|
|
619
|
+
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-")) {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
562
623
|
}
|
|
563
624
|
const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
|
|
564
625
|
if (disposed || !id || !pendingEvents.size)
|
|
@@ -590,12 +651,22 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
590
651
|
});
|
|
591
652
|
}
|
|
592
653
|
return {
|
|
593
|
-
async state() {
|
|
654
|
+
async state(options) {
|
|
594
655
|
await (trial ??= startTrial());
|
|
595
|
-
const interval = !current.pro && Date.now() < fastPollUntil ?
|
|
596
|
-
if (Date.now() - lastCheck >= interval)
|
|
656
|
+
const interval = !current.pro && Date.now() < fastPollUntil ? 2e3 : 6e4;
|
|
657
|
+
if (Date.now() - lastCheck >= interval && Date.now() >= retryAfter)
|
|
597
658
|
await refresh();
|
|
598
659
|
await parkUnpaidSession();
|
|
660
|
+
await reviewCounting;
|
|
661
|
+
if (options?.forUi && reviewDue && hasAccess(current)) {
|
|
662
|
+
reviewDue = false;
|
|
663
|
+
const usage = await readReviewUsage().catch(() => void 0);
|
|
664
|
+
if (usage && !usage.done) {
|
|
665
|
+
await writeReviewUsage({ ...usage, done: true }).catch(() => {
|
|
666
|
+
});
|
|
667
|
+
return { ...current, reviewPrompt: true };
|
|
668
|
+
}
|
|
669
|
+
}
|
|
599
670
|
return current;
|
|
600
671
|
},
|
|
601
672
|
async connect(mode, localeHint) {
|
|
@@ -662,7 +733,9 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
662
733
|
if (cachedOrder && cachedOrder.origin === origin && cachedOrder.locale === loc && Date.now() - cachedOrder.at < 8e3) {
|
|
663
734
|
const hit = cachedOrder.result;
|
|
664
735
|
cachedOrder = void 0;
|
|
665
|
-
|
|
736
|
+
if (current.pro)
|
|
737
|
+
return { status: "active", state: current };
|
|
738
|
+
schedule(hit.status === "qr" || hit.status === "redirect" ? 2500 : 6e4);
|
|
666
739
|
return hit;
|
|
667
740
|
}
|
|
668
741
|
const version = generation;
|
|
@@ -673,6 +746,17 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
673
746
|
record = JSON.parse(stored);
|
|
674
747
|
} catch {
|
|
675
748
|
}
|
|
749
|
+
if (record?.origin === origin && typeof record.token === "string") {
|
|
750
|
+
const rights = await entitlement(origin, record.token).catch(() => null);
|
|
751
|
+
if (rights?.ok) {
|
|
752
|
+
const ent = await rights.json().catch(() => null);
|
|
753
|
+
if (ent && ent.active === true) {
|
|
754
|
+
applyEntitlement(ent);
|
|
755
|
+
schedule(6e4);
|
|
756
|
+
return { status: "active", state: current };
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}
|
|
676
760
|
const requestOrder = async (checkoutUrl, token, cookie, persist) => {
|
|
677
761
|
const res = await checkoutPost(checkoutUrl, "order", origin, {}, token, cookie, localeHint);
|
|
678
762
|
if (res.status === 401 || res.status === 403 || res.status === 404 || res.status === 410)
|
|
@@ -870,13 +954,16 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
870
954
|
if (version !== generation || disposed || origin !== billingOrigin(getOrigin()))
|
|
871
955
|
return phoneFailure();
|
|
872
956
|
clearWaiting();
|
|
957
|
+
const clean = phone.trim().slice(0, 254);
|
|
958
|
+
if (clean)
|
|
959
|
+
lastSignIn = clean;
|
|
873
960
|
await storage.write(sessionRecord({ origin, token, ...checkoutUrl && { checkoutUrl }, ...cookie && { cookie } }));
|
|
874
961
|
++generation;
|
|
875
962
|
activeOrigin = origin;
|
|
876
963
|
applyEntitlement(state);
|
|
877
964
|
if (cachedOrder?.result.status === "active")
|
|
878
965
|
cachedOrder.result.state = current;
|
|
879
|
-
schedule(cachedOrder?.result.status === "qr" ?
|
|
966
|
+
schedule(cachedOrder?.result.status === "qr" || cachedOrder?.result.status === "redirect" ? 2500 : 6e4);
|
|
880
967
|
return { ok: true, value: current };
|
|
881
968
|
});
|
|
882
969
|
} catch {
|
|
@@ -927,6 +1014,8 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
927
1014
|
if (event !== "app_open") {
|
|
928
1015
|
pendingEvents.set(event, Math.min(1e3, (pendingEvents.get(event) ?? 0) + count));
|
|
929
1016
|
}
|
|
1017
|
+
if (reviewPrompt && !process.env.CI && (event === "doc_open" || event === "doc_edit"))
|
|
1018
|
+
countForReview(event, count);
|
|
930
1019
|
if (telemetryTimer)
|
|
931
1020
|
return;
|
|
932
1021
|
telemetryTimer = setTimeout(() => {
|
|
@@ -999,6 +1088,25 @@ async function atomicCreateIfMissing(path, initialContent) {
|
|
|
999
1088
|
return await readFile(path, "utf8");
|
|
1000
1089
|
}
|
|
1001
1090
|
}
|
|
1091
|
+
var REVIEW_MIN_OPENS = 5;
|
|
1092
|
+
var REVIEW_MIN_EDITS = 3;
|
|
1093
|
+
var reviewUsagePath = () => join(process.env.INKMAP_HOME || join(homedir(), ".inkmap"), "review-prompt");
|
|
1094
|
+
async function readReviewUsage() {
|
|
1095
|
+
const count = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : 0;
|
|
1096
|
+
try {
|
|
1097
|
+
const raw = JSON.parse(await readFile(reviewUsagePath(), "utf8"));
|
|
1098
|
+
return { opens: count(raw.opens), edits: count(raw.edits), done: raw.done === true };
|
|
1099
|
+
} catch {
|
|
1100
|
+
return { opens: 0, edits: 0, done: false };
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
async function writeReviewUsage(usage) {
|
|
1104
|
+
const path = reviewUsagePath();
|
|
1105
|
+
await mkdir(dirname(path), { recursive: true, mode: 448 });
|
|
1106
|
+
const temporary = path + "." + randomUUID();
|
|
1107
|
+
await writeFile(temporary, JSON.stringify(usage), { mode: 384 });
|
|
1108
|
+
await rename(temporary, path);
|
|
1109
|
+
}
|
|
1002
1110
|
async function localInstallId() {
|
|
1003
1111
|
const path = join(process.env.INKMAP_HOME || join(homedir(), ".inkmap"), "install-id");
|
|
1004
1112
|
const generated = "inst_" + randomUUID().replace(/-/g, "").slice(0, 24);
|
|
@@ -1029,19 +1137,51 @@ async function localTrialDeadline() {
|
|
|
1029
1137
|
return Number.isSafeInteger(started) && started > 0 && started <= Date.now() ? started + TRIAL_MS : void 0;
|
|
1030
1138
|
}
|
|
1031
1139
|
|
|
1032
|
-
// packages/cli/dist/
|
|
1140
|
+
// packages/cli/dist/open-browser.js
|
|
1033
1141
|
import { spawn } from "node:child_process";
|
|
1142
|
+
function run(cmd, args, launched = false) {
|
|
1143
|
+
return new Promise((done) => {
|
|
1144
|
+
const child = spawn(cmd, args, { stdio: "ignore", detached: true });
|
|
1145
|
+
child.on("error", () => done(false));
|
|
1146
|
+
if (launched)
|
|
1147
|
+
child.on("spawn", () => done(true));
|
|
1148
|
+
else
|
|
1149
|
+
child.on("exit", (code) => done(code === 0));
|
|
1150
|
+
child.unref();
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
async function openBrowserWindow(url) {
|
|
1154
|
+
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url))
|
|
1155
|
+
return;
|
|
1156
|
+
if (process.platform === "darwin") {
|
|
1157
|
+
if (await run("open", ["-a", "Google Chrome", url]))
|
|
1158
|
+
return;
|
|
1159
|
+
await run("open", [url]);
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
if (process.platform === "win32") {
|
|
1163
|
+
if (await run("cmd", ["/c", "start", "", "chrome", url]))
|
|
1164
|
+
return;
|
|
1165
|
+
await run("cmd", ["/c", "start", "", url]);
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
if (await run("google-chrome", [url], true))
|
|
1169
|
+
return;
|
|
1170
|
+
await run("xdg-open", [url], true);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// packages/cli/dist/server.js
|
|
1034
1174
|
import { createHash, randomBytes } from "node:crypto";
|
|
1035
1175
|
import { watch } from "node:fs";
|
|
1036
1176
|
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
1177
|
import { createServer } from "node:http";
|
|
1038
1178
|
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
|
|
1179
|
+
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
1180
|
|
|
1041
1181
|
// packages/cli/dist/workspace-fs.js
|
|
1042
1182
|
import { lstat, readdir, readFile as readFile2, realpath } from "node:fs/promises";
|
|
1043
1183
|
import { homedir as homedir2 } from "node:os";
|
|
1044
|
-
import { basename, delimiter, dirname as dirname2, isAbsolute, join as join2, posix, relative, resolve, sep
|
|
1184
|
+
import { basename, delimiter, dirname as dirname2, isAbsolute, join as join2, posix, relative, resolve, sep, win32 } from "node:path";
|
|
1045
1185
|
import { fileURLToPath } from "node:url";
|
|
1046
1186
|
var say = (zh, en) => detectOsLocale() === "zh" ? zh : en;
|
|
1047
1187
|
var MAX_MARKDOWN_BYTES = 5 * 1024 * 1024;
|
|
@@ -1072,22 +1212,21 @@ function insideOrEqual(root, target) {
|
|
|
1072
1212
|
if (root === target)
|
|
1073
1213
|
return true;
|
|
1074
1214
|
const rel = relative(root, target);
|
|
1075
|
-
return Boolean(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." +
|
|
1215
|
+
return Boolean(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." + sep));
|
|
1076
1216
|
}
|
|
1077
1217
|
function hasHiddenSegment(root, target) {
|
|
1078
1218
|
const rel = relative(root, target);
|
|
1079
1219
|
if (!rel || rel === ".")
|
|
1080
1220
|
return false;
|
|
1081
|
-
return rel.split(
|
|
1221
|
+
return rel.split(sep).some((part) => part.startsWith("."));
|
|
1082
1222
|
}
|
|
1083
1223
|
async function hasSymlinkUnderRoot(realRoot, rawTarget) {
|
|
1084
1224
|
let cur = rawTarget;
|
|
1085
1225
|
while (cur && cur !== dirname2(cur)) {
|
|
1086
|
-
const st = await lstat(cur);
|
|
1087
|
-
if (st.isSymbolicLink())
|
|
1088
|
-
return true;
|
|
1089
1226
|
if (await realpath(cur) === realRoot)
|
|
1090
1227
|
return false;
|
|
1228
|
+
if ((await lstat(cur)).isSymbolicLink())
|
|
1229
|
+
return true;
|
|
1091
1230
|
cur = dirname2(cur);
|
|
1092
1231
|
}
|
|
1093
1232
|
return false;
|
|
@@ -1386,13 +1525,18 @@ async function fileSource(file, log = () => {
|
|
|
1386
1525
|
log(`\u5DF2\u5199\u56DE ${path}`);
|
|
1387
1526
|
},
|
|
1388
1527
|
watch(onChange) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1528
|
+
try {
|
|
1529
|
+
const watcher = watch(dir, (_, changed) => {
|
|
1530
|
+
if (!changed || changed === basename2(path))
|
|
1531
|
+
onChange();
|
|
1532
|
+
});
|
|
1533
|
+
watcher.on("error", () => {
|
|
1534
|
+
});
|
|
1535
|
+
return () => watcher.close();
|
|
1536
|
+
} catch {
|
|
1537
|
+
return () => {
|
|
1538
|
+
};
|
|
1539
|
+
}
|
|
1396
1540
|
},
|
|
1397
1541
|
readView: () => readDiskViewState(path),
|
|
1398
1542
|
writeView: (state) => writeDiskViewState(path, state)
|
|
@@ -1406,37 +1550,12 @@ function within(root, rel, allowAbsoluteInRoot = false) {
|
|
|
1406
1550
|
return null;
|
|
1407
1551
|
}
|
|
1408
1552
|
const resolvedRoot = resolve2(root);
|
|
1409
|
-
const base = resolvedRoot.endsWith(
|
|
1553
|
+
const base = resolvedRoot.endsWith(sep2) ? resolvedRoot : resolvedRoot + sep2;
|
|
1410
1554
|
const full = allowAbsoluteInRoot && /^(?:[\\/]|[A-Za-z]:[\\/])/.test(decoded) ? normalize(decoded) : normalize(join3(resolvedRoot, decoded));
|
|
1411
1555
|
return full.startsWith(base) ? full : null;
|
|
1412
1556
|
}
|
|
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
1557
|
async function serve({ source: initialSource, webRoot, port = 4377, host = "127.0.0.1", log = () => {
|
|
1439
|
-
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false,
|
|
1558
|
+
}, license, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, workspaceRoots = [], confineToWorkspaceRoots = false, openSource = (path) => fileSource(path, log), allowPurchase = true }) {
|
|
1440
1559
|
if (sidebar && host !== "127.0.0.1")
|
|
1441
1560
|
throw new Error("The sidebar bridge requires loopback.");
|
|
1442
1561
|
const prefix = sidebar ? `/s/${randomBytes(24).toString("hex")}/` : "/";
|
|
@@ -1655,7 +1774,6 @@ data: ${JSON.stringify(data)}
|
|
|
1655
1774
|
if (url.pathname === "/api/capabilities" && req.method === "GET") {
|
|
1656
1775
|
return json(res, 200, {
|
|
1657
1776
|
purchase: canPurchase,
|
|
1658
|
-
...ideWorkspace && { ideWorkspace: true },
|
|
1659
1777
|
...sidebarAccountNavigation && { accountNavigation: "host" }
|
|
1660
1778
|
});
|
|
1661
1779
|
}
|
|
@@ -1676,6 +1794,8 @@ data: ${JSON.stringify(data)}
|
|
|
1676
1794
|
const { md, baseVersion } = JSON.parse(await readBody(req));
|
|
1677
1795
|
if (typeof md !== "string")
|
|
1678
1796
|
return json(res, 400, { error: zh() ? "md \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3002" : "md must be a string." });
|
|
1797
|
+
if (Buffer.byteLength(md) > MAX_MARKDOWN_BYTES)
|
|
1798
|
+
return json(res, 413, { error: zh() ? "\u6587\u6863\u8FC7\u5927\u3002" : "Document too large." });
|
|
1679
1799
|
if (!hasAccess(await license?.state() ?? { pro: false }))
|
|
1680
1800
|
return json(res, 403, { error: "Inkmap trial expired" });
|
|
1681
1801
|
return await serialized(async () => {
|
|
@@ -1693,7 +1813,7 @@ data: ${JSON.stringify(data)}
|
|
|
1693
1813
|
});
|
|
1694
1814
|
}
|
|
1695
1815
|
if (url.pathname === "/api/license" && req.method === "GET")
|
|
1696
|
-
return json(res, 200, await license?.state() ?? { pro: false });
|
|
1816
|
+
return json(res, 200, await license?.state({ forUi: true }) ?? { pro: false });
|
|
1697
1817
|
if (url.pathname === "/api/open" && req.method === "POST") {
|
|
1698
1818
|
if (!sameOriginWrite())
|
|
1699
1819
|
return json(res, 403, { error: "forbidden" });
|
|
@@ -1707,7 +1827,7 @@ data: ${JSON.stringify(data)}
|
|
|
1707
1827
|
if (!sameOriginWrite())
|
|
1708
1828
|
return json(res, 403, { error: "forbidden" });
|
|
1709
1829
|
const { event } = JSON.parse(await readBody(req));
|
|
1710
|
-
if (typeof event === "string" && event)
|
|
1830
|
+
if (typeof event === "string" && /^[a-z][a-z0-9_]{0,39}$/.test(event))
|
|
1711
1831
|
license?.track?.(event);
|
|
1712
1832
|
return json(res, 200, { ok: true });
|
|
1713
1833
|
}
|
|
@@ -1902,27 +2022,6 @@ function openExternalUrl(url) {
|
|
|
1902
2022
|
execFile(cmd, args, () => {
|
|
1903
2023
|
});
|
|
1904
2024
|
}
|
|
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
2025
|
function createAntigravitySidecar({
|
|
1927
2026
|
app,
|
|
1928
2027
|
webRoot = defaultWebRoot,
|
|
@@ -2174,7 +2273,7 @@ function createAntigravitySidecar({
|
|
|
2174
2273
|
const served = await browserServed;
|
|
2175
2274
|
await served.switchToFile?.(targetFile, { trustCaller: true }).catch(() => {
|
|
2176
2275
|
});
|
|
2177
|
-
await
|
|
2276
|
+
await openBrowserWindow(served.url);
|
|
2178
2277
|
return { ok: true, url: served.url };
|
|
2179
2278
|
}), "POST");
|
|
2180
2279
|
app.api("/api/view", (data) => serialized(async () => {
|
|
@@ -2189,7 +2288,7 @@ function createAntigravitySidecar({
|
|
|
2189
2288
|
}
|
|
2190
2289
|
return { ok: true };
|
|
2191
2290
|
}), "POST");
|
|
2192
|
-
app.api("/api/license", async () => await license.state(), "GET");
|
|
2291
|
+
app.api("/api/license", async () => await license.state({ forUi: true }), "GET");
|
|
2193
2292
|
app.api("/api/checkout", async (data) => {
|
|
2194
2293
|
const locale = typeof data?.locale === "string" ? data.locale : void 0;
|
|
2195
2294
|
const url = await license.connect("restore", locale);
|
|
@@ -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.18",
|
|
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.18",
|
|
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",
|