feat(agent-presets): give a preset a name and a description

A picker showed directory names, so the settings page could only ever list
`standard` / `core-web` / `cordis` and hope the reader knew what they meant.
A preset may now publish display text in an optional `preset.yml` beside
its composition, and the section renders cards — name, description, and the
one in use — instead of rows.

The file carries display text ONLY. `id` is the directory name and `trust`
comes from the root a preset was discovered under, so neither is writable
there: otherwise a locally authored preset could name itself into the
shipped set. It is a separate file because a composition is a top-level list
of plugin rows — YAML cannot carry sibling keys beside it, and a fake
metadata row would hand the Loader something to load.

Every read failure degrades to no metadata; absent, malformed, wrongly
typed, and blank all mean the same thing and the picker falls back to the
id. Presentation is not capability: a preset whose name is broken still
mounts.

The editor gained name and description fields above the YAML, and clearing
both removes the file rather than storing a blank name.
This commit is contained in:
Yichen Jiang
2026-08-05 16:30:14 +08:00
parent 5b93f48f78
commit 7281615d44
27 changed files with 593 additions and 68 deletions

View File

@@ -139,7 +139,7 @@ export interface PresetRoot {
export type PresetTrust = 'system' | 'user'
```
Source: [`packages/preset/agent-presets/src/types.ts:29`](../packages/preset/agent-presets/src/types.ts)
Source: [`packages/preset/agent-presets/src/types.ts:33`](../packages/preset/agent-presets/src/types.ts)
## `@deepseek-ai/dsh-agent-spine-demo`

View File

@@ -96,10 +96,11 @@ async read(id: string): Promise<string>
* names a missing plugin still fails at the next session that selects it.
* @param id - the profile id, which becomes its directory name.
* @param content - the composition text.
* @param metadata - display name and description; clearing both removes the file.
* @throws when the id is unusable, the text is not an entry list, or the
* deployment configures no writable root.
*/
async write(id: string, content: string): Promise<void>
async write(id: string, content: string, metadata: PresetMetadata = {}): Promise<void>
/**
* Delete a locally authored profile.
@@ -145,7 +146,7 @@ serviceFor<K extends string & keyof Context>(agent: { ctx: Context }, name: K):
async recompose(agentCtx: Context, id: string): Promise<AgentPreset>
```
Source: [`packages/preset/agent-presets/src/index.ts:63`](../../packages/preset/agent-presets/src/index.ts)
Source: [`packages/preset/agent-presets/src/index.ts:67`](../../packages/preset/agent-presets/src/index.ts)
## `ctx.agents` — `AgentRegistry`