• feat(self-modification): add dynamic Cordis plugin runtime and UI

This commit is contained in:
imccyu
2026-08-12 23:51:31 +08:00
parent 0367506471
commit 4064198560
147 changed files with 20904 additions and 2412 deletions
@@ -6,7 +6,20 @@ import type {} from '@deepseek-ai/dsh-client-locale/client'
declare module '@deepseek-ai/dsh-client-ui-slots' {
interface SlotMap {
/** Keyed atomic Tool call view, dispatched by the wire Tool name. */
/**
* Keyed atomic Tool call view, dispatched by the wire Tool name. Register
* with `key: '<tool name>'` to own how one tool's calls render inside a
* turn — the key domain is open (any wire tool name, including a tool your
* own package registered), so there is no compile-time key set to pick
* from and a typo simply never renders.
*
* A key the shipped composition already covers is replaced, not shared;
* an unclaimed key falls back to the generic tool row, so registering is
* additive for your own tool and a takeover for a shipped one. The owner
* passes the call's identity, its frozen running-or-settled node, and the
* expansion state (see ToolCallOwnerProps), so the view stays a pure
* function of what the turn already knows.
*/
'tool.call.toolview': { kind: 'keyed'; scope: 'session'; owner: ToolCallOwnerProps }
}
}
@@ -25,7 +25,15 @@ export const VARIANT_TITLES: Record<ToolRowVariant, string> = {
write: 'Write', edit: 'Edit', code: 'Code', others: 'Tool call',
}
/** Known tool name -> variant. */
/**
* Known tool name -> variant.
*
* `cordis_define` is deliberately absent: ui-cordis registers a keyed
* `tool.call.toolview` entry for it, and a keyed hit REPLACES the generic row
* (this table is only reached through GenericToolCard, the dispatch fallback in
* ToolCallTree). An entry here would be unreachable, and a second title for the
* same call would be a second answer to a question the card already owns.
*/
const TOOL_VARIANTS: Record<string, ToolRowVariant> = {
bash: 'bash',
// The PowerShell twin is a shell tool: the bash row family (icon, colors)
@@ -39,16 +47,24 @@ const TOOL_VARIANTS: Record<string, ToolRowVariant> = {
write: 'write',
edit: 'edit',
run_code: 'code',
cordis_inspect: 'read',
cordis_mount: 'code',
cordis_unmount: 'others',
cordis_package_inspect: 'read',
cordis_runtime_inspect: 'read',
// The three run-control verbs take one package id and produce a receipt, so
// the generic row is the decided intent, not an unclassified default: there is
// no program to show (that is `cordis_define`'s card) and no file to open. The
// id lands in the summary slot, and the titles below name the act.
cordis_run: 'others',
cordis_stop: 'others',
cordis_undefine: 'others',
}
/** Tool-owned titles that refine a generic row variant without replacing it. */
const TOOL_TITLES: Record<string, string> = {
cordis_inspect: 'Inspect',
cordis_mount: 'Mount temporary Plugin',
cordis_unmount: 'Unmount temporary Plugin',
cordis_package_inspect: 'Inspect',
cordis_runtime_inspect: 'Inspect',
cordis_run: 'Run dynamic package',
cordis_stop: 'Stop dynamic package',
cordis_undefine: 'Discard dynamic package',
pwsh: 'Pwsh',
}