inkmap-mcp 0.0.0-stage → 0.2.4

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.
@@ -0,0 +1,74 @@
1
+ // packages/antigravity/src/select.mjs
2
+ import { randomUUID } from "node:crypto";
3
+ import { lstat, mkdir, realpath, rename, rm, writeFile } from "node:fs/promises";
4
+ import { homedir } from "node:os";
5
+ import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
+ var MAX_BYTES = 5 * 1024 * 1024;
7
+ function targetStateFile() {
8
+ const base = process.env.INKMAP_HOME ?? join(homedir(), ".inkmap");
9
+ return join(base, "antigravity-target.json");
10
+ }
11
+ function inside(root, file) {
12
+ const rel = relative(root, file);
13
+ return Boolean(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(".." + sep));
14
+ }
15
+ async function selectTargetFile(rawFile, rawWorkspace) {
16
+ if (typeof rawFile !== "string" || !/\.md$/i.test(rawFile.trim())) {
17
+ throw new Error("\u8BF7\u6307\u5B9A\u4E00\u4E2A .md \u6216 .markmap.md \u6587\u4EF6\u8DEF\u5F84\u3002");
18
+ }
19
+ const candidate = resolve(rawFile.trim());
20
+ const info = await lstat(candidate);
21
+ if (!info.isFile() || info.size > MAX_BYTES) {
22
+ throw new Error("\u8BF7\u9009\u62E9 5 MiB \u4EE5\u5185\u7684\u666E\u901A Markdown \u6587\u4EF6\u3002");
23
+ }
24
+ const file = await realpath(candidate);
25
+ if (file !== candidate && !/\.md$/i.test(file)) {
26
+ throw new Error("\u65E0\u6548\u7684 Markdown \u6587\u4EF6\u8DEF\u5F84\u3002");
27
+ }
28
+ let workspace = dirname(file);
29
+ if (rawWorkspace) {
30
+ const resolvedWs = await realpath(resolve(rawWorkspace)).catch(() => null);
31
+ if (resolvedWs && inside(resolvedWs, file)) workspace = resolvedWs;
32
+ } else {
33
+ const cwd = await realpath(process.cwd()).catch(() => null);
34
+ if (cwd && inside(cwd, file)) workspace = cwd;
35
+ }
36
+ const statePath = targetStateFile();
37
+ await mkdir(dirname(statePath), { recursive: true, mode: 448 });
38
+ const temp = `${statePath}.${process.pid}.${randomUUID()}`;
39
+ const payload = { file, workspace, seq: Date.now() };
40
+ try {
41
+ await writeFile(temp, JSON.stringify(payload, null, 2) + "\n", { mode: 384 });
42
+ await rename(temp, statePath);
43
+ } finally {
44
+ await rm(temp, { force: true }).catch(() => {
45
+ });
46
+ }
47
+ return payload;
48
+ }
49
+ if (process.argv[1] && /select\.m?js$/i.test(process.argv[1])) {
50
+ const args = process.argv.slice(2);
51
+ let fileArg = "";
52
+ let workspaceArg = "";
53
+ for (let i = 0; i < args.length; i++) {
54
+ if (args[i] === "--workspace" && args[i + 1]) {
55
+ workspaceArg = args[++i];
56
+ } else if (!fileArg) {
57
+ fileArg = args[i];
58
+ }
59
+ }
60
+ selectTargetFile(fileArg, workspaceArg).then(
61
+ ({ file }) => {
62
+ console.log(`\u5DF2\u9009\u5B9A Inkmap \u6587\u6863\uFF1A${file}`);
63
+ console.log("\u5728\u5BF9\u8BDD\u4E2D\u8F93\u51FA\u4EE5\u4E0B\u80F6\u56CA\u6309\u94AE\u5373\u53EF\u5728\u53F3\u4FA7\u6253\u5F00\uFF1A[Inkmap](sidecar://inkmap/inkmap/)");
64
+ },
65
+ (error) => {
66
+ console.error(error instanceof Error ? error.message : String(error));
67
+ process.exitCode = 1;
68
+ }
69
+ );
70
+ }
71
+ export {
72
+ selectTargetFile,
73
+ targetStateFile
74
+ };
@@ -0,0 +1,26 @@
1
+ {
2
+ "command": "node",
3
+ "args": ["main.mjs"],
4
+ "restart_policy": "always",
5
+ "display_name": "Inkmap",
6
+ "description": "Interactive mind map editor for local Markdown (.md, .markmap.md) outlines with live file write-back in the Antigravity auxiliary pane and sidebar.",
7
+ "has_web_ui": true,
8
+ "agent_permissions": {
9
+ "allows_user_interactions": false
10
+ },
11
+ "ui_config": {
12
+ "display_name": "Inkmap",
13
+ "views": [
14
+ {
15
+ "path": "/",
16
+ "entrypoint": "SIDECAR_UI_ENTRYPOINT_AUX_PANE",
17
+ "title": "Inkmap"
18
+ },
19
+ {
20
+ "path": "/?view=sidebar",
21
+ "entrypoint": "SIDECAR_UI_ENTRYPOINT_SIDEBAR",
22
+ "title": "Inkmap"
23
+ }
24
+ ]
25
+ }
26
+ }
@@ -0,0 +1,25 @@
1
+ ---
2
+ name: inkmap
3
+ description: 用 Inkmap 在 Antigravity 右侧辅助面板中将本地 Markdown (.md, .markmap.md) 文件作为可编辑的思维导图打开。当用户要求用 Inkmap、思维导图或脑图查看/编辑 Markdown 文件时使用。
4
+ ---
5
+
6
+ # 用 Inkmap 打开 Markdown 思维导图
7
+
8
+ 1. **确认目标 Markdown 文件**:
9
+ - 优先使用用户在消息中 `@` 引用或明确指定的本地 `.md` / `.markmap.md` 文件绝对路径。
10
+ - 如果用户只给出了项目名或文件名(如跨工作区引用),先定位该 `.md` / `.markmap.md` 的绝对路径。
11
+ 2. **调用 `inkmap_open` MCP 工具切换并激活导图文档**:
12
+ - 调用插件自带的 MCP 工具 `inkmap_open`(归属于 `inkmap_inkmap` 服务,若为懒加载则先读取其 schema 再通过 `call_mcp_tool` 调用),传入:
13
+ ```json
14
+ {
15
+ "path": "/绝对路径/xxx.markmap.md",
16
+ "workspace": "/所属工作区根目录绝对路径"
17
+ }
18
+ ```
19
+ - 该调用会将目标文件同步写入 Inkmap 当前活动文档状态(无需把整份 Markdown 原文读入大模型上下文);在已开启 MCP Apps 的宿主版本中会自动展开右侧面板,在当前版本中已打开的右侧 Inkmap 面板也会在 1 秒内自动切换到该文档。
20
+ 3. **在回复中附上一键打开胶囊按钮**:
21
+ - 在回复中输出以下 `sidecar://` 链接,确保当右侧面板尚未打开时用户可一键展开:
22
+ ```markdown
23
+ [Inkmap](sidecar://inkmap/inkmap/)
24
+ ```
25
+ - 简短说明:点击上方按钮(或右侧面板顶部 `+` $\rightarrow$ **Inkmap**,或左侧边栏 **Inkmap**)即可直接编辑思维导图并实时写回原 `.md` 文件。
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "inkmap-local",
3
+ "interface": {
4
+ "displayName": "Inkmap Local"
5
+ },
6
+ "plugins": [
7
+ {
8
+ "name": "inkmap-codex",
9
+ "source": {
10
+ "source": "local",
11
+ "path": "./inkmap-codex"
12
+ },
13
+ "policy": {
14
+ "installation": "AVAILABLE",
15
+ "authentication": "ON_INSTALL"
16
+ },
17
+ "category": "Productivity"
18
+ }
19
+ ]
20
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "inkmap-codex",
3
+ "version": "0.2.4",
4
+ "description": "Open Markdown as an editable mind map with Inkmap.",
5
+ "requires_local_executor": true,
6
+ "interface": {
7
+ "displayName": "Inkmap",
8
+ "logo": "./assets/icon.png",
9
+ "composerIcon": "./assets/icon.png"
10
+ },
11
+ "mcpServers": "./.mcp.json"
12
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": {
3
+ "inkmap": {
4
+ "command": "node",
5
+ "args": [
6
+ "${PLUGIN_ROOT}/server.cjs"
7
+ ],
8
+ "cwd": "${PLUGIN_ROOT}"
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json",
3
+ "mcpServers": {
4
+ "inkmap": {
5
+ "type": "stdio",
6
+ "command": "node",
7
+ "args": [
8
+ "${PLUGIN_ROOT}/server.cjs"
9
+ ],
10
+ "cwd": "${PLUGIN_ROOT}"
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
+ "name": "inkmap-codex",
4
+ "version": "0.2.4",
5
+ "description": "Open Markdown as an editable mind map with Inkmap.",
6
+ "extensions": {
7
+ "com.openai": {
8
+ "requires_local_executor": true,
9
+ "interface": {
10
+ "displayName": "Inkmap",
11
+ "logo": "./assets/icon.png",
12
+ "composerIcon": "./assets/icon.png"
13
+ }
14
+ }
15
+ }
16
+ }