* feat(preset): declare Agent compositions in profile YAML * fix(preset): share scope binding cleanup and refresh module graph * fix(preset): use host syntax colors in the YAML editor * fix(preset): write new profile declarations as block YAML * fix(preset): align eager activation with browser and worker surfaces * fix(ui-agent-preset): retain the existing preset card layout * fix(preset): keep rows waiting for a Host service mounted and re-audit after settlement A preset row whose Host provider was still activating at declaration time was reported as waiting for a missing service, and the registry recorded the definition as broken for the rest of the process. Split the mount audit into failed and pending rows: failures and root-realm leaks still reject the mount, while pending rows stay mounted and every read and binding re-audits them after the Host Loader tree settles. Remove the accidental self-dependency of @deepseek-ai/dsh-web-app and its lockfile self-link. Archive the copy-only preset authoring note, which the declarative-preset note fully supersedes, and update the ralph note's restore recipe to the profile-patch mechanism. * chore(lint): re-key and prune the unknown-cast baseline after the master merge * refactor(web-app): ship each Agent preset as its own bundle patch file `dsh.bundle.patch` accepts an ordered file list, so the four shipped preset declarations move out of the 1000-line web patch into `presets/<id>.patch.yml`, one insert per file, applied after the host patch. The host patch keeps the preset registry row. Gates and test scaffolds that read the web layer resolve every patch file through `bundlePatchPaths` instead of one hardcoded path. * refactor(preset): drop the save notice injected into live Agents The notice duplicated the save result the Web editor already shows, and after the producer-owned message sources it would have needed its own persisted source kind. Saving now only persists and reports the activation diagnostic; the persistence catalog is unchanged from master. * docs: regenerate the module graph after dropping the registry's llm dependency * test(ui-agent-preset): cover the guide dialog's keyboard handling on the declarative section * fix(preset): address the remaining review comments Apply the lowercase id rule only when creating a declaration, so presets declared with other ids stay editable. Export `isBuiltInPreset` from the display fold and key the client card groups on it. Remove the dead `error` and `retry` locale keys, the JSDoc orphaned by the `trust` removal, the `trust` fields in the plugin-inventory test fixtures, and the stale `dsh-agent-presets` package name in comments and READMEs. * refactor(preset): make the Web preset page view-and-select only Remove the child-plugin YAML editor, the `agent_preset` tool and the registry's read/save Remote methods. Presets are declared and changed only by bundle patches; the settings page keeps the roster, the new-task default and the mode help, and its question icon explains that and offers to start a Creator-mode task. The `editing-cordis-compositions` skill and the Creator persona describe the bundle-based path, and the authored skill-load Session and Web snapshots are refreshed for it. * docs(skill): make the composition skill self-sufficient for preset authoring State where the shipped declarations live, list every declaration field, inline a complete minimal bundle and an override example, and name the verification calls, so Creator mode no longer reads DSH package sources to infer the format. Refresh the authored skill-load Session for the new text. * test(tools): drop the removed agent_preset tool from the catalog expectation
121 lines
5.4 KiB
TypeScript
121 lines
5.4 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
|
|
import type { ClientModuleLoader } from '@deepseek-ai/dsh-client-modules/client'
|
|
import { Context, Service } from '@deepseek-ai/cordis'
|
|
import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest'
|
|
import { cleanup } from '@testing-library/react'
|
|
import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
|
|
import { SlotRegistry } from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
import { resolveSlotLabel } from '@deepseek-ai/dsh-client-ui-slots'
|
|
import { usePinnedBrowserLanguages } from '@deepseek-ai/dsh-client-test-runtime'
|
|
import { apply, inject, NS } from '../src/client/index.ts'
|
|
import { PluginInventorySettingsTab } from '../src/client/PluginInventorySettingsTab.tsx'
|
|
import type { PluginInventorySettingsTabInjected } from '../src/client/PluginInventorySettingsTab.tsx'
|
|
import { apply as hostApply } from '../src/index.ts'
|
|
|
|
usePinnedBrowserLanguages('zh-CN')
|
|
afterEach(cleanup)
|
|
|
|
const EMPTY = { entries: [] }
|
|
type ListResult =
|
|
| { readonly ok: true; readonly value: typeof EMPTY }
|
|
| { readonly ok: false; readonly error: { readonly code: string; readonly message: string } }
|
|
|
|
async function bench() {
|
|
const ctx = new Context()
|
|
onTestFinished(async () => { await ctx.fiber.dispose() })
|
|
const retryClient = vi.fn(async () => {})
|
|
ctx.provide('modules', { entries: { state: createSnapshotStore({ syncing: false, failures: [] }), retry: retryClient } } as unknown as ClientModuleLoader)
|
|
await ctx.plugin(SlotRegistry).await()
|
|
const locale = new LocaleRuntime(ctx)
|
|
ctx.provide('locale', locale)
|
|
class RemoteService extends Service {
|
|
constructor(serviceCtx: Context) {
|
|
super(serviceCtx, 'remote')
|
|
}
|
|
}
|
|
new RemoteService(ctx)
|
|
const list = vi.fn<() => Promise<ListResult>>()
|
|
.mockResolvedValue({ ok: true, value: EMPTY })
|
|
ctx.provide('remote.pluginInventory', { list })
|
|
return { ctx, retryClient, slots: ctx.get('slots') as SlotRegistry, locale, list }
|
|
}
|
|
|
|
function declare(slots: SlotRegistry): () => void {
|
|
return slots.register({
|
|
name: 'root',
|
|
children: { 'settings.plugins.tab': { kind: 'list', scope: 'root' } },
|
|
} as never, () => null)
|
|
}
|
|
|
|
describe('ui-settings-plugin-inventory browser plugin', () => {
|
|
it('keeps the host Loader entry inert', () => {
|
|
expect(hostApply).not.toThrow()
|
|
})
|
|
|
|
it('declares only the services used by the Settings Remote contribution', () => {
|
|
expect(inject).toEqual(['slots', 'locale', 'remote', 'remote.pluginInventory', 'modules'])
|
|
})
|
|
|
|
it('registers a localized tab without reading the Remote eagerly', async () => {
|
|
const b = await bench()
|
|
declare(b.slots)
|
|
await b.ctx.plugin({ inject: [...inject], apply }).await()
|
|
|
|
const entry = b.slots.entries('settings.plugins.tab')[0]!
|
|
expect(entry.component).toBe(PluginInventorySettingsTab)
|
|
expect(entry.options).toMatchObject({ id: 'all', order: 10 })
|
|
expect(entry.locale).toBe(NS)
|
|
expect(resolveSlotLabel(entry.options.label)).toBe('插件列表')
|
|
expect(b.list).not.toHaveBeenCalled()
|
|
|
|
const injected = (entry.inject as unknown as () => PluginInventorySettingsTabInjected)()
|
|
const text = { en: 'Local tools', zh: '本地工具' }
|
|
expect(injected.resolveText(text)).toBe('本地工具')
|
|
b.locale.setLocale('en')
|
|
expect(injected.resolveText(text)).toBe('Local tools')
|
|
b.locale.setLocale('zh')
|
|
injected.retryClient()
|
|
const retryError = vi.spyOn(b.ctx.logger, 'error').mockImplementation(() => {})
|
|
b.retryClient.mockRejectedValueOnce(new Error('retry unavailable'))
|
|
injected.retryClient()
|
|
await vi.waitFor(() => { expect(retryError).toHaveBeenCalled() })
|
|
retryError.mockRestore()
|
|
await expect(injected.list()).resolves.toEqual(EMPTY)
|
|
expect(b.list).toHaveBeenCalledOnce()
|
|
b.list.mockResolvedValueOnce({ ok: false, error: { code: 'REMOTE_ERROR', message: 'unavailable' } })
|
|
await expect(injected.list()).rejects.toThrow('pluginInventory.list failed: REMOTE_ERROR: unavailable')
|
|
|
|
// Shipped preset names resolve over the agent-preset dictionaries the
|
|
// real plugin registers; user-authored metadata stays untranslated.
|
|
b.locale.register('settings.agentPreset', 'zh', { presetStandardName: '标准模式' } as never)
|
|
expect(injected.presetName({ id: 'standard', isDefault: true, rows: [] })).toBe('标准模式')
|
|
expect(injected.presetName({ id: 'mine', name: '我自己的', isDefault: false, rows: [] })).toBe('我自己的')
|
|
await b.ctx.fiber.dispose()
|
|
})
|
|
|
|
it('follows locale and recovers across late declaration and declarer reload', async () => {
|
|
const b = await bench()
|
|
const fiber = b.ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
expect(b.slots.entries('settings.plugins.tab')).toHaveLength(0)
|
|
|
|
const stop = declare(b.slots)
|
|
await vi.waitFor(() => { expect(b.slots.entries('settings.plugins.tab')).toHaveLength(1) })
|
|
b.locale.setLocale('en')
|
|
expect(resolveSlotLabel(b.slots.entries('settings.plugins.tab')[0]!.options.label)).toBe('Plugin list')
|
|
|
|
stop()
|
|
expect(b.slots.entries('settings.plugins.tab')).toHaveLength(0)
|
|
declare(b.slots)
|
|
await vi.waitFor(() => {
|
|
expect(b.slots.entries('settings.plugins.tab')[0]?.component).toBe(PluginInventorySettingsTab)
|
|
})
|
|
|
|
await fiber.dispose()
|
|
expect(b.slots.entries('settings.plugins.tab')).toHaveLength(0)
|
|
expect(() => b.locale.register(NS, 'zh', {})).not.toThrow()
|
|
await b.ctx.fiber.dispose()
|
|
})
|
|
})
|