dsh-mindmap 0.18.0 → 0.18.1
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/CHANGELOG.md +5 -0
- package/README.md +8 -3
- package/README.zh-CN.md +8 -3
- package/client.js +53 -6
- package/index.js +53 -19
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,9 @@ All notable changes to this project are documented here. Release-specific notes
|
|
|
6
6
|
|
|
7
7
|
### Added
|
|
8
8
|
|
|
9
|
+
- Add 复制当前节点文本内容 immediately above 复制节点路径 in node context menus. It copies the current node's complete own text without its path, ancestors, or descendants, preserves line breaks, and reuses the existing clipboard error and busy-state handling without modifying the mindmap or chat draft.
|
|
10
|
+
- Node context menus gain 复制节点路径: copy the complete root-to-current path as single-line plain text joined by `--->`, without descendants, chat submission, or draft replacement. The action uses the existing text clipboard fallback, disables menu actions while pending, and keeps errors visible for retry.
|
|
11
|
+
- Default generated names now include the user-facing host tool: `YYYYMMDD-HHmmss-DSH-<description>.md`. The settings panel adds 默认脑图命名是否添加AI工具标记 (`includeAIToolMarker`, on by default); disabling it restores the unmarked format without changing existing files or explicit user titles. The marker is DSH regardless of the selected model/provider. Changes apply to the next naming plan, while a create already awaiting confirmation keeps the exact path shown to the user.
|
|
9
12
|
- Refresh current mindmap from disk in either panel mode, without replacing drafts or submitting an AI request; failed reads retain the current canvas and show an error.
|
|
10
13
|
- A reproducible `npm run bench:client` benchmark compares cached and full replay using fictional long-conversation data and verifies output equivalence before timing.
|
|
11
14
|
|
|
@@ -25,6 +28,7 @@ All notable changes to this project are documented here. Release-specific notes
|
|
|
25
28
|
|
|
26
29
|
### Changed
|
|
27
30
|
|
|
31
|
+
- Mindmap guidance and create/open commands now route directly to native `mindmap_*` tools, explicitly excluding skill discovery/loading (`find-skills`, `workbuddy-mindmap`), external scripts, and generic file-write substitutes.
|
|
28
32
|
- Share the document projection between the header and workspace, and cache tool-result JSON per session. Changed result text invalidates its entry; session switches discard the previous reducer.
|
|
29
33
|
|
|
30
34
|
- Node text size is now one constant (`NODE_FONT_SIZE = 13`) with no smaller overrides: code blocks, tables and inline code used to render at 12px, which broke the readable-floor promise — the whole canvas shares a single CSS zoom, so 12px text landed at ~11.1px at the 12/13 floor. Code keeps its monospace face and surface colour, so the hierarchy survives without the size step.
|
|
@@ -34,6 +38,7 @@ All notable changes to this project are documented here. Release-specific notes
|
|
|
34
38
|
|
|
35
39
|
### Fixed
|
|
36
40
|
|
|
41
|
+
- Ordinary create/update calls no longer request an extra plugin confirmation when the host's live per-session `sandboxPolicy.resolve({ session })` explicitly returns `danger-full-access`. DSH's full-access preset also disables approval prompts, which rejects an extra `ask` as “the user rejected tool” even without a manual rejection. Full-access calls do not create reusable document grants, the workspace reports the effective confirmation mode, and effective-mode changes invalidate that session's prior grants and pending approval results without affecting other sessions. Switching back to a restricted policy restores the configured confirmation behavior. Renames, cleared content, broad rewrites, and upstream denials/asks/cancellations remain gated; missing, failing, or unknown policy APIs retain the previous confirmation policy. No session permission or host configuration is changed.
|
|
37
42
|
- Read draft text and attachment state from the host's `useInput` snapshot, including edits made while a file request is pending. Unknown state preserves input; old action-face getters remain supported. Inline references and attachment-only drafts block automatic submission too.
|
|
38
43
|
- Fresh disk reads no longer lose to older tool snapshots. A later tool event takes over normally; overlapping reads, closing, session switches, and newer open intents invalidate stale requests.
|
|
39
44
|
- Resolve all mindmap HTTP calls against the page base address, retaining reverse-proxy prefixes while refusing cross-origin base URLs.
|
package/README.md
CHANGED
|
@@ -32,8 +32,10 @@ A DeepSeek Harness plugin that turns a plain Markdown file into a live mindmap.
|
|
|
32
32
|
- **Collapsible subtrees** — every node with children carries a small toggle on its connector: collapsing hides the whole subtree and reports how many nodes are hidden, so large maps stay navigable. It is view state only — the markdown file is untouched, image export still covers the full subtree, and switching documents expands everything again.
|
|
33
33
|
- **PNG export** — one click on 导出图片 exports the current mindmap.
|
|
34
34
|
- **Copy as markdown** — one click on 复制全文 (left of 导出图片) copies the current mindmap's raw markdown source to the system clipboard, so pasting into markdown-aware editors restores headings, nested lists, and tables, while plain-text targets keep the literal `#`/`-` source. The button shows 已复制 ✓ for about two seconds on success; failures reuse the export error slot.
|
|
35
|
+
- **Copy current node text** — 复制当前节点文本内容 sits immediately above 复制节点路径 in the node context menu. It copies only the current node's complete text, preserving line breaks and excluding ancestors, paths, and descendants. The mindmap and chat draft remain unchanged.
|
|
36
|
+
- **Copy node path** — the node context menu includes 复制节点路径, which copies the complete root-to-current path as one plain-text line, for example `Node 1--->Node 2--->Node 3--->Node 4`. It excludes descendants and never submits a message or replaces the chat draft. Clipboard failures keep the menu open and show the error.
|
|
35
37
|
- **Node search and quick navigation** — search the current mindmap by text (⌘/Ctrl+F, or the 🔍 in the zoom bar), jump through matches with Enter / ↑ ↓ (wrap-around), and automatically reveal matches inside collapsed subtrees. Jumping keeps your zoom and only scrolls; search is view-only, so the markdown never changes.
|
|
36
|
-
- **Safety** —
|
|
38
|
+
- **Safety** — when the host's live session file policy explicitly grants `danger-full-access`, ordinary creates and updates do not request an additional plugin confirmation. Otherwise, write approval defaults to “once per session/document”; the settings page also offers “every write” and “disable ordinary confirmations”, and the current workspace shows and can revoke the current-session grant. Renames, cleared content, and broad rewrites still require a separate confirmation in every mode. Disabling approval prompts alone is not file authorization: the host automatically rejects requests that still need confirmation, including high-risk writes under its full-access preset. Missing or unrecognized host policy APIs retain the configured confirmation policy. Trusted automation can explicitly set `requireApproval: false` to skip ordinary confirmations; high-risk writes remain gated. The client has **no write path** to the filesystem — every edit goes through the AI tools.
|
|
37
39
|
|
|
38
40
|
Inside Better Sidebar, the mindmap list uses the host's 14px body typography. Markdown files carry a compact M badge; folders and other files use 14px outline icons. Other file formats are display-only, without hover feedback, opening, dragging, or context menus; folders remain expandable. Tabs, actions, and hints use the host's 12px typography role. Standalone mode retains its original appearance, and mindmap node typography, zoom, and image export are unchanged.
|
|
39
41
|
|
|
@@ -44,9 +46,10 @@ The embedded M badge uses a transparent background and inherits the filename's t
|
|
|
44
46
|
When you ask for a mindmap without naming a location — "创建一个脑图", "把刚才的讨论整理成脑图", "盘点一下这个问题" — the file lands in **`.mindmaps/`**, the mindmap inbox:
|
|
45
47
|
|
|
46
48
|
```text
|
|
47
|
-
.mindmaps/20260918-155230-项目盘点.md
|
|
49
|
+
.mindmaps/20260918-155230-DSH-项目盘点.md
|
|
48
50
|
```
|
|
49
51
|
|
|
52
|
+
- The **默认脑图命名是否添加AI工具标记** setting is on by default. The marker identifies the user-facing host tool, **DSH**, not its selected model, engine, or provider. Turning it off restores `YYYYMMDD-HHmmss-<description>.md`. This only affects future generated names; explicit user titles and existing files stay unchanged. A create already awaiting confirmation keeps the naming plan shown in that confirmation.
|
|
50
53
|
- The `YYYYMMDD-HHmmss` stamp is read by the host from the real clock; the model only supplies the short description (cleaned and truncated to 24 characters). Two captures in the same second get `-2`, `-3`, … suffixes — an existing file is never overwritten, and the write-confirmation names the exact file it is about to create.
|
|
51
54
|
- The path is checked twice: once when the confirmation is drawn, and again against the filesystem right before the write. If the target directory moved or was swapped for a symlink while you were reading the confirmation, the create is refused instead of writing outside the session working directory.
|
|
52
55
|
- `.mindmaps/` is created on first use, not at install time. The directory tree shows it as **脑图收件箱(.mindmaps)**, because a dotted folder otherwise reads as tool residue.
|
|
@@ -87,9 +90,11 @@ New-version cooldown policies can affect package selection shortly after publica
|
|
|
87
90
|
|
|
88
91
|
## Tools
|
|
89
92
|
|
|
93
|
+
Mindmap requests go directly to these four native `mindmap_*` tools. No skill discovery or loading is needed: `find-skills` and `workbuddy-mindmap` are not part of this plugin's workflow. The AI guidance and new/open commands explicitly request native tools only, without external scripts or generic file-write substitutes. A failed tool call is reported, not bypassed through a different tool.
|
|
94
|
+
|
|
90
95
|
| Tool | Description |
|
|
91
96
|
| --- | --- |
|
|
92
|
-
| `mindmap_create(name? \| description, directory?)` | Create a mindmap and show it in the panel (fails if the file already exists). With `name`, the file is `<name>.md`; without it, pass a short `description` and the host names the file `YYYYMMDD-HHmmss-<description>.md` inside the `.mindmaps/` inbox. Pass `directory` only when the user chose a location. |
|
|
97
|
+
| `mindmap_create(name? \| description, directory?)` | Create a mindmap and show it in the panel (fails if the file already exists). With `name`, the file is `<name>.md`; without it, pass a short `description` and the host names the file `YYYYMMDD-HHmmss-DSH-<description>.md` by default inside the `.mindmaps/` inbox (the DSH marker can be disabled in settings). Pass `directory` only when the user chose a location. |
|
|
93
98
|
| `mindmap_open(path)` | Open an existing `.md` as a mindmap in the panel. |
|
|
94
99
|
| `mindmap_get(path)` | Read the current Markdown content and revision of a mindmap document. |
|
|
95
100
|
| `mindmap_update(path, content, renameRoot?, expectedRevision?)` | Write the full Markdown; pass the read revision to reject stale writes; optionally rename the root node (renames the file, collisions rejected). |
|
package/README.zh-CN.md
CHANGED
|
@@ -32,8 +32,10 @@
|
|
|
32
32
|
- **子树折叠**——有子节点的节点在连线起点上带一个小开关:折叠后隐藏整棵子树并提示隐藏了多少节点,超大脑图也能逐层看。折叠只是视图状态,不改 markdown 文件,导出图片仍是完整子树;切换文档自动全部展开。
|
|
33
33
|
- **PNG 导出**——面板右上角「导出图片」一键导出当前脑图。
|
|
34
34
|
- **复制全文**——「导出图片」左侧一键把当前脑图的 Markdown 原文复制到系统剪贴板:粘到飞书文档 / Notion / Obsidian 等支持 Markdown 的目标会自动还原标题、嵌套列表和表格,粘到纯文本环境则是带 `#`、`-` 符号的源码,零信息损失。成功后按钮短暂显示「已复制 ✓」(约 2 秒),失败复用导出错误的红字提示位。
|
|
35
|
+
- **复制当前节点文本内容**——节点右键菜单中位于「复制节点路径」正上方。只复制当前节点自身的完整文本,保留原有换行;不包含父节点、路径或子节点,不修改脑图或聊天草稿。
|
|
36
|
+
- **复制节点路径**——节点右键菜单新增「复制节点路径」,把根节点到当前节点的完整路径复制为单行纯文本,例如 `节点1--->节点2--->节点3--->节点4`。不包含子节点,也不自动发送消息或覆盖聊天草稿;复制失败时保留菜单并提示原因。
|
|
35
37
|
- **节点搜索与快速定位**——⌘/Ctrl+F(或缩放条上的 🔍)在当前脑图中搜索文字,Enter / ↑ ↓ 逐个跳转匹配节点(双向环绕),并自动展开被折叠分支中的搜索结果;跳转保留当前缩放、只滚动视图。搜索只改视图状态,绝不动 Markdown。
|
|
36
|
-
-
|
|
38
|
+
- **安全**——宿主对当前会话明确授予 `danger-full-access`(完全文件权限)时,普通新建和更新不额外请求插件确认。其他情况下,写入确认默认采用“本会话一次”,也可切换为“每次确认”或“关闭普通确认”;当前脑图工作区会显示并可撤销本会话授权。重命名、清空和大范围重写在所有模式下仍需单独确认。仅关闭审批弹窗不等于授予文件权限:宿主会自动拒绝仍需确认的请求,包括完全权限预设下的高风险写入。宿主策略接口缺失或返回未知值时,沿用配置的确认策略。受信自动化可显式设置 `requireApproval: false` 关闭普通确认,但高风险写入仍需确认。客户端**没有任何写文件通道**,一切编辑都经 AI 工具。
|
|
37
39
|
|
|
38
40
|
内嵌 Better Sidebar 时,脑图列表采用宿主的 14px 正文字体。Markdown 文件显示紧凑的 M 徽标,文件夹与其他文件使用 14px 线框图标;其他格式文件仅展示,没有悬停反馈、打开、拖拽或右键菜单,文件夹仍可展开。标签、操作按钮和提示采用宿主的 12px 字体角色。独立模式保留原有外观;脑图节点的基础字体层级和图片导出保持不变。
|
|
39
41
|
|
|
@@ -44,9 +46,10 @@
|
|
|
44
46
|
你说「创建一个脑图」「把刚才的讨论整理成脑图」「盘点一下这个问题」这类没点目录的请求时,文件落在 **`.mindmaps/`**——脑图收件箱:
|
|
45
47
|
|
|
46
48
|
```text
|
|
47
|
-
.mindmaps/20260918-155230-项目盘点.md
|
|
49
|
+
.mindmaps/20260918-155230-DSH-项目盘点.md
|
|
48
50
|
```
|
|
49
51
|
|
|
52
|
+
- 设置面板新增 **「默认脑图命名是否添加AI工具标记」**,默认开启。标记指用户正在使用的宿主工具,所以这里是 **DSH**,不是内嵌模型、引擎或供应商;关闭后恢复 `YYYYMMDD-HHmmss-中文描述.md`。只影响后续默认命名,用户明确给出的文件名及已有文件保持不变;已经进入确认流程的创建仍使用确认时的命名计划。
|
|
50
53
|
- `YYYYMMDD-HHmmss` 由 host 读本机时钟生成,模型只给那句短描述(按文件名安全规则清理,最长 24 字)。同一秒撞名依次加 `-2`、`-3` 后缀,**已有文件永不被覆盖**;写入确认框里报出的就是它准备创建的那条路径。
|
|
51
54
|
- 路径校验走两遍:画确认框时一遍,真正落盘前再按当前文件系统核一遍。你还在读确认框时目标目录被改名、或被换成指向工作区外的符号链接,本次创建直接失败,绝不会把文件写到会话工作目录外面。
|
|
52
55
|
- `.mindmaps/` 第一次需要时才建,不在安装时预生成。目录树里它显示为 **「脑图收件箱(.mindmaps)」**,免得点号目录被当成工具残留以为内容看不见。
|
|
@@ -87,9 +90,11 @@ dsh plugin --profile <profile> add dsh-mindmap@<version>
|
|
|
87
90
|
|
|
88
91
|
## 工具
|
|
89
92
|
|
|
93
|
+
脑图请求直接使用下面四个 `mindmap_*` 原生工具,不需要查找或加载技能;`find-skills` 和 `workbuddy-mindmap` 不属于本插件的操作流程。AI 指引及新建/打开入口明确要求只用原生工具,不运行外部脚本,也不改用通用写文件工具。工具失败时如实报告,不换工具绕过权限。
|
|
94
|
+
|
|
90
95
|
| 工具 | 说明 |
|
|
91
96
|
| --- | --- |
|
|
92
|
-
| `mindmap_create(name? \| description, directory?)` | 新建脑图并显示到面板(文件已存在则报错)。给了 `name` 就建 `<name>.md`;没给就传一句短 `description`,由 host
|
|
97
|
+
| `mindmap_create(name? \| description, directory?)` | 新建脑图并显示到面板(文件已存在则报错)。给了 `name` 就建 `<name>.md`;没给就传一句短 `description`,由 host 默认命名成 `.mindmaps/YYYYMMDD-HHmmss-DSH-<description>.md`,可在设置中关闭 DSH 标记。只有用户点了位置才传 `directory`。 |
|
|
93
98
|
| `mindmap_open(path)` | 把已有 `.md` 作为脑图打开到面板。 |
|
|
94
99
|
| `mindmap_get(path)` | 读取脑图文档的当前 Markdown 内容和 revision。 |
|
|
95
100
|
| `mindmap_update(path, content, renameRoot?, expectedRevision?)` | 写入完整的新 Markdown;带上读取时的 revision 可避免覆盖并发修改;可选重命名根节点(重命名文件,撞名拒绝)。 |
|
package/client.js
CHANGED
|
@@ -392,6 +392,14 @@ window.__ModuleLoader__.load({
|
|
|
392
392
|
return [target];
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
/** 复制节点路径:根到当前节点的单行纯文本,不加聊天协议或展开子树。 */
|
|
396
|
+
function nodePathText(root, target) {
|
|
397
|
+
return nodePathTo(root, target).map((node) => {
|
|
398
|
+
const label = String(node.topic ?? "").replace(/\s+/g, " ").trim();
|
|
399
|
+
return label || EMPTY_NODE_MARKER;
|
|
400
|
+
}).join("--->");
|
|
401
|
+
}
|
|
402
|
+
|
|
395
403
|
/**
|
|
396
404
|
* 037 复制节点及子节点为文本:每个节点一行,每层 2 个半角空格。
|
|
397
405
|
* 多行节点内容的每一行都带同一层级前缀,空节点用明确标记保留其存在性。
|
|
@@ -1133,12 +1141,18 @@ window.__ModuleLoader__.load({
|
|
|
1133
1141
|
return raw === DEFAULT_MINDMAP_DIR ? DEFAULT_MINDMAP_DIR_LABEL : raw;
|
|
1134
1142
|
}
|
|
1135
1143
|
|
|
1144
|
+
/** 脑图入口直接路由到原生工具,不让通用技能发现把请求带到其它宿主。 */
|
|
1145
|
+
function nativeMindmapCommand(text) {
|
|
1146
|
+
return `${text}。本次脑图操作只使用 mindmap_ 开头的原生工具,不查找或加载技能,不运行外部脚本。`;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1136
1149
|
/** 新建入口文案:有目录上下文就写进那个目录,没有才交给默认收件箱。 */
|
|
1137
1150
|
function treeCreateDraft(relDirectory) {
|
|
1138
1151
|
const dir = String(relDirectory ?? "").trim();
|
|
1139
|
-
|
|
1140
|
-
?
|
|
1141
|
-
:
|
|
1152
|
+
const request = dir
|
|
1153
|
+
? `请直接用 mindmap_create 在 ${dir} 目录里创建一个 Markdown 脑图`
|
|
1154
|
+
: `请直接用 mindmap_create 新建一个脑图,按默认命名放进 ${DEFAULT_MINDMAP_DIR} 脑图收件箱`;
|
|
1155
|
+
return nativeMindmapCommand(`${request}。默认命名时只传 description,不传 name;文件名、时间戳和 AI 工具标记由宿主 DSH 按设置自动处理,不要自行拼接名字、时间戳或标记`);
|
|
1142
1156
|
}
|
|
1143
1157
|
|
|
1144
1158
|
function treeCreateLabel(relDirectory) {
|
|
@@ -1821,6 +1835,7 @@ window.__ModuleLoader__.load({
|
|
|
1821
1835
|
defaultPanelWidth: v && typeof v.defaultPanelWidth === "number" ? v.defaultPanelWidth : 42,
|
|
1822
1836
|
// 018:旧设置/读不到都默认开(!== false 语义)。
|
|
1823
1837
|
growthAnimation: !(v && v.growthAnimation === false),
|
|
1838
|
+
includeAIToolMarker: !(v && v.includeAIToolMarker === false),
|
|
1824
1839
|
});
|
|
1825
1840
|
} catch (err) {
|
|
1826
1841
|
if (alive) setError(String(err?.message ?? err));
|
|
@@ -1939,6 +1954,16 @@ window.__ModuleLoader__.load({
|
|
|
1939
1954
|
}),
|
|
1940
1955
|
] }),
|
|
1941
1956
|
(0, react_jsx_runtime.jsx)("p", { style: S.settingsHint, children: "开启后,脑图每次更新的新增/变化节点会逐个渐显长出(总时长不超过 2 秒);关闭则整棵树立刻完整显示。" }),
|
|
1957
|
+
(0, react_jsx_runtime.jsxs)("div", { style: S.settingsRow, children: [
|
|
1958
|
+
(0, react_jsx_runtime.jsx)("span", { style: S.settingsLabel, children: "默认脑图命名是否添加AI工具标记" }),
|
|
1959
|
+
(0, react_jsx_runtime.jsx)(Segmented, {
|
|
1960
|
+
options: [{ value: true, label: "开" }, { value: false, label: "关" }],
|
|
1961
|
+
value: value.includeAIToolMarker,
|
|
1962
|
+
disabled: saving,
|
|
1963
|
+
onChange: (v) => setField({ includeAIToolMarker: v }),
|
|
1964
|
+
}),
|
|
1965
|
+
] }),
|
|
1966
|
+
(0, react_jsx_runtime.jsx)("p", { style: S.settingsHint, children: "开启例:YYYYMMDD-HHmmss-DSH-项目盘点.md;关闭例:YYYYMMDD-HHmmss-项目盘点.md。AI 工具标记指宿主 DSH,不是模型;只对默认命名生效,显式 name 不变。" }),
|
|
1942
1967
|
] }),
|
|
1943
1968
|
(0, react_jsx_runtime.jsx)("p", { style: S.settingsGroupTitle, children: "写入确认" }),
|
|
1944
1969
|
(0, react_jsx_runtime.jsxs)("div", { style: S.settingsGroup, children: [
|
|
@@ -1956,6 +1981,7 @@ window.__ModuleLoader__.load({
|
|
|
1956
1981
|
}),
|
|
1957
1982
|
] }),
|
|
1958
1983
|
(0, react_jsx_runtime.jsx)("p", { style: S.settingsHint, children: value.approvalMode === "session" ? "本会话首次写入当前脑图后,后续普通更新无需重复确认。切换文件或会话会重新确认。" : value.approvalMode === "off" ? "普通更新不再弹窗;重命名、删除和大范围重写仍需确认。" : "每次写入都会弹窗确认。" }),
|
|
1984
|
+
(0, react_jsx_runtime.jsx)("p", { style: S.settingsHint, children: "DSH 明确授予完全文件权限时,普通新建和更新不额外确认;重命名、清空和大范围重写仍需确认。仅关闭审批弹窗不等于授予文件权限。" }),
|
|
1959
1985
|
value.approvalMode === "session" ? (0, react_jsx_runtime.jsx)("p", { style: S.settingsHint, children: "授权状态显示在当前脑图工作区;可在那里撤销当前会话的普通写入授权。" }) : null,
|
|
1960
1986
|
] }),
|
|
1961
1987
|
saving ? (0, react_jsx_runtime.jsx)("p", { style: S.settingsHint, children: "保存中…" }) : null,
|
|
@@ -2544,7 +2570,7 @@ window.__ModuleLoader__.load({
|
|
|
2544
2570
|
const fitStampRef = react.useRef([]);
|
|
2545
2571
|
const [zoom, setZoomState] = react.useState(1);
|
|
2546
2572
|
const [hover, setHover] = react.useState(null);
|
|
2547
|
-
// 037 节点右键菜单:{x, y, node};null = 关闭。busy 标记 chat/text/
|
|
2573
|
+
// 037 节点右键菜单:{x, y, node};null = 关闭。busy 标记 chat/self/path/text/
|
|
2548
2574
|
// copy/export 中的当前动作;任一动作在途时整张菜单禁用。
|
|
2549
2575
|
const [nodeMenu, setNodeMenu] = react.useState(null);
|
|
2550
2576
|
const [nodeMenuBusy, setNodeMenuBusy] = react.useState(null);
|
|
@@ -3252,7 +3278,7 @@ window.__ModuleLoader__.load({
|
|
|
3252
3278
|
setNodeMenu({ x: e.clientX, y: e.clientY, node: target });
|
|
3253
3279
|
}
|
|
3254
3280
|
|
|
3255
|
-
// 037 菜单动作:chat = 节点焦点上下文自动发送;text =
|
|
3281
|
+
// 037 菜单动作:chat = 节点焦点上下文自动发送;self = 当前节点全文;path = 根到当前节点路径;text = 子树文本;copy = PNG 写系统剪贴板
|
|
3256
3282
|
// (可粘贴到聊天/文档);export = PNG 下载为文件。图片范围 = 该节点
|
|
3257
3283
|
// 及其全部子孙(buildExportSvg 以任意节点为根重排布局,根样式随深度判定)。
|
|
3258
3284
|
async function onNodeMenuAction(mode) {
|
|
@@ -3263,6 +3289,8 @@ window.__ModuleLoader__.load({
|
|
|
3263
3289
|
try {
|
|
3264
3290
|
if (mode === "chat") submitNodeChat(nodeFocusPrompt(node, target));
|
|
3265
3291
|
else if (mode === "text") await copyPlainText(nodeTreeText(target));
|
|
3292
|
+
else if (mode === "self") await copyPlainText(nodeFullText(target));
|
|
3293
|
+
else if (mode === "path") await copyPlainText(nodePathText(node, target));
|
|
3266
3294
|
else if (mode === "copy") await copyPng(target, theme && theme.colorTheme);
|
|
3267
3295
|
else await exportPng(target, target.topic, theme && theme.colorTheme);
|
|
3268
3296
|
setNodeMenu(null);
|
|
@@ -3487,6 +3515,24 @@ window.__ModuleLoader__.load({
|
|
|
3487
3515
|
onClick: () => onNodeMenuAction("text"),
|
|
3488
3516
|
children: nodeMenuBusy === "text" ? "复制中…" : "复制节点及子节点为文本",
|
|
3489
3517
|
}),
|
|
3518
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
3519
|
+
type: "button",
|
|
3520
|
+
style: nodeMenuItemStyle("self"),
|
|
3521
|
+
disabled: Boolean(nodeMenuBusy),
|
|
3522
|
+
...nodeMenuHoverProps("self"),
|
|
3523
|
+
title: "只复制当前节点自身的完整文本,不包含路径和子节点",
|
|
3524
|
+
onClick: () => onNodeMenuAction("self"),
|
|
3525
|
+
children: nodeMenuBusy === "self" ? "复制中…" : "复制当前节点文本内容",
|
|
3526
|
+
}),
|
|
3527
|
+
(0, react_jsx_runtime.jsx)("button", {
|
|
3528
|
+
type: "button",
|
|
3529
|
+
style: nodeMenuItemStyle("path"),
|
|
3530
|
+
disabled: Boolean(nodeMenuBusy),
|
|
3531
|
+
...nodeMenuHoverProps("path"),
|
|
3532
|
+
title: "把根节点到当前节点的路径复制到剪贴板,节点间使用 ---> 连接",
|
|
3533
|
+
onClick: () => onNodeMenuAction("path"),
|
|
3534
|
+
children: nodeMenuBusy === "path" ? "复制中…" : "复制节点路径",
|
|
3535
|
+
}),
|
|
3490
3536
|
(0, react_jsx_runtime.jsx)("button", {
|
|
3491
3537
|
type: "button",
|
|
3492
3538
|
style: nodeMenuItemStyle("copy"),
|
|
@@ -3800,7 +3846,7 @@ window.__ModuleLoader__.load({
|
|
|
3800
3846
|
if (draftBlocked()) return false;
|
|
3801
3847
|
if (!inputActions || typeof inputActions.setDraft !== "function" || typeof inputActions.submit !== "function") return false;
|
|
3802
3848
|
try {
|
|
3803
|
-
inputActions.setDraft(text);
|
|
3849
|
+
inputActions.setDraft(nativeMindmapCommand(text));
|
|
3804
3850
|
inputActions.submit();
|
|
3805
3851
|
return true;
|
|
3806
3852
|
} catch {
|
|
@@ -5322,6 +5368,7 @@ window.__ModuleLoader__.load({
|
|
|
5322
5368
|
escapePathSegment,
|
|
5323
5369
|
nodePathTo,
|
|
5324
5370
|
nodePathLabel,
|
|
5371
|
+
nodePathText,
|
|
5325
5372
|
renderInline,
|
|
5326
5373
|
// 038 行内链接 token 拆解 + 脑图区主体模式判定(纯函数,供测试)。
|
|
5327
5374
|
parseInlineLinkToken,
|
package/index.js
CHANGED
|
@@ -8,12 +8,13 @@
|
|
|
8
8
|
// 文件被外部改名时根标题由 client 从路径推导,天然跟随。
|
|
9
9
|
// - 四工具都带 path/name 参数(决策 3:多脑图并存,作用于指定那颗)。
|
|
10
10
|
// - 036 默认落点:用户没指定目录的随手创建进 `.mindmaps/` 脑图收件箱,
|
|
11
|
-
// 名字 `YYYYMMDD-HHmmss-中文描述.md`——时间戳由 host 读表(模型不猜时间),
|
|
12
|
-
//
|
|
11
|
+
// 名字 `YYYYMMDD-HHmmss-DSH-中文描述.md`——时间戳由 host 读表(模型不猜时间),
|
|
12
|
+
// DSH 是宿主工具标记(设置可关闭),描述由 AI 给。同秒撞名加 -2/-3 不覆盖。
|
|
13
13
|
// - 结果 JSON {ok, op, path, rootTitle, content, renamedFrom?}:content 全文
|
|
14
14
|
// 供模型续编辑,client 用同一份重放面板(工具结果即实时通道,002 第二节)。
|
|
15
15
|
// - requireApproval 配置(决策 6):默认 true;approvalMode 默认按「当前会话 + 当前文件」
|
|
16
16
|
// 首次确认,后续普通更新复用授权;per-operation 可恢复每次确认,off 关闭普通确认。
|
|
17
|
+
// 宿主明确授予 danger-full-access 时普通写入不额外确认,不缓存成文档授权。
|
|
17
18
|
// 重命名、清空和大范围重写始终重新确认,关闭普通确认也不能跳过。
|
|
18
19
|
// 015 起经 settings namespace 可运行时切换。
|
|
19
20
|
// - 依赖:仅 @deepseek-ai/schemastery(settings schema;发布包正常解析,
|
|
@@ -58,12 +59,14 @@ const MIGRATABLE_KEYS = {
|
|
|
58
59
|
cardStyle: (v) => v === 'rounded' || v === 'square',
|
|
59
60
|
colorTheme: (v) => v === 'ocean' || v === 'sunset' || v === 'forest',
|
|
60
61
|
growthAnimation: (v) => v === 'true' || v === 'false',
|
|
62
|
+
includeAIToolMarker: (v) => v === 'true' || v === 'false',
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
const MIGRATABLE_PARSERS = {
|
|
64
66
|
requireApproval: (v) => v === 'true',
|
|
65
67
|
defaultPanelWidth: (v) => Number(v),
|
|
66
68
|
growthAnimation: (v) => v === 'true',
|
|
69
|
+
includeAIToolMarker: (v) => v === 'true',
|
|
67
70
|
}
|
|
68
71
|
|
|
69
72
|
function parseLegacyMindmapSection(raw) {
|
|
@@ -99,6 +102,7 @@ const CONFIG_DEFAULTS = {
|
|
|
99
102
|
cardStyle: 'rounded',
|
|
100
103
|
colorTheme: 'ocean',
|
|
101
104
|
growthAnimation: true,
|
|
105
|
+
includeAIToolMarker: true,
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
function isAllDefaults(value) {
|
|
@@ -128,12 +132,13 @@ function configValue(value) {
|
|
|
128
132
|
|
|
129
133
|
export const Config = Schema.object({
|
|
130
134
|
requireApproval: Schema.boolean().default(true).description('Legacy switch: false skips ordinary confirmations only, and is lifted when the settings panel picks an explicit approval mode. Rename, clearing content, and broad rewrites always require approval.').extra('volatile', true),
|
|
131
|
-
approvalMode: Schema.union([...APPROVAL_MODES, 'once-per-document', 'always']).default('session').description('Confirm every ordinary write, once per document in the current session, or disable ordinary confirmations. High-risk writes always require approval.').extra('volatile', true),
|
|
135
|
+
approvalMode: Schema.union([...APPROVAL_MODES, 'once-per-document', 'always']).default('session').description('Confirm every ordinary write, once per document in the current session, or disable ordinary confirmations. Explicit host danger-full-access skips ordinary confirmations. High-risk writes always require approval.').extra('volatile', true),
|
|
132
136
|
defaultPanelWidth: Schema.number().default(42).description('Default floating-panel width as a percentage of the viewport (clamped 20-80 on the client).').extra('volatile', true),
|
|
133
137
|
lineStyle: Schema.union(['curve', 'elbow']).default('elbow').description('Connector line style between nodes: curve (bezier) or elbow (orthogonal).').extra('volatile', true),
|
|
134
138
|
cardStyle: Schema.union(['rounded', 'square']).default('rounded').description('Node card corner style.').extra('volatile', true),
|
|
135
139
|
colorTheme: Schema.union(['ocean', 'sunset', 'forest']).default('ocean').description('Node color theme.').extra('volatile', true),
|
|
136
140
|
growthAnimation: Schema.boolean().default(true).description('Progressive growth animation: newly added/changed nodes fade in one by one after each update (total capped at ~2s). Turn off for instant full render.').extra('volatile', true),
|
|
141
|
+
includeAIToolMarker: Schema.boolean().default(true).description('默认脑图命名是否添加AI工具标记:默认开启,在时间戳和描述之间添加宿主工具名 DSH,不记录模型或引擎;关闭后恢复无标记格式。仅影响默认命名,不修改显式文件名或已有文件。').extra('volatile', true),
|
|
137
142
|
})
|
|
138
143
|
|
|
139
144
|
const MAX_CONTENT_BYTES = 2 * 1024 * 1024
|
|
@@ -149,7 +154,9 @@ const BROAD_REWRITE_RATIO_MIN_BYTES = 4 * 1024
|
|
|
149
154
|
// 036 默认脑图收件箱:用户没指定目录时的落点。目录只在第一次需要时按需创建,
|
|
150
155
|
// 也不自动进 .gitignore——脑图仍是普通 Markdown,用户可以审阅、diff、提交。
|
|
151
156
|
export const DEFAULT_MINDMAP_DIR = '.mindmaps'
|
|
152
|
-
//
|
|
157
|
+
// 用户可见的宿主工具名,不是会话内嵌的模型、引擎或 provider。
|
|
158
|
+
const HOST_TOOL_MARKER = 'DSH'
|
|
159
|
+
// 描述只占默认名的一段,留足时间戳、宿主标记、连接符与撞名后缀后仍低于 MAX_NAME_CHARS。
|
|
153
160
|
const MAX_DESCRIPTION_CHARS = 24
|
|
154
161
|
// 同一秒同名(默认命名)时的后缀尝试次数上限。
|
|
155
162
|
const MAX_CREATE_ATTEMPTS = 50
|
|
@@ -158,8 +165,10 @@ const GUIDANCE = `## Mindmap editing (dsh-mindmap)
|
|
|
158
165
|
|
|
159
166
|
A mindmap is a plain markdown file in the session working directory. The right-side panel renders it live; the filename (without .md) is the root node title. These files are ordinary documents: the user reviews and commits them with git themselves.
|
|
160
167
|
|
|
168
|
+
For mindmap tasks, use only the native \`mindmap_*\` tools listed below. They are already available: do not search for, load, or install skills (including \`find-skills\` and \`workbuddy-mindmap\`), even when a skill catalog suggests a matching skill. Do not use shell commands, external scripts, HTML generators, or generic file-write tools as a substitute. This DSH panel does not depend on a WorkBuddy skill. If a native tool fails, report that failure; do not switch to another tool to bypass its permissions.
|
|
169
|
+
|
|
161
170
|
Tools:
|
|
162
|
-
- mindmap_create(name? | description, directory?): create a mindmap and show it in the panel (fails if the file already exists). Give \`name\` when the user named the mindmap; otherwise give a short \`description\` and the host names the file \`YYYYMMDD-HHmmss-<description>.md
|
|
171
|
+
- mindmap_create(name? | description, directory?): create a mindmap and show it in the panel (fails if the file already exists). Give \`name\` when the user named the mindmap; otherwise give a short \`description\` and the host names the file \`YYYYMMDD-HHmmss-DSH-<description>.md\` by default (the tool marker is configurable). Give \`directory\` only when the user picked a location.
|
|
163
172
|
- mindmap_open(path): open an existing .md as a mindmap in the panel.
|
|
164
173
|
- mindmap_get(path): read the current markdown content.
|
|
165
174
|
- mindmap_update(path, content, renameRoot?, expectedRevision?): write the FULL updated markdown. Pass the revision returned by mindmap_get/open when editing; a mismatch stops the write instead of overwriting newer changes. renameRoot renames the file to match a new root title (fails on name collision); use it only when the user asks to rename the root node.
|
|
@@ -169,13 +178,14 @@ Markdown mapping (the panel's parser): headings nest by level (H1 are root child
|
|
|
169
178
|
Behavior rules:
|
|
170
179
|
- Where new files go: for casual requests ("创建一个脑图", "把刚才的讨论整理成脑图", "盘点一下这个问题") omit \`directory\` — the host files them in \`${DEFAULT_MINDMAP_DIR}/\`, the mindmap inbox, created on first use. That is the only location the plugin ever chooses on its own: when the user names a directory (or right-clicks one in the tree), pass that \`directory\` and leave their placement alone.
|
|
171
180
|
- Never write a date or time into a mindmap filename yourself. Pass a bare \`description\` (e.g. 项目盘点) and the host stamps the real current time, then takes the first free name (\`-2\`, \`-3\`, …) so an existing file is never overwritten. The path the user confirms is the path it writes; if another create claims that name while the confirmation is pending, the host steps to the next free suffix and reports the final path in the tool result — relay that path to the user rather than assuming the one they confirmed.
|
|
172
|
-
-
|
|
181
|
+
- The AI tool marker is the user-facing host tool \`DSH\`, not the selected model or provider. The setting \`includeAIToolMarker\` (默认脑图命名是否添加AI工具标记) defaults to true; turning it off restores \`YYYYMMDD-HHmmss-<description>.md\`. The host applies it automatically: do not put a timestamp or tool marker into \`description\` or invent a full \`name\` to force the format. A user's explicit \`name\` stays unchanged, and existing documents are never renamed by this setting.
|
|
182
|
+
- Because the root node title is the filename, a default-created mindmap shows its timestamp and optional tool marker as the root title (e.g. 20260918-155230-DSH-项目盘点). Rename it with renameRoot only when the user asks; do not restructure the document to hide the stamp.
|
|
173
183
|
- When the user asks to create a mindmap, call mindmap_create. When the user asks to open, view, show, or switch to an existing mindmap, call mindmap_open (do not use mindmap_get alone). Both operations bring that document to the visible mindmap panel automatically.
|
|
174
184
|
- Always mindmap_get before editing, then send the complete updated document and the returned revision as expectedRevision to mindmap_update. If the tool reports a revision conflict, stop and ask the user whether to reload or merge; never overwrite newer text silently. Every call must carry the FULL document, never a fragment.
|
|
175
185
|
- Update step by step: whenever the request involves several parts, call mindmap_update as soon as each part is ready — several small updates beat one giant update at the end. The panel plays a growth animation on newly added/changed nodes, so step-by-step updates make the tree visibly grow while you work. Do not call mindmap_update twice in a row with identical content.
|
|
176
186
|
- Never delete the whole document or restructure it without an explicit user request. Make the smallest change that answers the request.
|
|
177
187
|
- When the user steps away or pauses (e.g. "我去买咖啡"), stop all mindmap edits immediately and wait — never continue autonomously.
|
|
178
|
-
-
|
|
188
|
+
- Ordinary writes follow the host's live file policy: explicit \`danger-full-access\` skips the plugin's ordinary confirmations; otherwise native write approval defaults to once per document in the current session. \`per-operation\` asks for each ordinary write; \`off\` skips ordinary confirmations. Rename, clearing content, and broad rewrites still require confirmation in every mode. The current mindmap workspace shows and can revoke the current-session grants. If approval prompts are disabled, that is not permission to bypass a required confirmation; report the failure without claiming that the user personally clicked Reject. Never treat a rejected or failed write as approved.
|
|
179
189
|
- Never run any git command for these files. The user commits themselves.
|
|
180
190
|
- Mindmap files stay inside the session working directory.`
|
|
181
191
|
|
|
@@ -380,9 +390,10 @@ function sanitizeDescription(input) {
|
|
|
380
390
|
return chars.length > MAX_DESCRIPTION_CHARS ? chars.slice(0, MAX_DESCRIPTION_CHARS).join('') : raw
|
|
381
391
|
}
|
|
382
392
|
|
|
383
|
-
/** 默认脑图主干:`YYYYMMDD-HHmmss
|
|
384
|
-
function defaultStem(date, description) {
|
|
385
|
-
|
|
393
|
+
/** 默认脑图主干:`YYYYMMDD-HHmmss-DSH-中文描述`;关闭标记时沿用旧格式。 */
|
|
394
|
+
function defaultStem(date, description, includeAIToolMarker = true) {
|
|
395
|
+
const marker = includeAIToolMarker !== false ? `-${HOST_TOOL_MARKER}` : ''
|
|
396
|
+
return `${timestampStamp(date)}${marker}-${sanitizeDescription(description)}`
|
|
386
397
|
}
|
|
387
398
|
|
|
388
399
|
/** create 参数里的显式目录(去空白);缺省 = 走默认收件箱。 */
|
|
@@ -399,14 +410,14 @@ function explicitDirectory(args) {
|
|
|
399
410
|
* 生成,撞名可以加后缀。两者互相独立:只给名字不给目录时进收件箱,但那是用户的
|
|
400
411
|
* 命名意图,撞名了不能替他改名。
|
|
401
412
|
*/
|
|
402
|
-
function planCreatePaths(cwd, args, now = new Date()) {
|
|
413
|
+
function planCreatePaths(cwd, args, now = new Date(), includeAIToolMarker = true) {
|
|
403
414
|
if (!cwd) throw new Error('The session has no working directory; cannot create a mindmap.')
|
|
404
415
|
const directory = explicitDirectory(args)
|
|
405
416
|
const explicitName = typeof args?.name === 'string' ? args.name.trim() : ''
|
|
406
417
|
if (!explicitName && (typeof args?.description !== 'string' || !args.description.trim())) {
|
|
407
418
|
throw new Error('mindmap_create needs either `name` (an explicit title) or `description` (a short phrase such as 项目盘点); the host supplies the timestamp.')
|
|
408
419
|
}
|
|
409
|
-
const stem = explicitName ? sanitizeStem(explicitName) : defaultStem(now, args?.description)
|
|
420
|
+
const stem = explicitName ? sanitizeStem(explicitName) : defaultStem(now, args?.description, includeAIToolMarker)
|
|
410
421
|
return {
|
|
411
422
|
stem,
|
|
412
423
|
relative: join(directory || DEFAULT_MINDMAP_DIR, `${stem}.md`),
|
|
@@ -667,6 +678,7 @@ export function apply(ctx, config = {}) {
|
|
|
667
678
|
cardStyle: cardStyle === 'square' ? 'square' : 'rounded',
|
|
668
679
|
colorTheme: colorTheme === 'sunset' || colorTheme === 'forest' ? colorTheme : 'ocean',
|
|
669
680
|
growthAnimation: configValue(config.growthAnimation) !== false,
|
|
681
|
+
includeAIToolMarker: configValue(config.includeAIToolMarker) !== false,
|
|
670
682
|
}
|
|
671
683
|
}
|
|
672
684
|
|
|
@@ -704,6 +716,7 @@ export function apply(ctx, config = {}) {
|
|
|
704
716
|
// 成功后写入,拒绝、失败或取消都不会消耗授权。WeakMap 随 session 生命周期
|
|
705
717
|
// 自然释放,不把授权带到别的会话。
|
|
706
718
|
let approvedTargets = new WeakMap()
|
|
719
|
+
const effectiveApprovalModes = new WeakMap()
|
|
707
720
|
const pendingApprovals = new WeakMap()
|
|
708
721
|
// 实际写盘路径:默认命名在「审批到写盘」之间被别人抢注时会挪到下一个空闲后缀,
|
|
709
722
|
// 授权必须跟着记真实路径,不能把审批阶段的旧候选登记成本次会话的授权目标。
|
|
@@ -718,6 +731,25 @@ export function apply(ctx, config = {}) {
|
|
|
718
731
|
}
|
|
719
732
|
return mode
|
|
720
733
|
}
|
|
734
|
+
// 完全权限预设同时关闭审批弹窗(never):额外返回 ask 会被宿主自动拒绝。
|
|
735
|
+
// 只认公共 sandboxPolicy 对当前 session 的实时解析;never 本身不是授权。
|
|
736
|
+
// 能力缺失、解析失败、未知模式或无会话时保留旧策略,不读部署默认值猜权限。
|
|
737
|
+
const ordinaryApprovalModeOf = (session) => {
|
|
738
|
+
let mode = readApprovalMode()
|
|
739
|
+
if (session && typeof session === 'object') {
|
|
740
|
+
try {
|
|
741
|
+
const policy = ctx.get?.('sandboxPolicy')?.resolve?.({ session })
|
|
742
|
+
if (policy?.mode === 'danger-full-access') mode = 'off'
|
|
743
|
+
} catch { /* 旧宿主或策略不可用时不新增免确认权限。 */ }
|
|
744
|
+
const previous = effectiveApprovalModes.get(session)
|
|
745
|
+
if (previous !== undefined && previous !== mode) {
|
|
746
|
+
// 只撤销本会话的旧授权;pending.state 身份检查也阻止在途结果恢复它。
|
|
747
|
+
approvedTargets.delete(session)
|
|
748
|
+
}
|
|
749
|
+
effectiveApprovalModes.set(session, mode)
|
|
750
|
+
}
|
|
751
|
+
return mode
|
|
752
|
+
}
|
|
721
753
|
const stateOf = (session) => {
|
|
722
754
|
if (!session || typeof session !== 'object') return null
|
|
723
755
|
let state = approvedTargets.get(session)
|
|
@@ -728,8 +760,9 @@ export function apply(ctx, config = {}) {
|
|
|
728
760
|
return state
|
|
729
761
|
}
|
|
730
762
|
const approvalStatusOf = (session) => {
|
|
763
|
+
const mode = ordinaryApprovalModeOf(session)
|
|
731
764
|
const state = session && typeof session === 'object' ? approvedTargets.get(session) : null
|
|
732
|
-
return { mode
|
|
765
|
+
return { mode, grantedDocuments: state?.paths.size ?? 0 }
|
|
733
766
|
}
|
|
734
767
|
const revokeApproval = (session) => {
|
|
735
768
|
if (!session || typeof session !== 'object') return approvalStatusOf(session)
|
|
@@ -758,7 +791,8 @@ export function apply(ctx, config = {}) {
|
|
|
758
791
|
const plannedCreate = async (exec, cwd, args) => {
|
|
759
792
|
const cached = createPlans.get(exec)
|
|
760
793
|
if (cached && cached.args === args) return cached.plan
|
|
761
|
-
|
|
794
|
+
// 设置与时间戳一并锁定在本次计划里;确认期间切换开关只影响下一次创建。
|
|
795
|
+
const base = planCreatePaths(cwd, args ?? {}, new Date(), activeConfig().includeAIToolMarker !== false)
|
|
762
796
|
const first = await resolveMindmapPath(cwd, base.relative)
|
|
763
797
|
// 顺序不能换:先过权威路径校验才敢探测。`.mindmaps` 若是指向外部的符号链接,
|
|
764
798
|
// 上面这一步已经拒了,不会把别人的目录当成候选清单来读。
|
|
@@ -814,11 +848,11 @@ export function apply(ctx, config = {}) {
|
|
|
814
848
|
const target = await targetOf(exec)
|
|
815
849
|
const rename = exec.name === 'mindmap_update' && typeof args.renameRoot === 'string' && args.renameRoot.trim()
|
|
816
850
|
const deleteDocument = exec.name === 'mindmap_update' && typeof args.content === 'string' && args.content.trim() === ''
|
|
817
|
-
const mode =
|
|
851
|
+
const mode = ordinaryApprovalModeOf(session)
|
|
818
852
|
const broadRewrite = await needsRewriteApproval(exec, target, args.content)
|
|
819
853
|
const highRisk = Boolean(rename || deleteDocument || broadRewrite)
|
|
820
|
-
const state = stateOf(session)
|
|
821
854
|
if (mode === 'off' && !highRisk) return decision
|
|
855
|
+
const state = stateOf(session)
|
|
822
856
|
if (mode === 'session' && !highRisk && state?.paths.has(target)) return decision
|
|
823
857
|
if (mode === 'session' && !highRisk && state) pendingApprovals.set(exec, { session, target, state, generation: state.generation })
|
|
824
858
|
if (exec.name === 'mindmap_create') {
|
|
@@ -844,7 +878,7 @@ export function apply(ctx, config = {}) {
|
|
|
844
878
|
if (!pending) return
|
|
845
879
|
pendingApprovals.delete(exec)
|
|
846
880
|
if (result?.isError !== false || exec.signal?.aborted) return
|
|
847
|
-
if (
|
|
881
|
+
if (ordinaryApprovalModeOf(pending.session) !== 'session') return
|
|
848
882
|
// 撤销或策略切换之后,尚未结束的旧调用不能重新恢复授权。
|
|
849
883
|
if (approvedTargets.get(pending.session) !== pending.state || pending.state.generation !== pending.generation) return
|
|
850
884
|
// 审批后被抢注、实际写到了 -2 的情形:授权记真实路径,不记用户没见过的那条。
|
|
@@ -855,12 +889,12 @@ export function apply(ctx, config = {}) {
|
|
|
855
889
|
|
|
856
890
|
ctx.tools.register(defineTool({
|
|
857
891
|
name: 'mindmap_create',
|
|
858
|
-
description: `Create a new mindmap markdown file and show it in the mindmap panel. Fails if the file already exists. The filename becomes the root node title. Pass \`name\` when the user gave an explicit title, otherwise pass \`description\` and the file is auto-named YYYYMMDD-HHmmss-<description>.md inside the default mindmap inbox (${DEFAULT_MINDMAP_DIR}/) — the host picks the next free -2/-3 suffix when that name is already taken, so nothing is ever overwritten. Only pass \`directory\` when the user chose a location.`,
|
|
892
|
+
description: `Create a new mindmap markdown file and show it in the mindmap panel. Fails if the file already exists. The filename becomes the root node title. Pass \`name\` when the user gave an explicit title, otherwise pass \`description\` and the file is auto-named YYYYMMDD-HHmmss-DSH-<description>.md by default (the includeAIToolMarker setting can omit DSH) inside the default mindmap inbox (${DEFAULT_MINDMAP_DIR}/) — the host picks the next free -2/-3 suffix when that name is already taken, so nothing is ever overwritten. Only pass \`directory\` when the user chose a location.`,
|
|
859
893
|
parameters: {
|
|
860
894
|
type: 'object',
|
|
861
895
|
properties: {
|
|
862
896
|
name: { type: 'string', description: 'Explicit mindmap document name (without .md). Becomes the filename and the root node title; a name collision is reported instead of auto-renaming. Omit it for a quick capture and pass `description` instead.' },
|
|
863
|
-
description: { type: 'string', description: `Short phrase for the auto-generated filename when \`name\` is omitted (e.g. 项目盘点). Cleaned and truncated to ${MAX_DESCRIPTION_CHARS} characters. Never put a date or
|
|
897
|
+
description: { type: 'string', description: `Short phrase for the auto-generated filename when \`name\` is omitted (e.g. 项目盘点). Cleaned and truncated to ${MAX_DESCRIPTION_CHARS} characters. Never put a date, time, or AI tool marker here — the host supplies the real time and optional DSH marker.` },
|
|
864
898
|
directory: { type: 'string', description: `Directory relative to the session working directory, only when the user picked one (it must already exist). Omit it to file the mindmap in the default inbox ${DEFAULT_MINDMAP_DIR}/, which is created on first use.` },
|
|
865
899
|
},
|
|
866
900
|
required: [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mindmap",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "Mindmap plugin for DeepSeek Harness: a plain markdown file in the working directory IS the mindmap; the chat edits it step by step and the right-side panel follows live.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|