inkmap-mcp 0.3.18 → 0.3.19
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/LICENSE.md +4 -2
- package/README.md +2 -1
- package/dist/bundles/antigravity/plugin.json +1 -1
- package/dist/bundles/antigravity/sidecars/inkmap/main.mjs +113 -28
- 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/client.js +3 -0
- package/dist/bundles/harness/host.js +138 -52
- package/dist/bundles/harness/package.json +1 -1
- package/dist/bundles/vscode/dist/extension.js +215 -101
- package/dist/bundles/vscode/package.json +1 -1
- package/dist/cli.cjs +318 -211
- package/dist/codex.html +526 -525
- package/dist/web/app.js +50014 -49912
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -66,23 +66,83 @@ var init_product = __esm({
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
// packages/core/dist/images.js
|
|
70
|
+
function sniffImage(bytes) {
|
|
71
|
+
if (startsWith(bytes, "\x89PNG\r\n\n"))
|
|
72
|
+
return "png";
|
|
73
|
+
if (startsWith(bytes, "\xFF\xD8\xFF"))
|
|
74
|
+
return "jpg";
|
|
75
|
+
if (startsWith(bytes, "GIF87a") || startsWith(bytes, "GIF89a"))
|
|
76
|
+
return "gif";
|
|
77
|
+
if (startsWith(bytes, "RIFF") && startsWith(bytes, "WEBP", 8))
|
|
78
|
+
return "webp";
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
function decodeImageDataUrl(dataUrl) {
|
|
82
|
+
const match = typeof dataUrl === "string" ? /^data:[\w.+/-]*;base64,([A-Za-z0-9+/]*={0,2})$/.exec(dataUrl) : null;
|
|
83
|
+
if (!match)
|
|
84
|
+
return { problem: "type" };
|
|
85
|
+
if (match[1].length * 3 / 4 - 2 > MAX_IMAGE_BYTES)
|
|
86
|
+
return { problem: "size" };
|
|
87
|
+
let binary;
|
|
88
|
+
try {
|
|
89
|
+
binary = atob(match[1]);
|
|
90
|
+
} catch {
|
|
91
|
+
return { problem: "type" };
|
|
92
|
+
}
|
|
93
|
+
if (binary.length > MAX_IMAGE_BYTES)
|
|
94
|
+
return { problem: "size" };
|
|
95
|
+
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
96
|
+
const extension = sniffImage(bytes);
|
|
97
|
+
return extension ? { bytes, extension } : { problem: "type" };
|
|
98
|
+
}
|
|
99
|
+
function imageFolderName(documentFileName) {
|
|
100
|
+
const stem = documentFileName.replace(/\.(?:md|markdown)$/i, "").trim();
|
|
101
|
+
return `${/^\.*$/.test(stem) ? "images" : stem}.assets`;
|
|
102
|
+
}
|
|
103
|
+
function imageFileName(when, extension, attempt = 1) {
|
|
104
|
+
const two = (n) => String(n).padStart(2, "0");
|
|
105
|
+
const stamp = `${when.getFullYear()}${two(when.getMonth() + 1)}${two(when.getDate())}-${two(when.getHours())}${two(when.getMinutes())}${two(when.getSeconds())}`;
|
|
106
|
+
return `image-${stamp}${attempt > 1 ? `-${attempt}` : ""}.${extension}`;
|
|
107
|
+
}
|
|
108
|
+
function imageLinkPath(folder, file2) {
|
|
109
|
+
const encode3 = (part) => part.replace(/[%\s()<>#?[\]\\"]/g, (char) => encodeURIComponent(char).replace(/\(/g, "%28").replace(/\)/g, "%29"));
|
|
110
|
+
return `${encode3(folder)}/${encode3(file2)}`;
|
|
111
|
+
}
|
|
112
|
+
var MAX_IMAGE_BYTES, startsWith, imageMarkdown;
|
|
113
|
+
var init_images = __esm({
|
|
114
|
+
"packages/core/dist/images.js"() {
|
|
115
|
+
"use strict";
|
|
116
|
+
MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
117
|
+
startsWith = (bytes, signature, offset = 0) => [...signature].every((char, i) => bytes[offset + i] === char.charCodeAt(0));
|
|
118
|
+
imageMarkdown = (path) => ``;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
69
122
|
// packages/core/dist/index.js
|
|
70
123
|
var dist_exports = {};
|
|
71
124
|
__export(dist_exports, {
|
|
72
125
|
DAY_MS: () => DAY_MS,
|
|
126
|
+
MAX_IMAGE_BYTES: () => MAX_IMAGE_BYTES,
|
|
73
127
|
PRODUCT: () => PRODUCT,
|
|
74
128
|
TRIAL_MS: () => TRIAL_MS,
|
|
75
129
|
YUNFAN_BILLING_ORIGIN: () => YUNFAN_BILLING_ORIGIN,
|
|
76
130
|
billingFlowUrl: () => billingFlowUrl,
|
|
131
|
+
decodeImageDataUrl: () => decodeImageDataUrl,
|
|
77
132
|
documentSetting: () => documentSetting,
|
|
78
133
|
frontMatterTitle: () => frontMatterTitle,
|
|
79
134
|
hasAccess: () => hasAccess,
|
|
135
|
+
imageFileName: () => imageFileName,
|
|
136
|
+
imageFolderName: () => imageFolderName,
|
|
137
|
+
imageLinkPath: () => imageLinkPath,
|
|
138
|
+
imageMarkdown: () => imageMarkdown,
|
|
80
139
|
isRich: () => isRich,
|
|
81
140
|
parse: () => parse,
|
|
82
141
|
plainText: () => plainText,
|
|
83
142
|
sanitizeViewState: () => sanitizeViewState,
|
|
84
143
|
serialize: () => serialize,
|
|
85
144
|
serializeWithLines: () => serializeWithLines,
|
|
145
|
+
sniffImage: () => sniffImage,
|
|
86
146
|
trialDaysLeft: () => trialDaysLeft,
|
|
87
147
|
withDocumentSetting: () => withDocumentSetting,
|
|
88
148
|
withFrontMatterTitle: () => withFrontMatterTitle
|
|
@@ -451,6 +511,7 @@ var init_dist = __esm({
|
|
|
451
511
|
"packages/core/dist/index.js"() {
|
|
452
512
|
"use strict";
|
|
453
513
|
init_product();
|
|
514
|
+
init_images();
|
|
454
515
|
THEMATIC_BREAK = /^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
455
516
|
ITEM = /^(\s*)([-*+]|\d+[.)])(?:([ \t]+)(.*))?$/;
|
|
456
517
|
YAML_KEY = /^(?:"[^"]*"|'[^']*'|[^\s#"'-].*?)[ \t]*:(?:[ \t]|$)/;
|
|
@@ -466,7 +527,7 @@ var INKMAP_VERSION;
|
|
|
466
527
|
var init_version = __esm({
|
|
467
528
|
"packages/cli/dist/version.js"() {
|
|
468
529
|
"use strict";
|
|
469
|
-
INKMAP_VERSION = "0.3.
|
|
530
|
+
INKMAP_VERSION = "0.3.19";
|
|
470
531
|
}
|
|
471
532
|
});
|
|
472
533
|
|
|
@@ -1891,52 +1952,83 @@ var init_workspace_fs = __esm({
|
|
|
1891
1952
|
}
|
|
1892
1953
|
});
|
|
1893
1954
|
|
|
1955
|
+
// packages/cli/dist/image-assets.js
|
|
1956
|
+
async function saveImageAsset(documentDir, documentFileName, image, when = /* @__PURE__ */ new Date()) {
|
|
1957
|
+
const folder = imageFolderName(documentFileName);
|
|
1958
|
+
const target = (0, import_node_path3.join)(documentDir, folder);
|
|
1959
|
+
await (0, import_promises3.mkdir)(target, { recursive: true });
|
|
1960
|
+
if (!insideOrEqual(await (0, import_promises3.realpath)(documentDir), await (0, import_promises3.realpath)(target))) {
|
|
1961
|
+
throw new Error(say("\u56FE\u7247\u76EE\u5F55\u6307\u5411\u6587\u6863\u76EE\u5F55\u4E4B\u5916\uFF0C\u672A\u4FDD\u5B58\u56FE\u7247\u3002", "The pictures folder leads outside the document's folder, so nothing was saved."));
|
|
1962
|
+
}
|
|
1963
|
+
for (let attempt = 1; attempt <= 100; attempt++) {
|
|
1964
|
+
const name = imageFileName(when, image.extension, attempt);
|
|
1965
|
+
try {
|
|
1966
|
+
await (0, import_promises3.writeFile)((0, import_node_path3.join)(target, name), image.bytes, { flag: "wx" });
|
|
1967
|
+
return imageLinkPath(folder, name);
|
|
1968
|
+
} catch (error62) {
|
|
1969
|
+
if (error62.code !== "EEXIST")
|
|
1970
|
+
throw error62;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
throw new Error(say("\u65E0\u6CD5\u4E3A\u56FE\u7247\u751F\u6210\u65B0\u7684\u6587\u4EF6\u540D\u3002", "Could not find a free file name for the picture."));
|
|
1974
|
+
}
|
|
1975
|
+
var import_promises3, import_node_path3;
|
|
1976
|
+
var init_image_assets = __esm({
|
|
1977
|
+
"packages/cli/dist/image-assets.js"() {
|
|
1978
|
+
"use strict";
|
|
1979
|
+
import_promises3 = require("node:fs/promises");
|
|
1980
|
+
import_node_path3 = require("node:path");
|
|
1981
|
+
init_dist();
|
|
1982
|
+
init_workspace_fs();
|
|
1983
|
+
}
|
|
1984
|
+
});
|
|
1985
|
+
|
|
1894
1986
|
// packages/cli/dist/server.js
|
|
1895
1987
|
function docName(path) {
|
|
1896
|
-
return (0,
|
|
1988
|
+
return (0, import_node_path4.basename)(path).replace(/\.md$/i, "").replace(/\.markmap$/i, "");
|
|
1897
1989
|
}
|
|
1898
1990
|
function viewStateFile(key) {
|
|
1899
|
-
const base = process.env.INKMAP_HOME || (0,
|
|
1900
|
-
return (0,
|
|
1991
|
+
const base = process.env.INKMAP_HOME || (0, import_node_path4.join)((0, import_node_os3.homedir)(), ".inkmap");
|
|
1992
|
+
return (0, import_node_path4.join)(base, "view-state", hash(key) + ".json");
|
|
1901
1993
|
}
|
|
1902
1994
|
async function readDiskViewState(key) {
|
|
1903
1995
|
try {
|
|
1904
|
-
return sanitizeViewState(JSON.parse(await (0,
|
|
1996
|
+
return sanitizeViewState(JSON.parse(await (0, import_promises4.readFile)(viewStateFile(key), "utf8")));
|
|
1905
1997
|
} catch {
|
|
1906
1998
|
return void 0;
|
|
1907
1999
|
}
|
|
1908
2000
|
}
|
|
1909
2001
|
async function writeDiskViewState(key, state) {
|
|
1910
2002
|
const target = viewStateFile(key);
|
|
1911
|
-
await (0,
|
|
2003
|
+
await (0, import_promises4.mkdir)((0, import_node_path4.dirname)(target), { recursive: true, mode: 448 });
|
|
1912
2004
|
const temp = `${target}.${process.pid}.${Date.now()}`;
|
|
1913
2005
|
try {
|
|
1914
|
-
await (0,
|
|
1915
|
-
await (0,
|
|
2006
|
+
await (0, import_promises4.writeFile)(temp, JSON.stringify(state), { mode: 384 });
|
|
2007
|
+
await (0, import_promises4.rename)(temp, target);
|
|
1916
2008
|
} finally {
|
|
1917
|
-
await (0,
|
|
2009
|
+
await (0, import_promises4.rm)(temp, { force: true }).catch(() => {
|
|
1918
2010
|
});
|
|
1919
2011
|
}
|
|
1920
2012
|
}
|
|
1921
2013
|
async function fileSource(file2, log = () => {
|
|
1922
2014
|
}) {
|
|
1923
|
-
const path = await (0,
|
|
1924
|
-
if (!(await (0,
|
|
2015
|
+
const path = await (0, import_promises4.realpath)((0, import_node_path4.resolve)(file2)).catch(() => (0, import_node_path4.resolve)(file2));
|
|
2016
|
+
if (!(await (0, import_promises4.stat)(path)).isFile())
|
|
1925
2017
|
throw new Error(`\u4E0D\u662F\u6587\u4EF6\uFF1A${path}`);
|
|
1926
|
-
const dir = (0,
|
|
2018
|
+
const dir = (0, import_node_path4.dirname)(path);
|
|
1927
2019
|
return {
|
|
1928
2020
|
name: docName(path),
|
|
1929
2021
|
key: path,
|
|
1930
2022
|
dir,
|
|
1931
|
-
read: () => (0,
|
|
2023
|
+
read: () => (0, import_promises4.readFile)(path, "utf8"),
|
|
1932
2024
|
async write(md) {
|
|
1933
|
-
await (0,
|
|
2025
|
+
await (0, import_promises4.writeFile)(path, md, "utf8");
|
|
1934
2026
|
log(`\u5DF2\u5199\u56DE ${path}`);
|
|
1935
2027
|
},
|
|
1936
2028
|
watch(onChange) {
|
|
1937
2029
|
try {
|
|
1938
2030
|
const watcher = (0, import_node_fs.watch)(dir, (_2, changed) => {
|
|
1939
|
-
if (!changed || changed === (0,
|
|
2031
|
+
if (!changed || changed === (0, import_node_path4.basename)(path))
|
|
1940
2032
|
onChange();
|
|
1941
2033
|
});
|
|
1942
2034
|
watcher.on("error", () => {
|
|
@@ -1958,9 +2050,9 @@ function within(root, rel, allowAbsoluteInRoot = false) {
|
|
|
1958
2050
|
} catch {
|
|
1959
2051
|
return null;
|
|
1960
2052
|
}
|
|
1961
|
-
const resolvedRoot = (0,
|
|
1962
|
-
const base = resolvedRoot.endsWith(
|
|
1963
|
-
const full = allowAbsoluteInRoot && /^(?:[\\/]|[A-Za-z]:[\\/])/.test(decoded) ? (0,
|
|
2053
|
+
const resolvedRoot = (0, import_node_path4.resolve)(root);
|
|
2054
|
+
const base = resolvedRoot.endsWith(import_node_path4.sep) ? resolvedRoot : resolvedRoot + import_node_path4.sep;
|
|
2055
|
+
const full = allowAbsoluteInRoot && /^(?:[\\/]|[A-Za-z]:[\\/])/.test(decoded) ? (0, import_node_path4.normalize)(decoded) : (0, import_node_path4.normalize)((0, import_node_path4.join)(resolvedRoot, decoded));
|
|
1964
2056
|
return full.startsWith(base) ? full : null;
|
|
1965
2057
|
}
|
|
1966
2058
|
async function serve({ source: initialSource, webRoot, port = 4377, host = "127.0.0.1", log = () => {
|
|
@@ -2018,19 +2110,19 @@ data: ${JSON.stringify(data)}
|
|
|
2018
2110
|
}), 80);
|
|
2019
2111
|
};
|
|
2020
2112
|
let unwatch = activeSource.watch(scheduleRefresh);
|
|
2021
|
-
const canonicalActiveKey = async () => activeSource.key ? await (0,
|
|
2113
|
+
const canonicalActiveKey = async () => activeSource.key ? await (0, import_promises4.realpath)(activeSource.key).catch(() => activeSource.key) : void 0;
|
|
2022
2114
|
async function collectWorkspaceFiles() {
|
|
2023
2115
|
const roots = /* @__PURE__ */ new Map();
|
|
2024
2116
|
if (activeSource.key && !confineToWorkspaceRoots) {
|
|
2025
|
-
const realKey = await (0,
|
|
2026
|
-
const projRoot = await (0,
|
|
2027
|
-
roots.set(projRoot, { path: projRoot, name: (0,
|
|
2117
|
+
const realKey = await (0, import_promises4.realpath)(activeSource.key).catch(() => activeSource.key);
|
|
2118
|
+
const projRoot = await (0, import_promises4.realpath)(await findProjectRoot(realKey)).catch(() => (0, import_node_path4.dirname)(realKey));
|
|
2119
|
+
roots.set(projRoot, { path: projRoot, name: (0, import_node_path4.basename)(projRoot), active: true });
|
|
2028
2120
|
}
|
|
2029
|
-
const envRoots = [...workspaceRoots, ...(process.env.INKMAP_WORKSPACES || "").split(
|
|
2121
|
+
const envRoots = [...workspaceRoots, ...(process.env.INKMAP_WORKSPACES || "").split(import_node_path4.delimiter)].filter(Boolean);
|
|
2030
2122
|
for (const raw of envRoots) {
|
|
2031
|
-
const real = await (0,
|
|
2123
|
+
const real = await (0, import_promises4.realpath)((0, import_node_path4.resolve)(raw)).catch(() => null);
|
|
2032
2124
|
if (real && !roots.has(real)) {
|
|
2033
|
-
roots.set(real, { path: real, name: (0,
|
|
2125
|
+
roots.set(real, { path: real, name: (0, import_node_path4.basename)(real), active: roots.size === 0 });
|
|
2034
2126
|
}
|
|
2035
2127
|
}
|
|
2036
2128
|
const items = [];
|
|
@@ -2041,7 +2133,7 @@ data: ${JSON.stringify(data)}
|
|
|
2041
2133
|
if (seen.has(f2))
|
|
2042
2134
|
continue;
|
|
2043
2135
|
seen.add(f2);
|
|
2044
|
-
const rel = (0,
|
|
2136
|
+
const rel = (0, import_node_path4.relative)(root.path, f2);
|
|
2045
2137
|
items.push({
|
|
2046
2138
|
path: f2,
|
|
2047
2139
|
label: `${root.name} / ${rel}`,
|
|
@@ -2053,7 +2145,7 @@ data: ${JSON.stringify(data)}
|
|
|
2053
2145
|
if (activeSource.key && activeReal && !seen.has(activeReal)) {
|
|
2054
2146
|
items.unshift({
|
|
2055
2147
|
path: activeSource.key,
|
|
2056
|
-
label: `${(0,
|
|
2148
|
+
label: `${(0, import_node_path4.basename)(activeSource.dir)} / ${(0, import_node_path4.basename)(activeSource.key)}`,
|
|
2057
2149
|
group: "active"
|
|
2058
2150
|
});
|
|
2059
2151
|
}
|
|
@@ -2064,10 +2156,10 @@ data: ${JSON.stringify(data)}
|
|
|
2064
2156
|
const notMarkdown = () => new HttpError(400, zh() ? "\u8BF7\u9009\u62E9 .md \u6216 .markmap.md \u6587\u4EF6\u3002" : "Choose a .md or .markmap.md file.");
|
|
2065
2157
|
if (!candidatePath || typeof candidatePath !== "string" || !/\.md$/i.test(candidatePath))
|
|
2066
2158
|
throw notMarkdown();
|
|
2067
|
-
const resolvedCandidate = (0,
|
|
2068
|
-
const rawStat = await (0,
|
|
2069
|
-
const realTarget = await (0,
|
|
2070
|
-
const targetStat = realTarget ? await (0,
|
|
2159
|
+
const resolvedCandidate = (0, import_node_path4.resolve)(candidatePath);
|
|
2160
|
+
const rawStat = await (0, import_promises4.lstat)(resolvedCandidate).catch(() => null);
|
|
2161
|
+
const realTarget = await (0, import_promises4.realpath)(resolvedCandidate).catch(() => null);
|
|
2162
|
+
const targetStat = realTarget ? await (0, import_promises4.stat)(realTarget).catch(() => null) : null;
|
|
2071
2163
|
if (!rawStat || rawStat.isSymbolicLink() && !trustCaller || !realTarget || !targetStat?.isFile() || targetStat.size > MAX_MARKDOWN_BYTES) {
|
|
2072
2164
|
throw new HttpError(403, zh() ? "\u8BF7\u9009\u62E9 5 MiB \u4EE5\u5185\u7684\u666E\u901A Markdown \u6587\u4EF6\u3002" : "Choose a regular Markdown file up to 5 MiB.");
|
|
2073
2165
|
}
|
|
@@ -2119,15 +2211,15 @@ data: ${JSON.stringify(data)}
|
|
|
2119
2211
|
if (!full)
|
|
2120
2212
|
return json2(res, 403, { error: "forbidden" });
|
|
2121
2213
|
try {
|
|
2122
|
-
const ext = (0,
|
|
2214
|
+
const ext = (0, import_node_path4.extname)(full).toLowerCase();
|
|
2123
2215
|
if (ext === ".html") {
|
|
2124
2216
|
const osLoc = detectOsLocale();
|
|
2125
|
-
const htmlText = (await (0,
|
|
2217
|
+
const htmlText = (await (0, import_promises4.readFile)(full, "utf8")).replace(/<html\b([^>]*)>/i, () => `<html lang="${osLoc === "zh" ? "zh-CN" : "en"}" data-os-locale="${osLoc}">`);
|
|
2126
2218
|
res.writeHead(200, { "content-type": TYPES[".html"], "cache-control": "no-store" });
|
|
2127
2219
|
res.end(htmlText, "utf8");
|
|
2128
2220
|
return;
|
|
2129
2221
|
}
|
|
2130
|
-
const body = await (0,
|
|
2222
|
+
const body = await (0, import_promises4.readFile)(full);
|
|
2131
2223
|
const headers = {
|
|
2132
2224
|
"content-type": TYPES[ext] ?? "application/octet-stream",
|
|
2133
2225
|
"cache-control": sidebar ? "no-store" : "no-cache"
|
|
@@ -2221,6 +2313,20 @@ data: ${JSON.stringify(data)}
|
|
|
2221
2313
|
return json2(res, 200, { version: version2 });
|
|
2222
2314
|
});
|
|
2223
2315
|
}
|
|
2316
|
+
if (url2.pathname === "/api/image" && req.method === "POST") {
|
|
2317
|
+
if (!sameOriginWrite())
|
|
2318
|
+
return json2(res, 403, { error: "forbidden" });
|
|
2319
|
+
const image = decodeImageDataUrl(JSON.parse(await readBody(req)).dataUrl);
|
|
2320
|
+
if ("problem" in image) {
|
|
2321
|
+
return json2(res, image.problem === "size" ? 413 : 415, { error: image.problem });
|
|
2322
|
+
}
|
|
2323
|
+
if (!hasAccess(await license?.state() ?? { pro: false }))
|
|
2324
|
+
return json2(res, 403, { error: "Inkmap trial expired" });
|
|
2325
|
+
return await serialized(async () => {
|
|
2326
|
+
const name = activeSource.key ? (0, import_node_path4.basename)(activeSource.key) : activeSource.name;
|
|
2327
|
+
return json2(res, 200, { path: await saveImageAsset(activeSource.dir, name, image) });
|
|
2328
|
+
});
|
|
2329
|
+
}
|
|
2224
2330
|
if (url2.pathname === "/api/license" && req.method === "GET")
|
|
2225
2331
|
return json2(res, 200, await license?.state({ forUi: true }) ?? { pro: false });
|
|
2226
2332
|
if (url2.pathname === "/api/open" && req.method === "POST") {
|
|
@@ -2336,8 +2442,8 @@ data: ${JSON.stringify(data)}
|
|
|
2336
2442
|
if (url2.pathname.startsWith("/doc-assets/")) {
|
|
2337
2443
|
let asset = within(activeSource.dir, url2.pathname.slice("/doc-assets/".length), true);
|
|
2338
2444
|
if (asset) {
|
|
2339
|
-
const root = await (0,
|
|
2340
|
-
asset = await (0,
|
|
2445
|
+
const root = await (0, import_promises4.realpath)(activeSource.dir).catch(() => null);
|
|
2446
|
+
asset = await (0, import_promises4.realpath)(asset).catch(() => null);
|
|
2341
2447
|
const allowedExt = sidebar ? /\.(?:png|jpe?g|gif|webp|avif|bmp|ico)$/i : /\.(?:png|jpe?g|gif|webp|avif|bmp|ico|svg)$/i;
|
|
2342
2448
|
if (!root || !asset || !insideOrEqual(root, asset) || !allowedExt.test(asset))
|
|
2343
2449
|
asset = null;
|
|
@@ -2393,17 +2499,18 @@ data: ${JSON.stringify(data)}
|
|
|
2393
2499
|
})
|
|
2394
2500
|
};
|
|
2395
2501
|
}
|
|
2396
|
-
var import_node_crypto2, import_node_fs,
|
|
2502
|
+
var import_node_crypto2, import_node_fs, import_promises4, import_node_http, import_node_os3, import_node_path4, MAX_BODY, TYPES, HttpError, LOOPBACK_HOST, hash;
|
|
2397
2503
|
var init_server = __esm({
|
|
2398
2504
|
"packages/cli/dist/server.js"() {
|
|
2399
2505
|
"use strict";
|
|
2400
2506
|
init_dist();
|
|
2401
2507
|
import_node_crypto2 = require("node:crypto");
|
|
2402
2508
|
import_node_fs = require("node:fs");
|
|
2403
|
-
|
|
2509
|
+
import_promises4 = require("node:fs/promises");
|
|
2404
2510
|
import_node_http = require("node:http");
|
|
2405
2511
|
import_node_os3 = require("node:os");
|
|
2406
|
-
|
|
2512
|
+
import_node_path4 = require("node:path");
|
|
2513
|
+
init_image_assets();
|
|
2407
2514
|
init_license();
|
|
2408
2515
|
init_open_browser();
|
|
2409
2516
|
init_workspace_fs();
|
|
@@ -40392,14 +40499,14 @@ function nextTargetSeq() {
|
|
|
40392
40499
|
return lastTargetSeq;
|
|
40393
40500
|
}
|
|
40394
40501
|
async function writeTargetSelection(filePath, workspaceDir, extra) {
|
|
40395
|
-
const real = await (0,
|
|
40396
|
-
const info = await (0,
|
|
40502
|
+
const real = await (0, import_promises5.realpath)(filePath);
|
|
40503
|
+
const info = await (0, import_promises5.lstat)(real);
|
|
40397
40504
|
if (!info.isFile() || info.size > MAX_MARKDOWN_BYTES || !/\.md$/i.test(real)) {
|
|
40398
40505
|
throw new Error(say("\u8BF7\u9009\u62E9 5 MiB \u4EE5\u5185\u7684 .md \u6216 .markmap.md \u6587\u4EF6\u3002", "Choose a .md or .markmap.md file up to 5 MiB."));
|
|
40399
40506
|
}
|
|
40400
|
-
const workspace = workspaceDir ? await (0,
|
|
40507
|
+
const workspace = workspaceDir ? await (0, import_promises5.realpath)(workspaceDir).catch(() => findProjectRoot(real)) : await findProjectRoot(real);
|
|
40401
40508
|
const statePath = targetStateFile();
|
|
40402
|
-
await (0,
|
|
40509
|
+
await (0, import_promises5.mkdir)((0, import_node_path5.dirname)(statePath), { recursive: true, mode: 448 });
|
|
40403
40510
|
const seq = nextTargetSeq();
|
|
40404
40511
|
const payload = {
|
|
40405
40512
|
file: real,
|
|
@@ -40412,10 +40519,10 @@ async function writeTargetSelection(filePath, workspaceDir, extra) {
|
|
|
40412
40519
|
};
|
|
40413
40520
|
const tmp = `${statePath}.${process.pid}.${seq}`;
|
|
40414
40521
|
try {
|
|
40415
|
-
await (0,
|
|
40416
|
-
await (0,
|
|
40522
|
+
await (0, import_promises5.writeFile)(tmp, JSON.stringify(payload, null, 2), { mode: 384 });
|
|
40523
|
+
await (0, import_promises5.rename)(tmp, statePath);
|
|
40417
40524
|
} catch (err) {
|
|
40418
|
-
await (0,
|
|
40525
|
+
await (0, import_promises5.rm)(tmp, { force: true }).catch(() => {
|
|
40419
40526
|
});
|
|
40420
40527
|
throw err;
|
|
40421
40528
|
}
|
|
@@ -40449,7 +40556,7 @@ function createMcpWorkspaceManager() {
|
|
|
40449
40556
|
const seen = /* @__PURE__ */ new Set();
|
|
40450
40557
|
if (target && !seen.has(target.file)) {
|
|
40451
40558
|
const owner = roots.find((r2) => insideOrEqual(r2.path, target.file));
|
|
40452
|
-
const rel = owner ? (0,
|
|
40559
|
+
const rel = owner ? (0, import_node_path5.relative)(owner.path, target.file) : (0, import_node_path5.basename)(target.file);
|
|
40453
40560
|
items.push({
|
|
40454
40561
|
path: target.file,
|
|
40455
40562
|
uri: (0, import_node_url2.pathToFileURL)(target.file).href,
|
|
@@ -40464,7 +40571,7 @@ function createMcpWorkspaceManager() {
|
|
|
40464
40571
|
if (seen.has(entry.path))
|
|
40465
40572
|
continue;
|
|
40466
40573
|
seen.add(entry.path);
|
|
40467
|
-
const rel = (0,
|
|
40574
|
+
const rel = (0, import_node_path5.relative)(root.path, entry.path);
|
|
40468
40575
|
items.push({
|
|
40469
40576
|
path: entry.path,
|
|
40470
40577
|
uri: (0, import_node_url2.pathToFileURL)(entry.path).href,
|
|
@@ -40598,13 +40705,13 @@ function createMcpWorkspaceManager() {
|
|
|
40598
40705
|
})
|
|
40599
40706
|
};
|
|
40600
40707
|
}
|
|
40601
|
-
var import_node_crypto3,
|
|
40708
|
+
var import_node_crypto3, import_promises5, import_node_path5, import_node_url2, sha1, lastTargetSeq;
|
|
40602
40709
|
var init_mcp_files = __esm({
|
|
40603
40710
|
"packages/cli/dist/mcp-files.js"() {
|
|
40604
40711
|
"use strict";
|
|
40605
40712
|
import_node_crypto3 = require("node:crypto");
|
|
40606
|
-
|
|
40607
|
-
|
|
40713
|
+
import_promises5 = require("node:fs/promises");
|
|
40714
|
+
import_node_path5 = require("node:path");
|
|
40608
40715
|
import_node_url2 = require("node:url");
|
|
40609
40716
|
init_dist();
|
|
40610
40717
|
init_server();
|
|
@@ -40621,17 +40728,17 @@ __export(codex_exports, {
|
|
|
40621
40728
|
serveCodex: () => serveCodex
|
|
40622
40729
|
});
|
|
40623
40730
|
function resolveWebRoot() {
|
|
40624
|
-
return WEB_ROOT_CANDIDATES.find((dir) => (0, import_node_fs2.existsSync)((0,
|
|
40731
|
+
return WEB_ROOT_CANDIDATES.find((dir) => (0, import_node_fs2.existsSync)((0, import_node_path6.join)(dir, "index.html"))) ?? null;
|
|
40625
40732
|
}
|
|
40626
40733
|
async function validatedMarkdownFile(path) {
|
|
40627
40734
|
if (!path || !/\.md$/i.test(path))
|
|
40628
40735
|
throw new Error(say("\u8BF7\u9009\u62E9 .md \u6216 .markmap.md \u6587\u4EF6\u3002", "Choose a .md or .markmap.md file."));
|
|
40629
|
-
const info = await (0,
|
|
40736
|
+
const info = await (0, import_promises6.lstat)(path);
|
|
40630
40737
|
if (info.isSymbolicLink() || !info.isFile() || info.size > MAX_MARKDOWN_BYTES) {
|
|
40631
40738
|
throw new Error(say("\u8BF7\u9009\u62E9 5 MiB \u4EE5\u5185\u7684\u666E\u901A Markdown \u6587\u4EF6\u3002", "Choose a regular Markdown file up to 5 MiB."));
|
|
40632
40739
|
}
|
|
40633
|
-
const real = await (0,
|
|
40634
|
-
const home = await (0,
|
|
40740
|
+
const real = await (0, import_promises6.realpath)(path);
|
|
40741
|
+
const home = await (0, import_promises6.realpath)((0, import_node_os4.homedir)()).catch(() => (0, import_node_os4.homedir)());
|
|
40635
40742
|
if (!/\.md$/i.test(real) || insideOrEqual(home, real) && hasHiddenSegment(home, real)) {
|
|
40636
40743
|
throw new Error(say("\u4E0D\u652F\u6301\u8BBF\u95EE\u8BE5\u6587\u4EF6\u3002", "This file cannot be opened."));
|
|
40637
40744
|
}
|
|
@@ -40639,7 +40746,7 @@ async function validatedMarkdownFile(path) {
|
|
|
40639
40746
|
}
|
|
40640
40747
|
async function createInkmapMcpServer(options = {}) {
|
|
40641
40748
|
const loadHtml = async () => {
|
|
40642
|
-
const raw = options.html ?? await (0,
|
|
40749
|
+
const raw = options.html ?? await (0, import_promises6.readFile)(HTML, "utf8").catch((error62) => {
|
|
40643
40750
|
if (error62.code === "ENOENT") {
|
|
40644
40751
|
throw new Error("MCP App editor assets are missing. Run npm run build:sidebars.");
|
|
40645
40752
|
}
|
|
@@ -40692,9 +40799,9 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
40692
40799
|
const clientName = server.server.getClientVersion()?.name ?? "";
|
|
40693
40800
|
let extDir = null;
|
|
40694
40801
|
if (/cursor/i.test(clientName)) {
|
|
40695
|
-
extDir = (0,
|
|
40802
|
+
extDir = (0, import_node_path6.join)(process.env.INKMAP_CURSOR_CONFIG_DIR || (0, import_node_path6.join)((0, import_node_os4.homedir)(), ".cursor"), "extensions");
|
|
40696
40803
|
} else if (/visual studio code|vscode/i.test(clientName)) {
|
|
40697
|
-
extDir = (0,
|
|
40804
|
+
extDir = (0, import_node_path6.join)((0, import_node_os4.homedir)(), ".vscode", "extensions");
|
|
40698
40805
|
}
|
|
40699
40806
|
if (!extDir || !(0, import_node_fs2.existsSync)(extDir))
|
|
40700
40807
|
return false;
|
|
@@ -40714,12 +40821,12 @@ async function createInkmapMcpServer(options = {}) {
|
|
|
40714
40821
|
async function waitForEditorBridgeAck(seq, timeoutMs = 280) {
|
|
40715
40822
|
if (!seq)
|
|
40716
40823
|
return false;
|
|
40717
|
-
const inkmapDir = process.env.INKMAP_HOME || (0,
|
|
40718
|
-
const ackPath = (0,
|
|
40824
|
+
const inkmapDir = process.env.INKMAP_HOME || (0, import_node_path6.join)((0, import_node_os4.homedir)(), ".inkmap");
|
|
40825
|
+
const ackPath = (0, import_node_path6.join)(inkmapDir, "antigravity-target-ack.json");
|
|
40719
40826
|
const deadline = Date.now() + timeoutMs;
|
|
40720
40827
|
while (Date.now() < deadline) {
|
|
40721
40828
|
try {
|
|
40722
|
-
const raw = JSON.parse(await (0,
|
|
40829
|
+
const raw = JSON.parse(await (0, import_promises6.readFile)(ackPath, "utf8"));
|
|
40723
40830
|
if (raw && raw.ok === true && Number(raw.seq) >= seq) {
|
|
40724
40831
|
return true;
|
|
40725
40832
|
}
|
|
@@ -40989,7 +41096,7 @@ async function serveCodex() {
|
|
|
40989
41096
|
process.once("SIGINT", shutdown);
|
|
40990
41097
|
await server.connect(transport);
|
|
40991
41098
|
}
|
|
40992
|
-
var import_node_fs2,
|
|
41099
|
+
var import_node_fs2, import_promises6, import_node_os4, import_node_path6, import_node_url3, UI, HTML, WEB_ROOT_CANDIDATES, INLINE_DOC_LIMIT, appOnly;
|
|
40993
41100
|
var init_codex = __esm({
|
|
40994
41101
|
"packages/cli/dist/codex.js"() {
|
|
40995
41102
|
"use strict";
|
|
@@ -40997,9 +41104,9 @@ var init_codex = __esm({
|
|
|
40997
41104
|
init_stdio2();
|
|
40998
41105
|
init_server4();
|
|
40999
41106
|
import_node_fs2 = require("node:fs");
|
|
41000
|
-
|
|
41107
|
+
import_promises6 = require("node:fs/promises");
|
|
41001
41108
|
import_node_os4 = require("node:os");
|
|
41002
|
-
|
|
41109
|
+
import_node_path6 = require("node:path");
|
|
41003
41110
|
import_node_url3 = require("node:url");
|
|
41004
41111
|
init_zod();
|
|
41005
41112
|
init_dist();
|
|
@@ -41161,33 +41268,33 @@ function isChineseTerminalLocale() {
|
|
|
41161
41268
|
return detectOsLocale() === "zh";
|
|
41162
41269
|
}
|
|
41163
41270
|
function getInkmapHome() {
|
|
41164
|
-
return process.env.INKMAP_HOME || (0,
|
|
41271
|
+
return process.env.INKMAP_HOME || (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".inkmap");
|
|
41165
41272
|
}
|
|
41166
41273
|
function getClaudeDesktopDir() {
|
|
41167
41274
|
if (process.env.INKMAP_CLAUDE_CONFIG_DIR)
|
|
41168
41275
|
return process.env.INKMAP_CLAUDE_CONFIG_DIR;
|
|
41169
41276
|
if (process.platform === "darwin") {
|
|
41170
|
-
return (0,
|
|
41277
|
+
return (0, import_node_path7.join)((0, import_node_os5.homedir)(), "Library", "Application Support", "Claude");
|
|
41171
41278
|
}
|
|
41172
41279
|
if (process.platform === "win32") {
|
|
41173
|
-
const appData = process.env.APPDATA || (0,
|
|
41174
|
-
return (0,
|
|
41280
|
+
const appData = process.env.APPDATA || (0, import_node_path7.join)((0, import_node_os5.homedir)(), "AppData", "Roaming");
|
|
41281
|
+
return (0, import_node_path7.join)(appData, "Claude");
|
|
41175
41282
|
}
|
|
41176
|
-
const xdg = process.env.XDG_CONFIG_HOME || (0,
|
|
41177
|
-
return (0,
|
|
41283
|
+
const xdg = process.env.XDG_CONFIG_HOME || (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".config");
|
|
41284
|
+
return (0, import_node_path7.join)(xdg, "Claude");
|
|
41178
41285
|
}
|
|
41179
41286
|
function getCursorDir() {
|
|
41180
|
-
return process.env.INKMAP_CURSOR_CONFIG_DIR || (0,
|
|
41287
|
+
return process.env.INKMAP_CURSOR_CONFIG_DIR || (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".cursor");
|
|
41181
41288
|
}
|
|
41182
41289
|
function getEditorDir(editor) {
|
|
41183
41290
|
const { env, dir } = EXTENSION_EDITORS[editor];
|
|
41184
|
-
return process.env[env] || (0,
|
|
41291
|
+
return process.env[env] || (0, import_node_path7.join)((0, import_node_os5.homedir)(), dir);
|
|
41185
41292
|
}
|
|
41186
41293
|
function getClaudeCodeConfigPath() {
|
|
41187
|
-
return process.env.INKMAP_CLAUDE_CODE_CONFIG || (0,
|
|
41294
|
+
return process.env.INKMAP_CLAUDE_CODE_CONFIG || (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".claude.json");
|
|
41188
41295
|
}
|
|
41189
41296
|
function getAntigravityConfigDir() {
|
|
41190
|
-
return process.env.ANTIGRAVITY_CONFIG_DIR || (0,
|
|
41297
|
+
return process.env.ANTIGRAVITY_CONFIG_DIR || (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".gemini", "config");
|
|
41191
41298
|
}
|
|
41192
41299
|
function editorPathMarkers(editor) {
|
|
41193
41300
|
if (editor === "cursor")
|
|
@@ -41197,9 +41304,9 @@ function editorPathMarkers(editor) {
|
|
|
41197
41304
|
}
|
|
41198
41305
|
function resolveCommandOnPath(cmd) {
|
|
41199
41306
|
const exts = process.platform === "win32" ? ["", ".cmd", ".exe", ".bat"] : [""];
|
|
41200
|
-
for (const dir of (process.env.PATH || "").split(
|
|
41307
|
+
for (const dir of (process.env.PATH || "").split(import_node_path7.delimiter).filter(Boolean)) {
|
|
41201
41308
|
for (const ext of exts) {
|
|
41202
|
-
const candidate = (0,
|
|
41309
|
+
const candidate = (0, import_node_path7.join)(dir, cmd + ext);
|
|
41203
41310
|
try {
|
|
41204
41311
|
if ((0, import_node_fs3.statSync)(candidate).isFile())
|
|
41205
41312
|
return (0, import_node_fs3.realpathSync)(candidate);
|
|
@@ -41223,14 +41330,14 @@ function findCursorCommand() {
|
|
|
41223
41330
|
if (process.env.INKMAP_ISOLATED_DETECT)
|
|
41224
41331
|
return null;
|
|
41225
41332
|
if (process.platform === "darwin") {
|
|
41226
|
-
for (const dir of ["/Applications", (0,
|
|
41227
|
-
const cmd = (0,
|
|
41333
|
+
for (const dir of ["/Applications", (0, import_node_path7.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
41334
|
+
const cmd = (0, import_node_path7.join)(dir, "Cursor.app/Contents/Resources/app/bin/cursor");
|
|
41228
41335
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41229
41336
|
return cmd;
|
|
41230
41337
|
}
|
|
41231
41338
|
} else if (process.platform === "win32") {
|
|
41232
|
-
const localApp = process.env.LOCALAPPDATA || (0,
|
|
41233
|
-
const cmd = (0,
|
|
41339
|
+
const localApp = process.env.LOCALAPPDATA || (0, import_node_path7.join)((0, import_node_os5.homedir)(), "AppData", "Local");
|
|
41340
|
+
const cmd = (0, import_node_path7.join)(localApp, "Programs", "cursor", "resources", "app", "bin", "cursor.cmd");
|
|
41234
41341
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41235
41342
|
return cmd;
|
|
41236
41343
|
}
|
|
@@ -41241,14 +41348,14 @@ function findEditorCommand(editor) {
|
|
|
41241
41348
|
return null;
|
|
41242
41349
|
const { cli, macApp, winDir } = EXTENSION_EDITORS[editor];
|
|
41243
41350
|
if (process.platform === "darwin") {
|
|
41244
|
-
for (const dir of ["/Applications", (0,
|
|
41245
|
-
const cmd = (0,
|
|
41351
|
+
for (const dir of ["/Applications", (0, import_node_path7.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
41352
|
+
const cmd = (0, import_node_path7.join)(dir, macApp, "Contents", "Resources", "app", "bin", cli);
|
|
41246
41353
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41247
41354
|
return cmd;
|
|
41248
41355
|
}
|
|
41249
41356
|
} else if (process.platform === "win32") {
|
|
41250
|
-
const localApp = process.env.LOCALAPPDATA || (0,
|
|
41251
|
-
const cmd = (0,
|
|
41357
|
+
const localApp = process.env.LOCALAPPDATA || (0, import_node_path7.join)((0, import_node_os5.homedir)(), "AppData", "Local");
|
|
41358
|
+
const cmd = (0, import_node_path7.join)(localApp, "Programs", winDir, "bin", `${cli}.cmd`);
|
|
41252
41359
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41253
41360
|
return cmd;
|
|
41254
41361
|
}
|
|
@@ -41268,8 +41375,8 @@ function findCodexCommand() {
|
|
|
41268
41375
|
if (probeCliCommand("codex"))
|
|
41269
41376
|
return "codex";
|
|
41270
41377
|
if (process.platform === "darwin") {
|
|
41271
|
-
for (const dir of ["/Applications", (0,
|
|
41272
|
-
const cmd = (0,
|
|
41378
|
+
for (const dir of ["/Applications", (0, import_node_path7.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
41379
|
+
const cmd = (0, import_node_path7.join)(dir, "ChatGPT.app/Contents/Resources/codex-cli/bin/codex");
|
|
41273
41380
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41274
41381
|
return cmd;
|
|
41275
41382
|
}
|
|
@@ -41277,7 +41384,7 @@ function findCodexCommand() {
|
|
|
41277
41384
|
return null;
|
|
41278
41385
|
}
|
|
41279
41386
|
function getDshHome() {
|
|
41280
|
-
return process.env.DSH_HOME || (0,
|
|
41387
|
+
return process.env.DSH_HOME || (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".dsh");
|
|
41281
41388
|
}
|
|
41282
41389
|
function findDshCommand() {
|
|
41283
41390
|
if (process.env.INKMAP_DSH_BIN) {
|
|
@@ -41288,14 +41395,14 @@ function findDshCommand() {
|
|
|
41288
41395
|
if (probeCliCommand("dsh"))
|
|
41289
41396
|
return "dsh";
|
|
41290
41397
|
if (process.platform === "darwin") {
|
|
41291
|
-
for (const dir of ["/Applications", (0,
|
|
41292
|
-
const cmd = (0,
|
|
41398
|
+
for (const dir of ["/Applications", (0, import_node_path7.join)((0, import_node_os5.homedir)(), "Applications")]) {
|
|
41399
|
+
const cmd = (0, import_node_path7.join)(dir, "DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh");
|
|
41293
41400
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41294
41401
|
return cmd;
|
|
41295
41402
|
}
|
|
41296
41403
|
} else if (process.platform === "win32") {
|
|
41297
|
-
const localApp = process.env.LOCALAPPDATA || (0,
|
|
41298
|
-
const cmd = (0,
|
|
41404
|
+
const localApp = process.env.LOCALAPPDATA || (0, import_node_path7.join)((0, import_node_os5.homedir)(), "AppData", "Local");
|
|
41405
|
+
const cmd = (0, import_node_path7.join)(localApp, "Programs", "DeepSeek Harness", "resources", "runtime", "cli", "bin", "dsh.cmd");
|
|
41299
41406
|
if ((0, import_node_fs3.existsSync)(cmd))
|
|
41300
41407
|
return cmd;
|
|
41301
41408
|
}
|
|
@@ -41304,7 +41411,7 @@ function findDshCommand() {
|
|
|
41304
41411
|
function detectInstalledTargets() {
|
|
41305
41412
|
const found = [];
|
|
41306
41413
|
const claudeDir = getClaudeDesktopDir();
|
|
41307
|
-
if ((0, import_node_fs3.existsSync)(claudeDir) || process.platform === "darwin" && ((0, import_node_fs3.existsSync)("/Applications/Claude.app") || (0, import_node_fs3.existsSync)((0,
|
|
41414
|
+
if ((0, import_node_fs3.existsSync)(claudeDir) || process.platform === "darwin" && ((0, import_node_fs3.existsSync)("/Applications/Claude.app") || (0, import_node_fs3.existsSync)((0, import_node_path7.join)((0, import_node_os5.homedir)(), "Applications", "Claude.app")))) {
|
|
41308
41415
|
found.push("claude");
|
|
41309
41416
|
}
|
|
41310
41417
|
const claudeCodeCfg = getClaudeCodeConfigPath();
|
|
@@ -41319,7 +41426,7 @@ function detectInstalledTargets() {
|
|
|
41319
41426
|
found.push(editor);
|
|
41320
41427
|
}
|
|
41321
41428
|
const agyDir = getAntigravityConfigDir();
|
|
41322
|
-
if ((0, import_node_fs3.existsSync)(agyDir) || !process.env.ANTIGRAVITY_CONFIG_DIR && (0, import_node_fs3.existsSync)((0,
|
|
41429
|
+
if ((0, import_node_fs3.existsSync)(agyDir) || !process.env.ANTIGRAVITY_CONFIG_DIR && (0, import_node_fs3.existsSync)((0, import_node_path7.join)((0, import_node_os5.homedir)(), ".gemini", "antigravity"))) {
|
|
41323
41430
|
found.push("antigravity");
|
|
41324
41431
|
}
|
|
41325
41432
|
if (!process.env.INKMAP_ISOLATED_DETECT && findCodexCommand()) {
|
|
@@ -41327,7 +41434,7 @@ function detectInstalledTargets() {
|
|
|
41327
41434
|
} else if (process.env.INKMAP_CODEX_BIN && (0, import_node_fs3.existsSync)(process.env.INKMAP_CODEX_BIN)) {
|
|
41328
41435
|
found.push("codex");
|
|
41329
41436
|
}
|
|
41330
|
-
if (!process.env.INKMAP_ISOLATED_DETECT && (findDshCommand() || (0, import_node_fs3.existsSync)((0,
|
|
41437
|
+
if (!process.env.INKMAP_ISOLATED_DETECT && (findDshCommand() || (0, import_node_fs3.existsSync)((0, import_node_path7.join)(getDshHome(), "profiles", "desktop"))) || process.env.INKMAP_DSH_BIN && (0, import_node_fs3.existsSync)(process.env.INKMAP_DSH_BIN)) {
|
|
41331
41438
|
found.push("deepseek");
|
|
41332
41439
|
}
|
|
41333
41440
|
return found;
|
|
@@ -41350,7 +41457,7 @@ function readJsonObject(filePath) {
|
|
|
41350
41457
|
return parsed;
|
|
41351
41458
|
}
|
|
41352
41459
|
function writeJsonAtomic(filePath, data) {
|
|
41353
|
-
(0, import_node_fs3.mkdirSync)((0,
|
|
41460
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path7.dirname)(filePath), { recursive: true });
|
|
41354
41461
|
let target = filePath;
|
|
41355
41462
|
let mode = 384;
|
|
41356
41463
|
try {
|
|
@@ -41363,67 +41470,67 @@ function writeJsonAtomic(filePath, data) {
|
|
|
41363
41470
|
(0, import_node_fs3.renameSync)(tmp, target);
|
|
41364
41471
|
}
|
|
41365
41472
|
function stageStandaloneMcpApp() {
|
|
41366
|
-
const appDir = (0,
|
|
41473
|
+
const appDir = (0, import_node_path7.join)(getInkmapHome(), "mcp-app");
|
|
41367
41474
|
(0, import_node_fs3.mkdirSync)(appDir, { recursive: true });
|
|
41368
|
-
const bundledCli = (0,
|
|
41369
|
-
const bundledHtml = (0,
|
|
41370
|
-
const bundledWeb = (0,
|
|
41371
|
-
const monorepoAntigravity = (0,
|
|
41475
|
+
const bundledCli = (0, import_node_path7.join)(DIST_DIR, "cli.cjs");
|
|
41476
|
+
const bundledHtml = (0, import_node_path7.join)(DIST_DIR, "codex.html");
|
|
41477
|
+
const bundledWeb = (0, import_node_path7.join)(DIST_DIR, "web");
|
|
41478
|
+
const monorepoAntigravity = (0, import_node_path7.resolve)(PKG_ROOT, "..", "..", "dist", "sidebars", "inkmap-antigravity", "inkmap");
|
|
41372
41479
|
if ((0, import_node_fs3.existsSync)(bundledCli) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
41373
|
-
(0, import_node_fs3.cpSync)(bundledCli, (0,
|
|
41374
|
-
(0, import_node_fs3.cpSync)(bundledHtml, (0,
|
|
41480
|
+
(0, import_node_fs3.cpSync)(bundledCli, (0, import_node_path7.join)(appDir, "cli.cjs"));
|
|
41481
|
+
(0, import_node_fs3.cpSync)(bundledHtml, (0, import_node_path7.join)(appDir, "codex.html"));
|
|
41375
41482
|
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
41376
|
-
(0, import_node_fs3.rmSync)((0,
|
|
41377
|
-
(0, import_node_fs3.cpSync)(bundledWeb, (0,
|
|
41483
|
+
(0, import_node_fs3.rmSync)((0, import_node_path7.join)(appDir, "web"), { recursive: true, force: true });
|
|
41484
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path7.join)(appDir, "web"), { recursive: true });
|
|
41378
41485
|
}
|
|
41379
|
-
(0, import_node_fs3.writeFileSync)((0,
|
|
41486
|
+
(0, import_node_fs3.writeFileSync)((0, import_node_path7.join)(appDir, "server.cjs"), SERVER_WRAPPER, { mode: 493 });
|
|
41380
41487
|
for (const notice of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
41381
|
-
const src = (0,
|
|
41488
|
+
const src = (0, import_node_path7.join)(PKG_ROOT, notice);
|
|
41382
41489
|
if ((0, import_node_fs3.existsSync)(src))
|
|
41383
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
41490
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path7.join)(appDir, notice));
|
|
41384
41491
|
}
|
|
41385
|
-
return { serverScript: (0,
|
|
41492
|
+
return { serverScript: (0, import_node_path7.join)(appDir, "server.cjs"), appDir };
|
|
41386
41493
|
}
|
|
41387
|
-
if ((0, import_node_fs3.existsSync)((0,
|
|
41388
|
-
(0, import_node_fs3.cpSync)((0,
|
|
41389
|
-
(0, import_node_fs3.cpSync)((0,
|
|
41390
|
-
const sidecarWeb = (0,
|
|
41494
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path7.join)(monorepoAntigravity, "server.cjs")) && (0, import_node_fs3.existsSync)((0, import_node_path7.join)(monorepoAntigravity, "codex.html"))) {
|
|
41495
|
+
(0, import_node_fs3.cpSync)((0, import_node_path7.join)(monorepoAntigravity, "server.cjs"), (0, import_node_path7.join)(appDir, "server.cjs"));
|
|
41496
|
+
(0, import_node_fs3.cpSync)((0, import_node_path7.join)(monorepoAntigravity, "codex.html"), (0, import_node_path7.join)(appDir, "codex.html"));
|
|
41497
|
+
const sidecarWeb = (0, import_node_path7.join)(monorepoAntigravity, "sidecars", "inkmap", "web");
|
|
41391
41498
|
if ((0, import_node_fs3.existsSync)(sidecarWeb)) {
|
|
41392
|
-
(0, import_node_fs3.rmSync)((0,
|
|
41393
|
-
(0, import_node_fs3.cpSync)(sidecarWeb, (0,
|
|
41499
|
+
(0, import_node_fs3.rmSync)((0, import_node_path7.join)(appDir, "web"), { recursive: true, force: true });
|
|
41500
|
+
(0, import_node_fs3.cpSync)(sidecarWeb, (0, import_node_path7.join)(appDir, "web"), { recursive: true });
|
|
41394
41501
|
}
|
|
41395
41502
|
for (const notice of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
41396
|
-
const src = (0,
|
|
41503
|
+
const src = (0, import_node_path7.join)(monorepoAntigravity, notice);
|
|
41397
41504
|
if ((0, import_node_fs3.existsSync)(src))
|
|
41398
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
41505
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path7.join)(appDir, notice));
|
|
41399
41506
|
}
|
|
41400
|
-
return { serverScript: (0,
|
|
41507
|
+
return { serverScript: (0, import_node_path7.join)(appDir, "server.cjs"), appDir };
|
|
41401
41508
|
}
|
|
41402
|
-
const devBin = (0,
|
|
41509
|
+
const devBin = (0, import_node_path7.join)(PKG_ROOT, "bin", "inkmap.js");
|
|
41403
41510
|
if ((0, import_node_fs3.existsSync)(devBin) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
41404
41511
|
return { serverScript: devBin, appDir };
|
|
41405
41512
|
}
|
|
41406
41513
|
throw new Error("\u672A\u627E\u5230\u5DF2\u6784\u5EFA\u7684 MCP App \u8D44\u6E90\uFF08codex.html\uFF09\u3002/ Built MCP App assets are missing.");
|
|
41407
41514
|
}
|
|
41408
41515
|
function installIdeExtension(editorDir, cliCmd) {
|
|
41409
|
-
const vscodeBundle = (0,
|
|
41410
|
-
const bundledWeb = (0,
|
|
41411
|
-
if (!(0, import_node_fs3.existsSync)((0,
|
|
41516
|
+
const vscodeBundle = (0, import_node_path7.join)(DIST_DIR, "bundles", "vscode");
|
|
41517
|
+
const bundledWeb = (0, import_node_path7.join)(DIST_DIR, "web");
|
|
41518
|
+
if (!(0, import_node_fs3.existsSync)((0, import_node_path7.join)(vscodeBundle, "package.json")) || !(0, import_node_fs3.existsSync)((0, import_node_path7.join)(vscodeBundle, "dist", "extension.js"))) {
|
|
41412
41519
|
return null;
|
|
41413
41520
|
}
|
|
41414
|
-
const extPkg = JSON.parse((0, import_node_fs3.readFileSync)((0,
|
|
41521
|
+
const extPkg = JSON.parse((0, import_node_fs3.readFileSync)((0, import_node_path7.join)(vscodeBundle, "package.json"), "utf8"));
|
|
41415
41522
|
const version2 = extPkg.version;
|
|
41416
|
-
const staging = (0, import_node_fs3.mkdtempSync)((0,
|
|
41523
|
+
const staging = (0, import_node_fs3.mkdtempSync)((0, import_node_path7.join)((0, import_node_os5.tmpdir)(), "inkmap-vsix-"));
|
|
41417
41524
|
try {
|
|
41418
|
-
const extStaging = (0,
|
|
41525
|
+
const extStaging = (0, import_node_path7.join)(staging, "extension");
|
|
41419
41526
|
(0, import_node_fs3.cpSync)(vscodeBundle, extStaging, { recursive: true });
|
|
41420
41527
|
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
41421
|
-
(0, import_node_fs3.cpSync)(bundledWeb, (0,
|
|
41528
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path7.join)(extStaging, "dist", "web"), { recursive: true });
|
|
41422
41529
|
}
|
|
41423
41530
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md", "README.md"]) {
|
|
41424
|
-
const src = (0,
|
|
41531
|
+
const src = (0, import_node_path7.join)(PKG_ROOT, doc);
|
|
41425
41532
|
if ((0, import_node_fs3.existsSync)(src))
|
|
41426
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
41533
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path7.join)(extStaging, doc));
|
|
41427
41534
|
}
|
|
41428
41535
|
if (cliCmd) {
|
|
41429
41536
|
const contentTypesXml = `<?xml version="1.0" encoding="utf-8"?>
|
|
@@ -41436,7 +41543,7 @@ function installIdeExtension(editorDir, cliCmd) {
|
|
|
41436
41543
|
];
|
|
41437
41544
|
const walk = (dir, prefix) => {
|
|
41438
41545
|
for (const item of (0, import_node_fs3.readdirSync)(dir, { withFileTypes: true })) {
|
|
41439
|
-
const full = (0,
|
|
41546
|
+
const full = (0, import_node_path7.join)(dir, item.name);
|
|
41440
41547
|
const rel = `${prefix}/${item.name}`;
|
|
41441
41548
|
if (item.isDirectory())
|
|
41442
41549
|
walk(full, rel);
|
|
@@ -41445,28 +41552,28 @@ function installIdeExtension(editorDir, cliCmd) {
|
|
|
41445
41552
|
}
|
|
41446
41553
|
};
|
|
41447
41554
|
walk(extStaging, "extension");
|
|
41448
|
-
const vsixPath = (0,
|
|
41555
|
+
const vsixPath = (0, import_node_path7.join)(staging, `inkmap-${version2}.vsix`);
|
|
41449
41556
|
(0, import_node_fs3.writeFileSync)(vsixPath, buildZipBuffer(entries));
|
|
41450
41557
|
try {
|
|
41451
41558
|
execCliSync(cliCmd, ["--install-extension", vsixPath, "--force"], { stdio: "pipe" });
|
|
41452
|
-
const installed = (0,
|
|
41453
|
-
if ((0, import_node_fs3.existsSync)((0,
|
|
41559
|
+
const installed = (0, import_node_path7.join)(editorDir, "extensions", `inkmap.inkmap-vscode-${version2}`);
|
|
41560
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path7.join)(installed, "package.json")))
|
|
41454
41561
|
return installed;
|
|
41455
41562
|
} catch {
|
|
41456
41563
|
}
|
|
41457
41564
|
}
|
|
41458
|
-
const extRoot = (0,
|
|
41565
|
+
const extRoot = (0, import_node_path7.join)(editorDir, "extensions");
|
|
41459
41566
|
(0, import_node_fs3.mkdirSync)(extRoot, { recursive: true });
|
|
41460
41567
|
for (const old of (0, import_node_fs3.readdirSync)(extRoot)) {
|
|
41461
41568
|
if (old.toLowerCase().startsWith("inkmap.inkmap-vscode")) {
|
|
41462
|
-
(0, import_node_fs3.rmSync)((0,
|
|
41569
|
+
(0, import_node_fs3.rmSync)((0, import_node_path7.join)(extRoot, old), { recursive: true, force: true });
|
|
41463
41570
|
}
|
|
41464
41571
|
}
|
|
41465
41572
|
const folderName = `inkmap.inkmap-vscode-${version2}`;
|
|
41466
|
-
const dest = (0,
|
|
41573
|
+
const dest = (0, import_node_path7.join)(extRoot, folderName);
|
|
41467
41574
|
(0, import_node_fs3.cpSync)(extStaging, dest, { recursive: true });
|
|
41468
41575
|
try {
|
|
41469
|
-
const obsoletePath = (0,
|
|
41576
|
+
const obsoletePath = (0, import_node_path7.join)(extRoot, ".obsolete");
|
|
41470
41577
|
if ((0, import_node_fs3.existsSync)(obsoletePath)) {
|
|
41471
41578
|
const obs = JSON.parse((0, import_node_fs3.readFileSync)(obsoletePath, "utf8"));
|
|
41472
41579
|
let changedObs = false;
|
|
@@ -41479,7 +41586,7 @@ function installIdeExtension(editorDir, cliCmd) {
|
|
|
41479
41586
|
if (changedObs)
|
|
41480
41587
|
writeJsonAtomic(obsoletePath, obs);
|
|
41481
41588
|
}
|
|
41482
|
-
const registryPath = (0,
|
|
41589
|
+
const registryPath = (0, import_node_path7.join)(extRoot, "extensions.json");
|
|
41483
41590
|
const existingList = (0, import_node_fs3.existsSync)(registryPath) ? JSON.parse((0, import_node_fs3.readFileSync)(registryPath, "utf8")) : [];
|
|
41484
41591
|
if (Array.isArray(existingList)) {
|
|
41485
41592
|
const filtered = existingList.filter((item) => String(item?.identifier?.id ?? "").toLowerCase() !== "inkmap.inkmap-vscode");
|
|
@@ -41520,16 +41627,16 @@ function uninstallIdeExtension(editorDir, cliCmd) {
|
|
|
41520
41627
|
} catch {
|
|
41521
41628
|
}
|
|
41522
41629
|
}
|
|
41523
|
-
const extRoot = (0,
|
|
41630
|
+
const extRoot = (0, import_node_path7.join)(editorDir, "extensions");
|
|
41524
41631
|
if ((0, import_node_fs3.existsSync)(extRoot)) {
|
|
41525
41632
|
for (const entry of (0, import_node_fs3.readdirSync)(extRoot)) {
|
|
41526
41633
|
if (entry.toLowerCase().startsWith("inkmap.inkmap-vscode")) {
|
|
41527
|
-
(0, import_node_fs3.rmSync)((0,
|
|
41634
|
+
(0, import_node_fs3.rmSync)((0, import_node_path7.join)(extRoot, entry), { recursive: true, force: true });
|
|
41528
41635
|
removed = true;
|
|
41529
41636
|
}
|
|
41530
41637
|
}
|
|
41531
41638
|
try {
|
|
41532
|
-
const registryPath = (0,
|
|
41639
|
+
const registryPath = (0, import_node_path7.join)(extRoot, "extensions.json");
|
|
41533
41640
|
if ((0, import_node_fs3.existsSync)(registryPath)) {
|
|
41534
41641
|
const existingList = JSON.parse((0, import_node_fs3.readFileSync)(registryPath, "utf8"));
|
|
41535
41642
|
if (Array.isArray(existingList)) {
|
|
@@ -41551,7 +41658,7 @@ function buildMcpEntry(serverScript, workspaces, existingEntry, withTypeStdio =
|
|
|
41551
41658
|
const args = isDirectServer ? [serverScript] : [serverScript, "mcp"];
|
|
41552
41659
|
const prevEnv = existingEntry && typeof existingEntry === "object" && !Array.isArray(existingEntry) && typeof existingEntry.env === "object" ? { ...existingEntry.env } : {};
|
|
41553
41660
|
if (workspaces.length > 0) {
|
|
41554
|
-
prevEnv.INKMAP_WORKSPACES = workspaces.map((w2) => (0,
|
|
41661
|
+
prevEnv.INKMAP_WORKSPACES = workspaces.map((w2) => (0, import_node_path7.resolve)(w2)).join(import_node_path7.delimiter);
|
|
41555
41662
|
}
|
|
41556
41663
|
const entry = {};
|
|
41557
41664
|
if (withTypeStdio)
|
|
@@ -41602,36 +41709,36 @@ async function refreshAntigravityMcp() {
|
|
|
41602
41709
|
}
|
|
41603
41710
|
}
|
|
41604
41711
|
async function installAntigravityPlugin(workspaces = []) {
|
|
41605
|
-
const pluginsDir = (0,
|
|
41606
|
-
const destination = (0,
|
|
41607
|
-
const bundledAgy = (0,
|
|
41608
|
-
const bundledCli = (0,
|
|
41609
|
-
const bundledHtml = (0,
|
|
41610
|
-
const bundledWeb = (0,
|
|
41611
|
-
const monorepoAgy = (0,
|
|
41712
|
+
const pluginsDir = (0, import_node_path7.join)(getAntigravityConfigDir(), "plugins");
|
|
41713
|
+
const destination = (0, import_node_path7.join)(pluginsDir, "inkmap");
|
|
41714
|
+
const bundledAgy = (0, import_node_path7.join)(DIST_DIR, "bundles", "antigravity");
|
|
41715
|
+
const bundledCli = (0, import_node_path7.join)(DIST_DIR, "cli.cjs");
|
|
41716
|
+
const bundledHtml = (0, import_node_path7.join)(DIST_DIR, "codex.html");
|
|
41717
|
+
const bundledWeb = (0, import_node_path7.join)(DIST_DIR, "web");
|
|
41718
|
+
const monorepoAgy = (0, import_node_path7.resolve)(PKG_ROOT, "..", "..", "dist", "sidebars", "inkmap-antigravity", "inkmap");
|
|
41612
41719
|
(0, import_node_fs3.mkdirSync)(pluginsDir, { recursive: true });
|
|
41613
41720
|
(0, import_node_fs3.rmSync)(destination, { recursive: true, force: true });
|
|
41614
|
-
if ((0, import_node_fs3.existsSync)((0,
|
|
41721
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path7.join)(bundledAgy, "plugin.json")) && (0, import_node_fs3.existsSync)(bundledCli) && (0, import_node_fs3.existsSync)(bundledHtml)) {
|
|
41615
41722
|
(0, import_node_fs3.cpSync)(bundledAgy, destination, { recursive: true });
|
|
41616
|
-
(0, import_node_fs3.cpSync)(bundledCli, (0,
|
|
41617
|
-
(0, import_node_fs3.cpSync)(bundledHtml, (0,
|
|
41618
|
-
(0, import_node_fs3.writeFileSync)((0,
|
|
41723
|
+
(0, import_node_fs3.cpSync)(bundledCli, (0, import_node_path7.join)(destination, "cli.cjs"));
|
|
41724
|
+
(0, import_node_fs3.cpSync)(bundledHtml, (0, import_node_path7.join)(destination, "codex.html"));
|
|
41725
|
+
(0, import_node_fs3.writeFileSync)((0, import_node_path7.join)(destination, "server.cjs"), SERVER_WRAPPER, { mode: 493 });
|
|
41619
41726
|
if ((0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
41620
|
-
(0, import_node_fs3.cpSync)(bundledWeb, (0,
|
|
41727
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path7.join)(destination, "sidecars", "inkmap", "web"), { recursive: true });
|
|
41621
41728
|
}
|
|
41622
41729
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md", "README.md"]) {
|
|
41623
|
-
const src = (0,
|
|
41730
|
+
const src = (0, import_node_path7.join)(PKG_ROOT, doc);
|
|
41624
41731
|
if ((0, import_node_fs3.existsSync)(src))
|
|
41625
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
41732
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path7.join)(destination, doc));
|
|
41626
41733
|
}
|
|
41627
|
-
} else if ((0, import_node_fs3.existsSync)((0,
|
|
41734
|
+
} else if ((0, import_node_fs3.existsSync)((0, import_node_path7.join)(monorepoAgy, "plugin.json"))) {
|
|
41628
41735
|
(0, import_node_fs3.cpSync)(monorepoAgy, destination, { recursive: true });
|
|
41629
41736
|
} else {
|
|
41630
41737
|
throw new Error("\u672A\u627E\u5230 Antigravity \u63D2\u4EF6\u8D44\u6E90 / Antigravity plugin bundle not found.");
|
|
41631
41738
|
}
|
|
41632
41739
|
if (workspaces.length > 0) {
|
|
41633
41740
|
try {
|
|
41634
|
-
const mcpCfgPath = (0,
|
|
41741
|
+
const mcpCfgPath = (0, import_node_path7.join)(destination, "mcp_config.json");
|
|
41635
41742
|
if ((0, import_node_fs3.existsSync)(mcpCfgPath)) {
|
|
41636
41743
|
const cfg = readJsonObject(mcpCfgPath);
|
|
41637
41744
|
const servers = cfg.mcpServers && typeof cfg.mcpServers === "object" && !Array.isArray(cfg.mcpServers) ? { ...cfg.mcpServers } : {};
|
|
@@ -41640,7 +41747,7 @@ async function installAntigravityPlugin(workspaces = []) {
|
|
|
41640
41747
|
...servers.inkmap,
|
|
41641
41748
|
env: {
|
|
41642
41749
|
...servers.inkmap.env && typeof servers.inkmap.env === "object" ? servers.inkmap.env : {},
|
|
41643
|
-
INKMAP_WORKSPACES: workspaces.map((w2) => (0,
|
|
41750
|
+
INKMAP_WORKSPACES: workspaces.map((w2) => (0, import_node_path7.resolve)(w2)).join(import_node_path7.delimiter)
|
|
41644
41751
|
}
|
|
41645
41752
|
};
|
|
41646
41753
|
cfg.mcpServers = servers;
|
|
@@ -41658,33 +41765,33 @@ function installCodexPlugin(zh) {
|
|
|
41658
41765
|
if (!codex) {
|
|
41659
41766
|
throw new Error("\u672A\u68C0\u6D4B\u5230 codex \u547D\u4EE4\uFF0C\u8BF7\u5148\u5B89\u88C5 ChatGPT Desktop \u6216 Codex CLI / Codex CLI not found.");
|
|
41660
41767
|
}
|
|
41661
|
-
const bundledCodex = (0,
|
|
41662
|
-
const bundledCli = (0,
|
|
41663
|
-
const bundledHtml = (0,
|
|
41664
|
-
const monorepoCodexRoot = (0,
|
|
41665
|
-
const destination = (0,
|
|
41768
|
+
const bundledCodex = (0, import_node_path7.join)(DIST_DIR, "bundles", "codex");
|
|
41769
|
+
const bundledCli = (0, import_node_path7.join)(DIST_DIR, "cli.cjs");
|
|
41770
|
+
const bundledHtml = (0, import_node_path7.join)(DIST_DIR, "codex.html");
|
|
41771
|
+
const monorepoCodexRoot = (0, import_node_path7.resolve)(PKG_ROOT, "..", "..", "dist", "sidebars");
|
|
41772
|
+
const destination = (0, import_node_path7.join)(getInkmapHome(), "codex-marketplace");
|
|
41666
41773
|
(0, import_node_fs3.mkdirSync)(destination, { recursive: true });
|
|
41667
41774
|
const marketplaceRoot = (0, import_node_fs3.realpathSync)(destination);
|
|
41668
|
-
const fromNpmBundle = (0, import_node_fs3.existsSync)((0,
|
|
41669
|
-
const fromMonorepo = (0, import_node_fs3.existsSync)((0,
|
|
41775
|
+
const fromNpmBundle = (0, import_node_fs3.existsSync)((0, import_node_path7.join)(bundledCodex, ".agents")) && (0, import_node_fs3.existsSync)(bundledCli) && (0, import_node_fs3.existsSync)(bundledHtml);
|
|
41776
|
+
const fromMonorepo = (0, import_node_fs3.existsSync)((0, import_node_path7.join)(monorepoCodexRoot, "inkmap-codex")) && (0, import_node_fs3.existsSync)((0, import_node_path7.join)(monorepoCodexRoot, ".agents"));
|
|
41670
41777
|
if (!fromNpmBundle && !fromMonorepo)
|
|
41671
41778
|
throw new Error("\u672A\u627E\u5230 Codex \u63D2\u4EF6\u8D44\u6E90 / Codex plugin bundle not found.");
|
|
41672
|
-
(0, import_node_fs3.rmSync)((0,
|
|
41673
|
-
(0, import_node_fs3.rmSync)((0,
|
|
41779
|
+
(0, import_node_fs3.rmSync)((0, import_node_path7.join)(marketplaceRoot, ".agents"), { recursive: true, force: true });
|
|
41780
|
+
(0, import_node_fs3.rmSync)((0, import_node_path7.join)(marketplaceRoot, "inkmap-codex"), { recursive: true, force: true });
|
|
41674
41781
|
if (fromNpmBundle) {
|
|
41675
41782
|
(0, import_node_fs3.cpSync)(bundledCodex, marketplaceRoot, { recursive: true });
|
|
41676
|
-
const pluginDir = (0,
|
|
41677
|
-
(0, import_node_fs3.cpSync)(bundledCli, (0,
|
|
41678
|
-
(0, import_node_fs3.cpSync)(bundledHtml, (0,
|
|
41679
|
-
(0, import_node_fs3.writeFileSync)((0,
|
|
41783
|
+
const pluginDir = (0, import_node_path7.join)(marketplaceRoot, "inkmap-codex");
|
|
41784
|
+
(0, import_node_fs3.cpSync)(bundledCli, (0, import_node_path7.join)(pluginDir, "cli.cjs"));
|
|
41785
|
+
(0, import_node_fs3.cpSync)(bundledHtml, (0, import_node_path7.join)(pluginDir, "codex.html"));
|
|
41786
|
+
(0, import_node_fs3.writeFileSync)((0, import_node_path7.join)(pluginDir, "server.cjs"), SERVER_WRAPPER, { mode: 493 });
|
|
41680
41787
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
41681
|
-
const src = (0,
|
|
41788
|
+
const src = (0, import_node_path7.join)(PKG_ROOT, doc);
|
|
41682
41789
|
if ((0, import_node_fs3.existsSync)(src))
|
|
41683
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
41790
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path7.join)(pluginDir, doc));
|
|
41684
41791
|
}
|
|
41685
41792
|
} else {
|
|
41686
|
-
(0, import_node_fs3.cpSync)((0,
|
|
41687
|
-
(0, import_node_fs3.cpSync)((0,
|
|
41793
|
+
(0, import_node_fs3.cpSync)((0, import_node_path7.join)(monorepoCodexRoot, ".agents"), (0, import_node_path7.join)(marketplaceRoot, ".agents"), { recursive: true });
|
|
41794
|
+
(0, import_node_fs3.cpSync)((0, import_node_path7.join)(monorepoCodexRoot, "inkmap-codex"), (0, import_node_path7.join)(marketplaceRoot, "inkmap-codex"), { recursive: true });
|
|
41688
41795
|
}
|
|
41689
41796
|
const marketplaceName = "inkmap-local";
|
|
41690
41797
|
const rawList = execCliSync(codex, ["plugin", "marketplace", "list", "--json"], { encoding: "utf8" });
|
|
@@ -41700,7 +41807,7 @@ function installCodexPlugin(zh) {
|
|
|
41700
41807
|
};
|
|
41701
41808
|
}
|
|
41702
41809
|
function configureDshMarketIndex(profileDir) {
|
|
41703
|
-
const pkgPath = (0,
|
|
41810
|
+
const pkgPath = (0, import_node_path7.join)(profileDir, "package.json");
|
|
41704
41811
|
if ((0, import_node_fs3.existsSync)(pkgPath)) {
|
|
41705
41812
|
try {
|
|
41706
41813
|
const pkg = JSON.parse((0, import_node_fs3.readFileSync)(pkgPath, "utf8"));
|
|
@@ -41720,7 +41827,7 @@ function configureDshMarketIndex(profileDir) {
|
|
|
41720
41827
|
} catch {
|
|
41721
41828
|
}
|
|
41722
41829
|
}
|
|
41723
|
-
const patchPath = (0,
|
|
41830
|
+
const patchPath = (0, import_node_path7.join)(profileDir, "cordis.patch.yml");
|
|
41724
41831
|
const indexUrl = "https://zhiyuanv.com/dsh-index.json";
|
|
41725
41832
|
try {
|
|
41726
41833
|
const existing = (0, import_node_fs3.existsSync)(patchPath) ? (0, import_node_fs3.readFileSync)(patchPath, "utf8") : "";
|
|
@@ -41742,34 +41849,34 @@ function configureDshMarketIndex(profileDir) {
|
|
|
41742
41849
|
}
|
|
41743
41850
|
}
|
|
41744
41851
|
function installDeepSeekHarnessPlugin(zh) {
|
|
41745
|
-
const bundledHarness = (0,
|
|
41746
|
-
const bundledWeb = (0,
|
|
41747
|
-
const monorepoHarness = (0,
|
|
41748
|
-
const stagedDir = (0,
|
|
41852
|
+
const bundledHarness = (0, import_node_path7.join)(DIST_DIR, "bundles", "harness");
|
|
41853
|
+
const bundledWeb = (0, import_node_path7.join)(DIST_DIR, "web");
|
|
41854
|
+
const monorepoHarness = (0, import_node_path7.resolve)(PKG_ROOT, "..", "..", "dist", "sidebars", "dsh-inkmap");
|
|
41855
|
+
const stagedDir = (0, import_node_path7.join)(getInkmapHome(), "dsh-inkmap");
|
|
41749
41856
|
(0, import_node_fs3.rmSync)(stagedDir, { recursive: true, force: true });
|
|
41750
41857
|
(0, import_node_fs3.mkdirSync)(stagedDir, { recursive: true });
|
|
41751
|
-
if ((0, import_node_fs3.existsSync)((0,
|
|
41858
|
+
if ((0, import_node_fs3.existsSync)((0, import_node_path7.join)(bundledHarness, "package.json")) && (0, import_node_fs3.existsSync)(bundledWeb)) {
|
|
41752
41859
|
(0, import_node_fs3.cpSync)(bundledHarness, stagedDir, { recursive: true });
|
|
41753
|
-
(0, import_node_fs3.cpSync)(bundledWeb, (0,
|
|
41860
|
+
(0, import_node_fs3.cpSync)(bundledWeb, (0, import_node_path7.join)(stagedDir, "web"), { recursive: true });
|
|
41754
41861
|
for (const doc of ["LICENSE.md", "THIRD_PARTY_NOTICES.md"]) {
|
|
41755
|
-
const src = (0,
|
|
41862
|
+
const src = (0, import_node_path7.join)(PKG_ROOT, doc);
|
|
41756
41863
|
if ((0, import_node_fs3.existsSync)(src))
|
|
41757
|
-
(0, import_node_fs3.cpSync)(src, (0,
|
|
41864
|
+
(0, import_node_fs3.cpSync)(src, (0, import_node_path7.join)(stagedDir, doc));
|
|
41758
41865
|
}
|
|
41759
|
-
} else if ((0, import_node_fs3.existsSync)((0,
|
|
41866
|
+
} else if ((0, import_node_fs3.existsSync)((0, import_node_path7.join)(monorepoHarness, "package.json"))) {
|
|
41760
41867
|
(0, import_node_fs3.cpSync)(monorepoHarness, stagedDir, { recursive: true });
|
|
41761
41868
|
} else {
|
|
41762
41869
|
throw new Error("\u672A\u627E\u5230 DeepSeek Harness \u63D2\u4EF6\u8D44\u6E90 / DeepSeek Harness plugin bundle not found.");
|
|
41763
41870
|
}
|
|
41764
41871
|
const realStaged = (0, import_node_fs3.realpathSync)(stagedDir);
|
|
41765
41872
|
const dshCmd = findDshCommand();
|
|
41766
|
-
const profileDir = (0,
|
|
41873
|
+
const profileDir = (0, import_node_path7.join)(getDshHome(), "profiles", "desktop");
|
|
41767
41874
|
if (dshCmd) {
|
|
41768
41875
|
execCliSync(dshCmd, ["plugin", "--profile", "desktop", "add", realStaged], { stdio: "pipe" });
|
|
41769
41876
|
} else if ((0, import_node_fs3.existsSync)(profileDir)) {
|
|
41770
|
-
const nodeModulesTarget = (0,
|
|
41877
|
+
const nodeModulesTarget = (0, import_node_path7.join)(profileDir, "node_modules", "dsh-inkmap");
|
|
41771
41878
|
(0, import_node_fs3.rmSync)(nodeModulesTarget, { recursive: true, force: true });
|
|
41772
|
-
(0, import_node_fs3.mkdirSync)((0,
|
|
41879
|
+
(0, import_node_fs3.mkdirSync)((0, import_node_path7.join)(profileDir, "node_modules"), { recursive: true });
|
|
41773
41880
|
(0, import_node_fs3.cpSync)(realStaged, nodeModulesTarget, { recursive: true });
|
|
41774
41881
|
} else {
|
|
41775
41882
|
throw new Error("\u672A\u68C0\u6D4B\u5230 DeepSeek Harness \u5BA2\u6237\u7AEF / DeepSeek Harness not found.");
|
|
@@ -41791,7 +41898,7 @@ async function runInstall(options = {}) {
|
|
|
41791
41898
|
const toRemove = explicitTargets ?? ["claude", "claude-code", "cursor", ...EXTENSION_EDITOR_KEYS, "antigravity", "codex", "deepseek"];
|
|
41792
41899
|
for (const target of toRemove) {
|
|
41793
41900
|
if (target === "claude") {
|
|
41794
|
-
const cfg = (0,
|
|
41901
|
+
const cfg = (0, import_node_path7.join)(getClaudeDesktopDir(), "claude_desktop_config.json");
|
|
41795
41902
|
if (removeMcpJsonConfig(cfg))
|
|
41796
41903
|
result.removed.push({ target, location: cfg });
|
|
41797
41904
|
} else if (target === "claude-code") {
|
|
@@ -41799,17 +41906,17 @@ async function runInstall(options = {}) {
|
|
|
41799
41906
|
if (removeMcpJsonConfig(cfg))
|
|
41800
41907
|
result.removed.push({ target, location: cfg });
|
|
41801
41908
|
} else if (target === "cursor") {
|
|
41802
|
-
const cfg = (0,
|
|
41909
|
+
const cfg = (0, import_node_path7.join)(getCursorDir(), "mcp.json");
|
|
41803
41910
|
const removedMcp = removeMcpJsonConfig(cfg);
|
|
41804
41911
|
const removedExt = uninstallIdeExtension(getCursorDir(), findCursorCommand());
|
|
41805
41912
|
if (removedMcp || removedExt)
|
|
41806
41913
|
result.removed.push({ target, location: cfg });
|
|
41807
41914
|
} else if (isExtensionEditor(target)) {
|
|
41808
41915
|
if (uninstallIdeExtension(getEditorDir(target), findEditorCommand(target))) {
|
|
41809
|
-
result.removed.push({ target, location: (0,
|
|
41916
|
+
result.removed.push({ target, location: (0, import_node_path7.join)(getEditorDir(target), "extensions") });
|
|
41810
41917
|
}
|
|
41811
41918
|
} else if (target === "antigravity") {
|
|
41812
|
-
const dir = (0,
|
|
41919
|
+
const dir = (0, import_node_path7.join)(getAntigravityConfigDir(), "plugins", "inkmap");
|
|
41813
41920
|
if ((0, import_node_fs3.existsSync)(dir)) {
|
|
41814
41921
|
(0, import_node_fs3.rmSync)(dir, { recursive: true, force: true });
|
|
41815
41922
|
await refreshAntigravityMcp();
|
|
@@ -41827,21 +41934,21 @@ async function runInstall(options = {}) {
|
|
|
41827
41934
|
} catch {
|
|
41828
41935
|
}
|
|
41829
41936
|
}
|
|
41830
|
-
const dir = (0,
|
|
41937
|
+
const dir = (0, import_node_path7.join)(getInkmapHome(), "codex-marketplace");
|
|
41831
41938
|
if ((0, import_node_fs3.existsSync)(dir)) {
|
|
41832
41939
|
(0, import_node_fs3.rmSync)(dir, { recursive: true, force: true });
|
|
41833
41940
|
result.removed.push({ target, location: dir });
|
|
41834
41941
|
}
|
|
41835
41942
|
} else if (target === "deepseek") {
|
|
41836
41943
|
const dshCmd = findDshCommand();
|
|
41837
|
-
const profileDir = (0,
|
|
41944
|
+
const profileDir = (0, import_node_path7.join)(getDshHome(), "profiles", "desktop");
|
|
41838
41945
|
if (dshCmd && (0, import_node_fs3.existsSync)(profileDir)) {
|
|
41839
41946
|
try {
|
|
41840
41947
|
execCliSync(dshCmd, ["plugin", "--profile", "desktop", "remove", "dsh-inkmap"], { stdio: "pipe" });
|
|
41841
41948
|
} catch {
|
|
41842
41949
|
}
|
|
41843
41950
|
}
|
|
41844
|
-
const dir = (0,
|
|
41951
|
+
const dir = (0, import_node_path7.join)(getInkmapHome(), "dsh-inkmap");
|
|
41845
41952
|
if ((0, import_node_fs3.existsSync)(dir)) {
|
|
41846
41953
|
(0, import_node_fs3.rmSync)(dir, { recursive: true, force: true });
|
|
41847
41954
|
result.removed.push({ target, location: profileDir });
|
|
@@ -41849,7 +41956,7 @@ async function runInstall(options = {}) {
|
|
|
41849
41956
|
}
|
|
41850
41957
|
}
|
|
41851
41958
|
if (!explicitTargets) {
|
|
41852
|
-
(0, import_node_fs3.rmSync)((0,
|
|
41959
|
+
(0, import_node_fs3.rmSync)((0, import_node_path7.join)(getInkmapHome(), "mcp-app"), { recursive: true, force: true });
|
|
41853
41960
|
}
|
|
41854
41961
|
if (result.removed.length === 0) {
|
|
41855
41962
|
log("[inkmap] \u672A\u53D1\u73B0\u5DF2\u5B89\u88C5\u7684 Inkmap \u5BA2\u6237\u7AEF\u914D\u7F6E / No installed Inkmap client configs found.");
|
|
@@ -41877,7 +41984,7 @@ async function runInstall(options = {}) {
|
|
|
41877
41984
|
}
|
|
41878
41985
|
for (const target of targets) {
|
|
41879
41986
|
if (target === "claude") {
|
|
41880
|
-
const cfg = (0,
|
|
41987
|
+
const cfg = (0, import_node_path7.join)(getClaudeDesktopDir(), "claude_desktop_config.json");
|
|
41881
41988
|
upsertMcpJsonConfig(cfg, serverScript, workspaces, false);
|
|
41882
41989
|
result.installed.push({
|
|
41883
41990
|
target,
|
|
@@ -41893,10 +42000,10 @@ async function runInstall(options = {}) {
|
|
|
41893
42000
|
note: zhLocale ? "\u5728 Claude Code \u4E2D\u5DF2\u6CE8\u518C\u5168\u5C40 inkmap MCP \u670D\u52A1" : "Registered global inkmap MCP server in Claude Code"
|
|
41894
42001
|
});
|
|
41895
42002
|
} else if (target === "cursor") {
|
|
41896
|
-
const cfg = (0,
|
|
42003
|
+
const cfg = (0, import_node_path7.join)(getCursorDir(), "mcp.json");
|
|
41897
42004
|
upsertMcpJsonConfig(cfg, serverScript, workspaces, false);
|
|
41898
42005
|
const extLoc = installIdeExtension(getCursorDir(), findCursorCommand());
|
|
41899
|
-
const cursorServerDir = (0,
|
|
42006
|
+
const cursorServerDir = (0, import_node_path7.join)((0, import_node_os5.homedir)(), ".cursor-server");
|
|
41900
42007
|
if ((0, import_node_fs3.existsSync)(cursorServerDir)) {
|
|
41901
42008
|
try {
|
|
41902
42009
|
installIdeExtension(cursorServerDir, null);
|
|
@@ -42033,12 +42140,12 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
42033
42140
|
const val = argv[++i];
|
|
42034
42141
|
if (!val)
|
|
42035
42142
|
throw new Error("--workspace \u9700\u8981\u63D0\u4F9B\u76EE\u5F55\u8DEF\u5F84 / --workspace requires a directory path");
|
|
42036
|
-
workspaces.push(...val.split(
|
|
42143
|
+
workspaces.push(...val.split(import_node_path7.delimiter).filter(Boolean));
|
|
42037
42144
|
continue;
|
|
42038
42145
|
}
|
|
42039
42146
|
if (arg.startsWith("--workspace=")) {
|
|
42040
42147
|
const val = arg.slice("--workspace=".length);
|
|
42041
|
-
workspaces.push(...val.split(
|
|
42148
|
+
workspaces.push(...val.split(import_node_path7.delimiter).filter(Boolean));
|
|
42042
42149
|
continue;
|
|
42043
42150
|
}
|
|
42044
42151
|
const normalized = normalizeTarget(arg);
|
|
@@ -42057,14 +42164,14 @@ async function runInstallCli(argv, uninstall = false) {
|
|
|
42057
42164
|
uninstall
|
|
42058
42165
|
});
|
|
42059
42166
|
}
|
|
42060
|
-
var import_node_child_process3, import_node_fs3, import_node_os5,
|
|
42167
|
+
var import_node_child_process3, import_node_fs3, import_node_os5, import_node_path7, import_node_url4, import_node_zlib, EXTENSION_EDITORS, EXTENSION_EDITOR_KEYS, isExtensionEditor, DIST_DIR, PKG_ROOT, SERVER_WRAPPER, CRC_TABLE;
|
|
42061
42168
|
var init_install = __esm({
|
|
42062
42169
|
"packages/cli/dist/install.js"() {
|
|
42063
42170
|
"use strict";
|
|
42064
42171
|
import_node_child_process3 = require("node:child_process");
|
|
42065
42172
|
import_node_fs3 = require("node:fs");
|
|
42066
42173
|
import_node_os5 = require("node:os");
|
|
42067
|
-
|
|
42174
|
+
import_node_path7 = require("node:path");
|
|
42068
42175
|
import_node_url4 = require("node:url");
|
|
42069
42176
|
import_node_zlib = require("node:zlib");
|
|
42070
42177
|
init_license();
|
|
@@ -42076,8 +42183,8 @@ var init_install = __esm({
|
|
|
42076
42183
|
};
|
|
42077
42184
|
EXTENSION_EDITOR_KEYS = Object.keys(EXTENSION_EDITORS);
|
|
42078
42185
|
isExtensionEditor = (target) => target in EXTENSION_EDITORS;
|
|
42079
|
-
DIST_DIR = (0,
|
|
42080
|
-
PKG_ROOT = (0,
|
|
42186
|
+
DIST_DIR = (0, import_node_path7.dirname)((0, import_node_url4.fileURLToPath)(inkmapModuleUrl));
|
|
42187
|
+
PKG_ROOT = (0, import_node_path7.resolve)(DIST_DIR, "..");
|
|
42081
42188
|
SERVER_WRAPPER = `#!/usr/bin/env node
|
|
42082
42189
|
"use strict";
|
|
42083
42190
|
require("./cli.cjs").main(["mcp", ...process.argv.slice(2)]).catch(err => {
|
|
@@ -42105,7 +42212,7 @@ __export(index_exports, {
|
|
|
42105
42212
|
main: () => main
|
|
42106
42213
|
});
|
|
42107
42214
|
module.exports = __toCommonJS(index_exports);
|
|
42108
|
-
var
|
|
42215
|
+
var import_node_path8 = require("node:path");
|
|
42109
42216
|
var import_node_url5 = require("node:url");
|
|
42110
42217
|
init_dist();
|
|
42111
42218
|
init_license();
|
|
@@ -42127,9 +42234,9 @@ var USAGE = `Inkmap v${INKMAP_VERSION} \u2014 Markdown \u4EA4\u4E92\u601D\u7EF4\
|
|
|
42127
42234
|
function appendEnvWorkspaces(dirs) {
|
|
42128
42235
|
if (dirs.length === 0)
|
|
42129
42236
|
return;
|
|
42130
|
-
const resolved = dirs.map((d2) => (0,
|
|
42131
|
-
const current = (process.env.INKMAP_WORKSPACES || "").split(
|
|
42132
|
-
process.env.INKMAP_WORKSPACES = [.../* @__PURE__ */ new Set([...current, ...resolved])].join(
|
|
42237
|
+
const resolved = dirs.map((d2) => (0, import_node_path8.resolve)(d2));
|
|
42238
|
+
const current = (process.env.INKMAP_WORKSPACES || "").split(import_node_path8.delimiter).filter(Boolean);
|
|
42239
|
+
process.env.INKMAP_WORKSPACES = [.../* @__PURE__ */ new Set([...current, ...resolved])].join(import_node_path8.delimiter);
|
|
42133
42240
|
}
|
|
42134
42241
|
async function main(argv) {
|
|
42135
42242
|
if (argv.length === 0 && !process.stdin.isTTY) {
|
|
@@ -42156,9 +42263,9 @@ async function main(argv) {
|
|
|
42156
42263
|
const val = argv[++i];
|
|
42157
42264
|
if (!val)
|
|
42158
42265
|
throw new Error("--workspace \u9700\u8981\u76EE\u5F55\u8DEF\u5F84");
|
|
42159
|
-
extraWorkspaces.push(...val.split(
|
|
42266
|
+
extraWorkspaces.push(...val.split(import_node_path8.delimiter).filter(Boolean));
|
|
42160
42267
|
} else if (arg.startsWith("--workspace=")) {
|
|
42161
|
-
extraWorkspaces.push(...arg.slice("--workspace=".length).split(
|
|
42268
|
+
extraWorkspaces.push(...arg.slice("--workspace=".length).split(import_node_path8.delimiter).filter(Boolean));
|
|
42162
42269
|
} else if (arg === "-h" || arg === "--help") {
|
|
42163
42270
|
console.log(USAGE);
|
|
42164
42271
|
return;
|