From d9339a909466f8f51fb9936da28ade00776c5f72 Mon Sep 17 00:00:00 2001 From: newbie Date: Fri, 13 Nov 2026 11:33:27 +0800 Subject: [PATCH] feat(skills,mcp): searchable import panel with batch import; compact MCP toolbar with contextual batch actions (0.9.7) --- client/index.js | 379 +++++++++++++++++++++++++++++++---------- lib/index.js | 2 +- lib/mnemon/index.js | 2 +- package.json | 2 +- preview-import.mjs | 360 ++++++++++++++++++++++++++++++++++++++ preview-mcp.mjs | 344 +++++++++++++++++++++++++++++++++++++ src/index.ts | 2 +- src/mnemon/index.ts | 2 +- verify-card-render.mjs | 14 +- verify-full-load.mjs | 2 +- verify-upgrade.mjs | 2 +- 11 files changed, 1006 insertions(+), 105 deletions(-) create mode 100644 preview-import.mjs create mode 100644 preview-mcp.mjs diff --git a/client/index.js b/client/index.js index 92a99ca..feca005 100644 --- a/client/index.js +++ b/client/index.js @@ -305,8 +305,8 @@ window.__ModuleLoader__.load({ display: 'flex', flexDirection: 'column', gap: '4px', - flex: '1 1 220px', - minWidth: 0, + flex: '1 1 auto', + minWidth: '220px', }, label: { fontSize: '12px', @@ -392,6 +392,8 @@ window.__ModuleLoader__.load({ border: '1px solid rgba(127,127,127,0.35)', fontSize: '12px', maxWidth: '100%', + whiteSpace: 'nowrap', + flex: '0 0 auto', }, table: { width: '100%', @@ -1191,7 +1193,7 @@ window.__ModuleLoader__.load({ // ---- import skills from other tools ------------------------------- function ImportSection(props) { var onImported = props && typeof props.onImported === 'function' ? props.onImported : null - var tuple = React.useState({ expanded: false, status: 'idle', sources: [], open: {}, busy: '', notice: null, imported: {} }) + var tuple = React.useState({ expanded: false, status: 'idle', sources: [], open: {}, busy: '', notice: null, imported: {}, search: '', selection: [], progress: null }) var s = tuple[0] var set = tuple[1] function patch(next) { set(function (prev) { return Object.assign({}, prev, next) }) } @@ -1224,19 +1226,97 @@ window.__ModuleLoader__.load({ } function toggleSource(sourceId) { var next = Object.assign({}, s.open) - next[sourceId] = next[sourceId] !== true + var open = s.open[sourceId] !== false + next[sourceId] = !open patch({ open: next }) } - function doImport(source, skill) { - patch({ busy: source.id + ':' + skill.folder }) - postJson(API.skills + '/import', { sourceId: source.id, folder: skill.folder }).then(function (res) { - if (res.body !== null && res.body !== undefined && res.body.ok === true) { - var imported = Object.assign({}, s.imported) - imported[skill.folder] = true - patch({ busy: '', imported: imported, notice: { tone: 'ok', text: '已导入「' + skill.name + '」到 DSH,技能文件夹里就能看到。' } }) - if (onImported !== null) onImported() - } else patch({ busy: '', notice: { tone: 'bad', text: bodyError(res, '导入失败') } }) - }, function (error) { patch({ busy: '', notice: { tone: 'bad', text: messageOf(error) } }) }) + var mine = dshFolders() + var others = s.sources.filter(function (source) { return !source.writable }) + var needle = String(s.search).trim().toLowerCase() + function skillsOf(source) { + var list = [] + var groups = source.groups || [] + groups.forEach(function (group) { + var items = group.skills || [] + items.forEach(function (skill) { list.push(skill) }) + }) + return list + } + function importedYet(skill) { + return mine[skill.folder] === true || s.imported[skill.folder] === true + } + var candidates = [] + others.forEach(function (source) { + if (!source.exists) return + skillsOf(source).forEach(function (skill) { + candidates.push({ source: source, skill: skill }) + }) + }) + var matches = needle === '' ? candidates : candidates.filter(function (entry) { + var hay = String(entry.skill.name || '') + ' ' + String(entry.skill.folder || '') + ' ' + String(entry.skill.description || '') + return hay.toLowerCase().indexOf(needle) >= 0 + }) + var importable = matches.filter(function (entry) { return !importedYet(entry.skill) }) + var alreadyCount = candidates.length - candidates.filter(function (entry) { return !importedYet(entry.skill) }).length + function keyOf(entry) { + return String(entry.source.id) + ':' + String(entry.skill.folder) + } + var chosen = s.selection + function isChosen(entry) { + return chosen.indexOf(keyOf(entry)) >= 0 + } + function chooseMany(list, on) { + var next = chosen.slice() + list.forEach(function (entry) { + var key = keyOf(entry) + var at = next.indexOf(key) + if (on === true && at < 0) next.push(key) + if (on !== true && at >= 0) next.splice(at, 1) + }) + patch({ selection: next }) + } + var chosenEntries = candidates.filter(function (entry) { + return chosen.indexOf(keyOf(entry)) >= 0 && !importedYet(entry.skill) + }) + function importSelected() { + var targets = chosenEntries + if (targets.length === 0) return Promise.resolve() + patch({ busy: 'batch', notice: null, progress: { done: 0, total: targets.length } }) + var done = 0 + var failures = [] + var importedMap = Object.assign({}, s.imported) + var chain = Promise.resolve() + targets.forEach(function (entry) { + chain = chain.then(function () { + return postJson(API.skills + '/import', { sourceId: entry.source.id, folder: entry.skill.folder }).then( + function (res) { + if (res.body !== null && res.body !== undefined && res.body.ok === true) { + done += 1 + importedMap[entry.skill.folder] = true + } else failures.push(String(entry.skill.name) + '(' + bodyError(res, '失败') + ')') + patch({ progress: { done: done + failures.length, total: targets.length } }) + }, + function (error) { + failures.push(String(entry.skill.name) + '(' + messageOf(error) + ')') + patch({ progress: { done: done + failures.length, total: targets.length } }) + }, + ) + }) + }) + return chain.then(function () { + patch({ + busy: '', + progress: null, + selection: [], + imported: importedMap, + notice: { + tone: failures.length === 0 ? 'ok' : 'warn', + text: '已导入 ' + String(done) + ' / ' + String(targets.length) + ' 个技能到 DSH' + (failures.length === 0 ? '。' : ';失败:' + failures.join('、')), + }, + }) + if (onImported !== null) onImported() + load() + }) } if (!s.expanded) { return h( @@ -1250,40 +1330,73 @@ window.__ModuleLoader__.load({ s.notice === null ? null : h(Banner, { tone: s.notice.tone }, s.notice.text), ) } - var mine = dshFolders() - var others = s.sources.filter(function (source) { return !source.writable }) - var rows = others.map(function (source) { - var skills = [] - var groups = source.groups || [] - groups.forEach(function (group) { - var list = group.skills || [] - list.forEach(function (skill) { skills.push(skill) }) - }) - var open = s.open[source.id] === true + function describe(skill) { + var text = String(skill.description === undefined || skill.description === null ? '' : skill.description).trim() + if (/^[>|][+-]?$/.test(text)) return '' + return text + } + var blocks = others.map(function (source) { + var all = skillsOf(source) + var visible = matches.filter(function (entry) { return entry.source.id === source.id }) + var open = s.open[source.id] !== false + var selectable = visible.filter(function (entry) { return !importedYet(entry.skill) }) return h('div', { key: source.id, style: styles.row }, h('div', { style: styles.rowHead }, h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: '8px', minWidth: 0 } }, - h('span', { style: styles.sourceGlyph }, source.label.slice(0, 1)), - h('span', { style: styles.sourceTitle }, source.label), - h('span', { style: styles.hint }, source.exists ? skills.length + ' 个技能' : '未安装'), + h('span', { style: styles.sourceGlyph }, String(source.label).slice(0, 1)), + h('span', { style: styles.sourceTitle }, String(source.label)), + h( + 'span', + { style: styles.hint }, + source.exists + ? String(all.length) + ' 个技能' + (needle === '' ? '' : ' · 匹配 ' + String(visible.length)) + ' · 可导入 ' + String(selectable.length) + : '未安装', + ), ), - source.exists ? h(Btn, { label: open ? '收起' : '展开', variant: 'small', onClick: function () { toggleSource(source.id) } }) : null, - ), - h('span', { style: styles.mono }, source.root), - !source.exists || !open ? null : skills.length === 0 - ? h('p', { style: styles.hint }, '这个来源里还没有技能。') - : h('div', { style: { display: 'flex', flexDirection: 'column', gap: '2px' } }, skills.map(function (skill) { - var has = mine[skill.folder] === true || s.imported[skill.folder] === true - return h('div', { key: skill.folder, style: styles.skillRow }, - h('span', { style: { minWidth: 0 } }, - h('span', { style: styles.rowTitle }, skill.name), - skill.description ? h('span', { style: Object.assign({}, styles.hint, { display: 'block' }) }, skill.description) : null, - ), - has - ? h(Pill, { label: 'DSH', value: '已导入', tone: 'muted' }) - : h(Btn, { label: s.busy === source.id + ':' + skill.folder ? '导入中…' : '导入', variant: 'small', disabled: s.busy !== '', onClick: function () { doImport(source, skill) } }), + source.exists + ? h('div', { style: styles.actions }, + h(Btn, { + label: '全选本来源(' + String(selectable.length) + ')', + ariaLabel: '全选本来源 ' + String(source.label), + variant: 'small', + disabled: selectable.length === 0 || s.busy !== '', + onClick: function () { chooseMany(visible, true) }, + }), + h(Btn, { label: open ? '收起' : '展开', variant: 'small', onClick: function () { toggleSource(source.id) } }), ) - })), + : null, + ), + h('span', { style: styles.mono }, String(source.root)), + !source.exists || !open + ? null + : visible.length === 0 + ? h('p', { style: styles.hint }, needle === '' ? '这个来源里还没有技能。' : '没有匹配「' + s.search + '」的技能。') + : h( + 'div', + { style: { display: 'flex', flexDirection: 'column', gap: '2px', maxHeight: '320px', overflow: 'auto' } }, + visible.map(function (entry) { + var skill = entry.skill + var has = importedYet(skill) + return h( + 'label', + { key: String(skill.folder), style: styles.checkboxRow }, + h('input', { + type: 'checkbox', + checked: has || isChosen(entry), + disabled: has || s.busy !== '', + 'aria-label': '选择技能 ' + String(skill.name), + onChange: function (event) { chooseMany([entry], event.target.checked === true) }, + }), + h( + 'span', + { style: { minWidth: 0, flex: '1 1 auto' } }, + h('span', { style: styles.rowTitle }, String(skill.name)), + describe(skill) === '' ? null : h('span', { style: Object.assign({}, styles.hint, styles.clamp1) }, describe(skill)), + ), + has ? h(Pill, { label: 'DSH', value: '已导入', tone: 'muted' }) : null, + ) + }), + ), ) }) return h( @@ -1300,7 +1413,72 @@ window.__ModuleLoader__.load({ }, s.status === 'loading' ? h('p', { style: styles.hint }, '正在读取来源…') : others.length === 0 ? h('p', { style: styles.hint }, '没有检测到其他软件的技能目录。') - : h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px' } }, rows), + : h( + 'div', + { style: styles.root }, + h( + 'div', + { style: styles.pills }, + h(Pill, { label: '来源', value: String(others.length), tone: 'muted' }), + h(Pill, { label: '可导入', value: String(candidates.length - alreadyCount), tone: 'muted' }), + s.search === '' ? null : h(Pill, { label: '匹配', value: String(matches.length), tone: matches.length === 0 ? 'muted' : 'ok' }), + h(Pill, { label: '已选', value: String(chosenEntries.length), tone: chosenEntries.length === 0 ? 'muted' : 'ok' }), + alreadyCount === 0 ? null : h(Pill, { label: '已在 DSH', value: String(alreadyCount), tone: 'muted' }), + ), + h( + 'div', + { style: { display: 'flex', gap: '8px', alignItems: 'center', flexWrap: 'wrap' } }, + h('input', { + type: 'search', + style: Object.assign({}, styles.input, { flex: '1 1 220px', minWidth: 0 }), + value: s.search, + placeholder: '搜索技能:名称 / 目录 / 描述', + 'aria-label': '搜索要导入的技能', + onChange: function (event) { patch({ search: event.target.value }) }, + }), + s.search === '' ? null : h(Btn, { + label: '清空搜索', + variant: 'small', + onClick: function () { patch({ search: '' }) }, + }), + ), + h( + 'div', + { style: Object.assign({}, styles.actions, { flexWrap: 'wrap' }) }, + h(Btn, { + label: '全选匹配可导入(' + String(importable.length) + ')', + ariaLabel: '全选匹配可导入', + variant: 'small', + disabled: importable.length === 0 || s.busy !== '', + onClick: function () { chooseMany(importable, true) }, + }), + h(Btn, { + label: '全选全部(' + String(candidates.length - alreadyCount) + ')', + ariaLabel: '全选全部', + variant: 'small', + disabled: candidates.length - alreadyCount === 0 || s.busy !== '', + onClick: function () { + chooseMany(candidates.filter(function (entry) { return !importedYet(entry.skill) }), true) + }, + }), + h(Btn, { + label: '清空已选', + ariaLabel: '清空已选', + variant: 'small', + disabled: chosenEntries.length === 0, + onClick: function () { patch({ selection: [] }) }, + }), + h(Btn, { + variant: 'primary', + label: s.busy === 'batch' ? '导入中…' : '导入所选(' + String(chosenEntries.length) + ')', + ariaLabel: '导入所选', + disabled: s.busy !== '' || chosenEntries.length === 0, + onClick: importSelected, + }), + ), + s.progress === null ? null : h('p', { style: styles.hint }, '正在导入:' + String(s.progress.done) + ' / ' + String(s.progress.total)), + h('div', { style: { display: 'flex', flexDirection: 'column', gap: '10px' } }, blocks), + ), s.notice === null ? null : h(Banner, { tone: s.notice.tone }, s.notice.text), ) } @@ -3099,6 +3277,7 @@ window.__ModuleLoader__.load({ { style: Object.assign({}, styles.actions, { flexWrap: 'wrap' }) }, h(Btn, { label: '全选匹配结果(' + String(visibleItems.length) + ')', + ariaLabel: '全选匹配结果', variant: 'small', disabled: visibleItems.length === 0, onClick: function () { @@ -3107,6 +3286,7 @@ window.__ModuleLoader__.load({ }), h(Btn, { label: '全选全部(' + String(items.length) + ')', + ariaLabel: '全选全部', variant: 'small', disabled: items.length === 0 || mcpChosen.length === items.length, onClick: function () { @@ -3115,6 +3295,7 @@ window.__ModuleLoader__.load({ }), h(Btn, { label: '取消勾选匹配项(' + String(matchedSelected) + ')', + ariaLabel: '取消勾选匹配项', variant: 'small', disabled: matchedSelected === 0, onClick: function () { @@ -3123,6 +3304,7 @@ window.__ModuleLoader__.load({ }), h(Btn, { label: '清空已选', + ariaLabel: '清空已选', variant: 'small', disabled: mcpChosen.length === 0, onClick: function () { @@ -3130,60 +3312,69 @@ window.__ModuleLoader__.load({ }, }), ), - h( - 'div', - { style: Object.assign({}, styles.actions, { flexWrap: 'wrap' }) }, - h(Btn, { - label: '批量健康检查', - variant: 'small', - disabled: mcpChosen.length === 0 || mcp.busy !== '', - onClick: function () { - runMcpBulk('批量健康检查', 'healthCheck', function (item) { return { connectorId: item.connectorId } }) - }, - }), - h(Btn, { - label: '批量启用', - variant: 'small', - disabled: mcpChosen.length === 0 || mcp.busy !== '', - onClick: function () { - runMcpBulk('批量启用', 'setEnabled', function (item) { return { key: item.key, enabled: true } }) - }, - }), - h(Btn, { - label: '批量停用', - variant: 'small', - disabled: mcpChosen.length === 0 || mcp.busy !== '', - onClick: function () { - runMcpBulk('批量停用', 'setEnabled', function (item) { return { key: item.key, enabled: false } }) - }, - }), - h(Btn, { - label: '批量重连', - variant: 'small', - disabled: mcpChosen.length === 0 || mcp.busy !== '', - onClick: function () { - runMcpBulk('批量重连', 'reconnect', function (item) { return { key: item.key } }) - }, - }), - mcp.confirmBulk === true - ? h(Btn, { - label: '确认批量移除(' + String(mcpChosen.length) + ')', - variant: 'danger', - disabled: mcpChosen.length === 0 || mcp.busy !== '', - onClick: function () { - runMcpBulk('批量移除', 'disconnect', function (item) { return { key: item.key } }) - }, - }) - : h(Btn, { - label: '批量移除…', + mcpChosen.length === 0 + ? h('p', { style: styles.hint }, '勾选左侧连接后,这里会出现批量健康检查、启停、重连与移除。') + : h( + 'div', + { style: Object.assign({}, styles.actions, { flexWrap: 'wrap' }) }, + h('span', { style: styles.hint }, '批量操作(已选 ' + String(mcpChosen.length) + '):'), + h(Btn, { + label: '健康检查', + ariaLabel: '批量健康检查', variant: 'small', - disabled: mcpChosen.length === 0 || mcp.busy !== '', + disabled: mcp.busy !== '', onClick: function () { - patchMcp({ confirmBulk: true }) - setNotice({ tone: 'warn', text: '批量移除会断开所选 ' + String(mcpChosen.length) + ' 条连接定义;再点一次「确认批量移除」才执行。' }) + runMcpBulk('批量健康检查', 'healthCheck', function (item) { return { connectorId: item.connectorId } }) }, }), - ), + h(Btn, { + label: '启用', + ariaLabel: '批量启用', + variant: 'small', + disabled: mcp.busy !== '', + onClick: function () { + runMcpBulk('批量启用', 'setEnabled', function (item) { return { key: item.key, enabled: true } }) + }, + }), + h(Btn, { + label: '停用', + ariaLabel: '批量停用', + variant: 'small', + disabled: mcp.busy !== '', + onClick: function () { + runMcpBulk('批量停用', 'setEnabled', function (item) { return { key: item.key, enabled: false } }) + }, + }), + h(Btn, { + label: '重连', + ariaLabel: '批量重连', + variant: 'small', + disabled: mcp.busy !== '', + onClick: function () { + runMcpBulk('批量重连', 'reconnect', function (item) { return { key: item.key } }) + }, + }), + mcp.confirmBulk === true + ? h(Btn, { + label: '确认移除(' + String(mcpChosen.length) + ')', + ariaLabel: '确认批量移除', + variant: 'danger', + disabled: mcp.busy !== '', + onClick: function () { + runMcpBulk('批量移除', 'disconnect', function (item) { return { key: item.key } }) + }, + }) + : h(Btn, { + label: '移除…', + ariaLabel: '批量移除', + variant: 'small', + disabled: mcp.busy !== '', + onClick: function () { + patchMcp({ confirmBulk: true }) + setNotice({ tone: 'warn', text: '批量移除会断开所选 ' + String(mcpChosen.length) + ' 条连接定义;再点一次「确认移除」才执行。' }) + }, + }), + ), mcpBulk === null ? null : h('p', { style: styles.hint }, String(mcpBulk.label) + ' 进行中:' + String(mcpBulk.done) + ' / ' + String(mcpBulk.total)), visibleItems.length === 0 ? h('p', { style: styles.hint }, '没有匹配「' + mcpSearch + '」的连接。换个关键词或切回「全部」筛选。') : null, visibleItems.map(function (item) { diff --git a/lib/index.js b/lib/index.js index 3faf73a..a1e18f1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -26,7 +26,7 @@ export const name = 'dsh-brain'; /** Services required before `apply` runs. */ export const inject = ['webServer']; /** Version reported by the status card. */ -const VERSION = '0.9.6'; +const VERSION = '0.9.7'; /** How often the skill directory is reconciled with the cloud center. */ const SKILL_SYNC_INTERVAL_MS = 15 * 60_000; /** How often queued reports are retried. */ diff --git a/lib/mnemon/index.js b/lib/mnemon/index.js index 55a76bc..0e41547 100644 --- a/lib/mnemon/index.js +++ b/lib/mnemon/index.js @@ -17,7 +17,7 @@ import { descriptor } from "./descriptor.js"; import { LongMemoryProvider } from "./driver.js"; export { LongMemoryProvider, descriptor }; /** Keep in sync with the package version (asserted by the verify script). */ -const PROVIDER_VERSION = '0.9.6'; +const PROVIDER_VERSION = '0.9.7'; export const definition = defineMemorySpaceProviderDefinition({ manifest: { apiVersion: MEMORY_SPACE_PROVIDER_API_VERSION, diff --git a/package.json b/package.json index 87dda56..c876cd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsh-brain", - "version": "0.9.6", + "version": "0.9.7", "description": "Cloud memory for DSH: report one activity turn per conversation round and expose memory_search / memory_read / memory_add tools against a LongMemory cloud endpoint.", "type": "module", "license": "MIT", diff --git a/preview-import.mjs b/preview-import.mjs new file mode 100644 index 0000000..3c04704 --- /dev/null +++ b/preview-import.mjs @@ -0,0 +1,360 @@ +// Renders the redesigned 「从其他软件导入」 panel to a PNG so the layout can be +// reviewed before DSH is restarted. It reads the *live* skill sources through +// the built plugin (read-only), expands the import panel, and screenshots the +// result with headless Chrome. +import { execFileSync } from 'node:child_process' +import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' + +const here = dirname(fileURLToPath(import.meta.url)) +const source = readFileSync(join(here, 'client', 'index.js'), 'utf8') + +// ── real data ─────────────────────────────────────────────────────────── +const { SkillAdmin, skillsHoldingDir } = await import('./lib/skill-admin.js') +const { SkillGroupManager, detectSources } = await import('./lib/skill-groups.js') +const { SettingsStore } = await import('./lib/store.js') + +const store = new SettingsStore({}) +const admin = new SkillAdmin({ + skillsRoot: () => join(store.path, '..', 'skills'), + holdingDir: () => skillsHoldingDir(), + syncStatePath: () => join(store.path, '..', 'dsh-brain-skills.json'), + syncRunning: () => false, + log: () => {}, +}) +const groups = new SkillGroupManager({ sources: () => detectSources(), admin, log: () => {} }) +const overview = await groups.overview() + +const statusBody = { + ok: true, + settings: { + enabled: true, + baseUrl: 'https://your-memory-host/api/longmemory', + baseUrlConfigured: true, + baseUrlOrigin: 'https://your-memory-host', + clientId: 'dsh-desktop', + requestTimeoutMs: 5000, + defaultK: 10, + summaryEnabled: true, + summaryMaxChars: 6000, + skillsSyncEnabled: true, + skillsDir: '', + }, + tokens: { + activity: { configured: true, masked: 'cmt_9f2c1a…7d4e' }, + memory: { configured: true, masked: 'cmt_3b81cc…22a9' }, + summary: { configured: true, masked: 'cmt_71ad02…9f10' }, + }, + settingsPath: '%USERPROFILE%/.dsh/dsh-brain.json', + reporter: { attempted: 12, recorded: 11, duplicate: 1, failed: 0, skipped: 0, queued: 0, recent: [] }, + lastCheck: { + at: Date.now(), + checks: [ + { id: 'network', label: '服务地址', state: 'ok', message: '服务可达(HTTP 200)' }, + { id: 'activity', label: '活动上报权限(activity:write)', state: 'ok', message: '鉴权通过' }, + { id: 'memory', label: '记忆读写权限(memory:write)', state: 'ok', message: '鉴权通过(3 个项目)' }, + { id: 'summary', label: '摘要权限(summary:write)', state: 'ok', message: '鉴权通过' }, + ], + }, + capabilities: { version: '0.9.7', features: { skills: true, skillsMarketplace: false, mcpBridge: 'host-plugin' }, notes: [] }, + skills: { running: false, downloaded: [], uploaded: [], updated: [], conflicts: [], skipped: 0 }, +} + +// ── minimal React + HTML serializer ───────────────────────────────────── +let hooks = [] +let cursor = 0 +let pendingEffects = [] +let scheduled = false + +const React = { + createElement(type, props, ...children) { + const flat = [] + const push = (value) => { + if (Array.isArray(value)) value.forEach(push) + else if (value !== null && value !== undefined && value !== false && value !== true) flat.push(value) + } + push(children) + return { type, props: { ...(props ?? {}), children: flat.length === 1 ? flat[0] : flat }, children: flat } + }, + useState(initial) { + const index = cursor++ + if (!(index in hooks)) hooks[index] = typeof initial === 'function' ? initial() : initial + const setter = (next) => { + const value = typeof next === 'function' ? next(hooks[index]) : next + if (value !== hooks[index]) { + hooks[index] = value + scheduled = true + } + } + return [hooks[index], setter] + }, + useEffect(fn) { + pendingEffects.push(fn) + }, + useCallback(fn) { + return fn + }, + Component: function Component(props) { + this.props = props + }, +} +React.Component.prototype.setState = function setState(patch) { + this.state = { ...this.state, ...patch } + scheduled = true +} + +function walk(node, visit) { + if (node === null || node === undefined || node === false || node === true) return + if (typeof node === 'string' || typeof node === 'number') return + if (Array.isArray(node)) { + node.forEach((child) => walk(child, visit)) + return + } + if (typeof node.type === 'function') { + if (node.type.prototype && typeof node.type.prototype.render === 'function') { + const instance = new node.type(node.props) + instance.props = node.props + if (instance.state === undefined) instance.state = {} + instance.setState = function setState(patch) { + instance.state = { ...instance.state, ...patch } + scheduled = true + } + walk(instance.render(), visit) + return + } + walk(node.type({ ...node.props, children: node.children }), visit) + return + } + visit(node) + node.children.forEach((child) => walk(child, visit)) +} + +const UNITLESS = new Set(['fontWeight', 'opacity', 'lineHeight', 'flex', 'zIndex', 'flexGrow', 'flexShrink']) + +function styleOf(style) { + const parts = [] + for (const [key, value] of Object.entries(style ?? {})) { + if (value === null || value === undefined) continue + const name = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`) + parts.push(`${name}:${typeof value === 'number' && !UNITLESS.has(key) ? `${value}px` : String(value)}`) + } + return parts.join(';') +} + +function escapeHtml(text) { + return String(text).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"') +} + +function toHtml(node) { + if (node === null || node === undefined || node === false || node === true) return '' + if (typeof node === 'string' || typeof node === 'number') return escapeHtml(node) + if (Array.isArray(node)) return node.map(toHtml).join('') + const { type, props, children } = node + if (typeof type === 'function') { + if (type.prototype && typeof type.prototype.render === 'function') { + const instance = new type(props) + instance.props = props + if (instance.state === undefined) instance.state = {} + return toHtml(instance.render()) + } + return toHtml(type({ ...props, children })) + } + const attrs = [] + const style = styleOf(props.style) + if (style !== '') attrs.push(`style="${style}"`) + if (props.id !== undefined) attrs.push(`id="${escapeHtml(props.id)}"`) + if (props.role !== undefined) attrs.push(`role="${escapeHtml(props.role)}"`) + if (props.title !== undefined) attrs.push(`title="${escapeHtml(props.title)}"`) + if (props.disabled === true) attrs.push('disabled') + if (props.type === 'checkbox') attrs.push(props.checked === true ? 'checked' : '') + for (const [key, value] of Object.entries(props)) { + if (key.startsWith('aria-')) attrs.push(`${key}="${escapeHtml(value)}"`) + } + if (type === 'input') { + attrs.push(`value="${escapeHtml(props.value === undefined ? '' : props.value)}"`) + attrs.push(`placeholder="${escapeHtml(props.placeholder === undefined ? '' : props.placeholder)}"`) + attrs.push(`type="${escapeHtml(props.type === undefined ? 'text' : props.type)}"`) + return `` + } + return `<${type} ${attrs.filter(Boolean).join(' ')}>${children.map(toHtml).join('')}` +} + +// ── drive the real bundle ─────────────────────────────────────────────── +const localStorageStub = { + getItem: (key) => (String(key).endsWith(':tab') ? 'skills' : null), + setItem: () => {}, +} +let registered = null +globalThis.window = { + localStorage: localStorageStub, + addEventListener: () => {}, + removeEventListener: () => {}, + __ModuleLoader__: { + load(spec) { + const exportsObject = spec.factory(requireShim) + const captured = [] + exportsObject.apply({ + slots: { + inject: (_seat, fn) => fn(), + register: (_options, component) => { + captured.push(component) + return () => {} + }, + }, + }) + registered = captured[0] + }, + }, +} +function requireShim(id) { + if (id === 'react') return React + throw new Error(`unexpected require: ${id}`) +} + +const fakeFetch = async (url) => { + const path = String(url).split('?')[0] + let body = { ok: false } + if (path === '/dsh-brain/status') body = statusBody + else if (path === '/dsh-brain/skills/sources') body = { ok: true, ...overview } + else if (path === '/dsh-brain/sync/status') body = { ok: true, stats: { running: false, lastRunAt: Date.now(), uploaded: [], downloaded: [] }, conflicts: [] } + else if (path.startsWith('/dsh-brain/skills/api')) { + body = { ok: true, skills: overview.sources[0]?.groups.flatMap((group) => group.skills) ?? [], plans: [] } + } + return { status: body.ok === false ? 404 : 200, json: async () => body, text: async () => JSON.stringify(body) } +} + +function loadCard() { + registered = null + new Function('window', 'require', 'document', 'localStorage', 'fetch', 'console', 'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'AbortController', source)( + globalThis.window, + requireShim, + { visibilityState: 'visible' }, + localStorageStub, + fakeFetch, + { warn: () => {}, log: () => {} }, + () => 0, + () => {}, + () => 0, + () => {}, + AbortController, + ) + return registered +} + +async function settle(element, passes) { + let text = '' + for (let pass = 0; pass < passes; pass += 1) { + cursor = 0 + pendingEffects = [] + scheduled = false + text = toHtml(element) + const effects = pendingEffects + pendingEffects = [] + for (const effect of effects) { + const cleanup = effect() + if (typeof cleanup === 'function') cleanup() + } + await new Promise((resolve) => setTimeout(resolve, 0)) + if (!scheduled) break + } + return text +} + +function clickLabel(root, prefix) { + let clicked = false + walk(root, (node) => { + if (clicked) return + const props = node.props ?? {} + const label = props['aria-label'] + const text = typeof props.children === 'string' ? props.children : '' + const matches = (typeof label === 'string' && label.startsWith(prefix)) || text.startsWith(prefix) + if (matches && typeof props.onClick === 'function') { + props.onClick() + clicked = true + } + }) + return clicked +} + +function typeInto(root, label, value) { + let typed = false + walk(root, (node) => { + if (typed) return + const props = node.props ?? {} + if (props['aria-label'] === label && typeof props.onChange === 'function') { + props.onChange({ target: { value } }) + typed = true + } + }) + return typed +} + +const card = loadCard() +const treeEl = React.createElement(card, null) +const firstBody = await settle(treeEl, 6) +if (!firstBody.includes('技能文件夹')) console.log('debug body head:', firstBody.slice(0, 600)) + +cursor = 0 +pendingEffects = [] +if (!clickLabel(treeEl, '从其他软件导入')) throw new Error('preview: could not find the import button') +const body = await settle(treeEl, 6) +if (body.includes('渲染失败')) throw new Error('the card rendered its error boundary') + +// Second view: search filters the candidate list, then select-all-matched. +cursor = 0 +pendingEffects = [] +if (!typeInto(treeEl, '搜索要导入的技能', 'nature')) throw new Error('preview: could not find the import search box') +await settle(treeEl, 6) +cursor = 0 +pendingEffects = [] +if (!clickLabel(treeEl, '全选匹配可导入')) console.warn('preview: select-all was not clickable') +const searchBody = await settle(treeEl, 6) + +// Third view: dark theme, default (unfiltered) state. +cursor = 0 +pendingEffects = [] +typeInto(treeEl, '搜索要导入的技能', '') +clickLabel(treeEl, '清空已选') +const darkBody = await settle(treeEl, 6) + +const page = (content, theme) => ` +
${content}
` + +const outDir = join(here, '_preview') +mkdirSync(outDir, { recursive: true }) +const lightPath = join(outDir, 'import-light.html') +const searchPath = join(outDir, 'import-search.html') +const darkPath = join(outDir, 'import-dark.html') +writeFileSync(lightPath, page(body, 'light'), 'utf8') +writeFileSync(searchPath, page(searchBody, 'light'), 'utf8') +writeFileSync(darkPath, page(darkBody, 'dark'), 'utf8') + +const chrome = 'C:/Program Files/Google/Chrome/Application/chrome.exe' +for (const [input, output, height] of [ + [lightPath, join(outDir, 'import-light.png'), 2600], + [searchPath, join(outDir, 'import-search.png'), 1600], + [darkPath, join(outDir, 'import-dark.png'), 2600], +]) { + execFileSync(chrome, [ + '--headless=new', + '--disable-gpu', + '--hide-scrollbars', + '--force-device-scale-factor=2', + `--window-size=640,${height}`, + `--screenshot=${output}`, + `file:///${input.replace(/\\/g, '/')}`, + ], { stdio: 'ignore' }) + console.log(`wrote ${output}`) +} +console.log('sources:', overview.sources.map((item) => `${item.label}=${item.total}`).join(', ')) diff --git a/preview-mcp.mjs b/preview-mcp.mjs new file mode 100644 index 0000000..6ed5409 --- /dev/null +++ b/preview-mcp.mjs @@ -0,0 +1,344 @@ +// Renders the MCP management tab to a PNG so the search / select-all / batch +// layout can be reviewed before DSH is restarted. Data is a representative +// catalogue (no real host bridge is called); the render tree is the real one. +import { execFileSync } from 'node:child_process' +import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url' + +const here = dirname(fileURLToPath(import.meta.url)) +const source = readFileSync(join(here, 'client', 'index.js'), 'utf8') + +const statusBody = { + ok: true, + settings: { + enabled: true, + baseUrl: 'https://your-memory-host/api/longmemory', + baseUrlConfigured: true, + baseUrlOrigin: 'https://your-memory-host', + clientId: 'dsh-desktop', + requestTimeoutMs: 5000, + defaultK: 10, + summaryEnabled: true, + summaryMaxChars: 6000, + skillsSyncEnabled: true, + skillsDir: '', + }, + tokens: { + activity: { configured: true, masked: 'cmt_9f2c1a…7d4e' }, + memory: { configured: true, masked: 'cmt_3b81cc…22a9' }, + summary: { configured: true, masked: 'cmt_71ad02…9f10' }, + }, + settingsPath: '%USERPROFILE%/.dsh/dsh-brain.json', + reporter: { attempted: 12, recorded: 11, duplicate: 1, failed: 0, skipped: 0, queued: 0, recent: [] }, + lastCheck: { + at: Date.now(), + checks: [ + { id: 'network', label: '服务地址', state: 'ok', message: '服务可达(HTTP 200)' }, + { id: 'activity', label: '活动上报权限(activity:write)', state: 'ok', message: '鉴权通过' }, + { id: 'memory', label: '记忆读写权限(memory:write)', state: 'ok', message: '鉴权通过(3 个项目)' }, + { id: 'summary', label: '摘要权限(summary:write)', state: 'ok', message: '鉴权通过' }, + ], + }, + capabilities: { version: '0.9.7', features: { skills: true, skillsMarketplace: false, mcpBridge: 'host-plugin' }, notes: [] }, + skills: { running: false, downloaded: [], uploaded: [], updated: [], conflicts: [], skipped: 0 }, +} + +const connections = [ + { key: 'github', connectorId: 'c-github', name: 'github', transport: 'streamable-http', authMode: 'bearer', injectionLabel: '会话级', connectionState: 'connected', enabled: true, scope: { visibility: 'workspace' }, healthCheckedAt: Date.now() - 120000, lastError: null }, + { key: 'notion', connectorId: 'c-notion', name: 'notion', transport: 'streamable-http', authMode: 'oauth2', injectionLabel: '会话级', connectionState: 'connected', enabled: true, scope: { visibility: 'session' }, healthCheckedAt: Date.now() - 900000, lastError: null }, + { key: 'chrome-devtools', connectorId: 'c-chrome', name: 'chrome-devtools', transport: 'stdio', authMode: 'none', injectionLabel: '全局', connectionState: 'connected', enabled: true, scope: { visibility: 'global' }, healthCheckedAt: Date.now() - 60000, lastError: null }, + { key: 'filesystem', connectorId: 'c-fs', name: 'filesystem', transport: 'stdio', authMode: 'none', injectionLabel: '全局', connectionState: 'disabled', enabled: false, scope: { visibility: 'global' }, healthCheckedAt: Date.now() - 86400000, lastError: null }, + { key: 'postgres', connectorId: 'c-pg', name: 'postgres', transport: 'stdio', authMode: 'none', injectionLabel: '全局', connectionState: 'error', enabled: true, scope: { visibility: 'global' }, healthCheckedAt: Date.now() - 3600000, lastError: 'spawn postgres-mcp ENOENT' }, + { key: 'brave-search', connectorId: 'c-brave', name: 'brave-search', transport: 'streamable-http', authMode: 'api-key', injectionLabel: '会话级', connectionState: 'unknown', enabled: true, scope: { visibility: 'session' }, healthCheckedAt: null, lastError: null }, +] + +// ── minimal React + HTML serializer ───────────────────────────────────── +let hooks = [] +let cursor = 0 +let pendingEffects = [] +let scheduled = false + +const React = { + createElement(type, props, ...children) { + const flat = [] + const push = (value) => { + if (Array.isArray(value)) value.forEach(push) + else if (value !== null && value !== undefined && value !== false && value !== true) flat.push(value) + } + push(children) + return { type, props: { ...(props ?? {}), children: flat.length === 1 ? flat[0] : flat }, children: flat } + }, + useState(initial) { + const index = cursor++ + if (!(index in hooks)) hooks[index] = typeof initial === 'function' ? initial() : initial + const setter = (next) => { + const value = typeof next === 'function' ? next(hooks[index]) : next + if (value !== hooks[index]) { + hooks[index] = value + scheduled = true + } + } + return [hooks[index], setter] + }, + useEffect(fn) { + pendingEffects.push(fn) + }, + useCallback(fn) { + return fn + }, + Component: function Component(props) { + this.props = props + }, +} +React.Component.prototype.setState = function setState(patch) { + this.state = { ...this.state, ...patch } + scheduled = true +} + +function walk(node, visit) { + if (node === null || node === undefined || node === false || node === true) return + if (typeof node === 'string' || typeof node === 'number') return + if (Array.isArray(node)) { + node.forEach((child) => walk(child, visit)) + return + } + if (typeof node.type === 'function') { + if (node.type.prototype && typeof node.type.prototype.render === 'function') { + const instance = new node.type(node.props) + instance.props = node.props + if (instance.state === undefined) instance.state = {} + instance.setState = function setState(patch) { + instance.state = { ...instance.state, ...patch } + scheduled = true + } + walk(instance.render(), visit) + return + } + walk(node.type({ ...node.props, children: node.children }), visit) + return + } + visit(node) + node.children.forEach((child) => walk(child, visit)) +} + +const UNITLESS = new Set(['fontWeight', 'opacity', 'lineHeight', 'flex', 'zIndex', 'flexGrow', 'flexShrink']) + +function styleOf(style) { + const parts = [] + for (const [key, value] of Object.entries(style ?? {})) { + if (value === null || value === undefined) continue + const name = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`) + parts.push(`${name}:${typeof value === 'number' && !UNITLESS.has(key) ? `${value}px` : String(value)}`) + } + return parts.join(';') +} + +function escapeHtml(text) { + return String(text).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"') +} + +function toHtml(node) { + if (node === null || node === undefined || node === false || node === true) return '' + if (typeof node === 'string' || typeof node === 'number') return escapeHtml(node) + if (Array.isArray(node)) return node.map(toHtml).join('') + const { type, props, children } = node + if (typeof type === 'function') { + if (type.prototype && typeof type.prototype.render === 'function') { + const instance = new type(props) + instance.props = props + if (instance.state === undefined) instance.state = {} + return toHtml(instance.render()) + } + return toHtml(type({ ...props, children })) + } + const attrs = [] + const style = styleOf(props.style) + if (style !== '') attrs.push(`style="${style}"`) + if (props.id !== undefined) attrs.push(`id="${escapeHtml(props.id)}"`) + if (props.role !== undefined) attrs.push(`role="${escapeHtml(props.role)}"`) + if (props.title !== undefined) attrs.push(`title="${escapeHtml(props.title)}"`) + if (props.disabled === true) attrs.push('disabled') + if (props.type === 'checkbox') attrs.push(props.checked === true ? 'checked' : '') + for (const [key, value] of Object.entries(props)) { + if (key.startsWith('aria-')) attrs.push(`${key}="${escapeHtml(value)}"`) + } + if (type === 'input') { + attrs.push(`value="${escapeHtml(props.value === undefined ? '' : props.value)}"`) + attrs.push(`placeholder="${escapeHtml(props.placeholder === undefined ? '' : props.placeholder)}"`) + attrs.push(`type="${escapeHtml(props.type === undefined ? 'text' : props.type)}"`) + return `` + } + return `<${type} ${attrs.filter(Boolean).join(' ')}>${children.map(toHtml).join('')}` +} + +// ── drive the real bundle ─────────────────────────────────────────────── +const localStorageStub = { + getItem: (key) => (String(key).endsWith(':tab') ? 'mcp' : null), + setItem: () => {}, +} +let registered = null +globalThis.window = { + localStorage: localStorageStub, + addEventListener: () => {}, + removeEventListener: () => {}, + __ModuleLoader__: { + load(spec) { + const exportsObject = spec.factory(requireShim) + const captured = [] + exportsObject.apply({ + slots: { + inject: (_seat, fn) => fn(), + register: (_options, component) => { + captured.push(component) + return () => {} + }, + }, + }) + registered = captured[0] + }, + }, +} +function requireShim(id) { + if (id === 'react') return React + throw new Error(`unexpected require: ${id}`) +} + +const fakeFetch = async (url, init) => { + const path = String(url).split('?')[0] + let body = { ok: false } + if (path === '/dsh-brain/status') body = statusBody + else if (path === '/dsh-brain/sync/status') body = { ok: true, stats: { running: false, lastRunAt: Date.now(), uploaded: [], downloaded: [] }, conflicts: [] } + else if (path === '/mcp-connector/api') { + let method = 'status' + try { + method = JSON.parse(init?.body ?? '{}').method ?? 'status' + } catch { + method = 'status' + } + body = method === 'status' + ? { ok: true, message: '共 ' + connections.length + ' 条连接', detail: { items: connections, scope: {} } } + : { ok: true, message: '演示数据:' + method + ' 已受理' } + } + return { status: body.ok === false ? 404 : 200, json: async () => body, text: async () => JSON.stringify(body) } +} + +function loadCard() { + registered = null + new Function('window', 'require', 'document', 'localStorage', 'fetch', 'console', 'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'AbortController', source)( + globalThis.window, + requireShim, + { visibilityState: 'visible' }, + localStorageStub, + fakeFetch, + { warn: () => {}, log: () => {} }, + () => 0, + () => {}, + () => 0, + () => {}, + AbortController, + ) + return registered +} + +async function settle(element, passes) { + let text = '' + for (let pass = 0; pass < passes; pass += 1) { + cursor = 0 + pendingEffects = [] + scheduled = false + text = toHtml(element) + const effects = pendingEffects + pendingEffects = [] + for (const effect of effects) { + const cleanup = effect() + if (typeof cleanup === 'function') cleanup() + } + await new Promise((resolve) => setTimeout(resolve, 0)) + if (!scheduled) break + } + return text +} + +function clickLabel(root, prefix) { + let clicked = false + walk(root, (node) => { + if (clicked) return + const props = node.props ?? {} + const label = props['aria-label'] + const text = typeof props.children === 'string' ? props.children : '' + if (((typeof label === 'string' && label.startsWith(prefix)) || text.startsWith(prefix)) && typeof props.onClick === 'function') { + props.onClick() + clicked = true + } + }) + return clicked +} + +function typeInto(root, label, value) { + let typed = false + walk(root, (node) => { + if (typed) return + const props = node.props ?? {} + if (props['aria-label'] === label && typeof props.onChange === 'function') { + props.onChange({ target: { value } }) + typed = true + } + }) + return typed +} + +const card = loadCard() +const treeEl = React.createElement(card, null) +const firstBody = await settle(treeEl, 6) +if (!firstBody.includes('我的连接')) throw new Error('preview: MCP tab did not render') + +// View 2: filter to streamable-http connections and select them all. +cursor = 0 +pendingEffects = [] +typeInto(treeEl, '搜索 MCP 连接', 'search') +await settle(treeEl, 6) +cursor = 0 +pendingEffects = [] +clickLabel(treeEl, '全选匹配结果') +const chosenBody = await settle(treeEl, 6) + +const page = (content, theme) => ` +
${content}
` + +const outDir = join(here, '_preview') +mkdirSync(outDir, { recursive: true }) +const lightPath = join(outDir, 'mcp-light.html') +const chosenPath = join(outDir, 'mcp-selected.html') +const darkPath = join(outDir, 'mcp-dark.html') +writeFileSync(lightPath, page(firstBody, 'light'), 'utf8') +writeFileSync(chosenPath, page(chosenBody, 'light'), 'utf8') +writeFileSync(darkPath, page(chosenBody, 'dark'), 'utf8') + +const chrome = 'C:/Program Files/Google/Chrome/Application/chrome.exe' +for (const [input, output, height] of [ + [lightPath, join(outDir, 'mcp-light.png'), 2200], + [chosenPath, join(outDir, 'mcp-selected.png'), 2200], + [darkPath, join(outDir, 'mcp-dark.png'), 2200], +]) { + execFileSync(chrome, [ + '--headless=new', + '--disable-gpu', + '--hide-scrollbars', + '--force-device-scale-factor=2', + `--window-size=640,${height}`, + `--screenshot=${output}`, + `file:///${input.replace(/\\/g, '/')}`, + ], { stdio: 'ignore' }) + console.log(`wrote ${output}`) +} diff --git a/src/index.ts b/src/index.ts index 4e7d9cf..75a4856 100644 --- a/src/index.ts +++ b/src/index.ts @@ -30,7 +30,7 @@ export const name = 'dsh-brain' export const inject = ['webServer'] /** Version reported by the status card. */ -const VERSION = '0.9.6' +const VERSION = '0.9.7' /** How often the skill directory is reconciled with the cloud center. */ const SKILL_SYNC_INTERVAL_MS = 15 * 60_000 diff --git a/src/mnemon/index.ts b/src/mnemon/index.ts index 53d3711..8005621 100644 --- a/src/mnemon/index.ts +++ b/src/mnemon/index.ts @@ -23,7 +23,7 @@ import { LongMemoryProvider } from './driver.ts' export { LongMemoryProvider, descriptor } /** Keep in sync with the package version (asserted by the verify script). */ -const PROVIDER_VERSION = '0.9.6' +const PROVIDER_VERSION = '0.9.7' export const definition = defineMemorySpaceProviderDefinition({ manifest: { diff --git a/verify-card-render.mjs b/verify-card-render.mjs index b8976b3..e4c0532 100644 --- a/verify-card-render.mjs +++ b/verify-card-render.mjs @@ -481,6 +481,12 @@ check('foreign sources start collapsed behind the import button', const openedImport = await drive('skills', true, '从其他软件导入') check('clicking the import button reveals foreign sources as import candidates', openedImport.includes('Codex') && openedImport.includes('收起') && !openedImport.includes('仅本卡')) +check('the import panel has search, select-all and batch import', + openedImport.includes('全选匹配可导入') && + openedImport.includes('全选全部') && + openedImport.includes('清空已选') && + openedImport.includes('导入所选') && + openedImport.includes('全选本来源')) const openedAssign = await drive('skills', true, '把技能加入 QQ-Skill') check('clicking + on a category opens the inline skill assignment picker with search', @@ -512,11 +518,11 @@ check('the MCP list has search, filters and select-all', mcpText.includes('全选全部') && mcpText.includes('清空已选') && mcpText.includes('筛选:全部') && - mcpText.includes('批量健康检查')) + mcpText.includes('勾选左侧连接后')) -const mcpChosen = await drive('mcp', true, '全选匹配结果(1)') -check('selecting all matched connections reveals the batch removal confirm', - mcpChosen.includes('批量移除…') && mcpChosen.includes('批量停用')) +const mcpChosen = await drive('mcp', true, '全选匹配结果') +check('selecting all matched connections reveals the batch actions', + mcpChosen.includes('批量操作(已选 1)') && mcpChosen.includes('移除…')) check('the removed MCP marketplace panel no longer renders', !mcpText.includes('MCP 市场') && !mcpText.includes('读取 MCP 市场失败')) const missing = await drive('mcp', false) diff --git a/verify-full-load.mjs b/verify-full-load.mjs index 929f0e9..bfde25b 100644 --- a/verify-full-load.mjs +++ b/verify-full-load.mjs @@ -57,7 +57,7 @@ async function post(path, body) { } const caps = await get('/dsh-brain/capabilities') -check('capabilities answers with 0.9.6', caps.body?.version === '0.9.6', String(caps.body?.version)) +check('capabilities answers with 0.9.7', caps.body?.version === '0.9.7', String(caps.body?.version)) check('P3 market is advertised with one provider', caps.body?.features?.skillsMarketplace === true && caps.body?.features?.marketProviders === 1) check('P3 update and sync-resolve are advertised', caps.body?.features?.skillUpdate === true && caps.body?.features?.syncResolve === true) check('P4/P5/v1.1 flags are advertised', caps.body?.features?.multiClient === true && caps.body?.features?.brainMigration === 'ready') diff --git a/verify-upgrade.mjs b/verify-upgrade.mjs index b131eac..c5d18f6 100644 --- a/verify-upgrade.mjs +++ b/verify-upgrade.mjs @@ -74,7 +74,7 @@ for (const name of readdirSync(libDir)) { } check('no personal domain remains in shipped lib/', leaked.length === 0, leaked.join(',')) const pkg = JSON.parse(readFileSync(join(process.cwd(), 'package.json'), 'utf8')) -check('package version is the delivery version', pkg.version === '0.9.6', pkg.version) +check('package version is the delivery version', pkg.version === '0.9.7', pkg.version) const passed = results.filter((r) => r.ok).length console.log(`\n${passed}/${results.length} passed`)