dsh-mindmap 0.14.2 → 0.16.0
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 +3 -0
- package/index.js +141 -28
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,9 @@ All notable changes to this project are documented here. Release-specific notes
|
|
|
24
24
|
|
|
25
25
|
### Fixed
|
|
26
26
|
|
|
27
|
+
- Restored host-side settings on 0.1.7+ hosts: the service no longer has `register`, so the 0.15.0 startup path never read live values or ran its `.imported` migration. The flat `Config` export remains the loader-discovered schema; host approval now reads the `mindmap` descriptor from `describe()` at execution time, and legacy settings are restored via revision-checked `update()` only when the profile has no saved user overrides. Older hosts retain their `register` path. The tests now mock the actual service surface without `register` and exercise live approval changes and one-time migration.
|
|
28
|
+
- Extended the tooling peer range with `^0.2.0-alpha.0` for the 0.2.0 prerelease tuple. Hosts that enforce peer compatibility no longer skip the plugin solely because its previous range stopped at 0.1.7; the optional sidebar peer is unchanged.
|
|
29
|
+
- 0.1.7 settings volatile mechanism: all seven Config fields (`requireApproval`, `approvalMode`, `defaultPanelWidth`, `lineStyle`, `cardStyle`, `colorTheme`, `growthAnimation`) are now marked `.extra('volatile', true)` on their schemastery schema nodes. Without `meta.volatile`, the 0.1.7 host's settings storage (`dsh-settings` `volatileForm`/`isVolatilePath`/`write`) rejects all reads and writes for the `mindmap` namespace — the settings panel (设置 → 思维脑图) displays stale or default values and saving a new choice is silently dropped. The `volatile` meta is transparent to older hosts (0.1.5 and below ignore it), so the dual-path behavior is unchanged. A one-time legacy migration was also added: on startup, when the settings value is all-defaults, the plugin reads `~/.dsh/settings.yaml.imported` (the host-renamed old `settings.yaml`), extracts the `mindmap:` section's scalar fields with a line-by-line parser (no YAML dependency), validates each value against its allowed set, and writes the result to the new settings store via `scope.update()`. The `.imported` file is never deleted (it is host-managed); failures are silently skipped so the plugin still loads and the user can configure manually.
|
|
27
30
|
- dsh-tools peer dependency window extended to cover the `0.1.7-rc.2` release: `^0.1.7-alpha.0` is appended to the comparator list (`^0.1.0-rc.6 || ^0.1.1-rc.0 || ^0.1.2-alpha.0 || ^0.1.3-alpha.0 || ^0.1.5-alpha.0 || ^0.1.7-alpha.0`). Under node-semver prerelease tuple rules, `0.1.7-rc.2` requires a `[0,1,7]` tuple with a prerelease tag in the range — without this comparator, `pnpm add dsh-mindmap` on a 0.1.7 host fails with ERESOLVE. The static API surface (Agent `{ id }`, `SessionHeader.cwd`, `settings.describe` envelope, `ChatSnapshot.legacy.nodes`, `ToolResultNode` fields, `conversation.session.header.actions` / `conversation.chat.turn` slots, `settings.section` slot, client inject ids, `@deepseek-ai/schemastery ^3.18.0`) was verified unchanged against the 0.1.7-rc.2 npm package. A `settings.plugin.item` string found in client.js comments was confirmed to be a documentation remark (the actual registration uses `settings.section`, which remains healthy in 0.1.7); no code migration is required.
|
|
28
31
|
- Creating a mindmap re-checks its target against the filesystem immediately before the write (036 follow-up, P1). The path was validated when the confirmation was drawn, but the plan was then trusted as-is: renaming the target directory and replacing it with a symlink pointing outside the session working directory while the user was reading the confirmation made `mindmap_create` write the file outside the workspace. Every candidate — inbox or explicit directory — is now re-resolved through the same inside-the-cwd check right before its atomic `wx` create; a path that no longer resolves inside the session cwd aborts the create (no outside file, no session grant), and the user is asked to start it again. The path confirmed and the path written stay the same one.
|
|
29
32
|
- Fixed a session-initialization race where an AI `mindmap_create` could expand the right-side tab but leave the workspace on the directory list. Session cleanup now runs before automatic document selection, and the opening-event cursor is reset when switching sessions.
|
package/index.js
CHANGED
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
// 015 起经 settings namespace 可运行时切换。
|
|
19
19
|
// - 依赖:仅 @deepseek-ai/schemastery(settings schema;发布包正常解析,
|
|
20
20
|
// link 开发需先 npm i)。工具参数 schema 仍手写 JSON Schema(003 偏差 1)。
|
|
21
|
-
import { access, mkdir, open, opendir, realpath, rename, stat, unlink, writeFile } from 'node:fs/promises'
|
|
21
|
+
import { access, mkdir, open, opendir, readFile, realpath, rename, stat, unlink, writeFile } from 'node:fs/promises'
|
|
22
22
|
import { createHash, randomUUID } from 'node:crypto'
|
|
23
|
+
import { homedir } from 'node:os'
|
|
23
24
|
import { dirname, isAbsolute, join, relative, resolve as resolvePath, sep } from 'node:path'
|
|
24
25
|
import Schema from '@deepseek-ai/schemastery'
|
|
25
26
|
|
|
@@ -41,14 +42,98 @@ function normalizeApprovalMode(value, requireApproval = true) {
|
|
|
41
42
|
return 'session'
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
* 0.1.7 迁移:从 settings.yaml.imported 的 mindmap 段提取标量字段。
|
|
47
|
+
* 该文件是宿主自动改名后的旧 settings.yaml,格式是顶层 YAML 段,
|
|
48
|
+
* mindmap 段下全是 `key: value` 标量行——不引入 YAML 库,只按行解析。
|
|
49
|
+
* 容错:文件不存在、解析失败、mindmap 段缺失一律返回 null(静默跳过)。
|
|
50
|
+
*
|
|
51
|
+
* `raw` 是文件的完整文本;返回已校验过的可写入字段对象,或 null。
|
|
52
|
+
*/
|
|
53
|
+
const MIGRATABLE_KEYS = {
|
|
54
|
+
requireApproval: (v) => v === 'true' || v === 'false',
|
|
55
|
+
approvalMode: (v) => APPROVAL_MODES.includes(v) || v === 'once-per-document' || v === 'always',
|
|
56
|
+
defaultPanelWidth: (v) => /^\d+$/.test(v) && Number(v) >= 20 && Number(v) <= 80,
|
|
57
|
+
lineStyle: (v) => v === 'curve' || v === 'elbow',
|
|
58
|
+
cardStyle: (v) => v === 'rounded' || v === 'square',
|
|
59
|
+
colorTheme: (v) => v === 'ocean' || v === 'sunset' || v === 'forest',
|
|
60
|
+
growthAnimation: (v) => v === 'true' || v === 'false',
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const MIGRATABLE_PARSERS = {
|
|
64
|
+
requireApproval: (v) => v === 'true',
|
|
65
|
+
defaultPanelWidth: (v) => Number(v),
|
|
66
|
+
growthAnimation: (v) => v === 'true',
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parseLegacyMindmapSection(raw) {
|
|
70
|
+
if (typeof raw !== 'string') return null
|
|
71
|
+
const lines = raw.split('\n')
|
|
72
|
+
let inMindmap = false
|
|
73
|
+
const found = {}
|
|
74
|
+
for (const line of lines) {
|
|
75
|
+
if (/^mindmap:\s*$/.test(line)) { inMindmap = true; continue }
|
|
76
|
+
if (inMindmap) {
|
|
77
|
+
if (/^\S/.test(line)) break
|
|
78
|
+
const m = /^\s{2,}(\w+):\s*(.+?)\s*$/.exec(line)
|
|
79
|
+
if (!m) continue
|
|
80
|
+
const key = m[1]
|
|
81
|
+
const val = m[2]
|
|
82
|
+
if (MIGRATABLE_KEYS[key] && MIGRATABLE_KEYS[key](val)) {
|
|
83
|
+
found[key] = MIGRATABLE_PARSERS[key] ? MIGRATABLE_PARSERS[key](val) : val
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return Object.keys(found).length ? found : null
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 判断当前 settings value 是否全为默认值。迁移还要检查 descriptor.user,
|
|
92
|
+
* 否则用户明确保存了默认值后,每次启动都会被旧文件覆盖。
|
|
93
|
+
*/
|
|
94
|
+
const CONFIG_DEFAULTS = {
|
|
95
|
+
requireApproval: true,
|
|
96
|
+
approvalMode: 'session',
|
|
97
|
+
defaultPanelWidth: 42,
|
|
98
|
+
lineStyle: 'elbow',
|
|
99
|
+
cardStyle: 'rounded',
|
|
100
|
+
colorTheme: 'ocean',
|
|
101
|
+
growthAnimation: true,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isAllDefaults(value) {
|
|
105
|
+
if (!value || typeof value !== 'object') return true
|
|
106
|
+
// 空对象(新存储里没有任何值)= 需要迁移
|
|
107
|
+
if (Object.keys(value).length === 0) return true
|
|
108
|
+
for (const key in CONFIG_DEFAULTS) {
|
|
109
|
+
if (value[key] !== CONFIG_DEFAULTS[key]) return false
|
|
110
|
+
}
|
|
111
|
+
return true
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** 只恢复尚无用户覆盖值的旧设置;修订号防止读取旧文件期间覆盖新的面板写入。 */
|
|
115
|
+
async function migrateLegacyMindmap(settings, imported, isActive = () => true) {
|
|
116
|
+
const descriptor = settings.describe().find((row) => row.ns === SETTINGS_NAMESPACE)
|
|
117
|
+
if (!descriptor || !isAllDefaults(descriptor.value) || Object.keys(descriptor.user ?? {}).length) return
|
|
118
|
+
const raw = await readFile(imported, 'utf8').catch(() => null)
|
|
119
|
+
const legacy = parseLegacyMindmapSection(raw)
|
|
120
|
+
if (!legacy || !isActive()) return
|
|
121
|
+
await settings.update(SETTINGS_NAMESPACE, legacy, descriptor.revision)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** 0.1.7+ 的 Config 字段可能是随设置变更而更新的 volatile 引用。 */
|
|
125
|
+
function configValue(value) {
|
|
126
|
+
return value !== null && typeof value === 'object' && typeof value.get === 'function' ? value.get() : value
|
|
127
|
+
}
|
|
128
|
+
|
|
44
129
|
export const Config = Schema.object({
|
|
45
|
-
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.'),
|
|
46
|
-
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.'),
|
|
47
|
-
defaultPanelWidth: Schema.number().default(42).description('Default floating-panel width as a percentage of the viewport (clamped 20-80 on the client).'),
|
|
48
|
-
lineStyle: Schema.union(['curve', 'elbow']).default('elbow').description('Connector line style between nodes: curve (bezier) or elbow (orthogonal).'),
|
|
49
|
-
cardStyle: Schema.union(['rounded', 'square']).default('rounded').description('Node card corner style.'),
|
|
50
|
-
colorTheme: Schema.union(['ocean', 'sunset', 'forest']).default('ocean').description('Node color theme.'),
|
|
51
|
-
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.'),
|
|
130
|
+
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),
|
|
132
|
+
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
|
+
lineStyle: Schema.union(['curve', 'elbow']).default('elbow').description('Connector line style between nodes: curve (bezier) or elbow (orthogonal).').extra('volatile', true),
|
|
134
|
+
cardStyle: Schema.union(['rounded', 'square']).default('rounded').description('Node card corner style.').extra('volatile', true),
|
|
135
|
+
colorTheme: Schema.union(['ocean', 'sunset', 'forest']).default('ocean').description('Node color theme.').extra('volatile', true),
|
|
136
|
+
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),
|
|
52
137
|
})
|
|
53
138
|
|
|
54
139
|
const MAX_CONTENT_BYTES = 2 * 1024 * 1024
|
|
@@ -565,28 +650,51 @@ function defineTool(spec) {
|
|
|
565
650
|
}
|
|
566
651
|
|
|
567
652
|
export function apply(ctx, config = {}) {
|
|
568
|
-
//
|
|
569
|
-
//
|
|
570
|
-
const entryConfig = {
|
|
571
|
-
requireApproval
|
|
572
|
-
approvalMode
|
|
573
|
-
|
|
574
|
-
lineStyle
|
|
575
|
-
cardStyle
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
653
|
+
// 新宿主从平铺导出的 Config 发现 schema,entry 的 config 由宿主提供;
|
|
654
|
+
// 未取得设置描述符时,回退到入口配置(兼容旧宿主和 volatile 引用)。
|
|
655
|
+
const entryConfig = () => {
|
|
656
|
+
const requireApproval = configValue(config.requireApproval) !== false
|
|
657
|
+
const approvalMode = configValue(config.approvalMode)
|
|
658
|
+
const defaultPanelWidth = configValue(config.defaultPanelWidth)
|
|
659
|
+
const lineStyle = configValue(config.lineStyle)
|
|
660
|
+
const cardStyle = configValue(config.cardStyle)
|
|
661
|
+
const colorTheme = configValue(config.colorTheme)
|
|
662
|
+
return {
|
|
663
|
+
requireApproval,
|
|
664
|
+
approvalMode: normalizeApprovalMode(approvalMode, requireApproval),
|
|
665
|
+
defaultPanelWidth: typeof defaultPanelWidth === 'number' ? defaultPanelWidth : 42,
|
|
666
|
+
lineStyle: lineStyle === 'curve' ? 'curve' : 'elbow',
|
|
667
|
+
cardStyle: cardStyle === 'square' ? 'square' : 'rounded',
|
|
668
|
+
colorTheme: colorTheme === 'sunset' || colorTheme === 'forest' ? colorTheme : 'ocean',
|
|
669
|
+
growthAnimation: configValue(config.growthAnimation) !== false,
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
let activeConfig = entryConfig
|
|
585
674
|
ctx.inject(['settings'], (sctx) => {
|
|
586
|
-
const
|
|
587
|
-
|
|
675
|
+
const settings = sctx.settings
|
|
676
|
+
let active = true
|
|
677
|
+
if (typeof settings.register === 'function') {
|
|
678
|
+
// 0.1.5 等旧宿主仍由插件注册 namespace。
|
|
679
|
+
const scope = settings.register(SETTINGS_NAMESPACE, Config, { base: entryConfig() })
|
|
680
|
+
activeConfig = () => scope.get()
|
|
681
|
+
} else {
|
|
682
|
+
// 0.1.7+ 只有 describe/update 服务面;描述符的 value 是已解析的实时值。
|
|
683
|
+
activeConfig = () => ({
|
|
684
|
+
...entryConfig(),
|
|
685
|
+
...settings.describe().find((row) => row.ns === SETTINGS_NAMESPACE)?.value,
|
|
686
|
+
})
|
|
687
|
+
// .imported 是宿主改名后的旧文件:只在新存储无用户覆盖时恢复,
|
|
688
|
+
// 不删除旧文件,失败也不妨碍工具和设置面板继续工作。
|
|
689
|
+
void (async () => {
|
|
690
|
+
// describe 只包含 state=2 的插件;等 loader 完成加载后再尝试迁移。
|
|
691
|
+
await sctx.root?.loader?.await?.()
|
|
692
|
+
if (active) await migrateLegacyMindmap(settings, join(homedir(), '.dsh', 'settings.yaml.imported'), () => active)
|
|
693
|
+
})().catch(() => {})
|
|
694
|
+
}
|
|
588
695
|
sctx.effect(() => () => {
|
|
589
|
-
|
|
696
|
+
active = false
|
|
697
|
+
activeConfig = entryConfig
|
|
590
698
|
})
|
|
591
699
|
})
|
|
592
700
|
|
|
@@ -963,4 +1071,9 @@ export const internals = Object.freeze({
|
|
|
963
1071
|
isTrustedRequest,
|
|
964
1072
|
buildResult,
|
|
965
1073
|
revisionOfContent,
|
|
1074
|
+
Config,
|
|
1075
|
+
parseLegacyMindmapSection,
|
|
1076
|
+
isAllDefaults,
|
|
1077
|
+
CONFIG_DEFAULTS,
|
|
1078
|
+
migrateLegacyMindmap,
|
|
966
1079
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mindmap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
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",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@deepseek-ai/schemastery": "^3.18.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6 || ^0.1.1-rc.0 || ^0.1.2-alpha.0 || ^0.1.3-alpha.0 || ^0.1.5-alpha.0 || ^0.1.7-alpha.0",
|
|
39
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6 || ^0.1.1-rc.0 || ^0.1.2-alpha.0 || ^0.1.3-alpha.0 || ^0.1.5-alpha.0 || ^0.1.7-alpha.0 || ^0.2.0-alpha.0",
|
|
40
40
|
"dsh-better-sidebar": ">=0.10.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|