diff --git a/client/index.js b/client/index.js index 2211f34..49215b3 100644 --- a/client/index.js +++ b/client/index.js @@ -1255,12 +1255,12 @@ window.__ModuleLoader__.load({ } // ---- import skills from other tools ------------------------------- - function ImportSection() { - var tuple = React.useState({ status: 'loading', sources: [], open: {}, busy: '', notice: null, imported: {} }) + 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 s = tuple[0] var set = tuple[1] function patch(next) { set(function (prev) { return Object.assign({}, prev, next) }) } - React.useEffect(function () { load() }, []) function load() { patch({ status: 'loading', notice: null }) request(API.skills + '/sources', { method: 'GET' }).then(function (res) { @@ -1269,6 +1269,13 @@ window.__ModuleLoader__.load({ } else patch({ status: 'error', notice: { tone: 'bad', text: bodyError(res, '读取来源失败') } }) }, function (error) { patch({ status: 'error', notice: { tone: 'bad', text: messageOf(error) } }) }) } + function openPanel() { + patch({ expanded: true }) + if (s.status === 'idle' || s.status === 'error') load() + } + function closePanel() { + patch({ expanded: false }) + } function dshFolders() { var found = {} s.sources.forEach(function (source) { @@ -1293,9 +1300,22 @@ window.__ModuleLoader__.load({ 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) } }) }) } + if (!s.expanded) { + return h( + 'div', + { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '8px', flexWrap: 'wrap' } }, + h(Btn, { + label: '从其他软件导入', + ariaLabel: '从其他软件导入', + onClick: openPanel, + }), + 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) { @@ -1332,7 +1352,18 @@ window.__ModuleLoader__.load({ })), ) }) - return h(Section, { title: '从其他软件导入', hint: '把其他软件技能目录里的技能复制一份到 DSH,原目录不动;同名技能不能重复导入。', aside: h(Btn, { label: '刷新', variant: 'small', onClick: load }) }, + return h( + Section, + { + title: '从其他软件导入', + hint: '把其他软件技能目录里的技能复制一份到 DSH,原目录不动;同名技能不能重复导入。', + aside: h( + 'div', + { style: styles.actions }, + h(Btn, { label: '刷新', variant: 'small', onClick: load }), + h(Btn, { label: '收起', variant: 'small', onClick: closePanel }), + ), + }, 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), @@ -1725,7 +1756,13 @@ window.__ModuleLoader__.load({ } function openAssign(source, group) { + var renameKey = String(source.id) + ':' + group.id + if (tree.assign !== null && tree.assign.sourceId === source.id && tree.assign.groupId === group.id) { + patchTree({ assign: null }) + return + } patchTree({ + openGroups: Object.assign({}, tree.openGroups, { [renameKey]: true }), assign: { sourceId: source.id, groupId: group.id, @@ -2603,6 +2640,7 @@ window.__ModuleLoader__.load({ var renameKey = String(source.id) + ':' + group.id var renaming = tree.edit !== null && tree.edit.kind === 'rename' && tree.edit.key === renameKey var confirming = tree.confirm === renameKey + var assigning = tree.assign !== null && tree.assign.sourceId === source.id && tree.assign.groupId === group.id var groupSkills = group.visible === undefined ? group.skills || [] : group.visible return h( 'div', @@ -2682,12 +2720,15 @@ window.__ModuleLoader__.load({ }), ), ), + assigning ? h('div', { style: styles.nested }, assignBox) : null, open ? h( 'div', { style: styles.nested }, groupSkills.length === 0 - ? h('p', { style: styles.hint }, group.id === 'unassigned' ? '没有未分类的技能。' : '这个分类还没有技能,点「+」加入。') + ? assigning + ? null + : h('p', { style: styles.hint }, group.id === 'unassigned' ? '没有未分类的技能。' : '这个分类还没有技能,点「+」加入。') : groupSkills.map(function (skill) { return renderSkillRow(source, skill) }), @@ -2704,7 +2745,12 @@ window.__ModuleLoader__.load({ 'div', { style: styles.root, key: 'skills' }, - h(ImportSection, {}), + h(ImportSection, { + onImported: function () { + loadTree() + loadSkills() + }, + }), h( Section, diff --git a/lib/index.js b/lib/index.js index 5797ce5..86321ab 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.0'; +const VERSION = '0.9.2'; /** 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 cf43a76..b88a85b 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.0'; +const PROVIDER_VERSION = '0.9.2'; export const definition = defineMemorySpaceProviderDefinition({ manifest: { apiVersion: MEMORY_SPACE_PROVIDER_API_VERSION, diff --git a/package.json b/package.json index 0e42657..8b8683d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dsh-brain", - "version": "0.9.1", + "version": "0.9.2", "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/src/index.ts b/src/index.ts index f158ba3..5f75c5f 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.0' +const VERSION = '0.9.2' /** 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 3a15725..ca9c7ce 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.0' +const PROVIDER_VERSION = '0.9.2' export const definition = defineMemorySpaceProviderDefinition({ manifest: { diff --git a/verify-card-render.mjs b/verify-card-render.mjs index 9d8f0cd..18c5f2e 100644 --- a/verify-card-render.mjs +++ b/verify-card-render.mjs @@ -475,8 +475,16 @@ check('the tree is DSH-only: no source card, no foreign sources', !skillsText.includes('C:/Users/test/.dsh/skills') && !skillsText.includes('由 Codex 自行加载')) check('categories render with their counts', skillsText.includes('QQ-Skill') && skillsText.includes('1 项 · 1/1 启用') && skillsText.includes('未分类')) check('the metadata-only promise is on screen', skillsText.includes('分类只记在这个来源里,不移动文件')) -check('foreign sources appear only as import candidates', - skillsText.includes('Codex') && !skillsText.includes('仅本卡')) +check('foreign sources start collapsed behind the import button', + !skillsText.includes('Codex') && !skillsText.includes('仅本卡')) + +const openedImport = await drive('skills', true, '从其他软件导入') +check('clicking the import button reveals foreign sources as import candidates', + openedImport.includes('Codex') && openedImport.includes('收起') && !openedImport.includes('仅本卡')) + +const openedAssign = await drive('skills', true, '把技能加入 QQ-Skill') +check('clicking + on a category opens the inline skill assignment picker', + openedAssign.includes('加入分类:QQ-Skill') && openedAssign.includes('保存分类') && openedAssign.includes('parked-one')) // Categories start collapsed; expanding one must reveal its skills. const expandedSkills = await drive('skills', true, '展开或收起 未分类') diff --git a/verify-full-load.mjs b/verify-full-load.mjs index 12be42e..860680a 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.8.0', caps.body?.version === '0.9.0', String(caps.body?.version)) +check('capabilities answers with 0.9.2', caps.body?.version === '0.9.2', 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 2d1ebbb..907f102 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.0', pkg.version) +check('package version is the delivery version', pkg.version === '0.9.2', pkg.version) const passed = results.filter((r) => r.ok).length console.log(`\n${passed}/${results.length} passed`)