refactor(ui)!: rename settings-ui bundle to dsh-brain-ui with export alias
This commit is contained in:
parent
bdea045635
commit
d68840202e
|
|
@ -39,7 +39,7 @@
|
|||
| `dsh-brain-memory` | 五个 `memory_*` 工具注册。 |
|
||||
| `dsh-brain-skills` | 技能管理页、`skill_list` 工具、技能市场、来源树。 |
|
||||
| `dsh-brain-mcp` | MCP 管理页开关(页签与宿主桥接能力声明;MCP 连接本身由宿主 `dsh-mcp-connector` 管理,本插件不做 MCP 云同步)。 |
|
||||
| `dsh-brain-settings-ui` | 配置页与状态/能力/配置路由。 |
|
||||
| `dsh-brain-ui` | 左侧栏 Brain 总面板与 better-sidebar 项目记忆页签;配置页与状态/能力/配置路由。 |
|
||||
|
||||
- 停掉 `dsh-brain-cloudsync` 后活动上报与技能同步停止,但记忆读写工具
|
||||
仍可用(它们实时访问云端)。停掉 `dsh-brain-memory` 才会移除记忆工具。
|
||||
|
|
@ -47,6 +47,7 @@
|
|||
重复实例;设置持久化在 `$DSH_HOME/dsh-brain.json`(侧车文件为权威,
|
||||
插件行的 config 只作首次种子)。
|
||||
- 根导出 `.` 仍是兼容组合器:老的单行 profile 升级后行为不变。
|
||||
- 0.11.0 起第五个子插件行 id 从 `dsh-brain-settings-ui` 改为 `dsh-brain-ui`(package exports 保留 `./settings-ui` 别名指向同一入口)。若 profile 里还留有旧 id 的禁用/配置行,请到「设置 → 插件」对 `dsh-brain-ui` 重新设置;插件不会自动改写宿主配置文件。
|
||||
|
||||
## 安装
|
||||
|
||||
|
|
|
|||
|
|
@ -32,5 +32,5 @@
|
|||
name: dsh-brain/skills
|
||||
- id: dsh-brain-mcp
|
||||
name: dsh-brain/mcp
|
||||
- id: dsh-brain-settings-ui
|
||||
name: dsh-brain/settings-ui
|
||||
- id: dsh-brain-ui
|
||||
name: dsh-brain/ui
|
||||
|
|
|
|||
|
|
@ -1,27 +1,7 @@
|
|||
import { brainKernel, VERSION } from "../kernel.js";
|
||||
import { createCoreRoutes, legacyAliases } from "../routes.js";
|
||||
import { createSettingsUiRoutes } from "../settings-ui/routes.js";
|
||||
export const name = 'dsh-brain-settings-ui';
|
||||
/** Services required before `apply` runs. */
|
||||
export const inject = ['webServer'];
|
||||
/** Register the sub-plugin with the host. */
|
||||
export function apply(ctx, config) {
|
||||
const logger = ctx.logger('dsh-brain');
|
||||
const kernel = brainKernel(config, logger);
|
||||
kernel.activate('settings-ui');
|
||||
kernel.logEvent('boot.entry', { bundle: 'settings-ui' });
|
||||
ctx.effect(() => () => kernel.deactivate('settings-ui'), 'dsh-brain-settings-ui: activation');
|
||||
const webServer = ctx.webServer;
|
||||
if (webServer === undefined) {
|
||||
logger.warn('webServer service unavailable; the configuration page stays disabled');
|
||||
return;
|
||||
}
|
||||
const routes = [
|
||||
...createSettingsUiRoutes({ version: VERSION, store: kernel.store }),
|
||||
...createCoreRoutes(kernel.routeDeps()),
|
||||
];
|
||||
routes.push(...legacyAliases(routes));
|
||||
for (const route of routes) {
|
||||
ctx.effect(() => webServer.register(route), `dsh-brain-settings-ui: route ${route.path}`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Backward-compatible entry alias: the bundle was renamed from
|
||||
* dsh-brain-settings-ui to dsh-brain-ui. The package exports map points the
|
||||
* old './settings-ui' subpath at lib/entries/ui.js; this physical module is a
|
||||
* second safety net for profiles that resolve the old file path directly.
|
||||
*/
|
||||
export * from "./ui.js";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
import { brainKernel, VERSION } from "../kernel.js";
|
||||
import { createCoreRoutes, legacyAliases } from "../routes.js";
|
||||
import { createSettingsUiRoutes } from "../settings-ui/routes.js";
|
||||
export const name = 'dsh-brain-ui';
|
||||
/** Services required before `apply` runs. */
|
||||
export const inject = ['webServer'];
|
||||
/** The pre-rename row id; only used to point a stale profile at the new row. */
|
||||
const LEGACY_BUNDLE_ID = 'dsh-brain-settings-ui';
|
||||
function profileMentionsLegacyId(ctx) {
|
||||
try {
|
||||
const face = ctx;
|
||||
return [face.config, face.settings].some((value) => value !== undefined && JSON.stringify(value).includes(LEGACY_BUNDLE_ID));
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/** Register the sub-plugin with the host. */
|
||||
export function apply(ctx, config) {
|
||||
const logger = ctx.logger('dsh-brain');
|
||||
const kernel = brainKernel(config, logger);
|
||||
kernel.activate('ui');
|
||||
kernel.logEvent('boot.entry', { bundle: 'ui' });
|
||||
ctx.effect(() => () => kernel.deactivate('ui'), 'dsh-brain-ui: activation');
|
||||
// We never rewrite host files: if the old row is visible in the live config
|
||||
// face, tell the user which row to re-toggle after the rename.
|
||||
if (profileMentionsLegacyId(ctx)) {
|
||||
logger.info('detected the old plugin id ' + LEGACY_BUNDLE_ID + '; re-apply the plugin toggle under dsh-brain-ui in Settings → Plugins');
|
||||
}
|
||||
const webServer = ctx.webServer;
|
||||
if (webServer === undefined) {
|
||||
logger.warn('webServer service unavailable; the configuration page stays disabled');
|
||||
return;
|
||||
}
|
||||
const routes = [
|
||||
...createSettingsUiRoutes({ version: VERSION, store: kernel.store }),
|
||||
...createCoreRoutes(kernel.routeDeps()),
|
||||
];
|
||||
routes.push(...legacyAliases(routes));
|
||||
for (const route of routes) {
|
||||
ctx.effect(() => webServer.register(route), `dsh-brain-ui: route ${route.path}`);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import * as cloudsync from "./entries/cloudsync.js";
|
|||
import * as memory from "./entries/memory.js";
|
||||
import * as skills from "./entries/skills.js";
|
||||
import * as mcp from "./entries/mcp.js";
|
||||
import * as settingsUi from "./entries/settings-ui.js";
|
||||
import * as ui from "./entries/ui.js";
|
||||
/** Package name; also the client bundle id. */
|
||||
export const name = 'dsh-brain';
|
||||
/** Services required before `apply` runs. */
|
||||
|
|
@ -13,5 +13,5 @@ export function apply(ctx, config) {
|
|||
memory.apply(ctx, config);
|
||||
skills.apply(ctx, config);
|
||||
mcp.apply(ctx, config);
|
||||
settingsUi.apply(ctx, config);
|
||||
ui.apply(ctx, config);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Shared kernel for the dsh-brain sub-plugins.
|
||||
*
|
||||
* The five bundle entries (dsh-brain/cloudsync, dsh-brain/memory,
|
||||
* dsh-brain/skills, dsh-brain/mcp, dsh-brain/settings-ui) and the compat
|
||||
* dsh-brain/skills, dsh-brain/mcp, dsh-brain/ui) and the compat
|
||||
* root entry all load from the same package inside the same host process,
|
||||
* so this module's export resolves to a single instance: whichever entry
|
||||
* applies first builds the services, the rest reuse them.
|
||||
|
|
@ -316,7 +316,7 @@ export class BrainKernel {
|
|||
memory: this.isActive('memory'),
|
||||
skills: this.isActive('skills'),
|
||||
mcp: this.isActive('mcp'),
|
||||
'settings-ui': this.isActive('settings-ui'),
|
||||
ui: this.isActive('ui'),
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
"./memory": "./lib/entries/memory.js",
|
||||
"./skills": "./lib/entries/skills.js",
|
||||
"./mcp": "./lib/entries/mcp.js",
|
||||
"./settings-ui": "./lib/entries/settings-ui.js",
|
||||
"./ui": "./lib/entries/ui.js",
|
||||
"./settings-ui": "./lib/entries/ui.js",
|
||||
"./cordis.patch.yml": "./cordis.patch.yml",
|
||||
"./package.json": "./package.json",
|
||||
"./mnemon-provider": "./lib/mnemon/index.js",
|
||||
|
|
|
|||
|
|
@ -1,40 +1,7 @@
|
|||
/**
|
||||
* Settings-UI sub-plugin entry — the configuration page and core routes.
|
||||
*
|
||||
* Owns the standalone HTML page, the status / capabilities / config /
|
||||
* migrate routes, and their legacy /cloud-memory aliases. The capability
|
||||
* report is assembled from the kernel's active-bundle view, so the page
|
||||
* reflects which sibling sub-plugins are currently enabled.
|
||||
* Backward-compatible entry alias: the bundle was renamed from
|
||||
* dsh-brain-settings-ui to dsh-brain-ui. The package exports map points the
|
||||
* old './settings-ui' subpath at lib/entries/ui.js; this physical module is a
|
||||
* second safety net for profiles that resolve the old file path directly.
|
||||
*/
|
||||
import type { CloudMemoryContext } from '../context-types.ts'
|
||||
import { brainKernel, VERSION } from '../kernel.ts'
|
||||
import { createCoreRoutes, legacyAliases } from '../routes.ts'
|
||||
import { createSettingsUiRoutes } from '../settings-ui/routes.ts'
|
||||
|
||||
export const name = 'dsh-brain-settings-ui'
|
||||
|
||||
/** Services required before `apply` runs. */
|
||||
export const inject = ['webServer']
|
||||
|
||||
/** Register the sub-plugin with the host. */
|
||||
export function apply(ctx: CloudMemoryContext, config: unknown): void {
|
||||
const logger = ctx.logger('dsh-brain')
|
||||
const kernel = brainKernel(config, logger)
|
||||
kernel.activate('settings-ui')
|
||||
kernel.logEvent('boot.entry', { bundle: 'settings-ui' })
|
||||
ctx.effect(() => () => kernel.deactivate('settings-ui'), 'dsh-brain-settings-ui: activation')
|
||||
|
||||
const webServer = ctx.webServer
|
||||
if (webServer === undefined) {
|
||||
logger.warn('webServer service unavailable; the configuration page stays disabled')
|
||||
return
|
||||
}
|
||||
const routes = [
|
||||
...createSettingsUiRoutes({ version: VERSION, store: kernel.store }),
|
||||
...createCoreRoutes(kernel.routeDeps()),
|
||||
]
|
||||
routes.push(...legacyAliases(routes))
|
||||
for (const route of routes) {
|
||||
ctx.effect(() => webServer.register(route), `dsh-brain-settings-ui: route ${route.path}`)
|
||||
}
|
||||
}
|
||||
export * from './ui.ts'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,59 @@
|
|||
/**
|
||||
* UI sub-plugin entry — the configuration page, core routes and the panel host.
|
||||
*
|
||||
* Owns the standalone HTML page, the status / capabilities / config /
|
||||
* migrate routes, and their legacy /cloud-memory aliases. The capability
|
||||
* report is assembled from the kernel's active-bundle view, so the page
|
||||
* reflects which sibling sub-plugins are currently enabled. The client half
|
||||
* of this bundle adds the left-rail Brain panel and the better-sidebar tab.
|
||||
*/
|
||||
import type { CloudMemoryContext } from '../context-types.ts'
|
||||
import { brainKernel, VERSION } from '../kernel.ts'
|
||||
import { createCoreRoutes, legacyAliases } from '../routes.ts'
|
||||
import { createSettingsUiRoutes } from '../settings-ui/routes.ts'
|
||||
|
||||
export const name = 'dsh-brain-ui'
|
||||
|
||||
/** Services required before `apply` runs. */
|
||||
export const inject = ['webServer']
|
||||
|
||||
/** The pre-rename row id; only used to point a stale profile at the new row. */
|
||||
const LEGACY_BUNDLE_ID = 'dsh-brain-settings-ui'
|
||||
|
||||
function profileMentionsLegacyId(ctx: CloudMemoryContext): boolean {
|
||||
try {
|
||||
const face = (ctx as unknown as { config?: unknown; settings?: unknown })
|
||||
return [face.config, face.settings].some((value) => value !== undefined && JSON.stringify(value).includes(LEGACY_BUNDLE_ID))
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** Register the sub-plugin with the host. */
|
||||
export function apply(ctx: CloudMemoryContext, config: unknown): void {
|
||||
const logger = ctx.logger('dsh-brain')
|
||||
const kernel = brainKernel(config, logger)
|
||||
kernel.activate('ui')
|
||||
kernel.logEvent('boot.entry', { bundle: 'ui' })
|
||||
ctx.effect(() => () => kernel.deactivate('ui'), 'dsh-brain-ui: activation')
|
||||
|
||||
// We never rewrite host files: if the old row is visible in the live config
|
||||
// face, tell the user which row to re-toggle after the rename.
|
||||
if (profileMentionsLegacyId(ctx)) {
|
||||
logger.info('detected the old plugin id ' + LEGACY_BUNDLE_ID + '; re-apply the plugin toggle under dsh-brain-ui in Settings → Plugins')
|
||||
}
|
||||
|
||||
const webServer = ctx.webServer
|
||||
if (webServer === undefined) {
|
||||
logger.warn('webServer service unavailable; the configuration page stays disabled')
|
||||
return
|
||||
}
|
||||
const routes = [
|
||||
...createSettingsUiRoutes({ version: VERSION, store: kernel.store }),
|
||||
...createCoreRoutes(kernel.routeDeps()),
|
||||
]
|
||||
routes.push(...legacyAliases(routes))
|
||||
for (const route of routes) {
|
||||
ctx.effect(() => webServer.register(route), `dsh-brain-ui: route ${route.path}`)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
* Plugin entry — compat root.
|
||||
*
|
||||
* The package now ships five toggleable sub-plugin rows (see
|
||||
* cordis.patch.yml): cloud-sync, memory, skills, mcp, and settings-ui.
|
||||
* cordis.patch.yml): cloud-sync, memory, skills, mcp, and ui.
|
||||
* This root entry remains for older single-row profiles: it applies all
|
||||
* five entries against the same context, so the route and tool tables it
|
||||
* registers are identical to the pre-split build, including the legacy
|
||||
|
|
@ -16,7 +16,7 @@ import * as cloudsync from './entries/cloudsync.ts'
|
|||
import * as memory from './entries/memory.ts'
|
||||
import * as skills from './entries/skills.ts'
|
||||
import * as mcp from './entries/mcp.ts'
|
||||
import * as settingsUi from './entries/settings-ui.ts'
|
||||
import * as ui from './entries/ui.ts'
|
||||
|
||||
/** Package name; also the client bundle id. */
|
||||
export const name = 'dsh-brain'
|
||||
|
|
@ -30,5 +30,5 @@ export function apply(ctx: CloudMemoryContext, config: unknown): void {
|
|||
memory.apply(ctx, config)
|
||||
skills.apply(ctx, config)
|
||||
mcp.apply(ctx, config)
|
||||
settingsUi.apply(ctx, config)
|
||||
ui.apply(ctx, config)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* Shared kernel for the dsh-brain sub-plugins.
|
||||
*
|
||||
* The five bundle entries (dsh-brain/cloudsync, dsh-brain/memory,
|
||||
* dsh-brain/skills, dsh-brain/mcp, dsh-brain/settings-ui) and the compat
|
||||
* dsh-brain/skills, dsh-brain/mcp, dsh-brain/ui) and the compat
|
||||
* root entry all load from the same package inside the same host process,
|
||||
* so this module's export resolves to a single instance: whichever entry
|
||||
* applies first builds the services, the rest reuse them.
|
||||
|
|
@ -47,7 +47,7 @@ export interface KernelLogger {
|
|||
}
|
||||
|
||||
/** The bundles a sub-plugin entry can activate. */
|
||||
export type BrainBundle = 'cloudsync' | 'memory' | 'skills' | 'mcp' | 'settings-ui'
|
||||
export type BrainBundle = 'cloudsync' | 'memory' | 'skills' | 'mcp' | 'ui'
|
||||
|
||||
/** The shared service set behind every dsh-brain sub-plugin entry. */
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ export class BrainKernel {
|
|||
memory: this.isActive('memory'),
|
||||
skills: this.isActive('skills'),
|
||||
mcp: this.isActive('mcp'),
|
||||
'settings-ui': this.isActive('settings-ui'),
|
||||
ui: this.isActive('ui'),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,8 @@ const cloudsyncEntry = await import('./lib/entries/cloudsync.js')
|
|||
const memoryEntry = await import('./lib/entries/memory.js')
|
||||
const skillsEntry = await import('./lib/entries/skills.js')
|
||||
const mcpEntry = await import('./lib/entries/mcp.js')
|
||||
const settingsUiEntry = await import('./lib/entries/settings-ui.js')
|
||||
const uiEntry = await import('./lib/entries/ui.js')
|
||||
const legacySettingsUiEntry = await import('./lib/entries/settings-ui.js')
|
||||
const { buildStatusPayload } = await import('./lib/routes.js')
|
||||
const root = await import('./lib/index.js')
|
||||
|
||||
|
|
@ -77,9 +78,9 @@ const SEED = { baseUrl: 'https://your-memory-host/api/longmemory', clientId: 'sm
|
|||
resetBrainKernel()
|
||||
|
||||
let ui = fakeCtx()
|
||||
settingsUiEntry.apply(ui.ctx, SEED)
|
||||
uiEntry.apply(ui.ctx, SEED)
|
||||
const uiPaths = ui.routes.map((route) => `${route.kind}:${route.path}`)
|
||||
check('settings-ui entry applies and registers the page + core routes', [
|
||||
check('ui entry applies and registers the page + core routes', [
|
||||
'exact:/dsh-brain',
|
||||
'exact:/dsh-brain/status',
|
||||
'exact:/dsh-brain/capabilities',
|
||||
|
|
@ -91,7 +92,8 @@ check('settings-ui entry applies and registers the page + core routes', [
|
|||
'exact:/cloud-memory/config',
|
||||
'prefix:/cloud-memory/migrate',
|
||||
].every((item) => uiPaths.includes(item)), uiPaths.join(' | '))
|
||||
check('settings-ui entry registers no tools', ui.tools.length === 0, `${ui.tools.length} tools`)
|
||||
check('ui entry registers no tools', ui.tools.length === 0, `${ui.tools.length} tools`)
|
||||
check('legacy ./settings-ui subpath still resolves to the ui entry', typeof legacySettingsUiEntry.apply === 'function' && legacySettingsUiEntry.name === 'dsh-brain-ui', String(legacySettingsUiEntry.name))
|
||||
|
||||
const mcpCtx = fakeCtx()
|
||||
mcpEntry.apply(mcpCtx.ctx, SEED)
|
||||
|
|
|
|||
Loading…
Reference in New Issue