feat: optimize prompt
This commit is contained in:
@@ -280,6 +280,8 @@ Select only the fields that the UI actually needs. Do not copy or render an enti
|
||||
|
||||
To place interactive UI in the latest `cordis_run` card, register `tool.view.cordis` with `key: 'self'`:
|
||||
|
||||
When the feature needs user interaction tied to this Package's result, this region is often a good fit because it keeps the controls in the conversation flow beside the Run card. It is not the default target for every Client UI: settings, sidebars, message actions, and overlays should use their own queried Slots when those locations better match the feature.
|
||||
|
||||
```js
|
||||
return {
|
||||
apply(ctx) {
|
||||
|
||||
@@ -172,9 +172,22 @@ function readExact(input: JsonValue | undefined, field: string): string | undefi
|
||||
type LiveSlotNode = ReturnType<SlotRegistry['snapshot']>[number]
|
||||
|
||||
const SLOT_CATALOG = new Map(CLIENT_SLOT_API.map(entry => [entry.key, entry]))
|
||||
const GUARDED_SLOT_KEYS = new Map<string, {
|
||||
description: string
|
||||
values: readonly { value: string; description: string }[]
|
||||
}>([
|
||||
['tool.view.cordis', {
|
||||
description: 'fixed by the dynamic Client Guard',
|
||||
values: [{
|
||||
value: 'self',
|
||||
description: 'The only accepted key. The Guard binds it to this Package\'s pluginId and packageId.',
|
||||
}],
|
||||
}],
|
||||
])
|
||||
|
||||
function compactSlotTree(node: LiveSlotNode): JsonValue {
|
||||
const catalog = SLOT_CATALOG.get(node.name)
|
||||
const guardedKeys = catalog === undefined ? undefined : GUARDED_SLOT_KEYS.get(catalog.key)
|
||||
return {
|
||||
name: node.name,
|
||||
kind: node.kind,
|
||||
@@ -189,7 +202,10 @@ function compactSlotTree(node: LiveSlotNode): JsonValue {
|
||||
required: option.requirement === 'required',
|
||||
})),
|
||||
},
|
||||
...catalog.keyDomain === '' ? {} : { keyDomain: catalog.keyDomain },
|
||||
...catalog.keyDomain === '' ? {} : {
|
||||
keyDomain: guardedKeys?.description ?? catalog.keyDomain,
|
||||
...guardedKeys === undefined ? {} : { allowedKeys: guardedKeys.values.map(value => ({ ...value })) },
|
||||
},
|
||||
},
|
||||
children: node.children.map(compactSlotTree),
|
||||
}
|
||||
@@ -208,6 +224,7 @@ function inspectLiveSlot(node: LiveSlotNode): JsonValue {
|
||||
}
|
||||
|
||||
function inspectSlotCatalog(entry: ClientSlotEntry): JsonValue {
|
||||
const guardedKeys = GUARDED_SLOT_KEYS.get(entry.key)
|
||||
return {
|
||||
description: entry.doc,
|
||||
registration: entry.registerOptions.map(option => ({
|
||||
@@ -219,7 +236,8 @@ function inspectSlotCatalog(entry: ClientSlotEntry): JsonValue {
|
||||
ownerProps: [...entry.ownerProps],
|
||||
ownerPropsReferences: [...entry.ownerPropsReferences],
|
||||
standardProps: [...entry.standardProps],
|
||||
keyDomain: entry.keyDomain,
|
||||
keyDomain: guardedKeys?.description ?? entry.keyDomain,
|
||||
...guardedKeys === undefined ? {} : { allowedKeys: guardedKeys.values.map(value => ({ ...value })) },
|
||||
hookContext: entry.hookContext,
|
||||
slotInject: entry.slotInject,
|
||||
replaceRisk: entry.replaceRisk,
|
||||
|
||||
@@ -1680,8 +1680,8 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
key: 'tool.view.cordis',
|
||||
kind: 'keyed',
|
||||
scope: 'session',
|
||||
summary: 'Package-owned interactive UI hosted by the latest successful Run card.',
|
||||
doc: 'Package-owned interactive UI hosted by the latest successful Run card.',
|
||||
summary: 'Interactive Package-owned region rendered inside the latest eligible `cordis_run` card in the conversation flow.',
|
||||
doc: 'Interactive Package-owned region rendered inside the latest eligible\n`cordis_run` card in the conversation flow. Use it for controls and other\nUI the user can interact with. Dynamic Client code registers with\n`key: \'self\'`; the Guard binds that key to the current Plugin and Package.',
|
||||
registerOptions: [
|
||||
{
|
||||
name: 'key',
|
||||
@@ -1714,7 +1714,7 @@ export const CLIENT_SLOT_API: readonly ClientSlotEntry[] = [
|
||||
occupants: [],
|
||||
replaceRisk: 'none',
|
||||
example: 'return {\n inject: [\'slots\'],\n apply(ctx) {\n ctx.slots.inject(\'tool.view.cordis\', () => ctx.slots.register(\n { name: \'tool.view.cordis\', key: \'<one key the owner dispatches>\' },\n () => React.createElement(\'div\', null, \'hello\'),\n ))\n },\n}',
|
||||
source: 'packages/extensions/ui-cordis/src/client/slots.ts:26',
|
||||
source: 'packages/extensions/ui-cordis/src/client/slots.ts:31',
|
||||
},
|
||||
]
|
||||
/* jscpd:ignore-end */
|
||||
@@ -9,8 +9,11 @@ Dynamic Cordis plugins temporarily extend the current DSH process. A Plugin uses
|
||||
|
||||
## Make the user-facing plan clear first
|
||||
|
||||
- First decide whether the task creates a new Plugin or modifies the Plugin named by the user with @pluginId. Proceed directly when the goal is clear; do not ask for repeated confirmation.
|
||||
- If a visual, copy, or interaction choice would materially affect the result, ask at most one concise creative-preference question and offer a few candidate directions. Do not conduct a multi-round interview or a complex questionnaire.
|
||||
- Dynamic Cordis Plugins are one available implementation mechanism, not the default for every request. Consider whether one could help only when the user intends to design or create something, or when a temporary interface could materially aid the current work. The presence of these instructions or Tools, and discussion of Cordis itself, do not make a request a dynamic-Plugin task.
|
||||
- When Cordis is a plausible fit, infer the intended work target and lifetime from the request and conversation. Use it only when the outcome belongs to the current running harness and should be delivered as a temporary runtime extension. If that distinction is materially ambiguous, ask at most one concise question about the intended result or lifetime. Otherwise proceed with the matching workflow; do not require the user to know or choose Cordis as an implementation mechanism.
|
||||
- Once a dynamic Plugin is appropriate, decide whether the task creates a new Plugin or modifies the Plugin named by the user with @pluginId. Proceed directly when the goal is clear; do not ask for repeated confirmation.
|
||||
- Choose Host, Client, or both from the requested outcome. Do not propose a Client/browser UI when the task does not need visible page behavior, and do not avoid Client when the requested outcome is visual, interactive, or depends on page state. Host versus Client is an implementation choice; do not make the user choose it.
|
||||
- When a design direction or a potentially useful interface would materially affect the result, ask at most one concise outcome or creative-preference question and offer a few candidate directions. Otherwise proceed directly; do not conduct a multi-round interview or a complex questionnaire.
|
||||
- cordis_define only defines and presents code; it does not run it. After definition, explain the pluginId and packageId returned by the Host and whether the next step is a run or update.
|
||||
- cordis_run may require user approval. When it returns awaiting-approval, explain that the user must allow or reject it in the UI. Do not wait, retry, or claim that it is running.
|
||||
- When it returns starting, explain that the request has entered the asynchronous flow and the Client is still activating. starting does not mean success. Wait for the system to report the final result through steering context.
|
||||
|
||||
@@ -22,7 +22,12 @@ export interface CordisToolViewOwnerProps {
|
||||
|
||||
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
||||
interface SlotMap {
|
||||
/** Package-owned interactive UI hosted by the latest successful Run card. */
|
||||
/**
|
||||
* Interactive Package-owned region rendered inside the latest eligible
|
||||
* `cordis_run` card in the conversation flow. Use it for controls and other
|
||||
* UI the user can interact with. Dynamic Client code registers with
|
||||
* `key: 'self'`; the Guard binds that key to the current Plugin and Package.
|
||||
*/
|
||||
'tool.view.cordis': {
|
||||
kind: 'keyed'
|
||||
scope: 'session'
|
||||
|
||||
Reference in New Issue
Block a user