inkmap-mcp 0.3.8 → 0.3.10
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 +40 -89
- package/dist/bundles/antigravity/assets/logo.svg +60 -18
- package/dist/bundles/antigravity/rules/AGENTS.md +8 -0
- package/dist/bundles/antigravity/sidecars/inkmap/bridge.js +12 -5
- package/dist/bundles/antigravity/sidecars/inkmap/main.mjs +655 -52
- package/dist/bundles/codex/inkmap-codex/.codex-plugin/plugin.json +1 -1
- package/dist/bundles/codex/inkmap-codex/assets/icon.png +0 -0
- package/dist/bundles/codex/inkmap-codex/plugin.json +1 -1
- package/dist/bundles/harness/README.md +15 -15
- package/dist/bundles/harness/README.zh.md +29 -15
- package/dist/bundles/harness/host.js +128 -47
- package/dist/bundles/harness/icon.svg +60 -18
- package/dist/bundles/harness/package.json +1 -1
- package/dist/bundles/vscode/dist/extension.js +144 -50
- package/dist/bundles/vscode/images/icon.png +0 -0
- package/dist/bundles/vscode/package.json +1 -1
- package/dist/bundles/vscode/package.nls.json +2 -2
- package/dist/bundles/vscode/package.nls.zh-cn.json +2 -2
- package/dist/cli.cjs +475 -102
- package/dist/codex.html +470 -465
- package/dist/web/app.js +29793 -29742
- package/dist/web/index.html +5 -0
- package/package.json +1 -1
- package/server.json +4 -4
package/dist/cli.cjs
CHANGED
|
@@ -48,6 +48,10 @@ function billingFlowUrl(raw, origin, mode, legacy = false) {
|
|
|
48
48
|
function hasAccess(state, now = Date.now()) {
|
|
49
49
|
return state.pro || (state.trialUntil ?? 0) > now;
|
|
50
50
|
}
|
|
51
|
+
function trialDaysLeft(state, now = Date.now()) {
|
|
52
|
+
const remaining = (state.trialUntil ?? 0) - now;
|
|
53
|
+
return remaining > 0 ? Math.ceil(remaining / DAY_MS) : 0;
|
|
54
|
+
}
|
|
51
55
|
function sanitizeAds(input2) {
|
|
52
56
|
if (!Array.isArray(input2))
|
|
53
57
|
return [];
|
|
@@ -83,6 +87,245 @@ var init_product = __esm({
|
|
|
83
87
|
});
|
|
84
88
|
|
|
85
89
|
// packages/core/dist/index.js
|
|
90
|
+
var dist_exports = {};
|
|
91
|
+
__export(dist_exports, {
|
|
92
|
+
DAY_MS: () => DAY_MS,
|
|
93
|
+
PRODUCT: () => PRODUCT,
|
|
94
|
+
TRIAL_MS: () => TRIAL_MS,
|
|
95
|
+
YUNFAN_BILLING_ORIGIN: () => YUNFAN_BILLING_ORIGIN,
|
|
96
|
+
billingFlowUrl: () => billingFlowUrl,
|
|
97
|
+
documentSetting: () => documentSetting,
|
|
98
|
+
hasAccess: () => hasAccess,
|
|
99
|
+
isRich: () => isRich,
|
|
100
|
+
parse: () => parse,
|
|
101
|
+
plainText: () => plainText,
|
|
102
|
+
sanitizeAds: () => sanitizeAds,
|
|
103
|
+
sanitizeViewState: () => sanitizeViewState,
|
|
104
|
+
serialize: () => serialize,
|
|
105
|
+
serializeWithLines: () => serializeWithLines,
|
|
106
|
+
trialDaysLeft: () => trialDaysLeft,
|
|
107
|
+
withDocumentSetting: () => withDocumentSetting
|
|
108
|
+
});
|
|
109
|
+
function parse(markdown, title = "Untitled") {
|
|
110
|
+
const text = markdown.replace(/\r\n?/g, "\n");
|
|
111
|
+
const trailingNewline = text.endsWith("\n");
|
|
112
|
+
const lines = (trailingNewline ? text.slice(0, -1) : text).split("\n");
|
|
113
|
+
let frontMatter = "";
|
|
114
|
+
let i = 0;
|
|
115
|
+
if (lines[0] === "---") {
|
|
116
|
+
const end = lines.indexOf("---", 1);
|
|
117
|
+
if (end > 0) {
|
|
118
|
+
frontMatter = lines.slice(0, end + 1).join("\n") + "\n";
|
|
119
|
+
i = end + 1;
|
|
120
|
+
const t = frontMatter.match(/^title:\s*(.+)$/m);
|
|
121
|
+
if (t)
|
|
122
|
+
title = t[1].trim().replace(/^["']|["']$/g, "");
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const top = { md: title, kind: "heading", level: 0, children: [] };
|
|
126
|
+
const stack = [{ node: top, indent: -1, content: 0, heading: 0 }];
|
|
127
|
+
let blank = 0;
|
|
128
|
+
let leadingBlank = -1;
|
|
129
|
+
let inFence = false;
|
|
130
|
+
let current = null;
|
|
131
|
+
const pendingDividers = [];
|
|
132
|
+
const attach = (node2) => {
|
|
133
|
+
if (pendingDividers.length) {
|
|
134
|
+
node2.dividersBefore = pendingDividers.splice(0);
|
|
135
|
+
}
|
|
136
|
+
if (leadingBlank < 0)
|
|
137
|
+
leadingBlank = blank;
|
|
138
|
+
else if (blank)
|
|
139
|
+
node2.blankBefore = blank;
|
|
140
|
+
blank = 0;
|
|
141
|
+
stack[stack.length - 1].node.children.push(node2);
|
|
142
|
+
};
|
|
143
|
+
for (; i < lines.length; i++) {
|
|
144
|
+
const line = lines[i];
|
|
145
|
+
if (inFence) {
|
|
146
|
+
appendLine(current, line);
|
|
147
|
+
if (FENCE.test(line)) {
|
|
148
|
+
inFence = false;
|
|
149
|
+
if (current?.node.unindentedBlock)
|
|
150
|
+
current = null;
|
|
151
|
+
}
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (isBlank(line)) {
|
|
155
|
+
blank++;
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const indent = indentOf(line);
|
|
159
|
+
const isThematic = THEMATIC_BREAK.test(line);
|
|
160
|
+
if (isThematic && (!current || current.node.kind !== "item" || indent < current.content)) {
|
|
161
|
+
while (stack.length > 1 && stack[stack.length - 1].heading === void 0)
|
|
162
|
+
stack.pop();
|
|
163
|
+
current = null;
|
|
164
|
+
if (leadingBlank < 0) {
|
|
165
|
+
leadingBlank = blank;
|
|
166
|
+
pendingDividers.push({ blankBefore: 0, line });
|
|
167
|
+
} else {
|
|
168
|
+
pendingDividers.push({ blankBefore: blank, line });
|
|
169
|
+
}
|
|
170
|
+
blank = 0;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const item = isThematic ? null : ITEM.exec(line);
|
|
174
|
+
const heading = item ? null : HEADING.exec(line);
|
|
175
|
+
if (current && !item && !heading && (indent >= current.content || !blank && current.node.kind === "item" && indent > 0)) {
|
|
176
|
+
flushBlank(current);
|
|
177
|
+
appendLine(current, line);
|
|
178
|
+
if (FENCE.test(line))
|
|
179
|
+
inFence = true;
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (heading) {
|
|
183
|
+
const level = heading[1].length;
|
|
184
|
+
while (stack.length > 1 && (stack[stack.length - 1].heading === void 0 || stack[stack.length - 1].heading >= level))
|
|
185
|
+
stack.pop();
|
|
186
|
+
const node3 = { md: heading[2], kind: "heading", level, children: [] };
|
|
187
|
+
attach(node3);
|
|
188
|
+
stack.push({ node: node3, indent: -1, content: 0, heading: level });
|
|
189
|
+
current = null;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (item) {
|
|
193
|
+
while (stack.length > 1 && stack[stack.length - 1].heading === void 0 && stack[stack.length - 1].indent >= indent)
|
|
194
|
+
stack.pop();
|
|
195
|
+
const node3 = { md: item[4], kind: "item", marker: item[2], children: [] };
|
|
196
|
+
attach(node3);
|
|
197
|
+
current = { node: node3, indent, content: indent + item[2].length + item[3].length };
|
|
198
|
+
stack.push(current);
|
|
199
|
+
if (FENCE.test(item[4]))
|
|
200
|
+
inFence = true;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (!blank && indent === 0 && FENCE.test(line) && current && current.node.kind === "item") {
|
|
204
|
+
const node3 = { md: line, kind: "block", unindentedBlock: true, children: [] };
|
|
205
|
+
attach(node3);
|
|
206
|
+
current = { node: node3, indent: 0, content: 0 };
|
|
207
|
+
inFence = true;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
while (stack.length > 1 && stack[stack.length - 1].heading === void 0)
|
|
211
|
+
stack.pop();
|
|
212
|
+
const node2 = { md: line.slice(indent), kind: "block", children: [] };
|
|
213
|
+
attach(node2);
|
|
214
|
+
current = { node: node2, indent, content: indent };
|
|
215
|
+
if (FENCE.test(line))
|
|
216
|
+
inFence = true;
|
|
217
|
+
}
|
|
218
|
+
function flushBlank(frame) {
|
|
219
|
+
for (; blank > 0; blank--)
|
|
220
|
+
frame.node.md += "\n";
|
|
221
|
+
}
|
|
222
|
+
function appendLine(frame, line) {
|
|
223
|
+
frame.node.md += "\n" + (isBlank(line) ? "" : line.slice(Math.min(frame.content, indentOf(line))));
|
|
224
|
+
}
|
|
225
|
+
if (leadingBlank < 0)
|
|
226
|
+
leadingBlank = 0;
|
|
227
|
+
const trailingDividers = pendingDividers.length ? pendingDividers.splice(0) : void 0;
|
|
228
|
+
const tops = top.children;
|
|
229
|
+
if (tops.length === 1 && tops[0].kind === "heading") {
|
|
230
|
+
return { frontMatter, leadingBlank, root: tops[0], syntheticRoot: false, trailingNewline, ...trailingDividers && { trailingDividers } };
|
|
231
|
+
}
|
|
232
|
+
return { frontMatter, leadingBlank, root: top, syntheticRoot: true, trailingNewline, ...trailingDividers && { trailingDividers } };
|
|
233
|
+
}
|
|
234
|
+
function serialize(doc) {
|
|
235
|
+
return serializeWithLines(doc).md;
|
|
236
|
+
}
|
|
237
|
+
function serializeWithLines(doc) {
|
|
238
|
+
const out = [];
|
|
239
|
+
const lines = /* @__PURE__ */ new Map();
|
|
240
|
+
const offset = doc.frontMatter ? doc.frontMatter.split("\n").length - 1 : 0;
|
|
241
|
+
const blanks = (n = 0) => {
|
|
242
|
+
for (let k2 = 0; k2 < n; k2++)
|
|
243
|
+
out.push("");
|
|
244
|
+
};
|
|
245
|
+
const pushLines = (first, md, pad) => {
|
|
246
|
+
const [head, ...rest] = md.split("\n");
|
|
247
|
+
out.push(first + head);
|
|
248
|
+
for (const l of rest)
|
|
249
|
+
out.push(l === "" ? "" : pad + l);
|
|
250
|
+
};
|
|
251
|
+
const emitDividers = (divs, skipFirstBlank = false) => {
|
|
252
|
+
if (!divs?.length)
|
|
253
|
+
return false;
|
|
254
|
+
divs.forEach((d2, idx) => {
|
|
255
|
+
if (!(skipFirstBlank && idx === 0))
|
|
256
|
+
blanks(d2.blankBefore);
|
|
257
|
+
out.push(d2.line);
|
|
258
|
+
});
|
|
259
|
+
return true;
|
|
260
|
+
};
|
|
261
|
+
const write = (node2, parent, indent, headingLevel, first = false) => {
|
|
262
|
+
const keepSectionSpacing = parent.kind === "heading" || node2.kind === "item";
|
|
263
|
+
const hadDividers = parent.kind === "heading" ? emitDividers(node2.dividersBefore, first) : false;
|
|
264
|
+
if (!first || hadDividers)
|
|
265
|
+
blanks(keepSectionSpacing ? node2.blankBefore : 0);
|
|
266
|
+
lines.set(node2, offset + out.length);
|
|
267
|
+
if (node2.kind === "heading" && parent.kind === "heading") {
|
|
268
|
+
const level = node2.level && node2.level > headingLevel ? node2.level : headingLevel + 1;
|
|
269
|
+
pushLines("#".repeat(Math.min(level, 6)) + " ", node2.md, "");
|
|
270
|
+
node2.children.forEach((c) => write(c, node2, 0, level));
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (node2.kind === "block" && (parent.kind === "heading" || node2.unindentedBlock)) {
|
|
274
|
+
pushLines("", node2.md, "");
|
|
275
|
+
node2.children.forEach((c) => write(c, node2, 0, headingLevel));
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
const marker = node2.kind === "item" && node2.marker ? node2.marker : "-";
|
|
279
|
+
const pad = " ".repeat(indent);
|
|
280
|
+
pushLines(pad + marker + " ", node2.md, " ".repeat(indent + marker.length + 1));
|
|
281
|
+
node2.children.forEach((c) => write(c, node2, indent + marker.length + 1, headingLevel));
|
|
282
|
+
};
|
|
283
|
+
blanks(doc.leadingBlank);
|
|
284
|
+
if (doc.syntheticRoot) {
|
|
285
|
+
lines.set(doc.root, offset + out.length);
|
|
286
|
+
doc.root.children.forEach((c, k2) => write(c, doc.root, 0, 0, k2 === 0));
|
|
287
|
+
} else {
|
|
288
|
+
const level = doc.root.level || 1;
|
|
289
|
+
if (emitDividers(doc.root.dividersBefore, true)) {
|
|
290
|
+
blanks(doc.root.blankBefore);
|
|
291
|
+
}
|
|
292
|
+
lines.set(doc.root, offset + out.length);
|
|
293
|
+
pushLines("#".repeat(level) + " ", doc.root.md, "");
|
|
294
|
+
doc.root.children.forEach((c) => write(c, doc.root, 0, level));
|
|
295
|
+
}
|
|
296
|
+
emitDividers(doc.trailingDividers, out.length === 0);
|
|
297
|
+
const body = out.join("\n");
|
|
298
|
+
return { md: doc.frontMatter + body + (doc.trailingNewline ? "\n" : ""), lines };
|
|
299
|
+
}
|
|
300
|
+
function isRich(md) {
|
|
301
|
+
return /\n|[`*_\\|<>[\]!~]|\$[^\s$][\s\S]*\$|\$\$[\s\S]+\$\$|^#|^\d+\.\s/.test(md);
|
|
302
|
+
}
|
|
303
|
+
function plainText(md) {
|
|
304
|
+
return md.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/[`*_~]|\\(?=.)/g, "").replace(/\s*\n\s*/g, " ").trim();
|
|
305
|
+
}
|
|
306
|
+
function documentSetting(frontMatter, key) {
|
|
307
|
+
const section = frontMatter.match(SETTINGS_SECTION)?.[1] ?? "";
|
|
308
|
+
const value = section.match(new RegExp(`^[ \\t]+${key}:[ \\t]*(.*)$`, "m"))?.[1].trim();
|
|
309
|
+
return value ? value.replace(/^["']|["']$/g, "") : void 0;
|
|
310
|
+
}
|
|
311
|
+
function withDocumentSetting(frontMatter, key, value) {
|
|
312
|
+
const line = ` ${key}: ${value}
|
|
313
|
+
`;
|
|
314
|
+
if (!frontMatter)
|
|
315
|
+
return `---
|
|
316
|
+
inkmap:
|
|
317
|
+
${line}---
|
|
318
|
+
`;
|
|
319
|
+
const section = frontMatter.match(SETTINGS_SECTION);
|
|
320
|
+
if (!section)
|
|
321
|
+
return frontMatter.replace(/---\n$/, `inkmap:
|
|
322
|
+
${line}---
|
|
323
|
+
`);
|
|
324
|
+
const keyLine = new RegExp(`^[ \\t]+${key}:.*\\n`, "m");
|
|
325
|
+
const body = keyLine.test(section[1]) ? section[1].replace(keyLine, line) : section[1] + line;
|
|
326
|
+
return frontMatter.replace(SETTINGS_SECTION, `inkmap:
|
|
327
|
+
${body}`);
|
|
328
|
+
}
|
|
86
329
|
function sanitizeViewState(raw) {
|
|
87
330
|
if (!raw || typeof raw !== "object")
|
|
88
331
|
return void 0;
|
|
@@ -106,14 +349,30 @@ function sanitizeViewState(raw) {
|
|
|
106
349
|
}
|
|
107
350
|
return folds || view ? { ...folds && { folds }, ...view && { view } } : void 0;
|
|
108
351
|
}
|
|
352
|
+
var THEMATIC_BREAK, ITEM, HEADING, FENCE, indentOf, isBlank, SETTINGS_SECTION;
|
|
109
353
|
var init_dist = __esm({
|
|
110
354
|
"packages/core/dist/index.js"() {
|
|
111
355
|
"use strict";
|
|
112
356
|
init_product();
|
|
357
|
+
THEMATIC_BREAK = /^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
358
|
+
ITEM = /^(\s*)([-*+]|\d+[.)])(\s+)(.*)$/;
|
|
359
|
+
HEADING = /^(#{1,6})\s+(.*?)\s*#*\s*$/;
|
|
360
|
+
FENCE = /^\s*(```|~~~)/;
|
|
361
|
+
indentOf = (line) => line.length - line.trimStart().length;
|
|
362
|
+
isBlank = (line) => line.trim() === "";
|
|
363
|
+
SETTINGS_SECTION = /^inkmap:[ \t]*\n((?:[ \t]+.*\n)*)/m;
|
|
113
364
|
}
|
|
114
365
|
});
|
|
115
366
|
|
|
116
367
|
// packages/cli/dist/license.js
|
|
368
|
+
var license_exports = {};
|
|
369
|
+
__export(license_exports, {
|
|
370
|
+
adFeed: () => adFeed,
|
|
371
|
+
billingOrigin: () => billingOrigin,
|
|
372
|
+
detectOsLocale: () => detectOsLocale,
|
|
373
|
+
fileSessionStorage: () => fileSessionStorage,
|
|
374
|
+
licenseService: () => licenseService
|
|
375
|
+
});
|
|
117
376
|
function detectOsLocale() {
|
|
118
377
|
const explicit = (process.env.INKMAP_LOCALE || "").trim();
|
|
119
378
|
if (/^zh\b/i.test(explicit))
|
|
@@ -449,6 +708,52 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
449
708
|
};
|
|
450
709
|
poll();
|
|
451
710
|
}
|
|
711
|
+
async function sendPendingTelemetry() {
|
|
712
|
+
if (disposed || !pendingEvents.size)
|
|
713
|
+
return;
|
|
714
|
+
let origin;
|
|
715
|
+
try {
|
|
716
|
+
origin = billingOrigin(getOrigin());
|
|
717
|
+
} catch {
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (process.env.INKMAP_ALLOW_TEST_TELEMETRY !== "1") {
|
|
721
|
+
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT)
|
|
722
|
+
return;
|
|
723
|
+
const customHome = process.env.INKMAP_HOME || "";
|
|
724
|
+
if (customHome && (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-"))) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
|
|
729
|
+
if (disposed || !id || !pendingEvents.size)
|
|
730
|
+
return;
|
|
731
|
+
await (trial ??= startTrial());
|
|
732
|
+
const events = {};
|
|
733
|
+
for (const [k2, v2] of pendingEvents.entries())
|
|
734
|
+
events[k2] = v2;
|
|
735
|
+
pendingEvents.clear();
|
|
736
|
+
const tier = current.pro ? "pro" : (current.trialUntil ?? 0) > Date.now() ? "trial" : "expired";
|
|
737
|
+
const os = process.platform === "darwin" ? "mac" : process.platform === "win32" ? "win" : process.platform === "linux" ? "linux" : "other";
|
|
738
|
+
const hostName = detectedHost || inferNodeHost();
|
|
739
|
+
await fetch(origin + "/billing/v1/telemetry", {
|
|
740
|
+
method: "POST",
|
|
741
|
+
headers: { "content-type": "application/json" },
|
|
742
|
+
redirect: "error",
|
|
743
|
+
body: JSON.stringify({
|
|
744
|
+
product: PRODUCT.id,
|
|
745
|
+
installId: id,
|
|
746
|
+
host: hostName,
|
|
747
|
+
os,
|
|
748
|
+
version: "0.3.10",
|
|
749
|
+
locale: clientLocale(),
|
|
750
|
+
tier,
|
|
751
|
+
events
|
|
752
|
+
}),
|
|
753
|
+
signal: AbortSignal.timeout(5e3)
|
|
754
|
+
}).catch(() => {
|
|
755
|
+
});
|
|
756
|
+
}
|
|
452
757
|
return {
|
|
453
758
|
async state() {
|
|
454
759
|
await (trial ??= startTrial());
|
|
@@ -764,55 +1069,17 @@ function licenseService(storage, getOrigin, { loginOnly = false, host: defaultHo
|
|
|
764
1069
|
return;
|
|
765
1070
|
telemetryTimer = setTimeout(() => {
|
|
766
1071
|
telemetryTimer = void 0;
|
|
767
|
-
void (
|
|
768
|
-
if (disposed || !pendingEvents.size)
|
|
769
|
-
return;
|
|
770
|
-
let origin;
|
|
771
|
-
try {
|
|
772
|
-
origin = billingOrigin(getOrigin());
|
|
773
|
-
} catch {
|
|
774
|
-
return;
|
|
775
|
-
}
|
|
776
|
-
if (process.env.INKMAP_ALLOW_TEST_TELEMETRY !== "1") {
|
|
777
|
-
if (origin === "https://billing.example.com" || process.env.INKMAP_DISABLE_TELEMETRY === "1" || process.env.NODE_TEST_CONTEXT)
|
|
778
|
-
return;
|
|
779
|
-
const customHome = process.env.INKMAP_HOME || "";
|
|
780
|
-
if (customHome && (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-"))) {
|
|
781
|
-
return;
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
const id = await (installIdPromise ??= localInstallId().catch(() => void 0));
|
|
785
|
-
if (disposed || !id || !pendingEvents.size)
|
|
786
|
-
return;
|
|
787
|
-
await (trial ??= startTrial());
|
|
788
|
-
const events = {};
|
|
789
|
-
for (const [k2, v2] of pendingEvents.entries())
|
|
790
|
-
events[k2] = v2;
|
|
791
|
-
pendingEvents.clear();
|
|
792
|
-
const tier = current.pro ? "pro" : (current.trialUntil ?? 0) > Date.now() ? "trial" : "expired";
|
|
793
|
-
const os = process.platform === "darwin" ? "mac" : process.platform === "win32" ? "win" : process.platform === "linux" ? "linux" : "other";
|
|
794
|
-
const hostName = detectedHost || inferNodeHost();
|
|
795
|
-
await fetch(origin + "/billing/v1/telemetry", {
|
|
796
|
-
method: "POST",
|
|
797
|
-
headers: { "content-type": "application/json" },
|
|
798
|
-
redirect: "error",
|
|
799
|
-
body: JSON.stringify({
|
|
800
|
-
product: PRODUCT.id,
|
|
801
|
-
installId: id,
|
|
802
|
-
host: hostName,
|
|
803
|
-
os,
|
|
804
|
-
version: "0.3.8",
|
|
805
|
-
locale: clientLocale(),
|
|
806
|
-
tier,
|
|
807
|
-
events
|
|
808
|
-
}),
|
|
809
|
-
signal: AbortSignal.timeout(5e3)
|
|
810
|
-
}).catch(() => {
|
|
811
|
-
});
|
|
812
|
-
})();
|
|
1072
|
+
void sendPendingTelemetry();
|
|
813
1073
|
}, 800);
|
|
814
1074
|
telemetryTimer.unref();
|
|
815
1075
|
},
|
|
1076
|
+
async flushTelemetry() {
|
|
1077
|
+
if (telemetryTimer) {
|
|
1078
|
+
clearTimeout(telemetryTimer);
|
|
1079
|
+
telemetryTimer = void 0;
|
|
1080
|
+
}
|
|
1081
|
+
await sendPendingTelemetry();
|
|
1082
|
+
},
|
|
816
1083
|
dispose() {
|
|
817
1084
|
disposed = true;
|
|
818
1085
|
stopMagicPoll();
|
|
@@ -835,6 +1102,10 @@ function inferNodeHost() {
|
|
|
835
1102
|
return "cursor";
|
|
836
1103
|
if (app.includes("windsurf"))
|
|
837
1104
|
return "windsurf";
|
|
1105
|
+
if (app.includes("trae"))
|
|
1106
|
+
return "trae";
|
|
1107
|
+
if (app.includes("qoder"))
|
|
1108
|
+
return "qoder";
|
|
838
1109
|
return "vscode";
|
|
839
1110
|
}
|
|
840
1111
|
return "cli";
|
|
@@ -1057,12 +1328,38 @@ function within(root, rel) {
|
|
|
1057
1328
|
const full = (0, import_node_path2.normalize)((0, import_node_path2.join)(root, decodeURIComponent(rel)));
|
|
1058
1329
|
return full.startsWith(base) ? full : null;
|
|
1059
1330
|
}
|
|
1331
|
+
async function openBrowserWindow(url2) {
|
|
1332
|
+
if (process.env.INKMAP_NO_OPEN === "1" || !/^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):[0-9]+\//.test(url2))
|
|
1333
|
+
return;
|
|
1334
|
+
const run = (cmd, args) => new Promise((done) => {
|
|
1335
|
+
const child = (0, import_node_child_process2.spawn)(cmd, args, { stdio: "ignore", detached: true });
|
|
1336
|
+
child.on("error", () => done(false));
|
|
1337
|
+
child.on("exit", (code) => done(code === 0));
|
|
1338
|
+
child.unref();
|
|
1339
|
+
});
|
|
1340
|
+
if (process.platform === "darwin") {
|
|
1341
|
+
if (await run("open", ["-a", "Google Chrome", url2]))
|
|
1342
|
+
return;
|
|
1343
|
+
await run("open", [url2]);
|
|
1344
|
+
return;
|
|
1345
|
+
}
|
|
1346
|
+
if (process.platform === "win32") {
|
|
1347
|
+
if (await run("cmd", ["/c", "start", "", "chrome", url2]))
|
|
1348
|
+
return;
|
|
1349
|
+
await run("cmd", ["/c", "start", "", url2]);
|
|
1350
|
+
return;
|
|
1351
|
+
}
|
|
1352
|
+
if (await run("google-chrome", [url2]))
|
|
1353
|
+
return;
|
|
1354
|
+
await run("xdg-open", [url2]);
|
|
1355
|
+
}
|
|
1060
1356
|
async function serve({ source: initialSource, webRoot, port = 4377, host = "127.0.0.1", log = () => {
|
|
1061
1357
|
}, license, ads, sidebar = false, sidebarPurchase = false, sidebarAccountNavigation = false, loginOnly = false, ideWorkspace = false, workspaceRoots = [] }) {
|
|
1062
1358
|
if (sidebar && host !== "127.0.0.1")
|
|
1063
1359
|
throw new Error("The sidebar bridge requires loopback.");
|
|
1064
1360
|
const prefix = sidebar ? `/s/${(0, import_node_crypto2.randomBytes)(24).toString("hex")}/` : "/";
|
|
1065
1361
|
let activeSource = initialSource;
|
|
1362
|
+
let browserCompanion = null;
|
|
1066
1363
|
let bound;
|
|
1067
1364
|
let current = await activeSource.read();
|
|
1068
1365
|
let version2 = hash(current);
|
|
@@ -1308,6 +1605,44 @@ data: ${JSON.stringify(data)}
|
|
|
1308
1605
|
license?.track?.(event);
|
|
1309
1606
|
return json2(res, 200, { ok: true });
|
|
1310
1607
|
}
|
|
1608
|
+
if (url2.pathname === "/api/open-browser" && req.method === "POST") {
|
|
1609
|
+
if (!sameOriginPost())
|
|
1610
|
+
return json2(res, 403, { error: "forbidden" });
|
|
1611
|
+
if (license && !hasAccess(await license.state())) {
|
|
1612
|
+
return json2(res, 402, { error: detectOsLocale() === "zh" ? "\u514D\u8D39\u8BD5\u7528\u5DF2\u5230\u671F\uFF0C\u8BF7\u5148\u89E3\u9501\u6216\u6062\u590D Pro\u3002" : "Trial expired. Unlock or restore Pro first." });
|
|
1613
|
+
}
|
|
1614
|
+
license?.track?.("feature_browser");
|
|
1615
|
+
if (!sidebar) {
|
|
1616
|
+
const directUrl = `http://${host}:${bound}/`;
|
|
1617
|
+
await openBrowserWindow(directUrl);
|
|
1618
|
+
return json2(res, 200, { ok: true, url: directUrl });
|
|
1619
|
+
}
|
|
1620
|
+
if (!browserCompanion) {
|
|
1621
|
+
browserCompanion = (async () => {
|
|
1622
|
+
const src = activeSource.key ? await fileSource(activeSource.key) : activeSource;
|
|
1623
|
+
return serve({
|
|
1624
|
+
source: src,
|
|
1625
|
+
webRoot,
|
|
1626
|
+
host: "127.0.0.1",
|
|
1627
|
+
port: 0,
|
|
1628
|
+
license,
|
|
1629
|
+
ads,
|
|
1630
|
+
sidebar: false,
|
|
1631
|
+
loginOnly: false,
|
|
1632
|
+
workspaceRoots
|
|
1633
|
+
});
|
|
1634
|
+
})();
|
|
1635
|
+
browserCompanion.catch(() => {
|
|
1636
|
+
browserCompanion = null;
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
const companion = await browserCompanion;
|
|
1640
|
+
if (activeSource.key)
|
|
1641
|
+
await companion.switchToFile?.(activeSource.key).catch(() => {
|
|
1642
|
+
});
|
|
1643
|
+
await openBrowserWindow(companion.url);
|
|
1644
|
+
return json2(res, 200, { ok: true, url: companion.url });
|
|
1645
|
+
}
|
|
1311
1646
|
if (url2.pathname === "/api/checkout" && req.method === "POST") {
|
|
1312
1647
|
if (!sameOriginPost())
|
|
1313
1648
|
return json2(res, 403, { error: "forbidden" });
|
|
@@ -1401,17 +1736,21 @@ data: ${JSON.stringify(data)}
|
|
|
1401
1736
|
clearTimeout(pending);
|
|
1402
1737
|
unwatch();
|
|
1403
1738
|
unlisten();
|
|
1739
|
+
if (browserCompanion)
|
|
1740
|
+
void browserCompanion.then((s) => s.close()).catch(() => {
|
|
1741
|
+
});
|
|
1404
1742
|
for (const res of clients)
|
|
1405
1743
|
res.end();
|
|
1406
1744
|
server.close(() => done());
|
|
1407
1745
|
})
|
|
1408
1746
|
};
|
|
1409
1747
|
}
|
|
1410
|
-
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;
|
|
1748
|
+
var import_node_child_process2, import_node_crypto2, import_node_fs, import_promises2, import_node_http, import_node_os2, import_node_path2, SKIP_SCAN_DIRS, MAX_BODY, TYPES, hash;
|
|
1411
1749
|
var init_server = __esm({
|
|
1412
1750
|
"packages/cli/dist/server.js"() {
|
|
1413
1751
|
"use strict";
|
|
1414
1752
|
init_dist();
|
|
1753
|
+
import_node_child_process2 = require("node:child_process");
|
|
1415
1754
|
import_node_crypto2 = require("node:crypto");
|
|
1416
1755
|
import_node_fs = require("node:fs");
|
|
1417
1756
|
import_promises2 = require("node:fs/promises");
|
|
@@ -6648,7 +6987,7 @@ function validateFallback(schema, value, _ctx) {
|
|
|
6648
6987
|
}
|
|
6649
6988
|
return result.issues.length === 0;
|
|
6650
6989
|
}
|
|
6651
|
-
var _parse,
|
|
6990
|
+
var _parse, parse2, _parseAsync, parseAsync, _safeParse, safeParse, _safeParseAsync, safeParseAsync, COMPILE_INVALID, COMPILE_FALLBACK, validate, validateAsync, _encode, encode, _decode, decode, _encodeAsync, encodeAsync, _decodeAsync, decodeAsync, _safeEncode, safeEncode, _safeDecode, safeDecode, _safeEncodeAsync, safeEncodeAsync, _safeDecodeAsync, safeDecodeAsync;
|
|
6652
6991
|
var init_parse = __esm({
|
|
6653
6992
|
"node_modules/zod/v4/core/parse.js"() {
|
|
6654
6993
|
init_core();
|
|
@@ -6670,7 +7009,7 @@ var init_parse = __esm({
|
|
|
6670
7009
|
};
|
|
6671
7010
|
return fn;
|
|
6672
7011
|
};
|
|
6673
|
-
|
|
7012
|
+
parse2 = /* @__PURE__ */ _parse($ZodRealError);
|
|
6674
7013
|
_parseAsync = (_Err) => {
|
|
6675
7014
|
const fn = async (schema, value, _ctx, params) => {
|
|
6676
7015
|
const ctx = _ctx ? { ..._ctx, async: true } : { async: true };
|
|
@@ -6724,18 +7063,18 @@ var init_parse = __esm({
|
|
|
6724
7063
|
return result.issues.length === 0;
|
|
6725
7064
|
};
|
|
6726
7065
|
_encode = (_Err) => {
|
|
6727
|
-
const
|
|
7066
|
+
const parse4 = _parse(_Err);
|
|
6728
7067
|
const fn = (schema, value, _ctx, _params) => {
|
|
6729
7068
|
const ctx = _ctx ? { ..._ctx, direction: "backward" } : { direction: "backward" };
|
|
6730
|
-
return
|
|
7069
|
+
return parse4(schema, value, ctx, finalizeParams(fn, _params));
|
|
6731
7070
|
};
|
|
6732
7071
|
return fn;
|
|
6733
7072
|
};
|
|
6734
7073
|
encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
6735
7074
|
_decode = (_Err) => {
|
|
6736
|
-
const
|
|
7075
|
+
const parse4 = _parse(_Err);
|
|
6737
7076
|
const fn = (schema, value, _ctx, _params) => {
|
|
6738
|
-
return
|
|
7077
|
+
return parse4(schema, value, _ctx, finalizeParams(fn, _params));
|
|
6739
7078
|
};
|
|
6740
7079
|
return fn;
|
|
6741
7080
|
};
|
|
@@ -7660,7 +7999,7 @@ function capSize(inst, size) {
|
|
|
7660
7999
|
if (!caps.length)
|
|
7661
8000
|
return;
|
|
7662
8001
|
const cap = Math.min(...caps.map((c) => c[0]));
|
|
7663
|
-
const
|
|
8002
|
+
const parse4 = inst._zod.parse;
|
|
7664
8003
|
inst._zod.parse = (payload, ctx) => {
|
|
7665
8004
|
const n = size(payload.value);
|
|
7666
8005
|
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
@@ -7674,7 +8013,7 @@ function capSize(inst, size) {
|
|
|
7674
8013
|
}
|
|
7675
8014
|
}
|
|
7676
8015
|
}
|
|
7677
|
-
return
|
|
8016
|
+
return parse4(payload, ctx);
|
|
7678
8017
|
};
|
|
7679
8018
|
}
|
|
7680
8019
|
function handleArrayResult(result, final, index) {
|
|
@@ -9843,10 +10182,10 @@ var init_schemas = __esm({
|
|
|
9843
10182
|
throw new Error("implement() must be called with a function");
|
|
9844
10183
|
}
|
|
9845
10184
|
return Object.defineProperty(function(...args) {
|
|
9846
|
-
const parsedArgs = inst._def.input ?
|
|
10185
|
+
const parsedArgs = inst._def.input ? parse2(inst._def.input, args) : args;
|
|
9847
10186
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
9848
10187
|
if (inst._def.output) {
|
|
9849
|
-
return
|
|
10188
|
+
return parse2(inst._def.output, result);
|
|
9850
10189
|
}
|
|
9851
10190
|
return result;
|
|
9852
10191
|
}, "_zod", { value: inst._zod, enumerable: false });
|
|
@@ -22661,7 +23000,7 @@ __export(core_exports2, {
|
|
|
22661
23000
|
memoizer: () => memoizer,
|
|
22662
23001
|
mergeValues: () => mergeValues2,
|
|
22663
23002
|
meta: () => meta,
|
|
22664
|
-
parse: () =>
|
|
23003
|
+
parse: () => parse2,
|
|
22665
23004
|
parseAsync: () => parseAsync,
|
|
22666
23005
|
parseURLObject: () => parseURLObject,
|
|
22667
23006
|
prettifyError: () => prettifyError,
|
|
@@ -22752,7 +23091,7 @@ var init_schemas2 = __esm({
|
|
|
22752
23091
|
own(this, "with", value);
|
|
22753
23092
|
},
|
|
22754
23093
|
parse(data, params) {
|
|
22755
|
-
return
|
|
23094
|
+
return parse2(this, data, params, { callee: this.parse });
|
|
22756
23095
|
},
|
|
22757
23096
|
parseAsync(data, params) {
|
|
22758
23097
|
return parseAsync(this, data, params, { callee: this.parseAsync });
|
|
@@ -23257,13 +23596,13 @@ var init_errors3 = __esm({
|
|
|
23257
23596
|
});
|
|
23258
23597
|
|
|
23259
23598
|
// node_modules/zod/v4/classic/parse.js
|
|
23260
|
-
var
|
|
23599
|
+
var parse3, parseAsync2, safeParse3, safeParseAsync3, encode2, decode2, encodeAsync2, decodeAsync2, safeEncode2, safeDecode2, safeEncodeAsync2, safeDecodeAsync2;
|
|
23261
23600
|
var init_parse3 = __esm({
|
|
23262
23601
|
"node_modules/zod/v4/classic/parse.js"() {
|
|
23263
23602
|
init_core2();
|
|
23264
23603
|
init_errors3();
|
|
23265
23604
|
init_core2();
|
|
23266
|
-
|
|
23605
|
+
parse3 = /* @__PURE__ */ _parse(ZodRealError);
|
|
23267
23606
|
parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
23268
23607
|
safeParse3 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
23269
23608
|
safeParseAsync3 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
@@ -24076,7 +24415,7 @@ var init_schemas3 = __esm({
|
|
|
24076
24415
|
util_exports.own(this, "~standard", value);
|
|
24077
24416
|
},
|
|
24078
24417
|
parse: function _parse2(data, params) {
|
|
24079
|
-
return
|
|
24418
|
+
return parse3(this, data, params, { callee: _parse2 });
|
|
24080
24419
|
},
|
|
24081
24420
|
parseAsync: async function _parseAsync2(data, params) {
|
|
24082
24421
|
return await parseAsync2(this, data, params, { callee: _parseAsync2 });
|
|
@@ -26025,7 +26364,7 @@ __export(external_exports, {
|
|
|
26025
26364
|
optional: () => optional,
|
|
26026
26365
|
output: () => output,
|
|
26027
26366
|
overwrite: () => _overwrite,
|
|
26028
|
-
parse: () =>
|
|
26367
|
+
parse: () => parse3,
|
|
26029
26368
|
parseAsync: () => parseAsync2,
|
|
26030
26369
|
partialRecord: () => partialRecord,
|
|
26031
26370
|
pipe: () => pipe,
|
|
@@ -34115,7 +34454,7 @@ var require_fast_uri = __commonJS({
|
|
|
34115
34454
|
normalizeString(uri, options);
|
|
34116
34455
|
} else if (typeof uri === "object") {
|
|
34117
34456
|
uri = /** @type {T} */
|
|
34118
|
-
|
|
34457
|
+
parse4(serialize2(uri, options), options);
|
|
34119
34458
|
}
|
|
34120
34459
|
return uri;
|
|
34121
34460
|
}
|
|
@@ -34153,13 +34492,13 @@ var require_fast_uri = __commonJS({
|
|
|
34153
34492
|
throw new Error(resolved.error);
|
|
34154
34493
|
}
|
|
34155
34494
|
schemelessOptions.skipEscape = true;
|
|
34156
|
-
return
|
|
34495
|
+
return serialize2(resolved, schemelessOptions);
|
|
34157
34496
|
}
|
|
34158
34497
|
function resolveComponent(base, relative3, options, skipNormalization) {
|
|
34159
34498
|
const target = {};
|
|
34160
34499
|
if (!skipNormalization) {
|
|
34161
|
-
base =
|
|
34162
|
-
relative3 =
|
|
34500
|
+
base = parse4(serialize2(base, options), options);
|
|
34501
|
+
relative3 = parse4(serialize2(relative3, options), options);
|
|
34163
34502
|
}
|
|
34164
34503
|
options = options || {};
|
|
34165
34504
|
if (!options.tolerant && relative3.scheme) {
|
|
@@ -34214,7 +34553,7 @@ var require_fast_uri = __commonJS({
|
|
|
34214
34553
|
const normalizedB = normalizeComparableURI(uriB, options);
|
|
34215
34554
|
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
|
|
34216
34555
|
}
|
|
34217
|
-
function
|
|
34556
|
+
function serialize2(cmpts, opts) {
|
|
34218
34557
|
const component = {
|
|
34219
34558
|
host: cmpts.host,
|
|
34220
34559
|
scheme: cmpts.scheme,
|
|
@@ -34477,7 +34816,7 @@ var require_fast_uri = __commonJS({
|
|
|
34477
34816
|
}
|
|
34478
34817
|
return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
|
|
34479
34818
|
}
|
|
34480
|
-
function
|
|
34819
|
+
function parse4(uri, opts) {
|
|
34481
34820
|
return parseWithStatus(uri, opts).parsed;
|
|
34482
34821
|
}
|
|
34483
34822
|
function normalizeString(uri, opts) {
|
|
@@ -34486,7 +34825,7 @@ var require_fast_uri = __commonJS({
|
|
|
34486
34825
|
function normalizeStringWithStatus(uri, opts) {
|
|
34487
34826
|
const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
|
|
34488
34827
|
return {
|
|
34489
|
-
normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri :
|
|
34828
|
+
normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize2(parsed, opts),
|
|
34490
34829
|
malformedAuthorityOrPort,
|
|
34491
34830
|
malformedPercentEncoding,
|
|
34492
34831
|
malformedSchemeSpecific,
|
|
@@ -34500,7 +34839,7 @@ var require_fast_uri = __commonJS({
|
|
|
34500
34839
|
}
|
|
34501
34840
|
let value;
|
|
34502
34841
|
try {
|
|
34503
|
-
value = typeof uri === "string" ? uri :
|
|
34842
|
+
value = typeof uri === "string" ? uri : serialize2(uri, opts);
|
|
34504
34843
|
} catch {
|
|
34505
34844
|
return void 0;
|
|
34506
34845
|
}
|
|
@@ -34513,8 +34852,8 @@ var require_fast_uri = __commonJS({
|
|
|
34513
34852
|
resolve: resolve5,
|
|
34514
34853
|
resolveComponent,
|
|
34515
34854
|
equal,
|
|
34516
|
-
serialize,
|
|
34517
|
-
parse:
|
|
34855
|
+
serialize: serialize2,
|
|
34856
|
+
parse: parse4
|
|
34518
34857
|
};
|
|
34519
34858
|
module2.exports = fastUri;
|
|
34520
34859
|
module2.exports.default = fastUri;
|
|
@@ -39657,11 +39996,13 @@ function createMcpWorkspaceManager() {
|
|
|
39657
39996
|
throw new Error("\u4E0D\u652F\u6301\u7B26\u53F7\u94FE\u63A5\u6216\u975E Markdown \u6587\u4EF6\u3002");
|
|
39658
39997
|
}
|
|
39659
39998
|
const home = await (0, import_promises3.realpath)((0, import_node_os3.homedir)()).catch(() => (0, import_node_os3.homedir)());
|
|
39660
|
-
|
|
39999
|
+
const brainRoot = await (0, import_promises3.realpath)((0, import_node_path3.join)(home, ".gemini", "antigravity", "brain")).catch(() => null);
|
|
40000
|
+
const inBrainArtifact = Boolean(brainRoot && insideOrEqual(brainRoot, real) && !hasHiddenSegment(brainRoot, real));
|
|
40001
|
+
if (!inBrainArtifact && insideOrEqual(home, real) && hasHiddenSegment(home, real)) {
|
|
39661
40002
|
throw new Error("\u4E0D\u652F\u6301\u8BBF\u95EE\u9690\u85CF\u914D\u7F6E\u76EE\u5F55\u4E2D\u7684\u6587\u4EF6\u3002");
|
|
39662
40003
|
}
|
|
39663
40004
|
const matchedRoot = roots.find((r2) => insideOrEqual(r2.path, real));
|
|
39664
|
-
const permitted = target && target.file === real || Boolean(matchedRoot);
|
|
40005
|
+
const permitted = inBrainArtifact || target && target.file === real || Boolean(matchedRoot);
|
|
39665
40006
|
if (!permitted) {
|
|
39666
40007
|
if (!allowRegisterFromModel) {
|
|
39667
40008
|
throw new Error("\u8BE5\u6587\u4EF6\u4E0D\u5728\u5F53\u524D\u5141\u8BB8\u7684\u5DE5\u4F5C\u533A\u6216\u9879\u76EE\u76EE\u5F55\u5185\u3002");
|
|
@@ -39899,11 +40240,14 @@ __export(codex_exports, {
|
|
|
39899
40240
|
createInkmapMcpServer: () => createInkmapMcpServer,
|
|
39900
40241
|
serveCodex: () => serveCodex
|
|
39901
40242
|
});
|
|
40243
|
+
function resolveWebRoot() {
|
|
40244
|
+
return WEB_ROOT_CANDIDATES.find((dir) => (0, import_node_fs2.existsSync)((0, import_node_path4.join)(dir, "index.html"))) ?? null;
|
|
40245
|
+
}
|
|
39902
40246
|
function openSystemBrowser(url2) {
|
|
39903
40247
|
if (process.env.INKMAP_NO_OPEN === "1")
|
|
39904
40248
|
return;
|
|
39905
40249
|
const [cmd, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
39906
|
-
(0,
|
|
40250
|
+
(0, import_node_child_process3.spawn)(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
39907
40251
|
}
|
|
39908
40252
|
async function createInkmapMcpServer(options = {}) {
|
|
39909
40253
|
const loadHtml = async () => {
|
|
@@ -39923,7 +40267,7 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39923
40267
|
const fallbackEditors = /* @__PURE__ */ new Map();
|
|
39924
40268
|
const ads = adFeed(PRODUCT.adFeedUrl);
|
|
39925
40269
|
const workspaces = createMcpWorkspaceManager();
|
|
39926
|
-
const server = new McpServer({ name: "inkmap", version: "0.3.
|
|
40270
|
+
const server = new McpServer({ name: "inkmap", version: "0.3.10" });
|
|
39927
40271
|
function isAntigravityHost() {
|
|
39928
40272
|
const clientName = server.server.getClientVersion()?.name ?? "";
|
|
39929
40273
|
if (/antigravity/i.test(clientName))
|
|
@@ -39946,8 +40290,17 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39946
40290
|
return "codex";
|
|
39947
40291
|
if (clientName.includes("windsurf"))
|
|
39948
40292
|
return "windsurf";
|
|
40293
|
+
if (clientName.includes("trae"))
|
|
40294
|
+
return "trae";
|
|
40295
|
+
if (clientName.includes("qoder"))
|
|
40296
|
+
return "qoder";
|
|
40297
|
+
if (clientName.includes("deepseek") || clientName.includes("dsh"))
|
|
40298
|
+
return "deepseek";
|
|
39949
40299
|
return "mcp";
|
|
39950
40300
|
}
|
|
40301
|
+
server.server.oninitialized = () => {
|
|
40302
|
+
billing.track?.("plugin_activate", 1, detectMcpHost());
|
|
40303
|
+
};
|
|
39951
40304
|
function hasIdeEditorExtension() {
|
|
39952
40305
|
const clientName = server.server.getClientVersion()?.name ?? "";
|
|
39953
40306
|
let extDir = null;
|
|
@@ -39990,7 +40343,8 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39990
40343
|
return false;
|
|
39991
40344
|
}
|
|
39992
40345
|
async function openFallbackBrowserEditor(filePath, launchSystemBrowser = true) {
|
|
39993
|
-
|
|
40346
|
+
const webRoot = resolveWebRoot();
|
|
40347
|
+
if (!webRoot)
|
|
39994
40348
|
return void 0;
|
|
39995
40349
|
let pending = fallbackEditors.get("__workspace__");
|
|
39996
40350
|
if (!pending) {
|
|
@@ -39999,13 +40353,13 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
39999
40353
|
browserBilling ??= licenseService(fileSessionStorage(), billingOrigin2);
|
|
40000
40354
|
return serve({
|
|
40001
40355
|
source,
|
|
40002
|
-
webRoot
|
|
40356
|
+
webRoot,
|
|
40003
40357
|
port: 0,
|
|
40004
40358
|
license: browserBilling,
|
|
40005
40359
|
ads,
|
|
40006
40360
|
sidebar: false,
|
|
40007
40361
|
loginOnly: false,
|
|
40008
|
-
ideWorkspace:
|
|
40362
|
+
ideWorkspace: false
|
|
40009
40363
|
});
|
|
40010
40364
|
})();
|
|
40011
40365
|
fallbackEditors.set("__workspace__", pending);
|
|
@@ -40170,9 +40524,13 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
40170
40524
|
annotations: { readOnlyHint: true },
|
|
40171
40525
|
_meta: appOnly
|
|
40172
40526
|
}, async ({ file: file2 }) => {
|
|
40527
|
+
if (!hasAccess(await billing.state())) {
|
|
40528
|
+
throw new Error("Inkmap \u514D\u8D39\u8BD5\u7528\u5DF2\u5230\u671F\uFF0C\u8BF7\u767B\u5F55\u5DF2\u8D2D\u8D26\u53F7\u6062\u590D Pro \u6743\u76CA\u3002");
|
|
40529
|
+
}
|
|
40173
40530
|
const opened = await workspaces.open({ path: file2, fromModel: false });
|
|
40174
40531
|
if (!opened.currentFile)
|
|
40175
40532
|
throw new Error("\u672A\u9009\u62E9 Markdown \u6587\u4EF6\u3002");
|
|
40533
|
+
billing.track?.("feature_browser", 1, detectMcpHost());
|
|
40176
40534
|
const url2 = await openFallbackBrowserEditor(opened.currentFile);
|
|
40177
40535
|
return { content: [], structuredContent: { url: url2 ?? "" } };
|
|
40178
40536
|
});
|
|
@@ -40239,14 +40597,14 @@ async function serveCodex() {
|
|
|
40239
40597
|
};
|
|
40240
40598
|
await server.connect(transport);
|
|
40241
40599
|
}
|
|
40242
|
-
var
|
|
40600
|
+
var import_node_child_process3, import_node_fs2, import_promises4, import_node_os4, import_node_path4, import_node_url2, UI, HTML, WEB_ROOT_CANDIDATES, INLINE_DOC_LIMIT, appOnly;
|
|
40243
40601
|
var init_codex = __esm({
|
|
40244
40602
|
"packages/cli/dist/codex.js"() {
|
|
40245
40603
|
"use strict";
|
|
40246
40604
|
init_mcp();
|
|
40247
40605
|
init_stdio2();
|
|
40248
40606
|
init_server4();
|
|
40249
|
-
|
|
40607
|
+
import_node_child_process3 = require("node:child_process");
|
|
40250
40608
|
import_node_fs2 = require("node:fs");
|
|
40251
40609
|
import_promises4 = require("node:fs/promises");
|
|
40252
40610
|
import_node_os4 = require("node:os");
|
|
@@ -40259,7 +40617,11 @@ var init_codex = __esm({
|
|
|
40259
40617
|
init_server();
|
|
40260
40618
|
UI = "ui://inkmap/markdown.html";
|
|
40261
40619
|
HTML = new URL("./codex.html", inkmapModuleUrl);
|
|
40262
|
-
|
|
40620
|
+
WEB_ROOT_CANDIDATES = [
|
|
40621
|
+
(0, import_node_url2.fileURLToPath)(new URL("./web/", inkmapModuleUrl)),
|
|
40622
|
+
(0, import_node_url2.fileURLToPath)(new URL("./sidecars/inkmap/web/", inkmapModuleUrl)),
|
|
40623
|
+
(0, import_node_url2.fileURLToPath)(new URL("../web/", inkmapModuleUrl))
|
|
40624
|
+
];
|
|
40263
40625
|
INLINE_DOC_LIMIT = 256 * 1024;
|
|
40264
40626
|
appOnly = { ui: { visibility: ["app"] } };
|
|
40265
40627
|
}
|
|
@@ -40392,7 +40754,7 @@ function getAntigravityConfigDir() {
|
|
|
40392
40754
|
function findCursorCommand() {
|
|
40393
40755
|
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
40394
40756
|
return null;
|
|
40395
|
-
if ((0,
|
|
40757
|
+
if ((0, import_node_child_process4.spawnSync)("cursor", ["--version"], { stdio: "ignore" }).status === 0)
|
|
40396
40758
|
return "cursor";
|
|
40397
40759
|
if (process.platform === "darwin") {
|
|
40398
40760
|
for (const dir of ["/Applications", (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
@@ -40411,7 +40773,7 @@ function findCursorCommand() {
|
|
|
40411
40773
|
function findVscodeCommand() {
|
|
40412
40774
|
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
40413
40775
|
return null;
|
|
40414
|
-
if ((0,
|
|
40776
|
+
if ((0, import_node_child_process4.spawnSync)("code", ["--version"], { stdio: "ignore" }).status === 0)
|
|
40415
40777
|
return "code";
|
|
40416
40778
|
if (process.platform === "darwin") {
|
|
40417
40779
|
for (const dir of ["/Applications", (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
@@ -40431,7 +40793,7 @@ function findCodexCommand() {
|
|
|
40431
40793
|
if (process.env.INKMAP_CODEX_BIN) {
|
|
40432
40794
|
return (0, import_node_fs3.existsSync)(process.env.INKMAP_CODEX_BIN) ? process.env.INKMAP_CODEX_BIN : null;
|
|
40433
40795
|
}
|
|
40434
|
-
if ((0,
|
|
40796
|
+
if ((0, import_node_child_process4.spawnSync)("codex", ["--version"], { stdio: "ignore" }).status === 0)
|
|
40435
40797
|
return "codex";
|
|
40436
40798
|
if (process.platform === "darwin") {
|
|
40437
40799
|
for (const dir of ["/Applications", (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
@@ -40451,7 +40813,7 @@ function findDshCommand() {
|
|
|
40451
40813
|
}
|
|
40452
40814
|
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
40453
40815
|
return null;
|
|
40454
|
-
if ((0,
|
|
40816
|
+
if ((0, import_node_child_process4.spawnSync)("dsh", ["--version"], { stdio: "ignore" }).status === 0)
|
|
40455
40817
|
return "dsh";
|
|
40456
40818
|
if (process.platform === "darwin") {
|
|
40457
40819
|
for (const dir of ["/Applications", (0, import_node_path5.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
@@ -40474,7 +40836,7 @@ function detectInstalledTargets() {
|
|
|
40474
40836
|
found.push("claude");
|
|
40475
40837
|
}
|
|
40476
40838
|
const claudeCodeCfg = getClaudeCodeConfigPath();
|
|
40477
|
-
if ((0, import_node_fs3.existsSync)(claudeCodeCfg) || !process.env.INKMAP_ISOLATED_DETECT && (0,
|
|
40839
|
+
if ((0, import_node_fs3.existsSync)(claudeCodeCfg) || !process.env.INKMAP_ISOLATED_DETECT && (0, import_node_child_process4.spawnSync)("claude", ["--version"], { stdio: "ignore" }).status === 0) {
|
|
40478
40840
|
found.push("claude-code");
|
|
40479
40841
|
}
|
|
40480
40842
|
if ((0, import_node_fs3.existsSync)(getCursorDir()) || Boolean(findCursorCommand())) {
|
|
@@ -40603,7 +40965,7 @@ function installIdeExtension(editorDir, cliCmd) {
|
|
|
40603
40965
|
const vsixPath = (0, import_node_path5.join)(staging, `inkmap-${version2}.vsix`);
|
|
40604
40966
|
(0, import_node_fs3.writeFileSync)(vsixPath, buildZipBuffer(entries));
|
|
40605
40967
|
try {
|
|
40606
|
-
(0,
|
|
40968
|
+
(0, import_node_child_process4.execFileSync)(cliCmd, ["--install-extension", vsixPath, "--force"], { stdio: "pipe" });
|
|
40607
40969
|
return (0, import_node_path5.join)(editorDir, "extensions", `inkmap.inkmap-vscode-${version2}`);
|
|
40608
40970
|
} catch {
|
|
40609
40971
|
}
|
|
@@ -40626,7 +40988,7 @@ function uninstallIdeExtension(editorDir, cliCmd) {
|
|
|
40626
40988
|
let removed = false;
|
|
40627
40989
|
if (cliCmd) {
|
|
40628
40990
|
try {
|
|
40629
|
-
(0,
|
|
40991
|
+
(0, import_node_child_process4.execFileSync)(cliCmd, ["--uninstall-extension", "inkmap.inkmap-vscode"], { stdio: "pipe" });
|
|
40630
40992
|
removed = true;
|
|
40631
40993
|
} catch {
|
|
40632
40994
|
}
|
|
@@ -40758,13 +41120,13 @@ function installCodexPlugin() {
|
|
|
40758
41120
|
throw new Error("\u672A\u627E\u5230 Codex \u63D2\u4EF6\u8D44\u6E90 / Codex plugin bundle not found.");
|
|
40759
41121
|
}
|
|
40760
41122
|
const marketplaceName = "inkmap-local";
|
|
40761
|
-
const rawList = (0,
|
|
41123
|
+
const rawList = (0, import_node_child_process4.execFileSync)(codex, ["plugin", "marketplace", "list", "--json"], { encoding: "utf8" });
|
|
40762
41124
|
const { marketplaces = [] } = JSON.parse(rawList);
|
|
40763
41125
|
const existing = marketplaces.find((entry) => entry.name === marketplaceName);
|
|
40764
41126
|
if (!existing) {
|
|
40765
|
-
(0,
|
|
41127
|
+
(0, import_node_child_process4.execFileSync)(codex, ["plugin", "marketplace", "add", marketplaceRoot], { stdio: "pipe" });
|
|
40766
41128
|
}
|
|
40767
|
-
(0,
|
|
41129
|
+
(0, import_node_child_process4.execFileSync)(codex, ["plugin", "add", `inkmap-codex@${marketplaceName}`], { stdio: "pipe" });
|
|
40768
41130
|
return {
|
|
40769
41131
|
location: marketplaceRoot,
|
|
40770
41132
|
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"
|
|
@@ -40832,7 +41194,7 @@ function installDeepSeekHarnessPlugin() {
|
|
|
40832
41194
|
const dshCmd = findDshCommand();
|
|
40833
41195
|
const profileDir = (0, import_node_path5.join)(getDshHome(), "profiles", "desktop");
|
|
40834
41196
|
if (dshCmd) {
|
|
40835
|
-
(0,
|
|
41197
|
+
(0, import_node_child_process4.execFileSync)(dshCmd, ["plugin", "--profile", "desktop", "add", realStaged], { stdio: "pipe" });
|
|
40836
41198
|
} else if ((0, import_node_fs3.existsSync)(profileDir)) {
|
|
40837
41199
|
const nodeModulesTarget = (0, import_node_path5.join)(profileDir, "node_modules", "dsh-inkmap");
|
|
40838
41200
|
(0, import_node_fs3.rmSync)(nodeModulesTarget, { recursive: true, force: true });
|
|
@@ -40894,7 +41256,7 @@ async function runInstall(options = {}) {
|
|
|
40894
41256
|
const profileDir = (0, import_node_path5.join)(getDshHome(), "profiles", "desktop");
|
|
40895
41257
|
if (dshCmd && (0, import_node_fs3.existsSync)(profileDir)) {
|
|
40896
41258
|
try {
|
|
40897
|
-
(0,
|
|
41259
|
+
(0, import_node_child_process4.execFileSync)(dshCmd, ["plugin", "--profile", "desktop", "remove", "dsh-inkmap"], { stdio: "pipe" });
|
|
40898
41260
|
} catch {
|
|
40899
41261
|
}
|
|
40900
41262
|
}
|
|
@@ -41040,6 +41402,17 @@ async function runInstall(options = {}) {
|
|
|
41040
41402
|
log(" Qoder, WorkBuddy, Claude Desktop, Claude Code, OpenAI Codex, Google Antigravity & Trae!");
|
|
41041
41403
|
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");
|
|
41042
41404
|
}
|
|
41405
|
+
if (!options.uninstall && result.installed.length > 0) {
|
|
41406
|
+
try {
|
|
41407
|
+
const { fileSessionStorage: fileSessionStorage2, licenseService: licenseService2 } = await Promise.resolve().then(() => (init_license(), license_exports));
|
|
41408
|
+
const { YUNFAN_BILLING_ORIGIN: YUNFAN_BILLING_ORIGIN2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
41409
|
+
const svc = licenseService2(fileSessionStorage2(), () => process.env.INKMAP_BILLING_ORIGIN || YUNFAN_BILLING_ORIGIN2, { host: "cli" });
|
|
41410
|
+
svc.track?.("plugin_install", 1, "cli");
|
|
41411
|
+
await Promise.race([svc.flushTelemetry?.(), new Promise((r2) => setTimeout(r2, 1500))]);
|
|
41412
|
+
svc.dispose();
|
|
41413
|
+
} catch {
|
|
41414
|
+
}
|
|
41415
|
+
}
|
|
41043
41416
|
return result;
|
|
41044
41417
|
}
|
|
41045
41418
|
async function runInstallCli(argv, uninstall = false) {
|
|
@@ -41095,11 +41468,11 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
41095
41468
|
uninstall
|
|
41096
41469
|
});
|
|
41097
41470
|
}
|
|
41098
|
-
var
|
|
41471
|
+
var import_node_child_process4, import_node_fs3, import_node_os5, import_node_path5, import_node_url3, import_node_zlib, DIST_DIR, PKG_ROOT, SERVER_WRAPPER, CRC_TABLE;
|
|
41099
41472
|
var init_install = __esm({
|
|
41100
41473
|
"packages/cli/dist/install.js"() {
|
|
41101
41474
|
"use strict";
|
|
41102
|
-
|
|
41475
|
+
import_node_child_process4 = require("node:child_process");
|
|
41103
41476
|
import_node_fs3 = require("node:fs");
|
|
41104
41477
|
import_node_os5 = require("node:os");
|
|
41105
41478
|
import_node_path5 = require("node:path");
|
|
@@ -41135,14 +41508,14 @@ __export(index_exports, {
|
|
|
41135
41508
|
main: () => main
|
|
41136
41509
|
});
|
|
41137
41510
|
module.exports = __toCommonJS(index_exports);
|
|
41138
|
-
var
|
|
41511
|
+
var import_node_child_process5 = require("node:child_process");
|
|
41139
41512
|
var import_node_path6 = require("node:path");
|
|
41140
41513
|
var import_node_url4 = require("node:url");
|
|
41141
41514
|
init_dist();
|
|
41142
41515
|
init_license();
|
|
41143
41516
|
init_server();
|
|
41144
|
-
var INKMAP_VERSION = "0.3.
|
|
41145
|
-
var
|
|
41517
|
+
var INKMAP_VERSION = "0.3.10";
|
|
41518
|
+
var WEB_ROOT = (0, import_node_url4.fileURLToPath)(new URL("./web/", inkmapModuleUrl));
|
|
41146
41519
|
var USAGE = `Inkmap v${INKMAP_VERSION} \u2014 Markdown \u4EA4\u4E92\u601D\u7EF4\u5BFC\u56FE\u7F16\u8F91\u5668 & MCP App
|
|
41147
41520
|
|
|
41148
41521
|
\u7528\u6CD5 / Usage\uFF1A
|
|
@@ -41156,7 +41529,7 @@ var USAGE = `Inkmap v${INKMAP_VERSION} \u2014 Markdown \u4EA4\u4E92\u601D\u7EF4\
|
|
|
41156
41529
|
\u5728\u672C\u5730\u6D4F\u89C8\u5668\u4E2D\u4EE5\u601D\u7EF4\u5BFC\u56FE\u6253\u5F00\u5E76\u5B9E\u65F6\u53CC\u5411\u7F16\u8F91 Markdown \u6587\u4EF6`;
|
|
41157
41530
|
function openBrowser(url2) {
|
|
41158
41531
|
const [cmd, args] = process.platform === "darwin" ? ["open", [url2]] : process.platform === "win32" ? ["cmd", ["/c", "start", "", url2]] : ["xdg-open", [url2]];
|
|
41159
|
-
(0,
|
|
41532
|
+
(0, import_node_child_process5.spawn)(cmd, args, { stdio: "ignore", detached: true }).unref();
|
|
41160
41533
|
}
|
|
41161
41534
|
function appendEnvWorkspaces(dirs) {
|
|
41162
41535
|
if (dirs.length === 0)
|
|
@@ -41242,7 +41615,7 @@ ${USAGE}`);
|
|
|
41242
41615
|
const license = licenseService(fileSessionStorage(), () => process.env.INKMAP_BILLING_ORIGIN || YUNFAN_BILLING_ORIGIN);
|
|
41243
41616
|
const served = await serve({
|
|
41244
41617
|
source: await fileSource(file2, log),
|
|
41245
|
-
webRoot:
|
|
41618
|
+
webRoot: WEB_ROOT,
|
|
41246
41619
|
port: port ?? (sidebar ? 0 : void 0),
|
|
41247
41620
|
log,
|
|
41248
41621
|
license,
|